@gerege-systems/ui 0.14.0 → 0.15.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/dist-lib/components/ui/Accordion.js +1 -1
- package/dist-lib/components/ui/Accordion.js.map +1 -1
- package/dist-lib/components/ui/Alert.js +1 -1
- package/dist-lib/components/ui/Alert.js.map +1 -1
- package/dist-lib/components/ui/Avatar.js +1 -0
- package/dist-lib/components/ui/Avatar.js.map +1 -1
- package/dist-lib/components/ui/Breadcrumbs.js +6 -6
- package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
- package/dist-lib/components/ui/Button.js +9 -8
- package/dist-lib/components/ui/Button.js.map +1 -1
- package/dist-lib/components/ui/Calendar.js +3 -3
- package/dist-lib/components/ui/Calendar.js.map +1 -1
- package/dist-lib/components/ui/Card.js +7 -7
- package/dist-lib/components/ui/Card.js.map +1 -1
- package/dist-lib/components/ui/Carousel.js +1 -1
- package/dist-lib/components/ui/Carousel.js.map +1 -1
- package/dist-lib/components/ui/Chart.js +1 -1
- package/dist-lib/components/ui/Chart.js.map +1 -1
- package/dist-lib/components/ui/Checkbox.js +1 -1
- package/dist-lib/components/ui/Checkbox.js.map +1 -1
- package/dist-lib/components/ui/Combobox.js +12 -12
- package/dist-lib/components/ui/Combobox.js.map +1 -1
- package/dist-lib/components/ui/CommandPalette.js +8 -8
- package/dist-lib/components/ui/CommandPalette.js.map +1 -1
- package/dist-lib/components/ui/ContextMenu.js +1 -1
- package/dist-lib/components/ui/ContextMenu.js.map +1 -1
- package/dist-lib/components/ui/DataGrid.d.ts +7 -2
- package/dist-lib/components/ui/DataGrid.js +66 -54
- package/dist-lib/components/ui/DataGrid.js.map +1 -1
- package/dist-lib/components/ui/DatePicker.js +2 -2
- package/dist-lib/components/ui/DatePicker.js.map +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.js +25 -25
- package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
- package/dist-lib/components/ui/Dialog.d.ts +5 -1
- package/dist-lib/components/ui/Dialog.js +55 -58
- package/dist-lib/components/ui/Dialog.js.map +1 -1
- package/dist-lib/components/ui/Drawer.js +18 -18
- package/dist-lib/components/ui/Drawer.js.map +1 -1
- package/dist-lib/components/ui/DropdownMenu.js +1 -1
- package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
- package/dist-lib/components/ui/ErrorState.d.ts +5 -3
- package/dist-lib/components/ui/ErrorState.js +1 -1
- package/dist-lib/components/ui/ErrorState.js.map +1 -1
- package/dist-lib/components/ui/FileUpload.d.ts +6 -0
- package/dist-lib/components/ui/FileUpload.js +61 -56
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/IconButton.js +7 -7
- package/dist-lib/components/ui/IconButton.js.map +1 -1
- package/dist-lib/components/ui/Input.js +7 -7
- package/dist-lib/components/ui/Input.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +61 -60
- package/dist-lib/components/ui/MultiSelect.js.map +1 -1
- package/dist-lib/components/ui/Pagination.js +21 -21
- package/dist-lib/components/ui/Pagination.js.map +1 -1
- package/dist-lib/components/ui/Popover.js +4 -4
- package/dist-lib/components/ui/Popover.js.map +1 -1
- package/dist-lib/components/ui/RadioGroup.js +9 -9
- package/dist-lib/components/ui/RadioGroup.js.map +1 -1
- package/dist-lib/components/ui/RelativeTime.d.ts +5 -1
- package/dist-lib/components/ui/RelativeTime.js +23 -19
- package/dist-lib/components/ui/RelativeTime.js.map +1 -1
- package/dist-lib/components/ui/ScrollArea.js +11 -11
- package/dist-lib/components/ui/ScrollArea.js.map +1 -1
- package/dist-lib/components/ui/Select.js +29 -29
- package/dist-lib/components/ui/Select.js.map +1 -1
- package/dist-lib/components/ui/Sheet.js +1 -1
- package/dist-lib/components/ui/Sheet.js.map +1 -1
- package/dist-lib/components/ui/Sidebar.d.ts +3 -1
- package/dist-lib/components/ui/Sidebar.js +111 -107
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +29 -29
- package/dist-lib/components/ui/Slider.js.map +1 -1
- package/dist-lib/components/ui/Snackbar.js +28 -19
- package/dist-lib/components/ui/Snackbar.js.map +1 -1
- package/dist-lib/components/ui/Switch.js +7 -7
- package/dist-lib/components/ui/Switch.js.map +1 -1
- package/dist-lib/components/ui/Table.js +6 -6
- package/dist-lib/components/ui/Table.js.map +1 -1
- package/dist-lib/components/ui/Tabs.js +6 -6
- package/dist-lib/components/ui/Tabs.js.map +1 -1
- package/dist-lib/components/ui/TagInput.js +3 -3
- package/dist-lib/components/ui/TagInput.js.map +1 -1
- package/dist-lib/components/ui/Textarea.js +1 -1
- package/dist-lib/components/ui/Textarea.js.map +1 -1
- package/dist-lib/components/ui/Toast.js +8 -8
- package/dist-lib/components/ui/Toast.js.map +1 -1
- package/dist-lib/components/ui/TopNav.js +9 -9
- package/dist-lib/components/ui/TopNav.js.map +1 -1
- package/dist-lib/components/ui/Tree.js +2 -2
- package/dist-lib/components/ui/Tree.js.map +1 -1
- package/dist-lib/lib/strings.d.ts +4 -0
- package/dist-lib/lib/strings.js +3 -1
- package/dist-lib/lib/strings.js.map +1 -1
- package/dist-lib/lib/strings.mn.js +3 -1
- package/dist-lib/lib/strings.mn.js.map +1 -1
- package/dist-lib/styles.css +1 -1
- package/dist-lib/theme.css +67 -49
- package/package.json +1 -1
|
@@ -51,7 +51,11 @@ export interface ConfirmationDialogProps {
|
|
|
51
51
|
onConfirm: () => void | Promise<void>;
|
|
52
52
|
/** Force the submitting state from outside (in addition to the awaited `onConfirm`). */
|
|
53
53
|
loading?: boolean;
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Map a rejected `onConfirm` to the message shown. Without it the generic
|
|
56
|
+
* `errorState.genericDescription` string is shown — never `Error.message`,
|
|
57
|
+
* which is usually server or library text not meant for the user.
|
|
58
|
+
*/
|
|
55
59
|
formatError?: (err: unknown) => ReactNode;
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
3
|
-
import { useState as b, forwardRef as
|
|
3
|
+
import { useState as b, forwardRef as g } from "react";
|
|
4
4
|
import * as n from "@radix-ui/react-dialog";
|
|
5
5
|
import { X as S } from "../../icons/index.js";
|
|
6
6
|
import { cn as r } from "../../lib/utils.js";
|
|
7
7
|
import { useStrings as C } from "../../hooks/use-strings.js";
|
|
8
8
|
import { Button as N } from "./Button.js";
|
|
9
9
|
import { withReturnFocus as k } from "../../lib/return-focus.js";
|
|
10
|
-
const B = n.Root, Q = n.Trigger,
|
|
10
|
+
const B = n.Root, Q = n.Trigger, H = n.Portal, A = n.Close, w = g(function({ className: t, ...i }, a) {
|
|
11
11
|
return /* @__PURE__ */ e(
|
|
12
12
|
n.Overlay,
|
|
13
13
|
{
|
|
14
14
|
"data-slot": "dialog-overlay",
|
|
15
|
-
ref:
|
|
15
|
+
ref: a,
|
|
16
16
|
className: r(
|
|
17
17
|
"bg-overlay fixed inset-0 z-[var(--z-overlay)]",
|
|
18
18
|
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
19
19
|
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
20
|
-
|
|
20
|
+
t
|
|
21
21
|
),
|
|
22
22
|
...i
|
|
23
23
|
}
|
|
24
24
|
);
|
|
25
25
|
});
|
|
26
26
|
w.displayName = "DialogOverlay";
|
|
27
|
-
const z =
|
|
28
|
-
const
|
|
29
|
-
return /* @__PURE__ */ s(
|
|
27
|
+
const z = g(function({ className: t, children: i, showClose: a = !0, size: l = "md", returnFocusTo: m, onCloseAutoFocus: u, ...f }, p) {
|
|
28
|
+
const d = C();
|
|
29
|
+
return /* @__PURE__ */ s(H, { children: [
|
|
30
30
|
/* @__PURE__ */ e(w, {}),
|
|
31
31
|
/* @__PURE__ */ s(
|
|
32
32
|
n.Content,
|
|
33
33
|
{
|
|
34
34
|
"data-slot": "dialog-content",
|
|
35
|
-
ref:
|
|
36
|
-
onCloseAutoFocus: k(m,
|
|
35
|
+
ref: p,
|
|
36
|
+
onCloseAutoFocus: k(m, u),
|
|
37
37
|
className: r(
|
|
38
38
|
"fixed top-1/2 left-1/2 z-[var(--z-modal)] -translate-x-1/2 -translate-y-1/2",
|
|
39
39
|
"border-border bg-card text-card-foreground w-[calc(100%-2rem)] rounded-xl border shadow-lg",
|
|
@@ -44,19 +44,19 @@ const z = c(function({ className: a, children: i, showClose: o = !0, size: l = "
|
|
|
44
44
|
l === "sm" && "max-w-[400px]",
|
|
45
45
|
l === "md" && "max-w-[520px]",
|
|
46
46
|
l === "lg" && "max-w-[720px]",
|
|
47
|
-
|
|
47
|
+
t
|
|
48
48
|
),
|
|
49
|
-
...
|
|
49
|
+
...f,
|
|
50
50
|
children: [
|
|
51
51
|
i,
|
|
52
|
-
|
|
52
|
+
a && /* @__PURE__ */ e(
|
|
53
53
|
n.Close,
|
|
54
54
|
{
|
|
55
|
-
"aria-label":
|
|
55
|
+
"aria-label": d.dialog.close,
|
|
56
56
|
className: r(
|
|
57
57
|
"text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md",
|
|
58
58
|
"hover:bg-background-muted hover:text-foreground",
|
|
59
|
-
"focus-visible:ring-ring focus-visible:ring-offset-card outline-
|
|
59
|
+
"focus-visible:ring-ring focus-visible:ring-offset-card outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
60
60
|
"transition-colors duration-[var(--duration-fast)]"
|
|
61
61
|
),
|
|
62
62
|
children: /* @__PURE__ */ e(S, { className: "size-4", "aria-hidden": !0 })
|
|
@@ -68,60 +68,60 @@ const z = c(function({ className: a, children: i, showClose: o = !0, size: l = "
|
|
|
68
68
|
] });
|
|
69
69
|
});
|
|
70
70
|
z.displayName = "DialogContent";
|
|
71
|
-
function
|
|
72
|
-
return /* @__PURE__ */ e("div", { className: r("flex flex-col gap-1 pb-4",
|
|
71
|
+
function T({ className: o, ...t }) {
|
|
72
|
+
return /* @__PURE__ */ e("div", { className: r("flex flex-col gap-1 pb-4", o), ...t });
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
function
|
|
74
|
+
T.displayName = "DialogHeader";
|
|
75
|
+
function F({ className: o, ...t }) {
|
|
76
76
|
return /* @__PURE__ */ e(
|
|
77
77
|
"div",
|
|
78
78
|
{
|
|
79
|
-
className: r("flex flex-col-reverse gap-2 pt-6 sm:flex-row sm:justify-end",
|
|
80
|
-
...
|
|
79
|
+
className: r("flex flex-col-reverse gap-2 pt-6 sm:flex-row sm:justify-end", o),
|
|
80
|
+
...t
|
|
81
81
|
}
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
const O =
|
|
84
|
+
F.displayName = "DialogFooter";
|
|
85
|
+
const O = g(function({ className: t, ...i }, a) {
|
|
86
86
|
return /* @__PURE__ */ e(
|
|
87
87
|
n.Title,
|
|
88
88
|
{
|
|
89
|
-
ref:
|
|
90
|
-
className: r("text-foreground text-lg leading-tight font-semibold",
|
|
89
|
+
ref: a,
|
|
90
|
+
className: r("text-foreground text-lg leading-tight font-semibold", t),
|
|
91
91
|
...i
|
|
92
92
|
}
|
|
93
93
|
);
|
|
94
94
|
});
|
|
95
95
|
O.displayName = "DialogTitle";
|
|
96
|
-
const j =
|
|
96
|
+
const j = g(function({ className: t, ...i }, a) {
|
|
97
97
|
return /* @__PURE__ */ e(
|
|
98
98
|
n.Description,
|
|
99
99
|
{
|
|
100
|
-
ref:
|
|
101
|
-
className: r("text-foreground-muted text-sm",
|
|
100
|
+
ref: a,
|
|
101
|
+
className: r("text-foreground-muted text-sm", t),
|
|
102
102
|
...i
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
105
|
});
|
|
106
106
|
j.displayName = "DialogDescription";
|
|
107
|
-
function
|
|
108
|
-
open:
|
|
109
|
-
onOpenChange:
|
|
107
|
+
function X({
|
|
108
|
+
open: o,
|
|
109
|
+
onOpenChange: t,
|
|
110
110
|
title: i,
|
|
111
|
-
description:
|
|
111
|
+
description: a,
|
|
112
112
|
confirmLabel: l,
|
|
113
113
|
cancelLabel: m,
|
|
114
|
-
confirmVariant:
|
|
115
|
-
onConfirm:
|
|
116
|
-
loading:
|
|
117
|
-
formatError:
|
|
114
|
+
confirmVariant: u = "primary",
|
|
115
|
+
onConfirm: f,
|
|
116
|
+
loading: p,
|
|
117
|
+
formatError: d
|
|
118
118
|
}) {
|
|
119
|
-
const
|
|
120
|
-
|
|
119
|
+
const D = C(), [P, h] = b(!1), [v, x] = b(null), y = !!p || P, R = async () => {
|
|
120
|
+
x(null), h(!0);
|
|
121
121
|
try {
|
|
122
|
-
await
|
|
123
|
-
} catch (
|
|
124
|
-
|
|
122
|
+
await f();
|
|
123
|
+
} catch (c) {
|
|
124
|
+
x(d ? d(c) : D.errorState.genericDescription);
|
|
125
125
|
} finally {
|
|
126
126
|
h(!1);
|
|
127
127
|
}
|
|
@@ -129,38 +129,35 @@ function A({
|
|
|
129
129
|
return /* @__PURE__ */ e(
|
|
130
130
|
B,
|
|
131
131
|
{
|
|
132
|
-
open:
|
|
133
|
-
onOpenChange: (
|
|
134
|
-
|
|
132
|
+
open: o,
|
|
133
|
+
onOpenChange: (c) => {
|
|
134
|
+
c || x(null), t(c);
|
|
135
135
|
},
|
|
136
|
-
children: /* @__PURE__ */ s(z, { size: "sm", ...
|
|
137
|
-
/* @__PURE__ */ s(
|
|
136
|
+
children: /* @__PURE__ */ s(z, { size: "sm", ...a ? {} : { "aria-describedby": void 0 }, children: [
|
|
137
|
+
/* @__PURE__ */ s(T, { children: [
|
|
138
138
|
/* @__PURE__ */ e(O, { children: i }),
|
|
139
|
-
|
|
139
|
+
a && /* @__PURE__ */ e(j, { children: a })
|
|
140
140
|
] }),
|
|
141
141
|
v && /* @__PURE__ */ e("p", { role: "alert", className: "text-danger-text text-sm", children: v }),
|
|
142
|
-
/* @__PURE__ */ s(
|
|
143
|
-
/* @__PURE__ */ e(
|
|
144
|
-
/* @__PURE__ */ e(N, { variant:
|
|
142
|
+
/* @__PURE__ */ s(F, { children: [
|
|
143
|
+
/* @__PURE__ */ e(A, { asChild: !0, children: /* @__PURE__ */ e(N, { variant: "outline", disabled: y, children: m ?? D.confirmationDialog.cancel }) }),
|
|
144
|
+
/* @__PURE__ */ e(N, { variant: u, loading: y, onClick: R, children: l ?? D.confirmationDialog.confirm })
|
|
145
145
|
] })
|
|
146
146
|
] })
|
|
147
147
|
}
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
|
-
|
|
151
|
-
return t instanceof Error ? t.message : String(t);
|
|
152
|
-
}
|
|
153
|
-
A.displayName = "ConfirmationDialog";
|
|
150
|
+
X.displayName = "ConfirmationDialog";
|
|
154
151
|
export {
|
|
155
|
-
|
|
152
|
+
X as ConfirmationDialog,
|
|
156
153
|
B as Dialog,
|
|
157
|
-
|
|
154
|
+
A as DialogClose,
|
|
158
155
|
z as DialogContent,
|
|
159
156
|
j as DialogDescription,
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
F as DialogFooter,
|
|
158
|
+
T as DialogHeader,
|
|
162
159
|
w as DialogOverlay,
|
|
163
|
-
|
|
160
|
+
H as DialogPortal,
|
|
164
161
|
O as DialogTitle,
|
|
165
162
|
Q as DialogTrigger
|
|
166
163
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../src/components/ui/Dialog.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useState,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { Button, type ButtonProps } from './Button';\nimport { withReturnFocus, type ReturnFocusRef } from '@/lib/return-focus';\n\nexport const Dialog = DialogPrimitive.Root;\nexport const DialogTrigger = DialogPrimitive.Trigger;\nexport const DialogPortal = DialogPrimitive.Portal;\nexport const DialogClose = DialogPrimitive.Close;\n\nexport const DialogOverlay = forwardRef<\n ComponentRef<typeof DialogPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(function DialogOverlay({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n ref={ref}\n className={cn(\n 'bg-overlay fixed inset-0 z-[var(--z-overlay)]',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n className,\n )}\n {...props}\n />\n );\n});\nDialogOverlay.displayName = 'DialogOverlay';\n\nexport interface DialogContentProps extends ComponentPropsWithoutRef<\n typeof DialogPrimitive.Content\n> {\n /** Show the default close (×) button in the top-right. */\n showClose?: boolean;\n /** Dialog width — `sm` 400 / `md` 520 / `lg` 720. */\n size?: 'sm' | 'md' | 'lg';\n /**\n * Element to focus when the overlay closes. Overrides Radix's default\n * (the element focused when the content mounted), which is `<body>` for\n * controlled overlays opened from a pointer click on a non-focusable /\n * tooltip-wrapped trigger. A consumer `onCloseAutoFocus` runs first and\n * wins if it calls `preventDefault()`.\n */\n returnFocusTo?: ReturnFocusRef;\n}\n\nexport const DialogContent = forwardRef<\n ComponentRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(function DialogContent(\n { className, children, showClose = true, size = 'md', returnFocusTo, onCloseAutoFocus, ...props },\n ref,\n) {\n const strings = useStrings();\n return (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n ref={ref}\n onCloseAutoFocus={withReturnFocus(returnFocusTo, onCloseAutoFocus)}\n className={cn(\n 'fixed top-1/2 left-1/2 z-[var(--z-modal)] -translate-x-1/2 -translate-y-1/2',\n 'border-border bg-card text-card-foreground w-[calc(100%-2rem)] rounded-xl border shadow-lg',\n 'p-6',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n size === 'sm' && 'max-w-[400px]',\n size === 'md' && 'max-w-[520px]',\n size === 'lg' && 'max-w-[720px]',\n className,\n )}\n {...props}\n >\n {children}\n {showClose && (\n <DialogPrimitive.Close\n aria-label={strings.dialog.close}\n className={cn(\n 'text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-card outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n <X className=\"size-4\" aria-hidden />\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n});\nDialogContent.displayName = 'DialogContent';\n\nexport function DialogHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('flex flex-col gap-1 pb-4', className)} {...props} />;\n}\nDialogHeader.displayName = 'DialogHeader';\n\nexport function DialogFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn('flex flex-col-reverse gap-2 pt-6 sm:flex-row sm:justify-end', className)}\n {...props}\n />\n );\n}\nDialogFooter.displayName = 'DialogFooter';\n\nexport const DialogTitle = forwardRef<\n ComponentRef<typeof DialogPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(function DialogTitle({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-foreground text-lg leading-tight font-semibold', className)}\n {...props}\n />\n );\n});\nDialogTitle.displayName = 'DialogTitle';\n\nexport const DialogDescription = forwardRef<\n ComponentRef<typeof DialogPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(function DialogDescription({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-foreground-muted text-sm', className)}\n {...props}\n />\n );\n});\nDialogDescription.displayName = 'DialogDescription';\n\n/* -----------------------------------------------------------------------------\n * ConfirmationDialog — pre-composed pattern for destructive/important\n * confirmations. Use this when the body is a single sentence and the only\n * controls are Cancel + Confirm.\n * --------------------------------------------------------------------------- */\n\nexport interface ConfirmationDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n /** Label of the confirm button. */\n confirmLabel?: string;\n /** Label of the cancel button. */\n cancelLabel?: string;\n /** Variant of the confirm button — typically `primary` or `destructive`. */\n confirmVariant?: ButtonProps['variant'];\n /**\n * Called when the user confirms. Awaited — the confirm button shows a\n * spinner while pending and a rejection is rendered inline (the dialog stays\n * open so the user can retry or cancel).\n */\n onConfirm: () => void | Promise<void>;\n /** Force the submitting state from outside (in addition to the awaited `onConfirm`). */\n loading?: boolean;\n /** Map a rejected `onConfirm` to the message shown. Defaults to `Error.message`. */\n formatError?: (err: unknown) => ReactNode;\n}\n\n/**\n * Confirmation dialog with title, description, cancel + confirm buttons.\n *\n * @example Destructive confirmation\n * <ConfirmationDialog\n * open={open} onOpenChange={setOpen}\n * title=\"Delete project?\"\n * description=\"This permanently deletes the project and all its data.\"\n * confirmLabel=\"Delete project\"\n * confirmVariant=\"destructive\"\n * onConfirm={handleDelete}\n * />\n *\n * @do Lead the title with the action: \"Delete project?\" not \"Are you sure?\".\n * State consequences in the description.\n * @dont Use for low-risk reversible actions — those don't need a dialog.\n */\nexport function ConfirmationDialog({\n open,\n onOpenChange,\n title,\n description,\n confirmLabel,\n cancelLabel,\n confirmVariant = 'primary',\n onConfirm,\n loading,\n formatError = defaultFormatError,\n}: ConfirmationDialogProps) {\n const strings = useStrings();\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const busy = Boolean(loading) || pending;\n\n const handleConfirm = async () => {\n setFailure(null);\n setPending(true);\n try {\n await onConfirm();\n } catch (err) {\n setFailure(formatError(err));\n } finally {\n setPending(false);\n }\n };\n\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!next) setFailure(null);\n onOpenChange(next);\n }}\n >\n {/* No description → drop aria-describedby so Radix does not warn and AT is not pointed at nothing. */}\n <DialogContent size=\"sm\" {...(description ? {} : { 'aria-describedby': undefined })}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n {description && <DialogDescription>{description}</DialogDescription>}\n </DialogHeader>\n {failure && (\n <p role=\"alert\" className=\"text-danger-text text-sm\">\n {failure}\n </p>\n )}\n <DialogFooter>\n <DialogClose asChild>\n <Button variant=\"outline\" disabled={busy}>\n {cancelLabel ?? strings.confirmationDialog.cancel}\n </Button>\n </DialogClose>\n <Button variant={confirmVariant} loading={busy} onClick={handleConfirm}>\n {confirmLabel ?? strings.confirmationDialog.confirm}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction defaultFormatError(err: unknown): ReactNode {\n return err instanceof Error ? err.message : String(err);\n}\nConfirmationDialog.displayName = 'ConfirmationDialog';\n"],"names":["Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","forwardRef","className","props","ref","jsx","cn","DialogContent","children","showClose","size","returnFocusTo","onCloseAutoFocus","strings","useStrings","jsxs","withReturnFocus","X","DialogHeader","DialogFooter","DialogTitle","DialogDescription","ConfirmationDialog","open","onOpenChange","title","description","confirmLabel","cancelLabel","confirmVariant","onConfirm","loading","formatError","defaultFormatError","pending","setPending","useState","failure","setFailure","busy","handleConfirm","err","next","Button"],"mappings":";;;;;;;;;AAiBO,MAAMA,IAASC,EAAgB,MACzBC,IAAgBD,EAAgB,SAChCE,IAAeF,EAAgB,QAC/BG,IAAcH,EAAgB,OAE9BI,IAAgBC,EAG3B,SAAuB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAASC,GAAK;AACrD,SACE,gBAAAC;AAAA,IAACT,EAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,KAAAQ;AAAA,MACA,WAAWE;AAAA,QACT;AA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.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useState,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { Button, type ButtonProps } from './Button';\nimport { withReturnFocus, type ReturnFocusRef } from '@/lib/return-focus';\n\nexport const Dialog = DialogPrimitive.Root;\nexport const DialogTrigger = DialogPrimitive.Trigger;\nexport const DialogPortal = DialogPrimitive.Portal;\nexport const DialogClose = DialogPrimitive.Close;\n\nexport const DialogOverlay = forwardRef<\n ComponentRef<typeof DialogPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(function DialogOverlay({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n ref={ref}\n className={cn(\n 'bg-overlay fixed inset-0 z-[var(--z-overlay)]',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n className,\n )}\n {...props}\n />\n );\n});\nDialogOverlay.displayName = 'DialogOverlay';\n\nexport interface DialogContentProps extends ComponentPropsWithoutRef<\n typeof DialogPrimitive.Content\n> {\n /** Show the default close (×) button in the top-right. */\n showClose?: boolean;\n /** Dialog width — `sm` 400 / `md` 520 / `lg` 720. */\n size?: 'sm' | 'md' | 'lg';\n /**\n * Element to focus when the overlay closes. Overrides Radix's default\n * (the element focused when the content mounted), which is `<body>` for\n * controlled overlays opened from a pointer click on a non-focusable /\n * tooltip-wrapped trigger. A consumer `onCloseAutoFocus` runs first and\n * wins if it calls `preventDefault()`.\n */\n returnFocusTo?: ReturnFocusRef;\n}\n\nexport const DialogContent = forwardRef<\n ComponentRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(function DialogContent(\n { className, children, showClose = true, size = 'md', returnFocusTo, onCloseAutoFocus, ...props },\n ref,\n) {\n const strings = useStrings();\n return (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n ref={ref}\n onCloseAutoFocus={withReturnFocus(returnFocusTo, onCloseAutoFocus)}\n className={cn(\n 'fixed top-1/2 left-1/2 z-[var(--z-modal)] -translate-x-1/2 -translate-y-1/2',\n 'border-border bg-card text-card-foreground w-[calc(100%-2rem)] rounded-xl border shadow-lg',\n 'p-6',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n size === 'sm' && 'max-w-[400px]',\n size === 'md' && 'max-w-[520px]',\n size === 'lg' && 'max-w-[720px]',\n className,\n )}\n {...props}\n >\n {children}\n {showClose && (\n <DialogPrimitive.Close\n aria-label={strings.dialog.close}\n className={cn(\n 'text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-card outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n <X className=\"size-4\" aria-hidden />\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n});\nDialogContent.displayName = 'DialogContent';\n\nexport function DialogHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('flex flex-col gap-1 pb-4', className)} {...props} />;\n}\nDialogHeader.displayName = 'DialogHeader';\n\nexport function DialogFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn('flex flex-col-reverse gap-2 pt-6 sm:flex-row sm:justify-end', className)}\n {...props}\n />\n );\n}\nDialogFooter.displayName = 'DialogFooter';\n\nexport const DialogTitle = forwardRef<\n ComponentRef<typeof DialogPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(function DialogTitle({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-foreground text-lg leading-tight font-semibold', className)}\n {...props}\n />\n );\n});\nDialogTitle.displayName = 'DialogTitle';\n\nexport const DialogDescription = forwardRef<\n ComponentRef<typeof DialogPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(function DialogDescription({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-foreground-muted text-sm', className)}\n {...props}\n />\n );\n});\nDialogDescription.displayName = 'DialogDescription';\n\n/* -----------------------------------------------------------------------------\n * ConfirmationDialog — pre-composed pattern for destructive/important\n * confirmations. Use this when the body is a single sentence and the only\n * controls are Cancel + Confirm.\n * --------------------------------------------------------------------------- */\n\nexport interface ConfirmationDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n /** Label of the confirm button. */\n confirmLabel?: string;\n /** Label of the cancel button. */\n cancelLabel?: string;\n /** Variant of the confirm button — typically `primary` or `destructive`. */\n confirmVariant?: ButtonProps['variant'];\n /**\n * Called when the user confirms. Awaited — the confirm button shows a\n * spinner while pending and a rejection is rendered inline (the dialog stays\n * open so the user can retry or cancel).\n */\n onConfirm: () => void | Promise<void>;\n /** Force the submitting state from outside (in addition to the awaited `onConfirm`). */\n loading?: boolean;\n /**\n * Map a rejected `onConfirm` to the message shown. Without it the generic\n * `errorState.genericDescription` string is shown — never `Error.message`,\n * which is usually server or library text not meant for the user.\n */\n formatError?: (err: unknown) => ReactNode;\n}\n\n/**\n * Confirmation dialog with title, description, cancel + confirm buttons.\n *\n * @example Destructive confirmation\n * <ConfirmationDialog\n * open={open} onOpenChange={setOpen}\n * title=\"Delete project?\"\n * description=\"This permanently deletes the project and all its data.\"\n * confirmLabel=\"Delete project\"\n * confirmVariant=\"destructive\"\n * onConfirm={handleDelete}\n * />\n *\n * @do Lead the title with the action: \"Delete project?\" not \"Are you sure?\".\n * State consequences in the description.\n * @dont Use for low-risk reversible actions — those don't need a dialog.\n */\nexport function ConfirmationDialog({\n open,\n onOpenChange,\n title,\n description,\n confirmLabel,\n cancelLabel,\n confirmVariant = 'primary',\n onConfirm,\n loading,\n formatError,\n}: ConfirmationDialogProps) {\n const strings = useStrings();\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const busy = Boolean(loading) || pending;\n\n const handleConfirm = async () => {\n setFailure(null);\n setPending(true);\n try {\n await onConfirm();\n } catch (err) {\n setFailure(formatError ? formatError(err) : strings.errorState.genericDescription);\n } finally {\n setPending(false);\n }\n };\n\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!next) setFailure(null);\n onOpenChange(next);\n }}\n >\n {/* No description → drop aria-describedby so Radix does not warn and AT is not pointed at nothing. */}\n <DialogContent size=\"sm\" {...(description ? {} : { 'aria-describedby': undefined })}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n {description && <DialogDescription>{description}</DialogDescription>}\n </DialogHeader>\n {failure && (\n <p role=\"alert\" className=\"text-danger-text text-sm\">\n {failure}\n </p>\n )}\n <DialogFooter>\n <DialogClose asChild>\n <Button variant=\"outline\" disabled={busy}>\n {cancelLabel ?? strings.confirmationDialog.cancel}\n </Button>\n </DialogClose>\n <Button variant={confirmVariant} loading={busy} onClick={handleConfirm}>\n {confirmLabel ?? strings.confirmationDialog.confirm}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n}\n\nConfirmationDialog.displayName = 'ConfirmationDialog';\n"],"names":["Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","forwardRef","className","props","ref","jsx","cn","DialogContent","children","showClose","size","returnFocusTo","onCloseAutoFocus","strings","useStrings","jsxs","withReturnFocus","X","DialogHeader","DialogFooter","DialogTitle","DialogDescription","ConfirmationDialog","open","onOpenChange","title","description","confirmLabel","cancelLabel","confirmVariant","onConfirm","loading","formatError","pending","setPending","useState","failure","setFailure","busy","handleConfirm","err","next","Button"],"mappings":";;;;;;;;;AAiBO,MAAMA,IAASC,EAAgB,MACzBC,IAAgBD,EAAgB,SAChCE,IAAeF,EAAgB,QAC/BG,IAAcH,EAAgB,OAE9BI,IAAgBC,EAG3B,SAAuB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAASC,GAAK;AACrD,SACE,gBAAAC;AAAA,IAACT,EAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,KAAAQ;AAAA,MACA,WAAWE;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACAJ;AAAA,MAAA;AAAA,MAED,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDH,EAAc,cAAc;AAmBrB,MAAMO,IAAgBN,EAG3B,SACA,EAAE,WAAAC,GAAW,UAAAM,GAAU,WAAAC,IAAY,IAAM,MAAAC,IAAO,MAAM,eAAAC,GAAe,kBAAAC,GAAkB,GAAGT,EAAA,GAC1FC,GACA;AACA,QAAMS,IAAUC,EAAA;AAChB,2BACGhB,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAO,EAACL,GAAA,EAAc;AAAA,IACf,gBAAAe;AAAA,MAACnB,EAAgB;AAAA,MAAhB;AAAA,QACC,aAAU;AAAA,QACV,KAAAQ;AAAA,QACA,kBAAkBY,EAAgBL,GAAeC,CAAgB;AAAA,QACjE,WAAWN;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACAI,MAAS,QAAQ;AAAA,UACjBA,MAAS,QAAQ;AAAA,UACjBA,MAAS,QAAQ;AAAA,UACjBR;AAAA,QAAA;AAAA,QAED,GAAGC;AAAA,QAEH,UAAA;AAAA,UAAAK;AAAA,UACAC,KACC,gBAAAJ;AAAA,YAACT,EAAgB;AAAA,YAAhB;AAAA,cACC,cAAYiB,EAAQ,OAAO;AAAA,cAC3B,WAAWP;AAAA,gBACT;AAAA,gBACA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BAAmB,QAC7C,GACF;AAAA,UACA,gBAAAR,EAACqC,GAAA,EAAO,SAASb,GAAgB,SAASS,GAAM,SAASC,GACtD,UAAAZ,KAAgBd,EAAQ,mBAAmB,QAAA,CAC9C;AAAA,QAAA,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEAS,EAAmB,cAAc;"}
|
|
@@ -3,7 +3,7 @@ import { jsx as r, jsxs as c } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef as s, useContext as v, createContext as y } from "react";
|
|
4
4
|
import { Drawer as a } from "vaul";
|
|
5
5
|
import { X as N } from "../../icons/index.js";
|
|
6
|
-
import { cn as
|
|
6
|
+
import { cn as l } from "../../lib/utils.js";
|
|
7
7
|
import { useStrings as C } from "../../hooks/use-strings.js";
|
|
8
8
|
import { withReturnFocus as z } from "../../lib/return-focus.js";
|
|
9
9
|
const m = y("bottom"), T = ({
|
|
@@ -19,13 +19,13 @@ const m = y("bottom"), T = ({
|
|
|
19
19
|
}
|
|
20
20
|
) });
|
|
21
21
|
T.displayName = "Drawer";
|
|
22
|
-
const I = a.Trigger, F = a.Portal, J = a.Close, f = s(function({ className: e, ...o },
|
|
22
|
+
const I = a.Trigger, F = a.Portal, J = a.Close, f = s(function({ className: e, ...o }, n) {
|
|
23
23
|
return /* @__PURE__ */ r(
|
|
24
24
|
a.Overlay,
|
|
25
25
|
{
|
|
26
26
|
"data-slot": "drawer-overlay",
|
|
27
|
-
ref:
|
|
28
|
-
className:
|
|
27
|
+
ref: n,
|
|
28
|
+
className: l("bg-overlay fixed inset-0 z-[var(--z-overlay)]", e),
|
|
29
29
|
...o
|
|
30
30
|
}
|
|
31
31
|
);
|
|
@@ -44,7 +44,7 @@ const O = {
|
|
|
44
44
|
}, k = s(function({
|
|
45
45
|
className: e,
|
|
46
46
|
direction: o,
|
|
47
|
-
hideHandle:
|
|
47
|
+
hideHandle: n,
|
|
48
48
|
showClose: u = !0,
|
|
49
49
|
returnFocusTo: x,
|
|
50
50
|
onCloseAutoFocus: b,
|
|
@@ -60,7 +60,7 @@ const O = {
|
|
|
60
60
|
"data-slot": "drawer-content",
|
|
61
61
|
ref: g,
|
|
62
62
|
onCloseAutoFocus: z(x, b),
|
|
63
|
-
className:
|
|
63
|
+
className: l(
|
|
64
64
|
"bg-card fixed z-[var(--z-modal)]",
|
|
65
65
|
O[i],
|
|
66
66
|
d && "flex-row",
|
|
@@ -68,16 +68,16 @@ const O = {
|
|
|
68
68
|
),
|
|
69
69
|
...h,
|
|
70
70
|
children: [
|
|
71
|
-
!
|
|
72
|
-
/* @__PURE__ */ r("div", { className:
|
|
71
|
+
!n && /* @__PURE__ */ r("div", { "aria-hidden": !0, className: j[i] }),
|
|
72
|
+
/* @__PURE__ */ r("div", { className: l("min-h-0 min-w-0 flex-1", d && "flex flex-col"), children: w }),
|
|
73
73
|
u && /* @__PURE__ */ r(
|
|
74
74
|
a.Close,
|
|
75
75
|
{
|
|
76
76
|
"aria-label": D.drawer.close,
|
|
77
|
-
className:
|
|
77
|
+
className: l(
|
|
78
78
|
"text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md",
|
|
79
79
|
"hover:bg-background-muted hover:text-foreground",
|
|
80
|
-
"focus-visible:ring-ring focus-visible:ring-offset-card outline-
|
|
80
|
+
"focus-visible:ring-ring focus-visible:ring-offset-card outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
81
81
|
"transition-colors duration-[var(--duration-fast)]"
|
|
82
82
|
),
|
|
83
83
|
children: /* @__PURE__ */ r(N, { className: "size-4", "aria-hidden": !0 })
|
|
@@ -90,30 +90,30 @@ const O = {
|
|
|
90
90
|
});
|
|
91
91
|
k.displayName = "DrawerContent";
|
|
92
92
|
function H({ className: t, ...e }) {
|
|
93
|
-
return /* @__PURE__ */ r("div", { className:
|
|
93
|
+
return /* @__PURE__ */ r("div", { className: l("grid gap-1 p-4 text-center sm:text-left", t), ...e });
|
|
94
94
|
}
|
|
95
95
|
H.displayName = "DrawerHeader";
|
|
96
96
|
function P({ className: t, ...e }) {
|
|
97
|
-
return /* @__PURE__ */ r("div", { className:
|
|
97
|
+
return /* @__PURE__ */ r("div", { className: l("mt-auto flex flex-col gap-2 p-4", t), ...e });
|
|
98
98
|
}
|
|
99
99
|
P.displayName = "DrawerFooter";
|
|
100
|
-
const R = s(function({ className: e, ...o },
|
|
100
|
+
const R = s(function({ className: e, ...o }, n) {
|
|
101
101
|
return /* @__PURE__ */ r(
|
|
102
102
|
a.Title,
|
|
103
103
|
{
|
|
104
|
-
ref:
|
|
105
|
-
className:
|
|
104
|
+
ref: n,
|
|
105
|
+
className: l("text-lg font-semibold", e),
|
|
106
106
|
...o
|
|
107
107
|
}
|
|
108
108
|
);
|
|
109
109
|
});
|
|
110
110
|
R.displayName = "DrawerTitle";
|
|
111
|
-
const S = s(function({ className: e, ...o },
|
|
111
|
+
const S = s(function({ className: e, ...o }, n) {
|
|
112
112
|
return /* @__PURE__ */ r(
|
|
113
113
|
a.Description,
|
|
114
114
|
{
|
|
115
|
-
ref:
|
|
116
|
-
className:
|
|
115
|
+
ref: n,
|
|
116
|
+
className: l("text-foreground-muted text-sm", e),
|
|
117
117
|
...o
|
|
118
118
|
}
|
|
119
119
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sources":["../../../src/components/ui/Drawer.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n forwardRef,\n useContext,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport { Drawer as DrawerPrimitive } from 'vaul';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { withReturnFocus, type ReturnFocusRef } from '@/lib/return-focus';\n\ntype Direction = 'top' | 'right' | 'bottom' | 'left';\n\n// vaul needs `direction` on Root for its drag physics; DrawerContent reads it\n// back from here so the side only has to be declared once.\nconst DrawerDirectionContext = createContext<Direction>('bottom');\n\nexport const Drawer = ({\n shouldScaleBackground = true,\n direction = 'bottom',\n ...props\n}: ComponentPropsWithoutRef<typeof DrawerPrimitive.Root>) => (\n <DrawerDirectionContext.Provider value={direction}>\n <DrawerPrimitive.Root\n shouldScaleBackground={shouldScaleBackground}\n direction={direction}\n {...props}\n />\n </DrawerDirectionContext.Provider>\n);\nDrawer.displayName = 'Drawer';\n\nexport const DrawerTrigger = DrawerPrimitive.Trigger;\nexport const DrawerPortal = DrawerPrimitive.Portal;\nexport const DrawerClose = DrawerPrimitive.Close;\n\nexport const DrawerOverlay = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>\n>(function DrawerOverlay({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Overlay\n data-slot=\"drawer-overlay\"\n ref={ref}\n className={cn('bg-overlay fixed inset-0 z-[var(--z-overlay)]', className)}\n {...props}\n />\n );\n});\nDrawerOverlay.displayName = 'DrawerOverlay';\n\n// Edge-anchored sides pad by the matching safe-area inset (consumers set viewport-fit=cover).\nconst directionStyles: Record<Direction, string> = {\n bottom:\n 'inset-x-0 bottom-0 mt-24 flex h-auto max-h-[90dvh] flex-col rounded-t-xl border-t border-border pb-[env(safe-area-inset-bottom)]',\n top: 'inset-x-0 top-0 mb-24 flex h-auto max-h-[90dvh] flex-col rounded-b-xl border-b border-border',\n left: 'inset-y-0 left-0 flex h-full w-full max-w-[min(26.25rem,90vw)] flex-col rounded-r-xl border-r border-border pl-[env(safe-area-inset-left)]',\n right:\n 'inset-y-0 right-0 flex h-full w-full max-w-[min(26.25rem,90vw)] flex-col rounded-l-xl border-l border-border pr-[env(safe-area-inset-right)]',\n};\n\nconst handleStyles: Record<Direction, string> = {\n bottom: 'mx-auto mt-3 h-1.5 w-12 rounded-full bg-border',\n top: 'mx-auto mb-3 h-1.5 w-12 rounded-full bg-border order-last',\n left: 'mx-1.5 my-auto h-12 w-1.5 rounded-full bg-border order-last self-stretch shrink-0',\n right: 'mx-1.5 my-auto h-12 w-1.5 rounded-full bg-border shrink-0 self-stretch',\n};\n\nexport interface DrawerContentProps extends ComponentPropsWithoutRef<\n typeof DrawerPrimitive.Content\n> {\n /**\n * Side the drawer slides in from. Prefer setting `direction` on `<Drawer>`\n * (vaul needs it there for drag physics); this prop only overrides the\n * visual placement.\n */\n direction?: Direction;\n /** Hide the drag handle. */\n hideHandle?: boolean;\n /** Show the close (×) button. Default `true`. */\n showClose?: boolean;\n /**\n * Element to focus when the overlay closes. Overrides Radix's default\n * (the element focused when the content mounted), which is `<body>` for\n * controlled overlays opened from a pointer click on a non-focusable /\n * tooltip-wrapped trigger. A consumer `onCloseAutoFocus` runs first and\n * wins if it calls `preventDefault()`.\n */\n returnFocusTo?: ReturnFocusRef;\n}\n\nexport const DrawerContent = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Content>,\n DrawerContentProps\n>(function DrawerContent(\n {\n className,\n direction: directionProp,\n hideHandle,\n showClose = true,\n returnFocusTo,\n onCloseAutoFocus,\n children,\n ...props\n },\n ref,\n) {\n const rootDirection = useContext(DrawerDirectionContext);\n const direction = directionProp ?? rootDirection;\n const strings = useStrings();\n const isHorizontal = direction === 'left' || direction === 'right';\n return (\n <DrawerPortal>\n <DrawerOverlay />\n <DrawerPrimitive.Content\n data-slot=\"drawer-content\"\n ref={ref}\n onCloseAutoFocus={withReturnFocus(returnFocusTo, onCloseAutoFocus)}\n className={cn(\n 'bg-card fixed z-[var(--z-modal)]',\n directionStyles[direction],\n isHorizontal && 'flex-row',\n className,\n )}\n {...props}\n >\n {!hideHandle && <div aria-hidden className={handleStyles[direction]} />}\n <div className={cn('min-h-0 min-w-0 flex-1', isHorizontal && 'flex flex-col')}>\n {children}\n </div>\n {showClose && (\n <DrawerPrimitive.Close\n aria-label={strings.drawer.close}\n className={cn(\n 'text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-card outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n <X className=\"size-4\" aria-hidden />\n </DrawerPrimitive.Close>\n )}\n </DrawerPrimitive.Content>\n </DrawerPortal>\n );\n});\nDrawerContent.displayName = 'DrawerContent';\n\nexport function DrawerHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('grid gap-1 p-4 text-center sm:text-left', className)} {...props} />;\n}\nDrawerHeader.displayName = 'DrawerHeader';\n\nexport function DrawerFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />;\n}\nDrawerFooter.displayName = 'DrawerFooter';\n\nexport const DrawerTitle = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>\n>(function DrawerTitle({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold', className)}\n {...props}\n />\n );\n});\nDrawerTitle.displayName = 'DrawerTitle';\n\nexport const DrawerDescription = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>\n>(function DrawerDescription({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Description\n ref={ref}\n className={cn('text-foreground-muted text-sm', className)}\n {...props}\n />\n );\n});\nDrawerDescription.displayName = 'DrawerDescription';\n"],"names":["DrawerDirectionContext","createContext","Drawer","shouldScaleBackground","direction","props","jsx","DrawerPrimitive","DrawerTrigger","DrawerPortal","DrawerClose","DrawerOverlay","forwardRef","className","ref","cn","directionStyles","handleStyles","DrawerContent","directionProp","hideHandle","showClose","returnFocusTo","onCloseAutoFocus","children","rootDirection","useContext","strings","useStrings","isHorizontal","jsxs","withReturnFocus","X","DrawerHeader","DrawerFooter","DrawerTitle","DrawerDescription"],"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ACnD,SACE,gBAAAR;AAAA,IAACC,EAAgB;AAAA,IAAhB;AAAA,MACC,KAAAO;AAAA,MACA,WAAWC,EAAG,yBAAyBF,CAAS;AAAA,MAC/C,GAAGR;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD8B,EAAY,cAAc;AAEnB,MAAMC,IAAoBxB,EAG/B,SAA2B,EAAE,WAAAC,GAAW,GAAGR,EAAA,GAASS,GAAK;AACzD,SACE,gBAAAR;AAAA,IAACC,EAAgB;AAAA,IAAhB;AAAA,MACC,KAAAO;AAAA,MACA,WAAWC,EAAG,iCAAiCF,CAAS;AAAA,MACvD,GAAGR;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD+B,EAAkB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Drawer.js","sources":["../../../src/components/ui/Drawer.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n forwardRef,\n useContext,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport { Drawer as DrawerPrimitive } from 'vaul';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { withReturnFocus, type ReturnFocusRef } from '@/lib/return-focus';\n\ntype Direction = 'top' | 'right' | 'bottom' | 'left';\n\n// vaul needs `direction` on Root for its drag physics; DrawerContent reads it\n// back from here so the side only has to be declared once.\nconst DrawerDirectionContext = createContext<Direction>('bottom');\n\nexport const Drawer = ({\n shouldScaleBackground = true,\n direction = 'bottom',\n ...props\n}: ComponentPropsWithoutRef<typeof DrawerPrimitive.Root>) => (\n <DrawerDirectionContext.Provider value={direction}>\n <DrawerPrimitive.Root\n shouldScaleBackground={shouldScaleBackground}\n direction={direction}\n {...props}\n />\n </DrawerDirectionContext.Provider>\n);\nDrawer.displayName = 'Drawer';\n\nexport const DrawerTrigger = DrawerPrimitive.Trigger;\nexport const DrawerPortal = DrawerPrimitive.Portal;\nexport const DrawerClose = DrawerPrimitive.Close;\n\nexport const DrawerOverlay = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>\n>(function DrawerOverlay({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Overlay\n data-slot=\"drawer-overlay\"\n ref={ref}\n className={cn('bg-overlay fixed inset-0 z-[var(--z-overlay)]', className)}\n {...props}\n />\n );\n});\nDrawerOverlay.displayName = 'DrawerOverlay';\n\n// Edge-anchored sides pad by the matching safe-area inset (consumers set viewport-fit=cover).\nconst directionStyles: Record<Direction, string> = {\n bottom:\n 'inset-x-0 bottom-0 mt-24 flex h-auto max-h-[90dvh] flex-col rounded-t-xl border-t border-border pb-[env(safe-area-inset-bottom)]',\n top: 'inset-x-0 top-0 mb-24 flex h-auto max-h-[90dvh] flex-col rounded-b-xl border-b border-border',\n left: 'inset-y-0 left-0 flex h-full w-full max-w-[min(26.25rem,90vw)] flex-col rounded-r-xl border-r border-border pl-[env(safe-area-inset-left)]',\n right:\n 'inset-y-0 right-0 flex h-full w-full max-w-[min(26.25rem,90vw)] flex-col rounded-l-xl border-l border-border pr-[env(safe-area-inset-right)]',\n};\n\nconst handleStyles: Record<Direction, string> = {\n bottom: 'mx-auto mt-3 h-1.5 w-12 rounded-full bg-border',\n top: 'mx-auto mb-3 h-1.5 w-12 rounded-full bg-border order-last',\n left: 'mx-1.5 my-auto h-12 w-1.5 rounded-full bg-border order-last self-stretch shrink-0',\n right: 'mx-1.5 my-auto h-12 w-1.5 rounded-full bg-border shrink-0 self-stretch',\n};\n\nexport interface DrawerContentProps extends ComponentPropsWithoutRef<\n typeof DrawerPrimitive.Content\n> {\n /**\n * Side the drawer slides in from. Prefer setting `direction` on `<Drawer>`\n * (vaul needs it there for drag physics); this prop only overrides the\n * visual placement.\n */\n direction?: Direction;\n /** Hide the drag handle. */\n hideHandle?: boolean;\n /** Show the close (×) button. Default `true`. */\n showClose?: boolean;\n /**\n * Element to focus when the overlay closes. Overrides Radix's default\n * (the element focused when the content mounted), which is `<body>` for\n * controlled overlays opened from a pointer click on a non-focusable /\n * tooltip-wrapped trigger. A consumer `onCloseAutoFocus` runs first and\n * wins if it calls `preventDefault()`.\n */\n returnFocusTo?: ReturnFocusRef;\n}\n\nexport const DrawerContent = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Content>,\n DrawerContentProps\n>(function DrawerContent(\n {\n className,\n direction: directionProp,\n hideHandle,\n showClose = true,\n returnFocusTo,\n onCloseAutoFocus,\n children,\n ...props\n },\n ref,\n) {\n const rootDirection = useContext(DrawerDirectionContext);\n const direction = directionProp ?? rootDirection;\n const strings = useStrings();\n const isHorizontal = direction === 'left' || direction === 'right';\n return (\n <DrawerPortal>\n <DrawerOverlay />\n <DrawerPrimitive.Content\n data-slot=\"drawer-content\"\n ref={ref}\n onCloseAutoFocus={withReturnFocus(returnFocusTo, onCloseAutoFocus)}\n className={cn(\n 'bg-card fixed z-[var(--z-modal)]',\n directionStyles[direction],\n isHorizontal && 'flex-row',\n className,\n )}\n {...props}\n >\n {!hideHandle && <div aria-hidden className={handleStyles[direction]} />}\n <div className={cn('min-h-0 min-w-0 flex-1', isHorizontal && 'flex flex-col')}>\n {children}\n </div>\n {showClose && (\n <DrawerPrimitive.Close\n aria-label={strings.drawer.close}\n className={cn(\n 'text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-card outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n <X className=\"size-4\" aria-hidden />\n </DrawerPrimitive.Close>\n )}\n </DrawerPrimitive.Content>\n </DrawerPortal>\n );\n});\nDrawerContent.displayName = 'DrawerContent';\n\nexport function DrawerHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('grid gap-1 p-4 text-center sm:text-left', className)} {...props} />;\n}\nDrawerHeader.displayName = 'DrawerHeader';\n\nexport function DrawerFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />;\n}\nDrawerFooter.displayName = 'DrawerFooter';\n\nexport const DrawerTitle = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>\n>(function DrawerTitle({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold', className)}\n {...props}\n />\n );\n});\nDrawerTitle.displayName = 'DrawerTitle';\n\nexport const DrawerDescription = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>\n>(function DrawerDescription({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Description\n ref={ref}\n className={cn('text-foreground-muted text-sm', className)}\n {...props}\n />\n );\n});\nDrawerDescription.displayName = 'DrawerDescription';\n"],"names":["DrawerDirectionContext","createContext","Drawer","shouldScaleBackground","direction","props","jsx","DrawerPrimitive","DrawerTrigger","DrawerPortal","DrawerClose","DrawerOverlay","forwardRef","className","ref","cn","directionStyles","handleStyles","DrawerContent","directionProp","hideHandle","showClose","returnFocusTo","onCloseAutoFocus","children","rootDirection","useContext","strings","useStrings","isHorizontal","jsxs","withReturnFocus","X","DrawerHeader","DrawerFooter","DrawerTitle","DrawerDescription"],"mappings":";;;;;;;;AAoBA,MAAMA,IAAyBC,EAAyB,QAAQ,GAEnDC,IAAS,CAAC;AAAA,EACrB,uBAAAC,IAAwB;AAAA,EACxB,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MACE,gBAAAC,EAACN,EAAuB,UAAvB,EAAgC,OAAOI,GACtC,UAAA,gBAAAE;AAAA,EAACC,EAAgB;AAAA,EAAhB;AAAA,IACC,uBAAAJ;AAAA,IACA,WAAAC;AAAA,IACC,GAAGC;AAAA,EAAA;AACN,EAAA,CACF;AAEFH,EAAO,cAA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WC,EAAG,iCAAiCF,CAAS;AAAA,MACvD,GAAGR;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD+B,EAAkB,cAAc;"}
|
|
@@ -5,7 +5,7 @@ import * as o from "@radix-ui/react-dropdown-menu";
|
|
|
5
5
|
import { Check as c, Circle as m, ChevronRight as g } from "../../icons/index.js";
|
|
6
6
|
import { cn as d } from "../../lib/utils.js";
|
|
7
7
|
const k = o.Root, R = o.Trigger, T = o.Group, f = o.Portal, j = o.Sub, G = o.RadioGroup, p = d(
|
|
8
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-
|
|
8
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-hidden",
|
|
9
9
|
"data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground",
|
|
10
10
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
11
11
|
"transition-colors duration-[var(--duration-fast)]",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.js","sources":["../../../src/components/ui/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/* -----------------------------------------------------------------------------\n * Full dropdown menu surface with submenu support, separators, checkbox /\n * radio items, and keyboard shortcut labels (Kbd).\n * --------------------------------------------------------------------------- */\n\nexport const DropdownMenu = DropdownMenuPrimitive.Root;\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n // Leading icons in items default to 16px like Button/Sidebar/Command do —\n // a bare lucide icon is 24px and every consumer was sizing it by hand.\n '[&_svg]:size-4 [&_svg]:shrink-0',\n);\n\nexport const DropdownMenuSubTrigger = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(function DropdownMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </DropdownMenuPrimitive.SubTrigger>\n );\n});\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\nexport const DropdownMenuSubContent = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(function DropdownMenuSubContent({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\nexport const DropdownMenuContent = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n // `align` defaults to 'end' (Radix default is 'center'): triggers are\n // usually right-aligned icon buttons in toolbars/table rows. Pass\n // `align=\"start\"` for left-anchored triggers.\n>(function DropdownMenuContent({ className, sideOffset = 4, align = 'end', ...props }, ref) {\n return (\n <DropdownMenuPortal>\n <DropdownMenuPrimitive.Content\n data-slot=\"dropdown-menu-content\"\n ref={ref}\n sideOffset={sideOffset}\n align={align}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n 'data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1',\n className,\n )}\n {...props}\n />\n </DropdownMenuPortal>\n );\n});\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\nexport const DropdownMenuItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function DropdownMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(function DropdownMenuCheckboxItem({ className, children, checked, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n checked={checked}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n});\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\nexport const DropdownMenuRadioItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(function DropdownMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n});\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\nexport const DropdownMenuLabel = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(function DropdownMenuLabel({ className, inset, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\nexport const DropdownMenuSeparator = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(function DropdownMenuSeparator({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/**\n * Trailing right-aligned shortcut label inside a menu item. Pair with `<Kbd>`\n * inside the Kbd component file if you want stylised keys.\n */\nexport function DropdownMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/**\n * @example\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild><IconButton aria-label=\"More\" icon={<MoreHorizontal />} /></DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Open<DropdownMenuShortcut>⌘O</DropdownMenuShortcut></DropdownMenuItem>\n * <DropdownMenuItem>Rename</DropdownMenuItem>\n * <DropdownMenuSeparator />\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n *\n * @do Group destructive items at the bottom with a separator.\n * @dont Mix link navigation and action items in the same menu — split into\n * two menus or two groups with labels.\n */\n"],"names":["DropdownMenu","DropdownMenuPrimitive","DropdownMenuTrigger","DropdownMenuGroup","DropdownMenuPortal","DropdownMenuSub","DropdownMenuRadioGroup","itemClasses","cn","DropdownMenuSubTrigger","forwardRef","className","inset","children","props","ref","jsxs","jsx","ChevronRight","DropdownMenuSubContent","DropdownMenuContent","sideOffset","align","DropdownMenuItem","destructive","DropdownMenuCheckboxItem","checked","Check","DropdownMenuRadioItem","Circle","DropdownMenuLabel","DropdownMenuSeparator","DropdownMenuShortcut"],"mappings":";;;;;;AAiBO,MAAMA,IAAeC,EAAsB,MACrCC,IAAsBD,EAAsB,SAC5CE,IAAoBF,EAAsB,OAC1CG,IAAqBH,EAAsB,QAC3CI,IAAkBJ,EAAsB,KACxCK,IAAyBL,EAAsB,YAEt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,2DACd,UAAA,gBAAAA,EAAChB,EAAsB,eAAtB,EACC,UAAA,gBAAAgB,EAACY,GAAA,EAAO,WAAU,kCAAiC,eAAW,GAAA,CAAC,GACjE,GACF;AAAA,QACChB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;AACDe,EAAsB,cAAc;AAE7B,MAAME,IAAoBpB,EAK/B,SAA2B,EAAE,WAAAC,GAAW,OAAAC,GAAO,GAAGE,EAAA,GAASC,GAAK;AAChE,SACE,gBAAAE;AAAA,IAAChB,EAAsB;AAAA,IAAtB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP;AAAA,QACT;AAAA,QACAI,KAAS;AAAA,QACTD;AAAA,MAAA;AAAA,MAED,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDgB,EAAkB,cAAc;AAEzB,MAAMC,IAAwBrB,EAGnC,SAA+B,EAAE,WAAAC,GAAW,GAAGG,EAAA,GAASC,GAAK;AAC7D,SACE,gBAAAE;AAAA,IAAChB,EAAsB;AAAA,IAAtB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP,EAAG,6BAA6BG,CAAS;AAAA,MACnD,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDiB,EAAsB,cAAc;AAM7B,SAASC,EAAqB,EAAE,WAAArB,GAAW,GAAGG,KAA0C;AAC7F,SACE,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWT,EAAG,oEAAoEG,CAAS;AAAA,MAC1F,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV;AACAkB,EAAqB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"DropdownMenu.js","sources":["../../../src/components/ui/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/* -----------------------------------------------------------------------------\n * Full dropdown menu surface with submenu support, separators, checkbox /\n * radio items, and keyboard shortcut labels (Kbd).\n * --------------------------------------------------------------------------- */\n\nexport const DropdownMenu = DropdownMenuPrimitive.Root;\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-hidden',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n // Leading icons in items default to 16px like Button/Sidebar/Command do —\n // a bare lucide icon is 24px and every consumer was sizing it by hand.\n '[&_svg]:size-4 [&_svg]:shrink-0',\n);\n\nexport const DropdownMenuSubTrigger = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(function DropdownMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </DropdownMenuPrimitive.SubTrigger>\n );\n});\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\nexport const DropdownMenuSubContent = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(function DropdownMenuSubContent({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\nexport const DropdownMenuContent = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n // `align` defaults to 'end' (Radix default is 'center'): triggers are\n // usually right-aligned icon buttons in toolbars/table rows. Pass\n // `align=\"start\"` for left-anchored triggers.\n>(function DropdownMenuContent({ className, sideOffset = 4, align = 'end', ...props }, ref) {\n return (\n <DropdownMenuPortal>\n <DropdownMenuPrimitive.Content\n data-slot=\"dropdown-menu-content\"\n ref={ref}\n sideOffset={sideOffset}\n align={align}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n 'data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1',\n className,\n )}\n {...props}\n />\n </DropdownMenuPortal>\n );\n});\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\nexport const DropdownMenuItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function DropdownMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(function DropdownMenuCheckboxItem({ className, children, checked, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n checked={checked}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n});\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\nexport const DropdownMenuRadioItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(function DropdownMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n});\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\nexport const DropdownMenuLabel = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(function DropdownMenuLabel({ className, inset, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\nexport const DropdownMenuSeparator = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(function DropdownMenuSeparator({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/**\n * Trailing right-aligned shortcut label inside a menu item. Pair with `<Kbd>`\n * inside the Kbd component file if you want stylised keys.\n */\nexport function DropdownMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/**\n * @example\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild><IconButton aria-label=\"More\" icon={<MoreHorizontal />} /></DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Open<DropdownMenuShortcut>⌘O</DropdownMenuShortcut></DropdownMenuItem>\n * <DropdownMenuItem>Rename</DropdownMenuItem>\n * <DropdownMenuSeparator />\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n *\n * @do Group destructive items at the bottom with a separator.\n * @dont Mix link navigation and action items in the same menu — split into\n * two menus or two groups with labels.\n */\n"],"names":["DropdownMenu","DropdownMenuPrimitive","DropdownMenuTrigger","DropdownMenuGroup","DropdownMenuPortal","DropdownMenuSub","DropdownMenuRadioGroup","itemClasses","cn","DropdownMenuSubTrigger","forwardRef","className","inset","children","props","ref","jsxs","jsx","ChevronRight","DropdownMenuSubContent","DropdownMenuContent","sideOffset","align","DropdownMenuItem","destructive","DropdownMenuCheckboxItem","checked","Check","DropdownMenuRadioItem","Circle","DropdownMenuLabel","DropdownMenuSeparator","DropdownMenuShortcut"],"mappings":";;;;;;AAiBO,MAAMA,IAAeC,EAAsB,MACrCC,IAAsBD,EAAsB,SAC5CE,IAAoBF,EAAsB,OAC1CG,IAAqBH,EAAsB,QAC3CI,IAAkBJ,EAAsB,KACxCK,IAAyBL,EAAsB,YAEtDM,IAAcC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AACF,GAEaC,IAAyBC,EAKpC,SAAgC,EAAE,WAAAC,GAAW,OAAAC,GAAO,UAAAC,GAAU,GAAGC,EAAA,GAASC,GAAK;AAC/E,SACE,gBAAAC;AAAA,IAACf,EAAsB;AAAA,IAAtB;AAAA,MACC,aAAU;AAAA,MACV,KAAAc;AAAA,MACA,WAAWP;AAAA,QACTD;AAAA,QACA;AAAA,QACAK,KAAS;AAAA,QACTD;AAAA,MAAA;AAAA,MAED,GAAGG;AAAA,MAEH,UAAA;AAAA,QAAAD;AAAA,QACD,gBAAAI,EAACC,GAAA,EAAa,WAAU,yCAAwC,eAAW,GAAA,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlF,CAAC;AACDT,EAAuB,cAAc;AAE9B,MAAMU,IAAyBT,EAGpC,SAAgC,EAAE,WAAAC,GAAW,GAAGG,EAAA,GAASC,GAAK;AAC9D,SACE,gBAAAE;AAAA,IAAChB,EAAsB;AAAA,IAAtB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACAG;AAAA,MAAA;AAAA,MAED,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDK,EAAuB,cAAc;AAE9B,MAAM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AAC;AAAA,IAAA;AAAA,MACC,WAAWT,EAAG,oEAAoEG,CAAS;AAAA,MAC1F,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV;AACAkB,EAAqB,cAAc;"}
|
|
@@ -18,9 +18,11 @@ export interface ErrorStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 't
|
|
|
18
18
|
/** Heading level of the title. Default 3 — match the surrounding outline. */
|
|
19
19
|
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
20
20
|
/**
|
|
21
|
-
* Announce the error
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Announce the error when it appears in-place (e.g. a failed refetch inside
|
|
22
|
+
* a panel). Rendered as `role="alert"`: a live region that mounts already
|
|
23
|
+
* populated is not announced, an alert inserted into the page is. Off by
|
|
24
|
+
* default — page-level errors are read as part of the page and must not
|
|
25
|
+
* double-announce.
|
|
24
26
|
*/
|
|
25
27
|
live?: boolean;
|
|
26
28
|
}
|
|
@@ -48,7 +48,7 @@ const T = (e) => ({
|
|
|
48
48
|
"border-border bg-background-subtle flex flex-col items-center justify-center gap-3 rounded-lg border p-10 text-center",
|
|
49
49
|
p
|
|
50
50
|
),
|
|
51
|
-
|
|
51
|
+
role: m ? "alert" : void 0,
|
|
52
52
|
...u,
|
|
53
53
|
children: [
|
|
54
54
|
c ?? t.illustration,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorState.js","sources":["../../../src/components/ui/ErrorState.tsx"],"sourcesContent":["'use client';\n\nimport { createElement, forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport type { UiStrings } from '@/lib/strings';\nimport { NotFound, ServerError, ConnectionLost, Locked } from '@/illustrations';\nimport { Button } from './Button';\n\nexport interface ErrorStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** `403` permission-denied, `404` not-found, `500` server, or `generic` (catch-all). */\n variant?: '403' | '404' | '500' | 'generic';\n /** Override the default title. */\n title?: ReactNode;\n /** Override the default description. */\n description?: ReactNode;\n /**\n * Override the variant's default illustration. Pass any ReactNode (e.g.\n * `<Illustrations.Construction className=\"size-32\" />`).\n */\n illustration?: ReactNode;\n /** Custom action node. Replaces the default retry button. */\n action?: ReactNode;\n /** When provided, renders a default \"Try again\" button calling this handler. */\n onRetry?: () => void;\n /** Heading level of the title. Default 3 — match the surrounding outline. */\n headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /**\n * Announce the error
|
|
1
|
+
{"version":3,"file":"ErrorState.js","sources":["../../../src/components/ui/ErrorState.tsx"],"sourcesContent":["'use client';\n\nimport { createElement, forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport type { UiStrings } from '@/lib/strings';\nimport { NotFound, ServerError, ConnectionLost, Locked } from '@/illustrations';\nimport { Button } from './Button';\n\nexport interface ErrorStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** `403` permission-denied, `404` not-found, `500` server, or `generic` (catch-all). */\n variant?: '403' | '404' | '500' | 'generic';\n /** Override the default title. */\n title?: ReactNode;\n /** Override the default description. */\n description?: ReactNode;\n /**\n * Override the variant's default illustration. Pass any ReactNode (e.g.\n * `<Illustrations.Construction className=\"size-32\" />`).\n */\n illustration?: ReactNode;\n /** Custom action node. Replaces the default retry button. */\n action?: ReactNode;\n /** When provided, renders a default \"Try again\" button calling this handler. */\n onRetry?: () => void;\n /** Heading level of the title. Default 3 — match the surrounding outline. */\n headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /**\n * Announce the error when it appears in-place (e.g. a failed refetch inside\n * a panel). Rendered as `role=\"alert\"`: a live region that mounts already\n * populated is not announced, an alert inserted into the page is. Off by\n * default — page-level errors are read as part of the page and must not\n * double-announce.\n */\n live?: boolean;\n}\n\nconst presets = (s: UiStrings) => ({\n '403': {\n illustration: <Locked className=\"size-32\" />,\n title: s.errorState.forbiddenTitle,\n description: s.errorState.forbiddenDescription,\n },\n '404': {\n illustration: <NotFound className=\"size-32\" />,\n title: s.errorState.notFoundTitle,\n description: s.errorState.notFoundDescription,\n },\n '500': {\n illustration: <ServerError className=\"size-32\" />,\n title: s.errorState.serverTitle,\n description: s.errorState.serverDescription,\n },\n generic: {\n illustration: <ConnectionLost className=\"size-32\" />,\n title: s.errorState.genericTitle,\n description: s.errorState.genericDescription,\n },\n});\n\n/**\n * Page-level error placeholder. Pair with `onRetry` for transient failures.\n *\n * @example 404 (uses built-in line illustration)\n * <ErrorState variant=\"404\" />\n *\n * @example 500 with retry\n * <ErrorState variant=\"500\" onRetry={refetch} />\n *\n * @example 403 with a way out (no retry — permission won't change on reload)\n * <ErrorState variant=\"403\" action={<Button variant=\"outline\" asChild><a href=\"/\">Go home</a></Button>} />\n *\n * @example Custom\n * <ErrorState\n * title=\"Quota exceeded\"\n * description=\"Your plan allows 1,000 events/day.\"\n * illustration={<Illustrations.Construction className=\"size-32\" />}\n * action={<Button>Upgrade plan</Button>}\n * />\n *\n * @do Match the tone to the cause — server errors apologise, user errors\n * explain. Always offer a next step.\n * @dont Show a raw stack trace to end users.\n */\nexport const ErrorState = forwardRef<HTMLDivElement, ErrorStateProps>(function ErrorState(\n {\n variant = 'generic',\n title,\n description,\n illustration,\n action,\n onRetry,\n headingLevel = 3,\n live,\n className,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const preset = presets(strings)[variant];\n return (\n <div\n data-slot=\"error-state\"\n ref={ref}\n className={cn(\n 'border-border bg-background-subtle flex flex-col items-center justify-center gap-3 rounded-lg border p-10 text-center',\n className,\n )}\n role={live ? 'alert' : undefined}\n {...props}\n >\n {illustration ?? preset.illustration}\n {createElement(\n `h${headingLevel}`,\n { className: 'text-base font-semibold text-foreground leading-tight' },\n title ?? preset.title,\n )}\n <p className=\"text-foreground-muted max-w-md text-sm leading-relaxed\">\n {description ?? preset.description}\n </p>\n {(action || onRetry) && (\n <div className=\"mt-2 flex items-center gap-2\">\n {action ?? (\n <Button onClick={onRetry} variant=\"outline\">\n {strings.errorState.tryAgain}\n </Button>\n )}\n </div>\n )}\n </div>\n );\n});\nErrorState.displayName = 'ErrorState';\n"],"names":["presets","s","jsx","Locked","NotFound","ServerError","ConnectionLost","ErrorState","forwardRef","variant","title","description","illustration","action","onRetry","headingLevel","live","className","props","ref","strings","useStrings","preset","jsxs","cn","createElement","Button"],"mappings":";;;;;;;AAqCA,MAAMA,IAAU,CAACC,OAAkB;AAAA,EACjC,KAAO;AAAA,IACL,cAAc,gBAAAC,EAACC,GAAA,EAAO,WAAU,UAAA,CAAU;AAAA,IAC1C,OAAOF,EAAE,WAAW;AAAA,IACpB,aAAaA,EAAE,WAAW;AAAA,EAAA;AAAA,EAE5B,KAAO;AAAA,IACL,cAAc,gBAAAC,EAACE,GAAA,EAAS,WAAU,UAAA,CAAU;AAAA,IAC5C,OAAOH,EAAE,WAAW;AAAA,IACpB,aAAaA,EAAE,WAAW;AAAA,EAAA;AAAA,EAE5B,KAAO;AAAA,IACL,cAAc,gBAAAC,EAACG,GAAA,EAAY,WAAU,UAAA,CAAU;AAAA,IAC/C,OAAOJ,EAAE,WAAW;AAAA,IACpB,aAAaA,EAAE,WAAW;AAAA,EAAA;AAAA,EAE5B,SAAS;AAAA,IACP,cAAc,gBAAAC,EAACI,GAAA,EAAe,WAAU,UAAA,CAAU;AAAA,IAClD,OAAOL,EAAE,WAAW;AAAA,IACpB,aAAaA,EAAE,WAAW;AAAA,EAAA;AAE9B,IA0BaM,IAAaC,EAA4C,SACpE;AAAA,EACE,SAAAC,IAAU;AAAA,EACV,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAUC,EAAA,GACVC,IAAStB,EAAQoB,CAAO,EAAEX,CAAO;AACvC,SACE,gBAAAc;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,KAAAJ;AAAA,MACA,WAAWK;AAAA,QACT;AAAA,QACAP;AAAA,MAAA;AAAA,MAEF,MAAMD,IAAO,UAAU;AAAA,MACtB,GAAGE;AAAA,MAEH,UAAA;AAAA,QAAAN,KAAgBU,EAAO;AAAA,QACvBG;AAAA,UACC,IAAIV,CAAY;AAAA,UAChB,EAAE,WAAW,wDAAA;AAAA,UACbL,KAASY,EAAO;AAAA,QAAA;AAAA,0BAEjB,KAAA,EAAE,WAAU,0DACV,UAAAX,KAAeW,EAAO,aACzB;AAAA,SACET,KAAUC,MACV,gBAAAZ,EAAC,OAAA,EAAI,WAAU,gCACZ,UAAAW,KACC,gBAAAX,EAACwB,GAAA,EAAO,SAASZ,GAAS,SAAQ,WAC/B,UAAAM,EAAQ,WAAW,UACtB,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;AACDb,EAAW,cAAc;"}
|
|
@@ -15,6 +15,12 @@ export interface FileUploadProps {
|
|
|
15
15
|
onReject?: (files: File[], reason: FileRejectReason) => void;
|
|
16
16
|
/** Helper text inside the drop zone. */
|
|
17
17
|
hint?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Failure to show under the drop zone (an upload that did not go through).
|
|
20
|
+
* Rejections for `accept` / `maxSize` are shown here automatically, in the
|
|
21
|
+
* library's strings, until the next accepted file.
|
|
22
|
+
*/
|
|
23
|
+
error?: ReactNode;
|
|
18
24
|
/** Disable the picker entirely. */
|
|
19
25
|
disabled?: boolean;
|
|
20
26
|
className?: string;
|