Helpers
Helpers are the decisions and formatting behind the components: date math, masks, ordering. They are plain functions with no DOM.
import { cycleValue } from '@ecopages/radiant-ui/helpers';
cycleValue(['light', 'dark', 'system'], 'system'); // 'light'Nothing in the entry touches the DOM at import time or when called, so helpers run on the server and in tests. Anything that reads or sets DOM state is a controller utility instead. The entry is tree-shakeable. Exports whose result is not obvious carry a TSDoc example, and each page below shows the results of real calls, computed when the docs are built.
Use a helper, not a controller, for anything that only maps input to output.
| Page | What it does | Reach for it when |
|---|---|---|
| Dates | Month grids, ISO days, selection state, locale formatting and parsing. | Any calendar, scheduler or date grid. |
| Date segments | The model of a segmented date input. | A date field with separate parts. |
| Masks | Pattern masks and locale date masks. | Formatted text input. |
| Numeric range | Clamp to a stepped range, ratio to value, slider keys. | Sliders, knobs and meters. |
| Text filter | Case- and accent-insensitive contains and starts-with; type-to-find. | Filtering a list as the user types; typeahead in a custom collection. |
| Input hints | Keyboard, Enter key and autofill attributes that agree for a kind of value. | A sign-in, OTP, search or address field. |
| Cycle value | The next value in a list, wrapping. | A cycle toggle. |
| Unique id | A CSS-safe, document-unique id. | aria-controls and aria-labelledby targets. |
| Ordering | Where a dragged item lands, and key-driven moves, from rectangles. | Your own drag logic, or applying a sortable onChange. |
| Decisions | Swipe direction from a delta and a release velocity, focus-trap wrap target, wrapped index, floating position. | Custom gestures, focus loops and option lists. |
| Media time | Time labels, seek clamping and the buffered end of a media element. | A player's time display and seek bar. |
| Momentum | The speed of a pointer just before release, the coast distance of a flick, the rubber band past an edge. | A flick, a momentum scroll or a pull past the end. |
| Virtual range | The offsets, visible range and scroll-to position of a virtualized list. | A virtualizer of your own. |
| Selection | Toggle by selection mode, a range from an anchor and a select-all checkbox state, each honouring a selectable filter. | A collection with its own selection input. |
| Tree collection | A flat node list as a tree: levels, positions, visible rows, and checked state with the leaf, trunk, branch and independent strategies. | A tree or treegrid view rendering from data, or tree checkboxes. |
| Color scheme | The <head> script that applies a saved scheme before first paint, the resolved scheme for a preference and the color-scheme value to write. | A theme switch and its boot script. |