vUXDocs v4.1.0

Form Components

A runnable demo of vUX-formComponents.js, exercising all six builders: select, radio, checkbox, datePicker, slideSwitch and file. See the Form Components guide for the full API.

Live example

Runs the module from this site, with every control on the page. Open it in its own tab for the full layout.

Open the live example

The page

SectionShows
Heroa select, a switch and a radio group: built by the same autoBuild() calls as the rest of the page
01 All six buildersevery widget, in four panels
02 Two attribute conventionsfull attribute name vs dataset name, and rebuilding content added later
03 Native change logone delegated listener proving the native input holds the state
04 Bad inputthe eight ways the builders reject config, including an incomplete autoBuild()

The controls

WidgetNative inputShows
Fruit select<select><optgroup>, a disabled option, the search box, keyboard navigation, refreshSelect() after adding an option
Toppings select<select multiple>toggle-to-select, comma label, full list as a tooltip (selectFieldToolTip)
Plan radios<input type="radio"> ×3a horizontal group (axisClass), label clicks, single-selection forwarding
Checkboxes<input type="checkbox"> ×2a content-supplied check glyph, clickable labels
Date of birth<input type="date">min/max, a preset value, decade → year → month → day drill-down, weekday tooltips (daysToolTip)
Meeting<input type="datetime-local">the same flow plus hour/minute entry and the AM/PM switch
Switches<input type="checkbox">data-dim/data-labels attributes, on/off styling, refresh() on an injected switch
Attachment<input type="file">label + browse button, file-name tooltip, button icon

What it demonstrates

  • The native input stays the source of truth. The "native change log" at the bottom uses one delegated change listener: every entry is fired by a hidden native input, so each line proves a widget wrote its state through.

  • The date picker writes attributes, not events: the two value: … | complete: … state lines are driven by a MutationObserver watching the native input's value and data-complete (the configured validationAttribute) attributes.

  • Leap years, open the date-of-birth picker and pick February 2024: it has 29 days.

  • Dynamic content: "Add option + refreshSelect()" mutates the native select and rebuilds one widget; "Inject a new switch + refresh()" inserts brand-new checkbox markup and converts it.

  • The two attribute conventions: the select and date picker take full attribute names (sizeAttribute: "data-size"), while the slide switch and file input take dataset names without the prefix (dataAttributeNames: { size: "dim" }).

  • The slide-switch markup rule: each switch checkbox is the last element child of its own wrapper DIV, with the text label outside it.

  • Glyphs supplied entirely through config content (the checkbox check mark, the calendar and folder icons, the search icon): no icon font needed.

  • Bad input fails immediately: section 04 performs each bad call and prints what was thrown.

All six builders are exposed on window.demoForm for the console, e.g. demoForm.select.refresh().

Styling

The page uses the shared example design system at ../shared/example.css. The widgets themselves are styled through builder config instead, because the component generates their stylesheets: main.js keeps the page's palette in one T object and interpolates it into the config strings, so the widget colours and the page stylesheet cannot drift apart. That is the pattern to copy: the component ships structure, the consuming page supplies the look.