@efolusi/meridian 1.20.0 → 1.21.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/README.md +1 -1
- package/ai/Bubble.d.ts +16 -0
- package/ai/Bubble.js +71 -0
- package/ai/ChatMessage.js +2 -5
- package/ai/Confirmation.d.ts +0 -7
- package/ai/Confirmation.js +3 -6
- package/ai/GeneratedImage.d.ts +0 -2
- package/ai/GeneratedImage.js +2 -4
- package/ai/Marker.d.ts +26 -0
- package/ai/Marker.js +67 -0
- package/ai/Message.d.ts +13 -0
- package/ai/Message.js +68 -0
- package/ai/MessageScroller.d.ts +21 -0
- package/ai/MessageScroller.js +283 -0
- package/ai/ModelSelector.d.ts +2 -2
- package/ai/ModelSelector.js +1 -2
- package/ai/Player.js +1 -1
- package/ai/PromptSteps.js +4 -2
- package/ai/Sandbox.d.ts +0 -2
- package/ai/Sandbox.js +2 -4
- package/ai/Suggestions.d.ts +0 -2
- package/ai/Suggestions.js +1 -4
- package/ai/WebPreview.d.ts +0 -2
- package/ai/WebPreview.js +2 -4
- package/code/Console.js +1 -1
- package/code/EnvList.d.ts +0 -2
- package/code/EnvList.js +2 -3
- package/components.css +652 -418
- package/data/BarChart.d.ts +0 -2
- package/data/BarChart.js +1 -4
- package/data/Chart.d.ts +14 -0
- package/data/Chart.js +149 -0
- package/data/EmptyState.d.ts +8 -13
- package/data/EmptyState.js +62 -24
- package/data/LineChart.js +7 -4
- package/data/Skeleton.d.ts +2 -11
- package/data/Skeleton.js +8 -38
- package/data/Sparkline.js +4 -1
- package/data/StatusDot.d.ts +0 -4
- package/data/StatusDot.js +3 -6
- package/data/Table.d.ts +11 -4
- package/data/Table.js +39 -7
- package/dates/Calendar.d.ts +10 -27
- package/dates/Calendar.js +250 -184
- package/dates/TimePicker.js +2 -2
- package/display/Accordion.d.ts +47 -15
- package/display/Accordion.js +257 -27
- package/display/AspectRatio.d.ts +4 -6
- package/display/AspectRatio.js +7 -5
- package/display/Avatar.d.ts +17 -14
- package/display/Avatar.js +68 -43
- package/display/Badge.d.ts +9 -8
- package/display/Badge.js +32 -14
- package/display/Card.d.ts +11 -13
- package/display/Card.js +74 -29
- package/display/Carousel.d.ts +23 -15
- package/display/Carousel.js +217 -66
- package/display/Collapsible.d.ts +19 -9
- package/display/Collapsible.js +140 -28
- package/display/Direction.d.ts +10 -0
- package/display/Direction.js +24 -0
- package/display/Item.d.ts +19 -0
- package/display/Item.js +152 -0
- package/display/Kbd.d.ts +5 -7
- package/display/Kbd.js +22 -10
- package/display/Link.js +2 -4
- package/display/Resizable.d.ts +6 -16
- package/display/Resizable.js +141 -58
- package/display/ScrollArea.d.ts +3 -1
- package/display/ScrollArea.js +30 -5
- package/display/Separator.d.ts +9 -0
- package/display/Separator.js +18 -0
- package/display/Timeline.d.ts +24 -0
- package/display/Timeline.js +51 -0
- package/display/Toolbar.js +5 -4
- package/display/TreeList.d.ts +0 -2
- package/display/TreeList.js +2 -5
- package/feedback/Alert.d.ts +13 -13
- package/feedback/Alert.js +40 -36
- package/feedback/AlertDialog.d.ts +30 -0
- package/feedback/AlertDialog.js +249 -0
- package/feedback/Banner.d.ts +1 -3
- package/feedback/Banner.js +1 -5
- package/feedback/ConfirmDialog.d.ts +1 -1
- package/feedback/ConfirmDialog.js +18 -20
- package/feedback/Dialog.d.ts +13 -16
- package/feedback/Dialog.js +204 -62
- package/feedback/Progress.d.ts +8 -9
- package/feedback/Progress.js +42 -24
- package/feedback/Sonner.d.ts +8 -0
- package/feedback/Sonner.js +238 -0
- package/feedback/Spinner.d.ts +2 -9
- package/feedback/Spinner.js +19 -28
- package/feedback/Tooltip.d.ts +9 -10
- package/feedback/Tooltip.js +147 -96
- package/files/Attachment.d.ts +27 -0
- package/files/Attachment.js +111 -0
- package/files/FileDrop.js +3 -1
- package/finance/PaymentCard.js +3 -3
- package/forms/Button.d.ts +6 -5
- package/forms/Button.js +22 -8
- package/forms/ButtonGroup.d.ts +11 -3
- package/forms/ButtonGroup.js +57 -6
- package/forms/Checkbox.d.ts +14 -3
- package/forms/Checkbox.js +84 -16
- package/forms/Combobox.d.ts +24 -16
- package/forms/Combobox.js +466 -135
- package/forms/Field.d.ts +14 -0
- package/forms/Field.js +99 -0
- package/forms/IconButton.d.ts +1 -1
- package/forms/IconButton.js +4 -3
- package/forms/Input.d.ts +8 -8
- package/forms/Input.js +46 -33
- package/forms/InputGroup.d.ts +8 -15
- package/forms/InputGroup.js +74 -35
- package/forms/InputOTP.d.ts +13 -0
- package/forms/InputOTP.js +125 -0
- package/forms/Label.d.ts +2 -6
- package/forms/Label.js +6 -4
- package/forms/NativeSelect.d.ts +16 -0
- package/forms/NativeSelect.js +35 -0
- package/forms/NumberInput.js +2 -2
- package/forms/Radio.d.ts +12 -1
- package/forms/Radio.js +76 -6
- package/forms/Select.d.ts +12 -9
- package/forms/Select.js +254 -42
- package/forms/Slider.d.ts +10 -17
- package/forms/Slider.js +78 -39
- package/forms/Switch.d.ts +8 -2
- package/forms/Switch.js +46 -15
- package/forms/Textarea.d.ts +1 -1
- package/forms/Textarea.js +26 -18
- package/forms/Toggle.d.ts +18 -15
- package/forms/Toggle.js +96 -42
- package/icons/_svg.js +2 -0
- package/index.d.ts +20 -8
- package/index.js +50 -38
- package/navigation/Breadcrumbs.d.ts +18 -11
- package/navigation/Breadcrumbs.js +99 -26
- package/navigation/Menubar.d.ts +52 -10
- package/navigation/Menubar.js +191 -146
- package/navigation/NavigationMenu.d.ts +15 -0
- package/navigation/NavigationMenu.js +296 -0
- package/navigation/Pagination.d.ts +10 -9
- package/navigation/Pagination.js +94 -51
- package/navigation/SideNav.js +4 -3
- package/navigation/Sidebar.d.ts +29 -0
- package/navigation/Sidebar.js +311 -0
- package/navigation/Tabs.d.ts +9 -5
- package/navigation/Tabs.js +132 -44
- package/overlay/Command.d.ts +32 -0
- package/overlay/Command.js +257 -0
- package/overlay/ContextMenu.d.ts +40 -8
- package/overlay/ContextMenu.js +468 -107
- package/overlay/Drawer.d.ts +29 -14
- package/overlay/Drawer.js +178 -80
- package/overlay/DropdownMenu.d.ts +43 -0
- package/overlay/DropdownMenu.js +502 -0
- package/overlay/HoverCard.d.ts +21 -12
- package/overlay/HoverCard.js +129 -61
- package/overlay/Popover.d.ts +11 -13
- package/overlay/Popover.js +138 -65
- package/overlay/Portal.js +21 -7
- package/overlay/Sheet.d.ts +11 -0
- package/overlay/Sheet.js +62 -0
- package/package.json +4 -1
- package/tokens/base.css +1 -1
- package/dates/DatePicker.d.ts +0 -14
- package/dates/DatePicker.js +0 -111
- package/dates/DateRangePicker.d.ts +0 -23
- package/dates/DateRangePicker.js +0 -150
- package/display/ListItem.d.ts +0 -19
- package/display/ListItem.js +0 -50
- package/feedback/Toast.d.ts +0 -78
- package/feedback/Toast.js +0 -192
- package/forms/DigitEntry.d.ts +0 -15
- package/forms/DigitEntry.js +0 -79
- package/forms/FormField.d.ts +0 -82
- package/forms/FormField.js +0 -209
- package/overlay/CommandPalette.d.ts +0 -21
- package/overlay/CommandPalette.js +0 -148
- package/overlay/Menu.d.ts +0 -24
- package/overlay/Menu.js +0 -139
package/forms/DigitEntry.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
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
|
-
import React from 'react';
|
|
4
|
-
import { useFieldProps } from "./FormField.js";
|
|
5
|
-
export function DigitEntry({
|
|
6
|
-
length = 6,
|
|
7
|
-
value,
|
|
8
|
-
onChange,
|
|
9
|
-
onComplete,
|
|
10
|
-
label,
|
|
11
|
-
invalid,
|
|
12
|
-
disabled,
|
|
13
|
-
style,
|
|
14
|
-
className,
|
|
15
|
-
...rest
|
|
16
|
-
}) {
|
|
17
|
-
// Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
|
|
18
|
-
const field = useFieldProps({
|
|
19
|
-
invalid,
|
|
20
|
-
id: rest.id,
|
|
21
|
-
'aria-describedby': rest['aria-describedby']
|
|
22
|
-
});
|
|
23
|
-
const [inner, setInner] = React.useState('');
|
|
24
|
-
const v = value != null ? value : inner;
|
|
25
|
-
const refs = React.useRef([]);
|
|
26
|
-
const set = next => {
|
|
27
|
-
next = next.replace(/\D/g, '').slice(0, length);
|
|
28
|
-
if (value == null) setInner(next);
|
|
29
|
-
if (onChange) onChange(next);
|
|
30
|
-
if (next.length === length && onComplete) onComplete(next);
|
|
31
|
-
};
|
|
32
|
-
const keyAt = (i, e) => {
|
|
33
|
-
if (e.key === 'Backspace') {
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
if (v[i]) set(v.slice(0, i) + v.slice(i + 1));else if (i > 0) {
|
|
36
|
-
set(v.slice(0, i - 1) + v.slice(i));
|
|
37
|
-
refs.current[i - 1] && refs.current[i - 1].focus();
|
|
38
|
-
}
|
|
39
|
-
} else if (e.key === 'ArrowLeft' && i > 0) refs.current[i - 1].focus();else if (e.key === 'ArrowRight' && i < length - 1) refs.current[i + 1].focus();
|
|
40
|
-
};
|
|
41
|
-
const inputAt = (i, e) => {
|
|
42
|
-
const ch = e.target.value.replace(/\D/g, '');
|
|
43
|
-
if (!ch) return;
|
|
44
|
-
const next = (v.slice(0, i) + ch + v.slice(i + ch.length)).slice(0, length);
|
|
45
|
-
set(next);
|
|
46
|
-
const to = Math.min(i + ch.length, length - 1);
|
|
47
|
-
refs.current[to] && refs.current[to].focus();
|
|
48
|
-
};
|
|
49
|
-
const cells = Array.from({
|
|
50
|
-
length
|
|
51
|
-
}, (_, i) => /*#__PURE__*/React.createElement("input", _extends({
|
|
52
|
-
key: i
|
|
53
|
-
}, i === 0 ? field.controlProps : null, {
|
|
54
|
-
ref: el => refs.current[i] = el,
|
|
55
|
-
className: "ef-digits__cell",
|
|
56
|
-
inputMode: "numeric",
|
|
57
|
-
autoComplete: i === 0 ? 'one-time-code' : 'off',
|
|
58
|
-
maxLength: length,
|
|
59
|
-
value: v[i] || '',
|
|
60
|
-
disabled: disabled,
|
|
61
|
-
"aria-label": `Digit ${i + 1} of ${length}`,
|
|
62
|
-
onChange: e => inputAt(i, e),
|
|
63
|
-
onKeyDown: e => keyAt(i, e),
|
|
64
|
-
onFocus: e => e.target.select()
|
|
65
|
-
})));
|
|
66
|
-
const group = /*#__PURE__*/React.createElement("div", {
|
|
67
|
-
className: `ef-digits${invalid ? ' ef-digits--invalid' : ''}`
|
|
68
|
-
}, cells);
|
|
69
|
-
if (!label) return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
70
|
-
className: className,
|
|
71
|
-
style: style
|
|
72
|
-
}), group);
|
|
73
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
74
|
-
className: `ef-field${className ? ' ' + className : ''}`,
|
|
75
|
-
style: style
|
|
76
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
77
|
-
className: "ef-field__label"
|
|
78
|
-
}, label), group);
|
|
79
|
-
}
|
package/forms/FormField.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export interface FieldWiring {
|
|
2
|
-
/** The control's id. `null` in `group` mode, where no single child owns it. */
|
|
3
|
-
id: string | null;
|
|
4
|
-
invalid: boolean;
|
|
5
|
-
required: boolean;
|
|
6
|
-
/** Spread on the real control element, after `{...rest}`. */
|
|
7
|
-
controlProps: {
|
|
8
|
-
id?: string;
|
|
9
|
-
'aria-describedby'?: string;
|
|
10
|
-
'aria-invalid'?: true;
|
|
11
|
-
'aria-required'?: true;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export interface FormFieldProps {
|
|
15
|
-
/** Rendered as `<label htmlFor>`, or a `<span id>` when `group`. */
|
|
16
|
-
label?: React.ReactNode;
|
|
17
|
-
/** Muted helper text below the control. Hidden while `error` is set. */
|
|
18
|
-
hint?: React.ReactNode;
|
|
19
|
-
/** Error message below the control. Truthy implies invalid. */
|
|
20
|
-
error?: React.ReactNode;
|
|
21
|
-
/** Invalid state with no message. @default false */
|
|
22
|
-
invalid?: boolean;
|
|
23
|
-
/** Red asterisk plus aria-required on the control. @default false */
|
|
24
|
-
required?: boolean;
|
|
25
|
-
/** Label a set of controls: role="group" + aria-labelledby. @default false */
|
|
26
|
-
group?: boolean;
|
|
27
|
-
/** The control's id. Generated with React.useId() when omitted. */
|
|
28
|
-
id?: string;
|
|
29
|
-
/** A control, or a function receiving the wiring to spread yourself. */
|
|
30
|
-
children?: React.ReactNode | ((field: FieldWiring) => React.ReactNode);
|
|
31
|
-
style?: React.CSSProperties;
|
|
32
|
-
className?: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Label / hint / error / required chrome around a control, and the owner of the
|
|
36
|
-
* id linking them. Design-system controls pick the wiring up from context; for
|
|
37
|
-
* anything else, pass a function and spread `controlProps` on the control.
|
|
38
|
-
*/
|
|
39
|
-
export declare function FormField(props: FormFieldProps): React.JSX.Element;
|
|
40
|
-
|
|
41
|
-
/** What `field(name)` returns: spread it on a control, or wire prop-by-prop. */
|
|
42
|
-
export interface FormFieldControl<V = unknown> {
|
|
43
|
-
value: V;
|
|
44
|
-
/** Accepts a change event (reads `target.value`, or `target.checked` for checkboxes) or a raw value. */
|
|
45
|
-
onChange: (eventOrValue: unknown) => void;
|
|
46
|
-
/** Marks the field touched, which lets its error surface. */
|
|
47
|
-
onBlur: () => void;
|
|
48
|
-
invalid: boolean;
|
|
49
|
-
/** Only set after the field was touched or a submit attempt (guidelines/forms.md timing). */
|
|
50
|
-
error: string | undefined;
|
|
51
|
-
}
|
|
52
|
-
export interface UseFormStateOptions<T extends Record<string, any>> {
|
|
53
|
-
/** Seed values. Read once, on the first render. */
|
|
54
|
-
initial: T;
|
|
55
|
-
/** Returns `{ field: 'message' }` for invalid fields; empty object = valid. */
|
|
56
|
-
validate?: (values: T) => Partial<Record<keyof T & string, string>>;
|
|
57
|
-
}
|
|
58
|
-
export interface UseFormStateReturn<T extends Record<string, any>> {
|
|
59
|
-
values: T;
|
|
60
|
-
/** The raw `validate(values)` result — not gated by touch. `field().error` is. */
|
|
61
|
-
errors: Partial<Record<keyof T & string, string>>;
|
|
62
|
-
touched: Partial<Record<keyof T & string, boolean>>;
|
|
63
|
-
set: <K extends keyof T & string>(name: K, value: T[K]) => void;
|
|
64
|
-
field: <K extends keyof T & string>(name: K) => FormFieldControl<T[K]>;
|
|
65
|
-
/** True while an async submit handler is in flight. */
|
|
66
|
-
submitting: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Wraps a submit handler: validates everything, marks all fields touched,
|
|
69
|
-
* and only calls `fn(values)` when clean. An async `fn` sets `submitting`
|
|
70
|
-
* around its promise.
|
|
71
|
-
*/
|
|
72
|
-
handleSubmit: (fn?: (values: T) => unknown | Promise<unknown>) => (e?: React.SyntheticEvent) => unknown;
|
|
73
|
-
/** Back to `initial`, untouched, not submitting. */
|
|
74
|
-
reset: () => void;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Zero-dependency form state. Published as a static — `FormField.useFormState()`
|
|
78
|
-
* — because only capitalised exports reach the global namespace.
|
|
79
|
-
*/
|
|
80
|
-
export declare namespace FormField {
|
|
81
|
-
function useFormState<T extends Record<string, any>>(options: UseFormStateOptions<T>): UseFormStateReturn<T>;
|
|
82
|
-
}
|
package/forms/FormField.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
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
|
-
import React from 'react';
|
|
4
|
-
import { Icon } from "../icons/Icon.js";
|
|
5
|
-
// Module-private, never exported: a control outside a FormField simply sees
|
|
6
|
-
// null and behaves standalone. Same shape as GroupCtx in Toggle.jsx.
|
|
7
|
-
const FieldCtx = /*#__PURE__*/React.createContext(null);
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* How a control joins an enclosing FormField.
|
|
11
|
-
*
|
|
12
|
-
* Lowercase, so it stays off the public namespace. That is deliberate: no
|
|
13
|
-
* consumer needs it — design-system controls are wired by their own props, and
|
|
14
|
-
* anything else is wired through FormField's render prop — and keeping it
|
|
15
|
-
* unreachable stops a seventh field dialect being invented in a showcase.
|
|
16
|
-
*/
|
|
17
|
-
export function useFieldProps(own = {}) {
|
|
18
|
-
const ctx = React.useContext(FieldCtx);
|
|
19
|
-
const invalid = !!(own.invalid || own.error || ctx && ctx.invalid);
|
|
20
|
-
const required = own.required != null ? !!own.required : !!(ctx && ctx.required);
|
|
21
|
-
const describedBy = [own['aria-describedby'], ctx && ctx.describedBy].filter(Boolean).join(' ');
|
|
22
|
-
const id = own.id || ctx && ctx.id || undefined;
|
|
23
|
-
// Keys are added conditionally, never assigned undefined: a control spreads
|
|
24
|
-
// {...rest} and then {...controlProps}, and an always-present key would reset
|
|
25
|
-
// a caller's own aria-invalid back to absent.
|
|
26
|
-
const controlProps = {};
|
|
27
|
-
if (id) controlProps.id = id;
|
|
28
|
-
if (describedBy) controlProps['aria-describedby'] = describedBy;
|
|
29
|
-
if (invalid) controlProps['aria-invalid'] = true;
|
|
30
|
-
if (required) controlProps['aria-required'] = true;
|
|
31
|
-
return {
|
|
32
|
-
inField: !!ctx,
|
|
33
|
-
id: id || null,
|
|
34
|
-
invalid,
|
|
35
|
-
required,
|
|
36
|
-
controlProps
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Label, hint, error and required chrome around any control, and the owner of
|
|
42
|
-
* the id that ties them together.
|
|
43
|
-
*
|
|
44
|
-
* Wrap a control as children and design-system controls pick the wiring up
|
|
45
|
-
* automatically. For anything else — a third-party input, a control with no
|
|
46
|
-
* label prop — pass a function and spread the wiring yourself.
|
|
47
|
-
*/
|
|
48
|
-
export function FormField({
|
|
49
|
-
label,
|
|
50
|
-
hint,
|
|
51
|
-
error,
|
|
52
|
-
invalid,
|
|
53
|
-
required,
|
|
54
|
-
group,
|
|
55
|
-
id,
|
|
56
|
-
children,
|
|
57
|
-
style,
|
|
58
|
-
className,
|
|
59
|
-
...rest
|
|
60
|
-
}) {
|
|
61
|
-
const uid = React.useId();
|
|
62
|
-
const controlId = id || uid + 'c';
|
|
63
|
-
const labelId = uid + 'l';
|
|
64
|
-
const noteId = uid + 'n';
|
|
65
|
-
const hasError = error != null && error !== false && error !== '';
|
|
66
|
-
const hasHint = !hasError && hint != null && hint !== false && hint !== '';
|
|
67
|
-
const note = hasError ? 'error' : hasHint ? 'hint' : null;
|
|
68
|
-
const bad = !!(invalid || hasError);
|
|
69
|
-
const ctx = React.useMemo(() => ({
|
|
70
|
-
// In group mode no single child owns the id — five radios cannot share one —
|
|
71
|
-
// so the group element carries the label and description instead.
|
|
72
|
-
id: group ? null : controlId,
|
|
73
|
-
describedBy: note && !group ? noteId : undefined,
|
|
74
|
-
invalid: bad,
|
|
75
|
-
required: !!required
|
|
76
|
-
}), [group, controlId, note, noteId, bad, required]);
|
|
77
|
-
const wiring = React.useMemo(() => {
|
|
78
|
-
const p = {};
|
|
79
|
-
if (ctx.id) p.id = ctx.id;
|
|
80
|
-
if (ctx.describedBy) p['aria-describedby'] = ctx.describedBy;
|
|
81
|
-
if (bad) p['aria-invalid'] = true;
|
|
82
|
-
if (required) p['aria-required'] = true;
|
|
83
|
-
return {
|
|
84
|
-
id: ctx.id,
|
|
85
|
-
invalid: bad,
|
|
86
|
-
required: !!required,
|
|
87
|
-
controlProps: p
|
|
88
|
-
};
|
|
89
|
-
}, [ctx, bad, required]);
|
|
90
|
-
const star = required ? /*#__PURE__*/React.createElement("span", {
|
|
91
|
-
className: "ef-field__req",
|
|
92
|
-
"aria-hidden": "true"
|
|
93
|
-
}, "*") : null;
|
|
94
|
-
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
95
|
-
role: group ? 'group' : undefined,
|
|
96
|
-
"aria-labelledby": group && label ? labelId : undefined,
|
|
97
|
-
"aria-describedby": group && note ? noteId : undefined,
|
|
98
|
-
className: `ef-field${className ? ' ' + className : ''}`,
|
|
99
|
-
style: style
|
|
100
|
-
}), label ? group ? /*#__PURE__*/React.createElement("span", {
|
|
101
|
-
id: labelId,
|
|
102
|
-
className: "ef-field__label"
|
|
103
|
-
}, label, star) : /*#__PURE__*/React.createElement("label", {
|
|
104
|
-
htmlFor: controlId,
|
|
105
|
-
className: "ef-field__label"
|
|
106
|
-
}, label, star) : null, /*#__PURE__*/React.createElement(FieldCtx.Provider, {
|
|
107
|
-
value: ctx
|
|
108
|
-
}, typeof children === 'function' ? children(wiring) : children), hasError ? /*#__PURE__*/React.createElement("span", {
|
|
109
|
-
id: noteId,
|
|
110
|
-
role: "alert",
|
|
111
|
-
className: "ef-field__error"
|
|
112
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
113
|
-
name: "circle-alert",
|
|
114
|
-
size: 13
|
|
115
|
-
}), error) : hasHint ? /*#__PURE__*/React.createElement("span", {
|
|
116
|
-
id: noteId,
|
|
117
|
-
className: "ef-field__hint"
|
|
118
|
-
}, hint) : null);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Zero-dependency form state: values, per-field wiring, validation timing.
|
|
123
|
-
*
|
|
124
|
-
* `validate(values)` returns `{ field: 'message' }` for whatever is currently
|
|
125
|
-
* invalid; an empty object means clean. A field's error only surfaces once
|
|
126
|
-
* that field has blurred or a submit was attempted — the timing
|
|
127
|
-
* guidelines/forms.md prescribes (blur, then re-validate on change, then
|
|
128
|
-
* everything on submit) — while `errors` always carries the raw result.
|
|
129
|
-
*
|
|
130
|
-
* Lowercase, so the compiler files it under unexposedExports and it never
|
|
131
|
-
* reaches the global namespace directly. Consumers get it as
|
|
132
|
-
* `FormField.useFormState` (assigned at the bottom of this file), the same
|
|
133
|
-
* publication Toaster.useToast uses.
|
|
134
|
-
*/
|
|
135
|
-
export function useFormState({
|
|
136
|
-
initial,
|
|
137
|
-
validate
|
|
138
|
-
} = {}) {
|
|
139
|
-
// The first render's `initial` wins for the life of the hook, so an inline
|
|
140
|
-
// object literal does not re-seed the form on every render.
|
|
141
|
-
const initialRef = React.useRef(initial || {});
|
|
142
|
-
const [values, setValues] = React.useState(initialRef.current);
|
|
143
|
-
const [touched, setTouched] = React.useState({});
|
|
144
|
-
const [submitted, setSubmitted] = React.useState(false);
|
|
145
|
-
const [submitting, setSubmitting] = React.useState(false);
|
|
146
|
-
const errors = validate ? validate(values) || {} : {};
|
|
147
|
-
const set = React.useCallback((name, val) => {
|
|
148
|
-
setValues(prev => ({
|
|
149
|
-
...prev,
|
|
150
|
-
[name]: val
|
|
151
|
-
}));
|
|
152
|
-
}, []);
|
|
153
|
-
const field = name => {
|
|
154
|
-
const err = touched[name] || submitted ? errors[name] : undefined;
|
|
155
|
-
return {
|
|
156
|
-
value: values[name],
|
|
157
|
-
onChange: eventOrValue => {
|
|
158
|
-
const t = eventOrValue && typeof eventOrValue === 'object' ? eventOrValue.target : null;
|
|
159
|
-
set(name, t && 'value' in t ? t.type === 'checkbox' ? t.checked : t.value : eventOrValue);
|
|
160
|
-
},
|
|
161
|
-
onBlur: () => setTouched(prev => prev[name] ? prev : {
|
|
162
|
-
...prev,
|
|
163
|
-
[name]: true
|
|
164
|
-
}),
|
|
165
|
-
invalid: err != null && err !== '',
|
|
166
|
-
error: err != null && err !== '' ? err : undefined
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
const handleSubmit = fn => e => {
|
|
170
|
-
if (e && typeof e.preventDefault === 'function') e.preventDefault();
|
|
171
|
-
setSubmitted(true);
|
|
172
|
-
const errs = validate ? validate(values) || {} : {};
|
|
173
|
-
const all = {};
|
|
174
|
-
Object.keys(values).forEach(k => {
|
|
175
|
-
all[k] = true;
|
|
176
|
-
});
|
|
177
|
-
Object.keys(errs).forEach(k => {
|
|
178
|
-
all[k] = true;
|
|
179
|
-
});
|
|
180
|
-
setTouched(prev => ({
|
|
181
|
-
...prev,
|
|
182
|
-
...all
|
|
183
|
-
}));
|
|
184
|
-
if (Object.keys(errs).length > 0) return;
|
|
185
|
-
const out = fn ? fn(values) : undefined;
|
|
186
|
-
if (out && typeof out.then === 'function') {
|
|
187
|
-
setSubmitting(true);
|
|
188
|
-
return Promise.resolve(out).finally(() => setSubmitting(false));
|
|
189
|
-
}
|
|
190
|
-
return out;
|
|
191
|
-
};
|
|
192
|
-
const reset = React.useCallback(() => {
|
|
193
|
-
setValues(initialRef.current);
|
|
194
|
-
setTouched({});
|
|
195
|
-
setSubmitted(false);
|
|
196
|
-
setSubmitting(false);
|
|
197
|
-
}, []);
|
|
198
|
-
return {
|
|
199
|
-
values,
|
|
200
|
-
errors,
|
|
201
|
-
touched,
|
|
202
|
-
set,
|
|
203
|
-
field,
|
|
204
|
-
submitting,
|
|
205
|
-
handleSubmit,
|
|
206
|
-
reset
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
FormField.useFormState = useFormState;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface CommandItem {
|
|
2
|
-
id: string;
|
|
3
|
-
label: string;
|
|
4
|
-
/** Lucide icon name */
|
|
5
|
-
icon?: string;
|
|
6
|
-
/** Right-aligned hint, e.g. a shortcut or product name */
|
|
7
|
-
hint?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface CommandGroup {
|
|
10
|
-
group: string;
|
|
11
|
-
items: CommandItem[];
|
|
12
|
-
}
|
|
13
|
-
export interface CommandPaletteProps {
|
|
14
|
-
open: boolean;
|
|
15
|
-
onClose?: () => void;
|
|
16
|
-
groups: CommandGroup[];
|
|
17
|
-
onSelect?: (id: string) => void;
|
|
18
|
-
/** @default 'Type a command or search…' */
|
|
19
|
-
placeholder?: string;
|
|
20
|
-
}
|
|
21
|
-
export declare function CommandPalette(props: CommandPaletteProps): React.JSX.Element;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
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
|
-
import React from 'react';
|
|
4
|
-
import { Icon } from "../icons/Icon.js";
|
|
5
|
-
import { Kbd } from "../display/Kbd.js";
|
|
6
|
-
export function CommandPalette({
|
|
7
|
-
open,
|
|
8
|
-
onClose,
|
|
9
|
-
groups,
|
|
10
|
-
onSelect,
|
|
11
|
-
placeholder = 'Type a command or search…',
|
|
12
|
-
style,
|
|
13
|
-
className,
|
|
14
|
-
...rest
|
|
15
|
-
}) {
|
|
16
|
-
const [q, setQ] = React.useState('');
|
|
17
|
-
const [idx, setIdx] = React.useState(0);
|
|
18
|
-
const listId = React.useId();
|
|
19
|
-
const prevFocus = React.useRef(null);
|
|
20
|
-
const inputRef = React.useRef(null);
|
|
21
|
-
React.useEffect(() => {
|
|
22
|
-
if (!open) return;
|
|
23
|
-
setQ('');
|
|
24
|
-
setIdx(0);
|
|
25
|
-
prevFocus.current = document.activeElement;
|
|
26
|
-
if (inputRef.current) inputRef.current.focus();
|
|
27
|
-
return () => {
|
|
28
|
-
if (prevFocus.current && prevFocus.current.focus) prevFocus.current.focus();
|
|
29
|
-
};
|
|
30
|
-
}, [open]);
|
|
31
|
-
const flat = [];
|
|
32
|
-
const shown = (groups || []).map(g => {
|
|
33
|
-
const items = g.items.filter(it => !q || (it.label + ' ' + (it.hint || '')).toLowerCase().includes(q.toLowerCase()));
|
|
34
|
-
items.forEach(it => flat.push(it));
|
|
35
|
-
return {
|
|
36
|
-
...g,
|
|
37
|
-
items
|
|
38
|
-
};
|
|
39
|
-
}).filter(g => g.items.length);
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
setIdx(0);
|
|
42
|
-
}, [q]);
|
|
43
|
-
const flatRef = React.useRef(flat);
|
|
44
|
-
flatRef.current = flat;
|
|
45
|
-
const idxRef = React.useRef(idx);
|
|
46
|
-
idxRef.current = idx;
|
|
47
|
-
React.useEffect(() => {
|
|
48
|
-
if (!open) return;
|
|
49
|
-
const key = e => {
|
|
50
|
-
if (e.key === 'Escape') onClose && onClose();
|
|
51
|
-
if (e.key === 'ArrowDown') {
|
|
52
|
-
e.preventDefault();
|
|
53
|
-
setIdx(i => Math.min(i + 1, flatRef.current.length - 1));
|
|
54
|
-
}
|
|
55
|
-
if (e.key === 'ArrowUp') {
|
|
56
|
-
e.preventDefault();
|
|
57
|
-
setIdx(i => Math.max(i - 1, 0));
|
|
58
|
-
}
|
|
59
|
-
if (e.key === 'Enter') {
|
|
60
|
-
const it = flatRef.current[idxRef.current];
|
|
61
|
-
if (it) {
|
|
62
|
-
onSelect && onSelect(it.id);
|
|
63
|
-
onClose && onClose();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
document.addEventListener('keydown', key);
|
|
68
|
-
return () => document.removeEventListener('keydown', key);
|
|
69
|
-
}, [open, onClose, onSelect]);
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
if (!open) return;
|
|
72
|
-
const el = document.getElementById(listId + '-opt-' + idx);
|
|
73
|
-
if (el && el.scrollIntoView) el.scrollIntoView({
|
|
74
|
-
block: 'nearest'
|
|
75
|
-
});
|
|
76
|
-
}, [open, idx, listId]);
|
|
77
|
-
if (!open) return null;
|
|
78
|
-
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
79
|
-
className: `ef-cmdk__overlay${className ? ' ' + className : ''}`,
|
|
80
|
-
style: style,
|
|
81
|
-
onMouseDown: e => {
|
|
82
|
-
if (e.target === e.currentTarget && onClose) onClose();
|
|
83
|
-
}
|
|
84
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
85
|
-
className: "ef-cmdk",
|
|
86
|
-
role: "dialog",
|
|
87
|
-
"aria-modal": "true",
|
|
88
|
-
"aria-label": "Command palette"
|
|
89
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
90
|
-
className: "ef-cmdk__inputrow"
|
|
91
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
92
|
-
name: "search",
|
|
93
|
-
size: 17,
|
|
94
|
-
style: {
|
|
95
|
-
color: 'var(--text-muted)'
|
|
96
|
-
}
|
|
97
|
-
}), /*#__PURE__*/React.createElement("input", {
|
|
98
|
-
className: "ef-cmdk__input",
|
|
99
|
-
ref: inputRef,
|
|
100
|
-
placeholder: placeholder,
|
|
101
|
-
value: q,
|
|
102
|
-
onChange: e => setQ(e.target.value),
|
|
103
|
-
role: "combobox",
|
|
104
|
-
"aria-expanded": "true",
|
|
105
|
-
"aria-controls": listId,
|
|
106
|
-
"aria-autocomplete": "list",
|
|
107
|
-
"aria-label": placeholder,
|
|
108
|
-
"aria-activedescendant": flat.length ? `${listId}-opt-${idx}` : undefined
|
|
109
|
-
}), /*#__PURE__*/React.createElement(Kbd, null, "Esc")), /*#__PURE__*/React.createElement("div", {
|
|
110
|
-
className: "ef-cmdk__list",
|
|
111
|
-
role: "listbox",
|
|
112
|
-
id: listId
|
|
113
|
-
}, shown.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
114
|
-
className: "ef-cmdk__empty"
|
|
115
|
-
}, "Nothing matches \"", q, "\" \u2014 try a product or action name."), shown.map(g => /*#__PURE__*/React.createElement(React.Fragment, {
|
|
116
|
-
key: g.group
|
|
117
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
118
|
-
className: "ef-cmdk__group"
|
|
119
|
-
}, g.group), g.items.map(it => {
|
|
120
|
-
const fi = flat.indexOf(it);
|
|
121
|
-
const active = fi === idx;
|
|
122
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
123
|
-
key: it.id,
|
|
124
|
-
role: "option",
|
|
125
|
-
id: `${listId}-opt-${fi}`,
|
|
126
|
-
"aria-selected": active,
|
|
127
|
-
className: `ef-cmdk__item${active ? ' ef-cmdk__item--active' : ''}`,
|
|
128
|
-
onMouseEnter: () => setIdx(fi),
|
|
129
|
-
onClick: () => {
|
|
130
|
-
onSelect && onSelect(it.id);
|
|
131
|
-
onClose && onClose();
|
|
132
|
-
}
|
|
133
|
-
}, it.icon ? /*#__PURE__*/React.createElement("span", {
|
|
134
|
-
className: "ef-cmdk__item__icon"
|
|
135
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
136
|
-
name: it.icon,
|
|
137
|
-
size: 16
|
|
138
|
-
})) : null, it.label, it.hint ? /*#__PURE__*/React.createElement("span", {
|
|
139
|
-
className: "ef-cmdk__item__hint"
|
|
140
|
-
}, it.hint) : null);
|
|
141
|
-
})))), /*#__PURE__*/React.createElement("div", {
|
|
142
|
-
className: "ef-cmdk__foot"
|
|
143
|
-
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Kbd, null, "\u2191"), /*#__PURE__*/React.createElement(Kbd, null, "\u2193"), " navigate"), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Kbd, null, "\u21B5"), " run"), /*#__PURE__*/React.createElement("span", {
|
|
144
|
-
style: {
|
|
145
|
-
marginLeft: 'auto'
|
|
146
|
-
}
|
|
147
|
-
}, /*#__PURE__*/React.createElement(Kbd, null, "\u2318"), /*#__PURE__*/React.createElement(Kbd, null, "K"), " anywhere"))));
|
|
148
|
-
}
|
package/overlay/Menu.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface MenuItem {
|
|
2
|
-
id: string;
|
|
3
|
-
label: React.ReactNode;
|
|
4
|
-
/** Lucide icon name */
|
|
5
|
-
icon?: string;
|
|
6
|
-
/** Red destructive styling */
|
|
7
|
-
danger?: boolean;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
/** Shortcut hint, e.g. "⌘D" */
|
|
10
|
-
kbd?: string;
|
|
11
|
-
onClick?: () => void;
|
|
12
|
-
}
|
|
13
|
-
export interface MenuProps {
|
|
14
|
-
/** The element that toggles the menu (Button, IconButton, …) */
|
|
15
|
-
trigger: React.ReactNode;
|
|
16
|
-
/** Items; the string 'separator' inserts a rule */
|
|
17
|
-
items: Array<MenuItem | 'separator'>;
|
|
18
|
-
onSelect?: (id: string) => void;
|
|
19
|
-
/** Panel edge alignment @default 'left' */
|
|
20
|
-
align?: 'left' | 'right';
|
|
21
|
-
style?: React.CSSProperties;
|
|
22
|
-
className?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLSpanElement>>;
|