@mage-ui/components 1.0.116 → 1.0.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/controls/dropzone/Dropzone.d.mts +9 -3
- package/dist/components/controls/dropzone/Dropzone.d.mts.map +1 -1
- package/dist/components/controls/dropzone/Dropzone.mjs +1 -1
- package/dist/components/controls/dropzone/Dropzone.mjs.map +1 -1
- package/dist/components/controls/dropzone/use-dropzone-state.mjs +1 -1
- package/dist/components/controls/dropzone/use-dropzone-state.mjs.map +1 -1
- package/dist/components/controls/dropzone-files/DropzoneFiles.d.mts +9 -3
- package/dist/components/controls/dropzone-files/DropzoneFiles.d.mts.map +1 -1
- package/dist/components/controls/dropzone-files/DropzoneFiles.mjs +1 -1
- package/dist/components/controls/dropzone-files/DropzoneFiles.mjs.map +1 -1
- package/dist/components/controls/file-input/BaseFileInput.d.mts +9 -4
- package/dist/components/controls/file-input/BaseFileInput.d.mts.map +1 -1
- package/dist/components/controls/file-input/BaseFileInput.mjs.map +1 -1
- package/dist/components/controls/file-input/FileInputMultiple.d.mts.map +1 -1
- package/dist/components/controls/file-input/FileInputMultiple.mjs +1 -1
- package/dist/components/controls/file-input/FileInputMultiple.mjs.map +1 -1
- package/dist/components/data-display/index.d.mts +2 -1
- package/dist/components/data-display/uploading-files/UploadingFiles.d.mts +49 -0
- package/dist/components/data-display/uploading-files/UploadingFiles.d.mts.map +1 -0
- package/dist/components/data-display/uploading-files/UploadingFiles.mjs +2 -0
- package/dist/components/data-display/uploading-files/UploadingFiles.mjs.map +1 -0
- package/dist/components/forms/Form.d.mts +46 -0
- package/dist/components/forms/Form.d.mts.map +1 -1
- package/dist/components/forms/Form.mjs +1 -1
- package/dist/components/forms/Form.mjs.map +1 -1
- package/dist/components/forms/controls/FormDropzone.d.mts +12 -0
- package/dist/components/forms/controls/FormDropzone.d.mts.map +1 -0
- package/dist/components/forms/controls/FormDropzone.mjs +2 -0
- package/dist/components/forms/controls/FormDropzone.mjs.map +1 -0
- package/dist/components/forms/controls/FormDropzoneFiles.d.mts +12 -0
- package/dist/components/forms/controls/FormDropzoneFiles.d.mts.map +1 -0
- package/dist/components/forms/controls/FormDropzoneFiles.mjs +2 -0
- package/dist/components/forms/controls/FormDropzoneFiles.mjs.map +1 -0
- package/dist/components/forms/controls/FormFileInput.d.mts +12 -0
- package/dist/components/forms/controls/FormFileInput.d.mts.map +1 -0
- package/dist/components/forms/controls/FormFileInput.mjs +2 -0
- package/dist/components/forms/controls/FormFileInput.mjs.map +1 -0
- package/dist/components/forms/controls/FormFileInputMultiple.d.mts +12 -0
- package/dist/components/forms/controls/FormFileInputMultiple.d.mts.map +1 -0
- package/dist/components/forms/controls/FormFileInputMultiple.mjs +2 -0
- package/dist/components/forms/controls/FormFileInputMultiple.mjs.map +1 -0
- package/dist/components/forms/controls/index.mjs +1 -1
- package/dist/components/forms/controls/index.mjs.map +1 -1
- package/dist/components/forms/controls/register-components.mjs +1 -1
- package/dist/components/forms/controls/register-components.mjs.map +1 -1
- package/dist/components/forms/rules/extract-form-rules.mjs +1 -1
- package/dist/components/forms/rules/extract-form-rules.mjs.map +1 -1
- package/dist/components/index.d.mts +1 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
|
@@ -26,10 +26,13 @@ type DropzoneProps = {
|
|
|
26
26
|
removeFile: (fileName: string) => void;
|
|
27
27
|
}) => ReactNode;
|
|
28
28
|
initialFiles?: Record<string, FileData>;
|
|
29
|
-
maxFiles?: number;
|
|
29
|
+
maxFiles?: number; /** Required when autoSend=true (default). Optional when autoSend=false. */
|
|
30
|
+
url?: string; /** When false, files are added to state but not uploaded automatically. Default: true. */
|
|
31
|
+
autoSend?: boolean; /** Maximum file size in bytes. Files exceeding this will be rejected. */
|
|
32
|
+
maxSize?: number; /** Called when the file list changes (added or removed). Useful when autoSend=false. */
|
|
33
|
+
onChange?: (files: File[]) => void;
|
|
30
34
|
data?: Record<string, unknown>;
|
|
31
35
|
headers?: Record<string, string>;
|
|
32
|
-
url: string;
|
|
33
36
|
accept?: string[];
|
|
34
37
|
preventDropOnDocument?: boolean;
|
|
35
38
|
title?: ReactNode;
|
|
@@ -59,8 +62,11 @@ declare const Dropzone: ({
|
|
|
59
62
|
children,
|
|
60
63
|
initialFiles,
|
|
61
64
|
maxFiles,
|
|
62
|
-
accept,
|
|
63
65
|
url,
|
|
66
|
+
autoSend,
|
|
67
|
+
maxSize,
|
|
68
|
+
onChange,
|
|
69
|
+
accept,
|
|
64
70
|
title,
|
|
65
71
|
subtitle,
|
|
66
72
|
hint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropzone.d.mts","names":[],"sources":["../../../../src/components/controls/dropzone/Dropzone.tsx"],"mappings":";;;;;;KA2BY,QAAA;EACV,IAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACA,QAAA;EACA,OAAA;EACA,GAAA;EACA,KAAA;EACA,QAAA;AAAA;AAAA,KAGU,aAAA;EACV,QAAA;IACE,KAAA;IACA,WAAA;IACA;EAAA;IAEA,KAAA,EAAO,MAAA,SAAe,QAAA;IACtB,WAAA;IACA,UAAA,GAAa,QAAA;EAAA,MACT,SAAA;EACN,YAAA,GAAe,MAAA,SAAe,QAAA;EAC9B,QAAA;
|
|
1
|
+
{"version":3,"file":"Dropzone.d.mts","names":[],"sources":["../../../../src/components/controls/dropzone/Dropzone.tsx"],"mappings":";;;;;;KA2BY,QAAA;EACV,IAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACA,QAAA;EACA,OAAA;EACA,GAAA;EACA,KAAA;EACA,QAAA;AAAA;AAAA,KAGU,aAAA;EACV,QAAA;IACE,KAAA;IACA,WAAA;IACA;EAAA;IAEA,KAAA,EAAO,MAAA,SAAe,QAAA;IACtB,WAAA;IACA,UAAA,GAAa,QAAA;EAAA,MACT,SAAA;EACN,YAAA,GAAe,MAAA,SAAe,QAAA;EAC9B,QAAA,WAdQ;EAgBR,GAAA,WAbuB;EAevB,QAAA,YAbE;EAeF,OAAA,WAbE;EAeF,QAAA,IAAY,KAAA,EAAO,IAAA;EACnB,IAAA,GAAO,MAAA;EACP,OAAA,GAAU,MAAA;EACV,MAAA;EACA,qBAAA;EACA,KAAA,GAAQ,SAAA;EACR,QAAA,GAAW,SAAA;EACX,IAAA,GAAO,SAAA;EACP,OAAA;EACA,cAAA,IAAkB,IAAA,EAAM,QAAA;EACxB,UAAA;IACE,QAAA;IACA,IAAA;IACA,gBAAA;MACE,IAAA;MACA,KAAA;IAAA;IAEF,QAAA;IACA,YAAA,GAAe,SAAA;IACf,MAAA,GAAS,eAAA;IACT,QAAA;IACA,KAAA;IACA,QAAA;IACA,IAAA;EAAA;AAAA;AAAA,cAIS,QAAA;EAAY,IAAA;EAAA,OAAA;EAAA,QAAA;EAAA,YAAA;EAAA,QAAA;EAAA,GAAA;EAAA,QAAA;EAAA,OAAA;EAAA,QAAA;EAAA,MAAA;EAAA,KAAA;EAAA,QAAA;EAAA,IAAA;EAAA,OAAA;EAAA,cAAA;EAAA;AAAA,GAiBtB,aAAA,KAAa,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Icon as e}from"../../data-display/icons/icon/Icon.mjs";import{LoaderOval as t}from"../../data-display/loader-oval/LoaderOval.mjs";import{useDropzoneState as n}from"./use-dropzone-state.mjs";import{cx as r}from"@mage-ui/styled-system/css";import{dropzone as i,dropzoneDropzoneInner as a,dropzoneDropzoneRoot as o,dropzoneHint as s,dropzoneIcon as c,dropzoneIconSlot as l,dropzoneLoader as u,dropzoneLoaderRoot as d,dropzoneRoot as f,dropzoneSubtitle as p,dropzoneTextSlot as m,dropzoneTitle as h}from"@mage-ui/styled-system/recipes";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import{useCallback as y,useRef as b}from"react";import{Dropzone as x}from"@mantine/dropzone";const S=({data:S,headers:C,children:w,initialFiles:T={},maxFiles:E,
|
|
1
|
+
import{Icon as e}from"../../data-display/icons/icon/Icon.mjs";import{LoaderOval as t}from"../../data-display/loader-oval/LoaderOval.mjs";import{useDropzoneState as n}from"./use-dropzone-state.mjs";import{cx as r}from"@mage-ui/styled-system/css";import{dropzone as i,dropzoneDropzoneInner as a,dropzoneDropzoneRoot as o,dropzoneHint as s,dropzoneIcon as c,dropzoneIconSlot as l,dropzoneLoader as u,dropzoneLoaderRoot as d,dropzoneRoot as f,dropzoneSubtitle as p,dropzoneTextSlot as m,dropzoneTitle as h}from"@mage-ui/styled-system/recipes";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import{useCallback as y,useRef as b}from"react";import{Dropzone as x}from"@mantine/dropzone";const S=({data:S,headers:C,children:w,initialFiles:T={},maxFiles:E,url:D,autoSend:O=!0,maxSize:k,onChange:A,accept:j,title:M,subtitle:N,hint:P,inputId:F,onFileUploaded:I,classNames:L})=>{let R=b(null),z=b(new Map),{files:B,isUploading:V,uploadMultipleFiles:H,addFile:U,removeFile:W}=n(D,T,I,C),G=y(e=>{W(e),z.current.delete(e),!O&&A&&A(Array.from(z.current.values()))},[W,O,A]),K=y(async e=>{let t=Object.keys(B).length,n=(E??1/0)-t;if(n<=0)return;let r=e.slice(0,n);if(O)await H(r,S);else{for(let e of r)U(e),z.current.set(e.name,e);A?.(Array.from(z.current.values()))}},[O,H,U,S,B,E,A]);return v(`div`,{className:r(L?.dropzone??i(),L?.root??f()),children:[v(x,{ref:R,onDrop:K,disabled:Object.keys(B).length>=(E??1/0),loading:V,accept:j,maxSize:k,preventDropOnDocument:!0,inputProps:{id:F},classNames:{root:L?.dropzoneDropzone?.root??r(o(),`group`),inner:L?.dropzoneDropzone?.inner??a()},children:[_(`div`,{className:L?.iconSlot??l(),children:V?_(t,{classNames:{loader:L?.loader?.loader??u(),root:L?.loader?.root??d()}}):v(g,{children:[_(x.Idle,{children:_(e,{name:`mage-dropzone-upload-01`,path:`/icons/sprite-mage.svg`,classNames:{icon:L?.dropzoneIcon?.icon??c()}})}),_(x.Accept,{children:_(e,{name:`mage-dropzone-thumbs-up`,path:`/icons/sprite-mage.svg`,classNames:{icon:L?.dropzoneIcon?.icon??c()}})}),_(x.Reject,{children:_(e,{name:`mage-dropzone-thumbs-down`,path:`/icons/sprite-mage.svg`,classNames:{icon:L?.dropzoneIcon?.icon??c()}})})]})}),v(`div`,{className:L?.textSlot??m(),children:[_(`span`,{className:L?.title??h(),children:M||`Upload files`}),_(`span`,{className:L?.subtitle??p(),children:N||`Drag images here or click to select files`}),_(`span`,{className:L?.hint??s(),children:P||`Attach as many files as you like, each file should not exceed 5mb`})]})]}),w({files:B,isUploading:V,removeFile:G})]})};export{S as Dropzone};
|
|
2
2
|
//# sourceMappingURL=Dropzone.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropzone.mjs","names":["Dropzone","MantineDropzone"],"sources":["../../../../src/components/controls/dropzone/Dropzone.tsx"],"sourcesContent":["import { type ReactNode, useCallback, useRef } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n dropzone,\n dropzoneDropzoneInner,\n dropzoneDropzoneRoot,\n dropzoneHint,\n dropzoneIcon,\n dropzoneIconSlot,\n dropzoneLoader,\n dropzoneLoaderRoot,\n dropzoneRoot,\n dropzoneSubtitle,\n dropzoneTextSlot,\n dropzoneTitle,\n} from '@mage-ui/styled-system/recipes';\nimport { Dropzone as MantineDropzone } from '@mantine/dropzone';\nimport {\n Icon,\n type IconProps,\n LoaderOval,\n type LoaderOvalProps,\n} from '@/components/data-display';\n\nimport { useDropzoneState } from './use-dropzone-state';\n\nexport type FileData = {\n name: string;\n size: number;\n type: string;\n date: string;\n uploaded: boolean;\n loading: boolean;\n url: string;\n error?: string;\n progress?: number; // (0-100)\n};\n\nexport type DropzoneProps = {\n children: ({\n files,\n isUploading,\n removeFile,\n }: {\n files: Record<string, FileData>;\n isUploading: boolean;\n removeFile: (fileName: string) => void;\n }) => ReactNode;\n initialFiles?: Record<string, FileData>;\n maxFiles?: number;\n data?: Record<string, unknown>;\n headers?: Record<string, string>;\n
|
|
1
|
+
{"version":3,"file":"Dropzone.mjs","names":["Dropzone","MantineDropzone"],"sources":["../../../../src/components/controls/dropzone/Dropzone.tsx"],"sourcesContent":["import { type ReactNode, useCallback, useRef } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n dropzone,\n dropzoneDropzoneInner,\n dropzoneDropzoneRoot,\n dropzoneHint,\n dropzoneIcon,\n dropzoneIconSlot,\n dropzoneLoader,\n dropzoneLoaderRoot,\n dropzoneRoot,\n dropzoneSubtitle,\n dropzoneTextSlot,\n dropzoneTitle,\n} from '@mage-ui/styled-system/recipes';\nimport { Dropzone as MantineDropzone } from '@mantine/dropzone';\nimport {\n Icon,\n type IconProps,\n LoaderOval,\n type LoaderOvalProps,\n} from '@/components/data-display';\n\nimport { useDropzoneState } from './use-dropzone-state';\n\nexport type FileData = {\n name: string;\n size: number;\n type: string;\n date: string;\n uploaded: boolean;\n loading: boolean;\n url: string;\n error?: string;\n progress?: number; // (0-100)\n};\n\nexport type DropzoneProps = {\n children: ({\n files,\n isUploading,\n removeFile,\n }: {\n files: Record<string, FileData>;\n isUploading: boolean;\n removeFile: (fileName: string) => void;\n }) => ReactNode;\n initialFiles?: Record<string, FileData>;\n maxFiles?: number;\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 /** Maximum file size in bytes. Files exceeding this will be rejected. */\n maxSize?: number;\n /** Called when the file list changes (added or removed). Useful when autoSend=false. */\n onChange?: (files: File[]) => void;\n data?: Record<string, unknown>;\n headers?: Record<string, string>;\n accept?: string[];\n preventDropOnDocument?: boolean;\n title?: ReactNode;\n subtitle?: ReactNode;\n hint?: ReactNode;\n inputId?: string;\n onFileUploaded?: (file: FileData) => void;\n classNames?: {\n dropzone?: string;\n root?: string;\n dropzoneDropzone?: {\n root?: string;\n inner?: string;\n };\n iconSlot?: string;\n dropzoneIcon?: IconProps['classNames'];\n loader?: LoaderOvalProps['classNames'];\n textSlot?: string;\n title?: string;\n subtitle?: string;\n hint?: string;\n };\n};\n\nexport const Dropzone = ({\n data,\n headers,\n children,\n initialFiles = {},\n maxFiles,\n url,\n autoSend = true,\n maxSize,\n onChange,\n accept,\n title,\n subtitle,\n hint,\n inputId,\n onFileUploaded,\n classNames,\n}: DropzoneProps) => {\n const dropzoneRef = useRef<HTMLDivElement>(null);\n const rawFilesRef = useRef<Map<string, File>>(new Map());\n const {\n files,\n isUploading,\n uploadMultipleFiles,\n addFile,\n removeFile: hookRemoveFile,\n } = useDropzoneState(url, initialFiles, onFileUploaded, headers);\n\n const removeFile = useCallback(\n (fileName: string) => {\n hookRemoveFile(fileName);\n rawFilesRef.current.delete(fileName);\n if (!autoSend && onChange) {\n onChange(Array.from(rawFilesRef.current.values()));\n }\n },\n [hookRemoveFile, autoSend, onChange],\n );\n\n const handleDrop = useCallback(\n async (acceptedFiles: File[]) => {\n const currentCount = Object.keys(files).length;\n const max = maxFiles ?? Number.POSITIVE_INFINITY;\n const remainingSlots = max - currentCount;\n if (remainingSlots <= 0) {\n return;\n }\n const filesToProcess = acceptedFiles.slice(0, remainingSlots);\n if (autoSend) {\n await uploadMultipleFiles(filesToProcess, data);\n } else {\n for (const file of filesToProcess) {\n addFile(file);\n rawFilesRef.current.set(file.name, file);\n }\n onChange?.(Array.from(rawFilesRef.current.values()));\n }\n },\n [autoSend, uploadMultipleFiles, addFile, data, files, maxFiles, onChange],\n );\n\n return (\n <div\n className={cx(\n classNames?.dropzone ?? dropzone(),\n classNames?.root ?? dropzoneRoot(),\n )}\n >\n <MantineDropzone\n ref={dropzoneRef}\n onDrop={handleDrop}\n disabled={\n Object.keys(files).length >= (maxFiles ?? Number.POSITIVE_INFINITY)\n }\n loading={isUploading}\n accept={accept}\n maxSize={maxSize}\n preventDropOnDocument\n inputProps={{ id: inputId }}\n classNames={{\n root:\n classNames?.dropzoneDropzone?.root ??\n cx(dropzoneDropzoneRoot(), 'group'),\n inner: classNames?.dropzoneDropzone?.inner ?? dropzoneDropzoneInner(),\n }}\n >\n <div className={classNames?.iconSlot ?? dropzoneIconSlot()}>\n {isUploading ? (\n <LoaderOval\n classNames={{\n loader: classNames?.loader?.loader ?? dropzoneLoader(),\n root: classNames?.loader?.root ?? dropzoneLoaderRoot(),\n }}\n />\n ) : (\n <>\n <MantineDropzone.Idle>\n <Icon\n name='mage-dropzone-upload-01'\n path='/icons/sprite-mage.svg'\n classNames={{\n icon: classNames?.dropzoneIcon?.icon ?? dropzoneIcon(),\n }}\n />\n </MantineDropzone.Idle>\n <MantineDropzone.Accept>\n <Icon\n name='mage-dropzone-thumbs-up'\n path='/icons/sprite-mage.svg'\n classNames={{\n icon: classNames?.dropzoneIcon?.icon ?? dropzoneIcon(),\n }}\n />\n </MantineDropzone.Accept>\n <MantineDropzone.Reject>\n <Icon\n name='mage-dropzone-thumbs-down'\n path='/icons/sprite-mage.svg'\n classNames={{\n icon: classNames?.dropzoneIcon?.icon ?? dropzoneIcon(),\n }}\n />\n </MantineDropzone.Reject>\n </>\n )}\n </div>\n <div className={classNames?.textSlot ?? dropzoneTextSlot()}>\n <span className={classNames?.title ?? dropzoneTitle()}>\n {title || 'Upload files'}\n </span>\n <span className={classNames?.subtitle ?? dropzoneSubtitle()}>\n {subtitle || 'Drag images here or click to select files'}\n </span>\n <span className={classNames?.hint ?? dropzoneHint()}>\n {hint ||\n 'Attach as many files as you like, each file should not exceed 5mb'}\n </span>\n </div>\n </MantineDropzone>\n {children({ files, isUploading, removeFile })}\n </div>\n );\n};\n"],"mappings":"wrBAqFA,MAAaA,GAAY,CACvB,OACA,UACA,WACA,eAAe,EAAE,CACjB,WACA,MACA,WAAW,GACX,UACA,WACA,SACA,QACA,WACA,OACA,UACA,iBACA,gBACmB,CACnB,IAAM,EAAc,EAAuB,KAAK,CAC1C,EAAc,EAA0B,IAAI,IAAM,CAClD,CACJ,QACA,cACA,sBACA,UACA,WAAY,GACV,EAAiB,EAAK,EAAc,EAAgB,EAAQ,CAE1D,EAAa,EAChB,GAAqB,CACpB,EAAe,EAAS,CACxB,EAAY,QAAQ,OAAO,EAAS,CAChC,CAAC,GAAY,GACf,EAAS,MAAM,KAAK,EAAY,QAAQ,QAAQ,CAAC,CAAC,EAGtD,CAAC,EAAgB,EAAU,EAAS,CACrC,CAEK,EAAa,EACjB,KAAO,IAA0B,CAC/B,IAAM,EAAe,OAAO,KAAK,EAAM,CAAC,OAElC,GADM,GAAY,KACK,EAC7B,GAAI,GAAkB,EACpB,OAEF,IAAM,EAAiB,EAAc,MAAM,EAAG,EAAe,CAC7D,GAAI,EACF,MAAM,EAAoB,EAAgB,EAAK,KAC1C,CACL,IAAK,IAAM,KAAQ,EACjB,EAAQ,EAAK,CACb,EAAY,QAAQ,IAAI,EAAK,KAAM,EAAK,CAE1C,IAAW,MAAM,KAAK,EAAY,QAAQ,QAAQ,CAAC,CAAC,GAGxD,CAAC,EAAU,EAAqB,EAAS,EAAM,EAAO,EAAU,EAAS,CAC1E,CAED,OACE,EAAC,MAAD,CACE,UAAW,EACT,GAAY,UAAY,GAAU,CAClC,GAAY,MAAQ,GAAc,CACnC,UAJH,CAME,EAACC,EAAD,CACE,IAAK,EACL,OAAQ,EACR,SACE,OAAO,KAAK,EAAM,CAAC,SAAW,GAAY,KAE5C,QAAS,EACD,SACC,UACT,sBAAA,GACA,WAAY,CAAE,GAAI,EAAS,CAC3B,WAAY,CACV,KACE,GAAY,kBAAkB,MAC9B,EAAG,GAAsB,CAAE,QAAQ,CACrC,MAAO,GAAY,kBAAkB,OAAS,GAAuB,CACtE,UAhBH,CAkBE,EAAC,MAAD,CAAK,UAAW,GAAY,UAAY,GAAkB,UACvD,EACC,EAAC,EAAD,CACE,WAAY,CACV,OAAQ,GAAY,QAAQ,QAAU,GAAgB,CACtD,KAAM,GAAY,QAAQ,MAAQ,GAAoB,CACvD,CACD,CAAA,CAEF,EAAA,EAAA,CAAA,SAAA,CACE,EAACA,EAAgB,KAAjB,CAAA,SACE,EAAC,EAAD,CACE,KAAK,0BACL,KAAK,yBACL,WAAY,CACV,KAAM,GAAY,cAAc,MAAQ,GAAc,CACvD,CACD,CAAA,CACmB,CAAA,CACvB,EAACA,EAAgB,OAAjB,CAAA,SACE,EAAC,EAAD,CACE,KAAK,0BACL,KAAK,yBACL,WAAY,CACV,KAAM,GAAY,cAAc,MAAQ,GAAc,CACvD,CACD,CAAA,CACqB,CAAA,CACzB,EAACA,EAAgB,OAAjB,CAAA,SACE,EAAC,EAAD,CACE,KAAK,4BACL,KAAK,yBACL,WAAY,CACV,KAAM,GAAY,cAAc,MAAQ,GAAc,CACvD,CACD,CAAA,CACqB,CAAA,CACxB,CAAA,CAAA,CAED,CAAA,CACN,EAAC,MAAD,CAAK,UAAW,GAAY,UAAY,GAAkB,UAA1D,CACE,EAAC,OAAD,CAAM,UAAW,GAAY,OAAS,GAAe,UAClD,GAAS,eACL,CAAA,CACP,EAAC,OAAD,CAAM,UAAW,GAAY,UAAY,GAAkB,UACxD,GAAY,4CACR,CAAA,CACP,EAAC,OAAD,CAAM,UAAW,GAAY,MAAQ,GAAc,UAChD,GACC,oEACG,CAAA,CACH,GACU,GACjB,EAAS,CAAE,QAAO,cAAa,aAAY,CAAC,CACzC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{uploadFile as e}from"./upload-service.mjs";import{useCallback as t,useRef as n,useState as r}from"react";const i=(i,a={},o,s)=>{let[c,l]=r((()=>{if(!a)return{};if(typeof a==`object`&&!(`name`in a))return a;if(typeof a==`object`&&`name`in a){let e=a;return{[e.name]:{name:e.name,size:e.size,type:e.type,date:e.date,uploaded:e.uploaded??!0,loading:e.loading??!1,url:e.url,error:e.error,progress:e.progress}}}return{}})()),[u,d]=r(!1),f=n(new Set),p=t((e,t)=>{let n={name:e.name,size:e.size,type:e.type,url:``,uploaded:!1,loading:!1,progress:0,date:t??new Date().toLocaleString(`es-ES`,{timeZone:`Europe/Madrid`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})};return l(t=>({...t,[e.name]:n})),e.name},[]),m=t((e,t)=>{l(n=>({...n,[e]:{...n[e],progress:t,loading:t<100}}))},[]),h=t((e,t)=>{l(n=>({...n,[e]:{...n[e],uploaded:!0,loading:!1,progress:100,url:t}}))},[]),g=t((e,t)=>{l(n=>({...n,[e]:{...n[e],uploaded:!1,loading:!1,progress:0,error:t}}))},[]),_=t(e=>{l(t=>{let n={...t};return delete n[e],n}),f.current.delete(e)},[]),v=t(()=>{l({}),f.current.clear()},[]),y=t(e=>f.current.has(e),[]),b=t(e=>{f.current.add(e)},[]),x=t(e=>{f.current.delete(e)},[]),S=t(async(t,n)=>{let r=new Date().toLocaleString(`es-ES`,{timeZone:`Europe/Madrid`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),a=p(t,r);b(a);try{let{body:c}=await e(i
|
|
1
|
+
import{uploadFile as e}from"./upload-service.mjs";import{useCallback as t,useRef as n,useState as r}from"react";const i=(i,a={},o,s)=>{let[c,l]=r((()=>{if(!a)return{};if(typeof a==`object`&&!(`name`in a))return a;if(typeof a==`object`&&`name`in a){let e=a;return{[e.name]:{name:e.name,size:e.size,type:e.type,date:e.date,uploaded:e.uploaded??!0,loading:e.loading??!1,url:e.url,error:e.error,progress:e.progress}}}return{}})()),[u,d]=r(!1),f=n(new Set),p=t((e,t)=>{let n={name:e.name,size:e.size,type:e.type,url:``,uploaded:!1,loading:!1,progress:0,date:t??new Date().toLocaleString(`es-ES`,{timeZone:`Europe/Madrid`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})};return l(t=>({...t,[e.name]:n})),e.name},[]),m=t((e,t)=>{l(n=>({...n,[e]:{...n[e],progress:t,loading:t<100}}))},[]),h=t((e,t)=>{l(n=>({...n,[e]:{...n[e],uploaded:!0,loading:!1,progress:100,url:t}}))},[]),g=t((e,t)=>{l(n=>({...n,[e]:{...n[e],uploaded:!1,loading:!1,progress:0,error:t}}))},[]),_=t(e=>{l(t=>{let n={...t};return delete n[e],n}),f.current.delete(e)},[]),v=t(()=>{l({}),f.current.clear()},[]),y=t(e=>f.current.has(e),[]),b=t(e=>{f.current.add(e)},[]),x=t(e=>{f.current.delete(e)},[]),S=t(async(t,n)=>{let r=new Date().toLocaleString(`es-ES`,{timeZone:`Europe/Madrid`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),a=p(t,r);b(a);try{let{body:c}=await e(i??``,t,n,e=>{m(a,e.percentage)},s);h(a,c.url),o?.({name:t.name,size:t.size,type:t.type,date:r,uploaded:!0,loading:!1,progress:100,url:c.url})}catch(e){console.error(`Error al subir archivo:`,e),g(a,e instanceof Error?e.message:`Error desconocido`)}finally{x(a)}},[p,b,m,h,g,x,o,i,s]);return{files:c,isUploading:u,setIsUploading:d,addFile:p,updateFileProgress:m,markFileAsUploaded:h,markFileAsError:g,removeFile:_,clearFiles:v,isFileUploading:y,addToUploadQueue:b,removeFromUploadQueue:x,uploadFileToServer:S,uploadMultipleFiles:t(async(e,t)=>{if(u){console.warn(`Ya hay una subida en progreso`);return}d(!0);try{for(let n of e)await S(n,t)}finally{d(!1)}},[u,d,S])}};export{i as useDropzoneState};
|
|
2
2
|
//# sourceMappingURL=use-dropzone-state.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dropzone-state.mjs","names":[],"sources":["../../../../src/components/controls/dropzone/use-dropzone-state.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nimport type { FileData } from './Dropzone';\nimport { uploadFile } from './upload-service';\n\nexport const useDropzoneState = (\n url: string,\n initialFiles: Record<string, FileData> | FileData | null | undefined = {},\n onFileUploaded?: (file: FileData) => void,\n headers?: Record<string, string>,\n) => {\n const normalizeInitialFiles = (): Record<string, FileData> => {\n if (!initialFiles) return {};\n\n if (typeof initialFiles === 'object' && !('name' in initialFiles)) {\n return initialFiles as Record<string, FileData>;\n }\n\n if (typeof initialFiles === 'object' && 'name' in initialFiles) {\n const fileData = initialFiles as FileData;\n return {\n [fileData.name]: {\n name: fileData.name,\n size: fileData.size,\n type: fileData.type,\n date: fileData.date,\n uploaded: fileData.uploaded ?? true,\n loading: fileData.loading ?? false,\n url: fileData.url,\n error: fileData.error,\n progress: fileData.progress,\n },\n };\n }\n\n return {};\n };\n\n const [files, setFiles] = useState<Record<string, FileData>>(\n normalizeInitialFiles(),\n );\n const [isUploading, setIsUploading] = useState(false);\n const uploadQueue = useRef<Set<string>>(new Set());\n\n const addFile = useCallback((file: File, date?: string) => {\n const fileData: FileData = {\n name: file.name,\n size: file.size,\n type: file.type,\n url: '',\n uploaded: false,\n loading: false,\n progress: 0,\n date:\n date ??\n new Date().toLocaleString('es-ES', {\n timeZone: 'Europe/Madrid',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n }),\n };\n\n setFiles((prev) => ({\n ...prev,\n [file.name]: fileData,\n }));\n\n return file.name;\n }, []);\n\n const updateFileProgress = useCallback(\n (fileName: string, progress: number) => {\n setFiles((prev) => ({\n ...prev,\n [fileName]: {\n ...prev[fileName],\n progress,\n loading: progress < 100,\n },\n }));\n },\n [],\n );\n\n const markFileAsUploaded = useCallback((fileName: string, url: string) => {\n setFiles((prev) => ({\n ...prev,\n [fileName]: {\n ...prev[fileName],\n uploaded: true,\n loading: false,\n progress: 100,\n url,\n },\n }));\n }, []);\n\n const markFileAsError = useCallback((fileName: string, error: string) => {\n setFiles((prev) => ({\n ...prev,\n [fileName]: {\n ...prev[fileName],\n uploaded: false,\n loading: false,\n progress: 0,\n error,\n },\n }));\n }, []);\n\n const removeFile = useCallback((fileName: string) => {\n setFiles((prev) => {\n const newFiles = { ...prev };\n delete newFiles[fileName];\n return newFiles;\n });\n uploadQueue.current.delete(fileName);\n }, []);\n\n const clearFiles = useCallback(() => {\n setFiles({});\n uploadQueue.current.clear();\n }, []);\n\n const isFileUploading = useCallback((fileName: string) => {\n return uploadQueue.current.has(fileName);\n }, []);\n\n const addToUploadQueue = useCallback((fileName: string) => {\n uploadQueue.current.add(fileName);\n }, []);\n\n const removeFromUploadQueue = useCallback((fileName: string) => {\n uploadQueue.current.delete(fileName);\n }, []);\n\n const uploadFileToServer = useCallback(\n async (file: File, data?: Record<string, unknown>) => {\n const date = new Date().toLocaleString('es-ES', {\n timeZone: 'Europe/Madrid',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n });\n const fileName = addFile(file, date);\n addToUploadQueue(fileName);\n\n try {\n const { body } = await uploadFile(\n url,\n file,\n data,\n (progress) => {\n updateFileProgress(fileName, progress.percentage);\n },\n headers,\n );\n\n markFileAsUploaded(fileName, body.url);\n onFileUploaded?.({\n name: file.name,\n size: file.size,\n type: file.type,\n date,\n uploaded: true,\n loading: false,\n progress: 100,\n url: body.url,\n });\n } catch (error) {\n console.error('Error al subir archivo:', error);\n markFileAsError(\n fileName,\n error instanceof Error ? error.message : 'Error desconocido',\n );\n } finally {\n removeFromUploadQueue(fileName);\n }\n },\n [\n addFile,\n addToUploadQueue,\n updateFileProgress,\n markFileAsUploaded,\n markFileAsError,\n removeFromUploadQueue,\n onFileUploaded,\n url,\n headers,\n ],\n );\n\n const uploadMultipleFiles = useCallback(\n async (acceptedFiles: File[], data?: Record<string, unknown>) => {\n if (isUploading) {\n console.warn('Ya hay una subida en progreso');\n return;\n }\n\n setIsUploading(true);\n\n try {\n for (const file of acceptedFiles) {\n await uploadFileToServer(file, data);\n }\n } finally {\n setIsUploading(false);\n }\n },\n [isUploading, setIsUploading, uploadFileToServer],\n );\n\n return {\n files,\n isUploading,\n setIsUploading,\n addFile,\n updateFileProgress,\n markFileAsUploaded,\n markFileAsError,\n removeFile,\n clearFiles,\n isFileUploading,\n addToUploadQueue,\n removeFromUploadQueue,\n uploadFileToServer,\n uploadMultipleFiles,\n };\n};\n"],"mappings":"gHAKA,MAAa,GACX,EACA,EAAuE,EAAE,CACzE,EACA,IACG,CA4BH,GAAM,CAAC,EAAO,GAAY,OA3BoC,CAC5D,GAAI,CAAC,EAAc,MAAO,EAAE,CAE5B,GAAI,OAAO,GAAiB,UAAY,EAAE,SAAU,GAClD,OAAO,EAGT,GAAI,OAAO,GAAiB,UAAY,SAAU,EAAc,CAC9D,IAAM,EAAW,EACjB,MAAO,EACJ,EAAS,MAAO,CACf,KAAM,EAAS,KACf,KAAM,EAAS,KACf,KAAM,EAAS,KACf,KAAM,EAAS,KACf,SAAU,EAAS,UAAY,GAC/B,QAAS,EAAS,SAAW,GAC7B,IAAK,EAAS,IACd,MAAO,EAAS,MAChB,SAAU,EAAS,SACpB,CACF,CAGH,MAAO,EAAE,IAIc,CACxB,CACK,CAAC,EAAa,GAAkB,EAAS,GAAM,CAC/C,EAAc,EAAoB,IAAI,IAAM,CAE5C,EAAU,GAAa,EAAY,IAAkB,CACzD,IAAM,EAAqB,CACzB,KAAM,EAAK,KACX,KAAM,EAAK,KACX,KAAM,EAAK,KACX,IAAK,GACL,SAAU,GACV,QAAS,GACT,SAAU,EACV,KACE,GACA,IAAI,MAAM,CAAC,eAAe,QAAS,CACjC,SAAU,gBACV,KAAM,UACN,MAAO,UACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACT,CAAC,CACL,CAOD,OALA,EAAU,IAAU,CAClB,GAAG,GACF,EAAK,MAAO,EACd,EAAE,CAEI,EAAK,MACX,EAAE,CAAC,CAEA,EAAqB,GACxB,EAAkB,IAAqB,CACtC,EAAU,IAAU,CAClB,GAAG,GACF,GAAW,CACV,GAAG,EAAK,GACR,WACA,QAAS,EAAW,IACrB,CACF,EAAE,EAEL,EAAE,CACH,CAEK,EAAqB,GAAa,EAAkB,IAAgB,CACxE,EAAU,IAAU,CAClB,GAAG,GACF,GAAW,CACV,GAAG,EAAK,GACR,SAAU,GACV,QAAS,GACT,SAAU,IACV,MACD,CACF,EAAE,EACF,EAAE,CAAC,CAEA,EAAkB,GAAa,EAAkB,IAAkB,CACvE,EAAU,IAAU,CAClB,GAAG,GACF,GAAW,CACV,GAAG,EAAK,GACR,SAAU,GACV,QAAS,GACT,SAAU,EACV,QACD,CACF,EAAE,EACF,EAAE,CAAC,CAEA,EAAa,EAAa,GAAqB,CACnD,EAAU,GAAS,CACjB,IAAM,EAAW,CAAE,GAAG,EAAM,CAE5B,OADA,OAAO,EAAS,GACT,GACP,CACF,EAAY,QAAQ,OAAO,EAAS,EACnC,EAAE,CAAC,CAEA,EAAa,MAAkB,CACnC,EAAS,EAAE,CAAC,CACZ,EAAY,QAAQ,OAAO,EAC1B,EAAE,CAAC,CAEA,EAAkB,EAAa,GAC5B,EAAY,QAAQ,IAAI,EAAS,CACvC,EAAE,CAAC,CAEA,EAAmB,EAAa,GAAqB,CACzD,EAAY,QAAQ,IAAI,EAAS,EAChC,EAAE,CAAC,CAEA,EAAwB,EAAa,GAAqB,CAC9D,EAAY,QAAQ,OAAO,EAAS,EACnC,EAAE,CAAC,CAEA,EAAqB,EACzB,MAAO,EAAY,IAAmC,CACpD,IAAM,EAAO,IAAI,MAAM,CAAC,eAAe,QAAS,CAC9C,SAAU,gBACV,KAAM,UACN,MAAO,UACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACT,CAAC,CACI,EAAW,EAAQ,EAAM,EAAK,CACpC,EAAiB,EAAS,CAE1B,GAAI,CACF,GAAM,CAAE,QAAS,MAAM,EACrB,
|
|
1
|
+
{"version":3,"file":"use-dropzone-state.mjs","names":[],"sources":["../../../../src/components/controls/dropzone/use-dropzone-state.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nimport type { FileData } from './Dropzone';\nimport { uploadFile } from './upload-service';\n\nexport const useDropzoneState = (\n url: string | undefined,\n initialFiles: Record<string, FileData> | FileData | null | undefined = {},\n onFileUploaded?: (file: FileData) => void,\n headers?: Record<string, string>,\n) => {\n const normalizeInitialFiles = (): Record<string, FileData> => {\n if (!initialFiles) return {};\n\n if (typeof initialFiles === 'object' && !('name' in initialFiles)) {\n return initialFiles as Record<string, FileData>;\n }\n\n if (typeof initialFiles === 'object' && 'name' in initialFiles) {\n const fileData = initialFiles as FileData;\n return {\n [fileData.name]: {\n name: fileData.name,\n size: fileData.size,\n type: fileData.type,\n date: fileData.date,\n uploaded: fileData.uploaded ?? true,\n loading: fileData.loading ?? false,\n url: fileData.url,\n error: fileData.error,\n progress: fileData.progress,\n },\n };\n }\n\n return {};\n };\n\n const [files, setFiles] = useState<Record<string, FileData>>(\n normalizeInitialFiles(),\n );\n const [isUploading, setIsUploading] = useState(false);\n const uploadQueue = useRef<Set<string>>(new Set());\n\n const addFile = useCallback((file: File, date?: string) => {\n const fileData: FileData = {\n name: file.name,\n size: file.size,\n type: file.type,\n url: '',\n uploaded: false,\n loading: false,\n progress: 0,\n date:\n date ??\n new Date().toLocaleString('es-ES', {\n timeZone: 'Europe/Madrid',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n }),\n };\n\n setFiles((prev) => ({\n ...prev,\n [file.name]: fileData,\n }));\n\n return file.name;\n }, []);\n\n const updateFileProgress = useCallback(\n (fileName: string, progress: number) => {\n setFiles((prev) => ({\n ...prev,\n [fileName]: {\n ...prev[fileName],\n progress,\n loading: progress < 100,\n },\n }));\n },\n [],\n );\n\n const markFileAsUploaded = useCallback((fileName: string, url: string) => {\n setFiles((prev) => ({\n ...prev,\n [fileName]: {\n ...prev[fileName],\n uploaded: true,\n loading: false,\n progress: 100,\n url,\n },\n }));\n }, []);\n\n const markFileAsError = useCallback((fileName: string, error: string) => {\n setFiles((prev) => ({\n ...prev,\n [fileName]: {\n ...prev[fileName],\n uploaded: false,\n loading: false,\n progress: 0,\n error,\n },\n }));\n }, []);\n\n const removeFile = useCallback((fileName: string) => {\n setFiles((prev) => {\n const newFiles = { ...prev };\n delete newFiles[fileName];\n return newFiles;\n });\n uploadQueue.current.delete(fileName);\n }, []);\n\n const clearFiles = useCallback(() => {\n setFiles({});\n uploadQueue.current.clear();\n }, []);\n\n const isFileUploading = useCallback((fileName: string) => {\n return uploadQueue.current.has(fileName);\n }, []);\n\n const addToUploadQueue = useCallback((fileName: string) => {\n uploadQueue.current.add(fileName);\n }, []);\n\n const removeFromUploadQueue = useCallback((fileName: string) => {\n uploadQueue.current.delete(fileName);\n }, []);\n\n const uploadFileToServer = useCallback(\n async (file: File, data?: Record<string, unknown>) => {\n const date = new Date().toLocaleString('es-ES', {\n timeZone: 'Europe/Madrid',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n });\n const fileName = addFile(file, date);\n addToUploadQueue(fileName);\n\n try {\n const { body } = await uploadFile(\n url ?? '',\n file,\n data,\n (progress) => {\n updateFileProgress(fileName, progress.percentage);\n },\n headers,\n );\n\n markFileAsUploaded(fileName, body.url);\n onFileUploaded?.({\n name: file.name,\n size: file.size,\n type: file.type,\n date,\n uploaded: true,\n loading: false,\n progress: 100,\n url: body.url,\n });\n } catch (error) {\n console.error('Error al subir archivo:', error);\n markFileAsError(\n fileName,\n error instanceof Error ? error.message : 'Error desconocido',\n );\n } finally {\n removeFromUploadQueue(fileName);\n }\n },\n [\n addFile,\n addToUploadQueue,\n updateFileProgress,\n markFileAsUploaded,\n markFileAsError,\n removeFromUploadQueue,\n onFileUploaded,\n url,\n headers,\n ],\n );\n\n const uploadMultipleFiles = useCallback(\n async (acceptedFiles: File[], data?: Record<string, unknown>) => {\n if (isUploading) {\n console.warn('Ya hay una subida en progreso');\n return;\n }\n\n setIsUploading(true);\n\n try {\n for (const file of acceptedFiles) {\n await uploadFileToServer(file, data);\n }\n } finally {\n setIsUploading(false);\n }\n },\n [isUploading, setIsUploading, uploadFileToServer],\n );\n\n return {\n files,\n isUploading,\n setIsUploading,\n addFile,\n updateFileProgress,\n markFileAsUploaded,\n markFileAsError,\n removeFile,\n clearFiles,\n isFileUploading,\n addToUploadQueue,\n removeFromUploadQueue,\n uploadFileToServer,\n uploadMultipleFiles,\n };\n};\n"],"mappings":"gHAKA,MAAa,GACX,EACA,EAAuE,EAAE,CACzE,EACA,IACG,CA4BH,GAAM,CAAC,EAAO,GAAY,OA3BoC,CAC5D,GAAI,CAAC,EAAc,MAAO,EAAE,CAE5B,GAAI,OAAO,GAAiB,UAAY,EAAE,SAAU,GAClD,OAAO,EAGT,GAAI,OAAO,GAAiB,UAAY,SAAU,EAAc,CAC9D,IAAM,EAAW,EACjB,MAAO,EACJ,EAAS,MAAO,CACf,KAAM,EAAS,KACf,KAAM,EAAS,KACf,KAAM,EAAS,KACf,KAAM,EAAS,KACf,SAAU,EAAS,UAAY,GAC/B,QAAS,EAAS,SAAW,GAC7B,IAAK,EAAS,IACd,MAAO,EAAS,MAChB,SAAU,EAAS,SACpB,CACF,CAGH,MAAO,EAAE,IAIc,CACxB,CACK,CAAC,EAAa,GAAkB,EAAS,GAAM,CAC/C,EAAc,EAAoB,IAAI,IAAM,CAE5C,EAAU,GAAa,EAAY,IAAkB,CACzD,IAAM,EAAqB,CACzB,KAAM,EAAK,KACX,KAAM,EAAK,KACX,KAAM,EAAK,KACX,IAAK,GACL,SAAU,GACV,QAAS,GACT,SAAU,EACV,KACE,GACA,IAAI,MAAM,CAAC,eAAe,QAAS,CACjC,SAAU,gBACV,KAAM,UACN,MAAO,UACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACT,CAAC,CACL,CAOD,OALA,EAAU,IAAU,CAClB,GAAG,GACF,EAAK,MAAO,EACd,EAAE,CAEI,EAAK,MACX,EAAE,CAAC,CAEA,EAAqB,GACxB,EAAkB,IAAqB,CACtC,EAAU,IAAU,CAClB,GAAG,GACF,GAAW,CACV,GAAG,EAAK,GACR,WACA,QAAS,EAAW,IACrB,CACF,EAAE,EAEL,EAAE,CACH,CAEK,EAAqB,GAAa,EAAkB,IAAgB,CACxE,EAAU,IAAU,CAClB,GAAG,GACF,GAAW,CACV,GAAG,EAAK,GACR,SAAU,GACV,QAAS,GACT,SAAU,IACV,MACD,CACF,EAAE,EACF,EAAE,CAAC,CAEA,EAAkB,GAAa,EAAkB,IAAkB,CACvE,EAAU,IAAU,CAClB,GAAG,GACF,GAAW,CACV,GAAG,EAAK,GACR,SAAU,GACV,QAAS,GACT,SAAU,EACV,QACD,CACF,EAAE,EACF,EAAE,CAAC,CAEA,EAAa,EAAa,GAAqB,CACnD,EAAU,GAAS,CACjB,IAAM,EAAW,CAAE,GAAG,EAAM,CAE5B,OADA,OAAO,EAAS,GACT,GACP,CACF,EAAY,QAAQ,OAAO,EAAS,EACnC,EAAE,CAAC,CAEA,EAAa,MAAkB,CACnC,EAAS,EAAE,CAAC,CACZ,EAAY,QAAQ,OAAO,EAC1B,EAAE,CAAC,CAEA,EAAkB,EAAa,GAC5B,EAAY,QAAQ,IAAI,EAAS,CACvC,EAAE,CAAC,CAEA,EAAmB,EAAa,GAAqB,CACzD,EAAY,QAAQ,IAAI,EAAS,EAChC,EAAE,CAAC,CAEA,EAAwB,EAAa,GAAqB,CAC9D,EAAY,QAAQ,OAAO,EAAS,EACnC,EAAE,CAAC,CAEA,EAAqB,EACzB,MAAO,EAAY,IAAmC,CACpD,IAAM,EAAO,IAAI,MAAM,CAAC,eAAe,QAAS,CAC9C,SAAU,gBACV,KAAM,UACN,MAAO,UACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACT,CAAC,CACI,EAAW,EAAQ,EAAM,EAAK,CACpC,EAAiB,EAAS,CAE1B,GAAI,CACF,GAAM,CAAE,QAAS,MAAM,EACrB,GAAO,GACP,EACA,EACC,GAAa,CACZ,EAAmB,EAAU,EAAS,WAAW,EAEnD,EACD,CAED,EAAmB,EAAU,EAAK,IAAI,CACtC,IAAiB,CACf,KAAM,EAAK,KACX,KAAM,EAAK,KACX,KAAM,EAAK,KACX,OACA,SAAU,GACV,QAAS,GACT,SAAU,IACV,IAAK,EAAK,IACX,CAAC,OACK,EAAO,CACd,QAAQ,MAAM,0BAA2B,EAAM,CAC/C,EACE,EACA,aAAiB,MAAQ,EAAM,QAAU,oBAC1C,QACO,CACR,EAAsB,EAAS,GAGnC,CACE,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAsBD,MAAO,CACL,QACA,cACA,iBACA,UACA,qBACA,qBACA,kBACA,aACA,aACA,kBACA,mBACA,wBACA,qBACA,oBAlC0B,EAC1B,MAAO,EAAuB,IAAmC,CAC/D,GAAI,EAAa,CACf,QAAQ,KAAK,gCAAgC,CAC7C,OAGF,EAAe,GAAK,CAEpB,GAAI,CACF,IAAK,IAAM,KAAQ,EACjB,MAAM,EAAmB,EAAM,EAAK,QAE9B,CACR,EAAe,GAAM,GAGzB,CAAC,EAAa,EAAgB,EAAmB,CAClD,CAiBA"}
|
|
@@ -12,9 +12,12 @@ type DropzoneFilesProps = {
|
|
|
12
12
|
subtitle?: ReactNode;
|
|
13
13
|
hint?: ReactNode;
|
|
14
14
|
initialFiles?: Record<string, FileData>;
|
|
15
|
-
maxFiles?: number;
|
|
16
|
-
|
|
17
|
-
|
|
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;
|
|
18
21
|
inputId?: string;
|
|
19
22
|
fileListHeight?: number | string;
|
|
20
23
|
classNames?: {
|
|
@@ -42,8 +45,11 @@ declare const DropzoneFiles: ({
|
|
|
42
45
|
hint,
|
|
43
46
|
initialFiles,
|
|
44
47
|
maxFiles,
|
|
48
|
+
maxSize,
|
|
45
49
|
accept,
|
|
46
50
|
url,
|
|
51
|
+
autoSend,
|
|
52
|
+
onChange,
|
|
47
53
|
inputId,
|
|
48
54
|
classNames
|
|
49
55
|
}: DropzoneFilesProps) => react_jsx_runtime0.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
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;EACA,MAAA;
|
|
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,cAAA;EACA,UAAA;IACE,aAAA;IACA,IAAA;IACA,YAAA;IACA,KAAA;IACA,WAAA;IACA,KAAA;IACA,QAAA;IACA,QAAA;IACA,YAAA,GAAe,iBAAA;IACf,QAAA,GAAW,aAAA;IACX,UAAA;MAAe,UAAA;IAAA;EAAA;AAAA;AAAA,cAMN,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;AAAA,GAgB3B,kBAAA,KAAkB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
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,
|
|
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,classNames:j})=>{let M=g(),N=A??M;return h(`div`,{className:r(j?.dropzoneFiles??i(),j?.root??f()),children:[h(`div`,{className:j?.labelWrapper??d(),children:[_&&m(`label`,{htmlFor:N,className:j?.label??u(),children:_}),v&&m(`p`,{className:j?.description??a(),children:v})]}),m(n,{maxFiles:w,maxSize:T,accept:E,url:D,autoSend:O,onChange:k,initialFiles:C,inputId:N,title:b,subtitle:x,hint:S,classNames:{dropzone:j?.dropzone?.dropzone??o()},children:({files:n,removeFile:r})=>Object.keys(n).length>0?m(`ul`,{className:j?.fileList??l(),children:Object.values(n).map(n=>m(`li`,{className:j?.fileItem??c(),children:m(e,{fileName:n.name,fileType:n.type,url:n.url,onRemove:()=>r(n.name),classNames:{uploadedFile:j?.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:j?.error??s(),children:y})]})};export{_ as DropzoneFiles};
|
|
2
2
|
//# sourceMappingURL=DropzoneFiles.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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 accept?: string[];\n url
|
|
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 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 dropzone?: DropzoneProps['classNames'];\n scrollArea?: { scrollArea?: string };\n // startIconWrapped?: IconWrappedProps['classNames'];\n // startIcon?: IconProps['classNames'];\n };\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 classNames,\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 classNames={{\n dropzone: classNames?.dropzone?.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":"upBAyEA,MAAa,GAAiB,CAC5B,QACA,cACA,QACA,QACA,WACA,OACA,eACA,WACA,UACA,SACA,MACA,WACA,WACA,UACA,gBACwB,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,OACN,WAAY,CACV,SAAU,GAAY,UAAU,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,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { FocusEvent, ReactNode } from "react";
|
|
3
2
|
|
|
4
3
|
//#region src/components/controls/file-input/BaseFileInput.d.ts
|
|
5
|
-
type
|
|
4
|
+
type FileInputValueComponent = (props: {
|
|
5
|
+
value: File | File[] | null;
|
|
6
|
+
}) => ReactNode;
|
|
7
|
+
type BaseFileInputProps = {
|
|
8
|
+
name?: string;
|
|
9
|
+
onBlur?: (event: FocusEvent) => void;
|
|
10
|
+
onFocus?: (event: FocusEvent) => void;
|
|
6
11
|
label?: ReactNode;
|
|
7
12
|
description?: ReactNode;
|
|
8
13
|
placeholder?: ReactNode;
|
|
@@ -12,7 +17,7 @@ type BaseFileInputProps = Omit<FileInputProps, 'value' | 'defaultValue' | 'onCha
|
|
|
12
17
|
disabled?: boolean;
|
|
13
18
|
multiple: boolean;
|
|
14
19
|
onChange?: (payload: File | File[] | null) => void;
|
|
15
|
-
valueComponent?:
|
|
20
|
+
valueComponent?: FileInputValueComponent;
|
|
16
21
|
classNames?: {
|
|
17
22
|
fileInput?: string;
|
|
18
23
|
root?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseFileInput.d.mts","names":[],"sources":["../../../../src/components/controls/file-input/BaseFileInput.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseFileInput.d.mts","names":[],"sources":["../../../../src/components/controls/file-input/BaseFileInput.tsx"],"mappings":";;;KAmBY,uBAAA,IAA2B,KAAA;EACrC,KAAA,EAAO,IAAA,GAAO,IAAA;AAAA,MACV,SAAA;AAAA,KAEM,kBAAA;EACV,IAAA;EACA,MAAA,IAAU,KAAA,EAAO,UAAA;EACjB,OAAA,IAAW,KAAA,EAAO,UAAA;EAClB,KAAA,GAAQ,SAAA;EACR,WAAA,GAAc,SAAA;EACd,WAAA,GAAc,SAAA;EACd,KAAA,GAAQ,SAAA;EACR,MAAA;EACA,QAAA;EACA,QAAA;EACA,QAAA;EACA,QAAA,IAAY,OAAA,EAAS,IAAA,GAAO,IAAA;EAC5B,cAAA,GAAiB,uBAAA;EACjB,UAAA;IACE,SAAA;IACA,IAAA;IACA,KAAA;IACA,QAAA;IACA,WAAA;IACA,KAAA;IACA,OAAA;IACA,KAAA;IACA,OAAA;IACA,WAAA;IACA,SAAA;MACE,IAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseFileInput.mjs","names":["MantineFileInput"],"sources":["../../../../src/components/controls/file-input/BaseFileInput.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n fileInput,\n fileInputDescription,\n fileInputError,\n fileInputInput,\n fileInputLabel,\n fileInputPlaceholder,\n fileInputRequired,\n fileInputRoot,\n fileInputSection,\n fileInputStartIcon,\n fileInputWrapper,\n} from '@mage-ui/styled-system/recipes';\nimport
|
|
1
|
+
{"version":3,"file":"BaseFileInput.mjs","names":["MantineFileInput"],"sources":["../../../../src/components/controls/file-input/BaseFileInput.tsx"],"sourcesContent":["import type { FocusEvent, ReactNode } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n fileInput,\n fileInputDescription,\n fileInputError,\n fileInputInput,\n fileInputLabel,\n fileInputPlaceholder,\n fileInputRequired,\n fileInputRoot,\n fileInputSection,\n fileInputStartIcon,\n fileInputWrapper,\n} from '@mage-ui/styled-system/recipes';\nimport { FileInput as MantineFileInput } from '@mantine/core';\nimport { Icon } from '@/components/data-display/icons/icon/Icon';\n\nexport type FileInputValueComponent = (props: {\n value: File | File[] | null;\n}) => ReactNode;\n\nexport type BaseFileInputProps = {\n name?: string;\n onBlur?: (event: FocusEvent) => void;\n onFocus?: (event: FocusEvent) => void;\n label?: ReactNode;\n description?: ReactNode;\n placeholder?: ReactNode;\n error?: ReactNode;\n accept?: string;\n required?: boolean;\n disabled?: boolean;\n multiple: boolean;\n onChange?: (payload: File | File[] | null) => void;\n valueComponent?: FileInputValueComponent;\n classNames?: {\n fileInput?: string;\n root?: string;\n label?: string;\n required?: string;\n description?: string;\n error?: string;\n wrapper?: string;\n input?: string;\n section?: string;\n placeholder?: string;\n startIcon?: {\n icon?: string;\n };\n };\n};\n\nexport const BaseFileInput = ({\n name,\n onBlur,\n onFocus,\n onChange,\n label,\n description,\n placeholder,\n error,\n multiple,\n accept,\n required,\n disabled,\n valueComponent,\n classNames,\n}: BaseFileInputProps) => {\n return (\n <MantineFileInput\n name={name}\n onBlur={onBlur}\n onFocus={onFocus}\n onChange={(payload) => {\n onChange?.(payload);\n }}\n disabled={disabled}\n required={required}\n multiple={multiple}\n accept={accept}\n clearable={true}\n label={label}\n description={description}\n placeholder={placeholder}\n error={error}\n valueComponent={valueComponent}\n leftSection={\n <Icon\n name='mage-dropzone-upload-01'\n path='/icons/sprite-mage.svg'\n classNames={{\n icon: classNames?.startIcon?.icon ?? fileInputStartIcon(),\n }}\n />\n }\n classNames={{\n root: cx(\n classNames?.fileInput ?? fileInput(),\n classNames?.root ?? fileInputRoot(),\n 'group',\n ),\n label: classNames?.label ?? fileInputLabel(),\n required: classNames?.required ?? fileInputRequired(),\n description: classNames?.description ?? fileInputDescription(),\n error: classNames?.error ?? fileInputError(),\n wrapper: classNames?.wrapper ?? fileInputWrapper(),\n input: cx(classNames?.input ?? fileInputInput(), 'peer'),\n section: cx(classNames?.section ?? fileInputSection(), 'group'),\n placeholder: classNames?.placeholder ?? fileInputPlaceholder(),\n }}\n />\n );\n};\n"],"mappings":"ydAsDA,MAAa,GAAiB,CAC5B,OACA,SACA,UACA,WACA,QACA,cACA,cACA,QACA,WACA,SACA,WACA,WACA,iBACA,gBAGE,EAACA,EAAD,CACQ,OACE,SACC,UACT,SAAW,GAAY,CACrB,IAAW,EAAQ,EAEX,WACA,WACA,WACF,SACR,UAAW,GACJ,QACM,cACA,cACN,QACS,iBAChB,YACE,EAAC,EAAD,CACE,KAAK,0BACL,KAAK,yBACL,WAAY,CACV,KAAM,GAAY,WAAW,MAAQ,GAAoB,CAC1D,CACD,CAAA,CAEJ,WAAY,CACV,KAAM,EACJ,GAAY,WAAa,GAAW,CACpC,GAAY,MAAQ,GAAe,CACnC,QACD,CACD,MAAO,GAAY,OAAS,GAAgB,CAC5C,SAAU,GAAY,UAAY,GAAmB,CACrD,YAAa,GAAY,aAAe,GAAsB,CAC9D,MAAO,GAAY,OAAS,GAAgB,CAC5C,QAAS,GAAY,SAAW,GAAkB,CAClD,MAAO,EAAG,GAAY,OAAS,GAAgB,CAAE,OAAO,CACxD,QAAS,EAAG,GAAY,SAAW,GAAkB,CAAE,QAAQ,CAC/D,YAAa,GAAY,aAAe,GAAsB,CAC/D,CACD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInputMultiple.d.mts","names":[],"sources":["../../../../src/components/controls/file-input/FileInputMultiple.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"FileInputMultiple.d.mts","names":[],"sources":["../../../../src/components/controls/file-input/FileInputMultiple.tsx"],"mappings":";;;;KASY,sBAAA,GAAyB,IAAA,CACnC,kBAAA;EAGA,QAAA,IAAY,KAAA,EAAO,IAAA;EACnB,eAAA;IACE,KAAA;IACA,IAAA;IACA,OAAA;IACA,KAAA;EAAA;AAAA;AAAA,cAuCS,iBAAA;EAAqB,IAAA;EAAA,MAAA;EAAA,OAAA;EAAA,QAAA;EAAA,KAAA;EAAA,WAAA;EAAA,WAAA;EAAA,KAAA;EAAA,MAAA;EAAA,QAAA;EAAA,QAAA;EAAA,UAAA;EAAA;AAAA,GAc/B,sBAAA,KAAsB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Badge as e}from"../../data-display/badge/Badge.mjs";import{BaseFileInput as t}from"./BaseFileInput.mjs";import{fileInputBadge as n}from"@mage-ui/styled-system/recipes";import{Fragment as r,jsx as i}from"react/jsx-runtime";const a=({badgeClassNames:t})=>({value:a})=>a?i(r,{children:(Array.isArray(a)?a:[a]).map(r=>i(e,{classNames:{badge:t?.badge??n()},children:r.name},`${r.name}-${r.lastModified}`))}):null,o=({name:e,onBlur:n,onFocus:r,onChange:o,label:s,description:c,placeholder:l,error:u,accept:d,required:f,disabled:p,classNames:m,badgeClassNames:h})=>i(t,{name:e,onBlur:n,onFocus:r,label:s,description:c,placeholder:l,error:u,accept:d,required:f,disabled:p,classNames:m,multiple:!0,valueComponent:a({badgeClassNames:h}),onChange:e=>{o?.(e)}});export{o as FileInputMultiple};
|
|
1
|
+
import{Badge as e}from"../../data-display/badge/Badge.mjs";import{BaseFileInput as t}from"./BaseFileInput.mjs";import{fileInputBadge as n}from"@mage-ui/styled-system/recipes";import{Fragment as r,jsx as i}from"react/jsx-runtime";const a=({badgeClassNames:t})=>({value:a})=>a?i(r,{children:(Array.isArray(a)?a:[a]).map(r=>i(e,{classNames:{badge:t?.badge??n(),root:t?.root,section:t?.section,label:t?.label},children:r.name},`${r.name}-${r.lastModified}`))}):null,o=({name:e,onBlur:n,onFocus:r,onChange:o,label:s,description:c,placeholder:l,error:u,accept:d,required:f,disabled:p,classNames:m,badgeClassNames:h})=>i(t,{name:e,onBlur:n,onFocus:r,label:s,description:c,placeholder:l,error:u,accept:d,required:f,disabled:p,classNames:m,multiple:!0,valueComponent:a({badgeClassNames:h}),onChange:e=>{o?.(e)}});export{o as FileInputMultiple};
|
|
2
2
|
//# sourceMappingURL=FileInputMultiple.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInputMultiple.mjs","names":[],"sources":["../../../../src/components/controls/file-input/FileInputMultiple.tsx"],"sourcesContent":["import { fileInputBadge } from '@mage-ui/styled-system/recipes';\nimport
|
|
1
|
+
{"version":3,"file":"FileInputMultiple.mjs","names":[],"sources":["../../../../src/components/controls/file-input/FileInputMultiple.tsx"],"sourcesContent":["import { fileInputBadge } from '@mage-ui/styled-system/recipes';\nimport { Badge } from '@/components/data-display/badge/Badge';\n\nimport {\n BaseFileInput,\n type BaseFileInputProps,\n type FileInputValueComponent,\n} from './BaseFileInput';\n\nexport type FileInputMultipleProps = Omit<\n BaseFileInputProps,\n 'multiple' | 'onChange' | 'valueComponent'\n> & {\n onChange?: (files: File[] | null) => void;\n badgeClassNames?: {\n badge?: string;\n root?: string;\n section?: string;\n label?: string;\n };\n};\n\nconst createValueComponent = ({\n badgeClassNames,\n}: {\n badgeClassNames?: {\n badge?: string;\n root?: string;\n section?: string;\n label?: string;\n };\n}): FileInputValueComponent => {\n return ({ value }) => {\n if (!value) return null;\n\n const files = Array.isArray(value) ? value : [value];\n\n return (\n <>\n {files.map((file) => (\n <Badge\n key={`${file.name}-${file.lastModified}`}\n classNames={{\n badge: badgeClassNames?.badge ?? fileInputBadge(),\n root: badgeClassNames?.root,\n section: badgeClassNames?.section,\n label: badgeClassNames?.label,\n }}\n >\n {file.name}\n </Badge>\n ))}\n </>\n );\n };\n};\n\nexport const FileInputMultiple = ({\n name,\n onBlur,\n onFocus,\n onChange,\n label,\n description,\n placeholder,\n error,\n accept,\n required,\n disabled,\n classNames,\n badgeClassNames,\n}: FileInputMultipleProps) => {\n return (\n <BaseFileInput\n name={name}\n onBlur={onBlur}\n onFocus={onFocus}\n label={label}\n description={description}\n placeholder={placeholder}\n error={error}\n accept={accept}\n required={required}\n disabled={disabled}\n classNames={classNames}\n multiple={true}\n valueComponent={createValueComponent({\n badgeClassNames,\n })}\n onChange={(payload) => {\n onChange?.(payload as File[] | null);\n }}\n />\n );\n};\n"],"mappings":"qOAsBA,MAAM,GAAwB,CAC5B,sBASQ,CAAE,WACH,EAKH,EAAA,EAAA,CAAA,UAHY,MAAM,QAAQ,EAAM,CAAG,EAAQ,CAAC,EAAM,EAIzC,IAAK,GACV,EAAC,EAAD,CAEE,WAAY,CACV,MAAO,GAAiB,OAAS,GAAgB,CACjD,KAAM,GAAiB,KACvB,QAAS,GAAiB,QAC1B,MAAO,GAAiB,MACzB,UAEA,EAAK,KACA,CATD,GAAG,EAAK,KAAK,GAAG,EAAK,eASpB,CACR,CACD,CAAA,CAnBc,KAwBV,GAAqB,CAChC,OACA,SACA,UACA,WACA,QACA,cACA,cACA,QACA,SACA,WACA,WACA,aACA,qBAGE,EAAC,EAAD,CACQ,OACE,SACC,UACF,QACM,cACA,cACN,QACC,SACE,WACA,WACE,aACZ,SAAU,GACV,eAAgB,EAAqB,CACnC,kBACD,CAAC,CACF,SAAW,GAAY,CACrB,IAAW,EAAyB,EAEtC,CAAA"}
|
|
@@ -34,4 +34,5 @@ import { RemovableItem, RemovableItemProps } from "./removable-item/RemovableIte
|
|
|
34
34
|
import { Tag, TagProps } from "./tag/Tag.mjs";
|
|
35
35
|
import { TagGroup, TagGroupProps } from "./tag-group/TagGroup.mjs";
|
|
36
36
|
import { UploadedFile, UploadedFileProps } from "./uploaded-file/UploadedFile.mjs";
|
|
37
|
-
import { UploadedFileDetails, UploadedFileDetailsProps } from "./uploaded-file/UploadedFileDetails.mjs";
|
|
37
|
+
import { UploadedFileDetails, UploadedFileDetailsProps } from "./uploaded-file/UploadedFileDetails.mjs";
|
|
38
|
+
import { UploadingFiles, UploadingFilesClassNames, UploadingFilesItemClassNames, UploadingFilesItemErrorClassNames, UploadingFilesItemErrorProps, UploadingFilesItemProps, UploadingFilesProps } from "./uploading-files/UploadingFiles.mjs";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/data-display/uploading-files/UploadingFiles.d.ts
|
|
4
|
+
type UploadingFilesClassNames = {
|
|
5
|
+
uploadingFiles?: string;
|
|
6
|
+
root?: string;
|
|
7
|
+
};
|
|
8
|
+
type UploadingFilesProps = {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
classNames?: UploadingFilesClassNames;
|
|
11
|
+
};
|
|
12
|
+
type UploadingFilesItemClassNames = {
|
|
13
|
+
root?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
progress?: string;
|
|
16
|
+
};
|
|
17
|
+
type UploadingFilesItemProps = {
|
|
18
|
+
name: string;
|
|
19
|
+
progress: number;
|
|
20
|
+
classNames?: UploadingFilesItemClassNames;
|
|
21
|
+
};
|
|
22
|
+
type UploadingFilesItemErrorClassNames = {
|
|
23
|
+
root?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
};
|
|
27
|
+
type UploadingFilesItemErrorProps = {
|
|
28
|
+
name: string;
|
|
29
|
+
message: string;
|
|
30
|
+
classNames?: UploadingFilesItemErrorClassNames;
|
|
31
|
+
};
|
|
32
|
+
declare const UploadingFiles: (({
|
|
33
|
+
children,
|
|
34
|
+
classNames
|
|
35
|
+
}: UploadingFilesProps) => ReactNode) & {
|
|
36
|
+
Item: ({
|
|
37
|
+
name,
|
|
38
|
+
progress,
|
|
39
|
+
classNames
|
|
40
|
+
}: UploadingFilesItemProps) => ReactNode;
|
|
41
|
+
ItemError: ({
|
|
42
|
+
name,
|
|
43
|
+
message,
|
|
44
|
+
classNames
|
|
45
|
+
}: UploadingFilesItemErrorProps) => ReactNode;
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { UploadingFiles, UploadingFilesClassNames, UploadingFilesItemClassNames, UploadingFilesItemErrorClassNames, UploadingFilesItemErrorProps, UploadingFilesItemProps, UploadingFilesProps };
|
|
49
|
+
//# sourceMappingURL=UploadingFiles.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UploadingFiles.d.mts","names":[],"sources":["../../../../src/components/data-display/uploading-files/UploadingFiles.tsx"],"mappings":";;;KAkBY,wBAAA;EACV,cAAA;EACA,IAAA;AAAA;AAAA,KAGU,mBAAA;EACV,QAAA,EAAU,SAAA;EACV,UAAA,GAAa,wBAAA;AAAA;AAAA,KAGH,4BAAA;EACV,IAAA;EACA,IAAA;EACA,QAAA;AAAA;AAAA,KAGU,uBAAA;EACV,IAAA;EACA,QAAA;EACA,UAAA,GAAa,4BAAA;AAAA;AAAA,KAGH,iCAAA;EACV,IAAA;EACA,IAAA;EACA,OAAA;AAAA;AAAA,KAGU,4BAAA;EACV,IAAA;EACA,OAAA;EACA,UAAA,GAAa,iCAAA;AAAA;AAAA,cAqEF,cAAA;EAAc,QAAA;EAAA;AAAA,GA/DxB,mBAAA,KAAsB,SAAA;;;;;KAetB,uBAAA,KAA0B,SAAA;;;;;KAuC1B,4BAAA,KAA+B,SAAA;AAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{cx as e}from"@mage-ui/styled-system/css";import{uploadingFiles as t,uploadingFilesItem as n,uploadingFilesItemErrorMessage as r,uploadingFilesItemName as i,uploadingFilesItemProgress as a,uploadingFilesItemProgressFill as o,uploadingFilesItemProgressRing as s,uploadingFilesItemProgressTrack as c,uploadingFilesRoot as l}from"@mage-ui/styled-system/recipes";import{jsx as u,jsxs as d}from"react/jsx-runtime";const f=2*Math.PI*8,p=Object.assign(({children:n,classNames:r})=>u(`ul`,{className:e(r?.uploadingFiles??t(),r?.root??l()),children:n}),{Item:({name:e,progress:t,classNames:r})=>{let l=f*(1-t/100);return d(`li`,{className:r?.root??n(),children:[u(`span`,{className:r?.name??i(),children:e}),d(`span`,{className:r?.progress??a(),children:[d(`svg`,{className:s(),viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[u(`circle`,{className:c(),cx:`10`,cy:`10`,r:8}),u(`circle`,{className:o(),cx:`10`,cy:`10`,r:8,strokeDasharray:f,strokeDashoffset:l})]}),t,`%`]})]})},ItemError:({name:e,message:t,classNames:a})=>d(`li`,{className:a?.root??n(),"data-error":`true`,children:[u(`span`,{className:a?.name??i(),children:e}),u(`span`,{className:a?.message??r(),children:t})]})});export{p as UploadingFiles};
|
|
2
|
+
//# sourceMappingURL=UploadingFiles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UploadingFiles.mjs","names":[],"sources":["../../../../src/components/data-display/uploading-files/UploadingFiles.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n uploadingFiles,\n uploadingFilesItem,\n uploadingFilesItemErrorMessage,\n uploadingFilesItemName,\n uploadingFilesItemProgress,\n uploadingFilesItemProgressFill,\n uploadingFilesItemProgressRing,\n uploadingFilesItemProgressTrack,\n uploadingFilesRoot,\n} from '@mage-ui/styled-system/recipes';\n\nconst RADIUS = 8;\nconst CIRCUMFERENCE = 2 * Math.PI * RADIUS;\n\nexport type UploadingFilesClassNames = {\n uploadingFiles?: string;\n root?: string;\n};\n\nexport type UploadingFilesProps = {\n children: ReactNode;\n classNames?: UploadingFilesClassNames;\n};\n\nexport type UploadingFilesItemClassNames = {\n root?: string;\n name?: string;\n progress?: string;\n};\n\nexport type UploadingFilesItemProps = {\n name: string;\n progress: number;\n classNames?: UploadingFilesItemClassNames;\n};\n\nexport type UploadingFilesItemErrorClassNames = {\n root?: string;\n name?: string;\n message?: string;\n};\n\nexport type UploadingFilesItemErrorProps = {\n name: string;\n message: string;\n classNames?: UploadingFilesItemErrorClassNames;\n};\n\nconst UploadingFilesRoot = ({\n children,\n classNames,\n}: UploadingFilesProps): ReactNode => (\n <ul\n className={cx(\n classNames?.uploadingFiles ?? uploadingFiles(),\n classNames?.root ?? uploadingFilesRoot(),\n )}\n >\n {children}\n </ul>\n);\n\nconst Item = ({\n name,\n progress,\n classNames,\n}: UploadingFilesItemProps): ReactNode => {\n const offset = CIRCUMFERENCE * (1 - progress / 100);\n\n return (\n <li className={classNames?.root ?? uploadingFilesItem()}>\n <span className={classNames?.name ?? uploadingFilesItemName()}>\n {name}\n </span>\n <span className={classNames?.progress ?? uploadingFilesItemProgress()}>\n <svg\n className={uploadingFilesItemProgressRing()}\n viewBox='0 0 20 20'\n aria-hidden='true'\n >\n <circle\n className={uploadingFilesItemProgressTrack()}\n cx='10'\n cy='10'\n r={RADIUS}\n />\n <circle\n className={uploadingFilesItemProgressFill()}\n cx='10'\n cy='10'\n r={RADIUS}\n strokeDasharray={CIRCUMFERENCE}\n strokeDashoffset={offset}\n />\n </svg>\n {progress}%\n </span>\n </li>\n );\n};\n\nconst ItemError = ({\n name,\n message,\n classNames,\n}: UploadingFilesItemErrorProps): ReactNode => (\n <li className={classNames?.root ?? uploadingFilesItem()} data-error='true'>\n <span className={classNames?.name ?? uploadingFilesItemName()}>{name}</span>\n <span className={classNames?.message ?? uploadingFilesItemErrorMessage()}>\n {message}\n </span>\n </li>\n);\n\nexport const UploadingFiles = Object.assign(UploadingFilesRoot, {\n Item,\n ItemError,\n});\n"],"mappings":"+ZAeA,MACM,EAAgB,EAAI,KAAK,GAAK,EAsGvB,EAAiB,OAAO,QAlET,CAC1B,WACA,gBAEA,EAAC,KAAD,CACE,UAAW,EACT,GAAY,gBAAkB,GAAgB,CAC9C,GAAY,MAAQ,GAAoB,CACzC,CAEA,WACE,CAAA,CAuDyD,CAC9D,MArDY,CACZ,OACA,WACA,gBACwC,CACxC,IAAM,EAAS,GAAiB,EAAI,EAAW,KAE/C,OACE,EAAC,KAAD,CAAI,UAAW,GAAY,MAAQ,GAAoB,UAAvD,CACE,EAAC,OAAD,CAAM,UAAW,GAAY,MAAQ,GAAwB,UAC1D,EACI,CAAA,CACP,EAAC,OAAD,CAAM,UAAW,GAAY,UAAY,GAA4B,UAArE,CACE,EAAC,MAAD,CACE,UAAW,GAAgC,CAC3C,QAAQ,YACR,cAAY,gBAHd,CAKE,EAAC,SAAD,CACE,UAAW,GAAiC,CAC5C,GAAG,KACH,GAAG,KACH,EAAG,EACH,CAAA,CACF,EAAC,SAAD,CACE,UAAW,GAAgC,CAC3C,GAAG,KACH,GAAG,KACH,EAAG,EACH,gBAAiB,EACjB,iBAAkB,EAClB,CAAA,CACE,GACL,EAAS,IACL,GACJ,IAmBP,WAfiB,CACjB,OACA,UACA,gBAEA,EAAC,KAAD,CAAI,UAAW,GAAY,MAAQ,GAAoB,CAAE,aAAW,gBAApE,CACE,EAAC,OAAD,CAAM,UAAW,GAAY,MAAQ,GAAwB,UAAG,EAAY,CAAA,CAC5E,EAAC,OAAD,CAAM,UAAW,GAAY,SAAW,GAAgC,UACrE,EACI,CAAA,CACJ,GAMN,CAAC"}
|
|
@@ -6,6 +6,10 @@ import { FormPasswordProps } from "./controls/FormPassword.mjs";
|
|
|
6
6
|
import { FormSelectProps } from "./controls/FormSelect.mjs";
|
|
7
7
|
import { FormComboboxProps } from "./controls/FormCombobox.mjs";
|
|
8
8
|
import { FormAutocompleteProps } from "./controls/FormAutocomplete.mjs";
|
|
9
|
+
import { FormFileInputProps } from "./controls/FormFileInput.mjs";
|
|
10
|
+
import { FormFileInputMultipleProps } from "./controls/FormFileInputMultiple.mjs";
|
|
11
|
+
import { FormDropzoneProps } from "./controls/FormDropzone.mjs";
|
|
12
|
+
import { FormDropzoneFilesProps } from "./controls/FormDropzoneFiles.mjs";
|
|
9
13
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
10
14
|
import React, { ReactNode } from "react";
|
|
11
15
|
import { FieldValues, UseFormSetError } from "react-hook-form";
|
|
@@ -146,6 +150,48 @@ declare const Form: {
|
|
|
146
150
|
}: FormAutocompleteProps): react_jsx_runtime0.JSX.Element;
|
|
147
151
|
displayName: string;
|
|
148
152
|
};
|
|
153
|
+
FileInput: {
|
|
154
|
+
({
|
|
155
|
+
$rule: _$rule,
|
|
156
|
+
isSubmitting: _isSubmitting,
|
|
157
|
+
name,
|
|
158
|
+
error,
|
|
159
|
+
onChange,
|
|
160
|
+
...props
|
|
161
|
+
}: FormFileInputProps): react_jsx_runtime0.JSX.Element;
|
|
162
|
+
displayName: string;
|
|
163
|
+
};
|
|
164
|
+
FileInputMultiple: {
|
|
165
|
+
({
|
|
166
|
+
$rule: _$rule,
|
|
167
|
+
isSubmitting: _isSubmitting,
|
|
168
|
+
name,
|
|
169
|
+
error,
|
|
170
|
+
onChange,
|
|
171
|
+
...props
|
|
172
|
+
}: FormFileInputMultipleProps): react_jsx_runtime0.JSX.Element;
|
|
173
|
+
displayName: string;
|
|
174
|
+
};
|
|
175
|
+
Dropzone: {
|
|
176
|
+
({
|
|
177
|
+
$rule: _$rule,
|
|
178
|
+
isSubmitting: _isSubmitting,
|
|
179
|
+
name,
|
|
180
|
+
onChange,
|
|
181
|
+
...props
|
|
182
|
+
}: FormDropzoneProps): react_jsx_runtime0.JSX.Element;
|
|
183
|
+
displayName: string;
|
|
184
|
+
};
|
|
185
|
+
DropzoneFiles: {
|
|
186
|
+
({
|
|
187
|
+
$rule: _$rule,
|
|
188
|
+
isSubmitting: _isSubmitting,
|
|
189
|
+
name,
|
|
190
|
+
onChange,
|
|
191
|
+
...props
|
|
192
|
+
}: FormDropzoneFilesProps): react_jsx_runtime0.JSX.Element;
|
|
193
|
+
displayName: string;
|
|
194
|
+
};
|
|
149
195
|
};
|
|
150
196
|
//#endregion
|
|
151
197
|
export { Form, FormProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.mts","names":[],"sources":["../../../src/components/forms/Form.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Form.d.mts","names":[],"sources":["../../../src/components/forms/Form.tsx"],"mappings":";;;;;;;;;;;;;;;;;;KAuBK,YAAA;EACH,IAAA;EACA,OAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,KAGU,SAAA,WAAoB,WAAA;EAC9B,QAAA,GAAW,MAAA;IAAU,IAAA,EAAM,CAAA;EAAA,MAAQ,OAAA;EACnC,aAAA,IAAiB,QAAA,EAAU,YAAA;EAC3B,eAAA,IAAmB,MAAA;IACjB,OAAA;IACA,QAAA,EAAU,eAAA,CAAgB,CAAA;IAC1B,MAAA;EAAA;EAEF,aAAA;EACA,QAAA,EAAU,SAAA;EACV,MAAA,GAAS,SAAA,CAAU,MAAA,SAAe,UAAA;EAClC,CAAA,IACE,GAAA,UACA,QAAA,GAAW,MAAA,kBACX,QAAA,uBACY,KAAA,CAAM,SAAA;EACpB,UAAA;IACE,IAAA;IACA,IAAA;EAAA;AAAA;AAAA,cAYS,IAAA;EAAA,WAAkB,WAAA;IAAW,QAAA;IAAA,aAAA;IAAA,eAAA;IAAA,aAAA;IAAA,QAAA;IAAA,MAAA;IAAA,CAAA;IAAA;EAAA,GASvC,SAAA,CAAU,CAAA,IAAE,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{FormAutocomplete as e}from"./controls/FormAutocomplete.mjs";import{FormCheckbox as t}from"./controls/FormCheckbox.mjs";import{FormCombobox as n}from"./controls/FormCombobox.mjs";import{
|
|
1
|
+
import{FormAutocomplete as e}from"./controls/FormAutocomplete.mjs";import{FormCheckbox as t}from"./controls/FormCheckbox.mjs";import{FormCombobox as n}from"./controls/FormCombobox.mjs";import{FormDropzone as r}from"./controls/FormDropzone.mjs";import{FormDropzoneFiles as i}from"./controls/FormDropzoneFiles.mjs";import{FormFileInput as a}from"./controls/FormFileInput.mjs";import{FormFileInputMultiple as o}from"./controls/FormFileInputMultiple.mjs";import{FormHidden as s}from"./controls/FormHidden.mjs";import{FormPassword as c}from"./controls/FormPassword.mjs";import{FormSelect as l}from"./controls/FormSelect.mjs";import{FormSubmit as u}from"./controls/FormSubmit.mjs";import{FormTextarea as d}from"./controls/FormTextarea.mjs";import{FormTextInput as f}from"./controls/FormTextInput.mjs";import{FormBase as p}from"./FormBase.mjs";import{FormErrorBox as m}from"./FormErrorBox.mjs";import{form as h,formRoot as g}from"@mage-ui/styled-system/recipes";import{jsx as _}from"react/jsx-runtime";const v=({$fetcher:e,onValidSubmit:t,onInvalidSubmit:n,invalidStatus:r=[],children:i,schema:a,t:o,classNames:s})=>_(p,{onSubmit:async({data:i,setError:a})=>{await e({data:i}).then(e=>{let n=e;if(n?.statusCode&&n.statusCode>=400)throw n;t?.(e||{})}).catch(e=>{switch(e.statusCode){case 400:case 422:e.cause?.issues&&Object.keys(e.cause.issues).forEach(t=>{a(t,{type:`server`,message:e.cause?.issues?.[t]})}),a(`root.serverError`,{type:`server`,message:e?.message??`Something went wrong`});break;default:if(r.includes(e.statusCode)){n?.({message:e.message,setError:a,status:e.statusCode});break}throw e}})},schema:a,errorBox:m,t:o,classNames:{form:s?.form??h(),root:s?.root??g()},children:i});v.displayName=`Form`,v.TextInput=f,v.Textarea=d,v.Submit=u,v.Hidden=s,v.Checkbox=t,v.Password=c,v.Select=l,v.Combobox=n,v.Autocomplete=e,v.FileInput=a,v.FileInputMultiple=o,v.Dropzone=r,v.DropzoneFiles=i;export{v as Form};
|
|
2
2
|
//# sourceMappingURL=Form.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.mjs","names":[],"sources":["../../../src/components/forms/Form.tsx"],"sourcesContent":["import type React from 'react';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, UseFormSetError } from 'react-hook-form';\nimport type { ZodObject, ZodTypeAny } from 'zod';\n\nimport { form, formRoot } from '@mage-ui/styled-system/recipes';\n\nimport { FormAutocomplete } from './controls/FormAutocomplete';\nimport { FormCheckbox } from './controls/FormCheckbox';\nimport { FormCombobox } from './controls/FormCombobox';\nimport { FormHidden } from './controls/FormHidden';\nimport { FormPassword } from './controls/FormPassword';\nimport { FormSelect } from './controls/FormSelect';\nimport { FormSubmit } from './controls/FormSubmit';\nimport { FormTextarea } from './controls/FormTextarea';\nimport { FormTextInput } from './controls/FormTextInput';\nimport { FormBase } from './FormBase';\nimport { FormErrorBox } from './FormErrorBox';\n\ntype FormResponse = {\n body?: object;\n details?: string;\n status?: number;\n url?: string;\n};\n\nexport type FormProps<T extends FieldValues> = {\n $fetcher: (params: { data: T }) => Promise<unknown>;\n onValidSubmit?: (response: FormResponse) => void;\n onInvalidSubmit?: (params: {\n message: string;\n setError: UseFormSetError<T>;\n status: number;\n }) => void;\n invalidStatus?: number[];\n children: ReactNode;\n schema?: ZodObject<Record<string, ZodTypeAny>>;\n t?: (\n key: string,\n bindings?: Record<string, string>,\n fallback?: string,\n ) => string | React.ReactNode;\n classNames?: {\n form?: string;\n root?: string;\n };\n};\n\ntype FormError = {\n statusCode: number;\n message: string;\n cause?: {\n issues: Record<string, string>;\n };\n};\n\nexport const Form = <T extends FieldValues>({\n $fetcher,\n onValidSubmit,\n onInvalidSubmit,\n invalidStatus = [],\n children,\n schema,\n t,\n classNames,\n}: FormProps<T>) => {\n const onSubmit = async ({\n data,\n setError,\n }: {\n data: FieldValues;\n setError: UseFormSetError<FieldValues>;\n }) => {\n await $fetcher({ data: data as T })\n .then((response) => {\n const res = response as FormError & FormResponse;\n if (res?.statusCode && res.statusCode >= 400) {\n throw res;\n }\n\n onValidSubmit?.((response || {}) as FormResponse);\n })\n .catch((error: FormError) => {\n switch (error.statusCode) {\n case 400:\n case 422: {\n if (error.cause?.issues) {\n Object.keys(error.cause.issues).forEach((key) => {\n setError(key, {\n type: 'server',\n message: error.cause?.issues?.[key],\n });\n });\n }\n setError('root.serverError', {\n type: 'server',\n message: error?.message ?? 'Something went wrong',\n });\n break;\n }\n default:\n if (invalidStatus.includes(error.statusCode)) {\n onInvalidSubmit?.({\n message: error.message,\n setError: setError as UseFormSetError<T>,\n status: error.statusCode,\n });\n break;\n }\n throw error;\n }\n });\n };\n\n return (\n <FormBase\n onSubmit={onSubmit}\n schema={schema}\n errorBox={FormErrorBox}\n t={t}\n classNames={{\n form: classNames?.form ?? form(),\n root: classNames?.root ?? formRoot(),\n }}\n >\n {children}\n </FormBase>\n );\n};\n\nForm.displayName = 'Form';\nForm.TextInput = FormTextInput;\nForm.Textarea = FormTextarea;\nForm.Submit = FormSubmit;\nForm.Hidden = FormHidden;\nForm.Checkbox = FormCheckbox;\nForm.Password = FormPassword;\nForm.Select = FormSelect;\nForm.Combobox = FormCombobox;\nForm.Autocomplete = FormAutocomplete;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Form.mjs","names":[],"sources":["../../../src/components/forms/Form.tsx"],"sourcesContent":["import type React from 'react';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, UseFormSetError } from 'react-hook-form';\nimport type { ZodObject, ZodTypeAny } from 'zod';\n\nimport { form, formRoot } from '@mage-ui/styled-system/recipes';\n\nimport { FormAutocomplete } from './controls/FormAutocomplete';\nimport { FormCheckbox } from './controls/FormCheckbox';\nimport { FormCombobox } from './controls/FormCombobox';\nimport { FormDropzone } from './controls/FormDropzone';\nimport { FormDropzoneFiles } from './controls/FormDropzoneFiles';\nimport { FormFileInput } from './controls/FormFileInput';\nimport { FormFileInputMultiple } from './controls/FormFileInputMultiple';\nimport { FormHidden } from './controls/FormHidden';\nimport { FormPassword } from './controls/FormPassword';\nimport { FormSelect } from './controls/FormSelect';\nimport { FormSubmit } from './controls/FormSubmit';\nimport { FormTextarea } from './controls/FormTextarea';\nimport { FormTextInput } from './controls/FormTextInput';\nimport { FormBase } from './FormBase';\nimport { FormErrorBox } from './FormErrorBox';\n\ntype FormResponse = {\n body?: object;\n details?: string;\n status?: number;\n url?: string;\n};\n\nexport type FormProps<T extends FieldValues> = {\n $fetcher: (params: { data: T }) => Promise<unknown>;\n onValidSubmit?: (response: FormResponse) => void;\n onInvalidSubmit?: (params: {\n message: string;\n setError: UseFormSetError<T>;\n status: number;\n }) => void;\n invalidStatus?: number[];\n children: ReactNode;\n schema?: ZodObject<Record<string, ZodTypeAny>>;\n t?: (\n key: string,\n bindings?: Record<string, string>,\n fallback?: string,\n ) => string | React.ReactNode;\n classNames?: {\n form?: string;\n root?: string;\n };\n};\n\ntype FormError = {\n statusCode: number;\n message: string;\n cause?: {\n issues: Record<string, string>;\n };\n};\n\nexport const Form = <T extends FieldValues>({\n $fetcher,\n onValidSubmit,\n onInvalidSubmit,\n invalidStatus = [],\n children,\n schema,\n t,\n classNames,\n}: FormProps<T>) => {\n const onSubmit = async ({\n data,\n setError,\n }: {\n data: FieldValues;\n setError: UseFormSetError<FieldValues>;\n }) => {\n await $fetcher({ data: data as T })\n .then((response) => {\n const res = response as FormError & FormResponse;\n if (res?.statusCode && res.statusCode >= 400) {\n throw res;\n }\n\n onValidSubmit?.((response || {}) as FormResponse);\n })\n .catch((error: FormError) => {\n switch (error.statusCode) {\n case 400:\n case 422: {\n if (error.cause?.issues) {\n Object.keys(error.cause.issues).forEach((key) => {\n setError(key, {\n type: 'server',\n message: error.cause?.issues?.[key],\n });\n });\n }\n setError('root.serverError', {\n type: 'server',\n message: error?.message ?? 'Something went wrong',\n });\n break;\n }\n default:\n if (invalidStatus.includes(error.statusCode)) {\n onInvalidSubmit?.({\n message: error.message,\n setError: setError as UseFormSetError<T>,\n status: error.statusCode,\n });\n break;\n }\n throw error;\n }\n });\n };\n\n return (\n <FormBase\n onSubmit={onSubmit}\n schema={schema}\n errorBox={FormErrorBox}\n t={t}\n classNames={{\n form: classNames?.form ?? form(),\n root: classNames?.root ?? formRoot(),\n }}\n >\n {children}\n </FormBase>\n );\n};\n\nForm.displayName = 'Form';\nForm.TextInput = FormTextInput;\nForm.Textarea = FormTextarea;\nForm.Submit = FormSubmit;\nForm.Hidden = FormHidden;\nForm.Checkbox = FormCheckbox;\nForm.Password = FormPassword;\nForm.Select = FormSelect;\nForm.Combobox = FormCombobox;\nForm.Autocomplete = FormAutocomplete;\nForm.FileInput = FormFileInput;\nForm.FileInputMultiple = FormFileInputMultiple;\nForm.Dropzone = FormDropzone;\nForm.DropzoneFiles = FormDropzoneFiles;\n"],"mappings":"m+BA4DA,MAAa,GAA+B,CAC1C,WACA,gBACA,kBACA,gBAAgB,EAAE,CAClB,WACA,SACA,IACA,gBAmDE,EAAC,EAAD,CACY,SAlDG,MAAO,CACtB,OACA,cAII,CACJ,MAAM,EAAS,CAAQ,OAAW,CAAC,CAChC,KAAM,GAAa,CAClB,IAAM,EAAM,EACZ,GAAI,GAAK,YAAc,EAAI,YAAc,IACvC,MAAM,EAGR,IAAiB,GAAY,EAAE,CAAkB,EACjD,CACD,MAAO,GAAqB,CAC3B,OAAQ,EAAM,WAAd,CACE,IAAK,KACL,IAAK,KACC,EAAM,OAAO,QACf,OAAO,KAAK,EAAM,MAAM,OAAO,CAAC,QAAS,GAAQ,CAC/C,EAAS,EAAK,CACZ,KAAM,SACN,QAAS,EAAM,OAAO,SAAS,GAChC,CAAC,EACF,CAEJ,EAAS,mBAAoB,CAC3B,KAAM,SACN,QAAS,GAAO,SAAW,uBAC5B,CAAC,CACF,MAEF,QACE,GAAI,EAAc,SAAS,EAAM,WAAW,CAAE,CAC5C,IAAkB,CAChB,QAAS,EAAM,QACL,WACV,OAAQ,EAAM,WACf,CAAC,CACF,MAEF,MAAM,IAEV,EAMM,SACR,SAAU,EACP,IACH,WAAY,CACV,KAAM,GAAY,MAAQ,GAAM,CAChC,KAAM,GAAY,MAAQ,GAAU,CACrC,CAEA,WACQ,CAAA,CAIf,EAAK,YAAc,OACnB,EAAK,UAAY,EACjB,EAAK,SAAW,EAChB,EAAK,OAAS,EACd,EAAK,OAAS,EACd,EAAK,SAAW,EAChB,EAAK,SAAW,EAChB,EAAK,OAAS,EACd,EAAK,SAAW,EAChB,EAAK,aAAe,EACpB,EAAK,UAAY,EACjB,EAAK,kBAAoB,EACzB,EAAK,SAAW,EAChB,EAAK,cAAgB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DropzoneProps } from "../../controls/dropzone/Dropzone.mjs";
|
|
2
|
+
//#region src/components/forms/controls/FormDropzone.d.ts
|
|
3
|
+
type FormDropzoneProps = Omit<DropzoneProps, '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 { FormDropzoneProps };
|
|
12
|
+
//# sourceMappingURL=FormDropzone.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDropzone.d.mts","names":[],"sources":["../../../../src/components/forms/controls/FormDropzone.tsx"],"mappings":";;KAOY,iBAAA,GAAoB,IAAA,CAC9B,aAAA;EAGA,IAAA;EACA,KAAA;EACA,YAAA;EACA,GAAA;EACA,QAAA,IAAY,KAAA,EAAO,IAAA;AAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Dropzone as e}from"../../controls/dropzone/Dropzone.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.Dropzone`;export{r as FormDropzone};
|
|
2
|
+
//# sourceMappingURL=FormDropzone.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDropzone.mjs","names":[],"sources":["../../../../src/components/forms/controls/FormDropzone.tsx"],"sourcesContent":["import { Controller } from 'react-hook-form';\n\nimport {\n Dropzone,\n type DropzoneProps,\n} from '@/components/controls/dropzone/Dropzone';\n\nexport type FormDropzoneProps = Omit<\n DropzoneProps,\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 FormDropzone = ({\n $rule: _$rule,\n isSubmitting: _isSubmitting,\n name,\n onChange,\n ...props\n}: FormDropzoneProps) => {\n return (\n <Controller\n name={name}\n render={({ field: { onChange: fieldOnChange } }) => (\n <Dropzone\n {...props}\n autoSend={false}\n onChange={(files) => {\n fieldOnChange(files);\n onChange?.(files);\n }}\n />\n )}\n />\n );\n};\n\nFormDropzone.displayName = 'Form.Dropzone';\n"],"mappings":"qJAkBA,MAAa,GAAgB,CAC3B,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,EAAa,YAAc"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FileInputProps } from "../../controls/file-input/FileInput.mjs";
|
|
2
|
+
//#region src/components/forms/controls/FormFileInput.d.ts
|
|
3
|
+
type FormFileInputProps = Omit<FileInputProps, 'onChange'> & {
|
|
4
|
+
$rule?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
isSubmitting?: boolean;
|
|
7
|
+
name: string;
|
|
8
|
+
onChange?: (file: File | null) => void;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { FormFileInputProps };
|
|
12
|
+
//# sourceMappingURL=FormFileInput.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormFileInput.d.mts","names":[],"sources":["../../../../src/components/forms/controls/FormFileInput.tsx"],"mappings":";;KAOY,kBAAA,GAAqB,IAAA,CAAK,cAAA;EACpC,KAAA;EACA,KAAA;EACA,YAAA;EACA,IAAA;EACA,QAAA,IAAY,IAAA,EAAM,IAAA;AAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{FileInput as e}from"../../controls/file-input/FileInput.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,error:o,onChange:s,...c})=>t(n,{name:a,render:({field:{onChange:n,onBlur:r}})=>t(e,{name:a,error:o,onBlur:r,...c,onChange:e=>{n(e),s?.(e)}})});r.displayName=`Form.FileInput`;export{r as FormFileInput};
|
|
2
|
+
//# sourceMappingURL=FormFileInput.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormFileInput.mjs","names":[],"sources":["../../../../src/components/forms/controls/FormFileInput.tsx"],"sourcesContent":["import { Controller } from 'react-hook-form';\n\nimport {\n FileInput,\n type FileInputProps,\n} from '@/components/controls/file-input/FileInput';\n\nexport type FormFileInputProps = Omit<FileInputProps, 'onChange'> & {\n $rule?: string;\n error?: string;\n isSubmitting?: boolean;\n name: string;\n onChange?: (file: File | null) => void;\n};\n\nexport const FormFileInput = ({\n $rule: _$rule,\n isSubmitting: _isSubmitting,\n name,\n error,\n onChange,\n ...props\n}: FormFileInputProps) => {\n return (\n <Controller\n name={name}\n render={({ field: { onChange: fieldOnChange, onBlur } }) => (\n <FileInput\n name={name}\n error={error}\n onBlur={onBlur}\n {...props}\n onChange={(file) => {\n fieldOnChange(file);\n onChange?.(file);\n }}\n />\n )}\n />\n );\n};\n\nFormFileInput.displayName = 'Form.FileInput';\n"],"mappings":"yJAeA,MAAa,GAAiB,CAC5B,MAAO,EACP,aAAc,EACd,OACA,QACA,WACA,GAAG,KAGD,EAAC,EAAD,CACQ,OACN,QAAS,CAAE,MAAO,CAAE,SAAU,EAAe,aAC3C,EAAC,EAAD,CACQ,OACC,QACC,SACR,GAAI,EACJ,SAAW,GAAS,CAClB,EAAc,EAAK,CACnB,IAAW,EAAK,EAElB,CAAA,CAEJ,CAAA,CAIN,EAAc,YAAc"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FileInputMultipleProps } from "../../controls/file-input/FileInputMultiple.mjs";
|
|
2
|
+
//#region src/components/forms/controls/FormFileInputMultiple.d.ts
|
|
3
|
+
type FormFileInputMultipleProps = Omit<FileInputMultipleProps, 'onChange'> & {
|
|
4
|
+
$rule?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
isSubmitting?: boolean;
|
|
7
|
+
name: string;
|
|
8
|
+
onChange?: (files: File[] | null) => void;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { FormFileInputMultipleProps };
|
|
12
|
+
//# sourceMappingURL=FormFileInputMultiple.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormFileInputMultiple.d.mts","names":[],"sources":["../../../../src/components/forms/controls/FormFileInputMultiple.tsx"],"mappings":";;KAOY,0BAAA,GAA6B,IAAA,CACvC,sBAAA;EAGA,KAAA;EACA,KAAA;EACA,YAAA;EACA,IAAA;EACA,QAAA,IAAY,KAAA,EAAO,IAAA;AAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{FileInputMultiple as e}from"../../controls/file-input/FileInputMultiple.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,error:o,onChange:s,...c})=>t(n,{name:a,render:({field:{onChange:n,onBlur:r}})=>t(e,{name:a,error:o,onBlur:r,...c,onChange:e=>{n(e),s?.(e)}})});r.displayName=`Form.FileInputMultiple`;export{r as FormFileInputMultiple};
|
|
2
|
+
//# sourceMappingURL=FormFileInputMultiple.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormFileInputMultiple.mjs","names":[],"sources":["../../../../src/components/forms/controls/FormFileInputMultiple.tsx"],"sourcesContent":["import { Controller } from 'react-hook-form';\n\nimport {\n FileInputMultiple,\n type FileInputMultipleProps,\n} from '@/components/controls/file-input/FileInputMultiple';\n\nexport type FormFileInputMultipleProps = Omit<\n FileInputMultipleProps,\n 'onChange'\n> & {\n $rule?: string;\n error?: string;\n isSubmitting?: boolean;\n name: string;\n onChange?: (files: File[] | null) => void;\n};\n\nexport const FormFileInputMultiple = ({\n $rule: _$rule,\n isSubmitting: _isSubmitting,\n name,\n error,\n onChange,\n ...props\n}: FormFileInputMultipleProps) => {\n return (\n <Controller\n name={name}\n render={({ field: { onChange: fieldOnChange, onBlur } }) => (\n <FileInputMultiple\n name={name}\n error={error}\n onBlur={onBlur}\n {...props}\n onChange={(files) => {\n fieldOnChange(files);\n onChange?.(files);\n }}\n />\n )}\n />\n );\n};\n\nFormFileInputMultiple.displayName = 'Form.FileInputMultiple';\n"],"mappings":"yKAkBA,MAAa,GAAyB,CACpC,MAAO,EACP,aAAc,EACd,OACA,QACA,WACA,GAAG,KAGD,EAAC,EAAD,CACQ,OACN,QAAS,CAAE,MAAO,CAAE,SAAU,EAAe,aAC3C,EAAC,EAAD,CACQ,OACC,QACC,SACR,GAAI,EACJ,SAAW,GAAU,CACnB,EAAc,EAAM,CACpB,IAAW,EAAM,EAEnB,CAAA,CAEJ,CAAA,CAIN,EAAsB,YAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{FormAutocomplete as e}from"./FormAutocomplete.mjs";import{FormCheckbox as t}from"./FormCheckbox.mjs";import{FormCombobox as n}from"./FormCombobox.mjs";import{
|
|
1
|
+
import{FormAutocomplete as e}from"./FormAutocomplete.mjs";import{FormCheckbox as t}from"./FormCheckbox.mjs";import{FormCombobox as n}from"./FormCombobox.mjs";import{FormDropzone as r}from"./FormDropzone.mjs";import{FormDropzoneFiles as i}from"./FormDropzoneFiles.mjs";import{FormFileInput as a}from"./FormFileInput.mjs";import{FormFileInputMultiple as o}from"./FormFileInputMultiple.mjs";import{FormHidden as s}from"./FormHidden.mjs";import{FormPassword as c}from"./FormPassword.mjs";import{FormSelect as l}from"./FormSelect.mjs";import{FormSubmit as u}from"./FormSubmit.mjs";import{FormTextarea as d}from"./FormTextarea.mjs";import{FormTextInput as f}from"./FormTextInput.mjs";const p=[u,f,d,c,s,t,l,n,e,a,o,r,i];export{p as controls};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/forms/controls/index.ts"],"sourcesContent":["import { FormAutocomplete } from './FormAutocomplete';\nimport { FormCheckbox } from './FormCheckbox';\nimport { FormCombobox } from './FormCombobox';\nimport { FormHidden } from './FormHidden';\nimport { FormPassword } from './FormPassword';\nimport { FormSelect } from './FormSelect';\nimport { FormSubmit } from './FormSubmit';\nimport { FormTextarea } from './FormTextarea';\nimport { FormTextInput } from './FormTextInput';\n\nexport const controls = [\n FormSubmit,\n FormTextInput,\n FormTextarea,\n FormPassword,\n FormHidden,\n FormCheckbox,\n FormSelect,\n FormCombobox,\n FormAutocomplete,\n] as React.ComponentType[];\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/forms/controls/index.ts"],"sourcesContent":["import { FormAutocomplete } from './FormAutocomplete';\nimport { FormCheckbox } from './FormCheckbox';\nimport { FormCombobox } from './FormCombobox';\nimport { FormDropzone } from './FormDropzone';\nimport { FormDropzoneFiles } from './FormDropzoneFiles';\nimport { FormFileInput } from './FormFileInput';\nimport { FormFileInputMultiple } from './FormFileInputMultiple';\nimport { FormHidden } from './FormHidden';\nimport { FormPassword } from './FormPassword';\nimport { FormSelect } from './FormSelect';\nimport { FormSubmit } from './FormSubmit';\nimport { FormTextarea } from './FormTextarea';\nimport { FormTextInput } from './FormTextInput';\n\nexport const controls = [\n FormSubmit,\n FormTextInput,\n FormTextarea,\n FormPassword,\n FormHidden,\n FormCheckbox,\n FormSelect,\n FormCombobox,\n FormAutocomplete,\n FormFileInput,\n FormFileInputMultiple,\n FormDropzone,\n FormDropzoneFiles,\n] as React.ComponentType[];\n"],"mappings":"sqBAcA,MAAa,EAAW,CACtB,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Fragment as e,jsx as t}from"react/jsx-runtime";import{Children as n,cloneElement as r,isValidElement as i}from"react";const a=new Set([`Form.Password`,`Form.Checkbox`,`Form.Select`,`Form.Combobox`,`Form.Autocomplete`,`Form.Hidden`]),o=(e,t,n)=>{if(e)try{let r=JSON.parse(e),i={...r.bindings,attribute:t},a=n?n(r.key,i,r.fallback):r.fallback;return String(a).replace(/{attribute}/g,t)}catch{return e.replace(/{attribute}/g,t)}},s=({children:s,register:c,componentTypes:l,errors:u={},t:d})=>{let f=e=>n.map(e,e=>{if(!i(e))return e;let t=e.props;if(l.some(t=>e.type===t)){let n=t.name,i=u[n??``]?.message?.toString(),s=n?o(i,n,d):void 0,l=e.type.displayName;return r(e,{...n!==void 0&&!a.has(l??``)&&n?c(n):{},error:s})}return t.children?r(e,{children:f(t.children)}):e});return t(e,{children:f(s)})};export{s as RegisteredFormChildren};
|
|
1
|
+
"use client";import{Fragment as e,jsx as t}from"react/jsx-runtime";import{Children as n,cloneElement as r,isValidElement as i}from"react";const a=new Set([`Form.Password`,`Form.Checkbox`,`Form.Select`,`Form.Combobox`,`Form.Autocomplete`,`Form.Hidden`,`Form.FileInput`,`Form.FileInputMultiple`,`Form.Dropzone`,`Form.DropzoneFiles`]),o=(e,t,n)=>{if(e)try{let r=JSON.parse(e),i={...r.bindings,attribute:t},a=n?n(r.key,i,r.fallback):r.fallback;return String(a).replace(/{attribute}/g,t)}catch{return e.replace(/{attribute}/g,t)}},s=({children:s,register:c,componentTypes:l,errors:u={},t:d})=>{let f=e=>n.map(e,e=>{if(!i(e))return e;let t=e.props;if(l.some(t=>e.type===t)){let n=t.name,i=u[n??``]?.message?.toString(),s=n?o(i,n,d):void 0,l=e.type.displayName;return r(e,{...n!==void 0&&!a.has(l??``)&&n?c(n):{},error:s})}return t.children?r(e,{children:f(t.children)}):e});return t(e,{children:f(s)})};export{s as RegisteredFormChildren};
|
|
2
2
|
//# sourceMappingURL=register-components.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-components.mjs","names":[],"sources":["../../../../src/components/forms/controls/register-components.tsx"],"sourcesContent":["'use client';\n\nimport type React from 'react';\nimport { Children, cloneElement, isValidElement } from 'react';\nimport type { FieldErrors, UseFormRegister } from 'react-hook-form';\n\ninterface TranslationMessage {\n key: string;\n bindings: Record<string, string>;\n fallback: string;\n}\n\nconst controllerDisplayNames = new Set([\n 'Form.Password',\n 'Form.Checkbox',\n 'Form.Select',\n 'Form.Combobox',\n 'Form.Autocomplete',\n 'Form.Hidden',\n]);\n\nconst parseAndTranslate = (\n message: string | undefined,\n fieldName: string,\n t?: (\n key: string,\n bindings?: Record<string, string>,\n fallback?: string,\n ) => string | React.ReactNode,\n): string | undefined => {\n if (!message) return undefined;\n\n try {\n const parsed: TranslationMessage = JSON.parse(message);\n const bindings = { ...parsed.bindings, attribute: fieldName };\n const result = t\n ? t(parsed.key, bindings, parsed.fallback)\n : parsed.fallback;\n return String(result).replace(/{attribute}/g, fieldName);\n } catch {\n return message.replace(/{attribute}/g, fieldName);\n }\n};\n\ninterface RegisteredFormChildrenProps {\n children: React.ReactNode;\n register: UseFormRegister<Record<string, unknown>>;\n componentTypes: React.ComponentType[];\n errors?: FieldErrors<Record<string, unknown>>;\n t?: (\n key: string,\n bindings?: Record<string, string>,\n fallback?: string,\n ) => string | React.ReactNode;\n}\n\nexport const RegisteredFormChildren = ({\n children,\n register,\n componentTypes,\n errors = {},\n t,\n}: RegisteredFormChildrenProps): React.ReactNode => {\n const processChildren = (nodes: React.ReactNode): React.ReactNode => {\n return Children.map(nodes, (child) => {\n if (!isValidElement(child)) {\n return child;\n }\n\n const childProps = child.props as {\n name?: string;\n children?: React.ReactNode;\n };\n\n if (\n componentTypes.some((type: React.ComponentType) => child.type === type)\n ) {\n const fieldName = childProps.name;\n const errorMessage = errors[fieldName ?? '']?.message?.toString();\n const translatedError = fieldName\n ? parseAndTranslate(errorMessage, fieldName, t)\n : undefined;\n const displayName = (\n child.type as React.ComponentType & { displayName?: string }\n ).displayName;\n const shouldRegister =\n fieldName !== undefined &&\n !controllerDisplayNames.has(displayName ?? '');\n const registrationProps =\n shouldRegister && fieldName ? register(fieldName) : {};\n\n return cloneElement(child, {\n ...registrationProps,\n error: translatedError,\n } as Partial<typeof child.props>);\n }\n\n if (childProps.children) {\n return cloneElement(child, {\n children: processChildren(childProps.children),\n } as Partial<typeof child.props>);\n }\n\n return child;\n });\n };\n\n return <>{processChildren(children)}</>;\n};\n"],"mappings":"0IAYA,MAAM,EAAyB,IAAI,IAAI,CACrC,gBACA,gBACA,cACA,gBACA,oBACA,
|
|
1
|
+
{"version":3,"file":"register-components.mjs","names":[],"sources":["../../../../src/components/forms/controls/register-components.tsx"],"sourcesContent":["'use client';\n\nimport type React from 'react';\nimport { Children, cloneElement, isValidElement } from 'react';\nimport type { FieldErrors, UseFormRegister } from 'react-hook-form';\n\ninterface TranslationMessage {\n key: string;\n bindings: Record<string, string>;\n fallback: string;\n}\n\nconst controllerDisplayNames = new Set([\n 'Form.Password',\n 'Form.Checkbox',\n 'Form.Select',\n 'Form.Combobox',\n 'Form.Autocomplete',\n 'Form.Hidden',\n 'Form.FileInput',\n 'Form.FileInputMultiple',\n 'Form.Dropzone',\n 'Form.DropzoneFiles',\n]);\n\nconst parseAndTranslate = (\n message: string | undefined,\n fieldName: string,\n t?: (\n key: string,\n bindings?: Record<string, string>,\n fallback?: string,\n ) => string | React.ReactNode,\n): string | undefined => {\n if (!message) return undefined;\n\n try {\n const parsed: TranslationMessage = JSON.parse(message);\n const bindings = { ...parsed.bindings, attribute: fieldName };\n const result = t\n ? t(parsed.key, bindings, parsed.fallback)\n : parsed.fallback;\n return String(result).replace(/{attribute}/g, fieldName);\n } catch {\n return message.replace(/{attribute}/g, fieldName);\n }\n};\n\ninterface RegisteredFormChildrenProps {\n children: React.ReactNode;\n register: UseFormRegister<Record<string, unknown>>;\n componentTypes: React.ComponentType[];\n errors?: FieldErrors<Record<string, unknown>>;\n t?: (\n key: string,\n bindings?: Record<string, string>,\n fallback?: string,\n ) => string | React.ReactNode;\n}\n\nexport const RegisteredFormChildren = ({\n children,\n register,\n componentTypes,\n errors = {},\n t,\n}: RegisteredFormChildrenProps): React.ReactNode => {\n const processChildren = (nodes: React.ReactNode): React.ReactNode => {\n return Children.map(nodes, (child) => {\n if (!isValidElement(child)) {\n return child;\n }\n\n const childProps = child.props as {\n name?: string;\n children?: React.ReactNode;\n };\n\n if (\n componentTypes.some((type: React.ComponentType) => child.type === type)\n ) {\n const fieldName = childProps.name;\n const errorMessage = errors[fieldName ?? '']?.message?.toString();\n const translatedError = fieldName\n ? parseAndTranslate(errorMessage, fieldName, t)\n : undefined;\n const displayName = (\n child.type as React.ComponentType & { displayName?: string }\n ).displayName;\n const shouldRegister =\n fieldName !== undefined &&\n !controllerDisplayNames.has(displayName ?? '');\n const registrationProps =\n shouldRegister && fieldName ? register(fieldName) : {};\n\n return cloneElement(child, {\n ...registrationProps,\n error: translatedError,\n } as Partial<typeof child.props>);\n }\n\n if (childProps.children) {\n return cloneElement(child, {\n children: processChildren(childProps.children),\n } as Partial<typeof child.props>);\n }\n\n return child;\n });\n };\n\n return <>{processChildren(children)}</>;\n};\n"],"mappings":"0IAYA,MAAM,EAAyB,IAAI,IAAI,CACrC,gBACA,gBACA,cACA,gBACA,oBACA,cACA,iBACA,yBACA,gBACA,qBACD,CAAC,CAEI,GACJ,EACA,EACA,IAKuB,CAClB,KAEL,GAAI,CACF,IAAM,EAA6B,KAAK,MAAM,EAAQ,CAChD,EAAW,CAAE,GAAG,EAAO,SAAU,UAAW,EAAW,CACvD,EAAS,EACX,EAAE,EAAO,IAAK,EAAU,EAAO,SAAS,CACxC,EAAO,SACX,OAAO,OAAO,EAAO,CAAC,QAAQ,eAAgB,EAAU,MAClD,CACN,OAAO,EAAQ,QAAQ,eAAgB,EAAU,GAgBxC,GAA0B,CACrC,WACA,WACA,iBACA,SAAS,EAAE,CACX,OACkD,CAClD,IAAM,EAAmB,GAChB,EAAS,IAAI,EAAQ,GAAU,CACpC,GAAI,CAAC,EAAe,EAAM,CACxB,OAAO,EAGT,IAAM,EAAa,EAAM,MAKzB,GACE,EAAe,KAAM,GAA8B,EAAM,OAAS,EAAK,CACvE,CACA,IAAM,EAAY,EAAW,KACvB,EAAe,EAAO,GAAa,KAAK,SAAS,UAAU,CAC3D,EAAkB,EACpB,EAAkB,EAAc,EAAW,EAAE,CAC7C,IAAA,GACE,EACJ,EAAM,KACN,YAOF,OAAO,EAAa,EAAO,CACzB,GANA,IAAc,IAAA,IACd,CAAC,EAAuB,IAAI,GAAe,GAAG,EAE5B,EAAY,EAAS,EAAU,CAAG,EAAE,CAItD,MAAO,EACR,CAAgC,CASnC,OANI,EAAW,SACN,EAAa,EAAO,CACzB,SAAU,EAAgB,EAAW,SAAS,CAC/C,CAAgC,CAG5B,GACP,CAGJ,OAAO,EAAA,EAAA,CAAA,SAAG,EAAgB,EAAS,CAAI,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{findFormComponents as e}from"../controls/find-form-components.mjs";import{PASSWORD_RULES as t}from"./password-rules.mjs";import n from"./password.mjs";import{parseRules as r}from"./zod.mjs";import{z as i}from"zod";const a=(e,t)=>{if(!e.name||!e.$rule?.includes(`confirmed`))return;let n=e.$rule.split(`|`).find(e=>e.startsWith(`confirmed`)),r=n?.includes(`:`)?n.split(`:`)[1]:`${e.name}_confirmation`;t.confirmedFields.push({field:e.name,target:r})},o=(e,t)=>{e.name&&(e.$rule?.includes(`required`)?(t.rules[e.name]=i.boolean().optional().or(i.literal(!1)),t.requiredBooleanFields.push(e.name)):t.rules[e.name]=i.boolean().optional())},s=(e,a)=>{if(!e.name)return;let o=i.string(),s=e.$rule?e.$rule.split(`|`).filter(e=>e.trim()!==`password`).join(`|`):``;s&&(o=r(s));let c=e.rules||(e.$rule?.includes(`password`)?t:[]);c.length>0&&(o=n(o,c));let l=!e.$rule||e.$rule.includes(`optional`)||s.includes(`optional`);a.rules[e.name]=l?o.optional():o},c=(e,t)=>{e.name&&(t.rules[e.name]=e.$rule?r(e.$rule):i.string().optional())},l=(e,t)=>{e.name&&(t.rules[e.name]=i.any().optional())},u=(e,t)=>t.confirmedFields.length===0&&t.requiredBooleanFields.length===0?e:e.superRefine((e,n)=>{t.confirmedFields.forEach(({field:t,target:r})=>{e[t]!==e[r]&&n.addIssue({code:i.ZodIssueCode.custom,message:JSON.stringify({key:`confirmed`,fallback:`La confirmación no coincide.`,bindings:{}}),path:[r]})}),t.requiredBooleanFields.forEach(t=>{e[t]!==!0&&n.addIssue({code:i.ZodIssueCode.custom,message:JSON.stringify({key:`required`,fallback:`El campo {attribute} es obligatorio.`,bindings:{}}),path:[t]})})}),
|
|
1
|
+
import{findFormComponents as e}from"../controls/find-form-components.mjs";import{PASSWORD_RULES as t}from"./password-rules.mjs";import n from"./password.mjs";import{parseRules as r}from"./zod.mjs";import{z as i}from"zod";const a=(e,t)=>{if(!e.name||!e.$rule?.includes(`confirmed`))return;let n=e.$rule.split(`|`).find(e=>e.startsWith(`confirmed`)),r=n?.includes(`:`)?n.split(`:`)[1]:`${e.name}_confirmation`;t.confirmedFields.push({field:e.name,target:r})},o=(e,t)=>{e.name&&(e.$rule?.includes(`required`)?(t.rules[e.name]=i.boolean().optional().or(i.literal(!1)),t.requiredBooleanFields.push(e.name)):t.rules[e.name]=i.boolean().optional())},s=(e,a)=>{if(!e.name)return;let o=i.string(),s=e.$rule?e.$rule.split(`|`).filter(e=>e.trim()!==`password`).join(`|`):``;s&&(o=r(s));let c=e.rules||(e.$rule?.includes(`password`)?t:[]);c.length>0&&(o=n(o,c));let l=!e.$rule||e.$rule.includes(`optional`)||s.includes(`optional`);a.rules[e.name]=l?o.optional():o},c=(e,t)=>{e.name&&(t.rules[e.name]=e.$rule?r(e.$rule):i.string().optional())},l=(e,t)=>{e.name&&(t.rules[e.name]=i.any().optional())},u=JSON.stringify({key:`required`,fallback:`El campo {attribute} es obligatorio.`,bindings:{}}),d=(e,t,n)=>{e.name&&(e.$rule?.includes(`required`)?t.rules[e.name]=n?i.any().refine(e=>Array.isArray(e)&&e.length>0,{message:u}):i.any().refine(e=>e instanceof File,{message:u}):t.rules[e.name]=i.any().optional())},f=(e,t)=>t.confirmedFields.length===0&&t.requiredBooleanFields.length===0?e:e.superRefine((e,n)=>{t.confirmedFields.forEach(({field:t,target:r})=>{e[t]!==e[r]&&n.addIssue({code:i.ZodIssueCode.custom,message:JSON.stringify({key:`confirmed`,fallback:`La confirmación no coincide.`,bindings:{}}),path:[r]})}),t.requiredBooleanFields.forEach(t=>{e[t]!==!0&&n.addIssue({code:i.ZodIssueCode.custom,message:JSON.stringify({key:`required`,fallback:`El campo {attribute} es obligatorio.`,bindings:{}}),path:[t]})})}),p=(t,n)=>{let r={rules:{},confirmedFields:[],requiredBooleanFields:[]};return e(t,n).forEach(e=>{let t=e.props,n=e.type.displayName;t.name&&(a(t,r),n===`Form.Checkbox`?o(t,r):n===`Form.Password`?s(t,r):n===`Form.Select`||n===`Form.Combobox`||n===`Form.Autocomplete`?l(t,r):n===`Form.FileInput`?d(t,r,!1):n===`Form.FileInputMultiple`||n===`Form.Dropzone`||n===`Form.DropzoneFiles`?d(t,r,!0):c(t,r))}),f(i.object(r.rules).loose(),r)};export{p as extractFormRules};
|
|
2
2
|
//# sourceMappingURL=extract-form-rules.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-form-rules.mjs","names":["passwordRule"],"sources":["../../../../src/components/forms/rules/extract-form-rules.ts"],"sourcesContent":["import type React from 'react';\nimport type { FieldValues } from 'react-hook-form';\nimport { type ZodTypeAny, z } from 'zod';\n\nimport type { PasswordRuleDefinition } from '@/components/controls/password-input/usePasswordRules';\n\nimport { findFormComponents } from '../controls/find-form-components';\nimport passwordRule from './password';\nimport { PASSWORD_RULES } from './password-rules';\nimport { parseRules } from './zod';\n\ntype FormRuleContext = {\n rules: Record<string, ZodTypeAny>;\n confirmedFields: { field: string; target: string }[];\n requiredBooleanFields: string[];\n};\n\ntype ComponentProps = {\n name?: string;\n $rule?: string;\n rules?: PasswordRuleDefinition[];\n};\n\nconst processConfirmedRule = (\n props: ComponentProps,\n context: FormRuleContext,\n) => {\n if (!props.name || !props.$rule?.includes('confirmed')) return;\n\n const rulesList = props.$rule.split('|');\n const confirmedRule = rulesList.find((r) => r.startsWith('confirmed'));\n const target = confirmedRule?.includes(':')\n ? confirmedRule.split(':')[1]\n : `${props.name}_confirmation`;\n\n context.confirmedFields.push({ field: props.name, target });\n};\n\nconst processCheckbox = (props: ComponentProps, context: FormRuleContext) => {\n if (!props.name) return;\n\n if (props.$rule?.includes('required')) {\n context.rules[props.name] = z.boolean().optional().or(z.literal(false));\n context.requiredBooleanFields.push(props.name);\n } else {\n context.rules[props.name] = z.boolean().optional();\n }\n};\n\nconst processPassword = (props: ComponentProps, context: FormRuleContext) => {\n if (!props.name) return;\n\n let baseSchema: ZodTypeAny = z.string();\n const otherRules = props.$rule\n ? props.$rule\n .split('|')\n .filter((r) => r.trim() !== 'password')\n .join('|')\n : '';\n\n if (otherRules) {\n baseSchema = parseRules(otherRules);\n }\n\n const passwordRules =\n props.rules || (props.$rule?.includes('password') ? PASSWORD_RULES : []);\n\n if (passwordRules.length > 0) {\n baseSchema = passwordRule(baseSchema, passwordRules);\n }\n\n const isOptional =\n !props.$rule ||\n props.$rule.includes('optional') ||\n otherRules.includes('optional');\n\n context.rules[props.name] = isOptional ? baseSchema.optional() : baseSchema;\n};\n\nconst processDefault = (props: ComponentProps, context: FormRuleContext) => {\n if (!props.name) return;\n context.rules[props.name] = props.$rule\n ? parseRules(props.$rule)\n : z.string().optional();\n};\n\nconst processDropdown = (props: ComponentProps, context: FormRuleContext) => {\n if (!props.name) return;\n context.rules[props.name] = z.any().optional();\n};\n\nconst applyRefinements = (\n schema: z.ZodObject<FieldValues>,\n context: FormRuleContext,\n) => {\n if (\n context.confirmedFields.length === 0 &&\n context.requiredBooleanFields.length === 0\n ) {\n return schema;\n }\n\n return schema.superRefine((data, ctx) => {\n context.confirmedFields.forEach(({ field, target }) => {\n if (data[field] !== data[target]) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: JSON.stringify({\n key: 'confirmed',\n fallback: 'La confirmación no coincide.',\n bindings: {},\n }),\n path: [target],\n });\n }\n });\n\n context.requiredBooleanFields.forEach((field) => {\n if (data[field] !== true) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: JSON.stringify({\n key: 'required',\n fallback: 'El campo {attribute} es obligatorio.',\n bindings: {},\n }),\n path: [field],\n });\n }\n });\n });\n};\n\nexport const extractFormRules = (\n children: React.ReactNode,\n componentTypes: React.ComponentType[],\n): ZodTypeAny => {\n const context: FormRuleContext = {\n rules: {},\n confirmedFields: [],\n requiredBooleanFields: [],\n };\n\n const components = findFormComponents(children, componentTypes);\n\n components.forEach((component) => {\n const props = component.props as ComponentProps;\n const displayName = (component.type as { displayName?: string })\n .displayName;\n\n if (props.name) {\n processConfirmedRule(props, context);\n\n if (displayName === 'Form.Checkbox') {\n processCheckbox(props, context);\n } else if (displayName === 'Form.Password') {\n processPassword(props, context);\n } else if (\n displayName === 'Form.Select' ||\n displayName === 'Form.Combobox' ||\n displayName === 'Form.Autocomplete'\n ) {\n processDropdown(props, context);\n } else {\n processDefault(props, context);\n }\n }\n });\n\n return applyRefinements(z.object(context.rules).loose(), context);\n};\n"],"mappings":"6NAuBA,MAAM,GACJ,EACA,IACG,CACH,GAAI,CAAC,EAAM,MAAQ,CAAC,EAAM,OAAO,SAAS,YAAY,CAAE,OAGxD,IAAM,EADY,EAAM,MAAM,MAAM,IAAI,CACR,KAAM,GAAM,EAAE,WAAW,YAAY,CAAC,CAChE,EAAS,GAAe,SAAS,IAAI,CACvC,EAAc,MAAM,IAAI,CAAC,GACzB,GAAG,EAAM,KAAK,eAElB,EAAQ,gBAAgB,KAAK,CAAE,MAAO,EAAM,KAAM,SAAQ,CAAC,EAGvD,GAAmB,EAAuB,IAA6B,CACtE,EAAM,OAEP,EAAM,OAAO,SAAS,WAAW,EACnC,EAAQ,MAAM,EAAM,MAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAM,CAAC,CACvE,EAAQ,sBAAsB,KAAK,EAAM,KAAK,EAE9C,EAAQ,MAAM,EAAM,MAAQ,EAAE,SAAS,CAAC,UAAU,GAIhD,GAAmB,EAAuB,IAA6B,CAC3E,GAAI,CAAC,EAAM,KAAM,OAEjB,IAAI,EAAyB,EAAE,QAAQ,CACjC,EAAa,EAAM,MACrB,EAAM,MACH,MAAM,IAAI,CACV,OAAQ,GAAM,EAAE,MAAM,GAAK,WAAW,CACtC,KAAK,IAAI,CACZ,GAEA,IACF,EAAa,EAAW,EAAW,EAGrC,IAAM,EACJ,EAAM,QAAU,EAAM,OAAO,SAAS,WAAW,CAAG,EAAiB,EAAE,EAErE,EAAc,OAAS,IACzB,EAAaA,EAAa,EAAY,EAAc,EAGtD,IAAM,EACJ,CAAC,EAAM,OACP,EAAM,MAAM,SAAS,WAAW,EAChC,EAAW,SAAS,WAAW,CAEjC,EAAQ,MAAM,EAAM,MAAQ,EAAa,EAAW,UAAU,CAAG,GAG7D,GAAkB,EAAuB,IAA6B,CACrE,EAAM,OACX,EAAQ,MAAM,EAAM,MAAQ,EAAM,MAC9B,EAAW,EAAM,MAAM,CACvB,EAAE,QAAQ,CAAC,UAAU,GAGrB,GAAmB,EAAuB,IAA6B,CACtE,EAAM,OACX,EAAQ,MAAM,EAAM,MAAQ,EAAE,KAAK,CAAC,UAAU,GAG1C,GACJ,EACA,IAGE,EAAQ,gBAAgB,SAAW,GACnC,EAAQ,sBAAsB,SAAW,EAElC,EAGF,EAAO,aAAa,EAAM,IAAQ,CACvC,EAAQ,gBAAgB,SAAS,CAAE,QAAO,YAAa,CACjD,EAAK,KAAW,EAAK,IACvB,EAAI,SAAS,CACX,KAAM,EAAE,aAAa,OACrB,QAAS,KAAK,UAAU,CACtB,IAAK,YACL,SAAU,+BACV,SAAU,EAAE,CACb,CAAC,CACF,KAAM,CAAC,EAAO,CACf,CAAC,EAEJ,CAEF,EAAQ,sBAAsB,QAAS,GAAU,CAC3C,EAAK,KAAW,IAClB,EAAI,SAAS,CACX,KAAM,EAAE,aAAa,OACrB,QAAS,KAAK,UAAU,CACtB,IAAK,WACL,SAAU,uCACV,SAAU,EAAE,CACb,CAAC,CACF,KAAM,CAAC,EAAM,CACd,CAAC,EAEJ,EACF,CAGS,GACX,EACA,IACe,CACf,IAAM,EAA2B,CAC/B,MAAO,EAAE,CACT,gBAAiB,EAAE,CACnB,sBAAuB,EAAE,CAC1B,
|
|
1
|
+
{"version":3,"file":"extract-form-rules.mjs","names":["passwordRule"],"sources":["../../../../src/components/forms/rules/extract-form-rules.ts"],"sourcesContent":["import type React from 'react';\nimport type { FieldValues } from 'react-hook-form';\nimport { type ZodTypeAny, z } from 'zod';\n\nimport type { PasswordRuleDefinition } from '@/components/controls/password-input/usePasswordRules';\n\nimport { findFormComponents } from '../controls/find-form-components';\nimport passwordRule from './password';\nimport { PASSWORD_RULES } from './password-rules';\nimport { parseRules } from './zod';\n\ntype FormRuleContext = {\n rules: Record<string, ZodTypeAny>;\n confirmedFields: { field: string; target: string }[];\n requiredBooleanFields: string[];\n};\n\ntype ComponentProps = {\n name?: string;\n $rule?: string;\n rules?: PasswordRuleDefinition[];\n};\n\nconst processConfirmedRule = (\n props: ComponentProps,\n context: FormRuleContext,\n) => {\n if (!props.name || !props.$rule?.includes('confirmed')) return;\n\n const rulesList = props.$rule.split('|');\n const confirmedRule = rulesList.find((r) => r.startsWith('confirmed'));\n const target = confirmedRule?.includes(':')\n ? confirmedRule.split(':')[1]\n : `${props.name}_confirmation`;\n\n context.confirmedFields.push({ field: props.name, target });\n};\n\nconst processCheckbox = (props: ComponentProps, context: FormRuleContext) => {\n if (!props.name) return;\n\n if (props.$rule?.includes('required')) {\n context.rules[props.name] = z.boolean().optional().or(z.literal(false));\n context.requiredBooleanFields.push(props.name);\n } else {\n context.rules[props.name] = z.boolean().optional();\n }\n};\n\nconst processPassword = (props: ComponentProps, context: FormRuleContext) => {\n if (!props.name) return;\n\n let baseSchema: ZodTypeAny = z.string();\n const otherRules = props.$rule\n ? props.$rule\n .split('|')\n .filter((r) => r.trim() !== 'password')\n .join('|')\n : '';\n\n if (otherRules) {\n baseSchema = parseRules(otherRules);\n }\n\n const passwordRules =\n props.rules || (props.$rule?.includes('password') ? PASSWORD_RULES : []);\n\n if (passwordRules.length > 0) {\n baseSchema = passwordRule(baseSchema, passwordRules);\n }\n\n const isOptional =\n !props.$rule ||\n props.$rule.includes('optional') ||\n otherRules.includes('optional');\n\n context.rules[props.name] = isOptional ? baseSchema.optional() : baseSchema;\n};\n\nconst processDefault = (props: ComponentProps, context: FormRuleContext) => {\n if (!props.name) return;\n context.rules[props.name] = props.$rule\n ? parseRules(props.$rule)\n : z.string().optional();\n};\n\nconst processDropdown = (props: ComponentProps, context: FormRuleContext) => {\n if (!props.name) return;\n context.rules[props.name] = z.any().optional();\n};\n\nconst requiredMessage = JSON.stringify({\n key: 'required',\n fallback: 'El campo {attribute} es obligatorio.',\n bindings: {},\n});\n\nconst processFileInput = (\n props: ComponentProps,\n context: FormRuleContext,\n multiple: boolean,\n) => {\n if (!props.name) return;\n\n if (props.$rule?.includes('required')) {\n context.rules[props.name] = multiple\n ? z.any().refine((val) => Array.isArray(val) && val.length > 0, {\n message: requiredMessage,\n })\n : z\n .any()\n .refine((val) => val instanceof File, { message: requiredMessage });\n } else {\n context.rules[props.name] = z.any().optional();\n }\n};\n\nconst applyRefinements = (\n schema: z.ZodObject<FieldValues>,\n context: FormRuleContext,\n) => {\n if (\n context.confirmedFields.length === 0 &&\n context.requiredBooleanFields.length === 0\n ) {\n return schema;\n }\n\n return schema.superRefine((data, ctx) => {\n context.confirmedFields.forEach(({ field, target }) => {\n if (data[field] !== data[target]) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: JSON.stringify({\n key: 'confirmed',\n fallback: 'La confirmación no coincide.',\n bindings: {},\n }),\n path: [target],\n });\n }\n });\n\n context.requiredBooleanFields.forEach((field) => {\n if (data[field] !== true) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: JSON.stringify({\n key: 'required',\n fallback: 'El campo {attribute} es obligatorio.',\n bindings: {},\n }),\n path: [field],\n });\n }\n });\n });\n};\n\nexport const extractFormRules = (\n children: React.ReactNode,\n componentTypes: React.ComponentType[],\n): ZodTypeAny => {\n const context: FormRuleContext = {\n rules: {},\n confirmedFields: [],\n requiredBooleanFields: [],\n };\n\n const components = findFormComponents(children, componentTypes);\n\n components.forEach((component) => {\n const props = component.props as ComponentProps;\n const displayName = (component.type as { displayName?: string })\n .displayName;\n\n if (props.name) {\n processConfirmedRule(props, context);\n\n if (displayName === 'Form.Checkbox') {\n processCheckbox(props, context);\n } else if (displayName === 'Form.Password') {\n processPassword(props, context);\n } else if (\n displayName === 'Form.Select' ||\n displayName === 'Form.Combobox' ||\n displayName === 'Form.Autocomplete'\n ) {\n processDropdown(props, context);\n } else if (displayName === 'Form.FileInput') {\n processFileInput(props, context, false);\n } else if (\n displayName === 'Form.FileInputMultiple' ||\n displayName === 'Form.Dropzone' ||\n displayName === 'Form.DropzoneFiles'\n ) {\n processFileInput(props, context, true);\n } else {\n processDefault(props, context);\n }\n }\n });\n\n return applyRefinements(z.object(context.rules).loose(), context);\n};\n"],"mappings":"6NAuBA,MAAM,GACJ,EACA,IACG,CACH,GAAI,CAAC,EAAM,MAAQ,CAAC,EAAM,OAAO,SAAS,YAAY,CAAE,OAGxD,IAAM,EADY,EAAM,MAAM,MAAM,IAAI,CACR,KAAM,GAAM,EAAE,WAAW,YAAY,CAAC,CAChE,EAAS,GAAe,SAAS,IAAI,CACvC,EAAc,MAAM,IAAI,CAAC,GACzB,GAAG,EAAM,KAAK,eAElB,EAAQ,gBAAgB,KAAK,CAAE,MAAO,EAAM,KAAM,SAAQ,CAAC,EAGvD,GAAmB,EAAuB,IAA6B,CACtE,EAAM,OAEP,EAAM,OAAO,SAAS,WAAW,EACnC,EAAQ,MAAM,EAAM,MAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAM,CAAC,CACvE,EAAQ,sBAAsB,KAAK,EAAM,KAAK,EAE9C,EAAQ,MAAM,EAAM,MAAQ,EAAE,SAAS,CAAC,UAAU,GAIhD,GAAmB,EAAuB,IAA6B,CAC3E,GAAI,CAAC,EAAM,KAAM,OAEjB,IAAI,EAAyB,EAAE,QAAQ,CACjC,EAAa,EAAM,MACrB,EAAM,MACH,MAAM,IAAI,CACV,OAAQ,GAAM,EAAE,MAAM,GAAK,WAAW,CACtC,KAAK,IAAI,CACZ,GAEA,IACF,EAAa,EAAW,EAAW,EAGrC,IAAM,EACJ,EAAM,QAAU,EAAM,OAAO,SAAS,WAAW,CAAG,EAAiB,EAAE,EAErE,EAAc,OAAS,IACzB,EAAaA,EAAa,EAAY,EAAc,EAGtD,IAAM,EACJ,CAAC,EAAM,OACP,EAAM,MAAM,SAAS,WAAW,EAChC,EAAW,SAAS,WAAW,CAEjC,EAAQ,MAAM,EAAM,MAAQ,EAAa,EAAW,UAAU,CAAG,GAG7D,GAAkB,EAAuB,IAA6B,CACrE,EAAM,OACX,EAAQ,MAAM,EAAM,MAAQ,EAAM,MAC9B,EAAW,EAAM,MAAM,CACvB,EAAE,QAAQ,CAAC,UAAU,GAGrB,GAAmB,EAAuB,IAA6B,CACtE,EAAM,OACX,EAAQ,MAAM,EAAM,MAAQ,EAAE,KAAK,CAAC,UAAU,GAG1C,EAAkB,KAAK,UAAU,CACrC,IAAK,WACL,SAAU,uCACV,SAAU,EAAE,CACb,CAAC,CAEI,GACJ,EACA,EACA,IACG,CACE,EAAM,OAEP,EAAM,OAAO,SAAS,WAAW,CACnC,EAAQ,MAAM,EAAM,MAAQ,EACxB,EAAE,KAAK,CAAC,OAAQ,GAAQ,MAAM,QAAQ,EAAI,EAAI,EAAI,OAAS,EAAG,CAC5D,QAAS,EACV,CAAC,CACF,EACG,KAAK,CACL,OAAQ,GAAQ,aAAe,KAAM,CAAE,QAAS,EAAiB,CAAC,CAEzE,EAAQ,MAAM,EAAM,MAAQ,EAAE,KAAK,CAAC,UAAU,GAI5C,GACJ,EACA,IAGE,EAAQ,gBAAgB,SAAW,GACnC,EAAQ,sBAAsB,SAAW,EAElC,EAGF,EAAO,aAAa,EAAM,IAAQ,CACvC,EAAQ,gBAAgB,SAAS,CAAE,QAAO,YAAa,CACjD,EAAK,KAAW,EAAK,IACvB,EAAI,SAAS,CACX,KAAM,EAAE,aAAa,OACrB,QAAS,KAAK,UAAU,CACtB,IAAK,YACL,SAAU,+BACV,SAAU,EAAE,CACb,CAAC,CACF,KAAM,CAAC,EAAO,CACf,CAAC,EAEJ,CAEF,EAAQ,sBAAsB,QAAS,GAAU,CAC3C,EAAK,KAAW,IAClB,EAAI,SAAS,CACX,KAAM,EAAE,aAAa,OACrB,QAAS,KAAK,UAAU,CACtB,IAAK,WACL,SAAU,uCACV,SAAU,EAAE,CACb,CAAC,CACF,KAAM,CAAC,EAAM,CACd,CAAC,EAEJ,EACF,CAGS,GACX,EACA,IACe,CACf,IAAM,EAA2B,CAC/B,MAAO,EAAE,CACT,gBAAiB,EAAE,CACnB,sBAAuB,EAAE,CAC1B,CAoCD,OAlCmB,EAAmB,EAAU,EAAe,CAEpD,QAAS,GAAc,CAChC,IAAM,EAAQ,EAAU,MAClB,EAAe,EAAU,KAC5B,YAEC,EAAM,OACR,EAAqB,EAAO,EAAQ,CAEhC,IAAgB,gBAClB,EAAgB,EAAO,EAAQ,CACtB,IAAgB,gBACzB,EAAgB,EAAO,EAAQ,CAE/B,IAAgB,eAChB,IAAgB,iBAChB,IAAgB,oBAEhB,EAAgB,EAAO,EAAQ,CACtB,IAAgB,iBACzB,EAAiB,EAAO,EAAS,GAAM,CAEvC,IAAgB,0BAChB,IAAgB,iBAChB,IAAgB,qBAEhB,EAAiB,EAAO,EAAS,GAAK,CAEtC,EAAe,EAAO,EAAQ,GAGlC,CAEK,EAAiB,EAAE,OAAO,EAAQ,MAAM,CAAC,OAAO,CAAE,EAAQ"}
|
|
@@ -43,6 +43,7 @@ import { Tag, TagProps } from "./data-display/tag/Tag.mjs";
|
|
|
43
43
|
import { TagGroup, TagGroupProps } from "./data-display/tag-group/TagGroup.mjs";
|
|
44
44
|
import { UploadedFile, UploadedFileProps } from "./data-display/uploaded-file/UploadedFile.mjs";
|
|
45
45
|
import { UploadedFileDetails, UploadedFileDetailsProps } from "./data-display/uploaded-file/UploadedFileDetails.mjs";
|
|
46
|
+
import { UploadingFiles, UploadingFilesClassNames, UploadingFilesItemClassNames, UploadingFilesItemErrorClassNames, UploadingFilesItemErrorProps, UploadingFilesItemProps, UploadingFilesProps } from "./data-display/uploading-files/UploadingFiles.mjs";
|
|
46
47
|
import { AvatarDropzone, AvatarDropzoneProps } from "./controls/avatar-dropzone/AvatarDropzone.mjs";
|
|
47
48
|
import { AvatarUpload, AvatarUploadProps } from "./controls/avatar-upload/AvatarUpload.mjs";
|
|
48
49
|
import { Checkbox, CheckboxProps } from "./controls/checkbox/Checkbox.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -43,6 +43,7 @@ import { Tag, TagProps } from "./components/data-display/tag/Tag.mjs";
|
|
|
43
43
|
import { TagGroup, TagGroupProps } from "./components/data-display/tag-group/TagGroup.mjs";
|
|
44
44
|
import { UploadedFile, UploadedFileProps } from "./components/data-display/uploaded-file/UploadedFile.mjs";
|
|
45
45
|
import { UploadedFileDetails, UploadedFileDetailsProps } from "./components/data-display/uploaded-file/UploadedFileDetails.mjs";
|
|
46
|
+
import { UploadingFiles, UploadingFilesClassNames, UploadingFilesItemClassNames, UploadingFilesItemErrorClassNames, UploadingFilesItemErrorProps, UploadingFilesItemProps, UploadingFilesProps } from "./components/data-display/uploading-files/UploadingFiles.mjs";
|
|
46
47
|
import { AvatarDropzone, AvatarDropzoneProps } from "./components/controls/avatar-dropzone/AvatarDropzone.mjs";
|
|
47
48
|
import { AvatarUpload, AvatarUploadProps } from "./components/controls/avatar-upload/AvatarUpload.mjs";
|
|
48
49
|
import { Checkbox, CheckboxProps } from "./components/controls/checkbox/Checkbox.mjs";
|
|
@@ -84,4 +85,4 @@ import { Modals } from "./components/overlays/modal/index.mjs";
|
|
|
84
85
|
import { Toast, ToastIntent, ToastOptions, ToastProviderProps } from "./components/overlays/toast/Toast.mjs";
|
|
85
86
|
import { Tooltip, TooltipProps } from "./components/overlays/tooltip/Tooltip.mjs";
|
|
86
87
|
import { MageUiProvider, MageUiProviderProps } from "./providers/MageUiProvider.mjs";
|
|
87
|
-
export { AssignedUser, AssignedUserProps, Autocomplete, AutocompleteProps, Avatar, AvatarDropzone, AvatarDropzoneProps, AvatarProps, AvatarUpload, AvatarUploadProps, Badge, BadgeProps, Breadcrumbs, BreadcrumbsBarProps, BreadcrumbsProps, Button, ButtonAction, ButtonActionProps, ButtonIcon, ButtonIconProps, ButtonIconVisual, ButtonIconVisualProps, ButtonLoader, ButtonProps, ButtonVisual, ButtonVisualProps, Calendar, CalendarEvent, CalendarProps, CalendarView, Card, CardBase, CardBody, CardClassNames, CardFooter, CardHeader, CardProps, CardRoot, Checkbox, CheckboxProps, ColumnDef, Combobox, ComboboxProps, DEFAULT_DATA_TABLE_LABELS, DataTable, DataTableBottomSlot, DataTableBottomSlotProps, DataTableClassNames, DataTableColumnMeta, DataTableContextProvider, DataTableContextValue, DataTableErrorState, DataTableExpansionConfig, DataTableExtraColumnConfig, DataTableFiltersConfig, DataTableLabels, DataTablePageSize, DataTablePageSizeProps, DataTablePagination, DataTablePaginationConfig, DataTablePaginationProps, DataTableProps, DataTableRecord, DataTableSearchConfig, DataTableSelectionConfig, DataTableSortingConfig, DataTableTableConfig, DataTableTopSlot, DataTableTopSlotProps, DateLocalizer, DatePicker, DatePickerProps, DescriptionList, DescriptionListClassNames, DescriptionListItemProps, DescriptionListProps, Dropzone, DropzoneFiles, DropzoneFilesProps, DropzoneProps, ExpandedState, FileData, FileInput, FileInputMultiple, FileInputMultipleProps, FileInputProps, FluidGrid, FluidGridProps, Form, FormProps, Grid, GridClassNames, HorizontalDivider, HorizontalDividerProps, Icon, IconProps, IconRaw, IconRawProps, IconSvg, IconSvgProps, IconWrapped, IconWrappedProps, Indicator, IndicatorProps, LoaderDot, LoaderDotProps, LoaderOval, LoaderOvalProps, LogoImage, LogoImageProps, LogoSvg, LogoSvgProps, MageUiProvider, MageUiProviderProps, Menu, MenuProps, Modal, ModalClassNames, ModalIntent, ModalProps, ModalRegistry, ModalRegistryEntry, ModalRootProps, Modals, NavigationMenu, NavigationMenuProps, NotificationBanner, NotificationBannerIntent, NotificationBannerProps, PASSWORD_RULES, Pagination, PaginationClassNames, PaginationRootProps, PaginationState, PasswordInput, PasswordInputProps, PasswordRule, PasswordRuleDefinition, PasswordSegment, PasswordStrengthInput, PasswordStrengthInputProps, Radio, RadioProps, RemovableItem, RemovableItemProps, RowSelectionState, ScrollArea, ScrollAreaAutosize, ScrollAreaAutosizeProps, ScrollAreaClassNames, ScrollAreaProps, Select, SelectProps, Sidebar, SidebarClassNames, SidebarProps, SortingState, Switch, SwitchGroup, SwitchGroupProps, SwitchProps, Table, TableBodyProps, TableCaptionProps, TableCellProps, TableClassNames, TableFootProps, TableHeadProps, TableHeaderCellProps, TableProps, TableRowProps, Tag, TagGroup, TagGroupProps, TagProps, TextInput, TextInputProps, Textarea, TextareaProps, Toast, ToastIntent, ToastOptions, ToastProviderProps, Tooltip, TooltipProps, UploadedFile, UploadedFileDetails, UploadedFileDetailsProps, UploadedFileProps, Virtual, VirtualItem, VirtualPadding, VirtualProps, VisuallyHidden, VisuallyHiddenProps, useDataTableContext, usePasswordRules, z };
|
|
88
|
+
export { AssignedUser, AssignedUserProps, Autocomplete, AutocompleteProps, Avatar, AvatarDropzone, AvatarDropzoneProps, AvatarProps, AvatarUpload, AvatarUploadProps, Badge, BadgeProps, Breadcrumbs, BreadcrumbsBarProps, BreadcrumbsProps, Button, ButtonAction, ButtonActionProps, ButtonIcon, ButtonIconProps, ButtonIconVisual, ButtonIconVisualProps, ButtonLoader, ButtonProps, ButtonVisual, ButtonVisualProps, Calendar, CalendarEvent, CalendarProps, CalendarView, Card, CardBase, CardBody, CardClassNames, CardFooter, CardHeader, CardProps, CardRoot, Checkbox, CheckboxProps, ColumnDef, Combobox, ComboboxProps, DEFAULT_DATA_TABLE_LABELS, DataTable, DataTableBottomSlot, DataTableBottomSlotProps, DataTableClassNames, DataTableColumnMeta, DataTableContextProvider, DataTableContextValue, DataTableErrorState, DataTableExpansionConfig, DataTableExtraColumnConfig, DataTableFiltersConfig, DataTableLabels, DataTablePageSize, DataTablePageSizeProps, DataTablePagination, DataTablePaginationConfig, DataTablePaginationProps, DataTableProps, DataTableRecord, DataTableSearchConfig, DataTableSelectionConfig, DataTableSortingConfig, DataTableTableConfig, DataTableTopSlot, DataTableTopSlotProps, DateLocalizer, DatePicker, DatePickerProps, DescriptionList, DescriptionListClassNames, DescriptionListItemProps, DescriptionListProps, Dropzone, DropzoneFiles, DropzoneFilesProps, DropzoneProps, ExpandedState, FileData, FileInput, FileInputMultiple, FileInputMultipleProps, FileInputProps, FluidGrid, FluidGridProps, Form, FormProps, Grid, GridClassNames, HorizontalDivider, HorizontalDividerProps, Icon, IconProps, IconRaw, IconRawProps, IconSvg, IconSvgProps, IconWrapped, IconWrappedProps, Indicator, IndicatorProps, LoaderDot, LoaderDotProps, LoaderOval, LoaderOvalProps, LogoImage, LogoImageProps, LogoSvg, LogoSvgProps, MageUiProvider, MageUiProviderProps, Menu, MenuProps, Modal, ModalClassNames, ModalIntent, ModalProps, ModalRegistry, ModalRegistryEntry, ModalRootProps, Modals, NavigationMenu, NavigationMenuProps, NotificationBanner, NotificationBannerIntent, NotificationBannerProps, PASSWORD_RULES, Pagination, PaginationClassNames, PaginationRootProps, PaginationState, PasswordInput, PasswordInputProps, PasswordRule, PasswordRuleDefinition, PasswordSegment, PasswordStrengthInput, PasswordStrengthInputProps, Radio, RadioProps, RemovableItem, RemovableItemProps, RowSelectionState, ScrollArea, ScrollAreaAutosize, ScrollAreaAutosizeProps, ScrollAreaClassNames, ScrollAreaProps, Select, SelectProps, Sidebar, SidebarClassNames, SidebarProps, SortingState, Switch, SwitchGroup, SwitchGroupProps, SwitchProps, Table, TableBodyProps, TableCaptionProps, TableCellProps, TableClassNames, TableFootProps, TableHeadProps, TableHeaderCellProps, TableProps, TableRowProps, Tag, TagGroup, TagGroupProps, TagProps, TextInput, TextInputProps, Textarea, TextareaProps, Toast, ToastIntent, ToastOptions, ToastProviderProps, Tooltip, TooltipProps, UploadedFile, UploadedFileDetails, UploadedFileDetailsProps, UploadedFileProps, UploadingFiles, UploadingFilesClassNames, UploadingFilesItemClassNames, UploadingFilesItemErrorClassNames, UploadingFilesItemErrorProps, UploadingFilesItemProps, UploadingFilesProps, Virtual, VirtualItem, VirtualPadding, VirtualProps, VisuallyHidden, VisuallyHiddenProps, useDataTableContext, usePasswordRules, z };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Button as e}from"./components/buttons/button/Button.mjs";import{VisuallyHidden as t}from"./components/misc/visually-hidden/VisuallyHidden.mjs";import{ButtonAction as n}from"./components/buttons/button-action/ButtonAction.mjs";import{ButtonLoader as r}from"./components/buttons/button-action/ButtonLoader.mjs";import{AssignedUser as i}from"./components/data-display/assigned-user/AssignedUser.mjs";import{Avatar as a}from"./components/data-display/avatar/Avatar.mjs";import{Badge as o}from"./components/data-display/badge/Badge.mjs";import{Tooltip as s}from"./components/overlays/tooltip/Tooltip.mjs";import{Calendar as c}from"./components/data-display/calendar/Calendar.mjs";import{Virtual as l}from"./components/misc/virtual/Virtual.mjs";import{ScrollArea as u}from"./components/misc/scroll-area/ScrollArea.mjs";import{Table as d}from"./components/data-display/table/Table.mjs";import{IconRaw as f}from"./components/data-display/icons/icon-raw/IconRaw.mjs";import{Icon as p}from"./components/data-display/icons/icon/Icon.mjs";import{DEFAULT_DATA_TABLE_LABELS as m,DataTableContextProvider as h,useDataTableContext as g}from"./components/data-display/datatables/useDataTableContext.mjs";import{Checkbox as _}from"./components/controls/checkbox/Checkbox.mjs";import{DataTable as v}from"./components/data-display/datatables/DataTable.mjs";import{HorizontalDivider as y}from"./components/misc/horizontal-divider/HorizontalDivider.mjs";import{ScrollAreaAutosize as b}from"./components/misc/scroll-area-autosize/ScrollAreaAutosize.mjs";import{TextInput as x}from"./components/controls/text-input/TextInput.mjs";import{IconWrapped as S}from"./components/data-display/icons/icon-wrapped/IconWrapped.mjs";import{Select as C}from"./components/controls/dropdown/select/Select.mjs";import{DataTablePageSize as w}from"./components/data-display/datatables/DataTablePageSize.mjs";import{Pagination as T}from"./components/navigations/pagination/Pagination.mjs";import{DataTablePagination as E}from"./components/data-display/datatables/DataTablePagination.mjs";import{DataTableBottomSlot as D}from"./components/data-display/datatables/DataTableBottomSlot.mjs";import{DataTableErrorState as O}from"./components/data-display/datatables/DataTableErrorState.mjs";import{DataTableTopSlot as k}from"./components/data-display/datatables/DataTableTopSlot.mjs";import{DescriptionList as A}from"./components/data-display/description-list/DescriptionList.mjs";import{IconSvg as j}from"./components/data-display/icons/icon-svg/IconSvg.mjs";import{Indicator as M}from"./components/data-display/indicator/Indicator.mjs";import{LoaderDot as N}from"./components/data-display/loader-dot/LoaderDot.mjs";import{LoaderOval as P}from"./components/data-display/loader-oval/LoaderOval.mjs";import{LogoImage as F}from"./components/data-display/logos/logo-image/LogoImage.mjs";import{LogoSvg as I}from"./components/data-display/logos/logo-svg/LogoSvg.mjs";import{NotificationBanner as L}from"./components/data-display/notification-banner/NotificationBanner.mjs";import{RemovableItem as R}from"./components/data-display/removable-item/RemovableItem.mjs";import{TagGroup as z}from"./components/data-display/tag-group/TagGroup.mjs";import{Tag as B}from"./components/data-display/tag/Tag.mjs";import{UploadedFile as V}from"./components/data-display/uploaded-file/UploadedFile.mjs";import{UploadedFileDetails as H}from"./components/data-display/uploaded-file/UploadedFileDetails.mjs";import{
|
|
1
|
+
import{Button as e}from"./components/buttons/button/Button.mjs";import{VisuallyHidden as t}from"./components/misc/visually-hidden/VisuallyHidden.mjs";import{ButtonAction as n}from"./components/buttons/button-action/ButtonAction.mjs";import{ButtonLoader as r}from"./components/buttons/button-action/ButtonLoader.mjs";import{AssignedUser as i}from"./components/data-display/assigned-user/AssignedUser.mjs";import{Avatar as a}from"./components/data-display/avatar/Avatar.mjs";import{Badge as o}from"./components/data-display/badge/Badge.mjs";import{Tooltip as s}from"./components/overlays/tooltip/Tooltip.mjs";import{Calendar as c}from"./components/data-display/calendar/Calendar.mjs";import{Virtual as l}from"./components/misc/virtual/Virtual.mjs";import{ScrollArea as u}from"./components/misc/scroll-area/ScrollArea.mjs";import{Table as d}from"./components/data-display/table/Table.mjs";import{IconRaw as f}from"./components/data-display/icons/icon-raw/IconRaw.mjs";import{Icon as p}from"./components/data-display/icons/icon/Icon.mjs";import{DEFAULT_DATA_TABLE_LABELS as m,DataTableContextProvider as h,useDataTableContext as g}from"./components/data-display/datatables/useDataTableContext.mjs";import{Checkbox as _}from"./components/controls/checkbox/Checkbox.mjs";import{DataTable as v}from"./components/data-display/datatables/DataTable.mjs";import{HorizontalDivider as y}from"./components/misc/horizontal-divider/HorizontalDivider.mjs";import{ScrollAreaAutosize as b}from"./components/misc/scroll-area-autosize/ScrollAreaAutosize.mjs";import{TextInput as x}from"./components/controls/text-input/TextInput.mjs";import{IconWrapped as S}from"./components/data-display/icons/icon-wrapped/IconWrapped.mjs";import{Select as C}from"./components/controls/dropdown/select/Select.mjs";import{DataTablePageSize as w}from"./components/data-display/datatables/DataTablePageSize.mjs";import{Pagination as T}from"./components/navigations/pagination/Pagination.mjs";import{DataTablePagination as E}from"./components/data-display/datatables/DataTablePagination.mjs";import{DataTableBottomSlot as D}from"./components/data-display/datatables/DataTableBottomSlot.mjs";import{DataTableErrorState as O}from"./components/data-display/datatables/DataTableErrorState.mjs";import{DataTableTopSlot as k}from"./components/data-display/datatables/DataTableTopSlot.mjs";import{DescriptionList as A}from"./components/data-display/description-list/DescriptionList.mjs";import{IconSvg as j}from"./components/data-display/icons/icon-svg/IconSvg.mjs";import{Indicator as M}from"./components/data-display/indicator/Indicator.mjs";import{LoaderDot as N}from"./components/data-display/loader-dot/LoaderDot.mjs";import{LoaderOval as P}from"./components/data-display/loader-oval/LoaderOval.mjs";import{LogoImage as F}from"./components/data-display/logos/logo-image/LogoImage.mjs";import{LogoSvg as I}from"./components/data-display/logos/logo-svg/LogoSvg.mjs";import{NotificationBanner as L}from"./components/data-display/notification-banner/NotificationBanner.mjs";import{RemovableItem as R}from"./components/data-display/removable-item/RemovableItem.mjs";import{TagGroup as z}from"./components/data-display/tag-group/TagGroup.mjs";import{Tag as B}from"./components/data-display/tag/Tag.mjs";import{UploadedFile as V}from"./components/data-display/uploaded-file/UploadedFile.mjs";import{UploadedFileDetails as H}from"./components/data-display/uploaded-file/UploadedFileDetails.mjs";import{UploadingFiles as U}from"./components/data-display/uploading-files/UploadingFiles.mjs";import{ButtonIcon as W}from"./components/buttons/button-icon/ButtonIcon.mjs";import{ButtonIconVisual as G}from"./components/buttons/button-icon-visual/ButtonIconVisual.mjs";import{ButtonVisual as K}from"./components/buttons/button-visual/ButtonVisual.mjs";import{AvatarDropzone as q}from"./components/controls/avatar-dropzone/AvatarDropzone.mjs";import{Modal as J}from"./components/overlays/modal/Modal.mjs";import{Modals as Y}from"./components/overlays/modal/index.mjs";import{Toast as X}from"./components/overlays/toast/Toast.mjs";import{AvatarUpload as Z}from"./components/controls/avatar-upload/AvatarUpload.mjs";import{DatePicker as Q}from"./components/controls/date-picker/DatePicker.mjs";import{Autocomplete as $}from"./components/controls/dropdown/autocomplete/Autocomplete.mjs";import{Combobox as ee}from"./components/controls/dropdown/combobox/Combobox.mjs";import{Dropzone as te}from"./components/controls/dropzone/Dropzone.mjs";import{DropzoneFiles as ne}from"./components/controls/dropzone-files/DropzoneFiles.mjs";import{FileInput as re}from"./components/controls/file-input/FileInput.mjs";import{FileInputMultiple as ie}from"./components/controls/file-input/FileInputMultiple.mjs";import{PasswordInput as ae}from"./components/controls/password-input/PasswordInput.mjs";import{PasswordStrengthInput as oe}from"./components/controls/password-input/PasswordStrengthInput.mjs";import{usePasswordRules as se}from"./components/controls/password-input/usePasswordRules.mjs";import{Radio as ce}from"./components/controls/radio/Radio.mjs";import{SwitchGroup as le}from"./components/controls/switch-group/SwitchGroup.mjs";import{Switch as ue}from"./components/controls/switch/Switch.mjs";import{Textarea as de}from"./components/controls/textarea/Textarea.mjs";import{PASSWORD_RULES as fe}from"./components/forms/rules/password-rules.mjs";import{z as pe}from"./components/forms/rules/zod.mjs";import{Form as me}from"./components/forms/Form.mjs";import{Card as he,CardBase as ge,CardBody as _e,CardFooter as ve,CardHeader as ye,CardRoot as be}from"./components/layouts/card/Card.mjs";import{FluidGrid as xe}from"./components/layouts/fluid-grid/FluidGrid.mjs";import{Grid as Se}from"./components/layouts/grid/Grid.mjs";import{Breadcrumbs as Ce}from"./components/navigations/breadcrumbs/Breadcrumbs.mjs";import{Menu as we}from"./components/navigations/menu/Menu.mjs";import{NavigationMenu as Te}from"./components/navigations/navigation-menu/NavigationMenu.mjs";import{Sidebar as Ee}from"./components/navigations/sidebars/sidebar/Sidebar.mjs";import{MageUiProvider as De}from"./providers/MageUiProvider.mjs";export{i as AssignedUser,$ as Autocomplete,a as Avatar,q as AvatarDropzone,Z as AvatarUpload,o as Badge,Ce as Breadcrumbs,e as Button,n as ButtonAction,W as ButtonIcon,G as ButtonIconVisual,r as ButtonLoader,K as ButtonVisual,c as Calendar,he as Card,ge as CardBase,_e as CardBody,ve as CardFooter,ye as CardHeader,be as CardRoot,_ as Checkbox,ee as Combobox,m as DEFAULT_DATA_TABLE_LABELS,v as DataTable,D as DataTableBottomSlot,h as DataTableContextProvider,O as DataTableErrorState,w as DataTablePageSize,E as DataTablePagination,k as DataTableTopSlot,Q as DatePicker,A as DescriptionList,te as Dropzone,ne as DropzoneFiles,re as FileInput,ie as FileInputMultiple,xe as FluidGrid,me as Form,Se as Grid,y as HorizontalDivider,p as Icon,f as IconRaw,j as IconSvg,S as IconWrapped,M as Indicator,N as LoaderDot,P as LoaderOval,F as LogoImage,I as LogoSvg,De as MageUiProvider,we as Menu,J as Modal,Y as Modals,Te as NavigationMenu,L as NotificationBanner,fe as PASSWORD_RULES,T as Pagination,ae as PasswordInput,oe as PasswordStrengthInput,ce as Radio,R as RemovableItem,u as ScrollArea,b as ScrollAreaAutosize,C as Select,Ee as Sidebar,ue as Switch,le as SwitchGroup,d as Table,B as Tag,z as TagGroup,x as TextInput,de as Textarea,X as Toast,s as Tooltip,V as UploadedFile,H as UploadedFileDetails,U as UploadingFiles,l as Virtual,t as VisuallyHidden,g as useDataTableContext,se as usePasswordRules,pe as z};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mage-ui/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.118",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"rimraf": "^6.1.3",
|
|
26
26
|
"tsdown": "^0.21.4",
|
|
27
27
|
"typescript": "^5.9.3",
|
|
28
|
-
"@mage-ui/preset": "1.0.
|
|
28
|
+
"@mage-ui/preset": "1.0.118",
|
|
29
29
|
"@mage-ui/styled-system": "1.0.8"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|