@smwb/ui-react 2.5.0 → 2.6.1

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.
Files changed (66) hide show
  1. package/dist/assets/styles/less/components/confirmDialog/confirmDialog.entry.css +1 -0
  2. package/dist/assets/styles/less/components/fileDrop/fileDrop.entry.css +1 -0
  3. package/dist/assets/styles/less/components/fileInput/fileInput.entry.css +1 -0
  4. package/dist/assets/styles/less/components/floatingWindow/floatingWindow.entry.css +1 -0
  5. package/dist/assets/styles/less/components/treeView/treeView.entry.css +1 -1
  6. package/dist/components/dataDisplay/chat/chat.d.ts +1 -1
  7. package/dist/components/dataDisplay/chat/chat.js.map +1 -1
  8. package/dist/components/dataDisplay/chat/useChatFileUpload.d.ts +16 -4
  9. package/dist/components/dataDisplay/chat/useChatFileUpload.js +38 -29
  10. package/dist/components/dataDisplay/chat/useChatFileUpload.js.map +1 -1
  11. package/dist/components/feedBack/confirmDialog/confirmDialog.d.ts +27 -0
  12. package/dist/components/feedBack/confirmDialog/confirmDialog.js +49 -0
  13. package/dist/components/feedBack/confirmDialog/confirmDialog.js.map +1 -0
  14. package/dist/components/feedBack/confirmDialog/index.d.ts +2 -0
  15. package/dist/components/inputs/fileDrop/countPreview.js +15 -0
  16. package/dist/components/inputs/fileDrop/countPreview.js.map +1 -0
  17. package/dist/components/inputs/fileDrop/fileDrop.d.ts +1 -1
  18. package/dist/components/inputs/fileDrop/fileDrop.js +60 -0
  19. package/dist/components/inputs/fileDrop/fileDrop.js.map +1 -0
  20. package/dist/components/inputs/fileDrop/index.d.ts +9 -0
  21. package/dist/components/inputs/fileDrop/preview.js +41 -0
  22. package/dist/components/inputs/fileDrop/preview.js.map +1 -0
  23. package/dist/components/inputs/fileDrop/previewWrapper.js +27 -0
  24. package/dist/components/inputs/fileDrop/previewWrapper.js.map +1 -0
  25. package/dist/components/inputs/fileDrop/utils.js +7 -0
  26. package/dist/components/inputs/fileDrop/utils.js.map +1 -0
  27. package/dist/components/inputs/fileInput/fileInput.d.ts +1 -1
  28. package/dist/components/inputs/fileInput/fileInput.js +35 -0
  29. package/dist/components/inputs/fileInput/fileInput.js.map +1 -0
  30. package/dist/components/inputs/fileInput/index.d.ts +2 -0
  31. package/dist/components/layout/floatingWindow/floatingWindow.d.ts +92 -0
  32. package/dist/components/layout/floatingWindow/floatingWindow.js +326 -0
  33. package/dist/components/layout/floatingWindow/floatingWindow.js.map +1 -0
  34. package/dist/components/layout/floatingWindow/index.d.ts +2 -0
  35. package/dist/headless/components/dataDisplay/chat/chat.js.map +1 -1
  36. package/dist/headless/components/dataDisplay/chat/useChatFileUpload.js +38 -29
  37. package/dist/headless/components/dataDisplay/chat/useChatFileUpload.js.map +1 -1
  38. package/dist/headless/components/feedBack/confirmDialog/confirmDialog.js +48 -0
  39. package/dist/headless/components/feedBack/confirmDialog/confirmDialog.js.map +1 -0
  40. package/dist/headless/components/inputs/fileDrop/countPreview.js +15 -0
  41. package/dist/headless/components/inputs/fileDrop/countPreview.js.map +1 -0
  42. package/dist/headless/components/inputs/fileDrop/fileDrop.js +59 -0
  43. package/dist/headless/components/inputs/fileDrop/fileDrop.js.map +1 -0
  44. package/dist/headless/components/inputs/fileDrop/preview.js +41 -0
  45. package/dist/headless/components/inputs/fileDrop/preview.js.map +1 -0
  46. package/dist/headless/components/inputs/fileDrop/previewWrapper.js +27 -0
  47. package/dist/headless/components/inputs/fileDrop/previewWrapper.js.map +1 -0
  48. package/dist/headless/components/inputs/fileDrop/utils.js +7 -0
  49. package/dist/headless/components/inputs/fileDrop/utils.js.map +1 -0
  50. package/dist/headless/components/inputs/fileInput/fileInput.js +34 -0
  51. package/dist/headless/components/inputs/fileInput/fileInput.js.map +1 -0
  52. package/dist/headless/components/layout/floatingWindow/floatingWindow.js +325 -0
  53. package/dist/headless/components/layout/floatingWindow/floatingWindow.js.map +1 -0
  54. package/dist/headless/hooks/useDropzone.js +47 -0
  55. package/dist/headless/hooks/useDropzone.js.map +1 -0
  56. package/dist/headless/index.js +277 -259
  57. package/dist/headless/index.js.map +1 -1
  58. package/dist/hooks/useDropzone.d.ts +44 -0
  59. package/dist/hooks/useDropzone.js +47 -0
  60. package/dist/hooks/useDropzone.js.map +1 -0
  61. package/dist/index.cjs +2 -2
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.d.ts +10 -0
  64. package/dist/index.js +277 -259
  65. package/dist/index.js.map +1 -1
  66. package/package.json +2 -3
@@ -1,42 +1,51 @@
1
- import { useDropzone as F } from "react-dropzone";
2
- import { CHAT_DEFAULT_FILE_UPLOAD_MAX_FILES as d } from "./types.js";
3
- function A(e) {
4
- return e == null ? d : Math.max(1, e);
1
+ import { useDropzone as g } from "../../../hooks/useDropzone.js";
2
+ import { CHAT_DEFAULT_FILE_UPLOAD_MAX_FILES as F } from "./types.js";
3
+ function d(e) {
4
+ return e == null ? F : Math.max(1, e);
5
5
  }
6
- function D({
6
+ function v({
7
7
  enabled: e = !1,
8
- accept: s,
9
- maxFiles: n,
10
- onUploadFiles: o,
11
- disabled: l = !1
8
+ accept: p,
9
+ maxFiles: s,
10
+ onUploadFiles: t,
11
+ disabled: i = !1
12
12
  }) {
13
- const t = A(n), i = e && !!o && !l, { getRootProps: a, getInputProps: c, open: r, isDragActive: u, inputRef: p } = F({
14
- accept: s,
15
- maxFiles: t,
16
- multiple: t > 1,
17
- disabled: !i,
18
- noClick: !0,
19
- noKeyboard: !0,
20
- useFsAccessApi: !1,
21
- onDropAccepted: (f) => {
22
- o && o(f);
13
+ const n = d(s), r = e && !!t && !i, {
14
+ getRootProps: l,
15
+ getInputProps: c,
16
+ open: u,
17
+ isDragActive: a,
18
+ inputRef: P
19
+ } = g({
20
+ accept: p,
21
+ maxFiles: n,
22
+ multiple: n > 1,
23
+ disabled: !r,
24
+ onDropAccepted: (o) => {
25
+ t && t(o);
23
26
  }
24
27
  });
25
28
  return {
26
- enabled: i,
27
- maxFiles: t,
28
- getRootProps: a,
29
- getInputProps: c,
29
+ enabled: r,
30
+ maxFiles: n,
31
+ getRootProps: () => {
32
+ const { onClick: o, ...f } = l();
33
+ return f;
34
+ },
35
+ getInputProps: (o) => ({
36
+ ...c(),
37
+ ...o != null ? o : {}
38
+ }),
30
39
  open: () => {
31
- r == null || r();
40
+ u();
32
41
  },
33
- inputRef: p,
34
- isDragActive: u
42
+ inputRef: P,
43
+ isDragActive: a
35
44
  };
36
45
  }
37
46
  export {
38
- D as default,
39
- A as resolveChatFileUploadMaxFiles,
40
- D as useChatFileUpload
47
+ v as default,
48
+ d as resolveChatFileUploadMaxFiles,
49
+ v as useChatFileUpload
41
50
  };
42
51
  //# sourceMappingURL=useChatFileUpload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useChatFileUpload.js","sources":["../../../../../src/components/dataDisplay/chat/useChatFileUpload.ts"],"sourcesContent":["import { useDropzone, type Accept } from \"react-dropzone\";\nimport { CHAT_DEFAULT_FILE_UPLOAD_MAX_FILES } from \"./types\";\n\nexport interface UseChatFileUploadOptions {\n enabled?: boolean;\n accept?: Accept;\n maxFiles?: number;\n onUploadFiles?: (files: File[]) => void | Promise<void>;\n disabled?: boolean;\n}\n\nexport function resolveChatFileUploadMaxFiles(maxFiles?: number): number {\n if (maxFiles == null) {\n return CHAT_DEFAULT_FILE_UPLOAD_MAX_FILES;\n }\n\n return Math.max(1, maxFiles);\n}\n\nexport function useChatFileUpload({\n enabled = false,\n accept,\n maxFiles,\n onUploadFiles,\n disabled = false,\n}: UseChatFileUploadOptions) {\n const resolvedMaxFiles = resolveChatFileUploadMaxFiles(maxFiles);\n const active = enabled && Boolean(onUploadFiles) && !disabled;\n\n const { getRootProps, getInputProps, open, isDragActive, inputRef } = useDropzone({\n accept,\n maxFiles: resolvedMaxFiles,\n multiple: resolvedMaxFiles > 1,\n disabled: !active,\n noClick: true,\n noKeyboard: true,\n useFsAccessApi: false,\n onDropAccepted: (files) => {\n if (onUploadFiles) {\n void onUploadFiles(files);\n }\n },\n });\n\n const openFilePicker = () => {\n open?.();\n };\n\n return {\n enabled: active,\n maxFiles: resolvedMaxFiles,\n getRootProps,\n getInputProps,\n open: openFilePicker,\n inputRef,\n isDragActive,\n };\n}\n\nexport default useChatFileUpload;\n"],"names":["resolveChatFileUploadMaxFiles","maxFiles","CHAT_DEFAULT_FILE_UPLOAD_MAX_FILES","useChatFileUpload","enabled","accept","onUploadFiles","disabled","resolvedMaxFiles","active","getRootProps","getInputProps","open","isDragActive","inputRef","useDropzone","files"],"mappings":";;AAWO,SAASA,EAA8BC,GAA2B;AACvE,SAAIA,KAAY,OACPC,IAGF,KAAK,IAAI,GAAGD,CAAQ;AAC7B;AAEO,SAASE,EAAkB;AAAA,EAChC,SAAAC,IAAU;AAAA,EACV,QAAAC;AAAA,EACA,UAAAJ;AAAA,EACA,eAAAK;AAAA,EACA,UAAAC,IAAW;AACb,GAA6B;AAC3B,QAAMC,IAAmBR,EAA8BC,CAAQ,GACzDQ,IAASL,KAAW,EAAQE,KAAkB,CAACC,GAE/C,EAAE,cAAAG,GAAc,eAAAC,GAAe,MAAAC,GAAM,cAAAC,GAAc,UAAAC,EAAA,IAAaC,EAAY;AAAA,IAChF,QAAAV;AAAA,IACA,UAAUG;AAAA,IACV,UAAUA,IAAmB;AAAA,IAC7B,UAAU,CAACC;AAAA,IACX,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,gBAAgB,CAACO,MAAU;AACzB,MAAIV,KACGA,EAAcU,CAAK;AAAA,IAE5B;AAAA,EAAA,CACD;AAMD,SAAO;AAAA,IACL,SAASP;AAAA,IACT,UAAUD;AAAA,IACV,cAAAE;AAAA,IACA,eAAAC;AAAA,IACA,MATqB,MAAM;AAC3B,MAAAC,KAAA,QAAAA;AAAA,IACF;AAAA,IAQE,UAAAE;AAAA,IACA,cAAAD;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"useChatFileUpload.js","sources":["../../../../../src/components/dataDisplay/chat/useChatFileUpload.ts"],"sourcesContent":["import React from \"react\";\nimport { type DropzoneAccept, type DropzoneInputProps, useDropzone } from \"../../../hooks/useDropzone\";\nimport { CHAT_DEFAULT_FILE_UPLOAD_MAX_FILES } from \"./types\";\n\n/** Kept as a named alias so `ChatProps.fileUploadAccept` reads the same as before. */\nexport type Accept = DropzoneAccept;\n\nexport interface UseChatFileUploadOptions {\n enabled?: boolean;\n accept?: Accept;\n maxFiles?: number;\n onUploadFiles?: (files: File[]) => void | Promise<void>;\n disabled?: boolean;\n}\n\nexport interface ChatFileUploadRootProps {\n onDragOver: (event: React.DragEvent<HTMLElement>) => void;\n onDragLeave: () => void;\n onDrop: (event: React.DragEvent<HTMLElement>) => void;\n}\n\nexport function resolveChatFileUploadMaxFiles(maxFiles?: number): number {\n if (maxFiles == null) {\n return CHAT_DEFAULT_FILE_UPLOAD_MAX_FILES;\n }\n\n return Math.max(1, maxFiles);\n}\n\nexport function useChatFileUpload({\n enabled = false,\n accept,\n maxFiles,\n onUploadFiles,\n disabled = false,\n}: UseChatFileUploadOptions) {\n const resolvedMaxFiles = resolveChatFileUploadMaxFiles(maxFiles);\n const active = enabled && Boolean(onUploadFiles) && !disabled;\n\n const {\n getRootProps: getDropzoneRootProps,\n getInputProps: getDropzoneInputProps,\n open,\n isDragActive,\n inputRef,\n } = useDropzone({\n accept,\n maxFiles: resolvedMaxFiles,\n multiple: resolvedMaxFiles > 1,\n disabled: !active,\n onDropAccepted: (files) => {\n if (onUploadFiles) {\n void onUploadFiles(files);\n }\n },\n });\n\n // Drag/drop root props WITHOUT a click handler — the `noClick` behaviour this hook used to\n // configure on react-dropzone. Clicking the chat surface must never open the file picker;\n // the attach button calls `open()` explicitly. Mirrors ui-solid's createChatFileUpload.\n const getRootProps = (): ChatFileUploadRootProps => {\n const { onClick: _onClick, ...rest } = getDropzoneRootProps();\n void _onClick;\n return rest;\n };\n\n const getInputProps = (extra?: { id?: string }): DropzoneInputProps & { id?: string } => ({\n ...getDropzoneInputProps(),\n ...(extra ?? {}),\n });\n\n const openFilePicker = () => {\n open();\n };\n\n return {\n enabled: active,\n maxFiles: resolvedMaxFiles,\n getRootProps,\n getInputProps,\n open: openFilePicker,\n inputRef,\n isDragActive,\n };\n}\n\nexport default useChatFileUpload;\n"],"names":["resolveChatFileUploadMaxFiles","maxFiles","CHAT_DEFAULT_FILE_UPLOAD_MAX_FILES","useChatFileUpload","enabled","accept","onUploadFiles","disabled","resolvedMaxFiles","active","getDropzoneRootProps","getDropzoneInputProps","open","isDragActive","inputRef","useDropzone","files","_onClick","rest","extra"],"mappings":";;AAqBO,SAASA,EAA8BC,GAA2B;AACvE,SAAIA,KAAY,OACPC,IAGF,KAAK,IAAI,GAAGD,CAAQ;AAC7B;AAEO,SAASE,EAAkB;AAAA,EAChC,SAAAC,IAAU;AAAA,EACV,QAAAC;AAAA,EACA,UAAAJ;AAAA,EACA,eAAAK;AAAA,EACA,UAAAC,IAAW;AACb,GAA6B;AAC3B,QAAMC,IAAmBR,EAA8BC,CAAQ,GACzDQ,IAASL,KAAW,EAAQE,KAAkB,CAACC,GAE/C;AAAA,IACJ,cAAcG;AAAA,IACd,eAAeC;AAAA,IACf,MAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,EAAA,IACEC,EAAY;AAAA,IACd,QAAAV;AAAA,IACA,UAAUG;AAAA,IACV,UAAUA,IAAmB;AAAA,IAC7B,UAAU,CAACC;AAAA,IACX,gBAAgB,CAACO,MAAU;AACzB,MAAIV,KACGA,EAAcU,CAAK;AAAA,IAE5B;AAAA,EAAA,CACD;AAoBD,SAAO;AAAA,IACL,SAASP;AAAA,IACT,UAAUD;AAAA,IACV,cAlBmB,MAA+B;AAClD,YAAM,EAAE,SAASS,GAAU,GAAGC,EAAA,IAASR,EAAA;AAEvC,aAAOQ;AAAA,IACT;AAAA,IAeE,eAboB,CAACC,OAAmE;AAAA,MACxF,GAAGR,EAAA;AAAA,MACH,GAAIQ,KAAA,OAAAA,IAAS,CAAA;AAAA,IAAC;AAAA,IAYd,MATqB,MAAM;AAC3B,MAAAP,EAAA;AAAA,IACF;AAAA,IAQE,UAAAE;AAAA,IACA,cAAAD;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,48 @@
1
+ import { jsxs as a, jsx as o } from "react/jsx-runtime";
2
+ import { useId as p } from "react";
3
+ import j from "clsx";
4
+ import { Modal as r } from "../modal/modal.js";
5
+ import { Typography as b } from "../../dataDisplay/typography/typography.js";
6
+ import { Button as f } from "../../inputs/button/button.js";
7
+ function N(u) {
8
+ const { open: y, title: t, subject: n, message: i, confirmLabel: C, cancelLabel: l, danger: h, busy: e, onConfirm: g, onCancel: s, className: x } = u, c = p(), d = p(), m = [n ? c : "", i ? d : ""].filter(Boolean).join(" ");
9
+ return /* @__PURE__ */ a(
10
+ r,
11
+ {
12
+ open: y,
13
+ onClose: s,
14
+ size: "small",
15
+ role: "alertdialog",
16
+ backdrop: "dark",
17
+ closeOnEsc: !e,
18
+ closeOnOutsideClick: !e,
19
+ "aria-label": t,
20
+ ...m ? { "aria-describedby": m } : {},
21
+ children: [
22
+ /* @__PURE__ */ o(r.Header, { children: t }),
23
+ /* @__PURE__ */ o(r.Content, { children: /* @__PURE__ */ a("div", { className: j("smwb-confirm-dialog__body", x), children: [
24
+ n ? /* @__PURE__ */ o(b, { id: c, variant: "body2", color: "textPrimary", component: "span", children: n }) : null,
25
+ i ? /* @__PURE__ */ o(b, { id: d, variant: "caption", color: "textSecondary", component: "span", children: i }) : null
26
+ ] }) }),
27
+ /* @__PURE__ */ a(r.Footer, { children: [
28
+ /* @__PURE__ */ o(f, { variant: "text", size: "small", disabled: !!e, onClick: s, label: l != null ? l : "Cancel" }),
29
+ /* @__PURE__ */ o(
30
+ f,
31
+ {
32
+ variant: "contained",
33
+ size: "small",
34
+ color: h ? "error" : "primary",
35
+ disabled: !!e,
36
+ onClick: g,
37
+ label: C
38
+ }
39
+ )
40
+ ] })
41
+ ]
42
+ }
43
+ );
44
+ }
45
+ export {
46
+ N as ConfirmDialog
47
+ };
48
+ //# sourceMappingURL=confirmDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmDialog.js","sources":["../../../../../src/components/feedBack/confirmDialog/confirmDialog.tsx"],"sourcesContent":["import React, { useId } from \"react\";\nimport cn from \"clsx\";\nimport { Modal } from \"../modal\";\nimport { Button } from \"../../inputs/button\";\nimport { Typography } from \"../../dataDisplay/typography\";\n\nexport interface ConfirmDialogProps {\n open: boolean;\n title: string;\n /** The subject of the action, shown emphasised on its own line (e.g. the asset name). */\n subject?: string;\n /** A secondary explanatory line (e.g. \"can't be undone\"). */\n message?: string;\n confirmLabel: string;\n cancelLabel?: string;\n /** Style the confirm button as destructive (red). */\n danger?: boolean;\n /** Disable the actions + gate Esc/outside-click while a confirm is in flight. */\n busy?: boolean;\n onConfirm: () => void;\n onCancel: () => void;\n className?: string;\n}\n\n/**\n * An alert/confirm dialog built on {@link Modal}: a title, an optional emphasised subject + secondary\n * message, and Cancel / Confirm actions. `role=\"alertdialog\"` with the subject + message wired to\n * `aria-describedby` so a screen reader announces the consequence, not just the title. While `busy`,\n * Escape + outside-click are gated and the buttons disabled. Pure presentation — the caller owns the\n * open state and the confirm/cancel handlers (and supplies localised labels).\n */\nexport function ConfirmDialog(props: ConfirmDialogProps): React.ReactElement {\n const { open, title, subject, message, confirmLabel, cancelLabel, danger, busy, onConfirm, onCancel, className } =\n props;\n\n const subjectId = useId();\n const messageId = useId();\n // Only describe when there IS something to describe — an empty aria-describedby would point a\n // screen reader at nothing.\n const describedBy = [subject ? subjectId : \"\", message ? messageId : \"\"].filter(Boolean).join(\" \");\n\n return (\n <Modal\n open={open}\n onClose={onCancel}\n size=\"small\"\n role=\"alertdialog\"\n backdrop=\"dark\"\n closeOnEsc={!busy}\n closeOnOutsideClick={!busy}\n aria-label={title}\n {...(describedBy ? { \"aria-describedby\": describedBy } : {})}\n >\n <Modal.Header>{title}</Modal.Header>\n <Modal.Content>\n <div className={cn(\"smwb-confirm-dialog__body\", className)}>\n {subject ? (\n <Typography id={subjectId} variant=\"body2\" color=\"textPrimary\" component=\"span\">\n {subject}\n </Typography>\n ) : null}\n {message ? (\n <Typography id={messageId} variant=\"caption\" color=\"textSecondary\" component=\"span\">\n {message}\n </Typography>\n ) : null}\n </div>\n </Modal.Content>\n <Modal.Footer>\n <Button variant=\"text\" size=\"small\" disabled={!!busy} onClick={onCancel} label={cancelLabel ?? \"Cancel\"} />\n <Button\n variant=\"contained\"\n size=\"small\"\n color={danger ? \"error\" : \"primary\"}\n disabled={!!busy}\n onClick={onConfirm}\n label={confirmLabel}\n />\n </Modal.Footer>\n </Modal>\n );\n}\n\nexport default ConfirmDialog;\n"],"names":["ConfirmDialog","props","open","title","subject","message","confirmLabel","cancelLabel","danger","busy","onConfirm","onCancel","className","subjectId","useId","messageId","describedBy","jsxs","Modal","jsx","cn","Typography","Button"],"mappings":";;;;;;AA+BO,SAASA,EAAcC,GAA+C;AAC3E,QAAM,EAAE,MAAAC,GAAM,OAAAC,GAAO,SAAAC,GAAS,SAAAC,GAAS,cAAAC,GAAc,aAAAC,GAAa,QAAAC,GAAQ,MAAAC,GAAM,WAAAC,GAAW,UAAAC,GAAU,WAAAC,EAAA,IACnGX,GAEIY,IAAYC,EAAA,GACZC,IAAYD,EAAA,GAGZE,IAAc,CAACZ,IAAUS,IAAY,IAAIR,IAAUU,IAAY,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAEjG,SACE,gBAAAE;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAhB;AAAA,MACA,SAASS;AAAA,MACT,MAAK;AAAA,MACL,MAAK;AAAA,MACL,UAAS;AAAA,MACT,YAAY,CAACF;AAAA,MACb,qBAAqB,CAACA;AAAA,MACtB,cAAYN;AAAA,MACX,GAAIa,IAAc,EAAE,oBAAoBA,EAAA,IAAgB,CAAA;AAAA,MAEzD,UAAA;AAAA,QAAA,gBAAAG,EAACD,EAAM,QAAN,EAAc,UAAAf,EAAA,CAAM;AAAA,QACrB,gBAAAgB,EAACD,EAAM,SAAN,EACC,UAAA,gBAAAD,EAAC,SAAI,WAAWG,EAAG,6BAA6BR,CAAS,GACtD,UAAA;AAAA,UAAAR,IACC,gBAAAe,EAACE,GAAA,EAAW,IAAIR,GAAW,SAAQ,SAAQ,OAAM,eAAc,WAAU,QACtE,UAAAT,EAAA,CACH,IACE;AAAA,UACHC,IACC,gBAAAc,EAACE,GAAA,EAAW,IAAIN,GAAW,SAAQ,WAAU,OAAM,iBAAgB,WAAU,QAC1E,UAAAV,EAAA,CACH,IACE;AAAA,QAAA,EAAA,CACN,EAAA,CACF;AAAA,QACA,gBAAAY,EAACC,EAAM,QAAN,EACC,UAAA;AAAA,UAAA,gBAAAC,EAACG,GAAA,EAAO,SAAQ,QAAO,MAAK,SAAQ,UAAU,CAAC,CAACb,GAAM,SAASE,GAAU,OAAOJ,KAAA,OAAAA,IAAe,UAAU;AAAA,UACzG,gBAAAY;AAAA,YAACG;AAAA,YAAA;AAAA,cACC,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,OAAOd,IAAS,UAAU;AAAA,cAC1B,UAAU,CAAC,CAACC;AAAA,cACZ,SAASC;AAAA,cACT,OAAOJ;AAAA,YAAA;AAAA,UAAA;AAAA,QACT,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -0,0 +1,15 @@
1
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
+ import m from "clsx";
3
+ import { FloatingButton as t } from "../floatingButton/floatingButton.js";
4
+ import { Icon as p } from "../../base/icon/icon.js";
5
+ function w({ handleRemoveAll: o, filesLength: r, previewClassName: s, text: i }) {
6
+ const n = m("smwb-file-drop__preview", s);
7
+ return /* @__PURE__ */ l("div", { className: n, children: [
8
+ /* @__PURE__ */ e(t, { onClick: o, className: "smwb-file-drop__preview-button", children: /* @__PURE__ */ e(p, { name: "delete", size: 28 }) }),
9
+ /* @__PURE__ */ e("div", { className: "smwb-file-drop__preview-count", children: `${i || "uploaded files:"} ${r}` })
10
+ ] });
11
+ }
12
+ export {
13
+ w as CountPreview
14
+ };
15
+ //# sourceMappingURL=countPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countPreview.js","sources":["../../../../../src/components/inputs/fileDrop/countPreview.tsx"],"sourcesContent":["import { FloatingButton } from \"../floatingButton\";\nimport { Icon } from \"../../base/icon\";\nimport React from \"react\";\nimport cn from \"clsx\";\n\nexport interface CountPreviewProps {\n previewClassName?: string;\n text?: string;\n filesLength: number;\n handleRemoveAll: () => void;\n}\n\nexport function CountPreview({ handleRemoveAll, filesLength, previewClassName, text }: CountPreviewProps) {\n const previewClasses = cn(\"smwb-file-drop__preview\", previewClassName);\n\n return (\n <div className={previewClasses}>\n <FloatingButton onClick={handleRemoveAll} className=\"smwb-file-drop__preview-button\">\n <Icon name=\"delete\" size={28} />\n </FloatingButton>\n <div className=\"smwb-file-drop__preview-count\">{`${text ? text : \"uploaded files:\"} ${filesLength}`}</div>\n </div>\n );\n}\n"],"names":["CountPreview","handleRemoveAll","filesLength","previewClassName","text","previewClasses","cn","jsxs","jsx","FloatingButton","Icon"],"mappings":";;;;AAYO,SAASA,EAAa,EAAE,iBAAAC,GAAiB,aAAAC,GAAa,kBAAAC,GAAkB,MAAAC,KAA2B;AACxG,QAAMC,IAAiBC,EAAG,2BAA2BH,CAAgB;AAErE,SACE,gBAAAI,EAAC,OAAA,EAAI,WAAWF,GACd,UAAA;AAAA,IAAA,gBAAAG,EAACC,GAAA,EAAe,SAASR,GAAiB,WAAU,kCAClD,UAAA,gBAAAO,EAACE,GAAA,EAAK,MAAK,UAAS,MAAM,GAAA,CAAI,GAChC;AAAA,IACA,gBAAAF,EAAC,OAAA,EAAI,WAAU,iCAAiC,UAAA,GAAGJ,KAAc,iBAAiB,IAAIF,CAAW,GAAA,CAAG;AAAA,EAAA,GACtG;AAEJ;"}
@@ -0,0 +1,59 @@
1
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
+ import g, { forwardRef as P } from "react";
3
+ import { useDropzone as R } from "../../../hooks/useDropzone.js";
4
+ import { PreviewWrapper as z } from "./previewWrapper.js";
5
+ import C from "clsx";
6
+ const O = P(function(p, n) {
7
+ const {
8
+ preview: d,
9
+ previewCols: m = 3,
10
+ galleryItemSize: c = 100,
11
+ onDrop: f,
12
+ label: s = "",
13
+ className: b,
14
+ previewClassName: w,
15
+ disabled: e,
16
+ error: o,
17
+ ...u
18
+ } = p, [l, i] = g.useState([]), v = (t) => {
19
+ i((x) => [...x, ...t]), f(t);
20
+ }, { getRootProps: h, getInputProps: D } = R({
21
+ onDrop: v,
22
+ disabled: e,
23
+ ...u
24
+ }), N = () => {
25
+ i([]);
26
+ }, _ = C("smwb-file-drop", { "smwb-disabled": e, "smwb-error": !!o }, b);
27
+ return /* @__PURE__ */ a("div", { ref: n, className: _, "data-testid": "file-drop", children: [
28
+ l.length > 0 ? /* @__PURE__ */ r(
29
+ z,
30
+ {
31
+ preview: d,
32
+ files: l,
33
+ handleRemoveAll: N,
34
+ previewCols: m,
35
+ galleryItemSize: c,
36
+ previewClassName: w
37
+ }
38
+ ) : /* @__PURE__ */ a(
39
+ "div",
40
+ {
41
+ className: "smwb-file-drop__input",
42
+ role: "button",
43
+ tabIndex: e ? -1 : 0,
44
+ "aria-disabled": e || void 0,
45
+ "aria-label": s || "Upload files",
46
+ ...h(),
47
+ children: [
48
+ /* @__PURE__ */ r("div", { className: "smwb-file-drop__input-text", children: s }),
49
+ /* @__PURE__ */ r("input", { ...D() })
50
+ ]
51
+ }
52
+ ),
53
+ o ? /* @__PURE__ */ r("span", { className: "smwb-file-drop__error", role: "alert", children: o }) : null
54
+ ] });
55
+ });
56
+ export {
57
+ O as FileDrop
58
+ };
59
+ //# sourceMappingURL=fileDrop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileDrop.js","sources":["../../../../../src/components/inputs/fileDrop/fileDrop.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { type DropzoneOptions, useDropzone } from \"../../../hooks/useDropzone\";\nimport { PreviewWrapper } from \"./previewWrapper\";\nimport cn from \"clsx\";\n\nexport interface FileUploadProps extends DropzoneOptions {\n preview?: boolean;\n previewCols?: number;\n galleryItemSize?: number;\n onDrop: (files: File[]) => void;\n label?: string;\n className?: string;\n previewClassName?: string;\n disabled?: boolean;\n /** Validation message rendered below the drop zone. */\n error?: string;\n}\n\nexport const FileDrop = forwardRef<HTMLDivElement, FileUploadProps>(function FileDrop(props, ref) {\n const {\n preview,\n previewCols = 3,\n galleryItemSize = 100,\n onDrop: onDropProp,\n label = \"\",\n className,\n previewClassName,\n disabled,\n error,\n ...dropzoneOptions\n } = props;\n\n const [files, setFiles] = React.useState<File[]>([]);\n\n const onDrop = (acceptedFiles: File[]) => {\n setFiles((prev) => [...prev, ...acceptedFiles]);\n onDropProp(acceptedFiles);\n };\n\n const { getRootProps, getInputProps } = useDropzone({\n onDrop,\n disabled,\n ...dropzoneOptions,\n });\n\n const handleRemoveAll = () => {\n setFiles([]);\n };\n\n const wrapperClasses = cn(\"smwb-file-drop\", { \"smwb-disabled\": disabled, \"smwb-error\": !!error }, className);\n\n return (\n <div ref={ref} className={wrapperClasses} data-testid=\"file-drop\">\n {files.length > 0 ? (\n <PreviewWrapper\n preview={preview}\n files={files}\n handleRemoveAll={handleRemoveAll}\n previewCols={previewCols}\n galleryItemSize={galleryItemSize}\n previewClassName={previewClassName}\n />\n ) : (\n <div\n className=\"smwb-file-drop__input\"\n role=\"button\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled || undefined}\n aria-label={label || \"Upload files\"}\n {...getRootProps()}\n >\n <div className=\"smwb-file-drop__input-text\">{label}</div>\n <input {...getInputProps()} />\n </div>\n )}\n {error ? (\n <span className=\"smwb-file-drop__error\" role=\"alert\">\n {error}\n </span>\n ) : null}\n </div>\n );\n});\n\nexport default FileDrop;\n"],"names":["FileDrop","forwardRef","props","ref","preview","previewCols","galleryItemSize","onDropProp","label","className","previewClassName","disabled","error","dropzoneOptions","files","setFiles","React","onDrop","acceptedFiles","prev","getRootProps","getInputProps","useDropzone","handleRemoveAll","wrapperClasses","cn","jsx","PreviewWrapper","jsxs"],"mappings":";;;;;AAkBO,MAAMA,IAAWC,EAA4C,SAAkBC,GAAOC,GAAK;AAChG,QAAM;AAAA,IACJ,SAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,iBAAAC,IAAkB;AAAA,IAClB,QAAQC;AAAA,IACR,OAAAC,IAAQ;AAAA,IACR,WAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,IACDX,GAEE,CAACY,GAAOC,CAAQ,IAAIC,EAAM,SAAiB,CAAA,CAAE,GAE7CC,IAAS,CAACC,MAA0B;AACxC,IAAAH,EAAS,CAACI,MAAS,CAAC,GAAGA,GAAM,GAAGD,CAAa,CAAC,GAC9CX,EAAWW,CAAa;AAAA,EAC1B,GAEM,EAAE,cAAAE,GAAc,eAAAC,EAAA,IAAkBC,EAAY;AAAA,IAClD,QAAAL;AAAA,IACA,UAAAN;AAAA,IACA,GAAGE;AAAA,EAAA,CACJ,GAEKU,IAAkB,MAAM;AAC5B,IAAAR,EAAS,CAAA,CAAE;AAAA,EACb,GAEMS,IAAiBC,EAAG,kBAAkB,EAAE,iBAAiBd,GAAU,cAAc,CAAC,CAACC,EAAA,GAASH,CAAS;AAE3G,2BACG,OAAA,EAAI,KAAAN,GAAU,WAAWqB,GAAgB,eAAY,aACnD,UAAA;AAAA,IAAAV,EAAM,SAAS,IACd,gBAAAY;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,SAAAvB;AAAA,QACA,OAAAU;AAAA,QACA,iBAAAS;AAAA,QACA,aAAAlB;AAAA,QACA,iBAAAC;AAAA,QACA,kBAAAI;AAAA,MAAA;AAAA,IAAA,IAGF,gBAAAkB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,MAAK;AAAA,QACL,UAAUjB,IAAW,KAAK;AAAA,QAC1B,iBAAeA,KAAY;AAAA,QAC3B,cAAYH,KAAS;AAAA,QACpB,GAAGY,EAAA;AAAA,QAEJ,UAAA;AAAA,UAAA,gBAAAM,EAAC,OAAA,EAAI,WAAU,8BAA8B,UAAAlB,GAAM;AAAA,UACnD,gBAAAkB,EAAC,SAAA,EAAO,GAAGL,IAAc,CAAG;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAG/BT,sBACE,QAAA,EAAK,WAAU,yBAAwB,MAAK,SAC1C,aACH,IACE;AAAA,EAAA,GACN;AAEJ,CAAC;"}
@@ -0,0 +1,41 @@
1
+ import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
+ import { isImageFile as c } from "./utils.js";
3
+ import w from "clsx";
4
+ import { FloatingButton as d } from "../floatingButton/floatingButton.js";
5
+ import { Icon as v } from "../../base/icon/icon.js";
6
+ import { ImagesList as f } from "../../dataDisplay/imagesList/imagesList.js";
7
+ import g from "../../dataDisplay/imagesList/imagesListItem/imagesListItem.js";
8
+ function C(i) {
9
+ const { files: o, handleRemoveAll: l, previewCols: t, galleryItemSize: s, previewClassName: a } = i, n = w("smwb-file-drop__preview", a);
10
+ return /* @__PURE__ */ p("div", { className: n, children: [
11
+ /* @__PURE__ */ r(d, { onClick: l, className: "smwb-file-drop__preview-button", children: /* @__PURE__ */ r(v, { name: "delete", size: 28 }) }),
12
+ /* @__PURE__ */ r(f, { className: "smwb-file-drop__preview-gallery", cols: t, rowsHeight: s, children: o.map((e) => {
13
+ const m = c(e) ? URL.createObjectURL(e) : null;
14
+ return m ? /* @__PURE__ */ r(
15
+ g,
16
+ {
17
+ className: "smwb-file-drop__preview-gallery-image",
18
+ src: m,
19
+ rows: 1,
20
+ cols: 1,
21
+ itemBarContent: e.name
22
+ },
23
+ e.name
24
+ ) : /* @__PURE__ */ r(
25
+ "div",
26
+ {
27
+ className: "smwb-file-drop__preview-gallery-file",
28
+ style: {
29
+ width: `${s - 4}px`
30
+ },
31
+ children: e.name
32
+ },
33
+ e.name
34
+ );
35
+ }) })
36
+ ] });
37
+ }
38
+ export {
39
+ C as Preview
40
+ };
41
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sources":["../../../../../src/components/inputs/fileDrop/preview.tsx"],"sourcesContent":["import { FloatingButton } from \"../floatingButton\";\nimport { Icon } from \"../../base/icon\";\nimport { ImagesList, ImagesListItem } from \"../../dataDisplay/imagesList\";\nimport { isImageFile } from \"./utils\";\nimport React from \"react\";\nimport cn from \"clsx\";\n\nexport interface PreviewProps {\n previewCols?: number;\n galleryItemSize?: number;\n previewClassName?: string;\n files: File[];\n handleRemoveAll: () => void;\n}\n\nexport function Preview(props: PreviewProps) {\n const { files, handleRemoveAll, previewCols, galleryItemSize, previewClassName } = props;\n\n const previewClasses = cn(\"smwb-file-drop__preview\", previewClassName);\n\n return (\n <div className={previewClasses}>\n <FloatingButton onClick={handleRemoveAll} className=\"smwb-file-drop__preview-button\">\n <Icon name=\"delete\" size={28} />\n </FloatingButton>\n <ImagesList className=\"smwb-file-drop__preview-gallery\" cols={previewCols as number} rowsHeight={galleryItemSize}>\n {files.map((file: File) => {\n const src = isImageFile(file) ? URL.createObjectURL(file) : null;\n\n return src ? (\n <ImagesListItem\n className=\"smwb-file-drop__preview-gallery-image\"\n key={file.name}\n src={src}\n rows={1}\n cols={1}\n itemBarContent={file.name}\n />\n ) : (\n <div\n key={file.name}\n className=\"smwb-file-drop__preview-gallery-file\"\n style={{\n width: `${(galleryItemSize as number) - 4}px`,\n }}\n >\n {file.name}\n </div>\n );\n })}\n </ImagesList>\n </div>\n );\n}\n"],"names":["Preview","props","files","handleRemoveAll","previewCols","galleryItemSize","previewClassName","previewClasses","cn","jsxs","jsx","FloatingButton","Icon","ImagesList","file","src","isImageFile","ImagesListItem"],"mappings":";;;;;;;AAeO,SAASA,EAAQC,GAAqB;AAC3C,QAAM,EAAE,OAAAC,GAAO,iBAAAC,GAAiB,aAAAC,GAAa,iBAAAC,GAAiB,kBAAAC,MAAqBL,GAE7EM,IAAiBC,EAAG,2BAA2BF,CAAgB;AAErE,SACE,gBAAAG,EAAC,OAAA,EAAI,WAAWF,GACd,UAAA;AAAA,IAAA,gBAAAG,EAACC,GAAA,EAAe,SAASR,GAAiB,WAAU,kCAClD,UAAA,gBAAAO,EAACE,GAAA,EAAK,MAAK,UAAS,MAAM,GAAA,CAAI,GAChC;AAAA,IACA,gBAAAF,EAACG,GAAA,EAAW,WAAU,mCAAkC,MAAMT,GAAuB,YAAYC,GAC9F,UAAAH,EAAM,IAAI,CAACY,MAAe;AACzB,YAAMC,IAAMC,EAAYF,CAAI,IAAI,IAAI,gBAAgBA,CAAI,IAAI;AAE5D,aAAOC,IACL,gBAAAL;AAAA,QAACO;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UAEV,KAAAF;AAAA,UACA,MAAM;AAAA,UACN,MAAM;AAAA,UACN,gBAAgBD,EAAK;AAAA,QAAA;AAAA,QAJhBA,EAAK;AAAA,MAAA,IAOZ,gBAAAJ;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UACV,OAAO;AAAA,YACL,OAAO,GAAIL,IAA6B,CAAC;AAAA,UAAA;AAAA,UAG1C,UAAAS,EAAK;AAAA,QAAA;AAAA,QANDA,EAAK;AAAA,MAAA;AAAA,IAShB,CAAC,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
@@ -0,0 +1,27 @@
1
+ import { jsx as e, Fragment as p } from "react/jsx-runtime";
2
+ import { Preview as s } from "./preview.js";
3
+ import { CountPreview as v } from "./countPreview.js";
4
+ function g(t) {
5
+ const { previewCols: l, preview: m, galleryItemSize: n, handleRemoveAll: r, files: i, previewClassName: o } = t;
6
+ return /* @__PURE__ */ e(p, { children: m ? /* @__PURE__ */ e(
7
+ s,
8
+ {
9
+ files: i,
10
+ handleRemoveAll: r,
11
+ previewCols: l,
12
+ galleryItemSize: n,
13
+ previewClassName: o
14
+ }
15
+ ) : /* @__PURE__ */ e(
16
+ v,
17
+ {
18
+ filesLength: i.length,
19
+ handleRemoveAll: r,
20
+ previewClassName: o
21
+ }
22
+ ) });
23
+ }
24
+ export {
25
+ g as PreviewWrapper
26
+ };
27
+ //# sourceMappingURL=previewWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previewWrapper.js","sources":["../../../../../src/components/inputs/fileDrop/previewWrapper.tsx"],"sourcesContent":["import { Preview } from \"./preview\";\nimport { CountPreview } from \"./countPreview\";\nimport React from \"react\";\n\nexport interface PreviewWrapperProps {\n preview?: boolean;\n files: File[];\n handleRemoveAll: () => void;\n previewCols?: number;\n galleryItemSize?: number;\n previewClassName?: string;\n}\n\nexport function PreviewWrapper(props: PreviewWrapperProps) {\n const { previewCols, preview, galleryItemSize, handleRemoveAll, files, previewClassName } = props;\n\n return (\n <>\n {preview ? (\n <Preview\n files={files}\n handleRemoveAll={handleRemoveAll}\n previewCols={previewCols}\n galleryItemSize={galleryItemSize}\n previewClassName={previewClassName}\n />\n ) : (\n <CountPreview\n filesLength={files.length}\n handleRemoveAll={handleRemoveAll}\n previewClassName={previewClassName}\n />\n )}\n </>\n );\n}\n"],"names":["PreviewWrapper","props","previewCols","preview","galleryItemSize","handleRemoveAll","files","previewClassName","jsx","Preview","CountPreview"],"mappings":";;;AAaO,SAASA,EAAeC,GAA4B;AACzD,QAAM,EAAE,aAAAC,GAAa,SAAAC,GAAS,iBAAAC,GAAiB,iBAAAC,GAAiB,OAAAC,GAAO,kBAAAC,MAAqBN;AAE5F,gCAEK,UAAAE,IACC,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,OAAAH;AAAA,MACA,iBAAAD;AAAA,MACA,aAAAH;AAAA,MACA,iBAAAE;AAAA,MACA,kBAAAG;AAAA,IAAA;AAAA,EAAA,IAGF,gBAAAC;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,aAAaJ,EAAM;AAAA,MACnB,iBAAAD;AAAA,MACA,kBAAAE;AAAA,IAAA;AAAA,EAAA,GAGN;AAEJ;"}
@@ -0,0 +1,7 @@
1
+ function t(e) {
2
+ return /^image\/(png|jpeg)$/.test(e.type);
3
+ }
4
+ export {
5
+ t as isImageFile
6
+ };
7
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/inputs/fileDrop/utils.ts"],"sourcesContent":["export function isImageFile(file: File): boolean {\n return /^image\\/(png|jpeg)$/.test(file.type);\n}\n"],"names":["isImageFile","file"],"mappings":"AAAO,SAASA,EAAYC,GAAqB;AAC/C,SAAO,sBAAsB,KAAKA,EAAK,IAAI;AAC7C;"}
@@ -0,0 +1,34 @@
1
+ import { jsxs as w, jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as x } from "react";
3
+ import { useDropzone as D } from "../../../hooks/useDropzone.js";
4
+ import a from "clsx";
5
+ const P = x(function(p, m) {
6
+ const { label: c, onClick: e, onFilesSelected: o, className: u, buttonClassName: d, disabled: s, error: l, ...t } = p, { getRootProps: f, getInputProps: b } = D({
7
+ ...t,
8
+ disabled: s,
9
+ onDropAccepted: (r, h) => {
10
+ var i;
11
+ o == null || o(r), (i = t.onDropAccepted) == null || i.call(t, r, h);
12
+ }
13
+ }), N = (r) => {
14
+ e == null || e(r);
15
+ };
16
+ return /* @__PURE__ */ w(
17
+ "div",
18
+ {
19
+ ref: m,
20
+ className: a("smwb-file-input", { "smwb-disabled": s }, u),
21
+ "data-testid": "file-input",
22
+ ...f(),
23
+ children: [
24
+ /* @__PURE__ */ n("button", { type: "button", className: a(d), disabled: s, onClick: N, children: c }),
25
+ /* @__PURE__ */ n("input", { ...b() }),
26
+ l ? /* @__PURE__ */ n("span", { className: "smwb-file-input__error", role: "alert", children: l }) : null
27
+ ]
28
+ }
29
+ );
30
+ });
31
+ export {
32
+ P as FileInput
33
+ };
34
+ //# sourceMappingURL=fileInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileInput.js","sources":["../../../../../src/components/inputs/fileInput/fileInput.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { type DropzoneOptions, useDropzone } from \"../../../hooks/useDropzone\";\nimport cn from \"clsx\";\n\nexport interface FileInputProps extends DropzoneOptions {\n label?: string;\n className?: string;\n buttonClassName?: string;\n disabled?: boolean;\n /** Validation message shown below the control. */\n error?: string;\n /** Fired with the accepted files when the user picks them. */\n onFilesSelected?: (files: File[]) => void;\n /** @deprecated optional click passthrough on the trigger button. */\n onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport const FileInput = forwardRef<HTMLDivElement, FileInputProps>(function FileInput(props, ref) {\n const { label, onClick, onFilesSelected, className, buttonClassName, disabled, error, ...dropzoneOptions } = props;\n\n const { getRootProps, getInputProps } = useDropzone({\n ...dropzoneOptions,\n disabled,\n onDropAccepted: (accepted, event) => {\n onFilesSelected?.(accepted);\n dropzoneOptions.onDropAccepted?.(accepted, event);\n },\n });\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n };\n\n return (\n <div\n ref={ref}\n className={cn(\"smwb-file-input\", { \"smwb-disabled\": disabled }, className)}\n data-testid=\"file-input\"\n {...getRootProps()}\n >\n <button type=\"button\" className={cn(buttonClassName)} disabled={disabled} onClick={handleClick}>\n {label}\n </button>\n <input {...getInputProps()} />\n {error ? (\n <span className=\"smwb-file-input__error\" role=\"alert\">\n {error}\n </span>\n ) : null}\n </div>\n );\n});\n\nexport default FileInput;\n"],"names":["FileInput","forwardRef","props","ref","label","onClick","onFilesSelected","className","buttonClassName","disabled","error","dropzoneOptions","getRootProps","getInputProps","useDropzone","accepted","event","_a","handleClick","e","jsxs","cn","jsx"],"mappings":";;;;AAiBO,MAAMA,IAAYC,EAA2C,SAAmBC,GAAOC,GAAK;AACjG,QAAM,EAAE,OAAAC,GAAO,SAAAC,GAAS,iBAAAC,GAAiB,WAAAC,GAAW,iBAAAC,GAAiB,UAAAC,GAAU,OAAAC,GAAO,GAAGC,EAAA,IAAoBT,GAEvG,EAAE,cAAAU,GAAc,eAAAC,EAAA,IAAkBC,EAAY;AAAA,IAClD,GAAGH;AAAA,IACH,UAAAF;AAAA,IACA,gBAAgB,CAACM,GAAUC,MAAU;;AACnC,MAAAV,KAAA,QAAAA,EAAkBS,KAClBE,IAAAN,EAAgB,mBAAhB,QAAAM,EAAA,KAAAN,GAAiCI,GAAUC;AAAA,IAC7C;AAAA,EAAA,CACD,GAEKE,IAAc,CAACC,MAA2C;AAC9D,IAAAd,KAAA,QAAAA,EAAUc;AAAA,EACZ;AAEA,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAjB;AAAA,MACA,WAAWkB,EAAG,mBAAmB,EAAE,iBAAiBZ,EAAA,GAAYF,CAAS;AAAA,MACzE,eAAY;AAAA,MACX,GAAGK,EAAA;AAAA,MAEJ,UAAA;AAAA,QAAA,gBAAAU,EAAC,UAAA,EAAO,MAAK,UAAS,WAAWD,EAAGb,CAAe,GAAG,UAAAC,GAAoB,SAASS,GAChF,UAAAd,EAAA,CACH;AAAA,QACA,gBAAAkB,EAAC,SAAA,EAAO,GAAGT,EAAA,EAAc,CAAG;AAAA,QAC3BH,sBACE,QAAA,EAAK,WAAU,0BAAyB,MAAK,SAC3C,aACH,IACE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;"}