@efolusi/meridian 1.21.10 → 1.22.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.
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/ai/Citation.js +44 -22
- package/ai/Confirmation.js +2 -2
- package/ai/PromptComposer.d.ts +4 -0
- package/ai/PromptComposer.js +7 -1
- package/ai/RichComposer.js +3 -0
- package/ai/SourceCard.js +12 -4
- package/ai/UsageMeter.d.ts +3 -1
- package/ai/UsageMeter.js +8 -2
- package/ai/WebPreview.js +12 -4
- package/code/CodeBlock.js +26 -7
- package/code/CopyField.js +24 -9
- package/components.css +137 -56
- package/data/BarChart.d.ts +4 -0
- package/data/BarChart.js +28 -4
- package/data/Chart.d.ts +1 -1
- package/data/Chart.js +5 -2
- package/data/DonutChart.d.ts +4 -0
- package/data/DonutChart.js +38 -8
- package/data/LineChart.d.ts +4 -0
- package/data/LineChart.js +29 -7
- package/data/Table.d.ts +1 -0
- package/data/Table.js +35 -19
- package/dates/Calendar.js +43 -15
- package/dates/TimePicker.js +18 -3
- package/display/Toolbar.js +1 -0
- package/display/TreeList.js +20 -13
- package/feedback/AlertDialog.js +12 -12
- package/feedback/Dialog.js +17 -12
- package/feedback/Toast.js +5 -2
- package/feedback/Tooltip.js +5 -1
- package/files/FileDrop.d.ts +5 -1
- package/files/FileDrop.js +28 -1
- package/forms/ButtonTile.js +2 -0
- package/forms/Combobox.js +21 -5
- package/forms/NumberInput.js +21 -4
- package/forms/Questionnaire.js +1 -1
- package/forms/Slider.js +2 -1
- package/forms/Switch.js +14 -3
- package/index.js +3 -3
- package/navigation/NavigationMenu.js +17 -5
- package/navigation/PageControl.js +1 -0
- package/navigation/SegmentedControl.js +1 -0
- package/navigation/SideNav.js +2 -0
- package/navigation/Sidebar.js +74 -11
- package/navigation/SkipLink.d.ts +2 -1
- package/navigation/SkipLink.js +16 -4
- package/overlay/Command.js +1 -0
- package/overlay/ContextMenu.js +32 -10
- package/overlay/Drawer.d.ts +1 -0
- package/overlay/Drawer.js +19 -2
- package/overlay/DropdownMenu.js +32 -10
- package/overlay/HoverCard.js +8 -13
- package/overlay/Popover.js +46 -10
- package/overlay/Portal.js +67 -2
- package/package.json +1 -1
- package/tailwind.preset.cjs +34 -13
- package/tokens/base.css +5 -0
- package/tokens/colors.css +7 -3
- package/tokens.json +427 -95
package/feedback/AlertDialog.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
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
3
|
import React from 'react';
|
|
4
4
|
import { mergeRefs, buttonVariants } from "../forms/Button.js";
|
|
5
|
-
import { Portal } from "../overlay/Portal.js";
|
|
5
|
+
import { Portal, useEscapeLayer, useScrollLock, escapeLayerContext } from "../overlay/Portal.js";
|
|
6
6
|
const AlertDialogContext = /*#__PURE__*/React.createContext(null);
|
|
7
7
|
const FOCUSABLE = 'button:not([disabled]),[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
8
8
|
function useAlertDialog(part) {
|
|
@@ -111,28 +111,26 @@ export const AlertDialogContent = /*#__PURE__*/React.forwardRef(function AlertDi
|
|
|
111
111
|
}, ref) {
|
|
112
112
|
const ctx = useAlertDialog('AlertDialogContent');
|
|
113
113
|
const panelRef = React.useRef(null);
|
|
114
|
+
const layer = useEscapeLayer(ctx.open, event => {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
ctx.setOpen(false);
|
|
117
|
+
});
|
|
118
|
+
useScrollLock(ctx.open);
|
|
114
119
|
React.useEffect(() => {
|
|
115
120
|
if (!ctx.open) return;
|
|
116
|
-
const previousOverflow = document.body.style.overflow;
|
|
117
|
-
document.body.style.overflow = 'hidden';
|
|
118
121
|
const panel = panelRef.current;
|
|
119
122
|
const preferred = panel && (panel.querySelector('[data-slot="alert-dialog-cancel"]') || panel.querySelector(FOCUSABLE));
|
|
120
123
|
(preferred || panel)?.focus();
|
|
121
124
|
return () => {
|
|
122
|
-
document.body.style.overflow = previousOverflow;
|
|
123
125
|
ctx.triggerRef.current?.focus?.();
|
|
124
126
|
};
|
|
125
127
|
}, [ctx.open, ctx.triggerRef]);
|
|
126
128
|
if (!ctx.open && !forceMount) return null;
|
|
127
129
|
const handleKeyDown = event => {
|
|
128
130
|
if (onKeyDown) onKeyDown(event);
|
|
129
|
-
if (event.defaultPrevented) return;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
ctx.setOpen(false);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (event.key !== 'Tab') return;
|
|
131
|
+
if (event.defaultPrevented || event.key !== 'Tab') return;
|
|
132
|
+
// focus inside a portaled child layer (a popover) is that layer's business
|
|
133
|
+
if (layer.children > 0 && !panelRef.current?.contains(document.activeElement)) return;
|
|
136
134
|
const focusable = Array.from(panelRef.current?.querySelectorAll(FOCUSABLE) || []);
|
|
137
135
|
if (!focusable.length) {
|
|
138
136
|
event.preventDefault();
|
|
@@ -163,7 +161,9 @@ export const AlertDialogContent = /*#__PURE__*/React.forwardRef(function AlertDi
|
|
|
163
161
|
"data-size": size,
|
|
164
162
|
className: `ef-alertdialog__content ef-alertdialog__content--${size}${className ? ' ' + className : ''}`,
|
|
165
163
|
onKeyDown: handleKeyDown
|
|
166
|
-
}),
|
|
164
|
+
}), /*#__PURE__*/React.createElement(escapeLayerContext.Provider, {
|
|
165
|
+
value: layer
|
|
166
|
+
}, children))));
|
|
167
167
|
});
|
|
168
168
|
export const AlertDialogHeader = /*#__PURE__*/React.forwardRef(function AlertDialogHeader({
|
|
169
169
|
className,
|
package/feedback/Dialog.js
CHANGED
|
@@ -3,9 +3,11 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { IconButton } from "../forms/IconButton.js";
|
|
5
5
|
import { mergeRefs } from "../forms/Button.js";
|
|
6
|
-
import { Portal } from "../overlay/Portal.js";
|
|
6
|
+
import { Portal, useEscapeLayer, useScrollLock, escapeLayerContext } from "../overlay/Portal.js";
|
|
7
7
|
const DialogContext = /*#__PURE__*/React.createContext(null);
|
|
8
|
-
const FOCUSABLE = 'button,[href],input,select,textarea,[tabindex]
|
|
8
|
+
const FOCUSABLE = 'button,[href],input,select,textarea,[tabindex]';
|
|
9
|
+
// what Tab can actually reach: not disabled, not taken out with tabindex=-1, not hidden
|
|
10
|
+
const tabbable = root => [...root.querySelectorAll(FOCUSABLE)].filter(x => !x.disabled && x.tabIndex >= 0 && !x.closest('[hidden]'));
|
|
9
11
|
function cx(base, className) {
|
|
10
12
|
return base + (className ? ` ${className}` : '');
|
|
11
13
|
}
|
|
@@ -135,20 +137,21 @@ export const DialogContent = /*#__PURE__*/React.forwardRef(function DialogConten
|
|
|
135
137
|
if (!ctx || !ctx.open) return;
|
|
136
138
|
previous.current = document.activeElement;
|
|
137
139
|
const panel = panelRef.current;
|
|
138
|
-
const first = panel && panel
|
|
140
|
+
const first = panel && tabbable(panel)[0];
|
|
139
141
|
(first || panel).focus();
|
|
140
142
|
return () => previous.current && previous.current.focus && previous.current.focus();
|
|
141
143
|
}, [ctx && ctx.open]);
|
|
144
|
+
useScrollLock(!!(ctx && ctx.open));
|
|
145
|
+
const layer = useEscapeLayer(!!(ctx && ctx.open), e => {
|
|
146
|
+
if (onEscapeKeyDown) onEscapeKeyDown(e);
|
|
147
|
+
if (!e.defaultPrevented) ctx.setOpen(false);
|
|
148
|
+
});
|
|
142
149
|
React.useEffect(() => {
|
|
143
150
|
if (!ctx || !ctx.open) return;
|
|
144
151
|
const key = e => {
|
|
145
|
-
if (e.key
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (e.key !== 'Tab') return;
|
|
151
|
-
const f = [...panelRef.current.querySelectorAll(FOCUSABLE)].filter(x => !x.disabled);
|
|
152
|
+
if (e.key !== 'Tab' || e.defaultPrevented) return;
|
|
153
|
+
if (layer.children > 0 && !panelRef.current.contains(document.activeElement)) return;
|
|
154
|
+
const f = tabbable(panelRef.current);
|
|
152
155
|
if (!f.length) return e.preventDefault();
|
|
153
156
|
const i = f.indexOf(document.activeElement);
|
|
154
157
|
if (e.shiftKey && i <= 0) {
|
|
@@ -161,7 +164,7 @@ export const DialogContent = /*#__PURE__*/React.forwardRef(function DialogConten
|
|
|
161
164
|
};
|
|
162
165
|
document.addEventListener('keydown', key);
|
|
163
166
|
return () => document.removeEventListener('keydown', key);
|
|
164
|
-
}, [ctx && ctx.open
|
|
167
|
+
}, [ctx && ctx.open]);
|
|
165
168
|
if (!ctx || !ctx.open) return null;
|
|
166
169
|
return /*#__PURE__*/React.createElement(DialogPortal, null, /*#__PURE__*/React.createElement(DialogOverlay, _extends({}, overlayProps, {
|
|
167
170
|
ref: overlayRef
|
|
@@ -179,7 +182,9 @@ export const DialogContent = /*#__PURE__*/React.forwardRef(function DialogConten
|
|
|
179
182
|
maxWidth: width,
|
|
180
183
|
...style
|
|
181
184
|
}
|
|
182
|
-
}),
|
|
185
|
+
}), /*#__PURE__*/React.createElement(escapeLayerContext.Provider, {
|
|
186
|
+
value: layer
|
|
187
|
+
}, children), showCloseButton ? /*#__PURE__*/React.createElement("div", {
|
|
183
188
|
className: "ef-dialog__close"
|
|
184
189
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
185
190
|
icon: "x",
|
package/feedback/Toast.js
CHANGED
|
@@ -111,8 +111,11 @@ function add(options = {}) {
|
|
|
111
111
|
const previous = timers.get(id);
|
|
112
112
|
if (previous?.handle) clearTimeout(previous.handle);
|
|
113
113
|
timers.delete(id);
|
|
114
|
+
const duration = merged.duration ?? (next.type === 'loading' || next.actionProps ? 0 : defaultDuration);
|
|
115
|
+
// a toast that never expires must be dismissable, or it stays on screen for good
|
|
116
|
+
next.sticky = !(duration > 0) && next.type !== 'loading';
|
|
114
117
|
records = records.some(item => item.id === id) ? records.map(item => item.id === id ? next : item) : [...records, next];
|
|
115
|
-
schedule(id,
|
|
118
|
+
schedule(id, duration);
|
|
116
119
|
emit();
|
|
117
120
|
return id;
|
|
118
121
|
}
|
|
@@ -247,6 +250,6 @@ export function Toaster({
|
|
|
247
250
|
description: item.description,
|
|
248
251
|
actionProps: item.actionProps,
|
|
249
252
|
role: null,
|
|
250
|
-
onClose: closeButton || item.closeButton ? () => close(item.id) : undefined
|
|
253
|
+
onClose: closeButton || item.closeButton || item.sticky && item.closeButton !== false ? () => close(item.id) : undefined
|
|
251
254
|
})))));
|
|
252
255
|
}
|
package/feedback/Tooltip.js
CHANGED
|
@@ -90,8 +90,12 @@ export const TooltipTrigger = /*#__PURE__*/React.forwardRef(function TooltipTrig
|
|
|
90
90
|
onMouseLeave: compose(rest.onMouseLeave, ctx.hide),
|
|
91
91
|
onFocus: compose(rest.onFocus, () => ctx.show(true)),
|
|
92
92
|
onBlur: compose(rest.onBlur, ctx.hide),
|
|
93
|
+
// an open tooltip takes the first Escape, so the dialog it sits in stays
|
|
93
94
|
onKeyDown: compose(rest.onKeyDown, event => {
|
|
94
|
-
if (event.key === 'Escape'
|
|
95
|
+
if (event.key === 'Escape' && ctx.open) {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
ctx.hide();
|
|
98
|
+
}
|
|
95
99
|
})
|
|
96
100
|
};
|
|
97
101
|
if (asChild && /*#__PURE__*/React.isValidElement(children)) {
|
package/files/FileDrop.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export interface FileDropProps {
|
|
2
2
|
/** Receives the dropped/picked File[] */
|
|
3
3
|
onFiles?: (files: File[]) => void;
|
|
4
|
-
/**
|
|
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
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
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
3
|
import React from 'react';
|
|
4
4
|
import { Icon } from "../icons/Icon.js";
|
|
5
|
+
// The file picker enforces accept and multiple; a drop does not, so apply the
|
|
6
|
+
// same rules here. Matches the accept syntax: .ext, type/*, type/subtype.
|
|
7
|
+
function accepts(file, accept) {
|
|
8
|
+
if (!accept) return true;
|
|
9
|
+
const name = (file.name || '').toLowerCase();
|
|
10
|
+
const type = (file.type || '').toLowerCase();
|
|
11
|
+
const tokens = accept.split(',').map(t => t.trim().toLowerCase()).filter(Boolean);
|
|
12
|
+
if (!tokens.length || tokens.includes('*/*') || tokens.includes('*')) return true;
|
|
13
|
+
return tokens.some(t => t.startsWith('.') ? name.endsWith(t) : t.endsWith('/*') ? type.startsWith(t.slice(0, -1)) : type === t);
|
|
14
|
+
}
|
|
5
15
|
export function FileDrop({
|
|
6
16
|
onFiles,
|
|
17
|
+
onReject,
|
|
7
18
|
accept,
|
|
19
|
+
maxSize,
|
|
8
20
|
multiple = true,
|
|
9
21
|
title,
|
|
10
22
|
hint,
|
|
@@ -14,8 +26,23 @@ export function FileDrop({
|
|
|
14
26
|
}) {
|
|
15
27
|
const [over, setOver] = React.useState(false);
|
|
16
28
|
const inputRef = React.useRef(null);
|
|
29
|
+
// Every file ends up in onFiles or in one onReject(files, reason) call;
|
|
30
|
+
// reasons are checked in order: 'type', then 'size', then 'count'.
|
|
17
31
|
const handle = files => {
|
|
18
|
-
if (
|
|
32
|
+
if (!files) return;
|
|
33
|
+
const all = [...files];
|
|
34
|
+
const wrongType = all.filter(f => !accepts(f, accept));
|
|
35
|
+
const typed = all.filter(f => accepts(f, accept));
|
|
36
|
+
const tooBig = maxSize != null ? typed.filter(f => f.size > maxSize) : [];
|
|
37
|
+
const sized = typed.filter(f => !tooBig.includes(f));
|
|
38
|
+
const ok = multiple ? sized : sized.slice(0, 1);
|
|
39
|
+
const extra = sized.slice(ok.length);
|
|
40
|
+
if (onReject) {
|
|
41
|
+
if (wrongType.length) onReject(wrongType, 'type');
|
|
42
|
+
if (tooBig.length) onReject(tooBig, 'size');
|
|
43
|
+
if (extra.length) onReject(extra, 'count');
|
|
44
|
+
}
|
|
45
|
+
if (onFiles && ok.length) onFiles(ok);
|
|
19
46
|
};
|
|
20
47
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
21
48
|
role: "button",
|
package/forms/ButtonTile.js
CHANGED
|
@@ -9,11 +9,13 @@ export function ButtonTile({
|
|
|
9
9
|
selected,
|
|
10
10
|
disabled,
|
|
11
11
|
onClick,
|
|
12
|
+
type = 'button',
|
|
12
13
|
style,
|
|
13
14
|
className,
|
|
14
15
|
...rest
|
|
15
16
|
}) {
|
|
16
17
|
return /*#__PURE__*/React.createElement("button", _extends({}, rest, {
|
|
18
|
+
type: type,
|
|
17
19
|
className: `ef-tile${selected ? ' ef-tile--on' : ''}${className ? ' ' + className : ''}`,
|
|
18
20
|
disabled: disabled,
|
|
19
21
|
"aria-pressed": !!selected,
|
package/forms/Combobox.js
CHANGED
|
@@ -64,11 +64,26 @@ export function Combobox({
|
|
|
64
64
|
if (!isOpen || !autoHighlight || !visibleRecords.length) return;
|
|
65
65
|
if (!visibleRecords.some(record => record.id === active)) setActive(visibleRecords[0].id);
|
|
66
66
|
}, [isOpen, query, version, autoHighlight]);
|
|
67
|
+
const labelOf = next => {
|
|
68
|
+
const found = items.find(item => same(itemValue(item), next));
|
|
69
|
+
if (found !== undefined) return itemText(found);
|
|
70
|
+
const record = [...records.current.values()].find(entry => same(entry.value, next));
|
|
71
|
+
return record ? record.text : undefined;
|
|
72
|
+
};
|
|
67
73
|
React.useEffect(() => {
|
|
68
74
|
if (multiple || isOpen || query || currentValue == null) return;
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
75
|
+
const label = labelOf(currentValue);
|
|
76
|
+
if (label !== undefined) setQuery(label);
|
|
71
77
|
}, [currentValue, items, isOpen, multiple]);
|
|
78
|
+
// A value changed from outside (a controlled reset, a programmatic pick)
|
|
79
|
+
// must also move the text in the input, or it keeps showing the old label.
|
|
80
|
+
const shownValue = React.useRef(currentValue);
|
|
81
|
+
React.useEffect(() => {
|
|
82
|
+
if (multiple || same(shownValue.current, currentValue)) return;
|
|
83
|
+
shownValue.current = currentValue;
|
|
84
|
+
const label = currentValue == null ? '' : labelOf(currentValue);
|
|
85
|
+
if (label !== undefined && label !== query) setQuery(label);
|
|
86
|
+
}, [currentValue, multiple]);
|
|
72
87
|
const choose = React.useCallback((next, label) => {
|
|
73
88
|
if (multiple) {
|
|
74
89
|
const values = Array.isArray(selected) ? selected : [];
|
|
@@ -181,7 +196,8 @@ export const ComboboxClear = /*#__PURE__*/React.forwardRef(function ComboboxClea
|
|
|
181
196
|
function useInputKeyboard(context, onKeyDown) {
|
|
182
197
|
return event => {
|
|
183
198
|
onKeyDown?.(event);
|
|
184
|
-
|
|
199
|
+
// Keys typed while an IME composes text belong to the IME, not the list.
|
|
200
|
+
if (event.defaultPrevented || !context || event.nativeEvent?.isComposing || event.keyCode === 229) return;
|
|
185
201
|
const current = [...context.records.current.values()].filter(record => !record.disabled && context.matches(record));
|
|
186
202
|
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
187
203
|
event.preventDefault();
|
|
@@ -238,7 +254,7 @@ export const ComboboxInput = /*#__PURE__*/React.forwardRef(function ComboboxInpu
|
|
|
238
254
|
"aria-autocomplete": "list",
|
|
239
255
|
"aria-expanded": context?.isOpen,
|
|
240
256
|
"aria-controls": context?.listId,
|
|
241
|
-
"aria-activedescendant": context?.active || undefined,
|
|
257
|
+
"aria-activedescendant": context?.isOpen && context.active || undefined,
|
|
242
258
|
disabled: disabled || context?.disabled,
|
|
243
259
|
className: "ef-combobox__input",
|
|
244
260
|
value: context?.query ?? '',
|
|
@@ -472,7 +488,7 @@ export const ComboboxChipsInput = /*#__PURE__*/React.forwardRef(function Combobo
|
|
|
472
488
|
"aria-autocomplete": "list",
|
|
473
489
|
"aria-expanded": context?.isOpen,
|
|
474
490
|
"aria-controls": context?.listId,
|
|
475
|
-
"aria-activedescendant": context?.active || undefined,
|
|
491
|
+
"aria-activedescendant": context?.isOpen && context.active || undefined,
|
|
476
492
|
className: join('ef-combobox__chips-input', className),
|
|
477
493
|
value: context?.query ?? '',
|
|
478
494
|
onChange: event => {
|
package/forms/NumberInput.js
CHANGED
|
@@ -79,7 +79,10 @@ export function NumberInput({
|
|
|
79
79
|
});
|
|
80
80
|
const uid = React.useId();
|
|
81
81
|
const inputId = field.id || (label ? uid + 'n' : undefined);
|
|
82
|
+
const noteId = hint || error ? uid + 'h' : undefined;
|
|
83
|
+
const describedBy = [...new Set([field.controlProps['aria-describedby'], noteId].filter(Boolean))].join(' ') || undefined;
|
|
82
84
|
const bad = field.invalid;
|
|
85
|
+
const locked = disabled || !!rest.readOnly;
|
|
83
86
|
const [inner, setInner] = React.useState(defaultValue !== undefined ? defaultValue : null);
|
|
84
87
|
const v = value !== undefined ? value : inner;
|
|
85
88
|
// The text being edited; null means "not editing, show the formatted value".
|
|
@@ -123,7 +126,14 @@ export function NumberInput({
|
|
|
123
126
|
emit(normalize(next), e);
|
|
124
127
|
};
|
|
125
128
|
const keys = e => {
|
|
126
|
-
|
|
129
|
+
rest.onKeyDown?.(e);
|
|
130
|
+
if (e.defaultPrevented) return;
|
|
131
|
+
// Enter commits first so an implicit form submit reads the typed number.
|
|
132
|
+
if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
|
|
133
|
+
commit(e);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (locked) return;
|
|
127
137
|
if (e.key === 'ArrowUp') {
|
|
128
138
|
e.preventDefault();
|
|
129
139
|
stepBy(1, e.shiftKey ? 10 : 1, e);
|
|
@@ -141,8 +151,8 @@ export function NumberInput({
|
|
|
141
151
|
}
|
|
142
152
|
};
|
|
143
153
|
const shown = draft != null ? draft : v == null ? '' : fmt(v);
|
|
144
|
-
const upStuck =
|
|
145
|
-
const downStuck =
|
|
154
|
+
const upStuck = locked || v != null && Number.isFinite(max) && v >= max;
|
|
155
|
+
const downStuck = locked || v != null && Number.isFinite(min) && v <= min;
|
|
146
156
|
const control = /*#__PURE__*/React.createElement("span", {
|
|
147
157
|
className: `ef-number ef-number--${size}${bad ? ' ef-number--invalid' : ''}${disabled ? ' ef-number--disabled' : ''}`
|
|
148
158
|
}, /*#__PURE__*/React.createElement("input", _extends({}, rest, field.controlProps, {
|
|
@@ -155,9 +165,13 @@ export function NumberInput({
|
|
|
155
165
|
disabled: disabled,
|
|
156
166
|
value: shown,
|
|
157
167
|
"aria-invalid": bad || undefined,
|
|
168
|
+
"aria-describedby": describedBy,
|
|
158
169
|
onChange: e => setDraft(e.target.value),
|
|
159
170
|
onKeyDown: keys,
|
|
160
|
-
onBlur:
|
|
171
|
+
onBlur: e => {
|
|
172
|
+
commit(e);
|
|
173
|
+
rest.onBlur?.(e);
|
|
174
|
+
}
|
|
161
175
|
})), /*#__PURE__*/React.createElement("span", {
|
|
162
176
|
className: "ef-number__steps"
|
|
163
177
|
}, /*#__PURE__*/React.createElement("button", {
|
|
@@ -194,11 +208,14 @@ export function NumberInput({
|
|
|
194
208
|
htmlFor: inputId,
|
|
195
209
|
className: "ef-field__label"
|
|
196
210
|
}, label) : null, control, error ? /*#__PURE__*/React.createElement("span", {
|
|
211
|
+
id: noteId,
|
|
212
|
+
role: "alert",
|
|
197
213
|
className: "ef-field__error"
|
|
198
214
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
199
215
|
name: "circle-alert",
|
|
200
216
|
size: 12
|
|
201
217
|
}), error) : hint ? /*#__PURE__*/React.createElement("span", {
|
|
218
|
+
id: noteId,
|
|
202
219
|
className: "ef-field__hint"
|
|
203
220
|
}, hint) : null);
|
|
204
221
|
}
|
package/forms/Questionnaire.js
CHANGED
|
@@ -94,7 +94,7 @@ export const Questionnaire = /*#__PURE__*/React.forwardRef(function Questionnair
|
|
|
94
94
|
onReset?.(event);
|
|
95
95
|
};
|
|
96
96
|
const onKeyDown = event => {
|
|
97
|
-
if (!shortcuts || event.metaKey || event.ctrlKey || event.altKey || /input|textarea|select/i.test(event.target.tagName)) return;
|
|
97
|
+
if (!shortcuts || event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey || /input|textarea|select/i.test(event.target.tagName)) return;
|
|
98
98
|
const keyIndex = shortcuts === 'letters' ? event.key.toLowerCase().charCodeAt(0) - 97 : Number(event.key) - 1;
|
|
99
99
|
if (keyIndex < 0) return;
|
|
100
100
|
const controls = [...(formRef.current?.elements || [])].filter(control => control.name === activeItem && !control.disabled && /radio|checkbox/.test(control.type));
|
package/forms/Slider.js
CHANGED
|
@@ -67,6 +67,7 @@ export const Slider = /*#__PURE__*/React.forwardRef(function Slider({
|
|
|
67
67
|
style: rangeStyle
|
|
68
68
|
})), values.map((value, index) => /*#__PURE__*/React.createElement("input", _extends({}, rest, field.controlProps, {
|
|
69
69
|
key: index,
|
|
70
|
+
id: index === 0 ? field.controlProps.id || rest.id : undefined,
|
|
70
71
|
type: "range",
|
|
71
72
|
"data-slot": "slider-thumb",
|
|
72
73
|
"aria-label": rest['aria-label'] ? `${rest['aria-label']}${values.length > 1 ? ` ${index + 1}` : ''}` : undefined,
|
|
@@ -80,7 +81,7 @@ export const Slider = /*#__PURE__*/React.forwardRef(function Slider({
|
|
|
80
81
|
onChange: event => update(index, Number(event.target.value)),
|
|
81
82
|
onPointerUp: () => onValueCommit?.(latestRef.current),
|
|
82
83
|
onKeyUp: event => {
|
|
83
|
-
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) onValueCommit?.(latestRef.current);
|
|
84
|
+
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown'].includes(event.key)) onValueCommit?.(latestRef.current);
|
|
84
85
|
}
|
|
85
86
|
}))));
|
|
86
87
|
const rootProps = {
|
package/forms/Switch.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
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
3
|
import React from 'react';
|
|
4
|
+
import { mergeRefs } from "./Button.js";
|
|
4
5
|
import { useFieldProps } from "./Field.js";
|
|
5
6
|
export const Switch = /*#__PURE__*/React.forwardRef(function Switch({
|
|
6
7
|
label,
|
|
@@ -23,12 +24,16 @@ export const Switch = /*#__PURE__*/React.forwardRef(function Switch({
|
|
|
23
24
|
'aria-describedby': rest['aria-describedby']
|
|
24
25
|
});
|
|
25
26
|
const [inner, setInner] = React.useState(!!defaultChecked);
|
|
27
|
+
const uid = React.useId();
|
|
28
|
+
const buttonRef = React.useRef(null);
|
|
29
|
+
const labelId = label ? `${uid}l` : undefined;
|
|
26
30
|
const checked = checkedProp !== undefined ? checkedProp : inner;
|
|
27
31
|
const control = /*#__PURE__*/React.createElement("button", _extends({
|
|
28
|
-
ref: ref,
|
|
32
|
+
ref: mergeRefs(ref, buttonRef),
|
|
29
33
|
type: "button",
|
|
30
34
|
role: "switch",
|
|
31
35
|
"aria-checked": checked,
|
|
36
|
+
"aria-labelledby": labelId,
|
|
32
37
|
"aria-required": required || undefined,
|
|
33
38
|
disabled: disabled,
|
|
34
39
|
"data-slot": "switch",
|
|
@@ -55,8 +60,14 @@ export const Switch = /*#__PURE__*/React.forwardRef(function Switch({
|
|
|
55
60
|
}) : null;
|
|
56
61
|
if (!label) return /*#__PURE__*/React.createElement(React.Fragment, null, control, formValue);
|
|
57
62
|
return /*#__PURE__*/React.createElement("span", {
|
|
58
|
-
className: "ef-switch-field"
|
|
63
|
+
className: "ef-switch-field",
|
|
64
|
+
"data-disabled": disabled ? '' : undefined
|
|
59
65
|
}, control, /*#__PURE__*/React.createElement("span", {
|
|
60
|
-
|
|
66
|
+
id: labelId,
|
|
67
|
+
className: "ef-switch__label",
|
|
68
|
+
onClick: event => {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
if (!disabled) buttonRef.current?.click();
|
|
71
|
+
}
|
|
61
72
|
}, label), formValue);
|
|
62
73
|
});
|
package/index.js
CHANGED
|
@@ -53,7 +53,7 @@ export { badgeVariants, Badge } from './display/Badge.js';
|
|
|
53
53
|
export { CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter, Card } from './display/Card.js';
|
|
54
54
|
export { Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext } from './display/Carousel.js';
|
|
55
55
|
export { Collapsible, CollapsibleTrigger, CollapsibleContent } from './display/Collapsible.js';
|
|
56
|
-
export { DirectionProvider } from './display/Direction.js';
|
|
56
|
+
export { DirectionProvider, useDirection } from './display/Direction.js';
|
|
57
57
|
export { Divider } from './display/Divider.js';
|
|
58
58
|
export { ItemGroup, ItemSeparator, Item, ItemMedia, ItemContent, ItemTitle, ItemDescription, ItemActions, ItemHeader, ItemFooter } from './display/Item.js';
|
|
59
59
|
export { Kbd, KbdGroup } from './display/Kbd.js';
|
|
@@ -81,10 +81,10 @@ export { FileTile } from './files/FileTile.js';
|
|
|
81
81
|
export { FileTypeIcon } from './files/FileTypeIcon.js';
|
|
82
82
|
export { PaymentCard } from './finance/PaymentCard.js';
|
|
83
83
|
export { buttonVariants, Button } from './forms/Button.js';
|
|
84
|
-
export { ButtonGroup, ButtonGroupText, ButtonGroupSeparator } from './forms/ButtonGroup.js';
|
|
84
|
+
export { buttonGroupVariants, ButtonGroup, ButtonGroupText, ButtonGroupSeparator } from './forms/ButtonGroup.js';
|
|
85
85
|
export { ButtonTile, ButtonTileGroup } from './forms/ButtonTile.js';
|
|
86
86
|
export { Checkbox } from './forms/Checkbox.js';
|
|
87
|
-
export { Combobox, ComboboxValue, ComboboxTrigger, ComboboxClear, ComboboxInput, ComboboxContent, ComboboxList, ComboboxItem, ComboboxGroup, ComboboxLabel, ComboboxCollection, ComboboxEmpty, ComboboxSeparator, ComboboxChips, ComboboxChip, ComboboxChipsInput } from './forms/Combobox.js';
|
|
87
|
+
export { Combobox, ComboboxValue, ComboboxTrigger, ComboboxClear, ComboboxInput, ComboboxContent, ComboboxList, ComboboxItem, ComboboxGroup, ComboboxLabel, ComboboxCollection, ComboboxEmpty, ComboboxSeparator, ComboboxChips, ComboboxChip, ComboboxChipsInput, useComboboxAnchor } from './forms/Combobox.js';
|
|
88
88
|
export { Field, FieldSet, FieldGroup, FieldContent, FieldLabel, FieldTitle, FieldDescription, FieldLegend, FieldSeparator, FieldError } from './forms/Field.js';
|
|
89
89
|
export { IconButton } from './forms/IconButton.js';
|
|
90
90
|
export { Input } from './forms/Input.js';
|
|
@@ -38,6 +38,7 @@ export const NavigationMenu = /*#__PURE__*/React.forwardRef(function NavigationM
|
|
|
38
38
|
});
|
|
39
39
|
const rootRef = React.useRef(null);
|
|
40
40
|
const timerRef = React.useRef(null);
|
|
41
|
+
const pendingFocusRef = React.useRef(null);
|
|
41
42
|
const value = controlled === undefined ? internal : controlled;
|
|
42
43
|
const setValue = React.useCallback(next => {
|
|
43
44
|
if (controlled === undefined) setInternal(next);
|
|
@@ -48,11 +49,13 @@ export const NavigationMenu = /*#__PURE__*/React.forwardRef(function NavigationM
|
|
|
48
49
|
if (!root || !trigger) return;
|
|
49
50
|
const rootRect = root.getBoundingClientRect();
|
|
50
51
|
const triggerRect = trigger.getBoundingClientRect();
|
|
52
|
+
// inset-inline-start counts from the right edge in a right-to-left layout
|
|
53
|
+
const rtl = (root.closest('[dir]')?.getAttribute('dir') || direction) === 'rtl';
|
|
51
54
|
setIndicator({
|
|
52
|
-
start: triggerRect.left - rootRect.left,
|
|
55
|
+
start: rtl ? rootRect.right - triggerRect.right : triggerRect.left - rootRect.left,
|
|
53
56
|
width: triggerRect.width
|
|
54
57
|
});
|
|
55
|
-
}, []);
|
|
58
|
+
}, [direction]);
|
|
56
59
|
const openItem = React.useCallback((next, trigger, immediate = false) => {
|
|
57
60
|
clearTimeout(timerRef.current);
|
|
58
61
|
const open = () => {
|
|
@@ -96,7 +99,8 @@ export const NavigationMenu = /*#__PURE__*/React.forwardRef(function NavigationM
|
|
|
96
99
|
tabStop,
|
|
97
100
|
setTabStop,
|
|
98
101
|
indicator,
|
|
99
|
-
updateIndicator
|
|
102
|
+
updateIndicator,
|
|
103
|
+
pendingFocusRef
|
|
100
104
|
}), [value, setValue, viewport, viewportNode, openItem, moveTrigger, focusTrigger, direction, orientation, tabStop, indicator, updateIndicator]);
|
|
101
105
|
return /*#__PURE__*/React.createElement(NavigationRootContext.Provider, {
|
|
102
106
|
value: context
|
|
@@ -161,8 +165,10 @@ export const NavigationMenuTrigger = /*#__PURE__*/React.forwardRef(function Navi
|
|
|
161
165
|
if (event.defaultPrevented) return;
|
|
162
166
|
if (event.key === 'Enter' || event.key === ' ' || event.key === 'ArrowDown') {
|
|
163
167
|
event.preventDefault();
|
|
168
|
+
// the panel may not exist yet (the viewport mounts on first open), so the
|
|
169
|
+
// content moves focus into itself once it has rendered
|
|
170
|
+
if (root) root.pendingFocusRef.current = itemValue;
|
|
164
171
|
root?.openItem(itemValue, localRef.current, true);
|
|
165
|
-
requestAnimationFrame(() => root?.viewportNode?.querySelector('a,button,[tabindex]:not([tabindex="-1"])')?.focus());
|
|
166
172
|
} else if (root?.orientation === 'horizontal' && (event.key === 'ArrowLeft' || event.key === 'ArrowRight') || root?.orientation === 'vertical' && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) {
|
|
167
173
|
event.preventDefault();
|
|
168
174
|
const visualDelta = event.key === 'ArrowRight' || event.key === 'ArrowDown' ? 1 : -1;
|
|
@@ -209,6 +215,12 @@ export const NavigationMenuContent = /*#__PURE__*/React.forwardRef(function Navi
|
|
|
209
215
|
const root = React.useContext(NavigationRootContext);
|
|
210
216
|
const itemValue = React.useContext(NavigationItemContext);
|
|
211
217
|
const open = root?.value === itemValue;
|
|
218
|
+
const localRef = React.useRef(null);
|
|
219
|
+
useIsoLayoutEffect(() => {
|
|
220
|
+
if (!open || !localRef.current || root?.pendingFocusRef.current !== itemValue) return;
|
|
221
|
+
root.pendingFocusRef.current = null;
|
|
222
|
+
localRef.current.querySelector('a[href],button:not([disabled]),[tabindex]:not([tabindex="-1"])')?.focus();
|
|
223
|
+
});
|
|
212
224
|
const keyboard = event => {
|
|
213
225
|
onKeyDown?.(event);
|
|
214
226
|
if (!event.defaultPrevented && event.key === 'Escape') {
|
|
@@ -219,7 +231,7 @@ export const NavigationMenuContent = /*#__PURE__*/React.forwardRef(function Navi
|
|
|
219
231
|
};
|
|
220
232
|
if (!open && !forceMount) return null;
|
|
221
233
|
const content = /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
222
|
-
ref: ref,
|
|
234
|
+
ref: mergeRefs(ref, localRef),
|
|
223
235
|
"data-slot": "navigation-menu-content",
|
|
224
236
|
"data-state": open ? 'open' : 'closed',
|
|
225
237
|
hidden: !open,
|
|
@@ -21,6 +21,7 @@ export function SegmentedControl({
|
|
|
21
21
|
} : o;
|
|
22
22
|
return /*#__PURE__*/React.createElement("button", {
|
|
23
23
|
key: opt.id,
|
|
24
|
+
type: "button",
|
|
24
25
|
className: `ef-seg__opt${value === opt.id ? ' ef-seg__opt--active' : ''}`,
|
|
25
26
|
"aria-pressed": value === opt.id,
|
|
26
27
|
disabled: opt.disabled,
|
package/navigation/SideNav.js
CHANGED
|
@@ -52,6 +52,8 @@ export function SideNav({
|
|
|
52
52
|
}
|
|
53
53
|
}, g.items.map(it => /*#__PURE__*/React.createElement("button", {
|
|
54
54
|
key: it.id,
|
|
55
|
+
type: "button",
|
|
56
|
+
"aria-current": value === it.id ? 'page' : undefined,
|
|
55
57
|
className: `ef-sidenav__item${value === it.id ? ' ef-sidenav__item--on' : ''}`,
|
|
56
58
|
onClick: () => onChange && onChange(it.id)
|
|
57
59
|
}, /*#__PURE__*/React.createElement("span", {
|