@vokality/design-system 1.3.0 → 3.0.0

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 (175) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +51 -5
  3. package/dist/browser.d.ts +13 -0
  4. package/dist/browser.js +7 -0
  5. package/dist/charts/chart.d.ts +6 -5
  6. package/dist/charts/chart.js +44 -25
  7. package/dist/chat.d.ts +54 -0
  8. package/dist/chat.js +1 -0
  9. package/dist/components/Accordion/Accordion.js +1 -1
  10. package/dist/components/Alert/Alert.js +5 -2
  11. package/dist/components/AppShell/AppShell.js +10 -14
  12. package/dist/components/Avatar/Avatar.js +2 -2
  13. package/dist/components/AvatarGroup/AvatarGroup.js +2 -2
  14. package/dist/components/BarChart/BarChart.js +17 -15
  15. package/dist/components/Breadcrumbs/Breadcrumbs.js +6 -3
  16. package/dist/components/Calendar/Calendar.js +6 -5
  17. package/dist/components/Card/Card.js +2 -3
  18. package/dist/components/ChatInbox/ChatInbox.d.ts +11 -0
  19. package/dist/components/ChatInbox/ChatInbox.js +49 -0
  20. package/dist/components/ChatPanel/ChatPanel.d.ts +3 -0
  21. package/dist/components/ChatPanel/ChatPanel.js +13 -0
  22. package/dist/components/ChatPanel/composer.d.ts +5 -0
  23. package/dist/components/ChatPanel/composer.js +32 -0
  24. package/dist/components/ChatPanel/transcript.d.ts +13 -0
  25. package/dist/components/ChatPanel/transcript.js +39 -0
  26. package/dist/components/ChatWidget/ChatWidget.d.ts +12 -0
  27. package/dist/components/ChatWidget/ChatWidget.js +42 -0
  28. package/dist/components/Checkbox/Checkbox.d.ts +5 -10
  29. package/dist/components/Checkbox/Checkbox.js +5 -19
  30. package/dist/components/CodeBlock/CodeBlock.js +19 -5
  31. package/dist/components/Combobox/Combobox.js +22 -15
  32. package/dist/components/Combobox/ListPanel.js +20 -9
  33. package/dist/components/CommandPalette/CommandPalette.js +33 -14
  34. package/dist/components/ContextMenu/ContextMenu.d.ts +2 -2
  35. package/dist/components/ContextMenu/ContextMenu.js +5 -50
  36. package/dist/components/DatePicker/DatePicker.js +35 -29
  37. package/dist/components/DescriptionList/DescriptionList.js +1 -1
  38. package/dist/components/Dialog/Dialog.d.ts +24 -7
  39. package/dist/components/Dialog/Dialog.js +30 -41
  40. package/dist/components/Drawer/Drawer.d.ts +4 -2
  41. package/dist/components/EmptyState/EmptyState.js +2 -2
  42. package/dist/components/ErrorSummary/ErrorSummary.js +5 -3
  43. package/dist/components/FaqList/FaqList.js +1 -1
  44. package/dist/components/Field/Field.js +4 -4
  45. package/dist/components/Fieldset/Fieldset.js +3 -3
  46. package/dist/components/FileUpload/FileUpload.js +17 -9
  47. package/dist/components/Grid/Grid.d.ts +867 -5
  48. package/dist/components/Grid/Grid.js +3 -4
  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 +867 -5
  52. package/dist/components/Inline/Inline.js +2 -3
  53. package/dist/components/LineChart/LineChart.js +17 -15
  54. package/dist/components/LinkProvider/LinkProvider.d.ts +1 -1
  55. package/dist/components/LinkProvider/LinkProvider.js +6 -2
  56. package/dist/components/List/List.js +1 -1
  57. package/dist/components/MediaCard/MediaCard.js +2 -2
  58. package/dist/components/Menu/Menu.js +6 -43
  59. package/dist/components/Menu/entries.d.ts +1 -30
  60. package/dist/components/Menu/entries.js +16 -100
  61. package/dist/components/MultiSelect/MultiSelect.js +43 -34
  62. package/dist/components/NumberInput/NumberInput.js +17 -18
  63. package/dist/components/OtpInput/OtpInput.d.ts +1 -1
  64. package/dist/components/OtpInput/OtpInput.js +10 -67
  65. package/dist/components/PageHeader/PageHeader.js +2 -2
  66. package/dist/components/Pagination/Pagination.js +3 -1
  67. package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
  68. package/dist/components/PasswordInput/PasswordInput.js +9 -4
  69. package/dist/components/Popover/Popover.d.ts +6 -7
  70. package/dist/components/Popover/Popover.js +2 -19
  71. package/dist/components/Progress/Progress.d.ts +1 -1
  72. package/dist/components/Progress/Progress.js +7 -11
  73. package/dist/components/Radio/Radio.d.ts +4 -2
  74. package/dist/components/RadioGroup/RadioGroup.d.ts +5 -12
  75. package/dist/components/RadioGroup/RadioGroup.js +6 -33
  76. package/dist/components/RichTextEditor/RichTextEditor.d.ts +63 -0
  77. package/dist/components/RichTextEditor/RichTextEditor.js +175 -0
  78. package/dist/components/RichTextEditor/toolbar.d.ts +15 -0
  79. package/dist/components/RichTextEditor/toolbar.js +142 -0
  80. package/dist/components/RichTextEditor/uploads.d.ts +41 -0
  81. package/dist/components/RichTextEditor/uploads.js +124 -0
  82. package/dist/components/SearchInput/SearchInput.js +4 -2
  83. package/dist/components/SectionHeader/SectionHeader.js +1 -3
  84. package/dist/components/SegmentedControl/SegmentedControl.js +2 -12
  85. package/dist/components/Select/Select.d.ts +15 -16
  86. package/dist/components/Select/Select.js +11 -252
  87. package/dist/components/Slider/Slider.js +11 -21
  88. package/dist/components/Sparkline/Sparkline.js +8 -3
  89. package/dist/components/Spinner/Spinner.js +5 -2
  90. package/dist/components/Stack/Stack.d.ts +867 -5
  91. package/dist/components/Stack/Stack.js +2 -3
  92. package/dist/components/Stat/Stat.js +6 -3
  93. package/dist/components/Steps/Steps.js +6 -3
  94. package/dist/components/Switch/Switch.d.ts +7 -7
  95. package/dist/components/Switch/Switch.js +4 -10
  96. package/dist/components/Table/Table.js +38 -19
  97. package/dist/components/Tabs/Tabs.js +2 -22
  98. package/dist/components/Tag/Tag.js +3 -1
  99. package/dist/components/Text/Text.d.ts +9 -5
  100. package/dist/components/Text/Text.js +3 -4
  101. package/dist/components/TileGrid/TileGrid.js +1 -1
  102. package/dist/components/TimePicker/TimePicker.js +35 -33
  103. package/dist/components/Timeline/Timeline.js +5 -4
  104. package/dist/components/Toaster/Toaster.js +21 -17
  105. package/dist/components/Tooltip/Tooltip.d.ts +6 -6
  106. package/dist/components/Tooltip/Tooltip.js +3 -17
  107. package/dist/components/TreeView/TreeView.js +15 -12
  108. package/dist/components.css +281 -60
  109. package/dist/hooks/useTheme.js +6 -6
  110. package/dist/icons/message-circle.svg +1 -0
  111. package/dist/internal/CharCount.js +3 -1
  112. package/dist/internal/choice.d.ts +10 -48
  113. package/dist/internal/choice.js +8 -96
  114. package/dist/internal/describedBy.d.ts +3 -0
  115. package/dist/internal/describedBy.js +4 -0
  116. package/dist/internal/options.d.ts +10 -5
  117. package/dist/internal/options.js +25 -11
  118. package/dist/internal/status.d.ts +3 -2
  119. package/dist/internal/status.js +10 -2
  120. package/dist/internal/useScrollActive.js +2 -2
  121. package/dist/internal/useToday.d.ts +3 -0
  122. package/dist/internal/useToday.js +42 -0
  123. package/dist/lib/dates.js +25 -15
  124. package/dist/lib/format.js +11 -8
  125. package/dist/lib/icons.d.ts +5 -0
  126. package/dist/lib/icons.js +2 -0
  127. package/dist/lib/math.js +17 -5
  128. package/dist/lib/rich-text.d.ts +13 -0
  129. package/dist/lib/rich-text.js +62 -0
  130. package/dist/lib/space.d.ts +1 -2
  131. package/dist/lib/space.js +4 -1
  132. package/dist/lib/text.js +1 -1
  133. package/dist/lib/theme.js +1 -1
  134. package/dist/localization.d.ts +166 -0
  135. package/dist/localization.js +142 -0
  136. package/dist/tokens.css +2 -0
  137. package/dist/tokens.dtcg.json +10 -0
  138. package/dist/tokens.json +10 -0
  139. package/dist/types.d.ts +6 -1
  140. package/dist/vokality.css +283 -60
  141. package/dist/vokality.iife.js +35981 -9698
  142. package/docs/brand.md +8 -5
  143. package/docs/components/AppShell/README.md +1 -1
  144. package/docs/components/Badge/README.md +1 -1
  145. package/docs/components/BarChart/README.md +1 -0
  146. package/docs/components/Button/README.md +4 -2
  147. package/docs/components/ChatInbox/README.md +41 -0
  148. package/docs/components/ChatWidget/README.md +47 -0
  149. package/docs/components/Checkbox/README.md +7 -3
  150. package/docs/components/ContextMenu/README.md +7 -3
  151. package/docs/components/Dialog/README.md +9 -4
  152. package/docs/components/Drawer/README.md +1 -1
  153. package/docs/components/Field/README.md +1 -1
  154. package/docs/components/Fieldset/README.md +2 -2
  155. package/docs/components/Inline/README.md +1 -1
  156. package/docs/components/LineChart/README.md +1 -0
  157. package/docs/components/LocaleProvider/README.md +48 -0
  158. package/docs/components/Menu/README.md +13 -8
  159. package/docs/components/OtpInput/README.md +9 -5
  160. package/docs/components/PasswordInput/README.md +11 -2
  161. package/docs/components/Popover/README.md +6 -3
  162. package/docs/components/Progress/README.md +3 -1
  163. package/docs/components/RadioGroup/README.md +5 -2
  164. package/docs/components/RichTextEditor/README.md +84 -0
  165. package/docs/components/SegmentedControl/README.md +2 -0
  166. package/docs/components/Select/README.md +13 -17
  167. package/docs/components/Skeleton/README.md +1 -1
  168. package/docs/components/Slider/README.md +4 -2
  169. package/docs/components/Steps/README.md +1 -1
  170. package/docs/components/Switch/README.md +5 -2
  171. package/docs/components/Tabs/README.md +4 -2
  172. package/docs/components/Text/README.md +1 -1
  173. package/docs/components/Toaster/README.md +3 -1
  174. package/docs/components/Tooltip/README.md +5 -3
  175. package/package.json +49 -5
package/dist/lib/math.js CHANGED
@@ -23,14 +23,26 @@ export function pageList(page, count, siblings) {
23
23
  }
24
24
  /** Round axis ticks from 0 to at least `max`, about `count` steps of 1, 2, 2.5 or 5 × 10ⁿ. */
25
25
  export function niceTicks(max, count) {
26
+ if (!Number.isFinite(max))
27
+ throw new RangeError("The axis maximum must be finite.");
26
28
  if (!(max > 0))
27
29
  return [0, 1];
28
- const raw = max / (count || 4), mag = Math.pow(10, Math.floor(Math.log10(raw))), f = raw / mag;
30
+ const divisions = count || 4;
31
+ if (!Number.isFinite(divisions) || divisions < 0)
32
+ throw new RangeError("The tick count must be finite and positive.");
33
+ const raw = max / divisions, mag = Math.pow(10, Math.floor(Math.log10(raw))), f = raw / mag;
29
34
  const step = (f <= 1 ? 1 : f <= 2 ? 2 : f <= 2.5 ? 2.5 : f <= 5 ? 5 : 10) * mag;
35
+ if (!Number.isFinite(step) || step <= 0)
36
+ return [0, max];
30
37
  const ticks = [];
31
- for (let v = 0; v <= max + step * 0.0001; v += step)
32
- ticks.push(+v.toFixed(10));
33
- if (ticks[ticks.length - 1] < max)
34
- ticks.push(+(ticks[ticks.length - 1] + step).toFixed(10));
38
+ const tolerantLimit = max + step * 0.0001;
39
+ const limit = Number.isFinite(tolerantLimit) ? tolerantLimit : max;
40
+ for (let v = 0; v <= limit; v += step)
41
+ ticks.push(Number(v.toPrecision(12)));
42
+ const last = ticks.at(-1);
43
+ if (last !== undefined && last < max) {
44
+ const next = last + step;
45
+ ticks.push(Number.isFinite(next) ? Number(next.toPrecision(12)) : max);
46
+ }
35
47
  return ticks;
36
48
  }
@@ -0,0 +1,13 @@
1
+ import type { Node } from "prosemirror-model";
2
+ /** Control characters are never valid in persisted attachment names or document URLs. */
3
+ export declare function hasRichTextControlCharacters(value: string): boolean;
4
+ /** URLs accepted by the editor, its clipboard boundary and attachment uploads. */
5
+ export declare function isRichTextUrl(value: unknown): value is string;
6
+ /** Images may load only HTTP(S) or relative URLs; email and telephone links are links only. */
7
+ export declare function isRichTextImageUrl(value: unknown): value is string;
8
+ /** Validate all URL-bearing nodes before a parsed or pasted document enters the view. */
9
+ export declare function hasSafeRichTextUrls(doc: Node): boolean;
10
+ /** Parse CommonMark without interpreting raw HTML. Unknown values fail at this boundary. */
11
+ export declare function parseRichTextMarkdown(value: unknown): Node;
12
+ /** CommonMark serialization preserves document structure and escapes link labels. */
13
+ export declare function serializeRichTextMarkdown(doc: Node): string;
@@ -0,0 +1,62 @@
1
+ import { defaultMarkdownParser, defaultMarkdownSerializer } from "prosemirror-markdown";
2
+ /** Control characters are never valid in persisted attachment names or document URLs. */
3
+ export function hasRichTextControlCharacters(value) {
4
+ return Array.from(value).some((character) => {
5
+ const code = character.charCodeAt(0);
6
+ return code < 32 || code === 127;
7
+ });
8
+ }
9
+ /** URLs accepted by the editor, its clipboard boundary and attachment uploads. */
10
+ export function isRichTextUrl(value) {
11
+ if (typeof value !== "string" || !value || value !== value.trim() || (hasRichTextControlCharacters(value) || value.includes(" ") || value.includes("\\")))
12
+ return false;
13
+ if (value.startsWith("//"))
14
+ return false;
15
+ const scheme = /^([A-Za-z][A-Za-z0-9+.-]*):/.exec(value);
16
+ const schemeName = scheme?.[1];
17
+ if (schemeName) {
18
+ if (!["https", "http", "mailto", "tel"].includes(schemeName.toLowerCase()))
19
+ return false;
20
+ try {
21
+ const url = new URL(value);
22
+ return url.protocol === "http:" || url.protocol === "https:" ? !!url.hostname : url.pathname.length > 0;
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ // A colon in the first path segment is never a relative URL.
29
+ const firstPathSegment = value.split(/[/?#]/, 1)[0];
30
+ return firstPathSegment !== undefined && !firstPathSegment.includes(":");
31
+ }
32
+ /** Images may load only HTTP(S) or relative URLs; email and telephone links are links only. */
33
+ export function isRichTextImageUrl(value) {
34
+ return isRichTextUrl(value) && !/^(mailto|tel):/i.test(value);
35
+ }
36
+ /** Validate all URL-bearing nodes before a parsed or pasted document enters the view. */
37
+ export function hasSafeRichTextUrls(doc) {
38
+ let valid = true;
39
+ doc.descendants((node) => {
40
+ if (node.type.name === "image" && !isRichTextImageUrl(node.attrs.src))
41
+ valid = false;
42
+ if (node.marks.some((mark) => mark.type.name === "link" && !isRichTextUrl(mark.attrs.href)))
43
+ valid = false;
44
+ return valid;
45
+ });
46
+ return valid;
47
+ }
48
+ /** Parse CommonMark without interpreting raw HTML. Unknown values fail at this boundary. */
49
+ export function parseRichTextMarkdown(value) {
50
+ if (typeof value !== "string")
51
+ throw new TypeError("Rich-text content must be a Markdown string.");
52
+ const doc = defaultMarkdownParser.parse(value);
53
+ if (!hasSafeRichTextUrls(doc))
54
+ throw new TypeError("Rich-text content contains an unsafe URL.");
55
+ return doc;
56
+ }
57
+ /** CommonMark serialization preserves document structure and escapes link labels. */
58
+ export function serializeRichTextMarkdown(doc) {
59
+ if (!hasSafeRichTextUrls(doc))
60
+ throw new TypeError("Rich-text content contains an unsafe URL.");
61
+ return defaultMarkdownSerializer.serialize(doc);
62
+ }
@@ -1,4 +1,3 @@
1
1
  import type { SpaceStep } from "../types.js";
2
2
  export declare const SPACE: Record<SpaceStep, string>;
3
- /** A spacing step ("md") as its token, or any other CSS length as given; `fallback` when unset. */
4
- export declare function space(value: SpaceStep | string | undefined, fallback: SpaceStep): string;
3
+ export declare function space(value: string | undefined, fallback: SpaceStep): string;
package/dist/lib/space.js CHANGED
@@ -3,7 +3,10 @@ export const SPACE = {
3
3
  xl: "var(--space-xl)", "2xl": "var(--space-2xl)", "3xl": "var(--space-3xl)",
4
4
  };
5
5
  /** A spacing step ("md") as its token, or any other CSS length as given; `fallback` when unset. */
6
+ function isSpaceStep(value) {
7
+ return Object.hasOwn(SPACE, value);
8
+ }
6
9
  export function space(value, fallback) {
7
10
  const v = value == null ? fallback : value;
8
- return SPACE[v] || v;
11
+ return isSpaceStep(v) ? SPACE[v] : v;
9
12
  }
package/dist/lib/text.js CHANGED
@@ -8,5 +8,5 @@ export function para(content) {
8
8
  }
9
9
  /** Two-digit step numbers: 1 → "01". */
10
10
  export function pad(n) {
11
- return String(n).length < 2 ? "0" + n : String(n);
11
+ return String(n).length < 2 ? "0" + String(n) : String(n);
12
12
  }
package/dist/lib/theme.js CHANGED
@@ -6,7 +6,7 @@ export const THEMES = ["dark", "light", "contrast"];
6
6
  */
7
7
  export function themeScript(options = {}) {
8
8
  // JSON-quoted, with "<" escaped so the value can never close the inline <script>.
9
- const key = JSON.stringify(String(options.storageKey || "vk-theme")).replace(/</g, "\\u003c");
9
+ const key = JSON.stringify(options.storageKey || "vk-theme").replace(/</g, "\\u003c");
10
10
  const fallback = JSON.stringify(options.defaultTheme && THEMES.includes(options.defaultTheme) ? options.defaultTheme : "dark");
11
11
  const system = options.followSystem === false ? "" :
12
12
  'if(matchMedia("(prefers-contrast: more)").matches)t="contrast";else if(matchMedia("(prefers-color-scheme: light)").matches)t="light";else if(matchMedia("(prefers-color-scheme: dark)").matches)t="dark";';
@@ -0,0 +1,166 @@
1
+ import { type ReactNode } from "react";
2
+ /** Accessible labels and feedback for RichTextEditor. */
3
+ export interface RichTextMessages {
4
+ toolbar: string;
5
+ formatting: string;
6
+ paragraph: string;
7
+ heading: (level: number) => string;
8
+ bold: string;
9
+ italic: string;
10
+ bulletList: string;
11
+ orderedList: string;
12
+ quote: string;
13
+ inlineCode: string;
14
+ codeBlock: string;
15
+ undo: string;
16
+ redo: string;
17
+ addLink: string;
18
+ removeLink: string;
19
+ linkUrl: string;
20
+ linkText: string;
21
+ applyLink: string;
22
+ cancel: string;
23
+ invalidUrl: string;
24
+ emoji: string;
25
+ emojiSearch: string;
26
+ noEmoji: string;
27
+ emojiName: (value: string) => string;
28
+ attachFiles: string;
29
+ uploading: (name: string) => string;
30
+ uploadFailed: (name: string) => string;
31
+ retryUpload: (name: string) => string;
32
+ cancelUpload: (name: string) => string;
33
+ removeAttachment: (name: string) => string;
34
+ attachmentUploaded: (name: string) => string;
35
+ maxFileSize: (size: string) => string;
36
+ editorLoading: string;
37
+ }
38
+ /** Conversation chrome, delivery feedback and composer labels. */
39
+ export interface ChatMessages {
40
+ open: string;
41
+ close: string;
42
+ messages: string;
43
+ message: string;
44
+ placeholder: string;
45
+ send: string;
46
+ sending: string;
47
+ failed: string;
48
+ retry: string;
49
+ retryMessage: (author: string) => string;
50
+ tryAgain: string;
51
+ back: string;
52
+ empty: string;
53
+ chooseThread: string;
54
+ noThreads: string;
55
+ conversations: string;
56
+ unread: (count: number) => string;
57
+ }
58
+ /** Built-in interface copy. Functions keep interpolation and plurals typed. */
59
+ export interface LocaleMessages {
60
+ richText: RichTextMessages;
61
+ chat: ChatMessages;
62
+ dismiss: string;
63
+ close: string;
64
+ clear: string;
65
+ today: string;
66
+ showPassword: string;
67
+ hidePassword: string;
68
+ decrease: string;
69
+ increase: string;
70
+ loading: string;
71
+ progress: string;
72
+ breadcrumb: string;
73
+ pagination: string;
74
+ previous: string;
75
+ next: string;
76
+ page: (page: number) => string;
77
+ previousMonth: string;
78
+ nextMonth: string;
79
+ chooseDate: string;
80
+ chooseDates: string;
81
+ selectDate: string;
82
+ selectDates: string;
83
+ invalidDate: (example: string) => string;
84
+ invalidTime: (example: string) => string;
85
+ times: string;
86
+ selectOne: string;
87
+ noMatches: (query: string) => string;
88
+ remove: (name: string) => string;
89
+ clearSearch: string;
90
+ moreActions: string;
91
+ actions: string;
92
+ skipToContent: string;
93
+ sidebar: string;
94
+ showSidebar: string;
95
+ hideSidebar: string;
96
+ menu: string;
97
+ statusInfo: string;
98
+ statusSuccess: string;
99
+ statusWarning: string;
100
+ statusDanger: string;
101
+ notifications: string;
102
+ dismissNotification: string;
103
+ notificationAnnouncement: string;
104
+ dropFile: string;
105
+ dropFiles: string;
106
+ or: string;
107
+ browse: string;
108
+ fileTooLarge: (size: string) => string;
109
+ fixProblems: (count: number) => string;
110
+ charactersLeft: (count: number) => string;
111
+ charactersOver: (count: number) => string;
112
+ oneTimeCode: string;
113
+ digit: string;
114
+ digitPosition: (label: string, position: number, total: number) => string;
115
+ details: string;
116
+ selectAllRows: string;
117
+ row: (position: number) => string;
118
+ selectRow: (position: number) => string;
119
+ showDetails: (name: string) => string;
120
+ hideDetails: (name: string) => string;
121
+ nothingToShow: string;
122
+ pageSummary: (from: number, to: number, total: number) => string;
123
+ completedStep: string;
124
+ currentStep: string;
125
+ up: string;
126
+ down: string;
127
+ copy: string;
128
+ copied: string;
129
+ code: string;
130
+ languageCode: (language: string) => string;
131
+ commandPalette: string;
132
+ commandSearch: string;
133
+ commands: string;
134
+ noCommands: (query: string) => string;
135
+ commandMove: string;
136
+ commandRun: string;
137
+ commandClose: string;
138
+ category: string;
139
+ value: string;
140
+ showChart: string;
141
+ showTable: string;
142
+ barChart: string;
143
+ lineChart: string;
144
+ chartInstructions: (title: string) => string;
145
+ trend: (values: string) => string;
146
+ }
147
+ /** Partial dictionaries inherit omitted keys within each interface domain. */
148
+ export type LocaleMessageOverrides = Partial<Omit<LocaleMessages, "richText" | "chat">> & {
149
+ richText?: Partial<RichTextMessages>;
150
+ chat?: Partial<ChatMessages>;
151
+ };
152
+ export interface LocaleProviderProps {
153
+ /** Explicit locale for both built-in messages and date/number formatting. Inherits when omitted. */
154
+ locale?: string;
155
+ /** App-specific translations; nested providers inherit these and replace only the keys supplied. */
156
+ messages?: LocaleMessageOverrides;
157
+ children?: ReactNode;
158
+ }
159
+ /** Scoped locale and translations. Does not read browser language or mutate the document. */
160
+ export declare function LocaleProvider({ locale, messages, children }: LocaleProviderProps): import("react/jsx-runtime").JSX.Element;
161
+ export interface LocaleValue {
162
+ locale: string;
163
+ messages: LocaleMessages;
164
+ }
165
+ /** Read the nearest provider; an explicit control locale selects its formatting and default dictionary. */
166
+ export declare function useLocale(localeOverride?: string): LocaleValue;
@@ -0,0 +1,142 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ import { resolveLocale } from "./lib/format.js";
5
+ const englishEmojiNames = {
6
+ "😀": "Grinning face", "🙂": "Smile", "❤️": "Heart", "👍": "Thumbs up", "👎": "Thumbs down", "🎉": "Celebration",
7
+ "✅": "Check", "⚠️": "Warning", "💡": "Idea", "🚀": "Rocket", "👀": "Eyes", "🙏": "Thank you",
8
+ };
9
+ const dutchEmojiNames = {
10
+ "😀": "Grijnzend gezicht", "🙂": "Glimlach", "❤️": "Hart", "👍": "Duim omhoog", "👎": "Duim omlaag", "🎉": "Feest",
11
+ "✅": "Vinkje", "⚠️": "Waarschuwing", "💡": "Idee", "🚀": "Raket", "👀": "Ogen", "🙏": "Bedankt",
12
+ };
13
+ const english = {
14
+ chat: {
15
+ open: "Open chat", close: "Close chat", messages: "Messages", message: "Message", placeholder: "Write a message…",
16
+ send: "Send message", sending: "Sending message", failed: "Message not sent", retry: "Retry", retryMessage: (author) => "Retry message from " + author,
17
+ tryAgain: "Try again", back: "Back to conversations", empty: "No messages yet. Start the conversation.", chooseThread: "Choose a conversation to read and reply.", noThreads: "No conversations yet.",
18
+ conversations: "Conversations", unread: (count) => String(count) + (count === 1 ? " unread message" : " unread messages"),
19
+ },
20
+ richText: {
21
+ formatting: "Formatting options",
22
+ toolbar: "Formatting", paragraph: "Paragraph", heading: (level) => "Heading " + String(level),
23
+ bold: "Bold", italic: "Italic", bulletList: "Bullet list", orderedList: "Numbered list", quote: "Quote",
24
+ inlineCode: "Inline code", codeBlock: "Code block", undo: "Undo", redo: "Redo",
25
+ addLink: "Add link", removeLink: "Remove link", linkUrl: "Link URL", linkText: "Link text", applyLink: "Apply link", cancel: "Cancel",
26
+ invalidUrl: "Enter a valid URL or relative link.", emojiName: (value) => englishEmojiNames[value] || value, emoji: "Insert emoji", emojiSearch: "Search emoji", noEmoji: "No emoji found", attachFiles: "Attach files",
27
+ uploading: (name) => "Uploading " + name, uploadFailed: (name) => "Could not upload " + name,
28
+ retryUpload: (name) => "Retry upload for " + name, cancelUpload: (name) => "Cancel upload for " + name,
29
+ removeAttachment: (name) => "Remove attachment " + name, attachmentUploaded: (name) => "Uploaded " + name,
30
+ maxFileSize: (size) => "Choose a file smaller than " + size + ".", editorLoading: "Loading editor",
31
+ },
32
+ dismiss: "Dismiss", close: "Close", clear: "Clear", today: "Today",
33
+ showPassword: "Show", hidePassword: "Hide", decrease: "Decrease", increase: "Increase",
34
+ loading: "Loading", progress: "Progress", breadcrumb: "Breadcrumb", pagination: "Pagination",
35
+ previous: "Previous", next: "Next", page: (page) => "Page " + String(page),
36
+ previousMonth: "Previous month", nextMonth: "Next month",
37
+ chooseDate: "Choose a date", chooseDates: "Choose dates", selectDate: "Select a date", selectDates: "Select dates",
38
+ invalidDate: (example) => "Enter a date like " + example + ".",
39
+ invalidTime: (example) => "Enter a time like " + example + ".",
40
+ times: "Times", selectOne: "Select one", noMatches: (query) => "No matches for “" + query + "”",
41
+ remove: (name) => "Remove " + name, clearSearch: "Clear search", moreActions: "More actions", actions: "Actions",
42
+ skipToContent: "Skip to content", sidebar: "Sidebar", showSidebar: "Show sidebar", hideSidebar: "Hide sidebar", menu: "Menu",
43
+ statusInfo: "Info", statusSuccess: "Success", statusWarning: "Warning", statusDanger: "Error",
44
+ notifications: "Notifications", dismissNotification: "Dismiss notification", notificationAnnouncement: "Notification",
45
+ dropFile: "Drop a file here", dropFiles: "Drop files here", or: " or ", browse: "browse",
46
+ fileTooLarge: (size) => "Larger than " + size + ".",
47
+ fixProblems: (count) => "Fix " + String(count) + (count === 1 ? " problem" : " problems") + " to continue",
48
+ charactersLeft: (count) => String(count) + (count === 1 ? " character left" : " characters left"),
49
+ charactersOver: (count) => String(count) + (count === 1 ? " character over" : " characters over"),
50
+ oneTimeCode: "One-time code", digit: "Digit", digitPosition: (label, position, total) => label + " " + String(position) + " of " + String(total),
51
+ details: "Details", selectAllRows: "Select all rows", row: (position) => "row " + String(position),
52
+ selectRow: (position) => "Select row " + String(position), showDetails: (name) => "Show details for " + name,
53
+ hideDetails: (name) => "Hide details for " + name, nothingToShow: "Nothing to show yet.",
54
+ pageSummary: (from, to, total) => String(from) + "–" + String(to) + " of " + String(total),
55
+ completedStep: " (completed)", currentStep: " (current step)", up: "Up ", down: "Down ",
56
+ copy: "Copy", copied: "Copied", code: "Code", languageCode: (language) => language + " code",
57
+ commandPalette: "Command palette", commandSearch: "Type a command or search", commands: "Commands",
58
+ noCommands: (query) => "No commands match “" + query + "”", commandMove: " to move ", commandRun: " to run ", commandClose: " to close",
59
+ category: "Category", value: "Value", showChart: "Show chart", showTable: "Show table",
60
+ barChart: "Bar chart", lineChart: "Line chart", chartInstructions: (title) => title + ". Use the arrow keys to read each value.",
61
+ trend: (values) => "Trend: " + values,
62
+ };
63
+ const dutch = {
64
+ chat: {
65
+ open: "Chat openen", close: "Chat sluiten", messages: "Berichten", message: "Bericht", placeholder: "Schrijf een bericht…",
66
+ send: "Bericht verzenden", sending: "Bericht wordt verzonden", failed: "Bericht niet verzonden", retry: "Opnieuw proberen", retryMessage: (author) => "Bericht van " + author + " opnieuw proberen",
67
+ tryAgain: "Opnieuw proberen", back: "Terug naar gesprekken", empty: "Nog geen berichten. Begin het gesprek.", chooseThread: "Kies een gesprek om te lezen en te antwoorden.", noThreads: "Nog geen gesprekken.",
68
+ conversations: "Gesprekken", unread: (count) => String(count) + (count === 1 ? " ongelezen bericht" : " ongelezen berichten"),
69
+ },
70
+ richText: {
71
+ formatting: "Opmaakopties",
72
+ toolbar: "Opmaak", paragraph: "Alinea", heading: (level) => "Kop " + String(level),
73
+ bold: "Vet", italic: "Cursief", bulletList: "Opsomming", orderedList: "Genummerde lijst", quote: "Citaat",
74
+ inlineCode: "Inline code", codeBlock: "Codeblok", undo: "Ongedaan maken", redo: "Opnieuw uitvoeren",
75
+ addLink: "Link toevoegen", removeLink: "Link verwijderen", linkUrl: "Link-URL", linkText: "Linktekst", applyLink: "Link toepassen", cancel: "Annuleren",
76
+ invalidUrl: "Voer een geldige URL of relatieve link in.", emojiName: (value) => dutchEmojiNames[value] || value, emoji: "Emoji invoegen", emojiSearch: "Emoji zoeken", noEmoji: "Geen emoji gevonden", attachFiles: "Bestanden bijvoegen",
77
+ uploading: (name) => name + " uploaden", uploadFailed: (name) => name + " kon niet worden geüpload",
78
+ retryUpload: (name) => "Upload van " + name + " opnieuw proberen", cancelUpload: (name) => "Upload van " + name + " annuleren",
79
+ removeAttachment: (name) => "Bijlage " + name + " verwijderen", attachmentUploaded: (name) => name + " geüpload",
80
+ maxFileSize: (size) => "Kies een bestand kleiner dan " + size + ".", editorLoading: "Editor laden",
81
+ },
82
+ dismiss: "Sluiten", close: "Sluiten", clear: "Wissen", today: "Vandaag",
83
+ showPassword: "Tonen", hidePassword: "Verbergen", decrease: "Verlagen", increase: "Verhogen",
84
+ loading: "Laden", progress: "Voortgang", breadcrumb: "Kruimelpad", pagination: "Paginering",
85
+ previous: "Vorige", next: "Volgende", page: (page) => "Pagina " + String(page),
86
+ previousMonth: "Vorige maand", nextMonth: "Volgende maand",
87
+ chooseDate: "Kies een datum", chooseDates: "Kies datums", selectDate: "Selecteer een datum", selectDates: "Selecteer datums",
88
+ invalidDate: (example) => "Voer een datum in zoals " + example + ".",
89
+ invalidTime: (example) => "Voer een tijd in zoals " + example + ".",
90
+ times: "Tijden", selectOne: "Selecteer een optie", noMatches: (query) => "Geen resultaten voor “" + query + "”",
91
+ remove: (name) => name ? "Verwijder " + name : "Verwijderen", clearSearch: "Zoekopdracht wissen", moreActions: "Meer acties", actions: "Acties",
92
+ skipToContent: "Ga naar inhoud", sidebar: "Zijbalk", showSidebar: "Zijbalk tonen", hideSidebar: "Zijbalk verbergen", menu: "Menu",
93
+ statusInfo: "Informatie", statusSuccess: "Geslaagd", statusWarning: "Waarschuwing", statusDanger: "Fout",
94
+ notifications: "Meldingen", dismissNotification: "Melding sluiten", notificationAnnouncement: "Melding",
95
+ dropFile: "Sleep een bestand hierheen", dropFiles: "Sleep bestanden hierheen", or: " of ", browse: "bladeren",
96
+ fileTooLarge: (size) => "Groter dan " + size + ".",
97
+ fixProblems: (count) => "Los " + String(count) + (count === 1 ? " probleem" : " problemen") + " op om door te gaan",
98
+ charactersLeft: (count) => "Nog " + String(count) + (count === 1 ? " teken" : " tekens"),
99
+ charactersOver: (count) => String(count) + (count === 1 ? " teken te veel" : " tekens te veel"),
100
+ oneTimeCode: "Eenmalige code", digit: "Cijfer", digitPosition: (label, position, total) => label + " " + String(position) + " van " + String(total),
101
+ details: "Details", selectAllRows: "Alle rijen selecteren", row: (position) => "rij " + String(position),
102
+ selectRow: (position) => "Selecteer rij " + String(position), showDetails: (name) => "Details tonen voor " + name,
103
+ hideDetails: (name) => "Details verbergen voor " + name, nothingToShow: "Er is nog niets om weer te geven.",
104
+ pageSummary: (from, to, total) => String(from) + "–" + String(to) + " van " + String(total),
105
+ completedStep: " (voltooid)", currentStep: " (huidige stap)", up: "Omhoog ", down: "Omlaag ",
106
+ copy: "Kopiëren", copied: "Gekopieerd", code: "Code", languageCode: (language) => language + "-code",
107
+ commandPalette: "Opdrachtenpalet", commandSearch: "Typ een opdracht of zoek", commands: "Opdrachten",
108
+ noCommands: (query) => "Geen opdrachten voor “" + query + "”", commandMove: " om te navigeren ", commandRun: " om uit te voeren ", commandClose: " om te sluiten",
109
+ category: "Categorie", value: "Waarde", showChart: "Grafiek tonen", showTable: "Tabel tonen",
110
+ barChart: "Staafdiagram", lineChart: "Lijndiagram", chartInstructions: (title) => title + ". Gebruik de pijltjestoetsen om elke waarde te lezen.",
111
+ trend: (values) => "Trend: " + values,
112
+ };
113
+ /** Optional translation fields inherit when omitted or explicitly undefined. */
114
+ function mergeDefined(base, overrides) {
115
+ const merged = { ...base };
116
+ if (overrides)
117
+ for (const key in overrides) {
118
+ const value = overrides[key];
119
+ if (value !== undefined)
120
+ merged[key] = value;
121
+ }
122
+ return merged;
123
+ }
124
+ const LocaleContext = createContext({ locale: "en-US", overrides: {} });
125
+ /** Scoped locale and translations. Does not read browser language or mutate the document. */
126
+ export function LocaleProvider({ locale, messages, children }) {
127
+ const parent = useContext(LocaleContext);
128
+ const value = useMemo(() => ({
129
+ locale: locale === undefined ? parent.locale : resolveLocale(locale),
130
+ overrides: mergeDefined(parent.overrides, { ...messages, richText: mergeDefined(parent.overrides.richText || {}, messages?.richText), chat: mergeDefined(parent.overrides.chat || {}, messages?.chat) }),
131
+ }), [locale, messages, parent]);
132
+ return _jsx(LocaleContext.Provider, { value: value, children: children });
133
+ }
134
+ /** Read the nearest provider; an explicit control locale selects its formatting and default dictionary. */
135
+ export function useLocale(localeOverride) {
136
+ const context = useContext(LocaleContext);
137
+ const locale = localeOverride === undefined ? context.locale : resolveLocale(localeOverride);
138
+ return useMemo(() => {
139
+ const defaults = /^nl(?:-|$)/i.test(locale) ? dutch : english;
140
+ return { locale, messages: mergeDefined(defaults, { ...context.overrides, richText: mergeDefined(defaults.richText, context.overrides.richText), chat: mergeDefined(defaults.chat, context.overrides.chat) }) };
141
+ }, [locale, context.overrides]);
142
+ }
package/dist/tokens.css CHANGED
@@ -245,6 +245,8 @@
245
245
  --sidebar-width: 15rem;
246
246
  --topbar-height: 56px;
247
247
  --control-height: 44px;
248
+ --control-font-size: 1rem;
249
+ --control-padding-block: 0.6rem;
248
250
  --button-height: 40px;
249
251
  --button-height-sm: 32px;
250
252
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
@@ -1186,6 +1186,16 @@
1186
1186
  "$value": "44px",
1187
1187
  "$description": "Inputs, selects, date fields."
1188
1188
  },
1189
+ "control-font-size": {
1190
+ "$type": "dimension",
1191
+ "$value": "1rem",
1192
+ "$description": "Text inside inputs, selects and date fields; 16px or more avoids iOS focus zoom."
1193
+ },
1194
+ "control-padding-block": {
1195
+ "$type": "dimension",
1196
+ "$value": "0.6rem",
1197
+ "$description": "Vertical padding inside single-line inputs, selects and date fields."
1198
+ },
1189
1199
  "button-height": {
1190
1200
  "$type": "dimension",
1191
1201
  "$value": "40px",
package/dist/tokens.json CHANGED
@@ -1202,6 +1202,16 @@
1202
1202
  "value": "44px",
1203
1203
  "usage": "Inputs, selects, date fields."
1204
1204
  },
1205
+ {
1206
+ "name": "control-font-size",
1207
+ "value": "1rem",
1208
+ "usage": "Text inside inputs, selects and date fields; 16px or more avoids iOS focus zoom."
1209
+ },
1210
+ {
1211
+ "name": "control-padding-block",
1212
+ "value": "0.6rem",
1213
+ "usage": "Vertical padding inside single-line inputs, selects and date fields."
1214
+ },
1205
1215
  {
1206
1216
  "name": "button-height",
1207
1217
  "value": "40px",
package/dist/types.d.ts CHANGED
@@ -42,9 +42,14 @@ export type MenuEntry = {
42
42
  label: string;
43
43
  };
44
44
  export type SpaceStep = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
45
+ export type ElementTag = keyof React.JSX.IntrinsicElements;
45
46
  export type AsProp = {
46
- as?: keyof React.JSX.IntrinsicElements;
47
+ as?: ElementTag;
47
48
  };
49
+ /** A component's own props plus the attributes and events of the element it renders `as`, typed for that element. */
50
+ export type PolymorphicProps<T extends ElementTag, Own> = Own & {
51
+ as?: T;
52
+ } & Omit<React.ComponentPropsWithoutRef<T>, keyof Own | "as">;
48
53
  export interface ChartSeries {
49
54
  key: string;
50
55
  label: string;