@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
@@ -1,5 +1,6 @@
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 { useEffect, useRef, useState } from "react";
4
5
  import { Popover } from "radix-ui";
5
6
  import { Icon } from "../Icon/Icon.js";
@@ -19,25 +20,27 @@ function optionWithValue(options, value) {
19
20
  }
20
21
  /** The end of the field: a clear button while there is text, else the chevron. */
21
22
  function FieldEnd({ clearable, clearLabel, onClear }) {
23
+ const { messages } = useLocale();
22
24
  if (!clearable)
23
25
  return _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" });
24
- return (_jsx("button", { type: "button", tabIndex: -1, className: "vk-field-clear", "aria-label": clearLabel || "Clear", onMouseDown: (e) => e.preventDefault(), onClick: onClear, children: _jsx(Icon, { name: "x", size: 16 }) }));
26
+ return (_jsx("button", { type: "button", tabIndex: -1, className: "vk-field-clear", "aria-label": clearLabel || messages.clear, onMouseDown: (e) => { e.preventDefault(); }, onClick: onClear, children: _jsx(Icon, { name: "x", size: 16 }) }));
25
27
  }
26
28
  /** The popup, which ListPanel makes the Radix content (so a plain element, not a component): a <ul> listbox, or a <div> status when nothing matches. */
27
29
  function optionList({ listId, options, value, active, setActive, query, onPick, emptyText, ...labels }) {
28
30
  if (!options.length) {
29
- return (_jsx("div", { id: listId, className: "vk-select-menu vk-select-empty", role: "status", children: emptyText || "No matches for “" + query + "”" }));
31
+ return (_jsx("div", { id: listId, className: "vk-select-menu vk-select-empty", role: "status", children: emptyText }));
30
32
  }
31
33
  return (_jsx("ul", { id: listId, role: "listbox", className: "vk-select-menu", "aria-labelledby": labels["aria-labelledby"], "aria-label": labels["aria-label"], children: options.map((o, i) => {
32
34
  const isSel = o.value === value;
33
- return (_jsxs("li", { id: listId + "-" + i, "data-index": i, role: "option", "aria-selected": isSel ? "true" : "false", "aria-disabled": o.disabled ? "true" : undefined, className: cx("vk-select-option", i === active && "vk-select-option-active"), onMouseDown: (e) => e.preventDefault(), onMouseMove: () => {
35
+ return (_jsxs("li", { id: listId + "-" + String(i), "data-index": i, role: "option", "aria-selected": isSel ? "true" : "false", "aria-disabled": o.disabled ? "true" : undefined, className: cx("vk-select-option", i === active && "vk-select-option-active"), onMouseDown: (e) => { e.preventDefault(); }, onMouseMove: () => {
34
36
  if (!o.disabled && i !== active)
35
37
  setActive(i);
36
- }, onClick: () => onPick(o), children: [_jsxs("span", { className: "vk-select-option-text", children: [_jsx("span", { children: highlight(o.label, query) }), o.description ? _jsx("span", { className: "vk-select-option-description", children: o.description }) : null] }), isSel ? _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) : null] }, o.value));
38
+ }, onClick: () => { onPick(o); }, children: [_jsxs("span", { className: "vk-select-option-text", children: [_jsx("span", { children: highlight(o.label, query) }), o.description ? _jsx("span", { className: "vk-select-option-description", children: o.description }) : null] }), isSel ? _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) : null] }, o.value));
37
39
  }) }));
38
40
  }
39
41
  /** Searchable single select (WAI-ARIA combobox, list autocomplete). The list is a Radix Popover anchored to the field. */
40
42
  export function Combobox(props) {
43
+ const { messages } = useLocale();
41
44
  const options = normalizeOptions(props.options);
42
45
  const base = useUid("vk-combo");
43
46
  const inputId = props.id || base + "-input";
@@ -46,7 +49,7 @@ export function Combobox(props) {
46
49
  const [uncontrolledValue, setUncontrolledValue] = useState(props.defaultValue !== undefined ? props.defaultValue : null);
47
50
  const value = controlled ? props.value : uncontrolledValue;
48
51
  const selected = optionWithValue(options, value);
49
- const selectedLabel = selected ? String(selected.label) : "";
52
+ const selectedLabel = selected ? selected.label : "";
50
53
  const [text, setText] = useState(selectedLabel);
51
54
  const [query, setQuery] = useState("");
52
55
  const [open, setOpen] = useState(Boolean(props.defaultOpen));
@@ -82,7 +85,7 @@ export function Combobox(props) {
82
85
  if (!o || o.disabled)
83
86
  return;
84
87
  setValue(o);
85
- setText(String(o.label));
88
+ setText(o.label);
86
89
  setQuery("");
87
90
  close();
88
91
  };
@@ -93,25 +96,29 @@ export function Combobox(props) {
93
96
  setActive(i);
94
97
  };
95
98
  const selectedIn = (list) => {
96
- for (let i = 0; i < list.length; i++)
97
- if (list[i].value === value && !list[i].disabled)
98
- return i;
99
+ for (const [index, option] of list.entries())
100
+ if (option.value === value && !option.disabled)
101
+ return index;
99
102
  return nextEnabled(list, 0, 1);
100
103
  };
101
104
  const onKeyDown = (e) => {
102
105
  const key = e.key;
103
106
  if (key === "ArrowDown") {
104
107
  e.preventDefault();
105
- if (!open)
106
- return openAt(e.altKey ? -1 : selectedIn(filtered));
108
+ if (!open) {
109
+ openAt(e.altKey ? -1 : selectedIn(filtered));
110
+ return;
111
+ }
107
112
  const n = nextEnabled(filtered, active + 1, 1);
108
113
  if (n >= 0)
109
114
  setActive(n);
110
115
  }
111
116
  else if (key === "ArrowUp") {
112
117
  e.preventDefault();
113
- if (!open)
114
- return openAt(nextEnabled(filtered, filtered.length - 1, -1));
118
+ if (!open) {
119
+ openAt(nextEnabled(filtered, filtered.length - 1, -1));
120
+ return;
121
+ }
115
122
  const p = nextEnabled(filtered, active - 1, -1);
116
123
  if (p >= 0)
117
124
  setActive(p);
@@ -143,7 +150,7 @@ export function Combobox(props) {
143
150
  }
144
151
  };
145
152
  const a11y = omit(props, ["options", "placeholder", "className", "value", "defaultValue", "onChange", "disabled", "name", "id", "defaultOpen", "emptyText", "icon", "required", "clearLabel"]);
146
- const input = (_jsx("input", { ref: inputRef, id: inputId, type: "text", role: "combobox", autoComplete: "off", spellCheck: false, className: cx("vk-input", "vk-combobox-input", props.icon === "search" && "vk-has-lead"), placeholder: props.placeholder, disabled: props.disabled, required: props.required, "aria-autocomplete": "list", "aria-expanded": open ? "true" : "false", "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? listId + "-" + active : undefined, value: text, onChange: (e) => {
153
+ const input = (_jsx("input", { ref: inputRef, id: inputId, type: "text", role: "combobox", autoComplete: "off", spellCheck: false, className: cx("vk-input", "vk-combobox-input", props.icon === "search" && "vk-has-lead"), placeholder: props.placeholder, disabled: props.disabled, required: props.required, "aria-autocomplete": "list", "aria-expanded": open ? "true" : "false", "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? listId + "-" + String(active) : undefined, value: text, onChange: (e) => {
147
154
  const v = e.target.value;
148
155
  setText(v);
149
156
  setQuery(v);
@@ -181,7 +188,7 @@ export function Combobox(props) {
181
188
  setActive,
182
189
  query,
183
190
  onPick: commit,
184
- emptyText: props.emptyText,
191
+ emptyText: props.emptyText || messages.noMatches(query),
185
192
  "aria-label": props["aria-label"],
186
193
  "aria-labelledby": props["aria-labelledby"],
187
194
  }) }), props.name ? _jsx("input", { type: "hidden", name: props.name, value: value ?? "" }) : null] }) }));
@@ -20,7 +20,7 @@ const PANEL_STYLE = {
20
20
  "--vk-float-max": "max(96px, var(--radix-popper-available-height))",
21
21
  };
22
22
  const inside = (root, target) => Boolean(root.current && target instanceof Node && root.current.contains(target));
23
- const prevent = (e) => e.preventDefault();
23
+ const prevent = (e) => { e.preventDefault(); };
24
24
  /**
25
25
  * The listbox panel of Combobox and MultiSelect: Radix Popover content, portalled to the body and
26
26
  * placed 4px from the field (Popover.Anchor), at least as wide, flipping above when there's no room.
@@ -55,15 +55,26 @@ export function ListPanel({ rootRef, active, children }) {
55
55
  const node = nodeRef.current;
56
56
  if (!shown || !node || active < 0)
57
57
  return;
58
- const el = node.querySelector(`[data-index="${active}"]`);
58
+ const el = node.querySelector(`[data-index="${String(active)}"]`);
59
59
  if (!el)
60
60
  return;
61
- // Scroll the list only (scrollIntoView could also scroll the page).
62
- const top = el.offsetTop, bottom = top + el.offsetHeight;
63
- if (top < node.scrollTop)
64
- node.scrollTop = top;
65
- else if (bottom > node.scrollTop + node.clientHeight)
66
- node.scrollTop = bottom - node.clientHeight;
61
+ const reveal = () => {
62
+ // Scroll the list only (scrollIntoView could also scroll the page).
63
+ const top = el.offsetTop, bottom = top + el.offsetHeight;
64
+ if (top < node.scrollTop)
65
+ node.scrollTop = top;
66
+ else if (bottom > node.scrollTop + node.clientHeight)
67
+ node.scrollTop = bottom - node.clientHeight;
68
+ };
69
+ reveal();
70
+ // Radix measures and caps the panel after it mounts, and again when the viewport changes.
71
+ // Keep the active option visible as that available space or its text dimensions change.
72
+ if (typeof ResizeObserver === "undefined")
73
+ return;
74
+ const observer = new ResizeObserver(reveal);
75
+ observer.observe(node);
76
+ observer.observe(el);
77
+ return () => { observer.disconnect(); };
67
78
  }, [shown, active]);
68
79
  return (_jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { asChild: true, ref: ref, side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, onOpenAutoFocus: prevent, onCloseAutoFocus: prevent,
69
80
  // The input handles its own Escape (close, then clear); Radix dismisses only from elsewhere.
@@ -71,5 +82,5 @@ export function ListPanel({ rootRef, active, children }) {
71
82
  e.preventDefault(); }, onInteractOutside: (e) => { if (ours(e.target))
72
83
  e.preventDefault(); },
73
84
  // Keep focus in the input when the panel itself is pressed.
74
- onMouseDown: (e) => e.preventDefault(), tabIndex: undefined, style: PANEL_STYLE, children: children }) }));
85
+ onMouseDown: (e) => { e.preventDefault(); }, tabIndex: undefined, style: PANEL_STYLE, children: children }) }));
75
86
  }
@@ -1,5 +1,6 @@
1
1
  "use client";
2
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useLocale } from "../../localization.js";
3
4
  import { useEffect, useRef, useState } from "react";
4
5
  import { Dialog } from "../Dialog/Dialog.js";
5
6
  import { Icon } from "../Icon/Icon.js";
@@ -11,6 +12,7 @@ import { useUid } from "../../internal/useUid.js";
11
12
  import { cx } from "../../lib/cx.js";
12
13
  /** A searchable list of every action and destination in an app, opened with ⌘K (Ctrl+K). Its shell is the Radix-based Dialog. */
13
14
  export function CommandPalette({ commands, open: openProp, onOpenChange, hotkey, placeholder, emptyText, title }) {
15
+ const { messages } = useLocale();
14
16
  const controlled = openProp !== undefined;
15
17
  const [openState, setOpenState] = useState(false);
16
18
  const open = openProp ?? openState;
@@ -20,33 +22,49 @@ export function CommandPalette({ commands, open: openProp, onOpenChange, hotkey,
20
22
  onOpenChange?.(v);
21
23
  };
22
24
  const uid = useUid("vk-cmd");
25
+ // A keyboard command has no Dialog.Trigger: its invoker is application context.
26
+ const invokerRef = useRef(null);
23
27
  // The hotkey listener toggles from the latest state without re-subscribing on every change.
24
- const toggleRef = useRef(() => setOpen(!open));
25
- useIsoLayoutEffect(() => { toggleRef.current = () => setOpen(!open); });
28
+ const toggleRef = useRef(() => { setOpen(!open); });
29
+ useIsoLayoutEffect(() => { toggleRef.current = () => { setOpen(!open); }; });
26
30
  useEffect(() => {
27
31
  if (hotkey === false)
28
32
  return undefined;
29
33
  const onKey = (e) => {
30
34
  if ((e.metaKey || e.ctrlKey) && (e.key === "k" || e.key === "K")) {
31
35
  e.preventDefault();
36
+ if (e.target instanceof HTMLElement && !e.target.closest(".vk-cmd"))
37
+ invokerRef.current = e.target;
32
38
  toggleRef.current();
33
39
  }
34
40
  };
35
41
  document.addEventListener("keydown", onKey);
36
- return () => document.removeEventListener("keydown", onKey);
42
+ return () => { document.removeEventListener("keydown", onKey); };
37
43
  }, [hotkey]);
38
- return (_jsxs(Dialog, { open: open, onClose: () => setOpen(false), title: title || "Command palette", className: "vk-cmd", size: "md", closeOnBackdrop: true, children: [_jsx(PaletteSearch, { uid: uid, commands: commands, placeholder: placeholder, emptyText: emptyText, close: () => setOpen(false) }), _jsxs("div", { className: "vk-cmd-footer", "aria-hidden": "true", children: [_jsx(Kbd, { children: "↑" }), _jsx(Kbd, { children: "↓" }), " to move ", _jsx(Kbd, { children: "Enter" }), " to run ", _jsx(Kbd, { children: "Esc" }), " to close"] })] }));
44
+ return (_jsxs(Dialog, { open: open, onOpenChange: setOpen, title: title || messages.commandPalette, className: "vk-cmd", size: "md", contentProps: {
45
+ onOpenAutoFocus(event) {
46
+ event.preventDefault();
47
+ document.getElementById(uid + "-search")?.focus();
48
+ },
49
+ onCloseAutoFocus(event) {
50
+ if (invokerRef.current?.isConnected) {
51
+ event.preventDefault();
52
+ invokerRef.current.focus();
53
+ }
54
+ }
55
+ }, children: [_jsx(PaletteSearch, { uid: uid, commands: commands, placeholder: placeholder, emptyText: emptyText, close: () => { setOpen(false); } }), _jsxs("div", { className: "vk-cmd-footer", "aria-hidden": "true", children: [_jsx(Kbd, { children: "↑" }), _jsx(Kbd, { children: "↓" }), messages.commandMove, _jsx(Kbd, { children: "Enter" }), messages.commandRun, _jsx(Kbd, { children: "Esc" }), messages.commandClose] })] }));
39
56
  }
40
57
  /** The search box and the matching commands. */
41
58
  function PaletteSearch({ uid, commands, placeholder, emptyText, close }) {
59
+ const { messages } = useLocale();
42
60
  const [query, setQuery] = useState("");
43
61
  const [active, setActive] = useState(0);
44
62
  const listRef = useRef(null);
45
- const cmds = (commands || []).filter((c) => {
63
+ const cmds = commands.filter((c) => {
46
64
  if (!query)
47
65
  return true;
48
66
  const q = query.toLowerCase();
49
- return String(c.label).toLowerCase().includes(q) || (c.keywords || []).some((k) => k.toLowerCase().includes(q)) || (c.group && c.group.toLowerCase().includes(q));
67
+ return c.label.toLowerCase().includes(q) || (c.keywords || []).some((k) => k.toLowerCase().includes(q)) || (c.group && c.group.toLowerCase().includes(q));
50
68
  });
51
69
  useScrollActive(true, listRef, active);
52
70
  const run = (c) => {
@@ -60,11 +78,12 @@ function PaletteSearch({ uid, commands, placeholder, emptyText, close }) {
60
78
  cmds.forEach((c, i) => {
61
79
  const g = c.group || "";
62
80
  const last = groups[groups.length - 1];
63
- if (!last || last.name !== g)
64
- groups.push({ name: g, items: [] });
65
- groups[groups.length - 1].items.push({ c, i });
81
+ if (last && last.name === g)
82
+ last.items.push({ c, i });
83
+ else
84
+ groups.push({ name: g, items: [{ c, i }] });
66
85
  });
67
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "vk-cmd-search", children: [_jsx(Icon, { name: "search", size: 16, className: "vk-search-icon" }), _jsx("input", { "data-autofocus": "", type: "text", role: "combobox", className: "vk-input vk-search-input", placeholder: placeholder || "Type a command or search", autoComplete: "off", value: query, "aria-expanded": "true", "aria-controls": uid + "-list", "aria-activedescendant": cmds.length ? uid + "-" + active : undefined, "aria-autocomplete": "list", onChange: (e) => { setQuery(e.target.value); setActive(0); }, onKeyDown: (e) => {
86
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "vk-cmd-search", children: [_jsx(Icon, { name: "search", size: 16, className: "vk-search-icon" }), _jsx("input", { id: uid + "-search", type: "text", role: "combobox", className: "vk-input vk-search-input", placeholder: placeholder || messages.commandSearch, autoComplete: "off", value: query, "aria-expanded": "true", "aria-controls": uid + "-list", "aria-activedescendant": cmds.length ? uid + "-" + String(active) : undefined, "aria-autocomplete": "list", onChange: (e) => { setQuery(e.target.value); setActive(0); }, onKeyDown: (e) => {
68
87
  if (e.key === "ArrowDown") {
69
88
  e.preventDefault();
70
89
  setActive(Math.min(cmds.length - 1, active + 1));
@@ -78,9 +97,9 @@ function PaletteSearch({ uid, commands, placeholder, emptyText, close }) {
78
97
  run(cmds[active]);
79
98
  }
80
99
  } })] }), cmds.length
81
- ? (_jsx("div", { ref: listRef, id: uid + "-list", role: "listbox", "aria-label": "Commands", className: "vk-cmd-list", children: groups.map((g) => (_jsxs("div", { role: "group", "aria-label": g.name || undefined, children: [g.name ? _jsx("div", { className: "vk-menu-label", "aria-hidden": "true", children: g.name }) : null, g.items.map(({ c, i }) => (_jsxs("div", { id: uid + "-" + i, "data-index": i, role: "option", "aria-selected": i === active ? "true" : "false", "aria-disabled": c.disabled ? "true" : undefined, className: cx("vk-menu-item", "vk-cmd-item", i === active ? "vk-cmd-item-active" : null), onMouseMove: () => { if (active !== i)
100
+ ? (_jsx("div", { ref: listRef, id: uid + "-list", role: "listbox", "aria-label": messages.commands, className: "vk-cmd-list", children: groups.map((g) => (_jsxs("div", { role: "group", "aria-label": g.name || undefined, children: [g.name ? _jsx("div", { className: "vk-menu-label", "aria-hidden": "true", children: g.name }) : null, g.items.map(({ c, i }) => (_jsxs("div", { id: uid + "-" + String(i), "data-index": i, role: "option", "aria-selected": i === active ? "true" : "false", "aria-disabled": c.disabled ? "true" : undefined, className: cx("vk-menu-item", "vk-cmd-item", i === active ? "vk-cmd-item-active" : null), onMouseMove: () => { if (active !== i)
82
101
  setActive(i); },
83
102
  // Keep focus in the search box while clicking a command.
84
- onMouseDown: (e) => e.preventDefault(), onClick: () => run(c), children: [c.icon ? _jsx(Icon, { name: c.icon, size: 16, className: "vk-menu-item-icon" }) : _jsx("span", { className: "vk-menu-item-icon" }), _jsx("span", { className: "vk-menu-item-label", children: highlight(c.label, query) }), c.shortcut ? _jsx("kbd", { className: "vk-menu-shortcut", children: c.shortcut }) : null] }, c.id || c.label)))] }, g.name || "_"))) }))
85
- : _jsx("p", { className: "vk-select-empty", role: "status", children: emptyText || "No commands match “" + query + "”" })] }));
103
+ onMouseDown: (e) => { e.preventDefault(); }, onClick: () => { run(c); }, children: [c.icon ? _jsx(Icon, { name: c.icon, size: 16, className: "vk-menu-item-icon" }) : _jsx("span", { className: "vk-menu-item-icon" }), _jsx("span", { className: "vk-menu-item-label", children: highlight(c.label, query) }), c.shortcut ? _jsx("kbd", { className: "vk-menu-shortcut", children: c.shortcut }) : null] }, c.id || c.label)))] }, g.name || "_"))) }))
104
+ : _jsx("p", { className: "vk-select-empty", role: "status", children: emptyText || messages.noCommands(query) })] }));
86
105
  }
@@ -1,4 +1,4 @@
1
- import { type ReactNode } from "react";
1
+ import type { ReactNode } from "react";
2
2
  import type { MenuEntry } from "../../types.js";
3
3
  export interface ContextMenuProps {
4
4
  items: MenuEntry[];
@@ -7,5 +7,5 @@ export interface ContextMenuProps {
7
7
  disabled?: boolean;
8
8
  className?: string;
9
9
  }
10
- /** Right-click (or Shift+F10) actions for a region: a file, a row, a canvas object. Built on Radix ContextMenu. */
10
+ /** Actions for a region, with trigger gestures and focus supplied by Radix ContextMenu. */
11
11
  export declare function ContextMenu({ items, children, label, disabled, className }: ContextMenuProps): import("react/jsx-runtime").JSX.Element;
@@ -1,56 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useEffect, useState } from "react";
3
+ import { useLocale } from "../../localization.js";
4
4
  import { ContextMenu as Primitive } from "radix-ui";
5
5
  import { cx } from "../../lib/cx.js";
6
- import { MenuEntries, useDeferredSelect, useFocusOnOpen, moveFocusNow } from "../Menu/entries.js";
7
- /** Right-click (or Shift+F10) actions for a region: a file, a row, a canvas object. Built on Radix ContextMenu. */
6
+ import { MenuEntries } from "../Menu/entries.js";
7
+ /** Actions for a region, with trigger gestures and focus supplied by Radix ContextMenu. */
8
8
  export function ContextMenu({ items, children, label, disabled, className }) {
9
- // Opening goes through "opening": Radix moves its anchor to the new point in an effect; opening in the
10
- // same render would place the menu against the previous point for a frame (the viewport's corner, the first time).
11
- const [state, setState] = useState("closed");
12
- const open = state === "open";
13
- const { defer, flush } = useDeferredSelect();
14
- const { arm, onFocus } = useFocusOnOpen();
15
- const onOpenChange = (next) => {
16
- arm(next ? "first" : null);
17
- // An open menu stays open while Radix moves it to a new point.
18
- setState((s) => (!next ? "closed" : s === "open" ? "open" : "opening"));
19
- };
20
- useEffect(() => {
21
- if (state === "opening")
22
- setState("open");
23
- }, [state]);
24
- // Scrolling the page (not the menu itself) closes it: the menu is anchored to a point, not an element.
25
- useEffect(() => {
26
- if (!open)
27
- return undefined;
28
- const onScroll = (e) => {
29
- if (e.target instanceof Element && e.target.closest(".vk-menu"))
30
- return;
31
- arm(null);
32
- setState("closed");
33
- };
34
- window.addEventListener("scroll", onScroll, true);
35
- return () => window.removeEventListener("scroll", onScroll, true);
36
- }, [open, arm]);
37
- return (_jsxs(Primitive.Root, { open: open, onOpenChange: onOpenChange, modal: false, children: [_jsx(Primitive.Trigger, { asChild: true, disabled: disabled, children: _jsx("div", { className: cx("vk-context-target", className), onContextMenu: (e) => {
38
- // React bubbles events through portals: ignore right-clicks inside the open menu.
39
- if (!e.currentTarget.contains(e.target))
40
- e.preventDefault();
41
- }, onKeyDown: (e) => {
42
- if (disabled || !e.currentTarget.contains(e.target))
43
- return;
44
- if ((e.key === "F10" && e.shiftKey) || e.key === "ContextMenu") {
45
- // Radix opens on the contextmenu event only, which not every browser sends for these keys:
46
- // open it at the focused element instead, as a right-click there would.
47
- e.preventDefault();
48
- const target = e.target;
49
- const r = target.getBoundingClientRect();
50
- target.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: r.left + 8, clientY: r.bottom }));
51
- }
52
- }, children: children }) }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { className: "vk-menu vk-context-menu", "aria-label": label || "Actions", collisionPadding: 8, loop: true, onFocus: onFocus, onKeyDownCapture: moveFocusNow, onCloseAutoFocus: () => flush(), onKeyDown: (e) => { if (e.key === "Tab") {
53
- e.preventDefault();
54
- onOpenChange(false);
55
- } }, children: _jsx(MenuEntries, { parts: Primitive, items: items || [], defer: defer }) }) })] }));
9
+ const { messages } = useLocale();
10
+ return (_jsxs(Primitive.Root, { children: [_jsx(Primitive.Trigger, { asChild: true, disabled: disabled, children: _jsx("div", { className: cx("vk-context-target", className), children: children }) }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { className: "vk-menu vk-context-menu", "aria-label": label || messages.actions, collisionPadding: 8, children: _jsx(MenuEntries, { parts: Primitive, items: items }) }) })] }));
56
11
  }
@@ -1,5 +1,6 @@
1
1
  "use client";
2
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { LocaleProvider, useLocale } from "../../localization.js";
3
4
  import { forwardRef, useCallback, useRef, useState } from "react";
4
5
  import { Popover as Primitive } from "radix-ui";
5
6
  import { Button } from "../Button/Button.js";
@@ -7,9 +8,9 @@ import { Calendar } from "../Calendar/Calendar.js";
7
8
  import { Icon } from "../Icon/Icon.js";
8
9
  import { focusables } from "../../internal/focusables.js";
9
10
  import { useUid } from "../../internal/useUid.js";
11
+ import { useToday } from "../../internal/useToday.js";
10
12
  import { cx } from "../../lib/cx.js";
11
13
  import { parseDateInput, parseISO, toISO } from "../../lib/dates.js";
12
- import { resolveLocale } from "../../lib/format.js";
13
14
  import { dateFormat } from "../../lib/intl.js";
14
15
  import { omit } from "../../lib/omit.js";
15
16
  const tabbable = (el) => focusables(el).filter((n) => n.tabIndex >= 0);
@@ -31,7 +32,7 @@ function dateLabel(fmt, range, value) {
31
32
  const start = range ? parseISO(rangeValue?.start) : parseISO(typeof value === "string" ? value : null);
32
33
  const end = range ? parseISO(rangeValue?.end) : null;
33
34
  if (start && range && end)
34
- return fmt.formatRange ? fmt.formatRange(start, end) : fmt.format(start) + " – " + fmt.format(end);
35
+ return typeof Reflect.get(fmt, "formatRange") === "function" ? fmt.formatRange(start, end) : fmt.format(start) + " – " + fmt.format(end);
35
36
  if (start && range)
36
37
  return fmt.format(start) + " – …";
37
38
  if (start)
@@ -62,8 +63,9 @@ function allowedDate(iso, props) {
62
63
  return iso !== null && d !== null && !(minD && d < minD) && !(maxD && d > maxD) && !props.isDateDisabled?.(iso);
63
64
  }
64
65
  /** Typing mode: a text input, with a button that opens the calendar. */
65
- function TypedField(p) {
66
- return (_jsx(Primitive.Anchor, { asChild: true, children: _jsxs("div", { className: "vk-combobox-field vk-date-field", children: [_jsx("input", { ref: p.fieldRef, id: p.id, type: "text", autoComplete: "off", className: "vk-input vk-date-input", placeholder: p.placeholder, disabled: p.disabled, value: p.text, onChange: (e) => p.onType(e.target.value), onKeyDown: (e) => {
66
+ function TypedField({ fieldRef, popRef, ...p }) {
67
+ const { messages } = useLocale();
68
+ return (_jsx(Primitive.Anchor, { asChild: true, children: _jsxs("div", { className: "vk-combobox-field vk-date-field", children: [_jsx("input", { ref: fieldRef, id: p.id, type: "text", autoComplete: "off", className: "vk-input vk-date-input", placeholder: p.placeholder, disabled: p.disabled, value: p.text, onChange: (e) => { p.onType(e.target.value); }, onKeyDown: (e) => {
67
69
  if (e.key === "Enter") {
68
70
  e.preventDefault();
69
71
  p.onCommit();
@@ -73,29 +75,31 @@ function TypedField(p) {
73
75
  p.onOpen();
74
76
  }
75
77
  }, onBlur: (e) => {
76
- if (!(p.popRef.current && p.popRef.current.contains(e.relatedTarget)))
78
+ if (!(popRef.current && popRef.current.contains(e.relatedTarget)))
77
79
  p.onCommit();
78
- }, ...p.a11y, "aria-invalid": p.invalid || p.a11y["aria-invalid"] ? true : undefined, ...(p.invalid ? { "aria-describedby": cx(p.a11y["aria-describedby"], p.errId) } : null) }), _jsx(Primitive.Trigger, { asChild: true, children: _jsx("button", { type: "button", className: "vk-field-clear vk-date-button", disabled: p.disabled, "aria-label": (p.dialogLabel || "Choose a date") + (p.label ? ", " + p.label : ""), onClick: p.onButtonClick, children: _jsx(Icon, { name: "calendar", size: 16 }) }) })] }) }));
80
+ }, ...p.a11y, "aria-invalid": p.invalid || p.a11y["aria-invalid"] ? true : undefined, ...(p.invalid ? { "aria-describedby": cx(p.a11y["aria-describedby"], p.errId) } : null) }), _jsx(Primitive.Trigger, { asChild: true, children: _jsx("button", { type: "button", className: "vk-field-clear vk-date-button", disabled: p.disabled, "aria-label": (p.dialogLabel || messages.chooseDate) + (p.label ? ", " + p.label : ""), onClick: p.onButtonClick, children: _jsx(Icon, { name: "calendar", size: 16 }) }) })] }) }));
79
81
  }
80
82
  /** Without typing: a button that shows the chosen date(s) and opens the calendar. */
81
83
  function ButtonField({ fieldRef, id, disabled, open, label, placeholder, range, a11y, onOpen }) {
84
+ const { messages } = useLocale();
82
85
  return (_jsx(Primitive.Trigger, { asChild: true, children: _jsxs("button", { ref: fieldRef, id: id, type: "button", className: "vk-input vk-select-trigger vk-date-trigger", disabled: disabled, onKeyDown: (e) => {
83
86
  if (e.key === "ArrowDown" && !open) {
84
87
  e.preventDefault();
85
88
  onOpen();
86
89
  }
87
- }, ...a11y, children: [_jsx(Icon, { name: "calendar", size: 16, className: "vk-date-icon" }), _jsx("span", { className: label ? "vk-select-value" : "vk-select-value vk-select-placeholder", children: label || placeholder || (range ? "Select dates" : "Select a date") })] }) }));
90
+ }, ...a11y, children: [_jsx(Icon, { name: "calendar", size: 16, className: "vk-date-icon" }), _jsx("span", { className: label ? "vk-select-value" : "vk-select-value vk-select-placeholder", children: label || placeholder || (range ? messages.selectDates : messages.selectDate) })] }) }));
88
91
  }
89
92
  /** The portalled popover dialog: the Calendar, with Clear and (single mode) Today. */
90
- function DatePanel({ props, range, locale, value, todayISO, rootRef, popRef, refocus, changeOpen, set }) {
91
- const close = () => changeOpen(false);
92
- return (_jsx(Primitive.Portal, { children: _jsxs(Primitive.Content, { ref: popRef, "aria-label": props.dialogLabel || (range ? "Choose dates" : "Choose a date"), className: "vk-popover vk-date-popover", side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, onInteractOutside: (e) => {
93
+ function DatePanel({ props, range, locale, value, todayISO, rootRef, popRef, refocusRef, changeOpen, set }) {
94
+ const { messages } = useLocale();
95
+ const close = () => { changeOpen(false); };
96
+ return (_jsx(Primitive.Portal, { children: _jsxs(Primitive.Content, { ref: popRef, "aria-label": props.dialogLabel || (range ? messages.chooseDates : messages.chooseDate), className: "vk-popover vk-date-popover", side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, onInteractOutside: (e) => {
93
97
  // The field and its button belong to the picker: pressing them keeps it open (the button toggles it).
94
- if (rootRef.current && rootRef.current.contains(e.target))
98
+ if (e.target instanceof Node && rootRef.current && rootRef.current.contains(e.target))
95
99
  e.preventDefault();
96
100
  else
97
- refocus.current = false;
98
- }, onCloseAutoFocus: (e) => e.preventDefault(), onKeyDown: (e) => {
101
+ refocusRef.current = false;
102
+ }, onCloseAutoFocus: (e) => { e.preventDefault(); }, onKeyDown: (e) => {
99
103
  // Radix closes the panel on Escape; an enclosing dialog stays open.
100
104
  if (e.key === "Escape")
101
105
  e.stopPropagation();
@@ -108,23 +112,24 @@ function DatePanel({ props, range, locale, value, todayISO, rootRef, popRef, ref
108
112
  e.preventDefault();
109
113
  e.stopPropagation();
110
114
  const next = tabTarget(rootRef.current, content, e.shiftKey);
111
- refocus.current = !next;
115
+ refocusRef.current = !next;
112
116
  changeOpen(false);
113
117
  next?.focus();
114
- }, children: [_jsx(Calendar, { mode: props.mode, locale: locale, value: value, min: props.min, max: props.max, isDateDisabled: props.isDateDisabled, weekStartsOn: props.weekStartsOn, today: props.today, autoFocus: true, onChange: (next) => {
118
+ }, children: [_jsx(Calendar, { mode: props.mode, locale: locale, value: value, min: props.min, max: props.max, isDateDisabled: props.isDateDisabled, weekStartsOn: props.weekStartsOn, today: todayISO, autoFocus: true, onChange: (next) => {
115
119
  set(next);
116
120
  if (!range || (typeof next === "object" && next.start && next.end))
117
121
  close();
118
122
  } }), _jsxs("div", { className: "vk-popover-footer", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: () => {
119
123
  set(range ? { start: null, end: null } : null);
120
124
  close();
121
- }, children: "Clear" }), range ? null : (_jsx(Button, { variant: "outline", size: "sm", onClick: () => {
125
+ }, children: messages.clear }), range ? null : (_jsx(Button, { variant: "outline", size: "sm", onClick: () => {
122
126
  set(todayISO);
123
127
  close();
124
- }, children: "Today" }))] })] }) }));
128
+ }, children: messages.today }))] })] }) }));
125
129
  }
126
130
  function InvalidDate({ id, message, example }) {
127
- return _jsx("span", { id: id, className: "vk-field-error vk-inline-error", children: message || "Enter a date like " + example + "." });
131
+ const { messages } = useLocale();
132
+ return _jsx("span", { id: id, className: "vk-field-error vk-inline-error", children: message || messages.invalidDate(example) });
128
133
  }
129
134
  /** The value for forms: name=YYYY-MM-DD, or name_start and name_end in range mode. */
130
135
  function HiddenDate({ name, range, value }) {
@@ -138,8 +143,8 @@ function HiddenDate({ name, range, value }) {
138
143
  * to the text input, or to the trigger button when typing is off.
139
144
  */
140
145
  export const DatePicker = forwardRef(function DatePicker(props, ref) {
146
+ const { locale } = useLocale(props.locale);
141
147
  const range = props.mode === "range";
142
- const locale = resolveLocale(props.locale);
143
148
  const base = useUid("vk-date");
144
149
  const triggerId = props.id || base + "-trigger";
145
150
  const { value, set, draft, setDraft } = useDateValue(props, range);
@@ -155,18 +160,19 @@ export const DatePicker = forwardRef(function DatePicker(props, ref) {
155
160
  ref.current = el;
156
161
  }, [ref]);
157
162
  // False when the panel closes because people clicked or tabbed elsewhere: focus stays there.
158
- const refocus = useRef(true);
163
+ const refocusRef = useRef(true);
159
164
  const changeOpen = (next) => {
160
165
  if (next)
161
- refocus.current = true;
166
+ refocusRef.current = true;
162
167
  setOpen(next);
163
168
  // Focus returns right away rather than after the exit animation.
164
- if (!next && refocus.current)
169
+ if (!next && refocusRef.current)
165
170
  fieldRef.current?.focus();
166
171
  };
167
172
  const fmt = dateFormat(locale, { month: "short", day: "numeric", year: "numeric" });
168
173
  const label = dateLabel(fmt, range, value);
169
- const todayISO = props.today || toISO(new Date());
174
+ const todayDate = useToday(props.today);
175
+ const todayISO = toISO(todayDate);
170
176
  const typing = !range && props.allowTyping !== false;
171
177
  const text = draft ? draft.text : label || "";
172
178
  const invalid = Boolean(draft?.invalid);
@@ -188,11 +194,11 @@ export const DatePicker = forwardRef(function DatePicker(props, ref) {
188
194
  };
189
195
  const a11y = omit(props, ["mode", "locale", "id", "value", "defaultValue", "onChange", "placeholder", "min", "max", "isDateDisabled", "weekStartsOn", "name", "disabled", "defaultOpen", "className", "today", "dialogLabel", "allowTyping", "invalidMessage"]);
190
196
  const errId = base + "-err";
191
- const example = fmt.format(parseISO(todayISO) || new Date());
192
- const trigger = typing ? (_jsx(TypedField, { fieldRef: setFieldRef, id: triggerId, placeholder: props.placeholder || example, disabled: props.disabled, text: text, invalid: invalid, errId: errId, a11y: a11y, dialogLabel: props.dialogLabel, label: label, onType: (t) => setDraft({ text: t, invalid: false, value }), onCommit: commitTyped, onOpen: () => changeOpen(true), onButtonClick: () => {
197
+ const example = fmt.format(todayDate);
198
+ const trigger = typing ? (_jsx(TypedField, { fieldRef: setFieldRef, id: triggerId, placeholder: props.placeholder || example, disabled: props.disabled, text: text, invalid: invalid, errId: errId, a11y: a11y, dialogLabel: props.dialogLabel, label: label, onType: (t) => { setDraft({ text: t, invalid: false, value }); }, onCommit: commitTyped, onOpen: () => { changeOpen(true); }, onButtonClick: () => {
193
199
  // Closing with the button leaves focus on it.
194
200
  if (open)
195
- refocus.current = false;
196
- }, popRef: popRef })) : (_jsx(ButtonField, { fieldRef: setFieldRef, id: triggerId, disabled: props.disabled, open: open, label: label, placeholder: props.placeholder, range: range, a11y: a11y, onOpen: () => changeOpen(true) }));
197
- return (_jsx(Primitive.Root, { open: open, onOpenChange: changeOpen, children: _jsxs("div", { ref: rootRef, className: cx("vk-select", "vk-datepicker", props.className), "data-state": open ? "open" : "closed", children: [trigger, _jsx(DatePanel, { props: props, range: range, locale: locale, value: value, todayISO: todayISO, rootRef: rootRef, popRef: popRef, refocus: refocus, changeOpen: changeOpen, set: set }), invalid ? _jsx(InvalidDate, { id: errId, message: props.invalidMessage, example: example }) : null, props.name ? _jsx(HiddenDate, { name: props.name, range: range, value: value }) : null] }) }));
201
+ refocusRef.current = false;
202
+ }, popRef: popRef })) : (_jsx(ButtonField, { fieldRef: setFieldRef, id: triggerId, disabled: props.disabled, open: open, label: label, placeholder: props.placeholder, range: range, a11y: a11y, onOpen: () => { changeOpen(true); } }));
203
+ return (_jsx(LocaleProvider, { locale: locale, children: _jsx(Primitive.Root, { open: open, onOpenChange: changeOpen, children: _jsxs("div", { ref: rootRef, className: cx("vk-select", "vk-datepicker", props.className), "data-state": open ? "open" : "closed", children: [trigger, _jsx(DatePanel, { props: props, range: range, locale: locale, value: value, todayISO: todayISO, rootRef: rootRef, popRef: popRef, refocusRef: refocusRef, changeOpen: changeOpen, set: set }), invalid ? _jsx(InvalidDate, { id: errId, message: props.invalidMessage, example: example }) : null, props.name ? _jsx(HiddenDate, { name: props.name, range: range, value: value }) : null] }) }) }));
198
204
  });
@@ -2,5 +2,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cx } from "../../lib/cx.js";
3
3
  /** Label and value pairs for a record's details. */
4
4
  export function DescriptionList({ items, layout, columns, className }) {
5
- return (_jsx("dl", { className: cx("vk-dl", layout === "stacked" && "vk-dl-stacked", columns === 2 && "vk-dl-2", className), children: (items || []).map((it, i) => (_jsxs("div", { className: "vk-dl-row", children: [_jsx("dt", { children: it.term }), _jsx("dd", { children: it.description })] }, (typeof it.term === "string" ? it.term : "") + "#" + i))) }));
5
+ return (_jsx("dl", { className: cx("vk-dl", layout === "stacked" && "vk-dl-stacked", columns === 2 && "vk-dl-2", className), children: items.map((it, i) => (_jsxs("div", { className: "vk-dl-row", children: [_jsx("dt", { children: it.term }), _jsx("dd", { children: it.description })] }, (typeof it.term === "string" ? it.term : "") + "#" + String(i)))) }));
6
6
  }
@@ -1,23 +1,40 @@
1
- import { type ReactNode } from "react";
2
- export interface DialogProps {
3
- open: boolean;
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import { AlertDialog, Dialog as Primitive } from "radix-ui";
3
+ interface DialogFrameProps extends Pick<Primitive.DialogProps, 'open' | 'defaultOpen' | 'onOpenChange'> {
4
+ /** Compatibility alias for onOpenChange(false). */
4
5
  onClose?: () => void;
6
+ /** Radix Trigger asChild: supplies opening behavior and focus restoration. */
7
+ trigger?: ReactElement;
5
8
  title: ReactNode;
6
9
  description?: ReactNode;
7
10
  children?: ReactNode;
8
11
  footer?: ReactNode;
9
12
  size?: 'sm' | 'md' | 'lg';
10
- role?: 'dialog' | 'alertdialog';
11
- dismissible?: boolean;
12
- closeOnBackdrop?: boolean;
13
+ /** Presentation only; Escape and outside interaction remain Radix behavior. */
14
+ hideCloseButton?: boolean;
13
15
  closeLabel?: string;
14
16
  className?: string;
15
17
  }
18
+ /** The content contract follows the selected Radix component without widening event props. */
19
+ export type DialogProps = DialogFrameProps & ({
20
+ role?: 'dialog';
21
+ contentProps?: Omit<Primitive.DialogContentProps, 'children' | 'className'>;
22
+ cancel?: never;
23
+ action?: never;
24
+ } | {
25
+ role: 'alertdialog';
26
+ contentProps?: Omit<AlertDialog.AlertDialogContentProps, 'children' | 'className'>;
27
+ /** Radix Cancel receives initial focus when supplied. */
28
+ cancel?: ReactElement;
29
+ /** Radix Action closes after the supplied action. */
30
+ action?: ReactElement;
31
+ });
16
32
  /**
17
33
  * Modal dialog (Radix Dialog; Radix AlertDialog for `role="alertdialog"`): focus moves in and is
18
- * trapped, the page behind is inert and can't scroll, and closing returns focus to the opener.
34
+ * trapped, the page behind is inert and can't scroll, and closing returns focus to its Radix Trigger.
19
35
  */
20
36
  export declare function Dialog(props: DialogProps & {
21
37
  /** Set by Drawer: renders the panel as a sheet on this side. */
22
38
  side?: 'right' | 'left';
23
39
  }): import("react/jsx-runtime").JSX.Element;
40
+ export {};