@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.
- package/CHANGELOG.md +92 -0
- package/README.md +134 -2
- package/dist/charts/chart.d.ts +52 -0
- package/dist/charts/chart.js +108 -0
- package/dist/components/Accordion/Accordion.d.ts +15 -0
- package/dist/components/Accordion/Accordion.js +16 -0
- package/dist/components/Alert/Alert.d.ts +14 -0
- package/dist/components/Alert/Alert.js +12 -0
- package/dist/components/AppShell/AppShell.d.ts +21 -0
- package/dist/components/AppShell/AppShell.js +48 -0
- package/dist/components/Avatar/Avatar.d.ts +11 -0
- package/dist/components/Avatar/Avatar.js +19 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +11 -0
- package/dist/components/AvatarGroup/AvatarGroup.js +13 -0
- package/dist/components/Badge/Badge.d.ts +9 -0
- package/dist/components/Badge/Badge.js +6 -0
- package/dist/components/BarChart/BarChart.d.ts +7 -0
- package/dist/components/BarChart/BarChart.js +45 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +11 -0
- package/dist/components/Button/Button.d.ts +17 -0
- package/dist/components/Button/Button.js +23 -0
- package/dist/components/Calendar/Calendar.d.ts +21 -0
- package/dist/components/Calendar/Calendar.js +144 -0
- package/dist/components/Card/Card.d.ts +16 -0
- package/dist/components/Card/Card.js +11 -0
- package/dist/components/Checkbox/Checkbox.d.ts +12 -0
- package/dist/components/Checkbox/Checkbox.js +24 -0
- package/dist/components/Code/Code.d.ts +7 -0
- package/dist/components/Code/Code.js +6 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +10 -0
- package/dist/components/CodeBlock/CodeBlock.js +43 -0
- package/dist/components/Combobox/Combobox.d.ts +23 -0
- package/dist/components/Combobox/Combobox.js +188 -0
- package/dist/components/Combobox/ListPanel.d.ts +16 -0
- package/dist/components/Combobox/ListPanel.js +75 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +23 -0
- package/dist/components/CommandPalette/CommandPalette.js +86 -0
- package/dist/components/Container/Container.d.ts +10 -0
- package/dist/components/Container/Container.js +7 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
- package/dist/components/ContextMenu/ContextMenu.js +56 -0
- package/dist/components/DatePicker/DatePicker.d.ts +25 -0
- package/dist/components/DatePicker/DatePicker.js +198 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +12 -0
- package/dist/components/DescriptionList/DescriptionList.js +6 -0
- package/dist/components/Dialog/Dialog.d.ts +23 -0
- package/dist/components/Dialog/Dialog.js +53 -0
- package/dist/components/Divider/Divider.d.ts +6 -0
- package/dist/components/Divider/Divider.js +10 -0
- package/dist/components/Drawer/Drawer.d.ts +6 -0
- package/dist/components/Drawer/Drawer.js +6 -0
- package/dist/components/EmptyState/EmptyState.d.ts +11 -0
- package/dist/components/EmptyState/EmptyState.js +10 -0
- package/dist/components/ErrorSummary/ErrorSummary.d.ts +10 -0
- package/dist/components/ErrorSummary/ErrorSummary.js +28 -0
- package/dist/components/FaqList/FaqList.d.ts +10 -0
- package/dist/components/FaqList/FaqList.js +6 -0
- package/dist/components/Field/Field.d.ts +12 -0
- package/dist/components/Field/Field.js +25 -0
- package/dist/components/Figure/Figure.d.ts +11 -0
- package/dist/components/Figure/Figure.js +6 -0
- package/dist/components/FileUpload/FileUpload.d.ts +25 -0
- package/dist/components/FileUpload/FileUpload.js +47 -0
- package/dist/components/Grid/Grid.d.ts +12 -0
- package/dist/components/Grid/Grid.js +10 -0
- package/dist/components/HatchDivider/HatchDivider.d.ts +2 -0
- package/dist/components/HatchDivider/HatchDivider.js +5 -0
- package/dist/components/Heading/Heading.d.ts +12 -0
- package/dist/components/Heading/Heading.js +11 -0
- package/dist/components/Icon/Icon.d.ts +8 -0
- package/dist/components/Icon/Icon.js +17 -0
- package/dist/components/IconButton/IconButton.d.ts +11 -0
- package/dist/components/IconButton/IconButton.js +16 -0
- package/dist/components/Inline/Inline.d.ts +13 -0
- package/dist/components/Inline/Inline.js +8 -0
- package/dist/components/Input/Input.d.ts +10 -0
- package/dist/components/Input/Input.js +25 -0
- package/dist/components/Kbd/Kbd.d.ts +7 -0
- package/dist/components/Kbd/Kbd.js +6 -0
- package/dist/components/LineChart/LineChart.d.ts +7 -0
- package/dist/components/LineChart/LineChart.js +53 -0
- package/dist/components/Link/Link.d.ts +7 -0
- package/dist/components/Link/Link.js +12 -0
- package/dist/components/LinkProvider/LinkProvider.d.ts +22 -0
- package/dist/components/LinkProvider/LinkProvider.js +21 -0
- package/dist/components/List/List.d.ts +24 -0
- package/dist/components/List/List.js +24 -0
- package/dist/components/MediaCard/MediaCard.d.ts +19 -0
- package/dist/components/MediaCard/MediaCard.js +25 -0
- package/dist/components/Menu/Menu.d.ts +14 -0
- package/dist/components/Menu/Menu.js +53 -0
- package/dist/components/Menu/entries.d.ts +40 -0
- package/dist/components/Menu/entries.js +146 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +24 -0
- package/dist/components/MultiSelect/MultiSelect.js +166 -0
- package/dist/components/NavList/NavList.d.ts +19 -0
- package/dist/components/NavList/NavList.js +10 -0
- package/dist/components/NumberInput/NumberInput.d.ts +13 -0
- package/dist/components/NumberInput/NumberInput.js +90 -0
- package/dist/components/OtpInput/OtpInput.d.ts +19 -0
- package/dist/components/OtpInput/OtpInput.js +75 -0
- package/dist/components/PageHeader/PageHeader.d.ts +18 -0
- package/dist/components/PageHeader/PageHeader.js +11 -0
- package/dist/components/Pagination/Pagination.d.ts +15 -0
- package/dist/components/Pagination/Pagination.js +22 -0
- package/dist/components/PasswordInput/PasswordInput.d.ts +7 -0
- package/dist/components/PasswordInput/PasswordInput.js +11 -0
- package/dist/components/Popover/Popover.d.ts +18 -0
- package/dist/components/Popover/Popover.js +26 -0
- package/dist/components/Progress/Progress.d.ts +13 -0
- package/dist/components/Progress/Progress.js +24 -0
- package/dist/components/Prose/Prose.d.ts +8 -0
- package/dist/components/Prose/Prose.js +7 -0
- package/dist/components/Quote/Quote.d.ts +10 -0
- package/dist/components/Quote/Quote.js +7 -0
- package/dist/components/Radio/Radio.d.ts +7 -0
- package/dist/components/Radio/Radio.js +9 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +21 -0
- package/dist/components/RadioGroup/RadioGroup.js +41 -0
- package/dist/components/SearchInput/SearchInput.d.ts +10 -0
- package/dist/components/SearchInput/SearchInput.js +39 -0
- package/dist/components/SectionHeader/SectionHeader.d.ts +10 -0
- package/dist/components/SectionHeader/SectionHeader.js +9 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +19 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +21 -0
- package/dist/components/Select/Select.d.ts +26 -0
- package/dist/components/Select/Select.js +262 -0
- package/dist/components/Skeleton/Skeleton.d.ts +8 -0
- package/dist/components/Skeleton/Skeleton.js +13 -0
- package/dist/components/Slider/Slider.d.ts +21 -0
- package/dist/components/Slider/Slider.js +43 -0
- package/dist/components/Sparkline/Sparkline.d.ts +11 -0
- package/dist/components/Sparkline/Sparkline.js +15 -0
- package/dist/components/Spinner/Spinner.d.ts +8 -0
- package/dist/components/Spinner/Spinner.js +8 -0
- package/dist/components/SquareGlyph/SquareGlyph.d.ts +7 -0
- package/dist/components/SquareGlyph/SquareGlyph.js +6 -0
- package/dist/components/Stack/Stack.d.ts +11 -0
- package/dist/components/Stack/Stack.js +8 -0
- package/dist/components/Stat/Stat.d.ts +13 -0
- package/dist/components/Stat/Stat.js +22 -0
- package/dist/components/Steps/Steps.d.ts +13 -0
- package/dist/components/Steps/Steps.js +13 -0
- package/dist/components/Switch/Switch.d.ts +7 -0
- package/dist/components/Switch/Switch.js +16 -0
- package/dist/components/Table/Table.d.ts +48 -0
- package/dist/components/Table/Table.js +144 -0
- package/dist/components/Tabs/Tabs.d.ts +19 -0
- package/dist/components/Tabs/Tabs.js +29 -0
- package/dist/components/Tag/Tag.d.ts +12 -0
- package/dist/components/Tag/Tag.js +8 -0
- package/dist/components/Text/Text.d.ts +10 -0
- package/dist/components/Text/Text.js +7 -0
- package/dist/components/Textarea/Textarea.d.ts +6 -0
- package/dist/components/Textarea/Textarea.js +17 -0
- package/dist/components/ThemeScript/ThemeScript.d.ts +7 -0
- package/dist/components/ThemeScript/ThemeScript.js +9 -0
- package/dist/components/TileGrid/TileGrid.d.ts +13 -0
- package/dist/components/TileGrid/TileGrid.js +8 -0
- package/dist/components/TimePicker/TimePicker.d.ts +28 -0
- package/dist/components/TimePicker/TimePicker.js +192 -0
- package/dist/components/Timeline/Timeline.d.ts +16 -0
- package/dist/components/Timeline/Timeline.js +10 -0
- package/dist/components/Toaster/Toaster.d.ts +50 -0
- package/dist/components/Toaster/Toaster.js +63 -0
- package/dist/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/components/Tooltip/Tooltip.js +21 -0
- package/dist/components/TreeView/TreeView.d.ts +30 -0
- package/dist/components/TreeView/TreeView.js +127 -0
- package/dist/components.css +1798 -0
- package/dist/fonts/FONT-NOTICES.txt +20 -0
- package/dist/fonts/IBMPlexSans-Latin.woff2 +0 -0
- package/dist/fonts/IBMPlexSans-OFL.txt +93 -0
- package/dist/fonts/Manrope-Latin.woff2 +0 -0
- package/dist/fonts/Manrope-OFL.txt +93 -0
- package/dist/fonts/SpaceGrotesk-Latin.woff2 +0 -0
- package/dist/fonts/SpaceGrotesk-OFL.txt +93 -0
- package/dist/fonts.css +23 -0
- package/dist/hooks/useTheme.d.ts +16 -0
- package/dist/hooks/useTheme.js +82 -0
- package/dist/icons/arrow-down.svg +1 -0
- package/dist/icons/arrow-up-right.svg +1 -0
- package/dist/icons/arrow-up.svg +1 -0
- package/dist/icons/calendar.svg +1 -0
- package/dist/icons/chart.svg +1 -0
- package/dist/icons/check.svg +1 -0
- package/dist/icons/chevron-down.svg +1 -0
- package/dist/icons/chevron-left.svg +1 -0
- package/dist/icons/chevron-right.svg +1 -0
- package/dist/icons/chevrons-up-down.svg +1 -0
- package/dist/icons/circle-alert.svg +1 -0
- package/dist/icons/circle-check.svg +1 -0
- package/dist/icons/clock.svg +1 -0
- package/dist/icons/copy.svg +1 -0
- package/dist/icons/ellipsis.svg +1 -0
- package/dist/icons/file.svg +1 -0
- package/dist/icons/folder.svg +1 -0
- package/dist/icons/home.svg +1 -0
- package/dist/icons/info.svg +1 -0
- package/dist/icons/map-pin.svg +1 -0
- package/dist/icons/menu.svg +1 -0
- package/dist/icons/minus.svg +1 -0
- package/dist/icons/pencil.svg +1 -0
- package/dist/icons/phone.svg +1 -0
- package/dist/icons/plus.svg +1 -0
- package/dist/icons/quote.svg +1 -0
- package/dist/icons/search.svg +1 -0
- package/dist/icons/sidebar.svg +1 -0
- package/dist/icons/trash.svg +1 -0
- package/dist/icons/triangle-alert.svg +1 -0
- package/dist/icons/upload.svg +1 -0
- package/dist/icons/users.svg +1 -0
- package/dist/icons/x.svg +1 -0
- package/dist/index.d.ts +178 -0
- package/dist/index.js +93 -0
- package/dist/internal/CharCount.d.ts +17 -0
- package/dist/internal/CharCount.js +23 -0
- package/dist/internal/choice.d.ts +65 -0
- package/dist/internal/choice.js +111 -0
- package/dist/internal/focusables.d.ts +3 -0
- package/dist/internal/focusables.js +8 -0
- package/dist/internal/options.d.ts +15 -0
- package/dist/internal/options.js +30 -0
- package/dist/internal/status.d.ts +6 -0
- package/dist/internal/status.js +5 -0
- package/dist/internal/useIsoLayoutEffect.d.ts +3 -0
- package/dist/internal/useIsoLayoutEffect.js +4 -0
- package/dist/internal/useScrollActive.d.ts +3 -0
- package/dist/internal/useScrollActive.js +12 -0
- package/dist/internal/useUid.d.ts +2 -0
- package/dist/internal/useUid.js +6 -0
- package/dist/lib/cx.d.ts +2 -0
- package/dist/lib/cx.js +4 -0
- package/dist/lib/dates.d.ts +10 -0
- package/dist/lib/dates.js +107 -0
- package/dist/lib/format.d.ts +15 -0
- package/dist/lib/format.js +50 -0
- package/dist/lib/icons.d.ts +220 -0
- package/dist/lib/icons.js +54 -0
- package/dist/lib/intl.d.ts +4 -0
- package/dist/lib/intl.js +19 -0
- package/dist/lib/math.d.ts +5 -0
- package/dist/lib/math.js +36 -0
- package/dist/lib/omit.d.ts +2 -0
- package/dist/lib/omit.js +10 -0
- package/dist/lib/space.d.ts +4 -0
- package/dist/lib/space.js +9 -0
- package/dist/lib/text.d.ts +8 -0
- package/dist/lib/text.js +12 -0
- package/dist/lib/theme.d.ts +16 -0
- package/dist/lib/theme.js +14 -0
- package/dist/lib/utils.d.ts +17 -0
- package/dist/lib/utils.js +5 -0
- package/dist/tailwind.css +110 -0
- package/dist/tokens.css +316 -0
- package/dist/tokens.dtcg.json +1606 -0
- package/dist/tokens.json +1217 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.js +1 -0
- package/dist/vokality.css +2139 -0
- package/dist/vokality.iife.js +19408 -0
- package/docs/brand.md +163 -0
- package/docs/components/Accordion/README.md +24 -0
- package/docs/components/Alert/README.md +31 -0
- package/docs/components/AppShell/README.md +20 -0
- package/docs/components/Avatar/README.md +17 -0
- package/docs/components/AvatarGroup/README.md +12 -0
- package/docs/components/Badge/README.md +24 -0
- package/docs/components/BarChart/README.md +30 -0
- package/docs/components/Breadcrumbs/README.md +16 -0
- package/docs/components/Button/README.md +43 -0
- package/docs/components/Calendar/README.md +43 -0
- package/docs/components/Card/README.md +16 -0
- package/docs/components/Checkbox/README.md +30 -0
- package/docs/components/Code/README.md +9 -0
- package/docs/components/CodeBlock/README.md +15 -0
- package/docs/components/Combobox/README.md +43 -0
- package/docs/components/CommandPalette/README.md +20 -0
- package/docs/components/Container/README.md +10 -0
- package/docs/components/ContextMenu/README.md +13 -0
- package/docs/components/Dashboard/README.md +12 -0
- package/docs/components/DatePicker/README.md +34 -0
- package/docs/components/DescriptionList/README.md +18 -0
- package/docs/components/Dialog/README.md +28 -0
- package/docs/components/Divider/README.md +15 -0
- package/docs/components/Drawer/README.md +16 -0
- package/docs/components/EmptyState/README.md +17 -0
- package/docs/components/ErrorPage/README.md +11 -0
- package/docs/components/ErrorSummary/README.md +16 -0
- package/docs/components/FaqList/README.md +11 -0
- package/docs/components/Field/README.md +27 -0
- package/docs/components/Figure/README.md +9 -0
- package/docs/components/FileUpload/README.md +20 -0
- package/docs/components/FormPage/README.md +11 -0
- package/docs/components/Grid/README.md +11 -0
- package/docs/components/HatchDivider/README.md +10 -0
- package/docs/components/Heading/README.md +10 -0
- package/docs/components/Icon/README.md +23 -0
- package/docs/components/IconButton/README.md +28 -0
- package/docs/components/Inline/README.md +9 -0
- package/docs/components/Input/README.md +31 -0
- package/docs/components/Kbd/README.md +13 -0
- package/docs/components/LineChart/README.md +27 -0
- package/docs/components/Link/README.md +31 -0
- package/docs/components/List/README.md +21 -0
- package/docs/components/ListDetail/README.md +11 -0
- package/docs/components/MediaCard/README.md +16 -0
- package/docs/components/Menu/README.md +45 -0
- package/docs/components/MultiSelect/README.md +41 -0
- package/docs/components/NavList/README.md +21 -0
- package/docs/components/NumberInput/README.md +19 -0
- package/docs/components/OtpInput/README.md +17 -0
- package/docs/components/PageHeader/README.md +17 -0
- package/docs/components/Pagination/README.md +22 -0
- package/docs/components/PasswordInput/README.md +13 -0
- package/docs/components/Popover/README.md +23 -0
- package/docs/components/Progress/README.md +19 -0
- package/docs/components/Prose/README.md +12 -0
- package/docs/components/Quote/README.md +13 -0
- package/docs/components/Radio/README.md +25 -0
- package/docs/components/RadioGroup/README.md +23 -0
- package/docs/components/SearchInput/README.md +23 -0
- package/docs/components/SectionHeader/README.md +14 -0
- package/docs/components/SegmentedControl/README.md +19 -0
- package/docs/components/Select/README.md +52 -0
- package/docs/components/SettingsPage/README.md +11 -0
- package/docs/components/SignIn/README.md +11 -0
- package/docs/components/Skeleton/README.md +16 -0
- package/docs/components/Slider/README.md +22 -0
- package/docs/components/Sparkline/README.md +13 -0
- package/docs/components/Spinner/README.md +16 -0
- package/docs/components/SquareGlyph/README.md +18 -0
- package/docs/components/Stack/README.md +11 -0
- package/docs/components/Stat/README.md +20 -0
- package/docs/components/Steps/README.md +22 -0
- package/docs/components/Switch/README.md +27 -0
- package/docs/components/Table/README.md +35 -0
- package/docs/components/Tabs/README.md +26 -0
- package/docs/components/Tag/README.md +21 -0
- package/docs/components/Text/README.md +11 -0
- package/docs/components/Textarea/README.md +20 -0
- package/docs/components/ThemeScript/README.md +47 -0
- package/docs/components/TileGrid/README.md +12 -0
- package/docs/components/TimePicker/README.md +19 -0
- package/docs/components/Timeline/README.md +12 -0
- package/docs/components/Toaster/README.md +34 -0
- package/docs/components/Tooltip/README.md +23 -0
- package/docs/components/TreeView/README.md +15 -0
- package/package.json +76 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@vokality/design-system`. The package follows [semantic versioning](https://semver.org); see CONTRIBUTING.md for what counts as breaking.
|
|
4
|
+
|
|
5
|
+
## 1.2.2 — 2026-10-12
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Publish the package publicly on npmjs.org so installs do not require a GitHub package-read token.
|
|
9
|
+
- Release CI publishes the tested tarball through npm trusted publishing.
|
|
10
|
+
- Include the bundled fonts' SIL Open Font License texts and copyright notices. Component behavior, exports, tokens and font files are unchanged.
|
|
11
|
+
|
|
12
|
+
## 1.2.1 — 2026-10-12
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- `Select` and `Dialog` no longer write refs during render (React's concurrent rendering could see a stale callback).
|
|
16
|
+
- Effects list their real dependencies: `CommandPalette`'s shortcut follows a changed `hotkey`; `TimePicker` reformats its text when `locale` changes; `useTheme`, `ContextMenu`, `ErrorSummary` and `Combobox` keep their behaviour with complete dependencies.
|
|
17
|
+
- `DatePicker` derives its typed text from the value instead of syncing it in an effect, so a new value always shows its label and clears a stale error. A controlled parent that ignores `onChange` now sees the field show the unchanged value instead of the typed text.
|
|
18
|
+
- List keys in `Breadcrumbs`, `DescriptionList`, `Steps`, `Timeline` and chart rows include a stable value, not just the position.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Intl date and number formatters are cached per locale and options (`formatNumber`, `formatCurrency`, `formatDate`, `Calendar`, the pickers and charts no longer build one per call).
|
|
22
|
+
- Larger components (`Table`, `Calendar`, `DatePicker`, `TimePicker`, `Combobox`, `AppShell` and others) are split into smaller internal pieces; markup, props and behaviour are unchanged. The code passes `react-doctor` with no findings.
|
|
23
|
+
- Releases build and pack in a read-only job and publish the packed tarball in a separate job without running project scripts (see CONTRIBUTING.md).
|
|
24
|
+
|
|
25
|
+
## 1.2.0 — 2026-10-12
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
- Interactive components are built on [Radix Primitives](https://www.radix-ui.com/primitives) (`radix-ui` 1.8.0, now a dependency). Their props and look are unchanged; keyboard, focus and screen-reader behaviour now come from Radix, and floating panels are positioned by Radix and portalled to `<body>`, so a dialog, drawer or scrolling container never clips them.
|
|
29
|
+
- Dialog, Drawer and AppShell's mobile sidebar: Radix Dialog (AlertDialog for `role="alertdialog"`). Popover: Radix Popover. CommandPalette: a Radix Dialog shell.
|
|
30
|
+
- Menu: Radix DropdownMenu. ContextMenu: Radix ContextMenu.
|
|
31
|
+
- Select: Radix Select. Combobox, MultiSelect, DatePicker and TimePicker: their panels are Radix Popovers.
|
|
32
|
+
- Checkbox, Switch, RadioGroup, SegmentedControl, Slider, Progress and Field's label: the matching Radix primitives.
|
|
33
|
+
- Tabs, Accordion, Toaster (`toast()`) and Tooltip: the matching Radix primitives. Toasts can be swiped away and reached with F8.
|
|
34
|
+
- Popups opened inside a Dialog or Drawer now sit above it; Escape in a popup inside a dialog closes only the popup.
|
|
35
|
+
- `Select`, `Tabs` and `SegmentedControl` call `onChange` only when the value changes (re-choosing the current one no longer calls it). `RadioGroup` also calls `onChange` when uncontrolled.
|
|
36
|
+
- `Button`, `IconButton`, `Link` and the inputs forward refs, so they work as Radix `asChild` triggers and with your own refs.
|
|
37
|
+
|
|
38
|
+
## 1.1.0 — 2026-10-11
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
- `ThemeScript`: a blocking script for `<head>` that applies the saved or system theme before first paint, so there is no flash of the wrong theme.
|
|
42
|
+
- `useTheme()`: the saved preference (`system`, `dark`, `light`, `contrast`), the theme in effect, and a setter. Every reader updates together, other tabs follow, and `system` follows OS changes live.
|
|
43
|
+
- `themeScript(options)` and `themes`, for pages not rendered by React.
|
|
44
|
+
- `LinkProvider`: internal links in buttons, nav lists, breadcrumbs, cards and list rows render with your router's link component (such as `next/link`), so navigation stays client-side.
|
|
45
|
+
- The design guide (`docs/brand.md`) and each component's docs (`docs/components/<Name>/README.md`) ship in the package.
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
- `DatePicker`'s `onChange` type now includes `null`, which it already passed when a single date is cleared. `CalendarProps` lists `today`, which both components already read.
|
|
49
|
+
- `Checkbox` and `Radio` are client components. They use hooks, so rendering them from a server component used to fail.
|
|
50
|
+
- `FileUpload`'s `onChange` received `undefined` in its `files` array for each entry from `defaultFiles`. Those entries now appear only in the second argument, `entries`.
|
|
51
|
+
- `IconButton` with `href` now accepts link attributes (`target`, `rel`, `download`) in its types, as `Button` does.
|
|
52
|
+
- Select, DatePicker (button mode) and TimePicker triggers lost their `card` fill: the read-only field style also matched non-editable elements. It now applies only to read-only `<input>` and `<textarea>`.
|
|
53
|
+
- `Card`, `MediaCard`, `EmptyState`, `PageHeader`, `Dialog`, `SectionHeader`, `FileUpload` and chart descriptions wrapped any content in a `<p>`. A form or `<div>` inside a `<p>` is invalid HTML, so the browser restructured it and React hydration failed. Plain text still gets a `<p>`; other content gets a `<div>`.
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
- The package is written in TypeScript and ships one module per component (`dist/components/<Name>/`), each with its own declarations and, for client components, its own `"use client"`. Apps bundle only the components they import, and the helpers, `ThemeScript` and display-only components are importable from server components. Every component exports its props type (`ButtonProps`, `SelectProps`, …). The public API is unchanged; `Alert` and `List` no longer need a client boundary.
|
|
57
|
+
- Development, CI and publishing use Bun (latest) instead of npm: `bun install`, `bun run test` (Bun's test runner), `bun publish`.
|
|
58
|
+
- The claude.ai docs page is built from this repository, stamped with its version and commit, and kept in sync by a daily routine (see CONTRIBUTING.md → The docs page). Logos and imagery now live in `assets/`.
|
|
59
|
+
- The package moved to its own repository, `Vokality/design-system`, with its history. Releases now publish automatically when a merge to `main` bumps the version, and create the matching tag and GitHub release.
|
|
60
|
+
|
|
61
|
+
## 1.0.0 — 2026-10-11
|
|
62
|
+
|
|
63
|
+
First release, generalised from the Vokality website for every Vokality project.
|
|
64
|
+
|
|
65
|
+
### Tokens
|
|
66
|
+
- Three themes: `dark` (default), `light` and `contrast` (AAA), with the same token names in each.
|
|
67
|
+
- Color, status (`info`, `success`, `warning`, `danger` with tints and lines), `input-border` for 3:1 control edges, `overlay`, `ring`.
|
|
68
|
+
- Chart palettes: eight categorical series (`chart-1`…`chart-8`, fixed order, color-vision checked), a sequential ramp (`seq-1`…`seq-7`) and a diverging ramp (`div-1`…`div-7`).
|
|
69
|
+
- Type (display, sans, numeric, mono families and named styles), space, radius, z-index, motion (`motion-*`, `ease-standard`), breakpoints (`bp-*`) and layout sizes.
|
|
70
|
+
- Outputs: CSS variables, Tailwind v4 theme, JSON and W3C DTCG (Figma via Tokens Studio).
|
|
71
|
+
|
|
72
|
+
### Components
|
|
73
|
+
- Actions: Button (loading, block), IconButton, Link, Menu (submenus, checkbox and radio items), ContextMenu.
|
|
74
|
+
- Form controls: Field, Input (prefix, suffix, count), Textarea, PasswordInput, NumberInput, Slider, OtpInput, SearchInput, Select, Combobox, MultiSelect, Calendar, DatePicker (typed or picked), TimePicker, Checkbox, Radio, RadioGroup, Switch, SegmentedControl, FileUpload, ErrorSummary. None use native browser widgets.
|
|
75
|
+
- Feedback: Alert, Toaster and `toast()`, Progress, Spinner, Skeleton, EmptyState.
|
|
76
|
+
- Overlays: Dialog, Drawer, Popover, Tooltip (touch support), CommandPalette.
|
|
77
|
+
- Navigation: Tabs, Pagination, Breadcrumbs, NavList, Steps, TreeView.
|
|
78
|
+
- Data display: Table (sort, selection, expandable rows, loading, paging), List, DescriptionList, Stat, Timeline, Accordion, Badge, Tag, Avatar, AvatarGroup, Kbd.
|
|
79
|
+
- Typography: Heading, Text, Prose, Code, CodeBlock, Figure.
|
|
80
|
+
- Layout: AppShell, PageHeader, Container, Stack, Inline, Grid. Charts: BarChart, LineChart, Sparkline.
|
|
81
|
+
- Patterns: SectionHeader, Card, MediaCard, Quote, FaqList, TileGrid, Icon, SquareGlyph, Divider, HatchDivider.
|
|
82
|
+
- Page templates: sign in, settings, list and detail, form, dashboard, error.
|
|
83
|
+
|
|
84
|
+
### Packaging
|
|
85
|
+
- Published privately to GitHub Packages.
|
|
86
|
+
- Components ship as a client module and helpers as a plain module, so Next.js server components can call `formatCurrency` and the other helpers. Tested in a Next.js 16 / React 19 / Tailwind v4 app, and against React 18.
|
|
87
|
+
|
|
88
|
+
### Behaviour
|
|
89
|
+
- WAI-ARIA keyboard and screen-reader patterns for every interactive component; focus trapping and return in modals.
|
|
90
|
+
- Floating panels use fixed positioning against their trigger, so they are never clipped by dialogs, drawers, scrolling tables or the app shell.
|
|
91
|
+
- Forced-colors support, reduced-motion support, SSR-safe ids and portals.
|
|
92
|
+
- Locale-aware formatting for `en-US`, `nl-NL`, `nl-CW`, `nl-AW`, `nl-SX`, `nl-SR` (Papiamentu tags fall back to Dutch), including the Caribbean guilder (XCG), Aruban florin (AWG) and Surinamese dollar (SRD).
|
package/README.md
CHANGED
|
@@ -1,3 +1,135 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vokality/design-system
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Tokens, themes and React components for every Vokality project: product UIs, dashboards, internal tools, sites and documents. The design guide (principles, color, type, layout, writing) is [`docs/brand.md`](docs/brand.md); each component's anatomy, states and usage are in [`docs/components/<Name>/README.md`](docs/components).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
The package is public on npmjs.org. Installing it locally, in CI or on a build host does not require a token.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bun add @vokality/design-system
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
React 18 or later is a peer dependency.
|
|
14
|
+
|
|
15
|
+
Projects upgrading from the GitHub Packages release must point the `@vokality` scope at `https://registry.npmjs.org` and update their lockfile. Existing lockfiles may still contain authenticated GitHub tarball URLs even after the registry setting changes.
|
|
16
|
+
|
|
17
|
+
The repository remains private. The package keeps its existing `UNLICENSED` designation; public availability does not grant a new license to Vokality's code or brand assets. The bundled fonts have their own SIL Open Font License notices in `dist/fonts/`.
|
|
18
|
+
|
|
19
|
+
## Use
|
|
20
|
+
|
|
21
|
+
Import the stylesheet once (fonts, all themes and component styles), then the components:
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import "@vokality/design-system/vokality.css";
|
|
25
|
+
import { PageHeader, Button, Field, Input, Select, toast, Toaster } from "@vokality/design-system";
|
|
26
|
+
|
|
27
|
+
export function Settings() {
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<PageHeader title="Workspace" actions={<Button onClick={() => toast({ title: "Saved", status: "success" })}>Save changes</Button>} />
|
|
31
|
+
<Field label="Name"><Input defaultValue="Northwind" /></Field>
|
|
32
|
+
<Field label="Region"><Select options={["Curaçao", "Aruba", "Sint Maarten"]} placeholder="Choose a region" /></Field>
|
|
33
|
+
<Toaster />
|
|
34
|
+
</>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- **Next.js App Router:** components are client components (they ship with `"use client"`), so use them from server components freely; they render on the server and hydrate without warnings. The helpers (`formatCurrency`, `formatNumber`, `formatPercent`, `formatDate`, `utils`, `iconData`) are plain functions you can call in server components too.
|
|
40
|
+
- **Client-side navigation:** wrap the app once in `LinkProvider` with your router's link component, and every internal link in the system (buttons, nav lists, breadcrumbs, cards, list rows) uses it:
|
|
41
|
+
```tsx
|
|
42
|
+
"use client";
|
|
43
|
+
import NextLink from "next/link";
|
|
44
|
+
import { LinkProvider } from "@vokality/design-system";
|
|
45
|
+
export function Providers({ children }: { children: React.ReactNode }) {
|
|
46
|
+
return <LinkProvider component={NextLink}>{children}</LinkProvider>;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
Hash, external, `mailto:` and `tel:` links stay plain `<a>`.
|
|
50
|
+
- **Any React app:** Vite, Remix and other React 18+ setups work the same way: import the CSS once, then the components. Bundlers resolve the font files referenced by the CSS.
|
|
51
|
+
- **Not React:** projects in other frameworks can still use the tokens and styles (`tokens.css`, `tailwind.css`, `tokens.json`) and the icon SVGs; the components themselves need React.
|
|
52
|
+
- **No build step:** `@vokality/design-system/iife` is a window-global build (`window.Vokality`) for plain HTML pages that load React from a `<script>`.
|
|
53
|
+
- **Types:** the package is written in TypeScript; declarations ship next to each module, with every prop documented. Props types are exported as `<Name>Props` (`import type { ButtonProps } from "@vokality/design-system"`).
|
|
54
|
+
- **Tree-shaking:** each component is its own module, so an app bundles only the components it imports.
|
|
55
|
+
- **Built on Radix:** the interactive components (dialogs, popovers, menus, selects, tabs, toggles, sliders, toasts, tooltips) are [Radix Primitives](https://www.radix-ui.com/primitives) styled with the system's tokens, so keyboard, focus and screen-reader behaviour follow the WAI-ARIA patterns. `radix-ui` installs with the package; you don't import it yourself.
|
|
56
|
+
|
|
57
|
+
## Themes
|
|
58
|
+
|
|
59
|
+
Set `data-theme` on `<html>`, or on any element to theme a subtree:
|
|
60
|
+
|
|
61
|
+
| `data-theme` | Use |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `dark` (default, also `:root`) | The signature look; products and tools. |
|
|
64
|
+
| `light` | Documents, long reading, print, or where people prefer it. |
|
|
65
|
+
| `contrast` | High contrast (AAA), offered as a setting. |
|
|
66
|
+
|
|
67
|
+
To follow the system until the person picks a theme, without a flash of the wrong one, put `ThemeScript` in `<head>` and switch with `useTheme`:
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
// app/layout.tsx
|
|
71
|
+
import { ThemeScript } from "@vokality/design-system";
|
|
72
|
+
|
|
73
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
74
|
+
return (
|
|
75
|
+
<html lang="en" suppressHydrationWarning>
|
|
76
|
+
<head><ThemeScript /></head>
|
|
77
|
+
<body>{children}</body>
|
|
78
|
+
</html>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
const { theme, resolvedTheme, setTheme } = useTheme(); // theme: "system" | "dark" | "light" | "contrast"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Pages not rendered by React can inline `themeScript()` instead. See `docs/components/ThemeScript/README.md`.
|
|
88
|
+
|
|
89
|
+
## Starting a new project
|
|
90
|
+
|
|
91
|
+
[`Vokality/app-template`](https://github.com/Vokality/app-template) is a Next.js app already set up with this package: `.npmrc`, CSS imports, theme switching, the app shell, sample pages, CI and Dependabot. On GitHub, choose **Use this template**.
|
|
92
|
+
|
|
93
|
+
## Tailwind CSS v4
|
|
94
|
+
|
|
95
|
+
```css
|
|
96
|
+
@import "tailwindcss";
|
|
97
|
+
@import "@vokality/design-system/vokality.css";
|
|
98
|
+
@import "@vokality/design-system/tailwind.css";
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Every token becomes a utility that follows the active theme: `bg-background`, `bg-card`, `text-muted-foreground`, `border-input-border`, `text-primary`, `font-display`, `bg-chart-3`, and breakpoints `xs`…`2xl`. Corners are square at every radius.
|
|
102
|
+
|
|
103
|
+
## What's in the package
|
|
104
|
+
|
|
105
|
+
| Path | Contents |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `.` | React components, `toast`, format helpers (`formatNumber`, `formatCurrency`, `formatPercent`, `formatDate`), `utils`, `iconData` |
|
|
108
|
+
| `vokality.css` | `fonts.css` + `tokens.css` + `components.css` |
|
|
109
|
+
| `tokens.css` | CSS custom properties for every theme, plus `.vk-text-*` type styles |
|
|
110
|
+
| `tailwind.css` | Tailwind v4 `@theme` mapping |
|
|
111
|
+
| `tokens.json` | The source tokens (colors per theme, type, space, radius, z-index, motion, breakpoints, sizes, charts) |
|
|
112
|
+
| `tokens.dtcg.json` | W3C design-tokens format: one set per theme, a `global` set and `$themes`. Import into Figma with Tokens Studio, or build with Style Dictionary. |
|
|
113
|
+
| `icons/*.svg` | Every icon as a 24px stroke SVG |
|
|
114
|
+
| `fonts/*` | Manrope, IBM Plex Sans and Space Grotesk (Latin subsets, woff2) |
|
|
115
|
+
| `iife` | Window-global build for the documentation artifact and script-tag pages |
|
|
116
|
+
|
|
117
|
+
## Docs in the package
|
|
118
|
+
|
|
119
|
+
The design guide and every component's page ship with the package, so they match the installed version and work offline (and for coding assistants):
|
|
120
|
+
|
|
121
|
+
- `node_modules/@vokality/design-system/docs/brand.md`: principles, color, type, layout, writing.
|
|
122
|
+
- `node_modules/@vokality/design-system/docs/components/<Name>/README.md`: anatomy, states, props, accessibility and rules for each component.
|
|
123
|
+
|
|
124
|
+
## Develop
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
bun install
|
|
128
|
+
bun run test # build, then token, contrast, format, render and build tests (bun test)
|
|
129
|
+
bun run test:browser # keyboard, focus and overlay behaviour in headless Chromium
|
|
130
|
+
bun run typecheck # the declarations against test/types-usage.tsx
|
|
131
|
+
bun run preview --theme=light # render every docs/components preview; screenshots in artifact/shots
|
|
132
|
+
bun run artifact # build the claude.ai docs page in artifact/ (see "The docs page" in CONTRIBUTING.md)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) before adding tokens or components, and [CHANGELOG.md](CHANGELOG.md) for releases.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Dispatch, KeyboardEvent, ReactNode, RefObject, SetStateAction } from "react";
|
|
2
|
+
import type { ChartProps, ChartSeries } from "../types.js";
|
|
3
|
+
export type ChartFormat = (value: number) => string;
|
|
4
|
+
/** What the frame, table and tooltip read: the chart's props with the series, formatter and x key resolved. */
|
|
5
|
+
export interface ChartViewProps<Row> {
|
|
6
|
+
data: Row[];
|
|
7
|
+
series: ChartSeries[];
|
|
8
|
+
format: ChartFormat;
|
|
9
|
+
xKey: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
allowTable?: boolean;
|
|
13
|
+
/** Header of the category column in the table view. Default "Category". */
|
|
14
|
+
xLabel?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/** The field `key` of `row`, as stored. */
|
|
18
|
+
export declare function cell(row: unknown, key: string): unknown;
|
|
19
|
+
/** The field as a number for the geometry: missing or non-numeric values plot as 0. */
|
|
20
|
+
export declare function cellNumber(row: unknown, key: string): number;
|
|
21
|
+
/** The field as a label (the x value). */
|
|
22
|
+
export declare function cellLabel(row: unknown, key: string): ReactNode;
|
|
23
|
+
export declare function useWidth(ref: RefObject<HTMLElement>, fallback: number): number;
|
|
24
|
+
export declare function seriesColor(i: number): string;
|
|
25
|
+
export declare function ChartLegend({ series }: {
|
|
26
|
+
series: ChartSeries[];
|
|
27
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function ChartTable<Row>(props: ChartViewProps<Row> & {
|
|
29
|
+
hidden?: boolean;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
/** The figure around a chart: title, description, the "Show table" toggle, the legend and a screen-reader table. */
|
|
32
|
+
export declare function ChartFrame<Row>(props: ChartViewProps<Row> & {
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
/** The tooltip for the row at `idx`, centred on `x` but kept inside the plot. */
|
|
36
|
+
export declare function chartTooltip<Row>(props: ChartViewProps<Row>, idx: number | null, x: number, width: number): import("react/jsx-runtime").JSX.Element | null;
|
|
37
|
+
export interface ChartState {
|
|
38
|
+
ref: RefObject<HTMLDivElement>;
|
|
39
|
+
width: number;
|
|
40
|
+
/** Index of the row under the pointer or keyboard focus. */
|
|
41
|
+
active: number | null;
|
|
42
|
+
setActive: Dispatch<SetStateAction<number | null>>;
|
|
43
|
+
fmt: ChartFormat;
|
|
44
|
+
series: ChartSeries[];
|
|
45
|
+
xKey: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function useChart<Row>(props: ChartProps<Row> & {
|
|
48
|
+
width?: number;
|
|
49
|
+
valueLabel?: string;
|
|
50
|
+
}): ChartState;
|
|
51
|
+
/** Arrow keys, Home and End step through the rows; Escape clears. */
|
|
52
|
+
export declare function chartKeys(c: ChartState, n: number): (e: KeyboardEvent<HTMLElement>) => void;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { isValidElement, useRef, useState } from "react";
|
|
4
|
+
import { Button } from "../components/Button/Button.js";
|
|
5
|
+
import { useIsoLayoutEffect } from "../internal/useIsoLayoutEffect.js";
|
|
6
|
+
import { cx } from "../lib/cx.js";
|
|
7
|
+
import { numberFormat } from "../lib/intl.js";
|
|
8
|
+
import { para } from "../lib/text.js";
|
|
9
|
+
/* Rows are caller data of any shape: these read one field by name. */
|
|
10
|
+
/** The field `key` of `row`, as stored. */
|
|
11
|
+
export function cell(row, key) {
|
|
12
|
+
return typeof row === "object" && row !== null ? Reflect.get(row, key) : undefined;
|
|
13
|
+
}
|
|
14
|
+
/** The field as a number for the geometry: missing or non-numeric values plot as 0. */
|
|
15
|
+
export function cellNumber(row, key) {
|
|
16
|
+
return Number(cell(row, key)) || 0;
|
|
17
|
+
}
|
|
18
|
+
/** The field as a label (the x value). */
|
|
19
|
+
export function cellLabel(row, key) {
|
|
20
|
+
const v = cell(row, key);
|
|
21
|
+
return typeof v === "string" || typeof v === "number" || isValidElement(v) ? v : null;
|
|
22
|
+
}
|
|
23
|
+
/** The field through the value formatter, which gets the raw value: the default shows "—" for a missing one. */
|
|
24
|
+
function formatCell(format, row, key) {
|
|
25
|
+
return format(cell(row, key));
|
|
26
|
+
}
|
|
27
|
+
export function useWidth(ref, fallback) {
|
|
28
|
+
const [width, setWidth] = useState(fallback);
|
|
29
|
+
useIsoLayoutEffect(() => {
|
|
30
|
+
const el = ref.current;
|
|
31
|
+
if (!el)
|
|
32
|
+
return;
|
|
33
|
+
const set = () => {
|
|
34
|
+
const w = el.getBoundingClientRect().width;
|
|
35
|
+
if (w)
|
|
36
|
+
setWidth(Math.round(w));
|
|
37
|
+
};
|
|
38
|
+
set();
|
|
39
|
+
if (typeof ResizeObserver === "undefined")
|
|
40
|
+
return;
|
|
41
|
+
const ro = new ResizeObserver(set);
|
|
42
|
+
ro.observe(el);
|
|
43
|
+
return () => ro.disconnect();
|
|
44
|
+
}, []);
|
|
45
|
+
return width;
|
|
46
|
+
}
|
|
47
|
+
export function seriesColor(i) {
|
|
48
|
+
return "var(--chart-" + ((i % 8) + 1) + ")";
|
|
49
|
+
}
|
|
50
|
+
export function ChartLegend({ series }) {
|
|
51
|
+
return (_jsx("ul", { className: "vk-chart-legend", children: series.map((s, i) => _jsxs("li", { children: [_jsx("span", { className: "vk-chart-swatch", style: { background: seriesColor(i) }, "aria-hidden": "true" }), s.label] }, s.key)) }));
|
|
52
|
+
}
|
|
53
|
+
export function ChartTable(props) {
|
|
54
|
+
const { data, series, format, xKey } = props;
|
|
55
|
+
return (_jsxs("table", { className: cx("vk-table", props.hidden ? null : "vk-chart-table"), children: [_jsx("caption", { className: "vk-sr-only", children: props.title }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: props.xLabel || "Category" }), series.map((s) => _jsx("th", { scope: "col", className: "vk-td-end", children: s.label }, s.key))] }) }), _jsx("tbody", { children: data.map((d, i) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: cellLabel(d, xKey) }), series.map((s) => _jsx("td", { className: "vk-td-end vk-td-num", children: formatCell(format, d, s.key) }, s.key))] }, String(cell(d, xKey)) + "#" + i))) })] }));
|
|
56
|
+
}
|
|
57
|
+
/** The chart's caption: title, description and the "Show table" toggle. */
|
|
58
|
+
function ChartCaption({ title, description, allowTable, showTable, onToggle }) {
|
|
59
|
+
const Description = para(description);
|
|
60
|
+
return (_jsxs("figcaption", { className: "vk-chart-head", children: [_jsxs("div", { children: [title ? _jsx("p", { className: "vk-chart-title", children: title }) : null, description ? _jsx(Description, { className: "vk-chart-description", children: description }) : null] }), allowTable !== false ? _jsx(Button, { variant: "ghost", size: "sm", "aria-pressed": showTable ? "true" : "false", onClick: onToggle, children: showTable ? "Show chart" : "Show table" }) : null] }));
|
|
61
|
+
}
|
|
62
|
+
/** The figure around a chart: title, description, the "Show table" toggle, the legend and a screen-reader table. */
|
|
63
|
+
export function ChartFrame(props) {
|
|
64
|
+
const [showTable, setShowTable] = useState(false);
|
|
65
|
+
const { title, description, allowTable, series } = props;
|
|
66
|
+
const hasCaption = Boolean(title || description || allowTable !== false);
|
|
67
|
+
return (_jsxs("figure", { className: cx("vk-chart", props.className), children: [hasCaption ? _jsx(ChartCaption, { title: title, description: description, allowTable: allowTable, showTable: showTable, onToggle: () => setShowTable(!showTable) }) : null, series.length > 1 && !showTable ? _jsx(ChartLegend, { series: series }) : null, showTable ? (_jsx("div", { className: "vk-table-wrap", children: _jsx(ChartTable, { ...props }) })) : (_jsxs(_Fragment, { children: [props.children, _jsx("div", { className: "vk-sr-only", children: _jsx(ChartTable, { ...props, hidden: true }) })] }))] }));
|
|
68
|
+
}
|
|
69
|
+
/** The tooltip for the row at `idx`, centred on `x` but kept inside the plot. */
|
|
70
|
+
export function chartTooltip(props, idx, x, width) {
|
|
71
|
+
if (idx == null)
|
|
72
|
+
return null;
|
|
73
|
+
const d = props.data[idx];
|
|
74
|
+
const left = Math.min(Math.max(x, 80), width - 80);
|
|
75
|
+
return (_jsxs("div", { className: "vk-chart-tooltip", style: { left: left + "px" }, role: "presentation", children: [_jsx("p", { className: "vk-chart-tooltip-title", children: cellLabel(d, props.xKey) }), props.series.map((s, i) => (_jsxs("p", { className: "vk-chart-tooltip-row", children: [_jsx("span", { className: "vk-chart-swatch", style: { background: seriesColor(i) } }), _jsx("span", { className: "vk-chart-tooltip-label", children: s.label }), _jsx("span", { className: "vk-chart-tooltip-value", children: formatCell(props.format, d, s.key) })] }, s.key)))] }));
|
|
76
|
+
}
|
|
77
|
+
export function useChart(props) {
|
|
78
|
+
const ref = useRef(null);
|
|
79
|
+
const width = useWidth(ref, props.width || 640);
|
|
80
|
+
const [active, setActive] = useState(null);
|
|
81
|
+
const fmt = props.valueFormat || ((v) => (v == null ? "—" : numberFormat(props.locale || "en-US").format(v)));
|
|
82
|
+
const series = props.series || [{ key: "value", label: props.valueLabel || "Value" }];
|
|
83
|
+
return { ref, width, active, setActive, fmt, series, xKey: props.xKey || "label" };
|
|
84
|
+
}
|
|
85
|
+
/** Arrow keys, Home and End step through the rows; Escape clears. */
|
|
86
|
+
export function chartKeys(c, n) {
|
|
87
|
+
return (e) => {
|
|
88
|
+
const a = c.active == null ? -1 : c.active;
|
|
89
|
+
if (e.key === "ArrowRight") {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
c.setActive(Math.min(n - 1, a + 1));
|
|
92
|
+
}
|
|
93
|
+
else if (e.key === "ArrowLeft") {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
c.setActive(Math.max(0, a < 0 ? 0 : a - 1));
|
|
96
|
+
}
|
|
97
|
+
else if (e.key === "Home") {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
c.setActive(0);
|
|
100
|
+
}
|
|
101
|
+
else if (e.key === "End") {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
c.setActive(n - 1);
|
|
104
|
+
}
|
|
105
|
+
else if (e.key === "Escape")
|
|
106
|
+
c.setActive(null);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface AccordionProps {
|
|
3
|
+
items: {
|
|
4
|
+
id: string;
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
content: ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}[];
|
|
9
|
+
type?: "single" | "multiple";
|
|
10
|
+
defaultOpen?: string[];
|
|
11
|
+
headingLevel?: "h2" | "h3" | "h4";
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** A stack of sections that expand and collapse, for long content people scan by heading: settings groups, FAQs, details. */
|
|
15
|
+
export declare function Accordion({ items: itemsProp, type, defaultOpen, headingLevel, className }: AccordionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Accordion as Primitive } from "radix-ui";
|
|
4
|
+
import { Icon } from "../Icon/Icon.js";
|
|
5
|
+
import { cx } from "../../lib/cx.js";
|
|
6
|
+
/** A stack of sections that expand and collapse, for long content people scan by heading: settings groups, FAQs, details. */
|
|
7
|
+
export function Accordion({ items: itemsProp, type, defaultOpen, headingLevel, className }) {
|
|
8
|
+
const items = itemsProp || [];
|
|
9
|
+
const Heading = headingLevel || "h3";
|
|
10
|
+
const body = items.map((it) => (_jsxs(Primitive.Item, { value: it.id, disabled: it.disabled, className: "vk-accordion-item", children: [_jsx(Primitive.Header, { asChild: true, children: _jsx(Heading, { className: "vk-accordion-heading", children: _jsxs(Primitive.Trigger, { className: "vk-accordion-trigger", children: [_jsx("span", { children: it.title }), _jsx(Icon, { name: "chevron-down", className: "vk-accordion-icon" })] }) }) }), _jsx(Primitive.Content, { className: "vk-accordion-panel", children: it.content })] }, it.id)));
|
|
11
|
+
const cls = cx("vk-accordion", className);
|
|
12
|
+
// "single" stays collapsible: the open item closes again on a second press, as before.
|
|
13
|
+
return type === "multiple"
|
|
14
|
+
? _jsx(Primitive.Root, { type: "multiple", defaultValue: defaultOpen || [], className: cls, children: body })
|
|
15
|
+
: _jsx(Primitive.Root, { type: "single", collapsible: true, defaultValue: defaultOpen?.[0], className: cls, children: body });
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { Status } from "../../types.js";
|
|
3
|
+
export interface AlertProps {
|
|
4
|
+
status?: Status;
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
action?: ReactNode;
|
|
8
|
+
onDismiss?: () => void;
|
|
9
|
+
dismissLabel?: string;
|
|
10
|
+
live?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Inline status message. */
|
|
14
|
+
export declare function Alert({ status: statusProp, title, children, action, onDismiss, dismissLabel, live, className }: AlertProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "../Icon/Icon.js";
|
|
3
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
4
|
+
import { STATUS_ICON, STATUS_WORD } from "../../internal/status.js";
|
|
5
|
+
import { cx } from "../../lib/cx.js";
|
|
6
|
+
/** Inline status message. */
|
|
7
|
+
export function Alert({ status: statusProp, title, children, action, onDismiss, dismissLabel, live, className }) {
|
|
8
|
+
const status = statusProp || "info";
|
|
9
|
+
// Live alerts announce themselves: urgently for danger and warning, politely otherwise.
|
|
10
|
+
const role = live ? (status === "danger" || status === "warning" ? "alert" : "status") : undefined;
|
|
11
|
+
return (_jsxs("div", { className: cx("vk-alert", "vk-alert-" + status, className), role: role, children: [_jsx(Icon, { name: STATUS_ICON[status], size: 18, className: "vk-alert-icon" }), _jsxs("div", { className: "vk-alert-body", children: [_jsx("span", { className: "vk-sr-only", children: STATUS_WORD[status] + ": " }), title ? _jsx("p", { className: "vk-alert-title", children: title }) : null, children ? _jsx("div", { className: "vk-alert-text", children: children }) : null, action ? _jsx("div", { className: "vk-alert-action", children: action }) : null] }), onDismiss ? _jsx(IconButton, { icon: "x", size: 16, label: dismissLabel || "Dismiss", className: "vk-alert-close", onClick: onDismiss }) : null] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface AppShellProps {
|
|
3
|
+
brand?: ReactNode;
|
|
4
|
+
sidebar?: ReactNode;
|
|
5
|
+
sidebarFooter?: ReactNode;
|
|
6
|
+
search?: ReactNode;
|
|
7
|
+
actions?: ReactNode;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
defaultCollapsed?: boolean;
|
|
10
|
+
mainId?: string;
|
|
11
|
+
/** Fixed height (for embedding); the main area scrolls inside it. */
|
|
12
|
+
height?: string;
|
|
13
|
+
skipLabel?: string;
|
|
14
|
+
menuLabel?: string;
|
|
15
|
+
collapseLabel?: string;
|
|
16
|
+
expandLabel?: string;
|
|
17
|
+
sidebarLabel?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/** The frame of an application: a top bar, a sidebar for navigation (a slide-over on small screens, a Radix Dialog) and the main area. */
|
|
21
|
+
export declare function AppShell(props: AppShellProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Dialog as Primitive } from "radix-ui";
|
|
5
|
+
import { Icon } from "../Icon/Icon.js";
|
|
6
|
+
import { focusables } from "../../internal/focusables.js";
|
|
7
|
+
import { useUid } from "../../internal/useUid.js";
|
|
8
|
+
import { cx } from "../../lib/cx.js";
|
|
9
|
+
/** The frame of an application: a top bar, a sidebar for navigation (a slide-over on small screens, a Radix Dialog) and the main area. */
|
|
10
|
+
export function AppShell(props) {
|
|
11
|
+
const [mobileOpen, setMobileOpen] = useState(false);
|
|
12
|
+
const [collapsed, setCollapsed] = useState(Boolean(props.defaultCollapsed));
|
|
13
|
+
const sidebarId = useUid("vk-sidebar");
|
|
14
|
+
const mainId = props.mainId || "main";
|
|
15
|
+
useCloseWhenWide(mobileOpen, setMobileOpen);
|
|
16
|
+
return (_jsx(Primitive.Root, { open: mobileOpen, onOpenChange: setMobileOpen, children: _jsxs("div", { className: cx("vk-shell", collapsed ? "vk-shell-collapsed" : null, mobileOpen ? "vk-shell-mobile-open" : null, props.className), style: props.height ? { height: props.height, minHeight: 0, overflow: "hidden" } : undefined, children: [_jsx("a", { className: "vk-skip-link", href: "#" + mainId, children: props.skipLabel || "Skip to content" }), _jsx(ShellTopbar, { ...props, sidebarId: sidebarId, mobileOpen: mobileOpen, collapsed: collapsed, onToggleCollapsed: () => setCollapsed(!collapsed) }), _jsxs("div", { className: "vk-shell-body", children: [_jsx(ShellSidebar, { id: sidebarId, modal: mobileOpen, label: props.sidebarLabel || "Sidebar", footer: props.sidebarFooter, children: props.sidebar }), _jsx(Primitive.Overlay, { className: "vk-shell-scrim" }), _jsx("main", { id: mainId, tabIndex: -1, className: "vk-shell-main", children: props.children })] })] }) }));
|
|
17
|
+
}
|
|
18
|
+
/** The slide-over only exists under 48rem: growing past that closes it. */
|
|
19
|
+
function useCloseWhenWide(open, setOpen) {
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!open || typeof window.matchMedia !== "function")
|
|
22
|
+
return undefined;
|
|
23
|
+
const mq = window.matchMedia("(max-width: 48rem)");
|
|
24
|
+
const onChange = () => { if (!mq.matches)
|
|
25
|
+
setOpen(false); };
|
|
26
|
+
onChange();
|
|
27
|
+
mq.addEventListener("change", onChange);
|
|
28
|
+
return () => mq.removeEventListener("change", onChange);
|
|
29
|
+
}, [open, setOpen]);
|
|
30
|
+
}
|
|
31
|
+
function ShellTopbar(props) {
|
|
32
|
+
const { sidebarId, mobileOpen, collapsed } = props;
|
|
33
|
+
const collapseLabel = collapsed ? props.expandLabel || "Show sidebar" : props.collapseLabel || "Hide sidebar";
|
|
34
|
+
return (_jsxs("header", { className: "vk-shell-topbar", children: [_jsx(Primitive.Trigger, { className: "vk-icon-btn vk-icon-btn-ghost vk-shell-menu", "aria-label": props.menuLabel || "Menu", "aria-controls": sidebarId, children: _jsx(Icon, { name: mobileOpen ? "x" : "menu" }) }), _jsx("button", { type: "button", className: "vk-icon-btn vk-icon-btn-ghost vk-shell-collapse", "aria-label": collapseLabel, "aria-expanded": collapsed ? "false" : "true", "aria-controls": sidebarId, title: collapseLabel, onClick: props.onToggleCollapsed, children: _jsx(Icon, { name: "sidebar" }) }), _jsx("div", { className: "vk-shell-brand", children: props.brand }), props.search ? _jsx("div", { className: "vk-shell-search", children: props.search }) : null, _jsx("div", { className: "vk-shell-actions", children: props.actions })] }));
|
|
35
|
+
}
|
|
36
|
+
function ShellSidebar({ id, modal, label, footer, children }) {
|
|
37
|
+
const sidebarRef = useRef(null);
|
|
38
|
+
const aside = (_jsxs("aside", { ref: sidebarRef, id: id, className: "vk-shell-sidebar", "aria-label": label, children: [children, footer ? _jsx("div", { className: "vk-shell-sidebar-footer", children: footer }) : null] }));
|
|
39
|
+
if (!modal)
|
|
40
|
+
return aside;
|
|
41
|
+
// Open on a small screen: the same sidebar as a modal dialog, in place (no portal) so it stays inside the shell.
|
|
42
|
+
return (_jsx(Primitive.Content, { asChild: true, "aria-modal": "true", "aria-describedby": undefined, onOpenAutoFocus: (e) => {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
const el = sidebarRef.current;
|
|
45
|
+
if (el)
|
|
46
|
+
(focusables(el)[0] || el).focus();
|
|
47
|
+
}, children: aside }));
|
|
48
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface AvatarProps {
|
|
2
|
+
src?: string;
|
|
3
|
+
alt?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
decorative?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Up to two initials from a name: "Ana de Vries" → "AD". */
|
|
9
|
+
export declare function initials(name?: string): string;
|
|
10
|
+
/** Photo or initials in a disc; people only. */
|
|
11
|
+
export declare function Avatar(props: AvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** Up to two initials from a name: "Ana de Vries" → "AD". */
|
|
3
|
+
export function initials(name) {
|
|
4
|
+
return String(name || "")
|
|
5
|
+
.split(/\s+/)
|
|
6
|
+
.filter(Boolean)
|
|
7
|
+
.slice(0, 2)
|
|
8
|
+
.map((w) => w.charAt(0).toUpperCase())
|
|
9
|
+
.join("");
|
|
10
|
+
}
|
|
11
|
+
/** Photo or initials in a disc; people only. */
|
|
12
|
+
export function Avatar(props) {
|
|
13
|
+
const size = props.size || 34;
|
|
14
|
+
const style = { width: size + "px", height: size + "px", fontSize: Math.round(size * 0.32) + "px" };
|
|
15
|
+
if (props.src)
|
|
16
|
+
return _jsx("img", { className: "vk-avatar", src: props.src, alt: props.alt || "", width: size, height: size, style: style });
|
|
17
|
+
const a11y = props.decorative ? { "aria-hidden": "true" } : { role: "img", "aria-label": props.name };
|
|
18
|
+
return (_jsx("span", { className: "vk-avatar vk-avatar-initials", style: style, ...a11y, children: initials(props.name) }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface AvatarGroupProps {
|
|
2
|
+
people: {
|
|
3
|
+
name: string;
|
|
4
|
+
src?: string;
|
|
5
|
+
}[];
|
|
6
|
+
max?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
label?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A row of overlapping avatars for the people on a record, with a "+N" for the rest. */
|
|
11
|
+
export declare function AvatarGroup(props: AvatarGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar } from "../Avatar/Avatar.js";
|
|
3
|
+
/** A row of overlapping avatars for the people on a record, with a "+N" for the rest. */
|
|
4
|
+
export function AvatarGroup(props) {
|
|
5
|
+
const people = props.people || [];
|
|
6
|
+
const max = props.max || 4;
|
|
7
|
+
// When some are hidden, the last slot holds the "+N" count.
|
|
8
|
+
const shown = people.slice(0, people.length > max ? max - 1 : max);
|
|
9
|
+
const rest = people.length - shown.length;
|
|
10
|
+
const size = props.size || 28;
|
|
11
|
+
const label = props.label || people.map((p) => p.name).join(", ");
|
|
12
|
+
return (_jsxs("span", { className: "vk-avatar-group", role: "img", "aria-label": label, children: [shown.map((p) => (_jsx("span", { className: "vk-avatar-group-item", title: p.name, children: _jsx(Avatar, { src: p.src, name: p.name, size: size, decorative: true }) }, p.name))), rest > 0 ? (_jsx("span", { className: "vk-avatar-group-item", children: _jsx("span", { className: "vk-avatar vk-avatar-initials vk-avatar-more", style: { width: size + "px", height: size + "px", fontSize: Math.round(size * 0.36) + "px" }, "aria-hidden": "true", children: "+" + rest }) })) : null] }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** Outlined uppercase status tag. */
|
|
3
|
+
export interface BadgeProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
tone?: "neutral" | "info" | "success" | "warning" | "danger";
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Outlined uppercase status tag. */
|
|
9
|
+
export declare function Badge({ children, tone, className }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../lib/cx.js";
|
|
3
|
+
/** Outlined uppercase status tag. */
|
|
4
|
+
export function Badge({ children, tone, className }) {
|
|
5
|
+
return _jsx("span", { className: cx("vk-badge", tone && "vk-badge-" + tone, className), children: children });
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChartProps } from "../../types.js";
|
|
2
|
+
export interface BarChartProps<Row = Record<string, unknown>> extends ChartProps<Row> {
|
|
3
|
+
/** Stack the series into one bar per category instead of grouping them side by side. */
|
|
4
|
+
stacked?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Vertical bars for comparing amounts across categories: grouped, or stacked to show a total and its parts. */
|
|
7
|
+
export declare function BarChart<Row = Record<string, unknown>>(props: BarChartProps<Row>): import("react/jsx-runtime").JSX.Element;
|