@vokality/design-system 0.0.0-stage → 1.2.2

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 (350) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +134 -2
  3. package/dist/charts/chart.d.ts +52 -0
  4. package/dist/charts/chart.js +108 -0
  5. package/dist/components/Accordion/Accordion.d.ts +15 -0
  6. package/dist/components/Accordion/Accordion.js +16 -0
  7. package/dist/components/Alert/Alert.d.ts +14 -0
  8. package/dist/components/Alert/Alert.js +12 -0
  9. package/dist/components/AppShell/AppShell.d.ts +21 -0
  10. package/dist/components/AppShell/AppShell.js +48 -0
  11. package/dist/components/Avatar/Avatar.d.ts +11 -0
  12. package/dist/components/Avatar/Avatar.js +19 -0
  13. package/dist/components/AvatarGroup/AvatarGroup.d.ts +11 -0
  14. package/dist/components/AvatarGroup/AvatarGroup.js +13 -0
  15. package/dist/components/Badge/Badge.d.ts +9 -0
  16. package/dist/components/Badge/Badge.js +6 -0
  17. package/dist/components/BarChart/BarChart.d.ts +7 -0
  18. package/dist/components/BarChart/BarChart.js +45 -0
  19. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -0
  20. package/dist/components/Breadcrumbs/Breadcrumbs.js +11 -0
  21. package/dist/components/Button/Button.d.ts +17 -0
  22. package/dist/components/Button/Button.js +23 -0
  23. package/dist/components/Calendar/Calendar.d.ts +21 -0
  24. package/dist/components/Calendar/Calendar.js +144 -0
  25. package/dist/components/Card/Card.d.ts +16 -0
  26. package/dist/components/Card/Card.js +11 -0
  27. package/dist/components/Checkbox/Checkbox.d.ts +12 -0
  28. package/dist/components/Checkbox/Checkbox.js +24 -0
  29. package/dist/components/Code/Code.d.ts +7 -0
  30. package/dist/components/Code/Code.js +6 -0
  31. package/dist/components/CodeBlock/CodeBlock.d.ts +10 -0
  32. package/dist/components/CodeBlock/CodeBlock.js +43 -0
  33. package/dist/components/Combobox/Combobox.d.ts +23 -0
  34. package/dist/components/Combobox/Combobox.js +188 -0
  35. package/dist/components/Combobox/ListPanel.d.ts +16 -0
  36. package/dist/components/Combobox/ListPanel.js +75 -0
  37. package/dist/components/CommandPalette/CommandPalette.d.ts +23 -0
  38. package/dist/components/CommandPalette/CommandPalette.js +86 -0
  39. package/dist/components/Container/Container.d.ts +10 -0
  40. package/dist/components/Container/Container.js +7 -0
  41. package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
  42. package/dist/components/ContextMenu/ContextMenu.js +56 -0
  43. package/dist/components/DatePicker/DatePicker.d.ts +25 -0
  44. package/dist/components/DatePicker/DatePicker.js +198 -0
  45. package/dist/components/DescriptionList/DescriptionList.d.ts +12 -0
  46. package/dist/components/DescriptionList/DescriptionList.js +6 -0
  47. package/dist/components/Dialog/Dialog.d.ts +23 -0
  48. package/dist/components/Dialog/Dialog.js +53 -0
  49. package/dist/components/Divider/Divider.d.ts +6 -0
  50. package/dist/components/Divider/Divider.js +10 -0
  51. package/dist/components/Drawer/Drawer.d.ts +6 -0
  52. package/dist/components/Drawer/Drawer.js +6 -0
  53. package/dist/components/EmptyState/EmptyState.d.ts +11 -0
  54. package/dist/components/EmptyState/EmptyState.js +10 -0
  55. package/dist/components/ErrorSummary/ErrorSummary.d.ts +10 -0
  56. package/dist/components/ErrorSummary/ErrorSummary.js +28 -0
  57. package/dist/components/FaqList/FaqList.d.ts +10 -0
  58. package/dist/components/FaqList/FaqList.js +6 -0
  59. package/dist/components/Field/Field.d.ts +12 -0
  60. package/dist/components/Field/Field.js +25 -0
  61. package/dist/components/Figure/Figure.d.ts +11 -0
  62. package/dist/components/Figure/Figure.js +6 -0
  63. package/dist/components/FileUpload/FileUpload.d.ts +25 -0
  64. package/dist/components/FileUpload/FileUpload.js +47 -0
  65. package/dist/components/Grid/Grid.d.ts +12 -0
  66. package/dist/components/Grid/Grid.js +10 -0
  67. package/dist/components/HatchDivider/HatchDivider.d.ts +2 -0
  68. package/dist/components/HatchDivider/HatchDivider.js +5 -0
  69. package/dist/components/Heading/Heading.d.ts +12 -0
  70. package/dist/components/Heading/Heading.js +11 -0
  71. package/dist/components/Icon/Icon.d.ts +8 -0
  72. package/dist/components/Icon/Icon.js +17 -0
  73. package/dist/components/IconButton/IconButton.d.ts +11 -0
  74. package/dist/components/IconButton/IconButton.js +16 -0
  75. package/dist/components/Inline/Inline.d.ts +13 -0
  76. package/dist/components/Inline/Inline.js +8 -0
  77. package/dist/components/Input/Input.d.ts +10 -0
  78. package/dist/components/Input/Input.js +25 -0
  79. package/dist/components/Kbd/Kbd.d.ts +7 -0
  80. package/dist/components/Kbd/Kbd.js +6 -0
  81. package/dist/components/LineChart/LineChart.d.ts +7 -0
  82. package/dist/components/LineChart/LineChart.js +53 -0
  83. package/dist/components/Link/Link.d.ts +7 -0
  84. package/dist/components/Link/Link.js +12 -0
  85. package/dist/components/LinkProvider/LinkProvider.d.ts +22 -0
  86. package/dist/components/LinkProvider/LinkProvider.js +21 -0
  87. package/dist/components/List/List.d.ts +24 -0
  88. package/dist/components/List/List.js +24 -0
  89. package/dist/components/MediaCard/MediaCard.d.ts +19 -0
  90. package/dist/components/MediaCard/MediaCard.js +25 -0
  91. package/dist/components/Menu/Menu.d.ts +14 -0
  92. package/dist/components/Menu/Menu.js +53 -0
  93. package/dist/components/Menu/entries.d.ts +40 -0
  94. package/dist/components/Menu/entries.js +146 -0
  95. package/dist/components/MultiSelect/MultiSelect.d.ts +24 -0
  96. package/dist/components/MultiSelect/MultiSelect.js +166 -0
  97. package/dist/components/NavList/NavList.d.ts +19 -0
  98. package/dist/components/NavList/NavList.js +10 -0
  99. package/dist/components/NumberInput/NumberInput.d.ts +13 -0
  100. package/dist/components/NumberInput/NumberInput.js +90 -0
  101. package/dist/components/OtpInput/OtpInput.d.ts +19 -0
  102. package/dist/components/OtpInput/OtpInput.js +75 -0
  103. package/dist/components/PageHeader/PageHeader.d.ts +18 -0
  104. package/dist/components/PageHeader/PageHeader.js +11 -0
  105. package/dist/components/Pagination/Pagination.d.ts +15 -0
  106. package/dist/components/Pagination/Pagination.js +22 -0
  107. package/dist/components/PasswordInput/PasswordInput.d.ts +7 -0
  108. package/dist/components/PasswordInput/PasswordInput.js +11 -0
  109. package/dist/components/Popover/Popover.d.ts +18 -0
  110. package/dist/components/Popover/Popover.js +26 -0
  111. package/dist/components/Progress/Progress.d.ts +13 -0
  112. package/dist/components/Progress/Progress.js +24 -0
  113. package/dist/components/Prose/Prose.d.ts +8 -0
  114. package/dist/components/Prose/Prose.js +7 -0
  115. package/dist/components/Quote/Quote.d.ts +10 -0
  116. package/dist/components/Quote/Quote.js +7 -0
  117. package/dist/components/Radio/Radio.d.ts +7 -0
  118. package/dist/components/Radio/Radio.js +9 -0
  119. package/dist/components/RadioGroup/RadioGroup.d.ts +21 -0
  120. package/dist/components/RadioGroup/RadioGroup.js +41 -0
  121. package/dist/components/SearchInput/SearchInput.d.ts +10 -0
  122. package/dist/components/SearchInput/SearchInput.js +39 -0
  123. package/dist/components/SectionHeader/SectionHeader.d.ts +10 -0
  124. package/dist/components/SectionHeader/SectionHeader.js +9 -0
  125. package/dist/components/SegmentedControl/SegmentedControl.d.ts +19 -0
  126. package/dist/components/SegmentedControl/SegmentedControl.js +21 -0
  127. package/dist/components/Select/Select.d.ts +26 -0
  128. package/dist/components/Select/Select.js +262 -0
  129. package/dist/components/Skeleton/Skeleton.d.ts +8 -0
  130. package/dist/components/Skeleton/Skeleton.js +13 -0
  131. package/dist/components/Slider/Slider.d.ts +21 -0
  132. package/dist/components/Slider/Slider.js +43 -0
  133. package/dist/components/Sparkline/Sparkline.d.ts +11 -0
  134. package/dist/components/Sparkline/Sparkline.js +15 -0
  135. package/dist/components/Spinner/Spinner.d.ts +8 -0
  136. package/dist/components/Spinner/Spinner.js +8 -0
  137. package/dist/components/SquareGlyph/SquareGlyph.d.ts +7 -0
  138. package/dist/components/SquareGlyph/SquareGlyph.js +6 -0
  139. package/dist/components/Stack/Stack.d.ts +11 -0
  140. package/dist/components/Stack/Stack.js +8 -0
  141. package/dist/components/Stat/Stat.d.ts +13 -0
  142. package/dist/components/Stat/Stat.js +22 -0
  143. package/dist/components/Steps/Steps.d.ts +13 -0
  144. package/dist/components/Steps/Steps.js +13 -0
  145. package/dist/components/Switch/Switch.d.ts +7 -0
  146. package/dist/components/Switch/Switch.js +16 -0
  147. package/dist/components/Table/Table.d.ts +48 -0
  148. package/dist/components/Table/Table.js +144 -0
  149. package/dist/components/Tabs/Tabs.d.ts +19 -0
  150. package/dist/components/Tabs/Tabs.js +29 -0
  151. package/dist/components/Tag/Tag.d.ts +12 -0
  152. package/dist/components/Tag/Tag.js +8 -0
  153. package/dist/components/Text/Text.d.ts +10 -0
  154. package/dist/components/Text/Text.js +7 -0
  155. package/dist/components/Textarea/Textarea.d.ts +6 -0
  156. package/dist/components/Textarea/Textarea.js +17 -0
  157. package/dist/components/ThemeScript/ThemeScript.d.ts +7 -0
  158. package/dist/components/ThemeScript/ThemeScript.js +9 -0
  159. package/dist/components/TileGrid/TileGrid.d.ts +13 -0
  160. package/dist/components/TileGrid/TileGrid.js +8 -0
  161. package/dist/components/TimePicker/TimePicker.d.ts +28 -0
  162. package/dist/components/TimePicker/TimePicker.js +192 -0
  163. package/dist/components/Timeline/Timeline.d.ts +16 -0
  164. package/dist/components/Timeline/Timeline.js +10 -0
  165. package/dist/components/Toaster/Toaster.d.ts +50 -0
  166. package/dist/components/Toaster/Toaster.js +63 -0
  167. package/dist/components/Tooltip/Tooltip.d.ts +11 -0
  168. package/dist/components/Tooltip/Tooltip.js +21 -0
  169. package/dist/components/TreeView/TreeView.d.ts +30 -0
  170. package/dist/components/TreeView/TreeView.js +127 -0
  171. package/dist/components.css +1798 -0
  172. package/dist/fonts/FONT-NOTICES.txt +20 -0
  173. package/dist/fonts/IBMPlexSans-Latin.woff2 +0 -0
  174. package/dist/fonts/IBMPlexSans-OFL.txt +93 -0
  175. package/dist/fonts/Manrope-Latin.woff2 +0 -0
  176. package/dist/fonts/Manrope-OFL.txt +93 -0
  177. package/dist/fonts/SpaceGrotesk-Latin.woff2 +0 -0
  178. package/dist/fonts/SpaceGrotesk-OFL.txt +93 -0
  179. package/dist/fonts.css +23 -0
  180. package/dist/hooks/useTheme.d.ts +16 -0
  181. package/dist/hooks/useTheme.js +82 -0
  182. package/dist/icons/arrow-down.svg +1 -0
  183. package/dist/icons/arrow-up-right.svg +1 -0
  184. package/dist/icons/arrow-up.svg +1 -0
  185. package/dist/icons/calendar.svg +1 -0
  186. package/dist/icons/chart.svg +1 -0
  187. package/dist/icons/check.svg +1 -0
  188. package/dist/icons/chevron-down.svg +1 -0
  189. package/dist/icons/chevron-left.svg +1 -0
  190. package/dist/icons/chevron-right.svg +1 -0
  191. package/dist/icons/chevrons-up-down.svg +1 -0
  192. package/dist/icons/circle-alert.svg +1 -0
  193. package/dist/icons/circle-check.svg +1 -0
  194. package/dist/icons/clock.svg +1 -0
  195. package/dist/icons/copy.svg +1 -0
  196. package/dist/icons/ellipsis.svg +1 -0
  197. package/dist/icons/file.svg +1 -0
  198. package/dist/icons/folder.svg +1 -0
  199. package/dist/icons/home.svg +1 -0
  200. package/dist/icons/info.svg +1 -0
  201. package/dist/icons/map-pin.svg +1 -0
  202. package/dist/icons/menu.svg +1 -0
  203. package/dist/icons/minus.svg +1 -0
  204. package/dist/icons/pencil.svg +1 -0
  205. package/dist/icons/phone.svg +1 -0
  206. package/dist/icons/plus.svg +1 -0
  207. package/dist/icons/quote.svg +1 -0
  208. package/dist/icons/search.svg +1 -0
  209. package/dist/icons/sidebar.svg +1 -0
  210. package/dist/icons/trash.svg +1 -0
  211. package/dist/icons/triangle-alert.svg +1 -0
  212. package/dist/icons/upload.svg +1 -0
  213. package/dist/icons/users.svg +1 -0
  214. package/dist/icons/x.svg +1 -0
  215. package/dist/index.d.ts +178 -0
  216. package/dist/index.js +93 -0
  217. package/dist/internal/CharCount.d.ts +17 -0
  218. package/dist/internal/CharCount.js +23 -0
  219. package/dist/internal/choice.d.ts +65 -0
  220. package/dist/internal/choice.js +111 -0
  221. package/dist/internal/focusables.d.ts +3 -0
  222. package/dist/internal/focusables.js +8 -0
  223. package/dist/internal/options.d.ts +15 -0
  224. package/dist/internal/options.js +30 -0
  225. package/dist/internal/status.d.ts +6 -0
  226. package/dist/internal/status.js +5 -0
  227. package/dist/internal/useIsoLayoutEffect.d.ts +3 -0
  228. package/dist/internal/useIsoLayoutEffect.js +4 -0
  229. package/dist/internal/useScrollActive.d.ts +3 -0
  230. package/dist/internal/useScrollActive.js +12 -0
  231. package/dist/internal/useUid.d.ts +2 -0
  232. package/dist/internal/useUid.js +6 -0
  233. package/dist/lib/cx.d.ts +2 -0
  234. package/dist/lib/cx.js +4 -0
  235. package/dist/lib/dates.d.ts +10 -0
  236. package/dist/lib/dates.js +107 -0
  237. package/dist/lib/format.d.ts +15 -0
  238. package/dist/lib/format.js +50 -0
  239. package/dist/lib/icons.d.ts +220 -0
  240. package/dist/lib/icons.js +54 -0
  241. package/dist/lib/intl.d.ts +4 -0
  242. package/dist/lib/intl.js +19 -0
  243. package/dist/lib/math.d.ts +5 -0
  244. package/dist/lib/math.js +36 -0
  245. package/dist/lib/omit.d.ts +2 -0
  246. package/dist/lib/omit.js +10 -0
  247. package/dist/lib/space.d.ts +4 -0
  248. package/dist/lib/space.js +9 -0
  249. package/dist/lib/text.d.ts +8 -0
  250. package/dist/lib/text.js +12 -0
  251. package/dist/lib/theme.d.ts +16 -0
  252. package/dist/lib/theme.js +14 -0
  253. package/dist/lib/utils.d.ts +17 -0
  254. package/dist/lib/utils.js +5 -0
  255. package/dist/tailwind.css +110 -0
  256. package/dist/tokens.css +316 -0
  257. package/dist/tokens.dtcg.json +1606 -0
  258. package/dist/tokens.json +1217 -0
  259. package/dist/types.d.ts +67 -0
  260. package/dist/types.js +1 -0
  261. package/dist/vokality.css +2139 -0
  262. package/dist/vokality.iife.js +19408 -0
  263. package/docs/brand.md +163 -0
  264. package/docs/components/Accordion/README.md +24 -0
  265. package/docs/components/Alert/README.md +31 -0
  266. package/docs/components/AppShell/README.md +20 -0
  267. package/docs/components/Avatar/README.md +17 -0
  268. package/docs/components/AvatarGroup/README.md +12 -0
  269. package/docs/components/Badge/README.md +24 -0
  270. package/docs/components/BarChart/README.md +30 -0
  271. package/docs/components/Breadcrumbs/README.md +16 -0
  272. package/docs/components/Button/README.md +43 -0
  273. package/docs/components/Calendar/README.md +43 -0
  274. package/docs/components/Card/README.md +16 -0
  275. package/docs/components/Checkbox/README.md +30 -0
  276. package/docs/components/Code/README.md +9 -0
  277. package/docs/components/CodeBlock/README.md +15 -0
  278. package/docs/components/Combobox/README.md +43 -0
  279. package/docs/components/CommandPalette/README.md +20 -0
  280. package/docs/components/Container/README.md +10 -0
  281. package/docs/components/ContextMenu/README.md +13 -0
  282. package/docs/components/Dashboard/README.md +12 -0
  283. package/docs/components/DatePicker/README.md +34 -0
  284. package/docs/components/DescriptionList/README.md +18 -0
  285. package/docs/components/Dialog/README.md +28 -0
  286. package/docs/components/Divider/README.md +15 -0
  287. package/docs/components/Drawer/README.md +16 -0
  288. package/docs/components/EmptyState/README.md +17 -0
  289. package/docs/components/ErrorPage/README.md +11 -0
  290. package/docs/components/ErrorSummary/README.md +16 -0
  291. package/docs/components/FaqList/README.md +11 -0
  292. package/docs/components/Field/README.md +27 -0
  293. package/docs/components/Figure/README.md +9 -0
  294. package/docs/components/FileUpload/README.md +20 -0
  295. package/docs/components/FormPage/README.md +11 -0
  296. package/docs/components/Grid/README.md +11 -0
  297. package/docs/components/HatchDivider/README.md +10 -0
  298. package/docs/components/Heading/README.md +10 -0
  299. package/docs/components/Icon/README.md +23 -0
  300. package/docs/components/IconButton/README.md +28 -0
  301. package/docs/components/Inline/README.md +9 -0
  302. package/docs/components/Input/README.md +31 -0
  303. package/docs/components/Kbd/README.md +13 -0
  304. package/docs/components/LineChart/README.md +27 -0
  305. package/docs/components/Link/README.md +31 -0
  306. package/docs/components/List/README.md +21 -0
  307. package/docs/components/ListDetail/README.md +11 -0
  308. package/docs/components/MediaCard/README.md +16 -0
  309. package/docs/components/Menu/README.md +45 -0
  310. package/docs/components/MultiSelect/README.md +41 -0
  311. package/docs/components/NavList/README.md +21 -0
  312. package/docs/components/NumberInput/README.md +19 -0
  313. package/docs/components/OtpInput/README.md +17 -0
  314. package/docs/components/PageHeader/README.md +17 -0
  315. package/docs/components/Pagination/README.md +22 -0
  316. package/docs/components/PasswordInput/README.md +13 -0
  317. package/docs/components/Popover/README.md +23 -0
  318. package/docs/components/Progress/README.md +19 -0
  319. package/docs/components/Prose/README.md +12 -0
  320. package/docs/components/Quote/README.md +13 -0
  321. package/docs/components/Radio/README.md +25 -0
  322. package/docs/components/RadioGroup/README.md +23 -0
  323. package/docs/components/SearchInput/README.md +23 -0
  324. package/docs/components/SectionHeader/README.md +14 -0
  325. package/docs/components/SegmentedControl/README.md +19 -0
  326. package/docs/components/Select/README.md +52 -0
  327. package/docs/components/SettingsPage/README.md +11 -0
  328. package/docs/components/SignIn/README.md +11 -0
  329. package/docs/components/Skeleton/README.md +16 -0
  330. package/docs/components/Slider/README.md +22 -0
  331. package/docs/components/Sparkline/README.md +13 -0
  332. package/docs/components/Spinner/README.md +16 -0
  333. package/docs/components/SquareGlyph/README.md +18 -0
  334. package/docs/components/Stack/README.md +11 -0
  335. package/docs/components/Stat/README.md +20 -0
  336. package/docs/components/Steps/README.md +22 -0
  337. package/docs/components/Switch/README.md +27 -0
  338. package/docs/components/Table/README.md +35 -0
  339. package/docs/components/Tabs/README.md +26 -0
  340. package/docs/components/Tag/README.md +21 -0
  341. package/docs/components/Text/README.md +11 -0
  342. package/docs/components/Textarea/README.md +20 -0
  343. package/docs/components/ThemeScript/README.md +47 -0
  344. package/docs/components/TileGrid/README.md +12 -0
  345. package/docs/components/TimePicker/README.md +19 -0
  346. package/docs/components/Timeline/README.md +12 -0
  347. package/docs/components/Toaster/README.md +34 -0
  348. package/docs/components/Tooltip/README.md +23 -0
  349. package/docs/components/TreeView/README.md +15 -0
  350. package/package.json +76 -4
@@ -0,0 +1,144 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { Checkbox } from "../Checkbox/Checkbox.js";
5
+ import { Icon } from "../Icon/Icon.js";
6
+ import { Pagination } from "../Pagination/Pagination.js";
7
+ import { Skeleton } from "../Skeleton/Skeleton.js";
8
+ import { cx } from "../../lib/cx.js";
9
+ /** Reads a row's field by name: columns and `rowKey` address rows by string keys. */
10
+ const field = (row, key) => row[key];
11
+ /** A row's key: rowKey(row), else row[rowKey || "id"], else its index. Keys are strings or numbers by contract. */
12
+ function keyOfRow(rowKey, r, i) {
13
+ if (typeof rowKey === "function")
14
+ return rowKey(r);
15
+ const k = field(r, rowKey || "id");
16
+ return k != null ? k : i;
17
+ }
18
+ /** `rows` in `sort` order, by the column's sortValue or else the field itself. */
19
+ function sortRows(rows, columns, sort) {
20
+ const col = columns.find((c) => c.key === sort.key);
21
+ const get = col?.sortValue || ((r) => field(r, sort.key));
22
+ return rows.slice().sort((a, b) => {
23
+ const x = get(a), y = get(b);
24
+ const cmp = typeof x === "number" && typeof y === "number" ? x - y : String(x).localeCompare(String(y), undefined, { numeric: true });
25
+ return sort.direction === "asc" ? cmp : -cmp;
26
+ });
27
+ }
28
+ /** The sort, controlled by `sort` or kept here; setSort cycles a column through ascending, descending and unsorted. */
29
+ function useTableSort({ sort: sortProp, defaultSort, onSortChange }) {
30
+ const sortControlled = sortProp !== undefined;
31
+ const [sortState, setSortState] = useState(defaultSort || null);
32
+ const sort = sortControlled ? sortProp : sortState;
33
+ const setSort = (key) => {
34
+ const next = !sort || sort.key !== key ? { key, direction: "asc" } : sort.direction === "asc" ? { key, direction: "desc" } : null;
35
+ if (!sortControlled)
36
+ setSortState(next);
37
+ onSortChange?.(next);
38
+ };
39
+ return { sort, setSort };
40
+ }
41
+ /** The selected row keys, controlled by `selected` or kept here. */
42
+ function useTableSelection({ selected: selectedProp, defaultSelected, onSelectionChange }) {
43
+ const selControlled = selectedProp !== undefined;
44
+ const [selState, setSelState] = useState(defaultSelected || []);
45
+ const selected = selControlled ? selectedProp : selState;
46
+ const setSelected = (next) => {
47
+ if (!selControlled)
48
+ setSelState(next);
49
+ onSelectionChange?.(next);
50
+ };
51
+ return { selected, setSelected };
52
+ }
53
+ const ARIA_SORT = { asc: "ascending", desc: "descending" };
54
+ const SORT_ICON = { asc: "arrow-up", desc: "arrow-down" };
55
+ /** Numeric and end-aligned columns line up on the end edge. */
56
+ const alignsEnd = (c) => c.numeric || c.align === "end";
57
+ /** A column header: a sort button with its direction icon when the column is sortable. */
58
+ function TableHeaderCell({ column: c, sort, onSort }) {
59
+ // The active sort direction for this column, if it is the sorted one.
60
+ const dir = sort && sort.key === c.key ? sort.direction : null;
61
+ return (_jsx("th", { scope: "col", style: c.width ? { width: c.width } : undefined, className: cx(alignsEnd(c) && "vk-td-end"), "aria-sort": c.sortable ? (dir ? ARIA_SORT[dir] : "none") : undefined, children: c.sortable ? (_jsxs("button", { type: "button", className: cx("vk-th-sort", dir && "vk-th-sort-active"), onClick: () => onSort(c.key), children: [c.header, _jsx(Icon, { name: dir ? SORT_ICON[dir] : "chevrons-up-down", size: 14, className: "vk-th-sort-icon" })] })) : (c.header) }));
62
+ }
63
+ /** The header row: the details column, the select-all checkbox and the column headers. */
64
+ function TableHead({ columns, sort, onSort, expandable, expandColumnLabel, selectable, selectAllLabel, allKeys, selCount, onSelectAll }) {
65
+ return (_jsxs("tr", { children: [expandable ? (_jsx("th", { className: "vk-td-select", scope: "col", children: _jsx("span", { className: "vk-sr-only", children: expandColumnLabel || "Details" }) })) : null, selectable ? (_jsx("th", { className: "vk-td-select", scope: "col", children: _jsx(Checkbox, { label: selectAllLabel || "Select all rows", hideLabel: true, checked: allKeys.length > 0 && selCount === allKeys.length, indeterminate: selCount > 0 && selCount < allKeys.length, onChange: onSelectAll }) })) : null, columns.map((c) => _jsx(TableHeaderCell, { column: c, sort: sort, onSort: onSort }, c.key))] }));
66
+ }
67
+ /** A row's data cells: the first is the row header unless `rowHeader` is false. */
68
+ function TableCells({ row: r, columns, rowHeader }) {
69
+ return columns.map((c, ci) => {
70
+ const content = c.render ? c.render(r) : field(r, c.key);
71
+ const cls = cx(c.numeric && "vk-td-num", alignsEnd(c) && "vk-td-end", (c.nowrap || c.numeric) && "vk-td-nowrap");
72
+ return ci === 0 && rowHeader !== false ? (_jsx("th", { scope: "row", className: cx("vk-td-rowheader", cls), children: content }, c.key)) : (_jsx("td", { className: cls, children: content }, c.key));
73
+ });
74
+ }
75
+ /** The cell with the button that shows or hides a row's details. */
76
+ function RowToggleCell({ rowKey: k, name, isOpen, onToggle }) {
77
+ return (_jsx("td", { className: "vk-td-select", children: _jsx("button", { type: "button", className: "vk-icon-btn vk-icon-btn-ghost vk-row-toggle", "aria-expanded": isOpen ? "true" : "false", "aria-controls": "vk-row-" + k, "aria-label": (isOpen ? "Hide details for " : "Show details for ") + name, onClick: onToggle, children: _jsx(Icon, { name: "chevron-right", size: 14, className: cx("vk-tree-caret", isOpen && "vk-tree-caret-open") }) }) }));
78
+ }
79
+ /** One record: its details toggle and checkbox, its cells, and its details row when open. */
80
+ function TableRow({ row: r, index: i, rowKey: k, columns, colCount, selectable, isSel, isOpen, rowLabel, rowHeader, renderExpanded, onToggleSelect, onToggleOpen }) {
81
+ const label = rowLabel ? rowLabel(r) : null;
82
+ return (_jsxs(_Fragment, { children: [_jsxs("tr", { "aria-selected": selectable ? String(isSel) : undefined, className: cx(isSel && "vk-tr-selected", isOpen && "vk-tr-open"), children: [renderExpanded ? _jsx(RowToggleCell, { rowKey: k, name: label != null ? label.replace(/^Select /, "") : "row " + (i + 1), isOpen: isOpen, onToggle: onToggleOpen }) : null, selectable ? (_jsx("td", { className: "vk-td-select", children: _jsx(Checkbox, { label: label != null ? label : "Select row " + (i + 1), hideLabel: true, checked: isSel, onChange: onToggleSelect }) })) : null, _jsx(TableCells, { row: r, columns: columns, rowHeader: rowHeader })] }), renderExpanded && isOpen ? (_jsx("tr", { id: "vk-row-" + k, className: "vk-tr-expanded", children: _jsx("td", { colSpan: colCount, children: renderExpanded(r) }) })) : null] }));
83
+ }
84
+ /** Placeholder rows while the data loads. */
85
+ function TableLoadingRows({ rows, colCount }) {
86
+ return Array.from({ length: rows }, (_, li) => (_jsx("tr", { className: "vk-tr-loading", children: Array.from({ length: colCount }, (_, ci) => (_jsx("td", { children: _jsx(Skeleton, { width: ci === 0 ? "70%" : "50%", height: "0.8rem" }) }, ci))) }, "_load" + li)));
87
+ }
88
+ /** The scroll container around the table: a focusable, labelled region when it has a max height. */
89
+ function TableWrap({ maxHeight, caption, density, loading, className, children }) {
90
+ return (_jsx("div", { className: cx("vk-table-wrap", density === "compact" && "vk-table-compact", className), style: maxHeight ? { maxHeight } : undefined, tabIndex: maxHeight ? 0 : undefined, role: maxHeight ? "region" : undefined, "aria-label": maxHeight ? caption : undefined, "aria-busy": loading ? "true" : undefined, children: children }));
91
+ }
92
+ /** The rows on view: sorted unless `manualSort`, then cut to the current page when `pageSize` is set. */
93
+ function useTableView(props, columns) {
94
+ const { sort, setSort } = useTableSort(props);
95
+ const rows = props.rows || [];
96
+ const sorted = sort && !props.manualSort ? sortRows(rows, columns, sort) : rows;
97
+ const pageSize = props.pageSize;
98
+ const [pageState, setPage] = useState(1);
99
+ const pageCount = pageSize ? Math.max(1, Math.ceil(sorted.length / pageSize)) : 1;
100
+ const page = Math.min(pageState, pageCount);
101
+ const view = pageSize ? sorted.slice((page - 1) * pageSize, page * pageSize) : sorted;
102
+ return { sort, setSort, view, page, pageCount, setPage, total: sorted.length };
103
+ }
104
+ /** The pager below a paginated table, with its "1–10 of 42" summary; nothing when everything fits on one page. */
105
+ function TablePager({ page, pageCount, onChange, pageSize, total, summaryFormat }) {
106
+ if (total <= pageSize)
107
+ return null;
108
+ const from = (page - 1) * pageSize + 1;
109
+ const to = Math.min(total, page * pageSize);
110
+ return _jsx(Pagination, { page: page, pageCount: pageCount, onChange: onChange, summary: summaryFormat ? summaryFormat(from, to, total) : from + "–" + to + " of " + total });
111
+ }
112
+ /** The record rows, each with its selection and details state. */
113
+ function TableBodyRows({ view, allKeys, selected, setSelected, expanded, setExpanded, ...rowProps }) {
114
+ const selectedSet = new Set(selected);
115
+ const expandedSet = new Set(expanded);
116
+ return view.map((r, i) => {
117
+ const k = allKeys[i];
118
+ const isSel = selectedSet.has(k);
119
+ const isOpen = expandedSet.has(k);
120
+ return (_jsx(TableRow, { ...rowProps, row: r, index: i, rowKey: k, isSel: isSel, isOpen: isOpen, onToggleSelect: () => setSelected(isSel ? selected.filter((x) => x !== k) : selected.concat([k])), onToggleOpen: () => setExpanded(isOpen ? expanded.filter((x) => x !== k) : expanded.concat([k])) }, k));
121
+ });
122
+ }
123
+ /** A data table for comparing records: sortable columns, row selection, numeric alignment and an empty state. */
124
+ export function Table(props) {
125
+ const { caption, selectable, loading, renderExpanded, pageSize, className } = props;
126
+ const columns = props.columns || [];
127
+ const { sort, setSort, view, page, pageCount, setPage, total } = useTableView(props, columns);
128
+ const { selected, setSelected } = useTableSelection(props);
129
+ const [expanded, setExpanded] = useState(props.defaultExpanded || []);
130
+ const colCount = columns.length + Number(Boolean(selectable)) + Number(Boolean(renderExpanded));
131
+ const allKeys = view.map((r, i) => keyOfRow(props.rowKey, r, i));
132
+ const selectedSet = new Set(selected);
133
+ const selCount = allKeys.filter((k) => selectedSet.has(k)).length;
134
+ let body = _jsx("tr", { children: _jsx("td", { className: "vk-td-empty", colSpan: colCount, children: props.emptyText || "Nothing to show yet." }) });
135
+ if (loading)
136
+ body = _jsx(TableLoadingRows, { rows: props.loadingRows || 5, colCount: colCount });
137
+ else if (view.length) {
138
+ body = (_jsx(TableBodyRows, { view: view, allKeys: allKeys, selected: selected, setSelected: setSelected, expanded: expanded, setExpanded: setExpanded, columns: columns, colCount: colCount, selectable: selectable, rowLabel: props.rowLabel, rowHeader: props.rowHeader, renderExpanded: renderExpanded }));
139
+ }
140
+ const table = (_jsx(TableWrap, { maxHeight: props.maxHeight, caption: caption, density: props.density, loading: loading, className: pageSize ? undefined : className, children: _jsxs("table", { className: "vk-table", children: [caption ? _jsx("caption", { className: props.captionHidden ? "vk-sr-only" : "vk-table-caption", children: caption }) : null, _jsx("thead", { children: _jsx(TableHead, { columns: columns, sort: sort, onSort: setSort, expandable: Boolean(renderExpanded), expandColumnLabel: props.expandColumnLabel, selectable: selectable, selectAllLabel: props.selectAllLabel, allKeys: allKeys, selCount: selCount, onSelectAll: () => setSelected(selCount === allKeys.length ? [] : allKeys) }) }), _jsx("tbody", { children: body })] }) }));
141
+ if (!pageSize)
142
+ return table;
143
+ return (_jsxs("div", { className: cx("vk-table-paged", className), children: [table, _jsx(TablePager, { page: page, pageCount: pageCount, onChange: setPage, pageSize: pageSize, total: total, summaryFormat: props.summaryFormat })] }));
144
+ }
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from "react";
2
+ /** Tabs with automatic activation. */
3
+ export interface TabsProps {
4
+ tabs: {
5
+ id: string;
6
+ label: ReactNode;
7
+ content: ReactNode;
8
+ count?: number | string;
9
+ disabled?: boolean;
10
+ }[];
11
+ value?: string;
12
+ defaultValue?: string;
13
+ onChange?: (id: string) => void;
14
+ label?: string;
15
+ keepMounted?: boolean;
16
+ className?: string;
17
+ }
18
+ /** Tabs with automatic activation (Radix Tabs): arrow keys move focus and selection, wrapping; Home and End jump. */
19
+ export declare function Tabs({ tabs: tabsProp, value: valueProp, defaultValue, onChange, label, keepMounted, className }: TabsProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef, useState } from "react";
4
+ import { Tabs as Primitive } from "radix-ui";
5
+ import { cx } from "../../lib/cx.js";
6
+ /** Tabs with automatic activation (Radix Tabs): arrow keys move focus and selection, wrapping; Home and End jump. */
7
+ export function Tabs({ tabs: tabsProp, value: valueProp, defaultValue, onChange, label, keepMounted, className }) {
8
+ const tabs = tabsProp || [];
9
+ const controlled = valueProp !== undefined;
10
+ const [internal, setInternal] = useState(defaultValue !== undefined ? defaultValue : tabs.length ? tabs[0].id : undefined);
11
+ const value = controlled ? valueProp : internal;
12
+ // A mouse press reports the same tab twice in one event (focus, then press); pass it on once.
13
+ const reported = useRef(null);
14
+ const select = (id) => {
15
+ if (reported.current === id)
16
+ return;
17
+ reported.current = id;
18
+ queueMicrotask(() => { reported.current = null; });
19
+ if (!controlled)
20
+ setInternal(id);
21
+ onChange?.(id);
22
+ };
23
+ return (_jsxs(Primitive.Root, { className: cx("vk-tabs", className), value: value ?? "", onValueChange: select, activationMode: "automatic", children: [_jsx(Primitive.List, { "aria-label": label, className: "vk-tablist", loop: true, children: tabs.map((t) => (_jsxs(Primitive.Trigger, { value: t.id, disabled: t.disabled, className: "vk-tab", "data-tab": t.id, children: [t.label, t.count != null ? _jsx("span", { className: "vk-tab-count", children: t.count }) : null] }, t.id))) }), tabs.map((t) => {
24
+ const selected = t.id === value;
25
+ // Every panel stays in the DOM (hidden when not selected) so each tab's aria-controls resolves;
26
+ // only the selected panel renders its content unless keepMounted.
27
+ return (_jsx(Primitive.Content, { value: t.id, forceMount: true, hidden: !selected, className: "vk-tabpanel", children: selected || keepMounted ? t.content : null }, t.id));
28
+ })] }));
29
+ }
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from "react";
2
+ export interface TagProps {
3
+ children: ReactNode;
4
+ onRemove?: () => void;
5
+ removeLabel?: string;
6
+ className?: string;
7
+ }
8
+ /** Chip for a chosen value or filter, optionally removable. */
9
+ export declare function Tag({ children, onRemove, removeLabel, className, removeTabIndex }: TagProps & {
10
+ /** Internal: MultiSelect keeps its tags' remove buttons out of the tab order. */
11
+ removeTabIndex?: number;
12
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Icon } from "../Icon/Icon.js";
4
+ import { cx } from "../../lib/cx.js";
5
+ /** Chip for a chosen value or filter, optionally removable. */
6
+ export function Tag({ children, onRemove, removeLabel, className, removeTabIndex }) {
7
+ return (_jsxs("span", { className: cx("vk-tag", className), children: [_jsx("span", { className: "vk-tag-label", children: children }), onRemove ? (_jsx("button", { type: "button", className: "vk-tag-remove", tabIndex: removeTabIndex, "aria-label": removeLabel || "Remove " + (typeof children === "string" ? children : ""), onMouseDown: (e) => e.preventDefault(), onClick: onRemove, children: _jsx(Icon, { name: "x", size: 12 }) })) : null] }));
8
+ }
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from "react";
2
+ import type { AsProp } from "../../types.js";
3
+ export interface TextProps extends AsProp {
4
+ size?: string;
5
+ tone?: "muted" | "subtle" | "primary" | "danger" | "success";
6
+ children?: ReactNode;
7
+ className?: string;
8
+ }
9
+ /** Running text in one of the system's text styles and tones. */
10
+ export declare function Text({ as, size, tone, children, className }: TextProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from "../../lib/cx.js";
3
+ /** Running text in one of the system's text styles and tones. */
4
+ export function Text({ as, size, tone, children, className }) {
5
+ const Tag = as || "p";
6
+ return _jsx(Tag, { className: cx("vk-text", "vk-text-" + (size || "body"), tone && "vk-tone-" + tone, className), children: children });
7
+ }
@@ -0,0 +1,6 @@
1
+ import { type TextareaHTMLAttributes } from "react";
2
+ export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
3
+ showCount?: boolean;
4
+ }
5
+ /** Multi-line text control (5 rows, vertical resize). The ref is the <textarea>. */
6
+ export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import { CharCount, useControlledText } from "../../internal/CharCount.js";
5
+ import { cx } from "../../lib/cx.js";
6
+ import { omit } from "../../lib/omit.js";
7
+ /** Multi-line text control (5 rows, vertical resize). The ref is the <textarea>. */
8
+ export const Textarea = forwardRef(function Textarea(props, ref) {
9
+ const txt = useControlledText(props);
10
+ // The counter's limit; 0 when there is no counter (the native maxLength applies instead).
11
+ const countMax = props.showCount && props.maxLength ? props.maxLength : 0;
12
+ const rest = omit(props, ["className", "showCount", "value", "defaultValue", "onChange"]);
13
+ const area = (_jsx("textarea", { rows: 5, ref: ref, ...rest, value: txt.value, onChange: txt.onChange, maxLength: countMax ? undefined : props.maxLength, className: cx("vk-input", "vk-textarea", countMax ? null : props.className) }));
14
+ if (!countMax)
15
+ return area;
16
+ return (_jsxs("span", { className: cx("vk-affix", props.className), children: [area, _jsx(CharCount, { value: txt.value, max: countMax })] }));
17
+ });
@@ -0,0 +1,7 @@
1
+ import { type ThemeOptions } from "../../lib/theme.js";
2
+ export interface ThemeScriptProps extends ThemeOptions {
3
+ /** For a Content-Security-Policy that allows inline scripts by nonce. */
4
+ nonce?: string;
5
+ }
6
+ /** Put in <head>: applies the saved or system theme before first paint, so there is no flash. */
7
+ export declare function ThemeScript(props: ThemeScriptProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // No "use client": ThemeScript has no hooks or browser APIs, so it renders as a
3
+ // React Server Component in a layout. React never runs a <script> created by a
4
+ // client component.
5
+ import { themeScript } from "../../lib/theme.js";
6
+ /** Put in <head>: applies the saved or system theme before first paint, so there is no flash. */
7
+ export function ThemeScript(props) {
8
+ return _jsx("script", { nonce: props.nonce, dangerouslySetInnerHTML: { __html: themeScript(props) } });
9
+ }
@@ -0,0 +1,13 @@
1
+ /** Grid of link tiles between sibling pages; the current one is marked active. */
2
+ export interface TileGridProps {
3
+ heading?: string;
4
+ headingId?: string;
5
+ label?: string;
6
+ items: {
7
+ label: string;
8
+ href: string;
9
+ active?: boolean;
10
+ }[];
11
+ }
12
+ /** Grid of link tiles between sibling pages; the current one is marked active. */
13
+ export declare function TileGrid({ heading, headingId: id, label, items }: TileGridProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Anchor } from "../LinkProvider/LinkProvider.js";
3
+ import { cx } from "../../lib/cx.js";
4
+ /** Grid of link tiles between sibling pages; the current one is marked active. */
5
+ export function TileGrid({ heading, headingId: id, label, items }) {
6
+ const headingId = id || "tiles-heading";
7
+ return (_jsxs("nav", { "aria-labelledby": heading ? headingId : undefined, "aria-label": heading ? undefined : label, children: [heading ? _jsx("h2", { id: headingId, className: "vk-tile-heading", children: heading }) : null, _jsx("ul", { className: "vk-tile-grid", children: (items || []).map((item) => (_jsx("li", { children: _jsx(Anchor, { href: item.href, className: cx("vk-tile", item.active && "vk-tile-active"), "aria-current": item.active ? "page" : undefined, children: _jsx("span", { className: "vk-tile-label", children: item.label }) }) }, item.label))) })] }));
8
+ }
@@ -0,0 +1,28 @@
1
+ /** "HH:MM", 24-hour. */
2
+ export type TimeValue = string;
3
+ export interface TimePickerProps {
4
+ value?: TimeValue | null;
5
+ defaultValue?: TimeValue;
6
+ onChange?: (value: TimeValue | null) => void;
7
+ step?: number;
8
+ min?: TimeValue;
9
+ max?: TimeValue;
10
+ locale?: string;
11
+ placeholder?: string;
12
+ name?: string;
13
+ disabled?: boolean;
14
+ defaultOpen?: boolean;
15
+ invalidMessage?: string;
16
+ id?: string;
17
+ className?: string;
18
+ 'aria-label'?: string;
19
+ 'aria-labelledby'?: string;
20
+ 'aria-describedby'?: string;
21
+ 'aria-invalid'?: boolean;
22
+ }
23
+ /**
24
+ * A time field: type a time or pick one from a list in steps. The list is a
25
+ * Radix Popover anchored to the field; focus stays in the input
26
+ * (aria-activedescendant). The ref goes to the input.
27
+ */
28
+ export declare const TimePicker: import("react").ForwardRefExoticComponent<TimePickerProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,192 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
4
+ import { Popover as Primitive } from "radix-ui";
5
+ import { Icon } from "../Icon/Icon.js";
6
+ import { useUid } from "../../internal/useUid.js";
7
+ import { cx } from "../../lib/cx.js";
8
+ import { formatTime, pad2, parseTime } from "../../lib/dates.js";
9
+ import { resolveLocale } from "../../lib/format.js";
10
+ import { omit } from "../../lib/omit.js";
11
+ /** Every step from `from` to `to`. An unparseable min or max (null) matches no time. */
12
+ function timeOptions(stepMin, from, to, locale) {
13
+ const times = [];
14
+ if (from === null || to === null)
15
+ return times;
16
+ for (let m = 0; m < 1440; m += stepMin) {
17
+ const v = pad2(Math.floor(m / 60)) + ":" + pad2(m % 60);
18
+ if (v >= from && v <= to)
19
+ times.push({ value: v, label: formatTime(v, locale) });
20
+ }
21
+ return times;
22
+ }
23
+ /** Whether a typed time is within min and max (each checked only when given). */
24
+ function allowed(v, props, from, to) {
25
+ return (!props.min || (from !== null && v >= from)) && (!props.max || (to !== null && v <= to));
26
+ }
27
+ /**
28
+ * The value (controlled or not) and the field's text, which shows the value on the locale's
29
+ * clock and is reset whenever the value or the locale changes. commitText parses what was typed.
30
+ */
31
+ function useTimeValue(props, locale, from, to) {
32
+ const valueProp = props.value;
33
+ const controlled = valueProp !== undefined;
34
+ const [uncontrolled, setUncontrolled] = useState(props.defaultValue || null);
35
+ const value = controlled ? valueProp : uncontrolled;
36
+ const [text, setText] = useState(() => formatTime(value, locale));
37
+ const [invalid, setInvalid] = useState(false);
38
+ useEffect(() => {
39
+ setText(formatTime(value, locale));
40
+ }, [value, locale]);
41
+ const commit = (v) => {
42
+ if (!controlled)
43
+ setUncontrolled(v);
44
+ setText(formatTime(v, locale));
45
+ setInvalid(false);
46
+ props.onChange?.(v);
47
+ };
48
+ const commitText = () => {
49
+ if (!text.trim()) {
50
+ commit(null);
51
+ return;
52
+ }
53
+ const v = parseTime(text);
54
+ if (v && allowed(v, props, from, to))
55
+ commit(v);
56
+ else
57
+ setInvalid(true);
58
+ };
59
+ const type = (next) => {
60
+ setText(next);
61
+ setInvalid(false);
62
+ };
63
+ return { value, text, invalid, type, commit, commitText };
64
+ }
65
+ /** The field's aria-invalid, and aria-describedby pointing at the error while the typed time is invalid. */
66
+ function invalidAria(invalid, props, errId) {
67
+ return {
68
+ "aria-invalid": invalid || props["aria-invalid"] ? true : undefined,
69
+ ...(invalid ? { "aria-describedby": cx(props["aria-describedby"], errId) } : null),
70
+ };
71
+ }
72
+ function InvalidTime({ id, message, locale }) {
73
+ return _jsx("span", { id: id, className: "vk-field-error vk-inline-error", children: message || "Enter a time like " + formatTime("14:30", locale) + "." });
74
+ }
75
+ /** The portalled list of times. */
76
+ function TimeList({ listId, label, times, value, open, active, setActive, onPick, rootRef, escaped }) {
77
+ // The list mounts a render after `open` turns true (it is portalled): keep it in state so scrolling waits for it.
78
+ const [list, setList] = useState(null);
79
+ // Keep the active option in view, scrolling only the list.
80
+ useEffect(() => {
81
+ if (!open || !list || active < 0)
82
+ return;
83
+ const el = list.querySelector(`[data-index="${active}"]`);
84
+ if (!el)
85
+ return;
86
+ const top = el.offsetTop, bottom = top + el.offsetHeight;
87
+ if (top < list.scrollTop)
88
+ list.scrollTop = top;
89
+ else if (bottom > list.scrollTop + list.clientHeight)
90
+ list.scrollTop = bottom - list.clientHeight;
91
+ }, [open, list, active]);
92
+ return (_jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { asChild: true, side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8,
93
+ // Focus stays in the input while the list is open, and wherever people moved it after.
94
+ onOpenAutoFocus: (e) => e.preventDefault(), onCloseAutoFocus: (e) => e.preventDefault(), onEscapeKeyDown: () => {
95
+ escaped.current = true;
96
+ }, onInteractOutside: (e) => {
97
+ // Pressing the field keeps the list open.
98
+ if (rootRef.current && rootRef.current.contains(e.target))
99
+ e.preventDefault();
100
+ }, children: _jsx("ul", { ref: setList, id: listId, role: "listbox", "aria-label": label, className: "vk-select-menu vk-time-menu",
101
+ // Keep focus (and the typed text) in the input when pressing the list.
102
+ onMouseDown: (e) => e.preventDefault(), children: times.map((t, i) => (_jsxs("li", { id: listId + "-" + i, "data-index": i, role: "option", "aria-selected": t.value === value ? "true" : "false", className: cx("vk-select-option", i === active && "vk-select-option-active"), onMouseMove: () => {
103
+ if (i !== active)
104
+ setActive(i);
105
+ }, onClick: () => onPick(t.value), children: [_jsx("span", { className: "vk-time-option", children: t.label }), t.value === value ? _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) : null] }, t.value))) }) }) }));
106
+ }
107
+ /**
108
+ * A time field: type a time or pick one from a list in steps. The list is a
109
+ * Radix Popover anchored to the field; focus stays in the input
110
+ * (aria-activedescendant). The ref goes to the input.
111
+ */
112
+ export const TimePicker = forwardRef(function TimePicker(props, ref) {
113
+ const locale = resolveLocale(props.locale);
114
+ const from = parseTime(props.min || "00:00"), to = parseTime(props.max || "23:59");
115
+ const times = timeOptions(props.step || 30, from, to, locale);
116
+ const { value, text, invalid, type, commit, commitText } = useTimeValue(props, locale, from, to);
117
+ const [open, setOpen] = useState(Boolean(props.defaultOpen));
118
+ const [active, setActive] = useState(() => {
119
+ if (!props.defaultOpen)
120
+ return -1;
121
+ const i = times.findIndex((t) => value && t.value >= value);
122
+ return i < 0 ? 0 : i;
123
+ });
124
+ const uid = useUid("vk-time");
125
+ const listId = uid + "-list";
126
+ const rootRef = useRef(null);
127
+ // Set when Radix closes the list on Escape, which happens before the input sees the key.
128
+ const escaped = useRef(false);
129
+ const setInputRef = useCallback((el) => {
130
+ if (typeof ref === "function")
131
+ ref(el);
132
+ else if (ref)
133
+ ref.current = el;
134
+ }, [ref]);
135
+ const nearest = () => {
136
+ if (!value)
137
+ return 0;
138
+ const i = times.findIndex((t) => t.value >= value);
139
+ return i < 0 ? times.length - 1 : i;
140
+ };
141
+ const openList = () => {
142
+ escaped.current = false;
143
+ setOpen(true);
144
+ setActive(nearest());
145
+ };
146
+ const pick = (v) => {
147
+ commit(v);
148
+ setOpen(false);
149
+ };
150
+ const onKeyDown = (e) => {
151
+ if (e.key === "ArrowDown") {
152
+ e.preventDefault();
153
+ if (!open)
154
+ openList();
155
+ else
156
+ setActive(Math.min(times.length - 1, active + 1));
157
+ }
158
+ else if (e.key === "ArrowUp") {
159
+ e.preventDefault();
160
+ if (!open)
161
+ openList();
162
+ else
163
+ setActive(Math.max(0, active - 1));
164
+ }
165
+ else if (e.key === "Enter") {
166
+ e.preventDefault();
167
+ if (open && active >= 0)
168
+ pick(times[active].value);
169
+ else
170
+ commitText();
171
+ }
172
+ else if (e.key === "Escape") {
173
+ if (open || escaped.current) {
174
+ // Closes the list only, not an enclosing dialog.
175
+ e.preventDefault();
176
+ e.stopPropagation();
177
+ setOpen(false);
178
+ }
179
+ escaped.current = false;
180
+ }
181
+ };
182
+ const a11y = omit(props, ["value", "defaultValue", "onChange", "step", "min", "max", "locale", "id", "name", "placeholder", "defaultOpen", "className", "disabled", "invalidMessage"]);
183
+ return (_jsx(Primitive.Root, { open: open, onOpenChange: setOpen, children: _jsxs("div", { ref: rootRef, className: cx("vk-select", "vk-timepicker", props.className), "data-state": open ? "open" : "closed", children: [_jsx(Primitive.Anchor, { asChild: true, children: _jsxs("div", { className: "vk-combobox-field", children: [_jsx("input", { ref: setInputRef, id: props.id || uid, type: "text", role: "combobox", autoComplete: "off", className: "vk-input vk-combobox-input", placeholder: props.placeholder || formatTime("09:30", locale), disabled: props.disabled, value: text, "aria-autocomplete": "none", "aria-expanded": open ? "true" : "false", "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? listId + "-" + active : undefined, onChange: (e) => type(e.target.value), onClick: () => {
184
+ if (!open)
185
+ openList();
186
+ }, onKeyDown: onKeyDown, onBlur: (e) => {
187
+ if (rootRef.current && !rootRef.current.contains(e.relatedTarget)) {
188
+ setOpen(false);
189
+ commitText();
190
+ }
191
+ }, ...a11y, ...invalidAria(invalid, props, uid + "-err") }), _jsx(Icon, { name: "clock", size: 16, className: "vk-select-icon" })] }) }), _jsx(TimeList, { listId: listId, label: props["aria-label"] || "Times", times: times, value: value, open: open, active: active, setActive: setActive, onPick: pick, rootRef: rootRef, escaped: escaped }), invalid ? _jsx(InvalidTime, { id: uid + "-err", message: props.invalidMessage, locale: locale }) : null, props.name ? _jsx("input", { type: "hidden", name: props.name, value: value || "" }) : null] }) }));
192
+ });
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from "react";
2
+ import type { IconName, Status } from "../../types.js";
3
+ export interface TimelineProps {
4
+ items: {
5
+ title: ReactNode;
6
+ description?: ReactNode;
7
+ time?: ReactNode;
8
+ dateTime?: string;
9
+ status?: Status | "primary";
10
+ icon?: IconName;
11
+ }[];
12
+ label?: string;
13
+ className?: string;
14
+ }
15
+ /** A vertical sequence of events: an invoice's history, an audit log, a delivery's progress. */
16
+ export declare function Timeline({ items, label, className }: TimelineProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Icon } from "../Icon/Icon.js";
3
+ import { STATUS_WORD } from "../../internal/status.js";
4
+ import { cx } from "../../lib/cx.js";
5
+ /** A status without a word of its own ("primary") is announced as itself. */
6
+ const STATUS_TEXT = STATUS_WORD;
7
+ /** A vertical sequence of events: an invoice's history, an audit log, a delivery's progress. */
8
+ export function Timeline({ items, label, className }) {
9
+ return (_jsx("ol", { className: cx("vk-timeline", className), "aria-label": label, children: (items || []).map((it, i) => (_jsxs("li", { className: cx("vk-timeline-item", it.status && "vk-timeline-" + it.status), children: [_jsx("span", { className: "vk-timeline-marker", "aria-hidden": "true", children: it.icon ? _jsx(Icon, { name: it.icon, size: 14 }) : null }), _jsxs("div", { className: "vk-timeline-body", children: [_jsxs("p", { className: "vk-timeline-title", children: [it.title, it.status ? _jsx("span", { className: "vk-sr-only", children: " (" + (STATUS_TEXT[it.status] || it.status) + ")" }) : null] }), it.description ? _jsx("div", { className: "vk-timeline-description", children: it.description }) : null, it.time ? _jsx("time", { className: "vk-timeline-time", dateTime: it.dateTime, children: it.time }) : null] })] }, (it.dateTime || (typeof it.title === "string" ? it.title : "")) + "#" + i))) }));
10
+ }
@@ -0,0 +1,50 @@
1
+ import { type ReactNode } from "react";
2
+ import type { Status } from "../../types.js";
3
+ export interface ToasterProps {
4
+ max?: number;
5
+ position?: 'bottom' | 'top'; /** The region's accessible name; `{hotkey}` is replaced with the key that focuses it (F8). */
6
+ label?: string;
7
+ }
8
+ export interface ToastOptions {
9
+ id?: string;
10
+ title: string;
11
+ description?: ReactNode;
12
+ status?: Status;
13
+ action?: {
14
+ label: string;
15
+ onClick?: () => void;
16
+ }; /** ms; 0 keeps it until dismissed. Default 5000, danger 0. */
17
+ duration?: number;
18
+ }
19
+ export interface ToastFn {
20
+ (opts: ToastOptions | string): string;
21
+ info(opts: Omit<ToastOptions, 'status'> | string): string;
22
+ success(opts: Omit<ToastOptions, 'status'> | string): string;
23
+ warning(opts: Omit<ToastOptions, 'status'> | string): string;
24
+ danger(opts: Omit<ToastOptions, 'status'> | string): string;
25
+ dismiss(id?: string): void;
26
+ }
27
+ /** A toast in the store, with its defaults filled in. `key` changes each time the id is shown again. */
28
+ interface ToastRecord extends ToastOptions {
29
+ id: string;
30
+ status: Status;
31
+ duration: number;
32
+ key: number;
33
+ }
34
+ type ToastListener = (items: ToastRecord[]) => void;
35
+ /** Module-level, so toast() works from anywhere; each mounted Toaster subscribes. */
36
+ export declare const toastStore: {
37
+ items: ToastRecord[];
38
+ listeners: ToastListener[];
39
+ seq: number;
40
+ };
41
+ export declare function emitToasts(): void;
42
+ /** Shows a toast and returns its id; toast.dismiss(id) removes it, toast.dismiss() removes all. */
43
+ export declare const toast: ToastFn;
44
+ /** One toast (Radix Toast.Root). Radix runs its timer, pausing it while the pointer or focus is in the stack. */
45
+ export declare function ToastItem({ toast: t }: {
46
+ toast: ToastRecord;
47
+ }): import("react/jsx-runtime").JSX.Element;
48
+ /** Toast stack; render once per app. Radix Toast: F8 focuses the stack, a swipe right dismisses a toast. */
49
+ export declare function Toaster({ max, position, label }: ToasterProps): import("react/jsx-runtime").JSX.Element;
50
+ export {};