@gerege-systems/ui 0.14.1 → 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/Avatar.js +1 -0
- package/dist-lib/components/ui/Avatar.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/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 +54 -57
- package/dist-lib/components/ui/Dialog.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 +60 -55
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +40 -39
- package/dist-lib/components/ui/MultiSelect.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/Sidebar.d.ts +3 -1
- package/dist-lib/components/ui/Sidebar.js +97 -97
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +28 -28
- package/dist-lib/components/ui/Slider.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 +25 -21
- package/package.json +1 -1
|
@@ -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,15 +44,15 @@ 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",
|
|
@@ -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-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 /** 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;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,kBA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,QAAKA,KAAMJ,EAAW,IAAI,GAC1Bd,EAAakB,CAAI;AAAA,MACnB;AAAA,MAGA,UAAA,gBAAA3B,EAACR,GAAA,EAAc,MAAK,MAAM,GAAImB,IAAc,CAAA,IAAK,EAAE,oBAAoB,OAAA,GACrE,UAAA;AAAA,QAAA,gBAAAX,EAACG,GAAA,EACC,UAAA;AAAA,UAAA,gBAAAb,EAACe,KAAa,UAAAK,EAAA,CAAM;AAAA,UACnBC,KAAe,gBAAArB,EAACgB,GAAA,EAAmB,UAAAK,EAAA,CAAY;AAAA,QAAA,GAClD;AAAA,QACCW,KACC,gBAAAhC,EAAC,KAAA,EAAE,MAAK,SAAQ,WAAU,4BACvB,UAAAgC,GACH;AAAA,0BAEDlB,GAAA,EACC,UAAA;AAAA,UAAA,gBAAAd,EAACN,GAAA,EAAY,SAAO,IAClB,UAAA,gBAAAM,EAACsC,GAAA,EAAO,SAAQ,WAAU,UAAUJ,GACjC,UAAAX,KAAef,EAAQ,mBAAmB,QAC7C,GACF;AAAA,UACA,gBAAAR,EAACsC,GAAA,EAAO,SAASd,GAAgB,SAASU,GAAM,SAASC,GACtD,UAAAb,KAAgBd,EAAQ,mBAAmB,QAAA,CAC9C;AAAA,QAAA,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAASoB,EAAmBQ,GAAyB;AACnD,SAAOA,aAAe,QAAQA,EAAI,UAAU,OAAOA,CAAG;AACxD;AACAnB,EAAmB,cAAc;"}
|
|
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-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,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|
|
@@ -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;
|
|
@@ -1,112 +1,117 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Upload as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { useStrings as
|
|
2
|
+
import { jsxs as g, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as _, useRef as L, useId as q, useState as k, useCallback as $ } from "react";
|
|
4
|
+
import { Upload as G, File as H, X as J } from "../../icons/index.js";
|
|
5
|
+
import { cn as I } from "../../lib/utils.js";
|
|
6
|
+
import { useStrings as K } from "../../hooks/use-strings.js";
|
|
7
7
|
import { formatString as h } from "../../lib/strings.js";
|
|
8
|
-
function
|
|
9
|
-
return
|
|
8
|
+
function W(o, n) {
|
|
9
|
+
return o < 1024 ? h(n.bytes, { n: o }) : o < 1024 * 1024 ? h(n.kilobytes, { n: (o / 1024).toFixed(1) }) : h(n.megabytes, { n: (o / 1024 / 1024).toFixed(1) });
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
if (!
|
|
13
|
-
const a =
|
|
11
|
+
function P(o, n) {
|
|
12
|
+
if (!n) return !0;
|
|
13
|
+
const a = n.split(",").map((r) => r.trim().toLowerCase()).filter(Boolean);
|
|
14
14
|
if (!a.length) return !0;
|
|
15
|
-
const
|
|
16
|
-
return a.some((r) => r.startsWith(".") ?
|
|
15
|
+
const l = o.name.toLowerCase(), d = o.type.toLowerCase();
|
|
16
|
+
return a.some((r) => r.startsWith(".") ? l.endsWith(r) : r.endsWith("/*") ? d.startsWith(r.slice(0, -1)) : d === r);
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const Q = _(function({ accept: n, multiple: a, maxSize: l, value: d, onChange: r, onReject: i, hint: F, error: x, disabled: b, className: T }, A) {
|
|
19
|
+
const c = K(), M = L(null), y = q(), [O, B] = k([]), [C, w] = k(!1), [v, E] = k(null), z = `${y}-error`, u = L(0), m = d ?? O, U = $(
|
|
20
20
|
(e) => {
|
|
21
|
-
|
|
21
|
+
d === void 0 && B(e), r == null || r(e);
|
|
22
22
|
},
|
|
23
|
-
[r,
|
|
24
|
-
),
|
|
23
|
+
[r, d]
|
|
24
|
+
), D = $(
|
|
25
25
|
(e) => {
|
|
26
|
-
const
|
|
27
|
-
for (const
|
|
28
|
-
|
|
29
|
-
N.length && (i == null || i(N, "type")),
|
|
26
|
+
const s = [], f = [], N = [];
|
|
27
|
+
for (const p of Array.from(e))
|
|
28
|
+
P(p, n) ? l && p.size > l ? f.push(p) : s.push(p) : N.push(p);
|
|
29
|
+
N.length && (i == null || i(N, "type")), f.length && (i == null || i(f, "size")), E(f.length ? "size" : N.length ? "type" : null), s.length && U(a ? [...m, ...s] : s.slice(0, 1));
|
|
30
30
|
},
|
|
31
|
-
[
|
|
32
|
-
),
|
|
33
|
-
e.preventDefault(),
|
|
31
|
+
[n, m, l, a, i, U]
|
|
32
|
+
), S = (e) => U(m.filter((s, f) => f !== e)), X = (e) => {
|
|
33
|
+
e.preventDefault(), u.current = 0, w(!1), !b && D(e.dataTransfer.files);
|
|
34
34
|
};
|
|
35
|
-
return /* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ g("div", { ref: A, className: I("flex flex-col gap-3", T), children: [
|
|
36
|
+
/* @__PURE__ */ g(
|
|
37
37
|
"label",
|
|
38
38
|
{
|
|
39
39
|
"data-slot": "file-upload",
|
|
40
|
-
htmlFor:
|
|
40
|
+
htmlFor: y,
|
|
41
41
|
onDragEnter: () => {
|
|
42
|
-
|
|
42
|
+
u.current += 1, b || w(!0);
|
|
43
43
|
},
|
|
44
44
|
onDragOver: (e) => e.preventDefault(),
|
|
45
45
|
onDragLeave: () => {
|
|
46
|
-
|
|
46
|
+
u.current = Math.max(0, u.current - 1), u.current === 0 && w(!1);
|
|
47
47
|
},
|
|
48
|
-
onDrop:
|
|
49
|
-
className:
|
|
48
|
+
onDrop: X,
|
|
49
|
+
className: I(
|
|
50
50
|
"group relative flex cursor-pointer flex-col items-center justify-center gap-2",
|
|
51
51
|
"border-border-input bg-background-subtle rounded-md border border-dashed px-6 py-8",
|
|
52
52
|
"text-center transition-colors",
|
|
53
53
|
"hover:border-border-strong hover:bg-background-muted",
|
|
54
54
|
"focus-within:ring-ring focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2",
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
C && "border-accent bg-accent-soft",
|
|
56
|
+
b && "pointer-events-none opacity-50"
|
|
57
57
|
),
|
|
58
58
|
children: [
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
|
|
59
|
+
/* @__PURE__ */ t(G, { className: "text-foreground-muted size-5", "aria-hidden": !0 }),
|
|
60
|
+
/* @__PURE__ */ g("div", { className: "space-y-1", children: [
|
|
61
|
+
/* @__PURE__ */ t("p", { className: "text-sm font-medium", children: c.fileUpload.drop }),
|
|
62
|
+
F && /* @__PURE__ */ t("p", { className: "text-foreground-muted text-xs", children: F })
|
|
63
63
|
] }),
|
|
64
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ t(
|
|
65
65
|
"input",
|
|
66
66
|
{
|
|
67
|
-
ref:
|
|
68
|
-
id:
|
|
67
|
+
ref: M,
|
|
68
|
+
id: y,
|
|
69
69
|
type: "file",
|
|
70
|
-
accept:
|
|
70
|
+
accept: n,
|
|
71
71
|
multiple: a,
|
|
72
|
-
disabled:
|
|
72
|
+
disabled: b,
|
|
73
|
+
"aria-invalid": x || v ? !0 : void 0,
|
|
74
|
+
"aria-describedby": x || v ? z : void 0,
|
|
73
75
|
className: "sr-only",
|
|
74
76
|
onChange: (e) => {
|
|
75
|
-
e.target.files &&
|
|
77
|
+
e.target.files && D(e.target.files), e.target.value = "";
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
)
|
|
79
81
|
]
|
|
80
82
|
}
|
|
81
83
|
),
|
|
82
|
-
|
|
84
|
+
(x || v) && /* @__PURE__ */ t("p", { id: z, role: "alert", className: "text-danger-text text-xs", children: x ?? (v === "size" ? h(c.fileUpload.tooLarge, {
|
|
85
|
+
max: W(l ?? 0, c.fileUpload)
|
|
86
|
+
}) : c.fileUpload.wrongType) }),
|
|
87
|
+
m.length > 0 && /* @__PURE__ */ t("ul", { className: "flex flex-col gap-2", children: m.map((e, s) => /* @__PURE__ */ g(
|
|
83
88
|
"li",
|
|
84
89
|
{
|
|
85
90
|
className: "border-border bg-card flex items-center gap-3 rounded-md border px-3 py-2",
|
|
86
91
|
children: [
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
92
|
+
/* @__PURE__ */ t(H, { className: "text-foreground-muted size-4 shrink-0", "aria-hidden": !0 }),
|
|
93
|
+
/* @__PURE__ */ g("div", { className: "min-w-0 flex-1", children: [
|
|
94
|
+
/* @__PURE__ */ t("p", { className: "truncate text-sm", title: e.name, children: e.name }),
|
|
95
|
+
/* @__PURE__ */ t("p", { className: "text-foreground-muted text-xs", children: W(e.size, c.fileUpload) })
|
|
91
96
|
] }),
|
|
92
|
-
/* @__PURE__ */
|
|
97
|
+
/* @__PURE__ */ t(
|
|
93
98
|
"button",
|
|
94
99
|
{
|
|
95
100
|
type: "button",
|
|
96
|
-
onClick: () =>
|
|
101
|
+
onClick: () => S(s),
|
|
97
102
|
className: "text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background rounded-sm p-1 outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
98
|
-
"aria-label": h(
|
|
99
|
-
children: /* @__PURE__ */
|
|
103
|
+
"aria-label": h(c.fileUpload.remove, { name: e.name }),
|
|
104
|
+
children: /* @__PURE__ */ t(J, { className: "size-4", "aria-hidden": !0 })
|
|
100
105
|
}
|
|
101
106
|
)
|
|
102
107
|
]
|
|
103
108
|
},
|
|
104
|
-
`${e.name}-${e.size}-${e.lastModified}-${
|
|
109
|
+
`${e.name}-${e.size}-${e.lastModified}-${s}`
|
|
105
110
|
)) })
|
|
106
111
|
] });
|
|
107
112
|
});
|
|
108
|
-
|
|
113
|
+
Q.displayName = "FileUpload";
|
|
109
114
|
export {
|
|
110
|
-
|
|
115
|
+
Q as FileUpload
|
|
111
116
|
};
|
|
112
117
|
//# sourceMappingURL=FileUpload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUpload.js","sources":["../../../src/components/ui/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useCallback,\n useId,\n useRef,\n useState,\n type DragEvent as ReactDragEvent,\n type ReactNode,\n} from 'react';\nimport { File as FileIcon, Upload, X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString, type UiStrings } from '@/lib/strings';\n\nexport type FileRejectReason = 'size' | 'type';\n\nexport interface FileUploadProps {\n /** Accepted file types, e.g. `image/*` or `.pdf,.docx`. */\n accept?: string;\n /** Allow multiple files. */\n multiple?: boolean;\n /** Max file size in bytes. Files larger than this are rejected. */\n maxSize?: number;\n /** Controlled file list. */\n value?: File[];\n /** Called when files are added or removed. */\n onChange?: (files: File[]) => void;\n /** Called with the files that were dropped because of `maxSize` or `accept`. */\n onReject?: (files: File[], reason: FileRejectReason) => void;\n /** Helper text inside the drop zone. */\n hint?: ReactNode;\n /** Disable the picker entirely. */\n disabled?: boolean;\n className?: string;\n}\n\nfunction formatSize(bytes: number, s: UiStrings['fileUpload']) {\n if (bytes < 1024) return formatString(s.bytes, { n: bytes });\n if (bytes < 1024 * 1024) return formatString(s.kilobytes, { n: (bytes / 1024).toFixed(1) });\n return formatString(s.megabytes, { n: (bytes / 1024 / 1024).toFixed(1) });\n}\n\n/** Mirror the browser's `accept` matching for dropped files (which skip the picker filter). */\nfunction matchesAccept(file: File, accept?: string): boolean {\n if (!accept) return true;\n const rules = accept\n .split(',')\n .map((r) => r.trim().toLowerCase())\n .filter(Boolean);\n if (!rules.length) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return rules.some((rule) => {\n if (rule.startsWith('.')) return name.endsWith(rule);\n if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1));\n return type === rule;\n });\n}\n\n/**\n * Drag-and-drop file picker with an inline file list. Uncontrolled by default;\n * pass `value` + `onChange` to control externally.\n */\nexport const FileUpload = forwardRef<HTMLDivElement, FileUploadProps>(function FileUpload(\n { accept, multiple, maxSize, value, onChange, onReject, hint, disabled, className },\n ref,\n) {\n const strings = useStrings();\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n const [internal, setInternal] = useState<File[]>([]);\n const [over, setOver] = useState(false);\n // dragenter/dragleave fire for every child element; count nesting depth so\n // the highlight does not flicker while the pointer crosses the label's children.\n const dragDepth = useRef(0);\n const files = value ?? internal;\n\n const update = useCallback(\n (next: File[]) => {\n if (value === undefined) setInternal(next);\n onChange?.(next);\n },\n [onChange, value],\n );\n\n const addFiles = useCallback(\n (incoming: FileList | File[]) => {\n const accepted: File[] = [];\n const tooLarge: File[] = [];\n const wrongType: File[] = [];\n for (const f of Array.from(incoming)) {\n if (!matchesAccept(f, accept)) wrongType.push(f);\n else if (maxSize && f.size > maxSize) tooLarge.push(f);\n else accepted.push(f);\n }\n if (wrongType.length) onReject?.(wrongType, 'type');\n if (tooLarge.length) onReject?.(tooLarge, 'size');\n if (!accepted.length) return;\n update(multiple ? [...files, ...accepted] : accepted.slice(0, 1));\n },\n [accept, files, maxSize, multiple, onReject, update],\n );\n\n const remove = (idx: number) => update(files.filter((_, i) => i !== idx));\n\n const onDrop = (e: ReactDragEvent<HTMLLabelElement>) => {\n e.preventDefault();\n dragDepth.current = 0;\n setOver(false);\n if (disabled) return;\n addFiles(e.dataTransfer.files);\n };\n\n return (\n <div ref={ref} className={cn('flex flex-col gap-3', className)}>\n <label\n data-slot=\"file-upload\"\n htmlFor={inputId}\n onDragEnter={() => {\n dragDepth.current += 1;\n if (!disabled) setOver(true);\n }}\n onDragOver={(e) => e.preventDefault()}\n onDragLeave={() => {\n dragDepth.current = Math.max(0, dragDepth.current - 1);\n if (dragDepth.current === 0) setOver(false);\n }}\n onDrop={onDrop}\n className={cn(\n 'group relative flex cursor-pointer flex-col items-center justify-center gap-2',\n 'border-border-input bg-background-subtle rounded-md border border-dashed px-6 py-8',\n 'text-center transition-colors',\n 'hover:border-border-strong hover:bg-background-muted',\n 'focus-within:ring-ring focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2',\n over && 'border-accent bg-accent-soft',\n disabled && 'pointer-events-none opacity-50',\n )}\n >\n <Upload className=\"text-foreground-muted size-5\" aria-hidden />\n <div className=\"space-y-1\">\n <p className=\"text-sm font-medium\">{strings.fileUpload.drop}</p>\n {hint && <p className=\"text-foreground-muted text-xs\">{hint}</p>}\n </div>\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n className=\"sr-only\"\n onChange={(e) => {\n if (e.target.files) addFiles(e.target.files);\n // Allow re-selecting the same file after removing it.\n e.target.value = '';\n }}\n />\n </label>\n\n {files.length > 0 && (\n <ul className=\"flex flex-col gap-2\">\n {files.map((file, idx) => (\n <li\n key={`${file.name}-${file.size}-${file.lastModified}-${idx}`}\n className=\"border-border bg-card flex items-center gap-3 rounded-md border px-3 py-2\"\n >\n <FileIcon className=\"text-foreground-muted size-4 shrink-0\" aria-hidden />\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm\" title={file.name}>\n {file.name}\n </p>\n <p className=\"text-foreground-muted text-xs\">\n {formatSize(file.size, strings.fileUpload)}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => remove(idx)}\n className=\"text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background rounded-sm p-1 outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2\"\n aria-label={formatString(strings.fileUpload.remove, { name: file.name })}\n >\n <X className=\"size-4\" aria-hidden />\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n});\nFileUpload.displayName = 'FileUpload';\n"],"names":["formatSize","bytes","s","formatString","matchesAccept","file","accept","rules","name","type","rule","FileUpload","forwardRef","multiple","maxSize","value","onChange","onReject","hint","disabled","className","ref","strings","useStrings","inputRef","useRef","inputId","useId","internal","setInternal","useState","over","setOver","dragDepth","files","update","useCallback","next","addFiles","incoming","accepted","tooLarge","wrongType","f","remove","idx","_","i","onDrop","cn","jsxs","jsx","Upload","FileIcon"],"mappings":";;;;;;;AAsCA,SAASA,EAAWC,GAAeC,GAA4B;AAC7D,SAAID,IAAQ,OAAaE,EAAaD,EAAE,OAAO,EAAED,GAAU,IACvDA,IAAQ,OAAO,OAAaE,EAAaD,EAAE,WAAW,EAAE,IAAID,IAAQ,MAAM,QAAQ,CAAC,GAAG,IACnFE,EAAaD,EAAE,WAAW,EAAE,IAAID,IAAQ,OAAO,MAAM,QAAQ,CAAC,EAAA,CAAG;AAC1E;AAGA,SAASG,EAAcC,GAAYC,GAA0B;AAC3D,MAAI,CAACA,EAAQ,QAAO;AACpB,QAAMC,IAAQD,EACX,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,OAAO,YAAA,CAAa,EACjC,OAAO,OAAO;AACjB,MAAI,CAACC,EAAM,OAAQ,QAAO;AAC1B,QAAMC,IAAOH,EAAK,KAAK,YAAA,GACjBI,IAAOJ,EAAK,KAAK,YAAA;AACvB,SAAOE,EAAM,KAAK,CAACG,MACbA,EAAK,WAAW,GAAG,IAAUF,EAAK,SAASE,CAAI,IAC/CA,EAAK,SAAS,IAAI,IAAUD,EAAK,WAAWC,EAAK,MAAM,GAAG,EAAE,CAAC,IAC1DD,MAASC,CACjB;AACH;AAMO,MAAMC,IAAaC,EAA4C,SACpE,EAAE,QAAAN,GAAQ,UAAAO,GAAU,SAAAC,GAAS,OAAAC,GAAO,UAAAC,GAAU,UAAAC,GAAU,MAAAC,GAAM,UAAAC,GAAU,WAAAC,EAAA,GACxEC,GACA;AACA,QAAMC,IAAUC,EAAA,GACVC,IAAWC,EAAyB,IAAI,GACxCC,IAAUC,EAAA,GACV,CAACC,GAAUC,CAAW,IAAIC,EAAiB,CAAA,CAAE,GAC7C,CAACC,GAAMC,CAAO,IAAIF,EAAS,EAAK,GAGhCG,IAAYR,EAAO,CAAC,GACpBS,IAAQnB,KAASa,GAEjBO,I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WAAU,yCAAwC,eAAW,IAAC;AAAA,UACxE,gBAAAH,EAAC,OAAA,EAAI,WAAU,kBACb,UAAA;AAAA,YAAA,gBAAAC,EAAC,OAAE,WAAU,oBAAmB,OAAO9C,EAAK,MACzC,YAAK,KAAA,CACR;AAAA,YACA,gBAAA8C,EAAC,OAAE,WAAU,iCACV,YAAW9C,EAAK,MAAMiB,EAAQ,UAAU,EAAA,CAC3C;AAAA,UAAA,GACF;AAAA,UACA,gBAAA6B;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAMP,EAAOC,CAAG;AAAA,cACzB,WAAU;AAAA,cACV,cAAY1C,EAAamB,EAAQ,WAAW,QAAQ,EAAE,MAAMjB,EAAK,MAAM;AAAA,cAEvE,UAAA,gBAAA8C,EAAC,GAAA,EAAE,WAAU,UAAS,eAAW,GAAA,CAAC;AAAA,YAAA;AAAA,UAAA;AAAA,QACpC;AAAA,MAAA;AAAA,MAnBK,GAAG9C,EAAK,IAAI,IAAIA,EAAK,IAAI,IAAIA,EAAK,YAAY,IAAIwC,CAAG;AAAA,IAAA,CAqB7D,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ,CAAC;AACDlC,EAAW,cAAc;"}
|
|
1
|
+
{"version":3,"file":"FileUpload.js","sources":["../../../src/components/ui/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useCallback,\n useId,\n useRef,\n useState,\n type DragEvent as ReactDragEvent,\n type ReactNode,\n} from 'react';\nimport { File as FileIcon, Upload, X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString, type UiStrings } from '@/lib/strings';\n\nexport type FileRejectReason = 'size' | 'type';\n\nexport interface FileUploadProps {\n /** Accepted file types, e.g. `image/*` or `.pdf,.docx`. */\n accept?: string;\n /** Allow multiple files. */\n multiple?: boolean;\n /** Max file size in bytes. Files larger than this are rejected. */\n maxSize?: number;\n /** Controlled file list. */\n value?: File[];\n /** Called when files are added or removed. */\n onChange?: (files: File[]) => void;\n /** Called with the files that were dropped because of `maxSize` or `accept`. */\n onReject?: (files: File[], reason: FileRejectReason) => void;\n /** Helper text inside the drop zone. */\n hint?: ReactNode;\n /**\n * Failure to show under the drop zone (an upload that did not go through).\n * Rejections for `accept` / `maxSize` are shown here automatically, in the\n * library's strings, until the next accepted file.\n */\n error?: ReactNode;\n /** Disable the picker entirely. */\n disabled?: boolean;\n className?: string;\n}\n\nfunction formatSize(bytes: number, s: UiStrings['fileUpload']) {\n if (bytes < 1024) return formatString(s.bytes, { n: bytes });\n if (bytes < 1024 * 1024) return formatString(s.kilobytes, { n: (bytes / 1024).toFixed(1) });\n return formatString(s.megabytes, { n: (bytes / 1024 / 1024).toFixed(1) });\n}\n\n/** Mirror the browser's `accept` matching for dropped files (which skip the picker filter). */\nfunction matchesAccept(file: File, accept?: string): boolean {\n if (!accept) return true;\n const rules = accept\n .split(',')\n .map((r) => r.trim().toLowerCase())\n .filter(Boolean);\n if (!rules.length) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return rules.some((rule) => {\n if (rule.startsWith('.')) return name.endsWith(rule);\n if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1));\n return type === rule;\n });\n}\n\n/**\n * Drag-and-drop file picker with an inline file list. Uncontrolled by default;\n * pass `value` + `onChange` to control externally.\n */\nexport const FileUpload = forwardRef<HTMLDivElement, FileUploadProps>(function FileUpload(\n { accept, multiple, maxSize, value, onChange, onReject, hint, error, disabled, className },\n ref,\n) {\n const strings = useStrings();\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n const [internal, setInternal] = useState<File[]>([]);\n const [over, setOver] = useState(false);\n const [rejection, setRejection] = useState<FileRejectReason | null>(null);\n const errorId = `${inputId}-error`;\n // dragenter/dragleave fire for every child element; count nesting depth so\n // the highlight does not flicker while the pointer crosses the label's children.\n const dragDepth = useRef(0);\n const files = value ?? internal;\n\n const update = useCallback(\n (next: File[]) => {\n if (value === undefined) setInternal(next);\n onChange?.(next);\n },\n [onChange, value],\n );\n\n const addFiles = useCallback(\n (incoming: FileList | File[]) => {\n const accepted: File[] = [];\n const tooLarge: File[] = [];\n const wrongType: File[] = [];\n for (const f of Array.from(incoming)) {\n if (!matchesAccept(f, accept)) wrongType.push(f);\n else if (maxSize && f.size > maxSize) tooLarge.push(f);\n else accepted.push(f);\n }\n if (wrongType.length) onReject?.(wrongType, 'type');\n if (tooLarge.length) onReject?.(tooLarge, 'size');\n // One notice at a time; a size problem is the more actionable of the two.\n setRejection(tooLarge.length ? 'size' : wrongType.length ? 'type' : null);\n if (!accepted.length) return;\n update(multiple ? [...files, ...accepted] : accepted.slice(0, 1));\n },\n [accept, files, maxSize, multiple, onReject, update],\n );\n\n const remove = (idx: number) => update(files.filter((_, i) => i !== idx));\n\n const onDrop = (e: ReactDragEvent<HTMLLabelElement>) => {\n e.preventDefault();\n dragDepth.current = 0;\n setOver(false);\n if (disabled) return;\n addFiles(e.dataTransfer.files);\n };\n\n return (\n <div ref={ref} className={cn('flex flex-col gap-3', className)}>\n <label\n data-slot=\"file-upload\"\n htmlFor={inputId}\n onDragEnter={() => {\n dragDepth.current += 1;\n if (!disabled) setOver(true);\n }}\n onDragOver={(e) => e.preventDefault()}\n onDragLeave={() => {\n dragDepth.current = Math.max(0, dragDepth.current - 1);\n if (dragDepth.current === 0) setOver(false);\n }}\n onDrop={onDrop}\n className={cn(\n 'group relative flex cursor-pointer flex-col items-center justify-center gap-2',\n 'border-border-input bg-background-subtle rounded-md border border-dashed px-6 py-8',\n 'text-center transition-colors',\n 'hover:border-border-strong hover:bg-background-muted',\n 'focus-within:ring-ring focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2',\n over && 'border-accent bg-accent-soft',\n disabled && 'pointer-events-none opacity-50',\n )}\n >\n <Upload className=\"text-foreground-muted size-5\" aria-hidden />\n <div className=\"space-y-1\">\n <p className=\"text-sm font-medium\">{strings.fileUpload.drop}</p>\n {hint && <p className=\"text-foreground-muted text-xs\">{hint}</p>}\n </div>\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n aria-invalid={error || rejection ? true : undefined}\n aria-describedby={error || rejection ? errorId : undefined}\n className=\"sr-only\"\n onChange={(e) => {\n if (e.target.files) addFiles(e.target.files);\n // Allow re-selecting the same file after removing it.\n e.target.value = '';\n }}\n />\n </label>\n\n {(error || rejection) && (\n <p id={errorId} role=\"alert\" className=\"text-danger-text text-xs\">\n {error ??\n (rejection === 'size'\n ? formatString(strings.fileUpload.tooLarge, {\n max: formatSize(maxSize ?? 0, strings.fileUpload),\n })\n : strings.fileUpload.wrongType)}\n </p>\n )}\n\n {files.length > 0 && (\n <ul className=\"flex flex-col gap-2\">\n {files.map((file, idx) => (\n <li\n key={`${file.name}-${file.size}-${file.lastModified}-${idx}`}\n className=\"border-border bg-card flex items-center gap-3 rounded-md border px-3 py-2\"\n >\n <FileIcon className=\"text-foreground-muted size-4 shrink-0\" aria-hidden />\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm\" title={file.name}>\n {file.name}\n </p>\n <p className=\"text-foreground-muted text-xs\">\n {formatSize(file.size, strings.fileUpload)}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => remove(idx)}\n className=\"text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background rounded-sm p-1 outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2\"\n aria-label={formatString(strings.fileUpload.remove, { name: file.name })}\n >\n <X className=\"size-4\" aria-hidden />\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n});\nFileUpload.displayName = 'FileUpload';\n"],"names":["formatSize","bytes","s","formatString","matchesAccept","file","accept","rules","name","type","rule","FileUpload","forwardRef","multiple","maxSize","value","onChange","onReject","hint","error","disabled","className","ref","strings","useStrings","inputRef","useRef","inputId","useId","internal","setInternal","useState","over","setOver","rejection","setRejection","errorId","dragDepth","files","update","useCallback","next","addFiles","incoming","accepted","tooLarge","wrongType","f","remove","idx","_","i","onDrop","cn","jsxs","jsx","Upload","FileIcon","X"],"mappings":";;;;;;;AA4CA,SAASA,EAAWC,GAAeC,GAA4B;AAC7D,SAAID,IAAQ,OAAaE,EAAaD,EAAE,OAAO,EAAE,GAAGD,GAAO,IACvDA,IAAQ,OAAO,OAAaE,EAAaD,EAAE,WAAW,EAAE,IAAID,IAAQ,MAAM,QAAQ,CAAC,GAAG,IACnFE,EAAaD,EAAE,WAAW,EAAE,IAAID,IAAQ,OAAO,MAAM,QAAQ,CAAC,EAAA,CAAG;AAC1E;AAGA,SAASG,EAAcC,GAAYC,GAA0B;AAC3D,MAAI,CAACA,EAAQ,QAAO;AACpB,QAAMC,IAAQD,EACX,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,OAAO,YAAA,CAAa,EACjC,OAAO,OAAO;AACjB,MAAI,CAACC,EAAM,OAAQ,QAAO;AAC1B,QAAMC,IAAOH,EAAK,KAAK,YAAA,GACjBI,IAAOJ,EAAK,KAAK,YAAA;AACvB,SAAOE,EAAM,KAAK,CAACG,MACbA,EAAK,WAAW,GAAG,IAAUF,EAAK,SAASE,CAAI,IAC/CA,EAAK,SAAS,IAAI,IAAUD,EAAK,WAAWC,EAAK,MAAM,GAAG,EAAE,CAAC,IAC1DD,MAASC,CACjB;AACH;AAMO,MAAMC,IAAaC,EAA4C,SACpE,EAAE,QAAAN,GAAQ,UAAAO,GAAU,SAAAC,GAAS,OAAAC,GAAO,UAAAC,GAAU,UAAAC,GAAU,MAAAC,GAAM,OAAAC,GAAO,UAAAC,GAAU,WAAAC,EAAA,GAC/EC,GACA;AACA,QAAMC,IAAUC,EAAA,GACVC,IAAWC,EAAyB,IAAI,GACxCC,IAAUC,EAAA,GACV,CAACC,GAAUC,CAAW,IAAIC,EAAiB,CAAA,CAAE,GAC7C,CAACC,GAAMC,CAAO,IAAIF,EAAS,EAAK,GAChC,CAAC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