@constructive-io/ui 0.3.0 → 0.3.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.
- package/dist/components/card.d.ts +1 -1
- package/dist/components/toast/index.js +435 -32
- package/dist/components/toast/index.js.map +1 -1
- package/dist/index.cjs +99 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +100 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { VariantProps } from 'class-variance-authority';
|
|
5
5
|
|
|
6
6
|
declare const cardVariants: (props?: ({
|
|
7
|
-
variant?: "
|
|
7
|
+
variant?: "default" | "flat" | "elevated" | "ghost" | "interactive" | null | undefined;
|
|
8
8
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
9
|
interface CardProps extends React.ComponentProps<'div'>, VariantProps<typeof cardVariants> {
|
|
10
10
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import * as React3 from 'react';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { InfoIcon, XIcon, CheckCircleIcon, AlertTriangleIcon, AlertCircleIcon, CheckIcon, CopyIcon } from 'lucide-react';
|
|
3
5
|
import { toast } from 'sonner';
|
|
4
|
-
import * as React from 'react';
|
|
5
6
|
import { cva } from 'class-variance-authority';
|
|
6
7
|
import { clsx } from 'clsx';
|
|
7
8
|
import { twMerge } from 'tailwind-merge';
|
|
8
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
10
|
+
import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
|
|
11
|
+
import { ScrollArea as ScrollArea$1 } from '@base-ui/react/scroll-area';
|
|
9
12
|
|
|
10
13
|
// src/components/toast/toast-error.tsx
|
|
11
14
|
function cn(...inputs) {
|
|
@@ -43,12 +46,12 @@ var buttonVariants = cva(
|
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
);
|
|
46
|
-
var Button =
|
|
49
|
+
var Button = React3.forwardRef(
|
|
47
50
|
({ className, variant, size, asChild, children, type = "button", ...props }, ref) => {
|
|
48
51
|
const buttonClasses = cn(buttonVariants({ className, size, variant }));
|
|
49
|
-
if (asChild &&
|
|
52
|
+
if (asChild && React3.isValidElement(children)) {
|
|
50
53
|
const childProps = children.props;
|
|
51
|
-
return
|
|
54
|
+
return React3.cloneElement(children, {
|
|
52
55
|
...props,
|
|
53
56
|
className: cn(buttonClasses, childProps.className),
|
|
54
57
|
"data-slot": "button"
|
|
@@ -58,37 +61,437 @@ var Button = React.forwardRef(
|
|
|
58
61
|
}
|
|
59
62
|
);
|
|
60
63
|
Button.displayName = "Button";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
var PORTAL_ROOT_ID = "portal-root";
|
|
65
|
+
var PortalContext = React3.createContext({
|
|
66
|
+
layer: "base",
|
|
67
|
+
depth: 0,
|
|
68
|
+
floatingPortalStrategy: "root",
|
|
69
|
+
floatingZIndex: "default"
|
|
70
|
+
});
|
|
71
|
+
function ModalPortalScope({
|
|
72
|
+
children,
|
|
73
|
+
floatingPortalStrategy = "nested",
|
|
74
|
+
floatingZIndex = "default"
|
|
75
|
+
}) {
|
|
76
|
+
const parentContext = React3.useContext(PortalContext);
|
|
77
|
+
const depth = parentContext.layer === "modal" ? parentContext.depth + 1 : 0;
|
|
78
|
+
const value = React3.useMemo(
|
|
79
|
+
() => ({
|
|
80
|
+
layer: "modal",
|
|
81
|
+
depth,
|
|
82
|
+
floatingPortalStrategy,
|
|
83
|
+
floatingZIndex
|
|
84
|
+
}),
|
|
85
|
+
[depth, floatingPortalStrategy, floatingZIndex]
|
|
86
|
+
);
|
|
87
|
+
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
88
|
+
}
|
|
89
|
+
function useRootPortalContainer() {
|
|
90
|
+
const [container, setContainer] = React3.useState(null);
|
|
91
|
+
React3.useLayoutEffect(() => {
|
|
92
|
+
const el = document.getElementById(PORTAL_ROOT_ID);
|
|
93
|
+
setContainer(el);
|
|
94
|
+
}, []);
|
|
95
|
+
return container;
|
|
96
|
+
}
|
|
97
|
+
function composeRefs(...refs) {
|
|
98
|
+
return (node) => {
|
|
99
|
+
refs.forEach((ref) => {
|
|
100
|
+
if (typeof ref === "function") {
|
|
101
|
+
ref(node);
|
|
102
|
+
} else if (ref != null) {
|
|
103
|
+
ref.current = node;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function mergeProps(slotProps, childProps) {
|
|
109
|
+
const overrideProps = { ...childProps };
|
|
110
|
+
for (const propName in childProps) {
|
|
111
|
+
if (propName === "ref") continue;
|
|
112
|
+
const slotPropValue = slotProps[propName];
|
|
113
|
+
const childPropValue = childProps[propName];
|
|
114
|
+
if (/^on[A-Z]/.test(propName) && typeof slotPropValue === "function" && typeof childPropValue === "function") {
|
|
115
|
+
overrideProps[propName] = (...args) => {
|
|
116
|
+
childPropValue(...args);
|
|
117
|
+
slotPropValue(...args);
|
|
118
|
+
};
|
|
119
|
+
} else if (propName === "className" && typeof slotPropValue === "string" && typeof childPropValue === "string") {
|
|
120
|
+
overrideProps[propName] = `${slotPropValue} ${childPropValue}`.trim();
|
|
121
|
+
} else if (propName === "style" && typeof slotPropValue === "object" && typeof childPropValue === "object") {
|
|
122
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return { ...slotProps, ...overrideProps };
|
|
126
|
+
}
|
|
127
|
+
function mergePropsWithRef(parentProps, childElement) {
|
|
128
|
+
const childProps = childElement.props;
|
|
129
|
+
const parentRef = parentProps.ref;
|
|
130
|
+
const childRef = childProps.ref;
|
|
131
|
+
const mergedProps = mergeProps(parentProps, childProps);
|
|
132
|
+
if (parentRef || childRef) {
|
|
133
|
+
mergedProps.ref = composeRefs(parentRef, childRef);
|
|
134
|
+
}
|
|
135
|
+
return mergedProps;
|
|
136
|
+
}
|
|
137
|
+
function isSlottable(child) {
|
|
138
|
+
return React3.isValidElement(child);
|
|
139
|
+
}
|
|
140
|
+
var Slot = React3.forwardRef((props, forwardedRef) => {
|
|
141
|
+
const { children, ...slotProps } = props;
|
|
142
|
+
if (isSlottable(children)) {
|
|
143
|
+
const childProps = children.props;
|
|
144
|
+
const childRef = childProps.ref;
|
|
145
|
+
return React3.cloneElement(children, {
|
|
146
|
+
...mergeProps(slotProps, childProps),
|
|
147
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (React3.Children.count(children) > 1) {
|
|
151
|
+
const childrenArray = React3.Children.toArray(children);
|
|
152
|
+
const slottableChild = childrenArray.find(
|
|
153
|
+
(child) => React3.isValidElement(child) && child.type === Slottable
|
|
154
|
+
);
|
|
155
|
+
if (slottableChild) {
|
|
156
|
+
const newElement = slottableChild.props.children;
|
|
157
|
+
if (isSlottable(newElement)) {
|
|
158
|
+
const newElementProps = newElement.props;
|
|
159
|
+
const newChildren = childrenArray.map((child) => {
|
|
160
|
+
if (child === slottableChild) {
|
|
161
|
+
return React3.Children.count(newElementProps.children) > 1 ? React3.Children.only(null) : newElementProps.children;
|
|
162
|
+
}
|
|
163
|
+
return child;
|
|
164
|
+
});
|
|
165
|
+
const childRef = newElementProps.ref;
|
|
166
|
+
return React3.cloneElement(newElement, {
|
|
167
|
+
...mergeProps(slotProps, newElementProps),
|
|
168
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef,
|
|
169
|
+
children: newChildren
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
175
|
+
});
|
|
176
|
+
Slot.displayName = "Slot";
|
|
177
|
+
function Slottable({ children }) {
|
|
178
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
179
|
+
}
|
|
180
|
+
var ScrollArea = React3.forwardRef(
|
|
181
|
+
({ className, children, scrollFade = false, scrollbarGutter = false, ...props }, ref) => {
|
|
182
|
+
return /* @__PURE__ */ jsxs(
|
|
183
|
+
ScrollArea$1.Root,
|
|
184
|
+
{
|
|
185
|
+
ref,
|
|
186
|
+
className: cn("size-full min-h-0", className),
|
|
187
|
+
...props,
|
|
188
|
+
children: [
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
ScrollArea$1.Viewport,
|
|
191
|
+
{
|
|
192
|
+
className: cn(
|
|
193
|
+
"h-full overscroll-contain rounded-[inherit] outline-none transition-shadows focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
194
|
+
scrollFade && "mask-t-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-start)))] mask-b-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-end)))] mask-l-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-start)))] mask-r-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-end)))] [--fade-size:1.5rem]",
|
|
195
|
+
scrollbarGutter && "data-has-overflow-y:pe-2.5 data-has-overflow-x:pb-2.5"
|
|
196
|
+
),
|
|
197
|
+
"data-slot": "scroll-area-viewport",
|
|
198
|
+
children
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
/* @__PURE__ */ jsx(ScrollBar, { orientation: "vertical" }),
|
|
202
|
+
/* @__PURE__ */ jsx(ScrollBar, { orientation: "horizontal" }),
|
|
203
|
+
/* @__PURE__ */ jsx(ScrollArea$1.Corner, { "data-slot": "scroll-area-corner" })
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
ScrollArea.displayName = "ScrollArea";
|
|
210
|
+
function ScrollBar({
|
|
211
|
+
className,
|
|
212
|
+
orientation = "vertical",
|
|
213
|
+
...props
|
|
214
|
+
}) {
|
|
215
|
+
return /* @__PURE__ */ jsx(
|
|
216
|
+
ScrollArea$1.Scrollbar,
|
|
65
217
|
{
|
|
66
|
-
className:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
218
|
+
className: cn(
|
|
219
|
+
"m-1 flex opacity-0 transition-opacity delay-300 data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5 data-[orientation=horizontal]:flex-col data-hovering:opacity-100 data-scrolling:opacity-100 data-hovering:delay-0 data-scrolling:delay-0 data-hovering:duration-100 data-scrolling:duration-100",
|
|
220
|
+
className
|
|
221
|
+
),
|
|
222
|
+
"data-slot": "scroll-area-scrollbar",
|
|
223
|
+
orientation,
|
|
224
|
+
...props,
|
|
225
|
+
children: /* @__PURE__ */ jsx(
|
|
226
|
+
ScrollArea$1.Thumb,
|
|
227
|
+
{
|
|
228
|
+
className: "relative flex-1 rounded-full bg-foreground/20",
|
|
229
|
+
"data-slot": "scroll-area-thumb"
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
var Dialog = Dialog$1.Root;
|
|
236
|
+
function DialogPortal({ keepMounted = true, ...props }) {
|
|
237
|
+
const container = useRootPortalContainer();
|
|
238
|
+
const style = {
|
|
239
|
+
...props.style ?? {},
|
|
240
|
+
// Ensure floating overlays inside dialogs (select/menu/popover/tooltip) stack above the dialog.
|
|
241
|
+
// Nested Base UI portals inherit this var via Base UI portal nesting.
|
|
242
|
+
["--z-layer-floating"]: "var(--z-layer-floating-elevated)"
|
|
243
|
+
};
|
|
244
|
+
return /* @__PURE__ */ jsx(Dialog$1.Portal, { keepMounted, container, ...props, style });
|
|
245
|
+
}
|
|
246
|
+
function DialogClose({ asChild, nativeButton, children, ...props }) {
|
|
247
|
+
if (asChild && React3.isValidElement(children)) {
|
|
248
|
+
return /* @__PURE__ */ jsx(
|
|
249
|
+
Dialog$1.Close,
|
|
250
|
+
{
|
|
251
|
+
"data-slot": "dialog-close",
|
|
252
|
+
nativeButton: nativeButton ?? true,
|
|
253
|
+
...props,
|
|
254
|
+
render: (closeProps) => {
|
|
255
|
+
const { nativeButton: _, ...rest } = closeProps;
|
|
256
|
+
return React3.cloneElement(
|
|
257
|
+
children,
|
|
258
|
+
mergePropsWithRef(rest, children)
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
return /* @__PURE__ */ jsx(Dialog$1.Close, { "data-slot": "dialog-close", nativeButton, ...props, children });
|
|
265
|
+
}
|
|
266
|
+
function DialogBackdrop({
|
|
267
|
+
className,
|
|
268
|
+
...props
|
|
269
|
+
}) {
|
|
270
|
+
return /* @__PURE__ */ jsx(
|
|
271
|
+
Dialog$1.Backdrop,
|
|
272
|
+
{
|
|
273
|
+
className: cn(
|
|
274
|
+
"fixed inset-0 z-[var(--z-layer-modal-backdrop)] bg-black/32 backdrop-blur-sm transition-opacity duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",
|
|
275
|
+
className
|
|
276
|
+
),
|
|
277
|
+
"data-slot": "dialog-backdrop",
|
|
278
|
+
...props
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
function DialogViewport({
|
|
283
|
+
className,
|
|
284
|
+
...props
|
|
285
|
+
}) {
|
|
286
|
+
return /* @__PURE__ */ jsx(
|
|
287
|
+
Dialog$1.Viewport,
|
|
288
|
+
{
|
|
289
|
+
className: cn(
|
|
290
|
+
"fixed inset-0 z-[var(--z-layer-modal-content)] grid grid-rows-[1fr_auto_3fr] justify-items-center p-4",
|
|
291
|
+
className
|
|
292
|
+
),
|
|
293
|
+
"data-slot": "dialog-viewport",
|
|
294
|
+
...props
|
|
295
|
+
}
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
function DialogPopup({
|
|
299
|
+
className,
|
|
300
|
+
children,
|
|
301
|
+
showCloseButton = true,
|
|
302
|
+
bottomStickOnMobile = true,
|
|
303
|
+
...props
|
|
304
|
+
}) {
|
|
305
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
306
|
+
/* @__PURE__ */ jsx(DialogBackdrop, {}),
|
|
307
|
+
/* @__PURE__ */ jsx(
|
|
308
|
+
DialogViewport,
|
|
309
|
+
{
|
|
310
|
+
className: cn(
|
|
311
|
+
bottomStickOnMobile && "max-sm:grid-rows-[1fr_auto] max-sm:pt-12"
|
|
312
|
+
),
|
|
313
|
+
children: /* @__PURE__ */ jsxs(
|
|
314
|
+
Dialog$1.Popup,
|
|
78
315
|
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
children:
|
|
316
|
+
className: cn(
|
|
317
|
+
"-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]",
|
|
318
|
+
bottomStickOnMobile && "max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none",
|
|
319
|
+
className
|
|
320
|
+
),
|
|
321
|
+
"data-slot": "dialog-popup",
|
|
322
|
+
...props,
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ jsx(ModalPortalScope, { children }),
|
|
325
|
+
showCloseButton && /* @__PURE__ */ jsx(
|
|
326
|
+
Dialog$1.Close,
|
|
327
|
+
{
|
|
328
|
+
"aria-label": "Close",
|
|
329
|
+
nativeButton: true,
|
|
330
|
+
render: (closeProps) => {
|
|
331
|
+
const { nativeButton: _, ...rest } = closeProps;
|
|
332
|
+
return /* @__PURE__ */ jsx(
|
|
333
|
+
Button,
|
|
334
|
+
{
|
|
335
|
+
...rest,
|
|
336
|
+
className: "absolute end-2 top-2",
|
|
337
|
+
size: "icon",
|
|
338
|
+
variant: "ghost",
|
|
339
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
]
|
|
87
346
|
}
|
|
88
347
|
)
|
|
89
|
-
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
] });
|
|
351
|
+
}
|
|
352
|
+
function DialogHeader({ className, ...props }) {
|
|
353
|
+
return /* @__PURE__ */ jsx(
|
|
354
|
+
"div",
|
|
355
|
+
{
|
|
356
|
+
className: cn(
|
|
357
|
+
"flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4",
|
|
358
|
+
className
|
|
359
|
+
),
|
|
360
|
+
"data-slot": "dialog-header",
|
|
361
|
+
...props
|
|
90
362
|
}
|
|
91
|
-
)
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
function DialogFooter({
|
|
366
|
+
className,
|
|
367
|
+
variant = "default",
|
|
368
|
+
...props
|
|
369
|
+
}) {
|
|
370
|
+
return /* @__PURE__ */ jsx(
|
|
371
|
+
"div",
|
|
372
|
+
{
|
|
373
|
+
className: cn(
|
|
374
|
+
"flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]",
|
|
375
|
+
variant === "default" && "border-t bg-muted/50 py-4",
|
|
376
|
+
variant === "bare" && "in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pt-3 pt-4 pb-6",
|
|
377
|
+
className
|
|
378
|
+
),
|
|
379
|
+
"data-slot": "dialog-footer",
|
|
380
|
+
...props
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
function DialogTitle({ className, ...props }) {
|
|
385
|
+
return /* @__PURE__ */ jsx(
|
|
386
|
+
Dialog$1.Title,
|
|
387
|
+
{
|
|
388
|
+
className: cn("font-heading text-xl leading-none", className),
|
|
389
|
+
"data-slot": "dialog-title",
|
|
390
|
+
...props
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
function DialogPanel({ className, ...props }) {
|
|
395
|
+
return /* @__PURE__ */ jsx(ScrollArea, { children: /* @__PURE__ */ jsx(
|
|
396
|
+
"div",
|
|
397
|
+
{
|
|
398
|
+
className: cn(
|
|
399
|
+
"px-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-header])]:pt-1 in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-header]))]:pt-6 in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-footer]))]:pb-6! in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-footer].border-t))]:pb-1 pb-6",
|
|
400
|
+
className
|
|
401
|
+
),
|
|
402
|
+
"data-slot": "dialog-panel",
|
|
403
|
+
...props
|
|
404
|
+
}
|
|
405
|
+
) });
|
|
406
|
+
}
|
|
407
|
+
var LONG_DESCRIPTION_THRESHOLD = 140;
|
|
408
|
+
function isLongDescription(description) {
|
|
409
|
+
if (!description) return false;
|
|
410
|
+
return description.length > LONG_DESCRIPTION_THRESHOLD || description.includes("\n");
|
|
411
|
+
}
|
|
412
|
+
function ToastErrorContent({
|
|
413
|
+
toastId,
|
|
414
|
+
message,
|
|
415
|
+
description,
|
|
416
|
+
action,
|
|
417
|
+
onDismiss
|
|
418
|
+
}) {
|
|
419
|
+
const [detailsOpen, setDetailsOpen] = useState(false);
|
|
420
|
+
const [copied, setCopied] = useState(false);
|
|
421
|
+
const showDetails = isLongDescription(description);
|
|
422
|
+
const handleCopy = async () => {
|
|
423
|
+
if (!description) return;
|
|
424
|
+
try {
|
|
425
|
+
await navigator.clipboard.writeText(description);
|
|
426
|
+
setCopied(true);
|
|
427
|
+
setTimeout(() => setCopied(false), 1500);
|
|
428
|
+
} catch {
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
432
|
+
/* @__PURE__ */ jsx(
|
|
433
|
+
"div",
|
|
434
|
+
{
|
|
435
|
+
className: "bg-background text-foreground border-destructive/20 w-full rounded-md border px-4 py-3 shadow-lg\n sm:w-[var(--width)]",
|
|
436
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
437
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow gap-3", children: [
|
|
438
|
+
/* @__PURE__ */ jsx(AlertCircleIcon, { className: "text-destructive mt-0.5 shrink-0", size: 16, "aria-hidden": "true" }),
|
|
439
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow flex-col gap-1", children: [
|
|
440
|
+
/* @__PURE__ */ jsx("p", { className: "text-destructive text-sm font-medium break-words", children: message }),
|
|
441
|
+
description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground line-clamp-3 text-sm break-words", children: description }),
|
|
442
|
+
(showDetails || action) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
443
|
+
showDetails && /* @__PURE__ */ jsx(
|
|
444
|
+
"button",
|
|
445
|
+
{
|
|
446
|
+
className: "text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2 decoration-dotted",
|
|
447
|
+
onClick: () => setDetailsOpen(true),
|
|
448
|
+
children: "View details"
|
|
449
|
+
}
|
|
450
|
+
),
|
|
451
|
+
action && /* @__PURE__ */ jsx(
|
|
452
|
+
"button",
|
|
453
|
+
{
|
|
454
|
+
className: "text-destructive text-sm font-medium hover:underline",
|
|
455
|
+
onClick: action.onClick,
|
|
456
|
+
children: action.label
|
|
457
|
+
}
|
|
458
|
+
)
|
|
459
|
+
] })
|
|
460
|
+
] })
|
|
461
|
+
] }),
|
|
462
|
+
/* @__PURE__ */ jsx(
|
|
463
|
+
Button,
|
|
464
|
+
{
|
|
465
|
+
variant: "ghost",
|
|
466
|
+
className: "group -my-1.5 -me-2 size-8 shrink-0 p-0 hover:bg-transparent",
|
|
467
|
+
onClick: () => {
|
|
468
|
+
toast.dismiss(toastId);
|
|
469
|
+
onDismiss?.();
|
|
470
|
+
},
|
|
471
|
+
"aria-label": "Close error notification",
|
|
472
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: 16, className: "opacity-60 transition-opacity group-hover:opacity-100", "aria-hidden": "true" })
|
|
473
|
+
}
|
|
474
|
+
)
|
|
475
|
+
] })
|
|
476
|
+
}
|
|
477
|
+
),
|
|
478
|
+
showDetails && description && /* @__PURE__ */ jsx(Dialog, { open: detailsOpen, onOpenChange: setDetailsOpen, children: /* @__PURE__ */ jsxs(DialogPopup, { className: "max-w-2xl", children: [
|
|
479
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: message }) }),
|
|
480
|
+
/* @__PURE__ */ jsx(DialogPanel, { children: /* @__PURE__ */ jsx("pre", { className: "bg-muted text-foreground rounded-md p-3 text-xs break-words whitespace-pre-wrap", children: description }) }),
|
|
481
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
482
|
+
/* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: handleCopy, children: [
|
|
483
|
+
copied ? /* @__PURE__ */ jsx(CheckIcon, { size: 14, "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CopyIcon, { size: 14, "aria-hidden": "true" }),
|
|
484
|
+
copied ? "Copied" : "Copy"
|
|
485
|
+
] }),
|
|
486
|
+
/* @__PURE__ */ jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "sm", children: "Close" }) })
|
|
487
|
+
] })
|
|
488
|
+
] }) })
|
|
489
|
+
] });
|
|
490
|
+
}
|
|
491
|
+
function showErrorToast(props) {
|
|
492
|
+
return toast.custom((t) => /* @__PURE__ */ jsx(ToastErrorContent, { toastId: t, ...props }), {
|
|
493
|
+
duration: Infinity
|
|
494
|
+
});
|
|
92
495
|
}
|
|
93
496
|
function showInfoToast(props) {
|
|
94
497
|
const { message, description, action, onDismiss } = props;
|