YUI 3.0 PR2 Now Available: Widget and Plugin Infrastructure, Sample Widgets, and More

We're pleased today to announce the second preview release of the new YUI 3.x codeline. This release adds significantly to PR1, providing an all-new widget foundation, two sample widgets, a new plugin architecture, a new ultralight plugin for menu-style navigation, and enhancements throughout the library. We've ported YUI Test and Profiler from 2.6.0, moving two steps closer to parity with the YUI 2.x core and utility platform. YUI 3.0 PR2 is available for download immediately from YUILibrary.com; you can discuss the release with the YUI community in the YUI3 forum on Yahoo Groups.

A key part of our focus in YUI 3.x is to provide more granularity so that you can fine-tune your implementation to include only the features that you're actually using for a given component (watch the 3.x overview video for more on the larger goals for this codeline). Each 3.x component ships with a small functional core, and advanced features are added in the form of plugins or optional submodules. The submodule pattern was illustrated in PR1. In PR2, we're adding in the Widget infrastructure, designed to promote maximal modularity and code reuse, along with two reference widgets. We're also debuting the Plugin infrastructure. Plugins can be written to supplement a simple Node or to add features to a widget in a lightweight, a la carte fashion.

Here are the highlights of PR2:

Widget Infrastructure: The biggest addition in PR2 is the debut of the Widget infrastructure. PR2 delivers the base Widget class for YUI 3.x, which will be the foundation class for all formal YUI widgets. (In 2.x, we called these components "controls" in order to avoid confusion with Yahoo/Konfabulator widgets, but in 3.x we are standardizing on "widgets.") The Widget class extends Base, which was part of PR1. If you're interested in exploring the Widget infrastructure, we recommend reviewing Node,Event, Base, Widget, and Overlay (in that order) to get a sense how these pieces fit together.

Slider, Overlay, Console Widgets:Slider, Overlay and Console (what was LogReader in 2.x) are provided as the initial set of widget implementations for YUI 3.x, along with examples leveraging the Widget infrastructure. Overlay will be of particular interest to those of you who want to study the inner workings of the modular Widget system. It is constructed by combining the core Widget module with WidgetPosition (basic xy positioning), WidgetPositionExt (extended positioning: align, center), WidgetStdMod (standard module support) and WidgetStack (zIndex, shim support) extensions, which can be mixed and matched as required to provide other custom implementations. These initial widgets are meant to establish and confirm the concepts we're promoting in 3.x with respect to granular, reusable code. The widgets are likely to change as we move toward the GA for 3.x, but they should give you a good sense of how the library's new core is performing.

Plugin Infrastructure: Plugins provide atomic pieces of functionality that can be mixed and matched with other plugins to modify or add functionality on an existing widget (or Node). For example overlay.plug({fn:StdModIOPlugin, cfg:pluginCfg}) instantiates the StdModIOPlugin class and adds it to the host widget as the io property (the namespace defined by the plugin), adding input/output capabilities. In addition to adding completely new functionality, plugins may also modify existing functionality on the host by listening for events or by injecting code before or after the execution of methods on the host. For example, an Animation plugin might provide configurable animation effects that modify the base widget's native hide and show methods.

Node Plugins: The MenuNav Node Plugin provides a lightweight but feature-rich navigation menu as a simple one-line plugin to Node, with content/functionality driven entirely through markup/CSS. MenuNav, and Node plugins in general, are ideal choices for light implementations that don't need programmatic (API/event) access to the control once instantiated. MenuNav is the first such Node plugin implementation for YUI 3.x, and it replicates the most commonly used functionality from the YUI 2.x Menu Control in under 5KB (gzipped) JavaScript and CSS.

Event Updates: Event simulation (the ability to programatically fire events) has been moved into the Event utility in 3.0PR2; event simulation was previously part of YUI Test. The subscribe/publish methods have been expanded to support subscribing to or publishing mutliple events in a single call. Supplementary global events (available, contentready, focus, blur) and keyboard event support has been added.

IO Updates: The IO utility adds form-mining and file upload support, available as optional sub-modules. Existing queue and cross-domain request (XDR) support have been broken out into optional submodules to increase the granularity of the component. Now, users not interested in the advanced features (queuing, XDR, form-mining, file upload), can use the lighter io-base module.

Developer Tool Updates: The YUI Test framework, Profiler, and the Console widget are now available in the PR2 release. YUI Test adds support for mock objects. Mock objects allow you to isolate your tests from dependent code by defining objects that behave in predictable ways. Create mocks of XMLHttpRequest, document, or any other object on which your code depends without depending on the actual implementation.

Again, we're eager for your feedback and hope you enjoy checking out this second Preview Release.