@efolusi/meridian 1.20.0 → 1.21.1

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.
Files changed (183) hide show
  1. package/README.md +1 -1
  2. package/ai/Bubble.d.ts +16 -0
  3. package/ai/Bubble.js +71 -0
  4. package/ai/ChatMessage.js +2 -5
  5. package/ai/Confirmation.d.ts +0 -7
  6. package/ai/Confirmation.js +3 -6
  7. package/ai/GeneratedImage.d.ts +0 -2
  8. package/ai/GeneratedImage.js +2 -4
  9. package/ai/Marker.d.ts +26 -0
  10. package/ai/Marker.js +67 -0
  11. package/ai/Message.d.ts +13 -0
  12. package/ai/Message.js +68 -0
  13. package/ai/MessageScroller.d.ts +21 -0
  14. package/ai/MessageScroller.js +283 -0
  15. package/ai/ModelSelector.d.ts +2 -2
  16. package/ai/ModelSelector.js +1 -2
  17. package/ai/Player.js +1 -1
  18. package/ai/PromptSteps.js +4 -2
  19. package/ai/Sandbox.d.ts +0 -2
  20. package/ai/Sandbox.js +2 -4
  21. package/ai/Suggestions.d.ts +0 -2
  22. package/ai/Suggestions.js +1 -4
  23. package/ai/WebPreview.d.ts +0 -2
  24. package/ai/WebPreview.js +2 -4
  25. package/code/Console.js +1 -1
  26. package/code/EnvList.d.ts +0 -2
  27. package/code/EnvList.js +2 -3
  28. package/components.css +652 -418
  29. package/data/BarChart.d.ts +0 -2
  30. package/data/BarChart.js +1 -4
  31. package/data/Chart.d.ts +14 -0
  32. package/data/Chart.js +149 -0
  33. package/data/EmptyState.d.ts +8 -13
  34. package/data/EmptyState.js +62 -24
  35. package/data/LineChart.js +7 -4
  36. package/data/Skeleton.d.ts +2 -11
  37. package/data/Skeleton.js +8 -38
  38. package/data/Sparkline.js +4 -1
  39. package/data/StatusDot.d.ts +0 -4
  40. package/data/StatusDot.js +3 -6
  41. package/data/Table.d.ts +11 -4
  42. package/data/Table.js +39 -7
  43. package/dates/Calendar.d.ts +10 -27
  44. package/dates/Calendar.js +250 -184
  45. package/dates/TimePicker.js +2 -2
  46. package/display/Accordion.d.ts +47 -15
  47. package/display/Accordion.js +257 -27
  48. package/display/AspectRatio.d.ts +4 -6
  49. package/display/AspectRatio.js +7 -5
  50. package/display/Avatar.d.ts +17 -14
  51. package/display/Avatar.js +68 -43
  52. package/display/Badge.d.ts +9 -8
  53. package/display/Badge.js +32 -14
  54. package/display/Card.d.ts +11 -13
  55. package/display/Card.js +74 -29
  56. package/display/Carousel.d.ts +23 -15
  57. package/display/Carousel.js +217 -66
  58. package/display/Collapsible.d.ts +19 -9
  59. package/display/Collapsible.js +140 -28
  60. package/display/Direction.d.ts +10 -0
  61. package/display/Direction.js +24 -0
  62. package/display/Item.d.ts +19 -0
  63. package/display/Item.js +152 -0
  64. package/display/Kbd.d.ts +5 -7
  65. package/display/Kbd.js +22 -10
  66. package/display/Link.js +2 -4
  67. package/display/Resizable.d.ts +6 -16
  68. package/display/Resizable.js +141 -58
  69. package/display/ScrollArea.d.ts +3 -1
  70. package/display/ScrollArea.js +30 -5
  71. package/display/Separator.d.ts +9 -0
  72. package/display/Separator.js +18 -0
  73. package/display/Timeline.d.ts +24 -0
  74. package/display/Timeline.js +51 -0
  75. package/display/Toolbar.js +5 -4
  76. package/display/TreeList.d.ts +0 -2
  77. package/display/TreeList.js +2 -5
  78. package/feedback/Alert.d.ts +13 -13
  79. package/feedback/Alert.js +40 -36
  80. package/feedback/AlertDialog.d.ts +30 -0
  81. package/feedback/AlertDialog.js +249 -0
  82. package/feedback/Banner.d.ts +1 -3
  83. package/feedback/Banner.js +1 -5
  84. package/feedback/ConfirmDialog.d.ts +1 -1
  85. package/feedback/ConfirmDialog.js +18 -20
  86. package/feedback/Dialog.d.ts +13 -16
  87. package/feedback/Dialog.js +204 -62
  88. package/feedback/Progress.d.ts +8 -9
  89. package/feedback/Progress.js +42 -24
  90. package/feedback/Sonner.d.ts +8 -0
  91. package/feedback/Sonner.js +238 -0
  92. package/feedback/Spinner.d.ts +2 -9
  93. package/feedback/Spinner.js +19 -28
  94. package/feedback/Tooltip.d.ts +9 -10
  95. package/feedback/Tooltip.js +147 -96
  96. package/files/Attachment.d.ts +27 -0
  97. package/files/Attachment.js +111 -0
  98. package/files/FileDrop.js +3 -1
  99. package/finance/PaymentCard.js +3 -3
  100. package/forms/Button.d.ts +6 -5
  101. package/forms/Button.js +22 -8
  102. package/forms/ButtonGroup.d.ts +11 -3
  103. package/forms/ButtonGroup.js +57 -6
  104. package/forms/Checkbox.d.ts +14 -3
  105. package/forms/Checkbox.js +84 -16
  106. package/forms/Combobox.d.ts +24 -16
  107. package/forms/Combobox.js +466 -135
  108. package/forms/Field.d.ts +14 -0
  109. package/forms/Field.js +99 -0
  110. package/forms/IconButton.d.ts +1 -1
  111. package/forms/IconButton.js +4 -3
  112. package/forms/Input.d.ts +8 -8
  113. package/forms/Input.js +46 -33
  114. package/forms/InputGroup.d.ts +8 -15
  115. package/forms/InputGroup.js +74 -35
  116. package/forms/InputOTP.d.ts +13 -0
  117. package/forms/InputOTP.js +125 -0
  118. package/forms/Label.d.ts +2 -6
  119. package/forms/Label.js +6 -4
  120. package/forms/NativeSelect.d.ts +16 -0
  121. package/forms/NativeSelect.js +35 -0
  122. package/forms/NumberInput.js +2 -2
  123. package/forms/Radio.d.ts +12 -1
  124. package/forms/Radio.js +76 -6
  125. package/forms/Select.d.ts +12 -9
  126. package/forms/Select.js +254 -42
  127. package/forms/Slider.d.ts +10 -17
  128. package/forms/Slider.js +78 -39
  129. package/forms/Switch.d.ts +8 -2
  130. package/forms/Switch.js +46 -15
  131. package/forms/Textarea.d.ts +1 -1
  132. package/forms/Textarea.js +26 -18
  133. package/forms/Toggle.d.ts +18 -15
  134. package/forms/Toggle.js +96 -42
  135. package/icons/_svg.js +2 -0
  136. package/index.d.ts +20 -8
  137. package/index.js +50 -38
  138. package/navigation/Breadcrumbs.d.ts +18 -11
  139. package/navigation/Breadcrumbs.js +99 -26
  140. package/navigation/Menubar.d.ts +52 -10
  141. package/navigation/Menubar.js +191 -146
  142. package/navigation/NavigationMenu.d.ts +15 -0
  143. package/navigation/NavigationMenu.js +296 -0
  144. package/navigation/Pagination.d.ts +10 -9
  145. package/navigation/Pagination.js +94 -51
  146. package/navigation/SideNav.js +4 -3
  147. package/navigation/Sidebar.d.ts +29 -0
  148. package/navigation/Sidebar.js +311 -0
  149. package/navigation/Tabs.d.ts +9 -5
  150. package/navigation/Tabs.js +132 -44
  151. package/overlay/Command.d.ts +32 -0
  152. package/overlay/Command.js +257 -0
  153. package/overlay/ContextMenu.d.ts +40 -8
  154. package/overlay/ContextMenu.js +468 -107
  155. package/overlay/Drawer.d.ts +29 -14
  156. package/overlay/Drawer.js +178 -80
  157. package/overlay/DropdownMenu.d.ts +43 -0
  158. package/overlay/DropdownMenu.js +502 -0
  159. package/overlay/HoverCard.d.ts +21 -12
  160. package/overlay/HoverCard.js +129 -61
  161. package/overlay/Popover.d.ts +11 -13
  162. package/overlay/Popover.js +138 -65
  163. package/overlay/Portal.js +21 -7
  164. package/overlay/Sheet.d.ts +11 -0
  165. package/overlay/Sheet.js +62 -0
  166. package/package.json +4 -1
  167. package/tokens/base.css +1 -1
  168. package/dates/DatePicker.d.ts +0 -14
  169. package/dates/DatePicker.js +0 -111
  170. package/dates/DateRangePicker.d.ts +0 -23
  171. package/dates/DateRangePicker.js +0 -150
  172. package/display/ListItem.d.ts +0 -19
  173. package/display/ListItem.js +0 -50
  174. package/feedback/Toast.d.ts +0 -78
  175. package/feedback/Toast.js +0 -192
  176. package/forms/DigitEntry.d.ts +0 -15
  177. package/forms/DigitEntry.js +0 -79
  178. package/forms/FormField.d.ts +0 -82
  179. package/forms/FormField.js +0 -209
  180. package/overlay/CommandPalette.d.ts +0 -21
  181. package/overlay/CommandPalette.js +0 -148
  182. package/overlay/Menu.d.ts +0 -24
  183. package/overlay/Menu.js +0 -139
@@ -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
- export const Dialog = /*#__PURE__*/React.forwardRef(function Dialog({
8
- open,
9
- onClose,
10
- closeLabel = 'Close',
11
- title,
12
- description,
13
- footer,
14
- width = 440,
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 prevFocus = React.useRef(null);
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
- prevFocus.current = document.activeElement;
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
- if (prevFocus.current && prevFocus.current.focus) prevFocus.current.focus();
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 onKey = e => {
143
+ if (!ctx || !ctx.open) return;
144
+ const key = e => {
37
145
  if (e.key === 'Escape') {
38
- if (onClose) onClose();
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 panel = panelRef.current;
43
- const f = panel ? Array.from(panel.querySelectorAll(FOCUSABLE)).filter(el => !el.disabled) : [];
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 === -1 || i === f.length - 1)) {
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', onKey);
58
- return () => document.removeEventListener('keydown', onKey);
59
- }, [open, onClose]);
60
- if (!open) return null;
61
- return /*#__PURE__*/React.createElement("div", _extends({
62
- ref: ref
63
- }, rest, {
64
- className: `ef-dialog__overlay${className ? ' ' + className : ''}`,
65
- style: style,
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
- ref: panelRef,
173
+ "aria-labelledby": rest['aria-label'] ? undefined : ctx.titleId,
174
+ "aria-describedby": ctx.descriptionId,
74
175
  tabIndex: -1,
75
- "aria-labelledby": title ? titleId : undefined,
76
- "aria-describedby": description ? descId : undefined,
176
+ className: cx('ef-dialog__content', className),
77
177
  style: {
78
- maxWidth: width
178
+ position: 'relative',
179
+ maxWidth: width,
180
+ ...style
79
181
  }
80
- }, /*#__PURE__*/React.createElement("div", {
81
- className: "ef-dialog__head"
82
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
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: onClose
93
- }) : null), /*#__PURE__*/React.createElement("div", {
94
- className: "ef-dialog__body"
95
- }, children), footer ? /*#__PURE__*/React.createElement("div", {
96
- className: "ef-dialog__foot"
97
- }, footer) : null));
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("h2", _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
  });
@@ -1,15 +1,14 @@
1
- export interface ProgressProps {
2
- /** @default 0 */
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 right of the label (default = percent) */
8
+ /** Show a formatted value beside the integrated label. */
8
9
  showValue?: boolean;
9
10
  format?: (value: number, max: number) => string;
10
- /** @default 'default' (ink) */
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 function Progress(props: ProgressProps): React.JSX.Element;
14
+ export declare const Progress: React.ForwardRefExoticComponent<ProgressProps & React.RefAttributes<HTMLDivElement>>;
@@ -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
- export function Progress({
5
- value = 0,
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 pct = Math.min(100, Math.max(0, value / max * 100));
16
- const labelId = React.useId();
17
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
18
- className: `ef-progress ef-progress--${tone}${className ? ' ' + className : ''}`,
19
- style: style,
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
- "aria-valuenow": value,
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": max,
24
- "aria-labelledby": label ? labelId : undefined
25
- }), (label || showValue) && /*#__PURE__*/React.createElement("div", {
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: labelId,
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(value, max) : Math.round(pct) + '%') : null), /*#__PURE__*/React.createElement("div", {
33
- className: "ef-progress__track"
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
+ }
@@ -1,9 +1,2 @@
1
- export interface SpinnerProps {
2
- /** Px @default 16 */
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>>;