Mixins / foldkit-mixins-ui
SliderSlots
const · packages/mixins-ui/src/slider.ts:48
const SliderSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-labelledby">], readonly Slot.RequirementName[], boolean>; readonly header: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly label: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly description: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly output: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly control: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readon …;A slider: one number, or a { low, high } range of two, chosen on one
track. The value is the application's: the view draws value and sends
onChange with the next one, of the same kind.
Both kinds are one view over native input type="range" thumbs, so the
browser owns the drag, the keys (arrows, PageUp and PageDown, Home, End),
right to left and the form value, and the view keeps no state. One number
is a thumb across the whole control, named by the label, and a press
anywhere on the track moves it. A range is the APG's multi-thumb slider: a
root group named by the label, holding two thumbs that each name
themselves.
@foldkit/ui's Slider is not adapted any more. It draws one thumb and keeps
its drag in a Submodel, so a range could not be built on it; adapting it
for one number and drawing the range here meant two components and two
recipes for one control. An application already hosting that Submodel
draws it with Slots of its own.
The thumbs of a range cannot cross, and the browser keeps that: the low
thumb's max is the high value and the high thumb's min the low one, as
the APG has it, and each input spans only the part of the track it may
travel (from --fk-slider-low and --fk-slider-high on control, 0 to 1),
so a thumb sits where it would on the whole track. A drag past the other
thumb stops at it with no redraw needed, which a clamp in update alone
could not do: an unchanged Model draws nothing, and the input would keep its
own value.
marks, ticks and the shown value (showValue) are drawn beside the
thumbs, hidden from assistive technology: each thumb already says its value
through aria-valuetext. Each is placed by its share of the track,
--fk-slider-at. A shown value is drawn twice, by each thumb (value) and
at the end of the header (output), so the recipe's value axis picks a
place with no change to the view.
Vertical (orientation: 'vertical') is the same native inputs in a
vertical writing mode, read bottom to top: the browser turns their keys and
drag, and every logical inset the recipe places with turns with them.