@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,24 @@
1
+ import { Fragment as _Fragment, 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
+ /** Rows of records: people, files, notifications, recent items. */
5
+ export function List({ as, children, divided, bordered, label, className }) {
6
+ const Tag = as || "ul";
7
+ return (_jsx(Tag, { className: cx("vk-list", divided !== false && "vk-list-divided", bordered && "vk-list-bordered", className), "aria-label": label, children: children }));
8
+ }
9
+ /** A row's content: the leading element, title and description, and metadata. */
10
+ function ListItemBody({ title, description, meta, leading }) {
11
+ return (_jsxs(_Fragment, { children: [leading ? _jsx("span", { className: "vk-list-leading", children: leading }) : null, _jsxs("span", { className: "vk-list-text", children: [_jsx("span", { className: "vk-list-title", children: title }), description ? _jsx("span", { className: "vk-list-description", children: description }) : null] }), meta ? _jsx("span", { className: "vk-list-meta", children: meta }) : null] }));
12
+ }
13
+ /** A link, a button or static content, in that order of preference. */
14
+ function ListItemMain({ href, onClick, selected, children }) {
15
+ if (href)
16
+ return _jsx(Anchor, { href: href, className: "vk-list-main vk-list-interactive", "aria-current": selected ? "true" : undefined, children: children });
17
+ if (onClick)
18
+ return _jsx("button", { type: "button", className: "vk-list-main vk-list-interactive", "aria-pressed": selected != null ? (selected ? "true" : "false") : undefined, onClick: onClick, children: children });
19
+ return _jsx("div", { className: "vk-list-main", children: children });
20
+ }
21
+ /** One row of a List: a leading element, a title and description, metadata and trailing actions. */
22
+ export function ListItem({ title, description, meta, leading, trailing, href, onClick, selected, className }) {
23
+ return (_jsxs("li", { className: cx("vk-list-item", selected && "vk-list-item-selected", className), children: [_jsx(ListItemMain, { href: href, onClick: onClick, selected: selected, children: _jsx(ListItemBody, { title: title, description: description, meta: meta, leading: leading }) }), trailing ? _jsx("span", { className: "vk-list-trailing", children: trailing }) : null] }));
24
+ }
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from "react";
2
+ /** Image-led card: plain (text under the image) or outlined (one bordered panel). */
3
+ export interface MediaCardProps {
4
+ title: ReactNode;
5
+ image?: string;
6
+ imageAlt?: string;
7
+ /** CSS aspect-ratio of the image box; default "16 / 9". */
8
+ ratio?: string;
9
+ eyebrow?: ReactNode;
10
+ meta?: ReactNode;
11
+ description?: ReactNode;
12
+ badge?: ReactNode;
13
+ href?: string;
14
+ linkLabel?: string;
15
+ variant?: "plain" | "outlined";
16
+ as?: "div" | "li" | "article";
17
+ }
18
+ /** Image-led card: plain (text under the image) or outlined (one bordered panel). */
19
+ export declare function MediaCard({ title, image, imageAlt, ratio, eyebrow, meta, description, badge, href, linkLabel, variant, as }: MediaCardProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Badge } from "../Badge/Badge.js";
3
+ import { Icon } from "../Icon/Icon.js";
4
+ import { Anchor } from "../LinkProvider/LinkProvider.js";
5
+ import { cx } from "../../lib/cx.js";
6
+ import { para } from "../../lib/text.js";
7
+ // The text under the image.
8
+ function MediaCardBody({ title, eyebrow, meta, description, badge, href, linkLabel, outlined }) {
9
+ const Description = para(description);
10
+ return (_jsxs("div", { className: "vk-media-card-body", children: [eyebrow ? _jsx("span", { className: "vk-card-eyebrow", children: eyebrow }) : null, _jsxs("span", { className: cx(outlined ? "vk-card-title" : "vk-media-card-title", "vk-media-title-row"), children: [title, badge ? _jsx(Badge, { children: badge }) : null] }), meta ? _jsx("span", { className: "vk-media-card-meta", children: meta }) : null, description ? (_jsx(Description, { className: outlined ? "vk-card-body" : "vk-media-card-services", children: description })) : null, href && linkLabel ? (_jsxs("span", { className: "vk-media-card-link", children: [_jsx("span", { children: linkLabel }), _jsx(Icon, { name: "arrow-up-right", className: "vk-media-card-arrow" })] })) : null] }));
11
+ }
12
+ // With an href the whole card is one link; external links open in a new tab.
13
+ function MediaCardWrap({ href, children }) {
14
+ if (!href)
15
+ return _jsx("div", { className: "vk-media-card-wrap", children: children });
16
+ const external = /^https?:/.test(href);
17
+ return (_jsx(Anchor, { className: "vk-media-card-wrap", href: href, ...(external ? { target: "_blank", rel: "noopener noreferrer" } : {}), children: children }));
18
+ }
19
+ /** Image-led card: plain (text under the image) or outlined (one bordered panel). */
20
+ export function MediaCard({ title, image, imageAlt, ratio, eyebrow, meta, description, badge, href, linkLabel, variant, as }) {
21
+ const outlined = variant === "outlined";
22
+ const Tag = as || "div";
23
+ const mediaStyle = ratio ? { "--vk-media-ratio": ratio } : undefined;
24
+ return (_jsx(Tag, { className: cx("vk-media-card", outlined && "vk-media-card-outlined"), children: _jsxs(MediaCardWrap, { href: href, children: [_jsx("div", { className: "vk-media-card-media", style: mediaStyle, children: image ? _jsx("img", { className: "vk-media-card-img", src: image, alt: imageAlt || "" }) : null }), _jsx(MediaCardBody, { title: title, eyebrow: eyebrow, meta: meta, description: description, badge: badge, href: href, linkLabel: linkLabel, outlined: outlined })] }) }));
25
+ }
@@ -0,0 +1,14 @@
1
+ import type { IconName, MenuEntry } from "../../types.js";
2
+ export interface MenuProps {
3
+ items: MenuEntry[];
4
+ label?: string;
5
+ icon?: IconName;
6
+ triggerLabel?: string;
7
+ variant?: 'outline' | 'ghost' | 'primary';
8
+ size?: 'sm';
9
+ align?: 'start' | 'end';
10
+ disabled?: boolean;
11
+ className?: string;
12
+ }
13
+ /** Menu button (WAI-ARIA), built on Radix DropdownMenu. */
14
+ export declare function Menu({ items, label, icon, triggerLabel, variant, size, align, disabled, className }: MenuProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef, useState } from "react";
4
+ import { DropdownMenu as Primitive } from "radix-ui";
5
+ import { Icon } from "../Icon/Icon.js";
6
+ import { focusables } from "../../internal/focusables.js";
7
+ import { cx } from "../../lib/cx.js";
8
+ import { MenuEntries, useDeferredSelect, useFocusOnOpen, moveFocusNow } from "./entries.js";
9
+ /** Menu button (WAI-ARIA), built on Radix DropdownMenu. */
10
+ export function Menu({ items, label, icon, triggerLabel, variant, size, align, disabled, className }) {
11
+ const [open, setOpen] = useState(false);
12
+ // Which item takes focus as the menu opens: the last one after ↑ on the trigger, else the first.
13
+ const openWith = useRef("first");
14
+ // Set when Tab closed the menu: focus moves on from the trigger in that direction.
15
+ const tabOut = useRef(0);
16
+ const triggerRef = useRef(null);
17
+ const { defer, flush } = useDeferredSelect();
18
+ const { arm, onFocus } = useFocusOnOpen();
19
+ const onOpenChange = (next) => {
20
+ arm(next ? openWith.current : null);
21
+ setOpen(next);
22
+ };
23
+ // An icon with no label makes an icon button, named by triggerLabel.
24
+ const iconOnly = label ? undefined : icon;
25
+ return (_jsx("div", { className: cx("vk-menu-root", className), children: _jsxs(Primitive.Root, { open: open, onOpenChange: onOpenChange, modal: false, children: [_jsx(Primitive.Trigger, { ref: triggerRef, disabled: disabled, className: iconOnly ? "vk-icon-btn vk-icon-btn-" + (variant || "ghost") : cx("vk-btn", "vk-btn-" + (variant || "outline"), size === "sm" ? "vk-btn-sm" : null), "aria-label": iconOnly ? triggerLabel || "More actions" : undefined, title: iconOnly ? triggerLabel || "More actions" : undefined, onPointerDown: () => { openWith.current = "first"; }, onKeyDown: (e) => {
26
+ openWith.current = "first";
27
+ if (e.key === "ArrowUp" && !disabled) {
28
+ e.preventDefault();
29
+ openWith.current = "last";
30
+ onOpenChange(true);
31
+ }
32
+ }, children: iconOnly
33
+ ? _jsx(Icon, { name: iconOnly })
34
+ : _jsxs(_Fragment, { children: [_jsxs("span", { className: "vk-btn-label", children: [icon ? _jsx(Icon, { name: icon, size: 16, className: "vk-menu-trigger-icon" }) : null, label] }), _jsx("span", { className: "vk-btn-glyph", "aria-hidden": "true", children: _jsx(Icon, { name: "chevron-down", size: 14 }) })] }) }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { className: "vk-menu", side: "bottom", align: align === "end" ? "end" : "start", sideOffset: 4, collisionPadding: 8, loop: true, onFocus: onFocus, onKeyDownCapture: moveFocusNow, onCloseAutoFocus: (e) => {
35
+ const dir = tabOut.current;
36
+ tabOut.current = 0;
37
+ if (dir) {
38
+ // Tab closes the menu and moves on from the trigger, as if focus had stayed there.
39
+ e.preventDefault();
40
+ const trigger = triggerRef.current;
41
+ const list = focusables(document.body);
42
+ const at = trigger ? list.indexOf(trigger) : -1;
43
+ (list[at + dir] || trigger)?.focus();
44
+ }
45
+ flush();
46
+ }, onKeyDown: (e) => {
47
+ if (e.key === "Tab") {
48
+ e.preventDefault();
49
+ tabOut.current = e.shiftKey ? -1 : 1;
50
+ onOpenChange(false);
51
+ }
52
+ }, children: _jsx(MenuEntries, { parts: Primitive, items: items || [], defer: defer }) }) })] }) }));
53
+ }
@@ -0,0 +1,40 @@
1
+ import { type FocusEvent, type KeyboardEvent } from "react";
2
+ import type { DropdownMenu } from "radix-ui";
3
+ import type { MenuEntry } from "../../types.js";
4
+ /** The Radix menu parts the entries are built from: DropdownMenu's or ContextMenu's (same shapes). */
5
+ export type MenuParts = Pick<typeof DropdownMenu, "Item" | "CheckboxItem" | "RadioGroup" | "RadioItem" | "ItemIndicator" | "Separator" | "Label" | "Sub" | "SubTrigger" | "SubContent" | "Portal">;
6
+ interface MenuEntriesProps {
7
+ parts: MenuParts;
8
+ items: MenuEntry[];
9
+ /** Runs a plain item's onSelect once the menu has closed and focus has gone back (see useDeferredSelect). */
10
+ defer: (run: () => void) => void;
11
+ }
12
+ /**
13
+ * Plain items' onSelect runs after the menu has closed and focus is back on the trigger,
14
+ * so an action that opens a dialog captures the trigger as its return focus.
15
+ * `defer` queues the action; call `flush` from the content's onCloseAutoFocus.
16
+ */
17
+ export declare function useDeferredSelect(): {
18
+ defer: (run: () => void) => void;
19
+ flush: () => void;
20
+ };
21
+ /** Focuses the first or last enabled item of a menu, or the menu itself when none can take focus. */
22
+ export declare function focusEdgeItem(content: HTMLElement | null, edge: "first" | "last"): void;
23
+ /**
24
+ * Radix focuses a menu's content as it opens, and only moves on to the first item when it was
25
+ * opened with the keyboard. `arm(edge)` before opening; the content's `onFocus` then moves
26
+ * straight to the first (or last) item, however the menu was opened.
27
+ */
28
+ export declare function useFocusOnOpen(): {
29
+ arm: (which: "first" | "last" | null) => void;
30
+ onFocus: (e: FocusEvent<HTMLDivElement>) => void;
31
+ };
32
+ /**
33
+ * onKeyDownCapture for a menu's content (root or submenu): ↓ ↑ Home End move focus in the same
34
+ * keystroke, wrapping. Radix's roving focus moves it a task later (setTimeout), which lets a
35
+ * key that follows at once act on the old item.
36
+ */
37
+ export declare function moveFocusNow(e: KeyboardEvent<HTMLDivElement>): void;
38
+ /** Renders MenuEntry[] as Radix menu parts: items, checkbox and radio items, submenus, separators and labels. */
39
+ export declare function MenuEntries({ parts: P, items, defer }: MenuEntriesProps): import("react/jsx-runtime").JSX.Element;
40
+ export {};
@@ -0,0 +1,146 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Fragment, useCallback, useId, useRef, useState } from "react";
4
+ import { Icon } from "../Icon/Icon.js";
5
+ import { cx } from "../../lib/cx.js";
6
+ /**
7
+ * Plain items' onSelect runs after the menu has closed and focus is back on the trigger,
8
+ * so an action that opens a dialog captures the trigger as its return focus.
9
+ * `defer` queues the action; call `flush` from the content's onCloseAutoFocus.
10
+ */
11
+ export function useDeferredSelect() {
12
+ const pending = useRef(null);
13
+ const defer = useCallback((run) => { pending.current = run; }, []);
14
+ const flush = useCallback(() => {
15
+ const run = pending.current;
16
+ pending.current = null;
17
+ // After Radix has moved focus back (it does so right after the onCloseAutoFocus handlers).
18
+ if (run)
19
+ queueMicrotask(run);
20
+ }, []);
21
+ return { defer, flush };
22
+ }
23
+ /** Focuses the first or last enabled item of a menu, or the menu itself when none can take focus. */
24
+ export function focusEdgeItem(content, edge) {
25
+ if (!content)
26
+ return;
27
+ const items = Array.from(content.querySelectorAll('[role^="menuitem"]:not([data-disabled])'));
28
+ const target = edge === "last" ? items[items.length - 1] : items[0];
29
+ (target || content).focus({ preventScroll: true });
30
+ }
31
+ /**
32
+ * Radix focuses a menu's content as it opens, and only moves on to the first item when it was
33
+ * opened with the keyboard. `arm(edge)` before opening; the content's `onFocus` then moves
34
+ * straight to the first (or last) item, however the menu was opened.
35
+ */
36
+ export function useFocusOnOpen() {
37
+ const edge = useRef(null);
38
+ const arm = useCallback((which) => { edge.current = which; }, []);
39
+ const onFocus = useCallback((e) => {
40
+ const which = edge.current;
41
+ if (!which || e.target !== e.currentTarget)
42
+ return;
43
+ edge.current = null;
44
+ // Skips Radix's own entry focus (composed after this handler), which would pick the first item.
45
+ e.preventDefault();
46
+ focusEdgeItem(e.currentTarget, which);
47
+ }, []);
48
+ return { arm, onFocus };
49
+ }
50
+ const STEP = { ArrowDown: 1, ArrowUp: -1, Home: "first", End: "last", PageUp: "first", PageDown: "last" };
51
+ /**
52
+ * onKeyDownCapture for a menu's content (root or submenu): ↓ ↑ Home End move focus in the same
53
+ * keystroke, wrapping. Radix's roving focus moves it a task later (setTimeout), which lets a
54
+ * key that follows at once act on the old item.
55
+ */
56
+ export function moveFocusNow(e) {
57
+ const step = STEP[e.key];
58
+ if (step === undefined || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey)
59
+ return;
60
+ const content = e.currentTarget;
61
+ const target = e.target;
62
+ // Keys from a submenu bubble through the React tree (portals included); each level handles its own.
63
+ if (target.closest('[role="menu"]') !== content)
64
+ return;
65
+ const items = Array.from(content.querySelectorAll('[role^="menuitem"]:not([data-disabled])'));
66
+ if (!items.length)
67
+ return;
68
+ const at = items.indexOf(target);
69
+ let next;
70
+ if (step === "first")
71
+ next = items[0];
72
+ else if (step === "last")
73
+ next = items[items.length - 1];
74
+ else if (at < 0)
75
+ next = step === 1 ? items[0] : items[items.length - 1];
76
+ else
77
+ next = items[(at + step + items.length) % items.length];
78
+ // Prevented, so Radix's own (deferred) handlers for the same key stand down.
79
+ e.preventDefault();
80
+ next.focus();
81
+ }
82
+ function Body({ icon, label, shortcut, sub }) {
83
+ return (_jsxs(_Fragment, { children: [icon ? _jsx(Icon, { name: icon, size: 16, className: "vk-menu-item-icon" }) : _jsx("span", { className: "vk-menu-item-icon", "aria-hidden": "true" }), _jsx("span", { className: "vk-menu-item-label", children: label }), shortcut ? _jsx("kbd", { className: "vk-menu-shortcut", children: shortcut }) : null, sub ? _jsx(Icon, { name: "chevron-right", size: 14, className: "vk-menu-sub-icon" }) : null] }));
84
+ }
85
+ /** A submenu. Esc closes just this level and goes back to its item, like ← (Radix would close every level). */
86
+ function SubEntry({ parts: P, entry, items, defer }) {
87
+ const [open, setOpen] = useState(false);
88
+ const triggerRef = useRef(null);
89
+ return (_jsxs(P.Sub, { open: open, onOpenChange: setOpen, children: [_jsx(P.SubTrigger, { ref: triggerRef, className: cx("vk-menu-item", entry.danger ? "vk-menu-item-danger" : null), disabled: entry.disabled, textValue: entry.label, children: _jsx(Body, { icon: entry.icon, label: entry.label, shortcut: entry.shortcut, sub: true }) }), _jsx(P.Portal, { children: _jsx(P.SubContent, { className: "vk-menu vk-menu-sub", sideOffset: -4, alignOffset: -5, collisionPadding: 8, loop: true, onKeyDownCapture: moveFocusNow, onEscapeKeyDown: (e) => { e.preventDefault(); setOpen(false); triggerRef.current?.focus(); }, children: _jsx(MenuEntries, { parts: P, items: items, defer: defer }) }) })] }));
90
+ }
91
+ /** Splits entries into single entries and runs of consecutive radio entries. */
92
+ function segments(items) {
93
+ const out = [];
94
+ items.forEach((it, i) => {
95
+ if (it.type !== "radio") {
96
+ out.push({ at: i, entry: it });
97
+ return;
98
+ }
99
+ const last = out[out.length - 1];
100
+ if (last && "run" in last && last.at + last.run.length === i)
101
+ last.run.push(it);
102
+ else
103
+ out.push({ at: i, run: [it] });
104
+ });
105
+ return out;
106
+ }
107
+ /** Consecutive radio entries as one group; `start` is the first one's index in the menu. */
108
+ function RadioRun({ parts: P, run, start, labelledBy }) {
109
+ const checked = run.findIndex((r) => r.checked);
110
+ return (_jsx(P.RadioGroup, { value: checked >= 0 ? String(start + checked) : "", "aria-labelledby": labelledBy, children: run.map((r, k) => (_jsxs(P.RadioItem, { value: String(start + k), className: "vk-menu-item", disabled: r.disabled, textValue: r.label,
111
+ // Choosing a radio item keeps the menu open.
112
+ onSelect: (e) => { e.preventDefault(); r.onSelect?.(); }, children: [_jsx("span", { className: "vk-menu-item-icon vk-menu-check", "aria-hidden": "true", children: _jsx(P.ItemIndicator, { asChild: true, children: _jsx("span", { className: "vk-choice-dot vk-menu-dot" }) }) }), _jsx("span", { className: "vk-menu-item-label", children: r.label })] }, k + ":" + r.label))) }));
113
+ }
114
+ function CheckboxItem({ parts: P, entry: it }) {
115
+ return (_jsxs(P.CheckboxItem, { className: "vk-menu-item", checked: it.checked, disabled: it.disabled, textValue: it.label,
116
+ // Keeps the menu open; onCheckedChange first, then onSelect (Radix's own onCheckedChange is unused).
117
+ onSelect: (e) => { e.preventDefault(); it.onCheckedChange?.(!it.checked); it.onSelect?.(); }, children: [_jsx("span", { className: "vk-menu-item-icon vk-menu-check", "aria-hidden": "true", children: _jsx(P.ItemIndicator, { className: "vk-menu-indicator", children: _jsx(Icon, { name: "check", size: 16 }) }) }), _jsx("span", { className: "vk-menu-item-label", children: it.label })] }));
118
+ }
119
+ function PlainItem({ parts: P, entry: it, defer }) {
120
+ const onSelect = it.onSelect;
121
+ return (_jsx(P.Item, { className: cx("vk-menu-item", it.danger ? "vk-menu-item-danger" : null), disabled: it.disabled, textValue: it.label, onSelect: () => { if (onSelect)
122
+ defer(() => onSelect()); }, children: _jsx(Body, { icon: it.icon, label: it.label, shortcut: it.shortcut }) }));
123
+ }
124
+ /** Renders MenuEntry[] as Radix menu parts: items, checkbox and radio items, submenus, separators and labels. */
125
+ export function MenuEntries({ parts: P, items, defer }) {
126
+ const uid = useId();
127
+ return (_jsx(Fragment, { children: segments(items).map((s) => {
128
+ const first = items[s.at];
129
+ const key = s.at + ":" + ("label" in first ? first.label : first.type);
130
+ if ("run" in s) {
131
+ // A label right before a radio group names it.
132
+ const prev = items[s.at - 1];
133
+ return _jsx(RadioRun, { parts: P, run: s.run, start: s.at, labelledBy: prev && prev.type === "label" ? uid + "-l" + (s.at - 1) : undefined }, key);
134
+ }
135
+ const it = s.entry;
136
+ if (it.type === "separator")
137
+ return _jsx(P.Separator, { className: "vk-menu-separator" }, key);
138
+ if (it.type === "label")
139
+ return _jsx(P.Label, { id: uid + "-l" + s.at, className: "vk-menu-label", children: it.label }, key);
140
+ if (it.type === "checkbox")
141
+ return _jsx(CheckboxItem, { parts: P, entry: it }, key);
142
+ if (it.items)
143
+ return _jsx(SubEntry, { parts: P, entry: it, items: it.items, defer: defer }, key);
144
+ return _jsx(PlainItem, { parts: P, entry: it, defer: defer }, key);
145
+ }) }));
146
+ }
@@ -0,0 +1,24 @@
1
+ import type { SelectOption } from "../../types.js";
2
+ export interface MultiSelectProps {
3
+ options: (string | SelectOption)[];
4
+ value?: string[];
5
+ defaultValue?: string[];
6
+ onChange?: (values: string[]) => void;
7
+ /** Most that can be chosen. */
8
+ max?: number;
9
+ placeholder?: string;
10
+ /** One hidden input per value, all with this name. */
11
+ name?: string;
12
+ emptyText?: string;
13
+ disabled?: boolean;
14
+ required?: boolean;
15
+ defaultOpen?: boolean;
16
+ id?: string;
17
+ className?: string;
18
+ 'aria-label'?: string;
19
+ 'aria-labelledby'?: string;
20
+ 'aria-describedby'?: string;
21
+ 'aria-invalid'?: boolean;
22
+ }
23
+ /** Pick several options; chosen values show as removable tags, typing filters. The list is a Radix Popover anchored to the field. */
24
+ export declare function MultiSelect(props: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,166 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef, useState } from "react";
4
+ import { Popover } from "radix-ui";
5
+ import { ListPanel } from "../Combobox/ListPanel.js";
6
+ import { Icon } from "../Icon/Icon.js";
7
+ import { Tag } from "../Tag/Tag.js";
8
+ import { highlight, matches, nextEnabled, normalizeOptions } from "../../internal/options.js";
9
+ import { CHECK_PATH } from "../../internal/status.js";
10
+ import { useUid } from "../../internal/useUid.js";
11
+ import { cx } from "../../lib/cx.js";
12
+ import { omit } from "../../lib/omit.js";
13
+ /** The popup, which ListPanel makes the Radix content (so a plain element, not a component): a <ul> listbox of checkable options, or a <div> status when nothing matches. */
14
+ function optionList({ listId, options, values, max, active, setActive, query, onToggle, emptyText, ...labels }) {
15
+ if (!options.length) {
16
+ return (_jsx("div", { id: listId, className: "vk-select-menu vk-select-empty", role: "status", children: emptyText || "No matches for “" + query + "”" }));
17
+ }
18
+ const chosen = new Set(values);
19
+ const atMax = Boolean(max && values.length >= max);
20
+ return (_jsx("ul", { id: listId, role: "listbox", "aria-multiselectable": "true", className: "vk-select-menu", "aria-labelledby": labels["aria-labelledby"], "aria-label": labels["aria-label"], children: options.map((o, i) => {
21
+ const isSel = chosen.has(o.value);
22
+ const blocked = o.disabled || (!isSel && atMax);
23
+ return (_jsxs("li", { id: listId + "-" + i, "data-index": i, role: "option", "aria-selected": isSel ? "true" : "false", "aria-disabled": blocked ? "true" : undefined, className: cx("vk-select-option", "vk-multi-option", i === active && "vk-select-option-active"), onMouseDown: (e) => e.preventDefault(), onMouseMove: () => {
24
+ if (!o.disabled && i !== active)
25
+ setActive(i);
26
+ }, onClick: () => {
27
+ if (!blocked)
28
+ onToggle(o);
29
+ }, children: [_jsx("span", { className: "vk-choice-box vk-multi-box", "aria-hidden": "true", children: _jsx("svg", { className: "vk-choice-mark", viewBox: "0 0 16 16", width: 12, height: 12, fill: "none", children: _jsx("path", { d: CHECK_PATH, stroke: "currentColor", strokeWidth: 2, strokeLinecap: "square" }) }) }), _jsxs("span", { className: "vk-select-option-text", children: [_jsx("span", { children: highlight(o.label, query) }), o.description ? _jsx("span", { className: "vk-select-option-description", children: o.description }) : null] })] }, o.value));
30
+ }) }));
31
+ }
32
+ /** Pick several options; chosen values show as removable tags, typing filters. The list is a Radix Popover anchored to the field. */
33
+ export function MultiSelect(props) {
34
+ const options = normalizeOptions(props.options);
35
+ const base = useUid("vk-multi");
36
+ const inputId = props.id || base + "-input";
37
+ const listId = base + "-list";
38
+ const controlled = props.value !== undefined;
39
+ const [uncontrolledValues, setUncontrolledValues] = useState(props.defaultValue || []);
40
+ const values = controlled ? props.value || [] : uncontrolledValues;
41
+ const [query, setQuery] = useState("");
42
+ const [open, setOpen] = useState(Boolean(props.defaultOpen));
43
+ const [active, setActive] = useState(props.defaultOpen ? 0 : -1);
44
+ const rootRef = useRef(null);
45
+ const inputRef = useRef(null);
46
+ const filtered = options.filter((o) => matches(o, query));
47
+ const close = () => {
48
+ setOpen(false);
49
+ setActive(-1);
50
+ setQuery("");
51
+ };
52
+ const byValue = (v) => {
53
+ for (let i = 0; i < options.length; i++)
54
+ if (options[i].value === v)
55
+ return options[i];
56
+ return { value: v, label: v };
57
+ };
58
+ const setValues = (next) => {
59
+ if (!controlled)
60
+ setUncontrolledValues(next);
61
+ props.onChange?.(next);
62
+ };
63
+ const toggle = (o) => {
64
+ if (!o || o.disabled)
65
+ return;
66
+ const has = values.indexOf(o.value) >= 0;
67
+ if (!has && props.max && values.length >= props.max)
68
+ return;
69
+ setValues(has ? values.filter((v) => v !== o.value) : values.concat([o.value]));
70
+ };
71
+ const remove = (v) => {
72
+ setValues(values.filter((x) => x !== v));
73
+ inputRef.current?.focus();
74
+ };
75
+ const openAt = (i) => {
76
+ if (props.disabled)
77
+ return;
78
+ setOpen(true);
79
+ setActive(i);
80
+ };
81
+ const onKeyDown = (e) => {
82
+ const key = e.key;
83
+ if (key === "ArrowDown") {
84
+ e.preventDefault();
85
+ if (!open)
86
+ return openAt(nextEnabled(filtered, 0, 1));
87
+ const n = nextEnabled(filtered, active + 1, 1);
88
+ if (n >= 0)
89
+ setActive(n);
90
+ }
91
+ else if (key === "ArrowUp") {
92
+ e.preventDefault();
93
+ if (!open)
94
+ return openAt(nextEnabled(filtered, filtered.length - 1, -1));
95
+ const p = nextEnabled(filtered, active - 1, -1);
96
+ if (p >= 0)
97
+ setActive(p);
98
+ }
99
+ else if (key === "Enter" || (key === " " && !query)) {
100
+ if (open && active >= 0) {
101
+ e.preventDefault();
102
+ toggle(filtered[active]);
103
+ }
104
+ else if (key === "Enter" && !open) {
105
+ e.preventDefault();
106
+ openAt(nextEnabled(filtered, 0, 1));
107
+ }
108
+ }
109
+ else if (key === "Escape") {
110
+ if (open) {
111
+ e.preventDefault();
112
+ close();
113
+ }
114
+ else if (query) {
115
+ e.preventDefault();
116
+ setQuery("");
117
+ }
118
+ }
119
+ else if (key === "Backspace" && !query && values.length) {
120
+ remove(values[values.length - 1]);
121
+ }
122
+ else if (key === "Tab") {
123
+ close();
124
+ }
125
+ };
126
+ const a11y = omit(props, ["options", "placeholder", "className", "value", "defaultValue", "onChange", "disabled", "name", "id", "defaultOpen", "emptyText", "max", "required"]);
127
+ return (_jsx(Popover.Root, { open: open, onOpenChange: (next) => {
128
+ // A press outside, or Escape from outside the field.
129
+ if (!next)
130
+ close();
131
+ }, children: _jsxs("div", { ref: rootRef, className: cx("vk-select", "vk-multiselect", open && "vk-select-open", props.disabled && "vk-multiselect-disabled", props.className), children: [_jsx(Popover.Anchor, { asChild: true, children: _jsxs("div", {
132
+ // The box around the tags and the combobox input: a press anywhere in it focuses the
133
+ // input (which carries the role and keyboard support), so the box itself is presentational.
134
+ role: "presentation", className: "vk-input vk-multiselect-field", "aria-invalid": props["aria-invalid"], onMouseDown: (e) => {
135
+ if (props.disabled)
136
+ return;
137
+ if (e.target !== inputRef.current)
138
+ e.preventDefault();
139
+ inputRef.current?.focus();
140
+ if (!open)
141
+ openAt(nextEnabled(filtered, 0, 1));
142
+ }, children: [values.map((v) => {
143
+ const o = byValue(v);
144
+ return (_jsx(Tag, { removeTabIndex: -1, removeLabel: "Remove " + o.label, onRemove: props.disabled ? undefined : () => remove(v), children: o.label }, v));
145
+ }), _jsx("input", { ref: inputRef, id: inputId, type: "text", role: "combobox", autoComplete: "off", spellCheck: false, className: cx("vk-multiselect-input", values.length > 0 && "vk-multiselect-input-compact"), placeholder: values.length ? "" : props.placeholder, disabled: props.disabled, "aria-autocomplete": "list", "aria-expanded": open ? "true" : "false", "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? listId + "-" + active : undefined, "aria-required": props.required ? "true" : undefined, value: query, onChange: (e) => {
146
+ const v = e.target.value;
147
+ setQuery(v);
148
+ const list = options.filter((o) => matches(o, v));
149
+ openAt(nextEnabled(list, 0, 1));
150
+ }, onKeyDown: onKeyDown, onBlur: (e) => {
151
+ if (rootRef.current && !rootRef.current.contains(e.relatedTarget))
152
+ close();
153
+ }, ...a11y }), _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" })] }) }), _jsx(ListPanel, { rootRef: rootRef, active: active, children: optionList({
154
+ listId,
155
+ options: filtered,
156
+ values,
157
+ max: props.max,
158
+ active,
159
+ setActive,
160
+ query,
161
+ onToggle: toggle,
162
+ emptyText: props.emptyText,
163
+ "aria-label": props["aria-label"],
164
+ "aria-labelledby": props["aria-labelledby"],
165
+ }) }), props.name ? values.map((v) => _jsx("input", { type: "hidden", name: props.name, value: v }, v)) : null] }) }));
166
+ }
@@ -0,0 +1,19 @@
1
+ import type { IconName } from "../../types.js";
2
+ export interface NavItem {
3
+ label: string;
4
+ href: string;
5
+ icon?: IconName;
6
+ active?: boolean;
7
+ count?: number | string;
8
+ }
9
+ export interface NavListProps {
10
+ items?: NavItem[];
11
+ sections?: {
12
+ heading?: string;
13
+ items: NavItem[];
14
+ }[];
15
+ label?: string;
16
+ className?: string;
17
+ }
18
+ /** The vertical navigation for an app's sidebar: sections of links with icons, counts and the current page marked. */
19
+ export declare function NavList({ items, sections, label, className }: NavListProps): 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 { Anchor } from "../LinkProvider/LinkProvider.js";
4
+ import { cx } from "../../lib/cx.js";
5
+ /** The vertical navigation for an app's sidebar: sections of links with icons, counts and the current page marked. */
6
+ export function NavList({ items, sections, label, className }) {
7
+ // Without sections, `items` render as one untitled section.
8
+ const groups = sections || [{ items }];
9
+ return (_jsx("nav", { "aria-label": label, className: cx("vk-navlist", className), children: groups.map((sec, si) => (_jsxs("div", { className: "vk-navlist-section", children: [sec.heading ? _jsx("p", { className: "vk-navlist-heading", children: sec.heading }) : null, _jsx("ul", { children: (sec.items || []).map((it) => (_jsx("li", { children: _jsxs(Anchor, { href: it.href, className: cx("vk-navlist-item", it.active && "vk-navlist-item-active"), "aria-current": it.active ? "page" : undefined, children: [it.icon ? _jsx(Icon, { name: it.icon, size: 16, className: "vk-navlist-icon" }) : null, _jsx("span", { className: "vk-navlist-label", children: it.label }), it.count != null ? _jsx("span", { className: "vk-navlist-count", children: it.count }) : null] }) }, it.label))) })] }, si))) }));
10
+ }
@@ -0,0 +1,13 @@
1
+ import { type InputProps } from "../Input/Input.js";
2
+ export interface NumberInputProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'min' | 'max' | 'step'> {
3
+ value?: number | null;
4
+ defaultValue?: number | null;
5
+ onChange?: (value: number | null) => void;
6
+ min?: number;
7
+ max?: number;
8
+ step?: number;
9
+ decrementLabel?: string;
10
+ incrementLabel?: string;
11
+ }
12
+ /** Field for whole or decimal numbers, with − and + buttons and arrow-key steps. The ref is the <input>. */
13
+ export declare const NumberInput: import("react").ForwardRefExoticComponent<NumberInputProps & import("react").RefAttributes<HTMLInputElement>>;