@ac-kit/ui-common 0.2.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 (190) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +59 -3
  3. package/dist/adapter/_anchor.d.ts.map +1 -0
  4. package/dist/adapter/_anchor.js.map +1 -0
  5. package/dist/adapter/_dom.d.ts.map +1 -0
  6. package/dist/adapter/_dom.js.map +1 -0
  7. package/dist/{preact → adapter}/_live-announcer.d.ts +1 -1
  8. package/dist/adapter/_live-announcer.d.ts.map +1 -0
  9. package/dist/{preact → adapter}/_live-announcer.js +1 -1
  10. package/dist/adapter/_live-announcer.js.map +1 -0
  11. package/dist/adapter/join-classes.d.ts.map +1 -0
  12. package/dist/adapter/join-classes.js.map +1 -0
  13. package/dist/bit-grid/bit-grid.d.ts +151 -0
  14. package/dist/bit-grid/bit-grid.d.ts.map +1 -0
  15. package/dist/bit-grid/bit-grid.js +201 -0
  16. package/dist/bit-grid/bit-grid.js.map +1 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/preact/bit-grid.d.ts +39 -0
  22. package/dist/preact/bit-grid.d.ts.map +1 -0
  23. package/dist/preact/bit-grid.js +72 -0
  24. package/dist/preact/bit-grid.js.map +1 -0
  25. package/dist/preact/button.d.ts.map +1 -1
  26. package/dist/preact/button.js +1 -1
  27. package/dist/preact/button.js.map +1 -1
  28. package/dist/preact/dialog.d.ts.map +1 -1
  29. package/dist/preact/dialog.js +1 -1
  30. package/dist/preact/dialog.js.map +1 -1
  31. package/dist/preact/index.d.ts +3 -1
  32. package/dist/preact/index.d.ts.map +1 -1
  33. package/dist/preact/index.js +3 -1
  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 +1 -1
  37. package/dist/preact/knob.js.map +1 -1
  38. package/dist/preact/menu-button.d.ts.map +1 -1
  39. package/dist/preact/menu-button.js +3 -3
  40. package/dist/preact/menu-button.js.map +1 -1
  41. package/dist/preact/meter.d.ts.map +1 -1
  42. package/dist/preact/meter.js +1 -1
  43. package/dist/preact/meter.js.map +1 -1
  44. package/dist/preact/progress-ring.d.ts.map +1 -1
  45. package/dist/preact/progress-ring.js +1 -1
  46. package/dist/preact/progress-ring.js.map +1 -1
  47. package/dist/preact/radio-group.d.ts.map +1 -1
  48. package/dist/preact/radio-group.js +1 -1
  49. package/dist/preact/radio-group.js.map +1 -1
  50. package/dist/preact/readout.d.ts.map +1 -1
  51. package/dist/preact/readout.js +1 -1
  52. package/dist/preact/readout.js.map +1 -1
  53. package/dist/preact/slider.d.ts.map +1 -1
  54. package/dist/preact/slider.js +1 -1
  55. package/dist/preact/slider.js.map +1 -1
  56. package/dist/preact/spin-button.d.ts.map +1 -1
  57. package/dist/preact/spin-button.js +2 -2
  58. package/dist/preact/spin-button.js.map +1 -1
  59. package/dist/preact/swatch-strip.d.ts +30 -0
  60. package/dist/preact/swatch-strip.d.ts.map +1 -0
  61. package/dist/preact/swatch-strip.js +17 -0
  62. package/dist/preact/swatch-strip.js.map +1 -0
  63. package/dist/preact/switch.js +1 -1
  64. package/dist/preact/switch.js.map +1 -1
  65. package/dist/preact/tabs.d.ts.map +1 -1
  66. package/dist/preact/tabs.js +2 -2
  67. package/dist/preact/tabs.js.map +1 -1
  68. package/dist/preact/toaster.d.ts.map +1 -1
  69. package/dist/preact/toaster.js +2 -2
  70. package/dist/preact/toaster.js.map +1 -1
  71. package/dist/preact/toggle-button.d.ts.map +1 -1
  72. package/dist/preact/toggle-button.js +1 -1
  73. package/dist/preact/toggle-button.js.map +1 -1
  74. package/dist/preact/toolbar.d.ts.map +1 -1
  75. package/dist/preact/toolbar.js +2 -2
  76. package/dist/preact/toolbar.js.map +1 -1
  77. package/dist/preact/tooltip.d.ts.map +1 -1
  78. package/dist/preact/tooltip.js +2 -2
  79. package/dist/preact/tooltip.js.map +1 -1
  80. package/dist/preact/tree.d.ts.map +1 -1
  81. package/dist/preact/tree.js +2 -2
  82. package/dist/preact/tree.js.map +1 -1
  83. package/dist/react/_props.d.ts +22 -0
  84. package/dist/react/_props.d.ts.map +1 -0
  85. package/dist/react/_props.js +14 -0
  86. package/dist/react/_props.js.map +1 -0
  87. package/dist/react/bit-grid.d.ts +40 -0
  88. package/dist/react/bit-grid.d.ts.map +1 -0
  89. package/dist/react/bit-grid.js +71 -0
  90. package/dist/react/bit-grid.js.map +1 -0
  91. package/dist/react/button.d.ts +60 -0
  92. package/dist/react/button.d.ts.map +1 -0
  93. package/dist/react/button.js +34 -0
  94. package/dist/react/button.js.map +1 -0
  95. package/dist/react/dialog.d.ts +44 -0
  96. package/dist/react/dialog.d.ts.map +1 -0
  97. package/dist/react/dialog.js +91 -0
  98. package/dist/react/dialog.js.map +1 -0
  99. package/dist/react/index.d.ts +22 -0
  100. package/dist/react/index.d.ts.map +1 -0
  101. package/dist/react/index.js +22 -0
  102. package/dist/react/index.js.map +1 -0
  103. package/dist/react/knob.d.ts +55 -0
  104. package/dist/react/knob.d.ts.map +1 -0
  105. package/dist/react/knob.js +144 -0
  106. package/dist/react/knob.js.map +1 -0
  107. package/dist/react/menu-button.d.ts +147 -0
  108. package/dist/react/menu-button.d.ts.map +1 -0
  109. package/dist/react/menu-button.js +342 -0
  110. package/dist/react/menu-button.js.map +1 -0
  111. package/dist/react/meter.d.ts +34 -0
  112. package/dist/react/meter.d.ts.map +1 -0
  113. package/dist/react/meter.js +23 -0
  114. package/dist/react/meter.js.map +1 -0
  115. package/dist/react/progress-ring.d.ts +42 -0
  116. package/dist/react/progress-ring.d.ts.map +1 -0
  117. package/dist/react/progress-ring.js +28 -0
  118. package/dist/react/progress-ring.js.map +1 -0
  119. package/dist/react/radio-group.d.ts +52 -0
  120. package/dist/react/radio-group.d.ts.map +1 -0
  121. package/dist/react/radio-group.js +30 -0
  122. package/dist/react/radio-group.js.map +1 -0
  123. package/dist/react/readout.d.ts +23 -0
  124. package/dist/react/readout.d.ts.map +1 -0
  125. package/dist/react/readout.js +13 -0
  126. package/dist/react/readout.js.map +1 -0
  127. package/dist/react/slider.d.ts +44 -0
  128. package/dist/react/slider.d.ts.map +1 -0
  129. package/dist/react/slider.js +167 -0
  130. package/dist/react/slider.js.map +1 -0
  131. package/dist/react/spin-button.d.ts +71 -0
  132. package/dist/react/spin-button.d.ts.map +1 -0
  133. package/dist/react/spin-button.js +132 -0
  134. package/dist/react/spin-button.js.map +1 -0
  135. package/dist/react/swatch-strip.d.ts +31 -0
  136. package/dist/react/swatch-strip.d.ts.map +1 -0
  137. package/dist/react/swatch-strip.js +17 -0
  138. package/dist/react/swatch-strip.js.map +1 -0
  139. package/dist/react/switch.d.ts +26 -0
  140. package/dist/react/switch.d.ts.map +1 -0
  141. package/dist/react/switch.js +19 -0
  142. package/dist/react/switch.js.map +1 -0
  143. package/dist/react/tabs.d.ts +95 -0
  144. package/dist/react/tabs.d.ts.map +1 -0
  145. package/dist/react/tabs.js +274 -0
  146. package/dist/react/tabs.js.map +1 -0
  147. package/dist/react/toaster.d.ts +43 -0
  148. package/dist/react/toaster.d.ts.map +1 -0
  149. package/dist/react/toaster.js +368 -0
  150. package/dist/react/toaster.js.map +1 -0
  151. package/dist/react/toggle-button.d.ts +37 -0
  152. package/dist/react/toggle-button.d.ts.map +1 -0
  153. package/dist/react/toggle-button.js +22 -0
  154. package/dist/react/toggle-button.js.map +1 -0
  155. package/dist/react/toolbar.d.ts +25 -0
  156. package/dist/react/toolbar.d.ts.map +1 -0
  157. package/dist/react/toolbar.js +143 -0
  158. package/dist/react/toolbar.js.map +1 -0
  159. package/dist/react/tooltip.d.ts +68 -0
  160. package/dist/react/tooltip.d.ts.map +1 -0
  161. package/dist/react/tooltip.js +165 -0
  162. package/dist/react/tooltip.js.map +1 -0
  163. package/dist/react/tree.d.ts +94 -0
  164. package/dist/react/tree.d.ts.map +1 -0
  165. package/dist/react/tree.js +422 -0
  166. package/dist/react/tree.js.map +1 -0
  167. package/dist/react/use-element-binding.d.ts +35 -0
  168. package/dist/react/use-element-binding.d.ts.map +1 -0
  169. package/dist/react/use-element-binding.js +51 -0
  170. package/dist/react/use-element-binding.js.map +1 -0
  171. package/dist/swatch-strip/swatch-strip.d.ts +60 -0
  172. package/dist/swatch-strip/swatch-strip.d.ts.map +1 -0
  173. package/dist/swatch-strip/swatch-strip.js +60 -0
  174. package/dist/swatch-strip/swatch-strip.js.map +1 -0
  175. package/package.json +38 -15
  176. package/styles.css +191 -1
  177. package/dist/preact/_anchor.d.ts.map +0 -1
  178. package/dist/preact/_anchor.js.map +0 -1
  179. package/dist/preact/_dom.d.ts.map +0 -1
  180. package/dist/preact/_dom.js.map +0 -1
  181. package/dist/preact/_live-announcer.d.ts.map +0 -1
  182. package/dist/preact/_live-announcer.js.map +0 -1
  183. package/dist/preact/join-classes.d.ts.map +0 -1
  184. package/dist/preact/join-classes.js.map +0 -1
  185. /package/dist/{preact → adapter}/_anchor.d.ts +0 -0
  186. /package/dist/{preact → adapter}/_anchor.js +0 -0
  187. /package/dist/{preact → adapter}/_dom.d.ts +0 -0
  188. /package/dist/{preact → adapter}/_dom.js +0 -0
  189. /package/dist/{preact → adapter}/join-classes.d.ts +0 -0
  190. /package/dist/{preact → adapter}/join-classes.js +0 -0
@@ -0,0 +1,147 @@
1
+ /** @jsxImportSource react */
2
+ import type { Callable, CallableNoArgs } from "@ac-kit/core";
3
+ import { type ButtonHTMLAttributes, type JSX, type ReactNode } from "react";
4
+ import type { AnchoredAlign, AnchoredSide } from "../anchored/anchored.js";
5
+ import { type ButtonSize, type ButtonVariant } from "../button/button.js";
6
+ import type { ControlTone } from "../tone.js";
7
+ import { type ClassProps_ } from "./_props.js";
8
+ /**
9
+ * Props of {@link MenuButton}: its own, then any other `<button>` attribute.
10
+ * Its `ref` reaches the button.
11
+ */
12
+ export type MenuButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "className" | "children" | "popoverTarget" | "popoverTargetAction"> & ClassProps_ & {
13
+ /** The button's text and the menu's name. */
14
+ label: string;
15
+ /**
16
+ * Draw the icon alone, `label` naming and titling the button. Defaults to
17
+ * false.
18
+ */
19
+ isLabelHidden?: boolean;
20
+ /** Drawn before the label, hidden from assistive technology. */
21
+ icon?: ReactNode;
22
+ /** Defaults to `secondary`. */
23
+ variant?: ButtonVariant;
24
+ /** Defaults to `regular`. */
25
+ size?: ButtonSize;
26
+ tone?: ControlTone;
27
+ /** Defaults to `block-end`: below the button. */
28
+ side?: AnchoredSide;
29
+ /** Defaults to `start`. */
30
+ align?: AnchoredAlign;
31
+ /** Called once the menu has opened or closed. */
32
+ onOpenChange?: Callable<[isOpen: boolean]>;
33
+ /**
34
+ * The items: {@link MenuItem}, {@link MenuItemCheckbox},
35
+ * {@link MenuItemRadio}, grouped by {@link MenuGroup}, divided by
36
+ * {@link MenuSeparator}.
37
+ */
38
+ children: ReactNode;
39
+ /** Added to the menu's classes. */
40
+ menuClass?: string;
41
+ };
42
+ /**
43
+ * A button that opens a menu of actions and settings (WAI-ARIA menu button and
44
+ * menu patterns), over the Popover API: the menu sits in the top layer,
45
+ * anchored to the button by CSS anchor positioning, flipping to the other side
46
+ * when the viewport has no room; a press outside it or Escape closes it.
47
+ *
48
+ * Enter, Space and Arrow Down open it on its first item, Arrow Up on its last;
49
+ * in it, the arrows move round, Home and End go to the ends, typing a name
50
+ * moves to it, Enter and a click choose an item and close, Space checks a
51
+ * checkbox or radio item and keeps it open, Escape closes it and Tab moves on,
52
+ * focus going back to the button. A mouse moving over the items focuses them.
53
+ * The menu closes before an item's action runs, so an action that opens a
54
+ * dialog has the button as its opener.
55
+ *
56
+ * Its open state is its own (the browser's popover state): `onOpenChange`
57
+ * reports it. The items' checked states are the caller's.
58
+ */
59
+ export declare const MenuButton: import("react").ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "className" | "popoverTarget" | "popoverTargetAction"> & ClassProps_ & {
60
+ /** The button's text and the menu's name. */
61
+ label: string;
62
+ /**
63
+ * Draw the icon alone, `label` naming and titling the button. Defaults to
64
+ * false.
65
+ */
66
+ isLabelHidden?: boolean;
67
+ /** Drawn before the label, hidden from assistive technology. */
68
+ icon?: ReactNode;
69
+ /** Defaults to `secondary`. */
70
+ variant?: ButtonVariant;
71
+ /** Defaults to `regular`. */
72
+ size?: ButtonSize;
73
+ tone?: ControlTone;
74
+ /** Defaults to `block-end`: below the button. */
75
+ side?: AnchoredSide;
76
+ /** Defaults to `start`. */
77
+ align?: AnchoredAlign;
78
+ /** Called once the menu has opened or closed. */
79
+ onOpenChange?: Callable<[isOpen: boolean]>;
80
+ /**
81
+ * The items: {@link MenuItem}, {@link MenuItemCheckbox},
82
+ * {@link MenuItemRadio}, grouped by {@link MenuGroup}, divided by
83
+ * {@link MenuSeparator}.
84
+ */
85
+ children: ReactNode;
86
+ /** Added to the menu's classes. */
87
+ menuClass?: string;
88
+ } & import("react").RefAttributes<HTMLButtonElement>>;
89
+ type ItemBaseProps_ = ClassProps_ & {
90
+ /** Its label. */
91
+ children: ReactNode;
92
+ /** Drawn before the label, hidden from assistive technology. */
93
+ icon?: ReactNode;
94
+ /** Announced and focusable, but not chosen. Defaults to false. */
95
+ disabled?: boolean;
96
+ /** The name typeahead matches, when the label is not plain text. */
97
+ textValue?: string;
98
+ id?: string;
99
+ };
100
+ /** Props of {@link MenuItem}. */
101
+ export type MenuItemProps = ItemBaseProps_ & {
102
+ /** Called when it is chosen, once the menu has closed. */
103
+ onSelect: CallableNoArgs;
104
+ };
105
+ /** An action in a {@link MenuButton}'s menu: the `menuitem` role. */
106
+ export declare function MenuItem(props: MenuItemProps): JSX.Element;
107
+ /** Props of {@link MenuItemCheckbox}. */
108
+ export type MenuItemCheckboxProps = ItemBaseProps_ & {
109
+ isChecked: boolean;
110
+ /** Called with the state asked for: the opposite of `isChecked`. */
111
+ onCheckedChange: Callable<[isChecked: boolean]>;
112
+ };
113
+ /**
114
+ * A setting turned on or off in a {@link MenuButton}'s menu: the
115
+ * `menuitemcheckbox` role, a check mark drawn while on. Space flips it and
116
+ * keeps the menu open; Enter and a click flip it and close the menu.
117
+ */
118
+ export declare function MenuItemCheckbox(props: MenuItemCheckboxProps): JSX.Element;
119
+ /** Props of {@link MenuItemRadio}. */
120
+ export type MenuItemRadioProps = ItemBaseProps_ & {
121
+ isChecked: boolean;
122
+ /** Called when it is chosen while not checked. */
123
+ onSelect: CallableNoArgs;
124
+ };
125
+ /**
126
+ * One choice among the radio items of a {@link MenuGroup}: the `menuitemradio`
127
+ * role, a dot drawn on the chosen one. Space chooses it and keeps the menu
128
+ * open; Enter and a click choose it and close the menu. Choosing the checked
129
+ * one reports nothing.
130
+ */
131
+ export declare function MenuItemRadio(props: MenuItemRadioProps): JSX.Element;
132
+ /** Props of {@link MenuGroup}. */
133
+ export type MenuGroupProps = ClassProps_ & {
134
+ /** Its accessible name, drawn above its items unless `isLabelHidden`. */
135
+ label: string;
136
+ isLabelHidden?: boolean;
137
+ children: ReactNode;
138
+ };
139
+ /**
140
+ * A named group of items in a {@link MenuButton}'s menu, such as the radio items
141
+ * of one choice: the `group` role.
142
+ */
143
+ export declare function MenuGroup(props: MenuGroupProps): JSX.Element;
144
+ /** A line between items of a {@link MenuButton}'s menu: the `separator` role. */
145
+ export declare function MenuSeparator(props: ClassProps_): JSX.Element;
146
+ export {};
147
+ //# sourceMappingURL=menu-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-button.d.ts","sourceRoot":"","sources":["../../src/react/menu-button.tsx"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EACN,KAAK,oBAAoB,EAGzB,KAAK,GAAG,EACR,KAAK,SAAS,EAQd,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBA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Aa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CAkB5D;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAM7D"}
@@ -0,0 +1,342 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { bindPointers } from "@ac-kit/ui-gesture/dom";
3
+ import { createContext, forwardRef, useCallback, useContext, useId, useLayoutEffect, useRef, useState, } from "react";
4
+ import { addAnchorName_, anchorNameOf_ } from "../adapter/_anchor.js";
5
+ import { localesOf_ } from "../adapter/_dom.js";
6
+ import { buttonAttributes, } from "../button/button.js";
7
+ import { Typeahead } from "../focus/typeahead.js";
8
+ import { menuAttributes, menuButtonAttributes, menuButtonKeyAction, menuItemAttributes, menuKeyAction, } from "../menu/menu.js";
9
+ import { classOf_, reactAttributes_ } from "./_props.js";
10
+ import { useElementBinding, useLatest } from "./use-element-binding.js";
11
+ const MenuContext_ = createContext(undefined);
12
+ const ITEM_SELECTOR_ = '[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';
13
+ function itemsOf_(menu) {
14
+ return [...menu.querySelectorAll(ITEM_SELECTOR_)].filter((item) => item.closest('[role="menu"]') === menu);
15
+ }
16
+ function textOf_(item) {
17
+ return item.dataset["textValue"] ?? item.textContent;
18
+ }
19
+ function kindOf_(item) {
20
+ switch (item.getAttribute("role")) {
21
+ case "menuitemcheckbox":
22
+ return "checkbox";
23
+ case "menuitemradio":
24
+ return "radio";
25
+ default:
26
+ return "item";
27
+ }
28
+ }
29
+ function assignRef_(ref, value) {
30
+ if (typeof ref === "function") {
31
+ ref(value);
32
+ }
33
+ else if (ref !== undefined && ref !== null) {
34
+ ref.current = value;
35
+ }
36
+ }
37
+ function menuChevron_() {
38
+ return (_jsx("span", { className: "ack-menu-button-chevron", "aria-hidden": "true", children: _jsx("svg", { viewBox: "0 0 16 16", focusable: "false", children: _jsx("path", { d: "M4 6l4 4 4-4" }) }) }));
39
+ }
40
+ /**
41
+ * A button that opens a menu of actions and settings (WAI-ARIA menu button and
42
+ * menu patterns), over the Popover API: the menu sits in the top layer,
43
+ * anchored to the button by CSS anchor positioning, flipping to the other side
44
+ * when the viewport has no room; a press outside it or Escape closes it.
45
+ *
46
+ * Enter, Space and Arrow Down open it on its first item, Arrow Up on its last;
47
+ * in it, the arrows move round, Home and End go to the ends, typing a name
48
+ * moves to it, Enter and a click choose an item and close, Space checks a
49
+ * checkbox or radio item and keeps it open, Escape closes it and Tab moves on,
50
+ * focus going back to the button. A mouse moving over the items focuses them.
51
+ * The menu closes before an item's action runs, so an action that opens a
52
+ * dialog has the button as its opener.
53
+ *
54
+ * Its open state is its own (the browser's popover state): `onOpenChange`
55
+ * reports it. The items' checked states are the caller's.
56
+ */
57
+ export const MenuButton = forwardRef(MenuButton_);
58
+ function MenuButton_(props, callerRef) {
59
+ const { label, isLabelHidden = false, icon, variant, size, tone, side, align, onOpenChange, children, menuClass, class: extra, className, id: givenId, type = "button", onKeyDown, ...rest } = props;
60
+ const generatedButtonId = useId();
61
+ const buttonId = givenId ?? generatedButtonId;
62
+ const menuId = useId();
63
+ const [isOpen, setIsOpen] = useState(false);
64
+ const button = useRef(null);
65
+ const menu = useRef(null);
66
+ const openFocus = useRef("first");
67
+ const typeahead = useRef(new Typeahead());
68
+ const activations = useRef(new WeakMap());
69
+ const latestOnOpenChange = useLatest(onOpenChange);
70
+ const latestOnKeyDown = useLatest(onKeyDown);
71
+ const anchorName = anchorNameOf_(menuId);
72
+ const setButton = useCallback((node) => {
73
+ button.current = node;
74
+ assignRef_(callerRef, node);
75
+ }, [callerRef]);
76
+ useLayoutEffect(() => {
77
+ const element = button.current;
78
+ if (element === null) {
79
+ return undefined;
80
+ }
81
+ const anchor = addAnchorName_(element, anchorName);
82
+ // Written here rather than as a prop: React 18 and 19 spell it differently,
83
+ // and each warns about the other's spelling.
84
+ element.setAttribute("popovertarget", menuId);
85
+ return () => {
86
+ anchor[Symbol.dispose]();
87
+ element.removeAttribute("popovertarget");
88
+ };
89
+ }, [anchorName, menuId]);
90
+ const latestOnToggle = useLatest((event) => {
91
+ const element = menu.current;
92
+ if (element === null) {
93
+ return;
94
+ }
95
+ const isNowOpen = event.newState === "open";
96
+ setIsOpen(isNowOpen);
97
+ if (isNowOpen) {
98
+ if (!element.contains(document.activeElement)) {
99
+ focusOpening();
100
+ }
101
+ }
102
+ else {
103
+ typeahead.current.reset();
104
+ const focused = document.activeElement;
105
+ if (focused === null ||
106
+ focused === document.body ||
107
+ element.contains(focused)) {
108
+ focusButton();
109
+ }
110
+ }
111
+ latestOnOpenChange.current?.(isNowOpen);
112
+ });
113
+ const menuBinding = useElementBinding((element, signal) => {
114
+ menu.current = element;
115
+ element.style.setProperty("position-anchor", anchorName);
116
+ // A native listener: React 18 listens for `toggle` on `<details>` only.
117
+ element.addEventListener("toggle", (event) => {
118
+ latestOnToggle.current(event);
119
+ }, { signal });
120
+ const binding = bindPointers(element, {
121
+ onHover: (_sample, event) => {
122
+ const target = event.target instanceof Element
123
+ ? event.target.closest(ITEM_SELECTOR_)
124
+ : null;
125
+ if (target !== null &&
126
+ target !== document.activeElement &&
127
+ target.closest('[role="menu"]') === element) {
128
+ target.focus({ preventScroll: true });
129
+ }
130
+ },
131
+ }, { coordinates: "client", signal });
132
+ return {
133
+ [Symbol.dispose]() {
134
+ binding[Symbol.dispose]();
135
+ element.style.removeProperty("position-anchor");
136
+ if (menu.current === element) {
137
+ menu.current = null;
138
+ }
139
+ },
140
+ };
141
+ }, [anchorName]);
142
+ const focusButton = () => {
143
+ button.current?.focus();
144
+ };
145
+ const close = () => {
146
+ typeahead.current.reset();
147
+ const element = menu.current;
148
+ // Focus first: the item it is on is about to be hidden.
149
+ focusButton();
150
+ element?.hidePopover();
151
+ };
152
+ const focusOpening = () => {
153
+ const element = menu.current;
154
+ if (element === null) {
155
+ return;
156
+ }
157
+ const items = itemsOf_(element);
158
+ const target = openFocus.current === "last" ? items.at(-1) : items[0];
159
+ openFocus.current = "first";
160
+ (target ?? element).focus({ preventScroll: true });
161
+ };
162
+ // Made once: it reads refs only, so the items register once.
163
+ const [context] = useState(() => ({
164
+ activate: (isDisabled, keepsOpen, action) => {
165
+ if (isDisabled) {
166
+ return;
167
+ }
168
+ if (!keepsOpen) {
169
+ typeahead.current.reset();
170
+ // Focus first: the item it is on is about to be hidden.
171
+ button.current?.focus();
172
+ menu.current?.hidePopover();
173
+ }
174
+ action();
175
+ },
176
+ register: (element, activate) => {
177
+ activations.current.set(element, activate);
178
+ return () => {
179
+ activations.current.delete(element);
180
+ };
181
+ },
182
+ }));
183
+ return (_jsxs(_Fragment, { children: [_jsxs("button", { ...rest, ...buttonAttributes({ variant, size, tone }), ...menuButtonAttributes({ menuId, isOpen }), id: buttonId, ref: setButton, type: type, "aria-label": isLabelHidden ? label : undefined, title: rest.title ?? (isLabelHidden ? label : undefined), className: classOf_(isLabelHidden
184
+ ? "ack-control ack-button ack-icon-button ack-menu-button"
185
+ : "ack-control ack-button ack-menu-button", { class: extra, className }), onKeyDown: (event) => {
186
+ latestOnKeyDown.current?.(event);
187
+ if (event.defaultPrevented) {
188
+ return;
189
+ }
190
+ const focus = menuButtonKeyAction(event);
191
+ if (focus === undefined) {
192
+ return;
193
+ }
194
+ openFocus.current = focus;
195
+ // Enter and Space click the button, whose popover target opens it.
196
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") {
197
+ return;
198
+ }
199
+ event.preventDefault();
200
+ const element = menu.current;
201
+ if (element === null) {
202
+ return;
203
+ }
204
+ if (isOpen) {
205
+ focusOpening();
206
+ }
207
+ else {
208
+ element.showPopover({ source: event.currentTarget });
209
+ focusOpening();
210
+ }
211
+ }, children: [icon !== undefined && (_jsx("span", { className: "ack-button-icon", "aria-hidden": "true", children: icon })), !isLabelHidden && label, !isLabelHidden && menuChevron_()] }), _jsx("div", { ...reactAttributes_(menuAttributes({ labelledBy: buttonId, side, align })), id: menuId, ref: menuBinding, popover: "auto", className: classOf_("ack-menu", { class: menuClass }), onKeyDown: (event) => {
212
+ const element = event.currentTarget;
213
+ const items = itemsOf_(element);
214
+ const focused = event.target instanceof HTMLElement
215
+ ? event.target.closest(ITEM_SELECTOR_)
216
+ : null;
217
+ const index = focused === null ? -1 : items.indexOf(focused);
218
+ const current = index === -1 ? undefined : index;
219
+ const action = menuKeyAction({
220
+ key: event.key,
221
+ shiftKey: event.shiftKey,
222
+ ctrlKey: event.ctrlKey,
223
+ altKey: event.altKey,
224
+ metaKey: event.metaKey,
225
+ current,
226
+ count: items.length,
227
+ itemKind: current === undefined ? undefined : kindOf_(items[current]),
228
+ isTypingAhead: typeahead.current.isActive(event.timeStamp),
229
+ });
230
+ if (action === undefined) {
231
+ return;
232
+ }
233
+ switch (action.kind) {
234
+ case "focus":
235
+ event.preventDefault();
236
+ items[action.index].focus({ preventScroll: true });
237
+ break;
238
+ case "activate":
239
+ event.preventDefault();
240
+ if (focused !== null) {
241
+ activations.current.get(focused)?.(action.keepsOpen);
242
+ }
243
+ break;
244
+ case "close":
245
+ event.preventDefault();
246
+ close();
247
+ break;
248
+ case "leave":
249
+ // Focus on the button first, so Tab moves on from it.
250
+ close();
251
+ break;
252
+ case "typeahead": {
253
+ event.preventDefault();
254
+ const next = typeahead.current.find(action.character, event.timeStamp, items.map(textOf_), current, { locales: localesOf_(element) });
255
+ if (next !== undefined) {
256
+ items[next].focus({ preventScroll: true });
257
+ }
258
+ break;
259
+ }
260
+ }
261
+ }, children: _jsx(MenuContext_.Provider, { value: context, children: children }) })] }));
262
+ }
263
+ function useMenuContext_(component) {
264
+ const context = useContext(MenuContext_);
265
+ if (context === undefined) {
266
+ throw new Error(`${component} must be inside a MenuButton`);
267
+ }
268
+ return context;
269
+ }
270
+ function MenuItemBase_(props) {
271
+ const { children, icon, textValue, id, attributes } = props;
272
+ const context = useMenuContext_("A menu item");
273
+ const latestActivate = useLatest(props.onActivate);
274
+ const unregister = useRef(undefined);
275
+ const ref = useCallback((node) => {
276
+ unregister.current?.();
277
+ unregister.current =
278
+ node === null
279
+ ? undefined
280
+ : context.register(node, (keepsOpen) => {
281
+ latestActivate.current(keepsOpen);
282
+ });
283
+ }, [context.register]);
284
+ const isCheckable = attributes.kind !== "item";
285
+ return (_jsxs("div", { ...reactAttributes_(menuItemAttributes(attributes)), id: id, ref: ref, "data-text-value": textValue, className: classOf_("ack-menu-item", props), onClick: () => {
286
+ latestActivate.current(false);
287
+ }, children: [isCheckable && (_jsx("span", { className: "ack-menu-item-indicator", "aria-hidden": "true", children: _jsx("svg", { viewBox: "0 0 16 16", focusable: "false", children: attributes.kind === "radio" ? (_jsx("circle", { cx: "8", cy: "8", r: "3" })) : (_jsx("path", { d: "M3.5 8.5l3 3 6-7" })) }) })), icon !== undefined && (_jsx("span", { className: "ack-menu-item-icon", "aria-hidden": "true", children: icon })), _jsx("span", { className: "ack-menu-item-label", children: children })] }));
288
+ }
289
+ /** An action in a {@link MenuButton}'s menu: the `menuitem` role. */
290
+ export function MenuItem(props) {
291
+ const { disabled = false, onSelect } = props;
292
+ const context = useMenuContext_("MenuItem");
293
+ return (_jsx(MenuItemBase_, { ...props, attributes: { kind: "item", isDisabled: disabled }, onActivate: () => {
294
+ context.activate(disabled, false, onSelect);
295
+ } }));
296
+ }
297
+ /**
298
+ * A setting turned on or off in a {@link MenuButton}'s menu: the
299
+ * `menuitemcheckbox` role, a check mark drawn while on. Space flips it and
300
+ * keeps the menu open; Enter and a click flip it and close the menu.
301
+ */
302
+ export function MenuItemCheckbox(props) {
303
+ const { disabled = false, isChecked, onCheckedChange } = props;
304
+ const context = useMenuContext_("MenuItemCheckbox");
305
+ return (_jsx(MenuItemBase_, { ...props, attributes: { kind: "checkbox", isChecked, isDisabled: disabled }, onActivate: (keepsOpen) => {
306
+ context.activate(disabled, keepsOpen, () => {
307
+ onCheckedChange(!isChecked);
308
+ });
309
+ } }));
310
+ }
311
+ /**
312
+ * One choice among the radio items of a {@link MenuGroup}: the `menuitemradio`
313
+ * role, a dot drawn on the chosen one. Space chooses it and keeps the menu
314
+ * open; Enter and a click choose it and close the menu. Choosing the checked
315
+ * one reports nothing.
316
+ */
317
+ export function MenuItemRadio(props) {
318
+ const { disabled = false, isChecked, onSelect } = props;
319
+ const context = useMenuContext_("MenuItemRadio");
320
+ return (_jsx(MenuItemBase_, { ...props, attributes: { kind: "radio", isChecked, isDisabled: disabled }, onActivate: (keepsOpen) => {
321
+ context.activate(disabled, keepsOpen, () => {
322
+ if (!isChecked) {
323
+ onSelect();
324
+ }
325
+ });
326
+ } }));
327
+ }
328
+ /**
329
+ * A named group of items in a {@link MenuButton}'s menu, such as the radio items
330
+ * of one choice: the `group` role.
331
+ */
332
+ export function MenuGroup(props) {
333
+ const { label, isLabelHidden = false, children } = props;
334
+ useMenuContext_("MenuGroup");
335
+ return (_jsxs("div", { role: "group", "aria-label": label, className: classOf_("ack-menu-group", props), children: [!isLabelHidden && (_jsx("div", { className: "ack-menu-group-label", "aria-hidden": "true", children: label })), children] }));
336
+ }
337
+ /** A line between items of a {@link MenuButton}'s menu: the `separator` role. */
338
+ export function MenuSeparator(props) {
339
+ useMenuContext_("MenuSeparator");
340
+ return (_jsx("div", { role: "separator", className: classOf_("ack-menu-separator", props) }));
341
+ }
342
+ //# sourceMappingURL=menu-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-button.js","sourceRoot":"","sources":["../../src/react/menu-button.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAEN,aAAa,EACb,UAAU,EAIV,WAAW,EACX,UAAU,EACV,KAAK,EACL,eAAe,EACf,MAAM,EACN,QAAQ,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM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CAClB,cAAK,SAAS,EAAC,sBAAsB,iBAAa,MAAM,YACtD,KAAK,GACD,CACN,EACA,QAAQ,IACJ,CACN,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,KAAkB;IAC/C,eAAe,CAAC,eAAe,CAAC,CAAC;IAEjC,OAAO,CACN,cAAK,IAAI,EAAC,WAAW,EAAC,SAAS,EAAE,QAAQ,CAAC,oBAAoB,EAAE,KAAK,CAAC,GAAI,CAC1E,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { JSX } from "react";
2
+ import { type MeterSegment } from "../meter/meter.js";
3
+ import type { ControlTone } from "../tone.js";
4
+ import { type ClassProps_ } from "./_props.js";
5
+ /** Props of {@link Meter}. */
6
+ export type MeterProps = ClassProps_ & {
7
+ /** Its accessible name; it is not drawn. */
8
+ label: string;
9
+ value: number;
10
+ min: number;
11
+ max: number;
12
+ /**
13
+ * Segments lit from the bottom or the left by `value`, in the units of
14
+ * `value`. Without, a continuous bar.
15
+ */
16
+ segments?: readonly MeterSegment[];
17
+ /** Defaults to `horizontal`. */
18
+ orientation?: "horizontal" | "vertical";
19
+ /** What a person reads, announced with the value: `"-12 dB"`. */
20
+ valueText?: string;
21
+ /** The colour of a continuous bar; segments carry their own. */
22
+ tone?: ControlTone;
23
+ id?: string;
24
+ };
25
+ /**
26
+ * A read-only level meter: a continuous bar, or a row of segments that light in
27
+ * their tones as the level rises. The `meter` role, so it is announced with its
28
+ * value and range, not as a control.
29
+ *
30
+ * @throws {RangeError} When `min` or `max` is not finite, or `max` is not above
31
+ * `min`.
32
+ */
33
+ export declare function Meter(props: MeterProps): JSX.Element;
34
+ //# sourceMappingURL=meter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meter.d.ts","sourceRoot":"","sources":["../../src/react/meter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EACN,KAAK,YAAY,EAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,KAAK,WAAW,EAA+B,MAAM,aAAa,CAAC;AAE5E,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACtC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACnC,gCAAgC;IAChC,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAAC,OAAO,CA6CpD"}
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /** @jsxImportSource react */
3
+ import { inverseLerp } from "@ac-kit/math-scalar";
4
+ import { meterAttributes, meterLitCount, } from "../meter/meter.js";
5
+ import { classOf_ } from "./_props.js";
6
+ /**
7
+ * A read-only level meter: a continuous bar, or a row of segments that light in
8
+ * their tones as the level rises. The `meter` role, so it is announced with its
9
+ * value and range, not as a control.
10
+ *
11
+ * @throws {RangeError} When `min` or `max` is not finite, or `max` is not above
12
+ * `min`.
13
+ */
14
+ export function Meter(props) {
15
+ const { label, value, min, max, segments, orientation = "horizontal", valueText, tone, id, } = props;
16
+ const attributes = meterAttributes({ label, value, min, max, valueText });
17
+ const litCount = segments === undefined ? 0 : meterLitCount(value, segments);
18
+ const style = {
19
+ "--ack-meter-fraction": inverseLerp(min, max, attributes["aria-valuenow"]),
20
+ };
21
+ return (_jsx("div", { ...attributes, id: id, className: classOf_("ack-control ack-meter", props), "data-orientation": orientation, "data-tone": tone, style: style, children: segments === undefined ? (_jsx("div", { className: "ack-meter-bar", children: _jsx("div", { className: "ack-meter-fill" }) })) : (_jsx("div", { className: "ack-meter-segments", children: segments.map((segment, index) => (_jsx("span", { className: "ack-meter-segment", "data-tone": segment.tone, "data-lit": index < litCount ? "" : undefined }, index))) })) }));
22
+ }
23
+ //# sourceMappingURL=meter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meter.js","sourceRoot":"","sources":["../../src/react/meter.tsx"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAEN,eAAe,EACf,aAAa,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAoB,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAuB5E;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAC,KAAiB;IACtC,MAAM,EACL,KAAK,EACL,KAAK,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,WAAW,GAAG,YAAY,EAC1B,SAAS,EACT,IAAI,EACJ,EAAE,GACF,GAAG,KAAK,CAAC;IACV,MAAM,UAAU,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAiB;QAC3B,sBAAsB,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;KAC1E,CAAC;IAEF,OAAO,CACN,iBACK,UAAU,EACd,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,QAAQ,CAAC,uBAAuB,EAAE,KAAK,CAAC,sBACjC,WAAW,eAClB,IAAI,EACf,KAAK,EAAE,KAAK,YAEX,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CACzB,cAAK,SAAS,EAAC,eAAe,YAC7B,cAAK,SAAS,EAAC,gBAAgB,GAAG,GAC7B,CACN,CAAC,CAAC,CAAC,CACH,cAAK,SAAS,EAAC,oBAAoB,YACjC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CACjC,eAEC,SAAS,EAAC,mBAAmB,eAClB,OAAO,CAAC,IAAI,cACb,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,IAHtC,KAAK,CAIT,CACF,CAAC,GACG,CACN,GACI,CACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { JSX } from "react";
2
+ import type { ControlTone } from "../tone.js";
3
+ import { type ClassProps_ } from "./_props.js";
4
+ /** Props of {@link ProgressRing}. */
5
+ export type ProgressRingProps = ({
6
+ /** Its accessible name; it is not drawn. */
7
+ label: string;
8
+ labelledBy?: undefined;
9
+ } | {
10
+ label?: undefined;
11
+ /** The id of the element naming it, such as a heading. */
12
+ labelledBy: string;
13
+ }) & ClassProps_ & {
14
+ /** How far the task has gone; `undefined` while it cannot be told. */
15
+ value: number | undefined;
16
+ /** Defaults to 0. */
17
+ min?: number;
18
+ /** Defaults to 100. */
19
+ max?: number;
20
+ /**
21
+ * What a person reads, announced instead of the percentage: `"3 of 12
22
+ * files"`.
23
+ */
24
+ valueText?: string;
25
+ /** Draw `valueText` inside the ring. Defaults to false. */
26
+ isValueShown?: boolean;
27
+ tone?: ControlTone;
28
+ id?: string;
29
+ };
30
+ /**
31
+ * A circular progress indicator: an arc filling clockwise from twelve o'clock
32
+ * as `value` goes from `min` to `max`, or a turning arc while the progress
33
+ * cannot be told (`value` undefined), held still under `prefers-reduced-motion:
34
+ * reduce`. The `progressbar` role, so it is announced with its value, not as a
35
+ * control. Tie it to the region it reports on with `aria-busy` and
36
+ * `aria-describedby` there.
37
+ *
38
+ * @throws {RangeError} When `min` or `max` is not finite, or `max` is not above
39
+ * `min`.
40
+ */
41
+ export declare function ProgressRing(props: ProgressRingProps): JSX.Element;
42
+ //# sourceMappingURL=progress-ring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-ring.d.ts","sourceRoot":"","sources":["../../src/react/progress-ring.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,KAAK,WAAW,EAA+B,MAAM,aAAa,CAAC;AAE5E,qCAAqC;AACrC,MAAM,MAAM,iBAAiB,GAAG,CAC7B;IACA,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,SAAS,CAAC;CACtB,GACD;IACA,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;CAClB,CACH,GACA,WAAW,GAAG;IACb,sEAAsE;IACtE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,qBAAqB;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CA+DlE"}