@betterinternship/components 3.2.8 → 3.2.10
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.
|
@@ -5,8 +5,10 @@ declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogP
|
|
|
5
5
|
declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
8
|
+
declare function DialogContent({ className, children, showCloseButton, overlayClassName, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
9
9
|
showCloseButton?: boolean;
|
|
10
|
+
/** Classes for the backdrop, e.g. a lighter tint. */
|
|
11
|
+
overlayClassName?: string;
|
|
10
12
|
}): import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
declare function DialogHeader({ className, divider, ...props }: React.ComponentProps<'div'> & {
|
|
12
14
|
divider?: boolean;
|
|
@@ -15,7 +17,9 @@ declare function DialogFooter({ className, ...props }: React.ComponentProps<'div
|
|
|
15
17
|
declare function DialogDivider({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
16
18
|
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
|
|
17
19
|
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
declare function DialogBottomSheet({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
20
|
+
declare function DialogBottomSheet({ className, children, showCloseButton, overlayClassName, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
19
21
|
showCloseButton?: boolean;
|
|
22
|
+
/** Classes for the backdrop, e.g. a lighter tint. */
|
|
23
|
+
overlayClassName?: string;
|
|
20
24
|
}): import("react/jsx-runtime").JSX.Element;
|
|
21
25
|
export { Dialog, DialogBottomSheet, DialogClose, DialogContent, DialogDescription, DialogDivider, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };
|
|
@@ -15,11 +15,13 @@ function DialogPortal({ ...props }) {
|
|
|
15
15
|
function DialogClose({ ...props }) {
|
|
16
16
|
return jsx(SheetPrimitive.Close, { "data-slot": "dialog-close", ...props });
|
|
17
17
|
}
|
|
18
|
+
// Dialogs share the Sheet's layers (overlay 1100, content 1101), so either
|
|
19
|
+
// can open over the other and both sit above app chrome.
|
|
18
20
|
function DialogOverlay({ className, ...props }) {
|
|
19
|
-
return (jsx(SheetPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn('data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-
|
|
21
|
+
return (jsx(SheetPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn('data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1100] bg-black/30', className), ...props }));
|
|
20
22
|
}
|
|
21
|
-
function DialogContent({ className, children, showCloseButton = true, ...props }) {
|
|
22
|
-
return (jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [jsx(DialogOverlay, {}), jsxs(SheetPrimitive.Content, { "data-slot": "dialog-content", className: cn('bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-
|
|
23
|
+
function DialogContent({ className, children, showCloseButton = true, overlayClassName, ...props }) {
|
|
24
|
+
return (jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [jsx(DialogOverlay, { className: overlayClassName }), jsxs(SheetPrimitive.Content, { "data-slot": "dialog-content", className: cn('bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[1101] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-card border border-border p-6 shadow-card duration-interactive ease-out-strong sm:max-w-lg', className), ...props, children: [children, showCloseButton && (jsxs(SheetPrimitive.Close, { "data-slot": "dialog-close", className: "absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4", children: [jsx(XIcon, {}), jsx("span", { className: "sr-only", children: "Close" })] }))] })] }));
|
|
23
25
|
}
|
|
24
26
|
function DialogHeader({ className, divider = false, ...props }) {
|
|
25
27
|
return (jsx("div", { "data-slot": "dialog-header", className: cn('flex flex-col gap-2 pr-10 text-left', divider && 'border-b border-border pb-4', className), ...props }));
|
|
@@ -36,8 +38,8 @@ function DialogTitle({ className, ...props }) {
|
|
|
36
38
|
function DialogDescription({ className, ...props }) {
|
|
37
39
|
return (jsx(SheetPrimitive.Description, { "data-slot": "dialog-description", className: cn('text-muted-foreground text-sm', className), ...props }));
|
|
38
40
|
}
|
|
39
|
-
function DialogBottomSheet({ className, children, showCloseButton = true, ...props }) {
|
|
40
|
-
return (jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [jsx(DialogOverlay, {}), jsxs(SheetPrimitive.Content, { "data-slot": "dialog-content", className: cn('bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom fixed bottom-0 left-0 right-0 z-
|
|
41
|
+
function DialogBottomSheet({ className, children, showCloseButton = true, overlayClassName, ...props }) {
|
|
42
|
+
return (jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [jsx(DialogOverlay, { className: overlayClassName }), jsxs(SheetPrimitive.Content, { "data-slot": "dialog-content", className: cn('bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom fixed bottom-0 left-0 right-0 z-[1101] w-full max-h-[90dvh] overflow-y-auto rounded-t-card border-t border-border p-6 pb-[max(1.5rem,env(safe-area-inset-bottom))] shadow-card duration-interactive ease-out-strong', className), ...props, children: [children, showCloseButton && (jsxs(SheetPrimitive.Close, { "data-slot": "dialog-close", className: "absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4", children: [jsx(XIcon, {}), jsx("span", { className: "sr-only", children: "Close" })] }))] })] }));
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export { Dialog, DialogBottomSheet, DialogClose, DialogContent, DialogDescription, DialogDivider, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sources":["../../src/components/dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { XIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\nfunction Dialog({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\nfunction DialogOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n className={cn(\n 'data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-
|
|
1
|
+
{"version":3,"file":"dialog.js","sources":["../../src/components/dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { XIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\nfunction Dialog({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\n// Dialogs share the Sheet's layers (overlay 1100, content 1101), so either\n// can open over the other and both sit above app chrome.\nfunction DialogOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n className={cn(\n 'data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1100] bg-black/30',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogContent({\n className,\n children,\n showCloseButton = true,\n overlayClassName,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Content> & {\n showCloseButton?: boolean;\n /** Classes for the backdrop, e.g. a lighter tint. */\n overlayClassName?: string;\n}) {\n return (\n <DialogPortal data-slot=\"dialog-portal\">\n <DialogOverlay className={overlayClassName} />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n className={cn(\n 'bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[1101] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-card border border-border p-6 shadow-card duration-interactive ease-out-strong sm:max-w-lg',\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot=\"dialog-close\"\n className=\"absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4\"\n >\n <XIcon />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n}\n\nfunction DialogHeader({ className, divider = false, ...props }: React.ComponentProps<'div'> & { divider?: boolean }) {\n return (\n <div\n data-slot=\"dialog-header\"\n className={cn('flex flex-col gap-2 pr-10 text-left', divider && 'border-b border-border pb-4', className)}\n {...props}\n />\n );\n}\n\nfunction DialogFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(\n 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogDivider({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"dialog-divider\"\n role=\"separator\"\n className={cn('h-px w-full bg-border', className)}\n {...props}\n />\n );\n}\n\nfunction DialogTitle({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Title>) {\n return (\n <DialogPrimitive.Title\n data-slot=\"dialog-title\"\n className={cn('text-xl leading-snug font-semibold', className)}\n {...props}\n />\n );\n}\n\nfunction DialogDescription({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Description>) {\n return (\n <DialogPrimitive.Description\n data-slot=\"dialog-description\"\n className={cn('text-muted-foreground text-sm', className)}\n {...props}\n />\n );\n}\n\nfunction DialogBottomSheet({\n className,\n children,\n showCloseButton = true,\n overlayClassName,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Content> & {\n showCloseButton?: boolean;\n /** Classes for the backdrop, e.g. a lighter tint. */\n overlayClassName?: string;\n}) {\n return (\n <DialogPortal data-slot=\"dialog-portal\">\n <DialogOverlay className={overlayClassName} />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n className={cn(\n 'bg-background data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom fixed bottom-0 left-0 right-0 z-[1101] w-full max-h-[90dvh] overflow-y-auto rounded-t-card border-t border-border p-6 pb-[max(1.5rem,env(safe-area-inset-bottom))] shadow-card duration-interactive ease-out-strong',\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot=\"dialog-close\"\n className=\"absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4\"\n >\n <XIcon />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n}\n\nexport {\n Dialog,\n DialogBottomSheet,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogDivider,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n"],"names":["_jsx","DialogPrimitive","_jsxs"],"mappings":";;;;;AAMA,SAAS,MAAM,CAAC,EACd,GAAG,KAAK,EAC0C,EAAA;IAClD,OAAOA,GAAA,CAACC,cAAe,CAAC,IAAI,iBAAW,QAAQ,EAAA,GAAK,KAAK,EAAA,CAAI;AAC/D;AAEA,SAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EAC6C,EAAA;IACrD,OAAOD,GAAA,CAACC,cAAe,CAAC,OAAO,iBAAW,gBAAgB,EAAA,GAAK,KAAK,EAAA,CAAI;AAC1E;AAEA,SAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EAC4C,EAAA;IACpD,OAAOD,GAAA,CAACC,cAAe,CAAC,MAAM,iBAAW,eAAe,EAAA,GAAK,KAAK,EAAA,CAAI;AACxE;AAEA,SAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EAC2C,EAAA;IACnD,OAAOD,GAAA,CAACC,cAAe,CAAC,KAAK,iBAAW,cAAc,EAAA,GAAK,KAAK,EAAA,CAAI;AACtE;AAEA;AACA;AACA,SAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EAC6C,EAAA;IACrD,QACED,IAACC,cAAe,CAAC,OAAO,EAAA,EAAA,WAAA,EACZ,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CACX,uLAAuL,EACvL,SAAS,CACV,KACG,KAAK,EAAA,CACT;AAEN;AAEA,S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A,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,SAAS,EAAA,QAAA,EAAA,OAAA,EAAA,CAAa,CAAA,EAAA,CAChB,CACzB,CAAA,EAAA,CACuB,CAAA,EAAA,CACb;AAEnB;;;;"}
|
|
@@ -67,9 +67,16 @@ const FileUpload = React.forwardRef(({ label, name, variant = "compact", accept,
|
|
|
67
67
|
if (disabled)
|
|
68
68
|
return;
|
|
69
69
|
selectFiles(Array.from(event.dataTransfer.files).slice(0, multiple ? undefined : 1));
|
|
70
|
-
}, className: cn(
|
|
70
|
+
}, className: cn(
|
|
71
|
+
// min-w-0: as a grid item the button would otherwise refuse to
|
|
72
|
+
// shrink below its text, overflowing narrow containers (phones).
|
|
73
|
+
"flex w-full min-w-0 cursor-pointer items-center gap-2 border border-input text-left text-sm text-muted-foreground transition-colors hover:border-input-hover hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none disabled:cursor-not-allowed disabled:opacity-60", variant === "dropzone"
|
|
71
74
|
? "min-h-36 flex-col justify-center rounded-card border-solid border-border px-6 py-6 text-center"
|
|
72
|
-
: "min-h-11 rounded-control-lg px-4 py-2", dragging && "border-primary bg-primary-tint", error && "border-destructive"), children: [jsx(Upload, { className: "size-5 shrink-0 text-primary" }), jsx("span", { className: cn("min-w-0
|
|
75
|
+
: "min-h-11 rounded-control-lg px-4 py-2", dragging && "border-primary bg-primary-tint", error && "border-destructive"), children: [jsx(Upload, { className: "size-5 shrink-0 text-primary" }), jsx("span", { className: cn("min-w-0",
|
|
76
|
+
// The dropzone has room to wrap; the compact field truncates.
|
|
77
|
+
variant === "dropzone"
|
|
78
|
+
? "max-w-full text-balance [overflow-wrap:anywhere]"
|
|
79
|
+
: "truncate", fileName && "text-foreground"), children: fileName ?? placeholder ?? "Drop a file here or click to upload" })] }), jsx("input", { ref: (node) => {
|
|
73
80
|
inputRef.current = node;
|
|
74
81
|
if (typeof ref === "function")
|
|
75
82
|
ref(node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload.js","sources":["../../src/components/file-upload.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Upload } from \"lucide-react\";\nimport { cn } from \"@/utils\";\nimport { FieldLabel } from \"./label\";\n\nexport type FileUploadVariant = \"compact\" | \"dropzone\";\nexport type FileRejectReason = \"type\" | \"size\";\nexport type FileUploadProps = {\n label: string;\n name: string;\n variant?: FileUploadVariant;\n /** Same format as the input's `accept`: extensions (\".pdf\") and/or MIME types (\"image/*\"). Also checked on drop. */\n accept?: string;\n /** Files larger than this are rejected through `onReject` instead of being selected. */\n maxSizeMB?: number;\n multiple?: boolean;\n required?: boolean;\n placeholder?: string;\n disabled?: boolean;\n className?: string;\n /**\n * The selected file, when the parent owns it. Pass `null` to clear the field.\n * Leave undefined to let the field remember the last pick itself.\n */\n value?: File | null;\n /** Shown under the field and marks it invalid. */\n error?: string | null;\n onFileSelect?: (file: File | null) => void;\n onFilesSelect?: (files: File[]) => void;\n /** Called with each file that fails `accept` or `maxSizeMB`. */\n onReject?: (file: File, reason: FileRejectReason) => void;\n};\n\n/** True when the file matches one of the `accept` entries (or there are none). */\nfunction matchesAccept(file: File, accept?: string) {\n if (!accept) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept\n .split(\",\")\n .map((entry) => entry.trim().toLowerCase())\n .filter(Boolean)\n .some((entry) =>\n entry.startsWith(\".\")\n ? name.endsWith(entry)\n : entry.endsWith(\"/*\")\n ? type.startsWith(entry.slice(0, -1))\n : type === entry,\n );\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(\n (\n {\n label,\n name,\n variant = \"compact\",\n accept,\n maxSizeMB,\n multiple,\n required,\n placeholder,\n disabled,\n className,\n value,\n error,\n onFileSelect,\n onFilesSelect,\n onReject,\n },\n ref,\n ) => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [pickedName, setPickedName] = React.useState<string | null>(null);\n const [dragging, setDragging] = React.useState(false);\n const errorId = `${name}-error`;\n const controlled = value !== undefined;\n const fileName = controlled ? (value?.name ?? null) : pickedName;\n\n const selectFiles = (files: File[]) => {\n const accepted = files.filter((file) => {\n if (!matchesAccept(file, accept)) {\n onReject?.(file, \"type\");\n return false;\n }\n if (maxSizeMB !== undefined && file.size > maxSizeMB * 1024 * 1024) {\n onReject?.(file, \"size\");\n return false;\n }\n return true;\n });\n // Every file was rejected: keep the current selection as it was.\n if (files.length > 0 && accepted.length === 0) return;\n\n const file = accepted[0] ?? null;\n setPickedName(\n accepted.length > 1\n ? `${accepted.length} files selected`\n : (file?.name ?? null),\n );\n onFileSelect?.(file);\n onFilesSelect?.(accepted);\n };\n const openPicker = () => {\n if (!disabled) inputRef.current?.click();\n };\n\n return (\n <div className={cn(\"grid gap-field-label-gap\", className)}>\n <FieldLabel htmlFor={name}>\n {label}\n {required && <span className=\"text-destructive\"> *</span>}\n </FieldLabel>\n <button\n type=\"button\"\n disabled={disabled}\n onClick={openPicker}\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? errorId : undefined}\n onDragEnter={(event) => {\n event.preventDefault();\n setDragging(true);\n }}\n onDragOver={(event) => {\n event.preventDefault();\n if (!disabled) setDragging(true);\n }}\n onDragLeave={() => setDragging(false)}\n onDrop={(event) => {\n event.preventDefault();\n setDragging(false);\n if (disabled) return;\n selectFiles(\n Array.from(event.dataTransfer.files).slice(\n 0,\n multiple ? undefined : 1,\n ),\n );\n }}\n className={cn(\n \"flex w-full cursor-pointer items-center gap-2 border border-input text-left text-sm text-muted-foreground transition-colors hover:border-input-hover hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none disabled:cursor-not-allowed disabled:opacity-60\",\n variant === \"dropzone\"\n ? \"min-h-36 flex-col justify-center rounded-card border-solid border-border px-6 py-6 text-center\"\n : \"min-h-11 rounded-control-lg px-4 py-2\",\n dragging && \"border-primary bg-primary-tint\",\n error && \"border-destructive\",\n )}\n >\n <Upload className=\"size-5 shrink-0 text-primary\" />\n <span
|
|
1
|
+
{"version":3,"file":"file-upload.js","sources":["../../src/components/file-upload.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Upload } from \"lucide-react\";\nimport { cn } from \"@/utils\";\nimport { FieldLabel } from \"./label\";\n\nexport type FileUploadVariant = \"compact\" | \"dropzone\";\nexport type FileRejectReason = \"type\" | \"size\";\nexport type FileUploadProps = {\n label: string;\n name: string;\n variant?: FileUploadVariant;\n /** Same format as the input's `accept`: extensions (\".pdf\") and/or MIME types (\"image/*\"). Also checked on drop. */\n accept?: string;\n /** Files larger than this are rejected through `onReject` instead of being selected. */\n maxSizeMB?: number;\n multiple?: boolean;\n required?: boolean;\n placeholder?: string;\n disabled?: boolean;\n className?: string;\n /**\n * The selected file, when the parent owns it. Pass `null` to clear the field.\n * Leave undefined to let the field remember the last pick itself.\n */\n value?: File | null;\n /** Shown under the field and marks it invalid. */\n error?: string | null;\n onFileSelect?: (file: File | null) => void;\n onFilesSelect?: (files: File[]) => void;\n /** Called with each file that fails `accept` or `maxSizeMB`. */\n onReject?: (file: File, reason: FileRejectReason) => void;\n};\n\n/** True when the file matches one of the `accept` entries (or there are none). */\nfunction matchesAccept(file: File, accept?: string) {\n if (!accept) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept\n .split(\",\")\n .map((entry) => entry.trim().toLowerCase())\n .filter(Boolean)\n .some((entry) =>\n entry.startsWith(\".\")\n ? name.endsWith(entry)\n : entry.endsWith(\"/*\")\n ? type.startsWith(entry.slice(0, -1))\n : type === entry,\n );\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(\n (\n {\n label,\n name,\n variant = \"compact\",\n accept,\n maxSizeMB,\n multiple,\n required,\n placeholder,\n disabled,\n className,\n value,\n error,\n onFileSelect,\n onFilesSelect,\n onReject,\n },\n ref,\n ) => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [pickedName, setPickedName] = React.useState<string | null>(null);\n const [dragging, setDragging] = React.useState(false);\n const errorId = `${name}-error`;\n const controlled = value !== undefined;\n const fileName = controlled ? (value?.name ?? null) : pickedName;\n\n const selectFiles = (files: File[]) => {\n const accepted = files.filter((file) => {\n if (!matchesAccept(file, accept)) {\n onReject?.(file, \"type\");\n return false;\n }\n if (maxSizeMB !== undefined && file.size > maxSizeMB * 1024 * 1024) {\n onReject?.(file, \"size\");\n return false;\n }\n return true;\n });\n // Every file was rejected: keep the current selection as it was.\n if (files.length > 0 && accepted.length === 0) return;\n\n const file = accepted[0] ?? null;\n setPickedName(\n accepted.length > 1\n ? `${accepted.length} files selected`\n : (file?.name ?? null),\n );\n onFileSelect?.(file);\n onFilesSelect?.(accepted);\n };\n const openPicker = () => {\n if (!disabled) inputRef.current?.click();\n };\n\n return (\n <div className={cn(\"grid gap-field-label-gap\", className)}>\n <FieldLabel htmlFor={name}>\n {label}\n {required && <span className=\"text-destructive\"> *</span>}\n </FieldLabel>\n <button\n type=\"button\"\n disabled={disabled}\n onClick={openPicker}\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? errorId : undefined}\n onDragEnter={(event) => {\n event.preventDefault();\n setDragging(true);\n }}\n onDragOver={(event) => {\n event.preventDefault();\n if (!disabled) setDragging(true);\n }}\n onDragLeave={() => setDragging(false)}\n onDrop={(event) => {\n event.preventDefault();\n setDragging(false);\n if (disabled) return;\n selectFiles(\n Array.from(event.dataTransfer.files).slice(\n 0,\n multiple ? undefined : 1,\n ),\n );\n }}\n className={cn(\n // min-w-0: as a grid item the button would otherwise refuse to\n // shrink below its text, overflowing narrow containers (phones).\n \"flex w-full min-w-0 cursor-pointer items-center gap-2 border border-input text-left text-sm text-muted-foreground transition-colors hover:border-input-hover hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none disabled:cursor-not-allowed disabled:opacity-60\",\n variant === \"dropzone\"\n ? \"min-h-36 flex-col justify-center rounded-card border-solid border-border px-6 py-6 text-center\"\n : \"min-h-11 rounded-control-lg px-4 py-2\",\n dragging && \"border-primary bg-primary-tint\",\n error && \"border-destructive\",\n )}\n >\n <Upload className=\"size-5 shrink-0 text-primary\" />\n <span\n className={cn(\n \"min-w-0\",\n // The dropzone has room to wrap; the compact field truncates.\n variant === \"dropzone\"\n ? \"max-w-full text-balance [overflow-wrap:anywhere]\"\n : \"truncate\",\n fileName && \"text-foreground\",\n )}\n >\n {fileName ?? placeholder ?? \"Drop a file here or click to upload\"}\n </span>\n </button>\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n id={name}\n type=\"file\"\n name={name}\n accept={accept}\n multiple={multiple}\n required={required}\n disabled={disabled}\n onChange={(event) => {\n selectFiles(Array.from(event.target.files ?? []));\n // Let the same file be picked again, e.g. after a rejection.\n event.target.value = \"\";\n }}\n className=\"sr-only\"\n />\n {error && (\n <p id={errorId} role=\"alert\" className=\"m-0 text-xs text-destructive\">\n {error}\n </p>\n )}\n </div>\n );\n },\n);\nFileUpload.displayName = \"FileUpload\";\n"],"names":[],"mappings":";;;;;;;AAmCA;AACA;AACE;AAAa;;;AAGb;;AAEG;;;AAIG;AACA;AACE;AACA;AAEV;;;AAwBI;AACA;AACA;AACA;AACA;AAEA;;;AAGM;AACA;;AAEF;AACE;AACA;;AAEF;AACF;;;;;AAKA;AAEI;;AAGJ;AACA;AACF;;AAEE;AAAe;AACjB;AAEA;;;AAeM;;AAGE;;AACF;;;AAKE;;;;;;;AAaE;;;AAWA;AACE;;AAUJ;;;AAEK;AAAS;AAChB;AASE;;AAEA;;AAWV;AAEF;;"}
|