@arshad-shah/cynosure 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/README.md +3 -3
  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.map +1 -1
  156. package/dist/components/Select/Select.d.ts +18 -1
  157. package/dist/components/Select/Select.js +97 -88
  158. package/dist/components/Select/Select.js.map +1 -1
  159. package/dist/components/Select/index.d.ts +1 -0
  160. package/dist/components/SelectionFrame/SelectionFrame.d.ts +6 -0
  161. package/dist/components/SelectionFrame/SelectionFrame.js.map +1 -1
  162. package/dist/components/SideNav/SideNav.d.ts +37 -1
  163. package/dist/components/SideNav/SideNav.js +100 -73
  164. package/dist/components/SideNav/SideNav.js.map +1 -1
  165. package/dist/components/SideNav/index.d.ts +1 -1
  166. package/dist/components/SignaturePad/SignaturePad.d.ts +3 -0
  167. package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
  168. package/dist/components/Skeleton/Skeleton.d.ts +1 -0
  169. package/dist/components/Skeleton/Skeleton.js.map +1 -1
  170. package/dist/components/Slider/Slider.d.ts +11 -0
  171. package/dist/components/Slider/Slider.js +6 -6
  172. package/dist/components/Slider/Slider.js.map +1 -1
  173. package/dist/components/SortableList/SortableList.d.ts +6 -0
  174. package/dist/components/SortableList/SortableList.js.map +1 -1
  175. package/dist/components/SplitPane/SplitPane.d.ts +5 -0
  176. package/dist/components/SplitPane/SplitPane.js +4 -4
  177. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  178. package/dist/components/Stack/Stack.d.ts +7 -3
  179. package/dist/components/Stack/Stack.js +18 -12
  180. package/dist/components/Stack/Stack.js.map +1 -1
  181. package/dist/components/Stack/index.d.ts +1 -0
  182. package/dist/components/Stack/space.d.ts +18 -0
  183. package/dist/components/Stack/space.js +12 -0
  184. package/dist/components/Stack/space.js.map +1 -0
  185. package/dist/components/Steps/Steps.d.ts +4 -0
  186. package/dist/components/Steps/Steps.js.map +1 -1
  187. package/dist/components/Table/Table.d.ts +12 -0
  188. package/dist/components/Table/Table.js.map +1 -1
  189. package/dist/components/Tabs/Tabs.d.ts +14 -0
  190. package/dist/components/Tabs/Tabs.js +4 -4
  191. package/dist/components/Tabs/Tabs.js.map +1 -1
  192. package/dist/components/TagInput/TagInput.d.ts +18 -0
  193. package/dist/components/TagInput/TagInput.js +5 -5
  194. package/dist/components/TagInput/TagInput.js.map +1 -1
  195. package/dist/components/Text/Text.d.ts +72 -0
  196. package/dist/components/Text/Text.js +30 -0
  197. package/dist/components/Text/Text.js.map +1 -0
  198. package/dist/components/Text/index.d.ts +1 -0
  199. package/dist/components/TextArea/TextArea.d.ts +10 -0
  200. package/dist/components/TextArea/TextArea.js +4 -4
  201. package/dist/components/TextArea/TextArea.js.map +1 -1
  202. package/dist/components/TextField/TextField.d.ts +13 -0
  203. package/dist/components/TextField/TextField.js +4 -4
  204. package/dist/components/TextField/TextField.js.map +1 -1
  205. package/dist/components/ThemeToggle/ThemeToggle.d.ts +4 -0
  206. package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
  207. package/dist/components/TimeField/TimeField.d.ts +62 -8
  208. package/dist/components/TimeField/TimeField.js +308 -72
  209. package/dist/components/TimeField/TimeField.js.map +1 -1
  210. package/dist/components/Toast/Toast.d.ts +25 -1
  211. package/dist/components/Toast/Toast.js +134 -125
  212. package/dist/components/Toast/Toast.js.map +1 -1
  213. package/dist/components/Toast/index.d.ts +1 -1
  214. package/dist/components/Toolbar/Toolbar.d.ts +3 -0
  215. package/dist/components/Toolbar/Toolbar.js.map +1 -1
  216. package/dist/components/Tooltip/Tooltip.d.ts +1 -0
  217. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  218. package/dist/components/Tree/Tree.d.ts +8 -0
  219. package/dist/components/Tree/Tree.js.map +1 -1
  220. package/dist/components/VirtualList/VirtualList.d.ts +8 -0
  221. package/dist/components/VirtualList/VirtualList.js +4 -4
  222. package/dist/components/VirtualList/VirtualList.js.map +1 -1
  223. package/dist/components/ZoomControls/ZoomControls.d.ts +4 -0
  224. package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
  225. package/dist/foundations/ChoiceBase/ChoiceBase.d.ts +1 -0
  226. package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
  227. package/dist/foundations/HiddenValue/HiddenValue.d.ts +3 -0
  228. package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
  229. package/dist/foundations/Icon/Icon.d.ts +3 -0
  230. package/dist/foundations/Icon/Icon.js.map +1 -1
  231. package/dist/foundations/image-outcome.d.ts +15 -0
  232. package/dist/foundations/image-outcome.js +39 -0
  233. package/dist/foundations/image-outcome.js.map +1 -0
  234. package/dist/foundations/option-icon.d.ts +26 -0
  235. package/dist/foundations/option-icon.js +16 -0
  236. package/dist/foundations/option-icon.js.map +1 -0
  237. package/dist/icons/index.d.ts +1 -0
  238. package/dist/icons/index.js +476 -474
  239. package/dist/icons/keywords.d.ts +249 -0
  240. package/dist/icons/keywords.js +1728 -0
  241. package/dist/icons/keywords.js.map +1 -0
  242. package/dist/index.d.ts +20 -9
  243. package/dist/index.js +240 -213
  244. package/dist/styles/aspect-ratio.css +1 -0
  245. package/dist/styles/avatar.css +1 -0
  246. package/dist/styles/breadcrumbs.css +1 -0
  247. package/dist/styles/calendar.css +1 -1
  248. package/dist/styles/card.css +1 -1
  249. package/dist/styles/checkbox.css +1 -1
  250. package/dist/styles/checklist.css +1 -0
  251. package/dist/styles/container.css +1 -0
  252. package/dist/styles/divider.css +1 -0
  253. package/dist/styles/generated-css.d.ts +1 -1
  254. package/dist/styles/generated-css.js +1 -1
  255. package/dist/styles/generated-css.js.map +1 -1
  256. package/dist/styles/grid.css +1 -1
  257. package/dist/styles/heading.css +1 -0
  258. package/dist/styles/image.css +1 -0
  259. package/dist/styles/menu.css +1 -1
  260. package/dist/styles/page-header.css +1 -0
  261. package/dist/styles/pagination.css +1 -0
  262. package/dist/styles/side-nav.css +1 -1
  263. package/dist/styles/stack.css +1 -1
  264. package/dist/styles/text.css +1 -0
  265. package/dist/styles/time-field.css +1 -1
  266. package/dist/styles/toast.css +1 -1
  267. package/dist/styles.css +1 -1
  268. package/dist/theme/CynosureTheme.d.ts +4 -0
  269. package/dist/theme/CynosureTheme.js.map +1 -1
  270. package/dist/tokens/to-css.js +12 -12
  271. package/dist/tokens/to-css.js.map +1 -1
  272. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeToggle.js","names":["IconButton","SegmentedControl","monitor","moon","sun","useColorMode","jsx","ThemeToggle","value","onChange","storage","size","variant","labels","className","style","color","mode","set","next","order","names","icons","name","c","n"],"sources":["../../../src/components/ThemeToggle/ThemeToggle.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { monitor } from \"../../icons/monitor.js\";\nimport { moon } from \"../../icons/moon.js\";\nimport { sun } from \"../../icons/sun.js\";\nimport { type ColorMode, type ColorModeStorage, useColorMode } from \"../../theme/use-color-mode.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { SegmentedControl } from \"../SegmentedControl/SegmentedControl.js\";\n\nexport interface ThemeToggleProps {\n /** Controlled mode; omit to manage and persist it internally. */\n value?: ColorMode;\n onChange?: (mode: ColorMode) => void;\n /** Persistence for uncontrolled use (localStorage by default; chrome.storage works too). */\n storage?: ColorModeStorage;\n size?: Size;\n /**\n * `segmented` (default): three choices side by side. `cycle`: one icon button that steps light → dark → system\n * (for tight headers); its name says the current mode and the next one (\"Colour mode: Light. Switch to Dark\").\n */\n variant?: \"segmented\" | \"cycle\";\n labels?: {\n label?: string;\n light?: string;\n dark?: string;\n system?: string;\n /** The cycle button's name. Default \"Colour mode: Light. Switch to Dark\". */\n cycle?: (current: string, next: string) => string;\n };\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Light / dark / system switch: a SegmentedControl with Facet icons. Pair with `<CynosureTheme mode={…}>`. */\nexport function ThemeToggle({\n value,\n onChange,\n storage,\n size = \"md\",\n variant = \"segmented\",\n labels,\n className,\n style,\n}: ThemeToggleProps) {\n const color = useColorMode(storage ? { storage } : {});\n const mode = value ?? color.mode;\n const set = (next: ColorMode) => {\n if (value === undefined) color.setMode(next);\n onChange?.(next);\n };\n if (variant === \"cycle\") {\n const order: ColorMode[] = [\"light\", \"dark\", \"system\"];\n const names = {\n light: labels?.light ?? \"Light\",\n dark: labels?.dark ?? \"Dark\",\n system: labels?.system ?? \"System\",\n };\n const icons = { light: sun, dark: moon, system: monitor };\n const next = order[(order.indexOf(mode) + 1) % order.length] as ColorMode;\n const name = (labels?.cycle ?? ((c, n) => `${labels?.label ?? \"Colour mode\"}: ${c}. Switch to ${n}`))(\n names[mode],\n names[next],\n );\n return (\n <IconButton\n icon={icons[mode]}\n label={name}\n variant=\"ghost\"\n size={size}\n className={className ? `cy-theme-toggle-cycle ${className}` : \"cy-theme-toggle-cycle\"}\n {...(style ? { style } : {})}\n onClick={() => set(next)}\n />\n );\n }\n return (\n <SegmentedControl\n label={labels?.label ?? \"Colour mode\"}\n iconOnly\n size={size}\n className={className}\n style={style}\n value={mode}\n onChange={(next) => set(next as ColorMode)}\n options={[\n { value: \"light\", label: labels?.light ?? \"Light\", icon: sun },\n { value: \"dark\", label: labels?.dark ?? \"Dark\", icon: moon },\n { value: \"system\", label: labels?.system ?? \"System\", icon: monitor },\n ]}\n />\n );\n}\n"],"mappings":";;;;;;;;AAmCA,SAAgBO,EAAY,EAC1B,OAAAC,GACA,UAAAC,GACA,SAAAC,GACA,MAAAC,IAAO,MACP,SAAAC,IAAU,aACV,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACmB;AACnB,QAAMC,IAAQX,EAAaK,IAAU,EAAE,SAAAA,EAAQ,IAAI,CAAC,CAAC,GAC/CO,IAAOT,KAASQ,EAAM,MACtBE,IAAA,CAAOC,MAAoB;AAC/B,IAAIX,MAAU,UAAWQ,EAAM,QAAQG,CAAI,GAC3CV,IAAWU,CAAI;AAAA,EACjB;AACA,MAAIP,MAAY,SAAS;AACvB,UAAMQ,IAAqB;AAAA,MAAC;AAAA,MAAS;AAAA,MAAQ;AAAA,IAAQ,GAC/CC,IAAQ;AAAA,MACZ,OAAOR,GAAQ,SAAS;AAAA,MACxB,MAAMA,GAAQ,QAAQ;AAAA,MACtB,QAAQA,GAAQ,UAAU;AAAA,IAC5B,GACMS,IAAQ;AAAA,MAAE,OAAOlB;AAAA,MAAK,MAAMD;AAAA,MAAM,QAAQD;AAAA,IAAQ,GAClDiB,IAAOC,GAAOA,EAAM,QAAQH,CAAI,IAAI,KAAKG,EAAM,MAAA,GAC/CG,KAAQV,GAAQ,UAAA,CAAWW,GAAGC,MAAM,GAAGZ,GAAQ,SAAS,aAAA,KAAkBW,CAAA,eAAgBC,CAAA,KAC9FJ,EAAMJ,CAAA,GACNI,EAAMF,CAAA,CACR;AACA,WACE,gBAAAb,EAACN,GAAD;AAAA,MACE,MAAMsB,EAAML,CAAA;AAAA,MACZ,OAAOM;AAAA,MACP,SAAQ;AAAA,MACF,MAAAZ;AAAA,MACN,WAAWG,IAAY,yBAAyBA,CAAA,KAAc;AAAA,MAC9D,GAAKC,IAAQ,EAAE,OAAAA,EAAM,IAAI,CAAC;AAAA,MAC1B,SAAA,MAAeG,EAAIC,CAAI;AAAA,IACxB,CAAA;AAAA,EAEL;AACA,SACE,gBAAAb,EAACL,GAAD;AAAA,IACE,OAAOY,GAAQ,SAAS;AAAA,IACxB,UAAA;AAAA,IACM,MAAAF;AAAA,IACK,WAAAG;AAAA,IACJ,OAAAC;AAAA,IACP,OAAOE;AAAA,IACP,UAAA,CAAWE,MAASD,EAAIC,CAAiB;AAAA,IACzC,SAAS;AAAA,MACP;AAAA,QAAE,OAAO;AAAA,QAAS,OAAON,GAAQ,SAAS;AAAA,QAAS,MAAMT;AAAA,MAAI;AAAA,MAC7D;AAAA,QAAE,OAAO;AAAA,QAAQ,OAAOS,GAAQ,QAAQ;AAAA,QAAQ,MAAMV;AAAA,MAAK;AAAA,MAC3D;AAAA,QAAE,OAAO;AAAA,QAAU,OAAOU,GAAQ,UAAU;AAAA,QAAU,MAAMX;AAAA,MAAQ;AAAA,IACtE;AAAA,EACD,CAAA;AAEL"}
1
+ {"version":3,"file":"ThemeToggle.js","names":["IconButton","SegmentedControl","monitor","moon","sun","useColorMode","jsx","ThemeToggle","value","onChange","storage","size","variant","labels","className","style","color","mode","set","next","order","names","icons","name","c","n"],"sources":["../../../src/components/ThemeToggle/ThemeToggle.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { monitor } from \"../../icons/monitor.js\";\nimport { moon } from \"../../icons/moon.js\";\nimport { sun } from \"../../icons/sun.js\";\nimport { type ColorMode, type ColorModeStorage, useColorMode } from \"../../theme/use-color-mode.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { SegmentedControl } from \"../SegmentedControl/SegmentedControl.js\";\n\nexport interface ThemeToggleProps {\n /** Controlled mode; omit to manage and persist it internally. */\n value?: ColorMode;\n /** Called with the mode the person picks. */\n onChange?: (mode: ColorMode) => void;\n /** Persistence for uncontrolled use (localStorage by default; chrome.storage works too). */\n storage?: ColorModeStorage;\n /** Size of the control. Default \"md\". */\n size?: Size;\n /**\n * `segmented` (default): three choices side by side. `cycle`: one icon button that steps light → dark → system\n * (for tight headers); its name says the current mode and the next one (\"Colour mode: Light. Switch to Dark\").\n */\n variant?: \"segmented\" | \"cycle\";\n /** Replace the built-in English text: the control's name and the names of the three modes. */\n labels?: {\n label?: string;\n light?: string;\n dark?: string;\n system?: string;\n /** The cycle button's name. Default \"Colour mode: Light. Switch to Dark\". */\n cycle?: (current: string, next: string) => string;\n };\n /** Added to the control, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** Light / dark / system switch: a SegmentedControl with Facet icons. Pair with `<CynosureTheme mode={…}>`. */\nexport function ThemeToggle({\n value,\n onChange,\n storage,\n size = \"md\",\n variant = \"segmented\",\n labels,\n className,\n style,\n}: ThemeToggleProps) {\n const color = useColorMode(storage ? { storage } : {});\n const mode = value ?? color.mode;\n const set = (next: ColorMode) => {\n if (value === undefined) color.setMode(next);\n onChange?.(next);\n };\n if (variant === \"cycle\") {\n const order: ColorMode[] = [\"light\", \"dark\", \"system\"];\n const names = {\n light: labels?.light ?? \"Light\",\n dark: labels?.dark ?? \"Dark\",\n system: labels?.system ?? \"System\",\n };\n const icons = { light: sun, dark: moon, system: monitor };\n const next = order[(order.indexOf(mode) + 1) % order.length] as ColorMode;\n const name = (labels?.cycle ?? ((c, n) => `${labels?.label ?? \"Colour mode\"}: ${c}. Switch to ${n}`))(\n names[mode],\n names[next],\n );\n return (\n <IconButton\n icon={icons[mode]}\n label={name}\n variant=\"ghost\"\n size={size}\n className={className ? `cy-theme-toggle-cycle ${className}` : \"cy-theme-toggle-cycle\"}\n {...(style ? { style } : {})}\n onClick={() => set(next)}\n />\n );\n }\n return (\n <SegmentedControl\n label={labels?.label ?? \"Colour mode\"}\n iconOnly\n size={size}\n className={className}\n style={style}\n value={mode}\n onChange={(next) => set(next as ColorMode)}\n options={[\n { value: \"light\", label: labels?.light ?? \"Light\", icon: sun },\n { value: \"dark\", label: labels?.dark ?? \"Dark\", icon: moon },\n { value: \"system\", label: labels?.system ?? \"System\", icon: monitor },\n ]}\n />\n );\n}\n"],"mappings":";;;;;;;;AAuCA,SAAgBO,EAAY,EAC1B,OAAAC,GACA,UAAAC,GACA,SAAAC,GACA,MAAAC,IAAO,MACP,SAAAC,IAAU,aACV,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACmB;AACnB,QAAMC,IAAQX,EAAaK,IAAU,EAAE,SAAAA,EAAQ,IAAI,CAAC,CAAC,GAC/CO,IAAOT,KAASQ,EAAM,MACtBE,IAAA,CAAOC,MAAoB;AAC/B,IAAIX,MAAU,UAAWQ,EAAM,QAAQG,CAAI,GAC3CV,IAAWU,CAAI;AAAA,EACjB;AACA,MAAIP,MAAY,SAAS;AACvB,UAAMQ,IAAqB;AAAA,MAAC;AAAA,MAAS;AAAA,MAAQ;AAAA,IAAQ,GAC/CC,IAAQ;AAAA,MACZ,OAAOR,GAAQ,SAAS;AAAA,MACxB,MAAMA,GAAQ,QAAQ;AAAA,MACtB,QAAQA,GAAQ,UAAU;AAAA,IAC5B,GACMS,IAAQ;AAAA,MAAE,OAAOlB;AAAA,MAAK,MAAMD;AAAA,MAAM,QAAQD;AAAA,IAAQ,GAClDiB,IAAOC,GAAOA,EAAM,QAAQH,CAAI,IAAI,KAAKG,EAAM,MAAA,GAC/CG,KAAQV,GAAQ,UAAA,CAAWW,GAAGC,MAAM,GAAGZ,GAAQ,SAAS,aAAA,KAAkBW,CAAA,eAAgBC,CAAA,KAC9FJ,EAAMJ,CAAA,GACNI,EAAMF,CAAA,CACR;AACA,WACE,gBAAAb,EAACN,GAAD;AAAA,MACE,MAAMsB,EAAML,CAAA;AAAA,MACZ,OAAOM;AAAA,MACP,SAAQ;AAAA,MACF,MAAAZ;AAAA,MACN,WAAWG,IAAY,yBAAyBA,CAAA,KAAc;AAAA,MAC9D,GAAKC,IAAQ,EAAE,OAAAA,EAAM,IAAI,CAAC;AAAA,MAC1B,SAAA,MAAeG,EAAIC,CAAI;AAAA,IACxB,CAAA;AAAA,EAEL;AACA,SACE,gBAAAb,EAACL,GAAD;AAAA,IACE,OAAOY,GAAQ,SAAS;AAAA,IACxB,UAAA;AAAA,IACM,MAAAF;AAAA,IACK,WAAAG;AAAA,IACJ,OAAAC;AAAA,IACP,OAAOE;AAAA,IACP,UAAA,CAAWE,MAASD,EAAIC,CAAiB;AAAA,IACzC,SAAS;AAAA,MACP;AAAA,QAAE,OAAO;AAAA,QAAS,OAAON,GAAQ,SAAS;AAAA,QAAS,MAAMT;AAAA,MAAI;AAAA,MAC7D;AAAA,QAAE,OAAO;AAAA,QAAQ,OAAOS,GAAQ,QAAQ;AAAA,QAAQ,MAAMV;AAAA,MAAK;AAAA,MAC3D;AAAA,QAAE,OAAO;AAAA,QAAU,OAAOU,GAAQ,UAAU;AAAA,QAAU,MAAMX;AAAA,MAAQ;AAAA,IACtE;AAAA,EACD,CAAA;AAEL"}
@@ -1,36 +1,89 @@
1
1
  import { type CSSProperties, type ReactNode } from "react";
2
2
  import type { Size } from "../../tokens/schema.js";
3
+ export interface TimeFieldTokens {
4
+ rowHeight: string;
5
+ columnWidth: string;
6
+ lensBackground: string;
7
+ night: string;
8
+ day: string;
9
+ }
10
+ declare module "../../tokens/schema.js" {
11
+ interface ComponentTokens {
12
+ timeField: TimeFieldTokens;
13
+ }
14
+ }
3
15
  export interface TimeFieldLabels {
4
- /** Shown when the text is not a time. Default "Enter a time as HH:MM" (or HH:MM:SS with `seconds`). */
16
+ /** Shown when the text is not a time. Default "Enter a time as HH:MM" (the field's own placeholder). */
5
17
  invalid: string;
6
18
  /** Shown when the time is outside `min` and `max`. Default "This time is not available". */
7
19
  unavailable: string;
20
+ /** The button that opens the picker, and the picker's name. Default "Choose a time". */
21
+ open: string;
22
+ /** The picker's columns. Defaults "Hours", "Minutes" and "Seconds". */
23
+ hours: string;
24
+ minutes: string;
25
+ seconds: string;
26
+ /** The two halves of the day with `hourCycle={12}`, and the name of their switch. Defaults "AM", "PM", "AM or PM". */
27
+ am: string;
28
+ pm: string;
29
+ period: string;
30
+ /** The strip of the whole day under the columns. Default "Time of day". */
31
+ dayTrack: string;
32
+ /** The button that sets the current time. Default "Now". */
33
+ now: string;
8
34
  }
9
35
  export interface TimeFieldProps {
36
+ /** The field's visible label, and its accessible name. */
10
37
  label: ReactNode;
38
+ /** Hide the label visually; it still names the field. */
11
39
  labelHidden?: boolean;
40
+ /** Help text under the field, read with it by screen readers. */
12
41
  description?: ReactNode;
13
42
  /** Your own error; it replaces the field's own messages. */
14
43
  error?: ReactNode;
15
- /** `HH:MM` (or `HH:MM:SS` with `seconds`), 24-hour, or null when empty. */
44
+ /** `HH:MM` (or `HH:MM:SS` with `seconds`), 24-hour whatever `hourCycle` shows, or null when empty. */
16
45
  value?: string | null;
46
+ /** The starting time when `value` is not given, in the same form. */
17
47
  defaultValue?: string | null;
18
- /** A valid time (or null when cleared), when typing is finished or the arrows step it. */
48
+ /** A valid time (or null when cleared), when typing is finished, the arrows step it or the picker chooses it. */
19
49
  onChange?: (time: string | null) => void;
20
- /** Earliest and latest times, in the same form. */
50
+ /** The earliest time allowed, in the same form. Earlier times are explained and not reported. */
21
51
  min?: string | undefined;
52
+ /** The latest time allowed, in the same form. Later times are explained and not reported. */
22
53
  max?: string | undefined;
23
- /** Minutes the arrows move the minutes by. Default 1 (Shift: ten steps). */
54
+ /** Minutes between the picker's minutes, and what the arrows move the minutes by. Default 1 (Shift: ten steps). */
24
55
  step?: number;
25
56
  /** Include seconds. */
26
57
  seconds?: boolean;
58
+ /**
59
+ * How the time is shown: `24` as `21:30`, `12` as `9:30 PM` (with an AM/PM switch in the picker), or `"auto"` to
60
+ * follow the person's own language and region. The value is 24-hour either way. Default "auto".
61
+ */
62
+ hourCycle?: 12 | 24 | "auto";
63
+ /** The language and region `hourCycle="auto"` follows, such as `en-GB`. Default: the browser's. */
64
+ locale?: string | undefined;
65
+ /**
66
+ * Add a clock button that opens a picker: columns for hours and minutes that roll under one lens. Without it the
67
+ * field is only typed in.
68
+ */
69
+ picker?: boolean;
70
+ /** With `picker`: the strip of the whole day under the columns, to click or drag to a time. Default `true`. */
71
+ dayTrack?: boolean;
72
+ /** Form field name. The form receives the 24-hour `HH:MM`, however the time is shown. */
27
73
  name?: string | undefined;
74
+ /** The `id` of a form elsewhere on the page that the field belongs to. */
28
75
  form?: string | undefined;
76
+ /** The form cannot be submitted while the field is empty. */
29
77
  required?: boolean | undefined;
78
+ /** Cannot be focused, changed or submitted. */
30
79
  disabled?: boolean | undefined;
80
+ /** Shown and submitted but not changed: no typing, no arrows and no picker button. */
31
81
  readOnly?: boolean | undefined;
82
+ /** Height and text size of the field. Default "md". */
32
83
  size?: Size;
84
+ /** Replace the built-in English text: the two messages and the picker's names. */
33
85
  labels?: Partial<TimeFieldLabels>;
86
+ /** Added to the root element, for layout. */
34
87
  className?: string;
35
88
  /** Layout only. */
36
89
  style?: CSSProperties;
@@ -43,7 +96,8 @@ export declare function parseTime(text: string): number | null;
43
96
  /** `HH:MM` (or `HH:MM:SS`) from seconds since midnight. */
44
97
  export declare const formatTime: (total: number, seconds?: boolean) => string;
45
98
  /**
46
- * A time of day in a form, typed in 24-hour `HH:MM`. Forgiving as it reads (`930`, `9:30 pm`), strict in what it
47
- * reports, and Up/Down step the hours, minutes or seconds the caret is in.
99
+ * A time of day in a form: type it, step it with the arrows, or pick it from columns that roll under a lens, with a
100
+ * strip of the whole day to jump along. Forgiving as it reads (`930`, `9:30 pm`), strict in what it reports: always
101
+ * 24-hour `HH:MM`, however it is shown.
48
102
  */
49
- export declare function TimeField({ label, labelHidden, description, error, value, defaultValue, onChange, min, max, step, seconds, name, form, required, disabled, readOnly, size, labels, className, style, }: TimeFieldProps): import("react").JSX.Element;
103
+ export declare function TimeField({ label, labelHidden, description, error, value, defaultValue, onChange, min, max, step, seconds, hourCycle, locale, picker, dayTrack, name, form, required, disabled, readOnly, size, labels, className, style, }: TimeFieldProps): import("react").JSX.Element;
@@ -1,85 +1,321 @@
1
1
  "use client";
2
- import { useControllableState as Q } from "../../foundations/controllable.js";
3
- import { useClientLayoutEffect as V } from "../../foundations/client-layout-effect.js";
4
- import { TextField as W } from "../TextField/TextField.js";
5
- import { clock as X } from "../../icons/clock.js";
6
- import { useRef as F, useState as K } from "react";
7
- import { jsx as Z } from "react/jsx-runtime";
8
- var u = 86400, g = (e) => String(e).padStart(2, "0");
9
- function M(e) {
10
- const r = /^\s*(\d{1,2})(?::?(\d{2}))?(?::?(\d{2}))?\s*([ap]\.?m\.?)?\s*$/i.exec(e);
11
- if (!r) return null;
12
- let n = Number(r[1]);
13
- const l = Number(r[2] ?? 0), m = Number(r[3] ?? 0), p = r[4]?.[0]?.toLowerCase();
14
- if (p) {
15
- if (n < 1 || n > 12) return null;
16
- n = n % 12 + (p === "p" ? 12 : 0);
2
+ import { useControllableState as Ze } from "../../foundations/controllable.js";
3
+ import { useClientLayoutEffect as xe } from "../../foundations/client-layout-effect.js";
4
+ import { Button as et } from "../Button/Button.js";
5
+ import { clamp as tt } from "../../foundations/math.js";
6
+ import { IconButton as rt } from "../IconButton/IconButton.js";
7
+ import { isTypeaheadKey as ve, seekEnabled as O, useTypeahead as ot } from "../../foundations/listbox.js";
8
+ import { Popover as nt } from "../Popover/Popover.js";
9
+ import { TextField as st } from "../TextField/TextField.js";
10
+ import { HiddenValue as lt } from "../../foundations/HiddenValue/HiddenValue.js";
11
+ import { Slider as at } from "../Slider/Slider.js";
12
+ import { SegmentedControl as it } from "../SegmentedControl/SegmentedControl.js";
13
+ import { clock as He } from "../../icons/clock.js";
14
+ import { Fragment as ct, useEffect as De, useId as ut, useRef as T, useState as $ } from "react";
15
+ import { Fragment as mt, jsx as f, jsxs as C } from "react/jsx-runtime";
16
+ var y = 86400, w = (u) => String(u).padStart(2, "0");
17
+ function N(u) {
18
+ const d = /^\s*(\d{1,2})(?::?(\d{2}))?(?::?(\d{2}))?\s*([ap]\.?m\.?)?\s*$/i.exec(u);
19
+ if (!d) return null;
20
+ let a = Number(d[1]);
21
+ const p = Number(d[2] ?? 0), E = Number(d[3] ?? 0), I = d[4]?.[0]?.toLowerCase();
22
+ if (I) {
23
+ if (a < 1 || a > 12) return null;
24
+ a = a % 12 + (I === "p" ? 12 : 0);
17
25
  }
18
- return n > 23 || l > 59 || m > 59 ? null : n * 3600 + l * 60 + m;
26
+ return a > 23 || p > 59 || E > 59 ? null : a * 3600 + p * 60 + E;
19
27
  }
20
- var _ = (e, r = !1) => {
21
- const n = (e % u + u) % u, l = `${g(Math.floor(n / 3600))}:${g(Math.floor(n / 60) % 60)}`;
22
- return r ? `${l}:${g(n % 60)}` : l;
28
+ var Ce = (u, d = !1) => {
29
+ const a = (u % y + y) % y, p = `${w(Math.floor(a / 3600))}:${w(Math.floor(a / 60) % 60)}`;
30
+ return d ? `${p}:${w(a % 60)}` : p;
31
+ }, ne = 43200, Ee = (u, d) => {
32
+ const a = Math.floor(u / 3600);
33
+ return `${a % 12 || 12}:${w(Math.floor(u / 60) % 60)}${d ? `:${w(u % 60)}` : ""} ${a < 12 ? "AM" : "PM"}`;
34
+ }, ft = (u) => new Intl.DateTimeFormat(u, { hour: "numeric" }).resolvedOptions().hour12 === !0, Ie = {
35
+ h: 3600,
36
+ m: 60,
37
+ s: 1
23
38
  };
24
- function ot({ label: e, labelHidden: r, description: n, error: l, value: m, defaultValue: p = null, onChange: L, min: v, max: w, step: U = 1, seconds: S = !1, name: j, form: B, required: P, disabled: Y = !1, readOnly: y = !1, size: q = "md", labels: z, className: H, style: T }) {
25
- const $ = {
26
- invalid: `Enter a time as ${S ? "HH:MM:SS" : "HH:MM"}`,
39
+ function xt({ label: u, labelHidden: d, description: a, error: p, value: E, defaultValue: I = null, onChange: Pe, min: se, max: le, step: ae = 1, seconds: b = !1, hourCycle: P = "auto", locale: ie, picker: Fe = !1, dayTrack: Le = !0, name: _, form: ce, required: Ke, disabled: U = !1, readOnly: V = !1, size: Re = "md", labels: je, className: ue, style: me }) {
40
+ const [ze, Be] = $(24);
41
+ xe(() => {
42
+ P === "auto" && Be(ft(ie) ? 12 : 24);
43
+ }, [P, ie]);
44
+ const m = (P === "auto" ? ze : P) === 12, fe = `${m ? "H:MM" : "HH:MM"}${b ? ":SS" : ""}${m ? " AM" : ""}`, c = {
45
+ invalid: `Enter a time as ${fe}`,
27
46
  unavailable: "This time is not available",
28
- ...z
29
- }, [h, k] = Q(m, p, L), [i, b] = K(null), [x, d] = K(null), C = F(null), c = F(null);
30
- V(() => {
31
- c.current !== null && (C.current?.setSelectionRange(c.current, c.current), c.current = null);
32
- });
33
- const s = v === void 0 ? null : M(v), a = w === void 0 ? null : M(w), G = (t) => (s === null || t >= s) && (a === null || t <= a), D = (t) => {
34
- const o = _(t, S);
35
- b(null), d(null), o !== h && k(o);
36
- }, A = () => {
37
- if (i === null) return;
38
- if (i.trim() === "") {
39
- b(null), d(null), h !== null && k(null);
47
+ open: "Choose a time",
48
+ hours: "Hours",
49
+ minutes: "Minutes",
50
+ seconds: "Seconds",
51
+ am: "AM",
52
+ pm: "PM",
53
+ period: "AM or PM",
54
+ dayTrack: "Time of day",
55
+ now: "Now",
56
+ ...je
57
+ }, de = ut(), [g, pe] = Ze(E, I, Pe), [M, Y] = $(null), [he, F] = $(null), [W, ye] = $(!1), [Oe, _e] = $(!1), [Ue, Ve] = $(0), q = T(null), L = T([]), G = T([]), J = T([]), Q = T(!1), Ye = ot(), S = T(null);
58
+ xe(() => {
59
+ S.current !== null && (q.current?.setSelectionRange(S.current, S.current), S.current = null);
60
+ }), De(() => () => J.current.forEach(clearTimeout), []);
61
+ const K = se === void 0 ? null : N(se), R = le === void 0 ? null : N(le), A = K ?? 0, j = R ?? 86399, we = (e) => e >= A && e <= j, be = (e) => tt(e, A, j), x = Math.max(1, Math.round(ae)), X = g === null ? null : N(g), v = M ?? (m && X !== null ? Ee(X, b) : g ?? ""), Z = (e) => {
62
+ const t = Ce(e, b);
63
+ Y(null), F(null), t !== g && pe(t);
64
+ }, ge = () => {
65
+ if (M === null) return;
66
+ if (M.trim() === "") {
67
+ Y(null), F(null), g !== null && pe(null);
40
68
  return;
41
69
  }
42
- const t = M(i);
43
- if (t === null) return d($.invalid);
44
- if (!G(t)) return d($.unavailable);
45
- D(t);
46
- }, I = (t) => {
47
- if (t.key === "Enter" && A(), t.key !== "ArrowUp" && t.key !== "ArrowDown" || y) return;
48
- const o = i ?? h ?? "", E = M(o);
49
- if (E === null) return;
50
- t.preventDefault();
51
- const N = t.currentTarget.selectionStart ?? o.length, R = o.slice(0, N).split(":").length - 1, J = R === 0 ? 3600 : R === 1 ? 60 * U : 1;
52
- let f = ((E + (t.key === "ArrowUp" ? 1 : -1) * J * (t.shiftKey ? 10 : 1)) % u + u) % u;
53
- s !== null && f < s && (f = s), a !== null && f > a && (f = a), c.current = N, D(f);
54
- };
55
- return /* @__PURE__ */ Z(W, {
56
- ref: C,
57
- label: e,
58
- ...r ? { labelHidden: r } : {},
59
- ...n !== void 0 ? { description: n } : {},
60
- ...(l ?? x) != null ? { error: l ?? x } : {},
61
- value: i ?? h ?? "",
62
- onChange: b,
63
- onBlur: A,
64
- onKeyDown: I,
65
- placeholder: S ? "HH:MM:SS" : "HH:MM",
66
- inputMode: "numeric",
70
+ const e = N(M);
71
+ if (e === null) return F(c.invalid);
72
+ if (!we(e)) return F(c.unavailable);
73
+ Z(e);
74
+ }, We = (e) => {
75
+ if (e.key === "Enter" && ge(), e.key !== "ArrowUp" && e.key !== "ArrowDown" || V) return;
76
+ const t = N(v);
77
+ if (t === null) return;
78
+ e.preventDefault();
79
+ const r = e.currentTarget.selectionStart ?? v.length, o = v.slice(0, r).split(":").length - 1, n = v.search(/[ap]/i), s = n >= 0 && r > n, i = s ? ne : o === 0 ? 3600 : o === 1 ? 60 * ae : 1;
80
+ let l = ((t + (e.key === "ArrowUp" ? 1 : -1) * i * (e.shiftKey && !s ? 10 : 1)) % y + y) % y;
81
+ K !== null && l < K && (l = K), R !== null && l > R && (l = R), S.current = r, Z(l);
82
+ }, Me = M !== null ? N(M) : X, ee = be(Me ?? A), H = b ? ee : ee - ee % 60, h = {
83
+ h: Math.floor(H / 3600),
84
+ m: Math.floor(H / 60) % 60,
85
+ s: H % 60
86
+ }, te = (e, t) => t >= A && e <= j, re = (e, t, r) => {
87
+ const o = e === "h" && m ? h.h % 12 || 12 : h[e];
88
+ let n = 0;
89
+ return {
90
+ unit: e,
91
+ name: t,
92
+ rows: r.map((s, i) => {
93
+ const l = (e !== "h" ? h.h : m ? s % 12 + (h.h >= 12 ? 12 : 0) : s) * 3600 + (e === "m" ? s : h.m) * 60 + (e === "s" ? s : h.s), D = l - l % Ie[e], Xe = D + (e === "m" && !b ? 0 : Ie[e] - 1);
94
+ return Math.abs(s - o) < Math.abs(r[n] - o) && (n = i), {
95
+ text: e === "h" && m ? String(s) : w(s),
96
+ typed: String(s),
97
+ time: l,
98
+ disabled: !te(D, Xe),
99
+ selected: Me !== null && s === o
100
+ };
101
+ }),
102
+ rest: n
103
+ };
104
+ }, z = (e, t = 1) => Array.from({ length: Math.ceil(e / t) }, (r, o) => o * t), B = [
105
+ re("h", c.hours, m ? [12, ...z(12).slice(1)] : z(24)),
106
+ re("m", c.minutes, z(60, x)),
107
+ ...b ? [re("s", c.seconds, z(60))] : []
108
+ ], k = (e) => {
109
+ G.current = [], Z(be(e));
110
+ }, ke = (e) => {
111
+ h.h >= 12 !== e && k(H + (e ? ne : -43200));
112
+ }, Te = () => {
113
+ const e = /* @__PURE__ */ new Date();
114
+ return Math.round((e.getHours() * 60 + e.getMinutes()) / x) * x % 1440 * 60;
115
+ }, qe = (e) => {
116
+ e && (Q.current = !0, _e(we(Te()))), ye(e);
117
+ }, Ge = () => {
118
+ ye(!1), q.current?.focus();
119
+ }, $e = B.map((e) => e.rest).join();
120
+ De(() => {
121
+ if (!W) return;
122
+ const e = Q.current;
123
+ Q.current = !1, $e.split(",").forEach((t, r) => {
124
+ const o = L.current[r], n = o?.children[Number(t)];
125
+ !o || !n || o.scrollTo({
126
+ top: n.offsetTop - (o.clientHeight - n.offsetHeight) / 2,
127
+ behavior: e ? "instant" : "auto"
128
+ });
129
+ });
130
+ }, [
131
+ W,
132
+ $e,
133
+ Ue
134
+ ]);
135
+ const Je = (e) => () => {
136
+ clearTimeout(J.current[e]), J.current[e] = setTimeout(() => {
137
+ const t = L.current[e];
138
+ if (!G.current[e] || !t) return;
139
+ const r = t.scrollTop + t.clientHeight / 2;
140
+ let o = 0, n = Number.POSITIVE_INFINITY;
141
+ [...t.children].forEach((i, l) => {
142
+ const D = Math.abs(i.offsetTop + i.offsetHeight / 2 - r);
143
+ D < n && ([o, n] = [l, D]);
144
+ });
145
+ const s = B[e]?.rows[o];
146
+ s && k(s.time), Ve((i) => i + 1);
147
+ }, 120);
148
+ }, Qe = (e) => (t) => {
149
+ const r = B[e], o = r.rows.length, n = (i) => !r.rows[i]?.disabled, s = (i) => {
150
+ t.preventDefault();
151
+ const l = r.rows[i];
152
+ l && k(l.time);
153
+ };
154
+ if (t.key === "ArrowDown") return s(O(o, r.rest, 1, n));
155
+ if (t.key === "ArrowUp") return s(O(o, r.rest, -1, n));
156
+ if (t.key === "Home") return s(O(o, -1, 1, n));
157
+ if (t.key === "End") return s(O(o, o, -1, n));
158
+ if (t.key === "ArrowLeft" || t.key === "ArrowRight")
159
+ t.preventDefault(), L.current[e + (t.key === "ArrowRight" ? 1 : -1)]?.focus();
160
+ else if (t.key === "Enter")
161
+ t.preventDefault(), Ge();
162
+ else if (m && ve(t) && /^[ap]$/i.test(t.key)) ke(t.key.toLowerCase() === "p");
163
+ else if (ve(t)) {
164
+ const i = Ye(t.key, r.rows.map((l) => l.disabled ? null : l.typed), r.rest);
165
+ i >= 0 && s(i);
166
+ }
167
+ }, oe = (e) => () => {
168
+ G.current[e] = !0;
169
+ }, Ne = (e) => `${e / y * 100}%`, Se = Fe && !V, Ae = m && _ !== void 0;
170
+ return /* @__PURE__ */ C(mt, { children: [/* @__PURE__ */ f(st, {
171
+ ref: q,
172
+ label: u,
173
+ ...d ? { labelHidden: d } : {},
174
+ ...a !== void 0 ? { description: a } : {},
175
+ ...(p ?? he) != null ? { error: p ?? he } : {},
176
+ value: v,
177
+ onChange: Y,
178
+ onBlur: ge,
179
+ onKeyDown: We,
180
+ placeholder: fe,
181
+ inputMode: m ? "text" : "numeric",
67
182
  autoComplete: "off",
68
- iconStart: X,
69
- name: j,
70
- form: B,
71
- required: P,
72
- disabled: Y,
73
- readOnly: y,
74
- size: q,
75
- className: H ? `cy-time-field ${H}` : "cy-time-field",
76
- ...T ? { style: T } : {}
77
- });
183
+ ...Se ? {} : { iconStart: He },
184
+ name: Ae ? void 0 : _,
185
+ form: ce,
186
+ required: Ke,
187
+ disabled: U,
188
+ readOnly: V,
189
+ size: Re,
190
+ className: ue ? `cy-time-field ${ue}` : "cy-time-field",
191
+ ...me ? { style: me } : {},
192
+ addonEnd: Se && /* @__PURE__ */ f(nt, {
193
+ label: c.open,
194
+ open: W,
195
+ onOpenChange: qe,
196
+ placement: "bottom",
197
+ trigger: (e) => /* @__PURE__ */ f(rt, {
198
+ ...e,
199
+ icon: He,
200
+ label: c.open,
201
+ variant: "ghost",
202
+ size: "sm",
203
+ disabled: U,
204
+ className: "cy-time-field-open"
205
+ }),
206
+ children: /* @__PURE__ */ C("div", {
207
+ className: "cy-time-field-picker",
208
+ children: [
209
+ /* @__PURE__ */ C("div", {
210
+ className: "cy-time-field-wheel cy-reset",
211
+ children: [/* @__PURE__ */ C("div", {
212
+ className: "cy-time-field-drum cy-reset",
213
+ dir: "ltr",
214
+ children: [/* @__PURE__ */ f("div", { className: "cy-time-field-lens cy-reset" }), B.map((e, t) => /* @__PURE__ */ C(ct, { children: [t > 0 && /* @__PURE__ */ f("span", {
215
+ className: "cy-time-field-colon cy-reset",
216
+ "aria-hidden": "true",
217
+ children: ":"
218
+ }), /* @__PURE__ */ f("div", {
219
+ ref: (r) => {
220
+ L.current[t] = r;
221
+ },
222
+ role: "listbox",
223
+ tabIndex: 0,
224
+ "aria-label": e.name,
225
+ "aria-activedescendant": e.rows.some((r) => r.selected) ? `${de}-${e.unit}-${e.rest}` : void 0,
226
+ className: "cy-time-field-column cy-reset",
227
+ onKeyDown: Qe(t),
228
+ onClick: (r) => {
229
+ const o = r.target.closest("[data-index]"), n = e.rows[Number(o?.dataset.index ?? -1)];
230
+ n && !n.disabled && k(n.time);
231
+ },
232
+ onScroll: Je(t),
233
+ onWheel: oe(t),
234
+ onTouchStart: oe(t),
235
+ onPointerDown: oe(t),
236
+ children: e.rows.map((r, o) => /* @__PURE__ */ f("div", {
237
+ id: `${de}-${e.unit}-${o}`,
238
+ role: "option",
239
+ "aria-selected": r.selected,
240
+ "aria-disabled": r.disabled || void 0,
241
+ tabIndex: -1,
242
+ "data-index": o,
243
+ className: "cy-time-field-option cy-reset",
244
+ children: r.text
245
+ }, r.typed))
246
+ })] }, e.unit))]
247
+ }), m && /* @__PURE__ */ f(it, {
248
+ label: c.period,
249
+ size: "sm",
250
+ value: h.h >= 12 ? "pm" : "am",
251
+ onChange: (e) => ke(e === "pm"),
252
+ options: [{
253
+ value: "am",
254
+ label: c.am,
255
+ disabled: !te(0, 43199)
256
+ }, {
257
+ value: "pm",
258
+ label: c.pm,
259
+ disabled: !te(ne, 86399)
260
+ }]
261
+ })]
262
+ }),
263
+ Le && /* @__PURE__ */ f(at, {
264
+ label: c.dayTrack,
265
+ labelHidden: !0,
266
+ min: 0,
267
+ max: 1440,
268
+ step: x,
269
+ largeStep: 60,
270
+ size: "sm",
271
+ value: Math.floor(H / 60),
272
+ onChange: (e) => k(Math.min(e, 1440 - x) * 60),
273
+ marks: [
274
+ 0,
275
+ 6,
276
+ 12,
277
+ 18,
278
+ 24
279
+ ].map((e) => ({
280
+ value: e * 60,
281
+ ...e % 24 === 0 ? {} : { label: m ? `${e % 12 || 12} ${e < 12 ? c.am : c.pm}` : w(e) }
282
+ })),
283
+ labels: { value: (e) => {
284
+ const t = Math.min(e, 1439) * 60;
285
+ return m ? Ee(t, !1) : Ce(t);
286
+ } },
287
+ className: "cy-time-field-track",
288
+ trackContent: /* @__PURE__ */ f("div", {
289
+ className: "cy-time-field-day cy-reset",
290
+ style: {
291
+ "--_open-from": Ne(A),
292
+ "--_open-to": Ne(j)
293
+ }
294
+ })
295
+ }),
296
+ Oe && /* @__PURE__ */ f("div", {
297
+ className: "cy-time-field-foot cy-reset",
298
+ children: /* @__PURE__ */ f(et, {
299
+ variant: "ghost",
300
+ size: "sm",
301
+ onClick: () => k(Te()),
302
+ children: c.now
303
+ })
304
+ })
305
+ ]
306
+ })
307
+ })
308
+ }), Ae && /* @__PURE__ */ f(lt, {
309
+ name: _,
310
+ form: ce,
311
+ value: g ?? "",
312
+ disabled: U
313
+ })] });
78
314
  }
79
315
  export {
80
- ot as TimeField,
81
- _ as formatTime,
82
- M as parseTime
316
+ xt as TimeField,
317
+ Ce as formatTime,
318
+ N as parseTime
83
319
  };
84
320
 
85
321
  //# sourceMappingURL=TimeField.js.map