@efolusi/meridian 1.21.10 → 1.23.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 (147) hide show
  1. package/LICENSE +201 -21
  2. package/THIRD_PARTY_NOTICES.md +3 -3
  3. package/ai/AgentRun.js +1 -0
  4. package/ai/Bubble.js +1 -0
  5. package/ai/ChatMessage.js +1 -0
  6. package/ai/Citation.js +45 -22
  7. package/ai/Confirmation.js +3 -2
  8. package/ai/Conversation.js +1 -0
  9. package/ai/DocumentCard.js +1 -0
  10. package/ai/FeedbackBar.js +1 -0
  11. package/ai/GeneratedImage.js +1 -0
  12. package/ai/Marker.js +1 -0
  13. package/ai/Message.js +1 -0
  14. package/ai/MessageScroller.js +1 -0
  15. package/ai/ModelSelector.js +1 -0
  16. package/ai/Player.js +1 -0
  17. package/ai/PromptComposer.d.ts +4 -0
  18. package/ai/PromptComposer.js +8 -1
  19. package/ai/PromptSteps.js +1 -0
  20. package/ai/Reasoning.js +1 -0
  21. package/ai/RichComposer.js +4 -0
  22. package/ai/Sandbox.js +1 -0
  23. package/ai/SelectionQuote.js +1 -0
  24. package/ai/SourceCard.js +13 -4
  25. package/ai/Suggestions.js +1 -0
  26. package/ai/Task.js +1 -0
  27. package/ai/Todo.js +1 -0
  28. package/ai/ToolCall.js +1 -0
  29. package/ai/Transcript.js +1 -0
  30. package/ai/UsageMeter.d.ts +3 -1
  31. package/ai/UsageMeter.js +9 -2
  32. package/ai/WebPreview.js +13 -4
  33. package/code/CodeBlock.js +27 -7
  34. package/code/Console.js +1 -0
  35. package/code/CopyField.js +25 -9
  36. package/code/Diff.js +1 -0
  37. package/code/EnvList.js +1 -0
  38. package/code/Exception.js +1 -0
  39. package/code/Terminal.js +1 -0
  40. package/components.css +139 -56
  41. package/data/BarChart.d.ts +4 -0
  42. package/data/BarChart.js +29 -4
  43. package/data/Chart.d.ts +1 -1
  44. package/data/Chart.js +10 -4
  45. package/data/DonutChart.d.ts +4 -0
  46. package/data/DonutChart.js +38 -8
  47. package/data/EmptyState.js +1 -0
  48. package/data/KeyValueList.js +1 -0
  49. package/data/LineChart.d.ts +4 -0
  50. package/data/LineChart.js +30 -7
  51. package/data/Skeleton.js +1 -0
  52. package/data/Sparkline.js +1 -0
  53. package/data/Stat.js +1 -0
  54. package/data/StatusDot.js +1 -0
  55. package/data/Table.d.ts +1 -0
  56. package/data/Table.js +36 -19
  57. package/dates/Calendar.js +44 -15
  58. package/dates/TimePicker.js +19 -3
  59. package/display/Accordion.js +1 -0
  60. package/display/AspectRatio.js +1 -0
  61. package/display/Avatar.js +1 -0
  62. package/display/Badge.js +1 -0
  63. package/display/Card.js +1 -0
  64. package/display/Carousel.js +24 -6
  65. package/display/Collapsible.js +1 -0
  66. package/display/Direction.js +1 -0
  67. package/display/Divider.js +1 -0
  68. package/display/Item.js +1 -0
  69. package/display/Kbd.js +1 -0
  70. package/display/Link.js +1 -0
  71. package/display/Resizable.js +5 -4
  72. package/display/ScrollArea.js +4 -2
  73. package/display/Separator.js +1 -0
  74. package/display/Tag.js +1 -0
  75. package/display/Timeline.js +1 -0
  76. package/display/Toolbar.js +2 -0
  77. package/display/TreeList.js +21 -13
  78. package/feedback/Alert.js +1 -0
  79. package/feedback/AlertDialog.js +31 -18
  80. package/feedback/Banner.js +1 -0
  81. package/feedback/ConfirmDialog.js +1 -0
  82. package/feedback/Dialog.js +37 -18
  83. package/feedback/Loader.js +1 -0
  84. package/feedback/Progress.js +1 -0
  85. package/feedback/Spinner.js +1 -0
  86. package/feedback/Toast.js +10 -3
  87. package/feedback/Tooltip.js +25 -6
  88. package/files/Attachment.js +1 -0
  89. package/files/FileDrop.d.ts +5 -1
  90. package/files/FileDrop.js +29 -1
  91. package/files/FileTile.js +1 -0
  92. package/files/FileTypeIcon.js +1 -0
  93. package/finance/PaymentCard.js +1 -0
  94. package/forms/Button.js +55 -0
  95. package/forms/ButtonGroup.js +1 -0
  96. package/forms/ButtonTile.js +3 -0
  97. package/forms/Checkbox.js +1 -0
  98. package/forms/Combobox.js +31 -9
  99. package/forms/Field.js +1 -0
  100. package/forms/IconButton.js +1 -0
  101. package/forms/Input.js +1 -0
  102. package/forms/InputGroup.js +1 -0
  103. package/forms/InputOTP.js +1 -0
  104. package/forms/Label.js +1 -0
  105. package/forms/NativeSelect.js +1 -0
  106. package/forms/NumberInput.js +22 -4
  107. package/forms/Questionnaire.js +2 -1
  108. package/forms/Radio.js +1 -0
  109. package/forms/Select.js +7 -4
  110. package/forms/Slider.js +26 -3
  111. package/forms/Switch.js +15 -3
  112. package/forms/Textarea.js +1 -0
  113. package/forms/Toggle.js +1 -0
  114. package/icons/Icon.js +6 -0
  115. package/icons/_svg.js +1 -1
  116. package/index.js +3 -3
  117. package/navigation/Breadcrumbs.js +1 -0
  118. package/navigation/Menubar.js +1 -0
  119. package/navigation/NavigationMenu.js +18 -5
  120. package/navigation/PageControl.js +2 -0
  121. package/navigation/Pagination.js +1 -0
  122. package/navigation/SegmentedControl.js +2 -0
  123. package/navigation/SideNav.js +3 -0
  124. package/navigation/Sidebar.js +75 -11
  125. package/navigation/SkipLink.d.ts +2 -1
  126. package/navigation/SkipLink.js +17 -4
  127. package/navigation/Steps.js +1 -0
  128. package/navigation/Tabs.js +1 -0
  129. package/navigation/TopNav.js +1 -0
  130. package/overlay/Command.js +2 -0
  131. package/overlay/ContextMenu.js +40 -13
  132. package/overlay/Drawer.d.ts +4 -0
  133. package/overlay/Drawer.js +24 -3
  134. package/overlay/DropdownMenu.js +40 -13
  135. package/overlay/HoverCard.js +29 -19
  136. package/overlay/Popover.js +67 -16
  137. package/overlay/Portal.js +97 -2
  138. package/overlay/Sheet.js +1 -0
  139. package/package.json +2 -2
  140. package/tailwind.preset.cjs +60 -28
  141. package/tokens/base.css +19 -3
  142. package/tokens/colors.css +248 -46
  143. package/tokens/effects.css +33 -20
  144. package/tokens/fonts.css +7 -0
  145. package/tokens/spacing.css +42 -17
  146. package/tokens/typography.css +29 -8
  147. package/tokens.json +689 -115
package/feedback/Toast.js CHANGED
@@ -1,9 +1,10 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
5
6
  import { IconButton } from "../forms/IconButton.js";
6
- import { Portal } from "../overlay/Portal.js";
7
+ import { Portal, useHydrated } from "../overlay/Portal.js";
7
8
  const ICONS = {
8
9
  success: 'circle-check',
9
10
  danger: 'circle-alert',
@@ -111,8 +112,11 @@ function add(options = {}) {
111
112
  const previous = timers.get(id);
112
113
  if (previous?.handle) clearTimeout(previous.handle);
113
114
  timers.delete(id);
115
+ const duration = merged.duration ?? (next.type === 'loading' || next.actionProps ? 0 : defaultDuration);
116
+ // a toast that never expires must be dismissable, or it stays on screen for good
117
+ next.sticky = !(duration > 0) && next.type !== 'loading';
114
118
  records = records.some(item => item.id === id) ? records.map(item => item.id === id ? next : item) : [...records, next];
115
- schedule(id, merged.duration ?? (next.type === 'loading' || next.actionProps ? 0 : defaultDuration));
119
+ schedule(id, duration);
116
120
  emit();
117
121
  return id;
118
122
  }
@@ -214,6 +218,9 @@ export function Toaster({
214
218
  };
215
219
  }, [duration, toastOptions]);
216
220
  const resolvedOffset = typeof offset === 'number' ? `${offset}px` : offset;
221
+ // Mounted on every page load, so wait for hydration: see useHydrated.
222
+ const hydrated = useHydrated();
223
+ if (!hydrated) return /*#__PURE__*/React.createElement(React.Fragment, null, children);
217
224
  return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(ToastStack, _extends({}, rest, {
218
225
  dir: dir,
219
226
  position: position,
@@ -247,6 +254,6 @@ export function Toaster({
247
254
  description: item.description,
248
255
  actionProps: item.actionProps,
249
256
  role: null,
250
- onClose: closeButton || item.closeButton ? () => close(item.id) : undefined
257
+ onClose: closeButton || item.closeButton || item.sticky && item.closeButton !== false ? () => close(item.id) : undefined
251
258
  })))));
252
259
  }
@@ -1,8 +1,9 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { mergeRefs, useIsoLayoutEffect } from "../forms/Button.js";
5
- import { Portal } from "../overlay/Portal.js";
6
+ import { Portal, useHydrated } from "../overlay/Portal.js";
6
7
  const SIDES = ['top', 'bottom', 'left', 'right'];
7
8
  const TooltipProviderCtx = /*#__PURE__*/React.createContext({
8
9
  delayDuration: 0,
@@ -26,10 +27,16 @@ export function Tooltip({
26
27
  }) {
27
28
  const provider = React.useContext(TooltipProviderCtx);
28
29
  const [inner, setInner] = React.useState(defaultOpen);
29
- const open = controlled !== undefined ? controlled : inner;
30
+ // Closed while React hydrates server HTML (the server rendered no portal),
31
+ // open right after, so effects keyed on it run with the panel present.
32
+ const open = useHydrated() && (controlled !== undefined ? controlled : inner);
30
33
  const triggerRef = React.useRef(null);
31
34
  const timerRef = React.useRef(null);
32
- const contentId = React.useId();
35
+ // The content's own `id` wins over the generated one, and the trigger's
36
+ // aria attribute follows whichever is rendered.
37
+ const baseId = React.useId();
38
+ const [customId, setContentId] = React.useState();
39
+ const contentId = customId || baseId;
33
40
  const setOpen = React.useCallback(next => {
34
41
  if (controlled === undefined) setInner(next);
35
42
  onOpenChange?.(next);
@@ -50,8 +57,9 @@ export function Tooltip({
50
57
  hide,
51
58
  triggerRef,
52
59
  contentId,
60
+ setContentId,
53
61
  disableHoverableContent: disableHoverableContent ?? provider.disableHoverableContent
54
- }), [open, show, hide, contentId, disableHoverableContent, provider.disableHoverableContent]);
62
+ }), [open, show, hide, contentId, setContentId, disableHoverableContent, provider.disableHoverableContent]);
55
63
  return /*#__PURE__*/React.createElement(TooltipCtx.Provider, {
56
64
  value: value
57
65
  }, children);
@@ -90,8 +98,12 @@ export const TooltipTrigger = /*#__PURE__*/React.forwardRef(function TooltipTrig
90
98
  onMouseLeave: compose(rest.onMouseLeave, ctx.hide),
91
99
  onFocus: compose(rest.onFocus, () => ctx.show(true)),
92
100
  onBlur: compose(rest.onBlur, ctx.hide),
101
+ // an open tooltip takes the first Escape, so the dialog it sits in stays
93
102
  onKeyDown: compose(rest.onKeyDown, event => {
94
- if (event.key === 'Escape') ctx.hide();
103
+ if (event.key === 'Escape' && ctx.open) {
104
+ event.preventDefault();
105
+ ctx.hide();
106
+ }
95
107
  })
96
108
  };
97
109
  if (asChild && /*#__PURE__*/React.isValidElement(children)) {
@@ -118,9 +130,16 @@ export const TooltipContent = /*#__PURE__*/React.forwardRef(function TooltipCont
118
130
  className,
119
131
  style,
120
132
  children,
133
+ id,
121
134
  ...rest
122
135
  }, forwardedRef) {
123
136
  const ctx = React.useContext(TooltipCtx);
137
+ const registerId = ctx?.setContentId;
138
+ useIsoLayoutEffect(() => {
139
+ if (!registerId) return;
140
+ registerId(id);
141
+ return () => registerId(undefined);
142
+ }, [registerId, id]);
124
143
  const bubbleRef = React.useRef(null);
125
144
  const want = SIDES.includes(side) ? side : 'top';
126
145
  const [placed, setPlaced] = React.useState({
@@ -184,7 +203,7 @@ export const TooltipContent = /*#__PURE__*/React.forwardRef(function TooltipCont
184
203
  return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("span", _extends({}, rest, {
185
204
  ref: mergeRefs(forwardedRef, bubbleRef),
186
205
  role: "tooltip",
187
- id: ctx.contentId,
206
+ id: id || ctx.contentId,
188
207
  "data-slot": "tooltip-content",
189
208
  "data-state": "open",
190
209
  "data-side": placed.side,
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Button, mergeRefs } from "../forms/Button.js";
@@ -1,7 +1,11 @@
1
1
  export interface FileDropProps {
2
2
  /** Receives the dropped/picked File[] */
3
3
  onFiles?: (files: File[]) => void;
4
- /** input accept string, e.g. "image/*,.pdf" */
4
+ /** Files left out, grouped by reason: 'type' (not in accept), 'size' (over maxSize), 'count' (beyond one when multiple is false) */
5
+ onReject?: (files: File[], reason: 'type' | 'size' | 'count') => void;
6
+ /** Largest accepted file, in bytes */
7
+ maxSize?: number;
8
+ /** input accept string, e.g. "image/*,.pdf". Also filters dropped files; non-matching drops are ignored. */
5
9
  accept?: string;
6
10
  /** @default true */
7
11
  multiple?: boolean;
package/files/FileDrop.js CHANGED
@@ -1,10 +1,23 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
6
+ // The file picker enforces accept and multiple; a drop does not, so apply the
7
+ // same rules here. Matches the accept syntax: .ext, type/*, type/subtype.
8
+ function accepts(file, accept) {
9
+ if (!accept) return true;
10
+ const name = (file.name || '').toLowerCase();
11
+ const type = (file.type || '').toLowerCase();
12
+ const tokens = accept.split(',').map(t => t.trim().toLowerCase()).filter(Boolean);
13
+ if (!tokens.length || tokens.includes('*/*') || tokens.includes('*')) return true;
14
+ return tokens.some(t => t.startsWith('.') ? name.endsWith(t) : t.endsWith('/*') ? type.startsWith(t.slice(0, -1)) : type === t);
15
+ }
5
16
  export function FileDrop({
6
17
  onFiles,
18
+ onReject,
7
19
  accept,
20
+ maxSize,
8
21
  multiple = true,
9
22
  title,
10
23
  hint,
@@ -14,8 +27,23 @@ export function FileDrop({
14
27
  }) {
15
28
  const [over, setOver] = React.useState(false);
16
29
  const inputRef = React.useRef(null);
30
+ // Every file ends up in onFiles or in one onReject(files, reason) call;
31
+ // reasons are checked in order: 'type', then 'size', then 'count'.
17
32
  const handle = files => {
18
- if (onFiles && files && files.length) onFiles([...files]);
33
+ if (!files) return;
34
+ const all = [...files];
35
+ const wrongType = all.filter(f => !accepts(f, accept));
36
+ const typed = all.filter(f => accepts(f, accept));
37
+ const tooBig = maxSize != null ? typed.filter(f => f.size > maxSize) : [];
38
+ const sized = typed.filter(f => !tooBig.includes(f));
39
+ const ok = multiple ? sized : sized.slice(0, 1);
40
+ const extra = sized.slice(ok.length);
41
+ if (onReject) {
42
+ if (wrongType.length) onReject(wrongType, 'type');
43
+ if (tooBig.length) onReject(tooBig, 'size');
44
+ if (extra.length) onReject(extra, 'count');
45
+ }
46
+ if (onFiles && ok.length) onFiles(ok);
19
47
  };
20
48
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
21
49
  role: "button",
package/files/FileTile.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  export function PaymentCard({
package/forms/Button.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
@@ -21,9 +22,46 @@ import { Icon } from "../icons/Icon.js";
21
22
  * app rule accidentally collided with a component rule and lost, it now wins.
22
23
  * That is the intended direction, but it is a real change and worth looking at
23
24
  * a page or two after upgrading.
25
+ *
26
+ * Server-rendered apps can also import a static components.css (the registry's
27
+ * `meridian-ssr-css` item), so the HTML is styled before hydration. That sheet
28
+ * lists `<id>_<hash>` pairs in `--ef-css-static` on :root, the hash being
29
+ * FNV-1a over the exact text each component passes here. This skips an id only
30
+ * when the hash of `text` matches: an edited copy, or a component from another
31
+ * release than the sheet, injects its own CSS as before, so the static sheet
32
+ * can save work but never replace a component's CSS. The list is read once per
33
+ * page: reading it per call would force a style recalculation after every
34
+ * <style> this appends.
24
35
  */
36
+ let efStaticCss;
37
+ function efCssHash(text) {
38
+ let h = 0x811c9dc5;
39
+ for (let i = 0; i < text.length; i++) {
40
+ h ^= text.charCodeAt(i);
41
+ h = Math.imul(h, 0x01000193);
42
+ }
43
+ return (h >>> 0).toString(16).padStart(8, '0');
44
+ }
25
45
  export function injectEfCss(id, text) {
26
46
  if (typeof document === 'undefined' || document.getElementById(id)) return;
47
+ if (!efStaticCss) {
48
+ efStaticCss = new Map();
49
+ const listed = getComputedStyle(document.documentElement).getPropertyValue('--ef-css-static').trim();
50
+ for (const pair of listed ? listed.split(/\s+/) : []) {
51
+ const at = pair.lastIndexOf('_');
52
+ if (at > 0) efStaticCss.set(pair.slice(0, at), pair.slice(at + 1));
53
+ }
54
+ }
55
+ const listedHash = efStaticCss.get(id);
56
+ if (listedHash === true) return;
57
+ if (listedHash !== undefined) {
58
+ // Settle each id once: the hash runs on first render, not on every one.
59
+ if (listedHash === efCssHash(text)) {
60
+ efStaticCss.set(id, true);
61
+ return;
62
+ }
63
+ efStaticCss.delete(id);
64
+ }
27
65
  const s = document.createElement('style');
28
66
  s.id = id;
29
67
  s.textContent = `@layer meridian{${text}}`;
@@ -65,6 +103,23 @@ export function cssPct(value) {
65
103
  * to useEffect on the server is behaviour-identical. Lowercase: internal.
66
104
  */
67
105
  export const useIsoLayoutEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
106
+ const LAZY_TYPE = Symbol.for('react.lazy');
107
+ /**
108
+ * Whether `child` is an element of `Component`, for compound components that
109
+ * sort their children (Select items, Resizable panels, ScrollArea bars).
110
+ *
111
+ * Children written in a Next.js Server Component reach a client component with
112
+ * a lazy client reference as their type, not the function, so a plain
113
+ * `child.type === Component` is false there. Unwrap the lazy first. While its
114
+ * module is still loading, `_init` throws the module's promise, which suspends
115
+ * exactly as rendering the lazy element would.
116
+ */
117
+ export function isElementOfType(child, Component) {
118
+ if (! /*#__PURE__*/React.isValidElement(child)) return false;
119
+ let type = child.type;
120
+ if (type && type.$$typeof === LAZY_TYPE && typeof type._init === 'function') type = type._init(type._payload);
121
+ return type === Component;
122
+ }
68
123
  /**
69
124
  * The CSS kill-switch cannot reach JS-driven motion — rAF count-ups and
70
125
  * scrollTo({behavior:'smooth'}) — so those call sites ask here. Lowercase: internal.
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { mergeRefs } from "./Button.js";
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
@@ -9,11 +10,13 @@ export function ButtonTile({
9
10
  selected,
10
11
  disabled,
11
12
  onClick,
13
+ type = 'button',
12
14
  style,
13
15
  className,
14
16
  ...rest
15
17
  }) {
16
18
  return /*#__PURE__*/React.createElement("button", _extends({}, rest, {
19
+ type: type,
17
20
  className: `ef-tile${selected ? ' ef-tile--on' : ''}${className ? ' ' + className : ''}`,
18
21
  disabled: disabled,
19
22
  "aria-pressed": !!selected,
package/forms/Checkbox.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
package/forms/Combobox.js CHANGED
@@ -1,9 +1,10 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
5
6
  import { InputGroup, InputGroupAddon, InputGroupInput } from "./InputGroup.js";
6
- import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
7
+ import { Portal, useAnchoredStyle, useHydrated } from "../overlay/Portal.js";
7
8
  const ComboboxContext = /*#__PURE__*/React.createContext(null);
8
9
  const join = (...values) => values.filter(Boolean).join(' ');
9
10
  const textOf = node => React.Children.toArray(node).map(child => typeof child === 'string' || typeof child === 'number' ? String(child) : /*#__PURE__*/React.isValidElement(child) ? textOf(child.props.children) : '').join(' ').trim();
@@ -35,7 +36,10 @@ export function Combobox({
35
36
  const records = React.useRef(new Map());
36
37
  const anchorRef = React.useRef(null);
37
38
  const currentValue = value === undefined ? internalValue : value;
38
- const isOpen = open === undefined ? internalOpen : open;
39
+ // Closed while React hydrates server HTML (the server rendered no portal),
40
+ // open right after, so effects keyed on it run with the panel present.
41
+ const requestedOpen = open === undefined ? internalOpen : open;
42
+ const isOpen = useHydrated() && requestedOpen;
39
43
  const query = inputValue === undefined ? internalInput : inputValue;
40
44
  const setOpen = React.useCallback(next => {
41
45
  if (open === undefined) setInternalOpen(next);
@@ -64,11 +68,28 @@ export function Combobox({
64
68
  if (!isOpen || !autoHighlight || !visibleRecords.length) return;
65
69
  if (!visibleRecords.some(record => record.id === active)) setActive(visibleRecords[0].id);
66
70
  }, [isOpen, query, version, autoHighlight]);
71
+ const labelOf = next => {
72
+ const found = items.find(item => same(itemValue(item), next));
73
+ if (found !== undefined) return itemText(found);
74
+ const record = [...records.current.values()].find(entry => same(entry.value, next));
75
+ return record ? record.text : undefined;
76
+ };
77
+ // Keyed on the requested state, not isOpen: the hydration pass is not a
78
+ // close, and treating it as one filled the input and narrowed the list.
79
+ React.useEffect(() => {
80
+ if (multiple || requestedOpen || query || currentValue == null) return;
81
+ const label = labelOf(currentValue);
82
+ if (label !== undefined) setQuery(label);
83
+ }, [currentValue, items, requestedOpen, multiple]);
84
+ // A value changed from outside (a controlled reset, a programmatic pick)
85
+ // must also move the text in the input, or it keeps showing the old label.
86
+ const shownValue = React.useRef(currentValue);
67
87
  React.useEffect(() => {
68
- if (multiple || isOpen || query || currentValue == null) return;
69
- const found = items.find(item => same(itemValue(item), currentValue));
70
- if (found !== undefined) setQuery(itemText(found));
71
- }, [currentValue, items, isOpen, multiple]);
88
+ if (multiple || same(shownValue.current, currentValue)) return;
89
+ shownValue.current = currentValue;
90
+ const label = currentValue == null ? '' : labelOf(currentValue);
91
+ if (label !== undefined && label !== query) setQuery(label);
92
+ }, [currentValue, multiple]);
72
93
  const choose = React.useCallback((next, label) => {
73
94
  if (multiple) {
74
95
  const values = Array.isArray(selected) ? selected : [];
@@ -181,7 +202,8 @@ export const ComboboxClear = /*#__PURE__*/React.forwardRef(function ComboboxClea
181
202
  function useInputKeyboard(context, onKeyDown) {
182
203
  return event => {
183
204
  onKeyDown?.(event);
184
- if (event.defaultPrevented || !context) return;
205
+ // Keys typed while an IME composes text belong to the IME, not the list.
206
+ if (event.defaultPrevented || !context || event.nativeEvent?.isComposing || event.keyCode === 229) return;
185
207
  const current = [...context.records.current.values()].filter(record => !record.disabled && context.matches(record));
186
208
  if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
187
209
  event.preventDefault();
@@ -238,7 +260,7 @@ export const ComboboxInput = /*#__PURE__*/React.forwardRef(function ComboboxInpu
238
260
  "aria-autocomplete": "list",
239
261
  "aria-expanded": context?.isOpen,
240
262
  "aria-controls": context?.listId,
241
- "aria-activedescendant": context?.active || undefined,
263
+ "aria-activedescendant": context?.isOpen && context.active || undefined,
242
264
  disabled: disabled || context?.disabled,
243
265
  className: "ef-combobox__input",
244
266
  value: context?.query ?? '',
@@ -472,7 +494,7 @@ export const ComboboxChipsInput = /*#__PURE__*/React.forwardRef(function Combobo
472
494
  "aria-autocomplete": "list",
473
495
  "aria-expanded": context?.isOpen,
474
496
  "aria-controls": context?.listId,
475
- "aria-activedescendant": context?.active || undefined,
497
+ "aria-activedescendant": context?.isOpen && context.active || undefined,
476
498
  className: join('ef-combobox__chips-input', className),
477
499
  value: context?.query ?? '',
478
500
  onChange: event => {
package/forms/Field.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  const FieldCtx = /*#__PURE__*/React.createContext(null);
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
package/forms/Input.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { useFieldProps } from "./Field.js";
package/forms/InputOTP.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  const InputOTPCtx = /*#__PURE__*/React.createContext(null);
package/forms/Label.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  export const Label = /*#__PURE__*/React.forwardRef(function Label({
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
@@ -79,7 +80,10 @@ export function NumberInput({
79
80
  });
80
81
  const uid = React.useId();
81
82
  const inputId = field.id || (label ? uid + 'n' : undefined);
83
+ const noteId = hint || error ? uid + 'h' : undefined;
84
+ const describedBy = [...new Set([field.controlProps['aria-describedby'], noteId].filter(Boolean))].join(' ') || undefined;
82
85
  const bad = field.invalid;
86
+ const locked = disabled || !!rest.readOnly;
83
87
  const [inner, setInner] = React.useState(defaultValue !== undefined ? defaultValue : null);
84
88
  const v = value !== undefined ? value : inner;
85
89
  // The text being edited; null means "not editing, show the formatted value".
@@ -123,7 +127,14 @@ export function NumberInput({
123
127
  emit(normalize(next), e);
124
128
  };
125
129
  const keys = e => {
126
- if (disabled) return;
130
+ rest.onKeyDown?.(e);
131
+ if (e.defaultPrevented) return;
132
+ // Enter commits first so an implicit form submit reads the typed number.
133
+ if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
134
+ commit(e);
135
+ return;
136
+ }
137
+ if (locked) return;
127
138
  if (e.key === 'ArrowUp') {
128
139
  e.preventDefault();
129
140
  stepBy(1, e.shiftKey ? 10 : 1, e);
@@ -141,8 +152,8 @@ export function NumberInput({
141
152
  }
142
153
  };
143
154
  const shown = draft != null ? draft : v == null ? '' : fmt(v);
144
- const upStuck = disabled || v != null && Number.isFinite(max) && v >= max;
145
- const downStuck = disabled || v != null && Number.isFinite(min) && v <= min;
155
+ const upStuck = locked || v != null && Number.isFinite(max) && v >= max;
156
+ const downStuck = locked || v != null && Number.isFinite(min) && v <= min;
146
157
  const control = /*#__PURE__*/React.createElement("span", {
147
158
  className: `ef-number ef-number--${size}${bad ? ' ef-number--invalid' : ''}${disabled ? ' ef-number--disabled' : ''}`
148
159
  }, /*#__PURE__*/React.createElement("input", _extends({}, rest, field.controlProps, {
@@ -155,9 +166,13 @@ export function NumberInput({
155
166
  disabled: disabled,
156
167
  value: shown,
157
168
  "aria-invalid": bad || undefined,
169
+ "aria-describedby": describedBy,
158
170
  onChange: e => setDraft(e.target.value),
159
171
  onKeyDown: keys,
160
- onBlur: commit
172
+ onBlur: e => {
173
+ commit(e);
174
+ rest.onBlur?.(e);
175
+ }
161
176
  })), /*#__PURE__*/React.createElement("span", {
162
177
  className: "ef-number__steps"
163
178
  }, /*#__PURE__*/React.createElement("button", {
@@ -194,11 +209,14 @@ export function NumberInput({
194
209
  htmlFor: inputId,
195
210
  className: "ef-field__label"
196
211
  }, label) : null, control, error ? /*#__PURE__*/React.createElement("span", {
212
+ id: noteId,
213
+ role: "alert",
197
214
  className: "ef-field__error"
198
215
  }, /*#__PURE__*/React.createElement(Icon, {
199
216
  name: "circle-alert",
200
217
  size: 12
201
218
  }), error) : hint ? /*#__PURE__*/React.createElement("span", {
219
+ id: noteId,
202
220
  className: "ef-field__hint"
203
221
  }, hint) : null);
204
222
  }
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  const RootContext = /*#__PURE__*/React.createContext(null);
@@ -94,7 +95,7 @@ export const Questionnaire = /*#__PURE__*/React.forwardRef(function Questionnair
94
95
  onReset?.(event);
95
96
  };
96
97
  const onKeyDown = event => {
97
- if (!shortcuts || event.metaKey || event.ctrlKey || event.altKey || /input|textarea|select/i.test(event.target.tagName)) return;
98
+ if (!shortcuts || event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey || /input|textarea|select/i.test(event.target.tagName)) return;
98
99
  const keyIndex = shortcuts === 'letters' ? event.key.toLowerCase().charCodeAt(0) - 97 : Number(event.key) - 1;
99
100
  if (keyIndex < 0) return;
100
101
  const controls = [...(formRef.current?.elements || [])].filter(control => control.name === activeItem && !control.disabled && /radio|checkbox/.test(control.type));
package/forms/Radio.js CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { useFieldProps } from "./Field.js";
package/forms/Select.js CHANGED
@@ -1,15 +1,16 @@
1
1
  'use client';
2
+
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  import React from 'react';
4
5
  import { Icon } from "../icons/Icon.js";
5
- import { mergeRefs } from "./Button.js";
6
- import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
6
+ import { mergeRefs, isElementOfType } from "./Button.js";
7
+ import { Portal, useAnchoredStyle, useHydrated } from "../overlay/Portal.js";
7
8
  const SelectCtx = /*#__PURE__*/React.createContext(null);
8
9
  const itemText = children => typeof children === 'string' || typeof children === 'number' ? String(children) : '';
9
10
  function collectLabels(children, out = {}) {
10
11
  React.Children.forEach(children, child => {
11
12
  if (! /*#__PURE__*/React.isValidElement(child)) return;
12
- if (child.type === SelectItem) out[child.props.value] = itemText(child.props.children) || child.props.value;
13
+ if (isElementOfType(child, SelectItem)) out[child.props.value] = itemText(child.props.children) || child.props.value;
13
14
  if (child.props.children) collectLabels(child.props.children, out);
14
15
  });
15
16
  return out;
@@ -29,7 +30,9 @@ export function Select({
29
30
  const [innerValue, setInnerValue] = React.useState(defaultValue);
30
31
  const [innerOpen, setInnerOpen] = React.useState(defaultOpen);
31
32
  const value = controlled !== undefined ? controlled : innerValue;
32
- const open = controlledOpen !== undefined ? controlledOpen : innerOpen;
33
+ // Closed while React hydrates server HTML (the server rendered no portal),
34
+ // open right after, so effects keyed on it run with the panel present.
35
+ const open = useHydrated() && (controlledOpen !== undefined ? controlledOpen : innerOpen);
33
36
  const triggerRef = React.useRef(null);
34
37
  const contentRef = React.useRef(null);
35
38
  const declaredLabels = React.useMemo(() => collectLabels(children), [children]);