useSteps
Pure-function stepping math for OrigamSliderField. Computes reactive min / max / step / decimals values from the component props and exposes a roundValue helper that snaps any raw number to the nearest valid step (clamped to [min, max]). After the migration to a native <input type="range">, this is the only remaining logic layer for the slider — the browser now owns drag tracking.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
useSteps is intentionally a pure-function layer with no side effects. It does not manage drag state — drag is handled natively by the <input type="range"> element in OrigamSliderField. The older useSlider JS drag pipeline was removed during the native-input migration.
Interfaces consommées
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- propsrequisISliderFieldProps
- Component props. Reads min (default 0), max (default 100), and step (default 0 = no stepping). All three accept string or number — they are parsed with parseFloat internally.
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- min
- Parsed minimum value. Defaults to 0 when props.min is undefined or null.
- max
- Parsed maximum value. Defaults to 100 when props.max is undefined or null.
- step
- Parsed step value. 0 means no stepping (any value between min and max is valid). Positive values define the snap grid.
- decimals
- Number of decimal places to preserve in roundValue output. Derived from max(getDecimals(step), getDecimals(min)) to match the precision implied by the step grid.
- roundValue
- Snap a raw value to the nearest valid step, clamped to [min, max]. Handles the min-offset edge case so that a step=5 min=3 grid snaps to 3, 8, 13, … rather than 0, 5, 10, ….
Usage
Exemples
Extraits de code prêts à coller.
Snap a user-typed value to the step grid