@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/feedback/Dialog.js
CHANGED
|
@@ -1,98 +1,240 @@
|
|
|
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
|
import { IconButton } from "../forms/IconButton.js";
|
|
5
|
+
import { mergeRefs } from "../forms/Button.js";
|
|
6
|
+
import { Portal } from "../overlay/Portal.js";
|
|
7
|
+
const DialogContext = /*#__PURE__*/React.createContext(null);
|
|
6
8
|
const FOCUSABLE = 'button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
function cx(base, className) {
|
|
10
|
+
return base + (className ? ` ${className}` : '');
|
|
11
|
+
}
|
|
12
|
+
function compose(first, second) {
|
|
13
|
+
return e => {
|
|
14
|
+
if (first) first(e);
|
|
15
|
+
if (!e.defaultPrevented && second) second(e);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function Dialog({
|
|
19
|
+
open: controlled,
|
|
20
|
+
defaultOpen = false,
|
|
21
|
+
onOpenChange,
|
|
22
|
+
children
|
|
23
|
+
}) {
|
|
24
|
+
const [internal, setInternal] = React.useState(defaultOpen);
|
|
25
|
+
const titleId = React.useId();
|
|
26
|
+
const descriptionId = React.useId();
|
|
27
|
+
const open = controlled === undefined ? internal : controlled;
|
|
28
|
+
const setOpen = React.useCallback(next => {
|
|
29
|
+
if (controlled === undefined) setInternal(next);
|
|
30
|
+
onOpenChange?.(next);
|
|
31
|
+
}, [controlled, onOpenChange]);
|
|
32
|
+
const value = React.useMemo(() => ({
|
|
33
|
+
open,
|
|
34
|
+
setOpen,
|
|
35
|
+
titleId,
|
|
36
|
+
descriptionId
|
|
37
|
+
}), [open, setOpen, titleId, descriptionId]);
|
|
38
|
+
return /*#__PURE__*/React.createElement(DialogContext.Provider, {
|
|
39
|
+
value: value
|
|
40
|
+
}, children);
|
|
41
|
+
}
|
|
42
|
+
export const DialogTrigger = /*#__PURE__*/React.forwardRef(function DialogTrigger({
|
|
43
|
+
asChild = false,
|
|
44
|
+
children,
|
|
45
|
+
onClick,
|
|
46
|
+
slot = 'dialog-trigger',
|
|
47
|
+
...rest
|
|
48
|
+
}, ref) {
|
|
49
|
+
const ctx = React.useContext(DialogContext);
|
|
50
|
+
const props = {
|
|
51
|
+
...rest,
|
|
52
|
+
'data-slot': slot,
|
|
53
|
+
onClick: compose(onClick, () => ctx && ctx.setOpen(true))
|
|
54
|
+
};
|
|
55
|
+
if (asChild) {
|
|
56
|
+
const child = React.Children.only(children);
|
|
57
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
58
|
+
...props,
|
|
59
|
+
ref: mergeRefs(ref, child.ref),
|
|
60
|
+
className: child.props.className
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
64
|
+
ref: ref,
|
|
65
|
+
type: rest.type || 'button'
|
|
66
|
+
}), children);
|
|
67
|
+
});
|
|
68
|
+
export function DialogPortal({
|
|
69
|
+
children,
|
|
70
|
+
container
|
|
71
|
+
}) {
|
|
72
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
73
|
+
container: container
|
|
74
|
+
}, children);
|
|
75
|
+
}
|
|
76
|
+
export const DialogOverlay = /*#__PURE__*/React.forwardRef(function DialogOverlay({
|
|
77
|
+
className,
|
|
78
|
+
onMouseDown,
|
|
79
|
+
slot = 'dialog-overlay',
|
|
80
|
+
...rest
|
|
81
|
+
}, ref) {
|
|
82
|
+
const ctx = React.useContext(DialogContext);
|
|
83
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
84
|
+
ref: ref,
|
|
85
|
+
"data-slot": slot,
|
|
86
|
+
className: cx('ef-dialog__overlay', className),
|
|
87
|
+
onMouseDown: compose(onMouseDown, e => {
|
|
88
|
+
if (e.target === e.currentTarget && ctx) ctx.setOpen(false);
|
|
89
|
+
})
|
|
90
|
+
}));
|
|
91
|
+
});
|
|
92
|
+
export const DialogClose = /*#__PURE__*/React.forwardRef(function DialogClose({
|
|
93
|
+
asChild = false,
|
|
94
|
+
children,
|
|
95
|
+
onClick,
|
|
96
|
+
slot = 'dialog-close',
|
|
97
|
+
...rest
|
|
98
|
+
}, ref) {
|
|
99
|
+
const ctx = React.useContext(DialogContext);
|
|
100
|
+
const props = {
|
|
101
|
+
...rest,
|
|
102
|
+
'data-slot': slot,
|
|
103
|
+
onClick: compose(onClick, () => ctx && ctx.setOpen(false))
|
|
104
|
+
};
|
|
105
|
+
if (asChild) {
|
|
106
|
+
const child = React.Children.only(children);
|
|
107
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
108
|
+
...props,
|
|
109
|
+
ref: mergeRefs(ref, child.ref),
|
|
110
|
+
className: child.props.className
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
114
|
+
ref: ref,
|
|
115
|
+
type: rest.type || 'button'
|
|
116
|
+
}), children);
|
|
117
|
+
});
|
|
118
|
+
export const DialogContent = /*#__PURE__*/React.forwardRef(function DialogContent({
|
|
15
119
|
children,
|
|
16
|
-
style,
|
|
17
120
|
className,
|
|
121
|
+
style,
|
|
122
|
+
width = 440,
|
|
123
|
+
showCloseButton = true,
|
|
124
|
+
closeLabel = 'Close',
|
|
125
|
+
onEscapeKeyDown,
|
|
126
|
+
overlayProps,
|
|
127
|
+
overlayRef,
|
|
128
|
+
slot = 'dialog-content',
|
|
18
129
|
...rest
|
|
19
130
|
}, ref) {
|
|
131
|
+
const ctx = React.useContext(DialogContext);
|
|
20
132
|
const panelRef = React.useRef(null);
|
|
21
|
-
const
|
|
22
|
-
const titleId = React.useId();
|
|
23
|
-
const descId = React.useId();
|
|
133
|
+
const previous = React.useRef(null);
|
|
24
134
|
React.useEffect(() => {
|
|
25
|
-
if (!open) return;
|
|
26
|
-
|
|
135
|
+
if (!ctx || !ctx.open) return;
|
|
136
|
+
previous.current = document.activeElement;
|
|
27
137
|
const panel = panelRef.current;
|
|
28
138
|
const first = panel && panel.querySelector(FOCUSABLE);
|
|
29
139
|
(first || panel).focus();
|
|
30
|
-
return () =>
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
}, [open]);
|
|
140
|
+
return () => previous.current && previous.current.focus && previous.current.focus();
|
|
141
|
+
}, [ctx && ctx.open]);
|
|
34
142
|
React.useEffect(() => {
|
|
35
|
-
if (!open) return;
|
|
36
|
-
const
|
|
143
|
+
if (!ctx || !ctx.open) return;
|
|
144
|
+
const key = e => {
|
|
37
145
|
if (e.key === 'Escape') {
|
|
38
|
-
if (
|
|
146
|
+
if (onEscapeKeyDown) onEscapeKeyDown(e);
|
|
147
|
+
if (!e.defaultPrevented) ctx.setOpen(false);
|
|
39
148
|
return;
|
|
40
149
|
}
|
|
41
150
|
if (e.key !== 'Tab') return;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
if (!f.length) {
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
151
|
+
const f = [...panelRef.current.querySelectorAll(FOCUSABLE)].filter(x => !x.disabled);
|
|
152
|
+
if (!f.length) return e.preventDefault();
|
|
48
153
|
const i = f.indexOf(document.activeElement);
|
|
49
154
|
if (e.shiftKey && i <= 0) {
|
|
50
155
|
e.preventDefault();
|
|
51
156
|
f[f.length - 1].focus();
|
|
52
|
-
} else if (!e.shiftKey && (i
|
|
157
|
+
} else if (!e.shiftKey && (i < 0 || i === f.length - 1)) {
|
|
53
158
|
e.preventDefault();
|
|
54
159
|
f[0].focus();
|
|
55
160
|
}
|
|
56
161
|
};
|
|
57
|
-
document.addEventListener('keydown',
|
|
58
|
-
return () => document.removeEventListener('keydown',
|
|
59
|
-
}, [open,
|
|
60
|
-
if (!open) return null;
|
|
61
|
-
return /*#__PURE__*/React.createElement(
|
|
62
|
-
ref:
|
|
63
|
-
}, rest, {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
onMouseDown: e => {
|
|
67
|
-
if (e.target === e.currentTarget && onClose) onClose();
|
|
68
|
-
}
|
|
69
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
70
|
-
className: "ef-dialog",
|
|
162
|
+
document.addEventListener('keydown', key);
|
|
163
|
+
return () => document.removeEventListener('keydown', key);
|
|
164
|
+
}, [ctx && ctx.open, onEscapeKeyDown]);
|
|
165
|
+
if (!ctx || !ctx.open) return null;
|
|
166
|
+
return /*#__PURE__*/React.createElement(DialogPortal, null, /*#__PURE__*/React.createElement(DialogOverlay, _extends({}, overlayProps, {
|
|
167
|
+
ref: overlayRef
|
|
168
|
+
}), /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
169
|
+
ref: mergeRefs(ref, panelRef),
|
|
170
|
+
"data-slot": slot,
|
|
71
171
|
role: "dialog",
|
|
72
172
|
"aria-modal": "true",
|
|
73
|
-
|
|
173
|
+
"aria-labelledby": rest['aria-label'] ? undefined : ctx.titleId,
|
|
174
|
+
"aria-describedby": ctx.descriptionId,
|
|
74
175
|
tabIndex: -1,
|
|
75
|
-
|
|
76
|
-
"aria-describedby": description ? descId : undefined,
|
|
176
|
+
className: cx('ef-dialog__content', className),
|
|
77
177
|
style: {
|
|
78
|
-
|
|
178
|
+
position: 'relative',
|
|
179
|
+
maxWidth: width,
|
|
180
|
+
...style
|
|
79
181
|
}
|
|
80
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
81
|
-
className: "ef-
|
|
82
|
-
}, /*#__PURE__*/React.createElement(
|
|
83
|
-
className: "ef-dialog__title",
|
|
84
|
-
id: titleId
|
|
85
|
-
}, title), description ? /*#__PURE__*/React.createElement("div", {
|
|
86
|
-
className: "ef-dialog__desc",
|
|
87
|
-
id: descId
|
|
88
|
-
}, description) : null), onClose ? /*#__PURE__*/React.createElement(IconButton, {
|
|
182
|
+
}), children, showCloseButton ? /*#__PURE__*/React.createElement("div", {
|
|
183
|
+
className: "ef-dialog__close"
|
|
184
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
89
185
|
icon: "x",
|
|
90
186
|
label: closeLabel,
|
|
91
187
|
size: "sm",
|
|
92
|
-
onClick:
|
|
93
|
-
}) : null)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
188
|
+
onClick: () => ctx.setOpen(false)
|
|
189
|
+
})) : null)));
|
|
190
|
+
});
|
|
191
|
+
export const DialogHeader = /*#__PURE__*/React.forwardRef(function DialogHeader({
|
|
192
|
+
className,
|
|
193
|
+
slot = 'dialog-header',
|
|
194
|
+
...rest
|
|
195
|
+
}, ref) {
|
|
196
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
197
|
+
ref: ref,
|
|
198
|
+
"data-slot": slot,
|
|
199
|
+
className: cx('ef-dialog__header', className)
|
|
200
|
+
}));
|
|
201
|
+
});
|
|
202
|
+
export const DialogFooter = /*#__PURE__*/React.forwardRef(function DialogFooter({
|
|
203
|
+
className,
|
|
204
|
+
slot = 'dialog-footer',
|
|
205
|
+
...rest
|
|
206
|
+
}, ref) {
|
|
207
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
208
|
+
ref: ref,
|
|
209
|
+
"data-slot": slot,
|
|
210
|
+
className: cx('ef-dialog__footer', className)
|
|
211
|
+
}));
|
|
212
|
+
});
|
|
213
|
+
export const DialogTitle = /*#__PURE__*/React.forwardRef(function DialogTitle({
|
|
214
|
+
className,
|
|
215
|
+
id,
|
|
216
|
+
slot = 'dialog-title',
|
|
217
|
+
...rest
|
|
218
|
+
}, ref) {
|
|
219
|
+
const ctx = React.useContext(DialogContext);
|
|
220
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
221
|
+
ref: ref,
|
|
222
|
+
id: id || ctx && ctx.titleId,
|
|
223
|
+
"data-slot": slot,
|
|
224
|
+
className: cx('ef-dialog__title', className)
|
|
225
|
+
}));
|
|
226
|
+
});
|
|
227
|
+
export const DialogDescription = /*#__PURE__*/React.forwardRef(function DialogDescription({
|
|
228
|
+
className,
|
|
229
|
+
id,
|
|
230
|
+
slot = 'dialog-description',
|
|
231
|
+
...rest
|
|
232
|
+
}, ref) {
|
|
233
|
+
const ctx = React.useContext(DialogContext);
|
|
234
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
235
|
+
ref: ref,
|
|
236
|
+
id: id || ctx && ctx.descriptionId,
|
|
237
|
+
"data-slot": slot,
|
|
238
|
+
className: cx('ef-dialog__description', className)
|
|
239
|
+
}));
|
|
98
240
|
});
|
package/feedback/Progress.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
export interface ProgressProps {
|
|
2
|
-
/**
|
|
3
|
-
value?: number;
|
|
4
|
-
/** @default 100 */
|
|
1
|
+
export interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
2
|
+
/** Current value. Omit or pass null for an indeterminate progress bar. */
|
|
3
|
+
value?: number | null;
|
|
4
|
+
/** Positive maximum value. @default 100 */
|
|
5
5
|
max?: number;
|
|
6
|
+
/** Optional integrated label retained for Meridian consumers. */
|
|
6
7
|
label?: string;
|
|
7
|
-
/** Show value
|
|
8
|
+
/** Show a formatted value beside the integrated label. */
|
|
8
9
|
showValue?: boolean;
|
|
9
10
|
format?: (value: number, max: number) => string;
|
|
10
|
-
/** @default 'default'
|
|
11
|
+
/** Optional semantic tone retained for Meridian consumers. @default 'default' */
|
|
11
12
|
tone?: 'default' | 'warning' | 'danger';
|
|
12
|
-
style?: React.CSSProperties;
|
|
13
|
-
className?: string;
|
|
14
13
|
}
|
|
15
|
-
export declare
|
|
14
|
+
export declare const Progress: React.ForwardRefExoticComponent<ProgressProps & React.RefAttributes<HTMLDivElement>>;
|
package/feedback/Progress.js
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
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
|
-
|
|
5
|
-
|
|
4
|
+
function classes(...values) {
|
|
5
|
+
return values.filter(Boolean).join(' ');
|
|
6
|
+
}
|
|
7
|
+
export const Progress = /*#__PURE__*/React.forwardRef(function Progress({
|
|
8
|
+
value,
|
|
6
9
|
max = 100,
|
|
7
10
|
label,
|
|
8
11
|
showValue,
|
|
9
12
|
format,
|
|
10
13
|
tone = 'default',
|
|
11
|
-
style,
|
|
12
14
|
className,
|
|
15
|
+
style,
|
|
13
16
|
...rest
|
|
14
|
-
}) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
}, ref) {
|
|
18
|
+
const safeMax = Number.isFinite(max) && max > 0 ? max : 100;
|
|
19
|
+
const determinate = Number.isFinite(value);
|
|
20
|
+
const safeValue = determinate ? Math.min(safeMax, Math.max(0, value)) : null;
|
|
21
|
+
const percent = determinate ? safeValue / safeMax * 100 : 0;
|
|
22
|
+
const state = !determinate ? 'indeterminate' : safeValue === safeMax ? 'complete' : 'loading';
|
|
23
|
+
const generatedLabelId = React.useId();
|
|
24
|
+
const labelledBy = rest['aria-labelledby'] ?? (label ? generatedLabelId : undefined);
|
|
25
|
+
const track = /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
26
|
+
ref: ref,
|
|
20
27
|
role: "progressbar",
|
|
21
|
-
"
|
|
28
|
+
"data-slot": "progress",
|
|
29
|
+
"data-state": state,
|
|
30
|
+
"data-value": safeValue ?? undefined,
|
|
31
|
+
"data-max": safeMax,
|
|
32
|
+
"data-tone": tone,
|
|
22
33
|
"aria-valuemin": 0,
|
|
23
|
-
"aria-valuemax":
|
|
24
|
-
"aria-
|
|
25
|
-
|
|
34
|
+
"aria-valuemax": safeMax,
|
|
35
|
+
"aria-valuenow": safeValue ?? undefined,
|
|
36
|
+
"aria-labelledby": labelledBy,
|
|
37
|
+
className: classes('ef-progress', className),
|
|
38
|
+
style: style
|
|
39
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
"data-slot": "progress-indicator",
|
|
41
|
+
"data-state": state,
|
|
42
|
+
className: "ef-progress__indicator",
|
|
43
|
+
style: determinate ? {
|
|
44
|
+
transform: `translateX(calc(-100% + ${percent}%))`
|
|
45
|
+
} : undefined
|
|
46
|
+
}));
|
|
47
|
+
if (!label && !showValue) return track;
|
|
48
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: "ef-progress-shell"
|
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
26
51
|
className: "ef-progress__head"
|
|
27
52
|
}, /*#__PURE__*/React.createElement("span", {
|
|
28
|
-
id:
|
|
53
|
+
id: label ? generatedLabelId : undefined,
|
|
29
54
|
className: "ef-progress__label"
|
|
30
|
-
}, label), showValue ? /*#__PURE__*/React.createElement("span", {
|
|
55
|
+
}, label), showValue && determinate ? /*#__PURE__*/React.createElement("span", {
|
|
31
56
|
className: "ef-progress__val"
|
|
32
|
-
}, format ? format(
|
|
33
|
-
|
|
34
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
35
|
-
className: "ef-progress__fill",
|
|
36
|
-
style: {
|
|
37
|
-
width: pct + '%'
|
|
38
|
-
}
|
|
39
|
-
})));
|
|
40
|
-
}
|
|
57
|
+
}, format ? format(safeValue, safeMax) : `${Math.round(percent)}%`) : null), track);
|
|
58
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
3
|
+
export interface ToastAction { label: React.ReactNode; onClick: () => void }
|
|
4
|
+
export interface ExternalToast { id?: string | number; description?: React.ReactNode | ((value: unknown) => React.ReactNode); duration?: number; action?: React.ReactNode | ToastAction; closeButton?: boolean }
|
|
5
|
+
export interface ToastFunction { (message: React.ReactNode, options?: ExternalToast): string | number; success(message: React.ReactNode, options?: ExternalToast): string | number; info(message: React.ReactNode, options?: ExternalToast): string | number; warning(message: React.ReactNode, options?: ExternalToast): string | number; error(message: React.ReactNode, options?: ExternalToast): string | number; loading(message: React.ReactNode, options?: ExternalToast): string | number; custom(message: React.ReactElement, options?: ExternalToast): string | number; message(message: React.ReactNode, options?: ExternalToast): string | number; dismiss(id?: string | number): void; promise<T>(promise: Promise<T> | (() => Promise<T>), data: { loading?: React.ReactNode; success?: React.ReactNode | ((value: T) => React.ReactNode); error?: React.ReactNode | ((error: unknown) => React.ReactNode); description?: React.ReactNode | ((value: T) => React.ReactNode); duration?: number }): string | number }
|
|
6
|
+
export const toast: ToastFunction;
|
|
7
|
+
export interface ToasterProps extends React.HTMLAttributes<HTMLDivElement> { position?: ToastPosition; visibleToasts?: number; closeButton?: boolean; richColors?: boolean; duration?: number; toastOptions?: ExternalToast; expand?: boolean; theme?: 'light' | 'dark' | 'system'; dir?: 'ltr' | 'rtl'; gap?: number; offset?: number | string; mobileOffset?: number | string; label?: string; children?: React.ReactNode }
|
|
8
|
+
export function Toaster(props: ToasterProps): React.JSX.Element;
|
|
@@ -0,0 +1,238 @@
|
|
|
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 { IconButton } from "../forms/IconButton.js";
|
|
6
|
+
import { Portal } from "../overlay/Portal.js";
|
|
7
|
+
const ICONS = {
|
|
8
|
+
success: 'circle-check',
|
|
9
|
+
danger: 'circle-alert',
|
|
10
|
+
warning: 'triangle-alert',
|
|
11
|
+
info: 'info'
|
|
12
|
+
};
|
|
13
|
+
function SonnerToast({
|
|
14
|
+
tone = 'info',
|
|
15
|
+
title,
|
|
16
|
+
description,
|
|
17
|
+
action,
|
|
18
|
+
onClose,
|
|
19
|
+
role = 'status',
|
|
20
|
+
style,
|
|
21
|
+
className,
|
|
22
|
+
...rest
|
|
23
|
+
}) {
|
|
24
|
+
const actionNode = /*#__PURE__*/React.isValidElement(action) ? action : action && typeof action === 'object' ? /*#__PURE__*/React.createElement("button", {
|
|
25
|
+
className: "ef-toast__action",
|
|
26
|
+
onClick: action.onClick
|
|
27
|
+
}, action.label) : action ? /*#__PURE__*/React.createElement("span", {
|
|
28
|
+
className: "ef-toast__action"
|
|
29
|
+
}, action) : null;
|
|
30
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
31
|
+
"data-slot": "toast",
|
|
32
|
+
className: `ef-toast ef-toast--${tone}${className ? ` ${className}` : ''}`,
|
|
33
|
+
role: role || undefined,
|
|
34
|
+
style: style
|
|
35
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
36
|
+
className: "ef-toast__icon",
|
|
37
|
+
"aria-hidden": "true"
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
39
|
+
name: ICONS[tone] || 'info',
|
|
40
|
+
size: 18
|
|
41
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
style: {
|
|
43
|
+
flex: 1
|
|
44
|
+
}
|
|
45
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "ef-toast__title"
|
|
47
|
+
}, title), description ? /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "ef-toast__desc"
|
|
49
|
+
}, description) : null, actionNode), onClose ? /*#__PURE__*/React.createElement(IconButton, {
|
|
50
|
+
icon: "x",
|
|
51
|
+
label: "Dismiss",
|
|
52
|
+
size: "sm",
|
|
53
|
+
onClick: onClose
|
|
54
|
+
}) : null);
|
|
55
|
+
}
|
|
56
|
+
function SonnerStack({
|
|
57
|
+
children,
|
|
58
|
+
position = 'bottom-right',
|
|
59
|
+
style,
|
|
60
|
+
className,
|
|
61
|
+
...rest
|
|
62
|
+
}) {
|
|
63
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
64
|
+
"data-slot": "toaster",
|
|
65
|
+
"data-position": position,
|
|
66
|
+
className: `ef-toast-stack${className ? ` ${className}` : ''}`,
|
|
67
|
+
style: style
|
|
68
|
+
}), children);
|
|
69
|
+
}
|
|
70
|
+
let records = [];
|
|
71
|
+
let sequence = 0;
|
|
72
|
+
let defaultDuration = 5000;
|
|
73
|
+
let defaultToastOptions = {};
|
|
74
|
+
const listeners = new Set();
|
|
75
|
+
const timers = new Map();
|
|
76
|
+
const emit = () => listeners.forEach(listener => listener(records));
|
|
77
|
+
const resolve = (value, payload) => typeof value === 'function' ? value(payload) : value;
|
|
78
|
+
function dismiss(id) {
|
|
79
|
+
if (id == null) {
|
|
80
|
+
timers.forEach(timer => clearTimeout(timer.handle));
|
|
81
|
+
timers.clear();
|
|
82
|
+
records = [];
|
|
83
|
+
} else {
|
|
84
|
+
const timer = timers.get(id);
|
|
85
|
+
if (timer?.handle) clearTimeout(timer.handle);
|
|
86
|
+
timers.delete(id);
|
|
87
|
+
records = records.filter(item => item.id !== id);
|
|
88
|
+
}
|
|
89
|
+
emit();
|
|
90
|
+
}
|
|
91
|
+
function schedule(id, duration) {
|
|
92
|
+
if (!(duration > 0)) return;
|
|
93
|
+
const timer = {
|
|
94
|
+
remaining: duration,
|
|
95
|
+
startedAt: Date.now(),
|
|
96
|
+
handle: null
|
|
97
|
+
};
|
|
98
|
+
timer.handle = setTimeout(() => dismiss(id), duration);
|
|
99
|
+
timers.set(id, timer);
|
|
100
|
+
}
|
|
101
|
+
function create(message, options = {}, type = 'default') {
|
|
102
|
+
const merged = {
|
|
103
|
+
...defaultToastOptions,
|
|
104
|
+
...options
|
|
105
|
+
};
|
|
106
|
+
const id = merged.id ?? `toast-${++sequence}`;
|
|
107
|
+
const next = {
|
|
108
|
+
...merged,
|
|
109
|
+
id,
|
|
110
|
+
title: message,
|
|
111
|
+
type
|
|
112
|
+
};
|
|
113
|
+
const previous = timers.get(id);
|
|
114
|
+
if (previous?.handle) clearTimeout(previous.handle);
|
|
115
|
+
timers.delete(id);
|
|
116
|
+
records = records.some(item => item.id === id) ? records.map(item => item.id === id ? next : item) : [...records, next];
|
|
117
|
+
schedule(id, merged.duration ?? (type === 'loading' ? 0 : defaultDuration));
|
|
118
|
+
emit();
|
|
119
|
+
return id;
|
|
120
|
+
}
|
|
121
|
+
export function toast(message, options) {
|
|
122
|
+
return create(message, options);
|
|
123
|
+
}
|
|
124
|
+
toast.success = (message, options) => create(message, options, 'success');
|
|
125
|
+
toast.info = (message, options) => create(message, options, 'info');
|
|
126
|
+
toast.warning = (message, options) => create(message, options, 'warning');
|
|
127
|
+
toast.error = (message, options) => create(message, options, 'error');
|
|
128
|
+
toast.loading = (message, options) => create(message, {
|
|
129
|
+
...options,
|
|
130
|
+
duration: options?.duration ?? 0
|
|
131
|
+
}, 'loading');
|
|
132
|
+
toast.custom = (message, options) => create(message, options, 'custom');
|
|
133
|
+
toast.message = toast;
|
|
134
|
+
toast.dismiss = dismiss;
|
|
135
|
+
toast.promise = (promise, data = {}) => {
|
|
136
|
+
const id = toast.loading(resolve(data.loading));
|
|
137
|
+
Promise.resolve(typeof promise === 'function' ? promise() : promise).then(value => create(resolve(data.success, value), {
|
|
138
|
+
id,
|
|
139
|
+
description: resolve(data.description, value),
|
|
140
|
+
duration: data.duration
|
|
141
|
+
}, 'success'), error => create(resolve(data.error, error), {
|
|
142
|
+
id,
|
|
143
|
+
description: error?.message,
|
|
144
|
+
duration: data.duration
|
|
145
|
+
}, 'error'));
|
|
146
|
+
return id;
|
|
147
|
+
};
|
|
148
|
+
function pause() {
|
|
149
|
+
timers.forEach(timer => {
|
|
150
|
+
if (!timer.handle) return;
|
|
151
|
+
clearTimeout(timer.handle);
|
|
152
|
+
timer.remaining = Math.max(0, timer.remaining - (Date.now() - timer.startedAt));
|
|
153
|
+
timer.handle = null;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function resume() {
|
|
157
|
+
const expired = [];
|
|
158
|
+
timers.forEach((timer, id) => {
|
|
159
|
+
if (timer.handle) return;
|
|
160
|
+
if (timer.remaining <= 0) {
|
|
161
|
+
expired.push(id);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
timer.startedAt = Date.now();
|
|
165
|
+
timer.handle = setTimeout(() => dismiss(id), timer.remaining);
|
|
166
|
+
});
|
|
167
|
+
expired.forEach(dismiss);
|
|
168
|
+
}
|
|
169
|
+
export function Toaster({
|
|
170
|
+
position = 'bottom-right',
|
|
171
|
+
visibleToasts = 3,
|
|
172
|
+
closeButton = false,
|
|
173
|
+
richColors = false,
|
|
174
|
+
duration = 5000,
|
|
175
|
+
toastOptions = {},
|
|
176
|
+
expand = false,
|
|
177
|
+
theme = 'system',
|
|
178
|
+
dir,
|
|
179
|
+
gap = 10,
|
|
180
|
+
offset,
|
|
181
|
+
mobileOffset,
|
|
182
|
+
label = 'Notifications',
|
|
183
|
+
children,
|
|
184
|
+
style,
|
|
185
|
+
...rest
|
|
186
|
+
}) {
|
|
187
|
+
const [items, setItems] = React.useState(records);
|
|
188
|
+
React.useEffect(() => {
|
|
189
|
+
const listener = value => setItems(value);
|
|
190
|
+
listeners.add(listener);
|
|
191
|
+
listener(records);
|
|
192
|
+
return () => listeners.delete(listener);
|
|
193
|
+
}, []);
|
|
194
|
+
React.useEffect(() => {
|
|
195
|
+
defaultDuration = duration;
|
|
196
|
+
defaultToastOptions = toastOptions;
|
|
197
|
+
return () => {
|
|
198
|
+
defaultDuration = 5000;
|
|
199
|
+
defaultToastOptions = {};
|
|
200
|
+
};
|
|
201
|
+
}, [duration, toastOptions]);
|
|
202
|
+
const resolvedOffset = typeof offset === 'number' ? `${offset}px` : offset;
|
|
203
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(SonnerStack, _extends({}, rest, {
|
|
204
|
+
dir: dir,
|
|
205
|
+
position: position,
|
|
206
|
+
"data-rich-colors": richColors ? 'true' : 'false',
|
|
207
|
+
"data-expand": expand ? 'true' : 'false',
|
|
208
|
+
"data-theme": theme,
|
|
209
|
+
"data-mobile-offset": typeof mobileOffset === 'number' ? `${mobileOffset}px` : mobileOffset,
|
|
210
|
+
style: {
|
|
211
|
+
gap,
|
|
212
|
+
...(position.startsWith('top') ? {
|
|
213
|
+
top: resolvedOffset
|
|
214
|
+
} : {
|
|
215
|
+
bottom: resolvedOffset
|
|
216
|
+
}),
|
|
217
|
+
...style
|
|
218
|
+
},
|
|
219
|
+
"aria-label": label,
|
|
220
|
+
role: "log",
|
|
221
|
+
"aria-live": "polite",
|
|
222
|
+
"aria-relevant": "additions",
|
|
223
|
+
onMouseEnter: pause,
|
|
224
|
+
onMouseLeave: resume,
|
|
225
|
+
onFocusCapture: pause,
|
|
226
|
+
onBlurCapture: resume
|
|
227
|
+
}), items.slice(-visibleToasts).map(item => item.type === 'custom' && /*#__PURE__*/React.isValidElement(item.title) ? /*#__PURE__*/React.cloneElement(item.title, {
|
|
228
|
+
key: item.id
|
|
229
|
+
}) : /*#__PURE__*/React.createElement(SonnerToast, {
|
|
230
|
+
key: item.id,
|
|
231
|
+
tone: item.type === 'error' ? 'danger' : ['success', 'warning', 'info'].includes(item.type) ? item.type : 'info',
|
|
232
|
+
title: item.title,
|
|
233
|
+
description: item.description,
|
|
234
|
+
action: item.action,
|
|
235
|
+
role: null,
|
|
236
|
+
onClose: closeButton || item.closeButton ? () => dismiss(item.id) : undefined
|
|
237
|
+
})))));
|
|
238
|
+
}
|
package/feedback/Spinner.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
size?: number;
|
|
4
|
-
/** Optional text right of the spinner (also the aria-label) */
|
|
5
|
-
label?: string;
|
|
6
|
-
style?: React.CSSProperties;
|
|
7
|
-
className?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function Spinner(props: SpinnerProps): React.JSX.Element;
|
|
1
|
+
export type SpinnerProps = React.SVGProps<SVGSVGElement>;
|
|
2
|
+
export declare const Spinner: React.ForwardRefExoticComponent<SpinnerProps & React.RefAttributes<SVGSVGElement>>;
|