@arshad-shah/cynosure 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 (275) hide show
  1. package/README.md +9 -8
  2. package/dist/components/Accordion/Accordion.d.ts +14 -0
  3. package/dist/components/Accordion/Accordion.js.map +1 -1
  4. package/dist/components/Announcer/Announcer.d.ts +1 -0
  5. package/dist/components/Announcer/Announcer.js.map +1 -1
  6. package/dist/components/AppShell/AppShell.d.ts +22 -1
  7. package/dist/components/AppShell/AppShell.js +95 -83
  8. package/dist/components/AppShell/AppShell.js.map +1 -1
  9. package/dist/components/AppShell/index.d.ts +1 -1
  10. package/dist/components/AspectRatio/AspectRatio.d.ts +29 -0
  11. package/dist/components/AspectRatio/AspectRatio.js +21 -0
  12. package/dist/components/AspectRatio/AspectRatio.js.map +1 -0
  13. package/dist/components/AspectRatio/index.d.ts +1 -0
  14. package/dist/components/Avatar/Avatar.d.ts +96 -0
  15. package/dist/components/Avatar/Avatar.js +90 -0
  16. package/dist/components/Avatar/Avatar.js.map +1 -0
  17. package/dist/components/Avatar/index.d.ts +1 -0
  18. package/dist/components/Badge/Badge.d.ts +6 -0
  19. package/dist/components/Badge/Badge.js.map +1 -1
  20. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +55 -0
  21. package/dist/components/Breadcrumbs/Breadcrumbs.js +85 -0
  22. package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
  23. package/dist/components/Breadcrumbs/index.d.ts +1 -0
  24. package/dist/components/Button/Button.d.ts +13 -2
  25. package/dist/components/Button/Button.js +28 -26
  26. package/dist/components/Button/Button.js.map +1 -1
  27. package/dist/components/Calendar/Calendar.d.ts +65 -7
  28. package/dist/components/Calendar/Calendar.js +207 -95
  29. package/dist/components/Calendar/Calendar.js.map +1 -1
  30. package/dist/components/Calendar/dates.d.ts +4 -0
  31. package/dist/components/Calendar/dates.js +41 -27
  32. package/dist/components/Calendar/dates.js.map +1 -1
  33. package/dist/components/Calendar/index.d.ts +1 -1
  34. package/dist/components/Card/Card.d.ts +27 -0
  35. package/dist/components/Card/Card.js +48 -36
  36. package/dist/components/Card/Card.js.map +1 -1
  37. package/dist/components/Card/index.d.ts +1 -1
  38. package/dist/components/Checkbox/Checkbox.d.ts +8 -1
  39. package/dist/components/Checkbox/Checkbox.js +7 -6
  40. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  41. package/dist/components/Checkbox/ChoiceRow.d.ts +17 -1
  42. package/dist/components/Checkbox/ChoiceRow.js +19 -18
  43. package/dist/components/Checkbox/ChoiceRow.js.map +1 -1
  44. package/dist/components/Checklist/Checklist.d.ts +65 -0
  45. package/dist/components/Checklist/Checklist.js +163 -0
  46. package/dist/components/Checklist/Checklist.js.map +1 -0
  47. package/dist/components/Checklist/index.d.ts +1 -0
  48. package/dist/components/CodeBlock/CodeBlock.d.ts +5 -0
  49. package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
  50. package/dist/components/ColorField/ColorField.d.ts +12 -0
  51. package/dist/components/ColorField/ColorField.js +19 -19
  52. package/dist/components/ColorField/ColorField.js.map +1 -1
  53. package/dist/components/ColorSwatches/ColorSwatches.d.ts +5 -0
  54. package/dist/components/ColorSwatches/ColorSwatches.js +6 -6
  55. package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
  56. package/dist/components/Combobox/Combobox.d.ts +20 -1
  57. package/dist/components/Combobox/Combobox.js +38 -34
  58. package/dist/components/Combobox/Combobox.js.map +1 -1
  59. package/dist/components/CommandPalette/CommandPalette.d.ts +9 -0
  60. package/dist/components/CommandPalette/CommandPalette.js +10 -10
  61. package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
  62. package/dist/components/CompareSlider/CompareSlider.d.ts +4 -0
  63. package/dist/components/CompareSlider/CompareSlider.js +4 -4
  64. package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
  65. package/dist/components/Container/Container.d.ts +44 -0
  66. package/dist/components/Container/Container.js +24 -0
  67. package/dist/components/Container/Container.js.map +1 -0
  68. package/dist/components/Container/index.d.ts +1 -0
  69. package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
  70. package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
  71. package/dist/components/CopyButton/CopyButton.d.ts +8 -0
  72. package/dist/components/CopyButton/CopyButton.js.map +1 -1
  73. package/dist/components/DateField/DateField.d.ts +17 -0
  74. package/dist/components/DateField/DateField.js +6 -6
  75. package/dist/components/DateField/DateField.js.map +1 -1
  76. package/dist/components/DescriptionList/DescriptionList.d.ts +3 -0
  77. package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
  78. package/dist/components/Dialog/Dialog.d.ts +16 -2
  79. package/dist/components/Dialog/Dialog.js +82 -70
  80. package/dist/components/Dialog/Dialog.js.map +1 -1
  81. package/dist/components/Disclosure/Disclosure.d.ts +7 -0
  82. package/dist/components/Disclosure/Disclosure.js.map +1 -1
  83. package/dist/components/Divider/Divider.d.ts +59 -0
  84. package/dist/components/Divider/Divider.js +32 -0
  85. package/dist/components/Divider/Divider.js.map +1 -0
  86. package/dist/components/Divider/index.d.ts +1 -0
  87. package/dist/components/DocumentViewport/DocumentViewport.d.ts +8 -0
  88. package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
  89. package/dist/components/EmptyState/EmptyState.d.ts +3 -0
  90. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  91. package/dist/components/Field/Field.d.ts +6 -0
  92. package/dist/components/Field/Field.js.map +1 -1
  93. package/dist/components/FileDrop/FileDrop.d.ts +8 -0
  94. package/dist/components/FileDrop/FileDrop.js.map +1 -1
  95. package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +4 -0
  96. package/dist/components/FloatingToolbar/FloatingToolbar.js +4 -4
  97. package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
  98. package/dist/components/Grid/Grid.d.ts +33 -7
  99. package/dist/components/Grid/Grid.js +46 -25
  100. package/dist/components/Grid/Grid.js.map +1 -1
  101. package/dist/components/Grid/index.d.ts +1 -1
  102. package/dist/components/Heading/Heading.d.ts +57 -0
  103. package/dist/components/Heading/Heading.js +33 -0
  104. package/dist/components/Heading/Heading.js.map +1 -0
  105. package/dist/components/Heading/index.d.ts +1 -0
  106. package/dist/components/HoverCard/HoverCard.d.ts +1 -0
  107. package/dist/components/HoverCard/HoverCard.js.map +1 -1
  108. package/dist/components/IconButton/IconButton.d.ts +1 -0
  109. package/dist/components/IconButton/IconButton.js.map +1 -1
  110. package/dist/components/Image/Image.d.ts +62 -0
  111. package/dist/components/Image/Image.js +75 -0
  112. package/dist/components/Image/Image.js.map +1 -0
  113. package/dist/components/Image/index.d.ts +1 -0
  114. package/dist/components/Inline/Inline.d.ts +7 -3
  115. package/dist/components/Inline/Inline.js +19 -13
  116. package/dist/components/Inline/Inline.js.map +1 -1
  117. package/dist/components/Kbd/Kbd.d.ts +2 -0
  118. package/dist/components/Kbd/Kbd.js.map +1 -1
  119. package/dist/components/KeyValueEditor/KeyValueEditor.d.ts +7 -0
  120. package/dist/components/KeyValueEditor/KeyValueEditor.js +8 -8
  121. package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
  122. package/dist/components/Link/Link.d.ts +7 -0
  123. package/dist/components/Link/Link.js.map +1 -1
  124. package/dist/components/LoadingDots/LoadingDots.d.ts +2 -0
  125. package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
  126. package/dist/components/Menu/Menu.d.ts +13 -1
  127. package/dist/components/Menu/Menu.js +37 -35
  128. package/dist/components/Menu/Menu.js.map +1 -1
  129. package/dist/components/Notice/Notice.d.ts +5 -0
  130. package/dist/components/Notice/Notice.js.map +1 -1
  131. package/dist/components/NumberField/NumberField.d.ts +17 -0
  132. package/dist/components/NumberField/NumberField.js +8 -8
  133. package/dist/components/NumberField/NumberField.js.map +1 -1
  134. package/dist/components/PageHeader/PageHeader.d.ts +61 -0
  135. package/dist/components/PageHeader/PageHeader.js +63 -0
  136. package/dist/components/PageHeader/PageHeader.js.map +1 -0
  137. package/dist/components/PageHeader/index.d.ts +1 -0
  138. package/dist/components/Pagination/Pagination.d.ts +77 -0
  139. package/dist/components/Pagination/Pagination.js +120 -0
  140. package/dist/components/Pagination/Pagination.js.map +1 -0
  141. package/dist/components/Pagination/index.d.ts +1 -0
  142. package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +4 -0
  143. package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
  144. package/dist/components/Popover/Popover.d.ts +10 -0
  145. package/dist/components/Popover/Popover.js.map +1 -1
  146. package/dist/components/ProgressBar/ProgressBar.d.ts +5 -0
  147. package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
  148. package/dist/components/ProgressOverlay/ProgressOverlay.d.ts +3 -0
  149. package/dist/components/ProgressOverlay/ProgressOverlay.js.map +1 -1
  150. package/dist/components/Prose/Prose.d.ts +1 -0
  151. package/dist/components/Prose/Prose.js.map +1 -1
  152. package/dist/components/RadioGroup/RadioGroup.d.ts +13 -0
  153. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  154. package/dist/components/SegmentedControl/SegmentedControl.d.ts +9 -0
  155. package/dist/components/SegmentedControl/SegmentedControl.js +35 -27
  156. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  157. package/dist/components/Select/Select.d.ts +18 -1
  158. package/dist/components/Select/Select.js +97 -88
  159. package/dist/components/Select/Select.js.map +1 -1
  160. package/dist/components/Select/index.d.ts +1 -0
  161. package/dist/components/SelectionFrame/SelectionFrame.d.ts +6 -0
  162. package/dist/components/SelectionFrame/SelectionFrame.js.map +1 -1
  163. package/dist/components/SideNav/SideNav.d.ts +37 -1
  164. package/dist/components/SideNav/SideNav.js +100 -73
  165. package/dist/components/SideNav/SideNav.js.map +1 -1
  166. package/dist/components/SideNav/index.d.ts +1 -1
  167. package/dist/components/SignaturePad/SignaturePad.d.ts +3 -0
  168. package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
  169. package/dist/components/Skeleton/Skeleton.d.ts +1 -0
  170. package/dist/components/Skeleton/Skeleton.js.map +1 -1
  171. package/dist/components/Slider/Slider.d.ts +11 -0
  172. package/dist/components/Slider/Slider.js +6 -6
  173. package/dist/components/Slider/Slider.js.map +1 -1
  174. package/dist/components/SortableList/SortableList.d.ts +6 -0
  175. package/dist/components/SortableList/SortableList.js.map +1 -1
  176. package/dist/components/SplitPane/SplitPane.d.ts +5 -0
  177. package/dist/components/SplitPane/SplitPane.js +4 -4
  178. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  179. package/dist/components/Stack/Stack.d.ts +7 -3
  180. package/dist/components/Stack/Stack.js +18 -12
  181. package/dist/components/Stack/Stack.js.map +1 -1
  182. package/dist/components/Stack/index.d.ts +1 -0
  183. package/dist/components/Stack/space.d.ts +18 -0
  184. package/dist/components/Stack/space.js +12 -0
  185. package/dist/components/Stack/space.js.map +1 -0
  186. package/dist/components/Steps/Steps.d.ts +4 -0
  187. package/dist/components/Steps/Steps.js.map +1 -1
  188. package/dist/components/Table/Table.d.ts +12 -0
  189. package/dist/components/Table/Table.js.map +1 -1
  190. package/dist/components/Tabs/Tabs.d.ts +14 -0
  191. package/dist/components/Tabs/Tabs.js +4 -4
  192. package/dist/components/Tabs/Tabs.js.map +1 -1
  193. package/dist/components/TagInput/TagInput.d.ts +18 -0
  194. package/dist/components/TagInput/TagInput.js +5 -5
  195. package/dist/components/TagInput/TagInput.js.map +1 -1
  196. package/dist/components/Text/Text.d.ts +72 -0
  197. package/dist/components/Text/Text.js +30 -0
  198. package/dist/components/Text/Text.js.map +1 -0
  199. package/dist/components/Text/index.d.ts +1 -0
  200. package/dist/components/TextArea/TextArea.d.ts +10 -0
  201. package/dist/components/TextArea/TextArea.js +4 -4
  202. package/dist/components/TextArea/TextArea.js.map +1 -1
  203. package/dist/components/TextField/TextField.d.ts +13 -0
  204. package/dist/components/TextField/TextField.js +4 -4
  205. package/dist/components/TextField/TextField.js.map +1 -1
  206. package/dist/components/ThemeToggle/ThemeToggle.d.ts +4 -0
  207. package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
  208. package/dist/components/TimeField/TimeField.d.ts +62 -8
  209. package/dist/components/TimeField/TimeField.js +308 -72
  210. package/dist/components/TimeField/TimeField.js.map +1 -1
  211. package/dist/components/Toast/Toast.d.ts +25 -1
  212. package/dist/components/Toast/Toast.js +134 -125
  213. package/dist/components/Toast/Toast.js.map +1 -1
  214. package/dist/components/Toast/index.d.ts +1 -1
  215. package/dist/components/Toolbar/Toolbar.d.ts +3 -0
  216. package/dist/components/Toolbar/Toolbar.js.map +1 -1
  217. package/dist/components/Tooltip/Tooltip.d.ts +1 -0
  218. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  219. package/dist/components/Tree/Tree.d.ts +8 -0
  220. package/dist/components/Tree/Tree.js.map +1 -1
  221. package/dist/components/VirtualList/VirtualList.d.ts +8 -0
  222. package/dist/components/VirtualList/VirtualList.js +4 -4
  223. package/dist/components/VirtualList/VirtualList.js.map +1 -1
  224. package/dist/components/ZoomControls/ZoomControls.d.ts +4 -0
  225. package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
  226. package/dist/foundations/ChoiceBase/ChoiceBase.d.ts +1 -0
  227. package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
  228. package/dist/foundations/HiddenValue/HiddenValue.d.ts +3 -0
  229. package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
  230. package/dist/foundations/Icon/Icon.d.ts +3 -0
  231. package/dist/foundations/Icon/Icon.js.map +1 -1
  232. package/dist/foundations/image-outcome.d.ts +15 -0
  233. package/dist/foundations/image-outcome.js +39 -0
  234. package/dist/foundations/image-outcome.js.map +1 -0
  235. package/dist/foundations/option-icon.d.ts +26 -0
  236. package/dist/foundations/option-icon.js +16 -0
  237. package/dist/foundations/option-icon.js.map +1 -0
  238. package/dist/icons/index.d.ts +1 -0
  239. package/dist/icons/index.js +476 -474
  240. package/dist/icons/keywords.d.ts +249 -0
  241. package/dist/icons/keywords.js +1728 -0
  242. package/dist/icons/keywords.js.map +1 -0
  243. package/dist/index.d.ts +20 -9
  244. package/dist/index.js +240 -213
  245. package/dist/styles/app-shell.css +1 -1
  246. package/dist/styles/aspect-ratio.css +1 -0
  247. package/dist/styles/avatar.css +1 -0
  248. package/dist/styles/breadcrumbs.css +1 -0
  249. package/dist/styles/calendar.css +1 -1
  250. package/dist/styles/card.css +1 -1
  251. package/dist/styles/checkbox.css +1 -1
  252. package/dist/styles/checklist.css +1 -0
  253. package/dist/styles/container.css +1 -0
  254. package/dist/styles/divider.css +1 -0
  255. package/dist/styles/generated-css.d.ts +1 -1
  256. package/dist/styles/generated-css.js +1 -1
  257. package/dist/styles/generated-css.js.map +1 -1
  258. package/dist/styles/grid.css +1 -1
  259. package/dist/styles/heading.css +1 -0
  260. package/dist/styles/image.css +1 -0
  261. package/dist/styles/menu.css +1 -1
  262. package/dist/styles/page-header.css +1 -0
  263. package/dist/styles/pagination.css +1 -0
  264. package/dist/styles/segmented-control.css +1 -1
  265. package/dist/styles/side-nav.css +1 -1
  266. package/dist/styles/stack.css +1 -1
  267. package/dist/styles/text.css +1 -0
  268. package/dist/styles/time-field.css +1 -1
  269. package/dist/styles/toast.css +1 -1
  270. package/dist/styles.css +1 -1
  271. package/dist/theme/CynosureTheme.d.ts +4 -0
  272. package/dist/theme/CynosureTheme.js.map +1 -1
  273. package/dist/tokens/to-css.js +12 -12
  274. package/dist/tokens/to-css.js.map +1 -1
  275. package/package.json +4 -3
@@ -1,193 +1,202 @@
1
1
  "use client";
2
- import { Icon as W } from "../../foundations/Icon/Icon.js";
3
- import { useClientLayoutEffect as j } from "../../foundations/client-layout-effect.js";
4
- import { Button as G } from "../Button/Button.js";
5
- import { IconButton as J } from "../IconButton/IconButton.js";
6
- import { close as K } from "../../icons/close.js";
7
- import { ToastHostContext as Q } from "../../overlay/toast-host.js";
8
- import { TONE_ICONS as Y } from "../../foundations/tone-icons.js";
9
- import { createContext as Z, useCallback as _, useContext as tt, useEffect as w, useId as et, useMemo as X, useRef as C, useState as f } from "react";
10
- import { Fragment as nt, jsx as m, jsxs as $ } from "react/jsx-runtime";
11
- import { createPortal as ot } from "react-dom";
12
- var rt = {
2
+ import { Icon as J } from "../../foundations/Icon/Icon.js";
3
+ import { useClientLayoutEffect as z } from "../../foundations/client-layout-effect.js";
4
+ import { Button as K } from "../Button/Button.js";
5
+ import { IconButton as Q } from "../IconButton/IconButton.js";
6
+ import { close as Y } from "../../icons/close.js";
7
+ import { ToastHostContext as Z } from "../../overlay/toast-host.js";
8
+ import { space as tt } from "../Stack/space.js";
9
+ import { TONE_ICONS as et } from "../../foundations/tone-icons.js";
10
+ import { createContext as nt, useCallback as D, useContext as ot, useEffect as E, useId as rt, useMemo as X, useRef as I, useState as v } from "react";
11
+ import { Fragment as st, jsx as m, jsxs as M } from "react/jsx-runtime";
12
+ import { createPortal as it } from "react-dom";
13
+ var at = {
13
14
  region: "Notifications",
14
15
  dismiss: "Dismiss"
15
- }, st = 64, q = Z(null);
16
- function yt() {
17
- const y = tt(q);
18
- if (!y) throw new Error("useToast() needs a <Toaster> around it.");
19
- return y;
16
+ }, ct = 64, q = (o) => /^(\d|10)$/.test(o) ? tt(o) : o;
17
+ function lt(o) {
18
+ const { block: a, inline: g } = typeof o == "object" ? o : { block: o }, y = {};
19
+ return a && (y["--_offset-block"] = q(a)), g && (y["--_offset-inline"] = q(g)), y;
20
20
  }
21
- function ht({ position: y = "bottom-end", max: p = 3, labels: E, className: I, style: h, children: N }) {
22
- const b = {
23
- ...rt,
24
- ...E
25
- }, o = et(), S = C(0), [v, u] = f([]), [P, g] = f(!1), [r, l] = f(!1), [d, B] = f(!1), s = C(null), T = C(/* @__PURE__ */ new Map()), [D, L] = f([]), F = X(() => ({ register: (t) => (L((i) => [...i, t]), () => L((i) => i.filter((c) => c !== t))) }), []), e = D.at(-1) ?? null, n = _((t) => {
26
- T.current.delete(t), u((i) => i.filter((c) => c.id !== t));
27
- }, []), a = _((t) => {
28
- const i = s.current?.ownerDocument.activeElement, c = i?.closest(".cy-toast");
29
- if (c && s.current?.contains(c) && (t === void 0 || c.dataset.id === t)) {
30
- const M = [...s.current.querySelectorAll(".cy-toast:not([data-collapsed]):not([data-leaving])")], x = t === void 0 ? void 0 : M.find((V) => V !== c), H = x ? [...x.querySelectorAll("button")].at(-1) : void 0;
31
- H ? H.focus() : (i.blur(), l(!1));
21
+ var O = nt(null);
22
+ function Pt() {
23
+ const o = ot(O);
24
+ if (!o) throw new Error("useToast() needs a <Toaster> around it.");
25
+ return o;
26
+ }
27
+ function wt({ position: o = "bottom-end", max: a = 3, offset: g, labels: y, className: h, style: N, children: S }) {
28
+ const r = {
29
+ ...at,
30
+ ...y
31
+ }, L = rt(), w = I(0), [c, T] = v([]), [x, l] = v(!1), [f, s] = v(!1), [F, b] = v(!1), d = I(null), k = I(/* @__PURE__ */ new Map()), [_, C] = v([]), e = X(() => ({ register: (t) => (C((i) => [...i, t]), () => C((i) => i.filter((u) => u !== t))) }), []), n = _.at(-1) ?? null, p = D((t) => {
32
+ k.current.delete(t), T((i) => i.filter((u) => u.id !== t));
33
+ }, []), $ = D((t) => {
34
+ const i = d.current?.ownerDocument.activeElement, u = i?.closest(".cy-toast");
35
+ if (u && d.current?.contains(u) && (t === void 0 || u.dataset.id === t)) {
36
+ const B = [...d.current.querySelectorAll(".cy-toast:not([data-collapsed]):not([data-leaving])")], P = t === void 0 ? void 0 : B.find((G) => G !== u), j = P ? [...P.querySelectorAll("button")].at(-1) : void 0;
37
+ j ? j.focus() : (i.blur(), s(!1));
32
38
  }
33
- u((M) => M.map((x) => t === void 0 || x.id === t ? {
34
- ...x,
39
+ T((B) => B.map((P) => t === void 0 || P.id === t ? {
40
+ ...P,
35
41
  leaving: !0
36
- } : x));
37
- }, []), k = _((t) => {
38
- S.current += 1;
39
- const i = `${o}-${S.current}`;
40
- return u((c) => [...c, {
42
+ } : P));
43
+ }, []), A = D((t) => {
44
+ w.current += 1;
45
+ const i = `${L}-${w.current}`;
46
+ return T((u) => [...u, {
41
47
  ...t,
42
48
  id: i
43
49
  }]), i;
44
- }, [o]), z = X(() => ({
45
- toast: k,
46
- dismiss: a
47
- }), [k, a]);
48
- j(() => {
49
- const t = s.current;
50
+ }, [L]), R = X(() => ({
51
+ toast: A,
52
+ dismiss: $
53
+ }), [A, $]);
54
+ z(() => {
55
+ const t = d.current;
50
56
  return t?.showPopover?.(), () => {
51
57
  t?.matches(":popover-open") && t.hidePopover?.();
52
58
  };
53
- }, [e]), w(() => {
54
- const t = () => B(document.visibilityState === "hidden");
59
+ }, [n]), E(() => {
60
+ const t = () => b(document.visibilityState === "hidden");
55
61
  return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
56
- }, []), w(() => {
57
- r && !v.some((t) => !t.leaving) && l(!1);
58
- }, [r, v]);
59
- const O = v.filter((t) => !t.leaving), R = new Set(O.slice(-p).map((t) => t.id)), U = P || r || d, A = /* @__PURE__ */ m("section", {
60
- ref: s,
61
- "aria-label": b.region,
62
+ }, []), E(() => {
63
+ f && !c.some((t) => !t.leaving) && s(!1);
64
+ }, [f, c]);
65
+ const U = c.filter((t) => !t.leaving), V = new Set(U.slice(-a).map((t) => t.id)), W = x || f || F, H = /* @__PURE__ */ m("section", {
66
+ ref: d,
67
+ "aria-label": r.region,
62
68
  popover: "manual",
63
- className: I ? `cy-toaster ${I}` : "cy-toaster",
64
- "data-position": y,
65
- style: h,
66
- onPointerEnter: () => g(!0),
67
- onPointerLeave: () => g(!1),
68
- onFocus: () => l(!0),
69
+ className: h ? `cy-toaster ${h}` : "cy-toaster",
70
+ "data-position": o,
71
+ style: {
72
+ ...lt(g),
73
+ ...N
74
+ },
75
+ onPointerEnter: () => l(!0),
76
+ onPointerLeave: () => l(!1),
77
+ onFocus: () => s(!0),
69
78
  onBlur: (t) => {
70
- t.currentTarget.contains(t.relatedTarget) || l(!1);
79
+ t.currentTarget.contains(t.relatedTarget) || s(!1);
71
80
  },
72
- children: v.map((t) => /* @__PURE__ */ m(it, {
81
+ children: c.map((t) => /* @__PURE__ */ m(ut, {
73
82
  item: t,
74
- collapsed: !t.leaving && !R.has(t.id),
75
- paused: U,
76
- dismissLabel: b.dismiss,
77
- onDismiss: a,
78
- onRemoved: n,
79
- memory: T.current
83
+ collapsed: !t.leaving && !V.has(t.id),
84
+ paused: W,
85
+ dismissLabel: r.dismiss,
86
+ onDismiss: $,
87
+ onRemoved: p,
88
+ memory: k.current
80
89
  }, t.id))
81
90
  });
82
- return /* @__PURE__ */ $(q.Provider, {
83
- value: z,
84
- children: [/* @__PURE__ */ m(Q.Provider, {
85
- value: F,
86
- children: N
87
- }), e ? ot(A, e) : A]
91
+ return /* @__PURE__ */ M(O.Provider, {
92
+ value: R,
93
+ children: [/* @__PURE__ */ m(Z.Provider, {
94
+ value: e,
95
+ children: S
96
+ }), n ? it(H, n) : H]
88
97
  });
89
98
  }
90
- function it({ item: y, collapsed: p, paused: E, dismissLabel: I, onDismiss: h, onRemoved: N, memory: b }) {
91
- const { id: o, title: S, description: v, tone: u = "neutral", action: P, duration: g = 5e3, leaving: r = !1 } = y, l = C(null), [d] = f(() => {
92
- const e = b.get(o) ?? { announced: !1 };
93
- return b.set(o, e), e;
94
- }), [B] = f(d.announced), s = C(null), [T, D] = f(d.announced);
95
- w(() => {
96
- if (T) return;
99
+ function ut({ item: o, collapsed: a, paused: g, dismissLabel: y, onDismiss: h, onRemoved: N, memory: S }) {
100
+ const { id: r, title: L, description: w, tone: c = "neutral", action: T, duration: x = 5e3, leaving: l = !1 } = o, f = I(null), [s] = v(() => {
101
+ const e = S.get(r) ?? { announced: !1 };
102
+ return S.set(r, e), e;
103
+ }), [F] = v(s.announced), b = I(null), [d, k] = v(s.announced);
104
+ E(() => {
105
+ if (d) return;
97
106
  const e = setTimeout(() => {
98
- d.announced = !0, D(!0);
107
+ s.announced = !0, k(!0);
99
108
  }, 50);
100
109
  return () => clearTimeout(e);
101
- }, [T, d]), j(() => {
102
- l.current && (l.current.inert = p || r);
103
- }, [p, r]), w(() => {
104
- if (E || p || r || !Number.isFinite(g) || g <= 0) return;
105
- const e = Date.now(), n = d.remaining ?? g, a = setTimeout(() => h(o), Math.max(n, 0));
110
+ }, [d, s]), z(() => {
111
+ f.current && (f.current.inert = a || l);
112
+ }, [a, l]), E(() => {
113
+ if (g || a || l || !Number.isFinite(x) || x <= 0) return;
114
+ const e = Date.now(), n = s.remaining ?? x, p = setTimeout(() => h(r), Math.max(n, 0));
106
115
  return () => {
107
- clearTimeout(a), d.remaining = n - (Date.now() - e);
116
+ clearTimeout(p), s.remaining = n - (Date.now() - e);
108
117
  };
109
118
  }, [
110
- E,
111
- p,
112
- r,
113
119
  g,
114
- o,
120
+ a,
121
+ l,
122
+ x,
123
+ r,
115
124
  h,
116
- d
117
- ]), w(() => {
118
- if (!r) return;
119
- const e = l.current, n = e && Number.parseFloat(getComputedStyle(e).transitionDuration) * 1e3 || 0, a = setTimeout(() => N(o), n);
120
- return () => clearTimeout(a);
125
+ s
126
+ ]), E(() => {
127
+ if (!l) return;
128
+ const e = f.current, n = e && Number.parseFloat(getComputedStyle(e).transitionDuration) * 1e3 || 0, p = setTimeout(() => N(r), n);
129
+ return () => clearTimeout(p);
121
130
  }, [
131
+ l,
122
132
  r,
123
- o,
124
133
  N
125
134
  ]);
126
- const L = (e) => {
127
- const n = s.current;
135
+ const _ = (e) => {
136
+ const n = b.current;
128
137
  if (!n || n.pointer !== e.pointerId) return;
129
- s.current = null;
130
- const a = e.currentTarget;
131
- delete a.dataset.swiping, Math.abs(e.clientX - n.x) >= st ? h(o) : a.style.removeProperty("--_dx");
132
- }, F = Y[u];
133
- return /* @__PURE__ */ $("div", {
134
- ref: l,
135
- role: u === "danger" && !B ? "alert" : "status",
138
+ b.current = null;
139
+ const p = e.currentTarget;
140
+ delete p.dataset.swiping, Math.abs(e.clientX - n.x) >= ct ? h(r) : p.style.removeProperty("--_dx");
141
+ }, C = et[c];
142
+ return /* @__PURE__ */ M("div", {
143
+ ref: f,
144
+ role: c === "danger" && !F ? "alert" : "status",
136
145
  "aria-atomic": "true",
137
146
  className: "cy-toast",
138
- "data-id": o,
139
- "data-tone": u,
140
- "data-collapsed": p || void 0,
141
- "data-leaving": r || void 0,
147
+ "data-id": r,
148
+ "data-tone": c,
149
+ "data-collapsed": a || void 0,
150
+ "data-leaving": l || void 0,
142
151
  onPointerDown: (e) => {
143
- e.pointerType === "touch" && (s.current = {
152
+ e.pointerType === "touch" && (b.current = {
144
153
  x: e.clientX,
145
154
  pointer: e.pointerId
146
155
  });
147
156
  },
148
157
  onPointerMove: (e) => {
149
- const n = s.current;
158
+ const n = b.current;
150
159
  !n || n.pointer !== e.pointerId || (e.currentTarget.dataset.swiping = "", e.currentTarget.style.setProperty("--_dx", `${e.clientX - n.x}px`));
151
160
  },
152
- onPointerUp: L,
161
+ onPointerUp: _,
153
162
  onPointerCancel: (e) => {
154
- s.current = null, delete e.currentTarget.dataset.swiping, e.currentTarget.style.removeProperty("--_dx");
163
+ b.current = null, delete e.currentTarget.dataset.swiping, e.currentTarget.style.removeProperty("--_dx");
155
164
  },
156
165
  children: [
157
- F && /* @__PURE__ */ m(W, {
158
- icon: F,
166
+ C && /* @__PURE__ */ m(J, {
167
+ icon: C,
159
168
  className: "cy-toast-icon"
160
169
  }),
161
170
  /* @__PURE__ */ m("div", {
162
171
  className: "cy-toast-text cy-reset",
163
- children: T && /* @__PURE__ */ $(nt, { children: [/* @__PURE__ */ m("span", {
172
+ children: d && /* @__PURE__ */ M(st, { children: [/* @__PURE__ */ m("span", {
164
173
  className: "cy-toast-title cy-reset",
165
- children: S
166
- }), v && /* @__PURE__ */ m("span", {
174
+ children: L
175
+ }), w && /* @__PURE__ */ m("span", {
167
176
  className: "cy-toast-description cy-reset",
168
- children: v
177
+ children: w
169
178
  })] })
170
179
  }),
171
- P && /* @__PURE__ */ m(G, {
180
+ T && /* @__PURE__ */ m(K, {
172
181
  size: "sm",
173
182
  variant: "soft",
174
- tone: u === "neutral" ? "accent" : u,
175
- onClick: P.onClick,
176
- children: P.label
183
+ tone: c === "neutral" ? "accent" : c,
184
+ onClick: T.onClick,
185
+ children: T.label
177
186
  }),
178
- /* @__PURE__ */ m(J, {
179
- icon: K,
180
- label: I,
187
+ /* @__PURE__ */ m(Q, {
188
+ icon: Y,
189
+ label: y,
181
190
  variant: "ghost",
182
191
  size: "sm",
183
- onClick: () => h(o)
192
+ onClick: () => h(r)
184
193
  })
185
194
  ]
186
195
  });
187
196
  }
188
197
  export {
189
- ht as Toaster,
190
- yt as useToast
198
+ wt as Toaster,
199
+ Pt as useToast
191
200
  };
192
201
 
193
202
  //# sourceMappingURL=Toast.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.js","names":["_Fragment","closeIcon","Icon","useClientLayoutEffect","Button","IconButton","close","ToastHostContext","TONE_ICONS","createContext","useCallback","useContext","useEffect","useId","useMemo","useRef","useState","Fragment$1","jsx","jsxs","createPortal","DEFAULT_LABELS","SWIPE","ToastContext","useToast","api","Toaster","position","max","labels","className","style","children","text","prefix","count","items","setItems","hovered","setHovered","focused","setFocused","hidden","setHidden","region","memory","hosts","setHosts","registry","el","list","h","host","remove","id","t","dismiss","active","holder","others","next","button","toast","options","onVisibility","live","shown","paused","regionEl","e","item","ToastItem","collapsed","dismissLabel","onDismiss","onRemoved","title","description","tone","action","duration","leaving","mem","found","announcedBefore","drag","ready","setReady","started","left","node","ms","endSwipe","event","start","icon"],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import {\n type CSSProperties,\n createContext,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { TONE_ICONS } from \"../../foundations/tone-icons.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport { ToastHostContext, type ToastHostRegistry } from \"../../overlay/toast-host.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\nimport { Button } from \"../Button/Button.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface ToastTokens {\n width: string;\n radius: string;\n padding: string;\n gap: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n toast: ToastTokens;\n }\n}\n\nexport type ToastTone = Extract<Tone, \"neutral\" | \"success\" | \"danger\" | \"warning\" | \"info\">;\n\nexport interface ToastOptions {\n title: string;\n description?: string;\n /** Colour and icon. `danger` is announced assertively (`role=\"alert\"`); the others politely. */\n tone?: ToastTone;\n /** One button in the toast. It does not close the toast unless `onClick` dismisses it. */\n action?: { label: string; onClick: () => void };\n /** Milliseconds before it closes itself (default 5000). `Infinity` keeps it until dismissed. */\n duration?: number;\n}\n\nexport interface ToastApi {\n /** Shows a toast and returns its id. */\n toast: (options: ToastOptions) => string;\n /** Closes one toast, or all of them without an id. */\n dismiss: (id?: string) => void;\n}\n\nexport type ToastPosition =\n | \"top-start\"\n | \"top-center\"\n | \"top-end\"\n | \"bottom-start\"\n | \"bottom-center\"\n | \"bottom-end\";\n\nexport interface ToastLabels {\n /** Name of the notifications region. */\n region: string;\n /** Accessible name of each toast's close button. */\n dismiss: string;\n}\n\nexport interface ToasterProps {\n /** Where toasts stack. `start`/`end` follow the reading direction. */\n position?: ToastPosition;\n /** How many show at once; older ones collapse until newer ones close. */\n max?: number;\n labels?: Partial<ToastLabels>;\n className?: string;\n /** Layout only, applied to the region. Restyle through --cy-toast-* tokens. */\n style?: CSSProperties;\n /** The part of the app that can call `useToast()`. */\n children?: ReactNode;\n}\n\ninterface Item extends ToastOptions {\n id: string;\n leaving?: boolean;\n}\n\nconst DEFAULT_LABELS: ToastLabels = { region: \"Notifications\", dismiss: \"Dismiss\" };\n/** Horizontal distance a touch has to travel to swipe a toast away. */\nconst SWIPE = 64;\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/** `toast()` and `dismiss()` for the nearest `<Toaster>`. */\nexport function useToast(): ToastApi {\n const api = useContext(ToastContext);\n if (!api) throw new Error(\"useToast() needs a <Toaster> around it.\");\n return api;\n}\n\ntype RegionEl = HTMLElement & { showPopover?: () => void; hidePopover?: () => void };\n\n/** What a toast keeps when its element is re-created (the region moved into or out of a Dialog). */\ninterface Memory {\n announced: boolean;\n remaining?: number;\n}\ntype MemoryMap = Map<string, Memory>;\n\n/**\n * Hosts toasts for everything inside it: a region in the top layer, a store per Toaster (no globals), timers that pause\n * while the pointer or focus is on a toast, and polite or assertive announcements.\n */\nexport function Toaster({\n position = \"bottom-end\",\n max = 3,\n labels,\n className,\n style,\n children,\n}: ToasterProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const prefix = useId();\n const count = useRef(0);\n const [items, setItems] = useState<Item[]>([]);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [hidden, setHidden] = useState(false);\n const region = useRef<RegionEl>(null);\n const memory = useRef<MemoryMap>(new Map());\n // Containers lent by open modal Dialogs; the latest one hosts the region.\n const [hosts, setHosts] = useState<HTMLElement[]>([]);\n const registry = useMemo<ToastHostRegistry>(\n () => ({\n register: (el) => {\n setHosts((list) => [...list, el]);\n return () => setHosts((list) => list.filter((h) => h !== el));\n },\n }),\n [],\n );\n const host = hosts.at(-1) ?? null;\n\n const remove = useCallback((id: string) => {\n memory.current.delete(id);\n setItems((list) => list.filter((t) => t.id !== id));\n }, []);\n const dismiss = useCallback((id?: string) => {\n // Closing the toast that holds focus (its close button, from the keyboard): hand focus to the next toast's close\n // button, or let the region stop pausing if there is none.\n const active = region.current?.ownerDocument.activeElement;\n const holder = active?.closest<HTMLElement>(\".cy-toast\");\n if (holder && region.current?.contains(holder) && (id === undefined || holder.dataset.id === id)) {\n const others = [\n ...region.current.querySelectorAll<HTMLElement>(\n \".cy-toast:not([data-collapsed]):not([data-leaving])\",\n ),\n ];\n const next = id === undefined ? undefined : others.find((t) => t !== holder);\n const button = next ? [...next.querySelectorAll<HTMLElement>(\"button\")].at(-1) : undefined;\n if (button) button.focus();\n else {\n (active as HTMLElement).blur();\n setFocused(false);\n }\n }\n setItems((list) => list.map((t) => (id === undefined || t.id === id ? { ...t, leaving: true } : t)));\n }, []);\n const toast = useCallback(\n (options: ToastOptions) => {\n count.current += 1;\n const id = `${prefix}-${count.current}`;\n setItems((list) => [...list, { ...options, id }]);\n return id;\n },\n [prefix],\n );\n const api = useMemo<ToastApi>(() => ({ toast, dismiss }), [toast, dismiss]);\n\n // The region lives in the top layer for as long as the Toaster is mounted, so live regions exist before content.\n // It is re-created when it moves into or out of a Dialog; showing it again puts it on top of that dialog.\n useClientLayoutEffect(() => {\n const el = region.current;\n el?.showPopover?.();\n return () => {\n if (el?.matches(\":popover-open\")) el.hidePopover?.();\n };\n }, [host]);\n useEffect(() => {\n const onVisibility = () => setHidden(document.visibilityState === \"hidden\");\n document.addEventListener(\"visibilitychange\", onVisibility);\n return () => document.removeEventListener(\"visibilitychange\", onVisibility);\n }, []);\n // Focus left the region entirely (a toast closing with focus inside also counts).\n useEffect(() => {\n if (focused && !items.some((t) => !t.leaving)) setFocused(false);\n }, [focused, items]);\n\n const live = items.filter((t) => !t.leaving);\n const shown = new Set(live.slice(-max).map((t) => t.id));\n const paused = hovered || focused || hidden;\n\n const regionEl = (\n <section\n ref={region}\n aria-label={text.region}\n {...{ popover: \"manual\" }}\n className={className ? `cy-toaster ${className}` : \"cy-toaster\"}\n data-position={position}\n style={style}\n onPointerEnter={() => setHovered(true)}\n onPointerLeave={() => setHovered(false)}\n onFocus={() => setFocused(true)}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocused(false);\n }}\n >\n {items.map((item) => (\n <ToastItem\n key={item.id}\n item={item}\n collapsed={!item.leaving && !shown.has(item.id)}\n paused={paused}\n dismissLabel={text.dismiss}\n onDismiss={dismiss}\n onRemoved={remove}\n memory={memory.current}\n />\n ))}\n </section>\n );\n\n return (\n <ToastContext.Provider value={api}>\n <ToastHostContext.Provider value={registry}>{children}</ToastHostContext.Provider>\n {host ? createPortal(regionEl, host) : regionEl}\n </ToastContext.Provider>\n );\n}\n\ninterface ToastItemProps {\n item: Item;\n collapsed: boolean;\n paused: boolean;\n dismissLabel: string;\n onDismiss: (id: string) => void;\n onRemoved: (id: string) => void;\n memory: MemoryMap;\n}\n\nfunction ToastItem({ item, collapsed, paused, dismissLabel, onDismiss, onRemoved, memory }: ToastItemProps) {\n const { id, title, description, tone = \"neutral\", action, duration = 5000, leaving = false } = item;\n const el = useRef<HTMLDivElement>(null);\n // Survives the element being re-created (region moved into or out of a Dialog).\n const [mem] = useState<Memory>(() => {\n const found = memory.get(id) ?? { announced: false };\n memory.set(id, found);\n return found;\n });\n const [announcedBefore] = useState(mem.announced);\n const drag = useRef<{ x: number; pointer: number } | null>(null);\n // The live element exists (empty) first and its text arrives a moment later: screen readers announce text added to\n // a live region, and the text is added once, so the toast is announced once.\n // Already announced (re-created after a move): show the text at once, so nothing is inserted to announce again.\n const [ready, setReady] = useState(mem.announced);\n useEffect(() => {\n if (ready) return;\n const t = setTimeout(() => {\n mem.announced = true;\n setReady(true);\n }, 50);\n return () => clearTimeout(t);\n }, [ready, mem]);\n\n // Collapsed and leaving toasts cannot be focused or clicked. Set as a property: React 18 drops `inert={true}`.\n useClientLayoutEffect(() => {\n if (el.current) el.current.inert = collapsed || leaving;\n }, [collapsed, leaving]);\n\n // Auto-dismiss, keeping the time already spent across pauses and moves. The time left lives in `mem`, read when the\n // timer starts: a re-created toast's effects run after the old one has saved it.\n useEffect(() => {\n if (paused || collapsed || leaving || !Number.isFinite(duration) || duration <= 0) return;\n const started = Date.now();\n const left = mem.remaining ?? duration;\n const t = setTimeout(() => onDismiss(id), Math.max(left, 0));\n return () => {\n clearTimeout(t);\n mem.remaining = left - (Date.now() - started);\n };\n }, [paused, collapsed, leaving, duration, id, onDismiss, mem]);\n\n // Leaving: play the exit transition (none under reduced motion), then drop it from the store.\n useEffect(() => {\n if (!leaving) return;\n const node = el.current;\n const ms = node ? Number.parseFloat(getComputedStyle(node).transitionDuration) * 1000 || 0 : 0;\n const t = setTimeout(() => onRemoved(id), ms);\n return () => clearTimeout(t);\n }, [leaving, id, onRemoved]);\n\n const endSwipe = (event: PointerEvent<HTMLDivElement>) => {\n const start = drag.current;\n if (!start || start.pointer !== event.pointerId) return;\n drag.current = null;\n const node = event.currentTarget;\n delete node.dataset.swiping;\n if (Math.abs(event.clientX - start.x) >= SWIPE) onDismiss(id);\n else node.style.removeProperty(\"--_dx\");\n };\n\n const icon = TONE_ICONS[tone];\n return (\n <div\n ref={el}\n // An alert announces whenever it appears; one already announced comes back as a status.\n role={tone === \"danger\" && !announcedBefore ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n className=\"cy-toast\"\n data-id={id}\n data-tone={tone}\n data-collapsed={collapsed || undefined}\n data-leaving={leaving || undefined}\n onPointerDown={(event) => {\n if (event.pointerType !== \"touch\") return;\n drag.current = { x: event.clientX, pointer: event.pointerId };\n }}\n onPointerMove={(event) => {\n const start = drag.current;\n if (!start || start.pointer !== event.pointerId) return;\n event.currentTarget.dataset.swiping = \"\";\n event.currentTarget.style.setProperty(\"--_dx\", `${event.clientX - start.x}px`);\n }}\n onPointerUp={endSwipe}\n onPointerCancel={(event) => {\n // The browser took the gesture (a scroll): spring back, never dismiss.\n drag.current = null;\n delete event.currentTarget.dataset.swiping;\n event.currentTarget.style.removeProperty(\"--_dx\");\n }}\n >\n {icon && <Icon icon={icon} className=\"cy-toast-icon\" />}\n <div className=\"cy-toast-text cy-reset\">\n {ready && (\n <>\n <span className=\"cy-toast-title cy-reset\">{title}</span>\n {description && <span className=\"cy-toast-description cy-reset\">{description}</span>}\n </>\n )}\n </div>\n {action && (\n <Button size=\"sm\" variant=\"soft\" tone={tone === \"neutral\" ? \"accent\" : tone} onClick={action.onClick}>\n {action.label}\n </Button>\n )}\n <IconButton\n icon={closeIcon}\n label={dismissLabel}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => onDism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AK;AAAA,QAAK,SAAQ;AAAA,QAAO,MAAM0E,MAAS,YAAY,WAAWA;AAAA,QAAM,SAASC,EAAO;AAAA,QAC1F,UAAAA,EAAO;AAAA,MACF,CAAA;AAAA,MAEV,gBAAA7D,EAACb,GAAD;AAAA,QACE,MAAMJ;AAAAA,QACN,OAAOwE;AAAA,QACP,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,SAAA,MAAeC,EAAUpB,CAAE;AAAA,MAC5B,CAAA;AAAA,IACE;AAAA,E;AAET"}
1
+ {"version":3,"file":"Toast.js","names":["_Fragment","closeIcon","Icon","useClientLayoutEffect","Button","IconButton","close","ToastHostContext","space","TONE_ICONS","createContext","useCallback","useContext","useEffect","useId","useMemo","useRef","useState","Fragment$1","jsx","jsxs","createPortal","DEFAULT_LABELS","SWIPE","length","value","offsetVars","offset","block","inline","vars","ToastContext","useToast","api","Toaster","position","max","labels","className","style","children","text","prefix","count","items","setItems","hovered","setHovered","focused","setFocused","hidden","setHidden","region","memory","hosts","setHosts","registry","el","list","h","host","remove","id","t","dismiss","active","holder","others","next","button","toast","options","onVisibility","live","shown","paused","regionEl","e","item","ToastItem","collapsed","dismissLabel","onDismiss","onRemoved","title","description","tone","action","duration","leaving","mem","found","announcedBefore","drag","ready","setReady","started","left","node","ms","endSwipe","event","start","icon"],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import {\n type CSSProperties,\n createContext,\n type PointerEvent,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { TONE_ICONS } from \"../../foundations/tone-icons.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport { ToastHostContext, type ToastHostRegistry } from \"../../overlay/toast-host.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\nimport { Button } from \"../Button/Button.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { type Space, space } from \"../Stack/space.js\";\n\nexport interface ToastTokens {\n width: string;\n radius: string;\n padding: string;\n gap: string;\n /** Extra distance between the toasts and the top or bottom edge they sit on (a fixed tab bar or header). */\n offsetBlock: string;\n /** Extra distance between the toasts and the side they sit on (a fixed side rail). */\n offsetInline: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n toast: ToastTokens;\n }\n}\n\nexport type ToastTone = Extract<Tone, \"neutral\" | \"success\" | \"danger\" | \"warning\" | \"info\">;\n\nexport interface ToastOptions {\n title: string;\n description?: string;\n /** Colour and icon. `danger` is announced assertively (`role=\"alert\"`); the others politely. */\n tone?: ToastTone;\n /** One button in the toast. It does not close the toast unless `onClick` dismisses it. */\n action?: { label: string; onClick: () => void };\n /** Milliseconds before it closes itself (default 5000). `Infinity` keeps it until dismissed. */\n duration?: number;\n}\n\nexport interface ToastApi {\n /** Shows a toast and returns its id. */\n toast: (options: ToastOptions) => string;\n /** Closes one toast, or all of them without an id. */\n dismiss: (id?: string) => void;\n}\n\nexport type ToastPosition =\n | \"top-start\"\n | \"top-center\"\n | \"top-end\"\n | \"bottom-start\"\n | \"bottom-center\"\n | \"bottom-end\";\n\n/** A distance: a step of the space scale (`\"6\"` is `--cy-space-6`) or any CSS length (`\"72px\"`, `\"calc(56px + 1rem)\"`). */\nexport type ToastOffsetLength = Space | (string & {});\n\n/** How far in from their edges the toasts sit, for each axis. */\nexport interface ToastOffset {\n /** From the top or bottom edge, whichever `position` names. */\n block?: ToastOffsetLength | undefined;\n /** From the side `position` names (both sides for `center`). Follows the reading direction. */\n inline?: ToastOffsetLength | undefined;\n}\n\nexport interface ToastLabels {\n /** Name of the notifications region. */\n region: string;\n /** Accessible name of each toast's close button. */\n dismiss: string;\n}\n\nexport interface ToasterProps {\n /** Where toasts stack. `start`/`end` follow the reading direction. */\n position?: ToastPosition;\n /** How many show at once; older ones collapse until newer ones close. */\n max?: number;\n /**\n * Keeps the toasts clear of fixed parts of the app, such as a bottom tab bar: extra distance from the edge they sit\n * on, added to the usual margin and the device's safe area. A step of the space scale (`\"8\"`) or a CSS length\n * (`\"72px\"`) moves them in from the top or bottom edge; `{ block, inline }` sets that and the distance from the\n * side. To set it from CSS instead (only below a breakpoint, say) use the `--cy-toast-offset-block` and\n * `--cy-toast-offset-inline` tokens; this prop wins over them. Default: none.\n */\n offset?: ToastOffsetLength | ToastOffset | undefined;\n /** Replace the built-in English text: the region's name and the close button's name. */\n labels?: Partial<ToastLabels>;\n /** Added to the notifications region, for layout. */\n className?: string;\n /** Layout only, applied to the region. Restyle through --cy-toast-* tokens. */\n style?: CSSProperties;\n /** The part of the app that can call `useToast()`. */\n children?: ReactNode;\n}\n\ninterface Item extends ToastOptions {\n id: string;\n leaving?: boolean;\n}\n\nconst DEFAULT_LABELS: ToastLabels = { region: \"Notifications\", dismiss: \"Dismiss\" };\n/** Horizontal distance a touch has to travel to swipe a toast away. */\nconst SWIPE = 64;\n\nconst length = (value: ToastOffsetLength) => (/^(\\d|10)$/.test(value) ? space(value as Space) : value);\n/** The private custom properties toast.css reads the `offset` prop from; an axis that is not set is left to the token. */\nfunction offsetVars(offset: ToasterProps[\"offset\"]) {\n const { block, inline }: ToastOffset = typeof offset === \"object\" ? offset : { block: offset };\n const vars: Record<string, string> = {};\n if (block) vars[\"--_offset-block\"] = length(block);\n if (inline) vars[\"--_offset-inline\"] = length(inline);\n return vars;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/** `toast()` and `dismiss()` for the nearest `<Toaster>`. */\nexport function useToast(): ToastApi {\n const api = useContext(ToastContext);\n if (!api) throw new Error(\"useToast() needs a <Toaster> around it.\");\n return api;\n}\n\ntype RegionEl = HTMLElement & { showPopover?: () => void; hidePopover?: () => void };\n\n/** What a toast keeps when its element is re-created (the region moved into or out of a Dialog). */\ninterface Memory {\n announced: boolean;\n remaining?: number;\n}\ntype MemoryMap = Map<string, Memory>;\n\n/**\n * Hosts toasts for everything inside it: a region in the top layer, a store per Toaster (no globals), timers that pause\n * while the pointer or focus is on a toast, and polite or assertive announcements.\n */\nexport function Toaster({\n position = \"bottom-end\",\n max = 3,\n offset,\n labels,\n className,\n style,\n children,\n}: ToasterProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const prefix = useId();\n const count = useRef(0);\n const [items, setItems] = useState<Item[]>([]);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [hidden, setHidden] = useState(false);\n const region = useRef<RegionEl>(null);\n const memory = useRef<MemoryMap>(new Map());\n // Containers lent by open modal Dialogs; the latest one hosts the region.\n const [hosts, setHosts] = useState<HTMLElement[]>([]);\n const registry = useMemo<ToastHostRegistry>(\n () => ({\n register: (el) => {\n setHosts((list) => [...list, el]);\n return () => setHosts((list) => list.filter((h) => h !== el));\n },\n }),\n [],\n );\n const host = hosts.at(-1) ?? null;\n\n const remove = useCallback((id: string) => {\n memory.current.delete(id);\n setItems((list) => list.filter((t) => t.id !== id));\n }, []);\n const dismiss = useCallback((id?: string) => {\n // Closing the toast that holds focus (its close button, from the keyboard): hand focus to the next toast's close\n // button, or let the region stop pausing if there is none.\n const active = region.current?.ownerDocument.activeElement;\n const holder = active?.closest<HTMLElement>(\".cy-toast\");\n if (holder && region.current?.contains(holder) && (id === undefined || holder.dataset.id === id)) {\n const others = [\n ...region.current.querySelectorAll<HTMLElement>(\n \".cy-toast:not([data-collapsed]):not([data-leaving])\",\n ),\n ];\n const next = id === undefined ? undefined : others.find((t) => t !== holder);\n const button = next ? [...next.querySelectorAll<HTMLElement>(\"button\")].at(-1) : undefined;\n if (button) button.focus();\n else {\n (active as HTMLElement).blur();\n setFocused(false);\n }\n }\n setItems((list) => list.map((t) => (id === undefined || t.id === id ? { ...t, leaving: true } : t)));\n }, []);\n const toast = useCallback(\n (options: ToastOptions) => {\n count.current += 1;\n const id = `${prefix}-${count.current}`;\n setItems((list) => [...list, { ...options, id }]);\n return id;\n },\n [prefix],\n );\n const api = useMemo<ToastApi>(() => ({ toast, dismiss }), [toast, dismiss]);\n\n // The region lives in the top layer for as long as the Toaster is mounted, so live regions exist before content.\n // It is re-created when it moves into or out of a Dialog; showing it again puts it on top of that dialog.\n useClientLayoutEffect(() => {\n const el = region.current;\n el?.showPopover?.();\n return () => {\n if (el?.matches(\":popover-open\")) el.hidePopover?.();\n };\n }, [host]);\n useEffect(() => {\n const onVisibility = () => setHidden(document.visibilityState === \"hidden\");\n document.addEventListener(\"visibilitychange\", onVisibility);\n return () => document.removeEventListener(\"visibilitychange\", onVisibility);\n }, []);\n // Focus left the region entirely (a toast closing with focus inside also counts).\n useEffect(() => {\n if (focused && !items.some((t) => !t.leaving)) setFocused(false);\n }, [focused, items]);\n\n const live = items.filter((t) => !t.leaving);\n const shown = new Set(live.slice(-max).map((t) => t.id));\n const paused = hovered || focused || hidden;\n\n const regionEl = (\n <section\n ref={region}\n aria-label={text.region}\n {...{ popover: \"manual\" }}\n className={className ? `cy-toaster ${className}` : \"cy-toaster\"}\n data-position={position}\n style={{ ...offsetVars(offset), ...style }}\n onPointerEnter={() => setHovered(true)}\n onPointerLeave={() => setHovered(false)}\n onFocus={() => setFocused(true)}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocused(false);\n }}\n >\n {items.map((item) => (\n <ToastItem\n key={item.id}\n item={item}\n collapsed={!item.leaving && !shown.has(item.id)}\n paused={paused}\n dismissLabel={text.dismiss}\n onDismiss={dismiss}\n onRemoved={remove}\n memory={memory.current}\n />\n ))}\n </section>\n );\n\n return (\n <ToastContext.Provider value={api}>\n <ToastHostContext.Provider value={registry}>{children}</ToastHostContext.Provider>\n {host ? createPortal(regionEl, host) : regionEl}\n </ToastContext.Provider>\n );\n}\n\ninterface ToastItemProps {\n item: Item;\n collapsed: boolean;\n paused: boolean;\n dismissLabel: string;\n onDismiss: (id: string) => void;\n onRemoved: (id: string) => void;\n memory: MemoryMap;\n}\n\nfunction ToastItem({ item, collapsed, paused, dismissLabel, onDismiss, onRemoved, memory }: ToastItemProps) {\n const { id, title, description, tone = \"neutral\", action, duration = 5000, leaving = false } = item;\n const el = useRef<HTMLDivElement>(null);\n // Survives the element being re-created (region moved into or out of a Dialog).\n const [mem] = useState<Memory>(() => {\n const found = memory.get(id) ?? { announced: false };\n memory.set(id, found);\n return found;\n });\n const [announcedBefore] = useState(mem.announced);\n const drag = useRef<{ x: number; pointer: number } | null>(null);\n // The live element exists (empty) first and its text arrives a moment later: screen readers announce text added to\n // a live region, and the text is added once, so the toast is announced once.\n // Already announced (re-created after a move): show the text at once, so nothing is inserted to announce again.\n const [ready, setReady] = useState(mem.announced);\n useEffect(() => {\n if (ready) return;\n const t = setTimeout(() => {\n mem.announced = true;\n setReady(true);\n }, 50);\n return () => clearTimeout(t);\n }, [ready, mem]);\n\n // Collapsed and leaving toasts cannot be focused or clicked. Set as a property: React 18 drops `inert={true}`.\n useClientLayoutEffect(() => {\n if (el.current) el.current.inert = collapsed || leaving;\n }, [collapsed, leaving]);\n\n // Auto-dismiss, keeping the time already spent across pauses and moves. The time left lives in `mem`, read when the\n // timer starts: a re-created toast's effects run after the old one has saved it.\n useEffect(() => {\n if (paused || collapsed || leaving || !Number.isFinite(duration) || duration <= 0) return;\n const started = Date.now();\n const left = mem.remaining ?? duration;\n const t = setTimeout(() => onDismiss(id), Math.max(left, 0));\n return () => {\n clearTimeout(t);\n mem.remaining = left - (Date.now() - started);\n };\n }, [paused, collapsed, leaving, duration, id, onDismiss, mem]);\n\n // Leaving: play the exit transition (none under reduced motion), then drop it from the store.\n useEffect(() => {\n if (!leaving) return;\n const node = el.current;\n const ms = node ? Number.parseFloat(getComputedStyle(node).transitionDuration) * 1000 || 0 : 0;\n const t = setTimeout(() => onRemoved(id), ms);\n return () => clearTimeout(t);\n }, [leaving, id, onRemoved]);\n\n const endSwipe = (event: PointerEvent<HTMLDivElement>) => {\n const start = drag.current;\n if (!start || start.pointer !== event.pointerId) return;\n drag.current = null;\n const node = event.currentTarget;\n delete node.dataset.swiping;\n if (Math.abs(event.clientX - start.x) >= SWIPE) onDismiss(id);\n else node.style.removeProperty(\"--_dx\");\n };\n\n const icon = TONE_ICONS[tone];\n return (\n <div\n ref={el}\n // An alert announces whenever it appears; one already announced comes back as a status.\n role={tone === \"danger\" && !announcedBefore ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n className=\"cy-toast\"\n data-id={id}\n data-tone={tone}\n data-collapsed={collapsed || undefined}\n data-leaving={leaving || undefined}\n onPointerDown={(event) => {\n if (event.pointerType !== \"touch\") return;\n drag.current = { x: event.clientX, pointer: event.pointerId };\n }}\n onPointerMove={(event) => {\n const start = drag.current;\n if (!start || start.pointer !== event.pointerId) return;\n event.currentTarget.dataset.swiping = \"\";\n event.currentTarget.style.setProperty(\"--_dx\", `${event.clientX - start.x}px`);\n }}\n onPointerUp={endSwipe}\n onPointerCancel={(event) => {\n // The browser took the gesture (a scroll): spring back, never dismiss.\n drag.current = null;\n delete event.currentTarget.dataset.swiping;\n event.currentTarget.style.removeProperty(\"--_dx\");\n }}\n >\n {icon && <Icon icon={icon} className=\"cy-toast-icon\" />}\n <div className=\"cy-toast-text cy-reset\">\n {ready && (\n <>\n <span className=\"cy-toast-title cy-reset\">{title}</span>\n {description && <span className=\"cy-toast-description cy-reset\">{description}</span>}\n </>\n )}\n </div>\n {action && (\n <Button size=\"sm\" variant=\"soft\" tone={tone === \"neutral\" ? \"accent\" : tone} onClick={action.onClick}>\n {action.label}\n </Button>\n )}\n <IconButton\n icon={closeIcon}\n label={dismissLabel}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => onDismiss(id)}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAmHA,IAAMsB,KAA8B;AAAA,EAAE,QAAQ;AAAA,EAAiB,SAAS;AAAU,GAE5EC,KAAQ,IAERC,IAAA,CAAUC,MAA8B,YAAY,KAAKA,CAAK,IAAIjB,GAAMiB,CAAc,IAAIA;AAEhG,SA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A2B,UAAAiE;AAAA,QAAY,CAAA,GACtDC,KAAe,gBAAAlE,EAAC,QAAD;AAAA,UAAM,WAAU;AAAA,UAAiC,UAAAkE;AAAA,QAAkB,CAAA,CACnF,EAAA,CAAA;AAAA,MAED,CAAA;AAAA,MACJE,KACC,gBAAApE,EAACf,GAAD;AAAA,QAAQ,MAAK;AAAA,QAAK,SAAQ;AAAA,QAAO,MAAMkF,MAAS,YAAY,WAAWA;AAAA,QAAM,SAASC,EAAO;AAAA,QAC1F,UAAAA,EAAO;AAAA,MACF,CAAA;AAAA,MAEV,gBAAApE,EAACd,GAAD;AAAA,QACE,MAAMJ;AAAAA,QACN,OAAOgF;AAAA,QACP,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,SAAA,MAAeC,EAAUpB,CAAE;AAAA,MAC5B,CAAA;AAAA,IACE;AAAA,E;AAET"}
@@ -1 +1 @@
1
- export { type ToastApi, Toaster, type ToasterProps, type ToastLabels, type ToastOptions, type ToastPosition, type ToastTokens, type ToastTone, useToast, } from "./Toast.js";
1
+ export { type ToastApi, Toaster, type ToasterProps, type ToastLabels, type ToastOffset, type ToastOffsetLength, type ToastOptions, type ToastPosition, type ToastTokens, type ToastTone, useToast, } from "./Toast.js";
@@ -2,14 +2,17 @@ import { type CSSProperties, type ReactNode } from "react";
2
2
  export interface ToolbarProps {
3
3
  /** Accessible name (required: a toolbar must be named). */
4
4
  label: string;
5
+ /** Direction of the toolbar: Left/Right move between controls, or Up/Down when vertical. Default "horizontal". */
5
6
  orientation?: "horizontal" | "vertical";
6
7
  /** Arrow keys wrap from the last item to the first. */
7
8
  loop?: boolean;
9
+ /** Added to the root element, for layout. */
8
10
  className?: string;
9
11
  /** Layout only. */
10
12
  style?: CSSProperties;
11
13
  /** Buttons, IconButtons, SegmentedControls, fields. */
12
14
  children?: ReactNode;
15
+ /** Test id, set on the toolbar element. */
13
16
  "data-testid"?: string;
14
17
  }
15
18
  /** APG toolbar: one Tab stop; arrow keys move between controls (RTL aware), Home and End jump. */
@@ -1 +1 @@
1
- {"version":3,"file":"Toolbar.js","names":["useRovingFocus","useRef","jsx","ITEMS","Toolbar","label","orientation","loop","className","style","children","rest","ref"],"sources":["../../../src/components/Toolbar/Toolbar.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useRef } from \"react\";\nimport { useRovingFocus } from \"../../foundations/roving-focus.js\";\n\nexport interface ToolbarProps {\n /** Accessible name (required: a toolbar must be named). */\n label: string;\n orientation?: \"horizontal\" | \"vertical\";\n /** Arrow keys wrap from the last item to the first. */\n loop?: boolean;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n /** Buttons, IconButtons, SegmentedControls, fields. */\n children?: ReactNode;\n \"data-testid\"?: string;\n}\n\n/** Every focusable control inside joins the roving group (hidden form proxies excluded). */\nconst ITEMS =\n 'button, a[href], textarea, input:not([type=\"hidden\"]):not([aria-hidden=\"true\"]), [data-roving]';\n\n/** APG toolbar: one Tab stop; arrow keys move between controls (RTL aware), Home and End jump. */\nexport function Toolbar({\n label,\n orientation = \"horizontal\",\n loop = true,\n className,\n style,\n children,\n ...rest\n}: ToolbarProps) {\n const ref = useRef<HTMLDivElement>(null);\n useRovingFocus(ref, { orientation, loop, selector: ITEMS });\n return (\n <div\n ref={ref}\n {...rest}\n role=\"toolbar\"\n aria-label={label}\n aria-orientation={orientation}\n className={className ? `cy-toolbar ${className}` : \"cy-toolbar\"}\n style={style}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;AAkBA,IAAMG,IACJ;AAGF,SAAgBC,EAAQ,EACtB,OAAAC,GACA,aAAAC,IAAc,cACd,MAAAC,IAAO,IACP,WAAAC,GACA,OAAAC,GACA,UAAAC,GACA,GAAGC,EAAA,GACY;AACf,QAAMC,IAAMX,EAAuB,IAAI;AACvC,SAAAD,EAAeY,GAAK;AAAA,IAAE,aAAAN;AAAA,IAAa,MAAAC;AAAA,IAAM,UAAUJ;AAAA,EAAM,CAAC,GAExD,gBAAAD,EAAC,OAAD;AAAA,IACO,KAAAU;AAAA,IACL,GAAID;AAAA,IACJ,MAAK;AAAA,IACL,cAAYN;AAAA,IACZ,oBAAkBC;AAAA,IAClB,WAAWE,IAAY,cAAcA,CAAA,KAAc;AAAA,IAC5C,OAAAC;AAAA,IAEN,UAAAC;AAAA,EACE,CAAA;AAET"}
1
+ {"version":3,"file":"Toolbar.js","names":["useRovingFocus","useRef","jsx","ITEMS","Toolbar","label","orientation","loop","className","style","children","rest","ref"],"sources":["../../../src/components/Toolbar/Toolbar.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useRef } from \"react\";\nimport { useRovingFocus } from \"../../foundations/roving-focus.js\";\n\nexport interface ToolbarProps {\n /** Accessible name (required: a toolbar must be named). */\n label: string;\n /** Direction of the toolbar: Left/Right move between controls, or Up/Down when vertical. Default \"horizontal\". */\n orientation?: \"horizontal\" | \"vertical\";\n /** Arrow keys wrap from the last item to the first. */\n loop?: boolean;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n /** Buttons, IconButtons, SegmentedControls, fields. */\n children?: ReactNode;\n /** Test id, set on the toolbar element. */\n \"data-testid\"?: string;\n}\n\n/** Every focusable control inside joins the roving group (hidden form proxies excluded). */\nconst ITEMS =\n 'button, a[href], textarea, input:not([type=\"hidden\"]):not([aria-hidden=\"true\"]), [data-roving]';\n\n/** APG toolbar: one Tab stop; arrow keys move between controls (RTL aware), Home and End jump. */\nexport function Toolbar({\n label,\n orientation = \"horizontal\",\n loop = true,\n className,\n style,\n children,\n ...rest\n}: ToolbarProps) {\n const ref = useRef<HTMLDivElement>(null);\n useRovingFocus(ref, { orientation, loop, selector: ITEMS });\n return (\n <div\n ref={ref}\n {...rest}\n role=\"toolbar\"\n aria-label={label}\n aria-orientation={orientation}\n className={className ? `cy-toolbar ${className}` : \"cy-toolbar\"}\n style={style}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;AAqBA,IAAMG,IACJ;AAGF,SAAgBC,EAAQ,EACtB,OAAAC,GACA,aAAAC,IAAc,cACd,MAAAC,IAAO,IACP,WAAAC,GACA,OAAAC,GACA,UAAAC,GACA,GAAGC,EAAA,GACY;AACf,QAAMC,IAAMX,EAAuB,IAAI;AACvC,SAAAD,EAAeY,GAAK;AAAA,IAAE,aAAAN;AAAA,IAAa,MAAAC;AAAA,IAAM,UAAUJ;AAAA,EAAM,CAAC,GAExD,gBAAAD,EAAC,OAAD;AAAA,IACO,KAAAU;AAAA,IACL,GAAID;AAAA,IACJ,MAAK;AAAA,IACL,cAAYN;AAAA,IACZ,oBAAkBC;AAAA,IAClB,WAAWE,IAAY,cAAcA,CAAA,KAAc;AAAA,IAC5C,OAAAC;AAAA,IAEN,UAAAC;AAAA,EACE,CAAA;AAET"}
@@ -16,6 +16,7 @@ export interface TooltipProps {
16
16
  content: ReactNode;
17
17
  /** One focusable element (Button, IconButton, Link…). */
18
18
  children: ReactElement<Record<string, unknown>>;
19
+ /** Preferred side; flips when it does not fit. Default "top". */
19
20
  placement?: Placement;
20
21
  /** Hover delay in ms (focus opens immediately). */
21
22
  delay?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["useDismiss","usePopover","useAnchoredPosition","cloneElement","useCallback","useEffect","useId","useLayoutEffect","useRef","useState","jsx","jsxs","Tooltip","content","children","placement","delay","id","anchor","tip","timer","open","setOpen","trigger","triggerRef","pointerFocus","show","wait","hide"],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\n cloneElement,\n type ReactElement,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { usePopover } from \"../../overlay/floating.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { useAnchoredPosition } from \"../../overlay/use-anchored-position.js\";\n\nexport interface TooltipTokens {\n bg: string;\n ink: string;\n radius: string;\n maxWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n tooltip: TooltipTokens;\n }\n}\n\nexport interface TooltipProps {\n /** Short supplementary text; it becomes the trigger's accessible description. */\n content: ReactNode;\n /** One focusable element (Button, IconButton, Link…). */\n children: ReactElement<Record<string, unknown>>;\n placement?: Placement;\n /** Hover delay in ms (focus opens immediately). */\n delay?: number;\n}\n\n/**\n * Tooltip in the top layer (Popover API), positioned against its trigger. Opens on hover after `delay` and on\n * keyboard focus; dismissible with Escape; hoverable; never opens on touch (WCAG 1.4.13).\n */\nexport function Tooltip({ content, children, placement = \"top\", delay = 300 }: TooltipProps) {\n const id = `cy-tip-${useId().replace(/:/g, \"\")}`;\n const anchor = useRef<HTMLSpanElement>(null);\n const tip = useRef<HTMLSpanElement>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const [open, setOpen] = useState(false);\n const trigger = () => (anchor.current?.firstElementChild as HTMLElement | null) ?? anchor.current;\n const triggerRef = useRef<HTMLElement | null>(null);\n // Focus that follows a pointer press (mouse or touch) is not keyboard focus: hover handles mouse, touch never opens.\n const pointerFocus = useRef(false);\n\n const show = useCallback((wait: number) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setOpen(true), wait);\n }, []);\n const hide = useCallback((wait = 0) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setOpen(false), wait);\n }, []);\n\n useEffect(() => () => clearTimeout(timer.current), []);\n useLayoutEffect(() => {\n triggerRef.current = trigger();\n });\n usePopover(tip, open);\n // Escape closes the tooltip first when it sits inside a Popover, Menu or Dialog (shared layer stack).\n useDismiss({ open, onClose: () => setOpen(false), inside: [triggerRef, tip], outside: false });\n useAnchoredPosition(triggerRef, tip, open, placement);\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: delegated hover/focus listeners for the interactive child\n <span\n ref={anchor}\n className=\"cy-tooltip-anchor\"\n onPointerEnter={(e) => e.pointerType !== \"touch\" && show(delay)}\n onPointerLeave={() => hide(120)}\n onPointerDown={() => {\n pointerFocus.current = true;\n hide();\n }}\n onFocus={(e) => {\n if (!pointerFocus.current && (e.target as HTMLElement).matches(\":focus-visible\")) show(0);\n pointerFocus.current = false;\n }}\n onBlur={() => {\n pointerFocus.current = false;\n hide();\n }}\n >\n {cloneElement(children, {\n \"aria-describedby\": [children.props[\"aria-describedby\"], id].filter(Boolean).join(\" \"),\n })}\n <span\n ref={tip}\n id={id}\n role=\"tooltip\"\n className=\"cy-tooltip\"\n {...{ popover: \"manual\" }}\n onPointerEnter={() => clearTimeout(timer.current)}\n onPointerLeave={() => hide(120)}\n >\n {content}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;;;AA2CA,SAAgBY,EAAQ,EAAE,SAAAC,GAAS,UAAAC,GAAU,WAAAC,IAAY,OAAO,OAAAC,IAAQ,IAAA,GAAqB;AAC3F,QAAMC,IAAK,UAAUX,EAAM,EAAE,QAAQ,MAAM,EAAE,CAAA,IACvCY,IAASV,EAAwB,IAAI,GACrCW,IAAMX,EAAwB,IAAI,GAClCY,IAAQZ,EAAkD,MAAS,GACnE,CAACa,GAAMC,CAAA,IAAWb,EAAS,EAAK,GAChCc,IAAA,MAAiBL,EAAO,SAAS,qBAA4CA,EAAO,SACpFM,IAAahB,EAA2B,IAAI,GAE5CiB,IAAejB,EAAO,EAAK,GAE3BkB,IAAOtB,EAAA,CAAauB,MAAiB;AACzC,iBAAaP,EAAM,OAAO,GAC1BA,EAAM,UAAU,WAAA,MAAiBE,EAAQ,EAAI,GAAGK,CAAI;AAAA,EACtD,GAAG,CAAC,CAAC,GACCC,IAAOxB,EAAA,CAAauB,IAAO,MAAM;AACrC,iBAAaP,EAAM,OAAO,GAC1BA,EAAM,UAAU,WAAA,MAAiBE,EAAQ,EAAK,GAAGK,CAAI;AAAA,EACvD,GAAG,CAAC,CAAC;AAEL,SAAAtB,EAAA,MAAA,MAAsB,aAAae,EAAM,OAAO,GAAG,CAAC,CAAC,GACrDb,EAAA,MAAsB;AACpB,IAAAiB,EAAW,UAAUD,EAAQ;AAAA,EAC/B,CAAC,GACDtB,EAAWkB,GAAKE,CAAI,GAEpBrB,EAAW;AAAA,IAAE,MAAAqB;AAAA,IAAM,SAAA,MAAeC,EAAQ,EAAK;AAAA,IAAG,QAAQ,CAACE,GAAYL,CAAG;AAAA,IAAG,SAAS;AAAA,EAAM,CAAC,GAC7FjB,EAAoBsB,GAAYL,GAAKE,GAAMN,CAAS,GAIlD,gBAAAJ,EAAC,QAAD;AAAA,IACE,KAAKO;AAAA,IACL,WAAU;AAAA,IACV,gBAAA,CAAiB,MAAM,EAAE,gBAAgB,WAAWQ,EAAKV,CAAK;AAAA,IAC9D,gBAAA,MAAsBY,EAAK,GAAG;AAAA,IAC9B,eAAA,MAAqB;AACnB,MAAAH,EAAa,UAAU,IACvBG,EAAK;AAAA,IACP;AAAA,IACA,SAAA,CAAU,MAAM;AACd,MAAI,CAACH,EAAa,WAAY,EAAE,OAAuB,QAAQ,gBAAgB,KAAGC,EAAK,CAAC,GACxFD,EAAa,UAAU;AAAA,IACzB;AAAA,IACA,QAAA,MAAc;AACZ,MAAAA,EAAa,UAAU,IACvBG,EAAK;AAAA,IACP;AAAA,IAhBF,UAAA,CAkBGzB,EAAaW,GAAU,EACtB,oBAAoB,CAACA,EAAS,MAAM,kBAAA,GAAqBG,CAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EACvF,CAAC,GACD,gBAAAP,EAAC,QAAD;AAAA,MACE,KAAKS;AAAA,MACD,IAAAF;AAAA,MACJ,MAAK;AAAA,MACL,WAAU;AAAA,MACJ,SAAS;AAAA,MACf,gBAAA,MAAsB,aAAaG,EAAM,OAAO;AAAA,MAChD,gBAAA,MAAsBQ,EAAK,GAAG;AAAA,MAE7B,UAAAf;AAAA,IACG,CAAA,CACF;AAAA,E;AAEV"}
1
+ {"version":3,"file":"Tooltip.js","names":["useDismiss","usePopover","useAnchoredPosition","cloneElement","useCallback","useEffect","useId","useLayoutEffect","useRef","useState","jsx","jsxs","Tooltip","content","children","placement","delay","id","anchor","tip","timer","open","setOpen","trigger","triggerRef","pointerFocus","show","wait","hide"],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\n cloneElement,\n type ReactElement,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { usePopover } from \"../../overlay/floating.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { useAnchoredPosition } from \"../../overlay/use-anchored-position.js\";\n\nexport interface TooltipTokens {\n bg: string;\n ink: string;\n radius: string;\n maxWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n tooltip: TooltipTokens;\n }\n}\n\nexport interface TooltipProps {\n /** Short supplementary text; it becomes the trigger's accessible description. */\n content: ReactNode;\n /** One focusable element (Button, IconButton, Link…). */\n children: ReactElement<Record<string, unknown>>;\n /** Preferred side; flips when it does not fit. Default \"top\". */\n placement?: Placement;\n /** Hover delay in ms (focus opens immediately). */\n delay?: number;\n}\n\n/**\n * Tooltip in the top layer (Popover API), positioned against its trigger. Opens on hover after `delay` and on\n * keyboard focus; dismissible with Escape; hoverable; never opens on touch (WCAG 1.4.13).\n */\nexport function Tooltip({ content, children, placement = \"top\", delay = 300 }: TooltipProps) {\n const id = `cy-tip-${useId().replace(/:/g, \"\")}`;\n const anchor = useRef<HTMLSpanElement>(null);\n const tip = useRef<HTMLSpanElement>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const [open, setOpen] = useState(false);\n const trigger = () => (anchor.current?.firstElementChild as HTMLElement | null) ?? anchor.current;\n const triggerRef = useRef<HTMLElement | null>(null);\n // Focus that follows a pointer press (mouse or touch) is not keyboard focus: hover handles mouse, touch never opens.\n const pointerFocus = useRef(false);\n\n const show = useCallback((wait: number) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setOpen(true), wait);\n }, []);\n const hide = useCallback((wait = 0) => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setOpen(false), wait);\n }, []);\n\n useEffect(() => () => clearTimeout(timer.current), []);\n useLayoutEffect(() => {\n triggerRef.current = trigger();\n });\n usePopover(tip, open);\n // Escape closes the tooltip first when it sits inside a Popover, Menu or Dialog (shared layer stack).\n useDismiss({ open, onClose: () => setOpen(false), inside: [triggerRef, tip], outside: false });\n useAnchoredPosition(triggerRef, tip, open, placement);\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: delegated hover/focus listeners for the interactive child\n <span\n ref={anchor}\n className=\"cy-tooltip-anchor\"\n onPointerEnter={(e) => e.pointerType !== \"touch\" && show(delay)}\n onPointerLeave={() => hide(120)}\n onPointerDown={() => {\n pointerFocus.current = true;\n hide();\n }}\n onFocus={(e) => {\n if (!pointerFocus.current && (e.target as HTMLElement).matches(\":focus-visible\")) show(0);\n pointerFocus.current = false;\n }}\n onBlur={() => {\n pointerFocus.current = false;\n hide();\n }}\n >\n {cloneElement(children, {\n \"aria-describedby\": [children.props[\"aria-describedby\"], id].filter(Boolean).join(\" \"),\n })}\n <span\n ref={tip}\n id={id}\n role=\"tooltip\"\n className=\"cy-tooltip\"\n {...{ popover: \"manual\" }}\n onPointerEnter={() => clearTimeout(timer.current)}\n onPointerLeave={() => hide(120)}\n >\n {content}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;;;AA4CA,SAAgBY,EAAQ,EAAE,SAAAC,GAAS,UAAAC,GAAU,WAAAC,IAAY,OAAO,OAAAC,IAAQ,IAAA,GAAqB;AAC3F,QAAMC,IAAK,UAAUX,EAAM,EAAE,QAAQ,MAAM,EAAE,CAAA,IACvCY,IAASV,EAAwB,IAAI,GACrCW,IAAMX,EAAwB,IAAI,GAClCY,IAAQZ,EAAkD,MAAS,GACnE,CAACa,GAAMC,CAAA,IAAWb,EAAS,EAAK,GAChCc,IAAA,MAAiBL,EAAO,SAAS,qBAA4CA,EAAO,SACpFM,IAAahB,EAA2B,IAAI,GAE5CiB,IAAejB,EAAO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AqBG,CAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EACvF,CAAC,GACD,gBAAAP,EAAC,QAAD;AAAA,MACE,KAAKS;AAAA,MACD,IAAAF;AAAA,MACJ,MAAK;AAAA,MACL,WAAU;AAAA,MACJ,SAAS;AAAA,MACf,gBAAA,MAAsB,aAAaG,EAAM,OAAO;AAAA,MAChD,gBAAA,MAAsBQ,EAAK,GAAG;AAAA,MAE7B,UAAAf;AAAA,IACG,CAAA,CACF;AAAA,E;AAEV"}
@@ -28,14 +28,19 @@ export interface TreeLabels {
28
28
  export interface TreeProps {
29
29
  /** Accessible name of the tree. */
30
30
  label: string;
31
+ /** The top-level items; each can hold more under `children`. */
31
32
  items: TreeItem[];
32
33
  /** Selected ids (controlled) and the default for uncontrolled use. */
33
34
  selected?: string[];
35
+ /** Ids selected at the start when uncontrolled. */
34
36
  defaultSelected?: string[];
37
+ /** Called with the selected ids when the selection changes. */
35
38
  onSelectionChange?: (ids: string[]) => void;
36
39
  /** Expanded ids (controlled) and the default for uncontrolled use. */
37
40
  expanded?: string[];
41
+ /** Ids expanded at the start when uncontrolled. */
38
42
  defaultExpanded?: string[];
43
+ /** Called with the expanded ids when an item is expanded or collapsed. */
39
44
  onExpandedChange?: (ids: string[]) => void;
40
45
  /** `single` (default): one at a time. `multiple`: Space and clicks toggle. */
41
46
  selectionMode?: "single" | "multiple";
@@ -50,8 +55,11 @@ export interface TreeProps {
50
55
  * must share one height.
51
56
  */
52
57
  virtual?: boolean;
58
+ /** Row height and indent. Default "md". */
53
59
  size?: Extract<Size, "sm" | "md">;
60
+ /** Replace the built-in English text: the loading row and the failed-to-load row. */
54
61
  labels?: Partial<TreeLabels>;
62
+ /** Added to the root element, for layout. */
55
63
  className?: string;
56
64
  /** Layout only. Restyle through --cy-tree-* tokens. */
57
65
  style?: CSSProperties;