@arshad-shah/cynosure 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/README.md +9 -8
  2. package/dist/components/Accordion/Accordion.d.ts +14 -0
  3. package/dist/components/Accordion/Accordion.js.map +1 -1
  4. package/dist/components/Announcer/Announcer.d.ts +1 -0
  5. package/dist/components/Announcer/Announcer.js.map +1 -1
  6. package/dist/components/AppShell/AppShell.d.ts +22 -1
  7. package/dist/components/AppShell/AppShell.js +95 -83
  8. package/dist/components/AppShell/AppShell.js.map +1 -1
  9. package/dist/components/AppShell/index.d.ts +1 -1
  10. package/dist/components/AspectRatio/AspectRatio.d.ts +29 -0
  11. package/dist/components/AspectRatio/AspectRatio.js +21 -0
  12. package/dist/components/AspectRatio/AspectRatio.js.map +1 -0
  13. package/dist/components/AspectRatio/index.d.ts +1 -0
  14. package/dist/components/Avatar/Avatar.d.ts +96 -0
  15. package/dist/components/Avatar/Avatar.js +90 -0
  16. package/dist/components/Avatar/Avatar.js.map +1 -0
  17. package/dist/components/Avatar/index.d.ts +1 -0
  18. package/dist/components/Badge/Badge.d.ts +6 -0
  19. package/dist/components/Badge/Badge.js.map +1 -1
  20. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +55 -0
  21. package/dist/components/Breadcrumbs/Breadcrumbs.js +85 -0
  22. package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
  23. package/dist/components/Breadcrumbs/index.d.ts +1 -0
  24. package/dist/components/Button/Button.d.ts +13 -2
  25. package/dist/components/Button/Button.js +28 -26
  26. package/dist/components/Button/Button.js.map +1 -1
  27. package/dist/components/Calendar/Calendar.d.ts +65 -7
  28. package/dist/components/Calendar/Calendar.js +207 -95
  29. package/dist/components/Calendar/Calendar.js.map +1 -1
  30. package/dist/components/Calendar/dates.d.ts +4 -0
  31. package/dist/components/Calendar/dates.js +41 -27
  32. package/dist/components/Calendar/dates.js.map +1 -1
  33. package/dist/components/Calendar/index.d.ts +1 -1
  34. package/dist/components/Card/Card.d.ts +27 -0
  35. package/dist/components/Card/Card.js +48 -36
  36. package/dist/components/Card/Card.js.map +1 -1
  37. package/dist/components/Card/index.d.ts +1 -1
  38. package/dist/components/Checkbox/Checkbox.d.ts +8 -1
  39. package/dist/components/Checkbox/Checkbox.js +7 -6
  40. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  41. package/dist/components/Checkbox/ChoiceRow.d.ts +17 -1
  42. package/dist/components/Checkbox/ChoiceRow.js +19 -18
  43. package/dist/components/Checkbox/ChoiceRow.js.map +1 -1
  44. package/dist/components/Checklist/Checklist.d.ts +65 -0
  45. package/dist/components/Checklist/Checklist.js +163 -0
  46. package/dist/components/Checklist/Checklist.js.map +1 -0
  47. package/dist/components/Checklist/index.d.ts +1 -0
  48. package/dist/components/CodeBlock/CodeBlock.d.ts +5 -0
  49. package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
  50. package/dist/components/ColorField/ColorField.d.ts +12 -0
  51. package/dist/components/ColorField/ColorField.js +19 -19
  52. package/dist/components/ColorField/ColorField.js.map +1 -1
  53. package/dist/components/ColorSwatches/ColorSwatches.d.ts +5 -0
  54. package/dist/components/ColorSwatches/ColorSwatches.js +6 -6
  55. package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
  56. package/dist/components/Combobox/Combobox.d.ts +20 -1
  57. package/dist/components/Combobox/Combobox.js +38 -34
  58. package/dist/components/Combobox/Combobox.js.map +1 -1
  59. package/dist/components/CommandPalette/CommandPalette.d.ts +9 -0
  60. package/dist/components/CommandPalette/CommandPalette.js +10 -10
  61. package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
  62. package/dist/components/CompareSlider/CompareSlider.d.ts +4 -0
  63. package/dist/components/CompareSlider/CompareSlider.js +4 -4
  64. package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
  65. package/dist/components/Container/Container.d.ts +44 -0
  66. package/dist/components/Container/Container.js +24 -0
  67. package/dist/components/Container/Container.js.map +1 -0
  68. package/dist/components/Container/index.d.ts +1 -0
  69. package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
  70. package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
  71. package/dist/components/CopyButton/CopyButton.d.ts +8 -0
  72. package/dist/components/CopyButton/CopyButton.js.map +1 -1
  73. package/dist/components/DateField/DateField.d.ts +17 -0
  74. package/dist/components/DateField/DateField.js +6 -6
  75. package/dist/components/DateField/DateField.js.map +1 -1
  76. package/dist/components/DescriptionList/DescriptionList.d.ts +3 -0
  77. package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
  78. package/dist/components/Dialog/Dialog.d.ts +16 -2
  79. package/dist/components/Dialog/Dialog.js +82 -70
  80. package/dist/components/Dialog/Dialog.js.map +1 -1
  81. package/dist/components/Disclosure/Disclosure.d.ts +7 -0
  82. package/dist/components/Disclosure/Disclosure.js.map +1 -1
  83. package/dist/components/Divider/Divider.d.ts +59 -0
  84. package/dist/components/Divider/Divider.js +32 -0
  85. package/dist/components/Divider/Divider.js.map +1 -0
  86. package/dist/components/Divider/index.d.ts +1 -0
  87. package/dist/components/DocumentViewport/DocumentViewport.d.ts +8 -0
  88. package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
  89. package/dist/components/EmptyState/EmptyState.d.ts +3 -0
  90. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  91. package/dist/components/Field/Field.d.ts +6 -0
  92. package/dist/components/Field/Field.js.map +1 -1
  93. package/dist/components/FileDrop/FileDrop.d.ts +8 -0
  94. package/dist/components/FileDrop/FileDrop.js.map +1 -1
  95. package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +4 -0
  96. package/dist/components/FloatingToolbar/FloatingToolbar.js +4 -4
  97. package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
  98. package/dist/components/Grid/Grid.d.ts +33 -7
  99. package/dist/components/Grid/Grid.js +46 -25
  100. package/dist/components/Grid/Grid.js.map +1 -1
  101. package/dist/components/Grid/index.d.ts +1 -1
  102. package/dist/components/Heading/Heading.d.ts +57 -0
  103. package/dist/components/Heading/Heading.js +33 -0
  104. package/dist/components/Heading/Heading.js.map +1 -0
  105. package/dist/components/Heading/index.d.ts +1 -0
  106. package/dist/components/HoverCard/HoverCard.d.ts +1 -0
  107. package/dist/components/HoverCard/HoverCard.js.map +1 -1
  108. package/dist/components/IconButton/IconButton.d.ts +1 -0
  109. package/dist/components/IconButton/IconButton.js.map +1 -1
  110. package/dist/components/Image/Image.d.ts +62 -0
  111. package/dist/components/Image/Image.js +75 -0
  112. package/dist/components/Image/Image.js.map +1 -0
  113. package/dist/components/Image/index.d.ts +1 -0
  114. package/dist/components/Inline/Inline.d.ts +7 -3
  115. package/dist/components/Inline/Inline.js +19 -13
  116. package/dist/components/Inline/Inline.js.map +1 -1
  117. package/dist/components/Kbd/Kbd.d.ts +2 -0
  118. package/dist/components/Kbd/Kbd.js.map +1 -1
  119. package/dist/components/KeyValueEditor/KeyValueEditor.d.ts +7 -0
  120. package/dist/components/KeyValueEditor/KeyValueEditor.js +8 -8
  121. package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
  122. package/dist/components/Link/Link.d.ts +7 -0
  123. package/dist/components/Link/Link.js.map +1 -1
  124. package/dist/components/LoadingDots/LoadingDots.d.ts +2 -0
  125. package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
  126. package/dist/components/Menu/Menu.d.ts +13 -1
  127. package/dist/components/Menu/Menu.js +37 -35
  128. package/dist/components/Menu/Menu.js.map +1 -1
  129. package/dist/components/Notice/Notice.d.ts +5 -0
  130. package/dist/components/Notice/Notice.js.map +1 -1
  131. package/dist/components/NumberField/NumberField.d.ts +17 -0
  132. package/dist/components/NumberField/NumberField.js +8 -8
  133. package/dist/components/NumberField/NumberField.js.map +1 -1
  134. package/dist/components/PageHeader/PageHeader.d.ts +61 -0
  135. package/dist/components/PageHeader/PageHeader.js +63 -0
  136. package/dist/components/PageHeader/PageHeader.js.map +1 -0
  137. package/dist/components/PageHeader/index.d.ts +1 -0
  138. package/dist/components/Pagination/Pagination.d.ts +77 -0
  139. package/dist/components/Pagination/Pagination.js +120 -0
  140. package/dist/components/Pagination/Pagination.js.map +1 -0
  141. package/dist/components/Pagination/index.d.ts +1 -0
  142. package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +4 -0
  143. package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
  144. package/dist/components/Popover/Popover.d.ts +10 -0
  145. package/dist/components/Popover/Popover.js.map +1 -1
  146. package/dist/components/ProgressBar/ProgressBar.d.ts +5 -0
  147. package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
  148. package/dist/components/ProgressOverlay/ProgressOverlay.d.ts +3 -0
  149. package/dist/components/ProgressOverlay/ProgressOverlay.js.map +1 -1
  150. package/dist/components/Prose/Prose.d.ts +1 -0
  151. package/dist/components/Prose/Prose.js.map +1 -1
  152. package/dist/components/RadioGroup/RadioGroup.d.ts +13 -0
  153. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  154. package/dist/components/SegmentedControl/SegmentedControl.d.ts +9 -0
  155. package/dist/components/SegmentedControl/SegmentedControl.js +35 -27
  156. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  157. package/dist/components/Select/Select.d.ts +18 -1
  158. package/dist/components/Select/Select.js +97 -88
  159. package/dist/components/Select/Select.js.map +1 -1
  160. package/dist/components/Select/index.d.ts +1 -0
  161. package/dist/components/SelectionFrame/SelectionFrame.d.ts +6 -0
  162. package/dist/components/SelectionFrame/SelectionFrame.js.map +1 -1
  163. package/dist/components/SideNav/SideNav.d.ts +37 -1
  164. package/dist/components/SideNav/SideNav.js +100 -73
  165. package/dist/components/SideNav/SideNav.js.map +1 -1
  166. package/dist/components/SideNav/index.d.ts +1 -1
  167. package/dist/components/SignaturePad/SignaturePad.d.ts +3 -0
  168. package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
  169. package/dist/components/Skeleton/Skeleton.d.ts +1 -0
  170. package/dist/components/Skeleton/Skeleton.js.map +1 -1
  171. package/dist/components/Slider/Slider.d.ts +11 -0
  172. package/dist/components/Slider/Slider.js +6 -6
  173. package/dist/components/Slider/Slider.js.map +1 -1
  174. package/dist/components/SortableList/SortableList.d.ts +6 -0
  175. package/dist/components/SortableList/SortableList.js.map +1 -1
  176. package/dist/components/SplitPane/SplitPane.d.ts +5 -0
  177. package/dist/components/SplitPane/SplitPane.js +4 -4
  178. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  179. package/dist/components/Stack/Stack.d.ts +7 -3
  180. package/dist/components/Stack/Stack.js +18 -12
  181. package/dist/components/Stack/Stack.js.map +1 -1
  182. package/dist/components/Stack/index.d.ts +1 -0
  183. package/dist/components/Stack/space.d.ts +18 -0
  184. package/dist/components/Stack/space.js +12 -0
  185. package/dist/components/Stack/space.js.map +1 -0
  186. package/dist/components/Steps/Steps.d.ts +4 -0
  187. package/dist/components/Steps/Steps.js.map +1 -1
  188. package/dist/components/Table/Table.d.ts +12 -0
  189. package/dist/components/Table/Table.js.map +1 -1
  190. package/dist/components/Tabs/Tabs.d.ts +14 -0
  191. package/dist/components/Tabs/Tabs.js +4 -4
  192. package/dist/components/Tabs/Tabs.js.map +1 -1
  193. package/dist/components/TagInput/TagInput.d.ts +18 -0
  194. package/dist/components/TagInput/TagInput.js +5 -5
  195. package/dist/components/TagInput/TagInput.js.map +1 -1
  196. package/dist/components/Text/Text.d.ts +72 -0
  197. package/dist/components/Text/Text.js +30 -0
  198. package/dist/components/Text/Text.js.map +1 -0
  199. package/dist/components/Text/index.d.ts +1 -0
  200. package/dist/components/TextArea/TextArea.d.ts +10 -0
  201. package/dist/components/TextArea/TextArea.js +4 -4
  202. package/dist/components/TextArea/TextArea.js.map +1 -1
  203. package/dist/components/TextField/TextField.d.ts +13 -0
  204. package/dist/components/TextField/TextField.js +4 -4
  205. package/dist/components/TextField/TextField.js.map +1 -1
  206. package/dist/components/ThemeToggle/ThemeToggle.d.ts +4 -0
  207. package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
  208. package/dist/components/TimeField/TimeField.d.ts +62 -8
  209. package/dist/components/TimeField/TimeField.js +308 -72
  210. package/dist/components/TimeField/TimeField.js.map +1 -1
  211. package/dist/components/Toast/Toast.d.ts +25 -1
  212. package/dist/components/Toast/Toast.js +134 -125
  213. package/dist/components/Toast/Toast.js.map +1 -1
  214. package/dist/components/Toast/index.d.ts +1 -1
  215. package/dist/components/Toolbar/Toolbar.d.ts +3 -0
  216. package/dist/components/Toolbar/Toolbar.js.map +1 -1
  217. package/dist/components/Tooltip/Tooltip.d.ts +1 -0
  218. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  219. package/dist/components/Tree/Tree.d.ts +8 -0
  220. package/dist/components/Tree/Tree.js.map +1 -1
  221. package/dist/components/VirtualList/VirtualList.d.ts +8 -0
  222. package/dist/components/VirtualList/VirtualList.js +4 -4
  223. package/dist/components/VirtualList/VirtualList.js.map +1 -1
  224. package/dist/components/ZoomControls/ZoomControls.d.ts +4 -0
  225. package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
  226. package/dist/foundations/ChoiceBase/ChoiceBase.d.ts +1 -0
  227. package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
  228. package/dist/foundations/HiddenValue/HiddenValue.d.ts +3 -0
  229. package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
  230. package/dist/foundations/Icon/Icon.d.ts +3 -0
  231. package/dist/foundations/Icon/Icon.js.map +1 -1
  232. package/dist/foundations/image-outcome.d.ts +15 -0
  233. package/dist/foundations/image-outcome.js +39 -0
  234. package/dist/foundations/image-outcome.js.map +1 -0
  235. package/dist/foundations/option-icon.d.ts +26 -0
  236. package/dist/foundations/option-icon.js +16 -0
  237. package/dist/foundations/option-icon.js.map +1 -0
  238. package/dist/icons/index.d.ts +1 -0
  239. package/dist/icons/index.js +476 -474
  240. package/dist/icons/keywords.d.ts +249 -0
  241. package/dist/icons/keywords.js +1728 -0
  242. package/dist/icons/keywords.js.map +1 -0
  243. package/dist/index.d.ts +20 -9
  244. package/dist/index.js +240 -213
  245. package/dist/styles/app-shell.css +1 -1
  246. package/dist/styles/aspect-ratio.css +1 -0
  247. package/dist/styles/avatar.css +1 -0
  248. package/dist/styles/breadcrumbs.css +1 -0
  249. package/dist/styles/calendar.css +1 -1
  250. package/dist/styles/card.css +1 -1
  251. package/dist/styles/checkbox.css +1 -1
  252. package/dist/styles/checklist.css +1 -0
  253. package/dist/styles/container.css +1 -0
  254. package/dist/styles/divider.css +1 -0
  255. package/dist/styles/generated-css.d.ts +1 -1
  256. package/dist/styles/generated-css.js +1 -1
  257. package/dist/styles/generated-css.js.map +1 -1
  258. package/dist/styles/grid.css +1 -1
  259. package/dist/styles/heading.css +1 -0
  260. package/dist/styles/image.css +1 -0
  261. package/dist/styles/menu.css +1 -1
  262. package/dist/styles/page-header.css +1 -0
  263. package/dist/styles/pagination.css +1 -0
  264. package/dist/styles/segmented-control.css +1 -1
  265. package/dist/styles/side-nav.css +1 -1
  266. package/dist/styles/stack.css +1 -1
  267. package/dist/styles/text.css +1 -0
  268. package/dist/styles/time-field.css +1 -1
  269. package/dist/styles/toast.css +1 -1
  270. package/dist/styles.css +1 -1
  271. package/dist/theme/CynosureTheme.d.ts +4 -0
  272. package/dist/theme/CynosureTheme.js.map +1 -1
  273. package/dist/tokens/to-css.js +12 -12
  274. package/dist/tokens/to-css.js.map +1 -1
  275. package/package.json +4 -3
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","names":["external","_Fragment","externalIcon","Icon","LinkBase","external","forwardRef","Fragment$1","jsx","jsxs","Link","href","children","tone","size","external$1","onClick","labels","className","style","ref"],"sources":["../../../src/components/Link/Link.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type MouseEventHandler, type ReactNode } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { LinkBase } from \"../../foundations/LinkBase/LinkBase.js\";\nimport { external as externalIcon } from \"../../icons/external.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface LinkTokens {\n underlineOffset: string;\n underlineThickness: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n link: LinkTokens;\n }\n}\n\nexport interface LinkProps {\n href: string;\n children: ReactNode;\n tone?: Tone;\n size?: Size | \"inherit\";\n /** Opens in a new tab with a safe rel, an external icon and announced text. */\n external?: boolean;\n onClick?: MouseEventHandler<HTMLAnchorElement>;\n labels?: { external?: string };\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Inline text link. Text colours use each tone's readable text role. */\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(\n { href, children, tone = \"accent\", size = \"inherit\", external = false, onClick, labels, className, style },\n ref,\n) {\n return (\n <LinkBase\n ref={ref}\n href={href}\n onClick={onClick}\n className={`cy-link${className ? ` ${className}` : \"\"}`}\n data-tone={tone}\n data-size={size}\n style={style}\n {...(external ? { target: \"_blank\" } : {})}\n >\n {children}\n {external && (\n <>\n <Icon icon={externalIcon} size=\"sm\" className=\"cy-link-icon\" />\n <span className=\"cy-visually-hidden\"> {labels?.external ?? \"(opens in new tab)\"}</span>\n </>\n )}\n </LinkBase>\n );\n});\n"],"mappings":";;;;;;AAgCA,IAAaU,IAAOJ,EAAyC,SAC3D,EAAE,MAAAK,GAAM,UAAAC,GAAU,MAAAC,IAAO,UAAU,MAAAC,IAAO,WAAW,UAAAC,IAAW,IAAO,SAAAC,GAAS,QAAAC,GAAQ,WAAAC,GAAW,OAAAC,EAAA,GACnGC,GACA;AACA,SACE,gBAAAX,EAACL,GAAD;AAAA,IACO,KAAAgB;AAAA,IACC,MAAAT;AAAA,IACG,SAAAK;AAAA,IACT,WAAW,UAAUE,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACnD,aAAWL;AAAA,IACX,aAAWC;AAAA,IACJ,OAAAK;AAAA,IACP,GAAKnB,IAAW,EAAE,QAAQ,SAAS,IAAI,CAAC;AAAA,IAR1C,UAAA,CAUGY,GACAZ,KACC,gBAAAS,EAAAR,GAAA,EAAA,UAAA,CACE,gBAAAO,EAACL,GAAD;AAAA,MAAM,MAAMD;AAAAA,MAAc,MAAK;AAAA,MAAK,WAAU;AAAA,IAAgB,CAAA,GAC9D,gBAAAO,EAAC,QAAD;AAAA,MAAM,WAAU;AAAA,MAAhB,UAAA,CAAqC,KAAEQ,GAAQ,YAAY,oBAA2B;AAAA,IACtF,CAAA,CAAA,EAAA,CAAA,CAEI;AAAA,E;AAEd,CAAC"}
1
+ {"version":3,"file":"Link.js","names":["external","_Fragment","externalIcon","Icon","LinkBase","external","forwardRef","Fragment$1","jsx","jsxs","Link","href","children","tone","size","external$1","onClick","labels","className","style","ref"],"sources":["../../../src/components/Link/Link.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type MouseEventHandler, type ReactNode } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { LinkBase } from \"../../foundations/LinkBase/LinkBase.js\";\nimport { external as externalIcon } from \"../../icons/external.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface LinkTokens {\n underlineOffset: string;\n underlineThickness: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n link: LinkTokens;\n }\n}\n\nexport interface LinkProps {\n /** Where the link goes. */\n href: string;\n /** The link text. */\n children: ReactNode;\n /** Colour of the text. Default \"accent\". */\n tone?: Tone;\n /** Text size; `inherit` follows the surrounding text. Default \"inherit\". */\n size?: Size | \"inherit\";\n /** Opens in a new tab with a safe rel, an external icon and announced text. */\n external?: boolean;\n /** Called when the link is activated. */\n onClick?: MouseEventHandler<HTMLAnchorElement>;\n /** Replace the built-in English text: `external` is read out after a link that opens in a new tab. */\n labels?: { external?: string };\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Inline text link. Text colours use each tone's readable text role. */\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(\n { href, children, tone = \"accent\", size = \"inherit\", external = false, onClick, labels, className, style },\n ref,\n) {\n return (\n <LinkBase\n ref={ref}\n href={href}\n onClick={onClick}\n className={`cy-link${className ? ` ${className}` : \"\"}`}\n data-tone={tone}\n data-size={size}\n style={style}\n {...(external ? { target: \"_blank\" } : {})}\n >\n {children}\n {external && (\n <>\n <Icon icon={externalIcon} size=\"sm\" className=\"cy-link-icon\" />\n <span className=\"cy-visually-hidden\"> {labels?.external ?? \"(opens in new tab)\"}</span>\n </>\n )}\n </LinkBase>\n );\n});\n"],"mappings":";;;;;;AAuCA,IAAaU,IAAOJ,EAAyC,SAC3D,EAAE,MAAAK,GAAM,UAAAC,GAAU,MAAAC,IAAO,UAAU,MAAAC,IAAO,WAAW,UAAAC,IAAW,IAAO,SAAAC,GAAS,QAAAC,GAAQ,WAAAC,GAAW,OAAAC,EAAA,GACnGC,GACA;AACA,SACE,gBAAAX,EAACL,GAAD;AAAA,IACO,KAAAgB;AAAA,IACC,MAAAT;AAAA,IACG,SAAAK;AAAA,IACT,WAAW,UAAUE,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACnD,aAAWL;AAAA,IACX,aAAWC;AAAA,IACJ,OAAAK;AAAA,IACP,GAAKnB,IAAW,EAAE,QAAQ,SAAS,IAAI,CAAC;AAAA,IAR1C,UAAA,CAUGY,GACAZ,KACC,gBAAAS,EAAAR,GAAA,EAAA,UAAA,CACE,gBAAAO,EAACL,GAAD;AAAA,MAAM,MAAMD;AAAAA,MAAc,MAAK;AAAA,MAAK,WAAU;AAAA,IAAgB,CAAA,GAC9D,gBAAAO,EAAC,QAAD;AAAA,MAAM,WAAU;AAAA,MAAhB,UAAA,CAAqC,KAAEQ,GAAQ,YAAY,oBAA2B;AAAA,IACtF,CAAA,CAAA,EAAA,CAAA,CAEI;AAAA,E;AAEd,CAAC"}
@@ -25,9 +25,11 @@ export interface LoadingDotsProps {
25
25
  speed?: "slow" | "normal" | "fast";
26
26
  /** Announces progress (`role="status"`) with this name. Omit when the surrounding control already reports it (e.g. Button `aria-busy`). */
27
27
  label?: string;
28
+ /** Added to the root element, for layout. */
28
29
  className?: string;
29
30
  /** Layout only. Restyle through --cy-loading-dots-* tokens. */
30
31
  style?: CSSProperties;
32
+ /** Set on the root element, for tests. */
31
33
  "data-testid"?: string;
32
34
  }
33
35
  /** Three dots that pulse in sequence: Cynosure's indicator for short, indeterminate waits. */
@@ -1 +1 @@
1
- {"version":3,"file":"LoadingDots.js","names":["forwardRef","jsx","jsxs","LoadingDots","size","tone","color","speed","label","className","style","rest","ref"],"sources":["../../../src/components/LoadingDots/LoadingDots.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef } from \"react\";\nimport type { Tone } from \"../../tokens/schema.js\";\n\nexport interface LoadingDotsTokens {\n dotSize: string;\n gap: string;\n color: string;\n duration: string;\n sizeSm: string;\n sizeMd: string;\n sizeLg: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n loadingDots: LoadingDotsTokens;\n }\n}\n\nexport interface LoadingDotsProps {\n /** `inherit` follows the surrounding font size (use inside text and buttons); otherwise a fixed size. */\n size?: \"inherit\" | \"sm\" | \"md\" | \"lg\";\n /** Semantic colour. `inherit` uses the current text colour. */\n tone?: Tone | \"inherit\" | \"muted\";\n /** Any CSS colour; overrides `tone` for one-off cases. Prefer tones or tokens. */\n color?: string;\n /** Pulse speed. Reduced motion always shows static dots. */\n speed?: \"slow\" | \"normal\" | \"fast\";\n /** Announces progress (`role=\"status\"`) with this name. Omit when the surrounding control already reports it (e.g. Button `aria-busy`). */\n label?: string;\n className?: string;\n /** Layout only. Restyle through --cy-loading-dots-* tokens. */\n style?: CSSProperties;\n \"data-testid\"?: string;\n}\n\n/** Three dots that pulse in sequence: Cynosure's indicator for short, indeterminate waits. */\nexport const LoadingDots = forwardRef<HTMLSpanElement, LoadingDotsProps>(function LoadingDots(\n { size = \"inherit\", tone = \"inherit\", color, speed = \"normal\", label, className, style, ...rest },\n ref,\n) {\n return (\n <span\n ref={ref}\n {...rest}\n className={`cy-loading-dots${className ? ` ${className}` : \"\"}`}\n data-size={size}\n data-tone={tone}\n data-speed={speed}\n style={color ? ({ \"--cy-loading-dots-color\": color, ...style } as CSSProperties) : style}\n {...(label ? { role: \"status\", \"aria-label\": label } : { \"aria-hidden\": true })}\n >\n <span className=\"cy-reset cy-loading-dots-dot\" />\n <span className=\"cy-reset cy-loading-dots-dot\" />\n <span className=\"cy-reset cy-loading-dots-dot\" />\n </span>\n );\n});\n"],"mappings":";;;AAqCA,IAAaG,IAAcH,EAA8C,SACvE,EAAE,MAAAI,IAAO,WAAW,MAAAC,IAAO,WAAW,OAAAC,GAAO,OAAAC,IAAQ,UAAU,OAAAC,GAAO,WAAAC,GAAW,OAAAC,GAAO,GAAGC,EAAA,GAC3FC,GACA;AACA,SACE,gBAAAV,EAAC,QAAD;AAAA,IACO,KAAAU;AAAA,IACL,GAAID;AAAA,IACJ,WAAW,kBAAkBF,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IAC3D,aAAWL;AAAA,IACX,aAAWC;AAAA,IACX,cAAYE;AAAA,IACZ,OAAOD,IAAS;AAAA,MAAE,2BAA2BA;AAAA,MAAO,GAAGI;AAAA,IAAM,IAAsBA;AAAA,IACnF,GAAKF,IAAQ;AAAA,MAAE,MAAM;AAAA,MAAU,cAAcA;AAAA,IAAM,IAAI,EAAE,eAAe,GAAK;AAAA,IAR/E,UAAA;AAAA,MAUE,gBAAAP,EAAC,QAAD,EAAM,WAAU,+BAAgC,CAAA;AAAA,MAChD,gBAAAA,EAAC,QAAD,EAAM,WAAU,+BAAgC,CAAA;AAAA,MAChD,gBAAAA,EAAC,QAAD,EAAM,WAAU,+BAAgC,CAAA;AAAA,IAC5C;AAAA,E;AAEV,CAAC"}
1
+ {"version":3,"file":"LoadingDots.js","names":["forwardRef","jsx","jsxs","LoadingDots","size","tone","color","speed","label","className","style","rest","ref"],"sources":["../../../src/components/LoadingDots/LoadingDots.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef } from \"react\";\nimport type { Tone } from \"../../tokens/schema.js\";\n\nexport interface LoadingDotsTokens {\n dotSize: string;\n gap: string;\n color: string;\n duration: string;\n sizeSm: string;\n sizeMd: string;\n sizeLg: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n loadingDots: LoadingDotsTokens;\n }\n}\n\nexport interface LoadingDotsProps {\n /** `inherit` follows the surrounding font size (use inside text and buttons); otherwise a fixed size. */\n size?: \"inherit\" | \"sm\" | \"md\" | \"lg\";\n /** Semantic colour. `inherit` uses the current text colour. */\n tone?: Tone | \"inherit\" | \"muted\";\n /** Any CSS colour; overrides `tone` for one-off cases. Prefer tones or tokens. */\n color?: string;\n /** Pulse speed. Reduced motion always shows static dots. */\n speed?: \"slow\" | \"normal\" | \"fast\";\n /** Announces progress (`role=\"status\"`) with this name. Omit when the surrounding control already reports it (e.g. Button `aria-busy`). */\n label?: string;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-loading-dots-* tokens. */\n style?: CSSProperties;\n /** Set on the root element, for tests. */\n \"data-testid\"?: string;\n}\n\n/** Three dots that pulse in sequence: Cynosure's indicator for short, indeterminate waits. */\nexport const LoadingDots = forwardRef<HTMLSpanElement, LoadingDotsProps>(function LoadingDots(\n { size = \"inherit\", tone = \"inherit\", color, speed = \"normal\", label, className, style, ...rest },\n ref,\n) {\n return (\n <span\n ref={ref}\n {...rest}\n className={`cy-loading-dots${className ? ` ${className}` : \"\"}`}\n data-size={size}\n data-tone={tone}\n data-speed={speed}\n style={color ? ({ \"--cy-loading-dots-color\": color, ...style } as CSSProperties) : style}\n {...(label ? { role: \"status\", \"aria-label\": label } : { \"aria-hidden\": true })}\n >\n <span className=\"cy-reset cy-loading-dots-dot\" />\n <span className=\"cy-reset cy-loading-dots-dot\" />\n <span className=\"cy-reset cy-loading-dots-dot\" />\n </span>\n );\n});\n"],"mappings":";;;AAuCA,IAAaG,IAAcH,EAA8C,SACvE,EAAE,MAAAI,IAAO,WAAW,MAAAC,IAAO,WAAW,OAAAC,GAAO,OAAAC,IAAQ,UAAU,OAAAC,GAAO,WAAAC,GAAW,OAAAC,GAAO,GAAGC,EAAA,GAC3FC,GACA;AACA,SACE,gBAAAV,EAAC,QAAD;AAAA,IACO,KAAAU;AAAA,IACL,GAAID;AAAA,IACJ,WAAW,kBAAkBF,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IAC3D,aAAWL;AAAA,IACX,aAAWC;AAAA,IACX,cAAYE;AAAA,IACZ,OAAOD,IAAS;AAAA,MAAE,2BAA2BA;AAAA,MAAO,GAAGI;AAAA,IAAM,IAAsBA;AAAA,IACnF,GAAKF,IAAQ;AAAA,MAAE,MAAM;AAAA,MAAU,cAAcA;AAAA,IAAM,IAAI,EAAE,eAAe,GAAK;AAAA,IAR/E,UAAA;AAAA,MAUE,gBAAAP,EAAC,QAAD,EAAM,WAAU,+BAAgC,CAAA;AAAA,MAChD,gBAAAA,EAAC,QAAD,EAAM,WAAU,+BAAgC,CAAA;AAAA,MAChD,gBAAAA,EAAC,QAAD,EAAM,WAAU,+BAAgC,CAAA;AAAA,IAC5C;AAAA,E;AAEV,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type CSSProperties, type KeyboardEvent, type ReactNode, type Ref, type RefObject } from "react";
2
+ import { type OptionIconColor } from "../../foundations/option-icon.js";
2
3
  import type { IconData } from "../../icons/types.js";
3
4
  import type { Placement } from "../../overlay/position.js";
4
5
  import { type VirtualAnchor } from "../../overlay/use-anchored-position.js";
@@ -14,9 +15,10 @@ declare module "../../tokens/schema.js" {
14
15
  menu: MenuTokens;
15
16
  }
16
17
  }
17
- export interface MenuItem {
18
+ export interface MenuItem extends OptionIconColor {
18
19
  value: string;
19
20
  label: string;
21
+ /** Icon before the label, muted by default. Colour it with `iconTone` or `iconColor`. */
20
22
  icon?: IconData;
21
23
  /**
22
24
  * Keys shown at the end of the row and exposed as aria-keyshortcuts: ["Ctrl", "E"], or "mod+e" for this platform's
@@ -39,11 +41,17 @@ export interface MenuSection {
39
41
  export type MenuEntry = MenuItem | MenuSection;
40
42
  /** Spread onto the trigger (a Button or IconButton). */
41
43
  export interface MenuTriggerProps {
44
+ /** Spread onto the trigger. The menu is placed against this element and focus returns to it on close. */
42
45
  ref: Ref<HTMLButtonElement>;
46
+ /** Spread onto the trigger. Opens the menu, or closes it when it is open. */
43
47
  onClick: () => void;
48
+ /** Spread onto the trigger. Arrow Down opens the menu on its first item, Arrow Up on its last. */
44
49
  onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;
50
+ /** Spread onto the trigger. Whether the menu is open. */
45
51
  "aria-expanded": boolean;
52
+ /** Spread onto the trigger. The id of the menu panel. */
46
53
  "aria-controls": string;
54
+ /** Spread onto the trigger. Tells assistive technology that it opens a menu. */
47
55
  "aria-haspopup": "menu";
48
56
  }
49
57
  export interface MenuProps {
@@ -51,9 +59,13 @@ export interface MenuProps {
51
59
  trigger: (props: MenuTriggerProps) => ReactNode;
52
60
  /** Accessible name of the menu. */
53
61
  label: string;
62
+ /** The commands: items, or labelled sections of items. */
54
63
  items: MenuEntry[];
64
+ /** Called with the chosen item's `value`. */
55
65
  onSelect: (value: string) => void;
66
+ /** Side of the trigger the menu opens on. Default "bottom". */
56
67
  placement?: Placement;
68
+ /** Added to the menu panel, for layout. */
57
69
  className?: string;
58
70
  /** Layout only, applied to the panel. */
59
71
  style?: CSSProperties;
@@ -1,59 +1,61 @@
1
1
  "use client";
2
- import { ButtonBase as $ } from "../../foundations/ButtonBase/ButtonBase.js";
3
- import { Icon as N } from "../../foundations/Icon/Icon.js";
4
- import { useDismiss as I } from "../../overlay/dismiss.js";
2
+ import { ButtonBase as T } from "../../foundations/ButtonBase/ButtonBase.js";
3
+ import { Icon as I } from "../../foundations/Icon/Icon.js";
4
+ import { useDismiss as $ } from "../../overlay/dismiss.js";
5
5
  import { usePopover as P } from "../../overlay/floating.js";
6
6
  import { useAnchoredPosition as M } from "../../overlay/use-anchored-position.js";
7
- import { check as R } from "../../icons/check.js";
8
- import { useRovingFocus as j } from "../../foundations/roving-focus.js";
9
- import { ariaKeyShortcuts as q, shortcutKeys as B } from "../../foundations/hotkey.js";
10
- import { Kbd as C, useApple as U } from "../Kbd/Kbd.js";
11
- import { isTypeaheadKey as z, useTypeahead as E } from "../../foundations/listbox.js";
12
- import { Fragment as G, useCallback as K, useId as H, useRef as F, useState as D } from "react";
13
- import { Fragment as J, jsx as o, jsxs as m } from "react/jsx-runtime";
14
- var A = '[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]', L = (s) => "items" in s;
15
- function Q({ id: s, label: p, items: f, onSelect: h, open: t, onClose: c, focusOn: b, anchor: u, placement: i, offset: l, inside: k, returnFocus: y, className: n, style: d }) {
16
- const g = U(), r = F(null), S = E();
7
+ import { ariaKeyShortcuts as R, shortcutKeys as j } from "../../foundations/hotkey.js";
8
+ import { isTypeaheadKey as q, useTypeahead as B } from "../../foundations/listbox.js";
9
+ import { OptionIcon as C } from "../../foundations/option-icon.js";
10
+ import { useRovingFocus as U } from "../../foundations/roving-focus.js";
11
+ import { check as z } from "../../icons/check.js";
12
+ import { Kbd as E, useApple as G } from "../Kbd/Kbd.js";
13
+ import { Fragment as H, useCallback as N, useId as J, useRef as D, useState as K } from "react";
14
+ import { Fragment as L, jsx as o, jsxs as m } from "react/jsx-runtime";
15
+ var A = '[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]', Q = (s) => "items" in s;
16
+ function V({ id: s, label: p, items: f, onSelect: h, open: t, onClose: c, focusOn: b, anchor: u, placement: i, offset: l, inside: k, returnFocus: y, className: n, style: d }) {
17
+ const g = G(), r = D(null), F = B();
17
18
  P(r, t, (e) => {
18
19
  const a = [...e.querySelectorAll(A)].filter((w) => w.getAttribute("aria-disabled") !== "true");
19
20
  (b === "last" ? a[a.length - 1] : a[0])?.focus({ preventScroll: !0 });
20
- }), M(u, r, t, i, l, "start"), j(r, {
21
+ }), M(u, r, t, i, l, "start"), U(r, {
21
22
  orientation: "vertical",
22
23
  selector: A
23
- }), I({
24
+ }), $({
24
25
  open: t,
25
26
  onClose: c,
26
27
  inside: [...k, r],
27
28
  returnFocus: y
28
29
  });
29
- const T = (e) => {
30
+ const O = (e) => {
30
31
  e.disabled || (h(e.value), (e.keepOpen ?? !!e.kind) || c());
31
- }, O = (e) => {
32
+ }, S = (e) => {
32
33
  if (e.key === "Tab") {
33
34
  c();
34
35
  return;
35
36
  }
36
- if (!z(e)) return;
37
+ if (!q(e)) return;
37
38
  const a = [...e.currentTarget.querySelectorAll(A)].filter((x) => x.getAttribute("aria-disabled") !== "true"), w = a.indexOf(e.target);
38
- a[S(e.key, a.map((x) => x.dataset.label ?? ""), w)]?.focus();
39
- }, v = (e) => /* @__PURE__ */ m($, {
39
+ a[F(e.key, a.map((x) => x.dataset.label ?? ""), w)]?.focus();
40
+ }, v = (e) => /* @__PURE__ */ m(T, {
40
41
  role: e.kind ? e.kind === "checkbox" ? "menuitemcheckbox" : "menuitemradio" : "menuitem",
41
42
  "aria-checked": e.kind ? !!e.checked : void 0,
42
43
  "aria-disabled": e.disabled || void 0,
43
- "aria-keyshortcuts": e.shortcut && q(typeof e.shortcut == "string" ? B(e.shortcut, g) : e.shortcut),
44
+ "aria-keyshortcuts": e.shortcut && R(typeof e.shortcut == "string" ? j(e.shortcut, g) : e.shortcut),
44
45
  tabIndex: -1,
45
46
  className: "cy-menu-item",
46
47
  "data-tone": e.tone,
47
48
  "data-label": e.label,
48
- onClick: () => T(e),
49
+ onClick: () => O(e),
49
50
  children: [
50
51
  e.kind && /* @__PURE__ */ o("span", {
51
52
  className: "cy-menu-check",
52
53
  "aria-hidden": "true",
53
- children: e.checked && /* @__PURE__ */ o(N, { icon: R })
54
+ children: e.checked && /* @__PURE__ */ o(I, { icon: z })
54
55
  }),
55
- e.icon && /* @__PURE__ */ o(N, {
56
- icon: e.icon,
56
+ /* @__PURE__ */ o(C, {
57
+ option: e,
58
+ plain: e.disabled,
57
59
  className: "cy-menu-icon"
58
60
  }),
59
61
  /* @__PURE__ */ o("span", {
@@ -63,7 +65,7 @@ function Q({ id: s, label: p, items: f, onSelect: h, open: t, onClose: c, focusO
63
65
  e.shortcut && /* @__PURE__ */ o("span", {
64
66
  className: "cy-menu-shortcut",
65
67
  "aria-hidden": "true",
66
- children: /* @__PURE__ */ o(C, {
68
+ children: /* @__PURE__ */ o(E, {
67
69
  keys: e.shortcut,
68
70
  size: "sm"
69
71
  })
@@ -79,8 +81,8 @@ function Q({ id: s, label: p, items: f, onSelect: h, open: t, onClose: c, focusO
79
81
  popover: "manual",
80
82
  className: n ? `cy-menu ${n}` : "cy-menu",
81
83
  style: d,
82
- onKeyDown: O,
83
- children: f.map((e, a) => L(e) ? /* @__PURE__ */ m(G, { children: [a > 0 && /* @__PURE__ */ o("hr", { className: "cy-menu-separator" }), /* @__PURE__ */ m("div", {
84
+ onKeyDown: S,
85
+ children: f.map((e, a) => Q(e) ? /* @__PURE__ */ m(H, { children: [a > 0 && /* @__PURE__ */ o("hr", { className: "cy-menu-separator" }), /* @__PURE__ */ m("div", {
84
86
  role: "group",
85
87
  "aria-label": e.label,
86
88
  className: "cy-menu-group",
@@ -92,11 +94,11 @@ function Q({ id: s, label: p, items: f, onSelect: h, open: t, onClose: c, focusO
92
94
  })] }, `section-${e.label}`) : v(e))
93
95
  });
94
96
  }
95
- function te({ trigger: s, label: p, items: f, onSelect: h, placement: t = "bottom", className: c, style: b }) {
96
- const u = H(), [i, l] = D(!1), [k, y] = D("first"), n = F(null), d = K((r) => {
97
+ function ie({ trigger: s, label: p, items: f, onSelect: h, placement: t = "bottom", className: c, style: b }) {
98
+ const u = J(), [i, l] = K(!1), [k, y] = K("first"), n = D(null), d = N((r) => {
97
99
  y(r), l(!0);
98
- }, []), g = K(() => l(!1), []);
99
- return /* @__PURE__ */ m(J, { children: [s({
100
+ }, []), g = N(() => l(!1), []);
101
+ return /* @__PURE__ */ m(L, { children: [s({
100
102
  ref: n,
101
103
  onClick: () => i ? l(!1) : d("first"),
102
104
  onKeyDown: (r) => {
@@ -105,7 +107,7 @@ function te({ trigger: s, label: p, items: f, onSelect: h, placement: t = "botto
105
107
  "aria-expanded": i,
106
108
  "aria-controls": `${u}-menu`,
107
109
  "aria-haspopup": "menu"
108
- }), /* @__PURE__ */ o(Q, {
110
+ }), /* @__PURE__ */ o(V, {
109
111
  id: u,
110
112
  label: p,
111
113
  items: f,
@@ -123,8 +125,8 @@ function te({ trigger: s, label: p, items: f, onSelect: h, placement: t = "botto
123
125
  })] });
124
126
  }
125
127
  export {
126
- te as Menu,
127
- Q as MenuPanel
128
+ ie as Menu,
129
+ V as MenuPanel
128
130
  };
129
131
 
130
132
  //# sourceMappingURL=Menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","names":["_Fragment","ButtonBase","Icon","useDismiss","usePopover","useAnchoredPosition","check","useRovingFocus","ariaKeyShortcuts","shortcutKeys","Kbd","useApple","isTypeaheadKey","useTypeahead","Fragment","useCallback","useId","useRef","useState","Fragment$1","jsx","jsxs","ITEM","isSection","entry","MenuPanel","id","label","items","onSelect","open","onClose","focusOn","anchor","placement","offset","inside","returnFocus","className","style","apple","panel","typeTo","el","enabled","i","choose","item","onPanelKeyDown","event","list","from","row","Menu","trigger","setOpen","setFocusOn","triggerRef","show","at","close"],"sources":["../../../src/components/Menu/Menu.tsx"],"sourcesContent":["import {\n type CSSProperties,\n Fragment,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n type RefObject,\n useCallback,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { ButtonBase } from \"../../foundations/ButtonBase/ButtonBase.js\";\nimport { ariaKeyShortcuts, shortcutKeys } from \"../../foundations/hotkey.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { isTypeaheadKey, useTypeahead } from \"../../foundations/listbox.js\";\nimport { useRovingFocus } from \"../../foundations/roving-focus.js\";\nimport { check } from \"../../icons/check.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { usePopover } from \"../../overlay/floating.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { useAnchoredPosition, type VirtualAnchor } from \"../../overlay/use-anchored-position.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\nimport { Kbd, useApple } from \"../Kbd/Kbd.js\";\n\nexport interface MenuTokens {\n minWidth: string;\n maxWidth: string;\n radius: string;\n rowHeight: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n menu: MenuTokens;\n }\n}\n\nexport interface MenuItem {\n value: string;\n label: string;\n icon?: IconData;\n /**\n * Keys shown at the end of the row and exposed as aria-keyshortcuts: [\"Ctrl\", \"E\"], or \"mod+e\" for this platform's\n * names (Cmd on Apple). Display only: bind them yourself (`useHotkey`).\n */\n shortcut?: string[] | string;\n disabled?: boolean;\n tone?: Extract<Tone, \"neutral\" | \"danger\">;\n /** Checkable item: a toggle (`checkbox`) or one of a set (`radio`). Checkable items keep the menu open. */\n kind?: \"checkbox\" | \"radio\";\n checked?: boolean;\n /** Stay open after choosing. Default: true for checkable items (several toggles in a row), false otherwise. */\n keepOpen?: boolean;\n}\n\nexport interface MenuSection {\n /** Group name (shown and announced). */\n label: string;\n items: MenuItem[];\n}\n\nexport type MenuEntry = MenuItem | MenuSection;\n\n/** Spread onto the trigger (a Button or IconButton). */\nexport interface MenuTriggerProps {\n ref: Ref<HTMLButtonElement>;\n onClick: () => void;\n onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;\n \"aria-expanded\": boolean;\n \"aria-controls\": string;\n \"aria-haspopup\": \"menu\";\n}\n\nexport interface MenuProps {\n /** Render the trigger: `(props) => <Button {...props}>Actions</Button>`. */\n trigger: (props: MenuTriggerProps) => ReactNode;\n /** Accessible name of the menu. */\n label: string;\n items: MenuEntry[];\n onSelect: (value: string) => void;\n placement?: Placement;\n className?: string;\n /** Layout only, applied to the panel. */\n style?: CSSProperties;\n}\n\nconst ITEM = '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]';\nconst isSection = (entry: MenuEntry): entry is MenuSection => \"items\" in entry;\n\nexport interface MenuPanelProps {\n id: string;\n label: string;\n items: MenuEntry[];\n onSelect: (value: string) => void;\n open: boolean;\n onClose: () => void;\n /** Which item takes focus when the panel opens. */\n focusOn: \"first\" | \"last\";\n /** What the panel is placed against: the trigger, or a point (context menus). */\n anchor: RefObject<HTMLElement | VirtualAnchor | null>;\n placement: Placement;\n offset: number;\n /** Elements that count as inside (clicking them does not dismiss). */\n inside: RefObject<HTMLElement | null>[];\n returnFocus: RefObject<HTMLElement | null>;\n className?: string | undefined;\n style?: CSSProperties | undefined;\n}\n\n/** Internal: the menu list in the top layer, shared by Menu and ContextMenu. */\nexport function MenuPanel({\n id,\n label,\n items,\n onSelect,\n open,\n onClose,\n focusOn,\n anchor,\n placement,\n offset,\n inside,\n returnFocus,\n className,\n style,\n}: MenuPanelProps) {\n const apple = useApple();\n const panel = useRef<HTMLDivElement>(null);\n const typeTo = useTypeahead();\n\n usePopover(panel, open, (el) => {\n const enabled = [...el.querySelectorAll<HTMLElement>(ITEM)].filter(\n (i) => i.getAttribute(\"aria-disabled\") !== \"true\",\n );\n (focusOn === \"last\" ? enabled[enabled.length - 1] : enabled[0])?.focus({ preventScroll: true });\n });\n useAnchoredPosition(anchor, panel, open, placement, offset, \"start\");\n useRovingFocus(panel, { orientation: \"vertical\", selector: ITEM });\n useDismiss({ open, onClose, inside: [...inside, panel], returnFocus });\n\n const choose = (item: MenuItem) => {\n if (item.disabled) return;\n onSelect(item.value);\n if (!(item.keepOpen ?? !!item.kind)) onClose();\n };\n\n const onPanelKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Tab leaves the menu like leaving the button: close and let focus move on.\n if (event.key === \"Tab\") {\n onClose();\n return;\n }\n if (!isTypeaheadKey(event)) return;\n const list = [...event.currentTarget.querySelectorAll<HTMLElement>(ITEM)].filter(\n (i) => i.getAttribute(\"aria-disabled\") !== \"true\",\n );\n const from = list.indexOf(event.target as HTMLElement);\n list[\n typeTo(\n event.key,\n list.map((i) => i.dataset.label ?? \"\"),\n from,\n )\n ]?.focus();\n };\n\n const row = (item: MenuItem) => (\n <ButtonBase\n key={item.value}\n role={item.kind ? (item.kind === \"checkbox\" ? \"menuitemcheckbox\" : \"menuitemradio\") : \"menuitem\"}\n aria-checked={item.kind ? !!item.checked : undefined}\n aria-disabled={item.disabled || undefined}\n aria-keyshortcuts={\n item.shortcut &&\n ariaKeyShortcuts(\n typeof item.shortcut === \"string\" ? shortcutKeys(item.shortcut, apple) : item.shortcut,\n )\n }\n tabIndex={-1}\n className=\"cy-menu-item\"\n data-tone={item.tone}\n data-label={item.label}\n onClick={() => choose(item)}\n >\n {item.kind && (\n <span className=\"cy-menu-check\" aria-hidden=\"true\">\n {item.checked && <Icon icon={check} />}\n </span>\n )}\n {item.icon && <Icon icon={item.icon} className=\"cy-menu-icon\" />}\n <span className=\"cy-menu-label\">{item.label}</span>\n {item.shortcut && (\n <span className=\"cy-menu-shortcut\" aria-hidden=\"true\">\n <Kbd keys={item.shortcut} size=\"sm\" />\n </span>\n )}\n </ButtonBase>\n );\n\n return (\n <div\n ref={panel}\n id={`${id}-menu`}\n role=\"menu\"\n aria-label={label}\n aria-orientation=\"vertical\"\n {...{ popover: \"manual\" }}\n className={className ? `cy-menu ${className}` : \"cy-menu\"}\n style={style}\n onKeyDown={onPanelKeyDown}\n >\n {items.map((entry, i) =>\n isSection(entry) ? (\n <Fragment key={`section-${entry.label}`}>\n {i > 0 && <hr className=\"cy-menu-separator\" />}\n {/* biome-ignore lint/a11y/useSemanticElements: APG menus group items with role=\"group\"; a fieldset is for forms */}\n <div role=\"group\" aria-label={entry.label} className=\"cy-menu-group\">\n <span className=\"cy-menu-group-label\" aria-hidden=\"true\">\n {entry.label}\n </span>\n {entry.items.map(row)}\n </div>\n </Fragment>\n ) : (\n row(entry)\n ),\n )}\n </div>\n );\n}\n\n/** APG menu button: commands in a top-layer list with arrow keys, type-ahead, sections and checkable items. */\nexport function Menu({ trigger, label, items, onSelect, placement = \"bottom\", className, style }: MenuProps) {\n const id = useId();\n const [open, setOpen] = useState(false);\n const [focusOn, setFocusOn] = useState<\"first\" | \"last\">(\"first\");\n const triggerRef = useRef<HTMLButtonElement>(null);\n const show = useCallback((at: \"first\" | \"last\") => {\n setFocusOn(at);\n setOpen(true);\n }, []);\n const close = useCallback(() => setOpen(false), []);\n\n return (\n <>\n {trigger({\n ref: triggerRef,\n onClick: () => (open ? setOpen(false) : show(\"first\")),\n onKeyDown: (event) => {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n show(event.key === \"ArrowUp\" ? \"last\" : \"first\");\n }\n },\n \"aria-expanded\": open,\n \"aria-controls\": `${id}-menu`,\n \"aria-haspopup\": \"menu\",\n })}\n <MenuPanel\n id={id}\n label={label}\n items={items}\n onSelect={onSelect}\n open={open}\n onClose={close}\n focusOn={focusOn}\n anchor={triggerRef}\n placement={placement}\n offset={4}\n inside={[triggerRef]}\n returnFocus={triggerRef}\n className={className}\n style={style}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAwFA,IAAMsB,IAAO,wEACPC,IAAA,CAAaC,MAA2C,WAAWA;AAuBzE,SAAgBC,EAAU,EACxB,IAAAC,GACA,OAAAC,GACA,OAAAC,GACA,UAAAC,GACA,MAAAC,GACA,SAAAC,GACA,SAAAC,GACA,QAAAC,GACA,WAAAC,GACA,QAAAC,GACA,QAAAC,GACA,aAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACiB;AACjB,QAAMC,IAAQ7B,EAAS,GACjB8B,IAAQxB,EAAuB,IAAI,GACnCyB,IAAS7B,EAAa;AAE5B,EAAAT,EAAWqC,GAAOX,GAAA,CAAOa,MAAO;AAC9B,UAAMC,IAAU,CAAC,GAAGD,EAAG,iBAA8BrB,CAAI,CAAC,EAAE,OAAA,CACzDuB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ACjB,iBAAiB,GAAGJ,CAAA;AAAA,IACpB,iBAAiB;AAAA,EACnB,CAAC,GACD,gBAAAN,EAACK,GAAD;AAAA,IACM,IAAAC;AAAA,IACG,OAAAC;AAAA,IACA,OAAAC;AAAA,IACG,UAAAC;AAAA,IACJ,MAAAC;AAAA,IACN,SAAS8B;AAAA,IACA,SAAA5B;AAAA,IACT,QAAQyB;AAAA,IACG,WAAAvB;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ,CAACuB,CAAU;AAAA,IACnB,aAAaA;AAAA,IACF,WAAAnB;AAAA,IACJ,OAAAC;AAAA,EACR,CAAA,CACD,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"Menu.js","names":["_Fragment","ButtonBase","Icon","useDismiss","usePopover","useAnchoredPosition","ariaKeyShortcuts","shortcutKeys","isTypeaheadKey","useTypeahead","OptionIcon","useRovingFocus","check","Kbd","useApple","Fragment","useCallback","useId","useRef","useState","Fragment$1","jsx","jsxs","ITEM","isSection","entry","MenuPanel","id","label","items","onSelect","open","onClose","focusOn","anchor","placement","offset","inside","returnFocus","className","style","apple","panel","typeTo","el","enabled","i","choose","item","onPanelKeyDown","event","list","from","row","Menu","trigger","setOpen","setFocusOn","triggerRef","show","at","close"],"sources":["../../../src/components/Menu/Menu.tsx"],"sourcesContent":["import {\n type CSSProperties,\n Fragment,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n type RefObject,\n useCallback,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { ButtonBase } from \"../../foundations/ButtonBase/ButtonBase.js\";\nimport { ariaKeyShortcuts, shortcutKeys } from \"../../foundations/hotkey.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { isTypeaheadKey, useTypeahead } from \"../../foundations/listbox.js\";\nimport { OptionIcon, type OptionIconColor } from \"../../foundations/option-icon.js\";\nimport { useRovingFocus } from \"../../foundations/roving-focus.js\";\nimport { check } from \"../../icons/check.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport { useDismiss } from \"../../overlay/dismiss.js\";\nimport { usePopover } from \"../../overlay/floating.js\";\nimport type { Placement } from \"../../overlay/position.js\";\nimport { useAnchoredPosition, type VirtualAnchor } from \"../../overlay/use-anchored-position.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\nimport { Kbd, useApple } from \"../Kbd/Kbd.js\";\n\nexport interface MenuTokens {\n minWidth: string;\n maxWidth: string;\n radius: string;\n rowHeight: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n menu: MenuTokens;\n }\n}\n\nexport interface MenuItem extends OptionIconColor {\n value: string;\n label: string;\n /** Icon before the label, muted by default. Colour it with `iconTone` or `iconColor`. */\n icon?: IconData;\n /**\n * Keys shown at the end of the row and exposed as aria-keyshortcuts: [\"Ctrl\", \"E\"], or \"mod+e\" for this platform's\n * names (Cmd on Apple). Display only: bind them yourself (`useHotkey`).\n */\n shortcut?: string[] | string;\n disabled?: boolean;\n tone?: Extract<Tone, \"neutral\" | \"danger\">;\n /** Checkable item: a toggle (`checkbox`) or one of a set (`radio`). Checkable items keep the menu open. */\n kind?: \"checkbox\" | \"radio\";\n checked?: boolean;\n /** Stay open after choosing. Default: true for checkable items (several toggles in a row), false otherwise. */\n keepOpen?: boolean;\n}\n\nexport interface MenuSection {\n /** Group name (shown and announced). */\n label: string;\n items: MenuItem[];\n}\n\nexport type MenuEntry = MenuItem | MenuSection;\n\n/** Spread onto the trigger (a Button or IconButton). */\nexport interface MenuTriggerProps {\n /** Spread onto the trigger. The menu is placed against this element and focus returns to it on close. */\n ref: Ref<HTMLButtonElement>;\n /** Spread onto the trigger. Opens the menu, or closes it when it is open. */\n onClick: () => void;\n /** Spread onto the trigger. Arrow Down opens the menu on its first item, Arrow Up on its last. */\n onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;\n /** Spread onto the trigger. Whether the menu is open. */\n \"aria-expanded\": boolean;\n /** Spread onto the trigger. The id of the menu panel. */\n \"aria-controls\": string;\n /** Spread onto the trigger. Tells assistive technology that it opens a menu. */\n \"aria-haspopup\": \"menu\";\n}\n\nexport interface MenuProps {\n /** Render the trigger: `(props) => <Button {...props}>Actions</Button>`. */\n trigger: (props: MenuTriggerProps) => ReactNode;\n /** Accessible name of the menu. */\n label: string;\n /** The commands: items, or labelled sections of items. */\n items: MenuEntry[];\n /** Called with the chosen item's `value`. */\n onSelect: (value: string) => void;\n /** Side of the trigger the menu opens on. Default \"bottom\". */\n placement?: Placement;\n /** Added to the menu panel, for layout. */\n className?: string;\n /** Layout only, applied to the panel. */\n style?: CSSProperties;\n}\n\nconst ITEM = '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]';\nconst isSection = (entry: MenuEntry): entry is MenuSection => \"items\" in entry;\n\nexport interface MenuPanelProps {\n id: string;\n label: string;\n items: MenuEntry[];\n onSelect: (value: string) => void;\n open: boolean;\n onClose: () => void;\n /** Which item takes focus when the panel opens. */\n focusOn: \"first\" | \"last\";\n /** What the panel is placed against: the trigger, or a point (context menus). */\n anchor: RefObject<HTMLElement | VirtualAnchor | null>;\n placement: Placement;\n offset: number;\n /** Elements that count as inside (clicking them does not dismiss). */\n inside: RefObject<HTMLElement | null>[];\n returnFocus: RefObject<HTMLElement | null>;\n className?: string | undefined;\n style?: CSSProperties | undefined;\n}\n\n/** Internal: the menu list in the top layer, shared by Menu and ContextMenu. */\nexport function MenuPanel({\n id,\n label,\n items,\n onSelect,\n open,\n onClose,\n focusOn,\n anchor,\n placement,\n offset,\n inside,\n returnFocus,\n className,\n style,\n}: MenuPanelProps) {\n const apple = useApple();\n const panel = useRef<HTMLDivElement>(null);\n const typeTo = useTypeahead();\n\n usePopover(panel, open, (el) => {\n const enabled = [...el.querySelectorAll<HTMLElement>(ITEM)].filter(\n (i) => i.getAttribute(\"aria-disabled\") !== \"true\",\n );\n (focusOn === \"last\" ? enabled[enabled.length - 1] : enabled[0])?.focus({ preventScroll: true });\n });\n useAnchoredPosition(anchor, panel, open, placement, offset, \"start\");\n useRovingFocus(panel, { orientation: \"vertical\", selector: ITEM });\n useDismiss({ open, onClose, inside: [...inside, panel], returnFocus });\n\n const choose = (item: MenuItem) => {\n if (item.disabled) return;\n onSelect(item.value);\n if (!(item.keepOpen ?? !!item.kind)) onClose();\n };\n\n const onPanelKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Tab leaves the menu like leaving the button: close and let focus move on.\n if (event.key === \"Tab\") {\n onClose();\n return;\n }\n if (!isTypeaheadKey(event)) return;\n const list = [...event.currentTarget.querySelectorAll<HTMLElement>(ITEM)].filter(\n (i) => i.getAttribute(\"aria-disabled\") !== \"true\",\n );\n const from = list.indexOf(event.target as HTMLElement);\n list[\n typeTo(\n event.key,\n list.map((i) => i.dataset.label ?? \"\"),\n from,\n )\n ]?.focus();\n };\n\n const row = (item: MenuItem) => (\n <ButtonBase\n key={item.value}\n role={item.kind ? (item.kind === \"checkbox\" ? \"menuitemcheckbox\" : \"menuitemradio\") : \"menuitem\"}\n aria-checked={item.kind ? !!item.checked : undefined}\n aria-disabled={item.disabled || undefined}\n aria-keyshortcuts={\n item.shortcut &&\n ariaKeyShortcuts(\n typeof item.shortcut === \"string\" ? shortcutKeys(item.shortcut, apple) : item.shortcut,\n )\n }\n tabIndex={-1}\n className=\"cy-menu-item\"\n data-tone={item.tone}\n data-label={item.label}\n onClick={() => choose(item)}\n >\n {item.kind && (\n <span className=\"cy-menu-check\" aria-hidden=\"true\">\n {item.checked && <Icon icon={check} />}\n </span>\n )}\n <OptionIcon option={item} plain={item.disabled} className=\"cy-menu-icon\" />\n <span className=\"cy-menu-label\">{item.label}</span>\n {item.shortcut && (\n <span className=\"cy-menu-shortcut\" aria-hidden=\"true\">\n <Kbd keys={item.shortcut} size=\"sm\" />\n </span>\n )}\n </ButtonBase>\n );\n\n return (\n <div\n ref={panel}\n id={`${id}-menu`}\n role=\"menu\"\n aria-label={label}\n aria-orientation=\"vertical\"\n {...{ popover: \"manual\" }}\n className={className ? `cy-menu ${className}` : \"cy-menu\"}\n style={style}\n onKeyDown={onPanelKeyDown}\n >\n {items.map((entry, i) =>\n isSection(entry) ? (\n <Fragment key={`section-${entry.label}`}>\n {i > 0 && <hr className=\"cy-menu-separator\" />}\n {/* biome-ignore lint/a11y/useSemanticElements: APG menus group items with role=\"group\"; a fieldset is for forms */}\n <div role=\"group\" aria-label={entry.label} className=\"cy-menu-group\">\n <span className=\"cy-menu-group-label\" aria-hidden=\"true\">\n {entry.label}\n </span>\n {entry.items.map(row)}\n </div>\n </Fragment>\n ) : (\n row(entry)\n ),\n )}\n </div>\n );\n}\n\n/** APG menu button: commands in a top-layer list with arrow keys, type-ahead, sections and checkable items. */\nexport function Menu({ trigger, label, items, onSelect, placement = \"bottom\", className, style }: MenuProps) {\n const id = useId();\n const [open, setOpen] = useState(false);\n const [focusOn, setFocusOn] = useState<\"first\" | \"last\">(\"first\");\n const triggerRef = useRef<HTMLButtonElement>(null);\n const show = useCallback((at: \"first\" | \"last\") => {\n setFocusOn(at);\n setOpen(true);\n }, []);\n const close = useCallback(() => setOpen(false), []);\n\n return (\n <>\n {trigger({\n ref: triggerRef,\n onClick: () => (open ? setOpen(false) : show(\"first\")),\n onKeyDown: (event) => {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n show(event.key === \"ArrowUp\" ? \"last\" : \"first\");\n }\n },\n \"aria-expanded\": open,\n \"aria-controls\": `${id}-menu`,\n \"aria-haspopup\": \"menu\",\n })}\n <MenuPanel\n id={id}\n label={label}\n items={items}\n onSelect={onSelect}\n open={open}\n onClose={close}\n focusOn={focusOn}\n anchor={triggerRef}\n placement={placement}\n offset={4}\n inside={[triggerRef]}\n returnFocus={triggerRef}\n className={className}\n style={style}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAoGA,IAAMuB,IAAO,wEACPC,IAAA,CAAaC,MAA2C,WAAWA;AAuBzE,SAAgBC,EAAU,EACxB,IAAAC,GACA,OAAAC,GACA,OAAAC,GAC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AAK,GAAG,CAAC,CAAC;AAElD,SACE,gBAAAlC,EAAAtB,GAAA,EAAA,UAAA,CACGuD,EAAQ;AAAA,IACP,KAAKG;AAAA,IACL,SAAA,MAAgB3B,IAAOyB,EAAQ,EAAK,IAAIG,EAAK,OAAO;AAAA,IACpD,WAAA,CAAYT,MAAU;AACpB,OAAIA,EAAM,QAAQ,eAAeA,EAAM,QAAQ,eAC7CA,EAAM,eAAe,GACrBS,EAAKT,EAAM,QAAQ,YAAY,SAAS,OAAO;AAAA,IAEnD;AAAA,IACA,iBAAiBnB;AAAA,IACjB,iBAAiB,GAAGJ,CAAA;AAAA,IACpB,iBAAiB;AAAA,EACnB,CAAC,GACD,gBAAAN,EAACK,GAAD;AAAA,IACM,IAAAC;AAAA,IACG,OAAAC;AAAA,IACA,OAAAC;AAAA,IACG,UAAAC;AAAA,IACJ,MAAAC;AAAA,IACN,SAAS8B;AAAA,IACA,SAAA5B;AAAA,IACT,QAAQyB;AAAA,IACG,WAAAvB;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ,CAACuB,CAAU;AAAA,IACnB,aAAaA;AAAA,IACF,WAAAnB;AAAA,IACJ,OAAAC;AAAA,EACR,CAAA,CACD,EAAA,CAAA;AAEN"}
@@ -21,18 +21,23 @@ export interface NoticeProps {
21
21
  * whose content changes are announced politely.
22
22
  */
23
23
  tone?: Tone;
24
+ /** Short heading above the message. */
24
25
  title?: ReactNode;
25
26
  /** One or two Buttons; they move under the text in narrow containers. */
26
27
  action?: ReactNode;
27
28
  /** Shows a close button. The Notice hides itself unless you control it with `onDismiss` and unmount it. */
28
29
  dismissible?: boolean;
30
+ /** Called when the close button is pressed. With it, hiding the Notice is up to you. */
29
31
  onDismiss?: () => void;
30
32
  /** Replace the tone's icon, or `null` for none. */
31
33
  icon?: IconData | null;
34
+ /** Replace the built-in English text: the dismiss button's name. */
32
35
  labels?: Partial<NoticeLabels>;
36
+ /** Added to the root element, for layout. */
33
37
  className?: string;
34
38
  /** Layout only. Restyle through --cy-notice-* tokens. */
35
39
  style?: CSSProperties;
40
+ /** The message. */
36
41
  children?: ReactNode;
37
42
  }
38
43
  /** An inline message about part of the page: a status, a warning or an error that stays until it is resolved. */
@@ -1 +1 @@
1
- {"version":3,"file":"Notice.js","names":["closeIcon","Icon","IconButton","close","TONE_ICONS","useState","jsx","jsxs","Notice","tone","title","action","dismissible","onDismiss","icon","labels","className","style","children","hidden","setHidden","glyph"],"sources":["../../../src/components/Notice/Notice.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useState } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { TONE_ICONS } from \"../../foundations/tone-icons.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface NoticeTokens {\n radius: string;\n padding: string;\n softMix: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n notice: NoticeTokens;\n }\n}\n\nexport interface NoticeLabels {\n /** Accessible name of the dismiss button. */\n dismiss: string;\n}\n\nexport interface NoticeProps {\n /**\n * Colour and icon. `danger` is `role=\"alert\"` (announced even when it mounts filled); the others are `role=\"status\"`,\n * whose content changes are announced politely.\n */\n tone?: Tone;\n title?: ReactNode;\n /** One or two Buttons; they move under the text in narrow containers. */\n action?: ReactNode;\n /** Shows a close button. The Notice hides itself unless you control it with `onDismiss` and unmount it. */\n dismissible?: boolean;\n onDismiss?: () => void;\n /** Replace the tone's icon, or `null` for none. */\n icon?: IconData | null;\n labels?: Partial<NoticeLabels>;\n className?: string;\n /** Layout only. Restyle through --cy-notice-* tokens. */\n style?: CSSProperties;\n children?: ReactNode;\n}\n\n/** An inline message about part of the page: a status, a warning or an error that stays until it is resolved. */\nexport function Notice({\n tone = \"info\",\n title,\n action,\n dismissible = false,\n onDismiss,\n icon,\n labels,\n className,\n style,\n children,\n}: NoticeProps) {\n const [hidden, setHidden] = useState(false);\n if (hidden) return null;\n const glyph = icon === undefined ? TONE_ICONS[tone] : icon;\n return (\n <div\n role={tone === \"danger\" ? \"alert\" : \"status\"}\n className={className ? `cy-notice ${className}` : \"cy-notice\"}\n data-tone={tone}\n style={style}\n >\n <div className=\"cy-notice-main cy-reset\">\n {glyph && <Icon icon={glyph} className=\"cy-notice-icon\" />}\n <div className=\"cy-notice-text cy-reset\">\n {title && <span className=\"cy-notice-title cy-reset\">{title}</span>}\n {children && <div className=\"cy-notice-body cy-reset\">{children}</div>}\n </div>\n {action && <div className=\"cy-notice-action cy-reset\">{action}</div>}\n {dismissible && (\n <IconButton\n icon={closeIcon}\n label={labels?.dismiss ?? \"Dismiss\"}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => {\n onDismiss?.();\n if (!onDismiss) setHidden(true);\n }}\n />\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;AA+CA,SAAgBQ,EAAO,EACrB,MAAAC,IAAO,QACP,OAAAC,GACA,QAAAC,GACA,aAAAC,IAAc,IACd,WAAAC,GACA,MAAAC,GACA,QAAAC,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACc;AACd,QAAM,CAACC,GAAQC,CAAA,IAAaf,EAAS,EAAK;AAC1C,MAAIc,EAAQ,QAAO;AACnB,QAAME,IAAQP,MAAS,SAAYV,EAAWK,CAAA,IAAQK;AACtD,SACE,gBAAAR,EAAC,OAAD;AAAA,IACE,MAAMG,MAAS,WAAW,UAAU;AAAA,IACpC,WAAWO,IAAY,aAAaA,CAAA,KAAc;AAAA,IAClD,aAAWP;AAAA,IACJ,OAAAQ;AAAA,IAEP,UAAA,gBAAAV,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAf,UAAA;AAAA,QACGc,KAAS,gBAAAf,EAACL,GAAD;AAAA,UAAM,MAAMoB;AAAA,UAAO,WAAU;AAAA,QAAkB,CAAA;AAAA,QACzD,gBAAAd,EAAC,OAAD;AAAA,UAAK,WAAU;AAAA,UAAf,UAAA,CACGG,KAAS,gBAAAJ,EAAC,QAAD;AAAA,YAAM,WAAU;AAAA,YAA4B,UAAAI;AAAA,UAAY,CAAA,GACjEQ,KAAY,gBAAAZ,EAAC,OAAD;AAAA,YAAK,WAAU;AAAA,YAA2B,UAAAY;AAAA,UAAc,CAAA,CAClE;AAAA,Q;A,QACJP,KAAU,gBAAAL,EAAC,OAAD;AAAA,UAAK,WAAU;AAAA,UAA6B,UAAAK;AAAA,QAAY,CAAA;AAAA,QAClEC,KACC,gBAAAN,EAACJ,GAAD;AAAA,UACE,MAAMF;AAAAA,UACN,OAAOe,GAAQ,WAAW;AAAA,UAC1B,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,SAAA,MAAe;AACb,YAAAF,IAAY,GACPA,KAAWO,EAAU,EAAI;AAAA,UAChC;AAAA,QACD,CAAA;AAAA,MAEA;AAAA,I;A,EACF,CAAA;AAET"}
1
+ {"version":3,"file":"Notice.js","names":["closeIcon","Icon","IconButton","close","TONE_ICONS","useState","jsx","jsxs","Notice","tone","title","action","dismissible","onDismiss","icon","labels","className","style","children","hidden","setHidden","glyph"],"sources":["../../../src/components/Notice/Notice.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useState } from \"react\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { TONE_ICONS } from \"../../foundations/tone-icons.js\";\nimport { close as closeIcon } from \"../../icons/close.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface NoticeTokens {\n radius: string;\n padding: string;\n softMix: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n notice: NoticeTokens;\n }\n}\n\nexport interface NoticeLabels {\n /** Accessible name of the dismiss button. */\n dismiss: string;\n}\n\nexport interface NoticeProps {\n /**\n * Colour and icon. `danger` is `role=\"alert\"` (announced even when it mounts filled); the others are `role=\"status\"`,\n * whose content changes are announced politely.\n */\n tone?: Tone;\n /** Short heading above the message. */\n title?: ReactNode;\n /** One or two Buttons; they move under the text in narrow containers. */\n action?: ReactNode;\n /** Shows a close button. The Notice hides itself unless you control it with `onDismiss` and unmount it. */\n dismissible?: boolean;\n /** Called when the close button is pressed. With it, hiding the Notice is up to you. */\n onDismiss?: () => void;\n /** Replace the tone's icon, or `null` for none. */\n icon?: IconData | null;\n /** Replace the built-in English text: the dismiss button's name. */\n labels?: Partial<NoticeLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-notice-* tokens. */\n style?: CSSProperties;\n /** The message. */\n children?: ReactNode;\n}\n\n/** An inline message about part of the page: a status, a warning or an error that stays until it is resolved. */\nexport function Notice({\n tone = \"info\",\n title,\n action,\n dismissible = false,\n onDismiss,\n icon,\n labels,\n className,\n style,\n children,\n}: NoticeProps) {\n const [hidden, setHidden] = useState(false);\n if (hidden) return null;\n const glyph = icon === undefined ? TONE_ICONS[tone] : icon;\n return (\n <div\n role={tone === \"danger\" ? \"alert\" : \"status\"}\n className={className ? `cy-notice ${className}` : \"cy-notice\"}\n data-tone={tone}\n style={style}\n >\n <div className=\"cy-notice-main cy-reset\">\n {glyph && <Icon icon={glyph} className=\"cy-notice-icon\" />}\n <div className=\"cy-notice-text cy-reset\">\n {title && <span className=\"cy-notice-title cy-reset\">{title}</span>}\n {children && <div className=\"cy-notice-body cy-reset\">{children}</div>}\n </div>\n {action && <div className=\"cy-notice-action cy-reset\">{action}</div>}\n {dismissible && (\n <IconButton\n icon={closeIcon}\n label={labels?.dismiss ?? \"Dismiss\"}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => {\n onDismiss?.();\n if (!onDismiss) setHidden(true);\n }}\n />\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;AAoDA,SAAgBQ,EAAO,EACrB,MAAAC,IAAO,QACP,OAAAC,GACA,QAAAC,GACA,aAAAC,IAAc,IACd,WAAAC,GACA,MAAAC,GACA,QAAAC,GACA,WAAAC,GACA,OAAAC,GACA,UAAAC,EAAA,GACc;AACd,QAAM,CAACC,GAAQC,CAAA,IAAaf,EAAS,EAAK;AAC1C,MAAIc,EAAQ,QAAO;AACnB,QAAME,IAAQP,MAAS,SAAYV,EAAWK,CAAA,IAAQK;AACtD,SACE,gBAAAR,EAAC,OAAD;AAAA,IACE,MAAMG,MAAS,WAAW,UAAU;AAAA,IACpC,WAAWO,IAAY,aAAaA,CAAA,KAAc;AAAA,IAClD,aAAWP;AAAA,IACJ,OAAAQ;AAAA,IAEP,UAAA,gBAAAV,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAf,UAAA;AAAA,QACGc,KAAS,gBAAAf,EAACL,GAAD;AAAA,UAAM,MAAMoB;AAAA,UAAO,WAAU;AAAA,QAAkB,CAAA;AAAA,QACzD,gBAAAd,EAAC,OAAD;AAAA,UAAK,WAAU;AAAA,UAAf,UAAA,CACGG,KAAS,gBAAAJ,EAAC,QAAD;AAAA,YAAM,WAAU;AAAA,YAA4B,UAAAI;AAAA,UAAY,CAAA,GACjEQ,KAAY,gBAAAZ,EAAC,OAAD;AAAA,YAAK,WAAU;AAAA,YAA2B,UAAAY;AAAA,UAAc,CAAA,CAClE;AAAA,Q;A,QACJP,KAAU,gBAAAL,EAAC,OAAD;AAAA,UAAK,WAAU;AAAA,UAA6B,UAAAK;AAAA,QAAY,CAAA;AAAA,QAClEC,KACC,gBAAAN,EAACJ,GAAD;AAAA,UACE,MAAMF;AAAAA,UACN,OAAOe,GAAQ,WAAW;AAAA,UAC1B,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,SAAA,MAAe;AACb,YAAAF,IAAY,GACPA,KAAWO,EAAU,EAAI;AAAA,UAChC;AAAA,QACD,CAAA;AAAA,MAEA;AAAA,I;A,EACF,CAAA;AAET"}
@@ -6,16 +6,23 @@ export interface NumberFieldLabels {
6
6
  increment: string;
7
7
  }
8
8
  export interface NumberFieldProps {
9
+ /** Visible label; it names the field. */
9
10
  label: ReactNode;
11
+ /** Visually hide the label (it still names the field). Prefer visible labels. */
10
12
  labelHidden?: boolean | undefined;
13
+ /** Help text shown below the field. */
11
14
  description?: ReactNode;
15
+ /** Error message shown below the field; it marks the field invalid. */
12
16
  error?: ReactNode;
13
17
  /** `null` is empty. */
14
18
  value?: number | null | undefined;
19
+ /** Starting value when uncontrolled; `null` is empty. */
15
20
  defaultValue?: number | null;
16
21
  /** Called with the new value when it is committed: a step, Enter, or leaving the field. */
17
22
  onChange?: ((value: number | null) => void) | undefined;
23
+ /** Smallest value. Typed and stepped values are kept at or above it, and Home jumps to it. */
18
24
  min?: number | undefined;
25
+ /** Largest value. Typed and stepped values are kept at or below it, and End jumps to it. */
19
26
  max?: number | undefined;
20
27
  /** Arrow keys and steppers move by this; values they produce snap to it. Default 1. */
21
28
  step?: number;
@@ -27,20 +34,30 @@ export interface NumberFieldProps {
27
34
  formatOptions?: Intl.NumberFormatOptions | undefined;
28
35
  /** Hide the − and + buttons (the keyboard still steps). */
29
36
  hideSteppers?: boolean;
37
+ /** Name the plain number is submitted under in a form. */
30
38
  name?: string | undefined;
39
+ /** Id of the form it belongs to, when it is not inside that form. */
31
40
  form?: string | undefined;
41
+ /** Marks the field as required for form validation. */
32
42
  required?: boolean | undefined;
43
+ /** Turns off the field and its stepper buttons. */
33
44
  disabled?: boolean | undefined;
45
+ /** The value can be read but not changed. */
34
46
  readOnly?: boolean | undefined;
47
+ /** Hint shown while the field is empty. */
35
48
  placeholder?: string | undefined;
49
+ /** Size of the field. Default "md". */
36
50
  size?: Size;
51
+ /** `outline` or `soft` (tinted, borderless until focus). Default "outline". */
37
52
  variant?: "outline" | "soft";
53
+ /** Replace the built-in English text: the stepper button names. */
38
54
  labels?: Partial<NumberFieldLabels>;
39
55
  /**
40
56
  * Drag the label sideways to change the value, as design tools do: one `step` every few pixels, Shift for ten. Escape
41
57
  * mid-drag puts it back. The keys and the steppers still work as before.
42
58
  */
43
59
  scrub?: boolean;
60
+ /** Added to the root element, for layout. */
44
61
  className?: string;
45
62
  /** Layout only. */
46
63
  style?: CSSProperties;
@@ -4,10 +4,10 @@ import { useClientLayoutEffect as ot } from "../../foundations/client-layout-eff
4
4
  import { clamp as ut } from "../../foundations/math.js";
5
5
  import { IconButton as _ } from "../IconButton/IconButton.js";
6
6
  import { minus as ct } from "../../icons/minus.js";
7
- import { useDrag as st } from "../../foundations/drag.js";
8
- import { HiddenValue as lt } from "../../foundations/HiddenValue/HiddenValue.js";
9
- import { TextField as it } from "../TextField/TextField.js";
10
- import { plus as at } from "../../icons/plus.js";
7
+ import { plus as st } from "../../icons/plus.js";
8
+ import { TextField as lt } from "../TextField/TextField.js";
9
+ import { useDrag as it } from "../../foundations/drag.js";
10
+ import { HiddenValue as at } from "../../foundations/HiddenValue/HiddenValue.js";
11
11
  import { useMemo as mt, useRef as y, useState as ft } from "react";
12
12
  import { Fragment as dt, jsx as E, jsxs as $ } from "react/jsx-runtime";
13
13
  var pt = {
@@ -55,7 +55,7 @@ function xt({ label: d, labelHidden: D, description: w, error: N, value: p, defa
55
55
  v.current && v.current !== t && delete v.current.dataset.scrub, t && (t.dataset.scrub = ""), v.current = t;
56
56
  });
57
57
  const S = y(null);
58
- st(v, {
58
+ it(v, {
59
59
  distance: 3,
60
60
  touchAction: "css",
61
61
  onStart: () => {
@@ -70,7 +70,7 @@ function xt({ label: d, labelHidden: D, description: w, error: N, value: p, defa
70
70
  }
71
71
  });
72
72
  const O = r !== null && e !== void 0 && r <= e, tt = r !== null && n !== void 0 && r >= n, et = Number.isInteger(o) && (e ?? 0) >= 0 && g?.style !== "percent";
73
- return /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ E(it, {
73
+ return /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ E(lt, {
74
74
  ref: b,
75
75
  label: d,
76
76
  labelHidden: D,
@@ -111,7 +111,7 @@ function xt({ label: d, labelHidden: D, description: w, error: N, value: p, defa
111
111
  f(-o), b.current?.focus();
112
112
  }
113
113
  }), /* @__PURE__ */ E(_, {
114
- icon: at,
114
+ icon: st,
115
115
  label: B.increment,
116
116
  variant: "ghost",
117
117
  size: "sm",
@@ -122,7 +122,7 @@ function xt({ label: d, labelHidden: D, description: w, error: N, value: p, defa
122
122
  }
123
123
  })]
124
124
  })
125
- }), /* @__PURE__ */ E(lt, {
125
+ }), /* @__PURE__ */ E(at, {
126
126
  name: K,
127
127
  form: A,
128
128
  value: r === null ? "" : String(r),
@@ -1 +1 @@
1
- {"version":3,"file":"NumberField.js","names":["_Fragment","useControllableState","useClientLayoutEffect","clamp","IconButton","minus","useDrag","HiddenValue","TextField","plus","useMemo","useRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","places","n","parseNumber","text","locale","options","parts","group","p","decimal","cleaned","NumberField","label","labelHidden","description","error","value","defaultValue","onChange","min","max","step","largeStep","formatOptions","hideSteppers","name","form","required","disabled","readOnly","placeholder","size","variant","labels","scrub","className","style","current","setCurrent","resetCurrent","draft","setDraft","input","format","shown","limit","commit","next","stepBy","delta","base","from","start","snapped","digits","commitDraft","parsed","onKeyDown","event","big","moves","move","handle","el","scrubFrom","steps","_","cancelled","atMin","atMax","integers"],"sources":["../../../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, useMemo, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { HiddenValue } from \"../../foundations/HiddenValue/HiddenValue.js\";\nimport { clamp } from \"../../foundations/math.js\";\nimport { minus } from \"../../icons/minus.js\";\nimport { plus } from \"../../icons/plus.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface NumberFieldLabels {\n /** Stepper button names. Defaults: \"Decrease\", \"Increase\". */\n decrement: string;\n increment: string;\n}\n\nexport interface NumberFieldProps {\n label: ReactNode;\n labelHidden?: boolean | undefined;\n description?: ReactNode;\n error?: ReactNode;\n /** `null` is empty. */\n value?: number | null | undefined;\n defaultValue?: number | null;\n /** Called with the new value when it is committed: a step, Enter, or leaving the field. */\n onChange?: ((value: number | null) => void) | undefined;\n min?: number | undefined;\n max?: number | undefined;\n /** Arrow keys and steppers move by this; values they produce snap to it. Default 1. */\n step?: number;\n /** Page Up and Page Down move by this. Default: 10 steps. */\n largeStep?: number;\n /** Locale for reading and writing numbers. Default: the browser's. */\n locale?: string | undefined;\n /** How the value is written: currency, percent, units, digits… (`Intl.NumberFormat` options). */\n formatOptions?: Intl.NumberFormatOptions | undefined;\n /** Hide the − and + buttons (the keyboard still steps). */\n hideSteppers?: boolean;\n name?: string | undefined;\n form?: string | undefined;\n required?: boolean | undefined;\n disabled?: boolean | undefined;\n readOnly?: boolean | undefined;\n placeholder?: string | undefined;\n size?: Size;\n variant?: \"outline\" | \"soft\";\n labels?: Partial<NumberFieldLabels>;\n /**\n * Drag the label sideways to change the value, as design tools do: one `step` every few pixels, Shift for ten. Escape\n * mid-drag puts it back. The keys and the steppers still work as before.\n */\n scrub?: boolean;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: NumberFieldLabels = { decrement: \"Decrease\", increment: \"Increase\" };\n\n/** Decimal places of `n`, so stepping by 0.1 gives 0.3 and not 0.30000000000000004. */\nconst places = (n: number) => (String(n).split(\".\")[1] ?? \"\").length;\n\n/** Reads what a person typed in `locale`: group separators, the local decimal mark, a typographic minus, a % or a currency. */\nexport function parseNumber(\n text: string,\n locale?: string,\n options?: Intl.NumberFormatOptions,\n): number | null {\n const parts = new Intl.NumberFormat(locale).formatToParts(-12345.6);\n const group = parts.find((p) => p.type === \"group\")?.value ?? \",\";\n const decimal = parts.find((p) => p.type === \"decimal\")?.value ?? \".\";\n const cleaned = text\n .replace(/[−‒–]/g, \"-\")\n .split(group)\n .join(group.trim() ? \"\" : group)\n .replace(/\\s/g, \"\")\n .split(decimal)\n .join(\".\")\n .replace(/[^\\d.-]/g, \"\");\n if (!/^-?\\d*\\.?\\d+$|^-?\\d+\\.?$/.test(cleaned)) return null;\n const n = Number(cleaned);\n if (!Number.isFinite(n)) return null;\n return options?.style === \"percent\" ? n / 100 : n;\n}\n\n/**\n * A number input: type it in your own format, or step it with the arrow keys, Page Up/Down, Home/End or the − and +\n * buttons. APG spinbutton; locale-aware; takes part in forms with the plain number.\n */\nexport function NumberField({\n label,\n labelHidden,\n description,\n error,\n value,\n defaultValue = null,\n onChange,\n min,\n max,\n step = 1,\n largeStep,\n locale,\n formatOptions,\n hideSteppers = false,\n name,\n form,\n required,\n disabled,\n readOnly,\n placeholder,\n size = \"md\",\n variant = \"outline\",\n labels,\n scrub = false,\n className,\n style,\n}: NumberFieldProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [current, setCurrent, resetCurrent] = useControllableState<number | null>(\n value,\n defaultValue,\n onChange,\n );\n const [draft, setDraft] = useState<string | null>(null);\n const input = useRef<HTMLInputElement>(null);\n const format = useMemo(\n () => new Intl.NumberFormat(locale, { maximumFractionDigits: 20, ...formatOptions }),\n [locale, formatOptions],\n );\n const shown = (n: number | null) => (n === null ? \"\" : format.format(n));\n\n const limit = (n: number) => clamp(n, min ?? Number.NEGATIVE_INFINITY, max ?? Number.POSITIVE_INFINITY);\n const commit = (next: number | null) => {\n setDraft(null);\n if (next !== current) setCurrent(next);\n };\n const stepBy = (delta: number) => {\n if (disabled || readOnly) return;\n const base = min ?? 0;\n const from = draft !== null ? (parseNumber(draft, locale, formatOptions) ?? current) : current;\n const start = from ?? (delta > 0 ? (min ?? 0) : (max ?? 0));\n // Snap onto the step grid (counted from min), then round away floating-point noise.\n const snapped = from === null ? start : Math.round((start - base + delta) / step) * step + base;\n const digits = Math.max(places(step), places(base));\n commit(limit(Number(snapped.toFixed(digits))));\n };\n const commitDraft = () => {\n if (draft === null) return;\n if (draft.trim() === \"\") return commit(null);\n const parsed = parseNumber(draft, locale, formatOptions);\n // Unreadable text goes back to the last good value.\n commit(parsed === null ? current : limit(parsed));\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n const big = largeStep ?? step * 10;\n const moves: Record<string, () => void> = {\n ArrowUp: () => stepBy(step),\n ArrowDown: () => stepBy(-step),\n PageUp: () => stepBy(big),\n PageDown: () => stepBy(-big),\n Enter: commitDraft,\n };\n if (min !== undefined) moves.Home = () => !disabled && !readOnly && commit(min);\n if (max !== undefined) moves.End = () => !disabled && !readOnly && commit(max);\n const move = moves[event.key];\n if (!move) return;\n if (event.key !== \"Enter\") event.preventDefault();\n move();\n };\n\n // Scrubbing: the field's own <label> is the handle.\n const handle = useRef<HTMLElement | null>(null);\n useClientLayoutEffect(() => {\n const el =\n scrub && !disabled && !readOnly\n ? ((input.current?.labels?.[0] as HTMLElement | undefined) ?? null)\n : null;\n if (handle.current && handle.current !== el) delete handle.current.dataset.scrub;\n if (el) el.dataset.scrub = \"\";\n handle.current = el;\n });\n const scrubFrom = useRef<number | null>(null);\n useDrag(handle, {\n distance: 3,\n touchAction: \"css\",\n onStart: () => {\n scrubFrom.current = current;\n },\n onMove: ({ delta, event }) => {\n const steps = Math.round(delta.x / 4) * (event.shiftKey ? 10 : 1);\n const from = scrubFrom.current ?? min ?? 0;\n const digits = Math.max(places(step), places(min ?? 0));\n commit(limit(Number((from + steps * step).toFixed(digits))));\n },\n onEnd: (_, cancelled) => {\n if (cancelled) commit(scrubFrom.current);\n input.current?.focus({ preventScroll: true });\n },\n });\n\n const atMin = current !== null && min !== undefined && current <= min;\n const atMax = current !== null && max !== undefined && current >= max;\n const integers = Number.isInteger(step) && (min ?? 0) >= 0 && formatOptions?.style !== \"percent\";\n\n return (\n <>\n <TextField\n ref={input}\n label={label}\n labelHidden={labelHidden}\n description={description}\n error={error}\n size={size}\n variant={variant}\n className={className ? `cy-number-field ${className}` : \"cy-number-field\"}\n {...(style ? { style } : {})}\n role=\"spinbutton\"\n inputMode={integers ? \"numeric\" : \"decimal\"}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n aria-valuenow={current ?? undefined}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuetext={current === null ? undefined : shown(current)}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n placeholder={placeholder}\n form={form}\n value={draft ?? shown(current)}\n onChange={setDraft}\n onKeyDown={onKeyDown}\n onBlur={commitDraft}\n addonEnd={\n !hideSteppers && (\n <span className=\"cy-number-field-steppers\">\n <IconButton\n icon={minus}\n label={text.decrement}\n variant=\"ghost\"\n size=\"sm\"\n tabIndex={-1}\n disabled={disabled || readOnly || atMin}\n onClick={() => {\n stepBy(-step);\n input.current?.focus();\n }}\n />\n <IconButton\n icon={plus}\n label={text.increment}\n variant=\"ghost\"\n size=\"sm\"\n tabIndex={-1}\n disabled={disabled || readOnly || atMax}\n onClick={() => {\n stepBy(step);\n input.current?.focus();\n }}\n />\n </span>\n )\n }\n />\n <HiddenValue\n name={name}\n form={form}\n value={current === null ? \"\" : String(current)}\n disabled={disabled}\n onReset={() => {\n setDraft(null);\n resetCurrent(defaultValue);\n }}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA2DA,IAAMgB,KAAoC;AAAA,EAAE,WAAW;AAAA,EAAY,WAAW;AAAW,GAGnFC,IAAA,CAAUC,OAAe,OAAOA,CAAC,EAAE,MAAM,GAAG,EAAE,CAAA,KAAM,IAAI;AAG9D,SAAgBC,EACdC,GACAC,GACAC,GACe;AACf,QAAMC,IAAQ,IAAI,KAAK,aAAaF,CAAM,EAAE,cAAc,QAAQ,GAC5DG,IAAQD,EAAM,KAAA,CAAME,MAAMA,EAAE,SAAS,OAAO,GAAG,SAAS,KACxDC,IAAUH,EAAM,KAAA,CAAME,MAAMA,EAAE,SAAS,SAAS,GAAG,SAAS,KAC5DE,IAAUP,EACb,QAAQ,UAAU,GAAG,EACrB,MAAMI,CAAK,EACX,KAAKA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AA,QACV,UAAUyB,KAAYC,KAAYwC;AAAA,QAClC,SAAA,MAAe;AACb,UAAArB,EAAO3B,CAAI,GACXqB,EAAM,SAAS,MAAM;AAAA,QACvB;AAAA,MACD,CAAA,CACG;AAAA,I;A,EAGX,CAAA,GACD,gBAAA7C,EAACP,IAAD;AAAA,IACQ,MAAAmC;AAAA,IACA,MAAAC;AAAA,IACN,OAAOW,MAAY,OAAO,KAAK,OAAOA,CAAO;AAAA,IACnC,UAAAT;AAAA,IACV,SAAA,MAAe;AACb,MAAAa,EAAS,IAAI,GACbF,EAAatB,CAAY;AAAA,IAC3B;AAAA,EACD,CAAA,CACD,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"NumberField.js","names":["_Fragment","useControllableState","useClientLayoutEffect","clamp","IconButton","minus","plus","TextField","useDrag","HiddenValue","useMemo","useRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","places","n","parseNumber","text","locale","options","parts","group","p","decimal","cleaned","NumberField","label","labelHidden","description","error","value","defaultValue","onChange","min","max","step","largeStep","formatOptions","hideSteppers","name","form","required","disabled","readOnly","placeholder","size","variant","labels","scrub","className","style","current","setCurrent","resetCurrent","draft","setDraft","input","format","shown","limit","commit","next","stepBy","delta","base","from","start","snapped","digits","commitDraft","parsed","onKeyDown","event","big","moves","move","handle","el","scrubFrom","steps","_","cancelled","atMin","atMax","integers"],"sources":["../../../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, useMemo, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { useDrag } from \"../../foundations/drag.js\";\nimport { HiddenValue } from \"../../foundations/HiddenValue/HiddenValue.js\";\nimport { clamp } from \"../../foundations/math.js\";\nimport { minus } from \"../../icons/minus.js\";\nimport { plus } from \"../../icons/plus.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { TextField } from \"../TextField/TextField.js\";\n\nexport interface NumberFieldLabels {\n /** Stepper button names. Defaults: \"Decrease\", \"Increase\". */\n decrement: string;\n increment: string;\n}\n\nexport interface NumberFieldProps {\n /** Visible label; it names the field. */\n label: ReactNode;\n /** Visually hide the label (it still names the field). Prefer visible labels. */\n labelHidden?: boolean | undefined;\n /** Help text shown below the field. */\n description?: ReactNode;\n /** Error message shown below the field; it marks the field invalid. */\n error?: ReactNode;\n /** `null` is empty. */\n value?: number | null | undefined;\n /** Starting value when uncontrolled; `null` is empty. */\n defaultValue?: number | null;\n /** Called with the new value when it is committed: a step, Enter, or leaving the field. */\n onChange?: ((value: number | null) => void) | undefined;\n /** Smallest value. Typed and stepped values are kept at or above it, and Home jumps to it. */\n min?: number | undefined;\n /** Largest value. Typed and stepped values are kept at or below it, and End jumps to it. */\n max?: number | undefined;\n /** Arrow keys and steppers move by this; values they produce snap to it. Default 1. */\n step?: number;\n /** Page Up and Page Down move by this. Default: 10 steps. */\n largeStep?: number;\n /** Locale for reading and writing numbers. Default: the browser's. */\n locale?: string | undefined;\n /** How the value is written: currency, percent, units, digits… (`Intl.NumberFormat` options). */\n formatOptions?: Intl.NumberFormatOptions | undefined;\n /** Hide the − and + buttons (the keyboard still steps). */\n hideSteppers?: boolean;\n /** Name the plain number is submitted under in a form. */\n name?: string | undefined;\n /** Id of the form it belongs to, when it is not inside that form. */\n form?: string | undefined;\n /** Marks the field as required for form validation. */\n required?: boolean | undefined;\n /** Turns off the field and its stepper buttons. */\n disabled?: boolean | undefined;\n /** The value can be read but not changed. */\n readOnly?: boolean | undefined;\n /** Hint shown while the field is empty. */\n placeholder?: string | undefined;\n /** Size of the field. Default \"md\". */\n size?: Size;\n /** `outline` or `soft` (tinted, borderless until focus). Default \"outline\". */\n variant?: \"outline\" | \"soft\";\n /** Replace the built-in English text: the stepper button names. */\n labels?: Partial<NumberFieldLabels>;\n /**\n * Drag the label sideways to change the value, as design tools do: one `step` every few pixels, Shift for ten. Escape\n * mid-drag puts it back. The keys and the steppers still work as before.\n */\n scrub?: boolean;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: NumberFieldLabels = { decrement: \"Decrease\", increment: \"Increase\" };\n\n/** Decimal places of `n`, so stepping by 0.1 gives 0.3 and not 0.30000000000000004. */\nconst places = (n: number) => (String(n).split(\".\")[1] ?? \"\").length;\n\n/** Reads what a person typed in `locale`: group separators, the local decimal mark, a typographic minus, a % or a currency. */\nexport function parseNumber(\n text: string,\n locale?: string,\n options?: Intl.NumberFormatOptions,\n): number | null {\n const parts = new Intl.NumberFormat(locale).formatToParts(-12345.6);\n const group = parts.find((p) => p.type === \"group\")?.value ?? \",\";\n const decimal = parts.find((p) => p.type === \"decimal\")?.value ?? \".\";\n const cleaned = text\n .replace(/[−‒–]/g, \"-\")\n .split(group)\n .join(group.trim() ? \"\" : group)\n .replace(/\\s/g, \"\")\n .split(decimal)\n .join(\".\")\n .replace(/[^\\d.-]/g, \"\");\n if (!/^-?\\d*\\.?\\d+$|^-?\\d+\\.?$/.test(cleaned)) return null;\n const n = Number(cleaned);\n if (!Number.isFinite(n)) return null;\n return options?.style === \"percent\" ? n / 100 : n;\n}\n\n/**\n * A number input: type it in your own format, or step it with the arrow keys, Page Up/Down, Home/End or the − and +\n * buttons. APG spinbutton; locale-aware; takes part in forms with the plain number.\n */\nexport function NumberField({\n label,\n labelHidden,\n description,\n error,\n value,\n defaultValue = null,\n onChange,\n min,\n max,\n step = 1,\n largeStep,\n locale,\n formatOptions,\n hideSteppers = false,\n name,\n form,\n required,\n disabled,\n readOnly,\n placeholder,\n size = \"md\",\n variant = \"outline\",\n labels,\n scrub = false,\n className,\n style,\n}: NumberFieldProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [current, setCurrent, resetCurrent] = useControllableState<number | null>(\n value,\n defaultValue,\n onChange,\n );\n const [draft, setDraft] = useState<string | null>(null);\n const input = useRef<HTMLInputElement>(null);\n const format = useMemo(\n () => new Intl.NumberFormat(locale, { maximumFractionDigits: 20, ...formatOptions }),\n [locale, formatOptions],\n );\n const shown = (n: number | null) => (n === null ? \"\" : format.format(n));\n\n const limit = (n: number) => clamp(n, min ?? Number.NEGATIVE_INFINITY, max ?? Number.POSITIVE_INFINITY);\n const commit = (next: number | null) => {\n setDraft(null);\n if (next !== current) setCurrent(next);\n };\n const stepBy = (delta: number) => {\n if (disabled || readOnly) return;\n const base = min ?? 0;\n const from = draft !== null ? (parseNumber(draft, locale, formatOptions) ?? current) : current;\n const start = from ?? (delta > 0 ? (min ?? 0) : (max ?? 0));\n // Snap onto the step grid (counted from min), then round away floating-point noise.\n const snapped = from === null ? start : Math.round((start - base + delta) / step) * step + base;\n const digits = Math.max(places(step), places(base));\n commit(limit(Number(snapped.toFixed(digits))));\n };\n const commitDraft = () => {\n if (draft === null) return;\n if (draft.trim() === \"\") return commit(null);\n const parsed = parseNumber(draft, locale, formatOptions);\n // Unreadable text goes back to the last good value.\n commit(parsed === null ? current : limit(parsed));\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n const big = largeStep ?? step * 10;\n const moves: Record<string, () => void> = {\n ArrowUp: () => stepBy(step),\n ArrowDown: () => stepBy(-step),\n PageUp: () => stepBy(big),\n PageDown: () => stepBy(-big),\n Enter: commitDraft,\n };\n if (min !== undefined) moves.Home = () => !disabled && !readOnly && commit(min);\n if (max !== undefined) moves.End = () => !disabled && !readOnly && commit(max);\n const move = moves[event.key];\n if (!move) return;\n if (event.key !== \"Enter\") event.preventDefault();\n move();\n };\n\n // Scrubbing: the field's own <label> is the handle.\n const handle = useRef<HTMLElement | null>(null);\n useClientLayoutEffect(() => {\n const el =\n scrub && !disabled && !readOnly\n ? ((input.current?.labels?.[0] as HTMLElement | undefined) ?? null)\n : null;\n if (handle.current && handle.current !== el) delete handle.current.dataset.scrub;\n if (el) el.dataset.scrub = \"\";\n handle.current = el;\n });\n const scrubFrom = useRef<number | null>(null);\n useDrag(handle, {\n distance: 3,\n touchAction: \"css\",\n onStart: () => {\n scrubFrom.current = current;\n },\n onMove: ({ delta, event }) => {\n const steps = Math.round(delta.x / 4) * (event.shiftKey ? 10 : 1);\n const from = scrubFrom.current ?? min ?? 0;\n const digits = Math.max(places(step), places(min ?? 0));\n commit(limit(Number((from + steps * step).toFixed(digits))));\n },\n onEnd: (_, cancelled) => {\n if (cancelled) commit(scrubFrom.current);\n input.current?.focus({ preventScroll: true });\n },\n });\n\n const atMin = current !== null && min !== undefined && current <= min;\n const atMax = current !== null && max !== undefined && current >= max;\n const integers = Number.isInteger(step) && (min ?? 0) >= 0 && formatOptions?.style !== \"percent\";\n\n return (\n <>\n <TextField\n ref={input}\n label={label}\n labelHidden={labelHidden}\n description={description}\n error={error}\n size={size}\n variant={variant}\n className={className ? `cy-number-field ${className}` : \"cy-number-field\"}\n {...(style ? { style } : {})}\n role=\"spinbutton\"\n inputMode={integers ? \"numeric\" : \"decimal\"}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n aria-valuenow={current ?? undefined}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuetext={current === null ? undefined : shown(current)}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n placeholder={placeholder}\n form={form}\n value={draft ?? shown(current)}\n onChange={setDraft}\n onKeyDown={onKeyDown}\n onBlur={commitDraft}\n addonEnd={\n !hideSteppers && (\n <span className=\"cy-number-field-steppers\">\n <IconButton\n icon={minus}\n label={text.decrement}\n variant=\"ghost\"\n size=\"sm\"\n tabIndex={-1}\n disabled={disabled || readOnly || atMin}\n onClick={() => {\n stepBy(-step);\n input.current?.focus();\n }}\n />\n <IconButton\n icon={plus}\n label={text.increment}\n variant=\"ghost\"\n size=\"sm\"\n tabIndex={-1}\n disabled={disabled || readOnly || atMax}\n onClick={() => {\n stepBy(step);\n input.current?.focus();\n }}\n />\n </span>\n )\n }\n />\n <HiddenValue\n name={name}\n form={form}\n value={current === null ? \"\" : String(current)}\n disabled={disabled}\n onReset={() => {\n setDraft(null);\n resetCurrent(defaultValue);\n }}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4EA,IAAMgB,KAAoC;AAAA,EAAE,WAAW;AAAA,EAAY,WAAW;AAAW,GAGnFC,IAAA,CAAUC,OAAe,OAAOA,CAAC,EAAE,MAAM,GAAG,EAAE,CAAA,KAAM,IAAI;AAG9D,SAAgBC,EACdC,GACAC,GACAC,GACe;AACf,QAAMC,IAAQ,IAAI,KAAK,aAAaF,CAAM,EAAE,cAAc,QAAQ,GAC5DG,IAAQD,EAAM,KAAA,CAAME,MAAMA,EAAE,SAAS,OAAO,GAAG,SAAS,KACxDC,IAAUH,EAAM,KAAA,CAAME,MAAMA,EAAE,SAAS,SAAS,GAAG,SAAS,KAC5DE,IAAUP,EACb,QAAQ,UAAU,GAAG,EACrB,MAAMI,CAAK,EACX,KAAKA,EAAM,KAAK,IAAI,KAAKA,CAAK,EAC9B,QAAQ,OAAO,EAAE,EACjB,MAAME,CAAO,EACb,KAAK,GAAG,EACR,QAAQ,YAAY,EAAE;AACzB,MAAI,CAAC,2BAA2B,KAAKC,CAAO,EAAG,QAAO;AACtD,QAAMT,IAAI,OAAOS,CAAO;AACxB,SAAK,OAAO,SAAST,CAAC,IACfI,GAAS,UAAU,YAAYJ,IAAI,MAAMA,IADhB;AAElC;AAMA,SAAgBU,GAAY,EAC1B,OAAAC,GACA,aAAAC,GACA,aAAAC,GACA,OAAAC,GACA,OAAAC,GACA,cAAAC,IAAe,MACf,UAAAC,GACA,KAAAC,GACA,KAAAC,GACA,MAAAC,IAAO,GACP,WAAAC,GACA,QAAAlB,GACA,eAAAmB,GACA,cAAAC,IAAe,IACf,MAAAC,GACA,MAAAC,GACA,UAAAC,GACA,UAAAC,GACA,UAAAC,GACA,aAAAC,GACA,MAAAC,IAAO,MACP,SAAAC,IAAU,WACV,QAAAC,GACA,OAAAC,IAAQ,IACR,WAAAC,GACA,OAAA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