@solibo/solibo-ui 0.2.13 → 0.2.15
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/assets/index.css +1 -1
- package/dist/assets/index10.css +0 -1
- package/dist/assets/index11.css +1 -1
- package/dist/assets/index12.css +1 -1
- package/dist/assets/index13.css +1 -1
- package/dist/assets/index14.css +1 -1
- package/dist/assets/index15.css +1 -1
- package/dist/assets/index16.css +1 -1
- package/dist/assets/index17.css +1 -1
- package/dist/assets/index18.css +1 -1
- package/dist/assets/index19.css +1 -0
- package/dist/assets/index2.css +1 -1
- package/dist/assets/index20.css +1 -0
- package/dist/assets/index21.css +1 -0
- package/dist/assets/index22.css +1 -0
- package/dist/assets/index23.css +1 -0
- package/dist/assets/index24.css +1 -0
- package/dist/assets/index25.css +1 -0
- package/dist/assets/index26.css +1 -0
- package/dist/assets/index27.css +1 -0
- package/dist/assets/index3.css +1 -1
- package/dist/assets/index4.css +1 -1
- package/dist/assets/index5.css +1 -1
- package/dist/assets/index6.css +1 -1
- package/dist/assets/index7.css +1 -1
- package/dist/assets/index8.css +1 -0
- package/dist/assets/index9.css +1 -1
- package/dist/assets/styles.css +1 -0
- package/dist/components/accordion/index.cjs +1 -1
- package/dist/components/accordion/index.cjs.map +1 -1
- package/dist/components/accordion/index.js +15 -29
- package/dist/components/accordion/index.js.map +1 -1
- package/dist/components/aside/index.cjs +1 -1
- package/dist/components/aside/index.cjs.map +1 -1
- package/dist/components/aside/index.js +19 -17
- package/dist/components/aside/index.js.map +1 -1
- package/dist/components/banner/index.cjs +1 -1
- package/dist/components/banner/index.cjs.map +1 -1
- package/dist/components/banner/index.js +18 -18
- package/dist/components/banner/index.js.map +1 -1
- package/dist/components/branding/index.cjs +1 -1
- package/dist/components/branding/index.cjs.map +1 -1
- package/dist/components/branding/index.js +11 -11
- package/dist/components/branding/index.js.map +1 -1
- package/dist/components/button/index.cjs +1 -1
- package/dist/components/button/index.cjs.map +1 -1
- package/dist/components/button/index.js +48 -30
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/card/index.cjs +1 -1
- package/dist/components/card/index.cjs.map +1 -1
- package/dist/components/card/index.js +34 -20
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.cjs +2 -0
- package/dist/components/checkbox/index.cjs.map +1 -0
- package/dist/components/checkbox/index.js +32 -0
- package/dist/components/checkbox/index.js.map +1 -0
- package/dist/components/component/index.cjs +1 -1
- package/dist/components/component/index.cjs.map +1 -1
- package/dist/components/component/index.js +15 -15
- package/dist/components/component/index.js.map +1 -1
- package/dist/components/dialog/index.cjs +1 -1
- package/dist/components/dialog/index.cjs.map +1 -1
- package/dist/components/dialog/index.js +30 -31
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/document/index.cjs +2 -0
- package/dist/components/document/index.cjs.map +1 -0
- package/dist/components/document/index.js +53 -0
- package/dist/components/document/index.js.map +1 -0
- package/dist/components/dropdown/index.cjs +1 -1
- package/dist/components/dropdown/index.cjs.map +1 -1
- package/dist/components/dropdown/index.js +31 -12
- package/dist/components/dropdown/index.js.map +1 -1
- package/dist/components/dropzone/index.cjs +2 -0
- package/dist/components/dropzone/index.cjs.map +1 -0
- package/dist/components/dropzone/index.js +63 -0
- package/dist/components/dropzone/index.js.map +1 -0
- package/dist/components/editor/index.cjs +21 -21
- package/dist/components/editor/index.cjs.map +1 -1
- package/dist/components/editor/index.js +1383 -1377
- package/dist/components/editor/index.js.map +1 -1
- package/dist/components/figure/index.cjs +1 -1
- package/dist/components/figure/index.cjs.map +1 -1
- package/dist/components/figure/index.js +6 -6
- package/dist/components/figure/index.js.map +1 -1
- package/dist/components/footer/index.cjs +2 -0
- package/dist/components/footer/index.cjs.map +1 -0
- package/dist/components/footer/index.js +15 -0
- package/dist/components/footer/index.js.map +1 -0
- package/dist/components/form/index.cjs +2 -0
- package/dist/components/form/index.cjs.map +1 -0
- package/dist/components/form/index.js +17 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/grid/index.cjs +2 -0
- package/dist/components/grid/index.cjs.map +1 -0
- package/dist/components/grid/index.js +140 -0
- package/dist/components/grid/index.js.map +1 -0
- package/dist/components/header/index.cjs +1 -1
- package/dist/components/header/index.cjs.map +1 -1
- package/dist/components/header/index.js +11 -10
- package/dist/components/header/index.js.map +1 -1
- package/dist/components/icon/index.cjs +1 -1
- package/dist/components/icon/index.cjs.map +1 -1
- package/dist/components/icon/index.js +53 -31
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/input/index.cjs +1 -1
- package/dist/components/input/index.cjs.map +1 -1
- package/dist/components/input/index.js +21 -17
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/layout/index.cjs +2 -0
- package/dist/components/layout/index.cjs.map +1 -0
- package/dist/components/layout/index.js +17 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/link/index.cjs +1 -1
- package/dist/components/link/index.cjs.map +1 -1
- package/dist/components/link/index.js +8 -8
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/list/index.cjs +1 -1
- package/dist/components/list/index.cjs.map +1 -1
- package/dist/components/list/index.js +6 -6
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/loading/index.cjs +2 -0
- package/dist/components/loading/index.cjs.map +1 -0
- package/dist/components/loading/index.js +99 -0
- package/dist/components/loading/index.js.map +1 -0
- package/dist/components/nav/index.cjs +1 -1
- package/dist/components/nav/index.cjs.map +1 -1
- package/dist/components/nav/index.js +92 -24
- package/dist/components/nav/index.js.map +1 -1
- package/dist/components/picture/index.cjs +2 -0
- package/dist/components/picture/index.cjs.map +1 -0
- package/dist/components/picture/index.js +150 -0
- package/dist/components/picture/index.js.map +1 -0
- package/dist/components/toggle/index.cjs +2 -0
- package/dist/components/toggle/index.cjs.map +1 -0
- package/dist/components/toggle/index.js +39 -0
- package/dist/components/toggle/index.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +165 -21
- package/dist/index.js +40 -20
- package/dist/index.js.map +1 -1
- package/dist/styles.module-B_pXIacc.cjs +2 -0
- package/dist/styles.module-B_pXIacc.cjs.map +1 -0
- package/dist/styles.module-BhmNqlYd.js +7 -0
- package/dist/styles.module-BhmNqlYd.js.map +1 -0
- package/package.json +3 -3
- package/dist/jsx-runtime-BJcCX4ED.cjs +0 -23
- package/dist/jsx-runtime-BJcCX4ED.cjs.map +0 -1
- package/dist/jsx-runtime-CDbhiqmm.js +0 -280
- package/dist/jsx-runtime-CDbhiqmm.js.map +0 -1
|
@@ -1,15 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
1
|
+
import { jsxs as t, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { t as c } from "../../classix-DG18itHa.js";
|
|
3
|
+
import '../../assets/index15.css';const _ = "_dropdown_1nq87_1", a = "_inline_1nq87_15", p = "_label_1nq87_25", n = {
|
|
4
|
+
dropdown: _,
|
|
5
|
+
inline: a,
|
|
6
|
+
label: p
|
|
7
|
+
}, b = ({ children: r, inline: s, label: e, placeholder: o, ...i }) => {
|
|
8
|
+
const l = /* @__PURE__ */ t(
|
|
9
|
+
"select",
|
|
10
|
+
{
|
|
11
|
+
className: c(n.dropdown, s && n.inline),
|
|
12
|
+
...i,
|
|
13
|
+
children: [
|
|
14
|
+
o && /* @__PURE__ */ d(
|
|
15
|
+
"option",
|
|
16
|
+
{
|
|
17
|
+
value: "",
|
|
18
|
+
hidden: !0,
|
|
19
|
+
children: o
|
|
20
|
+
}
|
|
21
|
+
),
|
|
22
|
+
r
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
return e ? /* @__PURE__ */ t("label", { className: n.label, children: [
|
|
27
|
+
e,
|
|
28
|
+
l
|
|
29
|
+
] }) : l;
|
|
30
|
+
};
|
|
12
31
|
export {
|
|
13
|
-
|
|
32
|
+
b as Dropdown
|
|
14
33
|
};
|
|
15
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/dropdown/index.tsx"],"sourcesContent":["import styles from './styles.module.css';\n\nexport type DropdownProps = {\n children?: React.ReactNode;\n};\n\nexport const Dropdown = ({ children, ...props }: DropdownProps) => {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/dropdown/index.tsx"],"sourcesContent":["import cx from 'classix';\n\nimport styles from './styles.module.css';\n\nexport type DropdownProps = React.SelectHTMLAttributes<HTMLSelectElement> & {\n children?: React.ReactNode;\n inline?: boolean;\n label?: string;\n placeholder?: string;\n};\n\nexport const Dropdown = ({ children, inline, label, placeholder, ...props }: DropdownProps) => {\n const selectElement = (\n <select\n className={cx(styles.dropdown, inline && styles.inline)}\n {...props}\n >\n {placeholder && (\n <option\n value={''}\n hidden\n >\n {placeholder}\n </option>\n )}\n {children}\n </select>\n );\n\n if (!label) {\n return selectElement;\n }\n\n return (\n <label className={styles.label}>\n {label}\n {selectElement}\n </label>\n );\n};\n"],"names":["Dropdown","children","inline","label","placeholder","props","selectElement","jsxs","cx","styles","jsx"],"mappings":";;;;;;GAWaA,IAAW,CAAC,EAAE,UAAAC,GAAU,QAAAC,GAAQ,OAAAC,GAAO,aAAAC,GAAa,GAAGC,QAA2B;AAC7F,QAAMC,IACJ,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAGC,EAAO,UAAUP,KAAUO,EAAO,MAAM;AAAA,MACrD,GAAGJ;AAAA,MAEH,UAAA;AAAA,QAAAD,KACC,gBAAAM;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,YACP,QAAM;AAAA,YAEL,UAAAN;AAAA,UAAA;AAAA,QAAA;AAAA,QAGJH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIL,SAAKE,IAKH,gBAAAI,EAAC,SAAA,EAAM,WAAWE,EAAO,OACtB,UAAA;AAAA,IAAAN;AAAA,IACAG;AAAA,EAAA,GACH,IAPOA;AASX;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index14.css');const l=require("react/jsx-runtime"),T=require("../../classix-5H4IWnMA.cjs"),o=require("react"),_=require("../icon/index.cjs"),q="_dropzone_1cqsl_1",M="_highlight_1cqsl_41",z={dropzone:q,highlight:M},I=e=>{var d;const[f,y]=o.useState(!1),[F,v]=o.useState({empty:[],oversize:[],wrongType:[]}),[p,x]=o.useState([]),[D,a]=o.useState(!1),r=(t,i)=>s=>{s.preventDefault(),s.stopPropagation(),t(i)},c=r(a,!0),S=r(a,!1),g=t=>{if(!t)return;const i=Array.from(t),s=i.filter(n=>n.size===0),u=e.maxFileSizeMB?i.filter(n=>n.size>e.maxFileSizeMB*1024*1024):[],m=e.mimeTypes?i.filter(n=>{var h;return!((h=e.mimeTypes)!=null&&h.includes(n.type))}):[],j=i.filter(n=>n.size>0&&(e.maxFileSizeMB?n.size<=e.maxFileSizeMB*1024*1024:!0)&&(e.mimeTypes?e.mimeTypes.includes(n.type):!0));x(j),s.length>0||u.length>0||m.length>0?(v({empty:s,oversize:u,wrongType:m}),y(!0),console.log("validFiles",p),console.log("invalidFiles",F)):e.onUpload(t),a(!1)};return l.jsxs("div",{className:T.t(z.dropzone,D?z.highlight:""),onDragEnter:c,onDragLeave:S,onDragOver:c,onDrop:t=>{var i;t.preventDefault(),g((i=t.dataTransfer)==null?void 0:i.files)},children:[f&&l.jsx(l.Fragment,{}),l.jsxs("label",{htmlFor:e.inputId??"file-upload",children:[l.jsx(_.Icon,{name:"upload",size:"large"}),l.jsx("span",{children:e.label}),l.jsx("input",{type:"file",multiple:e.isMultiple,accept:(d=e.mimeTypes)==null?void 0:d.join(", "),id:e.inputId??"file-upload",onChange:t=>g(t.target.files)})]})]})};exports.Dropzone=I;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/dropzone/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useState } from 'react';\n\nimport { Icon } from '@/components/icon';\n\nimport styles from './styles.module.css';\n\nexport type DropzoneProps = {\n allowDirectoryUpload?: boolean;\n inputId?: string;\n isMultiple?: boolean;\n label?: string;\n maxFileSizeMB?: number;\n mimeTypes?: string[];\n onUpload: (uploadContent: File[] | FileList) => void;\n};\n\nexport const Dropzone = (props: DropzoneProps) => {\n const [showWarning, setShowWarning] = useState(false);\n const [invalidFiles, setInvalidFiles] = useState<{\n empty: File[];\n oversize: File[];\n wrongType: File[];\n }>({ empty: [], oversize: [], wrongType: [] });\n const [validFiles, setValidFiles] = useState<File[]>([]);\n const [dragging, setDragging] = useState(false);\n\n const makeDragHandler = (set: (v: boolean) => void, value: boolean) => (e: React.DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n set(value);\n };\n\n const onDragIn = makeDragHandler(setDragging, true);\n const onDragOut = makeDragHandler(setDragging, false);\n\n const handleUpload = (files: FileList | null) => {\n if (!files) {\n return;\n }\n\n const fileList = Array.from(files);\n\n const emptyFiles = fileList.filter((file) => file.size === 0);\n const oversizeFiles = props.maxFileSizeMB\n ? fileList.filter((file) => file.size > props.maxFileSizeMB! * 1024 * 1024)\n : [];\n const unsupportedFiles = props.mimeTypes\n ? fileList.filter((file) => !props.mimeTypes?.includes(file.type))\n : [];\n const validatedFiles = fileList.filter(\n (file) =>\n file.size > 0 &&\n (props.maxFileSizeMB ? file.size <= props.maxFileSizeMB * 1024 * 1024 : true) &&\n (props.mimeTypes ? props.mimeTypes.includes(file.type) : true)\n );\n\n setValidFiles(validatedFiles);\n\n if (emptyFiles.length > 0 || oversizeFiles.length > 0 || unsupportedFiles.length > 0) {\n setInvalidFiles({ empty: emptyFiles, oversize: oversizeFiles, wrongType: unsupportedFiles });\n setShowWarning(true);\n console.log('validFiles', validFiles);\n console.log('invalidFiles', invalidFiles);\n } else {\n props.onUpload(files);\n }\n\n setDragging(false);\n };\n\n return (\n <div\n className={cx(styles.dropzone, dragging ? styles.highlight : '')}\n onDragEnter={onDragIn}\n onDragLeave={onDragOut}\n onDragOver={onDragIn}\n onDrop={(e) => {\n e.preventDefault();\n handleUpload(e.dataTransfer?.files);\n }}\n >\n {/*TODO: show invalid files*/}\n {showWarning && <></>}\n\n <label htmlFor={props.inputId ?? 'file-upload'}>\n <Icon\n name={'upload'}\n size={'large'}\n />\n <span>{props.label}</span>\n <input\n type='file'\n multiple={props.isMultiple}\n accept={props.mimeTypes?.join(', ')}\n id={props.inputId ?? 'file-upload'}\n onChange={(e) => handleUpload(e.target.files)}\n />\n </label>\n </div>\n );\n};\n"],"names":["Dropzone","props","showWarning","setShowWarning","useState","invalidFiles","setInvalidFiles","validFiles","setValidFiles","dragging","setDragging","makeDragHandler","set","value","e","onDragIn","onDragOut","handleUpload","files","fileList","emptyFiles","file","oversizeFiles","unsupportedFiles","_a","validatedFiles","jsxs","cx","styles","jsx","Fragment","Icon"],"mappings":"wRAiBaA,EAAYC,GAAyB,OAChD,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAAS,EAAK,EAC9C,CAACC,EAAcC,CAAe,EAAIF,EAAAA,SAIrC,CAAE,MAAO,CAAA,EAAI,SAAU,CAAA,EAAI,UAAW,CAAA,EAAI,EACvC,CAACG,EAAYC,CAAa,EAAIJ,EAAAA,SAAiB,CAAA,CAAE,EACjD,CAACK,EAAUC,CAAW,EAAIN,EAAAA,SAAS,EAAK,EAExCO,EAAkB,CAACC,EAA2BC,IAAoBC,GAAuB,CAC7FA,EAAE,eAAA,EACFA,EAAE,gBAAA,EACFF,EAAIC,CAAK,CACX,EAEME,EAAWJ,EAAgBD,EAAa,EAAI,EAC5CM,EAAYL,EAAgBD,EAAa,EAAK,EAE9CO,EAAgBC,GAA2B,CAC/C,GAAI,CAACA,EACH,OAGF,M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AAM,SAAA5B,EAAM,KAAA,CAAM,EACnB4B,EAAAA,IAAC,QAAA,CACC,KAAK,OACL,SAAU5B,EAAM,WAChB,QAAQuB,EAAAvB,EAAM,YAAN,YAAAuB,EAAiB,KAAK,MAC9B,GAAIvB,EAAM,SAAW,cACrB,SAAWa,GAAMG,EAAaH,EAAE,OAAO,KAAK,CAAA,CAAA,CAC9C,CAAA,CACF,CAAA,CAAA,CAAA,CAGN"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsxs as f, jsx as o, Fragment as I } from "react/jsx-runtime";
|
|
2
|
+
import { t as M } from "../../classix-DG18itHa.js";
|
|
3
|
+
import { useState as s } from "react";
|
|
4
|
+
import { Icon as w } from "../icon/index.js";
|
|
5
|
+
import '../../assets/index14.css';const B = "_dropzone_1cqsl_1", j = "_highlight_1cqsl_41", z = {
|
|
6
|
+
dropzone: B,
|
|
7
|
+
highlight: j
|
|
8
|
+
}, U = (e) => {
|
|
9
|
+
var d;
|
|
10
|
+
const [p, F] = s(!1), [y, v] = s({ empty: [], oversize: [], wrongType: [] }), [D, T] = s([]), [x, a] = s(!1), r = (i, t) => (n) => {
|
|
11
|
+
n.preventDefault(), n.stopPropagation(), i(t);
|
|
12
|
+
}, g = r(a, !0), S = r(a, !1), m = (i) => {
|
|
13
|
+
if (!i)
|
|
14
|
+
return;
|
|
15
|
+
const t = Array.from(i), n = t.filter((l) => l.size === 0), c = e.maxFileSizeMB ? t.filter((l) => l.size > e.maxFileSizeMB * 1024 * 1024) : [], h = e.mimeTypes ? t.filter((l) => {
|
|
16
|
+
var u;
|
|
17
|
+
return !((u = e.mimeTypes) != null && u.includes(l.type));
|
|
18
|
+
}) : [], _ = t.filter(
|
|
19
|
+
(l) => l.size > 0 && (e.maxFileSizeMB ? l.size <= e.maxFileSizeMB * 1024 * 1024 : !0) && (e.mimeTypes ? e.mimeTypes.includes(l.type) : !0)
|
|
20
|
+
);
|
|
21
|
+
T(_), n.length > 0 || c.length > 0 || h.length > 0 ? (v({ empty: n, oversize: c, wrongType: h }), F(!0), console.log("validFiles", D), console.log("invalidFiles", y)) : e.onUpload(i), a(!1);
|
|
22
|
+
};
|
|
23
|
+
return /* @__PURE__ */ f(
|
|
24
|
+
"div",
|
|
25
|
+
{
|
|
26
|
+
className: M(z.dropzone, x ? z.highlight : ""),
|
|
27
|
+
onDragEnter: g,
|
|
28
|
+
onDragLeave: S,
|
|
29
|
+
onDragOver: g,
|
|
30
|
+
onDrop: (i) => {
|
|
31
|
+
var t;
|
|
32
|
+
i.preventDefault(), m((t = i.dataTransfer) == null ? void 0 : t.files);
|
|
33
|
+
},
|
|
34
|
+
children: [
|
|
35
|
+
p && /* @__PURE__ */ o(I, {}),
|
|
36
|
+
/* @__PURE__ */ f("label", { htmlFor: e.inputId ?? "file-upload", children: [
|
|
37
|
+
/* @__PURE__ */ o(
|
|
38
|
+
w,
|
|
39
|
+
{
|
|
40
|
+
name: "upload",
|
|
41
|
+
size: "large"
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ o("span", { children: e.label }),
|
|
45
|
+
/* @__PURE__ */ o(
|
|
46
|
+
"input",
|
|
47
|
+
{
|
|
48
|
+
type: "file",
|
|
49
|
+
multiple: e.isMultiple,
|
|
50
|
+
accept: (d = e.mimeTypes) == null ? void 0 : d.join(", "),
|
|
51
|
+
id: e.inputId ?? "file-upload",
|
|
52
|
+
onChange: (i) => m(i.target.files)
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] })
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
U as Dropzone
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/dropzone/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useState } from 'react';\n\nimport { Icon } from '@/components/icon';\n\nimport styles from './styles.module.css';\n\nexport type DropzoneProps = {\n allowDirectoryUpload?: boolean;\n inputId?: string;\n isMultiple?: boolean;\n label?: string;\n maxFileSizeMB?: number;\n mimeTypes?: string[];\n onUpload: (uploadContent: File[] | FileList) => void;\n};\n\nexport const Dropzone = (props: DropzoneProps) => {\n const [showWarning, setShowWarning] = useState(false);\n const [invalidFiles, setInvalidFiles] = useState<{\n empty: File[];\n oversize: File[];\n wrongType: File[];\n }>({ empty: [], oversize: [], wrongType: [] });\n const [validFiles, setValidFiles] = useState<File[]>([]);\n const [dragging, setDragging] = useState(false);\n\n const makeDragHandler = (set: (v: boolean) => void, value: boolean) => (e: React.DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n set(value);\n };\n\n const onDragIn = makeDragHandler(setDragging, true);\n const onDragOut = makeDragHandler(setDragging, false);\n\n const handleUpload = (files: FileList | null) => {\n if (!files) {\n return;\n }\n\n const fileList = Array.from(files);\n\n const emptyFiles = fileList.filter((file) => file.size === 0);\n const oversizeFiles = props.maxFileSizeMB\n ? fileList.filter((file) => file.size > props.maxFileSizeMB! * 1024 * 1024)\n : [];\n const unsupportedFiles = props.mimeTypes\n ? fileList.filter((file) => !props.mimeTypes?.includes(file.type))\n : [];\n const validatedFiles = fileList.filter(\n (file) =>\n file.size > 0 &&\n (props.maxFileSizeMB ? file.size <= props.maxFileSizeMB * 1024 * 1024 : true) &&\n (props.mimeTypes ? props.mimeTypes.includes(file.type) : true)\n );\n\n setValidFiles(validatedFiles);\n\n if (emptyFiles.length > 0 || oversizeFiles.length > 0 || unsupportedFiles.length > 0) {\n setInvalidFiles({ empty: emptyFiles, oversize: oversizeFiles, wrongType: unsupportedFiles });\n setShowWarning(true);\n console.log('validFiles', validFiles);\n console.log('invalidFiles', invalidFiles);\n } else {\n props.onUpload(files);\n }\n\n setDragging(false);\n };\n\n return (\n <div\n className={cx(styles.dropzone, dragging ? styles.highlight : '')}\n onDragEnter={onDragIn}\n onDragLeave={onDragOut}\n onDragOver={onDragIn}\n onDrop={(e) => {\n e.preventDefault();\n handleUpload(e.dataTransfer?.files);\n }}\n >\n {/*TODO: show invalid files*/}\n {showWarning && <></>}\n\n <label htmlFor={props.inputId ?? 'file-upload'}>\n <Icon\n name={'upload'}\n size={'large'}\n />\n <span>{props.label}</span>\n <input\n type='file'\n multiple={props.isMultiple}\n accept={props.mimeTypes?.join(', ')}\n id={props.inputId ?? 'file-upload'}\n onChange={(e) => handleUpload(e.target.files)}\n />\n </label>\n </div>\n );\n};\n"],"names":["Dropzone","props","showWarning","setShowWarning","useState","invalidFiles","setInvalidFiles","validFiles","setValidFiles","dragging","setDragging","makeDragHandler","set","value","e","onDragIn","onDragOut","handleUpload","files","fileList","emptyFiles","file","oversizeFiles","unsupportedFiles","_a","validatedFiles","jsxs","cx","styles","jsx","Fragment","Icon"],"mappings":";;;;;;;GAiBaA,IAAW,CAACC,MAAyB;;AAChD,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAK,GAC9C,CAACC,GAAcC,CAAe,IAAIF,EAIrC,EAAE,OAAO,CAAA,GAAI,UAAU,CAAA,GAAI,WAAW,CAAA,GAAI,GACvC,CAACG,GAAYC,CAAa,IAAIJ,EAAiB,CAAA,CAAE,GACjD,CAACK,GAAUC,CAAW,IAAIN,EAAS,EAAK,GAExCO,IAAkB,CAACC,GAA2BC,MAAmB,CAACC,MAAuB;AAC7F,IAAAA,EAAE,eAAA,GACFA,EAAE,gBAAA,GACFF,EAAIC,CAAK;AAAA,EACX,GAEME,IAAWJ,EAAgBD,GAAa,EAAI,GAC5CM,IAAYL,EAAgBD,GAAa,EAAK,GAE9CO,IAAe,CAACC,MAA2B;AAC/C,QAAI,CAACA;AACH;AAGF,UAAMC,IAAW,MAAM,KAAKD,CAAK,GAE3BE,IAAaD,EAAS,OAAO,CAACE,MAASA,EAAK,SAAS,CAAC,GACtDC,IAAgBrB,EAAM,gBACxBkB,EAAS,OAAO,CAACE,MAASA,EAAK,OAAOpB,EAAM,gBAAiB,O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