@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/Slider.js
CHANGED
|
@@ -1,58 +1,97 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { useFieldProps } from "./Field.js";
|
|
5
|
+
function clamp(value, min, max) {
|
|
6
|
+
return Math.max(min, Math.min(max, value));
|
|
7
|
+
}
|
|
8
|
+
function asArray(value, fallback) {
|
|
9
|
+
return Array.isArray(value) ? value : fallback;
|
|
10
|
+
}
|
|
11
|
+
export const Slider = /*#__PURE__*/React.forwardRef(function Slider({
|
|
9
12
|
min = 0,
|
|
10
13
|
max = 100,
|
|
11
14
|
step = 1,
|
|
12
|
-
value,
|
|
15
|
+
value: valueProp,
|
|
13
16
|
defaultValue,
|
|
14
|
-
|
|
17
|
+
onValueChange,
|
|
18
|
+
onValueCommit,
|
|
15
19
|
disabled,
|
|
20
|
+
orientation = 'horizontal',
|
|
21
|
+
minStepsBetweenThumbs = 0,
|
|
22
|
+
inverted = false,
|
|
23
|
+
dir,
|
|
16
24
|
style,
|
|
17
25
|
className,
|
|
18
26
|
...rest
|
|
19
|
-
}) {
|
|
20
|
-
// Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
|
|
27
|
+
}, forwardedRef) {
|
|
21
28
|
const field = useFieldProps({
|
|
22
29
|
id: rest.id,
|
|
23
30
|
'aria-describedby': rest['aria-describedby']
|
|
24
31
|
});
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const fallback = [min];
|
|
33
|
+
const [inner, setInner] = React.useState(() => asArray(defaultValue, fallback));
|
|
34
|
+
const values = asArray(valueProp, inner).map(value => clamp(Number(value), min, max));
|
|
35
|
+
const latestRef = React.useRef(values);
|
|
36
|
+
latestRef.current = values;
|
|
37
|
+
const span = max - min || 1;
|
|
38
|
+
const percentages = values.map(value => (value - min) / span * 100);
|
|
39
|
+
const low = values.length > 1 ? Math.min(...percentages) : 0;
|
|
40
|
+
const high = values.length > 1 ? Math.max(...percentages) : percentages[0];
|
|
41
|
+
const update = (index, nextNumber) => {
|
|
42
|
+
const next = [...values];
|
|
43
|
+
const gap = minStepsBetweenThumbs * step;
|
|
44
|
+
const lower = index > 0 ? next[index - 1] + gap : min;
|
|
45
|
+
const upper = index < next.length - 1 ? next[index + 1] - gap : max;
|
|
46
|
+
next[index] = clamp(nextNumber, lower, upper);
|
|
47
|
+
latestRef.current = next;
|
|
48
|
+
if (valueProp === undefined) setInner(next);
|
|
49
|
+
onValueChange?.(next);
|
|
32
50
|
};
|
|
33
|
-
const
|
|
51
|
+
const rangeStyle = orientation === 'vertical' ? {
|
|
52
|
+
bottom: `${low}%`,
|
|
53
|
+
height: `${high - low}%`,
|
|
54
|
+
width: '100%'
|
|
55
|
+
} : {
|
|
56
|
+
insetInlineStart: `${inverted ? 100 - high : low}%`,
|
|
57
|
+
width: `${high - low}%`
|
|
58
|
+
};
|
|
59
|
+
const control = /*#__PURE__*/React.createElement("span", {
|
|
60
|
+
className: "ef-slider__control"
|
|
61
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
62
|
+
className: "ef-slider__rail",
|
|
63
|
+
"data-slot": "slider-track"
|
|
64
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
65
|
+
className: "ef-slider__range",
|
|
66
|
+
"data-slot": "slider-range",
|
|
67
|
+
style: rangeStyle
|
|
68
|
+
})), values.map((value, index) => /*#__PURE__*/React.createElement("input", _extends({}, rest, field.controlProps, {
|
|
69
|
+
key: index,
|
|
34
70
|
type: "range",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
min: min,
|
|
40
|
-
max: max,
|
|
71
|
+
"data-slot": "slider-thumb",
|
|
72
|
+
"aria-label": rest['aria-label'] ? `${rest['aria-label']}${values.length > 1 ? ` ${index + 1}` : ''}` : undefined,
|
|
73
|
+
min: index > 0 ? values[index - 1] + minStepsBetweenThumbs * step : min,
|
|
74
|
+
max: index < values.length - 1 ? values[index + 1] - minStepsBetweenThumbs * step : max,
|
|
41
75
|
step: step,
|
|
42
|
-
value:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
76
|
+
value: value,
|
|
77
|
+
disabled: disabled,
|
|
78
|
+
dir: inverted ? dir === 'rtl' ? 'ltr' : 'rtl' : dir,
|
|
79
|
+
className: "ef-slider__input",
|
|
80
|
+
onChange: event => update(index, Number(event.target.value)),
|
|
81
|
+
onPointerUp: () => onValueCommit?.(latestRef.current),
|
|
82
|
+
onKeyUp: event => {
|
|
83
|
+
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) onValueCommit?.(latestRef.current);
|
|
84
|
+
}
|
|
85
|
+
}))));
|
|
86
|
+
const rootProps = {
|
|
87
|
+
'data-slot': 'slider',
|
|
88
|
+
'data-orientation': orientation,
|
|
89
|
+
'data-disabled': disabled ? '' : undefined,
|
|
90
|
+
dir,
|
|
51
91
|
className: `ef-slider${className ? ' ' + className : ''}`,
|
|
52
|
-
style
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
92
|
+
style
|
|
93
|
+
};
|
|
94
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, rootProps, {
|
|
95
|
+
ref: forwardedRef
|
|
96
|
+
}), control);
|
|
97
|
+
});
|
package/forms/Switch.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
export interface SwitchProps extends Omit<React.
|
|
1
|
+
export interface SwitchProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'size' | 'value' | 'defaultValue' | 'onChange'> {
|
|
2
2
|
label?: React.ReactNode;
|
|
3
3
|
/** @default 'md' */
|
|
4
4
|
size?: 'sm' | 'md';
|
|
5
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
defaultChecked?: boolean;
|
|
8
|
+
name?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
required?: boolean;
|
|
5
11
|
}
|
|
6
|
-
export declare
|
|
12
|
+
export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
|
package/forms/Switch.js
CHANGED
|
@@ -1,31 +1,62 @@
|
|
|
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
|
-
export function Switch({
|
|
4
|
+
import { useFieldProps } from "./Field.js";
|
|
5
|
+
export const Switch = /*#__PURE__*/React.forwardRef(function Switch({
|
|
6
6
|
label,
|
|
7
7
|
size = 'md',
|
|
8
8
|
disabled,
|
|
9
|
+
checked: checkedProp,
|
|
10
|
+
defaultChecked,
|
|
11
|
+
onCheckedChange,
|
|
12
|
+
onClick,
|
|
13
|
+
name,
|
|
14
|
+
value = 'on',
|
|
15
|
+
required,
|
|
9
16
|
style,
|
|
10
17
|
className,
|
|
11
18
|
...rest
|
|
12
|
-
}) {
|
|
13
|
-
// Picks up id / aria wiring when nested in a
|
|
19
|
+
}, ref) {
|
|
20
|
+
// Picks up id / aria wiring when nested in a Field; standalone this is a no-op.
|
|
14
21
|
const field = useFieldProps({
|
|
15
22
|
id: rest.id,
|
|
16
23
|
'aria-describedby': rest['aria-describedby']
|
|
17
24
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: "
|
|
25
|
+
const [inner, setInner] = React.useState(!!defaultChecked);
|
|
26
|
+
const checked = checkedProp !== undefined ? checkedProp : inner;
|
|
27
|
+
const control = /*#__PURE__*/React.createElement("button", _extends({
|
|
28
|
+
ref: ref,
|
|
29
|
+
type: "button",
|
|
23
30
|
role: "switch",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
"aria-checked": checked,
|
|
32
|
+
"aria-required": required || undefined,
|
|
33
|
+
disabled: disabled,
|
|
34
|
+
"data-slot": "switch",
|
|
35
|
+
"data-state": checked ? 'checked' : 'unchecked',
|
|
36
|
+
className: `ef-switch ef-switch--${size}${disabled ? ' ef-switch--disabled' : ''}${className ? ' ' + className : ''}`,
|
|
37
|
+
style: style,
|
|
38
|
+
onClick: e => {
|
|
39
|
+
if (onClick) onClick(e);
|
|
40
|
+
if (!e.defaultPrevented) {
|
|
41
|
+
const next = !checked;
|
|
42
|
+
if (checkedProp === undefined) setInner(next);
|
|
43
|
+
if (onCheckedChange) onCheckedChange(next);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, rest, field.controlProps), /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
"data-slot": "switch-thumb",
|
|
48
|
+
"data-state": checked ? 'checked' : 'unchecked',
|
|
27
49
|
className: "ef-switch__track"
|
|
28
|
-
})
|
|
50
|
+
}));
|
|
51
|
+
const formValue = name && checked ? /*#__PURE__*/React.createElement("input", {
|
|
52
|
+
type: "hidden",
|
|
53
|
+
name: name,
|
|
54
|
+
value: value
|
|
55
|
+
}) : null;
|
|
56
|
+
if (!label) return /*#__PURE__*/React.createElement(React.Fragment, null, control, formValue);
|
|
57
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
58
|
+
className: "ef-switch-field"
|
|
59
|
+
}, control, /*#__PURE__*/React.createElement("span", {
|
|
29
60
|
className: "ef-switch__label"
|
|
30
|
-
}, label)
|
|
31
|
-
}
|
|
61
|
+
}, label), formValue);
|
|
62
|
+
});
|
package/forms/Textarea.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextArea
|
|
|
5
5
|
error?: string;
|
|
6
6
|
invalid?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare
|
|
8
|
+
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
package/forms/Textarea.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
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 "./
|
|
6
|
-
export function Textarea({
|
|
5
|
+
import { useFieldProps } from "./Field.js";
|
|
6
|
+
export const Textarea = /*#__PURE__*/React.forwardRef(function Textarea({
|
|
7
7
|
label,
|
|
8
8
|
hint,
|
|
9
9
|
error,
|
|
@@ -11,8 +11,8 @@ export function Textarea({
|
|
|
11
11
|
style,
|
|
12
12
|
className,
|
|
13
13
|
...rest
|
|
14
|
-
}) {
|
|
15
|
-
|
|
14
|
+
}, ref) {
|
|
15
|
+
const uid = React.useId();
|
|
16
16
|
const field = useFieldProps({
|
|
17
17
|
invalid,
|
|
18
18
|
error,
|
|
@@ -20,25 +20,33 @@ export function Textarea({
|
|
|
20
20
|
'aria-describedby': rest['aria-describedby']
|
|
21
21
|
});
|
|
22
22
|
const bad = field.invalid;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, rest, field.controlProps
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
className: `ef-
|
|
23
|
+
const controlId = field.id || rest.id || (label || hint || error ? `${uid}c` : undefined);
|
|
24
|
+
const noteId = hint || error ? `${uid}n` : undefined;
|
|
25
|
+
const describedBy = [...new Set([field.controlProps['aria-describedby'], rest['aria-describedby'], noteId].filter(Boolean))].join(' ') || undefined;
|
|
26
|
+
const control = /*#__PURE__*/React.createElement("textarea", _extends({}, rest, field.controlProps, {
|
|
27
|
+
ref: ref,
|
|
28
|
+
id: controlId,
|
|
29
|
+
"data-slot": "textarea",
|
|
30
|
+
"aria-describedby": describedBy,
|
|
31
|
+
"aria-invalid": bad || rest['aria-invalid'] || undefined,
|
|
32
|
+
className: `ef-textarea${bad ? ' ef-textarea--invalid' : ''}${className ? ' ' + className : ''}`,
|
|
33
33
|
style: style
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
}));
|
|
35
|
+
if (!label && !hint && !error) return control;
|
|
36
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: "ef-field"
|
|
38
|
+
}, label ? /*#__PURE__*/React.createElement("label", {
|
|
39
|
+
className: "ef-field__label",
|
|
40
|
+
htmlFor: controlId
|
|
41
|
+
}, label) : null, control, error ? /*#__PURE__*/React.createElement("span", {
|
|
42
|
+
id: noteId,
|
|
43
|
+
role: "alert",
|
|
37
44
|
className: "ef-field__error"
|
|
38
45
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
39
46
|
name: "circle-alert",
|
|
40
47
|
size: 12
|
|
41
48
|
}), error) : hint ? /*#__PURE__*/React.createElement("span", {
|
|
49
|
+
id: noteId,
|
|
42
50
|
className: "ef-field__hint"
|
|
43
51
|
}, hint) : null);
|
|
44
|
-
}
|
|
52
|
+
});
|
package/forms/Toggle.d.ts
CHANGED
|
@@ -3,24 +3,27 @@ export interface ToggleProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
3
3
|
pressed?: boolean;
|
|
4
4
|
defaultPressed?: boolean;
|
|
5
5
|
onPressedChange?: (pressed: boolean) => void;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/** @default 'md' */
|
|
11
|
-
size?: 'sm' | 'md';
|
|
12
|
-
children?: React.ReactNode;
|
|
6
|
+
/** @default 'default' */
|
|
7
|
+
variant?: 'default' | 'outline';
|
|
8
|
+
/** @default 'default' */
|
|
9
|
+
size?: 'default' | 'sm' | 'lg';
|
|
13
10
|
}
|
|
14
|
-
export interface ToggleGroupProps {
|
|
11
|
+
export interface ToggleGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
15
12
|
/** @default 'single' */
|
|
16
13
|
type?: 'single' | 'multiple';
|
|
17
|
-
/** Controlled: string (single) or string[] (multiple) */
|
|
18
14
|
value?: string | string[] | null;
|
|
19
15
|
defaultValue?: string | string[] | null;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
onValueChange?: (value: string | string[] | null) => void;
|
|
17
|
+
variant?: 'default' | 'outline';
|
|
18
|
+
size?: 'default' | 'sm' | 'lg';
|
|
19
|
+
/** Gap in 4px units. @default 2 */
|
|
20
|
+
spacing?: number;
|
|
21
|
+
orientation?: 'horizontal' | 'vertical';
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
dir?: 'ltr' | 'rtl';
|
|
24
24
|
}
|
|
25
|
-
export
|
|
26
|
-
export declare function
|
|
25
|
+
export interface ToggleGroupItemProps extends ToggleProps { value: string; }
|
|
26
|
+
export declare function toggleVariants(options?: Pick<ToggleProps, 'variant' | 'size'> & { className?: string }): string;
|
|
27
|
+
export declare const Toggle: React.ForwardRefExoticComponent<ToggleProps & React.RefAttributes<HTMLButtonElement>>;
|
|
28
|
+
export declare const ToggleGroup: React.ForwardRefExoticComponent<ToggleGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
29
|
+
export declare const ToggleGroupItem: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
|
package/forms/Toggle.js
CHANGED
|
@@ -1,74 +1,128 @@
|
|
|
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 { Icon } from "../icons/Icon.js";
|
|
5
4
|
const GroupCtx = /*#__PURE__*/React.createContext(null);
|
|
6
|
-
export function
|
|
5
|
+
export function toggleVariants({
|
|
6
|
+
variant = 'default',
|
|
7
|
+
size = 'default',
|
|
8
|
+
className = ''
|
|
9
|
+
} = {}) {
|
|
10
|
+
const mappedSize = size === 'default' ? 'default' : size;
|
|
11
|
+
return `ef-toggle ef-toggle--${variant} ef-toggle--${mappedSize}${className ? ' ' + className : ''}`;
|
|
12
|
+
}
|
|
13
|
+
export const Toggle = /*#__PURE__*/React.forwardRef(function Toggle({
|
|
7
14
|
pressed,
|
|
8
15
|
defaultPressed,
|
|
9
16
|
onPressedChange,
|
|
17
|
+
onClick,
|
|
10
18
|
value,
|
|
11
|
-
|
|
12
|
-
size = '
|
|
19
|
+
variant = 'default',
|
|
20
|
+
size = 'default',
|
|
13
21
|
disabled,
|
|
14
22
|
children,
|
|
15
|
-
style,
|
|
16
23
|
className,
|
|
24
|
+
_groupItem = false,
|
|
17
25
|
...rest
|
|
18
|
-
}) {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
}, ref) {
|
|
27
|
+
const groupContext = React.useContext(GroupCtx);
|
|
28
|
+
const context = _groupItem ? groupContext : null;
|
|
29
|
+
const [uncontrolled, setUncontrolled] = React.useState(!!defaultPressed);
|
|
30
|
+
const isOn = context ? context.isOn(value) : pressed !== undefined ? pressed : uncontrolled;
|
|
31
|
+
const press = event => {
|
|
32
|
+
onClick?.(event);
|
|
33
|
+
if (event.defaultPrevented) return;
|
|
34
|
+
if (context) context.toggle(value);else {
|
|
35
|
+
if (pressed === undefined) setUncontrolled(!isOn);
|
|
36
|
+
onPressedChange?.(!isOn);
|
|
26
37
|
}
|
|
27
|
-
if (pressed === undefined) setUn(!isOn);
|
|
28
|
-
if (onPressedChange) onPressedChange(!isOn);
|
|
29
38
|
};
|
|
30
|
-
|
|
39
|
+
const actualVariant = context?.variant ?? variant;
|
|
40
|
+
const actualSize = context?.size ?? size;
|
|
41
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, rest, {
|
|
42
|
+
ref: ref,
|
|
31
43
|
type: "button",
|
|
44
|
+
"data-slot": context ? 'toggle-group-item' : 'toggle',
|
|
45
|
+
"data-state": isOn ? 'on' : 'off',
|
|
32
46
|
"aria-pressed": isOn,
|
|
33
|
-
disabled: disabled,
|
|
47
|
+
disabled: disabled || context?.disabled,
|
|
34
48
|
onClick: press,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
export function ToggleGroup({
|
|
49
|
+
className: `${toggleVariants({
|
|
50
|
+
variant: actualVariant,
|
|
51
|
+
size: actualSize,
|
|
52
|
+
className
|
|
53
|
+
})}${isOn ? ' ef-toggle--on' : ''}`
|
|
54
|
+
}), children);
|
|
55
|
+
});
|
|
56
|
+
export const ToggleGroup = /*#__PURE__*/React.forwardRef(function ToggleGroup({
|
|
43
57
|
type = 'single',
|
|
44
58
|
value,
|
|
45
59
|
defaultValue,
|
|
46
|
-
|
|
60
|
+
onValueChange,
|
|
61
|
+
variant = 'default',
|
|
62
|
+
size = 'default',
|
|
63
|
+
spacing = 2,
|
|
64
|
+
orientation = 'horizontal',
|
|
65
|
+
disabled = false,
|
|
66
|
+
dir,
|
|
47
67
|
children,
|
|
48
68
|
style,
|
|
49
69
|
className,
|
|
70
|
+
onKeyDown,
|
|
50
71
|
...rest
|
|
51
|
-
}) {
|
|
52
|
-
const [
|
|
53
|
-
const
|
|
54
|
-
const isOn =
|
|
55
|
-
const toggle =
|
|
72
|
+
}, ref) {
|
|
73
|
+
const [uncontrolled, setUncontrolled] = React.useState(defaultValue !== undefined ? defaultValue : type === 'multiple' ? [] : null);
|
|
74
|
+
const current = value !== undefined ? value : uncontrolled;
|
|
75
|
+
const isOn = itemValue => type === 'multiple' ? (current || []).includes(itemValue) : current === itemValue;
|
|
76
|
+
const toggle = itemValue => {
|
|
56
77
|
let next;
|
|
57
78
|
if (type === 'multiple') {
|
|
58
|
-
const
|
|
59
|
-
next =
|
|
60
|
-
} else next =
|
|
61
|
-
if (value === undefined)
|
|
62
|
-
|
|
79
|
+
const selected = current || [];
|
|
80
|
+
next = selected.includes(itemValue) ? selected.filter(item => item !== itemValue) : [...selected, itemValue];
|
|
81
|
+
} else next = current === itemValue ? null : itemValue;
|
|
82
|
+
if (value === undefined) setUncontrolled(next);
|
|
83
|
+
onValueChange?.(next);
|
|
63
84
|
};
|
|
85
|
+
const keyNav = event => {
|
|
86
|
+
onKeyDown?.(event);
|
|
87
|
+
if (event.defaultPrevented) return;
|
|
88
|
+
const rtl = (dir || document.documentElement.dir) === 'rtl';
|
|
89
|
+
const previous = orientation === 'vertical' ? event.key === 'ArrowUp' : event.key === (rtl ? 'ArrowRight' : 'ArrowLeft');
|
|
90
|
+
const next = orientation === 'vertical' ? event.key === 'ArrowDown' : event.key === (rtl ? 'ArrowLeft' : 'ArrowRight');
|
|
91
|
+
if (!previous && !next && event.key !== 'Home' && event.key !== 'End') return;
|
|
92
|
+
const items = [...event.currentTarget.querySelectorAll('[data-slot="toggle-group-item"]:not(:disabled)')];
|
|
93
|
+
if (!items.length) return;
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
const index = items.indexOf(document.activeElement);
|
|
96
|
+
const target = event.key === 'Home' ? items[0] : event.key === 'End' ? items.at(-1) : items[(index + (previous ? -1 : 1) + items.length) % items.length];
|
|
97
|
+
target?.focus();
|
|
98
|
+
};
|
|
99
|
+
const ctx = React.useMemo(() => ({
|
|
100
|
+
isOn,
|
|
101
|
+
toggle,
|
|
102
|
+
variant,
|
|
103
|
+
size,
|
|
104
|
+
disabled
|
|
105
|
+
}), [current, type, variant, size, disabled]);
|
|
64
106
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
107
|
+
ref: ref,
|
|
65
108
|
role: "group",
|
|
109
|
+
"data-slot": "toggle-group",
|
|
110
|
+
"data-orientation": orientation,
|
|
111
|
+
dir: dir,
|
|
66
112
|
className: `ef-toggle-group${className ? ' ' + className : ''}`,
|
|
67
|
-
style:
|
|
113
|
+
style: {
|
|
114
|
+
'--ef-toggle-gap': `${spacing * 4}px`,
|
|
115
|
+
...style
|
|
116
|
+
},
|
|
117
|
+
onKeyDown: keyNav
|
|
68
118
|
}), /*#__PURE__*/React.createElement(GroupCtx.Provider, {
|
|
69
|
-
value:
|
|
70
|
-
isOn,
|
|
71
|
-
toggle
|
|
72
|
-
}
|
|
119
|
+
value: ctx
|
|
73
120
|
}, children));
|
|
74
|
-
}
|
|
121
|
+
});
|
|
122
|
+
export const ToggleGroupItem = /*#__PURE__*/React.forwardRef(function ToggleGroupItem(props, ref) {
|
|
123
|
+
return /*#__PURE__*/React.createElement(Toggle, _extends({}, props, {
|
|
124
|
+
ref: ref,
|
|
125
|
+
_groupItem: true,
|
|
126
|
+
"data-slot": "toggle-group-item"
|
|
127
|
+
}));
|
|
128
|
+
});
|
package/icons/_svg.js
CHANGED
|
@@ -24,6 +24,7 @@ export const SVGS = {
|
|
|
24
24
|
"chevron-up": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"m18 15-6-6-6 6\"></path>\n</svg>",
|
|
25
25
|
"circle-alert": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"></circle>\n <line x1=\"12\" x2=\"12\" y1=\"8\" y2=\"12\"></line>\n <line x1=\"12\" x2=\"12.01\" y1=\"16\" y2=\"16\"></line>\n</svg>",
|
|
26
26
|
"circle-check": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"></circle>\n <path d=\"m9 12 2 2 4-4\"></path>\n</svg>",
|
|
27
|
+
"circle": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"></circle>\n</svg>",
|
|
27
28
|
"clock": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"></circle>\n <path d=\"M12 6v6l4 2\"></path>\n</svg>",
|
|
28
29
|
"cloud": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z\"></path>\n</svg>",
|
|
29
30
|
"code": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"m16 18 6-6-6-6\"></path>\n <path d=\"m8 6-6 6 6 6\"></path>\n</svg>",
|
|
@@ -67,6 +68,7 @@ export const SVGS = {
|
|
|
67
68
|
"menu": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M4 5h16\"></path>\n <path d=\"M4 12h16\"></path>\n <path d=\"M4 19h16\"></path>\n</svg>",
|
|
68
69
|
"message-square": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z\"></path>\n</svg>",
|
|
69
70
|
"mic": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M12 19v3\"></path>\n <path d=\"M19 10v2a7 7 0 0 1-14 0v-2\"></path>\n <rect x=\"9\" y=\"2\" width=\"6\" height=\"13\" rx=\"3\"></rect>\n</svg>",
|
|
71
|
+
"minus": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M5 12h14\"></path>\n</svg>",
|
|
70
72
|
"monitor": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect width=\"20\" height=\"14\" x=\"2\" y=\"3\" rx=\"2\"></rect>\n <line x1=\"8\" x2=\"16\" y1=\"21\" y2=\"21\"></line>\n <line x1=\"12\" x2=\"12\" y1=\"17\" y2=\"21\"></line>\n</svg>",
|
|
71
73
|
"moon": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\"></path>\n</svg>",
|
|
72
74
|
"music": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M9 18V5l12-2v13\"></path>\n <circle cx=\"6\" cy=\"18\" r=\"3\"></circle>\n <circle cx=\"18\" cy=\"16\" r=\"3\"></circle>\n</svg>",
|