Slider.Bounds
interface · packages/mixins-ui/src/slider.ts:87
interface Bounds {
readonly min?: number | undefined
readonly max?: number | undefined
readonly step?: number | undefined
}Mixins / foldkit-mixins-ui
namespace · packages/mixins-ui/src/slider.ts:1
export * as Slider from './slider.js'Slider.Boundsinterface · packages/mixins-ui/src/slider.ts:87
interface Bounds {
readonly min?: number | undefined
readonly max?: number | undefined
readonly step?: number | undefined
}Slider.configurefunction · packages/mixins-ui/src/slider.ts:485
function configure<const Names extends string = never>(
config: Presets<SliderPreset, Names>,
): {
readonly view: {
<Outer>(
options: SliderView<Outer, number> & PresetOption<Names>,
h: HtmlBuilder<Outer>,
): Html
<Outer>(
options: SliderView<Outer, Range> & PresetOption<Names>,
h: HtmlBuilder<Outer>,
): Html
<Outer>(
options: SliderView<Outer, ReadonlyArray<number>> & PresetOption<Names>,
h: HtmlBuilder<Outer>,
): Html
}
}The application's own Slider: base for every use, presets chosen at a
use with preset, and the call over both. mixins concatenate in that
order and words merge word by word; any other option given at the call
replaces the preset's.
Slider.Markinterface · packages/mixins-ui/src/slider.ts:82
interface Mark {
readonly value: number
readonly label: string
}A mark with words under it, such as { value: 0, label: 'Off' }.
Slider.movedfunction · packages/mixins-ui/src/slider.ts:162
function moved(
range: Range,
thumb: 'low' | 'high',
value: number,
bounds?: Bounds,
): RangeThe range after thumb moves to value: on the step, within the bounds,
and never past the other thumb. The same range when nothing changed, so
update can return its Model as it was.
Slider.movedAtfunction · packages/mixins-ui/src/slider.ts:180
function movedAt(
values: ReadonlyArray<number>,
index: number,
value: number,
bounds?: Bounds,
): ReadonlyArray<number>The list after the thumb at index moves to value: on the step, within
the bounds, and never past a neighbour. The same list when nothing changed.
Slider.Rangeinterface · packages/mixins-ui/src/slider.ts:76
interface Range {
readonly low: number
readonly high: number
}Slider.SliderPresettype · packages/mixins-ui/src/slider.ts:474
type SliderPreset = Pick<
SliderView<never, number>,
| 'min'
| 'max'
| 'step'
| 'orientation'
| 'showValue'
| 'ticks'
| 'format'
| 'words'
| 'style'
> & {
readonly mixins?: MixinList<never>
}What a Slider is given once: its bounds, look and words. The value, the Messages and what it chooses are each use's.
Slider.SliderSlotsconst · 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.
Slider.SliderViewinterface · packages/mixins-ui/src/slider.ts:113
interface SliderView<
Message,
Value extends number | Range | ReadonlyArray<number>,
> extends Bounds {
readonly id: string
readonly label: string
readonly value: Value
readonly onChange: (value: Value) => NoInfer<Message>
readonly onCommit?: ((value: Value) => NoInfer<Message>) | undefined
readonly description?: string | undefined
readonly format?: ((value: number) => string) | undefined
readonly words?: Partial<SliderWords> | undefined
readonly marks?: ReadonlyArray<number | Mark> | undefined
readonly ticks?: boolean | undefined
readonly orientation?: 'horizontal' | 'vertical' | undefined
readonly showValue?: boolean | undefined
readonly name?: string | undefined
readonly disabled?: boolean | undefined
readonly style?: NamedStyle<typeof SliderSlots> | undefined
readonly mixins?: MixinList<Message> | undefined
}Slider.SliderWordsinterface · packages/mixins-ui/src/slider.ts:97
interface SliderWords {
readonly low: string
readonly high: string
readonly thumb: string
}The fixed text a Slider says. {index} is a thumb's place from one, {count} how many there are.
Slider.viewfunction · packages/mixins-ui/src/slider.ts:298
function view<Message>(
options: SliderView<Message, number>,
h: HtmlBuilder<Message>,
): Html
function view<Message>(
options: SliderView<Message, Range>,
h: HtmlBuilder<Message>,
): Html
function view<Message>(
options: SliderView<Message, ReadonlyArray<number>>,
h: HtmlBuilder<Message>,
): Html
function view<Message>(
options: AnySlider<Message>,
h: HtmlBuilder<Message>,
): HtmlA slider of any of the three kinds, for a caller that does not know which it draws.
Slider.wordsconst · packages/mixins-ui/src/slider.ts:107
const words = { low, high, thumb }The words a Slider uses when none are given.