@adamosuiteservices/ui 2.13.0 → 2.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/file-upload/file-upload.d.ts +11 -3
- package/dist/components/ui/typography/typography.d.ts +1 -1
- package/dist/file-upload.cjs +6 -18
- package/dist/file-upload.js +264 -134
- package/dist/styles.css +1 -1
- package/dist/typography-Bj8oEDuE.cjs +1 -0
- package/dist/typography-MnY0LQoZ.js +50 -0
- package/dist/typography.cjs +1 -1
- package/dist/typography.js +1 -1
- package/docs/components/ui/file-upload.md +882 -0
- package/docs/components/ui/typography.md +48 -8
- package/package.json +1 -1
- package/dist/typography-9EoV0kcN.js +0 -44
- package/dist/typography-DqQZZpkD.cjs +0 -1
|
@@ -3,12 +3,20 @@ export type FileUploadLabels = {
|
|
|
3
3
|
dragDrop?: string;
|
|
4
4
|
selectFile?: string;
|
|
5
5
|
fileRequirements?: string;
|
|
6
|
+
filesSelected?: (count: number) => string;
|
|
6
7
|
};
|
|
7
8
|
export type FileUploadProps = ComponentProps<"div"> & Readonly<{
|
|
8
|
-
selectedFile
|
|
9
|
-
|
|
9
|
+
selectedFile?: File | null;
|
|
10
|
+
selectedFiles?: File[];
|
|
11
|
+
onFileSelect?: (file: File | null) => void;
|
|
12
|
+
onFilesSelect?: (files: File[]) => void;
|
|
13
|
+
onInvalidFile?: (file: File, reason: "extension" | "size") => void;
|
|
10
14
|
acceptedExtensions?: string[];
|
|
11
15
|
maxSizeInMB?: number;
|
|
16
|
+
maxFiles?: number;
|
|
17
|
+
multiple?: boolean;
|
|
18
|
+
filesPosition?: "above" | "below";
|
|
19
|
+
invalid?: boolean;
|
|
12
20
|
labels?: FileUploadLabels;
|
|
13
21
|
}>;
|
|
14
|
-
export declare function FileUpload({ className, selectedFile, onFileSelect, acceptedExtensions, maxSizeInMB, labels, ...props }: FileUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function FileUpload({ className, selectedFile, selectedFiles, onFileSelect, onFilesSelect, onInvalidFile, acceptedExtensions, maxSizeInMB, maxFiles, multiple, filesPosition, invalid, labels, ...props }: FileUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
2
|
declare const typographyVariants: (props?: ({
|
|
3
3
|
variant?: "caption" | "sm" | "lg" | "md" | "xs" | null | undefined;
|
|
4
|
-
color?: "default" | "muted" | null | undefined;
|
|
4
|
+
color?: "default" | "success" | "warning" | "destructive" | "secondary" | "waiting" | "muted" | "primary" | null | undefined;
|
|
5
5
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
6
6
|
declare function Typography({ className, variant, color, asChild, ...props }: React.ComponentProps<"p"> & VariantProps<typeof typographyVariants> & {
|
|
7
7
|
asChild?: boolean;
|
package/dist/file-upload.cjs
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-BB_1_6y_.cjs"),
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`),children:e.jsxRuntimeExports.jsx(l.Icon,{symbol:"text_snippet",className:"adm:text-primary"})}),e.jsxRuntimeExports.jsxs("div",{className:`
|
|
8
|
-
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
9
|
-
`,children:[e.jsxRuntimeExports.jsx("div",{className:"adm:min-w-0 adm:flex-1",children:e.jsxRuntimeExports.jsx(r.Typography,{className:"adm:truncate adm:font-semibold",children:n.name})}),e.jsxRuntimeExports.jsxs(r.Typography,{className:"adm:shrink-0",color:"muted",children:[(n.size/1024/1024).toFixed(1)," MB"]})]}),e.jsxRuntimeExports.jsx(p.Button,{variant:"destructive-medium",onClick:E,type:"button",children:e.jsxRuntimeExports.jsx(l.Icon,{symbol:"delete",className:"adm:text-destructive"})})]}):e.jsxRuntimeExports.jsxs("div",{onDragOver:y,onDragLeave:R,onDrop:b,className:a.cn(`
|
|
10
|
-
adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
|
|
11
|
-
adm:border-2
|
|
12
|
-
`,`
|
|
13
|
-
adm:border-dashed adm:bg-background adm:p-6
|
|
14
|
-
adm:transition-colors
|
|
15
|
-
`,{"adm:border-primary":c,"adm:border-input":!c}),children:[e.jsxRuntimeExports.jsx("div",{className:a.cn(`
|
|
16
|
-
adm:flex adm:items-center adm:justify-center adm:rounded-xl
|
|
17
|
-
adm:bg-primary-50 adm:p-2.5
|
|
18
|
-
`),children:e.jsxRuntimeExports.jsx(l.Icon,{symbol:"text_snippet",className:"adm:text-primary"})}),e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:flex-col adm:items-center adm:gap-2",children:[e.jsxRuntimeExports.jsx(r.Typography,{children:i?.dragDrop||"Drag and drop your file here or"}),e.jsxRuntimeExports.jsxs("label",{htmlFor:"file-upload",children:[e.jsxRuntimeExports.jsx("input",{id:"file-upload",type:"file",accept:h,onChange:v,className:"adm:hidden"}),e.jsxRuntimeExports.jsx(p.Button,{asChild:!0,type:"button",variant:"link",className:"adm:cursor-pointer",children:e.jsxRuntimeExports.jsx("span",{children:i?.selectFile||"Select the file"})})]})]}),e.jsxRuntimeExports.jsx(r.Typography,{className:"adm:text-center",color:"muted",children:i?.fileRequirements||`Allowed files: ${d.join(", ")}. Maximum size ${x} MB.`})]})})}exports.FileUpload=D;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-BB_1_6y_.cjs"),T=require("./button-Day6_fbu.cjs"),w=require("./icon-DPMQJBkA.cjs"),h=require("./typography-Bj8oEDuE.cjs"),g=require("./index-DoxiiusW.cjs"),O=require("react");function U({isDragging:r,isMultiple:a,invalid:s,accept:o,acceptedExtensions:n,maxSizeInMB:x,maxFiles:c,labels:i,onDragOver:j,onDragLeave:b,onDrop:R,onFileChange:u}){return e.jsxRuntimeExports.jsxs("div",{onDragOver:j,onDragLeave:b,onDrop:R,className:g.cn(`
|
|
2
|
+
adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
|
|
3
|
+
adm:border-2
|
|
4
|
+
`,"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",{"adm:border-primary":r&&!s,"adm:border-destructive":s,"adm:border-input":!r&&!s}),children:[e.jsxRuntimeExports.jsx("div",{className:g.cn("adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",s?"adm:bg-destructive/10":"adm:bg-primary-50"),children:e.jsxRuntimeExports.jsx(w.Icon,{symbol:"text_snippet",className:s?"adm:text-destructive":"adm:text-primary"})}),e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:flex-col adm:items-center adm:gap-2",children:[e.jsxRuntimeExports.jsx(h.Typography,{color:s?"destructive":void 0,children:i?.dragDrop||(a?"Drag and drop your files here or":"Drag and drop your file here or")}),e.jsxRuntimeExports.jsxs("label",{htmlFor:"file-upload",children:[e.jsxRuntimeExports.jsx("input",{id:"file-upload",type:"file",accept:o,multiple:a,onChange:u,className:"adm:hidden"}),e.jsxRuntimeExports.jsx(T.Button,{asChild:!0,type:"button",variant:"link",className:"adm:cursor-pointer",children:e.jsxRuntimeExports.jsx("span",{children:i?.selectFile||(a?"Select files":"Select the file")})})]})]}),e.jsxRuntimeExports.jsx(h.Typography,{className:"adm:text-center",color:s?"destructive":"muted",children:i?.fileRequirements||`Allowed files: ${n.join(", ")}. Maximum size ${x} MB${a?`. Up to ${c} files`:""}.`})]})}function V({file:r,invalid:a,onRemove:s}){return e.jsxRuntimeExports.jsxs("div",{className:g.cn("adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",a?"adm:border-destructive adm:bg-destructive/5":"adm:border-input adm:bg-muted"),children:[e.jsxRuntimeExports.jsx("div",{className:g.cn("adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",a?"adm:bg-destructive/10":"adm:bg-primary-50"),children:e.jsxRuntimeExports.jsx(w.Icon,{symbol:"text_snippet",className:a?"adm:text-destructive":"adm:text-primary"})}),e.jsxRuntimeExports.jsxs("div",{className:`
|
|
5
|
+
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
6
|
+
`,children:[e.jsxRuntimeExports.jsx("div",{className:"adm:min-w-0 adm:flex-1",children:e.jsxRuntimeExports.jsx(h.Typography,{className:"adm:truncate adm:font-semibold",children:r.name})}),e.jsxRuntimeExports.jsxs(h.Typography,{className:"adm:shrink-0",color:"muted",children:[(r.size/1024/1024).toFixed(1)," MB"]})]}),e.jsxRuntimeExports.jsx(T.Button,{variant:"destructive-medium",onClick:s,type:"button",children:e.jsxRuntimeExports.jsx(w.Icon,{symbol:"delete",className:"adm:text-destructive"})})]})}function A({files:r,isMultiple:a,invalid:s,labels:o,onRemoveFile:n,onClearAll:x}){return r.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:flex-col adm:gap-3",children:[a&&r.length>1&&e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:items-center adm:justify-between",children:[e.jsxRuntimeExports.jsx(h.Typography,{className:"adm:text-sm adm:font-medium",color:s?"destructive":void 0,children:o?.filesSelected?.(r.length)||`${r.length} file${r.length!==1?"s":""} selected`}),e.jsxRuntimeExports.jsx(T.Button,{variant:"ghost",size:"sm",onClick:x,type:"button",children:"Clear all"})]}),r.map((c,i)=>e.jsxRuntimeExports.jsx(V,{file:c,invalid:s,onRemove:()=>n(i)},`${c.name}-${i}`))]})}function _({className:r,selectedFile:a,selectedFiles:s,onFileSelect:o,onFilesSelect:n,onInvalidFile:x,acceptedExtensions:c=[".xls",".xlsx",".numbers"],maxSizeInMB:i=50,maxFiles:j=10,multiple:b=!1,filesPosition:R="below",invalid:u=!1,labels:y,...$}){const[q,E]=O.useState(!1),z=c.join(","),k=i*1024*1024,m=b||s!==void 0||n!==void 0,p=m?s||[]:a?[a]:[],B=t=>{t.preventDefault(),E(!0)},F=t=>{t.preventDefault(),E(!1)},I=t=>{if(t.preventDefault(),E(!1),m){const l=Array.from(t.dataTransfer.files).filter(v);if(l.length>0){const C=[...s||[],...l].slice(0,j);n&&n(C)}}else{const d=t.dataTransfer.files[0];d&&v(d)&&o&&o(d)}},L=t=>{if(m){const l=(t.target.files?Array.from(t.target.files):[]).filter(v);if(l.length>0){const C=[...s||[],...l].slice(0,j);n&&n(C)}}else{const d=t.target.files?.[0];d&&v(d)&&o&&o(d)}t.target.value=""},N=t=>{if(m){const d=p.filter((l,f)=>f!==t);n&&n(d)}else o&&o(null)},v=t=>{const d=t.name.substring(t.name.lastIndexOf(".")),l=c.includes(d.toLowerCase()),f=t.size<=k;return!l&&x?x(t,"extension"):!f&&x&&x(t,"size"),l&&f},D=()=>{m?n&&n([]):o&&o(null)};return e.jsxRuntimeExports.jsxs("div",{className:g.cn("adm:flex adm:flex-col adm:gap-4",r),...$,children:[m&&R==="above"&&e.jsxRuntimeExports.jsx(A,{files:p,isMultiple:m,invalid:u,labels:y,onRemoveFile:N,onClearAll:D}),(m||p.length===0)&&e.jsxRuntimeExports.jsx(U,{isDragging:q,isMultiple:m,invalid:u,accept:z,acceptedExtensions:c,maxSizeInMB:i,maxFiles:j,labels:y,onDragOver:B,onDragLeave:F,onDrop:I,onFileChange:L}),!m&&p.length>0&&e.jsxRuntimeExports.jsx(A,{files:p,isMultiple:m,invalid:u,labels:y,onRemoveFile:N,onClearAll:D}),m&&R==="below"&&e.jsxRuntimeExports.jsx(A,{files:p,isMultiple:m,invalid:u,labels:y,onRemoveFile:N,onClearAll:D})]})}exports.FileUpload=_;
|
package/dist/file-upload.js
CHANGED
|
@@ -1,146 +1,276 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-BzflLqGi.js";
|
|
2
|
-
import { B as
|
|
3
|
-
import { I as
|
|
4
|
-
import { T as
|
|
5
|
-
import { c as
|
|
6
|
-
import { useState as
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { B as z } from "./button-Bn4LFAa9.js";
|
|
3
|
+
import { I as R } from "./icon-DKAhvlX_.js";
|
|
4
|
+
import { T as g } from "./typography-MnY0LQoZ.js";
|
|
5
|
+
import { c as j } from "./index-CRiPKpXj.js";
|
|
6
|
+
import { useState as _ } from "react";
|
|
7
|
+
function U({
|
|
8
|
+
isDragging: s,
|
|
9
|
+
isMultiple: t,
|
|
10
|
+
invalid: r,
|
|
11
|
+
accept: l,
|
|
12
|
+
acceptedExtensions: d,
|
|
13
|
+
maxSizeInMB: c,
|
|
14
|
+
maxFiles: f,
|
|
15
|
+
labels: o,
|
|
16
|
+
onDragOver: h,
|
|
17
|
+
onDragLeave: N,
|
|
18
|
+
onDrop: v,
|
|
19
|
+
onFileChange: u
|
|
15
20
|
}) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
return /* @__PURE__ */ e.jsxs(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
onDragOver: h,
|
|
25
|
+
onDragLeave: N,
|
|
26
|
+
onDrop: v,
|
|
27
|
+
className: j(
|
|
28
|
+
`
|
|
29
|
+
adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
|
|
30
|
+
adm:border-2
|
|
31
|
+
`,
|
|
32
|
+
"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",
|
|
33
|
+
{
|
|
34
|
+
"adm:border-primary": s && !r,
|
|
35
|
+
"adm:border-destructive": r,
|
|
36
|
+
"adm:border-input": !s && !r
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ e.jsx(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
className: j(
|
|
44
|
+
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
45
|
+
r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
46
|
+
),
|
|
47
|
+
children: /* @__PURE__ */ e.jsx(
|
|
48
|
+
R,
|
|
49
|
+
{
|
|
50
|
+
symbol: "text_snippet",
|
|
51
|
+
className: r ? "adm:text-destructive" : "adm:text-primary"
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", children: [
|
|
57
|
+
/* @__PURE__ */ e.jsx(g, { color: r ? "destructive" : void 0, children: o?.dragDrop || (t ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
|
|
58
|
+
/* @__PURE__ */ e.jsxs("label", { htmlFor: "file-upload", children: [
|
|
59
|
+
/* @__PURE__ */ e.jsx(
|
|
60
|
+
"input",
|
|
61
|
+
{
|
|
62
|
+
id: "file-upload",
|
|
63
|
+
type: "file",
|
|
64
|
+
accept: l,
|
|
65
|
+
multiple: t,
|
|
66
|
+
onChange: u,
|
|
67
|
+
className: "adm:hidden"
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ e.jsx(
|
|
71
|
+
z,
|
|
72
|
+
{
|
|
73
|
+
asChild: !0,
|
|
74
|
+
type: "button",
|
|
75
|
+
variant: "link",
|
|
76
|
+
className: "adm:cursor-pointer",
|
|
77
|
+
children: /* @__PURE__ */ e.jsx("span", { children: o?.selectFile || (t ? "Select files" : "Select the file") })
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
] })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ e.jsx(g, { className: "adm:text-center", color: r ? "destructive" : "muted", children: o?.fileRequirements || `Allowed files: ${d.join(", ")}. Maximum size ${c} MB${t ? `. Up to ${f} files` : ""}.` })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
function q({ file: s, invalid: t, onRemove: r }) {
|
|
88
|
+
return /* @__PURE__ */ e.jsxs(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
className: j(
|
|
92
|
+
"adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",
|
|
93
|
+
t ? "adm:border-destructive adm:bg-destructive/5" : "adm:border-input adm:bg-muted"
|
|
94
|
+
),
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ e.jsx(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
className: j(
|
|
100
|
+
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
101
|
+
t ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
102
|
+
),
|
|
103
|
+
children: /* @__PURE__ */ e.jsx(
|
|
104
|
+
R,
|
|
105
|
+
{
|
|
106
|
+
symbol: "text_snippet",
|
|
107
|
+
className: t ? "adm:text-destructive" : "adm:text-primary"
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ e.jsxs(
|
|
113
|
+
"div",
|
|
114
|
+
{
|
|
115
|
+
className: `
|
|
116
|
+
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
117
|
+
`,
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ e.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ e.jsx(g, { className: "adm:truncate adm:font-semibold", children: s.name }) }),
|
|
120
|
+
/* @__PURE__ */ e.jsxs(g, { className: "adm:shrink-0", color: "muted", children: [
|
|
121
|
+
(s.size / 1024 / 1024).toFixed(1),
|
|
122
|
+
" MB"
|
|
123
|
+
] })
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
/* @__PURE__ */ e.jsx(
|
|
128
|
+
z,
|
|
129
|
+
{
|
|
130
|
+
variant: "destructive-medium",
|
|
131
|
+
onClick: r,
|
|
132
|
+
type: "button",
|
|
133
|
+
children: /* @__PURE__ */ e.jsx(R, { symbol: "delete", className: "adm:text-destructive" })
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
function $({ files: s, isMultiple: t, invalid: r, labels: l, onRemoveFile: d, onClearAll: c }) {
|
|
141
|
+
return s.length === 0 ? null : /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
|
|
142
|
+
t && s.length > 1 && /* @__PURE__ */ e.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
|
|
143
|
+
/* @__PURE__ */ e.jsx(g, { className: "adm:text-sm adm:font-medium", color: r ? "destructive" : void 0, children: l?.filesSelected?.(s.length) || `${s.length} file${s.length !== 1 ? "s" : ""} selected` }),
|
|
144
|
+
/* @__PURE__ */ e.jsx(
|
|
145
|
+
z,
|
|
146
|
+
{
|
|
147
|
+
variant: "ghost",
|
|
148
|
+
size: "sm",
|
|
149
|
+
onClick: c,
|
|
150
|
+
type: "button",
|
|
151
|
+
children: "Clear all"
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] }),
|
|
155
|
+
s.map((f, o) => /* @__PURE__ */ e.jsx(
|
|
156
|
+
q,
|
|
157
|
+
{
|
|
158
|
+
file: f,
|
|
159
|
+
invalid: r,
|
|
160
|
+
onRemove: () => d(o)
|
|
161
|
+
},
|
|
162
|
+
`${f.name}-${o}`
|
|
163
|
+
))
|
|
164
|
+
] });
|
|
165
|
+
}
|
|
166
|
+
function Q({
|
|
167
|
+
className: s,
|
|
168
|
+
selectedFile: t,
|
|
169
|
+
selectedFiles: r,
|
|
170
|
+
onFileSelect: l,
|
|
171
|
+
onFilesSelect: d,
|
|
172
|
+
onInvalidFile: c,
|
|
173
|
+
acceptedExtensions: f = [".xls", ".xlsx", ".numbers"],
|
|
174
|
+
maxSizeInMB: o = 50,
|
|
175
|
+
maxFiles: h = 10,
|
|
176
|
+
multiple: N = !1,
|
|
177
|
+
filesPosition: v = "below",
|
|
178
|
+
invalid: u = !1,
|
|
179
|
+
labels: b,
|
|
180
|
+
...k
|
|
181
|
+
}) {
|
|
182
|
+
const [B, D] = _(!1), L = f.join(","), T = o * 1024 * 1024, m = N || r !== void 0 || d !== void 0, x = m ? r || [] : t ? [t] : [], F = (a) => {
|
|
183
|
+
a.preventDefault(), D(!0);
|
|
184
|
+
}, I = (a) => {
|
|
185
|
+
a.preventDefault(), D(!1);
|
|
186
|
+
}, O = (a) => {
|
|
187
|
+
if (a.preventDefault(), D(!1), m) {
|
|
188
|
+
const i = Array.from(a.dataTransfer.files).filter(y);
|
|
189
|
+
if (i.length > 0) {
|
|
190
|
+
const w = [...r || [], ...i].slice(0, h);
|
|
191
|
+
d && d(w);
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
const n = a.dataTransfer.files[0];
|
|
195
|
+
n && y(n) && l && l(n);
|
|
196
|
+
}
|
|
197
|
+
}, V = (a) => {
|
|
198
|
+
if (m) {
|
|
199
|
+
const i = (a.target.files ? Array.from(a.target.files) : []).filter(y);
|
|
200
|
+
if (i.length > 0) {
|
|
201
|
+
const w = [...r || [], ...i].slice(0, h);
|
|
202
|
+
d && d(w);
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
const n = a.target.files?.[0];
|
|
206
|
+
n && y(n) && l && l(n);
|
|
207
|
+
}
|
|
208
|
+
a.target.value = "";
|
|
209
|
+
}, C = (a) => {
|
|
210
|
+
if (m) {
|
|
211
|
+
const n = x.filter((i, p) => p !== a);
|
|
212
|
+
d && d(n);
|
|
213
|
+
} else
|
|
214
|
+
l && l(null);
|
|
20
215
|
}, y = (a) => {
|
|
21
|
-
a.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const d = a.target.files?.[0];
|
|
26
|
-
d && p(d) && t(d);
|
|
27
|
-
}, D = () => {
|
|
28
|
-
t(null);
|
|
29
|
-
}, p = (a) => {
|
|
30
|
-
const d = a.name.substring(a.name.lastIndexOf("."));
|
|
31
|
-
return n.includes(d.toLowerCase()) && a.size <= g;
|
|
216
|
+
const n = a.name.substring(a.name.lastIndexOf(".")), i = f.includes(n.toLowerCase()), p = a.size <= T;
|
|
217
|
+
return !i && c ? c(a, "extension") : !p && c && c(a, "size"), i && p;
|
|
218
|
+
}, A = () => {
|
|
219
|
+
m ? d && d([]) : l && l(null);
|
|
32
220
|
};
|
|
33
|
-
return /* @__PURE__ */ e.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"div",
|
|
221
|
+
return /* @__PURE__ */ e.jsxs("div", { className: j("adm:flex adm:flex-col adm:gap-4", s), ...k, children: [
|
|
222
|
+
m && v === "above" && /* @__PURE__ */ e.jsx(
|
|
223
|
+
$,
|
|
37
224
|
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"div",
|
|
45
|
-
{
|
|
46
|
-
className: s(`
|
|
47
|
-
adm:flex adm:items-center adm:justify-center adm:rounded-xl
|
|
48
|
-
adm:bg-primary-50 adm:p-2.5
|
|
49
|
-
`),
|
|
50
|
-
children: /* @__PURE__ */ e.jsx(o, { symbol: "text_snippet", className: "adm:text-primary" })
|
|
51
|
-
}
|
|
52
|
-
),
|
|
53
|
-
/* @__PURE__ */ e.jsxs(
|
|
54
|
-
"div",
|
|
55
|
-
{
|
|
56
|
-
className: `
|
|
57
|
-
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
58
|
-
`,
|
|
59
|
-
children: [
|
|
60
|
-
/* @__PURE__ */ e.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ e.jsx(m, { className: "adm:truncate adm:font-semibold", children: r.name }) }),
|
|
61
|
-
/* @__PURE__ */ e.jsxs(m, { className: "adm:shrink-0", color: "muted", children: [
|
|
62
|
-
(r.size / 1024 / 1024).toFixed(1),
|
|
63
|
-
" MB"
|
|
64
|
-
] })
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ e.jsx(
|
|
69
|
-
f,
|
|
70
|
-
{
|
|
71
|
-
variant: "destructive-medium",
|
|
72
|
-
onClick: D,
|
|
73
|
-
type: "button",
|
|
74
|
-
children: /* @__PURE__ */ e.jsx(o, { symbol: "delete", className: "adm:text-destructive" })
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
]
|
|
225
|
+
files: x,
|
|
226
|
+
isMultiple: m,
|
|
227
|
+
invalid: u,
|
|
228
|
+
labels: b,
|
|
229
|
+
onRemoveFile: C,
|
|
230
|
+
onClearAll: A
|
|
78
231
|
}
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/* @__PURE__ */ e.jsxs(
|
|
83
|
-
"div",
|
|
232
|
+
),
|
|
233
|
+
(m || x.length === 0) && /* @__PURE__ */ e.jsx(
|
|
234
|
+
U,
|
|
84
235
|
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
id: "file-upload",
|
|
120
|
-
type: "file",
|
|
121
|
-
accept: j,
|
|
122
|
-
onChange: N,
|
|
123
|
-
className: "adm:hidden"
|
|
124
|
-
}
|
|
125
|
-
),
|
|
126
|
-
/* @__PURE__ */ e.jsx(
|
|
127
|
-
f,
|
|
128
|
-
{
|
|
129
|
-
asChild: !0,
|
|
130
|
-
type: "button",
|
|
131
|
-
variant: "link",
|
|
132
|
-
className: "adm:cursor-pointer",
|
|
133
|
-
children: /* @__PURE__ */ e.jsx("span", { children: i?.selectFile || "Select the file" })
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
] })
|
|
137
|
-
] }),
|
|
138
|
-
/* @__PURE__ */ e.jsx(m, { className: "adm:text-center", color: "muted", children: i?.fileRequirements || `Allowed files: ${n.join(", ")}. Maximum size ${c} MB.` })
|
|
139
|
-
]
|
|
236
|
+
isDragging: B,
|
|
237
|
+
isMultiple: m,
|
|
238
|
+
invalid: u,
|
|
239
|
+
accept: L,
|
|
240
|
+
acceptedExtensions: f,
|
|
241
|
+
maxSizeInMB: o,
|
|
242
|
+
maxFiles: h,
|
|
243
|
+
labels: b,
|
|
244
|
+
onDragOver: F,
|
|
245
|
+
onDragLeave: I,
|
|
246
|
+
onDrop: O,
|
|
247
|
+
onFileChange: V
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
!m && x.length > 0 && /* @__PURE__ */ e.jsx(
|
|
251
|
+
$,
|
|
252
|
+
{
|
|
253
|
+
files: x,
|
|
254
|
+
isMultiple: m,
|
|
255
|
+
invalid: u,
|
|
256
|
+
labels: b,
|
|
257
|
+
onRemoveFile: C,
|
|
258
|
+
onClearAll: A
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
m && v === "below" && /* @__PURE__ */ e.jsx(
|
|
262
|
+
$,
|
|
263
|
+
{
|
|
264
|
+
files: x,
|
|
265
|
+
isMultiple: m,
|
|
266
|
+
invalid: u,
|
|
267
|
+
labels: b,
|
|
268
|
+
onRemoveFile: C,
|
|
269
|
+
onClearAll: A
|
|
140
270
|
}
|
|
141
271
|
)
|
|
142
|
-
|
|
272
|
+
] });
|
|
143
273
|
}
|
|
144
274
|
export {
|
|
145
|
-
|
|
275
|
+
Q as FileUpload
|
|
146
276
|
};
|