@finstack-com-public/design 0.10.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/dist/css/combobox.css +58 -0
- package/dist/css/combobox.md +75 -0
- package/dist/css/input.md +6 -1
- package/dist/css/select.css +103 -0
- package/dist/css/select.md +69 -0
- package/dist/css/slider.css +169 -0
- package/dist/css/slider.md +87 -0
- package/dist/css/switch.css +137 -0
- package/dist/css/switch.md +28 -0
- package/dist/css-text/combobox.d.ts +2 -0
- package/dist/css-text/combobox.js +1 -0
- package/dist/css-text/kit.js +471 -0
- package/dist/css-text/select.d.ts +2 -0
- package/dist/css-text/select.js +1 -0
- package/dist/css-text/slider.d.ts +2 -0
- package/dist/css-text/slider.js +1 -0
- package/dist/css-text/switch.d.ts +2 -0
- package/dist/css-text/switch.js +1 -0
- package/dist/dom/combobox.d.ts +47 -0
- package/dist/dom/combobox.js +178 -0
- package/dist/dom/index.d.ts +3 -0
- package/dist/dom/index.js +3 -0
- package/dist/dom/listbox.d.ts +11 -0
- package/dist/dom/listbox.js +9 -3
- package/dist/dom/select.d.ts +39 -0
- package/dist/dom/select.js +221 -0
- package/dist/dom/slider.d.ts +51 -0
- package/dist/dom/slider.js +256 -0
- package/dist/kit.css +471 -0
- package/dist/react/actions.js +12 -6
- package/dist/react/inputs.d.ts +181 -0
- package/dist/react/inputs.js +291 -15
- package/dist/react/navigation.js +33 -15
- package/dist/tokens/contrast-pairs.js +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "/* Slider and range slider (spec 02 B; F2 draft §4, T134). Usage: slider.md. Behaviour: createSlider,\n which writes each thumb's place (--fs-slider-at) and the fill's ends (--fs-slider-low, --fs-slider-high). */\n@layer fs.components {\n .fs-slider {\n --fs-slider-track-h: 4px;\n --fs-slider-thumb: var(--fs-icon-size);\n display: flex;\n align-items: center;\n gap: var(--fs-space-3);\n min-width: 0;\n min-height: var(--fs-control-h);\n font-size: var(--fs-text-body-size);\n line-height: var(--fs-text-body-line);\n /* A press starts a drag: the page must not scroll or select under it. */\n touch-action: none;\n user-select: none;\n }\n\n /* The track: 4 px, no fill or label inside it, so --fs-line-control-strong (3:1, D30). Half a thumb\n of room at each end keeps a thumb at the minimum or maximum inside the block. */\n .fs-slider__track {\n position: relative;\n flex: 1 1 auto;\n min-width: 0;\n box-sizing: border-box;\n height: var(--fs-slider-track-h);\n margin-inline: calc(var(--fs-slider-thumb) / 2);\n background: var(--fs-line-control-strong);\n border-radius: var(--fs-radius-sm);\n cursor: pointer;\n }\n /* The band from the minimum to the value, or between the two thumbs. */\n .fs-slider__fill {\n position: absolute;\n inset-block: 0;\n inset-inline-start: var(--fs-slider-low, 0%);\n inset-inline-end: calc(100% - var(--fs-slider-high, 0%));\n background: var(--fs-accent);\n border-radius: inherit;\n }\n /* Marks at the steps the product names, under the track. */\n .fs-slider__ticks {\n position: absolute;\n inset: 0;\n pointer-events: none;\n }\n .fs-slider__ticks > * {\n position: absolute;\n top: calc(var(--fs-slider-track-h) + 2px);\n inset-inline-start: var(--fs-slider-at, 0%);\n width: 1px;\n height: 4px;\n margin-inline-start: -0.5px;\n background: var(--fs-line-control-strong);\n }\n\n /* A thumb: a circle of the icon size (16 px, 20 at comfortable), a 2 px accent edge on the surface,\n its centre on the value. Its hit area is padded to the 24 px touch target (spec 06 §1). */\n .fs-slider__thumb {\n position: absolute;\n top: 50%;\n inset-inline-start: var(--fs-slider-at, 0%);\n box-sizing: border-box;\n width: var(--fs-slider-thumb);\n height: var(--fs-slider-thumb);\n margin-block-start: calc(var(--fs-slider-thumb) / -2);\n margin-inline-start: calc(var(--fs-slider-thumb) / -2);\n background: var(--fs-bg-surface);\n border: 2px solid var(--fs-accent);\n border-radius: 50%;\n cursor: grab;\n }\n .fs-slider__thumb::before {\n content: '';\n position: absolute;\n inset: calc((var(--fs-slider-thumb) - var(--fs-size-touch)) / 2 - 2px);\n border-radius: 50%;\n }\n /* --range: two thumbs. At one value, the focused one is on top. */\n .fs-slider--range .fs-slider__thumb:focus {\n z-index: 1;\n }\n @media (hover: hover) {\n .fs-slider__thumb:hover {\n border-color: var(--fs-accent-strong);\n }\n }\n /* Dragging: the helper sets .fs-is-dragging for the whole drag (pointer capture ends :active early in some engines).\n Two rules, not one list: the gallery clones a rule naming :active into a later sheet, and a list would take\n .fs-is-dragging along, past the forced-colours rule below. */\n .fs-slider__thumb.fs-is-dragging {\n background: var(--fs-bg-selected);\n border-color: var(--fs-accent-strong);\n cursor: grabbing;\n }\n .fs-slider__thumb:active {\n background: var(--fs-bg-selected);\n border-color: var(--fs-accent-strong);\n cursor: grabbing;\n }\n /* The ring recipe (D15). */\n .fs-slider__thumb:focus-visible {\n outline: var(--fs-ring-width) solid var(--fs-ring);\n outline-offset: var(--fs-ring-halo-width);\n box-shadow: 0 0 0 var(--fs-ring-halo-width) var(--fs-ring-halo);\n }\n\n /* The value beside it: an <output>, in tabular figures so it doesn't jitter while moving. */\n .fs-slider__value {\n flex: none;\n color: var(--fs-ink);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n }\n\n /* Disabled comes last: by colour, never opacity. The thumbs stay reachable (aria-disabled). */\n .fs-slider:has(.fs-slider__thumb[aria-disabled='true']) {\n color: var(--fs-ink-disabled);\n }\n .fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__track {\n background: var(--fs-line);\n cursor: not-allowed;\n }\n .fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__fill {\n background: var(--fs-ink-disabled);\n }\n .fs-slider__thumb[aria-disabled='true'] {\n background: var(--fs-bg-disabled);\n border-color: var(--fs-ink-disabled);\n cursor: not-allowed;\n }\n\n /* Forced colours erase the fills: the track becomes a 1 px CanvasText edge, the fill Highlight, the\n thumb a Canvas disc with a CanvasText edge, Highlight while focused or dragged; disabled GrayText.\n The thumb's place carries the value, and __value says it. */\n @media (forced-colors: active) {\n .fs-slider__track {\n background: Canvas;\n border: 1px solid CanvasText;\n }\n .fs-slider__fill {\n background: Highlight;\n }\n .fs-slider__ticks > * {\n background: CanvasText;\n }\n .fs-slider__thumb {\n background: Canvas;\n border-color: CanvasText;\n }\n .fs-slider__thumb:focus-visible,\n .fs-slider__thumb.fs-is-dragging {\n border-color: Highlight;\n }\n .fs-slider:has(.fs-slider__thumb[aria-disabled='true']) {\n color: GrayText;\n }\n .fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__track {\n border-color: GrayText;\n }\n .fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__fill,\n .fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__ticks > * {\n background: GrayText;\n }\n .fs-slider__thumb[aria-disabled='true'] {\n border-color: GrayText;\n }\n }\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "/* Switch (spec 02 B, T131): a native checkbox with role=\"switch\", drawn as a pill track with a knob.\n Usage: switch.md. */\n@layer fs.components {\n .fs-switch {\n /* W1: 28 × 16 at dense and compact, 36 × 20 at comfortable. The icon size is 16, 16 and 20 px at\n the three densities, so the height follows it and the width is twice it less 4 px. */\n --fs-switch-h: var(--fs-icon-size);\n --fs-switch-w: calc(var(--fs-switch-h) * 2 - 4px);\n display: inline-flex;\n align-items: center;\n gap: var(--fs-space-2);\n min-height: var(--fs-size-touch);\n font-size: var(--fs-text-body-size);\n line-height: var(--fs-text-body-line);\n color: var(--fs-ink);\n cursor: pointer;\n }\n /* --end: the label first, the switch at the row's end (a settings row). Same markup, so `order`. */\n .fs-switch--end {\n display: flex;\n justify-content: space-between;\n }\n .fs-switch--end > .fs-switch__input {\n order: 1;\n }\n\n /* The track. Its edge is --fs-line-control-strong (3:1): no label sits inside it, as the checkbox box. */\n .fs-switch__input {\n appearance: none;\n position: relative;\n flex: none;\n box-sizing: border-box;\n width: var(--fs-switch-w);\n height: var(--fs-switch-h);\n margin: 0;\n background: var(--fs-bg-sunken);\n border: var(--fs-line-width) solid var(--fs-line-control-strong);\n border-radius: var(--fs-radius-pill);\n cursor: pointer;\n }\n /* The knob: a circle 4 px smaller than the track's height, 2 px in from its outer edge. Its position\n says the state (W2: no glyph). --fs-dur is 0 under reduced motion, so the move is instant there. */\n .fs-switch__input::before {\n content: '';\n position: absolute;\n inset-block: 0;\n inset-inline-start: calc(2px - var(--fs-line-width));\n width: calc(var(--fs-switch-h) - 4px);\n height: calc(var(--fs-switch-h) - 4px);\n margin-block: auto;\n background: var(--fs-line-control-strong);\n border-radius: 50%;\n transition: inset-inline-start var(--fs-dur) var(--fs-ease);\n }\n .fs-switch__input:checked {\n background: var(--fs-accent);\n border-color: var(--fs-accent);\n }\n .fs-switch__input:checked::before {\n inset-inline-start: calc(var(--fs-switch-w) - var(--fs-switch-h) + 2px - var(--fs-line-width));\n background: var(--fs-bg-surface);\n }\n\n @media (hover: hover) {\n .fs-switch:hover > .fs-switch__input:not(:checked, :disabled) {\n border-color: var(--fs-ink-2);\n }\n }\n\n /* The ring recipe (D15). */\n .fs-switch__input:focus-visible {\n outline: var(--fs-ring-width) solid var(--fs-ring);\n outline-offset: var(--fs-ring-halo-width);\n box-shadow: 0 0 0 var(--fs-ring-halo-width) var(--fs-ring-halo);\n }\n\n /* Busy (aria-busy on the row): the change is on its way, so the knob keeps its place without motion. */\n .fs-switch[aria-busy='true'],\n .fs-switch[aria-busy='true'] > .fs-switch__input {\n cursor: progress;\n }\n .fs-switch[aria-busy='true'] > .fs-switch__input::before {\n transition: none;\n }\n\n /* Disabled comes last. Never opacity. */\n .fs-switch:has(:disabled) {\n color: var(--fs-ink-disabled);\n cursor: not-allowed;\n }\n .fs-switch__input:disabled {\n background: var(--fs-bg-disabled);\n border-color: var(--fs-line);\n cursor: not-allowed;\n }\n .fs-switch__input:disabled::before {\n background: var(--fs-ink-disabled);\n }\n .fs-switch__input:disabled:checked {\n background: var(--fs-ink-disabled);\n border-color: var(--fs-ink-disabled);\n }\n .fs-switch__input:disabled:checked::before {\n background: var(--fs-bg-disabled);\n }\n\n /* Forced colours erase the fills, and appearance: auto would draw a checkbox, so the kit keeps its\n drawing in system colours: the knob's place still tells off from on. */\n @media (forced-colors: active) {\n .fs-switch__input {\n background: Canvas;\n border-color: CanvasText;\n }\n .fs-switch__input::before {\n background: CanvasText;\n }\n .fs-switch__input:checked {\n background: Highlight;\n border-color: Highlight;\n }\n .fs-switch__input:checked::before {\n background: HighlightText;\n }\n .fs-switch:has(:disabled) {\n color: GrayText;\n }\n .fs-switch__input:disabled,\n .fs-switch__input:disabled:checked {\n background: Canvas;\n border-color: GrayText;\n }\n .fs-switch__input:disabled::before,\n .fs-switch__input:disabled:checked::before {\n background: GrayText;\n }\n }\n}\n";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Placement } from './position.ts';
|
|
2
|
+
export interface ComboboxOptions {
|
|
3
|
+
/** The `<input role="combobox">` that keeps focus, inside `root`. */
|
|
4
|
+
input: HTMLInputElement;
|
|
5
|
+
/** The `role="listbox"` element holding the `role="option"`s (directly or in `role="group"`s). */
|
|
6
|
+
list: HTMLElement;
|
|
7
|
+
/** An optional button that opens and closes the list (`tabindex="-1"`, named by the product). */
|
|
8
|
+
toggle?: HTMLElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* `aria-autocomplete` on the input: `'list'` (default) when the options follow the typed text,
|
|
11
|
+
* `'none'` when they don't. The kit never filters; this only tells screen readers (T133 C3: no
|
|
12
|
+
* `'both'`).
|
|
13
|
+
*/
|
|
14
|
+
autocomplete?: 'list' | 'none';
|
|
15
|
+
/** Escape on a closed list clears the input (APG optional). Default `false`. */
|
|
16
|
+
clearOnEscape?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Only an option's value is accepted. On a commit (the input's `change`: leaving it, or Enter,
|
|
19
|
+
* after typing), text matching an enabled option's value (ignoring case and outer spaces) is
|
|
20
|
+
* accepted as that option; other text fires `fs-change` with `option: null`, and the product
|
|
21
|
+
* sets `aria-invalid`. Default `false`: free text is allowed and read from the input.
|
|
22
|
+
*/
|
|
23
|
+
strict?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The text an accepted option writes into the input. Default: its `__label` text, else all of
|
|
26
|
+
* it. (Draft §1 called it `valueOf`, which every object already has from Object.prototype.)
|
|
27
|
+
*/
|
|
28
|
+
optionValue?: (option: HTMLElement) => string;
|
|
29
|
+
placement?: Placement;
|
|
30
|
+
}
|
|
31
|
+
export interface ComboboxChangeDetail {
|
|
32
|
+
/** The input's text after the change. */
|
|
33
|
+
value: string;
|
|
34
|
+
/** The accepted option; `null` when the input was cleared or (strict) the text matches none. */
|
|
35
|
+
option: HTMLElement | null;
|
|
36
|
+
}
|
|
37
|
+
export interface Combobox {
|
|
38
|
+
readonly isOpen: boolean;
|
|
39
|
+
/** Opens the list (on an option marked `aria-selected`, else the first enabled one). */
|
|
40
|
+
open(): void;
|
|
41
|
+
close(): void;
|
|
42
|
+
/** Re-reads the options (call it after filtering them) and takes new options. */
|
|
43
|
+
update(options?: Partial<Omit<ComboboxOptions, 'input' | 'list' | 'toggle'>>): void;
|
|
44
|
+
/** Silent (T88); also destroys its listbox. */
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
|
47
|
+
export declare function createCombobox(root: HTMLElement, options: ComboboxOptions): Combobox;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// The editable combobox (F2 draft §1, T133): a text input with list autocomplete on createListbox.
|
|
2
|
+
// Focus stays in the input (`aria-activedescendant`); the list is the completion list's
|
|
3
|
+
// `.fs-menu--listbox`. The product filters the options as the user types (the native `input`
|
|
4
|
+
// event) and calls `update()`; this helper adds the closed-state keys, the optional toggle button,
|
|
5
|
+
// `clearOnEscape`, `strict` and writing the accepted option's value into the input.
|
|
6
|
+
import { createListbox } from "./listbox.js";
|
|
7
|
+
const OPTIONS = '[role="option"]';
|
|
8
|
+
const isDisabled = (el) => el.getAttribute('aria-disabled') === 'true';
|
|
9
|
+
const textOf = (option) => (option.querySelector('.fs-menu__label') ?? option).textContent?.replace(/\s+/g, ' ').trim() ?? '';
|
|
10
|
+
export function createCombobox(root, options) {
|
|
11
|
+
let opts = { ...options };
|
|
12
|
+
const { input, list } = opts;
|
|
13
|
+
const toggle = opts.toggle ?? null;
|
|
14
|
+
const doc = root.ownerDocument;
|
|
15
|
+
const enabled = () => [...list.querySelectorAll(OPTIONS)].filter((o) => !isDisabled(o));
|
|
16
|
+
const valueFor = (option) => (opts.optionValue ?? textOf)(option);
|
|
17
|
+
const blocked = () => input.disabled || input.readOnly;
|
|
18
|
+
// The text last reported with fs-change (or found at the start), so a commit is reported once.
|
|
19
|
+
let committed = input.value;
|
|
20
|
+
// Set when a press on the toggle closed the list (createListbox's outside press), so the click
|
|
21
|
+
// that follows doesn't open it again.
|
|
22
|
+
let closedByPress = false;
|
|
23
|
+
// The combobox's keys run before createListbox's (registered first); Alt+keys are all its own.
|
|
24
|
+
input.addEventListener('keydown', onKeydown, true);
|
|
25
|
+
input.addEventListener('change', onCommit);
|
|
26
|
+
const lb = createListbox(list, { input, homeEnd: 'caret', placement: opts.placement });
|
|
27
|
+
list.addEventListener('fs-select', onAccepted);
|
|
28
|
+
list.addEventListener('fs-open', syncToggle);
|
|
29
|
+
list.addEventListener('fs-close', syncToggle);
|
|
30
|
+
if (toggle) {
|
|
31
|
+
toggle.setAttribute('aria-controls', list.id);
|
|
32
|
+
toggle.addEventListener('pointerdown', onTogglePointerdown);
|
|
33
|
+
toggle.addEventListener('click', onToggleClick);
|
|
34
|
+
doc.addEventListener('pointerdown', onDocPointerdown, true);
|
|
35
|
+
}
|
|
36
|
+
setAutocomplete();
|
|
37
|
+
syncToggle();
|
|
38
|
+
function setAutocomplete() {
|
|
39
|
+
input.setAttribute('aria-autocomplete', opts.autocomplete ?? 'list');
|
|
40
|
+
}
|
|
41
|
+
/** Opens the list at least as wide as the input. */
|
|
42
|
+
function show() {
|
|
43
|
+
if (!lb.isOpen)
|
|
44
|
+
list.style.minWidth = `${input.getBoundingClientRect().width}px`;
|
|
45
|
+
lb.open();
|
|
46
|
+
}
|
|
47
|
+
function syncToggle() {
|
|
48
|
+
toggle?.setAttribute('aria-expanded', String(lb.isOpen));
|
|
49
|
+
}
|
|
50
|
+
function change(value, option) {
|
|
51
|
+
committed = value;
|
|
52
|
+
root.dispatchEvent(new CustomEvent('fs-change', { bubbles: true, detail: { value, option } }));
|
|
53
|
+
}
|
|
54
|
+
/** Writes the option's value into the input, caret at its end, and reports it. */
|
|
55
|
+
function accept(option) {
|
|
56
|
+
const value = valueFor(option);
|
|
57
|
+
input.value = value;
|
|
58
|
+
input.setSelectionRange?.(value.length, value.length);
|
|
59
|
+
change(value, option);
|
|
60
|
+
}
|
|
61
|
+
// fs-select is internal: the combobox reports an accepted option with fs-change.
|
|
62
|
+
function onAccepted(e) {
|
|
63
|
+
if (e.target !== list)
|
|
64
|
+
return;
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
accept(e.detail.option);
|
|
67
|
+
}
|
|
68
|
+
function onCommit() {
|
|
69
|
+
if (!opts.strict || input.value === committed)
|
|
70
|
+
return;
|
|
71
|
+
const text = input.value.trim().toLocaleLowerCase();
|
|
72
|
+
if (text === '')
|
|
73
|
+
return change(input.value, null);
|
|
74
|
+
const match = enabled().find((o) => valueFor(o).trim().toLocaleLowerCase() === text);
|
|
75
|
+
if (match)
|
|
76
|
+
accept(match);
|
|
77
|
+
else
|
|
78
|
+
change(input.value, null);
|
|
79
|
+
}
|
|
80
|
+
function onKeydown(e) {
|
|
81
|
+
if (e.isComposing || e.ctrlKey || e.metaKey || e.shiftKey)
|
|
82
|
+
return;
|
|
83
|
+
const consume = () => {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
e.stopImmediatePropagation();
|
|
86
|
+
};
|
|
87
|
+
if (lb.isOpen) {
|
|
88
|
+
if (e.key === 'ArrowUp' && e.altKey) {
|
|
89
|
+
consume();
|
|
90
|
+
lb.close();
|
|
91
|
+
}
|
|
92
|
+
else if (e.key === 'Tab') {
|
|
93
|
+
// Accepts the current option and closes, and the key still moves focus on (APG); the
|
|
94
|
+
// completion list's own Tab, which keeps focus in the editor, never sees it.
|
|
95
|
+
e.stopImmediatePropagation();
|
|
96
|
+
const option = lb.active;
|
|
97
|
+
if (option)
|
|
98
|
+
accept(option);
|
|
99
|
+
lb.close();
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (blocked())
|
|
104
|
+
return;
|
|
105
|
+
switch (e.key) {
|
|
106
|
+
case 'ArrowDown':
|
|
107
|
+
consume();
|
|
108
|
+
show();
|
|
109
|
+
// Alt+Down opens without making an option current.
|
|
110
|
+
if (e.altKey)
|
|
111
|
+
lb.setActive(null);
|
|
112
|
+
return;
|
|
113
|
+
case 'ArrowUp': {
|
|
114
|
+
if (e.altKey)
|
|
115
|
+
return;
|
|
116
|
+
consume();
|
|
117
|
+
show();
|
|
118
|
+
const items = enabled();
|
|
119
|
+
return lb.setActive(items[items.length - 1] ?? null);
|
|
120
|
+
}
|
|
121
|
+
case 'Escape':
|
|
122
|
+
if (!opts.clearOnEscape || input.value === '')
|
|
123
|
+
return;
|
|
124
|
+
consume();
|
|
125
|
+
input.value = '';
|
|
126
|
+
return change('', null);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function onDocPointerdown(e) {
|
|
130
|
+
closedByPress = lb.isOpen && !!toggle && e.composedPath().includes(toggle);
|
|
131
|
+
}
|
|
132
|
+
// A press on the toggle keeps focus in the input (as a press inside the list does).
|
|
133
|
+
function onTogglePointerdown(e) {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
}
|
|
136
|
+
function onToggleClick() {
|
|
137
|
+
const pressed = closedByPress;
|
|
138
|
+
closedByPress = false;
|
|
139
|
+
if (lb.isOpen)
|
|
140
|
+
lb.close();
|
|
141
|
+
else if (!pressed && !blocked()) {
|
|
142
|
+
if (root.getRootNode().activeElement !== input)
|
|
143
|
+
input.focus();
|
|
144
|
+
show();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
get isOpen() {
|
|
149
|
+
return lb.isOpen;
|
|
150
|
+
},
|
|
151
|
+
open() {
|
|
152
|
+
show();
|
|
153
|
+
},
|
|
154
|
+
close() {
|
|
155
|
+
lb.close();
|
|
156
|
+
},
|
|
157
|
+
update(next = {}) {
|
|
158
|
+
opts = { ...opts, ...next };
|
|
159
|
+
setAutocomplete();
|
|
160
|
+
lb.update({ placement: opts.placement });
|
|
161
|
+
},
|
|
162
|
+
destroy() {
|
|
163
|
+
lb.destroy();
|
|
164
|
+
input.removeEventListener('keydown', onKeydown, true);
|
|
165
|
+
input.removeEventListener('change', onCommit);
|
|
166
|
+
list.removeEventListener('fs-select', onAccepted);
|
|
167
|
+
list.removeEventListener('fs-open', syncToggle);
|
|
168
|
+
list.removeEventListener('fs-close', syncToggle);
|
|
169
|
+
if (toggle) {
|
|
170
|
+
toggle.removeEventListener('pointerdown', onTogglePointerdown);
|
|
171
|
+
toggle.removeEventListener('click', onToggleClick);
|
|
172
|
+
doc.removeEventListener('pointerdown', onDocPointerdown, true);
|
|
173
|
+
toggle.removeAttribute('aria-controls');
|
|
174
|
+
toggle.removeAttribute('aria-expanded');
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { type Calendar, type CalendarChangeDetail, type CalendarDay, type CalendarLabels, type CalendarOptions, type CalendarPage, type CalendarRange, type CalendarRangeChangeDetail, type CalendarRangeLabels, type CalendarView, createCalendar, type Granularity, type RangeCalendar, type RangeCalendarOptions, } from './calendar.ts';
|
|
2
|
+
export { type Combobox, type ComboboxChangeDetail, type ComboboxOptions, createCombobox } from './combobox.ts';
|
|
2
3
|
export { createDialog, createSheet, type Dialog, type DialogCloseDetail, type DialogOptions } from './dialog.ts';
|
|
3
4
|
export { createListbox, type Listbox, type ListboxOptions, type ListboxSelectDetail } from './listbox.ts';
|
|
4
5
|
export { createLoader, type Loader, type LoaderOptions } from './loader.ts';
|
|
@@ -6,6 +7,8 @@ export { createMenu, type Menu, type MenuOptions, type MenuSelectDetail } from '
|
|
|
6
7
|
export { createPopover, type Popover, type PopoverOptions } from './popover.ts';
|
|
7
8
|
export { compute, place, type Placed, type Placement, type PlaceOptions, type Rect } from './position.ts';
|
|
8
9
|
export { createRovingGroup, type RovingChangeDetail, type RovingGroup, type RovingGroupOptions, } from './roving-group.ts';
|
|
10
|
+
export { createSelect, type Select, type SelectChangeDetail, type SelectOptions } from './select.ts';
|
|
11
|
+
export { createSlider, type RangeSlider, type RangeSliderChangeDetail, type RangeSliderOptions, rangeValueText, type Slider, type SliderChangeDetail, type SliderLabels, type SliderOptions, } from './slider.ts';
|
|
9
12
|
export { createTabs, type Tabs, type TabsDetail, type TabsOptions } from './tabs.ts';
|
|
10
13
|
export { createToaster, type Toaster, type ToasterOptions, type ToastSpec, type ToastTone } from './toaster.ts';
|
|
11
14
|
export { createTooltip, type Tooltip, type TooltipOptions } from './tooltip.ts';
|
package/dist/dom/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The plain-DOM behaviour helpers (D13; spec 03 §3). Each is also importable on its own:
|
|
2
2
|
// `@finstack-com-public/design/dom/<helper>`.
|
|
3
3
|
export { createCalendar, } from "./calendar.js";
|
|
4
|
+
export { createCombobox } from "./combobox.js";
|
|
4
5
|
export { createDialog, createSheet } from "./dialog.js";
|
|
5
6
|
export { createListbox } from "./listbox.js";
|
|
6
7
|
export { createLoader } from "./loader.js";
|
|
@@ -8,6 +9,8 @@ export { createMenu } from "./menu.js";
|
|
|
8
9
|
export { createPopover } from "./popover.js";
|
|
9
10
|
export { compute, place } from "./position.js";
|
|
10
11
|
export { createRovingGroup, } from "./roving-group.js";
|
|
12
|
+
export { createSelect } from "./select.js";
|
|
13
|
+
export { createSlider, rangeValueText, } from "./slider.js";
|
|
11
14
|
export { createTabs } from "./tabs.js";
|
|
12
15
|
export { createToaster } from "./toaster.js";
|
|
13
16
|
export { createTooltip } from "./tooltip.js";
|
package/dist/dom/listbox.d.ts
CHANGED
|
@@ -9,6 +9,17 @@ export interface ListboxOptions {
|
|
|
9
9
|
/** What the list is placed against while open. Default: the input's box. An editor passes the caret's. */
|
|
10
10
|
anchor?: () => Rect;
|
|
11
11
|
placement?: Placement;
|
|
12
|
+
/**
|
|
13
|
+
* Whether Up on the first option goes to the last and Down on the last to the first. Default
|
|
14
|
+
* `true` (the completion list); the custom select passes `false` (APG select-only combobox).
|
|
15
|
+
*/
|
|
16
|
+
wrap?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Who takes Home and End while open: `'options'` (default, the completion list and the custom
|
|
19
|
+
* select) moves to the first and last option; `'caret'` lets them through to move the input's
|
|
20
|
+
* caret (the editable combobox, APG's list autocomplete example).
|
|
21
|
+
*/
|
|
22
|
+
homeEnd?: 'options' | 'caret';
|
|
12
23
|
}
|
|
13
24
|
export interface ListboxSelectDetail {
|
|
14
25
|
option: HTMLElement;
|
package/dist/dom/listbox.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// A listbox driven by `aria-activedescendant`: focus stays in the input or editor, and the
|
|
2
2
|
// current option is drawn, not focused (spec 03 §3.2, 06 §4). The completion list (spec 02 H)
|
|
3
|
-
// and
|
|
3
|
+
// and F2's custom select (T132) and editable combobox (T133) build on it.
|
|
4
4
|
import { hideLayer, initLayer, showLayer } from "./layer.js";
|
|
5
5
|
import { place } from "./position.js";
|
|
6
6
|
const OPTIONS = '[role="option"]';
|
|
@@ -102,6 +102,8 @@ export function createListbox(list, options) {
|
|
|
102
102
|
return;
|
|
103
103
|
const items = enabled();
|
|
104
104
|
const i = active ? items.indexOf(active) : -1;
|
|
105
|
+
const last = items.length - 1;
|
|
106
|
+
const wrap = opts.wrap !== false;
|
|
105
107
|
const consume = () => {
|
|
106
108
|
e.preventDefault();
|
|
107
109
|
e.stopImmediatePropagation();
|
|
@@ -109,14 +111,18 @@ export function createListbox(list, options) {
|
|
|
109
111
|
switch (e.key) {
|
|
110
112
|
case 'ArrowDown':
|
|
111
113
|
consume();
|
|
112
|
-
return setActive(items[i < 0 ? 0 : (i + 1) % items.length] ?? null);
|
|
114
|
+
return setActive(items[i < 0 ? 0 : wrap ? (i + 1) % items.length : Math.min(i + 1, last)] ?? null);
|
|
113
115
|
case 'ArrowUp':
|
|
114
116
|
consume();
|
|
115
|
-
return setActive(items[i < 0 ?
|
|
117
|
+
return setActive(items[i < 0 ? last : wrap ? (i - 1 + items.length) % items.length : Math.max(i - 1, 0)] ?? null);
|
|
116
118
|
case 'Home':
|
|
119
|
+
if (opts.homeEnd === 'caret')
|
|
120
|
+
return;
|
|
117
121
|
consume();
|
|
118
122
|
return setActive(items[0] ?? null);
|
|
119
123
|
case 'End':
|
|
124
|
+
if (opts.homeEnd === 'caret')
|
|
125
|
+
return;
|
|
120
126
|
consume();
|
|
121
127
|
return setActive(items[items.length - 1] ?? null);
|
|
122
128
|
case 'Escape':
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Placement } from './position.ts';
|
|
2
|
+
export interface SelectOptions {
|
|
3
|
+
/** The `role="combobox"` element that keeps focus (a `div` with `tabindex="0"`), inside `root`. */
|
|
4
|
+
trigger: HTMLElement;
|
|
5
|
+
/** The `role="listbox"` element holding the `role="option"`s, inside `root`. */
|
|
6
|
+
list: HTMLElement;
|
|
7
|
+
/** The chosen option's id, or `null`. Default: the option marked `.fs-is-value`, else none. */
|
|
8
|
+
value?: string | null;
|
|
9
|
+
/** How long typed letters keep adding to one search, in ms. Default 500. */
|
|
10
|
+
typeaheadTimeout?: number;
|
|
11
|
+
/** The trigger's text with no value. Default: the text of the `__placeholder` it was given. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the helper writes the value into the trigger (`__value`/`__placeholder`), the
|
|
15
|
+
* `.fs-is-value` mark and the hidden input. Default `true`; a framework that renders those
|
|
16
|
+
* itself passes `false`.
|
|
17
|
+
*/
|
|
18
|
+
writeValue?: boolean;
|
|
19
|
+
placement?: Placement;
|
|
20
|
+
}
|
|
21
|
+
export interface SelectChangeDetail {
|
|
22
|
+
/** The accepted option's id. */
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
export interface Select {
|
|
26
|
+
readonly isOpen: boolean;
|
|
27
|
+
/** The chosen option's id, or `null`. */
|
|
28
|
+
readonly value: string | null;
|
|
29
|
+
/** Sets the value without an event (`null` clears it). */
|
|
30
|
+
setValue(id: string | null): void;
|
|
31
|
+
/** Opens the list on the value (else the first enabled option). */
|
|
32
|
+
open(): void;
|
|
33
|
+
/** Closes it, value unchanged. */
|
|
34
|
+
close(): void;
|
|
35
|
+
/** Re-reads the options (call it after changing them) and takes new options. */
|
|
36
|
+
update(options?: Partial<Omit<SelectOptions, 'trigger' | 'list'>>): void;
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare function createSelect(root: HTMLElement, options: SelectOptions): Select;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// The custom select (F2 draft §2, T132): a select-only combobox on createListbox. Focus stays on
|
|
2
|
+
// the trigger (`role="combobox"`); the list is the completion list's `.fs-menu--listbox`. This
|
|
3
|
+
// helper adds the closed-state keys, Space, Alt+Up, PageUp/PageDown, typeahead and the value.
|
|
4
|
+
import { createListbox } from "./listbox.js";
|
|
5
|
+
const OPTIONS = '[role="option"]';
|
|
6
|
+
const VALUE = 'fs-select__value';
|
|
7
|
+
const PLACEHOLDER = 'fs-select__placeholder';
|
|
8
|
+
const PAGE = 10;
|
|
9
|
+
const isDisabled = (el) => el.getAttribute('aria-disabled') === 'true';
|
|
10
|
+
/** The text an option is known by: its `__label`, else all of it. */
|
|
11
|
+
const textOf = (option) => (option.querySelector('.fs-menu__label') ?? option).textContent?.replace(/\s+/g, ' ').trim() ?? '';
|
|
12
|
+
export function createSelect(root, options) {
|
|
13
|
+
let opts = { ...options };
|
|
14
|
+
const { trigger, list } = opts;
|
|
15
|
+
const all = () => [...list.querySelectorAll(OPTIONS)];
|
|
16
|
+
const enabled = () => all().filter((o) => !isDisabled(o));
|
|
17
|
+
const byId = (id) => (id === null ? null : (all().find((o) => o.id === id) ?? null));
|
|
18
|
+
const marked = all().find((o) => o.classList.contains('fs-is-value'));
|
|
19
|
+
let value = opts.value !== undefined ? opts.value : (marked?.id ?? null);
|
|
20
|
+
const shown = trigger.querySelector(`.${VALUE}, .${PLACEHOLDER}`);
|
|
21
|
+
const givenPlaceholder = shown?.classList.contains(PLACEHOLDER) ? (shown.textContent ?? '') : '';
|
|
22
|
+
// Disabled and read-only triggers stay focusable but never open.
|
|
23
|
+
const blocked = () => trigger.getAttribute('aria-disabled') === 'true' || trigger.getAttribute('aria-readonly') === 'true';
|
|
24
|
+
let typed = '';
|
|
25
|
+
let typedAt = -Infinity;
|
|
26
|
+
// The select's keys listen on the trigger before createListbox's (registered first): it takes
|
|
27
|
+
// Tab, Space and the letters itself, and lets the rest through to the listbox while open.
|
|
28
|
+
trigger.addEventListener('keydown', onKeydown, true);
|
|
29
|
+
const lb = createListbox(list, { input: trigger, wrap: false, placement: opts.placement });
|
|
30
|
+
list.addEventListener('fs-select', onAccepted);
|
|
31
|
+
trigger.addEventListener('click', onClick);
|
|
32
|
+
render();
|
|
33
|
+
function render() {
|
|
34
|
+
if (opts.writeValue === false)
|
|
35
|
+
return;
|
|
36
|
+
const option = byId(value);
|
|
37
|
+
for (const o of all())
|
|
38
|
+
o.classList.toggle('fs-is-value', o === option);
|
|
39
|
+
let out = trigger.querySelector(`.${VALUE}, .${PLACEHOLDER}`);
|
|
40
|
+
if (!out) {
|
|
41
|
+
out = trigger.ownerDocument.createElement('span');
|
|
42
|
+
trigger.append(out);
|
|
43
|
+
}
|
|
44
|
+
out.classList.toggle(VALUE, !!option);
|
|
45
|
+
out.classList.toggle(PLACEHOLDER, !option);
|
|
46
|
+
out.textContent = option ? textOf(option) : (opts.placeholder ?? givenPlaceholder);
|
|
47
|
+
const input = root.querySelector(':scope > input[type="hidden"]');
|
|
48
|
+
if (input)
|
|
49
|
+
input.value = option ? (option.dataset.value ?? option.id) : '';
|
|
50
|
+
}
|
|
51
|
+
/** Opens with `target` current: the value (the list's own pick, F2's note), or an option. */
|
|
52
|
+
function openOn(target) {
|
|
53
|
+
if (lb.isOpen) {
|
|
54
|
+
if (target instanceof HTMLElement)
|
|
55
|
+
lb.setActive(target);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// Mark the value so createListbox opens on it; clear any other mark.
|
|
59
|
+
const option = byId(value);
|
|
60
|
+
for (const o of all()) {
|
|
61
|
+
if (o === option && !isDisabled(o))
|
|
62
|
+
o.setAttribute('aria-selected', 'true');
|
|
63
|
+
else
|
|
64
|
+
o.removeAttribute('aria-selected');
|
|
65
|
+
}
|
|
66
|
+
list.style.minWidth = `${trigger.getBoundingClientRect().width}px`;
|
|
67
|
+
lb.open();
|
|
68
|
+
const items = enabled();
|
|
69
|
+
if (target === 'first')
|
|
70
|
+
lb.setActive(items[0] ?? null);
|
|
71
|
+
else if (target === 'last')
|
|
72
|
+
lb.setActive(items[items.length - 1] ?? null);
|
|
73
|
+
else if (target instanceof HTMLElement)
|
|
74
|
+
lb.setActive(target);
|
|
75
|
+
}
|
|
76
|
+
function commit(option) {
|
|
77
|
+
if (isDisabled(option))
|
|
78
|
+
return;
|
|
79
|
+
const changed = option.id !== value;
|
|
80
|
+
value = option.id;
|
|
81
|
+
render();
|
|
82
|
+
if (changed)
|
|
83
|
+
root.dispatchEvent(new CustomEvent('fs-change', { bubbles: true, detail: { value } }));
|
|
84
|
+
}
|
|
85
|
+
function acceptActive() {
|
|
86
|
+
const option = lb.active;
|
|
87
|
+
if (option)
|
|
88
|
+
commit(option);
|
|
89
|
+
lb.close();
|
|
90
|
+
}
|
|
91
|
+
// fs-select is internal: the select reports a change with fs-change.
|
|
92
|
+
function onAccepted(e) {
|
|
93
|
+
if (e.target !== list)
|
|
94
|
+
return;
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
commit(e.detail.option);
|
|
97
|
+
}
|
|
98
|
+
function onClick() {
|
|
99
|
+
if (lb.isOpen)
|
|
100
|
+
lb.close();
|
|
101
|
+
else if (!blocked())
|
|
102
|
+
openOn('value');
|
|
103
|
+
}
|
|
104
|
+
/** The option typing `key` moves to, from `from` (the current option or the value). */
|
|
105
|
+
function typeahead(key, from) {
|
|
106
|
+
const now = Date.now();
|
|
107
|
+
typed = now - typedAt > (opts.typeaheadTimeout ?? 500) ? key : typed + key;
|
|
108
|
+
typedAt = now;
|
|
109
|
+
const items = enabled();
|
|
110
|
+
const at = from ? items.indexOf(from) : -1;
|
|
111
|
+
const query = typed.toLocaleLowerCase();
|
|
112
|
+
// One letter typed again cycles through the options starting with it; a longer string stays
|
|
113
|
+
// on the current option while it still matches.
|
|
114
|
+
const cycling = [...query].every((c) => c === query[0]);
|
|
115
|
+
const needle = cycling ? query[0] : query;
|
|
116
|
+
const start = cycling ? at + 1 : Math.max(at, 0);
|
|
117
|
+
for (let n = 0; n < items.length; n++) {
|
|
118
|
+
const option = items[(start + n) % items.length];
|
|
119
|
+
if (textOf(option).toLocaleLowerCase().startsWith(needle))
|
|
120
|
+
return option;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
function onKeydown(e) {
|
|
125
|
+
if (e.isComposing || e.ctrlKey || e.metaKey)
|
|
126
|
+
return;
|
|
127
|
+
const consume = () => {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
e.stopImmediatePropagation();
|
|
130
|
+
};
|
|
131
|
+
const printable = e.key.length === 1 && !e.altKey;
|
|
132
|
+
const typing = printable && (e.key !== ' ' || (typed !== '' && Date.now() - typedAt <= (opts.typeaheadTimeout ?? 500)));
|
|
133
|
+
if (!lb.isOpen) {
|
|
134
|
+
if (blocked())
|
|
135
|
+
return;
|
|
136
|
+
if (typing) {
|
|
137
|
+
consume();
|
|
138
|
+
return openOn(typeahead(e.key, byId(value)) ?? 'value');
|
|
139
|
+
}
|
|
140
|
+
switch (e.key) {
|
|
141
|
+
case 'ArrowDown':
|
|
142
|
+
case 'Enter':
|
|
143
|
+
case ' ':
|
|
144
|
+
consume();
|
|
145
|
+
return openOn('value');
|
|
146
|
+
case 'ArrowUp':
|
|
147
|
+
if (e.altKey)
|
|
148
|
+
return;
|
|
149
|
+
consume();
|
|
150
|
+
return openOn('first');
|
|
151
|
+
case 'Home':
|
|
152
|
+
consume();
|
|
153
|
+
return openOn('first');
|
|
154
|
+
case 'End':
|
|
155
|
+
consume();
|
|
156
|
+
return openOn('last');
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (typing) {
|
|
161
|
+
consume();
|
|
162
|
+
const option = typeahead(e.key, lb.active);
|
|
163
|
+
if (option)
|
|
164
|
+
lb.setActive(option);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
switch (e.key) {
|
|
168
|
+
case ' ':
|
|
169
|
+
consume();
|
|
170
|
+
return acceptActive();
|
|
171
|
+
case 'ArrowUp':
|
|
172
|
+
if (!e.altKey)
|
|
173
|
+
return;
|
|
174
|
+
consume();
|
|
175
|
+
return acceptActive();
|
|
176
|
+
case 'Tab':
|
|
177
|
+
// Accepts and closes; the key still moves focus on (APG).
|
|
178
|
+
e.stopImmediatePropagation();
|
|
179
|
+
return acceptActive();
|
|
180
|
+
case 'PageUp':
|
|
181
|
+
case 'PageDown': {
|
|
182
|
+
consume();
|
|
183
|
+
const items = enabled();
|
|
184
|
+
const i = lb.active ? items.indexOf(lb.active) : -1;
|
|
185
|
+
const next = e.key === 'PageDown' ? Math.min(i + PAGE, items.length - 1) : Math.max(i - PAGE, 0);
|
|
186
|
+
return lb.setActive(items[next] ?? null);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
get isOpen() {
|
|
192
|
+
return lb.isOpen;
|
|
193
|
+
},
|
|
194
|
+
get value() {
|
|
195
|
+
return value;
|
|
196
|
+
},
|
|
197
|
+
setValue(id) {
|
|
198
|
+
value = id;
|
|
199
|
+
render();
|
|
200
|
+
},
|
|
201
|
+
open() {
|
|
202
|
+
openOn('value');
|
|
203
|
+
},
|
|
204
|
+
close() {
|
|
205
|
+
lb.close();
|
|
206
|
+
},
|
|
207
|
+
update(next = {}) {
|
|
208
|
+
opts = { ...opts, ...next };
|
|
209
|
+
if (next.value !== undefined)
|
|
210
|
+
value = next.value;
|
|
211
|
+
lb.update({ placement: opts.placement });
|
|
212
|
+
render();
|
|
213
|
+
},
|
|
214
|
+
destroy() {
|
|
215
|
+
lb.destroy();
|
|
216
|
+
trigger.removeEventListener('keydown', onKeydown, true);
|
|
217
|
+
trigger.removeEventListener('click', onClick);
|
|
218
|
+
list.removeEventListener('fs-select', onAccepted);
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** The words a range needs: each thumb's accessible name. */
|
|
2
|
+
export interface SliderLabels {
|
|
3
|
+
/** The lower thumb's name ("From"). */
|
|
4
|
+
start: string;
|
|
5
|
+
/** The upper thumb's name ("To"). */
|
|
6
|
+
end: string;
|
|
7
|
+
}
|
|
8
|
+
interface SliderBaseOptions {
|
|
9
|
+
min: number;
|
|
10
|
+
max: number;
|
|
11
|
+
/** Values snap to `step` from `min`. Default 1. */
|
|
12
|
+
step?: number;
|
|
13
|
+
/** PageUp/PageDown's step. Default ten steps. */
|
|
14
|
+
pageStep?: number;
|
|
15
|
+
/** The value in words, for `aria-valuetext` and the `__value` output ("40 %"). */
|
|
16
|
+
valueText: (value: number) => string;
|
|
17
|
+
}
|
|
18
|
+
export interface SliderOptions extends SliderBaseOptions {
|
|
19
|
+
value: number;
|
|
20
|
+
}
|
|
21
|
+
export interface RangeSliderOptions extends SliderBaseOptions {
|
|
22
|
+
/** The two ends, lower first (fixed as a range at creation, as the calendar's `mode`). */
|
|
23
|
+
value: readonly [number, number];
|
|
24
|
+
labels: SliderLabels;
|
|
25
|
+
}
|
|
26
|
+
export interface SliderChangeDetail {
|
|
27
|
+
value: number;
|
|
28
|
+
}
|
|
29
|
+
export interface RangeSliderChangeDetail {
|
|
30
|
+
value: [number, number];
|
|
31
|
+
}
|
|
32
|
+
export interface Slider {
|
|
33
|
+
readonly value: number;
|
|
34
|
+
/** Sets the value (snapped and clamped) without an event. */
|
|
35
|
+
setValue(value: number): void;
|
|
36
|
+
update(options: Partial<Omit<SliderOptions, 'value'>>): void;
|
|
37
|
+
/** Removes every listener and ends a drag, silently (T88). */
|
|
38
|
+
destroy(): void;
|
|
39
|
+
}
|
|
40
|
+
export interface RangeSlider {
|
|
41
|
+
readonly value: [number, number];
|
|
42
|
+
/** Sets both ends (snapped, clamped and ordered) without an event. */
|
|
43
|
+
setValue(value: readonly [number, number]): void;
|
|
44
|
+
update(options: Partial<Omit<RangeSliderOptions, 'value'>>): void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
|
47
|
+
/** A range's `__value` text: both ends' words. */
|
|
48
|
+
export declare const rangeValueText: (low: string, high: string) => string;
|
|
49
|
+
export declare function createSlider(root: HTMLElement, options: RangeSliderOptions): RangeSlider;
|
|
50
|
+
export declare function createSlider(root: HTMLElement, options: SliderOptions): Slider;
|
|
51
|
+
export {};
|