Skip to main content

SpSlider

Function SpSlider 

Source
pub fn SpSlider(_: SpSliderProps) -> Element
Expand description

A draggable slider for a numeric value with live min/max bounds, its own built-in label, and an optional inline editable number field.

Maps to <sp-slider>. label renders as part of the slider’s own markup (its internal sp-field-label, linked to the handle or, when editable is set, to the paired sp-number-field) — a caller using this component does not also render a separate SpFieldLabel alongside it. min/max are passed as strings, recomputed by the caller on every render from the cell’s current filter bounds (see adam-web-ui/src/labels.rs’s CellMeta::range), so a range driven by other cells stays live. step, when present, sets the amount the drag handle/stepper/arrow keys move the value by — pass "1" for an integer-typed cell, mirroring SpNumberfield’s own step, or "0.01" for a floating-point cell displayed to two decimal places. Omitting step leaves Spectrum’s default of one, which also snaps the inline number field to whole numbers. Setting editable to true renders an internal sp-number-field alongside the track (SWC’s own Slider.render), letting the user type an exact value instead of only dragging; both the drag handle and the editable field dispatch the same DOM input event on this element (SWC’s SliderHandle.dispatchInputEvent), so a single oninput handler here covers both — reading the live numeric value off the DOM (not the synthetic event) is the caller’s job, mirroring SpTextfield/SpNumberfield. sp-slider has no invalid/readonly state; a caller that needs to surface either (e.g. a failing require on a range-filtered out cell) has to render that separately, alongside this component. onfocus/onblur fire for both the drag handle and (when editable is set) the inline number field — neither SWC handle re-dispatches a bubbling event, but DOM focus/blur are composed, so a listener on this host element still observes them across the intervening shadow boundaries, mirroring SpTextfield/SpNumberfield. format_options supplies JSON-encoded Intl.NumberFormat options for both the value label and the inline number field without changing the stored value. Empty inline edits remain uncommitted rather than restoring the slider’s last numeric value. A mounted slider captures unmanaged inline edits after Spectrum parses them, stores the raw localized text (including blanks) in adamNumericDraft, and redispatches a host input event. The Inspector’s numeric input bridge consumes and deletes that draft once; handle drags instead read the canonical host value. Empty inline change events are suppressed to preserve blanks.

§Props

For details, see the props struct definition.