@arshad-shah/cynosure 0.3.0 → 0.4.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 (290) hide show
  1. package/README.md +3 -3
  2. package/dist/adapters/astro/index.d.ts +52 -0
  3. package/dist/adapters/astro/index.js +27 -0
  4. package/dist/adapters/astro/index.js.map +1 -0
  5. package/dist/adapters/vite/index.d.ts +11 -0
  6. package/dist/adapters/vite/index.js +33 -12
  7. package/dist/adapters/vite/index.js.map +1 -1
  8. package/dist/brands/googleplay.d.ts +2 -0
  9. package/dist/brands/googleplay.js +17 -0
  10. package/dist/brands/googleplay.js.map +1 -0
  11. package/dist/brands/index.d.ts +1 -0
  12. package/dist/brands/index.js +132 -130
  13. package/dist/components/Announcer/Announcer.js +5 -5
  14. package/dist/components/Announcer/Announcer.js.map +1 -1
  15. package/dist/components/AppShell/AppShell.js +50 -53
  16. package/dist/components/AppShell/AppShell.js.map +1 -1
  17. package/dist/components/Avatar/Avatar.js +20 -20
  18. package/dist/components/Avatar/Avatar.js.map +1 -1
  19. package/dist/components/Button/Button.d.ts +17 -3
  20. package/dist/components/Button/Button.js +51 -44
  21. package/dist/components/Button/Button.js.map +1 -1
  22. package/dist/components/Calendar/Calendar.js +69 -69
  23. package/dist/components/Calendar/Calendar.js.map +1 -1
  24. package/dist/components/Card/Card.d.ts +8 -1
  25. package/dist/components/Card/Card.js.map +1 -1
  26. package/dist/components/Checkbox/Checkbox.d.ts +4 -4
  27. package/dist/components/Checkbox/Checkbox.js +33 -8
  28. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  29. package/dist/components/Checklist/Checklist.js +21 -21
  30. package/dist/components/Checklist/Checklist.js.map +1 -1
  31. package/dist/components/Choice/Choice.d.ts +73 -0
  32. package/dist/components/Choice/Choice.js +41 -0
  33. package/dist/components/Choice/Choice.js.map +1 -0
  34. package/dist/components/Choice/index.d.ts +1 -0
  35. package/dist/components/ColorField/ColorField.js +198 -207
  36. package/dist/components/ColorField/ColorField.js.map +1 -1
  37. package/dist/components/Combobox/Combobox.js +86 -115
  38. package/dist/components/Combobox/Combobox.js.map +1 -1
  39. package/dist/components/Container/Container.d.ts +2 -2
  40. package/dist/components/Container/Container.js +17 -13
  41. package/dist/components/Container/Container.js.map +1 -1
  42. package/dist/components/CopyButton/CopyButton.js +29 -28
  43. package/dist/components/CopyButton/CopyButton.js.map +1 -1
  44. package/dist/components/DeviceFrame/DeviceFrame.d.ts +63 -0
  45. package/dist/components/DeviceFrame/DeviceFrame.js +54 -0
  46. package/dist/components/DeviceFrame/DeviceFrame.js.map +1 -0
  47. package/dist/components/DeviceFrame/index.d.ts +1 -0
  48. package/dist/components/Dialog/Dialog.d.ts +10 -1
  49. package/dist/components/Dialog/Dialog.js +82 -77
  50. package/dist/components/Dialog/Dialog.js.map +1 -1
  51. package/dist/components/EmptyState/EmptyState.d.ts +5 -2
  52. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  53. package/dist/components/Field/Field.js +31 -33
  54. package/dist/components/Field/Field.js.map +1 -1
  55. package/dist/components/FileDrop/FileDrop.js +14 -14
  56. package/dist/components/FileDrop/FileDrop.js.map +1 -1
  57. package/dist/components/FloatingToolbar/FloatingToolbar.js +7 -6
  58. package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
  59. package/dist/components/Grid/Grid.d.ts +32 -11
  60. package/dist/components/Grid/Grid.js +68 -46
  61. package/dist/components/Grid/Grid.js.map +1 -1
  62. package/dist/components/Grid/index.d.ts +1 -1
  63. package/dist/components/Heading/Heading.d.ts +4 -2
  64. package/dist/components/Heading/Heading.js.map +1 -1
  65. package/dist/components/IconButton/IconButton.d.ts +16 -1
  66. package/dist/components/IconButton/IconButton.js +14 -10
  67. package/dist/components/IconButton/IconButton.js.map +1 -1
  68. package/dist/components/IconTile/IconTile.d.ts +45 -0
  69. package/dist/components/IconTile/IconTile.js +25 -0
  70. package/dist/components/IconTile/IconTile.js.map +1 -0
  71. package/dist/components/IconTile/index.d.ts +1 -0
  72. package/dist/components/Image/Image.js.map +1 -1
  73. package/dist/components/Inline/Inline.d.ts +3 -3
  74. package/dist/components/Inline/Inline.js +12 -22
  75. package/dist/components/Inline/Inline.js.map +1 -1
  76. package/dist/components/KeyValueEditor/KeyValueEditor.js +37 -36
  77. package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
  78. package/dist/components/Link/Link.d.ts +9 -1
  79. package/dist/components/Link/Link.js +20 -18
  80. package/dist/components/Link/Link.js.map +1 -1
  81. package/dist/components/List/List.d.ts +73 -0
  82. package/dist/components/List/List.js +64 -0
  83. package/dist/components/List/List.js.map +1 -0
  84. package/dist/components/List/index.d.ts +1 -0
  85. package/dist/components/Notice/Notice.js +12 -11
  86. package/dist/components/Notice/Notice.js.map +1 -1
  87. package/dist/components/OptionList/OptionList.d.ts +69 -0
  88. package/dist/components/OptionList/OptionList.js +75 -0
  89. package/dist/components/OptionList/OptionList.js.map +1 -0
  90. package/dist/components/OptionList/index.d.ts +1 -0
  91. package/dist/components/PageHeader/PageHeader.d.ts +6 -0
  92. package/dist/components/PageHeader/PageHeader.js +27 -27
  93. package/dist/components/PageHeader/PageHeader.js.map +1 -1
  94. package/dist/components/Pagination/Pagination.js +31 -30
  95. package/dist/components/Pagination/Pagination.js.map +1 -1
  96. package/dist/components/QRCode/QRCode.d.ts +56 -0
  97. package/dist/components/QRCode/QRCode.js +48 -0
  98. package/dist/components/QRCode/QRCode.js.map +1 -0
  99. package/dist/components/QRCode/index.d.ts +1 -0
  100. package/dist/components/RadioGroup/RadioGroup.js +32 -24
  101. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  102. package/dist/components/Section/Section.d.ts +57 -0
  103. package/dist/components/Section/Section.js +27 -0
  104. package/dist/components/Section/Section.js.map +1 -0
  105. package/dist/components/Section/index.d.ts +1 -0
  106. package/dist/components/SegmentedControl/SegmentedControl.js +12 -12
  107. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  108. package/dist/components/Select/Select.js +106 -133
  109. package/dist/components/Select/Select.js.map +1 -1
  110. package/dist/components/Sheet/Sheet.js +12 -7
  111. package/dist/components/Sheet/Sheet.js.map +1 -1
  112. package/dist/components/SideNav/SideNav.js +55 -53
  113. package/dist/components/SideNav/SideNav.js.map +1 -1
  114. package/dist/components/SiteFooter/SiteFooter.d.ts +66 -0
  115. package/dist/components/SiteFooter/SiteFooter.js +80 -0
  116. package/dist/components/SiteFooter/SiteFooter.js.map +1 -0
  117. package/dist/components/SiteFooter/index.d.ts +1 -0
  118. package/dist/components/SiteHeader/SiteHeader.d.ts +78 -0
  119. package/dist/components/SiteHeader/SiteHeader.js +114 -0
  120. package/dist/components/SiteHeader/SiteHeader.js.map +1 -0
  121. package/dist/components/SiteHeader/index.d.ts +1 -0
  122. package/dist/components/SkipLink/SkipLink.d.ts +42 -0
  123. package/dist/components/SkipLink/SkipLink.js +43 -0
  124. package/dist/components/SkipLink/SkipLink.js.map +1 -0
  125. package/dist/components/SkipLink/index.d.ts +1 -0
  126. package/dist/components/SortableList/SortableList.js +13 -13
  127. package/dist/components/SortableList/SortableList.js.map +1 -1
  128. package/dist/components/Stack/Stack.d.ts +16 -7
  129. package/dist/components/Stack/Stack.js +25 -18
  130. package/dist/components/Stack/Stack.js.map +1 -1
  131. package/dist/components/Stack/index.d.ts +1 -1
  132. package/dist/components/Stack/space.d.ts +29 -0
  133. package/dist/components/Stack/space.js +16 -5
  134. package/dist/components/Stack/space.js.map +1 -1
  135. package/dist/components/Stat/Stat.d.ts +88 -0
  136. package/dist/components/Stat/Stat.js +105 -0
  137. package/dist/components/Stat/Stat.js.map +1 -0
  138. package/dist/components/Stat/index.d.ts +1 -0
  139. package/dist/components/Steps/Steps.d.ts +10 -4
  140. package/dist/components/Steps/Steps.js +31 -30
  141. package/dist/components/Steps/Steps.js.map +1 -1
  142. package/dist/components/Switch/Switch.d.ts +4 -4
  143. package/dist/components/Switch/Switch.js +18 -7
  144. package/dist/components/Switch/Switch.js.map +1 -1
  145. package/dist/components/Table/Table.js +11 -12
  146. package/dist/components/Table/Table.js.map +1 -1
  147. package/dist/components/Tabs/Tabs.d.ts +4 -1
  148. package/dist/components/Tabs/Tabs.js +71 -70
  149. package/dist/components/Tabs/Tabs.js.map +1 -1
  150. package/dist/components/TagInput/TagInput.js +76 -97
  151. package/dist/components/TagInput/TagInput.js.map +1 -1
  152. package/dist/components/TextField/TextField.d.ts +4 -0
  153. package/dist/components/TextField/TextField.js +30 -29
  154. package/dist/components/TextField/TextField.js.map +1 -1
  155. package/dist/components/ThemeToggle/ThemeToggle.d.ts +7 -1
  156. package/dist/components/ThemeToggle/ThemeToggle.js +33 -30
  157. package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
  158. package/dist/components/Toast/Toast.js +22 -20
  159. package/dist/components/Toast/Toast.js.map +1 -1
  160. package/dist/components/Tooltip/Tooltip.d.ts +6 -1
  161. package/dist/components/Tooltip/Tooltip.js +19 -19
  162. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  163. package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
  164. package/dist/components/VisuallyHidden/VisuallyHidden.js +17 -0
  165. package/dist/components/VisuallyHidden/VisuallyHidden.js.map +1 -0
  166. package/dist/components/VisuallyHidden/index.d.ts +1 -0
  167. package/dist/foundations/ChoiceBase/ChoiceBase.js +8 -8
  168. package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
  169. package/dist/foundations/HiddenValue/HiddenValue.js +5 -5
  170. package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
  171. package/dist/foundations/Icon/Icon.d.ts +6 -1
  172. package/dist/foundations/Icon/Icon.js +15 -14
  173. package/dist/foundations/Icon/Icon.js.map +1 -1
  174. package/dist/foundations/image-outcome.d.ts +8 -3
  175. package/dist/foundations/image-outcome.js +12 -8
  176. package/dist/foundations/image-outcome.js.map +1 -1
  177. package/dist/foundations/printing.d.ts +6 -0
  178. package/dist/foundations/printing.js +17 -0
  179. package/dist/foundations/printing.js.map +1 -0
  180. package/dist/foundations/qr.d.ts +42 -0
  181. package/dist/foundations/qr.js +246 -0
  182. package/dist/foundations/qr.js.map +1 -0
  183. package/dist/icons/book-marked.d.ts +2 -0
  184. package/dist/icons/book-marked.js +14 -0
  185. package/dist/icons/book-marked.js.map +1 -0
  186. package/dist/icons/calendar-days.d.ts +2 -0
  187. package/dist/icons/calendar-days.js +24 -0
  188. package/dist/icons/calendar-days.js.map +1 -0
  189. package/dist/icons/check-square.d.ts +2 -0
  190. package/dist/icons/check-square.js +14 -0
  191. package/dist/icons/check-square.js.map +1 -0
  192. package/dist/icons/crescent.d.ts +2 -0
  193. package/dist/icons/crescent.js +14 -0
  194. package/dist/icons/crescent.js.map +1 -0
  195. package/dist/icons/index.d.ts +10 -0
  196. package/dist/icons/index.js +436 -416
  197. package/dist/icons/kaaba.d.ts +2 -0
  198. package/dist/icons/kaaba.js +14 -0
  199. package/dist/icons/kaaba.js.map +1 -0
  200. package/dist/icons/keywords.d.ts +11 -1
  201. package/dist/icons/keywords.js +89 -1
  202. package/dist/icons/keywords.js.map +1 -1
  203. package/dist/icons/list-tree.d.ts +2 -0
  204. package/dist/icons/list-tree.js +14 -0
  205. package/dist/icons/list-tree.js.map +1 -0
  206. package/dist/icons/mosque.d.ts +2 -0
  207. package/dist/icons/mosque.js +14 -0
  208. package/dist/icons/mosque.js.map +1 -0
  209. package/dist/icons/prayer-beads.d.ts +2 -0
  210. package/dist/icons/prayer-beads.js +67 -0
  211. package/dist/icons/prayer-beads.js.map +1 -0
  212. package/dist/icons/qr-code.d.ts +2 -0
  213. package/dist/icons/qr-code.js +38 -0
  214. package/dist/icons/qr-code.js.map +1 -0
  215. package/dist/icons/refresh-cw.d.ts +2 -0
  216. package/dist/icons/refresh-cw.js +14 -0
  217. package/dist/icons/refresh-cw.js.map +1 -0
  218. package/dist/icons/types.d.ts +1 -1
  219. package/dist/icons/types.js +2 -1
  220. package/dist/icons/types.js.map +1 -1
  221. package/dist/index.d.ts +16 -2
  222. package/dist/index.js +274 -241
  223. package/dist/styles/announcer.css +1 -1
  224. package/dist/styles/app-shell.css +1 -1
  225. package/dist/styles/avatar.css +1 -1
  226. package/dist/styles/base.css +1 -1
  227. package/dist/styles/button.css +1 -1
  228. package/dist/styles/calendar.css +1 -1
  229. package/dist/styles/card.css +1 -1
  230. package/dist/styles/checkbox.css +1 -1
  231. package/dist/styles/choice-base.css +1 -0
  232. package/dist/styles/choice.css +1 -1
  233. package/dist/styles/color-field.css +1 -1
  234. package/dist/styles/combobox.css +1 -1
  235. package/dist/styles/copy-button.css +1 -1
  236. package/dist/styles/date-field.css +1 -1
  237. package/dist/styles/device-frame.css +1 -0
  238. package/dist/styles/dialog.css +1 -1
  239. package/dist/styles/disclosure.css +1 -1
  240. package/dist/styles/field.css +1 -1
  241. package/dist/styles/file-drop.css +1 -1
  242. package/dist/styles/floating-toolbar.css +1 -1
  243. package/dist/styles/generated-css.d.ts +1 -1
  244. package/dist/styles/generated-css.js +1 -1
  245. package/dist/styles/generated-css.js.map +1 -1
  246. package/dist/styles/grid.css +1 -1
  247. package/dist/styles/heading.css +1 -1
  248. package/dist/styles/icon-tile.css +1 -0
  249. package/dist/styles/icon.css +1 -1
  250. package/dist/styles/inline.css +1 -0
  251. package/dist/styles/key-value-editor.css +1 -1
  252. package/dist/styles/link.css +1 -1
  253. package/dist/styles/list.css +1 -0
  254. package/dist/styles/manifest.json +715 -0
  255. package/dist/styles/notice.css +1 -1
  256. package/dist/styles/number-field.css +1 -1
  257. package/dist/styles/option-list.css +1 -0
  258. package/dist/styles/pagination.css +1 -1
  259. package/dist/styles/qr-code.css +1 -0
  260. package/dist/styles/radio-group.css +1 -1
  261. package/dist/styles/section.css +1 -0
  262. package/dist/styles/segmented-control.css +1 -1
  263. package/dist/styles/select.css +1 -1
  264. package/dist/styles/sheet.css +1 -1
  265. package/dist/styles/side-nav.css +1 -1
  266. package/dist/styles/site-footer.css +1 -0
  267. package/dist/styles/site-header.css +1 -0
  268. package/dist/styles/skip-link.css +1 -0
  269. package/dist/styles/sortable-list.css +1 -1
  270. package/dist/styles/stack.css +1 -1
  271. package/dist/styles/stat.css +1 -0
  272. package/dist/styles/steps.css +1 -1
  273. package/dist/styles/switch.css +1 -0
  274. package/dist/styles/table.css +1 -1
  275. package/dist/styles/tabs.css +1 -1
  276. package/dist/styles/tag-input.css +1 -1
  277. package/dist/styles/text-field.css +1 -1
  278. package/dist/styles/time-field.css +1 -1
  279. package/dist/styles/toast.css +1 -1
  280. package/dist/styles/visually-hidden.css +1 -0
  281. package/dist/styles.css +1 -1
  282. package/dist/tokens/create-theme.js +137 -108
  283. package/dist/tokens/create-theme.js.map +1 -1
  284. package/package.json +6 -1
  285. package/dist/components/Checkbox/ChoiceRow.d.ts +0 -39
  286. package/dist/components/Checkbox/ChoiceRow.js +0 -58
  287. package/dist/components/Checkbox/ChoiceRow.js.map +0 -1
  288. package/dist/styles/hidden-value.css +0 -1
  289. package/dist/styles/iconbutton.css +0 -1
  290. package/dist/styles/search-field.css +0 -1
@@ -1,68 +1,71 @@
1
1
  "use client";
2
- import { IconButton as $ } from "../IconButton/IconButton.js";
3
- import { SegmentedControl as x } from "../SegmentedControl/SegmentedControl.js";
4
- import { monitor as h } from "../../icons/monitor.js";
5
- import { moon as u } from "../../icons/moon.js";
6
- import { sun as y } from "../../icons/sun.js";
7
- import { useColorMode as D } from "../../theme/use-color-mode.js";
8
- import { jsx as a } from "react/jsx-runtime";
9
- function I({ value: m, onChange: f, storage: i, size: c = "md", variant: k = "segmented", labels: o, className: n, style: r }) {
10
- const l = D(i ? { storage: i } : {}), e = m ?? l.mode, s = (t) => {
11
- m === void 0 && l.setMode(t), f?.(t);
2
+ import { IconButton as x } from "../IconButton/IconButton.js";
3
+ import { SegmentedControl as D } from "../SegmentedControl/SegmentedControl.js";
4
+ import { monitor as u } from "../../icons/monitor.js";
5
+ import { moon as y } from "../../icons/moon.js";
6
+ import { sun as a } from "../../icons/sun.js";
7
+ import { useColorMode as L } from "../../theme/use-color-mode.js";
8
+ import { jsx as f } from "react/jsx-runtime";
9
+ function q({ value: r, onChange: k, storage: i, storageKey: c, size: l = "md", variant: p = "segmented", labels: o, className: n, style: m }) {
10
+ const d = L({
11
+ ...i ? { storage: i } : {},
12
+ ...c ? { key: c } : {}
13
+ }), e = r ?? d.mode, s = (t) => {
14
+ r === void 0 && d.setMode(t), k?.(t);
12
15
  };
13
- if (k === "cycle") {
16
+ if (p === "cycle") {
14
17
  const t = [
15
18
  "light",
16
19
  "dark",
17
20
  "system"
18
- ], d = {
21
+ ], g = {
19
22
  light: o?.light ?? "Light",
20
23
  dark: o?.dark ?? "Dark",
21
24
  system: o?.system ?? "System"
22
- }, p = {
23
- light: y,
24
- dark: u,
25
- system: h
26
- }, g = t[(t.indexOf(e) + 1) % t.length], C = (o?.cycle ?? ((v, S) => `${o?.label ?? "Colour mode"}: ${v}. Switch to ${S}`))(d[e], d[g]);
27
- return /* @__PURE__ */ a($, {
28
- icon: p[e],
29
- label: C,
25
+ }, C = {
26
+ light: a,
27
+ dark: y,
28
+ system: u
29
+ }, h = t[(t.indexOf(e) + 1) % t.length], v = (o?.cycle ?? ((S, $) => `${o?.label ?? "Colour mode"}: ${S}. Switch to ${$}`))(g[e], g[h]);
30
+ return /* @__PURE__ */ f(x, {
31
+ icon: C[e],
32
+ label: v,
30
33
  variant: "ghost",
31
- size: c,
34
+ size: l,
32
35
  className: n ? `cy-theme-toggle-cycle ${n}` : "cy-theme-toggle-cycle",
33
- ...r ? { style: r } : {},
34
- onClick: () => s(g)
36
+ ...m ? { style: m } : {},
37
+ onClick: () => s(h)
35
38
  });
36
39
  }
37
- return /* @__PURE__ */ a(x, {
40
+ return /* @__PURE__ */ f(D, {
38
41
  label: o?.label ?? "Colour mode",
39
42
  iconOnly: !0,
40
- size: c,
43
+ size: l,
41
44
  className: n,
42
- style: r,
45
+ style: m,
43
46
  value: e,
44
47
  onChange: (t) => s(t),
45
48
  options: [
46
49
  {
47
50
  value: "light",
48
51
  label: o?.light ?? "Light",
49
- icon: y
52
+ icon: a
50
53
  },
51
54
  {
52
55
  value: "dark",
53
56
  label: o?.dark ?? "Dark",
54
- icon: u
57
+ icon: y
55
58
  },
56
59
  {
57
60
  value: "system",
58
61
  label: o?.system ?? "System",
59
- icon: h
62
+ icon: u
60
63
  }
61
64
  ]
62
65
  });
63
66
  }
64
67
  export {
65
- I as ThemeToggle
68
+ q as ThemeToggle
66
69
  };
67
70
 
68
71
  //# sourceMappingURL=ThemeToggle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeToggle.js","names":["IconButton","SegmentedControl","monitor","moon","sun","useColorMode","jsx","ThemeToggle","value","onChange","storage","size","variant","labels","className","style","color","mode","set","next","order","names","icons","name","c","n"],"sources":["../../../src/components/ThemeToggle/ThemeToggle.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { monitor } from \"../../icons/monitor.js\";\nimport { moon } from \"../../icons/moon.js\";\nimport { sun } from \"../../icons/sun.js\";\nimport { type ColorMode, type ColorModeStorage, useColorMode } from \"../../theme/use-color-mode.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { SegmentedControl } from \"../SegmentedControl/SegmentedControl.js\";\n\nexport interface ThemeToggleProps {\n /** Controlled mode; omit to manage and persist it internally. */\n value?: ColorMode;\n /** Called with the mode the person picks. */\n onChange?: (mode: ColorMode) => void;\n /** Persistence for uncontrolled use (localStorage by default; chrome.storage works too). */\n storage?: ColorModeStorage;\n /** Size of the control. Default \"md\". */\n size?: Size;\n /**\n * `segmented` (default): three choices side by side. `cycle`: one icon button that steps light → dark → system\n * (for tight headers); its name says the current mode and the next one (\"Colour mode: Light. Switch to Dark\").\n */\n variant?: \"segmented\" | \"cycle\";\n /** Replace the built-in English text: the control's name and the names of the three modes. */\n labels?: {\n label?: string;\n light?: string;\n dark?: string;\n system?: string;\n /** The cycle button's name. Default \"Colour mode: Light. Switch to Dark\". */\n cycle?: (current: string, next: string) => string;\n };\n /** Added to the control, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Light / dark / system switch: a SegmentedControl with Facet icons. Pair with `<CynosureTheme mode={…}>`. */\nexport function ThemeToggle({\n value,\n onChange,\n storage,\n size = \"md\",\n variant = \"segmented\",\n labels,\n className,\n style,\n}: ThemeToggleProps) {\n const color = useColorMode(storage ? { storage } : {});\n const mode = value ?? color.mode;\n const set = (next: ColorMode) => {\n if (value === undefined) color.setMode(next);\n onChange?.(next);\n };\n if (variant === \"cycle\") {\n const order: ColorMode[] = [\"light\", \"dark\", \"system\"];\n const names = {\n light: labels?.light ?? \"Light\",\n dark: labels?.dark ?? \"Dark\",\n system: labels?.system ?? \"System\",\n };\n const icons = { light: sun, dark: moon, system: monitor };\n const next = order[(order.indexOf(mode) + 1) % order.length] as ColorMode;\n const name = (labels?.cycle ?? ((c, n) => `${labels?.label ?? \"Colour mode\"}: ${c}. Switch to ${n}`))(\n names[mode],\n names[next],\n );\n return (\n <IconButton\n icon={icons[mode]}\n label={name}\n variant=\"ghost\"\n size={size}\n className={className ? `cy-theme-toggle-cycle ${className}` : \"cy-theme-toggle-cycle\"}\n {...(style ? { style } : {})}\n onClick={() => set(next)}\n />\n );\n }\n return (\n <SegmentedControl\n label={labels?.label ?? \"Colour mode\"}\n iconOnly\n size={size}\n className={className}\n style={style}\n value={mode}\n onChange={(next) => set(next as ColorMode)}\n options={[\n { value: \"light\", label: labels?.light ?? \"Light\", icon: sun },\n { value: \"dark\", label: labels?.dark ?? \"Dark\", icon: moon },\n { value: \"system\", label: labels?.system ?? \"System\", icon: monitor },\n ]}\n />\n );\n}\n"],"mappings":";;;;;;;;AAuCA,SAAgBO,EAAY,EAC1B,OAAAC,GACA,UAAAC,GACA,SAAAC,GACA,MAAAC,IAAO,MACP,SAAAC,IAAU,aACV,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACmB;AACnB,QAAMC,IAAQX,EAAaK,IAAU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,QAAE,OAAO;AAAA,QAAS,OAAON,GAAQ,SAAS;AAAA,QAAS,MAAMT;AAAA,MAAI;AAAA,MAC7D;AAAA,QAAE,OAAO;AAAA,QAAQ,OAAOS,GAAQ,QAAQ;AAAA,QAAQ,MAAMV;AAAA,MAAK;AAAA,MAC3D;AAAA,QAAE,OAAO;AAAA,QAAU,OAAOU,GAAQ,UAAU;AAAA,QAAU,MAAMX;AAAA,MAAQ;AAAA,IACtE;AAAA,EACD,CAAA;AAEL"}
1
+ {"version":3,"file":"ThemeToggle.js","names":["IconButton","SegmentedControl","monitor","moon","sun","useColorMode","jsx","ThemeToggle","value","onChange","storage","storageKey","size","variant","labels","className","style","color","mode","set","next","order","names","icons","name","c","n"],"sources":["../../../src/components/ThemeToggle/ThemeToggle.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { monitor } from \"../../icons/monitor.js\";\nimport { moon } from \"../../icons/moon.js\";\nimport { sun } from \"../../icons/sun.js\";\nimport { type ColorMode, type ColorModeStorage, useColorMode } from \"../../theme/use-color-mode.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { SegmentedControl } from \"../SegmentedControl/SegmentedControl.js\";\n\nexport interface ThemeToggleProps {\n /** Controlled mode; omit to manage and persist it internally. */\n value?: ColorMode;\n /** Called with the mode the person picks. */\n onChange?: (mode: ColorMode) => void;\n /** Persistence for uncontrolled use (localStorage by default; chrome.storage works too). */\n storage?: ColorModeStorage;\n /**\n * The key the mode is saved under, for uncontrolled use. Give each product on a shared origin its own, and pass the\n * same one to `themeInitScript({ key })` so the saved mode is applied before the first paint. Default\n * \"cy-color-mode\".\n */\n storageKey?: string | undefined;\n /** Size of the control. Default \"md\". */\n size?: Size;\n /**\n * `segmented` (default): three choices side by side. `cycle`: one icon button that steps light → dark → system\n * (for tight headers); its name says the current mode and the next one (\"Colour mode: Light. Switch to Dark\").\n */\n variant?: \"segmented\" | \"cycle\";\n /** Replace the built-in English text: the control's name and the names of the three modes. */\n labels?: {\n label?: string;\n light?: string;\n dark?: string;\n system?: string;\n /** The cycle button's name. Default \"Colour mode: Light. Switch to Dark\". */\n cycle?: (current: string, next: string) => string;\n };\n /** Added to the control, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Light / dark / system switch: a SegmentedControl with Facet icons. Pair with `<CynosureTheme mode={…}>`. */\nexport function ThemeToggle({\n value,\n onChange,\n storage,\n storageKey,\n size = \"md\",\n variant = \"segmented\",\n labels,\n className,\n style,\n}: ThemeToggleProps) {\n const color = useColorMode({ ...(storage ? { storage } : {}), ...(storageKey ? { key: storageKey } : {}) });\n const mode = value ?? color.mode;\n const set = (next: ColorMode) => {\n if (value === undefined) color.setMode(next);\n onChange?.(next);\n };\n if (variant === \"cycle\") {\n const order: ColorMode[] = [\"light\", \"dark\", \"system\"];\n const names = {\n light: labels?.light ?? \"Light\",\n dark: labels?.dark ?? \"Dark\",\n system: labels?.system ?? \"System\",\n };\n const icons = { light: sun, dark: moon, system: monitor };\n const next = order[(order.indexOf(mode) + 1) % order.length] as ColorMode;\n const name = (labels?.cycle ?? ((c, n) => `${labels?.label ?? \"Colour mode\"}: ${c}. Switch to ${n}`))(\n names[mode],\n names[next],\n );\n return (\n <IconButton\n icon={icons[mode]}\n label={name}\n variant=\"ghost\"\n size={size}\n className={className ? `cy-theme-toggle-cycle ${className}` : \"cy-theme-toggle-cycle\"}\n {...(style ? { style } : {})}\n onClick={() => set(next)}\n />\n );\n }\n return (\n <SegmentedControl\n label={labels?.label ?? \"Colour mode\"}\n iconOnly\n size={size}\n className={className}\n style={style}\n value={mode}\n onChange={(next) => set(next as ColorMode)}\n options={[\n { value: \"light\", label: labels?.light ?? \"Light\", icon: sun },\n { value: \"dark\", label: labels?.dark ?? \"Dark\", icon: moon },\n { value: \"system\", label: labels?.system ?? \"System\", icon: monitor },\n ]}\n />\n );\n}\n"],"mappings":";;;;;;;;AA6CA,SAAgBO,EAAY,EAC1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AAA;AAAA,EAEL;AACA,SACE,gBAAAd,EAACL,GAAD;AAAA,IACE,OAAOa,GAAQ,SAAS;AAAA,IACxB,UAAA;AAAA,IACM,MAAAF;AAAA,IACK,WAAAG;AAAA,IACJ,OAAAC;AAAA,IACP,OAAOE;AAAA,IACP,UAAA,CAAWE,MAASD,EAAIC,CAAiB;AAAA,IACzC,SAAS;AAAA,MACP;AAAA,QAAE,OAAO;AAAA,QAAS,OAAON,GAAQ,SAAS;AAAA,QAAS,MAAMV;AAAA,MAAI;AAAA,MAC7D;AAAA,QAAE,OAAO;AAAA,QAAQ,OAAOU,GAAQ,QAAQ;AAAA,QAAQ,MAAMX;AAAA,MAAK;AAAA,MAC3D;AAAA,QAAE,OAAO;AAAA,QAAU,OAAOW,GAAQ,UAAU;AAAA,QAAU,MAAMZ;AAAA,MAAQ;AAAA,IACtE;AAAA,EACD,CAAA;AAEL"}
@@ -7,7 +7,7 @@ import { close as Y } from "../../icons/close.js";
7
7
  import { ToastHostContext as Z } from "../../overlay/toast-host.js";
8
8
  import { space as tt } from "../Stack/space.js";
9
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";
10
+ import { createContext as nt, useCallback as D, useContext as ot, useEffect as E, useId as rt, useMemo as X, useRef as N, useState as v } from "react";
11
11
  import { Fragment as st, jsx as m, jsxs as M } from "react/jsx-runtime";
12
12
  import { createPortal as it } from "react-dom";
13
13
  var at = {
@@ -19,30 +19,30 @@ function lt(o) {
19
19
  return a && (y["--_offset-block"] = q(a)), g && (y["--_offset-inline"] = q(g)), y;
20
20
  }
21
21
  var O = nt(null);
22
- function Pt() {
22
+ function wt() {
23
23
  const o = ot(O);
24
24
  if (!o) throw new Error("useToast() needs a <Toaster> around it.");
25
25
  return o;
26
26
  }
27
- function wt({ position: o = "bottom-end", max: a = 3, offset: g, labels: y, className: h, style: N, children: S }) {
27
+ function Pt({ position: o = "bottom-end", max: a = 3, offset: g, labels: y, className: h, style: I, children: S }) {
28
28
  const r = {
29
29
  ...at,
30
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) => {
31
+ }, L = rt(), P = N(0), [c, T] = v([]), [x, l] = v(!1), [f, s] = v(!1), [F, b] = v(!1), d = N(null), k = N(/* @__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
32
  k.current.delete(t), T((i) => i.filter((u) => u.id !== t));
33
33
  }, []), $ = D((t) => {
34
34
  const i = d.current?.ownerDocument.activeElement, u = i?.closest(".cy-toast");
35
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;
36
+ const B = [...d.current.querySelectorAll(".cy-toast:not([data-collapsed]):not([data-leaving])")], w = t === void 0 ? void 0 : B.find((G) => G !== u), j = w ? [...w.querySelectorAll("button")].at(-1) : void 0;
37
37
  j ? j.focus() : (i.blur(), s(!1));
38
38
  }
39
- T((B) => B.map((P) => t === void 0 || P.id === t ? {
40
- ...P,
39
+ T((B) => B.map((w) => t === void 0 || w.id === t ? {
40
+ ...w,
41
41
  leaving: !0
42
- } : P));
42
+ } : w));
43
43
  }, []), A = D((t) => {
44
- w.current += 1;
45
- const i = `${L}-${w.current}`;
44
+ P.current += 1;
45
+ const i = `${L}-${P.current}`;
46
46
  return T((u) => [...u, {
47
47
  ...t,
48
48
  id: i
@@ -70,7 +70,7 @@ function wt({ position: o = "bottom-end", max: a = 3, offset: g, labels: y, clas
70
70
  "data-position": o,
71
71
  style: {
72
72
  ...lt(g),
73
- ...N
73
+ ...I
74
74
  },
75
75
  onPointerEnter: () => l(!0),
76
76
  onPointerLeave: () => l(!1),
@@ -96,11 +96,11 @@ function wt({ position: o = "bottom-end", max: a = 3, offset: g, labels: y, clas
96
96
  }), n ? it(H, n) : H]
97
97
  });
98
98
  }
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(() => {
99
+ function ut({ item: o, collapsed: a, paused: g, dismissLabel: y, onDismiss: h, onRemoved: I, memory: S }) {
100
+ const { id: r, title: L, description: P, tone: c = "neutral", action: T, duration: x = 5e3, leaving: l = !1 } = o, f = N(null), [s] = v(() => {
101
101
  const e = S.get(r) ?? { announced: !1 };
102
102
  return S.set(r, e), e;
103
- }), [F] = v(s.announced), b = I(null), [d, k] = v(s.announced);
103
+ }), [F] = v(s.announced), b = N(null), [d, k] = v(s.announced);
104
104
  E(() => {
105
105
  if (d) return;
106
106
  const e = setTimeout(() => {
@@ -125,12 +125,12 @@ function ut({ item: o, collapsed: a, paused: g, dismissLabel: y, onDismiss: h, o
125
125
  s
126
126
  ]), E(() => {
127
127
  if (!l) return;
128
- const e = f.current, n = e && Number.parseFloat(getComputedStyle(e).transitionDuration) * 1e3 || 0, p = setTimeout(() => N(r), n);
128
+ const e = f.current, n = e && Number.parseFloat(getComputedStyle(e).transitionDuration) * 1e3 || 0, p = setTimeout(() => I(r), n);
129
129
  return () => clearTimeout(p);
130
130
  }, [
131
131
  l,
132
132
  r,
133
- N
133
+ I
134
134
  ]);
135
135
  const _ = (e) => {
136
136
  const n = b.current;
@@ -172,15 +172,16 @@ function ut({ item: o, collapsed: a, paused: g, dismissLabel: y, onDismiss: h, o
172
172
  children: d && /* @__PURE__ */ M(st, { children: [/* @__PURE__ */ m("span", {
173
173
  className: "cy-toast-title cy-reset",
174
174
  children: L
175
- }), w && /* @__PURE__ */ m("span", {
175
+ }), P && /* @__PURE__ */ m("span", {
176
176
  className: "cy-toast-description cy-reset",
177
- children: w
177
+ children: P
178
178
  })] })
179
179
  }),
180
180
  T && /* @__PURE__ */ m(K, {
181
181
  size: "sm",
182
182
  variant: "soft",
183
183
  tone: c === "neutral" ? "accent" : c,
184
+ className: "cy-toast-action",
184
185
  onClick: T.onClick,
185
186
  children: T.label
186
187
  }),
@@ -189,14 +190,15 @@ function ut({ item: o, collapsed: a, paused: g, dismissLabel: y, onDismiss: h, o
189
190
  label: y,
190
191
  variant: "ghost",
191
192
  size: "sm",
193
+ wrapperClassName: "cy-toast-dismiss",
192
194
  onClick: () => h(r)
193
195
  })
194
196
  ]
195
197
  });
196
198
  }
197
199
  export {
198
- wt as Toaster,
199
- Pt as useToast
200
+ Pt as Toaster,
201
+ wt as useToast
200
202
  };
201
203
 
202
204
  //# sourceMappingURL=Toast.js.map
@@ -1 +1 @@
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,SAASC,GAAWC,GAAgC;AAClD,QAAM,EAAE,OAAAC,GAAO,QAAAC,EAAA,IAAwB,OAAOF,KAAW,WAAWA,IAAS,EAAE,OAAOA,EAAO,GACvFG,IAA+B,CAAC;AACtC,SAAIF,MAAOE,EAAK,iBAAA,IAAqBN,EAAOI,CAAK,IAC7CC,MAAQC,EAAK,kBAAA,IAAsBN,EAAOK,CAAM,IAC7CC;AACT;AAEA,IAAMC,IAAerB,GAA+B,IAAI;AAGxD,SAAgBsB,KAAqB;AACnC,QAAMC,IAAMrB,GAAWmB,CAAY;AACnC,MAAI,CAACE,EAAK,OAAM,IAAI,MAAM,yCAAyC;AACnE,SAAOA;AACT;AAeA,SAAgBC,GAAQ,EACtB,UAAAC,IAAW,cACX,KAAAC,IAAM,GACN,QAAAT,GACA,QAAAU,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACe;AACf,QAAMC,IAAO;AAAA,IAAE,GAAGnB;AAAA,IAAgB,GAAGe;AAAA,EAAO,GACtCK,IAAS5B,GAAM,GACf6B,IAAQ3B,EAAO,CAAC,GAChB,CAAC4B,GAAOC,CAAA,IAAY5B,EAAiB,CAAC,CAAC,GACvC,CAAC6B,GAASC,CAAA,IAAc9B,EAAS,EAAK,GACtC,CAAC+B,GAASC,CAAA,IAAchC,EAAS,EAAK,GACtC,CAACiC,GAAQC,CAAA,IAAalC,EAAS,EAAK,GACpCmC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,OAAOQ,EAAM,cAAc,QAAQ,SACnCA,EAAM,cAAc,MAAM,eAAe,OAAO;AAAA,IAClD;AAAA,IA1BF,UAAA;AAAA,MA4BGE,KAAQ,gBAAApF,EAACjB,GAAD;AAAA,QAAY,MAAAqG;AAAA,QAAM,WAAU;AAAA,MAAiB,CAAA;AAAA,MACtD,gBAAApF,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QACZ,UAAA2E,KACC,gBAAA1E,EAAApB,IAAA,EAAA,UAAA,CACE,gBAAAmB,EAAC,QAAD;AAAA,UAAM,WAAU;AAAA,UAA2B,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
+ {"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\n size=\"sm\"\n variant=\"soft\"\n tone={tone === \"neutral\" ? \"accent\" : tone}\n className=\"cy-toast-action\"\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n )}\n <IconButton\n icon={closeIcon}\n label={dismissLabel}\n variant=\"ghost\"\n size=\"sm\"\n wrapperClassName=\"cy-toast-dismiss\"\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,SAASC,GAAWC,GAAgC;AAClD,QAAM,EAAE,OAAAC,GAAO,QAAAC,EAAA,IAAwB,OAAOF,KAAW,WAAWA,IAAS,EAAE,OAAOA,EAAO,GACvFG,IAA+B,CAAC;AACtC,SAAIF,MAAOE,EAAK,iBAAA,IAAqBN,EAAOI,CAAK,IAC7CC,MAAQC,EAAK,kBAAA,IAAsBN,EAAOK,CAAM,IAC7CC;AACT;AAEA,IAAMC,IAAerB,GAA+B,IAAI;AAGxD,SAAgBsB,KAAqB;AACnC,QAAMC,IAAMrB,GAAWmB,CAAY;AACnC,MAAI,CAACE,EAAK,OAAM,IAAI,MAAM,yCAAyC;AACnE,SAAOA;AACT;AAeA,SAAgBC,GAAQ,EACtB,UAAAC,IAAW,cACX,KAAAC,IAAM,GACN,QAAAT,GACA,QAAAU,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACe;AACf,QAAMC,IAAO;AAAA,IAAE,GAAGnB;AAAA,IAAgB,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
20
  placement?: Placement;
21
21
  /** Hover delay in ms (focus opens immediately). */
22
22
  delay?: number;
23
+ /**
24
+ * Added to the element around the trigger (the anchor, the box the parent lays out), for layout: a grid area,
25
+ * `flex`, margins.
26
+ */
27
+ className?: string | undefined;
23
28
  }
24
29
  /**
25
30
  * Tooltip in the top layer (Popover API), positioned against its trigger. Opens on hover after `delay` and on
26
31
  * keyboard focus; dismissible with Escape; hoverable; never opens on touch (WCAG 1.4.13).
27
32
  */
28
- export declare function Tooltip({ content, children, placement, delay }: TooltipProps): import("react").JSX.Element;
33
+ export declare function Tooltip({ content, children, placement, delay, className }: TooltipProps): import("react").JSX.Element;
@@ -1,50 +1,50 @@
1
1
  "use client";
2
- import { useDismiss as P } from "../../overlay/dismiss.js";
3
- import { usePopover as b } from "../../overlay/floating.js";
4
- import { useAnchoredPosition as g } from "../../overlay/use-anchored-position.js";
5
- import { cloneElement as v, useCallback as m, useEffect as E, useId as j, useLayoutEffect as x, useRef as o, useState as C } from "react";
6
- import { jsx as L, jsxs as w } from "react/jsx-runtime";
7
- function k({ content: d, children: a, placement: h = "top", delay: T = 300 }) {
8
- const p = `cy-tip-${j().replace(/:/g, "")}`, i = o(null), r = o(null), t = o(void 0), [c, u] = C(!1), y = () => i.current?.firstElementChild ?? i.current, l = o(null), n = o(!1), f = m((e) => {
2
+ import { useDismiss as b } from "../../overlay/dismiss.js";
3
+ import { usePopover as g } from "../../overlay/floating.js";
4
+ import { useAnchoredPosition as v } from "../../overlay/use-anchored-position.js";
5
+ import { cloneElement as E, useCallback as d, useEffect as j, useId as x, useLayoutEffect as C, useRef as o, useState as L } from "react";
6
+ import { jsx as w, jsxs as B } from "react/jsx-runtime";
7
+ function A({ content: h, children: a, placement: y = "top", delay: T = 300, className: p }) {
8
+ const f = `cy-tip-${x().replace(/:/g, "")}`, i = o(null), r = o(null), t = o(void 0), [c, u] = L(!1), P = () => i.current?.firstElementChild ?? i.current, l = o(null), n = o(!1), m = d((e) => {
9
9
  clearTimeout(t.current), t.current = setTimeout(() => u(!0), e);
10
- }, []), s = m((e = 0) => {
10
+ }, []), s = d((e = 0) => {
11
11
  clearTimeout(t.current), t.current = setTimeout(() => u(!1), e);
12
12
  }, []);
13
- return E(() => () => clearTimeout(t.current), []), x(() => {
14
- l.current = y();
15
- }), b(r, c), P({
13
+ return j(() => () => clearTimeout(t.current), []), C(() => {
14
+ l.current = P();
15
+ }), g(r, c), b({
16
16
  open: c,
17
17
  onClose: () => u(!1),
18
18
  inside: [l, r],
19
19
  outside: !1
20
- }), g(l, r, c, h), /* @__PURE__ */ w("span", {
20
+ }), v(l, r, c, y), /* @__PURE__ */ B("span", {
21
21
  ref: i,
22
- className: "cy-tooltip-anchor",
23
- onPointerEnter: (e) => e.pointerType !== "touch" && f(T),
22
+ className: p ? `cy-tooltip-anchor ${p}` : "cy-tooltip-anchor",
23
+ onPointerEnter: (e) => e.pointerType !== "touch" && m(T),
24
24
  onPointerLeave: () => s(120),
25
25
  onPointerDown: () => {
26
26
  n.current = !0, s();
27
27
  },
28
28
  onFocus: (e) => {
29
- !n.current && e.target.matches(":focus-visible") && f(0), n.current = !1;
29
+ !n.current && e.target.matches(":focus-visible") && m(0), n.current = !1;
30
30
  },
31
31
  onBlur: () => {
32
32
  n.current = !1, s();
33
33
  },
34
- children: [v(a, { "aria-describedby": [a.props["aria-describedby"], p].filter(Boolean).join(" ") }), /* @__PURE__ */ L("span", {
34
+ children: [E(a, { "aria-describedby": [a.props["aria-describedby"], f].filter(Boolean).join(" ") }), /* @__PURE__ */ w("span", {
35
35
  ref: r,
36
- id: p,
36
+ id: f,
37
37
  role: "tooltip",
38
38
  className: "cy-tooltip",
39
39
  popover: "manual",
40
40
  onPointerEnter: () => clearTimeout(t.current),
41
41
  onPointerLeave: () => s(120),
42
- children: d
42
+ children: h
43
43
  })]
44
44
  });
45
45
  }
46
46
  export {
47
- k as Tooltip
47
+ A as Tooltip
48
48
  };
49
49
 
50
50
  //# sourceMappingURL=Tooltip.js.map
@@ -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 /** 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,GACn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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","className","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 * Added to the element around the trigger (the anchor, the box the parent lays out), for layout: a grid area,\n * `flex`, margins.\n */\n className?: string | undefined;\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, className }: 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={className ? `cy-tooltip-anchor ${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":";;;;;;AAiDA,SAAgBY,EAAQ,EAAE,SAAAC,GAAS,UAAAC,GAAU,WAAAC,IAAY,OAAO,OAAAC,IAAQ,KAAK,WAAAC,EAAA,GAA2B;AACtG,QAAMC,IAAK,UAAUZ,EAAM,EAAE,QAAQ,MAAM,EAAE,CAAA,IACvCa,IAASX,EAAwB,IAAI,GACrCY,IAAMZ,EAAwB,IAAI,GAClCa,IAAQb,EAAkD,MAAS,GACnE,CAACc,GAAMC,CAAA,IAAWd,EAAS,EAAK,GAChCe,IAAA,MAAiBL,EAAO,SAAS,qBAA4CA,EAAO,SACpFM,IAAajB,EAA2B,IAAI,GAE5CkB,IAAelB,EAAO,EAAK,GAE3BmB,IAAOvB,EAAA,CAAawB,MAAiB;AACzC,iBAAaP,EAAM,OAAO,GAC1BA,EAAM,UAAU,WAAA,MAAiBE,EAAQ,EAAI,GAAGK,CAAI;AAAA,EACtD,GAAG,CAAC,CAAC,GACCC,IAAOzB,EAAA,CAAawB,IAAO,MAAM;AACrC,iBAAaP,EAAM,OAAO,GAC1BA,EAAM,UAAU,WAAA,MAAiBE,EAAQ,EAAK,GAAGK,CAAI;AAAA,EACvD,GAAG,CAAC,CAAC;AAEL,SAAAvB,EAAA,MAAA,MAAsB,aAAagB,EAAM,OAAO,GAAG,CAAC,CAAC,GACrDd,EAAA,MAAsB;AACpB,IAAAkB,EAAW,UAAUD,EAAQ;AAAA,EAC/B,CAAC,GACDvB,EAAWmB,GAAKE,CAAI,GAEpBtB,EAAW;AAAA,IAAE,MAAAsB;AAAA,IAAM,SAAA,MAAeC,EAAQ,EAAK;AAAA,IAAG,QAAQ,CAACE,GAAYL,CAAG;AAAA,IAAG,SAAS;AAAA,EAAM,CAAC,GAC7FlB,EAAoBuB,GAAYL,GAAKE,GAAMP,CAAS,GAIlD,gBAAAJ,EAAC,QAAD;AAAA,IACE,KAAKQ;AAAA,IACL,WAAWF,IAAY,qBAAqBA,CAAA,KAAc;AAAA,IAC1D,gBAAA,CAAiB,MAAM,EAAE,gBAAgB,WAAWU,EAAKX,CAAK;AAAA,IAC9D,gBAAA,MAAsBa,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,CAkBG1B,EAAaW,GAAU,EACtB,oBAAoB,CAACA,EAAS,MAAM,kBAAA,GAAqBI,CAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EACvF,CAAC,GACD,gBAAAR,EAAC,QAAD;AAAA,MACE,KAAKU;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,UAAAhB;AAAA,IACG,CAAA,CACF;AAAA,E;AAEV"}
@@ -0,0 +1,24 @@
1
+ import { type ReactNode } from "react";
2
+ export interface VisuallyHiddenProps {
3
+ /** The text for screen readers. */
4
+ children: ReactNode;
5
+ /**
6
+ * The element rendered. Use `span` inside a line of text, `div` or `p` for a block, and a heading level to give a
7
+ * section a heading that only screen readers announce. Default "span".
8
+ */
9
+ as?: "span" | "div" | "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
10
+ /**
11
+ * Show the content while something inside it has focus, for links and buttons that only keyboard users need. It is
12
+ * hidden again when focus leaves. Default false.
13
+ */
14
+ focusable?: boolean;
15
+ /** Set on the element, for `aria-labelledby`, `aria-describedby` and in-page links. */
16
+ id?: string | undefined;
17
+ /** Added to the element, for the layout of a focusable one while it is shown. */
18
+ className?: string | undefined;
19
+ }
20
+ /**
21
+ * Content for screen readers only: out of sight, still in the accessibility tree and read in place. With `focusable`,
22
+ * it is shown while something inside it has keyboard focus.
23
+ */
24
+ export declare const VisuallyHidden: import("react").ForwardRefExoticComponent<VisuallyHiddenProps & import("react").RefAttributes<HTMLElement>>;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { forwardRef as o } from "react";
3
+ import { jsx as n } from "react/jsx-runtime";
4
+ var u = o(function({ children: a, as: e = "span", focusable: r = !1, id: d, className: i }, l) {
5
+ return /* @__PURE__ */ n(e, {
6
+ ref: l,
7
+ id: d,
8
+ className: `cy-visually-hidden${i ? ` ${i}` : ""}`,
9
+ "data-focusable": r ? "" : void 0,
10
+ children: a
11
+ });
12
+ });
13
+ export {
14
+ u as VisuallyHidden
15
+ };
16
+
17
+ //# sourceMappingURL=VisuallyHidden.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VisuallyHidden.js","names":["Tag","forwardRef","jsx","VisuallyHidden","children","as","focusable","id","className","ref"],"sources":["../../../src/components/VisuallyHidden/VisuallyHidden.tsx"],"sourcesContent":["import { type ElementType, forwardRef, type ReactNode } from \"react\";\n\nexport interface VisuallyHiddenProps {\n /** The text for screen readers. */\n children: ReactNode;\n /**\n * The element rendered. Use `span` inside a line of text, `div` or `p` for a block, and a heading level to give a\n * section a heading that only screen readers announce. Default \"span\".\n */\n as?: \"span\" | \"div\" | \"p\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n /**\n * Show the content while something inside it has focus, for links and buttons that only keyboard users need. It is\n * hidden again when focus leaves. Default false.\n */\n focusable?: boolean;\n /** Set on the element, for `aria-labelledby`, `aria-describedby` and in-page links. */\n id?: string | undefined;\n /** Added to the element, for the layout of a focusable one while it is shown. */\n className?: string | undefined;\n}\n\n/**\n * Content for screen readers only: out of sight, still in the accessibility tree and read in place. With `focusable`,\n * it is shown while something inside it has keyboard focus.\n */\nexport const VisuallyHidden = forwardRef<HTMLElement, VisuallyHiddenProps>(function VisuallyHidden(\n { children, as = \"span\", focusable = false, id, className },\n ref,\n) {\n const Tag = as as ElementType;\n return (\n <Tag\n ref={ref}\n id={id}\n className={`cy-visually-hidden${className ? ` ${className}` : \"\"}`}\n data-focusable={focusable ? \"\" : undefined}\n >\n {children}\n </Tag>\n );\n});\n"],"mappings":";;;AAyBA,IAAaG,IAAiBF,EAA6C,SACzE,EAAE,UAAAG,GAAU,IAAAC,IAAK,QAAQ,WAAAC,IAAY,IAAO,IAAAC,GAAI,WAAAC,EAAA,GAChDC,GACA;AAEA,SACE,gBAAAP,EAACF,GAAD;AAAA,IACO,KAAAS;AAAA,IACD,IAAAF;AAAA,IACJ,WAAW,qBAAqBC,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IAC9D,kBAAgBF,IAAY,KAAK;AAAA,IAEhC,UAAAF;AAAA,EACE,CAAA;AAET,CAAC"}
@@ -0,0 +1 @@
1
+ export { VisuallyHidden, type VisuallyHiddenProps } from "./VisuallyHidden.js";
@@ -1,17 +1,17 @@
1
1
  "use client";
2
2
  import { useClientLayoutEffect as f } from "../client-layout-effect.js";
3
- import { forwardRef as o, useCallback as s, useRef as l } from "react";
4
- import { jsx as p } from "react/jsx-runtime";
5
- var y = o(function({ indeterminate: i = !1, className: n, ...u }, e) {
6
- const t = l(null), r = s((c) => {
3
+ import { forwardRef as s, useCallback as o, useRef as l } from "react";
4
+ import { jsx as m } from "react/jsx-runtime";
5
+ var y = s(function({ indeterminate: i = !1, className: n, ...r }, e) {
6
+ const t = l(null), u = o((c) => {
7
7
  t.current = c, typeof e == "function" ? e(c) : e && (e.current = c);
8
8
  }, [e]);
9
9
  return f(() => {
10
10
  t.current && (t.current.indeterminate = i);
11
- }, [i]), /* @__PURE__ */ p("input", {
12
- ref: r,
13
- className: `cy-choice-input${n ? ` ${n}` : ""}`,
14
- ...u
11
+ }, [i]), /* @__PURE__ */ m("input", {
12
+ ref: u,
13
+ className: `cy-choice-base${n ? ` ${n}` : ""}`,
14
+ ...r
15
15
  });
16
16
  });
17
17
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceBase.js","names":["useClientLayoutEffect","forwardRef","useCallback","useRef","jsx","ChoiceBase","indeterminate","className","rest","forwarded","inner","ref","node"],"sources":["../../../src/foundations/ChoiceBase/ChoiceBase.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes, useCallback, useRef } from \"react\";\nimport { useClientLayoutEffect } from \"../client-layout-effect.js\";\n\nexport interface ChoiceBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n /** Which native control to render. */\n type: \"checkbox\" | \"radio\";\n /** Checkbox only: the mixed state (aria-checked=\"mixed\"). */\n indeterminate?: boolean;\n}\n\n/**\n * Foundation: a native checkbox or radio, visually hidden under a Cynosure skin but still focusable, clickable and\n * form-associated (FormData, reset, required) for free.\n */\nexport const ChoiceBase = forwardRef<HTMLInputElement, ChoiceBaseProps>(function ChoiceBase(\n { indeterminate = false, className, ...rest },\n forwarded,\n) {\n const inner = useRef<HTMLInputElement | null>(null);\n const ref = useCallback(\n (node: HTMLInputElement | null) => {\n inner.current = node;\n if (typeof forwarded === \"function\") forwarded(node);\n else if (forwarded) forwarded.current = node;\n },\n [forwarded],\n );\n useClientLayoutEffect(() => {\n if (inner.current) inner.current.indeterminate = indeterminate;\n }, [indeterminate]);\n return <input ref={ref} className={`cy-choice-input${className ? ` ${className}` : \"\"}`} {...rest} />;\n});\n"],"mappings":";;;;AAcA,IAAaK,IAAaJ,EAA8C,SACtE,EAAE,eAAAK,IAAgB,IAAO,WAAAC,GAAW,GAAGC,EAAA,GACvCC,GACA;AACA,QAAMC,IAAQP,EAAgC,IAAI,GAC5CQ,IAAMT,EAAA,CACTU,MAAkC;AACjC,IAAAF,EAAM,UAAUE,GACZ,OAAOH,KAAc,aAAYA,EAAUG,CAAI,IAC1CH,MAAWA,EAAU,UAAUG;AAAA,EAC1C,GACA,CAACH,CAAS,CACZ;AACA,SAAAT,EAAA,MAA4B;AAC1B,IAAIU,EAAM,YAASA,EAAM,QAAQ,gBAAgBJ;AAAA,EACnD,GAAG,CAACA,CAAa,CAAC,GACX,gBAAAF,EAAC,SAAD;AAAA,IAAY,KAAAO;AAAA,IAAK,WAAW,kBAAkBJ,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IAAM,GAAIC;AAAA,EAAO,CAAA;AACtG,CAAC"}
1
+ {"version":3,"file":"ChoiceBase.js","names":["useClientLayoutEffect","forwardRef","useCallback","useRef","jsx","ChoiceBase","indeterminate","className","rest","forwarded","inner","ref","node"],"sources":["../../../src/foundations/ChoiceBase/ChoiceBase.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes, useCallback, useRef } from \"react\";\nimport { useClientLayoutEffect } from \"../client-layout-effect.js\";\n\nexport interface ChoiceBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n /** Which native control to render. */\n type: \"checkbox\" | \"radio\";\n /** Checkbox only: the mixed state (aria-checked=\"mixed\"). */\n indeterminate?: boolean;\n}\n\n/**\n * Foundation: a native checkbox or radio, visually hidden under a Cynosure skin but still focusable, clickable and\n * form-associated (FormData, reset, required) for free.\n */\nexport const ChoiceBase = forwardRef<HTMLInputElement, ChoiceBaseProps>(function ChoiceBase(\n { indeterminate = false, className, ...rest },\n forwarded,\n) {\n const inner = useRef<HTMLInputElement | null>(null);\n const ref = useCallback(\n (node: HTMLInputElement | null) => {\n inner.current = node;\n if (typeof forwarded === \"function\") forwarded(node);\n else if (forwarded) forwarded.current = node;\n },\n [forwarded],\n );\n useClientLayoutEffect(() => {\n if (inner.current) inner.current.indeterminate = indeterminate;\n }, [indeterminate]);\n return <input ref={ref} className={`cy-choice-base${className ? ` ${className}` : \"\"}`} {...rest} />;\n});\n"],"mappings":";;;;AAcA,IAAaK,IAAaJ,EAA8C,SACtE,EAAE,eAAAK,IAAgB,IAAO,WAAAC,GAAW,GAAGC,EAAA,GACvCC,GACA;AACA,QAAMC,IAAQP,EAAgC,IAAI,GAC5CQ,IAAMT,EAAA,CACTU,MAAkC;AACjC,IAAAF,EAAM,UAAUE,GACZ,OAAOH,KAAc,aAAYA,EAAUG,CAAI,IAC1CH,MAAWA,EAAU,UAAUG;AAAA,EAC1C,GACA,CAACH,CAAS,CACZ;AACA,SAAAT,EAAA,MAA4B;AAC1B,IAAIU,EAAM,YAASA,EAAM,QAAQ,gBAAgBJ;AAAA,EACnD,GAAG,CAACA,CAAa,CAAC,GACX,gBAAAF,EAAC,SAAD;AAAA,IAAY,KAAAO;AAAA,IAAK,WAAW,iBAAiBJ,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IAAM,GAAIC;AAAA,EAAO,CAAA;AACrG,CAAC"}