@efolusi/meridian 1.19.1 → 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 +660 -423
- 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 +42 -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
|
@@ -0,0 +1,35 @@
|
|
|
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 { mergeRefs } from "./Button.js";
|
|
6
|
+
export const NativeSelect = /*#__PURE__*/React.forwardRef(function NativeSelect({
|
|
7
|
+
size = 'md',
|
|
8
|
+
className,
|
|
9
|
+
style,
|
|
10
|
+
...props
|
|
11
|
+
}, ref) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
13
|
+
"data-slot": "native-select",
|
|
14
|
+
"data-size": size,
|
|
15
|
+
className: `ef-native-select${className ? ` ${className}` : ''}`,
|
|
16
|
+
style: style
|
|
17
|
+
}, /*#__PURE__*/React.createElement("select", _extends({}, props, {
|
|
18
|
+
ref: ref
|
|
19
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
20
|
+
className: "ef-native-select__icon"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
22
|
+
name: "chevron-down",
|
|
23
|
+
size: 16
|
|
24
|
+
})));
|
|
25
|
+
});
|
|
26
|
+
export const NativeSelectOption = /*#__PURE__*/React.forwardRef(function NativeSelectOption(props, ref) {
|
|
27
|
+
return /*#__PURE__*/React.createElement("option", _extends({}, props, {
|
|
28
|
+
ref: ref
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
export const NativeSelectOptGroup = /*#__PURE__*/React.forwardRef(function NativeSelectOptGroup(props, ref) {
|
|
32
|
+
return /*#__PURE__*/React.createElement("optgroup", _extends({}, props, {
|
|
33
|
+
ref: ref
|
|
34
|
+
}));
|
|
35
|
+
});
|
package/forms/NumberInput.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 { Icon } from "../icons/Icon.js";
|
|
5
|
-
import { useFieldProps } from "./
|
|
5
|
+
import { useFieldProps } from "./Field.js";
|
|
6
6
|
// How many decimal places a number carries, so a commit can round away float
|
|
7
7
|
// noise: 0.1 + 0.2 must land as 0.3, not 0.30000000000000004.
|
|
8
8
|
function decimalsOf(n) {
|
|
@@ -70,7 +70,7 @@ export function NumberInput({
|
|
|
70
70
|
// explicit format or parse always wins over it, and no locale keeps the old
|
|
71
71
|
// plain behaviour, so this is additive.
|
|
72
72
|
const loc = locale && !(format && parse) ? localeNumber(locale) : null;
|
|
73
|
-
// Picks up id / aria wiring when nested in a
|
|
73
|
+
// Picks up id / aria wiring when nested in a Field; standalone this is a no-op.
|
|
74
74
|
const field = useFieldProps({
|
|
75
75
|
invalid,
|
|
76
76
|
error,
|
package/forms/Radio.d.ts
CHANGED
|
@@ -3,4 +3,15 @@ export interface RadioProps extends React.InputHTMLAttributes<HTMLInputElement>
|
|
|
3
3
|
/** Muted second line under the label */
|
|
4
4
|
description?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare
|
|
6
|
+
export declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>;
|
|
7
|
+
export interface RadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
value?: string;
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
onValueChange?: (value: string) => void;
|
|
11
|
+
name?: string;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
orientation?: 'horizontal' | 'vertical';
|
|
15
|
+
}
|
|
16
|
+
export declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export declare const RadioGroupItem: React.ForwardRefExoticComponent<Omit<RadioProps, 'type'> & { value: string } & React.RefAttributes<HTMLInputElement>>;
|
package/forms/Radio.js
CHANGED
|
@@ -1,16 +1,82 @@
|
|
|
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 { useFieldProps } from "./
|
|
5
|
-
|
|
4
|
+
import { useFieldProps } from "./Field.js";
|
|
5
|
+
const RadioGroupContext = /*#__PURE__*/React.createContext(null);
|
|
6
|
+
export const RadioGroup = /*#__PURE__*/React.forwardRef(function RadioGroup({
|
|
7
|
+
value: valueProp,
|
|
8
|
+
defaultValue,
|
|
9
|
+
onValueChange,
|
|
10
|
+
name,
|
|
11
|
+
required,
|
|
12
|
+
disabled,
|
|
13
|
+
orientation = 'vertical',
|
|
14
|
+
className,
|
|
15
|
+
style,
|
|
16
|
+
children,
|
|
17
|
+
...rest
|
|
18
|
+
}, ref) {
|
|
19
|
+
const [inner, setInner] = React.useState(defaultValue);
|
|
20
|
+
const value = valueProp !== undefined ? valueProp : inner;
|
|
21
|
+
const generatedName = React.useId();
|
|
22
|
+
const change = next => {
|
|
23
|
+
if (valueProp === undefined) setInner(next);
|
|
24
|
+
onValueChange?.(next);
|
|
25
|
+
};
|
|
26
|
+
return /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
27
|
+
value: {
|
|
28
|
+
value,
|
|
29
|
+
change,
|
|
30
|
+
name: name || generatedName,
|
|
31
|
+
required,
|
|
32
|
+
disabled
|
|
33
|
+
}
|
|
34
|
+
}, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
35
|
+
ref: ref,
|
|
36
|
+
role: "radiogroup",
|
|
37
|
+
"aria-orientation": orientation,
|
|
38
|
+
"data-slot": "radio-group",
|
|
39
|
+
"data-orientation": orientation,
|
|
40
|
+
"data-disabled": disabled ? '' : undefined,
|
|
41
|
+
className: `ef-radio-group${className ? ' ' + className : ''}`,
|
|
42
|
+
style: style
|
|
43
|
+
}), children));
|
|
44
|
+
});
|
|
45
|
+
export const RadioGroupItem = /*#__PURE__*/React.forwardRef(function RadioGroupItem({
|
|
46
|
+
value,
|
|
47
|
+
disabled,
|
|
48
|
+
onChange,
|
|
49
|
+
className,
|
|
50
|
+
style,
|
|
51
|
+
...rest
|
|
52
|
+
}, ref) {
|
|
53
|
+
const group = React.useContext(RadioGroupContext);
|
|
54
|
+
const unavailable = disabled || group?.disabled;
|
|
55
|
+
return /*#__PURE__*/React.createElement(Radio, _extends({
|
|
56
|
+
ref: ref,
|
|
57
|
+
value: value,
|
|
58
|
+
name: group?.name,
|
|
59
|
+
required: group?.required,
|
|
60
|
+
disabled: unavailable,
|
|
61
|
+
checked: group ? group.value === value : rest.checked,
|
|
62
|
+
"data-disabled": unavailable ? '' : undefined,
|
|
63
|
+
onChange: e => {
|
|
64
|
+
if (group) group.change(value);
|
|
65
|
+
onChange?.(e);
|
|
66
|
+
},
|
|
67
|
+
className: className,
|
|
68
|
+
style: style
|
|
69
|
+
}, rest));
|
|
70
|
+
});
|
|
71
|
+
export const Radio = /*#__PURE__*/React.forwardRef(function Radio({
|
|
6
72
|
label,
|
|
7
73
|
description,
|
|
8
74
|
disabled,
|
|
9
75
|
style,
|
|
10
76
|
className,
|
|
11
77
|
...rest
|
|
12
|
-
}) {
|
|
13
|
-
// Picks up id / aria wiring when nested in a
|
|
78
|
+
}, ref) {
|
|
79
|
+
// Picks up id / aria wiring when nested in a Field; standalone this is a no-op.
|
|
14
80
|
const field = useFieldProps({
|
|
15
81
|
id: rest.id,
|
|
16
82
|
'aria-describedby': rest['aria-describedby']
|
|
@@ -19,14 +85,18 @@ export function Radio({
|
|
|
19
85
|
className: `ef-radio${disabled ? ' ef-radio--disabled' : ''}${className ? ' ' + className : ''}`,
|
|
20
86
|
style: style
|
|
21
87
|
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
88
|
+
ref: ref,
|
|
22
89
|
type: "radio",
|
|
90
|
+
"data-slot": "radio-group-item",
|
|
91
|
+
"data-state": rest.checked ? 'checked' : 'unchecked',
|
|
23
92
|
className: "ef-radio__input",
|
|
24
93
|
disabled: disabled
|
|
25
94
|
}, rest, field.controlProps)), /*#__PURE__*/React.createElement("span", {
|
|
26
|
-
className: "ef-radio__dot"
|
|
95
|
+
className: "ef-radio__dot",
|
|
96
|
+
"aria-hidden": "true"
|
|
27
97
|
}), label ? /*#__PURE__*/React.createElement("span", {
|
|
28
98
|
className: "ef-radio__label"
|
|
29
99
|
}, label, description ? /*#__PURE__*/React.createElement("span", {
|
|
30
100
|
className: "ef-radio__desc"
|
|
31
101
|
}, description) : null) : null);
|
|
32
|
-
}
|
|
102
|
+
});
|
package/forms/Select.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export interface SelectProps
|
|
2
|
-
label?: string;
|
|
3
|
-
hint?: string;
|
|
4
|
-
/** Options as strings or {value, label}; alternatively pass <option> children */
|
|
5
|
-
options?: Array<string | { value: string; label: string }>;
|
|
6
|
-
/** @default 'md' */
|
|
7
|
-
size?: 'sm' | 'md' | 'lg';
|
|
8
|
-
invalid?: boolean;
|
|
9
|
-
}
|
|
1
|
+
export interface SelectProps { value?: string; defaultValue?: string; onValueChange?: (value: string) => void; open?: boolean; defaultOpen?: boolean; onOpenChange?: (open: boolean) => void; disabled?: boolean; name?: string; required?: boolean; children?: React.ReactNode }
|
|
10
2
|
export declare function Select(props: SelectProps): React.JSX.Element;
|
|
3
|
+
export type SelectTriggerProps = React.ComponentPropsWithoutRef<'button'>;
|
|
4
|
+
export declare const SelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export interface SelectValueProps { placeholder?: React.ReactNode; children?: React.ReactNode; className?: string }
|
|
6
|
+
export declare function SelectValue(props: SelectValueProps): React.JSX.Element;
|
|
7
|
+
export type SelectContentProps = React.ComponentPropsWithoutRef<'div'> & { position?: 'item-aligned' | 'popper'; align?: 'start' | 'center' | 'end'; sideOffset?: number };
|
|
8
|
+
export declare const SelectContent: React.ForwardRefExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export declare const SelectGroup: React.ForwardRefExoticComponent<React.ComponentPropsWithoutRef<'div'> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export declare const SelectLabel: React.ForwardRefExoticComponent<React.ComponentPropsWithoutRef<'div'> & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export type SelectItemProps = Omit<React.ComponentPropsWithoutRef<'button'>, 'value'> & { value: string };
|
|
12
|
+
export declare const SelectItem: React.ForwardRefExoticComponent<SelectItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
13
|
+
export declare const SelectSeparator: React.ForwardRefExoticComponent<React.ComponentPropsWithoutRef<'div'> & React.RefAttributes<HTMLDivElement>>;
|
package/forms/Select.js
CHANGED
|
@@ -2,51 +2,263 @@
|
|
|
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
|
-
import {
|
|
5
|
+
import { mergeRefs } from "./Button.js";
|
|
6
|
+
import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
|
|
7
|
+
const SelectCtx = /*#__PURE__*/React.createContext(null);
|
|
8
|
+
const itemText = children => typeof children === 'string' || typeof children === 'number' ? String(children) : '';
|
|
9
|
+
function collectLabels(children, out = {}) {
|
|
10
|
+
React.Children.forEach(children, child => {
|
|
11
|
+
if (! /*#__PURE__*/React.isValidElement(child)) return;
|
|
12
|
+
if (child.type === SelectItem) out[child.props.value] = itemText(child.props.children) || child.props.value;
|
|
13
|
+
if (child.props.children) collectLabels(child.props.children, out);
|
|
14
|
+
});
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
6
17
|
export function Select({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
value: controlled,
|
|
19
|
+
defaultValue = '',
|
|
20
|
+
onValueChange,
|
|
21
|
+
onOpenChange,
|
|
22
|
+
open: controlledOpen,
|
|
23
|
+
defaultOpen = false,
|
|
24
|
+
disabled = false,
|
|
25
|
+
name,
|
|
26
|
+
required,
|
|
27
|
+
children
|
|
28
|
+
}) {
|
|
29
|
+
const [innerValue, setInnerValue] = React.useState(defaultValue);
|
|
30
|
+
const [innerOpen, setInnerOpen] = React.useState(defaultOpen);
|
|
31
|
+
const value = controlled !== undefined ? controlled : innerValue;
|
|
32
|
+
const open = controlledOpen !== undefined ? controlledOpen : innerOpen;
|
|
33
|
+
const triggerRef = React.useRef(null);
|
|
34
|
+
const contentRef = React.useRef(null);
|
|
35
|
+
const declaredLabels = React.useMemo(() => collectLabels(children), [children]);
|
|
36
|
+
const [labels, setLabels] = React.useState(declaredLabels);
|
|
37
|
+
const setOpen = React.useCallback(next => {
|
|
38
|
+
if (controlledOpen === undefined) setInnerOpen(next);
|
|
39
|
+
onOpenChange?.(next);
|
|
40
|
+
}, [controlledOpen, onOpenChange]);
|
|
41
|
+
const choose = React.useCallback((next, label) => {
|
|
42
|
+
if (controlled === undefined) setInnerValue(next);
|
|
43
|
+
onValueChange?.(next);
|
|
44
|
+
setLabels(prev => prev[next] === label ? prev : {
|
|
45
|
+
...prev,
|
|
46
|
+
[next]: label
|
|
47
|
+
});
|
|
48
|
+
setOpen(false);
|
|
49
|
+
triggerRef.current?.focus();
|
|
50
|
+
}, [controlled, onValueChange, setOpen]);
|
|
51
|
+
const register = React.useCallback((next, label) => setLabels(prev => prev[next] === label ? prev : {
|
|
52
|
+
...prev,
|
|
53
|
+
[next]: label
|
|
54
|
+
}), []);
|
|
55
|
+
const allLabels = {
|
|
56
|
+
...declaredLabels,
|
|
57
|
+
...labels
|
|
58
|
+
};
|
|
59
|
+
const ctx = React.useMemo(() => ({
|
|
60
|
+
value,
|
|
61
|
+
open,
|
|
62
|
+
disabled,
|
|
63
|
+
labels: allLabels,
|
|
64
|
+
setOpen,
|
|
65
|
+
choose,
|
|
66
|
+
register,
|
|
67
|
+
triggerRef,
|
|
68
|
+
contentRef
|
|
69
|
+
}), [value, open, disabled, allLabels, setOpen, choose, register]);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
if (!open) return;
|
|
72
|
+
const away = event => {
|
|
73
|
+
if (!triggerRef.current?.contains(event.target) && !contentRef.current?.contains(event.target)) setOpen(false);
|
|
74
|
+
};
|
|
75
|
+
document.addEventListener('pointerdown', away);
|
|
76
|
+
return () => document.removeEventListener('pointerdown', away);
|
|
77
|
+
}, [open, setOpen]);
|
|
78
|
+
return /*#__PURE__*/React.createElement(SelectCtx.Provider, {
|
|
79
|
+
value: ctx
|
|
80
|
+
}, name ? /*#__PURE__*/React.createElement("input", {
|
|
81
|
+
type: "hidden",
|
|
82
|
+
name: name,
|
|
83
|
+
value: value,
|
|
84
|
+
required: required
|
|
85
|
+
}) : null, children);
|
|
86
|
+
}
|
|
87
|
+
export const SelectTrigger = /*#__PURE__*/React.forwardRef(function SelectTrigger({
|
|
12
88
|
children,
|
|
13
|
-
style,
|
|
14
89
|
className,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
className:
|
|
36
|
-
|
|
90
|
+
onClick,
|
|
91
|
+
onKeyDown,
|
|
92
|
+
...props
|
|
93
|
+
}, ref) {
|
|
94
|
+
const ctx = React.useContext(SelectCtx);
|
|
95
|
+
const key = event => {
|
|
96
|
+
onKeyDown?.(event);
|
|
97
|
+
if (!event.defaultPrevented && ['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
ctx?.setOpen(true);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
103
|
+
ref: mergeRefs(ref, ctx?.triggerRef),
|
|
104
|
+
type: "button",
|
|
105
|
+
role: "combobox",
|
|
106
|
+
"aria-haspopup": "listbox",
|
|
107
|
+
"aria-expanded": !!ctx?.open,
|
|
108
|
+
disabled: ctx?.disabled || props.disabled,
|
|
109
|
+
"data-slot": "select-trigger",
|
|
110
|
+
className: `ef-select-trigger${className ? ` ${className}` : ''}`,
|
|
111
|
+
onClick: event => {
|
|
112
|
+
onClick?.(event);
|
|
113
|
+
if (!event.defaultPrevented) ctx?.setOpen(!ctx.open);
|
|
114
|
+
},
|
|
115
|
+
onKeyDown: key
|
|
116
|
+
}), children, /*#__PURE__*/React.createElement(Icon, {
|
|
37
117
|
name: "chevron-down",
|
|
38
118
|
size: 16
|
|
39
|
-
}))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
119
|
+
}));
|
|
120
|
+
});
|
|
121
|
+
export function SelectValue({
|
|
122
|
+
placeholder,
|
|
123
|
+
children,
|
|
124
|
+
className
|
|
125
|
+
}) {
|
|
126
|
+
const ctx = React.useContext(SelectCtx);
|
|
127
|
+
const shown = children ?? ctx?.labels[ctx?.value];
|
|
128
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
129
|
+
"data-slot": "select-value",
|
|
130
|
+
"data-placeholder": shown ? undefined : '',
|
|
131
|
+
className: `ef-select-value${className ? ` ${className}` : ''}`
|
|
132
|
+
}, shown || placeholder);
|
|
133
|
+
}
|
|
134
|
+
export const SelectContent = /*#__PURE__*/React.forwardRef(function SelectContent({
|
|
135
|
+
children,
|
|
136
|
+
className,
|
|
137
|
+
position,
|
|
138
|
+
align = 'start',
|
|
139
|
+
sideOffset = 5,
|
|
140
|
+
onKeyDown,
|
|
141
|
+
style,
|
|
142
|
+
...props
|
|
143
|
+
}, ref) {
|
|
144
|
+
const ctx = React.useContext(SelectCtx);
|
|
145
|
+
const {
|
|
146
|
+
style: anchored
|
|
147
|
+
} = useAnchoredStyle(ctx?.triggerRef, ctx?.contentRef, {
|
|
148
|
+
open: !!ctx?.open,
|
|
149
|
+
placement: 'bottom',
|
|
150
|
+
align,
|
|
151
|
+
offset: sideOffset
|
|
43
152
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
|
|
153
|
+
React.useEffect(() => {
|
|
154
|
+
if (!ctx?.open) return;
|
|
155
|
+
requestAnimationFrame(() => {
|
|
156
|
+
const selected = ctx.contentRef.current?.querySelector('[aria-selected="true"]');
|
|
157
|
+
const first = ctx.contentRef.current?.querySelector('[role="option"]:not(:disabled)');
|
|
158
|
+
(selected || first)?.focus();
|
|
159
|
+
});
|
|
160
|
+
}, [ctx?.open]);
|
|
161
|
+
if (!ctx?.open) return null;
|
|
162
|
+
const key = event => {
|
|
163
|
+
onKeyDown?.(event);
|
|
164
|
+
if (event.defaultPrevented) return;
|
|
165
|
+
const items = [...event.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')];
|
|
166
|
+
const index = items.indexOf(document.activeElement);
|
|
167
|
+
if (event.key === 'Escape') {
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
ctx.setOpen(false);
|
|
170
|
+
ctx.triggerRef.current?.focus();
|
|
171
|
+
} else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
items[(index + (event.key === 'ArrowDown' ? 1 : -1) + items.length) % items.length]?.focus();
|
|
174
|
+
} else if (event.key === 'Home' || event.key === 'End') {
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
items[event.key === 'Home' ? 0 : items.length - 1]?.focus();
|
|
177
|
+
} else if (event.key === 'Tab') ctx.setOpen(false);else if (event.key.length === 1 && /\S/.test(event.key) && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
|
178
|
+
const query = event.key.toLocaleLowerCase();
|
|
179
|
+
const match = items.slice(index + 1).concat(items.slice(0, index + 1)).find(item => (item.textContent || '').trim().toLocaleLowerCase().startsWith(query));
|
|
180
|
+
if (match) {
|
|
181
|
+
event.preventDefault();
|
|
182
|
+
match.focus();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
187
|
+
ref: mergeRefs(ref, ctx.contentRef),
|
|
188
|
+
role: "listbox",
|
|
189
|
+
"data-slot": "select-content",
|
|
190
|
+
"data-position": position,
|
|
191
|
+
className: `ef-select-content${className ? ` ${className}` : ''}`,
|
|
192
|
+
style: {
|
|
193
|
+
...anchored,
|
|
194
|
+
'--select-trigger-width': `${ctx.triggerRef.current?.offsetWidth || 160}px`,
|
|
195
|
+
...style
|
|
196
|
+
},
|
|
197
|
+
onKeyDown: key
|
|
198
|
+
}), children));
|
|
199
|
+
});
|
|
200
|
+
export const SelectGroup = /*#__PURE__*/React.forwardRef(function SelectGroup({
|
|
201
|
+
className,
|
|
202
|
+
...props
|
|
203
|
+
}, ref) {
|
|
204
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
205
|
+
ref: ref,
|
|
206
|
+
role: "group",
|
|
207
|
+
"data-slot": "select-group",
|
|
208
|
+
className: `ef-select-group${className ? ` ${className}` : ''}`
|
|
209
|
+
}));
|
|
210
|
+
});
|
|
211
|
+
export const SelectLabel = /*#__PURE__*/React.forwardRef(function SelectLabel({
|
|
212
|
+
className,
|
|
213
|
+
...props
|
|
214
|
+
}, ref) {
|
|
215
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
216
|
+
ref: ref,
|
|
217
|
+
"data-slot": "select-label",
|
|
218
|
+
className: `ef-select-label${className ? ` ${className}` : ''}`
|
|
219
|
+
}));
|
|
220
|
+
});
|
|
221
|
+
export const SelectSeparator = /*#__PURE__*/React.forwardRef(function SelectSeparator({
|
|
222
|
+
className,
|
|
223
|
+
...props
|
|
224
|
+
}, ref) {
|
|
225
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
226
|
+
ref: ref,
|
|
227
|
+
role: "separator",
|
|
228
|
+
"data-slot": "select-separator",
|
|
229
|
+
className: `ef-select-separator${className ? ` ${className}` : ''}`
|
|
230
|
+
}));
|
|
231
|
+
});
|
|
232
|
+
export const SelectItem = /*#__PURE__*/React.forwardRef(function SelectItem({
|
|
233
|
+
value,
|
|
234
|
+
disabled = false,
|
|
235
|
+
children,
|
|
236
|
+
className,
|
|
237
|
+
onClick,
|
|
238
|
+
...props
|
|
239
|
+
}, ref) {
|
|
240
|
+
const ctx = React.useContext(SelectCtx);
|
|
241
|
+
const label = itemText(children) || value;
|
|
242
|
+
React.useEffect(() => {
|
|
243
|
+
ctx?.register(value, label);
|
|
244
|
+
}, [ctx?.register, value, label]);
|
|
245
|
+
const selected = ctx?.value === value;
|
|
246
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
247
|
+
ref: ref,
|
|
248
|
+
type: "button",
|
|
249
|
+
role: "option",
|
|
250
|
+
"aria-selected": selected,
|
|
251
|
+
disabled: disabled,
|
|
252
|
+
"data-slot": "select-item",
|
|
253
|
+
className: `ef-select-item${className ? ` ${className}` : ''}`,
|
|
254
|
+
onClick: event => {
|
|
255
|
+
onClick?.(event);
|
|
256
|
+
if (!event.defaultPrevented) ctx?.choose(value, label);
|
|
257
|
+
}
|
|
258
|
+
}), children, selected ? /*#__PURE__*/React.createElement("span", {
|
|
259
|
+
className: "ef-select-check"
|
|
260
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
261
|
+
name: "check",
|
|
262
|
+
size: 15
|
|
263
|
+
})) : null);
|
|
264
|
+
});
|
package/forms/Slider.d.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
export interface SliderProps {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/** Controlled value */
|
|
11
|
-
value?: number;
|
|
12
|
-
defaultValue?: number;
|
|
13
|
-
onChange?: (value: number, e: React.ChangeEvent) => void;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
style?: React.CSSProperties;
|
|
16
|
-
className?: string;
|
|
1
|
+
export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'min' | 'max' | 'step' | 'size'> {
|
|
2
|
+
min?: number; max?: number; step?: number;
|
|
3
|
+
value?: number[]; defaultValue?: number[];
|
|
4
|
+
onValueChange?: (value: number[]) => void;
|
|
5
|
+
onValueCommit?: (value: number[]) => void;
|
|
6
|
+
orientation?: 'horizontal' | 'vertical';
|
|
7
|
+
minStepsBetweenThumbs?: number;
|
|
8
|
+
inverted?: boolean;
|
|
9
|
+
dir?: 'ltr' | 'rtl';
|
|
17
10
|
}
|
|
18
|
-
export declare
|
|
11
|
+
export declare const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<HTMLSpanElement>>;
|