@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.
Files changed (164) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +63 -3
  3. package/bin/vokality-skill.mjs +68 -0
  4. package/dist/browser.d.ts +13 -0
  5. package/dist/browser.js +7 -0
  6. package/dist/charts/chart.d.ts +6 -5
  7. package/dist/charts/chart.js +44 -25
  8. package/dist/chat.d.ts +54 -0
  9. package/dist/chat.js +1 -0
  10. package/dist/components/Accordion/Accordion.js +1 -1
  11. package/dist/components/Alert/Alert.js +5 -2
  12. package/dist/components/AppShell/AppShell.js +10 -14
  13. package/dist/components/Avatar/Avatar.js +2 -2
  14. package/dist/components/AvatarGroup/AvatarGroup.js +2 -2
  15. package/dist/components/BarChart/BarChart.js +17 -15
  16. package/dist/components/Breadcrumbs/Breadcrumbs.js +6 -3
  17. package/dist/components/Calendar/Calendar.js +6 -5
  18. package/dist/components/Card/Card.js +2 -3
  19. package/dist/components/ChatInbox/ChatInbox.d.ts +11 -0
  20. package/dist/components/ChatInbox/ChatInbox.js +49 -0
  21. package/dist/components/ChatPanel/ChatPanel.d.ts +3 -0
  22. package/dist/components/ChatPanel/ChatPanel.js +13 -0
  23. package/dist/components/ChatPanel/composer.d.ts +5 -0
  24. package/dist/components/ChatPanel/composer.js +32 -0
  25. package/dist/components/ChatPanel/transcript.d.ts +13 -0
  26. package/dist/components/ChatPanel/transcript.js +39 -0
  27. package/dist/components/ChatWidget/ChatWidget.d.ts +12 -0
  28. package/dist/components/ChatWidget/ChatWidget.js +42 -0
  29. package/dist/components/Checkbox/Checkbox.d.ts +5 -10
  30. package/dist/components/Checkbox/Checkbox.js +5 -19
  31. package/dist/components/CodeBlock/CodeBlock.js +19 -5
  32. package/dist/components/Combobox/Combobox.js +22 -15
  33. package/dist/components/Combobox/ListPanel.js +20 -9
  34. package/dist/components/CommandPalette/CommandPalette.js +33 -14
  35. package/dist/components/ContextMenu/ContextMenu.d.ts +2 -2
  36. package/dist/components/ContextMenu/ContextMenu.js +5 -50
  37. package/dist/components/DatePicker/DatePicker.js +35 -29
  38. package/dist/components/DescriptionList/DescriptionList.js +1 -1
  39. package/dist/components/Dialog/Dialog.d.ts +24 -7
  40. package/dist/components/Dialog/Dialog.js +30 -41
  41. package/dist/components/Drawer/Drawer.d.ts +4 -2
  42. package/dist/components/EmptyState/EmptyState.js +2 -2
  43. package/dist/components/ErrorSummary/ErrorSummary.js +5 -3
  44. package/dist/components/FaqList/FaqList.js +1 -1
  45. package/dist/components/Field/Field.js +2 -2
  46. package/dist/components/FileUpload/FileUpload.js +17 -9
  47. package/dist/components/Grid/Grid.d.ts +5 -5
  48. package/dist/components/Grid/Grid.js +1 -1
  49. package/dist/components/Heading/Heading.js +2 -1
  50. package/dist/components/Icon/Icon.js +4 -2
  51. package/dist/components/Inline/Inline.d.ts +7 -7
  52. package/dist/components/LineChart/LineChart.js +17 -15
  53. package/dist/components/LinkProvider/LinkProvider.d.ts +1 -1
  54. package/dist/components/LinkProvider/LinkProvider.js +6 -2
  55. package/dist/components/List/List.js +1 -1
  56. package/dist/components/MediaCard/MediaCard.js +2 -2
  57. package/dist/components/Menu/Menu.js +6 -43
  58. package/dist/components/Menu/entries.d.ts +1 -30
  59. package/dist/components/Menu/entries.js +16 -100
  60. package/dist/components/MultiSelect/MultiSelect.js +43 -34
  61. package/dist/components/NumberInput/NumberInput.js +17 -18
  62. package/dist/components/OtpInput/OtpInput.d.ts +1 -1
  63. package/dist/components/OtpInput/OtpInput.js +10 -67
  64. package/dist/components/PageHeader/PageHeader.js +2 -2
  65. package/dist/components/Pagination/Pagination.js +3 -1
  66. package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
  67. package/dist/components/PasswordInput/PasswordInput.js +9 -4
  68. package/dist/components/Popover/Popover.d.ts +6 -7
  69. package/dist/components/Popover/Popover.js +2 -19
  70. package/dist/components/Progress/Progress.d.ts +1 -1
  71. package/dist/components/Progress/Progress.js +7 -11
  72. package/dist/components/Radio/Radio.d.ts +4 -2
  73. package/dist/components/RadioGroup/RadioGroup.d.ts +5 -12
  74. package/dist/components/RadioGroup/RadioGroup.js +6 -33
  75. package/dist/components/RichTextEditor/RichTextEditor.d.ts +63 -0
  76. package/dist/components/RichTextEditor/RichTextEditor.js +175 -0
  77. package/dist/components/RichTextEditor/toolbar.d.ts +15 -0
  78. package/dist/components/RichTextEditor/toolbar.js +142 -0
  79. package/dist/components/RichTextEditor/uploads.d.ts +41 -0
  80. package/dist/components/RichTextEditor/uploads.js +124 -0
  81. package/dist/components/SearchInput/SearchInput.js +4 -2
  82. package/dist/components/SectionHeader/SectionHeader.js +1 -3
  83. package/dist/components/SegmentedControl/SegmentedControl.js +2 -12
  84. package/dist/components/Select/Select.d.ts +15 -16
  85. package/dist/components/Select/Select.js +11 -252
  86. package/dist/components/Slider/Slider.js +11 -21
  87. package/dist/components/Sparkline/Sparkline.js +8 -3
  88. package/dist/components/Spinner/Spinner.js +5 -2
  89. package/dist/components/Stack/Stack.d.ts +5 -5
  90. package/dist/components/Stat/Stat.js +6 -3
  91. package/dist/components/Steps/Steps.js +6 -3
  92. package/dist/components/Switch/Switch.d.ts +7 -7
  93. package/dist/components/Switch/Switch.js +4 -10
  94. package/dist/components/Table/Table.js +38 -19
  95. package/dist/components/Tabs/Tabs.js +2 -22
  96. package/dist/components/Tag/Tag.js +3 -1
  97. package/dist/components/Text/Text.d.ts +1 -1
  98. package/dist/components/TileGrid/TileGrid.js +1 -1
  99. package/dist/components/TimePicker/TimePicker.js +35 -33
  100. package/dist/components/Timeline/Timeline.js +5 -4
  101. package/dist/components/Toaster/Toaster.js +21 -17
  102. package/dist/components/Tooltip/Tooltip.d.ts +6 -6
  103. package/dist/components/Tooltip/Tooltip.js +3 -17
  104. package/dist/components/TreeView/TreeView.js +15 -12
  105. package/dist/components.css +179 -8
  106. package/dist/hooks/useTheme.js +6 -6
  107. package/dist/icons/message-circle.svg +1 -0
  108. package/dist/internal/CharCount.js +3 -1
  109. package/dist/internal/choice.d.ts +10 -48
  110. package/dist/internal/choice.js +8 -96
  111. package/dist/internal/options.d.ts +10 -5
  112. package/dist/internal/options.js +25 -11
  113. package/dist/internal/status.d.ts +3 -2
  114. package/dist/internal/status.js +10 -2
  115. package/dist/internal/useScrollActive.js +2 -2
  116. package/dist/internal/useToday.d.ts +3 -0
  117. package/dist/internal/useToday.js +42 -0
  118. package/dist/lib/dates.js +25 -15
  119. package/dist/lib/format.js +11 -8
  120. package/dist/lib/icons.d.ts +5 -0
  121. package/dist/lib/icons.js +2 -0
  122. package/dist/lib/math.js +17 -5
  123. package/dist/lib/rich-text.d.ts +13 -0
  124. package/dist/lib/rich-text.js +62 -0
  125. package/dist/lib/space.d.ts +1 -2
  126. package/dist/lib/space.js +4 -1
  127. package/dist/lib/text.js +1 -1
  128. package/dist/lib/theme.js +1 -1
  129. package/dist/localization.d.ts +166 -0
  130. package/dist/localization.js +142 -0
  131. package/dist/vokality.css +179 -8
  132. package/dist/vokality.iife.js +35986 -9685
  133. package/docs/brand.md +6 -3
  134. package/docs/components/AppShell/README.md +1 -1
  135. package/docs/components/BarChart/README.md +1 -0
  136. package/docs/components/ChatInbox/README.md +41 -0
  137. package/docs/components/ChatWidget/README.md +47 -0
  138. package/docs/components/Checkbox/README.md +7 -3
  139. package/docs/components/ContextMenu/README.md +7 -3
  140. package/docs/components/Dialog/README.md +9 -4
  141. package/docs/components/Drawer/README.md +1 -1
  142. package/docs/components/Field/README.md +1 -1
  143. package/docs/components/Fieldset/README.md +2 -2
  144. package/docs/components/LineChart/README.md +1 -0
  145. package/docs/components/LocaleProvider/README.md +48 -0
  146. package/docs/components/Menu/README.md +13 -8
  147. package/docs/components/OtpInput/README.md +9 -5
  148. package/docs/components/PasswordInput/README.md +11 -2
  149. package/docs/components/Popover/README.md +6 -3
  150. package/docs/components/Progress/README.md +3 -1
  151. package/docs/components/RadioGroup/README.md +5 -2
  152. package/docs/components/RichTextEditor/README.md +84 -0
  153. package/docs/components/SegmentedControl/README.md +2 -0
  154. package/docs/components/Select/README.md +13 -17
  155. package/docs/components/Skeleton/README.md +1 -1
  156. package/docs/components/Slider/README.md +4 -2
  157. package/docs/components/Steps/README.md +1 -1
  158. package/docs/components/Switch/README.md +5 -2
  159. package/docs/components/Tabs/README.md +4 -2
  160. package/docs/components/Toaster/README.md +3 -1
  161. package/docs/components/Tooltip/README.md +5 -3
  162. package/package.json +55 -6
  163. package/skills/vokality-design-system/SKILL.md +55 -0
  164. package/skills/vokality-design-system/references/examples.tsx +103 -0
@@ -0,0 +1,124 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
+ import { hasRichTextControlCharacters, isRichTextUrl } from "../../lib/rich-text.js";
5
+ import { formatBytes } from "../../lib/format.js";
6
+ import { useLocale } from "../../localization.js";
7
+ import { useIsoLayoutEffect } from "../../internal/useIsoLayoutEffect.js";
8
+ /** Even a typed app callback is an external runtime boundary. */
9
+ export function validateAttachment(value) {
10
+ if (typeof value !== "object" || value === null || !("name" in value) || !("url" in value) ||
11
+ typeof value.name !== "string" || !value.name.trim() || hasRichTextControlCharacters(value.name) || !isRichTextUrl(value.url) || /^(mailto|tel):/i.test(value.url)) {
12
+ throw new TypeError("An attachment upload must return a non-empty name and a safe HTTP(S) or relative URL.");
13
+ }
14
+ return { name: value.name, url: value.url };
15
+ }
16
+ /** Tracks upload attempts independently of editor transactions, including canceled/stale promises. */
17
+ export function useRichTextUploads(options) {
18
+ const { messages } = useLocale();
19
+ const [entries, setEntries] = useState([]);
20
+ const [announcement, setAnnouncement] = useState(null);
21
+ const settings = useRef(options);
22
+ useIsoLayoutEffect(() => { settings.current = options; }, [options]);
23
+ const nextId = useRef(0);
24
+ const attempts = useRef(new Map());
25
+ const alive = useRef(true);
26
+ const reportPending = () => { settings.current.onPendingChange?.(attempts.current.size > 0); };
27
+ useEffect(() => {
28
+ alive.current = true;
29
+ const controllers = attempts.current;
30
+ return () => { alive.current = false; controllers.forEach((controller) => { controller.abort(); }); controllers.clear(); };
31
+ }, []);
32
+ useEffect(() => {
33
+ if (!options.locked)
34
+ return;
35
+ attempts.current.forEach((controller) => { controller.abort(); });
36
+ attempts.current.clear();
37
+ }, [options.locked]);
38
+ const reset = useCallback(() => {
39
+ attempts.current.forEach((controller) => { controller.abort(); });
40
+ attempts.current.clear();
41
+ setEntries([]);
42
+ setAnnouncement(null);
43
+ }, []);
44
+ const isCurrentAttempt = (id, controller) => alive.current && !controller.signal.aborted && !settings.current.locked && attempts.current.get(id) === controller;
45
+ const start = async (id, file) => {
46
+ if (settings.current.locked || !settings.current.upload)
47
+ return;
48
+ const controller = new AbortController();
49
+ attempts.current.get(id)?.abort();
50
+ attempts.current.set(id, controller);
51
+ controller.signal.addEventListener("abort", () => {
52
+ if (attempts.current.get(id) === controller) {
53
+ attempts.current.delete(id);
54
+ reportPending();
55
+ }
56
+ if (alive.current)
57
+ setEntries((current) => current.filter((entry) => entry.id !== id));
58
+ }, { once: true });
59
+ reportPending();
60
+ setEntries((current) => {
61
+ const entry = { id, file, state: "pending" };
62
+ return current.some((item) => item.id === id) ? current.map((item) => item.id === id ? entry : item) : current.concat(entry);
63
+ });
64
+ try {
65
+ const limit = settings.current.maxFileSize;
66
+ if (limit !== undefined && file.size > limit) {
67
+ setEntries((current) => current.map((entry) => entry.id === id ? { ...entry, state: "error", issue: { kind: "too-large", limit } } : entry));
68
+ setAnnouncement({ kind: "too-large", limit });
69
+ settings.current.onError?.(new RangeError("Attachment exceeds the configured file size limit."), file);
70
+ return;
71
+ }
72
+ const result = await settings.current.upload(file, { signal: controller.signal });
73
+ if (!isCurrentAttempt(id, controller))
74
+ return;
75
+ const attachment = validateAttachment(result);
76
+ settings.current.insert(attachment);
77
+ setEntries((current) => current.map((entry) => entry.id === id ? { ...entry, state: "complete", attachment } : entry));
78
+ setAnnouncement({ kind: "uploaded", name: attachment.name });
79
+ }
80
+ catch (cause) {
81
+ if (!isCurrentAttempt(id, controller))
82
+ return;
83
+ const error = cause instanceof Error ? cause : new Error("Attachment upload failed.");
84
+ setEntries((current) => current.map((entry) => entry.id === id ? { ...entry, state: "error", issue: { kind: "failed" } } : entry));
85
+ setAnnouncement({ kind: "failed", name: file.name });
86
+ settings.current.onError?.(error, file);
87
+ }
88
+ finally {
89
+ if (attempts.current.get(id) === controller) {
90
+ attempts.current.delete(id);
91
+ reportPending();
92
+ }
93
+ }
94
+ };
95
+ const cancel = (id) => {
96
+ attempts.current.get(id)?.abort();
97
+ attempts.current.delete(id);
98
+ setEntries((current) => current.filter((entry) => entry.id !== id));
99
+ };
100
+ const remove = (entry) => {
101
+ if (settings.current.locked)
102
+ return;
103
+ if (entry.attachment)
104
+ settings.current.remove(entry.attachment);
105
+ cancel(entry.id);
106
+ };
107
+ return {
108
+ entries, announcement: announcement?.kind === "uploaded" ? messages.richText.attachmentUploaded(announcement.name) : announcement?.kind === "failed" ? messages.richText.uploadFailed(announcement.name) : announcement?.kind === "too-large" ? messages.richText.maxFileSize(formatBytes(announcement.limit)) : "",
109
+ add: (files) => { if (!settings.current.locked)
110
+ files.forEach((file) => { nextId.current += 1; void start(nextId.current, file); }); },
111
+ retry: (entry) => { void start(entry.id, entry.file); },
112
+ cancel, remove,
113
+ reset,
114
+ pending: entries.some((entry) => entry.state === "pending"),
115
+ };
116
+ }
117
+ export function RichTextUploads({ uploads, locked }) {
118
+ const { messages } = useLocale();
119
+ const copy = messages.richText;
120
+ return _jsxs(_Fragment, { children: [_jsx("span", { className: "vk-sr-only", role: "status", "aria-live": "polite", children: uploads.announcement }), uploads.entries.length ? _jsx("ul", { className: "vk-rich-uploads", children: uploads.entries.map((entry) => _jsxs("li", { className: "vk-rich-upload", "data-state": entry.state, children: [_jsx("span", { children: entry.file.name }), _jsx("span", { className: entry.state === "error" ? "vk-field-error" : "vk-rich-upload-status", children: entry.state === "pending" ? copy.uploading(entry.file.name) : entry.state === "error" ? (entry.issue?.kind === "too-large" ? copy.maxFileSize(formatBytes(entry.issue.limit)) : copy.uploadFailed(entry.file.name)) : copy.attachmentUploaded(entry.attachment?.name || entry.file.name) }), entry.state === "error" ? _jsx("button", { type: "button", className: "vk-link", disabled: locked, onClick: () => { uploads.retry(entry); }, "aria-label": copy.retryUpload(entry.file.name), children: copy.retryUpload(entry.file.name) }) : null, _jsx("button", { type: "button", className: "vk-link", disabled: locked, onClick: () => { if (entry.state === "pending")
121
+ uploads.cancel(entry.id);
122
+ else
123
+ uploads.remove(entry); }, "aria-label": entry.state === "pending" ? copy.cancelUpload(entry.file.name) : copy.removeAttachment(entry.file.name), children: entry.state === "pending" ? copy.cancel : messages.remove(entry.file.name) })] }, entry.id)) }) : null] });
124
+ }
@@ -1,11 +1,13 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useLocale } from "../../localization.js";
3
4
  import { forwardRef, useCallback, useRef, useState } from "react";
4
5
  import { Icon } from "../Icon/Icon.js";
5
6
  import { cx } from "../../lib/cx.js";
6
7
  import { omit } from "../../lib/omit.js";
7
8
  /** Search field with icon and clear button; no suggestions. The ref is the <input>. */
8
9
  export const SearchInput = forwardRef(function SearchInput(props, ref) {
10
+ const { messages } = useLocale();
9
11
  const controlled = props.value !== undefined;
10
12
  const [text, setText] = useState(props.defaultValue || "");
11
13
  const value = controlled ? props.value : text;
@@ -24,14 +26,14 @@ export const SearchInput = forwardRef(function SearchInput(props, ref) {
24
26
  setText(v);
25
27
  props.onChange?.(v, e);
26
28
  };
27
- return (_jsxs("span", { className: cx("vk-search", props.className), children: [_jsx(Icon, { name: "search", size: 16, className: "vk-search-icon" }), _jsx("input", { ref: setRef, type: "search", className: "vk-input vk-search-input", autoComplete: "off", ...rest, value: value, onChange: (e) => set(e.target.value, e), onKeyDown: (e) => {
29
+ return (_jsxs("span", { className: cx("vk-search", props.className), children: [_jsx(Icon, { name: "search", size: 16, className: "vk-search-icon" }), _jsx("input", { ref: setRef, type: "search", className: "vk-input vk-search-input", autoComplete: "off", ...rest, value: value, onChange: (e) => { set(e.target.value, e); }, onKeyDown: (e) => {
28
30
  if (e.key === "Escape" && value) {
29
31
  e.preventDefault();
30
32
  set("");
31
33
  props.onClear?.();
32
34
  }
33
35
  props.onKeyDown?.(e);
34
- } }), value && !props.disabled ? (_jsx("button", { type: "button", className: "vk-field-clear", "aria-label": props.clearLabel || "Clear search", onClick: () => {
36
+ } }), value && !props.disabled ? (_jsx("button", { type: "button", className: "vk-field-clear", "aria-label": props.clearLabel || messages.clearSearch, onClick: () => {
35
37
  set("");
36
38
  props.onClear?.();
37
39
  inputRef.current?.focus();
@@ -1,9 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { SquareGlyph } from "../SquareGlyph/SquareGlyph.js";
3
- import { para } from "../../lib/text.js";
4
3
  /** Section header: square glyph, uppercase label, optional lead. */
5
4
  export function SectionHeader({ id, heading, lead, glyph, as }) {
6
5
  const Tag = as || "h2";
7
- const Lead = para(lead);
8
- return (_jsxs("header", { className: "vk-section-header", children: [_jsxs(Tag, { id: id, className: "vk-section-heading", children: [_jsx(SquareGlyph, { children: glyph == null ? "+" : glyph }), _jsx("span", { children: heading })] }), lead ? _jsx(Lead, { className: "vk-section-lead", children: lead }) : null] }));
6
+ return (_jsxs("header", { className: "vk-section-header", children: [_jsxs(Tag, { id: id, className: "vk-section-heading", children: [_jsx(SquareGlyph, { children: glyph == null ? "+" : glyph }), _jsx("span", { children: heading })] }), lead ? _jsx("p", { className: "vk-section-lead", children: lead }) : null] }));
9
7
  }
@@ -1,21 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useState } from "react";
4
3
  import { RadioGroup as Primitive } from "radix-ui";
5
4
  import { Icon } from "../Icon/Icon.js";
6
5
  import { cx } from "../../lib/cx.js";
7
6
  import { normalizeOptions } from "../../internal/options.js";
8
- import { useArrowSelect } from "../../internal/choice.js";
9
7
  /** Exclusive options that apply immediately (Radix RadioGroup): one Tab stop, arrow keys move the selection and wrap. */
10
8
  export function SegmentedControl({ options: optionsProp, value: valueProp, defaultValue, onChange, label, size, className }) {
11
- const options = normalizeOptions(optionsProp);
12
- const controlled = valueProp !== undefined;
13
- const [internal, setInternal] = useState(defaultValue !== undefined ? defaultValue : options.length ? options[0].value : null);
14
- const value = controlled ? valueProp : internal;
15
- const arrows = useArrowSelect();
16
- return (_jsx(Primitive.Root, { "aria-label": label, className: cx("vk-segmented", size === "sm" && "vk-segmented-sm", className), value: value, ...arrows.group, onValueChange: (v) => {
17
- if (!controlled)
18
- setInternal(v);
19
- onChange?.(v);
20
- }, children: options.map((o) => (_jsxs(Primitive.Item, { value: o.value, disabled: o.disabled, className: "vk-segment", ...arrows.item, children: [o.icon ? _jsx(Icon, { name: o.icon, size: 16 }) : null, o.label] }, o.value))) }));
9
+ const options = normalizeOptions(optionsProp, (value) => ({ value, label: value }));
10
+ return (_jsx(Primitive.Root, { "aria-label": label, className: cx("vk-segmented", size === "sm" && "vk-segmented-sm", className), value: valueProp, defaultValue: defaultValue, onValueChange: onChange, children: options.map((o) => (_jsxs(Primitive.Item, { value: o.value, disabled: o.disabled, className: "vk-segment", children: [o.icon ? _jsx(Icon, { name: o.icon, size: 16 }) : null, o.label] }, o.value))) }));
21
11
  }
@@ -1,26 +1,25 @@
1
+ import { type ComponentPropsWithoutRef } from "react";
2
+ import { Select as Primitive } from "radix-ui";
1
3
  import type { SelectOption } from "../../types.js";
2
- export interface SelectProps {
4
+ type RootProps = ComponentPropsWithoutRef<typeof Primitive.Root>;
5
+ export interface SelectProps extends Omit<RootProps, "children" | "value" | "defaultValue" | "onValueChange"> {
6
+ /** Non-empty string values, following Radix Select's item contract. */
3
7
  options: (string | SelectOption)[];
8
+ /** Shown until an option is selected. */
4
9
  placeholder?: string;
10
+ /** The selected option; null clears the selection. */
5
11
  value?: string | null;
12
+ /** The initial selection for an uncontrolled select. */
6
13
  defaultValue?: string;
14
+ /** Receives Radix's changed value and its matching option. */
7
15
  onChange?: (value: string, option: SelectOption) => void;
8
- /** Adds a hidden input so the value posts with a form. */
9
- name?: string;
10
- disabled?: boolean;
11
- required?: boolean;
12
- /** Start open (documentation and tests). */
13
- defaultOpen?: boolean;
14
16
  id?: string;
15
17
  className?: string;
16
- 'aria-label'?: string;
17
- 'aria-labelledby'?: string;
18
- 'aria-describedby'?: string;
19
- 'aria-invalid'?: boolean;
18
+ "aria-label"?: string;
19
+ "aria-labelledby"?: string;
20
+ "aria-describedby"?: string;
21
+ "aria-invalid"?: boolean;
20
22
  }
21
- /**
22
- * Custom select (Radix Select, popper position; WAI-ARIA select-only combobox); no native <select>.
23
- * The ref is the trigger button. Radix forbids "" as an item value, so items carry their index
24
- * and "" means nothing is chosen: any option value, "" included, works.
25
- */
23
+ /** Styled Radix Select. Radix owns state, form participation, focus, keys and dismissal. */
26
24
  export declare const Select: import("react").ForwardRefExoticComponent<SelectProps & import("react").RefAttributes<HTMLButtonElement>>;
25
+ export {};
@@ -1,262 +1,21 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
4
- import { flushSync } from "react-dom";
3
+ import { forwardRef } from "react";
5
4
  import { Select as Primitive } from "radix-ui";
5
+ import { useLocale } from "../../localization.js";
6
6
  import { Icon } from "../Icon/Icon.js";
7
- import { focusables } from "../../internal/focusables.js";
8
7
  import { normalizeOptions } from "../../internal/options.js";
9
- import { useIsoLayoutEffect } from "../../internal/useIsoLayoutEffect.js";
10
8
  import { useUid } from "../../internal/useUid.js";
11
- import { omit } from "../../lib/omit.js";
12
9
  import { cx } from "../../lib/cx.js";
13
- /** Keys the closed trigger or the opening list holds for the list until it has focus. */
14
- const HELD = ["ArrowDown", "ArrowUp", "Home", "End", "PageUp", "PageDown", "Enter"];
15
- const typed = (e) => e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey;
16
- /** Focus the next (dir 1) or previous (-1) tabbable element after `from`, wrapping inside a modal dialog like its focus trap. */
17
- function focusNext(from, dir) {
18
- const body = from.ownerDocument.body;
19
- const scope = from.closest('[aria-modal="true"]') || body;
20
- const list = focusables(scope).filter((n) => n.tabIndex >= 0);
21
- const at = list.indexOf(from);
22
- let next = at >= 0 ? list[at + dir] : undefined;
23
- if (!next && at >= 0 && scope !== body)
24
- next = list[dir > 0 ? 0 : list.length - 1];
25
- (next || from).focus();
26
- }
27
- /**
28
- * Custom select (Radix Select, popper position; WAI-ARIA select-only combobox); no native <select>.
29
- * The ref is the trigger button. Radix forbids "" as an item value, so items carry their index
30
- * and "" means nothing is chosen: any option value, "" included, works.
31
- */
32
- export const Select = forwardRef(function Select(props, ref) {
33
- const options = normalizeOptions(props.options);
10
+ /** Styled Radix Select. Radix owns state, form participation, focus, keys and dismissal. */
11
+ export const Select = forwardRef(function Select({ options: optionValues, placeholder, value, defaultValue, onChange, id, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, ...rootProps }, ref) {
12
+ const { messages } = useLocale();
13
+ const options = normalizeOptions(optionValues);
34
14
  const baseId = useUid("vk-select");
35
- const controlled = props.value !== undefined;
36
- const [uncontrolledValue, setValue] = useState(() => props.defaultValue !== undefined ? props.defaultValue : props.placeholder ? null : options.length ? options[0].value : null);
37
- const value = controlled ? props.value : uncontrolledValue;
38
- const [open, setOpen] = useState(Boolean(props.defaultOpen));
39
- const triggerRef = useRef(null);
40
- const contentRef = useRef(null);
41
- const held = useRef([]);
42
- const tabbing = useRef(0);
43
- const search = useRef({ text: "", timer: 0 });
44
- let selectedIndex = -1;
45
- for (let k = 0; k < options.length; k++)
46
- if (options[k].value === value)
47
- selectedIndex = k;
48
- const selected = selectedIndex >= 0 ? options[selectedIndex] : null;
49
- const choose = (i) => {
50
- const o = options[i];
51
- if (!o || o.disabled || i === selectedIndex)
52
- return;
53
- if (!controlled)
54
- setValue(o.value);
55
- props.onChange?.(o.value, o);
15
+ const onValueChange = (nextValue) => {
16
+ const option = options.find((candidate) => candidate.value === nextValue);
17
+ if (option)
18
+ onChange?.(option.value, option);
56
19
  };
57
- const onValueChange = (v) => {
58
- // "" only comes from a form reset back to "nothing chosen".
59
- if (v === "") {
60
- if (!controlled)
61
- setValue(null);
62
- }
63
- else
64
- choose(Number(v));
65
- };
66
- // Radix hands focus back to the trigger only after the list has unmounted (a frame or two
67
- // later), so keys typed right after choosing or Escape would land on <body>. Close
68
- // synchronously and move focus at once: to the trigger, or on from it after Tab.
69
- const onOpenChange = (next) => {
70
- if (next) {
71
- setOpen(true);
72
- return;
73
- }
74
- held.current = [];
75
- search.current.text = "";
76
- const hadFocus = Boolean(contentRef.current?.contains(document.activeElement));
77
- const dir = tabbing.current;
78
- tabbing.current = 0;
79
- flushSync(() => setOpen(false));
80
- const trigger = triggerRef.current;
81
- if (!trigger || (!hadFocus && !dir))
82
- return;
83
- if (dir)
84
- focusNext(trigger, dir);
85
- else
86
- trigger.focus({ preventScroll: true });
87
- };
88
- const items = () => Array.from(contentRef.current?.querySelectorAll("[role=option]:not([data-disabled])") || []);
89
- const highlighted = () => {
90
- const el = document.activeElement;
91
- return el && el.getAttribute("role") === "option" && contentRef.current?.contains(el) ? Number(el.dataset.index) : -1;
92
- };
93
- const focusItem = (el) => {
94
- if (!el)
95
- return;
96
- el.focus({ preventScroll: true });
97
- el.scrollIntoView({ block: "nearest" });
98
- };
99
- const setTriggerRef = useCallback((el) => {
100
- triggerRef.current = el;
101
- if (typeof ref === "function")
102
- ref(el);
103
- else if (ref)
104
- ref.current = el;
105
- }, [ref]);
106
- // Radix opens on Enter, Space, ↓ and ↑. Home/End (PageUp/PageDown), ↑ with nothing chosen, and
107
- // typing a letter that matches open the list too, at that spot; keys pressed while the list is
108
- // still opening are handed to it once it has focus.
109
- const onTriggerKeyDown = (e) => {
110
- const key = e.key;
111
- if (open) {
112
- if (typed(e) || HELD.includes(key)) {
113
- e.preventDefault();
114
- held.current.push(key);
115
- }
116
- return;
117
- }
118
- if (props.disabled)
119
- return;
120
- let start = null;
121
- if (key === "Home" || key === "PageUp")
122
- start = "Home";
123
- else if (key === "End" || key === "PageDown")
124
- start = "End";
125
- else if (key === "ArrowUp" && selectedIndex < 0)
126
- start = "End";
127
- else if (typed(e) && key !== " ") {
128
- // Radix would change the value without opening; open at the match instead.
129
- e.preventDefault();
130
- const ch = key.toLowerCase();
131
- if (options.some((o) => !o.disabled && String(o.label).toLowerCase().indexOf(ch) === 0))
132
- start = key;
133
- }
134
- if (start) {
135
- e.preventDefault();
136
- held.current = [start];
137
- setOpen(true);
138
- }
139
- };
140
- // Radix focuses the chosen (or first) option once the list is placed: replay the held keys there.
141
- const onContentFocus = () => {
142
- if (!held.current.length)
143
- return;
144
- const keys = held.current;
145
- held.current = [];
146
- const press = (list) => {
147
- for (const key of list) {
148
- const content = contentRef.current;
149
- if (!content)
150
- return;
151
- const at = content.contains(document.activeElement) ? document.activeElement : content;
152
- at.dispatchEvent(new window.KeyboardEvent("keydown", { key, bubbles: true, cancelable: true }));
153
- }
154
- };
155
- // Moves happen at once, so the list never shows the interim option. A choosing key closes
156
- // the list, which can't happen inside Radix's focus effect: it waits for the next task.
157
- let cut = keys.findIndex((k) => k === "Enter" || k === " ");
158
- if (cut < 0)
159
- cut = keys.length;
160
- press(keys.slice(0, cut));
161
- if (cut < keys.length)
162
- setTimeout(() => press(keys.slice(cut)));
163
- };
164
- // Type-to-jump, as Radix does it (1s buffer, a repeated letter cycles), but moving focus at once:
165
- // Radix moves it in a timeout, so a quick Enter after a key would choose the old option.
166
- const typeahead = (ch) => {
167
- const s = search.current;
168
- window.clearTimeout(s.timer);
169
- s.text += ch.toLowerCase();
170
- s.timer = window.setTimeout(() => (s.text = ""), 1000);
171
- const repeated = s.text.length > 1 && Array.from(s.text).every((c) => c === s.text[0]);
172
- const q = repeated ? s.text[0] : s.text;
173
- const list = items();
174
- const cur = list.indexOf(document.activeElement);
175
- for (let n = 0; n < list.length; n++) {
176
- const el = list[(Math.max(cur, 0) + n) % list.length];
177
- if (q.length === 1 && el === list[cur])
178
- continue;
179
- if (String(options[Number(el.dataset.index)].label).toLowerCase().indexOf(q) === 0)
180
- return focusItem(el);
181
- }
182
- };
183
- const onContentKeyDown = (e) => {
184
- const key = e.key;
185
- const list = items();
186
- const cur = list.indexOf(document.activeElement);
187
- if (key === "Escape") {
188
- // Radix closes the list; don't let a surrounding dialog close too.
189
- e.stopPropagation();
190
- return;
191
- }
192
- if (key === "Enter") {
193
- // The option has been chosen and focus is back on the trigger button: stop Enter from also clicking it open.
194
- e.preventDefault();
195
- }
196
- else if (key === "Tab") {
197
- // Choose the active option, close, and move focus on from the trigger.
198
- e.preventDefault();
199
- e.stopPropagation();
200
- choose(highlighted());
201
- tabbing.current = e.shiftKey ? -1 : 1;
202
- onOpenChange(false);
203
- }
204
- else if (key === "ArrowUp" && e.altKey) {
205
- e.preventDefault();
206
- choose(highlighted());
207
- onOpenChange(false);
208
- }
209
- else if (key === "ArrowDown" && e.altKey) {
210
- e.preventDefault();
211
- }
212
- else if (key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End" || key === "PageUp" || key === "PageDown") {
213
- // Moved here (not left to Radix's timeout) so the next key acts on the new option.
214
- e.preventDefault();
215
- const last = list.length - 1;
216
- if (key === "ArrowDown")
217
- focusItem(list[cur < 0 ? 0 : cur + 1]);
218
- else if (key === "ArrowUp")
219
- focusItem(list[cur < 0 ? last : cur - 1]);
220
- else
221
- focusItem(list[key === "Home" || key === "PageUp" ? 0 : last]);
222
- }
223
- else if (typed(e)) {
224
- // Space while typing ahead is part of the search (see the option's onKeyDown).
225
- if (key === " " && !search.current.text)
226
- return;
227
- e.preventDefault();
228
- typeahead(key);
229
- }
230
- };
231
- // A press outside the list and its trigger closes it. Radix does this too, but on slow machines
232
- // (seen on CI) its dismiss can miss the press, leaving the list open over a page that ignores
233
- // the pointer. Close on our own as well; a second close is a no-op.
234
- const closeRef = useRef(onOpenChange);
235
- useIsoLayoutEffect(() => {
236
- closeRef.current = onOpenChange;
237
- });
238
- useEffect(() => {
239
- if (!open)
240
- return undefined;
241
- const onDown = (e) => {
242
- const target = e.target instanceof Node ? e.target : null;
243
- if (!target || contentRef.current?.contains(target) || triggerRef.current?.contains(target))
244
- return;
245
- closeRef.current(false);
246
- };
247
- document.addEventListener("pointerdown", onDown, true);
248
- return () => document.removeEventListener("pointerdown", onDown, true);
249
- }, [open]);
250
- // Radix chooses on Space; while a search is being typed, Space belongs to it instead.
251
- const onOptionKeyDown = (e) => {
252
- if (e.key === " " && search.current.text)
253
- e.preventDefault();
254
- };
255
- // Focus has already been placed (see onOpenChange); don't let Radix pull it back to the trigger.
256
- const onCloseAutoFocus = (e) => {
257
- if (document.activeElement && document.activeElement !== document.body)
258
- e.preventDefault();
259
- };
260
- const a11y = omit(props, ["options", "placeholder", "className", "value", "defaultValue", "onChange", "disabled", "name", "id", "defaultOpen", "required"]);
261
- return (_jsxs("div", { className: cx("vk-select", props.className), children: [_jsxs(Primitive.Root, { value: selectedIndex >= 0 ? String(selectedIndex) : "", onValueChange: onValueChange, open: open, onOpenChange: onOpenChange, disabled: props.disabled, children: [_jsxs(Primitive.Trigger, { ref: setTriggerRef, id: props.id, className: "vk-input vk-select-trigger", "aria-haspopup": "listbox", "aria-required": props.required ? true : undefined, onKeyDown: onTriggerKeyDown, ...a11y, children: [_jsx("span", { className: selected ? "vk-select-value" : "vk-select-value vk-select-placeholder", children: selected ? selected.label : props.placeholder || "Select one" }), _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" })] }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { ref: contentRef, position: "popper", side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, className: "vk-select-menu vk-select-content", "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], onKeyDown: onContentKeyDown, onFocus: onContentFocus, onCloseAutoFocus: onCloseAutoFocus, children: _jsx(Primitive.Viewport, { className: "vk-select-viewport", children: options.map((o, i) => (_jsxs(Primitive.Item, { value: String(i), textValue: String(o.label), disabled: o.disabled, "data-index": i, "aria-describedby": o.description ? baseId + "-" + i + "-desc" : undefined, onKeyDown: onOptionKeyDown, className: "vk-select-option", children: [_jsxs("span", { className: "vk-select-option-text", children: [_jsx(Primitive.ItemText, { children: o.label }), o.description ? _jsx("span", { id: baseId + "-" + i + "-desc", className: "vk-select-option-description", children: o.description }) : null] }), i === selectedIndex ? _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) : null] }, i + ":" + o.value))) }) }) })] }), props.name ? _jsx("input", { type: "hidden", name: props.name, value: value ?? "" }) : null] }));
20
+ return (_jsx("div", { className: cx("vk-select", className), children: _jsxs(Primitive.Root, { ...rootProps, value: value === null ? "" : value, defaultValue: defaultValue, onValueChange: onValueChange, children: [_jsxs(Primitive.Trigger, { ref: ref, id: id, className: "vk-input vk-select-trigger", "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, children: [_jsx("span", { className: "vk-select-value", children: _jsx(Primitive.Value, { placeholder: placeholder ?? messages.selectOne }) }), _jsx(Primitive.Icon, { asChild: true, children: _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" }) })] }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { position: "popper", side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, className: "vk-select-menu vk-select-content", "aria-label": ariaLabel, "aria-labelledby": labelledBy, children: _jsx(Primitive.Viewport, { className: "vk-select-viewport", children: options.map((option, index) => (_jsxs(Primitive.Item, { value: option.value, textValue: option.label, disabled: option.disabled, "data-index": index, "aria-describedby": option.description ? baseId + "-" + String(index) + "-desc" : undefined, className: "vk-select-option", children: [_jsxs("span", { className: "vk-select-option-text", children: [_jsx(Primitive.ItemText, { children: option.label }), option.description ? _jsx("span", { id: baseId + "-" + String(index) + "-desc", className: "vk-select-option-description", children: option.description }) : null] }), _jsx(Primitive.ItemIndicator, { asChild: true, children: _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) })] }, option.value))) }) }) })] }) }));
262
21
  });
@@ -6,30 +6,20 @@ import { useUid } from "../../internal/useUid.js";
6
6
  import { cx } from "../../lib/cx.js";
7
7
  /** Picks a number from a range by dragging or with the keyboard (Radix Slider; WAI-ARIA slider). */
8
8
  export function Slider(props) {
9
- const min = props.min == null ? 0 : props.min, max = props.max == null ? 100 : props.max, step = props.step || 1;
10
- const controlled = props.value !== undefined;
11
- const [uncontrolled, setUncontrolled] = useState(props.defaultValue != null ? props.defaultValue : min);
12
- const value = controlled ? props.value : uncontrolled;
9
+ const min = props.min ?? 0, max = props.max ?? 100, step = props.step ?? 1;
10
+ // Radix owns the value; this mirror supplies only the optional output and formatted value text.
11
+ const [displayValue, setDisplayValue] = useState(props.defaultValue ?? min);
12
+ const value = props.value ?? displayValue;
13
13
  const uid = useUid("vk-slider");
14
14
  const id = props.id || uid;
15
- const set = (n) => {
16
- if (!controlled)
17
- setUncontrolled(n);
18
- props.onChange?.(n);
19
- };
20
- // PageUp / PageDown move a tenth of the range (Radix moves ten steps); the rest of the keys are Radix's.
21
- const onKeyDown = (e) => {
22
- if (props.disabled || (e.key !== "PageUp" && e.key !== "PageDown"))
23
- return;
24
- e.preventDefault();
25
- const big = Math.max(step, (max - min) / 10);
26
- const snapped = Math.round((value + (e.key === "PageUp" ? big : -big) - min) / step) * step + min;
27
- const next = Math.max(min, Math.min(max, +snapped.toFixed(6)));
28
- if (next !== value)
29
- set(next);
30
- };
31
15
  const text = announce(props, value);
32
- return (_jsxs("div", { className: cx("vk-slider", props.className), children: [props.showValue ? _jsx("output", { className: "vk-slider-value", htmlFor: id, children: text }) : null, _jsxs(Primitive.Root, { className: "vk-slider-track", min: min, max: max, step: step, name: props.name, disabled: props.disabled, value: [value], onValueChange: (v) => set(v[0]), onKeyDown: onKeyDown, children: [_jsx(Primitive.Range, { className: "vk-slider-fill" }), _jsx(Primitive.Thumb, { id: id, className: "vk-slider-thumb", "aria-valuenow": value, "aria-valuetext": text, "aria-disabled": props.disabled ? "true" : undefined, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], "aria-describedby": props["aria-describedby"] })] }), props.showLimits ? _jsx(SliderLimits, { min: min, max: max, format: props.format }) : null] }));
16
+ return (_jsxs("div", { className: cx("vk-slider", props.className), children: [props.showValue ? _jsx("output", { className: "vk-slider-value", htmlFor: id, children: text }) : null, _jsxs(Primitive.Root, { className: "vk-slider-track", min: min, max: max, step: step, name: props.name, disabled: props.disabled, value: props.value === undefined ? undefined : [props.value], defaultValue: [props.defaultValue ?? min], onValueChange: (values) => {
17
+ const next = values[0];
18
+ if (next === undefined)
19
+ return;
20
+ setDisplayValue(next);
21
+ props.onChange?.(next);
22
+ }, children: [_jsx(Primitive.Range, { className: "vk-slider-fill" }), _jsx(Primitive.Thumb, { id: id, className: "vk-slider-thumb", "aria-valuetext": text, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], "aria-describedby": props["aria-describedby"] })] }), props.showLimits ? _jsx(SliderLimits, { min: min, max: max, format: props.format }) : null] }));
33
23
  }
34
24
  // The value as shown and announced: valueText, else format, else the number.
35
25
  function announce({ valueText, format }, value) {
@@ -1,15 +1,20 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useLocale } from "../../localization.js";
4
+ import { formatNumber } from "../../lib/format.js";
2
5
  import { cx } from "../../lib/cx.js";
3
6
  /** A word-sized trend line beside a number, in a table cell or a Stat. */
4
7
  export function Sparkline(props) {
8
+ const { locale, messages } = useLocale();
5
9
  const { width, height, tone, label, className } = props;
6
- const values = props.values || [];
10
+ const values = props.values;
7
11
  const w = width || 96, hgt = height || 28, p = 3;
8
12
  const min = Math.min(...values), max = Math.max(...values);
9
13
  const span = max - min || 1;
10
14
  const pt = (v, i) => [p + ((w - 2 * p) * i) / Math.max(1, values.length - 1), hgt - p - ((v - min) / span) * (hgt - 2 * p)];
11
15
  const pts = values.map((v, i) => pt(v, i).join(",")).join(" ");
12
- const end = values.length ? pt(values[values.length - 1], values.length - 1) : [0, 0];
16
+ const last = values.at(-1);
17
+ const end = last === undefined ? null : pt(last, values.length - 1);
13
18
  const color = tone ? "var(--" + tone + ")" : "var(--chart-1)";
14
- return (_jsxs("svg", { className: cx("vk-sparkline", className), width: w, height: hgt, viewBox: "0 0 " + w + " " + hgt, role: "img", "aria-label": label || "Trend: " + values.join(", "), children: [_jsx("polyline", { points: pts, fill: "none", stroke: color, strokeWidth: 1.5, strokeLinejoin: "round", strokeLinecap: "round" }), values.length ? _jsx("circle", { cx: end[0], cy: end[1], r: 2.5, fill: color }) : null] }));
19
+ return (_jsxs("svg", { className: cx("vk-sparkline", className), width: w, height: hgt, viewBox: `0 0 ${String(w)} ${String(hgt)}`, role: "img", "aria-label": label || messages.trend(values.map((value) => formatNumber(value, { locale })).join(", ")), children: [_jsx("polyline", { points: pts, fill: "none", stroke: color, strokeWidth: 1.5, strokeLinejoin: "round", strokeLinecap: "round" }), end ? _jsx("circle", { cx: end[0], cy: end[1], r: 2.5, fill: color }) : null] }));
15
20
  }
@@ -1,8 +1,11 @@
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 { cx } from "../../lib/cx.js";
3
5
  /** A small loading indicator for waits under a few seconds. */
4
6
  export function Spinner({ size: sizeProp, label, showLabel, className }) {
7
+ const { messages } = useLocale();
5
8
  const size = sizeProp || 16;
6
- const text = label || "Loading";
7
- return (_jsxs("span", { role: "status", className: cx("vk-spinner-wrap", className), children: [_jsx("span", { className: "vk-spinner", style: { width: size + "px", height: size + "px" }, "aria-hidden": "true" }), showLabel ? _jsx("span", { className: "vk-spinner-label", children: text }) : _jsx("span", { className: "vk-sr-only", children: text })] }));
9
+ const text = label || messages.loading;
10
+ return (_jsxs("span", { role: "status", className: cx("vk-spinner-wrap", className), children: [_jsx("span", { className: "vk-spinner", style: { width: String(size) + "px", height: String(size) + "px" }, "aria-hidden": "true" }), showLabel ? _jsx("span", { className: "vk-spinner-label", children: text }) : _jsx("span", { className: "vk-sr-only", children: text })] }));
8
11
  }