Helpers

Helpers are the decisions and formatting behind the components: date math, masks, number parsing, 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.

PageWhat it doesReach for it when
DatesMonth grids, ISO days, selection state, locale formatting and parsing.Any calendar, scheduler or date grid.
Date segmentsThe model of a segmented date input.A date field with separate parts.
MasksPattern masks and locale date masks.Formatted text input.
NumbersLocale-aware format and parse, step snapping.Number fields and steppers.
Numeric rangeClamp to a stepped range, ratio to value, slider keys.Sliders, knobs and meters.
Text filterCase- and accent-insensitive contains.Filtering a list as the user types.
Cycle valueThe next value in a list, wrapping.A cycle toggle.
Unique idA CSS-safe, document-unique id.aria-controls and aria-labelledby targets.
OrderingWhere a dragged item lands, and key-driven moves, from rectangles.Your own drag logic, or applying a sortable onChange.
DecisionsSwipe direction from a delta, focus-trap wrap target, wrapped index, floating position.Custom gestures, focus loops and option lists.