@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
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { Radio as Radio$1 } from '@base-ui/react/radio';
|
|
|
13
13
|
import { RadioGroup as RadioGroup$1 } from '@base-ui/react/radio-group';
|
|
14
14
|
import { Switch as Switch$1 } from '@base-ui/react/switch';
|
|
15
15
|
import { Select as Select$1 } from '@base-ui/react/select';
|
|
16
|
-
import { ChevronsUpDownIcon, XCircle, XIcon, ChevronDown, SearchIcon, CheckIcon, Ellipsis, Pencil, Trash2, ChevronRight, ChevronUpIcon, ChevronDownIcon, CircleIcon, ChevronRightIcon, X, GripVerticalIcon, ChevronLeftIcon, MoreHorizontalIcon, LoaderCircleIcon, PanelLeftIcon, WandSparkles,
|
|
16
|
+
import { ChevronsUpDownIcon, XCircle, XIcon, ChevronDown, SearchIcon, CheckIcon, Ellipsis, Pencil, Trash2, ChevronRight, ChevronUpIcon, ChevronDownIcon, CircleIcon, ChevronRightIcon, X, GripVerticalIcon, ChevronLeftIcon, MoreHorizontalIcon, LoaderCircleIcon, PanelLeftIcon, WandSparkles, InfoIcon, CheckCircleIcon, AlertTriangleIcon, Loader2, AlertCircleIcon, CopyIcon, CircleAlert, CheckCircle2, Network, UserPlus } from 'lucide-react';
|
|
17
17
|
import { Progress as Progress$1 } from '@base-ui/react/progress';
|
|
18
18
|
import { FormProvider, Controller, useFormContext, useFormState } from 'react-hook-form';
|
|
19
19
|
import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
|
|
@@ -1682,6 +1682,19 @@ function DialogDescription({
|
|
|
1682
1682
|
}
|
|
1683
1683
|
);
|
|
1684
1684
|
}
|
|
1685
|
+
function DialogPanel({ className, ...props }) {
|
|
1686
|
+
return /* @__PURE__ */ jsx(ScrollArea, { children: /* @__PURE__ */ jsx(
|
|
1687
|
+
"div",
|
|
1688
|
+
{
|
|
1689
|
+
className: cn(
|
|
1690
|
+
"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",
|
|
1691
|
+
className
|
|
1692
|
+
),
|
|
1693
|
+
"data-slot": "dialog-panel",
|
|
1694
|
+
...props
|
|
1695
|
+
}
|
|
1696
|
+
) });
|
|
1697
|
+
}
|
|
1685
1698
|
function AlertDialog({ ...props }) {
|
|
1686
1699
|
return /* @__PURE__ */ jsx(AlertDialog$1.Root, { "data-slot": "alert-dialog", ...props });
|
|
1687
1700
|
}
|
|
@@ -7224,37 +7237,94 @@ function DefaultCardSkeleton() {
|
|
|
7224
7237
|
] })
|
|
7225
7238
|
] });
|
|
7226
7239
|
}
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7240
|
+
var LONG_DESCRIPTION_THRESHOLD = 140;
|
|
7241
|
+
function isLongDescription(description) {
|
|
7242
|
+
if (!description) return false;
|
|
7243
|
+
return description.length > LONG_DESCRIPTION_THRESHOLD || description.includes("\n");
|
|
7244
|
+
}
|
|
7245
|
+
function ToastErrorContent({
|
|
7246
|
+
toastId,
|
|
7247
|
+
message,
|
|
7248
|
+
description,
|
|
7249
|
+
action,
|
|
7250
|
+
onDismiss
|
|
7251
|
+
}) {
|
|
7252
|
+
const [detailsOpen, setDetailsOpen] = useState(false);
|
|
7253
|
+
const [copied, setCopied] = useState(false);
|
|
7254
|
+
const showDetails = isLongDescription(description);
|
|
7255
|
+
const handleCopy = async () => {
|
|
7256
|
+
if (!description) return;
|
|
7257
|
+
try {
|
|
7258
|
+
await navigator.clipboard.writeText(description);
|
|
7259
|
+
setCopied(true);
|
|
7260
|
+
setTimeout(() => setCopied(false), 1500);
|
|
7261
|
+
} catch {
|
|
7262
|
+
}
|
|
7263
|
+
};
|
|
7264
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7265
|
+
/* @__PURE__ */ jsx(
|
|
7266
|
+
"div",
|
|
7267
|
+
{
|
|
7268
|
+
className: "bg-background text-foreground border-destructive/20 w-full rounded-md border px-4 py-3 shadow-lg\n sm:w-[var(--width)]",
|
|
7269
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
7270
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow gap-3", children: [
|
|
7271
|
+
/* @__PURE__ */ jsx(AlertCircleIcon, { className: "text-destructive mt-0.5 shrink-0", size: 16, "aria-hidden": "true" }),
|
|
7272
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow flex-col gap-1", children: [
|
|
7273
|
+
/* @__PURE__ */ jsx("p", { className: "text-destructive text-sm font-medium break-words", children: message }),
|
|
7274
|
+
description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground line-clamp-3 text-sm break-words", children: description }),
|
|
7275
|
+
(showDetails || action) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
7276
|
+
showDetails && /* @__PURE__ */ jsx(
|
|
7277
|
+
"button",
|
|
7278
|
+
{
|
|
7279
|
+
className: "text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2 decoration-dotted",
|
|
7280
|
+
onClick: () => setDetailsOpen(true),
|
|
7281
|
+
children: "View details"
|
|
7282
|
+
}
|
|
7283
|
+
),
|
|
7284
|
+
action && /* @__PURE__ */ jsx(
|
|
7285
|
+
"button",
|
|
7286
|
+
{
|
|
7287
|
+
className: "text-destructive text-sm font-medium hover:underline",
|
|
7288
|
+
onClick: action.onClick,
|
|
7289
|
+
children: action.label
|
|
7290
|
+
}
|
|
7291
|
+
)
|
|
7292
|
+
] })
|
|
7293
|
+
] })
|
|
7294
|
+
] }),
|
|
7295
|
+
/* @__PURE__ */ jsx(
|
|
7296
|
+
Button,
|
|
7297
|
+
{
|
|
7298
|
+
variant: "ghost",
|
|
7299
|
+
className: "group -my-1.5 -me-2 size-8 shrink-0 p-0 hover:bg-transparent",
|
|
7300
|
+
onClick: () => {
|
|
7301
|
+
toast.dismiss(toastId);
|
|
7302
|
+
onDismiss?.();
|
|
7303
|
+
},
|
|
7304
|
+
"aria-label": "Close error notification",
|
|
7305
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: 16, className: "opacity-60 transition-opacity group-hover:opacity-100", "aria-hidden": "true" })
|
|
7306
|
+
}
|
|
7307
|
+
)
|
|
7308
|
+
] })
|
|
7309
|
+
}
|
|
7310
|
+
),
|
|
7311
|
+
showDetails && description && /* @__PURE__ */ jsx(Dialog, { open: detailsOpen, onOpenChange: setDetailsOpen, children: /* @__PURE__ */ jsxs(DialogPopup, { className: "max-w-2xl", children: [
|
|
7312
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: message }) }),
|
|
7313
|
+
/* @__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 }) }),
|
|
7314
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
7315
|
+
/* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: handleCopy, children: [
|
|
7316
|
+
copied ? /* @__PURE__ */ jsx(CheckIcon, { size: 14, "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CopyIcon, { size: 14, "aria-hidden": "true" }),
|
|
7317
|
+
copied ? "Copied" : "Copy"
|
|
7241
7318
|
] }),
|
|
7242
|
-
/* @__PURE__ */ jsx(
|
|
7243
|
-
Button,
|
|
7244
|
-
{
|
|
7245
|
-
variant: "ghost",
|
|
7246
|
-
className: "group -my-1.5 -me-2 size-8 shrink-0 p-0 hover:bg-transparent",
|
|
7247
|
-
onClick: () => {
|
|
7248
|
-
toast.dismiss(t);
|
|
7249
|
-
onDismiss?.();
|
|
7250
|
-
},
|
|
7251
|
-
"aria-label": "Close error notification",
|
|
7252
|
-
children: /* @__PURE__ */ jsx(XIcon, { size: 16, className: "opacity-60 transition-opacity group-hover:opacity-100", "aria-hidden": "true" })
|
|
7253
|
-
}
|
|
7254
|
-
)
|
|
7319
|
+
/* @__PURE__ */ jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "sm", children: "Close" }) })
|
|
7255
7320
|
] })
|
|
7256
|
-
}
|
|
7257
|
-
)
|
|
7321
|
+
] }) })
|
|
7322
|
+
] });
|
|
7323
|
+
}
|
|
7324
|
+
function showErrorToast(props) {
|
|
7325
|
+
return toast.custom((t) => /* @__PURE__ */ jsx(ToastErrorContent, { toastId: t, ...props }), {
|
|
7326
|
+
duration: Infinity
|
|
7327
|
+
});
|
|
7258
7328
|
}
|
|
7259
7329
|
function showInfoToast(props) {
|
|
7260
7330
|
const { message, description, action, onDismiss } = props;
|