@ac-kit/ui-common 0.1.0 → 0.3.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 (231) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/README.md +383 -9
  3. package/dist/adapter/_anchor.d.ts +13 -0
  4. package/dist/adapter/_anchor.d.ts.map +1 -0
  5. package/dist/adapter/_anchor.js +39 -0
  6. package/dist/adapter/_anchor.js.map +1 -0
  7. package/dist/adapter/_dom.d.ts +14 -0
  8. package/dist/adapter/_dom.d.ts.map +1 -0
  9. package/dist/adapter/_dom.js +31 -0
  10. package/dist/adapter/_dom.js.map +1 -0
  11. package/dist/adapter/_live-announcer.d.ts +26 -0
  12. package/dist/adapter/_live-announcer.d.ts.map +1 -0
  13. package/dist/adapter/_live-announcer.js +101 -0
  14. package/dist/adapter/_live-announcer.js.map +1 -0
  15. package/dist/adapter/join-classes.d.ts.map +1 -0
  16. package/dist/adapter/join-classes.js.map +1 -0
  17. package/dist/anchored/anchored.d.ts +19 -0
  18. package/dist/anchored/anchored.d.ts.map +1 -0
  19. package/dist/anchored/anchored.js +2 -0
  20. package/dist/anchored/anchored.js.map +1 -0
  21. package/dist/bit-grid/bit-grid.d.ts +151 -0
  22. package/dist/bit-grid/bit-grid.d.ts.map +1 -0
  23. package/dist/bit-grid/bit-grid.js +201 -0
  24. package/dist/bit-grid/bit-grid.js.map +1 -0
  25. package/dist/focus/typeahead.d.ts +112 -0
  26. package/dist/focus/typeahead.d.ts.map +1 -0
  27. package/dist/focus/typeahead.js +178 -0
  28. package/dist/focus/typeahead.js.map +1 -0
  29. package/dist/index.d.ts +12 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +12 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/menu/menu.d.ts +157 -0
  34. package/dist/menu/menu.d.ts.map +1 -0
  35. package/dist/menu/menu.js +162 -0
  36. package/dist/menu/menu.js.map +1 -0
  37. package/dist/preact/bit-grid.d.ts +39 -0
  38. package/dist/preact/bit-grid.d.ts.map +1 -0
  39. package/dist/preact/bit-grid.js +72 -0
  40. package/dist/preact/bit-grid.js.map +1 -0
  41. package/dist/preact/button.d.ts.map +1 -1
  42. package/dist/preact/button.js +1 -1
  43. package/dist/preact/button.js.map +1 -1
  44. package/dist/preact/dialog.d.ts.map +1 -1
  45. package/dist/preact/dialog.js +1 -1
  46. package/dist/preact/dialog.js.map +1 -1
  47. package/dist/preact/index.d.ts +10 -1
  48. package/dist/preact/index.d.ts.map +1 -1
  49. package/dist/preact/index.js +10 -1
  50. package/dist/preact/index.js.map +1 -1
  51. package/dist/preact/knob.d.ts.map +1 -1
  52. package/dist/preact/knob.js +6 -14
  53. package/dist/preact/knob.js.map +1 -1
  54. package/dist/preact/menu-button.d.ts +117 -0
  55. package/dist/preact/menu-button.d.ts.map +1 -0
  56. package/dist/preact/menu-button.js +330 -0
  57. package/dist/preact/menu-button.js.map +1 -0
  58. package/dist/preact/meter.d.ts.map +1 -1
  59. package/dist/preact/meter.js +1 -1
  60. package/dist/preact/meter.js.map +1 -1
  61. package/dist/preact/progress-ring.d.ts +42 -0
  62. package/dist/preact/progress-ring.d.ts.map +1 -0
  63. package/dist/preact/progress-ring.js +26 -0
  64. package/dist/preact/progress-ring.js.map +1 -0
  65. package/dist/preact/radio-group.d.ts.map +1 -1
  66. package/dist/preact/radio-group.js +1 -1
  67. package/dist/preact/radio-group.js.map +1 -1
  68. package/dist/preact/readout.d.ts.map +1 -1
  69. package/dist/preact/readout.js +1 -1
  70. package/dist/preact/readout.js.map +1 -1
  71. package/dist/preact/slider.d.ts.map +1 -1
  72. package/dist/preact/slider.js +7 -5
  73. package/dist/preact/slider.js.map +1 -1
  74. package/dist/preact/spin-button.d.ts +67 -0
  75. package/dist/preact/spin-button.d.ts.map +1 -0
  76. package/dist/preact/spin-button.js +132 -0
  77. package/dist/preact/spin-button.js.map +1 -0
  78. package/dist/preact/swatch-strip.d.ts +30 -0
  79. package/dist/preact/swatch-strip.d.ts.map +1 -0
  80. package/dist/preact/swatch-strip.js +17 -0
  81. package/dist/preact/swatch-strip.js.map +1 -0
  82. package/dist/preact/switch.js +1 -1
  83. package/dist/preact/switch.js.map +1 -1
  84. package/dist/preact/tabs.d.ts +97 -0
  85. package/dist/preact/tabs.d.ts.map +1 -0
  86. package/dist/preact/tabs.js +264 -0
  87. package/dist/preact/tabs.js.map +1 -0
  88. package/dist/preact/toaster.d.ts +43 -0
  89. package/dist/preact/toaster.d.ts.map +1 -0
  90. package/dist/preact/toaster.js +356 -0
  91. package/dist/preact/toaster.js.map +1 -0
  92. package/dist/preact/toggle-button.d.ts.map +1 -1
  93. package/dist/preact/toggle-button.js +1 -1
  94. package/dist/preact/toggle-button.js.map +1 -1
  95. package/dist/preact/toolbar.d.ts.map +1 -1
  96. package/dist/preact/toolbar.js +3 -9
  97. package/dist/preact/toolbar.js.map +1 -1
  98. package/dist/preact/tooltip.d.ts +67 -0
  99. package/dist/preact/tooltip.d.ts.map +1 -0
  100. package/dist/preact/tooltip.js +165 -0
  101. package/dist/preact/tooltip.js.map +1 -0
  102. package/dist/preact/tree.d.ts +93 -0
  103. package/dist/preact/tree.d.ts.map +1 -0
  104. package/dist/preact/tree.js +399 -0
  105. package/dist/preact/tree.js.map +1 -0
  106. package/dist/progress/progress.d.ts +51 -0
  107. package/dist/progress/progress.d.ts.map +1 -0
  108. package/dist/progress/progress.js +43 -0
  109. package/dist/progress/progress.js.map +1 -0
  110. package/dist/react/_props.d.ts +22 -0
  111. package/dist/react/_props.d.ts.map +1 -0
  112. package/dist/react/_props.js +14 -0
  113. package/dist/react/_props.js.map +1 -0
  114. package/dist/react/bit-grid.d.ts +40 -0
  115. package/dist/react/bit-grid.d.ts.map +1 -0
  116. package/dist/react/bit-grid.js +71 -0
  117. package/dist/react/bit-grid.js.map +1 -0
  118. package/dist/react/button.d.ts +60 -0
  119. package/dist/react/button.d.ts.map +1 -0
  120. package/dist/react/button.js +34 -0
  121. package/dist/react/button.js.map +1 -0
  122. package/dist/react/dialog.d.ts +44 -0
  123. package/dist/react/dialog.d.ts.map +1 -0
  124. package/dist/react/dialog.js +91 -0
  125. package/dist/react/dialog.js.map +1 -0
  126. package/dist/react/index.d.ts +22 -0
  127. package/dist/react/index.d.ts.map +1 -0
  128. package/dist/react/index.js +22 -0
  129. package/dist/react/index.js.map +1 -0
  130. package/dist/react/knob.d.ts +55 -0
  131. package/dist/react/knob.d.ts.map +1 -0
  132. package/dist/react/knob.js +144 -0
  133. package/dist/react/knob.js.map +1 -0
  134. package/dist/react/menu-button.d.ts +147 -0
  135. package/dist/react/menu-button.d.ts.map +1 -0
  136. package/dist/react/menu-button.js +342 -0
  137. package/dist/react/menu-button.js.map +1 -0
  138. package/dist/react/meter.d.ts +34 -0
  139. package/dist/react/meter.d.ts.map +1 -0
  140. package/dist/react/meter.js +23 -0
  141. package/dist/react/meter.js.map +1 -0
  142. package/dist/react/progress-ring.d.ts +42 -0
  143. package/dist/react/progress-ring.d.ts.map +1 -0
  144. package/dist/react/progress-ring.js +28 -0
  145. package/dist/react/progress-ring.js.map +1 -0
  146. package/dist/react/radio-group.d.ts +52 -0
  147. package/dist/react/radio-group.d.ts.map +1 -0
  148. package/dist/react/radio-group.js +30 -0
  149. package/dist/react/radio-group.js.map +1 -0
  150. package/dist/react/readout.d.ts +23 -0
  151. package/dist/react/readout.d.ts.map +1 -0
  152. package/dist/react/readout.js +13 -0
  153. package/dist/react/readout.js.map +1 -0
  154. package/dist/react/slider.d.ts +44 -0
  155. package/dist/react/slider.d.ts.map +1 -0
  156. package/dist/react/slider.js +167 -0
  157. package/dist/react/slider.js.map +1 -0
  158. package/dist/react/spin-button.d.ts +71 -0
  159. package/dist/react/spin-button.d.ts.map +1 -0
  160. package/dist/react/spin-button.js +132 -0
  161. package/dist/react/spin-button.js.map +1 -0
  162. package/dist/react/swatch-strip.d.ts +31 -0
  163. package/dist/react/swatch-strip.d.ts.map +1 -0
  164. package/dist/react/swatch-strip.js +17 -0
  165. package/dist/react/swatch-strip.js.map +1 -0
  166. package/dist/react/switch.d.ts +26 -0
  167. package/dist/react/switch.d.ts.map +1 -0
  168. package/dist/react/switch.js +19 -0
  169. package/dist/react/switch.js.map +1 -0
  170. package/dist/react/tabs.d.ts +95 -0
  171. package/dist/react/tabs.d.ts.map +1 -0
  172. package/dist/react/tabs.js +274 -0
  173. package/dist/react/tabs.js.map +1 -0
  174. package/dist/react/toaster.d.ts +43 -0
  175. package/dist/react/toaster.d.ts.map +1 -0
  176. package/dist/react/toaster.js +368 -0
  177. package/dist/react/toaster.js.map +1 -0
  178. package/dist/react/toggle-button.d.ts +37 -0
  179. package/dist/react/toggle-button.d.ts.map +1 -0
  180. package/dist/react/toggle-button.js +22 -0
  181. package/dist/react/toggle-button.js.map +1 -0
  182. package/dist/react/toolbar.d.ts +25 -0
  183. package/dist/react/toolbar.d.ts.map +1 -0
  184. package/dist/react/toolbar.js +143 -0
  185. package/dist/react/toolbar.js.map +1 -0
  186. package/dist/react/tooltip.d.ts +68 -0
  187. package/dist/react/tooltip.d.ts.map +1 -0
  188. package/dist/react/tooltip.js +165 -0
  189. package/dist/react/tooltip.js.map +1 -0
  190. package/dist/react/tree.d.ts +94 -0
  191. package/dist/react/tree.d.ts.map +1 -0
  192. package/dist/react/tree.js +422 -0
  193. package/dist/react/tree.js.map +1 -0
  194. package/dist/react/use-element-binding.d.ts +35 -0
  195. package/dist/react/use-element-binding.d.ts.map +1 -0
  196. package/dist/react/use-element-binding.js +51 -0
  197. package/dist/react/use-element-binding.js.map +1 -0
  198. package/dist/spin-button/spin-button.d.ts +110 -0
  199. package/dist/spin-button/spin-button.d.ts.map +1 -0
  200. package/dist/spin-button/spin-button.js +179 -0
  201. package/dist/spin-button/spin-button.js.map +1 -0
  202. package/dist/swatch-strip/swatch-strip.d.ts +60 -0
  203. package/dist/swatch-strip/swatch-strip.d.ts.map +1 -0
  204. package/dist/swatch-strip/swatch-strip.js +60 -0
  205. package/dist/swatch-strip/swatch-strip.js.map +1 -0
  206. package/dist/tabs/tabs.d.ts +157 -0
  207. package/dist/tabs/tabs.d.ts.map +1 -0
  208. package/dist/tabs/tabs.js +120 -0
  209. package/dist/tabs/tabs.js.map +1 -0
  210. package/dist/toast/toast-queue.d.ts +212 -0
  211. package/dist/toast/toast-queue.d.ts.map +1 -0
  212. package/dist/toast/toast-queue.js +290 -0
  213. package/dist/toast/toast-queue.js.map +1 -0
  214. package/dist/toast/toasts-obscure.d.ts +25 -0
  215. package/dist/toast/toasts-obscure.d.ts.map +1 -0
  216. package/dist/toast/toasts-obscure.js +30 -0
  217. package/dist/toast/toasts-obscure.js.map +1 -0
  218. package/dist/tooltip/tooltip.d.ts +183 -0
  219. package/dist/tooltip/tooltip.d.ts.map +1 -0
  220. package/dist/tooltip/tooltip.js +185 -0
  221. package/dist/tooltip/tooltip.js.map +1 -0
  222. package/dist/tree/tree.d.ts +302 -0
  223. package/dist/tree/tree.d.ts.map +1 -0
  224. package/dist/tree/tree.js +439 -0
  225. package/dist/tree/tree.js.map +1 -0
  226. package/package.json +47 -14
  227. package/styles.css +1084 -3
  228. package/dist/preact/join-classes.d.ts.map +0 -1
  229. package/dist/preact/join-classes.js.map +0 -1
  230. /package/dist/{preact → adapter}/join-classes.d.ts +0 -0
  231. /package/dist/{preact → adapter}/join-classes.js +0 -0
@@ -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,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAWrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,mCAAmC;AACnC,MAAM,MAAM,eAAe,GAAG;IAC7B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3C;;;;OAIG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACrD,8DAA8D;IAC9D,QAAQ,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IACpC,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,+BAA+B;IAC/B,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IAC3C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,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 { LiveAnnouncer_ } from "../adapter/_live-announcer.js";
4
+ import { joinClasses } from "../adapter/join-classes.js";
5
+ import { snapSpinButtonValue, spinButtonAttributes, spinButtonValue, } from "../spin-button/spin-button.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,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAEN,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,GACf,MAAM,+BAA+B,CAAC;AAiDvC,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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KAAK,SAAS,IAAI,KAAK,IAAI,GAAG,CACjC,IACI,IACD,CACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { JSX } from "preact";
2
+ import { type SwatchStripItem } from "../swatch-strip/swatch-strip.js";
3
+ /** Props of {@link SwatchStrip}. */
4
+ export type SwatchStripProps = {
5
+ /** Its accessible name, drawn before the strip unless `isLabelHidden`. */
6
+ label: string;
7
+ isLabelHidden?: boolean;
8
+ items: readonly SwatchStripItem[];
9
+ /**
10
+ * Separate swatches, each named, or one continuous strip. Defaults to
11
+ * `swatches`.
12
+ */
13
+ appearance?: "swatches" | "gradient";
14
+ /**
15
+ * For a gradient, the CSS colour space the browser blends in; omitted, hard
16
+ * stops (see {@link swatchStripGradient}).
17
+ */
18
+ interpolation?: string;
19
+ id?: string;
20
+ class?: string;
21
+ };
22
+ /**
23
+ * A row of colour swatches, or the same colours as one gradient strip. The
24
+ * swatches are a list whose items are each named by their colour and label; a
25
+ * gradient is one image named by all its colours in order.
26
+ *
27
+ * @throws {RangeError} When `appearance` is `gradient` and `items` is empty.
28
+ */
29
+ export declare function SwatchStrip(props: SwatchStripProps): JSX.Element;
30
+ //# sourceMappingURL=swatch-strip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch-strip.d.ts","sourceRoot":"","sources":["../../src/preact/swatch-strip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,EACN,KAAK,eAAe,EAIpB,MAAM,iCAAiC,CAAC;AAEzC,oCAAoC;AACpC,MAAM,MAAM,gBAAgB,GAAG;IAC9B,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACrC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAuDhE"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { joinClasses } from "../adapter/join-classes.js";
3
+ import { swatchStripGradient, swatchStripItemLabel, swatchStripSummary, } from "../swatch-strip/swatch-strip.js";
4
+ /**
5
+ * A row of colour swatches, or the same colours as one gradient strip. The
6
+ * swatches are a list whose items are each named by their colour and label; a
7
+ * gradient is one image named by all its colours in order.
8
+ *
9
+ * @throws {RangeError} When `appearance` is `gradient` and `items` is empty.
10
+ */
11
+ export function SwatchStrip(props) {
12
+ const { label, isLabelHidden = false, items, appearance = "swatches", interpolation, id, } = props;
13
+ return (_jsxs("div", { id: id, class: joinClasses("ack-control ack-swatch-strip", props.class), "data-appearance": appearance, "data-label-hidden": isLabelHidden ? "" : undefined, children: [_jsx("span", { class: "ack-swatch-strip-label", "aria-hidden": "true", children: label }), appearance === "gradient" ? (_jsx("div", { class: "ack-swatch-strip-gradient", role: "img", "aria-label": swatchStripSummary(label, items), style: {
14
+ backgroundImage: swatchStripGradient(items.map((item) => item.color), { interpolation }),
15
+ } })) : (_jsx("ul", { class: "ack-swatch-strip-items", "aria-label": label, children: items.map((item, index) => (_jsxs("li", { class: "ack-swatch-strip-item", "aria-label": swatchStripItemLabel(item), children: [_jsx("span", { class: "ack-swatch-strip-swatch", style: { backgroundColor: item.color } }), item.label !== undefined && (_jsx("span", { class: "ack-swatch-strip-caption", "aria-hidden": "true", children: item.label }))] }, index))) }))] }));
16
+ }
17
+ //# sourceMappingURL=swatch-strip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch-strip.js","sourceRoot":"","sources":["../../src/preact/swatch-strip.t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S,IAAI,CAC5B,eAAM,KAAK,EAAC,0BAA0B,iBAAa,MAAM,YACvD,IAAI,CAAC,KAAK,GACL,CACP,KAZI,KAAK,CAaN,CACL,CAAC,GACE,CACL,IACI,CACN,CAAC;AACH,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { useId } from "preact/hooks";
3
+ import { joinClasses } from "../adapter/join-classes.js";
3
4
  import { switchAttributes } from "../switch/switch.js";
4
- import { joinClasses } from "./join-classes.js";
5
5
  /**
6
6
  * An on/off setting that takes effect as soon as it is flipped, like a phone's
7
7
  * airplane-mode switch. A native button announced as a switch, so it takes
@@ -1 +1 @@
1
- {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/preact/switch.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgBhD;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,KAAkB;IACxC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,GAAG,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IAC3E,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IACxB,MAAM,aAAa,GAAG,KAAK,EAAE,CAAC;IAE9B,OAAO,CACN,qBACK,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EACxC,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,qBACD,OAAO,sBACN,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EACvE,KAAK,EAAE,WAAW,CAAC,wBAAwB,EAAE,KAAK,CAAC,KAAK,CAAC,EACzD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AQ,CAAC,CAAC,IAAI,CAAC,aAE9B,gBAAM,KAAK,EAAC,iBAAiB,aAC5B,eAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAC,kBAAkB,YACzC,KAAK,GACA,EACN,WAAW,KAAK,SAAS,IAAI,CAC7B,eAAM,EAAE,EAAE,aAAa,EAAE,KAAK,EAAC,wBAAwB,YACrD,WAAW,GACN,CACP,IACK,EACP,eAAM,KAAK,EAAC,kBAAkB,iBAAa,MAAM,YAChD,eAAM,KAAK,EAAC,kBAAkB,GAAG,GAC3B,IACC,CACT,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;AAWzE,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,eAAe,EAKpB,MAAM,iBAAiB,CAAC;AAGzB,6BAA6B;AAC7B,MAAM,MAAM,SAAS,GAAG;IACvB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,gBAAgB,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,gCAAgC;IAChC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IACrC,mDAAmD;IACnD,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAmCF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CA6FlD;AAED,8EAA8E;AAC9E,MAAM,MAAM,YAAY,GAAG,CACxB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAA;CAAE,GACzC;IAAE,KAAK,CAAC,EAAE,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