@vokality/design-system 2.0.0 → 3.0.1
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 +35 -0
- package/README.md +63 -3
- package/bin/vokality-skill.mjs +68 -0
- package/dist/browser.d.ts +13 -0
- package/dist/browser.js +7 -0
- package/dist/charts/chart.d.ts +6 -5
- package/dist/charts/chart.js +44 -25
- package/dist/chat.d.ts +54 -0
- package/dist/chat.js +1 -0
- package/dist/components/Accordion/Accordion.js +1 -1
- package/dist/components/Alert/Alert.js +5 -2
- package/dist/components/AppShell/AppShell.js +10 -14
- package/dist/components/Avatar/Avatar.js +2 -2
- package/dist/components/AvatarGroup/AvatarGroup.js +2 -2
- package/dist/components/BarChart/BarChart.js +17 -15
- package/dist/components/Breadcrumbs/Breadcrumbs.js +6 -3
- package/dist/components/Calendar/Calendar.js +6 -5
- package/dist/components/Card/Card.js +2 -3
- package/dist/components/ChatInbox/ChatInbox.d.ts +11 -0
- package/dist/components/ChatInbox/ChatInbox.js +49 -0
- package/dist/components/ChatPanel/ChatPanel.d.ts +3 -0
- package/dist/components/ChatPanel/ChatPanel.js +13 -0
- package/dist/components/ChatPanel/composer.d.ts +5 -0
- package/dist/components/ChatPanel/composer.js +32 -0
- package/dist/components/ChatPanel/transcript.d.ts +13 -0
- package/dist/components/ChatPanel/transcript.js +39 -0
- package/dist/components/ChatWidget/ChatWidget.d.ts +12 -0
- package/dist/components/ChatWidget/ChatWidget.js +42 -0
- package/dist/components/Checkbox/Checkbox.d.ts +5 -10
- package/dist/components/Checkbox/Checkbox.js +5 -19
- package/dist/components/CodeBlock/CodeBlock.js +19 -5
- package/dist/components/Combobox/Combobox.js +22 -15
- package/dist/components/Combobox/ListPanel.js +20 -9
- package/dist/components/CommandPalette/CommandPalette.js +33 -14
- package/dist/components/ContextMenu/ContextMenu.d.ts +2 -2
- package/dist/components/ContextMenu/ContextMenu.js +5 -50
- package/dist/components/DatePicker/DatePicker.js +35 -29
- package/dist/components/DescriptionList/DescriptionList.js +1 -1
- package/dist/components/Dialog/Dialog.d.ts +24 -7
- package/dist/components/Dialog/Dialog.js +30 -41
- package/dist/components/Drawer/Drawer.d.ts +4 -2
- package/dist/components/EmptyState/EmptyState.js +2 -2
- package/dist/components/ErrorSummary/ErrorSummary.js +5 -3
- package/dist/components/FaqList/FaqList.js +1 -1
- package/dist/components/Field/Field.js +2 -2
- package/dist/components/FileUpload/FileUpload.js +17 -9
- package/dist/components/Grid/Grid.d.ts +5 -5
- package/dist/components/Grid/Grid.js +1 -1
- package/dist/components/Heading/Heading.js +2 -1
- package/dist/components/Icon/Icon.js +4 -2
- package/dist/components/Inline/Inline.d.ts +7 -7
- package/dist/components/LineChart/LineChart.js +17 -15
- package/dist/components/LinkProvider/LinkProvider.d.ts +1 -1
- package/dist/components/LinkProvider/LinkProvider.js +6 -2
- package/dist/components/List/List.js +1 -1
- package/dist/components/MediaCard/MediaCard.js +2 -2
- package/dist/components/Menu/Menu.js +6 -43
- package/dist/components/Menu/entries.d.ts +1 -30
- package/dist/components/Menu/entries.js +16 -100
- package/dist/components/MultiSelect/MultiSelect.js +43 -34
- package/dist/components/NumberInput/NumberInput.js +17 -18
- package/dist/components/OtpInput/OtpInput.d.ts +1 -1
- package/dist/components/OtpInput/OtpInput.js +10 -67
- package/dist/components/PageHeader/PageHeader.js +2 -2
- package/dist/components/Pagination/Pagination.js +3 -1
- package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/PasswordInput/PasswordInput.js +9 -4
- package/dist/components/Popover/Popover.d.ts +6 -7
- package/dist/components/Popover/Popover.js +2 -19
- package/dist/components/Progress/Progress.d.ts +1 -1
- package/dist/components/Progress/Progress.js +7 -11
- package/dist/components/Radio/Radio.d.ts +4 -2
- package/dist/components/RadioGroup/RadioGroup.d.ts +5 -12
- package/dist/components/RadioGroup/RadioGroup.js +6 -33
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +63 -0
- package/dist/components/RichTextEditor/RichTextEditor.js +175 -0
- package/dist/components/RichTextEditor/toolbar.d.ts +15 -0
- package/dist/components/RichTextEditor/toolbar.js +142 -0
- package/dist/components/RichTextEditor/uploads.d.ts +41 -0
- package/dist/components/RichTextEditor/uploads.js +124 -0
- package/dist/components/SearchInput/SearchInput.js +4 -2
- package/dist/components/SectionHeader/SectionHeader.js +1 -3
- package/dist/components/SegmentedControl/SegmentedControl.js +2 -12
- package/dist/components/Select/Select.d.ts +15 -16
- package/dist/components/Select/Select.js +11 -252
- package/dist/components/Slider/Slider.js +11 -21
- package/dist/components/Sparkline/Sparkline.js +8 -3
- package/dist/components/Spinner/Spinner.js +5 -2
- package/dist/components/Stack/Stack.d.ts +5 -5
- package/dist/components/Stat/Stat.js +6 -3
- package/dist/components/Steps/Steps.js +6 -3
- package/dist/components/Switch/Switch.d.ts +7 -7
- package/dist/components/Switch/Switch.js +4 -10
- package/dist/components/Table/Table.js +38 -19
- package/dist/components/Tabs/Tabs.js +2 -22
- package/dist/components/Tag/Tag.js +3 -1
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TileGrid/TileGrid.js +1 -1
- package/dist/components/TimePicker/TimePicker.js +35 -33
- package/dist/components/Timeline/Timeline.js +5 -4
- package/dist/components/Toaster/Toaster.js +21 -17
- package/dist/components/Tooltip/Tooltip.d.ts +6 -6
- package/dist/components/Tooltip/Tooltip.js +3 -17
- package/dist/components/TreeView/TreeView.js +15 -12
- package/dist/components.css +179 -8
- package/dist/hooks/useTheme.js +6 -6
- package/dist/icons/message-circle.svg +1 -0
- package/dist/internal/CharCount.js +3 -1
- package/dist/internal/choice.d.ts +10 -48
- package/dist/internal/choice.js +8 -96
- package/dist/internal/options.d.ts +10 -5
- package/dist/internal/options.js +25 -11
- package/dist/internal/status.d.ts +3 -2
- package/dist/internal/status.js +10 -2
- package/dist/internal/useScrollActive.js +2 -2
- package/dist/internal/useToday.d.ts +3 -0
- package/dist/internal/useToday.js +42 -0
- package/dist/lib/dates.js +25 -15
- package/dist/lib/format.js +11 -8
- package/dist/lib/icons.d.ts +5 -0
- package/dist/lib/icons.js +2 -0
- package/dist/lib/math.js +17 -5
- package/dist/lib/rich-text.d.ts +13 -0
- package/dist/lib/rich-text.js +62 -0
- package/dist/lib/space.d.ts +1 -2
- package/dist/lib/space.js +4 -1
- package/dist/lib/text.js +1 -1
- package/dist/lib/theme.js +1 -1
- package/dist/localization.d.ts +166 -0
- package/dist/localization.js +142 -0
- package/dist/vokality.css +179 -8
- package/dist/vokality.iife.js +35986 -9685
- package/docs/brand.md +6 -3
- package/docs/components/AppShell/README.md +1 -1
- package/docs/components/BarChart/README.md +1 -0
- package/docs/components/ChatInbox/README.md +41 -0
- package/docs/components/ChatWidget/README.md +47 -0
- package/docs/components/Checkbox/README.md +7 -3
- package/docs/components/ContextMenu/README.md +7 -3
- package/docs/components/Dialog/README.md +9 -4
- package/docs/components/Drawer/README.md +1 -1
- package/docs/components/Field/README.md +1 -1
- package/docs/components/Fieldset/README.md +2 -2
- package/docs/components/LineChart/README.md +1 -0
- package/docs/components/LocaleProvider/README.md +48 -0
- package/docs/components/Menu/README.md +13 -8
- package/docs/components/OtpInput/README.md +9 -5
- package/docs/components/PasswordInput/README.md +11 -2
- package/docs/components/Popover/README.md +6 -3
- package/docs/components/Progress/README.md +3 -1
- package/docs/components/RadioGroup/README.md +5 -2
- package/docs/components/RichTextEditor/README.md +84 -0
- package/docs/components/SegmentedControl/README.md +2 -0
- package/docs/components/Select/README.md +13 -17
- package/docs/components/Skeleton/README.md +1 -1
- package/docs/components/Slider/README.md +4 -2
- package/docs/components/Steps/README.md +1 -1
- package/docs/components/Switch/README.md +5 -2
- package/docs/components/Tabs/README.md +4 -2
- package/docs/components/Toaster/README.md +3 -1
- package/docs/components/Tooltip/README.md +5 -3
- package/package.json +55 -6
- package/skills/vokality-design-system/SKILL.md +55 -0
- package/skills/vokality-design-system/references/examples.tsx +103 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,41 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
+
## 3.0.1 — 2026-10-17
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- A bundled `vokality-design-system` Agent Skill with version-matched guidance for composing the existing React components, Radix contracts, tokens, localization, Markdown editing, chat and reduced motion.
|
|
9
|
+
- An explicit `vokality-skill` command to link the installed skill into a consuming project’s `.agents/skills` directory without overwriting existing skills. Package installation does not register skills automatically.
|
|
10
|
+
- Packed-package checks for the skill, its referenced documentation and typed usage examples, plus setup, upgrade and collision handling.
|
|
11
|
+
|
|
12
|
+
## 3.0.0 — 2026-10-17
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- `ChatWidget` and `ChatInbox` through direct entrypoints: floating and embedded conversation surfaces with shared typed messages, a Markdown composer, emoji and optional app-provided uploads.
|
|
16
|
+
- Motion for React provides restrained chat entrance/exit, launcher feedback and new-message transitions, with a complete reduced-motion opt-out. Chat composers start with a minimal toolbar; basic formatting is available through one native disclosure.
|
|
17
|
+
- Scoped localization through the direct `localization` entrypoint: English and Dutch interface messages, typed app overrides, inherited locale settings and portalled control support.
|
|
18
|
+
- `RichTextEditor` through the direct `rich-text` entrypoint: Markdown values, basic formatting, Unicode emoji and app-provided attachment uploads with recovery feedback.
|
|
19
|
+
- Validation for browser and React compatibility, real DOM hydration, a production Next.js App Router consumer, accessibility and forced colors, and visual comparisons of component previews across themes.
|
|
20
|
+
- Strict type-aware ESLint with official React/Hooks/Compiler rules and a full production-source React Doctor gate. TypeScript is pinned to the supported 6.0.3 toolchain with unchecked-index, unused-code, return-path and declaration checks.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Narrow layouts keep OTP digits together, step labels distinct, list metadata separate and segmented borders fitted to their contents. Loading skeletons remain visible in light themes.
|
|
24
|
+
- Editor popups use native Radix positioning and available-space constraints; chat composers retain a visible Send action in short viewports.
|
|
25
|
+
- Controlled field drafts, copy feedback cleanup, external toast subscriptions and rich editor lifecycles follow React's render-purity and Strict Mode contracts.
|
|
26
|
+
- Choice controls expose Radix value callbacks and real button DOM events; synthetic input-event proxies and duplicate arrow-key selection are removed.
|
|
27
|
+
- Reduced-motion loading indicators stop animating. Library components delegate focus isolation and restoration to Radix.
|
|
28
|
+
- Numeric axis ticks remain finite and terminating for very small and very large finite measurements.
|
|
29
|
+
- Combobox and MultiSelect keep their active option visible when popup height is capped or resized.
|
|
30
|
+
- Selects and menus delegate trigger activation, keyboard navigation, typeahead and dismissal directly to Radix; duplicate event, focus and gesture handlers are removed.
|
|
31
|
+
|
|
32
|
+
### Changed (breaking)
|
|
33
|
+
- React and React DOM now require 18.2 or later, matching Motion's supported installation requirements.
|
|
34
|
+
- Complete Radix components now receive styling and composition only. Checkbox and Switch use `onCheckedChange`; RadioGroup uses `onValueChange`; DOM handlers receive their real button targets. Checkbox indeterminate state is `checked="indeterminate"` or `defaultChecked="indeterminate"`.
|
|
35
|
+
- Select follows Radix defaults: no automatic first selection, non-empty option values, native form validation, closed typeahead selection and native keyboard/focus behavior.
|
|
36
|
+
- Tabs and SegmentedControl no longer select the first entry implicitly; supply `value` or `defaultValue` when an initial selection is wanted. Slider keys and Progress value semantics follow Radix.
|
|
37
|
+
- OTP and password visibility use the supplied, pinned Radix preview components. OTP paste/navigation and password selection/focus behavior now follow those primitives.
|
|
38
|
+
- Dialog exposes Radix state/content hooks and Trigger/Cancel/Action composition; custom autofocus priorities and dismissal policy flags are removed. `onClose` remains a direct close callback alias. Popover uses node children and native Close composition instead of a `close()` render prop. Tooltip uses Radix touch behavior without a custom touch timer.
|
|
39
|
+
|
|
5
40
|
## 2.0.0 — 2026-10-14
|
|
6
41
|
|
|
7
42
|
### Changed (breaking)
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The package is public on npmjs.org. Installing it locally, in CI or on a build h
|
|
|
10
10
|
bun add @vokality/design-system
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
React 18 or later is a peer dependency.
|
|
13
|
+
React 18.2 or later is a peer dependency.
|
|
14
14
|
|
|
15
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
16
|
|
|
@@ -47,12 +47,12 @@ export function Settings() {
|
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
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.
|
|
50
|
+
- **Any React app:** Vite, Remix and other React 18.2+ setups work the same way: import the CSS once, then the components. Bundlers resolve the font files referenced by the CSS.
|
|
51
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
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
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
54
|
- **Tree-shaking:** each component is its own module, so an app bundles only the components it imports.
|
|
55
|
-
- **Built on Radix:**
|
|
55
|
+
- **Built on Radix:** complete library components receive the system's styles, icons, content layout and typed data mapping. Radix owns state, keyboard, focus, gestures, dismissal, forms and timing; the design system does not run a second interaction engine. Composite controls use existing primitives for the parts they provide. `radix-ui` installs with the package; you do not import it yourself. See the component docs for its upstream contracts.
|
|
56
56
|
|
|
57
57
|
## Themes
|
|
58
58
|
|
|
@@ -92,6 +92,43 @@ Set `<html data-density="compact">` for dense operational interfaces. It uses 20
|
|
|
92
92
|
|
|
93
93
|
Compose pages with `Stack`, `Inline` and `Grid`; these forward standard attributes and events typed for the element they render, including `Inline as="form" onSubmit={...}`. Use `Fieldset` for related controls, `Button variant="text"` for record names, and `Text numeric overflowWrap="anywhere"` for long identifiers.
|
|
94
94
|
|
|
95
|
+
## Localization
|
|
96
|
+
|
|
97
|
+
Wrap the app in `LocaleProvider` to set built-in interface labels and formatting together. The default is `en-US`; Dutch messages cover the documented `nl-*` locales. Papiamentu locale tags retain the existing matching Dutch fallback for formatting and interface copy.
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { LocaleProvider } from "@vokality/design-system/localization";
|
|
101
|
+
|
|
102
|
+
<LocaleProvider locale="nl-CW" messages={{ close: "Sluiten" }}>
|
|
103
|
+
<App />
|
|
104
|
+
</LocaleProvider>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Providers nest, update when their props change, and reach portalled controls. `messages` accepts typed string and interpolation-function overrides; omitted keys inherit. Existing label props override the dictionary, and a control's explicit `locale` selects its own formatting and default messages. Pure formatting helpers still take an explicit locale. See `docs/components/LocaleProvider/README.md`.
|
|
108
|
+
|
|
109
|
+
## Rich-text editing
|
|
110
|
+
|
|
111
|
+
`RichTextEditor` stores Markdown and supports basic text formatting, Unicode emoji, and attachment links. It uses the same field, focus, density, theme and localization conventions as the other controls. Import it through its direct entrypoint:
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { RichTextEditor } from "@vokality/design-system/rich-text";
|
|
115
|
+
|
|
116
|
+
<Field label="Notes">
|
|
117
|
+
<RichTextEditor name="notes" value={markdown} onChange={setMarkdown}
|
|
118
|
+
onUploadAttachment={uploadAttachment} />
|
|
119
|
+
</Field>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The app supplies `uploadAttachment(file, { signal })`, which returns a promise of `{ name, url }`. The component manages upload feedback and inserts the returned attachment as a Markdown link. Store the Markdown value in your app; storage and upload endpoints remain app responsibilities. See `docs/components/RichTextEditor/README.md` for the content contract, supported formatting and upload recovery.
|
|
123
|
+
|
|
124
|
+
## Chat surfaces
|
|
125
|
+
|
|
126
|
+
`ChatWidget` supplies a floating launcher and a Radix popup. `ChatInbox` supplies an embedded conversation list and message panel, with a list/detail view on phones. Both reuse the Markdown rich editor for formatting, emoji and optional attachment uploads. Apps supply render-ready messages, selected conversations and send/retry callbacks; transport, streaming updates, persistence and authentication remain app responsibilities.
|
|
127
|
+
|
|
128
|
+
The composer starts with a message field, emoji and optional attachment action. One formatting toggle reveals basic text tools. Motion adds short chat entrance/exit, launcher feedback and new-message transitions; existing history stays still, and reduced-motion preferences disable these animations. See the [Motion and Radix integration guide](https://motion.dev/docs/radix) for the upstream composition pattern.
|
|
129
|
+
|
|
130
|
+
Import the components from `@vokality/design-system/chat-widget` and `@vokality/design-system/chat-inbox`. Shared message, conversation and composer types are defined in `@vokality/design-system/chat-models`. See the component documentation for controlled draft and message contracts.
|
|
131
|
+
|
|
95
132
|
## Starting a new project
|
|
96
133
|
|
|
97
134
|
[`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**.
|
|
@@ -111,6 +148,11 @@ Every token becomes a utility that follows the active theme: `bg-background`, `b
|
|
|
111
148
|
| Path | Contents |
|
|
112
149
|
| --- | --- |
|
|
113
150
|
| `.` | React components, `toast`, format helpers (`formatNumber`, `formatCurrency`, `formatPercent`, `formatDate`), `utils`, `iconData` |
|
|
151
|
+
| `localization` | `LocaleProvider`, `useLocale` and typed message contracts |
|
|
152
|
+
| `rich-text` | `RichTextEditor` and its Markdown, emoji and upload contracts |
|
|
153
|
+
| `chat-widget` | Floating `ChatWidget` |
|
|
154
|
+
| `chat-inbox` | Embedded `ChatInbox` |
|
|
155
|
+
| `chat-models` | Shared chat message, conversation and composer types |
|
|
114
156
|
| `vokality.css` | `fonts.css` + `tokens.css` + `components.css` |
|
|
115
157
|
| `tokens.css` | CSS custom properties for every theme, plus `.vk-text-*` type styles |
|
|
116
158
|
| `tailwind.css` | Tailwind v4 `@theme` mapping |
|
|
@@ -127,6 +169,20 @@ The design guide and every component's page ship with the package, so they match
|
|
|
127
169
|
- `node_modules/@vokality/design-system/docs/brand.md`: principles, color, type, layout, writing.
|
|
128
170
|
- `node_modules/@vokality/design-system/docs/components/<Name>/README.md`: anatomy, states, props, accessibility and rules for each component.
|
|
129
171
|
|
|
172
|
+
## Agent skill
|
|
173
|
+
|
|
174
|
+
The package includes a standard [Agent Skill](https://agentskills.io/specification) with version-matched integration guidance. After installing the package, run this **once from your consuming project root** to register it for Codex:
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
bun run vokality-skill
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The opt-in command creates `.agents/skills/vokality-design-system` as a link to the installed package’s `skills/vokality-design-system` directory. It follows the logical `node_modules` path, including hoisted workspace dependencies, so package upgrades update the guidance without copying it. Use `bun run vokality-skill --project <project-root>` to select a project explicitly. Existing files or other skills are never replaced. Installation itself runs no skill setup and changes no agent instructions.
|
|
181
|
+
|
|
182
|
+
Codex supports [project-local and symlinked skills](https://learn.chatgpt.com/docs/build-skills). It can select this skill when relevant, or you can invoke `$vokality-design-system`. For another Agent Skills-compatible tool, register the same bundled folder using that tool’s documented discovery location. The skill points to the shipped component docs, tokens and declarations; those remain the API source of truth. It does not install checks or enforce application code automatically.
|
|
183
|
+
|
|
184
|
+
On Unix, the relative link can be committed when the team shares the dependency layout. On Windows the command uses a directory junction; keep that machine-local path untracked. Remove the link to unregister the skill; do not remove its target in `node_modules`.
|
|
185
|
+
|
|
130
186
|
## Develop
|
|
131
187
|
|
|
132
188
|
```sh
|
|
@@ -134,6 +190,10 @@ bun install
|
|
|
134
190
|
bun run test # build, then token, contrast, format, render and build tests (bun test)
|
|
135
191
|
bun run test:browser # keyboard, focus and overlay behaviour in headless Chromium
|
|
136
192
|
bun run typecheck # the declarations against test/types-usage.tsx
|
|
193
|
+
bun run lint # strict type-aware TypeScript and React/Hooks rules
|
|
194
|
+
bun run doctor # full production-source React Doctor scan
|
|
195
|
+
bun run test:visual # compare all theme previews against reviewed image baselines
|
|
196
|
+
bun run test:next # production Next.js App Router consumer and hydration checks
|
|
137
197
|
bun run preview --theme=light # render every docs/components preview; screenshots in artifact/shots
|
|
138
198
|
bun run artifact # build the claude.ai docs page in artifact/ (see "The docs page" in CONTRIBUTING.md)
|
|
139
199
|
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { access, lstat, mkdir, readFile, readlink, realpath, symlink } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
const skillName = "vokality-design-system";
|
|
6
|
+
const usage = "Usage: vokality-skill [--project <project-root>]\nLinks the installed package skill into .agents/skills/vokality-design-system.\nRun explicitly from a project with package.json; existing skills are never replaced.";
|
|
7
|
+
|
|
8
|
+
async function installedSkill(project) {
|
|
9
|
+
for (let directory = project; ; directory = dirname(directory)) {
|
|
10
|
+
const packageRoot = join(directory, "node_modules", "@vokality", "design-system");
|
|
11
|
+
let manifest;
|
|
12
|
+
try {
|
|
13
|
+
manifest = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf8"));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (error.code !== "ENOENT") throw error;
|
|
16
|
+
if (dirname(directory) === directory) break;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (manifest?.name !== "@vokality/design-system" || typeof manifest.version !== "string") {
|
|
20
|
+
throw new Error(`Invalid design-system package at ${packageRoot}`);
|
|
21
|
+
}
|
|
22
|
+
const target = join(packageRoot, "skills", skillName);
|
|
23
|
+
await access(join(target, "SKILL.md")).catch(() => {
|
|
24
|
+
throw new Error(`The installed @vokality/design-system@${manifest.version} has no bundled skill. Upgrade the package first.`);
|
|
25
|
+
});
|
|
26
|
+
return { target, version: manifest.version };
|
|
27
|
+
}
|
|
28
|
+
throw new Error("Install @vokality/design-system in this project before linking its skill.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function main() {
|
|
32
|
+
const args = process.argv.slice(2);
|
|
33
|
+
if (args.length === 1 && ["--help", "-h"].includes(args[0])) {
|
|
34
|
+
console.log(usage);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (args.length !== 0 && (args.length !== 2 || args[0] !== "--project" || !args[1] || args[1].startsWith("--"))) {
|
|
38
|
+
throw new Error(usage);
|
|
39
|
+
}
|
|
40
|
+
const project = resolve(args[1] ?? process.cwd());
|
|
41
|
+
await access(join(project, "package.json")).catch(() => {
|
|
42
|
+
throw new Error(`No package.json at ${project}. Run from the project root or pass --project <project-root>.`);
|
|
43
|
+
});
|
|
44
|
+
const { target, version } = await installedSkill(project);
|
|
45
|
+
const destination = join(project, ".agents", "skills", skillName);
|
|
46
|
+
await mkdir(dirname(destination), { recursive: true });
|
|
47
|
+
const physicalParent = await realpath(dirname(destination));
|
|
48
|
+
const existing = await lstat(destination).catch((error) => {
|
|
49
|
+
if (error.code === "ENOENT") return null;
|
|
50
|
+
throw error;
|
|
51
|
+
});
|
|
52
|
+
if (existing) {
|
|
53
|
+
if (!existing.isSymbolicLink() || resolve(physicalParent, await readlink(destination)) !== target) {
|
|
54
|
+
throw new Error(`A different skill already exists at ${destination}. Move it yourself before linking; nothing was replaced.`);
|
|
55
|
+
}
|
|
56
|
+
console.log(`Already linked @vokality/design-system@${version}: ${destination}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Keep the logical node_modules path: package-manager store paths change on upgrades.
|
|
60
|
+
const linkTarget = process.platform === "win32" ? target : relative(physicalParent, target);
|
|
61
|
+
await symlink(linkTarget, destination, process.platform === "win32" ? "junction" : "dir");
|
|
62
|
+
console.log(`Linked @vokality/design-system@${version}: ${destination}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main().catch((error) => {
|
|
66
|
+
console.error(error.message);
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as components from "./index.js";
|
|
2
|
+
import { LocaleProvider, useLocale } from "./localization.js";
|
|
3
|
+
import { ChatWidget } from "./components/ChatWidget/ChatWidget.js";
|
|
4
|
+
import { ChatInbox } from "./components/ChatInbox/ChatInbox.js";
|
|
5
|
+
import { RichTextEditor } from "./components/RichTextEditor/RichTextEditor.js";
|
|
6
|
+
/** The complete API used by the documentation and script-tag browser build. */
|
|
7
|
+
export declare const browserApi: typeof components & {
|
|
8
|
+
LocaleProvider: typeof LocaleProvider;
|
|
9
|
+
useLocale: typeof useLocale;
|
|
10
|
+
RichTextEditor: typeof RichTextEditor;
|
|
11
|
+
ChatWidget: typeof ChatWidget;
|
|
12
|
+
ChatInbox: typeof ChatInbox;
|
|
13
|
+
};
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as components from "./index.js";
|
|
2
|
+
import { LocaleProvider, useLocale } from "./localization.js";
|
|
3
|
+
import { ChatWidget } from "./components/ChatWidget/ChatWidget.js";
|
|
4
|
+
import { ChatInbox } from "./components/ChatInbox/ChatInbox.js";
|
|
5
|
+
import { RichTextEditor } from "./components/RichTextEditor/RichTextEditor.js";
|
|
6
|
+
/** The complete API used by the documentation and script-tag browser build. */
|
|
7
|
+
export const browserApi = { ...components, LocaleProvider, useLocale, RichTextEditor, ChatWidget, ChatInbox };
|
package/dist/charts/chart.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Dispatch, KeyboardEvent, ReactNode,
|
|
1
|
+
import type { Dispatch, KeyboardEvent, ReactNode, RefCallback, SetStateAction } from "react";
|
|
2
2
|
import type { ChartProps, ChartSeries } from "../types.js";
|
|
3
3
|
export type ChartFormat = (value: number) => string;
|
|
4
4
|
/** What the frame, table and tooltip read: the chart's props with the series, formatter and x key resolved. */
|
|
5
5
|
export interface ChartViewProps<Row> {
|
|
6
|
+
locale?: string;
|
|
6
7
|
data: Row[];
|
|
7
8
|
series: ChartSeries[];
|
|
8
9
|
format: ChartFormat;
|
|
@@ -16,11 +17,11 @@ export interface ChartViewProps<Row> {
|
|
|
16
17
|
}
|
|
17
18
|
/** The field `key` of `row`, as stored. */
|
|
18
19
|
export declare function cell(row: unknown, key: string): unknown;
|
|
19
|
-
/**
|
|
20
|
+
/** Missing measurements retain the existing zero-height geometry. */
|
|
20
21
|
export declare function cellNumber(row: unknown, key: string): number;
|
|
21
22
|
/** The field as a label (the x value). */
|
|
22
23
|
export declare function cellLabel(row: unknown, key: string): ReactNode;
|
|
23
|
-
export declare function useWidth(
|
|
24
|
+
export declare function useWidth(element: HTMLElement | null, fallback: number): number;
|
|
24
25
|
export declare function seriesColor(i: number): string;
|
|
25
26
|
export declare function ChartLegend({ series }: {
|
|
26
27
|
series: ChartSeries[];
|
|
@@ -35,7 +36,7 @@ export declare function ChartFrame<Row>(props: ChartViewProps<Row> & {
|
|
|
35
36
|
/** The tooltip for the row at `idx`, centred on `x` but kept inside the plot. */
|
|
36
37
|
export declare function chartTooltip<Row>(props: ChartViewProps<Row>, idx: number | null, x: number, width: number): import("react/jsx-runtime").JSX.Element | null;
|
|
37
38
|
export interface ChartState {
|
|
38
|
-
|
|
39
|
+
setPlotElement: RefCallback<HTMLDivElement>;
|
|
39
40
|
width: number;
|
|
40
41
|
/** Index of the row under the pointer or keyboard focus. */
|
|
41
42
|
active: number | null;
|
|
@@ -49,4 +50,4 @@ export declare function useChart<Row>(props: ChartProps<Row> & {
|
|
|
49
50
|
valueLabel?: string;
|
|
50
51
|
}): ChartState;
|
|
51
52
|
/** Arrow keys, Home and End step through the rows; Escape clears. */
|
|
52
|
-
export declare function chartKeys(c: ChartState, n: number): (e: KeyboardEvent<HTMLElement>) => void;
|
|
53
|
+
export declare function chartKeys(c: Pick<ChartState, "active" | "setActive">, n: number): (e: KeyboardEvent<HTMLElement>) => void;
|
package/dist/charts/chart.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useLocale } from "../localization.js";
|
|
4
|
+
import { isValidElement, useState } from "react";
|
|
4
5
|
import { Button } from "../components/Button/Button.js";
|
|
5
6
|
import { useIsoLayoutEffect } from "../internal/useIsoLayoutEffect.js";
|
|
6
7
|
import { cx } from "../lib/cx.js";
|
|
7
8
|
import { numberFormat } from "../lib/intl.js";
|
|
8
|
-
import { para } from "../lib/text.js";
|
|
9
9
|
/* Rows are caller data of any shape: these read one field by name. */
|
|
10
10
|
/** The field `key` of `row`, as stored. */
|
|
11
11
|
export function cell(row, key) {
|
|
12
12
|
return typeof row === "object" && row !== null ? Reflect.get(row, key) : undefined;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
14
|
+
/** Validate unknown row values once before geometry or formatting consumes a number. */
|
|
15
|
+
function measurement(row, key) {
|
|
16
|
+
const value = cell(row, key);
|
|
17
|
+
if (value == null)
|
|
18
|
+
return null;
|
|
19
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
20
|
+
throw new TypeError(`Chart measurement "${key}" must be a finite number or null.`);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
/** Missing measurements retain the existing zero-height geometry. */
|
|
15
24
|
export function cellNumber(row, key) {
|
|
16
|
-
return
|
|
25
|
+
return measurement(row, key) ?? 0;
|
|
17
26
|
}
|
|
18
27
|
/** The field as a label (the x value). */
|
|
19
28
|
export function cellLabel(row, key) {
|
|
@@ -22,16 +31,16 @@ export function cellLabel(row, key) {
|
|
|
22
31
|
}
|
|
23
32
|
/** The field through the value formatter, which gets the raw value: the default shows "—" for a missing one. */
|
|
24
33
|
function formatCell(format, row, key) {
|
|
25
|
-
|
|
34
|
+
const value = measurement(row, key);
|
|
35
|
+
return value === null ? "—" : format(value);
|
|
26
36
|
}
|
|
27
|
-
export function useWidth(
|
|
37
|
+
export function useWidth(element, fallback) {
|
|
28
38
|
const [width, setWidth] = useState(fallback);
|
|
29
39
|
useIsoLayoutEffect(() => {
|
|
30
|
-
|
|
31
|
-
if (!el)
|
|
40
|
+
if (!element)
|
|
32
41
|
return;
|
|
33
42
|
const set = () => {
|
|
34
|
-
const w =
|
|
43
|
+
const w = element.getBoundingClientRect().width;
|
|
35
44
|
if (w)
|
|
36
45
|
setWidth(Math.round(w));
|
|
37
46
|
};
|
|
@@ -39,32 +48,41 @@ export function useWidth(ref, fallback) {
|
|
|
39
48
|
if (typeof ResizeObserver === "undefined")
|
|
40
49
|
return;
|
|
41
50
|
const ro = new ResizeObserver(set);
|
|
42
|
-
ro.observe(
|
|
43
|
-
return () => ro.disconnect();
|
|
44
|
-
}, []);
|
|
51
|
+
ro.observe(element);
|
|
52
|
+
return () => { ro.disconnect(); };
|
|
53
|
+
}, [element]);
|
|
45
54
|
return width;
|
|
46
55
|
}
|
|
47
56
|
export function seriesColor(i) {
|
|
48
|
-
return
|
|
57
|
+
return `var(--chart-${String((i % 8) + 1)})`;
|
|
49
58
|
}
|
|
50
59
|
export function ChartLegend({ series }) {
|
|
51
60
|
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
61
|
}
|
|
53
62
|
export function ChartTable(props) {
|
|
63
|
+
const { messages } = useLocale(props.locale);
|
|
54
64
|
const { data, series, format, xKey } = props;
|
|
55
|
-
|
|
65
|
+
// Categories need not be unique. Count only equal categories so inserting or
|
|
66
|
+
// reordering unrelated rows preserves their identity without a public row ID.
|
|
67
|
+
const occurrences = new Map();
|
|
68
|
+
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 || messages.category }), series.map((s) => _jsx("th", { scope: "col", className: "vk-td-end", children: s.label }, s.key))] }) }), _jsx("tbody", { children: data.map((d) => {
|
|
69
|
+
const category = String(cell(d, xKey));
|
|
70
|
+
const occurrence = occurrences.get(category) ?? 0;
|
|
71
|
+
occurrences.set(category, occurrence + 1);
|
|
72
|
+
return _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))] }, `${category}#${String(occurrence)}`);
|
|
73
|
+
}) })] }));
|
|
56
74
|
}
|
|
57
75
|
/** The chart's caption: title, description and the "Show table" toggle. */
|
|
58
|
-
function ChartCaption({ title, description, allowTable, showTable, onToggle }) {
|
|
59
|
-
const
|
|
60
|
-
return (_jsxs("figcaption", { className: "vk-chart-head", children: [_jsxs("div", { children: [title ? _jsx("p", { className: "vk-chart-title", children: title }) : null, description ? _jsx(
|
|
76
|
+
function ChartCaption({ title, description, allowTable, showTable, onToggle, locale }) {
|
|
77
|
+
const { messages } = useLocale(locale);
|
|
78
|
+
return (_jsxs("figcaption", { className: "vk-chart-head", children: [_jsxs("div", { children: [title ? _jsx("p", { className: "vk-chart-title", children: title }) : null, description ? _jsx("p", { className: "vk-chart-description", children: description }) : null] }), allowTable !== false ? _jsx(Button, { variant: "ghost", size: "sm", "aria-pressed": showTable ? "true" : "false", onClick: onToggle, children: showTable ? messages.showChart : messages.showTable }) : null] }));
|
|
61
79
|
}
|
|
62
80
|
/** The figure around a chart: title, description, the "Show table" toggle, the legend and a screen-reader table. */
|
|
63
81
|
export function ChartFrame(props) {
|
|
64
82
|
const [showTable, setShowTable] = useState(false);
|
|
65
83
|
const { title, description, allowTable, series } = props;
|
|
66
84
|
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 }) })] }))] }));
|
|
85
|
+
return (_jsxs("figure", { className: cx("vk-chart", props.className), children: [hasCaption ? _jsx(ChartCaption, { locale: props.locale, 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
86
|
}
|
|
69
87
|
/** The tooltip for the row at `idx`, centred on `x` but kept inside the plot. */
|
|
70
88
|
export function chartTooltip(props, idx, x, width) {
|
|
@@ -72,15 +90,16 @@ export function chartTooltip(props, idx, x, width) {
|
|
|
72
90
|
return null;
|
|
73
91
|
const d = props.data[idx];
|
|
74
92
|
const left = Math.min(Math.max(x, 80), width - 80);
|
|
75
|
-
return (_jsxs("div", { className: "vk-chart-tooltip", style: { left: left
|
|
93
|
+
return (_jsxs("div", { className: "vk-chart-tooltip", style: { left: `${String(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
94
|
}
|
|
77
95
|
export function useChart(props) {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
96
|
+
const { locale, messages } = useLocale(props.locale);
|
|
97
|
+
const [plotElement, setPlotElement] = useState(null);
|
|
98
|
+
const width = useWidth(plotElement, props.width || 640);
|
|
80
99
|
const [active, setActive] = useState(null);
|
|
81
|
-
const fmt = props.valueFormat || ((v) =>
|
|
82
|
-
const series = props.series || [{ key: "value", label: props.valueLabel ||
|
|
83
|
-
return {
|
|
100
|
+
const fmt = props.valueFormat || ((v) => numberFormat(locale).format(v));
|
|
101
|
+
const series = props.series || [{ key: "value", label: props.valueLabel || messages.value }];
|
|
102
|
+
return { setPlotElement, width, active, setActive, fmt, series, xKey: props.xKey || "label" };
|
|
84
103
|
}
|
|
85
104
|
/** Arrow keys, Home and End step through the rows; Escape clears. */
|
|
86
105
|
export function chartKeys(c, n) {
|
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RichTextEditorProps } from "./components/RichTextEditor/RichTextEditor.js";
|
|
3
|
+
/** Render-ready identity; pass an Avatar or another accessible visual in the slot. */
|
|
4
|
+
export interface ChatAuthor {
|
|
5
|
+
name: string;
|
|
6
|
+
avatar?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/** Applications own delivery, persistence and retry requests. Omit for a sent message. */
|
|
9
|
+
export type ChatMessageDelivery = {
|
|
10
|
+
state: "pending";
|
|
11
|
+
} | {
|
|
12
|
+
state: "failed";
|
|
13
|
+
error?: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export interface ChatMessage {
|
|
16
|
+
id: string;
|
|
17
|
+
author: ChatAuthor;
|
|
18
|
+
/** React content ready to display. Render Markdown in the application if needed. */
|
|
19
|
+
content: ReactNode;
|
|
20
|
+
timestamp?: ReactNode;
|
|
21
|
+
direction: "incoming" | "outgoing";
|
|
22
|
+
delivery?: ChatMessageDelivery;
|
|
23
|
+
}
|
|
24
|
+
/** The application handles async sending and supplies pending/error message data. */
|
|
25
|
+
export interface ChatComposerOptions extends Pick<RichTextEditorProps, "value" | "defaultValue" | "onChange" | "disabled" | "placeholder" | "name" | "onUploadAttachment" | "accept" | "maxFileSize" | "emojiOptions" | "onUploadError"> {
|
|
26
|
+
/** Returns after accepting the message. Only uncontrolled drafts clear automatically. */
|
|
27
|
+
onSend: (markdown: string) => void;
|
|
28
|
+
sending?: boolean;
|
|
29
|
+
label?: string;
|
|
30
|
+
sendLabel?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ChatThread {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
preview?: ReactNode;
|
|
36
|
+
avatar?: ReactNode;
|
|
37
|
+
timestamp?: ReactNode;
|
|
38
|
+
/** Positive whole-number count supplied by the application. */
|
|
39
|
+
unreadCount?: number;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** Shared conversation presentation used by the widget and inbox. */
|
|
43
|
+
export interface ChatPanelProps {
|
|
44
|
+
messages: readonly ChatMessage[];
|
|
45
|
+
composer: ChatComposerOptions;
|
|
46
|
+
emptyState?: ReactNode;
|
|
47
|
+
/** App-provided response/loading feedback, displayed in a polite status region. */
|
|
48
|
+
pending?: ReactNode;
|
|
49
|
+
error?: ReactNode;
|
|
50
|
+
onRetry?: () => void;
|
|
51
|
+
onRetryMessage?: (messageId: string) => void;
|
|
52
|
+
className?: string;
|
|
53
|
+
"aria-label"?: string;
|
|
54
|
+
}
|
package/dist/chat.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,7 +5,7 @@ import { Icon } from "../Icon/Icon.js";
|
|
|
5
5
|
import { cx } from "../../lib/cx.js";
|
|
6
6
|
/** A stack of sections that expand and collapse, for long content people scan by heading: settings groups, FAQs, details. */
|
|
7
7
|
export function Accordion({ items: itemsProp, type, defaultOpen, headingLevel, className }) {
|
|
8
|
-
const items = itemsProp
|
|
8
|
+
const items = itemsProp;
|
|
9
9
|
const Heading = headingLevel || "h3";
|
|
10
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
11
|
const cls = cx("vk-accordion", className);
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useLocale } from "../../localization.js";
|
|
2
4
|
import { Icon } from "../Icon/Icon.js";
|
|
3
5
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
4
|
-
import { STATUS_ICON,
|
|
6
|
+
import { STATUS_ICON, statusWord } from "../../internal/status.js";
|
|
5
7
|
import { cx } from "../../lib/cx.js";
|
|
6
8
|
/** Inline status message. */
|
|
7
9
|
export function Alert({ status: statusProp, title, children, action, onDismiss, dismissLabel, live, className }) {
|
|
10
|
+
const { messages } = useLocale();
|
|
8
11
|
const status = statusProp || "info";
|
|
9
12
|
// Live alerts announce themselves: urgently for danger and warning, politely otherwise.
|
|
10
13
|
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:
|
|
14
|
+
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: statusWord(status, messages) + ": " }), 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 || messages.dismiss, className: "vk-alert-close", onClick: onDismiss }) : null] }));
|
|
12
15
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useLocale } from "../../localization.js";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
4
5
|
import { Dialog as Primitive } from "radix-ui";
|
|
5
6
|
import { Icon } from "../Icon/Icon.js";
|
|
6
|
-
import { focusables } from "../../internal/focusables.js";
|
|
7
7
|
import { useUid } from "../../internal/useUid.js";
|
|
8
8
|
import { cx } from "../../lib/cx.js";
|
|
9
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
10
|
export function AppShell(props) {
|
|
11
|
+
const { messages } = useLocale();
|
|
11
12
|
const [mobileOpen, setMobileOpen] = useState(false);
|
|
12
13
|
const [collapsed, setCollapsed] = useState(Boolean(props.defaultCollapsed));
|
|
13
14
|
const sidebarId = useUid("vk-sidebar");
|
|
14
15
|
const mainId = props.mainId || "main";
|
|
15
16
|
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 ||
|
|
17
|
+
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 || messages.skipToContent }), _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 || messages.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
|
}
|
|
18
19
|
/** The slide-over only exists under 48rem: growing past that closes it. */
|
|
19
20
|
function useCloseWhenWide(open, setOpen) {
|
|
@@ -25,24 +26,19 @@ function useCloseWhenWide(open, setOpen) {
|
|
|
25
26
|
setOpen(false); };
|
|
26
27
|
onChange();
|
|
27
28
|
mq.addEventListener("change", onChange);
|
|
28
|
-
return () => mq.removeEventListener("change", onChange);
|
|
29
|
+
return () => { mq.removeEventListener("change", onChange); };
|
|
29
30
|
}, [open, setOpen]);
|
|
30
31
|
}
|
|
31
32
|
function ShellTopbar(props) {
|
|
33
|
+
const { messages } = useLocale();
|
|
32
34
|
const { sidebarId, mobileOpen, collapsed } = props;
|
|
33
|
-
const collapseLabel = collapsed ? props.expandLabel ||
|
|
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 ||
|
|
35
|
+
const collapseLabel = collapsed ? props.expandLabel || messages.showSidebar : props.collapseLabel || messages.hideSidebar;
|
|
36
|
+
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 || messages.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
37
|
}
|
|
36
38
|
function ShellSidebar({ id, modal, label, footer, children }) {
|
|
37
|
-
const
|
|
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
|
+
const aside = (_jsxs("aside", { id: id, className: "vk-shell-sidebar", "aria-label": label, children: [children, footer ? _jsx("div", { className: "vk-shell-sidebar-footer", children: footer }) : null] }));
|
|
39
40
|
if (!modal)
|
|
40
41
|
return aside;
|
|
41
42
|
// 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,
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
const el = sidebarRef.current;
|
|
45
|
-
if (el)
|
|
46
|
-
(focusables(el)[0] || el).focus();
|
|
47
|
-
}, children: aside }));
|
|
43
|
+
return (_jsx(Primitive.Content, { asChild: true, "aria-modal": "true", "aria-describedby": undefined, children: aside }));
|
|
48
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/** Up to two initials from a name: "Ana de Vries" → "AD". */
|
|
3
3
|
export function initials(name) {
|
|
4
|
-
return
|
|
4
|
+
return (name || "")
|
|
5
5
|
.split(/\s+/)
|
|
6
6
|
.filter(Boolean)
|
|
7
7
|
.slice(0, 2)
|
|
@@ -11,7 +11,7 @@ export function initials(name) {
|
|
|
11
11
|
/** Photo or initials in a disc; people only. */
|
|
12
12
|
export function Avatar(props) {
|
|
13
13
|
const size = props.size || 34;
|
|
14
|
-
const style = { width: size + "px", height: size + "px", fontSize: Math.round(size * 0.32) + "px" };
|
|
14
|
+
const style = { width: String(size) + "px", height: String(size) + "px", fontSize: String(Math.round(size * 0.32)) + "px" };
|
|
15
15
|
if (props.src)
|
|
16
16
|
return _jsx("img", { className: "vk-avatar", src: props.src, alt: props.alt || "", width: size, height: size, style: style });
|
|
17
17
|
const a11y = props.decorative ? { "aria-hidden": "true" } : { role: "img", "aria-label": props.name };
|
|
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Avatar } from "../Avatar/Avatar.js";
|
|
3
3
|
/** A row of overlapping avatars for the people on a record, with a "+N" for the rest. */
|
|
4
4
|
export function AvatarGroup(props) {
|
|
5
|
-
const people = props.people
|
|
5
|
+
const people = props.people;
|
|
6
6
|
const max = props.max || 4;
|
|
7
7
|
// When some are hidden, the last slot holds the "+N" count.
|
|
8
8
|
const shown = people.slice(0, people.length > max ? max - 1 : max);
|
|
9
9
|
const rest = people.length - shown.length;
|
|
10
10
|
const size = props.size || 28;
|
|
11
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] }));
|
|
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: String(size) + "px", height: String(size) + "px", fontSize: String(Math.round(size * 0.36)) + "px" }, "aria-hidden": "true", children: "+" + String(rest) }) })) : null] }));
|
|
13
13
|
}
|