@mage-ui/components 1.0.130 → 1.0.132

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 (67) hide show
  1. package/dist/components/controls/dropzone/Dropzone.d.mts +24 -93
  2. package/dist/components/controls/dropzone/Dropzone.d.mts.map +1 -1
  3. package/dist/components/controls/dropzone/Dropzone.mjs +1 -1
  4. package/dist/components/controls/dropzone/Dropzone.mjs.map +1 -1
  5. package/dist/components/controls/dropzone/DropzoneBase.d.mts +87 -0
  6. package/dist/components/controls/dropzone/DropzoneBase.d.mts.map +1 -0
  7. package/dist/components/controls/dropzone/DropzoneBase.mjs +2 -0
  8. package/dist/components/controls/dropzone/DropzoneBase.mjs.map +1 -0
  9. package/dist/components/controls/dropzone/DropzoneS3.d.mts +30 -0
  10. package/dist/components/controls/dropzone/DropzoneS3.d.mts.map +1 -0
  11. package/dist/components/controls/dropzone/DropzoneS3.mjs +2 -0
  12. package/dist/components/controls/dropzone/DropzoneS3.mjs.map +1 -0
  13. package/dist/components/controls/{avatar-dropzone → dropzone/avatar}/AvatarDropzone.d.mts +2 -2
  14. package/dist/components/controls/dropzone/avatar/AvatarDropzone.d.mts.map +1 -0
  15. package/dist/components/controls/dropzone/avatar/AvatarDropzone.mjs +2 -0
  16. package/dist/components/controls/dropzone/avatar/AvatarDropzone.mjs.map +1 -0
  17. package/dist/components/controls/dropzone/avatar/AvatarDropzoneS3.d.mts +41 -0
  18. package/dist/components/controls/dropzone/avatar/AvatarDropzoneS3.d.mts.map +1 -0
  19. package/dist/components/controls/dropzone/avatar/AvatarDropzoneS3.mjs +2 -0
  20. package/dist/components/controls/dropzone/avatar/AvatarDropzoneS3.mjs.map +1 -0
  21. package/dist/components/controls/dropzone/use-dropzone-state.mjs.map +1 -1
  22. package/dist/components/controls/dropzone/use-s3-upload.d.mts +70 -0
  23. package/dist/components/controls/dropzone/use-s3-upload.d.mts.map +1 -0
  24. package/dist/components/controls/dropzone/use-s3-upload.mjs +2 -0
  25. package/dist/components/controls/dropzone/use-s3-upload.mjs.map +1 -0
  26. package/dist/components/controls/index.d.mts +6 -5
  27. package/dist/components/data-display/index.d.mts +1 -0
  28. package/dist/components/data-display/resource-item/ResourceItem.mjs +1 -1
  29. package/dist/components/data-display/resource-item/ResourceItem.mjs.map +1 -1
  30. package/dist/components/data-display/uploaded-file/UploadedFile.mjs.map +1 -1
  31. package/dist/components/data-display/uploaded-files/UploadedFiles.d.mts +42 -0
  32. package/dist/components/data-display/uploaded-files/UploadedFiles.d.mts.map +1 -0
  33. package/dist/components/data-display/uploaded-files/UploadedFiles.mjs +2 -0
  34. package/dist/components/data-display/uploaded-files/UploadedFiles.mjs.map +1 -0
  35. package/dist/components/forms/Form.d.mts +5 -4
  36. package/dist/components/forms/Form.d.mts.map +1 -1
  37. package/dist/components/forms/Form.mjs +1 -1
  38. package/dist/components/forms/Form.mjs.map +1 -1
  39. package/dist/components/forms/controls/FormDropzoneS3.d.mts +12 -0
  40. package/dist/components/forms/controls/FormDropzoneS3.d.mts.map +1 -0
  41. package/dist/components/forms/controls/FormDropzoneS3.mjs +2 -0
  42. package/dist/components/forms/controls/FormDropzoneS3.mjs.map +1 -0
  43. package/dist/components/forms/controls/index.mjs +1 -1
  44. package/dist/components/forms/controls/index.mjs.map +1 -1
  45. package/dist/components/forms/controls/register-components.mjs +1 -1
  46. package/dist/components/forms/controls/register-components.mjs.map +1 -1
  47. package/dist/components/forms/rules/extract-form-rules.mjs +1 -1
  48. package/dist/components/forms/rules/extract-form-rules.mjs.map +1 -1
  49. package/dist/components/index.d.mts +7 -5
  50. package/dist/index.d.mts +8 -6
  51. package/dist/index.mjs +1 -1
  52. package/package.json +2 -2
  53. package/dist/components/controls/avatar-dropzone/AvatarDropzone.d.mts.map +0 -1
  54. package/dist/components/controls/avatar-dropzone/AvatarDropzone.mjs +0 -2
  55. package/dist/components/controls/avatar-dropzone/AvatarDropzone.mjs.map +0 -1
  56. package/dist/components/controls/dropzone-files/DropzoneFiles.d.mts +0 -62
  57. package/dist/components/controls/dropzone-files/DropzoneFiles.d.mts.map +0 -1
  58. package/dist/components/controls/dropzone-files/DropzoneFiles.mjs +0 -2
  59. package/dist/components/controls/dropzone-files/DropzoneFiles.mjs.map +0 -1
  60. package/dist/components/controls/dropzone-s3/DropzoneS3.d.mts +0 -114
  61. package/dist/components/controls/dropzone-s3/DropzoneS3.d.mts.map +0 -1
  62. package/dist/components/controls/dropzone-s3/DropzoneS3.mjs +0 -2
  63. package/dist/components/controls/dropzone-s3/DropzoneS3.mjs.map +0 -1
  64. package/dist/components/forms/controls/FormDropzoneFiles.d.mts +0 -12
  65. package/dist/components/forms/controls/FormDropzoneFiles.d.mts.map +0 -1
  66. package/dist/components/forms/controls/FormDropzoneFiles.mjs +0 -2
  67. package/dist/components/forms/controls/FormDropzoneFiles.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"AvatarDropzone.mjs","names":["MantineDropzone"],"sources":["../../../../src/components/controls/avatar-dropzone/AvatarDropzone.tsx"],"sourcesContent":["import { useCallback, useState } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n avatarDropzone,\n avatarDropzoneIcon,\n avatarDropzoneIconSlot,\n avatarDropzoneImage,\n avatarDropzoneInner,\n avatarDropzoneOverlay,\n avatarDropzoneOverlayIconSlot,\n avatarDropzoneRoot,\n} from '@mage-ui/styled-system/recipes';\nimport {\n IMAGE_MIME_TYPE,\n Dropzone as MantineDropzone,\n} from '@mantine/dropzone';\nimport { Icon, type IconProps } from '@/components/data-display';\n\nexport type AvatarDropzoneProps = {\n value?: string;\n onChange?: (file: File) => void;\n maxSize?: number;\n classNames?: {\n dropzone?: string;\n root?: string;\n inner?: string;\n image?: string;\n overlay?: string;\n overlayIconSlot?: string;\n iconSlot?: string;\n icon?: IconProps['classNames'];\n };\n};\n\nexport const AvatarDropzone = ({\n value,\n onChange,\n maxSize,\n classNames,\n}: AvatarDropzoneProps) => {\n const [preview, setPreview] = useState<string | null>(value ?? null);\n\n const handleDrop = useCallback(\n (files: File[]) => {\n const file = files[0];\n if (!file) return;\n const url = URL.createObjectURL(file);\n setPreview(url);\n onChange?.(file);\n },\n [onChange],\n );\n\n return (\n <MantineDropzone\n onDrop={handleDrop}\n accept={IMAGE_MIME_TYPE}\n maxFiles={1}\n maxSize={maxSize}\n classNames={{\n root: cx(\n classNames?.dropzone ?? avatarDropzone(),\n classNames?.root ?? avatarDropzoneRoot(),\n 'group',\n ),\n inner: classNames?.inner ?? avatarDropzoneInner(),\n }}\n >\n <MantineDropzone.Idle>\n {preview ? (\n <>\n <img\n src={preview}\n alt='Avatar'\n className={classNames?.image ?? avatarDropzoneImage()}\n />\n <div className={classNames?.overlay ?? avatarDropzoneOverlay()} />\n <div\n className={\n classNames?.overlayIconSlot ?? avatarDropzoneOverlayIconSlot()\n }\n >\n <Icon\n name='mage-avatar-dropzone-camera-plus'\n path='/icons/sprite-mage.svg'\n classNames={{\n icon: classNames?.icon?.icon ?? avatarDropzoneIcon(),\n }}\n />\n </div>\n </>\n ) : (\n <div className={classNames?.iconSlot ?? avatarDropzoneIconSlot()}>\n <Icon\n name='mage-avatar-dropzone-camera-plus'\n path='/icons/sprite-mage.svg'\n classNames={{\n icon: classNames?.icon?.icon ?? avatarDropzoneIcon(),\n }}\n />\n </div>\n )}\n </MantineDropzone.Idle>\n <MantineDropzone.Accept>\n <div className={classNames?.iconSlot ?? avatarDropzoneIconSlot()}>\n <Icon\n name='mage-dropzone-thumbs-up'\n path='/icons/sprite-mage.svg'\n classNames={{\n icon: classNames?.icon?.icon ?? avatarDropzoneIcon(),\n }}\n />\n </div>\n </MantineDropzone.Accept>\n <MantineDropzone.Reject>\n <div className={classNames?.iconSlot ?? avatarDropzoneIconSlot()}>\n <Icon\n name='mage-dropzone-thumbs-down'\n path='/icons/sprite-mage.svg'\n classNames={{\n icon: classNames?.icon?.icon ?? avatarDropzoneIcon(),\n }}\n />\n </div>\n </MantineDropzone.Reject>\n </M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A,EAAgB,OAAjB,CAAA,SACE,EAAC,MAAD,CAAK,UAAW,GAAY,UAAY,GAAwB,UAC9D,EAAC,EAAD,CACE,KAAK,4BACL,KAAK,yBACL,WAAY,CACV,KAAM,GAAY,MAAM,MAAQ,GAAoB,CACrD,CACD,CAAA,CACE,CAAA,CACiB,CAAA,CACT"}
@@ -1,62 +0,0 @@
1
- import { UploadedFileProps } from "../../data-display/uploaded-file/UploadedFile.mjs";
2
- import { DropzoneProps, FileData } from "../dropzone/Dropzone.mjs";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
4
- import { ReactNode } from "react";
5
-
6
- //#region src/components/controls/dropzone-files/DropzoneFiles.d.ts
7
- type DropzoneFilesProps = {
8
- label?: ReactNode;
9
- description?: ReactNode;
10
- error?: ReactNode;
11
- title?: ReactNode;
12
- subtitle?: ReactNode;
13
- hint?: ReactNode;
14
- initialFiles?: Record<string, FileData>;
15
- maxFiles?: number; /** Maximum file size in bytes. Files exceeding this will be rejected. */
16
- maxSize?: number;
17
- accept?: string[]; /** Required when autoSend=true (default). Optional when autoSend=false. */
18
- url?: string; /** When false, files are added to state but not uploaded automatically. Default: true. */
19
- autoSend?: boolean; /** Called when the file list changes (added or removed). Useful when autoSend=false. */
20
- onChange?: (files: File[]) => void;
21
- inputId?: string;
22
- hideWhenFull?: boolean;
23
- fileListHeight?: number | string;
24
- classNames?: {
25
- dropzoneFiles?: string;
26
- root?: string;
27
- labelWrapper?: string;
28
- label?: string;
29
- description?: string;
30
- error?: string;
31
- fileList?: string;
32
- fileItem?: string;
33
- uploadedFile?: UploadedFileProps['classNames'];
34
- dropzoneDropzone?: DropzoneProps['classNames'];
35
- scrollArea?: {
36
- scrollArea?: string;
37
- };
38
- };
39
- direction?: 'default' | 'reverse';
40
- };
41
- declare const DropzoneFiles: ({
42
- label,
43
- description,
44
- error,
45
- title,
46
- subtitle,
47
- hint,
48
- initialFiles,
49
- maxFiles,
50
- maxSize,
51
- accept,
52
- url,
53
- autoSend,
54
- onChange,
55
- inputId,
56
- hideWhenFull,
57
- classNames,
58
- direction
59
- }: DropzoneFilesProps) => react_jsx_runtime0.JSX.Element;
60
- //#endregion
61
- export { DropzoneFiles, DropzoneFilesProps };
62
- //# sourceMappingURL=DropzoneFiles.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropzoneFiles.d.mts","names":[],"sources":["../../../../src/components/controls/dropzone-files/DropzoneFiles.tsx"],"mappings":";;;;;;KAoCY,kBAAA;EACV,KAAA,GAAQ,SAAA;EACR,WAAA,GAAc,SAAA;EACd,KAAA,GAAQ,SAAA;EACR,KAAA,GAAQ,SAAA;EACR,QAAA,GAAW,SAAA;EACX,IAAA,GAAO,SAAA;EACP,YAAA,GAAe,MAAA,SAAe,QAAA;EAC9B,QAAA,WANc;EAQd,OAAA;EACA,MAAA,aANW;EAQX,GAAA,WAN8B;EAQ9B,QAAA,YAEmB;EAAnB,QAAA,IAAY,KAAA,EAAO,IAAA;EACnB,OAAA;EACA,YAAA;EACA,cAAA;EACA,UAAA;IACE,aAAA;IACA,IAAA;IACA,YAAA;IACA,KAAA;IACA,WAAA;IACA,KAAA;IACA,QAAA;IACA,QAAA;IACA,YAAA,GAAe,iBAAA;IACf,gBAAA,GAAmB,aAAA;IACnB,UAAA;MAAe,UAAA;IAAA;EAAA;EAIjB,SAAA;AAAA;AAAA,cAGW,aAAA;EAAiB,KAAA;EAAA,WAAA;EAAA,KAAA;EAAA,KAAA;EAAA,QAAA;EAAA,IAAA;EAAA,YAAA;EAAA,QAAA;EAAA,OAAA;EAAA,MAAA;EAAA,GAAA;EAAA,QAAA;EAAA,QAAA;EAAA,OAAA;EAAA,YAAA;EAAA,UAAA;EAAA;AAAA,GAkB3B,kBAAA,KAAkB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -1,2 +0,0 @@
1
- import{UploadedFile as e}from"../../data-display/uploaded-file/UploadedFile.mjs";import{UploadedFileDetails as t}from"../../data-display/uploaded-file/UploadedFileDetails.mjs";import{Dropzone as n}from"../dropzone/Dropzone.mjs";import{cx as r}from"@mage-ui/styled-system/css";import{dropzoneFiles as i,dropzoneFilesDescription as a,dropzoneFilesDropzone as o,dropzoneFilesError as s,dropzoneFilesFileItem as c,dropzoneFilesFileList as l,dropzoneFilesLabel as u,dropzoneFilesLabelWrapper as d,dropzoneFilesRoot as f,dropzoneFilesUploadedFile as p}from"@mage-ui/styled-system/recipes";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{useId as g}from"react";const _=({label:_,description:v,error:y,title:b,subtitle:x,hint:S,initialFiles:C,maxFiles:w,maxSize:T,accept:E,url:D,autoSend:O,onChange:k,inputId:A,hideWhenFull:j,classNames:M,direction:N=`default`})=>{let P=g(),F=A??P;return h(`div`,{className:r(M?.dropzoneFiles??i(),M?.root??f()),children:[h(`div`,{className:M?.labelWrapper??d(),children:[_&&m(`label`,{htmlFor:F,className:M?.label??u(),children:_}),v&&m(`p`,{className:M?.description??a(),children:v})]}),m(n,{maxFiles:w,maxSize:T,accept:E,url:D,autoSend:O,onChange:k,initialFiles:C,inputId:F,title:b,subtitle:x,hint:S,direction:N,hideWhenFull:j,classNames:{dropzone:M?.dropzoneDropzone?.dropzone??o()},children:({files:n,removeFile:r})=>Object.keys(n).length>0?m(`ul`,{className:M?.fileList??l(),children:Object.values(n).map(n=>m(`li`,{className:M?.fileItem??c(),children:m(e,{fileName:n.name,fileType:n.type,url:n.url,onRemove:()=>r(n.name),classNames:{uploadedFile:M?.uploadedFile?.uploadedFile??p()},children:m(t,{fileSize:`${(n.size/1024).toFixed(1)} KB`,fileDate:n.date,fileType:n.type})},n.name)},n.name))}):null}),y&&m(`p`,{className:M?.error??s(),children:y})]})};export{_ as DropzoneFiles};
2
- //# sourceMappingURL=DropzoneFiles.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropzoneFiles.mjs","names":[],"sources":["../../../../src/components/controls/dropzone-files/DropzoneFiles.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n dropzoneFiles,\n dropzoneFilesDescription,\n dropzoneFilesDropzone,\n dropzoneFilesError,\n dropzoneFilesFileItem,\n dropzoneFilesFileList,\n dropzoneFilesLabel,\n dropzoneFilesLabelWrapper,\n dropzoneFilesRoot,\n dropzoneFilesUploadedFile,\n // dropzoneFilesUploadedFileStartIconWrapped,\n // dropzoneFilesUploadedFileStartIconWrappedRoot,\n // dropzoneFilesUploadedFileStartIcon,\n // dropzoneFilesUploadedFileStartIconRoot,\n // dropzoneFilesUploadedFileStartIconIconRaw,\n // dropzoneFilesUploadedFileStartIconIconRawRoot,\n} from '@mage-ui/styled-system/recipes';\nimport {\n Dropzone,\n type DropzoneProps,\n type FileData,\n} from '@/components/controls';\nimport {\n // Icon,\n // type IconProps,\n // IconWrapped,\n // type IconWrappedProps,\n UploadedFile,\n UploadedFileDetails,\n type UploadedFileProps,\n} from '@/components/data-display';\n\nexport type DropzoneFilesProps = {\n label?: ReactNode;\n description?: ReactNode;\n error?: ReactNode;\n title?: ReactNode;\n subtitle?: ReactNode;\n hint?: ReactNode;\n initialFiles?: Record<string, FileData>;\n maxFiles?: number;\n /** Maximum file size in bytes. Files exceeding this will be rejected. */\n maxSize?: number;\n accept?: string[];\n /** Required when autoSend=true (default). Optional when autoSend=false. */\n url?: string;\n /** When false, files are added to state but not uploaded automatically. Default: true. */\n autoSend?: boolean;\n /** Called when the file list changes (added or removed). Useful when autoSend=false. */\n onChange?: (files: File[]) => void;\n inputId?: string;\n hideWhenFull?: boolean;\n fileListHeight?: number | string;\n classNames?: {\n dropzoneFiles?: string;\n root?: string;\n labelWrapper?: string;\n label?: string;\n description?: string;\n error?: string;\n fileList?: string;\n fileItem?: string;\n uploadedFile?: UploadedFileProps['classNames'];\n dropzoneDropzone?: DropzoneProps['classNames'];\n scrollArea?: { scrollArea?: string };\n // startIconWrapped?: IconWrappedProps['classNames'];\n // startIcon?: IconProps['classNames'];\n };\n direction?: 'default' | 'reverse';\n};\n\nexport const DropzoneFiles = ({\n label,\n description,\n error,\n title,\n subtitle,\n hint,\n initialFiles,\n maxFiles,\n maxSize,\n accept,\n url,\n autoSend,\n onChange,\n inputId,\n hideWhenFull,\n classNames,\n direction = 'default',\n}: DropzoneFilesProps) => {\n const generatedId = useId();\n const groupId = inputId ?? generatedId;\n\n // TODO: gestionar error\n // TOOD: gestionar required\n return (\n <div\n className={cx(\n classNames?.dropzoneFiles ?? dropzoneFiles(),\n classNames?.root ?? dropzoneFilesRoot(),\n )}\n >\n <div className={classNames?.labelWrapper ?? dropzoneFilesLabelWrapper()}>\n {/* TODO: label obligatori / hidden */}\n {label && (\n <label\n htmlFor={groupId}\n className={classNames?.label ?? dropzoneFilesLabel()}\n >\n {label}\n </label>\n )}\n {description && (\n <p className={classNames?.description ?? dropzoneFilesDescription()}>\n {description}\n </p>\n )}\n </div>\n <Dropzone\n maxFiles={maxFiles}\n maxSize={maxSize}\n accept={accept}\n url={url}\n autoSend={autoSend}\n onChange={onChange}\n initialFiles={initialFiles}\n inputId={groupId}\n title={title}\n subtitle={subtitle}\n hint={hint}\n direction={direction}\n hideWhenFull={hideWhenFull}\n classNames={{\n dropzone:\n classNames?.dropzoneDropzone?.dropzone ?? dropzoneFilesDropzone(),\n }}\n >\n {({ files, removeFile }) =>\n Object.keys(files).length > 0 ? (\n <ul className={classNames?.fileList ?? dropzoneFilesFileList()}>\n {Object.values(files).map((file) => (\n <li\n key={file.name}\n className={classNames?.fileItem ?? dropzoneFilesFileItem()}\n >\n <UploadedFile\n key={file.name}\n fileName={file.name}\n fileType={file.type}\n url={file.url}\n onRemove={() => removeFile(file.name)}\n classNames={{\n uploadedFile:\n classNames?.uploadedFile?.uploadedFile ??\n dropzoneFilesUploadedFile(),\n }}\n >\n {/* TODO: comentar */}\n <UploadedFileDetails\n fileSize={`${(file.size / 1024).toFixed(1)} KB`}\n fileDate={file.date}\n fileType={file.type}\n />\n </UploadedFile>\n </li>\n ))}\n </ul>\n ) : null\n }\n </Dropzone>\n {error && (\n <p className={classNames?.error ?? dropzoneFilesError()}>{error}</p>\n )}\n </div>\n );\n};\n"],"mappings":"upBA2EA,MAAa,GAAiB,CAC5B,QACA,cACA,QACA,QACA,WACA,OACA,eACA,WACA,UACA,SACA,MACA,WACA,WACA,UACA,eACA,aACA,YAAY,aACY,CACxB,IAAM,EAAc,GAAO,CACrB,EAAU,GAAW,EAI3B,OACE,EAAC,MAAD,CACE,UAAW,EACT,GAAY,eAAiB,GAAe,CAC5C,GAAY,MAAQ,GAAmB,CACxC,UAJH,CAME,EAAC,MAAD,CAAK,UAAW,GAAY,cAAgB,GAA2B,UAAvE,CAEG,GACC,EAAC,QAAD,CACE,QAAS,EACT,UAAW,GAAY,OAAS,GAAoB,UAEnD,EACK,CAAA,CAET,GACC,EAAC,IAAD,CAAG,UAAW,GAAY,aAAe,GAA0B,UAChE,EACC,CAAA,CAEF,GACN,EAAC,EAAD,CACY,WACD,UACD,SACH,MACK,WACA,WACI,eACd,QAAS,EACF,QACG,WACJ,OACK,YACG,eACd,WAAY,CACV,SACE,GAAY,kBAAkB,UAAY,GAAuB,CACpE,WAEC,CAAE,QAAO,gBACT,OAAO,KAAK,EAAM,CAAC,OAAS,EAC1B,EAAC,KAAD,CAAI,UAAW,GAAY,UAAY,GAAuB,UAC3D,OAAO,OAAO,EAAM,CAAC,IAAK,GACzB,EAAC,KAAD,CAEE,UAAW,GAAY,UAAY,GAAuB,UAE1D,EAAC,EAAD,CAEE,SAAU,EAAK,KACf,SAAU,EAAK,KACf,IAAK,EAAK,IACV,aAAgB,EAAW,EAAK,KAAK,CACrC,WAAY,CACV,aACE,GAAY,cAAc,cAC1B,GAA2B,CAC9B,UAGD,EAAC,EAAD,CACE,SAAU,IAAI,EAAK,KAAO,MAAM,QAAQ,EAAE,CAAC,KAC3C,SAAU,EAAK,KACf,SAAU,EAAK,KACf,CAAA,CACW,CAjBR,EAAK,KAiBG,CACZ,CAtBE,EAAK,KAsBP,CACL,CACC,CAAA,CACH,KAEG,CAAA,CACV,GACC,EAAC,IAAD,CAAG,UAAW,GAAY,OAAS,GAAoB,UAAG,EAAU,CAAA,CAElE"}
@@ -1,114 +0,0 @@
1
- import { DropzoneProps } from "../dropzone/Dropzone.mjs";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
- import { ReactNode } from "react";
4
-
5
- //#region src/components/controls/dropzone-s3/DropzoneS3.d.ts
6
- /**
7
- * Body of the response returned by the init endpoint. Must at least
8
- * expose a `url` to PUT the file to; may carry any number of extra
9
- * fields that the consumer forwards to the register step (e.g.
10
- * `document_id`, `key`).
11
- */
12
- type S3InitBody = {
13
- url: string;
14
- headers?: Record<string, string | string[]>;
15
- } & Record<string, unknown>;
16
- type S3InitResponse<TBody extends S3InitBody = S3InitBody> = {
17
- body: TBody;
18
- };
19
- /** Metadata derived from the file that body builders frequently need. */
20
- type S3FileMeta = {
21
- /**
22
- * Best-effort MIME type. When `acceptedTypes` is provided and the
23
- * browser-reported `file.type` is empty or unknown, this falls back to
24
- * the MIME mapped from the file extension.
25
- */
26
- mimeType: string; /** Lowercase file extension without the leading dot. */
27
- extension: string;
28
- };
29
- /** All replaceable UI and error strings surfaced by DropzoneS3. */
30
- type DropzoneS3Texts = {
31
- /** Main dropzone heading. */title?: ReactNode; /** Secondary dropzone text. */
32
- subtitle?: ReactNode; /** Small helper text below the subtitle. */
33
- hint?: ReactNode; /** Fallback shown when the init request fails without a parseable body. */
34
- initFailed?: (status: number) => string; /** Fallback shown when the register request fails without a parseable body. */
35
- registerFailed?: (status: number) => string; /** Error when the S3 PUT returns a non-2xx status. */
36
- uploadFailed?: (status: number, statusText: string) => string; /** Error when the network fails during the PUT. */
37
- networkError?: string; /** Error when the PUT is aborted. */
38
- uploadAborted?: string; /** Error when the PUT times out. */
39
- uploadTimedOut?: string;
40
- };
41
- type DropzoneS3Props<TInitBody extends S3InitBody = S3InitBody> = Omit<DropzoneProps, 'uploader' | 'url' | 'children' | 'accept' | 'title' | 'subtitle' | 'hint'> & {
42
- /** All replaceable UI and error strings. Any field left unset falls back
43
- * to the English default. */
44
- texts?: DropzoneS3Texts;
45
- /**
46
- * Map of file extension → MIME type. When provided, DropzoneS3
47
- * automatically computes the `accept` map (MIME → ['.ext']) used by
48
- * the underlying Mantine / react-dropzone, and uses it to resolve
49
- * `meta.mimeType` per file (covering browsers that report an empty
50
- * `file.type` for some Office formats).
51
- *
52
- * Ignored when `accept` is passed explicitly.
53
- */
54
- acceptedTypes?: Record<string, string>;
55
- /**
56
- * Explicit accept list forwarded to the underlying Mantine dropzone.
57
- * Takes precedence over `acceptedTypes`. Prefer the map shape
58
- * `{ [mimeType]: ['.ext', ...] }` — passing a `.ext` entry inside a
59
- * plain `string[]` triggers a "Skipped … not a valid MIME type"
60
- * warning in react-dropzone v15+.
61
- */
62
- accept?: string[] | Record<string, string[]>; /** POST endpoint that returns `{ body: { url, headers?, ...extras } }`. */
63
- initUrl: string; /** Build the init request JSON body from the file and resolved meta. */
64
- buildInitBody: (file: File, meta: S3FileMeta) => Record<string, unknown>;
65
- /**
66
- * Optional post-upload registration step. When set, a POST is sent to
67
- * `register.url` with the body produced by `register.buildBody`.
68
- */
69
- register?: {
70
- url: string;
71
- buildBody: (file: File, init: TInitBody, meta: S3FileMeta) => Record<string, unknown>;
72
- };
73
- /**
74
- * Called on every outbound request (init, register). Use it to supply
75
- * auth/CSRF headers that may rotate during the session.
76
- */
77
- getHeaders?: () => Record<string, string>;
78
- /**
79
- * Customize how an error response is turned into a human-readable
80
- * message. Defaults to common Laravel-style error shapes
81
- * (`errors`, `body.message`, `message`).
82
- */
83
- getErrorMessage?: (res: Response, fallback: string) => Promise<string>;
84
- /**
85
- * URL stored in `FileData.url` after a successful upload. Defaults to
86
- * `init.body.key` when present, falling back to the presigned URL
87
- * stripped of its query string.
88
- */
89
- resolveUploadedUrl?: (init: TInitBody, file: File) => string;
90
- /**
91
- * Override the default children (a list of in-flight / errored files).
92
- * Use it when you need to render the progress list elsewhere in the
93
- * layout or when you want a completely custom UI.
94
- */
95
- children?: DropzoneProps['children'];
96
- };
97
- /** Lowercase extension without leading dot, or empty string. */
98
- declare const getFileExtension: (filename: string) => string;
99
- declare const DropzoneS3: <TInitBody extends S3InitBody = S3InitBody>({
100
- texts,
101
- acceptedTypes,
102
- accept,
103
- initUrl,
104
- buildInitBody,
105
- register,
106
- getHeaders,
107
- getErrorMessage,
108
- resolveUploadedUrl,
109
- children,
110
- ...dropzoneProps
111
- }: DropzoneS3Props<TInitBody>) => react_jsx_runtime0.JSX.Element;
112
- //#endregion
113
- export { DropzoneS3, DropzoneS3Props, DropzoneS3Texts, S3FileMeta, S3InitBody, S3InitResponse, getFileExtension };
114
- //# sourceMappingURL=DropzoneS3.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropzoneS3.d.mts","names":[],"sources":["../../../../src/components/controls/dropzone-s3/DropzoneS3.tsx"],"mappings":";;;;;;;;AAgBA;;;KAAY,UAAA;EACV,GAAA;EACA,OAAA,GAAU,MAAA;AAAA,IACR,MAAA;AAAA,KAEQ,cAAA,eAA6B,UAAA,GAAa,UAAA;EACpD,IAAA,EAAM,KAAA;AAAA;AADR;AAAA,KAKY,UAAA;EALc;;;;;EAWxB,QAAA,UAXyB;EAazB,SAAA;AAAA;;KAIU,eAAA;EAhBC,6BAkBX,KAAA,GAAQ,SAAA,EAdE;EAgBV,QAAA,GAAW,SAAA;EAEX,IAAA,GAAO,SAAA,EAVE;EAYT,UAAA,IAAc,MAAA,qBARW;EAUzB,cAAA,IAAkB,MAAA,qBARV;EAUR,YAAA,IAAgB,MAAA,UAAgB,UAAA,qBANzB;EAQP,YAAA,WARgB;EAUhB,aAAA,WAdQ;EAgBR,cAAA;AAAA;AAAA,KAeU,eAAA,mBAAkC,UAAA,GAAa,UAAA,IAAc,IAAA,CACvE,aAAA;EA5BO;;EAiCP,KAAA,GAAQ,eAAA;EA7BR;;;;;;;;;EAuCA,aAAA,GAAgB,MAAA;EAhBN;;;;;;;EAwBV,MAAA,cAAoB,MAAA,oBARJ;EAUhB,OAAA,UAEsB;EAAtB,aAAA,GAAgB,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,UAAA,KAAe,MAAA;EAAA;;;;EAKjD,QAAA;IACE,GAAA;IACA,SAAA,GACE,IAAA,EAAM,IAAA,EACN,IAAA,EAAM,SAAA,EACN,IAAA,EAAM,UAAA,KACH,MAAA;EAAA;EAkBqB;;;;EAZ5B,UAAA,SAAmB,MAAA;EA7CO;;;;;EAmD1B,eAAA,IAAmB,GAAA,EAAK,QAAA,EAAU,QAAA,aAAqB,OAAA;EA7C/C;;;;;EAmDR,kBAAA,IAAsB,IAAA,EAAM,SAAA,EAAW,IAAA,EAAM,IAAA;EA7B7C;;;;;EAmCA,QAAA,GAAW,aAAA;AAAA;;cA+EA,gBAAA,GAAoB,QAAA;AAAA,cAyEpB,UAAA,qBAAgC,UAAA,GAAa,UAAA;EAAY,KAAA;EAAA,aAAA;EAAA,MAAA;EAAA,OAAA;EAAA,aAAA;EAAA,QAAA;EAAA,UAAA;EAAA,eAAA;EAAA,kBAAA;EAAA,QAAA;EAAA,GAAA;AAAA,GAYnE,eAAA,CAAgB,SAAA,MAAU,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -1,2 +0,0 @@
1
- import{UploadingFiles as e}from"../../data-display/uploading-files/UploadingFiles.mjs";import{Dropzone as t}from"../dropzone/Dropzone.mjs";import{jsx as n}from"react/jsx-runtime";const r={initFailed:e=>`Failed to request upload URL (${e})`,registerFailed:e=>`Failed to register file (${e})`,uploadFailed:(e,t)=>`Upload failed (${e} ${t})`,networkError:`Network error during direct upload`,uploadAborted:`Upload aborted`,uploadTimedOut:`Upload timed out`},i=async(e,t)=>{try{let n=await e.clone().json();if(n.errors){let e=Object.values(n.errors)[0];if(e&&e.length>0)return e[0]}return n.body?.message??n.body?.text??n.message??t}catch{return t}},a=(e,t,n,r,i)=>new Promise((a,o)=>{let s=new XMLHttpRequest;s.upload.addEventListener(`progress`,e=>{e.lengthComputable&&r(Math.round(e.loaded/e.total*100))}),s.addEventListener(`load`,()=>{s.status>=200&&s.status<300?a():o(Error(i.uploadFailed(s.status,s.statusText)))}),s.addEventListener(`error`,()=>o(Error(i.networkError))),s.addEventListener(`abort`,()=>o(Error(i.uploadAborted))),s.addEventListener(`timeout`,()=>o(Error(i.uploadTimedOut))),s.open(`PUT`,e);for(let[e,n]of Object.entries(t)){let t=e.toLowerCase();if(!(t===`host`||t===`content-length`))try{s.setRequestHeader(e,n)}catch{}}s.send(n)}),o=e=>{let t={};if(!e)return t;for(let[n,r]of Object.entries(e))t[n]=Array.isArray(r)?r.join(`,`):String(r);return t},s=e=>{let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``},c=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e)){let e=`.${n}`,i=t[r];i?i.includes(e)||i.push(e):t[r]=[e]}return t},l=(e,t)=>{let n=s(e.name);if(!t)return{mimeType:e.type,extension:n};let r=Object.values(t);return e.type&&r.includes(e.type)?{mimeType:e.type,extension:n}:{mimeType:t[n]??e.type,extension:n}},u=({files:t})=>{let r=Object.values(t).filter(e=>e.loading||!!e.error);return r.length===0?null:n(e,{children:r.map(t=>t.error?n(e.ItemError,{name:t.name,message:t.error},t.name):n(e.Item,{name:t.name,progress:t.progress??0},t.name))})},d=({texts:e,acceptedTypes:s,accept:d,initUrl:f,buildInitBody:p,register:m,getHeaders:h,getErrorMessage:g=i,resolveUploadedUrl:_,children:v,...y})=>{let b=d??c(s),x={...r,...e},S=async(e,{onProgress:t})=>{let n=()=>({"Content-Type":`application/json`,Accept:`application/json`,...h?.()??{}}),r=l(e,s),i=await fetch(f,{method:`POST`,headers:n(),body:JSON.stringify(p(e,r))});if(!i.ok)throw Error(await g(i,x.initFailed(i.status)));let c=await i.json(),{url:u,headers:d}=c.body;if(await a(u,o(d),e,n=>t?.({loaded:0,total:e.size,percentage:n}),x),m){let t=await fetch(m.url,{method:`POST`,headers:n(),body:JSON.stringify(m.buildBody(e,c.body,r))});if(!t.ok)throw Error(await g(t,x.registerFailed(t.status)))}return{body:{url:_?.(c.body,e)??(typeof c.body.key==`string`?c.body.key:u.split(`?`)[0])}}};return n(t,{...y,title:e?.title,subtitle:e?.subtitle,hint:e?.hint,accept:b,uploader:S,children:v??u})};export{d as DropzoneS3,s as getFileExtension};
2
- //# sourceMappingURL=DropzoneS3.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropzoneS3.mjs","names":[],"sources":["../../../../src/components/controls/dropzone-s3/DropzoneS3.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { UploadingFiles } from '@/components/data-display';\n\nimport {\n Dropzone,\n type DropzoneProps,\n type Uploader,\n} from '../dropzone/Dropzone';\n\n/**\n * Body of the response returned by the init endpoint. Must at least\n * expose a `url` to PUT the file to; may carry any number of extra\n * fields that the consumer forwards to the register step (e.g.\n * `document_id`, `key`).\n */\nexport type S3InitBody = {\n url: string;\n headers?: Record<string, string | string[]>;\n} & Record<string, unknown>;\n\nexport type S3InitResponse<TBody extends S3InitBody = S3InitBody> = {\n body: TBody;\n};\n\n/** Metadata derived from the file that body builders frequently need. */\nexport type S3FileMeta = {\n /**\n * Best-effort MIME type. When `acceptedTypes` is provided and the\n * browser-reported `file.type` is empty or unknown, this falls back to\n * the MIME mapped from the file extension.\n */\n mimeType: string;\n /** Lowercase file extension without the leading dot. */\n extension: string;\n};\n\n/** All replaceable UI and error strings surfaced by DropzoneS3. */\nexport type DropzoneS3Texts = {\n /** Main dropzone heading. */\n title?: ReactNode;\n /** Secondary dropzone text. */\n subtitle?: ReactNode;\n /** Small helper text below the subtitle. */\n hint?: ReactNode;\n /** Fallback shown when the init request fails without a parseable body. */\n initFailed?: (status: number) => string;\n /** Fallback shown when the register request fails without a parseable body. */\n registerFailed?: (status: number) => string;\n /** Error when the S3 PUT returns a non-2xx status. */\n uploadFailed?: (status: number, statusText: string) => string;\n /** Error when the network fails during the PUT. */\n networkError?: string;\n /** Error when the PUT is aborted. */\n uploadAborted?: string;\n /** Error when the PUT times out. */\n uploadTimedOut?: string;\n};\n\nconst DEFAULT_TEXTS = {\n initFailed: (status: number): string =>\n `Failed to request upload URL (${status})`,\n registerFailed: (status: number): string =>\n `Failed to register file (${status})`,\n uploadFailed: (status: number, statusText: string): string =>\n `Upload failed (${status} ${statusText})`,\n networkError: 'Network error during direct upload',\n uploadAborted: 'Upload aborted',\n uploadTimedOut: 'Upload timed out',\n} as const;\n\nexport type DropzoneS3Props<TInitBody extends S3InitBody = S3InitBody> = Omit<\n DropzoneProps,\n 'uploader' | 'url' | 'children' | 'accept' | 'title' | 'subtitle' | 'hint'\n> & {\n /** All replaceable UI and error strings. Any field left unset falls back\n * to the English default. */\n texts?: DropzoneS3Texts;\n /**\n * Map of file extension → MIME type. When provided, DropzoneS3\n * automatically computes the `accept` map (MIME → ['.ext']) used by\n * the underlying Mantine / react-dropzone, and uses it to resolve\n * `meta.mimeType` per file (covering browsers that report an empty\n * `file.type` for some Office formats).\n *\n * Ignored when `accept` is passed explicitly.\n */\n acceptedTypes?: Record<string, string>;\n /**\n * Explicit accept list forwarded to the underlying Mantine dropzone.\n * Takes precedence over `acceptedTypes`. Prefer the map shape\n * `{ [mimeType]: ['.ext', ...] }` — passing a `.ext` entry inside a\n * plain `string[]` triggers a \"Skipped … not a valid MIME type\"\n * warning in react-dropzone v15+.\n */\n accept?: string[] | Record<string, string[]>;\n /** POST endpoint that returns `{ body: { url, headers?, ...extras } }`. */\n initUrl: string;\n /** Build the init request JSON body from the file and resolved meta. */\n buildInitBody: (file: File, meta: S3FileMeta) => Record<string, unknown>;\n /**\n * Optional post-upload registration step. When set, a POST is sent to\n * `register.url` with the body produced by `register.buildBody`.\n */\n register?: {\n url: string;\n buildBody: (\n file: File,\n init: TInitBody,\n meta: S3FileMeta,\n ) => Record<string, unknown>;\n };\n /**\n * Called on every outbound request (init, register). Use it to supply\n * auth/CSRF headers that may rotate during the session.\n */\n getHeaders?: () => Record<string, string>;\n /**\n * Customize how an error response is turned into a human-readable\n * message. Defaults to common Laravel-style error shapes\n * (`errors`, `body.message`, `message`).\n */\n getErrorMessage?: (res: Response, fallback: string) => Promise<string>;\n /**\n * URL stored in `FileData.url` after a successful upload. Defaults to\n * `init.body.key` when present, falling back to the presigned URL\n * stripped of its query string.\n */\n resolveUploadedUrl?: (init: TInitBody, file: File) => string;\n /**\n * Override the default children (a list of in-flight / errored files).\n * Use it when you need to render the progress list elsewhere in the\n * layout or when you want a completely custom UI.\n */\n children?: DropzoneProps['children'];\n};\n\nconst defaultGetErrorMessage = async (\n res: Response,\n fallback: string,\n): Promise<string> => {\n try {\n const data = (await res.clone().json()) as {\n message?: string;\n body?: { message?: string; text?: string };\n errors?: Record<string, string[]>;\n };\n if (data.errors) {\n const first = Object.values(data.errors)[0];\n if (first && first.length > 0) return first[0];\n }\n return data.body?.message ?? data.body?.text ?? data.message ?? fallback;\n } catch {\n return fallback;\n }\n};\n\ntype PutTexts = {\n uploadFailed: (status: number, statusText: string) => string;\n networkError: string;\n uploadAborted: string;\n uploadTimedOut: string;\n};\n\nconst putWithProgress = (\n url: string,\n headers: Record<string, string>,\n file: File,\n onProgress: (percentage: number) => void,\n texts: PutTexts,\n): Promise<void> => {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.upload.addEventListener('progress', (e) => {\n if (e.lengthComputable) {\n onProgress(Math.round((e.loaded / e.total) * 100));\n }\n });\n xhr.addEventListener('load', () => {\n if (xhr.status >= 200 && xhr.status < 300) resolve();\n else reject(new Error(texts.uploadFailed(xhr.status, xhr.statusText)));\n });\n xhr.addEventListener('error', () => reject(new Error(texts.networkError)));\n xhr.addEventListener('abort', () => reject(new Error(texts.uploadAborted)));\n xhr.addEventListener('timeout', () =>\n reject(new Error(texts.uploadTimedOut)),\n );\n xhr.open('PUT', url);\n for (const [k, v] of Object.entries(headers)) {\n const lk = k.toLowerCase();\n if (lk === 'host' || lk === 'content-length') continue;\n try {\n xhr.setRequestHeader(k, v);\n } catch {\n // Some headers are blocked by the browser — skip silently.\n }\n }\n xhr.send(file);\n });\n};\n\nconst flattenHeaders = (\n headers: Record<string, string | string[]> | undefined,\n): Record<string, string> => {\n const out: Record<string, string> = {};\n if (!headers) return out;\n for (const [k, v] of Object.entries(headers)) {\n out[k] = Array.isArray(v) ? v.join(',') : String(v);\n }\n return out;\n};\n\n/** Lowercase extension without leading dot, or empty string. */\nexport const getFileExtension = (filename: string): string => {\n const dot = filename.lastIndexOf('.');\n return dot >= 0 ? filename.slice(dot + 1).toLowerCase() : '';\n};\n\n/**\n * Build the `accept` map in the shape react-dropzone v15+ expects:\n * `{ [mimeType]: ['.ext', ...] }`. Multiple extensions that share a\n * MIME type (e.g. xls + xlsx in some legacy mappings) are grouped\n * under the same key.\n *\n * The previous flat-array shape (`[...mimes, ...'.exts']`) caused\n * react-dropzone to log `Skipped \".xlsx\" because it is not a valid\n * MIME type` and dropped the extension from the `<input accept>`\n * attribute, breaking selection on browsers that report an empty\n * `file.type` for Office formats.\n */\nconst buildAcceptMap = (\n acceptedTypes: Record<string, string> | undefined,\n): Record<string, string[]> | undefined => {\n if (!acceptedTypes) return undefined;\n const map: Record<string, string[]> = {};\n for (const [ext, mime] of Object.entries(acceptedTypes)) {\n const dotted = `.${ext}`;\n const list = map[mime];\n if (list) {\n if (!list.includes(dotted)) list.push(dotted);\n } else {\n map[mime] = [dotted];\n }\n }\n return map;\n};\n\nconst resolveMeta = (\n file: File,\n acceptedTypes: Record<string, string> | undefined,\n): S3FileMeta => {\n const extension = getFileExtension(file.name);\n if (!acceptedTypes) {\n return { mimeType: file.type, extension };\n }\n const mimeList = Object.values(acceptedTypes);\n if (file.type && mimeList.includes(file.type)) {\n return { mimeType: file.type, extension };\n }\n return { mimeType: acceptedTypes[extension] ?? file.type, extension };\n};\n\nconst defaultChildren: DropzoneProps['children'] = ({ files }) => {\n const uploading = Object.values(files).filter((f) => f.loading || !!f.error);\n if (uploading.length === 0) return null;\n return (\n <UploadingFiles>\n {uploading.map((file) =>\n file.error ? (\n <UploadingFiles.ItemError\n key={file.name}\n name={file.name}\n message={file.error}\n />\n ) : (\n <UploadingFiles.Item\n key={file.name}\n name={file.name}\n progress={file.progress ?? 0}\n />\n ),\n )}\n </UploadingFiles>\n );\n};\n\nexport const DropzoneS3 = <TInitBody extends S3InitBody = S3InitBody>({\n texts,\n acceptedTypes,\n accept,\n initUrl,\n buildInitBody,\n register,\n getHeaders,\n getErrorMessage = defaultGetErrorMessage,\n resolveUploadedUrl,\n children,\n ...dropzoneProps\n}: DropzoneS3Props<TInitBody>) => {\n const acceptList = accept ?? buildAcceptMap(acceptedTypes);\n const t = { ...DEFAULT_TEXTS, ...texts };\n\n const uploader: Uploader = async (file, { onProgress }) => {\n const jsonHeaders = (): Record<string, string> => ({\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n ...(getHeaders?.() ?? {}),\n });\n const meta = resolveMeta(file, acceptedTypes);\n\n // 1. init — request a presigned URL.\n const initRes = await fetch(initUrl, {\n method: 'POST',\n headers: jsonHeaders(),\n body: JSON.stringify(buildInitBody(file, meta)),\n });\n if (!initRes.ok) {\n throw new Error(\n await getErrorMessage(initRes, t.initFailed(initRes.status)),\n );\n }\n const init = (await initRes.json()) as S3InitResponse<TInitBody>;\n const { url, headers: s3Headers } = init.body;\n\n // 2. direct upload to S3.\n await putWithProgress(\n url,\n flattenHeaders(s3Headers),\n file,\n (p) => onProgress?.({ loaded: 0, total: file.size, percentage: p }),\n t,\n );\n\n // 3. register (optional) — persist metadata on the app backend.\n if (register) {\n const regRes = await fetch(register.url, {\n method: 'POST',\n headers: jsonHeaders(),\n body: JSON.stringify(register.buildBody(file, init.body, meta)),\n });\n if (!regRes.ok) {\n throw new Error(\n await getErrorMessage(regRes, t.registerFailed(regRes.status)),\n );\n }\n }\n\n const storedUrl =\n resolveUploadedUrl?.(init.body, file) ??\n (typeof init.body.key === 'string' ? init.body.key : url.split('?')[0]);\n return { body: { url: storedUrl } };\n };\n\n return (\n <Dropzone\n {...dropzoneProps}\n title={texts?.title}\n subtitle={texts?.subtitle}\n hint={texts?.hint}\n accept={acceptList}\n uploader={uploader}\n >\n {children ?? defaultChildren}\n </Dropzone>\n );\n};\n"],"mappings":"mLA2DA,MAAM,EAAgB,CACpB,WAAa,GACX,iCAAiC,EAAO,GAC1C,eAAiB,GACf,4BAA4B,EAAO,GACrC,cAAe,EAAgB,IAC7B,kBAAkB,EAAO,GAAG,EAAW,GACzC,aAAc,qCACd,cAAe,iBACf,eAAgB,mBACjB,CAoEK,EAAyB,MAC7B,EACA,IACoB,CACpB,GAAI,CACF,IAAM,EAAQ,MAAM,EAAI,OAAO,CAAC,MAAM,CAKtC,GAAI,EAAK,OAAQ,CACf,IAAM,EAAQ,OAAO,OAAO,EAAK,OAAO,CAAC,GACzC,GAAI,GAAS,EAAM,OAAS,EAAG,OAAO,EAAM,GAE9C,OAAO,EAAK,MAAM,SAAW,EAAK,MAAM,MAAQ,EAAK,SAAW,OAC1D,CACN,OAAO,IAWL,GACJ,EACA,EACA,EACA,EACA,IAEO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAM,EAAM,IAAI,eAChB,EAAI,OAAO,iBAAiB,WAAa,GAAM,CACzC,EAAE,kBACJ,EAAW,KAAK,MAAO,EAAE,OAAS,EAAE,MAAS,IAAI,CAAC,EAEpD,CACF,EAAI,iBAAiB,WAAc,CAC7B,EAAI,QAAU,KAAO,EAAI,OAAS,IAAK,GAAS,CAC/C,EAAW,MAAM,EAAM,aAAa,EAAI,OAAQ,EAAI,WAAW,CAAC,CAAC,EACtE,CACF,EAAI,iBAAiB,YAAe,EAAW,MAAM,EAAM,aAAa,CAAC,CAAC,CAC1E,EAAI,iBAAiB,YAAe,EAAW,MAAM,EAAM,cAAc,CAAC,CAAC,CAC3E,EAAI,iBAAiB,cACnB,EAAW,MAAM,EAAM,eAAe,CAAC,CACxC,CACD,EAAI,KAAK,MAAO,EAAI,CACpB,IAAK,GAAM,CA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AAO,CAAC,CAC/D,CAOL,MAAO,CAAE,KAAM,CAAE,IAFf,IAAqB,EAAK,KAAM,EAAK,GACpC,OAAO,EAAK,KAAK,KAAQ,SAAW,EAAK,KAAK,IAAM,EAAI,MAAM,IAAI,CAAC,IACrC,CAAE,EAGrC,OACE,EAAC,EAAD,CACE,GAAI,EACJ,MAAO,GAAO,MACd,SAAU,GAAO,SACjB,KAAM,GAAO,KACb,OAAQ,EACE,oBAET,GAAY,EACJ,CAAA"}
@@ -1,12 +0,0 @@
1
- import { DropzoneFilesProps } from "../../controls/dropzone-files/DropzoneFiles.mjs";
2
- //#region src/components/forms/controls/FormDropzoneFiles.d.ts
3
- type FormDropzoneFilesProps = Omit<DropzoneFilesProps, 'url' | 'autoSend' | 'onChange'> & {
4
- name: string;
5
- $rule?: string;
6
- isSubmitting?: boolean;
7
- url?: string;
8
- onChange?: (files: File[]) => void;
9
- };
10
- //#endregion
11
- export { FormDropzoneFilesProps };
12
- //# sourceMappingURL=FormDropzoneFiles.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormDropzoneFiles.d.mts","names":[],"sources":["../../../../src/components/forms/controls/FormDropzoneFiles.tsx"],"mappings":";;KAOY,sBAAA,GAAyB,IAAA,CACnC,kBAAA;EAGA,IAAA;EACA,KAAA;EACA,YAAA;EACA,GAAA;EACA,QAAA,IAAY,KAAA,EAAO,IAAA;AAAA"}
@@ -1,2 +0,0 @@
1
- import{DropzoneFiles as e}from"../../controls/dropzone-files/DropzoneFiles.mjs";import{jsx as t}from"react/jsx-runtime";import{Controller as n}from"react-hook-form";const r=({$rule:r,isSubmitting:i,name:a,onChange:o,...s})=>t(n,{name:a,render:({field:{onChange:n}})=>t(e,{...s,autoSend:!1,onChange:e=>{n(e),o?.(e)}})});r.displayName=`Form.DropzoneFiles`;export{r as FormDropzoneFiles};
2
- //# sourceMappingURL=FormDropzoneFiles.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormDropzoneFiles.mjs","names":[],"sources":["../../../../src/components/forms/controls/FormDropzoneFiles.tsx"],"sourcesContent":["import { Controller } from 'react-hook-form';\n\nimport {\n DropzoneFiles,\n type DropzoneFilesProps,\n} from '@/components/controls/dropzone-files/DropzoneFiles';\n\nexport type FormDropzoneFilesProps = Omit<\n DropzoneFilesProps,\n 'url' | 'autoSend' | 'onChange'\n> & {\n name: string;\n $rule?: string;\n isSubmitting?: boolean;\n url?: string;\n onChange?: (files: File[]) => void;\n};\n\nexport const FormDropzoneFiles = ({\n $rule: _$rule,\n isSubmitting: _isSubmitting,\n name,\n onChange,\n ...props\n}: FormDropzoneFilesProps) => {\n return (\n <Controller\n name={name}\n render={({ field: { onChange: fieldOnChange } }) => (\n <DropzoneFiles\n {...props}\n autoSend={false}\n onChange={(files) => {\n fieldOnChange(files);\n onChange?.(files);\n }}\n />\n )}\n />\n );\n};\n\nFormDropzoneFiles.displayName = 'Form.DropzoneFiles';\n"],"mappings":"qKAkBA,MAAa,GAAqB,CAChC,MAAO,EACP,aAAc,EACd,OACA,WACA,GAAG,KAGD,EAAC,EAAD,CACQ,OACN,QAAS,CAAE,MAAO,CAAE,SAAU,MAC5B,EAAC,EAAD,CACE,GAAI,EACJ,SAAU,GACV,SAAW,GAAU,CACnB,EAAc,EAAM,CACpB,IAAW,EAAM,EAEnB,CAAA,CAEJ,CAAA,CAIN,EAAkB,YAAc"}