@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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,46 @@
|
|
|
3
3
|
Written by hand for each release. Token names, class names, file paths and exports are the
|
|
4
4
|
public API. While the kit is 0.x, a minor version may break them, and its entry says so.
|
|
5
5
|
|
|
6
|
+
## 0.11.0 — 2026-11-16
|
|
7
|
+
|
|
8
|
+
Nothing breaks. New blocks and React exports, so this is a minor release.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Switch (T131):** `.fs-switch` (`css/switch.css`), a native `<input type="checkbox" role="switch"
|
|
13
|
+
class="fs-switch__input">` drawn as a pill track with a knob, with a `__label` and an `--end` variant (label first,
|
|
14
|
+
switch at the row's end). Hover, focus, checked, disabled and busy (`aria-busy` on the row); 28 × 16 px at dense and
|
|
15
|
+
compact, 36 × 20 at comfortable (`--fs-switch-w`, `--fs-switch-h`); the knob slides in `--fs-dur` and its place says
|
|
16
|
+
the state; forced colours draw it in system colours. React `Switch` (`label`, `labelPosition`, `busy` and the
|
|
17
|
+
native checkbox props). The usage note says when to use a switch (it acts at once) and when a checkbox (a choice
|
|
18
|
+
applied by a later button).
|
|
19
|
+
- **Custom select (T132):** `.fs-select--listbox` (`css/select.css`), a select-only combobox: a `role="combobox"`
|
|
20
|
+
trigger drawn as the native select, opening a `.fs-menu--listbox`. `createSelect(root, { trigger, list, … })` over
|
|
21
|
+
`createListbox` adds the closed-state keys, Space, typeahead, no wrap and the value mark; it fires `fs-change` when
|
|
22
|
+
the value changes. Read-only and disabled triggers; with a `name`, a hidden input holds the value. React
|
|
23
|
+
`ListboxSelect` (controlled `value`/`open` with `default*` twins). `createListbox` takes a `wrap` option (default
|
|
24
|
+
`true`, so the completion list is unchanged).
|
|
25
|
+
- **Editable combobox (T133):** `.fs-combobox` (`css/combobox.css`), a text input with list autocomplete: an
|
|
26
|
+
`.fs-input` with `role="combobox"`, an optional toggle button and a `.fs-menu--listbox` popup, whose options may sit
|
|
27
|
+
in named groups. `createCombobox(root, { input, list, toggle?, … })` over `createListbox` adds the closed-state keys,
|
|
28
|
+
the toggle, `clearOnEscape`, `strict` and `optionValue`; accepting an option writes its value into the input and
|
|
29
|
+
fires `fs-change { value, option }`. The product filters the options. React `Combobox` (controlled `value`/`open`
|
|
30
|
+
with `default*` twins, `onInputChange` for filtering, items or groups). `createListbox` takes a `homeEnd` option
|
|
31
|
+
(default `'options'`, so the completion list and the custom select are unchanged; the combobox passes `'caret'`).
|
|
32
|
+
- **Slider and range slider (T134):** `.fs-slider` (`css/slider.css`), a `__track` with a `__fill`, optional `__ticks`
|
|
33
|
+
and one `role="slider"` `__thumb`, or two in `--range`, and an optional `__value` output. `createSlider(root, { min,
|
|
34
|
+
max, step?, pageStep?, value, valueText, labels? })` takes a number, or `[low, high]` with `labels.start`/`end` for a
|
|
35
|
+
range: the APG keys (Right and Left swap right to left), step snapping, pointer dragging with pointer capture, two
|
|
36
|
+
dependent thumbs that never cross; it fires the new event `fs-input { value }` while moving and `fs-change { value }`
|
|
37
|
+
when a move ends. With hidden inputs in the root, they hold the values. React `Slider` and `RangeSlider` (controlled
|
|
38
|
+
`value` with a `defaultValue` twin, `onInput`, `onChange`, `showValue`, `ticks`, `name`).
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- **A quick second change kept (I25):** a controlled React `Calendar`, `DateRangeCalendar`, `SegmentedControl`,
|
|
43
|
+
`Tabs`, `TabBar` or `Tree` no longer undoes a second pick or key made before the parent re-rendered: a value the
|
|
44
|
+
parent didn't take is put back after its render, not before.
|
|
45
|
+
|
|
6
46
|
## 0.10.3 — 2026-11-15
|
|
7
47
|
|
|
8
48
|
Nothing breaks. Two colours change: in dark, the checked checkbox and radio mark is navy instead of white; in light,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* Editable combobox (spec 02 B; F2 draft §1, T133): a text input with list autocomplete. Usage:
|
|
2
|
+
combobox.md. Behaviour: createCombobox. The input is a plain .fs-input (input.css: height, fill,
|
|
3
|
+
edge, hover, ring, invalid, read-only, disabled); the popup is the completion list's
|
|
4
|
+
.fs-menu--listbox (menu.css), grouped options included. */
|
|
5
|
+
@layer fs.components {
|
|
6
|
+
.fs-combobox {
|
|
7
|
+
position: relative;
|
|
8
|
+
display: block;
|
|
9
|
+
min-width: 0;
|
|
10
|
+
}
|
|
11
|
+
/* Room for the toggle at the input's end. */
|
|
12
|
+
.fs-combobox:has(> .fs-combobox__toggle) > .fs-input {
|
|
13
|
+
padding-right: calc(var(--fs-size-touch) + var(--fs-space-1));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* The toggle: a row icon button (24 px target) inside the input's end, out of the tab order. Its
|
|
17
|
+
chevron is a mask on currentColor, as the select's, so it follows the system colours. */
|
|
18
|
+
.fs-combobox__toggle {
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: calc((var(--fs-control-h) - var(--fs-size-touch)) / 2);
|
|
21
|
+
right: calc((var(--fs-control-h) - var(--fs-size-touch)) / 2);
|
|
22
|
+
}
|
|
23
|
+
.fs-combobox__toggle::before {
|
|
24
|
+
content: '';
|
|
25
|
+
width: 16px;
|
|
26
|
+
height: 16px;
|
|
27
|
+
background-color: currentColor;
|
|
28
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
|
|
29
|
+
center / contain no-repeat;
|
|
30
|
+
}
|
|
31
|
+
.fs-combobox__toggle[aria-expanded='true']::before {
|
|
32
|
+
transform: rotate(180deg);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Read-only: no toggle (the input already has no edge). */
|
|
36
|
+
.fs-combobox:has(> .fs-input:read-only:not(:disabled)) > .fs-combobox__toggle {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Disabled last: by colour, never opacity; the toggle takes no presses. */
|
|
41
|
+
.fs-combobox:has(> .fs-input:disabled) > .fs-combobox__toggle {
|
|
42
|
+
color: var(--fs-ink-disabled);
|
|
43
|
+
background-color: transparent;
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
pointer-events: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Forced colours: the current option keeps a Highlight outline (the input and the chevron are
|
|
49
|
+
drawn by the system already); a disabled toggle is GrayText. */
|
|
50
|
+
@media (forced-colors: active) {
|
|
51
|
+
.fs-combobox .fs-menu__item[aria-selected='true'] {
|
|
52
|
+
outline-color: Highlight;
|
|
53
|
+
}
|
|
54
|
+
.fs-combobox:has(> .fs-input:disabled) > .fs-combobox__toggle {
|
|
55
|
+
color: GrayText;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Editable combobox — `.fs-combobox`
|
|
2
|
+
|
|
3
|
+
Spec 02 B (F2 draft §1, T133). CSS: `css/combobox.css`, on top of `css/input.css` (the input),
|
|
4
|
+
`css/icon-button.css` (the toggle) and `css/menu.css` (the popup); `kit.css` has all of them.
|
|
5
|
+
Behaviour: `createCombobox(root, { input, list, toggle? })`. React: `Combobox`. Gallery: `inputs.html`.
|
|
6
|
+
|
|
7
|
+
A text input with list autocomplete: the user types, the product filters the options, and an
|
|
8
|
+
option can be picked or the text kept. For a fixed set of options with no typing, use the native
|
|
9
|
+
select or the custom select ([select.md](select.md)).
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<label class="fs-field__label" for="metric">Metric</label>
|
|
13
|
+
<div class="fs-combobox">
|
|
14
|
+
<input class="fs-input" id="metric" role="combobox" autocomplete="off" />
|
|
15
|
+
<button class="fs-icon-button fs-icon-button--row fs-combobox__toggle" type="button" tabindex="-1" aria-label="Show metrics"></button>
|
|
16
|
+
<div class="fs-menu fs-menu--listbox" role="listbox" id="metric-list" aria-label="Metrics" hidden>
|
|
17
|
+
<div role="group" aria-labelledby="metric-g1">
|
|
18
|
+
<div class="fs-menu__group-label" id="metric-g1" role="presentation">Sales</div>
|
|
19
|
+
<div class="fs-menu__item" role="option" id="m-revenue"><span class="fs-menu__label">Revenue</span><span class="fs-menu__detail">EUR</span></div>
|
|
20
|
+
<div class="fs-menu__item" role="option" id="m-margin"><span class="fs-menu__label">Margin</span><span class="fs-menu__detail">%</span></div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<!-- No matches: one <div class="fs-menu__empty" role="option" aria-disabled="true">No matches</div> in the list. -->
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { createCombobox } from '@finstack-com-public/design/dom/combobox';
|
|
29
|
+
const combo = createCombobox(rootEl, { input: inputEl, list: listEl, toggle: toggleEl });
|
|
30
|
+
inputEl.addEventListener('input', () => {
|
|
31
|
+
renderOptions(filter(inputEl.value)); // the product filters; the kit never does
|
|
32
|
+
combo.update();
|
|
33
|
+
combo.open();
|
|
34
|
+
});
|
|
35
|
+
rootEl.addEventListener('fs-change', (e) => save(e.detail.value, e.detail.option)); // accepted, or cleared
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **Parts.** The input is a plain `.fs-input` with `role="combobox"`, named by its field's `<label for>`;
|
|
39
|
+
the helper sets `aria-autocomplete` (`'list'`, or `'none'` when the options don't follow the
|
|
40
|
+
text), `aria-controls`, `aria-expanded` and `aria-activedescendant`. The toggle is optional: an
|
|
41
|
+
empty `.fs-icon-button--row` button whose chevron the CSS draws; give it `tabindex="-1"` (out of
|
|
42
|
+
the tab order, APG) and an `aria-label`. The list sits inside the root; the helper shows it in
|
|
43
|
+
the top layer, at least the input's width.
|
|
44
|
+
- **Groups** (T133 C1). Options may sit in `role="group"` elements named by a
|
|
45
|
+
`.fs-menu__group-label` (`role="presentation"`, as in a menu); the keys move across groups.
|
|
46
|
+
- **Keys** (F2 draft §1, APG list autocomplete). Closed: Down opens on the first option (or one
|
|
47
|
+
marked `aria-selected`), Alt+Down opens with none current, Up opens on the last; Escape clears
|
|
48
|
+
the input with `clearOnEscape`. Open: Up/Down move (wrapping), Enter or a click accepts, Tab
|
|
49
|
+
accepts and moves on, Escape or Alt+Up closes. Home, End, Left and Right always move the caret.
|
|
50
|
+
A press on the toggle opens or closes the list; focus stays in the input.
|
|
51
|
+
- **Typing** is the product's: on the native `input` event it filters the options, calls
|
|
52
|
+
`update()` and opens the list (with the `__empty` line when nothing matches, and its own live
|
|
53
|
+
region if it says how many). Typing fires no `fs-change`.
|
|
54
|
+
- **Accepting** writes `optionValue(option)` into the input (default: its `__label` text) and fires
|
|
55
|
+
`fs-change { value, option }` on the root. The helper fires no native `input` event, so refilter
|
|
56
|
+
on `fs-change` too. createListbox's `fs-select` stays inside.
|
|
57
|
+
- **Free text** is allowed and read from the input. With `strict`, a commit (leaving the input, or
|
|
58
|
+
Enter, after typing) whose text matches an enabled option's value, ignoring case, is accepted as
|
|
59
|
+
that option; other text fires `fs-change` with `option: null`, and the product sets
|
|
60
|
+
`aria-invalid="true"` and says why in the field's message.
|
|
61
|
+
- No `aria-autocomplete="both"` (inline completion) and no multi-select (T133 C2, C3; F10).
|
|
62
|
+
- Not form-associated beyond the input itself: its `name` and text go with the form.
|
|
63
|
+
|
|
64
|
+
| State | Set it with | Look |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| hover, focus | the browser | as `.fs-input`: darker edge; the ring (D15) |
|
|
67
|
+
| expanded | `aria-expanded="true"` (the helper sets it, and mirrors it on the toggle) | the toggle's chevron turns over |
|
|
68
|
+
| invalid | `aria-invalid="true"` on the input | danger edge (pair it with a message) |
|
|
69
|
+
| disabled | `disabled` on the input | disabled fill and ink, never opacity; the toggle greys out and takes no presses |
|
|
70
|
+
| read-only | `readonly` on the input | no edge, no toggle; never opens |
|
|
71
|
+
| current option | `aria-selected="true"` (the helper sets it) | the completion list's tint and inside ring |
|
|
72
|
+
| group | `role="group"` with a `__group-label` | the menu's caps label |
|
|
73
|
+
|
|
74
|
+
In forced colours the input and the toggle are drawn by the system, the chevron follows
|
|
75
|
+
`ButtonText`, the current option keeps a `Highlight` outline, and a disabled toggle is `GrayText`.
|
package/dist/css/input.md
CHANGED
|
@@ -10,7 +10,12 @@ Spec 02 B. CSS: `css/input.css`. Gallery: `inputs.html`.
|
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
- **Select:** the native `<select>` sits in a `.fs-select` wrapper, which draws the chevron: a
|
|
13
|
-
`<select>` can't hold a pseudo-element.
|
|
13
|
+
`<select>` can't hold a pseudo-element. For options with an icon, a detail or a long list, the
|
|
14
|
+
custom select `.fs-select--listbox` is in [select.md](select.md).
|
|
15
|
+
- **Combobox:** a text input whose typing filters a list of options to pick from is the editable
|
|
16
|
+
combobox `.fs-combobox`, in [combobox.md](combobox.md).
|
|
17
|
+
- **Slider:** a number picked by dragging along a track, or a range between two thumbs, is the
|
|
18
|
+
slider `.fs-slider`, in [slider.md](slider.md); a value typed exactly stays an `fs-input--num`.
|
|
14
19
|
- `fs-input--num` right-aligns with tabular figures; the number comes formatted from the product.
|
|
15
20
|
- `fs-input--picker` on a `<button>` makes a field that opens a picker (tree, chips, calendar). It
|
|
16
21
|
keeps the input's fill and edge: a button is `:read-only` to CSS, and the read-only look leaves
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* Custom select (spec 02 B; F2 draft §2, T132): a select-only combobox. Usage: select.md.
|
|
2
|
+
Behaviour: createSelect. The trigger also carries .fs-select__control (input.css), so it takes the
|
|
3
|
+
native select's height, fill, edge, hover, ring and invalid edge; the popup is the completion
|
|
4
|
+
list's .fs-menu--listbox (menu.css). */
|
|
5
|
+
@layer fs.components {
|
|
6
|
+
.fs-select__trigger {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
min-width: 0;
|
|
10
|
+
text-align: left;
|
|
11
|
+
user-select: none;
|
|
12
|
+
}
|
|
13
|
+
.fs-select__value,
|
|
14
|
+
.fs-select__placeholder {
|
|
15
|
+
flex: 1 1 auto;
|
|
16
|
+
min-width: 0;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
text-overflow: ellipsis;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
}
|
|
21
|
+
.fs-select__placeholder {
|
|
22
|
+
color: var(--fs-ink-muted);
|
|
23
|
+
}
|
|
24
|
+
/* The chevron sits in the trigger's row, whatever else the wrapper holds (the list, a hidden input). */
|
|
25
|
+
.fs-select--listbox::after {
|
|
26
|
+
bottom: auto;
|
|
27
|
+
margin: 0;
|
|
28
|
+
top: calc((var(--fs-control-h) - 16px) / 2);
|
|
29
|
+
}
|
|
30
|
+
.fs-select--listbox:has(> [aria-expanded='true'])::after {
|
|
31
|
+
transform: rotate(180deg);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* The value's option: weight 600 and a 16 px check at its end (aria-selected marks only the
|
|
35
|
+
current option while open, APG). Every option keeps the check's column, so rows line up. */
|
|
36
|
+
.fs-select--listbox .fs-menu__item[role='option']::after {
|
|
37
|
+
content: '';
|
|
38
|
+
flex: none;
|
|
39
|
+
width: 16px;
|
|
40
|
+
height: 16px;
|
|
41
|
+
margin-left: var(--fs-space-2);
|
|
42
|
+
}
|
|
43
|
+
.fs-select--listbox .fs-menu__item[role='option']:not(:has(.fs-menu__detail))::after {
|
|
44
|
+
margin-left: auto;
|
|
45
|
+
}
|
|
46
|
+
.fs-select--listbox .fs-menu__item.fs-is-value {
|
|
47
|
+
font-weight: var(--fs-weight-semibold);
|
|
48
|
+
}
|
|
49
|
+
.fs-select--listbox .fs-menu__item.fs-is-value::after {
|
|
50
|
+
background-color: var(--fs-accent);
|
|
51
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")
|
|
52
|
+
center / contain no-repeat;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Read-only: no edge, no chevron, the value in full ink (as a read-only input). */
|
|
56
|
+
.fs-select__trigger[aria-readonly='true'] {
|
|
57
|
+
background-color: transparent;
|
|
58
|
+
border-color: transparent;
|
|
59
|
+
cursor: default;
|
|
60
|
+
}
|
|
61
|
+
.fs-select--listbox:has(> [aria-readonly='true'])::after {
|
|
62
|
+
content: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Disabled last: by colour, never opacity. It stays focusable (aria-disabled). */
|
|
66
|
+
.fs-select__trigger[aria-disabled='true'] {
|
|
67
|
+
color: var(--fs-ink-disabled);
|
|
68
|
+
background-color: var(--fs-bg-disabled);
|
|
69
|
+
border-color: var(--fs-line);
|
|
70
|
+
cursor: not-allowed;
|
|
71
|
+
}
|
|
72
|
+
.fs-select__trigger[aria-disabled='true'] .fs-select__placeholder {
|
|
73
|
+
color: var(--fs-ink-disabled);
|
|
74
|
+
}
|
|
75
|
+
.fs-select--listbox:has(> [aria-disabled='true']) {
|
|
76
|
+
color: var(--fs-ink-disabled);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Forced colours: the trigger is a div, so the system draws no control edge for it: give it one.
|
|
80
|
+
The check is drawn in a system colour; the current option keeps the Highlight outline. */
|
|
81
|
+
@media (forced-colors: active) {
|
|
82
|
+
.fs-select__trigger {
|
|
83
|
+
border: var(--fs-line-width) solid ButtonText;
|
|
84
|
+
}
|
|
85
|
+
.fs-select__trigger[aria-readonly='true'] {
|
|
86
|
+
border-color: transparent;
|
|
87
|
+
}
|
|
88
|
+
.fs-select--listbox .fs-menu__item.fs-is-value::after {
|
|
89
|
+
background-color: CanvasText;
|
|
90
|
+
}
|
|
91
|
+
.fs-select--listbox .fs-menu__item[aria-selected='true'] {
|
|
92
|
+
outline-color: Highlight;
|
|
93
|
+
}
|
|
94
|
+
.fs-select__trigger[aria-disabled='true'],
|
|
95
|
+
.fs-select__trigger[aria-disabled='true'] .fs-select__placeholder {
|
|
96
|
+
color: GrayText;
|
|
97
|
+
border-color: GrayText;
|
|
98
|
+
}
|
|
99
|
+
.fs-select--listbox:has(> [aria-disabled='true'])::after {
|
|
100
|
+
background-color: GrayText;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Custom select — `.fs-select--listbox`
|
|
2
|
+
|
|
3
|
+
Spec 02 B (F2 draft §2, T132). CSS: `css/select.css`, on top of `css/input.css` (the trigger's look)
|
|
4
|
+
and `css/menu.css` (the popup); `kit.css` has all three. Behaviour: `createSelect(root, { trigger, list })`.
|
|
5
|
+
React: `ListboxSelect`. Gallery: `inputs.html`.
|
|
6
|
+
|
|
7
|
+
The native select (`.fs-select` around a `<select>`, see input.md) stays the default. This one is a
|
|
8
|
+
select-only combobox for options that need an icon, a detail, a disabled reason or a long list.
|
|
9
|
+
|
|
10
|
+
```html
|
|
11
|
+
<span class="fs-field__label" id="scenario-l">Scenario</span>
|
|
12
|
+
<div class="fs-select fs-select--listbox">
|
|
13
|
+
<div class="fs-select__control fs-select__trigger" role="combobox" tabindex="0" id="scenario" aria-labelledby="scenario-l scenario-v">
|
|
14
|
+
<span class="fs-select__value" id="scenario-v">Actual</span>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="fs-menu fs-menu--listbox" role="listbox" id="scenario-list" aria-label="Scenario" hidden>
|
|
17
|
+
<div class="fs-menu__item fs-is-value" role="option" id="sc-actual" data-value="actual"><span class="fs-menu__label">Actual</span></div>
|
|
18
|
+
<div class="fs-menu__item" role="option" id="sc-budget" data-value="budget">
|
|
19
|
+
<svg class="fs-icon" aria-hidden="true" …></svg><span class="fs-menu__label">Budget</span><span class="fs-menu__detail">2027</span>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="fs-menu__item" role="option" id="sc-archive" aria-disabled="true"><span class="fs-menu__label">Archive (read-only)</span></div>
|
|
22
|
+
</div>
|
|
23
|
+
<input type="hidden" name="scenario" value="actual" />
|
|
24
|
+
</div>
|
|
25
|
+
<!-- No value: <span class="fs-select__placeholder" id="scenario-v">Choose a scenario</span> in place of __value. -->
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { createSelect } from '@finstack-com-public/design/dom/select';
|
|
30
|
+
const select = createSelect(rootEl, { trigger: triggerEl, list: listEl });
|
|
31
|
+
rootEl.addEventListener('fs-change', (e) => save(e.detail.value)); // the option's id
|
|
32
|
+
select.setValue('sc-budget'); // no event
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- **Parts.** The trigger carries both `fs-select__control` (the native select's height, fill, edge,
|
|
36
|
+
hover, ring and invalid edge) and `fs-select__trigger`. It holds one span: `__value` (the option's
|
|
37
|
+
`__label` text, cut with "…") or `__placeholder` (muted). Keep its id: the trigger's
|
|
38
|
+
`aria-labelledby` names the field's label and then it, so the value is read with the name. The
|
|
39
|
+
list sits inside the root; the helper shows it in the top layer, at least the trigger's width.
|
|
40
|
+
- **Value.** The option holding it has `.fs-is-value`: weight 600 and a check at its end, since
|
|
41
|
+
`aria-selected` marks only the current option while open (APG). No `aria-checked` (T132 S3: screen
|
|
42
|
+
readers say it unevenly); the check and the trigger's text carry it. The helper writes the
|
|
43
|
+
mark, the trigger's span and, when the root holds one, the hidden input (`data-value`, else the
|
|
44
|
+
option's id; T132 S4). A framework that renders those itself passes `writeValue: false`.
|
|
45
|
+
- **Keys** (F2 draft §2, APG). Closed: Down, Alt+Down, Enter or Space open on the value; Up or Home
|
|
46
|
+
on the first option, End on the last; a letter opens on the first match. Open: Up/Down (no wrap),
|
|
47
|
+
Home/End, PageUp/PageDown (ten options); Enter, Space, Alt+Up or a click accept and close; Tab
|
|
48
|
+
accepts, closes and moves on; Escape closes with the value unchanged. Typed letters jump
|
|
49
|
+
(`typeaheadTimeout`, default 500 ms); one letter typed again cycles through its matches. A click
|
|
50
|
+
on the trigger toggles the list; a press outside or focus leaving closes it.
|
|
51
|
+
- **Events.** `fs-change { value }` on the root, only when the value changed. `fs-open` and
|
|
52
|
+
`fs-close` come from the list and bubble through the root; createListbox's `fs-select` stays inside.
|
|
53
|
+
- Disabled options (`aria-disabled="true"`) are skipped by the keys and typeahead and never accepted.
|
|
54
|
+
- Not form-associated (custom elements are out, D13): the hidden input is how a form sees it.
|
|
55
|
+
|
|
56
|
+
| State | Set it with | Look |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| hover, focus | the browser | darker edge; the ring (D15) |
|
|
59
|
+
| expanded | `aria-expanded="true"` (the helper sets it) | the chevron turns over |
|
|
60
|
+
| invalid | `aria-invalid="true"` on the trigger | danger edge (pair it with a message) |
|
|
61
|
+
| disabled | `aria-disabled="true"` on the trigger | disabled fill and ink, never opacity; stays focusable, never opens |
|
|
62
|
+
| read-only | `aria-readonly="true"` on the trigger | no edge, no chevron; never opens |
|
|
63
|
+
| placeholder | `__placeholder` in place of `__value` | muted ink |
|
|
64
|
+
| current option | `aria-selected="true"` (the helper sets it) | the completion list's tint and inside ring |
|
|
65
|
+
| value | `.fs-is-value` on its option | weight 600 and the accent check |
|
|
66
|
+
|
|
67
|
+
In forced colours the trigger gets a `ButtonText` edge (a `div` has no system control edge), the
|
|
68
|
+
check is drawn in `CanvasText`, the current option keeps a `Highlight` outline, and disabled is
|
|
69
|
+
`GrayText`.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/* Slider and range slider (spec 02 B; F2 draft §4, T134). Usage: slider.md. Behaviour: createSlider,
|
|
2
|
+
which writes each thumb's place (--fs-slider-at) and the fill's ends (--fs-slider-low, --fs-slider-high). */
|
|
3
|
+
@layer fs.components {
|
|
4
|
+
.fs-slider {
|
|
5
|
+
--fs-slider-track-h: 4px;
|
|
6
|
+
--fs-slider-thumb: var(--fs-icon-size);
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: var(--fs-space-3);
|
|
10
|
+
min-width: 0;
|
|
11
|
+
min-height: var(--fs-control-h);
|
|
12
|
+
font-size: var(--fs-text-body-size);
|
|
13
|
+
line-height: var(--fs-text-body-line);
|
|
14
|
+
/* A press starts a drag: the page must not scroll or select under it. */
|
|
15
|
+
touch-action: none;
|
|
16
|
+
user-select: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* The track: 4 px, no fill or label inside it, so --fs-line-control-strong (3:1, D30). Half a thumb
|
|
20
|
+
of room at each end keeps a thumb at the minimum or maximum inside the block. */
|
|
21
|
+
.fs-slider__track {
|
|
22
|
+
position: relative;
|
|
23
|
+
flex: 1 1 auto;
|
|
24
|
+
min-width: 0;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
height: var(--fs-slider-track-h);
|
|
27
|
+
margin-inline: calc(var(--fs-slider-thumb) / 2);
|
|
28
|
+
background: var(--fs-line-control-strong);
|
|
29
|
+
border-radius: var(--fs-radius-sm);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
/* The band from the minimum to the value, or between the two thumbs. */
|
|
33
|
+
.fs-slider__fill {
|
|
34
|
+
position: absolute;
|
|
35
|
+
inset-block: 0;
|
|
36
|
+
inset-inline-start: var(--fs-slider-low, 0%);
|
|
37
|
+
inset-inline-end: calc(100% - var(--fs-slider-high, 0%));
|
|
38
|
+
background: var(--fs-accent);
|
|
39
|
+
border-radius: inherit;
|
|
40
|
+
}
|
|
41
|
+
/* Marks at the steps the product names, under the track. */
|
|
42
|
+
.fs-slider__ticks {
|
|
43
|
+
position: absolute;
|
|
44
|
+
inset: 0;
|
|
45
|
+
pointer-events: none;
|
|
46
|
+
}
|
|
47
|
+
.fs-slider__ticks > * {
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: calc(var(--fs-slider-track-h) + 2px);
|
|
50
|
+
inset-inline-start: var(--fs-slider-at, 0%);
|
|
51
|
+
width: 1px;
|
|
52
|
+
height: 4px;
|
|
53
|
+
margin-inline-start: -0.5px;
|
|
54
|
+
background: var(--fs-line-control-strong);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* A thumb: a circle of the icon size (16 px, 20 at comfortable), a 2 px accent edge on the surface,
|
|
58
|
+
its centre on the value. Its hit area is padded to the 24 px touch target (spec 06 §1). */
|
|
59
|
+
.fs-slider__thumb {
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: 50%;
|
|
62
|
+
inset-inline-start: var(--fs-slider-at, 0%);
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
width: var(--fs-slider-thumb);
|
|
65
|
+
height: var(--fs-slider-thumb);
|
|
66
|
+
margin-block-start: calc(var(--fs-slider-thumb) / -2);
|
|
67
|
+
margin-inline-start: calc(var(--fs-slider-thumb) / -2);
|
|
68
|
+
background: var(--fs-bg-surface);
|
|
69
|
+
border: 2px solid var(--fs-accent);
|
|
70
|
+
border-radius: 50%;
|
|
71
|
+
cursor: grab;
|
|
72
|
+
}
|
|
73
|
+
.fs-slider__thumb::before {
|
|
74
|
+
content: '';
|
|
75
|
+
position: absolute;
|
|
76
|
+
inset: calc((var(--fs-slider-thumb) - var(--fs-size-touch)) / 2 - 2px);
|
|
77
|
+
border-radius: 50%;
|
|
78
|
+
}
|
|
79
|
+
/* --range: two thumbs. At one value, the focused one is on top. */
|
|
80
|
+
.fs-slider--range .fs-slider__thumb:focus {
|
|
81
|
+
z-index: 1;
|
|
82
|
+
}
|
|
83
|
+
@media (hover: hover) {
|
|
84
|
+
.fs-slider__thumb:hover {
|
|
85
|
+
border-color: var(--fs-accent-strong);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/* Dragging: the helper sets .fs-is-dragging for the whole drag (pointer capture ends :active early in some engines).
|
|
89
|
+
Two rules, not one list: the gallery clones a rule naming :active into a later sheet, and a list would take
|
|
90
|
+
.fs-is-dragging along, past the forced-colours rule below. */
|
|
91
|
+
.fs-slider__thumb.fs-is-dragging {
|
|
92
|
+
background: var(--fs-bg-selected);
|
|
93
|
+
border-color: var(--fs-accent-strong);
|
|
94
|
+
cursor: grabbing;
|
|
95
|
+
}
|
|
96
|
+
.fs-slider__thumb:active {
|
|
97
|
+
background: var(--fs-bg-selected);
|
|
98
|
+
border-color: var(--fs-accent-strong);
|
|
99
|
+
cursor: grabbing;
|
|
100
|
+
}
|
|
101
|
+
/* The ring recipe (D15). */
|
|
102
|
+
.fs-slider__thumb:focus-visible {
|
|
103
|
+
outline: var(--fs-ring-width) solid var(--fs-ring);
|
|
104
|
+
outline-offset: var(--fs-ring-halo-width);
|
|
105
|
+
box-shadow: 0 0 0 var(--fs-ring-halo-width) var(--fs-ring-halo);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* The value beside it: an <output>, in tabular figures so it doesn't jitter while moving. */
|
|
109
|
+
.fs-slider__value {
|
|
110
|
+
flex: none;
|
|
111
|
+
color: var(--fs-ink);
|
|
112
|
+
font-variant-numeric: tabular-nums;
|
|
113
|
+
white-space: nowrap;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Disabled comes last: by colour, never opacity. The thumbs stay reachable (aria-disabled). */
|
|
117
|
+
.fs-slider:has(.fs-slider__thumb[aria-disabled='true']) {
|
|
118
|
+
color: var(--fs-ink-disabled);
|
|
119
|
+
}
|
|
120
|
+
.fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__track {
|
|
121
|
+
background: var(--fs-line);
|
|
122
|
+
cursor: not-allowed;
|
|
123
|
+
}
|
|
124
|
+
.fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__fill {
|
|
125
|
+
background: var(--fs-ink-disabled);
|
|
126
|
+
}
|
|
127
|
+
.fs-slider__thumb[aria-disabled='true'] {
|
|
128
|
+
background: var(--fs-bg-disabled);
|
|
129
|
+
border-color: var(--fs-ink-disabled);
|
|
130
|
+
cursor: not-allowed;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Forced colours erase the fills: the track becomes a 1 px CanvasText edge, the fill Highlight, the
|
|
134
|
+
thumb a Canvas disc with a CanvasText edge, Highlight while focused or dragged; disabled GrayText.
|
|
135
|
+
The thumb's place carries the value, and __value says it. */
|
|
136
|
+
@media (forced-colors: active) {
|
|
137
|
+
.fs-slider__track {
|
|
138
|
+
background: Canvas;
|
|
139
|
+
border: 1px solid CanvasText;
|
|
140
|
+
}
|
|
141
|
+
.fs-slider__fill {
|
|
142
|
+
background: Highlight;
|
|
143
|
+
}
|
|
144
|
+
.fs-slider__ticks > * {
|
|
145
|
+
background: CanvasText;
|
|
146
|
+
}
|
|
147
|
+
.fs-slider__thumb {
|
|
148
|
+
background: Canvas;
|
|
149
|
+
border-color: CanvasText;
|
|
150
|
+
}
|
|
151
|
+
.fs-slider__thumb:focus-visible,
|
|
152
|
+
.fs-slider__thumb.fs-is-dragging {
|
|
153
|
+
border-color: Highlight;
|
|
154
|
+
}
|
|
155
|
+
.fs-slider:has(.fs-slider__thumb[aria-disabled='true']) {
|
|
156
|
+
color: GrayText;
|
|
157
|
+
}
|
|
158
|
+
.fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__track {
|
|
159
|
+
border-color: GrayText;
|
|
160
|
+
}
|
|
161
|
+
.fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__fill,
|
|
162
|
+
.fs-slider:has(.fs-slider__thumb[aria-disabled='true']) .fs-slider__ticks > * {
|
|
163
|
+
background: GrayText;
|
|
164
|
+
}
|
|
165
|
+
.fs-slider__thumb[aria-disabled='true'] {
|
|
166
|
+
border-color: GrayText;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Slider — `.fs-slider`
|
|
2
|
+
|
|
3
|
+
Spec 02 B (F2 draft §4, T134). CSS: `css/slider.css`. Behaviour: `createSlider(root, { min, max, value, valueText })`.
|
|
4
|
+
React: `Slider`, `RangeSlider`. Gallery: `inputs.html`.
|
|
5
|
+
|
|
6
|
+
A number picked by dragging a thumb along a track, or a range between two thumbs. Horizontal only;
|
|
7
|
+
no vertical sliders, labelled ticks or number box beside it (T134 Q3, F11). For a value typed
|
|
8
|
+
exactly, use `.fs-input` (numeric).
|
|
9
|
+
|
|
10
|
+
```html
|
|
11
|
+
<span class="fs-field__label" id="share-l">Share of revenue</span>
|
|
12
|
+
<div class="fs-slider">
|
|
13
|
+
<div class="fs-slider__track">
|
|
14
|
+
<div class="fs-slider__fill"></div>
|
|
15
|
+
<div class="fs-slider__thumb" role="slider" tabindex="0" aria-labelledby="share-l"></div>
|
|
16
|
+
</div>
|
|
17
|
+
<output class="fs-slider__value"></output>
|
|
18
|
+
<input type="hidden" name="share" />
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<span class="fs-field__label" id="years-l">Years</span>
|
|
22
|
+
<div class="fs-slider fs-slider--range" role="group" aria-labelledby="years-l">
|
|
23
|
+
<div class="fs-slider__track">
|
|
24
|
+
<div class="fs-slider__fill"></div>
|
|
25
|
+
<div class="fs-slider__ticks" aria-hidden="true"><span style="--fs-slider-at: 0%"></span><span style="--fs-slider-at: 50%"></span><span style="--fs-slider-at: 100%"></span></div>
|
|
26
|
+
<div class="fs-slider__thumb" role="slider" tabindex="0"></div>
|
|
27
|
+
<div class="fs-slider__thumb" role="slider" tabindex="0"></div>
|
|
28
|
+
</div>
|
|
29
|
+
<output class="fs-slider__value"></output>
|
|
30
|
+
</div>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { createSlider } from '@finstack-com-public/design/dom/slider';
|
|
35
|
+
const share = createSlider(shareEl, { min: 0, max: 100, step: 5, value: 40, valueText: (v) => `${v} %` });
|
|
36
|
+
shareEl.addEventListener('fs-input', (e) => preview(e.detail.value)); // while it moves
|
|
37
|
+
shareEl.addEventListener('fs-change', (e) => save(e.detail.value)); // a key press, or the pointer's release
|
|
38
|
+
const years = createSlider(yearsEl, {
|
|
39
|
+
min: 2020, max: 2030, value: [2024, 2027], valueText: String, labels: { start: 'From', end: 'To' },
|
|
40
|
+
});
|
|
41
|
+
share.setValue(60); // no event
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- **Parts.** `__track` (4 px, `--fs-slider-track-h`) holds `__fill` (the band from the minimum to the
|
|
45
|
+
value, or between the two thumbs), the optional `__ticks` and one `__thumb`, or two in `--range`.
|
|
46
|
+
`__value` is an optional `<output>` after the track, in tabular figures. A thumb is a circle of
|
|
47
|
+
the icon size (16 px; 20 at comfortable) with a 24 px hit area; the block is `--fs-control-h` high.
|
|
48
|
+
- **The helper writes the values.** It sets each thumb's `role="slider"`, `tabindex`,
|
|
49
|
+
`aria-valuenow`, `aria-valuemin`, `aria-valuemax` and `aria-valuetext` (the product's
|
|
50
|
+
`valueText(v)`: the kit holds no strings), its place `--fs-slider-at`, the fill's ends
|
|
51
|
+
`--fs-slider-low` and `--fs-slider-high` on the root, the `__value` text (a range's two texts
|
|
52
|
+
joined by " – ") and the root's hidden inputs (in thumb order). No `aria-orientation`: horizontal.
|
|
53
|
+
- **Names.** A single thumb is named by its field's label through `aria-labelledby` (a `<label for>`
|
|
54
|
+
can't name a `div`). A range's thumbs are named by `labels.start` and `labels.end` (required);
|
|
55
|
+
give the root `role="group"` named by the field's label, so "From, Years" is read in context.
|
|
56
|
+
- **A range's thumbs depend on each other** (APG Multi-Thumb Slider): the lower's `aria-valuemax` is
|
|
57
|
+
the upper's value and the upper's `aria-valuemin` the lower's, updated on every change; neither
|
|
58
|
+
crosses the other. Each thumb is its own tab stop, lower first, whatever their places.
|
|
59
|
+
- **Keys** (APG Slider). Right or Up one step up, Left or Down one step down; PageUp/PageDown
|
|
60
|
+
`pageStep` (default ten steps); Home/End the thumb's minimum/maximum (in a range, the other thumb).
|
|
61
|
+
In a right-to-left context (the root's computed `direction`) Right and Left swap.
|
|
62
|
+
- **Pointer.** A press on the track moves the nearer thumb there and starts a drag; a press on a
|
|
63
|
+
thumb grabs it where it was pressed. Two thumbs at one value: the first move picks the one free to
|
|
64
|
+
go that way. The drag uses pointer capture and `touch-action: none`; the thumb carries
|
|
65
|
+
`.fs-is-dragging` until the release.
|
|
66
|
+
- **Values** are numbers, snapped to `step` (default 1) from `min` and clamped to `min`/`max`; End
|
|
67
|
+
reaches a `max` off the step grid.
|
|
68
|
+
- **Events** (T134 Q4). `fs-input { value }` while it moves (each key press, each pointer move that
|
|
69
|
+
changes it); `fs-change { value }` when a move ends (each key press, or the pointer's release, if
|
|
70
|
+
the value changed). `value` is a number, or `[low, high]` for a range. `setValue`, `update` and
|
|
71
|
+
`destroy()` fire nothing; `destroy()` ends a drag and removes every listener.
|
|
72
|
+
- **Ticks** are marks the product places under the track: one empty child of `__ticks` each, at
|
|
73
|
+
`style="--fs-slider-at: <percent>"`, `aria-hidden` (the value text says the value).
|
|
74
|
+
- Not form-associated (custom elements are out, D13): the hidden inputs are how a form sees it.
|
|
75
|
+
|
|
76
|
+
| State | Set it with | Look |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| hover | the browser | the thumb's edge `accent-strong` |
|
|
79
|
+
| dragging | `.fs-is-dragging` (the helper sets it), or `:active` | thumb fill `bg-selected`, edge `accent-strong` |
|
|
80
|
+
| focus | the browser | the ring on the thumb (D15) |
|
|
81
|
+
| disabled | `aria-disabled="true"` on each thumb | track `line`, fill `ink-disabled`, thumb `bg-disabled` with an `ink-disabled` edge, never opacity; reachable, not movable |
|
|
82
|
+
|
|
83
|
+
Rest colours: track `line-control-strong` (3:1: no fill or label inside it, as the checkbox box,
|
|
84
|
+
D30), fill `accent`, thumb `bg-surface` with a 2 px `accent` edge. In forced colours the track
|
|
85
|
+
is a 1 px `CanvasText` edge, the fill `Highlight`, the thumb a `Canvas` disc with a `CanvasText`
|
|
86
|
+
edge, `Highlight` while focused or dragged, and disabled `GrayText`. A value is never colour alone:
|
|
87
|
+
the thumb's place and `__value` carry it.
|