@ac-kit/ui-common 0.1.0 → 0.2.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/README.md +327 -9
  3. package/dist/anchored/anchored.d.ts +19 -0
  4. package/dist/anchored/anchored.d.ts.map +1 -0
  5. package/dist/anchored/anchored.js +2 -0
  6. package/dist/anchored/anchored.js.map +1 -0
  7. package/dist/focus/typeahead.d.ts +112 -0
  8. package/dist/focus/typeahead.d.ts.map +1 -0
  9. package/dist/focus/typeahead.js +178 -0
  10. package/dist/focus/typeahead.js.map +1 -0
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +10 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/menu/menu.d.ts +157 -0
  16. package/dist/menu/menu.d.ts.map +1 -0
  17. package/dist/menu/menu.js +162 -0
  18. package/dist/menu/menu.js.map +1 -0
  19. package/dist/preact/_anchor.d.ts +13 -0
  20. package/dist/preact/_anchor.d.ts.map +1 -0
  21. package/dist/preact/_anchor.js +39 -0
  22. package/dist/preact/_anchor.js.map +1 -0
  23. package/dist/preact/_dom.d.ts +14 -0
  24. package/dist/preact/_dom.d.ts.map +1 -0
  25. package/dist/preact/_dom.js +31 -0
  26. package/dist/preact/_dom.js.map +1 -0
  27. package/dist/preact/_live-announcer.d.ts +26 -0
  28. package/dist/preact/_live-announcer.d.ts.map +1 -0
  29. package/dist/preact/_live-announcer.js +101 -0
  30. package/dist/preact/_live-announcer.js.map +1 -0
  31. package/dist/preact/index.d.ts +7 -0
  32. package/dist/preact/index.d.ts.map +1 -1
  33. package/dist/preact/index.js +7 -0
  34. package/dist/preact/index.js.map +1 -1
  35. package/dist/preact/knob.d.ts.map +1 -1
  36. package/dist/preact/knob.js +5 -13
  37. package/dist/preact/knob.js.map +1 -1
  38. package/dist/preact/menu-button.d.ts +117 -0
  39. package/dist/preact/menu-button.d.ts.map +1 -0
  40. package/dist/preact/menu-button.js +330 -0
  41. package/dist/preact/menu-button.js.map +1 -0
  42. package/dist/preact/progress-ring.d.ts +42 -0
  43. package/dist/preact/progress-ring.d.ts.map +1 -0
  44. package/dist/preact/progress-ring.js +26 -0
  45. package/dist/preact/progress-ring.js.map +1 -0
  46. package/dist/preact/slider.d.ts.map +1 -1
  47. package/dist/preact/slider.js +6 -4
  48. package/dist/preact/slider.js.map +1 -1
  49. package/dist/preact/spin-button.d.ts +67 -0
  50. package/dist/preact/spin-button.d.ts.map +1 -0
  51. package/dist/preact/spin-button.js +132 -0
  52. package/dist/preact/spin-button.js.map +1 -0
  53. package/dist/preact/tabs.d.ts +97 -0
  54. package/dist/preact/tabs.d.ts.map +1 -0
  55. package/dist/preact/tabs.js +264 -0
  56. package/dist/preact/tabs.js.map +1 -0
  57. package/dist/preact/toaster.d.ts +43 -0
  58. package/dist/preact/toaster.d.ts.map +1 -0
  59. package/dist/preact/toaster.js +356 -0
  60. package/dist/preact/toaster.js.map +1 -0
  61. package/dist/preact/toolbar.d.ts.map +1 -1
  62. package/dist/preact/toolbar.js +2 -8
  63. package/dist/preact/toolbar.js.map +1 -1
  64. package/dist/preact/tooltip.d.ts +67 -0
  65. package/dist/preact/tooltip.d.ts.map +1 -0
  66. package/dist/preact/tooltip.js +165 -0
  67. package/dist/preact/tooltip.js.map +1 -0
  68. package/dist/preact/tree.d.ts +93 -0
  69. package/dist/preact/tree.d.ts.map +1 -0
  70. package/dist/preact/tree.js +399 -0
  71. package/dist/preact/tree.js.map +1 -0
  72. package/dist/progress/progress.d.ts +51 -0
  73. package/dist/progress/progress.d.ts.map +1 -0
  74. package/dist/progress/progress.js +43 -0
  75. package/dist/progress/progress.js.map +1 -0
  76. package/dist/spin-button/spin-button.d.ts +110 -0
  77. package/dist/spin-button/spin-button.d.ts.map +1 -0
  78. package/dist/spin-button/spin-button.js +179 -0
  79. package/dist/spin-button/spin-button.js.map +1 -0
  80. package/dist/tabs/tabs.d.ts +157 -0
  81. package/dist/tabs/tabs.d.ts.map +1 -0
  82. package/dist/tabs/tabs.js +120 -0
  83. package/dist/tabs/tabs.js.map +1 -0
  84. package/dist/toast/toast-queue.d.ts +212 -0
  85. package/dist/toast/toast-queue.d.ts.map +1 -0
  86. package/dist/toast/toast-queue.js +290 -0
  87. package/dist/toast/toast-queue.js.map +1 -0
  88. package/dist/toast/toasts-obscure.d.ts +25 -0
  89. package/dist/toast/toasts-obscure.d.ts.map +1 -0
  90. package/dist/toast/toasts-obscure.js +30 -0
  91. package/dist/toast/toasts-obscure.js.map +1 -0
  92. package/dist/tooltip/tooltip.d.ts +183 -0
  93. package/dist/tooltip/tooltip.d.ts.map +1 -0
  94. package/dist/tooltip/tooltip.js +185 -0
  95. package/dist/tooltip/tooltip.js.map +1 -0
  96. package/dist/tree/tree.d.ts +302 -0
  97. package/dist/tree/tree.d.ts.map +1 -0
  98. package/dist/tree/tree.js +439 -0
  99. package/dist/tree/tree.js.map +1 -0
  100. package/package.json +22 -12
  101. package/styles.css +894 -3
@@ -0,0 +1,67 @@
1
+ import type { Callable } from "@ac-kit/core";
2
+ import type { ComponentChildren, JSX } from "preact";
3
+ import type { ControlTone } from "../tone.js";
4
+ /** Props of {@link SpinButton}. */
5
+ export type SpinButtonProps = {
6
+ /** Its accessible name, drawn above it unless `isLabelHidden`. */
7
+ label: string;
8
+ /** Name it without drawing `label`. Defaults to false. */
9
+ isLabelHidden?: boolean;
10
+ value: number;
11
+ /** Omit for no minimum. */
12
+ min?: number;
13
+ /** Omit for no maximum. */
14
+ max?: number;
15
+ /** Defaults to 1. */
16
+ step?: number;
17
+ /** What Page Up and Page Down move by. Defaults to ten steps. */
18
+ largeStep?: number;
19
+ /** The value as a person reads it, shown and announced. Defaults to `String`. */
20
+ format?: Callable<[value: number], string>;
21
+ /**
22
+ * Reads what a person typed: a number, or `undefined` when the text is not
23
+ * one. Giving it makes the value editable as text; without it, only the keys
24
+ * and the buttons change the value.
25
+ */
26
+ parse?: Callable<[text: string], number | undefined>;
27
+ /** A new value, once per key, button press or entry typed. */
28
+ onChange: Callable<[value: number]>;
29
+ /** The decrement button's accessible name: `"Decrease"`. */
30
+ decrementLabel: string;
31
+ /** The increment button's accessible name: `"Increase"`. */
32
+ incrementLabel: string;
33
+ /** Defaults to a minus sign. */
34
+ decrementIcon?: ComponentChildren;
35
+ /** Defaults to a plus sign. */
36
+ incrementIcon?: ComponentChildren;
37
+ /**
38
+ * The virtual keyboard of an editable one. Defaults to `numeric` for whole
39
+ * steps from a minimum of zero or more, `decimal` for other steps from such a
40
+ * minimum, and `text` when the value may be negative, which the numeric and
41
+ * decimal keyboards of some phones cannot type.
42
+ */
43
+ inputMode?: "numeric" | "decimal" | "text";
44
+ tone?: ControlTone;
45
+ disabled?: boolean;
46
+ id?: string;
47
+ class?: string;
48
+ };
49
+ /**
50
+ * A number stepped by keys and buttons (WAI-ARIA spinbutton pattern): Arrow Up
51
+ * and Down step it, Page Up and Down by ten steps, Home and End go to its
52
+ * minimum and maximum when it has them. With `parse`, the value is also typed:
53
+ * Enter or leaving the field commits it, snapped to the steps and the bounds,
54
+ * and Escape goes back to the value; text that is not a number is marked
55
+ * invalid and reverts. The − and + buttons are out of the tab order and never
56
+ * take focus (the field keeps it, and no phone keyboard opens), stop at the
57
+ * bounds, and announce the new value politely when focus is elsewhere, so a
58
+ * screen reader user pressing them hears it.
59
+ *
60
+ * For a count, a duration, a number of beats: a value whose steps people count.
61
+ * For a continuous setting, a `Slider` or a `Knob`.
62
+ *
63
+ * @throws {RangeError} When `step` or `largeStep` is not above zero, a bound is
64
+ * not finite, or `max` is not above `min`.
65
+ */
66
+ export declare function SpinButton(props: SpinButtonProps): JSX.Element;
67
+ //# sourceMappingURL=spin-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spin-button.d.ts","sourceRoot":"","sources":["../../src/preact/spin-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MA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AAE,MAAM,CAAC;CACf,CAAC;AA+BF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAmN9D"}
@@ -0,0 +1,132 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { useId, useLayoutEffect, useRef, useState } from "preact/hooks";
3
+ import { snapSpinButtonValue, spinButtonAttributes, spinButtonValue, } from "../spin-button/spin-button.js";
4
+ import { LiveAnnouncer_ } from "./_live-announcer.js";
5
+ import { joinClasses } from "./join-classes.js";
6
+ function defaultInputMode_(range) {
7
+ const { min, step } = range;
8
+ if (min === undefined || min < 0) {
9
+ return "text";
10
+ }
11
+ return Number.isInteger(step) && Number.isInteger(min)
12
+ ? "numeric"
13
+ : "decimal";
14
+ }
15
+ function minusIcon_() {
16
+ return (_jsx("svg", { viewBox: "0 0 16 16", focusable: "false", children: _jsx("path", { d: "M3 8h10" }) }));
17
+ }
18
+ function plusIcon_() {
19
+ return (_jsx("svg", { viewBox: "0 0 16 16", focusable: "false", children: _jsx("path", { d: "M3 8h10M8 3v10" }) }));
20
+ }
21
+ /**
22
+ * A number stepped by keys and buttons (WAI-ARIA spinbutton pattern): Arrow Up
23
+ * and Down step it, Page Up and Down by ten steps, Home and End go to its
24
+ * minimum and maximum when it has them. With `parse`, the value is also typed:
25
+ * Enter or leaving the field commits it, snapped to the steps and the bounds,
26
+ * and Escape goes back to the value; text that is not a number is marked
27
+ * invalid and reverts. The − and + buttons are out of the tab order and never
28
+ * take focus (the field keeps it, and no phone keyboard opens), stop at the
29
+ * bounds, and announce the new value politely when focus is elsewhere, so a
30
+ * screen reader user pressing them hears it.
31
+ *
32
+ * For a count, a duration, a number of beats: a value whose steps people count.
33
+ * For a continuous setting, a `Slider` or a `Knob`.
34
+ *
35
+ * @throws {RangeError} When `step` or `largeStep` is not above zero, a bound is
36
+ * not finite, or `max` is not above `min`.
37
+ */
38
+ export function SpinButton(props) {
39
+ const { label, isLabelHidden = false, value, min, max, step = 1, largeStep, format = String, parse, onChange, decrementLabel, incrementLabel, decrementIcon, incrementIcon, inputMode, tone, disabled = false, id, } = props;
40
+ const range = { min, max, step };
41
+ const labelId = useId();
42
+ const fieldId = useId();
43
+ const [draft, setDraft] = useState(undefined);
44
+ const field = useRef(null);
45
+ const announcer = useRef(undefined);
46
+ const pendingAnnouncement = useRef(undefined);
47
+ const base = spinButtonAttributes({
48
+ value,
49
+ range,
50
+ valueText: "",
51
+ disabled,
52
+ });
53
+ const shown = base["aria-valuenow"];
54
+ const attributes = { ...base, "aria-valuetext": format(shown) };
55
+ const parsed = draft === undefined ? undefined : parse?.(draft);
56
+ const isDraftValid = parsed !== undefined && Number.isFinite(parsed);
57
+ // Keys and buttons step from what was typed, when it is a number.
58
+ const from = isDraftValid ? snapSpinButtonValue(parsed, range) : shown;
59
+ useLayoutEffect(() => {
60
+ const pending = pendingAnnouncement.current;
61
+ pendingAnnouncement.current = undefined;
62
+ if (pending !== undefined && pending === value) {
63
+ announcer.current ??= new LiveAnnouncer_(document);
64
+ announcer.current.announce([format(value)], "polite");
65
+ }
66
+ }, [value]);
67
+ useLayoutEffect(() => () => {
68
+ announcer.current?.[Symbol.dispose]();
69
+ announcer.current = undefined;
70
+ }, []);
71
+ const commitValue = (next) => {
72
+ if (next !== value) {
73
+ onChange(next);
74
+ }
75
+ };
76
+ const commitDraft = () => {
77
+ if (draft === undefined) {
78
+ return;
79
+ }
80
+ setDraft(undefined);
81
+ if (isDraftValid) {
82
+ commitValue(from);
83
+ }
84
+ };
85
+ const onKeyDown = (event) => {
86
+ if (disabled || event.altKey || event.ctrlKey || event.metaKey) {
87
+ return;
88
+ }
89
+ if (event.key === "Enter") {
90
+ commitDraft();
91
+ return;
92
+ }
93
+ if (event.key === "Escape") {
94
+ if (draft !== undefined) {
95
+ event.preventDefault();
96
+ setDraft(undefined);
97
+ }
98
+ return;
99
+ }
100
+ const next = spinButtonValue(from, event.key, range, { largeStep });
101
+ if (next === undefined) {
102
+ return;
103
+ }
104
+ event.preventDefault();
105
+ setDraft(undefined);
106
+ commitValue(next);
107
+ };
108
+ const name = isLabelHidden
109
+ ? { "aria-label": label }
110
+ : { "aria-labelledby": labelId };
111
+ const text = draft ?? attributes["aria-valuetext"];
112
+ const stepButton = (key, buttonLabel, icon, isAtBound) => (_jsx("button", { type: "button", class: `ack-spin-button-step ack-spin-button-${key === "ArrowUp" ? "increment" : "decrement"}`, tabIndex: -1, "aria-label": buttonLabel, "aria-controls": fieldId, disabled: disabled || isAtBound, onMouseDown: (event) => {
113
+ // The field keeps focus, and a phone opens no keyboard.
114
+ event.preventDefault();
115
+ }, onClick: () => {
116
+ const next = spinButtonValue(from, key, range, { largeStep }) ?? from;
117
+ setDraft(undefined);
118
+ if (next !== value && field.current !== document.activeElement) {
119
+ pendingAnnouncement.current = next;
120
+ }
121
+ commitValue(next);
122
+ }, children: _jsx("span", { class: "ack-spin-button-icon", "aria-hidden": "true", children: icon }) }));
123
+ return (_jsxs("div", { id: id, class: joinClasses("ack-control ack-spin-button", props.class), "data-tone": tone, "data-disabled": disabled ? "" : undefined, children: [!isLabelHidden &&
124
+ (parse === undefined ? (_jsx("span", { class: "ack-spin-button-label", id: labelId, children: label })) : (_jsx("label", { class: "ack-spin-button-label", id: labelId, for: fieldId, children: label }))), _jsxs("div", { class: "ack-spin-button-body", children: [stepButton("ArrowDown", decrementLabel, decrementIcon ?? minusIcon_(), min !== undefined && shown <= min), parse === undefined ? (_jsx("div", { ...attributes, ...name, id: fieldId, ref: (node) => {
125
+ field.current = node;
126
+ }, class: "ack-spin-button-field", tabIndex: disabled ? -1 : 0, onKeyDown: onKeyDown, children: text })) : (_jsx("input", { ...attributes, ...name, id: fieldId, ref: (node) => {
127
+ field.current = node;
128
+ }, class: "ack-spin-button-field", type: "text", inputMode: inputMode ?? defaultInputMode_(range), autoComplete: "off", spellcheck: false, readOnly: disabled, tabIndex: disabled ? -1 : 0, "aria-invalid": draft !== undefined && !isDraftValid ? "true" : undefined, value: text, onInput: (event) => {
129
+ setDraft(event.currentTarget.value);
130
+ }, onBlur: commitDraft, onKeyDown: onKeyDown })), stepButton("ArrowUp", incrementLabel, incrementIcon ?? plusIcon_(), max !== undefined && shown >= max)] })] }));
131
+ }
132
+ //# sourceMappingURL=spin-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spin-button.js","sourceRoot":"","sources":["../../src/preact/spin-button.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EAEN,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,GACf,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgDhD,SAAS,iBAAiB,CACzB,KAAsB;IAEtB,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAC5B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC;IACf,CAAC;IAED,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;QACrD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AAED,SAAS,UAAU;IAClB,OAAO,CACN,cAAK,OAAO,EAAC,WAAW,EAAC,SAAS,EAAC,OAAO,YACzC,eAAM,CAAC,EAAC,SAAS,GAAG,GACf,CACN,CAAC;AACH,CAAC;AAED,SAAS,SAAS;IACjB,OAAO,CACN,cAAK,OAAO,EAAC,WAAW,EAAC,SAAS,EAAC,OAAO,YACzC,eAAM,CAAC,EAAC,gBAAgB,GAAG,GACtB,CACN,CAAC;AACH,CAAC;AAED;;;;;;;;;;;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AAO,EACX,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;4BACb,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;wBACtB,CAAC,EACD,KAAK,EAAC,uBAAuB,EAC7B,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3B,SAAS,EAAE,SAAS,YAEnB,IAAI,GACA,CACN,CAAC,CAAC,CAAC,CACH,mBACK,UAAU,KACV,IAAI,EACR,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;4BACb,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;wBACtB,CAAC,EACD,KAAK,EAAC,uBAAuB,EAC7B,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,SAAS,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAChD,YAAY,EAAC,KAAK,EAClB,UAAU,EAAE,KAAK,EACjB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAE1B,KAAK,KAAK,SAAS,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAE1D,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;4BAClB,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;wBACrC,CAAC,EACD,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,SAAS,GACnB,CACF,EACA,UAAU,CACV,SAAS,EACT,cAAc,EACd,aAAa,IAAI,SAAS,EAAE,EAC5B,GAAG,KAAK,SAAS,IAAI,KAAK,IAAI,GAAG,CACjC,IACI,IACD,CACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,97 @@
1
+ import type { Callable } from "@ac-kit/core";
2
+ import { type ComponentChildren, type JSX } from "preact";
3
+ import { type TabsActivation, type TabsOrientation } from "../tabs/tabs.js";
4
+ /** Props of {@link Tabs}. */
5
+ export type TabsProps = {
6
+ /** The `value` of the tab whose panel shows. */
7
+ selected: string;
8
+ /** Called with the `value` of the tab the person chooses. */
9
+ onSelectedChange: Callable<[value: string]>;
10
+ /**
11
+ * `automatic` (the default) shows a tab's panel as soon as the arrow keys
12
+ * reach it; `manual` waits for Enter, Space or a click, for panels slow to
13
+ * show.
14
+ */
15
+ activation?: TabsActivation;
16
+ /** Defaults to `horizontal`. */
17
+ orientation?: TabsOrientation;
18
+ /**
19
+ * Lets Delete close the focused tab: called with its `value`; remove the tab
20
+ * and its panel in answer. Focus moves to the tab after it (else before);
21
+ * when it was the selected one, the nearest enabled tab after it (else
22
+ * before) is selected in its place. A disabled tab is not deleted.
23
+ */
24
+ onDelete?: Callable<[value: string]>;
25
+ /** A {@link TabList} and the {@link TabPanel}s. */
26
+ children: ComponentChildren;
27
+ id?: string;
28
+ class?: string;
29
+ };
30
+ /**
31
+ * Panels of content of which one shows at a time, chosen by a row (or column)
32
+ * of tabs (WAI-ARIA tabs pattern). The tab list is one tab stop, on the
33
+ * selected tab; the arrow keys along it move between tabs, going round, Home
34
+ * and End to the ends, mirrored right to left. Tab then reaches the panel, or
35
+ * the first control inside it. A disabled tab takes focus, so it can be found
36
+ * and read, and is never selected.
37
+ *
38
+ * Every panel stays rendered, the others `hidden="until-found"`: their state is
39
+ * kept, and the browser's find in page reveals a match in one by selecting its
40
+ * tab. The selection is the caller's: `selected` and `onSelectedChange`.
41
+ *
42
+ * @example
43
+ * <Tabs selected={tab} onSelectedChange={setTab}>
44
+ * <TabList label="Settings">
45
+ * <Tab value="sound">Sound</Tab>
46
+ * <Tab value="display">Display</Tab>
47
+ * </TabList>
48
+ * <TabPanel value="sound">…</TabPanel>
49
+ * <TabPanel value="display">…</TabPanel>
50
+ * </Tabs>;
51
+ */
52
+ export declare function Tabs(props: TabsProps): JSX.Element;
53
+ /** Props of {@link TabList}: its accessible name, as text or by reference. */
54
+ export type TabListProps = ({
55
+ label: string;
56
+ labelledBy?: undefined;
57
+ } | {
58
+ label?: undefined;
59
+ labelledBy: string;
60
+ }) & {
61
+ /** The {@link Tab}s. */
62
+ children: ComponentChildren;
63
+ class?: string;
64
+ };
65
+ /** The row, or column, of {@link Tab}s of a {@link Tabs}: the `tablist` role. */
66
+ export declare function TabList(props: TabListProps): JSX.Element;
67
+ /** Props of {@link Tab}. */
68
+ export type TabProps = {
69
+ /** Which {@link TabPanel} it shows; unique among the tabs. */
70
+ value: string;
71
+ /** Its label. */
72
+ children: ComponentChildren;
73
+ /** Drawn before the label, hidden from assistive technology. */
74
+ icon?: ComponentChildren;
75
+ /** Announced and focusable, but never selected. Defaults to false. */
76
+ disabled?: boolean;
77
+ class?: string;
78
+ };
79
+ /**
80
+ * A tab of a {@link TabList}: a `<button>` with the `tab` role, selected by a
81
+ * click or by the keys {@link Tabs} describes.
82
+ */
83
+ export declare function Tab(props: TabProps): JSX.Element;
84
+ /** Props of {@link TabPanel}. */
85
+ export type TabPanelProps = {
86
+ /** The `value` of the {@link Tab} that shows it. */
87
+ value: string;
88
+ children: ComponentChildren;
89
+ class?: string;
90
+ };
91
+ /**
92
+ * The content a {@link Tab} shows: the `tabpanel` role, named by its tab. In the
93
+ * tab order itself only when nothing inside it is, so Tab from the tab list
94
+ * reaches its content either way.
95
+ */
96
+ export declare function TabPanel(props: TabPanelProps): JSX.Element;
97
+ //# sourceMappingURL=tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/preact/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,iBAAiB,EAAiB,KAAK,GAAG,EAAE,MAAM,QAAQ,CAAC;AASzE,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,eAAe,EAKpB,MAAM,iBAAiB,CAAC;AAKzB,6BAA6B;AAC7B,MAAM,MA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,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,GAAG,CAAC,OAAO,CA0ChD;AAED,iCAAiC;AACjC,MAAM,MAAM,aAAa,GAAG;IAC3B,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,GAAG,CAAC,OAAO,CA0D1D"}
@@ -0,0 +1,264 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { createContext } from "preact";
3
+ import { useContext, useId, useLayoutEffect, useRef, useState, } from "preact/hooks";
4
+ import { tabAttributes, tabListAttributes, tabPanelAttributes, tabsKeyAction, } from "../tabs/tabs.js";
5
+ import { directionOf_, hasTabbable_ } from "./_dom.js";
6
+ import { joinClasses } from "./join-classes.js";
7
+ import { useElementBinding, useLatest } from "./use-element-binding.js";
8
+ const TabsContext_ = createContext(undefined);
9
+ function useTabsContext_(component) {
10
+ const context = useContext(TabsContext_);
11
+ if (context === undefined) {
12
+ throw new Error(`${component} must be inside Tabs`);
13
+ }
14
+ return context;
15
+ }
16
+ function tabsOf_(list) {
17
+ return [...list.querySelectorAll('[role="tab"]')].filter((tab) => tab.closest('[role="tablist"]') === list);
18
+ }
19
+ /**
20
+ * Panels of content of which one shows at a time, chosen by a row (or column)
21
+ * of tabs (WAI-ARIA tabs pattern). The tab list is one tab stop, on the
22
+ * selected tab; the arrow keys along it move between tabs, going round, Home
23
+ * and End to the ends, mirrored right to left. Tab then reaches the panel, or
24
+ * the first control inside it. A disabled tab takes focus, so it can be found
25
+ * and read, and is never selected.
26
+ *
27
+ * Every panel stays rendered, the others `hidden="until-found"`: their state is
28
+ * kept, and the browser's find in page reveals a match in one by selecting its
29
+ * tab. The selection is the caller's: `selected` and `onSelectedChange`.
30
+ *
31
+ * @example
32
+ * <Tabs selected={tab} onSelectedChange={setTab}>
33
+ * <TabList label="Settings">
34
+ * <Tab value="sound">Sound</Tab>
35
+ * <Tab value="display">Display</Tab>
36
+ * </TabList>
37
+ * <TabPanel value="sound">…</TabPanel>
38
+ * <TabPanel value="display">…</TabPanel>
39
+ * </Tabs>;
40
+ */
41
+ export function Tabs(props) {
42
+ const { selected, onSelectedChange, activation = "automatic", orientation = "horizontal", onDelete, children, id, } = props;
43
+ const baseId = useId();
44
+ const latestSelected = useLatest(selected);
45
+ const latestOnSelectedChange = useLatest(onSelectedChange);
46
+ const latestOnDelete = useLatest(onDelete);
47
+ const tabs = useRef(new Map());
48
+ const pendingFocus = useRef(undefined);
49
+ const [handlers] = useState(() => {
50
+ const isDisabled = (value) => {
51
+ for (const tab of tabs.current.values()) {
52
+ if (tab.value === value) {
53
+ return tab.isDisabled;
54
+ }
55
+ }
56
+ return false;
57
+ };
58
+ const select = (value) => {
59
+ if (value !== latestSelected.current && !isDisabled(value)) {
60
+ latestOnSelectedChange.current(value);
61
+ }
62
+ };
63
+ return {
64
+ ids: (value) => {
65
+ const key = encodeURIComponent(value);
66
+ return { tab: `${baseId}-tab-${key}`, panel: `${baseId}-panel-${key}` };
67
+ },
68
+ select,
69
+ delete: (elements, index) => {
70
+ const deleted = tabs.current.get(elements[index]);
71
+ const onDeleteNow = latestOnDelete.current;
72
+ if (deleted === undefined ||
73
+ deleted.isDisabled ||
74
+ onDeleteNow === undefined) {
75
+ return;
76
+ }
77
+ const neighbour = elements[index + 1] ?? elements[index - 1];
78
+ const next = neighbour === undefined ? undefined : tabs.current.get(neighbour);
79
+ pendingFocus.current = next?.value;
80
+ onDeleteNow(deleted.value);
81
+ if (deleted.value !== latestSelected.current) {
82
+ return;
83
+ }
84
+ // A panel stays shown: the nearest enabled tab after, else before.
85
+ const order = [
86
+ ...elements.slice(index + 1),
87
+ ...elements.slice(0, index).reverse(),
88
+ ];
89
+ for (const element of order) {
90
+ const candidate = tabs.current.get(element);
91
+ if (candidate !== undefined && !candidate.isDisabled) {
92
+ latestOnSelectedChange.current(candidate.value);
93
+ break;
94
+ }
95
+ }
96
+ },
97
+ };
98
+ });
99
+ const context = {
100
+ ...handlers,
101
+ selected,
102
+ activation,
103
+ orientation,
104
+ isDeletable: onDelete !== undefined,
105
+ tabs: tabs.current,
106
+ pendingFocus,
107
+ };
108
+ return (_jsx("div", { id: id, class: joinClasses("ack-control ack-tabs", props.class), "data-orientation": orientation, children: _jsx(TabsContext_.Provider, { value: context, children: children }) }));
109
+ }
110
+ /** The row, or column, of {@link Tab}s of a {@link Tabs}: the `tablist` role. */
111
+ export function TabList(props) {
112
+ const { children } = props;
113
+ const context = useTabsContext_("TabList");
114
+ const list = useRef(null);
115
+ const nameInput = props.label === undefined
116
+ ? { labelledBy: props.labelledBy }
117
+ : { label: props.label };
118
+ // The selected tab is the tab stop; while none is, the first enabled one.
119
+ useLayoutEffect(() => {
120
+ const element = list.current;
121
+ if (element === null) {
122
+ return;
123
+ }
124
+ const elements = tabsOf_(element);
125
+ let stop = elements.find((tab) => tab.getAttribute("aria-selected") === "true");
126
+ stop ??=
127
+ elements.find((tab) => tab.getAttribute("aria-disabled") !== "true") ??
128
+ elements[0];
129
+ for (const tab of elements) {
130
+ tab.tabIndex = tab === stop ? 0 : -1;
131
+ }
132
+ const pending = context.pendingFocus.current;
133
+ if (pending !== undefined) {
134
+ context.pendingFocus.current = undefined;
135
+ elements.find((tab) => context.tabs.get(tab)?.value === pending)?.focus();
136
+ }
137
+ });
138
+ return (_jsx("div", { ...tabListAttributes({ ...nameInput, orientation: context.orientation }), ref: list,
139
+ // A list wider than its box scrolls; the tabs scroll into view as they
140
+ // take focus, so the scroller takes no tab stop of its own (Firefox and
141
+ // Chromium give scrollers one).
142
+ tabIndex: -1, class: joinClasses("ack-tab-list", props.class), "data-orientation": context.orientation, onKeyDown: (event) => {
143
+ const element = event.currentTarget;
144
+ const elements = tabsOf_(element);
145
+ const target = event.target instanceof HTMLElement
146
+ ? event.target.closest('[role="tab"]')
147
+ : null;
148
+ const current = target === null ? -1 : elements.indexOf(target);
149
+ if (current === -1) {
150
+ return;
151
+ }
152
+ const action = tabsKeyAction({
153
+ key: event.key,
154
+ shiftKey: event.shiftKey,
155
+ ctrlKey: event.ctrlKey,
156
+ altKey: event.altKey,
157
+ metaKey: event.metaKey,
158
+ current,
159
+ count: elements.length,
160
+ orientation: context.orientation,
161
+ direction: directionOf_(element),
162
+ activation: context.activation,
163
+ isDisabled: (index) => context.tabs.get(elements[index])?.isDisabled === true,
164
+ isDeletable: context.isDeletable,
165
+ });
166
+ if (action === undefined) {
167
+ return;
168
+ }
169
+ switch (action.kind) {
170
+ case "focus": {
171
+ event.preventDefault();
172
+ const tab = elements[action.index];
173
+ tab.focus();
174
+ const value = context.tabs.get(tab)?.value;
175
+ if (action.selects && value !== undefined) {
176
+ context.select(value);
177
+ }
178
+ break;
179
+ }
180
+ case "select":
181
+ // A tab is a button: Enter and Space click it, which selects it.
182
+ break;
183
+ case "delete":
184
+ event.preventDefault();
185
+ context.delete(elements, current);
186
+ break;
187
+ }
188
+ }, children: children }));
189
+ }
190
+ /**
191
+ * A tab of a {@link TabList}: a `<button>` with the `tab` role, selected by a
192
+ * click or by the keys {@link Tabs} describes.
193
+ */
194
+ export function Tab(props) {
195
+ const { value, children, icon, disabled = false } = props;
196
+ const context = useTabsContext_("Tab");
197
+ const ids = context.ids(value);
198
+ const isSelected = value === context.selected;
199
+ const element = useRef(null);
200
+ useLayoutEffect(() => {
201
+ const tab = element.current;
202
+ if (tab === null) {
203
+ return undefined;
204
+ }
205
+ context.tabs.set(tab, { value, isDisabled: disabled });
206
+ return () => {
207
+ context.tabs.delete(tab);
208
+ };
209
+ }, [value, disabled, context.tabs]);
210
+ return (_jsxs("button", { ...tabAttributes({
211
+ panelId: ids.panel,
212
+ isSelected,
213
+ isTabStop: isSelected,
214
+ isDisabled: disabled,
215
+ }), type: "button", id: ids.tab, ref: element, class: joinClasses("ack-tab", props.class), onClick: () => {
216
+ context.select(value);
217
+ }, children: [icon !== undefined && (_jsx("span", { class: "ack-tab-icon", "aria-hidden": "true", children: icon })), _jsx("span", { class: "ack-tab-label", children: children })] }));
218
+ }
219
+ /**
220
+ * The content a {@link Tab} shows: the `tabpanel` role, named by its tab. In the
221
+ * tab order itself only when nothing inside it is, so Tab from the tab list
222
+ * reaches its content either way.
223
+ */
224
+ export function TabPanel(props) {
225
+ const { value, children } = props;
226
+ const context = useTabsContext_("TabPanel");
227
+ const ids = context.ids(value);
228
+ const isSelected = value === context.selected;
229
+ const [isFocusable, setIsFocusable] = useState(true);
230
+ const panel = useRef(null);
231
+ const latestSelect = useLatest(context.select);
232
+ const binding = useElementBinding((element, signal) => {
233
+ panel.current = element;
234
+ // Find in page reveals a match in a hidden panel: show it.
235
+ element.addEventListener("beforematch", () => {
236
+ latestSelect.current(value);
237
+ }, { signal });
238
+ const observer = new MutationObserver(() => {
239
+ setIsFocusable(!hasTabbable_(element));
240
+ });
241
+ observer.observe(element, {
242
+ childList: true,
243
+ subtree: true,
244
+ attributes: true,
245
+ attributeFilter: ["disabled", "tabindex", "hidden", "inert"],
246
+ });
247
+ return {
248
+ [Symbol.dispose]() {
249
+ observer.disconnect();
250
+ },
251
+ };
252
+ }, [value]);
253
+ useLayoutEffect(() => {
254
+ const element = panel.current;
255
+ if (element !== null && isSelected) {
256
+ setIsFocusable(!hasTabbable_(element));
257
+ }
258
+ });
259
+ return (_jsx("div", { ...tabPanelAttributes({
260
+ tabId: ids.tab,
261
+ isFocusable: isSelected && isFocusable,
262
+ }), id: ids.panel, ref: binding, hidden: isSelected ? undefined : "until-found", class: joinClasses("ack-tab-panel", props.class), children: children }));
263
+ }
264
+ //# sourceMappingURL=tabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/preact/tabs.tsx"],"names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AG,EAAE;YAC1C,cAAc,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE;YACzB,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,IAAI;YAChB,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC;SAC5D,CAAC,CAAC;QAEH,OAAO;YACN,CAAC,MAAM,CAAC,OAAO,CAAC;gBACf,QAAQ,CAAC,UAAU,EAAE,CAAC;YACvB,CAAC;SACD,CAAC;IACH,CAAC,EACD,CAAC,KAAK,CAAC,CACP,CAAC;IACF,eAAe,CAAC,GAAG,EAAE;QACpB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,IAAI,OAAO,KAAK,IAAI,IAAI,UAAU,EAAE,CAAC;YACpC,cAAc,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,CACN,iBACK,kBAAkB,CAAC;YACtB,KAAK,EAAE,GAAG,CAAC,GAAG;YACd,WAAW,EAAE,UAAU,IAAI,WAAW;SACtC,CAAC,EACF,EAAE,EAAE,GAAG,CAAC,KAAK,EACb,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EAC9C,KAAK,EAAE,WAAW,CAAC,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,YAE/C,QAAQ,GACJ,CACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type ComponentChildren, type JSX } from "preact";
2
+ import { type ToasterPosition, type ToastQueue } from "../toast/toast-queue.js";
3
+ /** Props of {@link Toaster}. */
4
+ export type ToasterProps = {
5
+ /** The toasts it shows: the caller's, shown through `queue.show`. */
6
+ queue: ToastQueue;
7
+ /** The region's accessible name; say its shortcut in it: "Notifications (F8)". */
8
+ label: string;
9
+ /** Each toast's close button's accessible name and title. */
10
+ closeLabel: string;
11
+ /** Defaults to `bottom-end`. */
12
+ position?: ToasterPosition;
13
+ /**
14
+ * The keys (`KeyboardEvent.key`, without modifiers) that take focus to the
15
+ * toasts, and back. Defaults to `["F8"]`.
16
+ */
17
+ hotkeys?: readonly string[];
18
+ /** The close buttons' icon. Defaults to a drawn ×. */
19
+ closeIcon?: ComponentChildren;
20
+ id?: string;
21
+ class?: string;
22
+ };
23
+ /**
24
+ * The region where a {@link ToastQueue}'s toasts show: a landmark in the top
25
+ * layer (a manual popover) at an edge of the viewport, above the page and the
26
+ * dialogs open before them.
27
+ *
28
+ * Each toast is announced by a live region as it shows, politely or, for an
29
+ * `assertive` one, at once — inside the open dialog holding focus when there is
30
+ * one, since a modal dialog hides the rest of the page from assistive
31
+ * technology. Toasts never take focus: F8 (`hotkeys`) does, to the region, and
32
+ * again back to where it was. Escape dismisses the toast holding focus; each
33
+ * toast has a close button, and its action, when it has one, dismisses it too.
34
+ *
35
+ * Clocks stop while the pointer is over the toasts, focus is among them or the
36
+ * page is hidden, so a person reading or reaching one does not see it go (WCAG
37
+ * 2.2.1). Toasts enter and leave with transitions that `prefers-reduced-motion:
38
+ * reduce` turns off.
39
+ *
40
+ * Render one per page, outside any dialog.
41
+ */
42
+ export declare function Toaster(props: ToasterProps): JSX.Element;
43
+ //# sourceMappingURL=toaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toaster.d.ts","sourceRoot":"","sources":["../../src/preact/toaster.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,iBAAiB,EAAgB,KAAK,GAAG,EAAE,MAAM,QAAQ,CAAC;AAGxE,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,UAAU,EAIf,MAAM,yBAAyB,CAAC;AAOjC,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG;IAC1B,qEAAqE;IACrE,KAAK,EAAE,UAAU,CAAC;IAClB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,sDAAsD;IACtD,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAkCF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CA2axD"}