@mantine/dropzone 9.1.1 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/Dropzone.cjs CHANGED
@@ -14,7 +14,7 @@ const defaultProps = {
14
14
  activateOnDrag: true,
15
15
  dragEventsBubbling: true,
16
16
  activateOnKeyboard: true,
17
- useFsAccessApi: true,
17
+ useFsAccessApi: false,
18
18
  variant: "light",
19
19
  rejectColor: "red"
20
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Dropzone.cjs","names":["DropzoneProvider","Box","LoadingOverlay","classes","DropzoneAccept","DropzoneIdle","DropzoneReject"],"sources":["../src/Dropzone.tsx"],"sourcesContent":["import {\n Accept,\n DropEvent,\n FileError,\n FileRejection,\n FileWithPath,\n useDropzone,\n} from 'react-dropzone';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getRadius,\n LoaderProps,\n LoadingOverlay,\n MantineColor,\n MantineRadius,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { assignRef } from '@mantine/hooks';\nimport { DropzoneProvider } from './Dropzone.context';\nimport type {\n DropzoneFullScreenFactory,\n DropzoneFullScreenProps,\n DropzoneFullScreenStylesNames,\n DropzoneFullScreenType,\n} from './DropzoneFullScreen';\nimport { DropzoneAccept, DropzoneIdle, DropzoneReject } from './DropzoneStatus';\nimport classes from './Dropzone.module.css';\n\nexport type DropzoneStylesNames = 'root' | 'inner';\nexport type DropzoneVariant = 'filled' | 'light';\nexport type DropzoneCssVariables = {\n root:\n | '--dropzone-radius'\n | '--dropzone-accept-color'\n | '--dropzone-accept-bg'\n | '--dropzone-reject-color'\n | '--dropzone-reject-bg';\n};\n\nexport interface DropzoneProps\n extends BoxProps, StylesApiProps<DropzoneFactory>, ElementProps<'div', 'onDrop'> {\n /** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Accept` @default theme.primaryColor */\n acceptColor?: MantineColor;\n\n /** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Reject` @default 'red' */\n rejectColor?: MantineColor;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Determines whether files capturing should be disabled @default false */\n disabled?: boolean;\n\n /** Called when any files are dropped to the dropzone */\n onDropAny?: (files: FileWithPath[], fileRejections: FileRejection[]) => void;\n\n /** Called when valid files are dropped to the dropzone */\n onDrop: (files: FileWithPath[]) => void;\n\n /** Called when dropped files do not meet file restrictions */\n onReject?: (fileRejections: FileRejection[]) => void;\n\n /** Determines whether a loading overlay should be displayed over the dropzone @default false */\n loading?: boolean;\n\n /** Mime types of the files that dropzone can accepts. By default, dropzone accepts all file types. */\n accept?: Accept | string[];\n\n /** A ref function which when called opens the file system file picker */\n openRef?: React.Ref<() => void | undefined>;\n\n /** Determines whether multiple files can be dropped to the dropzone or selected from file system picker @default true */\n multiple?: boolean;\n\n /** Maximum file size in bytes */\n maxSize?: number;\n\n /** Name of the form control. Submitted with the form as part of a name/value pair. */\n name?: string;\n\n /** Maximum number of files that can be picked at once */\n maxFiles?: number;\n\n /** Set to autofocus the root element */\n autoFocus?: boolean;\n\n /** If `false`, disables click to open the native file selection dialog */\n activateOnClick?: boolean;\n\n /** If `false`, disables drag 'n' drop */\n activateOnDrag?: boolean;\n\n /** If `false`, disables Space/Enter to open the native file selection dialog. Note that it also stops tracking the focus state. */\n activateOnKeyboard?: boolean;\n\n /** If `false`, stops drag event propagation to parents */\n dragEventsBubbling?: boolean;\n\n /** Called when the `dragenter` event occurs */\n onDragEnter?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when the `dragleave` event occurs */\n onDragLeave?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when the `dragover` event occurs */\n onDragOver?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when user closes the file selection dialog with no selection */\n onFileDialogCancel?: () => void;\n\n /** Called when user opens the file selection dialog */\n onFileDialogOpen?: () => void;\n\n /** If `false`, allow dropped items to take over the current browser window */\n preventDropOnDocument?: boolean;\n\n /** Set to true to use the File System Access API to open the file picker instead of using an `input type=\"file\"` click event @default true */\n useFsAccessApi?: boolean;\n\n /** Use this to provide a custom file aggregator */\n getFilesFromEvent?: (event: DropEvent) => Promise<Array<File | DataTransferItem>>;\n\n /** Custom validation function. It must return null if there's no errors. */\n validator?: <T extends File>(file: T) => FileError | FileError[] | null;\n\n /** Determines whether pointer events should be enabled on the inner element @default false */\n enablePointerEvents?: boolean;\n\n /** Props passed down to the Loader component */\n loaderProps?: LoaderProps;\n\n /** Props passed down to the internal Input component */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport type DropzoneFactory = Factory<{\n props: DropzoneProps;\n ref: HTMLDivElement;\n stylesNames: DropzoneStylesNames;\n vars: DropzoneCssVariables;\n staticComponents: {\n Accept: typeof DropzoneAccept;\n Idle: typeof DropzoneIdle;\n Reject: typeof DropzoneReject;\n FullScreen: DropzoneFullScreenType;\n };\n}>;\n\nconst defaultProps = {\n multiple: true,\n maxSize: Infinity,\n activateOnClick: true,\n activateOnDrag: true,\n dragEventsBubbling: true,\n activateOnKeyboard: true,\n useFsAccessApi: true,\n variant: 'light',\n rejectColor: 'red',\n} satisfies Partial<DropzoneProps>;\n\nconst varsResolver = createVarsResolver<DropzoneFactory>(\n (theme, { radius, variant, acceptColor, rejectColor }) => {\n const acceptColors = theme.variantColorResolver({\n color: acceptColor || theme.primaryColor,\n theme,\n variant: variant!,\n });\n\n const rejectColors = theme.variantColorResolver({\n color: rejectColor || 'red',\n theme,\n variant: variant!,\n });\n\n return {\n root: {\n '--dropzone-radius': getRadius(radius),\n '--dropzone-accept-color': acceptColors.color,\n '--dropzone-accept-bg': acceptColors.background,\n '--dropzone-reject-color': rejectColors.color,\n '--dropzone-reject-bg': rejectColors.background,\n },\n };\n }\n);\n\nexport const Dropzone = factory<DropzoneFactory>((_props) => {\n const props = useProps('Dropzone', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n radius,\n disabled,\n loading,\n multiple,\n maxSize,\n accept,\n children,\n onDropAny,\n onDrop,\n onReject,\n openRef,\n name,\n maxFiles,\n autoFocus,\n activateOnClick,\n activateOnDrag,\n dragEventsBubbling,\n activateOnKeyboard,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onFileDialogCancel,\n onFileDialogOpen,\n preventDropOnDocument,\n useFsAccessApi,\n getFilesFromEvent,\n validator,\n rejectColor,\n acceptColor,\n enablePointerEvents,\n loaderProps,\n inputProps,\n mod,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<DropzoneFactory>({\n name: 'Dropzone',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { getRootProps, getInputProps, isDragAccept, isDragReject, isDragActive, open } =\n useDropzone({\n onDrop: onDropAny,\n onDropAccepted: onDrop,\n onDropRejected: onReject,\n disabled: disabled || loading,\n accept: Array.isArray(accept) ? accept.reduce((r, key) => ({ ...r, [key]: [] }), {}) : accept,\n multiple,\n maxSize,\n maxFiles,\n autoFocus,\n noClick: !activateOnClick,\n noDrag: !activateOnDrag,\n noDragEventsBubbling: !dragEventsBubbling,\n noKeyboard: !activateOnKeyboard,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onFileDialogCancel,\n onFileDialogOpen,\n preventDropOnDocument,\n useFsAccessApi,\n validator,\n ...(getFilesFromEvent ? { getFilesFromEvent } : null),\n });\n\n assignRef(openRef, open);\n\n const isAccepted = isDragActive && isDragAccept;\n const isRejected = isDragActive && isDragReject;\n const isIdle = !isAccepted && !isRejected;\n\n return (\n <DropzoneProvider value={{ accept: isAccepted, reject: isRejected, idle: isIdle }}>\n <Box\n {...getRootProps()}\n {...getStyles('root', { focusable: true })}\n {...others}\n mod={[\n {\n accept: isAccepted,\n reject: isRejected,\n idle: isIdle,\n disabled,\n loading,\n 'activate-on-click': activateOnClick,\n },\n mod,\n ]}\n >\n <LoadingOverlay\n visible={loading}\n overlayProps={{ radius }}\n unstyled={unstyled}\n loaderProps={loaderProps}\n />\n <input {...getInputProps(inputProps)} name={name} />\n <div {...getStyles('inner')} data-enable-pointer-events={enablePointerEvents || undefined}>\n {children}\n </div>\n </Box>\n </DropzoneProvider>\n );\n});\n\nDropzone.classes = classes;\nDropzone.varsResolver = varsResolver;\nDropzone.displayName = '@mantine/dropzone/Dropzone';\nDropzone.Accept = DropzoneAccept;\nDropzone.Idle = DropzoneIdle;\nDropzone.Reject = DropzoneReject;\n\nexport namespace Dropzone {\n export type Props = DropzoneProps;\n export type StylesNames = DropzoneStylesNames;\n export type CssVariables = DropzoneCssVariables;\n export type Factory = DropzoneFactory;\n\n export namespace FullScreen {\n export type Props = DropzoneFullScreenProps;\n export type StylesNames = DropzoneFullScreenStylesNames;\n export type Factory = DropzoneFullScreenFactory;\n }\n}\n"],"mappings":";;;;;;;;;AA2JA,MAAM,eAAe;CACnB,UAAU;CACV,SAAS;CACT,iBAAiB;CACjB,gBAAgB;CAChB,oBAAoB;CACpB,oBAAoB;CACpB,gBAAgB;CAChB,SAAS;CACT,aAAa;CACd;AAED,MAAM,gBAAA,GAAA,cAAA,qBACH,OAAO,EAAE,QAAQ,SAAS,aAAa,kBAAkB;CACxD,MAAM,eAAe,MAAM,qBAAqB;EAC9C,OAAO,eAAe,MAAM;EAC5B;EACS;EACV,CAAC;CAEF,MAAM,eAAe,MAAM,qBAAqB;EAC9C,OAAO,eAAe;EACtB;EACS;EACV,CAAC;AAEF,QAAO,EACL,MAAM;EACJ,sBAAA,GAAA,cAAA,WAA+B,OAAO;EACtC,2BAA2B,aAAa;EACxC,wBAAwB,aAAa;EACrC,2BAA2B,aAAa;EACxC,wBAAwB,aAAa;EACtC,EACF;EAEJ;AAED,MAAa,YAAA,GAAA,cAAA,UAAqC,WAAW;CAC3D,MAAM,SAAA,GAAA,cAAA,UAAiB,YAAY,cAAc,OAAO;CAC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AAqB;IACtB,EACD,IACD;aAdH;IAgBE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,gBAAD;KACE,SAAS;KACT,cAAc,EAAE,QAAQ;KACd;KACG;KACb,CAAA;IACF,iBAAA,GAAA,kBAAA,KAAC,SAAD;KAAO,GAAI,cAAc,WAAW;KAAQ;KAAQ,CAAA;IACpD,iBAAA,GAAA,kBAAA,KAAC,OAAD;KAAK,GAAI,UAAU,QAAQ;KAAE,8BAA4B,uBAAuB,KAAA;KAC7E;KACG,CAAA;IACF;;EACW,CAAA;EAErB;AAEF,SAAS,UAAUC,wBAAAA;AACnB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,SAASC,uBAAAA;AAClB,SAAS,OAAOC,uBAAAA;AAChB,SAAS,SAASC,uBAAAA"}
1
+ {"version":3,"file":"Dropzone.cjs","names":["DropzoneProvider","Box","LoadingOverlay","classes","DropzoneAccept","DropzoneIdle","DropzoneReject"],"sources":["../src/Dropzone.tsx"],"sourcesContent":["import {\n Accept,\n DropEvent,\n FileError,\n FileRejection,\n FileWithPath,\n useDropzone,\n} from 'react-dropzone';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getRadius,\n LoaderProps,\n LoadingOverlay,\n MantineColor,\n MantineRadius,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { assignRef } from '@mantine/hooks';\nimport { DropzoneProvider } from './Dropzone.context';\nimport type {\n DropzoneFullScreenFactory,\n DropzoneFullScreenProps,\n DropzoneFullScreenStylesNames,\n DropzoneFullScreenType,\n} from './DropzoneFullScreen';\nimport { DropzoneAccept, DropzoneIdle, DropzoneReject } from './DropzoneStatus';\nimport classes from './Dropzone.module.css';\n\nexport type DropzoneStylesNames = 'root' | 'inner';\nexport type DropzoneVariant = 'filled' | 'light';\nexport type DropzoneCssVariables = {\n root:\n | '--dropzone-radius'\n | '--dropzone-accept-color'\n | '--dropzone-accept-bg'\n | '--dropzone-reject-color'\n | '--dropzone-reject-bg';\n};\n\nexport interface DropzoneProps\n extends BoxProps, StylesApiProps<DropzoneFactory>, ElementProps<'div', 'onDrop'> {\n /** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Accept` @default theme.primaryColor */\n acceptColor?: MantineColor;\n\n /** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Reject` @default 'red' */\n rejectColor?: MantineColor;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Determines whether files capturing should be disabled @default false */\n disabled?: boolean;\n\n /** Called when any files are dropped to the dropzone */\n onDropAny?: (files: FileWithPath[], fileRejections: FileRejection[]) => void;\n\n /** Called when valid files are dropped to the dropzone */\n onDrop: (files: FileWithPath[]) => void;\n\n /** Called when dropped files do not meet file restrictions */\n onReject?: (fileRejections: FileRejection[]) => void;\n\n /** Determines whether a loading overlay should be displayed over the dropzone @default false */\n loading?: boolean;\n\n /** Mime types of the files that dropzone can accepts. By default, dropzone accepts all file types. */\n accept?: Accept | string[];\n\n /** A ref function which when called opens the file system file picker */\n openRef?: React.Ref<() => void | undefined>;\n\n /** Determines whether multiple files can be dropped to the dropzone or selected from file system picker @default true */\n multiple?: boolean;\n\n /** Maximum file size in bytes */\n maxSize?: number;\n\n /** Name of the form control. Submitted with the form as part of a name/value pair. */\n name?: string;\n\n /** Maximum number of files that can be picked at once */\n maxFiles?: number;\n\n /** Set to autofocus the root element */\n autoFocus?: boolean;\n\n /** If `false`, disables click to open the native file selection dialog */\n activateOnClick?: boolean;\n\n /** If `false`, disables drag 'n' drop */\n activateOnDrag?: boolean;\n\n /** If `false`, disables Space/Enter to open the native file selection dialog. Note that it also stops tracking the focus state. */\n activateOnKeyboard?: boolean;\n\n /** If `false`, stops drag event propagation to parents */\n dragEventsBubbling?: boolean;\n\n /** Called when the `dragenter` event occurs */\n onDragEnter?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when the `dragleave` event occurs */\n onDragLeave?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when the `dragover` event occurs */\n onDragOver?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when user closes the file selection dialog with no selection */\n onFileDialogCancel?: () => void;\n\n /** Called when user opens the file selection dialog */\n onFileDialogOpen?: () => void;\n\n /** If `false`, allow dropped items to take over the current browser window */\n preventDropOnDocument?: boolean;\n\n /** Set to true to use the File System Access API to open the file picker instead of using an `input type=\"file\"` click event @default false */\n useFsAccessApi?: boolean;\n\n /** Use this to provide a custom file aggregator */\n getFilesFromEvent?: (event: DropEvent) => Promise<Array<File | DataTransferItem>>;\n\n /** Custom validation function. It must return null if there's no errors. */\n validator?: <T extends File>(file: T) => FileError | FileError[] | null;\n\n /** Determines whether pointer events should be enabled on the inner element @default false */\n enablePointerEvents?: boolean;\n\n /** Props passed down to the Loader component */\n loaderProps?: LoaderProps;\n\n /** Props passed down to the internal Input component */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport type DropzoneFactory = Factory<{\n props: DropzoneProps;\n ref: HTMLDivElement;\n stylesNames: DropzoneStylesNames;\n vars: DropzoneCssVariables;\n staticComponents: {\n Accept: typeof DropzoneAccept;\n Idle: typeof DropzoneIdle;\n Reject: typeof DropzoneReject;\n FullScreen: DropzoneFullScreenType;\n };\n}>;\n\nconst defaultProps = {\n multiple: true,\n maxSize: Infinity,\n activateOnClick: true,\n activateOnDrag: true,\n dragEventsBubbling: true,\n activateOnKeyboard: true,\n useFsAccessApi: false,\n variant: 'light',\n rejectColor: 'red',\n} satisfies Partial<DropzoneProps>;\n\nconst varsResolver = createVarsResolver<DropzoneFactory>(\n (theme, { radius, variant, acceptColor, rejectColor }) => {\n const acceptColors = theme.variantColorResolver({\n color: acceptColor || theme.primaryColor,\n theme,\n variant: variant!,\n });\n\n const rejectColors = theme.variantColorResolver({\n color: rejectColor || 'red',\n theme,\n variant: variant!,\n });\n\n return {\n root: {\n '--dropzone-radius': getRadius(radius),\n '--dropzone-accept-color': acceptColors.color,\n '--dropzone-accept-bg': acceptColors.background,\n '--dropzone-reject-color': rejectColors.color,\n '--dropzone-reject-bg': rejectColors.background,\n },\n };\n }\n);\n\nexport const Dropzone = factory<DropzoneFactory>((_props) => {\n const props = useProps('Dropzone', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n radius,\n disabled,\n loading,\n multiple,\n maxSize,\n accept,\n children,\n onDropAny,\n onDrop,\n onReject,\n openRef,\n name,\n maxFiles,\n autoFocus,\n activateOnClick,\n activateOnDrag,\n dragEventsBubbling,\n activateOnKeyboard,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onFileDialogCancel,\n onFileDialogOpen,\n preventDropOnDocument,\n useFsAccessApi,\n getFilesFromEvent,\n validator,\n rejectColor,\n acceptColor,\n enablePointerEvents,\n loaderProps,\n inputProps,\n mod,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<DropzoneFactory>({\n name: 'Dropzone',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { getRootProps, getInputProps, isDragAccept, isDragReject, isDragActive, open } =\n useDropzone({\n onDrop: onDropAny,\n onDropAccepted: onDrop,\n onDropRejected: onReject,\n disabled: disabled || loading,\n accept: Array.isArray(accept) ? accept.reduce((r, key) => ({ ...r, [key]: [] }), {}) : accept,\n multiple,\n maxSize,\n maxFiles,\n autoFocus,\n noClick: !activateOnClick,\n noDrag: !activateOnDrag,\n noDragEventsBubbling: !dragEventsBubbling,\n noKeyboard: !activateOnKeyboard,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onFileDialogCancel,\n onFileDialogOpen,\n preventDropOnDocument,\n useFsAccessApi,\n validator,\n ...(getFilesFromEvent ? { getFilesFromEvent } : null),\n });\n\n assignRef(openRef, open);\n\n const isAccepted = isDragActive && isDragAccept;\n const isRejected = isDragActive && isDragReject;\n const isIdle = !isAccepted && !isRejected;\n\n return (\n <DropzoneProvider value={{ accept: isAccepted, reject: isRejected, idle: isIdle }}>\n <Box\n {...getRootProps()}\n {...getStyles('root', { focusable: true })}\n {...others}\n mod={[\n {\n accept: isAccepted,\n reject: isRejected,\n idle: isIdle,\n disabled,\n loading,\n 'activate-on-click': activateOnClick,\n },\n mod,\n ]}\n >\n <LoadingOverlay\n visible={loading}\n overlayProps={{ radius }}\n unstyled={unstyled}\n loaderProps={loaderProps}\n />\n <input {...getInputProps(inputProps)} name={name} />\n <div {...getStyles('inner')} data-enable-pointer-events={enablePointerEvents || undefined}>\n {children}\n </div>\n </Box>\n </DropzoneProvider>\n );\n});\n\nDropzone.classes = classes;\nDropzone.varsResolver = varsResolver;\nDropzone.displayName = '@mantine/dropzone/Dropzone';\nDropzone.Accept = DropzoneAccept;\nDropzone.Idle = DropzoneIdle;\nDropzone.Reject = DropzoneReject;\n\nexport namespace Dropzone {\n export type Props = DropzoneProps;\n export type StylesNames = DropzoneStylesNames;\n export type CssVariables = DropzoneCssVariables;\n export type Factory = DropzoneFactory;\n\n export namespace FullScreen {\n export type Props = DropzoneFullScreenProps;\n export type StylesNames = DropzoneFullScreenStylesNames;\n export type Factory = DropzoneFullScreenFactory;\n }\n}\n"],"mappings":";;;;;;;;;AA2JA,MAAM,eAAe;CACnB,UAAU;CACV,SAAS;CACT,iBAAiB;CACjB,gBAAgB;CAChB,oBAAoB;CACpB,oBAAoB;CACpB,gBAAgB;CAChB,SAAS;CACT,aAAa;AACf;AAEA,MAAM,gBAAA,GAAA,cAAA,qBACH,OAAO,EAAE,QAAQ,SAAS,aAAa,kBAAkB;CACxD,MAAM,eAAe,MAAM,qBAAqB;EAC9C,OAAO,eAAe,MAAM;EAC5B;EACS;CACX,CAAC;CAED,MAAM,eAAe,MAAM,qBAAqB;EAC9C,OAAO,eAAe;EACtB;EACS;CACX,CAAC;CAED,OAAO,EACL,MAAM;EACJ,sBAAA,GAAA,cAAA,WAA+B,MAAM;EACrC,2BAA2B,aAAa;EACxC,wBA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AAA,MAACC,cAAAA,KAAD;GACE,GAAI,aAAa;GACjB,GAAI,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;GACzC,GAAI;GACJ,KAAK,CACH;IACE,QAAQ;IACR,QAAQ;IACR,MAAM;IACN;IACA;IACA,qBAAqB;GACvB,GACA,GACF;aAdF;IAgBE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,gBAAD;KACE,SAAS;KACT,cAAc,EAAE,OAAO;KACb;KACG;IACd,CAAA;IACD,iBAAA,GAAA,kBAAA,KAAC,SAAD;KAAO,GAAI,cAAc,UAAU;KAAS;IAAO,CAAA;IACnD,iBAAA,GAAA,kBAAA,KAAC,OAAD;KAAK,GAAI,UAAU,OAAO;KAAG,8BAA4B,uBAAuB,KAAA;KAC7E;IACE,CAAA;GACF;;CACW,CAAA;AAEtB,CAAC;AAED,SAAS,UAAUC,wBAAAA;AACnB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,SAASC,uBAAAA;AAClB,SAAS,OAAOC,uBAAAA;AAChB,SAAS,SAASC,uBAAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Dropzone.context.cjs","names":[],"sources":["../src/Dropzone.context.ts"],"sourcesContent":["import { createSafeContext } from '@mantine/core';\n\nexport interface DropzoneContextValue {\n idle: boolean;\n accept: boolean;\n reject: boolean;\n}\n\nexport const [DropzoneProvider, useDropzoneContext] = createSafeContext<DropzoneContextValue>(\n 'Dropzone component was not found in tree'\n);\n"],"mappings":";;AAQA,MAAa,CAAC,kBAAkB,uBAAA,4BAAA,mBAC9B,2CACD"}
1
+ {"version":3,"file":"Dropzone.context.cjs","names":[],"sources":["../src/Dropzone.context.ts"],"sourcesContent":["import { createSafeContext } from '@mantine/core';\n\nexport interface DropzoneContextValue {\n idle: boolean;\n accept: boolean;\n reject: boolean;\n}\n\nexport const [DropzoneProvider, useDropzoneContext] = createSafeContext<DropzoneContextValue>(\n 'Dropzone component was not found in tree'\n);\n"],"mappings":";;AAQA,MAAa,CAAC,kBAAkB,uBAAA,0BAAA,EAAA,mBAC9B,0CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"DropzoneFullScreen.cjs","names":["OptionalPortal","Box","Dropzone","classes"],"sources":["../src/DropzoneFullScreen.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport {\n BasePortalProps,\n Box,\n BoxProps,\n ElementProps,\n factory,\n Factory,\n getDefaultZIndex,\n OptionalPortal,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { useDisclosure } from '@mantine/hooks';\nimport { Dropzone, DropzoneProps, DropzoneStylesNames, DropzoneVariant } from './Dropzone';\nimport classes from './Dropzone.module.css';\n\nexport type DropzoneFullScreenStylesNames = DropzoneStylesNames | 'fullScreen';\n\nexport interface DropzoneFullScreenProps\n extends\n BoxProps,\n Omit<DropzoneProps, 'styles' | 'classNames' | 'vars' | 'variant' | 'attributes'>,\n StylesApiProps<DropzoneFullScreenFactory>,\n ElementProps<'div', 'onDragLeave' | 'onDragOver' | 'onDrop' | 'onDragEnter'> {\n /** Determines whether user can drop files to browser window @default true */\n active?: boolean;\n\n /** Z-index value @default 9999 */\n zIndex?: React.CSSProperties['zIndex'];\n\n /** Determines whether component should be rendered within `Portal` @default true */\n withinPortal?: boolean;\n\n /** Props to pass down to the portal when withinPortal is `true` */\n portalProps?: Omit<BasePortalProps, 'withinPortal'>;\n}\n\nexport type DropzoneFullScreenFactory = Factory<{\n props: DropzoneFullScreenProps;\n ref: HTMLDivElement;\n stylesNames: DropzoneFullScreenStylesNames;\n variant: DropzoneVariant;\n}>;\n\nconst defaultProps = {\n maxSize: Infinity,\n activateOnDrag: true,\n dragEventsBubbling: true,\n activateOnKeyboard: true,\n active: true,\n zIndex: getDefaultZIndex('max'),\n withinPortal: true,\n} satisfies Partial<DropzoneFullScreenProps>;\n\nexport const DropzoneFullScreen = factory<DropzoneFullScreenFactory>((_props) => {\n const props = useProps('DropzoneFullScreen', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n active,\n onDrop,\n onReject,\n zIndex,\n withinPortal,\n portalProps,\n attributes,\n mod,\n ...others\n } = props;\n\n const getStyles = useStyles<DropzoneFullScreenFactory>({\n name: 'DropzoneFullScreen',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n rootSelector: 'fullScreen',\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<DropzoneFullScreenFactory>({\n classNames,\n styles,\n props,\n });\n\n const [counter, setCounter] = useState(0);\n const [visible, { open, close }] = useDisclosure(false);\n\n const handleDragEnter = (event: DragEvent) => {\n if (event.dataTransfer?.types.includes('Files')) {\n setCounter((prev) => prev + 1);\n open();\n }\n };\n\n const handleDragLeave = () => {\n setCounter((prev) => prev - 1);\n };\n\n useEffect(() => {\n counter === 0 && close();\n }, [counter]);\n\n useEffect(() => {\n if (!active) {\n return undefined;\n }\n\n document.addEventListener('dragenter', handleDragEnter, false);\n document.addEventListener('dragleave', handleDragLeave, false);\n\n return () => {\n document.removeEventListener('dragenter', handleDragEnter, false);\n document.removeEventListener('dragleave', handleDragLeave, false);\n };\n }, [active]);\n\n return (\n <OptionalPortal {...portalProps} withinPortal={withinPortal}>\n <Box\n {...getStyles('fullScreen', {\n style: { opacity: visible ? 1 : 0, pointerEvents: visible ? 'all' : 'none', zIndex },\n })}\n >\n <Dropzone\n activateOnClick={false}\n {...others}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n className={classes.dropzone}\n onDrop={(files: any) => {\n onDrop?.(files);\n close();\n setCounter(0);\n }}\n onReject={(files: any) => {\n onReject?.(files);\n close();\n setCounter(0);\n }}\n />\n </Box>\n </OptionalPortal>\n );\n});\n\nDropzoneFullScreen.classes = classes;\nDropzoneFullScreen.displayName = '@mantine/dropzone/DropzoneFullScreen';\n\nexport type DropzoneFullScreenType = typeof DropzoneFullScreen;\n"],"mappings":";;;;;;;;AA+CA,MAAM,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,GAAI;EAA2B;YAC7C,iBAAA,GAAA,kBAAA,KAACC,cAAAA,KAAD;GACE,GAAI,UAAU,cAAc,EAC1B,OAAO;IAAE,SAAS,UAAU,IAAI;IAAG,eAAe,UAAU,QAAQ;IAAQ;IAAQ,EACrF,CAAC;aAEF,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,UAAD;IACE,iBAAiB;IACjB,GAAI;IACJ,YAAY;IACZ,QAAQ;IACE;IACV,WAAWC,wBAAAA,QAAQ;IACnB,SAAS,UAAe;AACtB,cAAS,MAAM;AACf,YAAO;AACP,gBAAW,EAAE;;IAEf,WAAW,UAAe;AACxB,gBAAW,MAAM;AACjB,YAAO;AACP,gBAAW,EAAE;;IAEf,CAAA;GACE,CAAA;EACS,CAAA;EAEnB;AAEF,mBAAmB,UAAUA,wBAAAA;AAC7B,mBAAmB,cAAc"}
1
+ {"version":3,"file":"DropzoneFullScreen.cjs","names":["OptionalPortal","Box","Dropzone","classes"],"sources":["../src/DropzoneFullScreen.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport {\n BasePortalProps,\n Box,\n BoxProps,\n ElementProps,\n factory,\n Factory,\n getDefaultZIndex,\n OptionalPortal,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { useDisclosure } from '@mantine/hooks';\nimport { Dropzone, DropzoneProps, DropzoneStylesNames, DropzoneVariant } from './Dropzone';\nimport classes from './Dropzone.module.css';\n\nexport type DropzoneFullScreenStylesNames = DropzoneStylesNames | 'fullScreen';\n\nexport interface DropzoneFullScreenProps\n extends\n BoxProps,\n Omit<DropzoneProps, 'styles' | 'classNames' | 'vars' | 'variant' | 'attributes'>,\n StylesApiProps<DropzoneFullScreenFactory>,\n ElementProps<'div', 'onDragLeave' | 'onDragOver' | 'onDrop' | 'onDragEnter'> {\n /** Determines whether user can drop files to browser window @default true */\n active?: boolean;\n\n /** Z-index value @default 9999 */\n zIndex?: React.CSSProperties['zIndex'];\n\n /** Determines whether component should be rendered within `Portal` @default true */\n withinPortal?: boolean;\n\n /** Props to pass down to the portal when withinPortal is `true` */\n portalProps?: Omit<BasePortalProps, 'withinPortal'>;\n}\n\nexport type DropzoneFullScreenFactory = Factory<{\n props: DropzoneFullScreenProps;\n ref: HTMLDivElement;\n stylesNames: DropzoneFullScreenStylesNames;\n variant: DropzoneVariant;\n}>;\n\nconst defaultProps = {\n maxSize: Infinity,\n activateOnDrag: true,\n dragEventsBubbling: true,\n activateOnKeyboard: true,\n active: true,\n zIndex: getDefaultZIndex('max'),\n withinPortal: true,\n} satisfies Partial<DropzoneFullScreenProps>;\n\nexport const DropzoneFullScreen = factory<DropzoneFullScreenFactory>((_props) => {\n const props = useProps('DropzoneFullScreen', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n active,\n onDrop,\n onReject,\n zIndex,\n withinPortal,\n portalProps,\n attributes,\n mod,\n ...others\n } = props;\n\n const getStyles = useStyles<DropzoneFullScreenFactory>({\n name: 'DropzoneFullScreen',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n rootSelector: 'fullScreen',\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<DropzoneFullScreenFactory>({\n classNames,\n styles,\n props,\n });\n\n const [counter, setCounter] = useState(0);\n const [visible, { open, close }] = useDisclosure(false);\n\n const handleDragEnter = (event: DragEvent) => {\n if (event.dataTransfer?.types.includes('Files')) {\n setCounter((prev) => prev + 1);\n open();\n }\n };\n\n const handleDragLeave = () => {\n setCounter((prev) => prev - 1);\n };\n\n useEffect(() => {\n counter === 0 && close();\n }, [counter]);\n\n useEffect(() => {\n if (!active) {\n return undefined;\n }\n\n document.addEventListener('dragenter', handleDragEnter, false);\n document.addEventListener('dragleave', handleDragLeave, false);\n\n return () => {\n document.removeEventListener('dragenter', handleDragEnter, false);\n document.removeEventListener('dragleave', handleDragLeave, false);\n };\n }, [active]);\n\n return (\n <OptionalPortal {...portalProps} withinPortal={withinPortal}>\n <Box\n {...getStyles('fullScreen', {\n style: { opacity: visible ? 1 : 0, pointerEvents: visible ? 'all' : 'none', zIndex },\n })}\n >\n <Dropzone\n activateOnClick={false}\n {...others}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n className={classes.dropzone}\n onDrop={(files: any) => {\n onDrop?.(files);\n close();\n setCounter(0);\n }}\n onReject={(files: any) => {\n onReject?.(files);\n close();\n setCounter(0);\n }}\n />\n </Box>\n </OptionalPortal>\n );\n});\n\nDropzoneFullScreen.classes = classes;\nDropzoneFullScreen.displayName = '@mantine/dropzone/DropzoneFullScreen';\n\nexport type DropzoneFullScreenType = typeof DropzoneFullScreen;\n"],"mappings":";;;;;;;;AA+CA,MAAM,eAAe;CACnB,SAAS;CACT,gBAAgB;CAChB,oBAAoB;CACpB,oBAAoB;CACpB,QAAQ;CACR,SAAA,GAAA,cAAA,kBAAyB,KAAK;CAC9B,cAAc;AAChB;AAEA,MAAa,sBAAA,GAAA,cAAA,UAAyD,WAAW;CAC/E,MAAM,SAAA,GAAA,cAAA,UAAiB,sBAAsB,cAAc,MAAM;CACjE,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,QACA,QACA,UACA,QACA,cACA,aACA,YACA,KACA,GAAG,WACD;CAEJ,MAAM,aAAA,GAAA,cAAA,WAAiD;EACrD,MAAM;EACN,SAAA,wBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;CAChB,CAAC;CAED,MAAM,EAAE,oBAAoB,oBAAA,GAAA,cAAA,sBAAmE;EAC7F;EACA;EACA;CACF,CAAC;CAED,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,UAAuB,CAAC;CACxC,MAAM,CAAC,SAAS,EAAE,MAAM,YAAA,GAAA,eAAA,eAAyB,KAAK;CAEtD,MAAM,mBAAmB,UAAqB;EAC5C,IAAI,MAAM,cAAc,MAAM,SAAS,OAAO,GAAG;GAC/C,YAAY,SAAS,OAAO,CAAC;GAC7B,KAAK;EACP;CACF;CAEA,MAAM,wBAAwB;EAC5B,YAAY,SAAS,OAAO,CAAC;CAC/B;CAEA,CAAA,GAAA,MAAA,iBAAgB;EACd,YAAY,KAAK,MAAM;CACzB,GAAG,CAAC,OAAO,CAAC;CAEZ,CAAA,GAAA,MAAA,iBAAgB;EACd,IAAI,CAAC,QACH;EAGF,SAAS,iBAAiB,aAAa,iBAAiB,KAAK;EAC7D,SAAS,iBAAiB,aAAa,iBAAiB,KAAK;EAE7D,aAAa;GACX,SAAS,oBAAoB,aAAa,iBAAiB,KAAK;GAChE,SAAS,oBAAoB,aAAa,iBAAiB,KAAK;EAClE;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,OACE,iBAAA,GAAA,kBAAA,KAACA,cAAAA,gBAAD;EAAgB,GAAI;EAA2B;YAC7C,iBAAA,GAAA,kBAAA,KAACC,cAAAA,KAAD;GACE,GAAI,UAAU,cAAc,EAC1B,OAAO;IAAE,SAAS,UAAU,IAAI;IAAG,eAAe,UAAU,QAAQ;IAAQ;GAAO,EACrF,CAAC;aAED,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,UAAD;IACE,iBAAiB;IACjB,GAAI;IACJ,YAAY;IACZ,QAAQ;IACE;IACV,WAAWC,wBAAAA,QAAQ;IACnB,SAAS,UAAe;KACtB,SAAS,KAAK;KACd,MAAM;KACN,WAAW,CAAC;IACd;IACA,WAAW,UAAe;KACxB,WAAW,KAAK;KAChB,MAAM;KACN,WAAW,CAAC;IACd;GACD,CAAA;EACE,CAAA;CACS,CAAA;AAEpB,CAAC;AAED,mBAAmB,UAAUA,wBAAAA;AAC7B,mBAAmB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"DropzoneStatus.cjs","names":["useDropzoneContext"],"sources":["../src/DropzoneStatus.tsx"],"sourcesContent":["import { cloneElement } from 'react';\nimport { isElement, useProps } from '@mantine/core';\nimport { upperFirst } from '@mantine/hooks';\nimport { DropzoneContextValue, useDropzoneContext } from './Dropzone.context';\n\nexport interface DropzoneStatusProps {\n children: React.ReactNode;\n}\n\ntype DropzoneStatusComponent = React.FC<DropzoneStatusProps>;\n\nfunction createDropzoneStatus(status: keyof DropzoneContextValue) {\n const Component: DropzoneStatusComponent = (props) => {\n const { children, ...others } = useProps(`Dropzone${upperFirst(status)}`, {}, props);\n\n const ctx = useDropzoneContext();\n const _children = isElement(children) ? children : <span>{children}</span>;\n\n if (ctx[status]) {\n return cloneElement(_children as React.JSX.Element, others);\n }\n\n return null;\n };\n\n Component.displayName = `@mantine/dropzone/${upperFirst(status)}`;\n\n return Component;\n}\n\nexport const DropzoneAccept = createDropzoneStatus('accept');\nexport const DropzoneReject = createDropzoneStatus('reject');\nexport const DropzoneIdle = createDropzoneStatus('idle');\n\nexport type DropzoneAcceptProps = DropzoneStatusProps;\nexport type DropzoneRejectProps = DropzoneStatusProps;\nexport type DropzoneIdleProps = DropzoneStatusProps;\n"],"mappings":";;;;;;;AAWA,SAAS,qBAAqB,QAAoC;CAChE,MAAM,aAAsC,UAAU;EACpD,MAAM,EAAE,UAAU,GAAG,YAAA,GAAA,cAAA,UAAoB,YAAA,GAAA,eAAA,YAAsB,OAAO,IAAI,EAAE,EAAE,MAAM;EAEpF,MAAM,MAAMA,yBAAAA,oBAAoB;EAChC,MAAM,aAAA,GAAA,cAAA,WAAsB,SAAS,GAAG,WAAW,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAO,UAAgB,CAAA;AAE1E,MAAI,IAAI,QACN,SAAA,GAAA,MAAA,cAAoB,WAAgC,OAAO;AAG7D,SAAO;;AAGT,WAAU,cAAc,sBAAA,GAAA,eAAA,YAAgC,OAAO;AAE/D,QAAO;;AAGT,MAAa,iBAAiB,qBAAqB,SAAS;AAC5D,MAAa,iBAAiB,qBAAqB,SAAS;AAC5D,MAAa,eAAe,qBAAqB,OAAO"}
1
+ {"version":3,"file":"DropzoneStatus.cjs","names":["useDropzoneContext"],"sources":["../src/DropzoneStatus.tsx"],"sourcesContent":["import { cloneElement } from 'react';\nimport { isElement, useProps } from '@mantine/core';\nimport { upperFirst } from '@mantine/hooks';\nimport { DropzoneContextValue, useDropzoneContext } from './Dropzone.context';\n\nexport interface DropzoneStatusProps {\n children: React.ReactNode;\n}\n\ntype DropzoneStatusComponent = React.FC<DropzoneStatusProps>;\n\nfunction createDropzoneStatus(status: keyof DropzoneContextValue) {\n const Component: DropzoneStatusComponent = (props) => {\n const { children, ...others } = useProps(`Dropzone${upperFirst(status)}`, {}, props);\n\n const ctx = useDropzoneContext();\n const _children = isElement(children) ? children : <span>{children}</span>;\n\n if (ctx[status]) {\n return cloneElement(_children as React.JSX.Element, others);\n }\n\n return null;\n };\n\n Component.displayName = `@mantine/dropzone/${upperFirst(status)}`;\n\n return Component;\n}\n\nexport const DropzoneAccept = createDropzoneStatus('accept');\nexport const DropzoneReject = createDropzoneStatus('reject');\nexport const DropzoneIdle = createDropzoneStatus('idle');\n\nexport type DropzoneAcceptProps = DropzoneStatusProps;\nexport type DropzoneRejectProps = DropzoneStatusProps;\nexport type DropzoneIdleProps = DropzoneStatusProps;\n"],"mappings":";;;;;;;AAWA,SAAS,qBAAqB,QAAoC;CAChE,MAAM,aAAsC,UAAU;EACpD,MAAM,EAAE,UAAU,GAAG,YAAA,GAAA,cAAA,UAAoB,YAAA,GAAA,eAAA,YAAsB,MAAM,KAAK,CAAC,GAAG,KAAK;EAEnF,MAAM,MAAMA,yBAAAA,mBAAmB;EAC/B,MAAM,aAAA,GAAA,cAAA,WAAsB,QAAQ,IAAI,WAAW,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAO,SAAe,CAAA;EAEzE,IAAI,IAAI,SACN,QAAA,GAAA,MAAA,cAAoB,WAAgC,MAAM;EAG5D,OAAO;CACT;CAEA,UAAU,cAAc,sBAAA,GAAA,eAAA,YAAgC,MAAM;CAE9D,OAAO;AACT;AAEA,MAAa,iBAAiB,qBAAqB,QAAQ;AAC3D,MAAa,iBAAiB,qBAAqB,QAAQ;AAC3D,MAAa,eAAe,qBAAqB,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"mime-types.cjs","names":[],"sources":["../src/mime-types.ts"],"sourcesContent":["export const MIME_TYPES = {\n // Images\n png: 'image/png',\n gif: 'image/gif',\n jpeg: 'image/jpeg',\n svg: 'image/svg+xml',\n webp: 'image/webp',\n avif: 'image/avif',\n heic: 'image/heic',\n heif: 'image/heif',\n\n // Documents\n mp4: 'video/mp4',\n zip: 'application/zip',\n rar: 'application/x-rar',\n '7z': 'application/x-7z-compressed',\n csv: 'text/csv',\n pdf: 'application/pdf',\n doc: 'application/msword',\n docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n xls: 'application/vnd.ms-excel',\n xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ppt: 'application/vnd.ms-powerpoint',\n pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n exe: 'application/vnd.microsoft.portable-executable',\n} as const;\n\nexport const IMAGE_MIME_TYPE = [\n MIME_TYPES.png,\n MIME_TYPES.gif,\n MIME_TYPES.jpeg,\n MIME_TYPES.svg,\n MIME_TYPES.webp,\n MIME_TYPES.avif,\n MIME_TYPES.heic,\n MIME_TYPES.heif,\n];\n\nexport const PDF_MIME_TYPE = [MIME_TYPES.pdf];\nexport const MS_WORD_MIME_TYPE = [MIME_TYPES.doc, MIME_TYPES.docx];\nexport const MS_EXCEL_MIME_TYPE = [MIME_TYPES.xls, MIME_TYPES.xlsx];\nexport const MS_POWERPOINT_MIME_TYPE = [MIME_TYPES.ppt, MIME_TYPES.pptx];\nexport const EXE_MIME_TYPE = [MIME_TYPES.exe];\n"],"mappings":";;AAAA,MAAa,aAAa;CAExB,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CAGN,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACN;AAED,MAAa,kBAAkB;CAC7B,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACZ;AAED,MAAa,gBAAgB,CAAC,WAAW,IAAI;AAC7C,MAAa,oBAAoB,CAAC,WAAW,KAAK,WAAW,KAAK;AAClE,MAAa,qBAAqB,CAAC,WAAW,KAAK,WAAW,KAAK;AACnE,MAAa,0BAA0B,CAAC,WAAW,KAAK,WAAW,KAAK;AACxE,MAAa,gBAAgB,CAAC,WAAW,IAAI"}
1
+ {"version":3,"file":"mime-types.cjs","names":[],"sources":["../src/mime-types.ts"],"sourcesContent":["export const MIME_TYPES = {\n // Images\n png: 'image/png',\n gif: 'image/gif',\n jpeg: 'image/jpeg',\n svg: 'image/svg+xml',\n webp: 'image/webp',\n avif: 'image/avif',\n heic: 'image/heic',\n heif: 'image/heif',\n\n // Documents\n mp4: 'video/mp4',\n zip: 'application/zip',\n rar: 'application/x-rar',\n '7z': 'application/x-7z-compressed',\n csv: 'text/csv',\n pdf: 'application/pdf',\n doc: 'application/msword',\n docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n xls: 'application/vnd.ms-excel',\n xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ppt: 'application/vnd.ms-powerpoint',\n pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n exe: 'application/vnd.microsoft.portable-executable',\n} as const;\n\nexport const IMAGE_MIME_TYPE = [\n MIME_TYPES.png,\n MIME_TYPES.gif,\n MIME_TYPES.jpeg,\n MIME_TYPES.svg,\n MIME_TYPES.webp,\n MIME_TYPES.avif,\n MIME_TYPES.heic,\n MIME_TYPES.heif,\n];\n\nexport const PDF_MIME_TYPE = [MIME_TYPES.pdf];\nexport const MS_WORD_MIME_TYPE = [MIME_TYPES.doc, MIME_TYPES.docx];\nexport const MS_EXCEL_MIME_TYPE = [MIME_TYPES.xls, MIME_TYPES.xlsx];\nexport const MS_POWERPOINT_MIME_TYPE = [MIME_TYPES.ppt, MIME_TYPES.pptx];\nexport const EXE_MIME_TYPE = [MIME_TYPES.exe];\n"],"mappings":";;AAAA,MAAa,aAAa;CAExB,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CAGN,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;AACP;AAEA,MAAa,kBAAkB;CAC7B,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;AACb;AAEA,MAAa,gBAAgB,CAAC,WAAW,GAAG;AAC5C,MAAa,oBAAoB,CAAC,WAAW,KAAK,WAAW,IAAI;AACjE,MAAa,qBAAqB,CAAC,WAAW,KAAK,WAAW,IAAI;AAClE,MAAa,0BAA0B,CAAC,WAAW,KAAK,WAAW,IAAI;AACvE,MAAa,gBAAgB,CAAC,WAAW,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"Dropzone.context.mjs","names":[],"sources":["../src/Dropzone.context.ts"],"sourcesContent":["import { createSafeContext } from '@mantine/core';\n\nexport interface DropzoneContextValue {\n idle: boolean;\n accept: boolean;\n reject: boolean;\n}\n\nexport const [DropzoneProvider, useDropzoneContext] = createSafeContext<DropzoneContextValue>(\n 'Dropzone component was not found in tree'\n);\n"],"mappings":";;;AAQA,MAAa,CAAC,kBAAkB,sBAAsB,kBACpD,2CACD"}
1
+ {"version":3,"file":"Dropzone.context.mjs","names":[],"sources":["../src/Dropzone.context.ts"],"sourcesContent":["import { createSafeContext } from '@mantine/core';\n\nexport interface DropzoneContextValue {\n idle: boolean;\n accept: boolean;\n reject: boolean;\n}\n\nexport const [DropzoneProvider, useDropzoneContext] = createSafeContext<DropzoneContextValue>(\n 'Dropzone component was not found in tree'\n);\n"],"mappings":";;;AAQA,MAAa,CAAC,kBAAkB,sBAAsB,kBACpD,0CACF"}
package/esm/Dropzone.mjs CHANGED
@@ -14,7 +14,7 @@ const defaultProps = {
14
14
  activateOnDrag: true,
15
15
  dragEventsBubbling: true,
16
16
  activateOnKeyboard: true,
17
- useFsAccessApi: true,
17
+ useFsAccessApi: false,
18
18
  variant: "light",
19
19
  rejectColor: "red"
20
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Dropzone.mjs","names":["classes"],"sources":["../src/Dropzone.tsx"],"sourcesContent":["import {\n Accept,\n DropEvent,\n FileError,\n FileRejection,\n FileWithPath,\n useDropzone,\n} from 'react-dropzone';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getRadius,\n LoaderProps,\n LoadingOverlay,\n MantineColor,\n MantineRadius,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { assignRef } from '@mantine/hooks';\nimport { DropzoneProvider } from './Dropzone.context';\nimport type {\n DropzoneFullScreenFactory,\n DropzoneFullScreenProps,\n DropzoneFullScreenStylesNames,\n DropzoneFullScreenType,\n} from './DropzoneFullScreen';\nimport { DropzoneAccept, DropzoneIdle, DropzoneReject } from './DropzoneStatus';\nimport classes from './Dropzone.module.css';\n\nexport type DropzoneStylesNames = 'root' | 'inner';\nexport type DropzoneVariant = 'filled' | 'light';\nexport type DropzoneCssVariables = {\n root:\n | '--dropzone-radius'\n | '--dropzone-accept-color'\n | '--dropzone-accept-bg'\n | '--dropzone-reject-color'\n | '--dropzone-reject-bg';\n};\n\nexport interface DropzoneProps\n extends BoxProps, StylesApiProps<DropzoneFactory>, ElementProps<'div', 'onDrop'> {\n /** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Accept` @default theme.primaryColor */\n acceptColor?: MantineColor;\n\n /** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Reject` @default 'red' */\n rejectColor?: MantineColor;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Determines whether files capturing should be disabled @default false */\n disabled?: boolean;\n\n /** Called when any files are dropped to the dropzone */\n onDropAny?: (files: FileWithPath[], fileRejections: FileRejection[]) => void;\n\n /** Called when valid files are dropped to the dropzone */\n onDrop: (files: FileWithPath[]) => void;\n\n /** Called when dropped files do not meet file restrictions */\n onReject?: (fileRejections: FileRejection[]) => void;\n\n /** Determines whether a loading overlay should be displayed over the dropzone @default false */\n loading?: boolean;\n\n /** Mime types of the files that dropzone can accepts. By default, dropzone accepts all file types. */\n accept?: Accept | string[];\n\n /** A ref function which when called opens the file system file picker */\n openRef?: React.Ref<() => void | undefined>;\n\n /** Determines whether multiple files can be dropped to the dropzone or selected from file system picker @default true */\n multiple?: boolean;\n\n /** Maximum file size in bytes */\n maxSize?: number;\n\n /** Name of the form control. Submitted with the form as part of a name/value pair. */\n name?: string;\n\n /** Maximum number of files that can be picked at once */\n maxFiles?: number;\n\n /** Set to autofocus the root element */\n autoFocus?: boolean;\n\n /** If `false`, disables click to open the native file selection dialog */\n activateOnClick?: boolean;\n\n /** If `false`, disables drag 'n' drop */\n activateOnDrag?: boolean;\n\n /** If `false`, disables Space/Enter to open the native file selection dialog. Note that it also stops tracking the focus state. */\n activateOnKeyboard?: boolean;\n\n /** If `false`, stops drag event propagation to parents */\n dragEventsBubbling?: boolean;\n\n /** Called when the `dragenter` event occurs */\n onDragEnter?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when the `dragleave` event occurs */\n onDragLeave?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when the `dragover` event occurs */\n onDragOver?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when user closes the file selection dialog with no selection */\n onFileDialogCancel?: () => void;\n\n /** Called when user opens the file selection dialog */\n onFileDialogOpen?: () => void;\n\n /** If `false`, allow dropped items to take over the current browser window */\n preventDropOnDocument?: boolean;\n\n /** Set to true to use the File System Access API to open the file picker instead of using an `input type=\"file\"` click event @default true */\n useFsAccessApi?: boolean;\n\n /** Use this to provide a custom file aggregator */\n getFilesFromEvent?: (event: DropEvent) => Promise<Array<File | DataTransferItem>>;\n\n /** Custom validation function. It must return null if there's no errors. */\n validator?: <T extends File>(file: T) => FileError | FileError[] | null;\n\n /** Determines whether pointer events should be enabled on the inner element @default false */\n enablePointerEvents?: boolean;\n\n /** Props passed down to the Loader component */\n loaderProps?: LoaderProps;\n\n /** Props passed down to the internal Input component */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport type DropzoneFactory = Factory<{\n props: DropzoneProps;\n ref: HTMLDivElement;\n stylesNames: DropzoneStylesNames;\n vars: DropzoneCssVariables;\n staticComponents: {\n Accept: typeof DropzoneAccept;\n Idle: typeof DropzoneIdle;\n Reject: typeof DropzoneReject;\n FullScreen: DropzoneFullScreenType;\n };\n}>;\n\nconst defaultProps = {\n multiple: true,\n maxSize: Infinity,\n activateOnClick: true,\n activateOnDrag: true,\n dragEventsBubbling: true,\n activateOnKeyboard: true,\n useFsAccessApi: true,\n variant: 'light',\n rejectColor: 'red',\n} satisfies Partial<DropzoneProps>;\n\nconst varsResolver = createVarsResolver<DropzoneFactory>(\n (theme, { radius, variant, acceptColor, rejectColor }) => {\n const acceptColors = theme.variantColorResolver({\n color: acceptColor || theme.primaryColor,\n theme,\n variant: variant!,\n });\n\n const rejectColors = theme.variantColorResolver({\n color: rejectColor || 'red',\n theme,\n variant: variant!,\n });\n\n return {\n root: {\n '--dropzone-radius': getRadius(radius),\n '--dropzone-accept-color': acceptColors.color,\n '--dropzone-accept-bg': acceptColors.background,\n '--dropzone-reject-color': rejectColors.color,\n '--dropzone-reject-bg': rejectColors.background,\n },\n };\n }\n);\n\nexport const Dropzone = factory<DropzoneFactory>((_props) => {\n const props = useProps('Dropzone', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n radius,\n disabled,\n loading,\n multiple,\n maxSize,\n accept,\n children,\n onDropAny,\n onDrop,\n onReject,\n openRef,\n name,\n maxFiles,\n autoFocus,\n activateOnClick,\n activateOnDrag,\n dragEventsBubbling,\n activateOnKeyboard,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onFileDialogCancel,\n onFileDialogOpen,\n preventDropOnDocument,\n useFsAccessApi,\n getFilesFromEvent,\n validator,\n rejectColor,\n acceptColor,\n enablePointerEvents,\n loaderProps,\n inputProps,\n mod,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<DropzoneFactory>({\n name: 'Dropzone',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { getRootProps, getInputProps, isDragAccept, isDragReject, isDragActive, open } =\n useDropzone({\n onDrop: onDropAny,\n onDropAccepted: onDrop,\n onDropRejected: onReject,\n disabled: disabled || loading,\n accept: Array.isArray(accept) ? accept.reduce((r, key) => ({ ...r, [key]: [] }), {}) : accept,\n multiple,\n maxSize,\n maxFiles,\n autoFocus,\n noClick: !activateOnClick,\n noDrag: !activateOnDrag,\n noDragEventsBubbling: !dragEventsBubbling,\n noKeyboard: !activateOnKeyboard,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onFileDialogCancel,\n onFileDialogOpen,\n preventDropOnDocument,\n useFsAccessApi,\n validator,\n ...(getFilesFromEvent ? { getFilesFromEvent } : null),\n });\n\n assignRef(openRef, open);\n\n const isAccepted = isDragActive && isDragAccept;\n const isRejected = isDragActive && isDragReject;\n const isIdle = !isAccepted && !isRejected;\n\n return (\n <DropzoneProvider value={{ accept: isAccepted, reject: isRejected, idle: isIdle }}>\n <Box\n {...getRootProps()}\n {...getStyles('root', { focusable: true })}\n {...others}\n mod={[\n {\n accept: isAccepted,\n reject: isRejected,\n idle: isIdle,\n disabled,\n loading,\n 'activate-on-click': activateOnClick,\n },\n mod,\n ]}\n >\n <LoadingOverlay\n visible={loading}\n overlayProps={{ radius }}\n unstyled={unstyled}\n loaderProps={loaderProps}\n />\n <input {...getInputProps(inputProps)} name={name} />\n <div {...getStyles('inner')} data-enable-pointer-events={enablePointerEvents || undefined}>\n {children}\n </div>\n </Box>\n </DropzoneProvider>\n );\n});\n\nDropzone.classes = classes;\nDropzone.varsResolver = varsResolver;\nDropzone.displayName = '@mantine/dropzone/Dropzone';\nDropzone.Accept = DropzoneAccept;\nDropzone.Idle = DropzoneIdle;\nDropzone.Reject = DropzoneReject;\n\nexport namespace Dropzone {\n export type Props = DropzoneProps;\n export type StylesNames = DropzoneStylesNames;\n export type CssVariables = DropzoneCssVariables;\n export type Factory = DropzoneFactory;\n\n export namespace FullScreen {\n export type Props = DropzoneFullScreenProps;\n export type StylesNames = DropzoneFullScreenStylesNames;\n export type Factory = DropzoneFullScreenFactory;\n }\n}\n"],"mappings":";;;;;;;;;AA2JA,MAAM,eAAe;CACnB,UAAU;CACV,SAAS;CACT,iBAAiB;CACjB,gBAAgB;CAChB,oBAAoB;CACpB,oBAAoB;CACpB,gBAAgB;CAChB,SAAS;CACT,aAAa;CACd;AAED,MAAM,eAAe,oBAClB,OAAO,EAAE,QAAQ,SAAS,aAAa,kBAAkB;CACxD,MAAM,eAAe,MAAM,qBAAqB;EAC9C,OAAO,eAAe,MAAM;EAC5B;EACS;EACV,CAAC;CAEF,MAAM,eAAe,MAAM,qBAAqB;EAC9C,OAAO,eAAe;EACtB;EACS;EACV,CAAC;AAEF,QAAO,EACL,MAAM;EACJ,qBAAqB,UAAU,OAAO;EACtC,2BAA2B,aAAa;EACxC,wBAAwB,aAAa;EACrC,2BAA2B,aAAa;EACxC,wBAAwB,aAAa;EACtC,EACF;EAEJ;AAED,MAAa,WAAW,SAA0B,WAAW;CAC3D,MAAM,QAAQ,SAAS,YAAY,cAAc,OAAO;CACxD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,QACA,UACA,SACA,UACA,SACA,QACA,UACA,WACA,QACA,UACA,SACA,MACA,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QAAQ;KAAE,8BAA4B,uBAAuB,KAAA;KAC7E;KACG,CAAA;IACF;;EACW,CAAA;EAErB;AAEF,SAAS,UAAUA;AACnB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,SAAS;AAClB,SAAS,OAAO;AAChB,SAAS,SAAS"}
1
+ {"version":3,"file":"Dropzone.mjs","names":["classes"],"sources":["../src/Dropzone.tsx"],"sourcesContent":["import {\n Accept,\n DropEvent,\n FileError,\n FileRejection,\n FileWithPath,\n useDropzone,\n} from 'react-dropzone';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getRadius,\n LoaderProps,\n LoadingOverlay,\n MantineColor,\n MantineRadius,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { assignRef } from '@mantine/hooks';\nimport { DropzoneProvider } from './Dropzone.context';\nimport type {\n DropzoneFullScreenFactory,\n DropzoneFullScreenProps,\n DropzoneFullScreenStylesNames,\n DropzoneFullScreenType,\n} from './DropzoneFullScreen';\nimport { DropzoneAccept, DropzoneIdle, DropzoneReject } from './DropzoneStatus';\nimport classes from './Dropzone.module.css';\n\nexport type DropzoneStylesNames = 'root' | 'inner';\nexport type DropzoneVariant = 'filled' | 'light';\nexport type DropzoneCssVariables = {\n root:\n | '--dropzone-radius'\n | '--dropzone-accept-color'\n | '--dropzone-accept-bg'\n | '--dropzone-reject-color'\n | '--dropzone-reject-bg';\n};\n\nexport interface DropzoneProps\n extends BoxProps, StylesApiProps<DropzoneFactory>, ElementProps<'div', 'onDrop'> {\n /** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Accept` @default theme.primaryColor */\n acceptColor?: MantineColor;\n\n /** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Reject` @default 'red' */\n rejectColor?: MantineColor;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Determines whether files capturing should be disabled @default false */\n disabled?: boolean;\n\n /** Called when any files are dropped to the dropzone */\n onDropAny?: (files: FileWithPath[], fileRejections: FileRejection[]) => void;\n\n /** Called when valid files are dropped to the dropzone */\n onDrop: (files: FileWithPath[]) => void;\n\n /** Called when dropped files do not meet file restrictions */\n onReject?: (fileRejections: FileRejection[]) => void;\n\n /** Determines whether a loading overlay should be displayed over the dropzone @default false */\n loading?: boolean;\n\n /** Mime types of the files that dropzone can accepts. By default, dropzone accepts all file types. */\n accept?: Accept | string[];\n\n /** A ref function which when called opens the file system file picker */\n openRef?: React.Ref<() => void | undefined>;\n\n /** Determines whether multiple files can be dropped to the dropzone or selected from file system picker @default true */\n multiple?: boolean;\n\n /** Maximum file size in bytes */\n maxSize?: number;\n\n /** Name of the form control. Submitted with the form as part of a name/value pair. */\n name?: string;\n\n /** Maximum number of files that can be picked at once */\n maxFiles?: number;\n\n /** Set to autofocus the root element */\n autoFocus?: boolean;\n\n /** If `false`, disables click to open the native file selection dialog */\n activateOnClick?: boolean;\n\n /** If `false`, disables drag 'n' drop */\n activateOnDrag?: boolean;\n\n /** If `false`, disables Space/Enter to open the native file selection dialog. Note that it also stops tracking the focus state. */\n activateOnKeyboard?: boolean;\n\n /** If `false`, stops drag event propagation to parents */\n dragEventsBubbling?: boolean;\n\n /** Called when the `dragenter` event occurs */\n onDragEnter?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when the `dragleave` event occurs */\n onDragLeave?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when the `dragover` event occurs */\n onDragOver?: (event: React.DragEvent<HTMLElement>) => void;\n\n /** Called when user closes the file selection dialog with no selection */\n onFileDialogCancel?: () => void;\n\n /** Called when user opens the file selection dialog */\n onFileDialogOpen?: () => void;\n\n /** If `false`, allow dropped items to take over the current browser window */\n preventDropOnDocument?: boolean;\n\n /** Set to true to use the File System Access API to open the file picker instead of using an `input type=\"file\"` click event @default false */\n useFsAccessApi?: boolean;\n\n /** Use this to provide a custom file aggregator */\n getFilesFromEvent?: (event: DropEvent) => Promise<Array<File | DataTransferItem>>;\n\n /** Custom validation function. It must return null if there's no errors. */\n validator?: <T extends File>(file: T) => FileError | FileError[] | null;\n\n /** Determines whether pointer events should be enabled on the inner element @default false */\n enablePointerEvents?: boolean;\n\n /** Props passed down to the Loader component */\n loaderProps?: LoaderProps;\n\n /** Props passed down to the internal Input component */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport type DropzoneFactory = Factory<{\n props: DropzoneProps;\n ref: HTMLDivElement;\n stylesNames: DropzoneStylesNames;\n vars: DropzoneCssVariables;\n staticComponents: {\n Accept: typeof DropzoneAccept;\n Idle: typeof DropzoneIdle;\n Reject: typeof DropzoneReject;\n FullScreen: DropzoneFullScreenType;\n };\n}>;\n\nconst defaultProps = {\n multiple: true,\n maxSize: Infinity,\n activateOnClick: true,\n activateOnDrag: true,\n dragEventsBubbling: true,\n activateOnKeyboard: true,\n useFsAccessApi: false,\n variant: 'light',\n rejectColor: 'red',\n} satisfies Partial<DropzoneProps>;\n\nconst varsResolver = createVarsResolver<DropzoneFactory>(\n (theme, { radius, variant, acceptColor, rejectColor }) => {\n const acceptColors = theme.variantColorResolver({\n color: acceptColor || theme.primaryColor,\n theme,\n variant: variant!,\n });\n\n const rejectColors = theme.variantColorResolver({\n color: rejectColor || 'red',\n theme,\n variant: variant!,\n });\n\n return {\n root: {\n '--dropzone-radius': getRadius(radius),\n '--dropzone-accept-color': acceptColors.color,\n '--dropzone-accept-bg': acceptColors.background,\n '--dropzone-reject-color': rejectColors.color,\n '--dropzone-reject-bg': rejectColors.background,\n },\n };\n }\n);\n\nexport const Dropzone = factory<DropzoneFactory>((_props) => {\n const props = useProps('Dropzone', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n radius,\n disabled,\n loading,\n multiple,\n maxSize,\n accept,\n children,\n onDropAny,\n onDrop,\n onReject,\n openRef,\n name,\n maxFiles,\n autoFocus,\n activateOnClick,\n activateOnDrag,\n dragEventsBubbling,\n activateOnKeyboard,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onFileDialogCancel,\n onFileDialogOpen,\n preventDropOnDocument,\n useFsAccessApi,\n getFilesFromEvent,\n validator,\n rejectColor,\n acceptColor,\n enablePointerEvents,\n loaderProps,\n inputProps,\n mod,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<DropzoneFactory>({\n name: 'Dropzone',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { getRootProps, getInputProps, isDragAccept, isDragReject, isDragActive, open } =\n useDropzone({\n onDrop: onDropAny,\n onDropAccepted: onDrop,\n onDropRejected: onReject,\n disabled: disabled || loading,\n accept: Array.isArray(accept) ? accept.reduce((r, key) => ({ ...r, [key]: [] }), {}) : accept,\n multiple,\n maxSize,\n maxFiles,\n autoFocus,\n noClick: !activateOnClick,\n noDrag: !activateOnDrag,\n noDragEventsBubbling: !dragEventsBubbling,\n noKeyboard: !activateOnKeyboard,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onFileDialogCancel,\n onFileDialogOpen,\n preventDropOnDocument,\n useFsAccessApi,\n validator,\n ...(getFilesFromEvent ? { getFilesFromEvent } : null),\n });\n\n assignRef(openRef, open);\n\n const isAccepted = isDragActive && isDragAccept;\n const isRejected = isDragActive && isDragReject;\n const isIdle = !isAccepted && !isRejected;\n\n return (\n <DropzoneProvider value={{ accept: isAccepted, reject: isRejected, idle: isIdle }}>\n <Box\n {...getRootProps()}\n {...getStyles('root', { focusable: true })}\n {...others}\n mod={[\n {\n accept: isAccepted,\n reject: isRejected,\n idle: isIdle,\n disabled,\n loading,\n 'activate-on-click': activateOnClick,\n },\n mod,\n ]}\n >\n <LoadingOverlay\n visible={loading}\n overlayProps={{ radius }}\n unstyled={unstyled}\n loaderProps={loaderProps}\n />\n <input {...getInputProps(inputProps)} name={name} />\n <div {...getStyles('inner')} data-enable-pointer-events={enablePointerEvents || undefined}>\n {children}\n </div>\n </Box>\n </DropzoneProvider>\n );\n});\n\nDropzone.classes = classes;\nDropzone.varsResolver = varsResolver;\nDropzone.displayName = '@mantine/dropzone/Dropzone';\nDropzone.Accept = DropzoneAccept;\nDropzone.Idle = DropzoneIdle;\nDropzone.Reject = DropzoneReject;\n\nexport namespace Dropzone {\n export type Props = DropzoneProps;\n export type StylesNames = DropzoneStylesNames;\n export type CssVariables = DropzoneCssVariables;\n export type Factory = DropzoneFactory;\n\n export namespace FullScreen {\n export type Props = DropzoneFullScreenProps;\n export type StylesNames = DropzoneFullScreenStylesNames;\n export type Factory = DropzoneFullScreenFactory;\n }\n}\n"],"mappings":";;;;;;;;;AA2JA,MAAM,eAAe;CACnB,UAAU;CACV,SAAS;CACT,iBAAiB;CACjB,gBAAgB;CAChB,oBAAoB;CACpB,oBAAoB;CACpB,gBAAgB;CAChB,SAAS;CACT,aAAa;AACf;AAEA,MAAM,eAAe,oBAClB,OAAO,EAAE,QAAQ,SAAS,aAAa,kBAAkB;CACxD,MAAM,eAAe,MAAM,qBAAqB;EAC9C,OAAO,eAAe,MAAM;EAC5B;EACS;CACX,CAAC;CAED,MAAM,eAAe,MAAM,qBAAqB;EAC9C,OAAO,eAAe;EACtB;EACS;CACX,CAAC;CAED,OAAO,EACL,MAAM;EACJ,qBAAqB,UAAU,MAAM;EACrC,2BAA2B,aAAa;EACxC,wBAAwB,aAAa;EACrC,2BAA2B,aAAa;EACxC,wBAAwB,aAAa;CACvC,EACF;AACF,CACF;AAEA,MAAa,WAAW,SAA0B,WAAW;CAC3D,MAAM,QAAQ,SAAS,YAAY,cAAc,MAAM;CACvD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,QACA,UACA,SACA,UACA,SACA,QACA,UACA,WACA,QACA,UACA,SACA,MACA,UACA,WACA,iBACA,gBACA,oBACA,oBACA,aACA,aACA,YACA,oBACA,kBACA,uBACA,gBACA,mBACA,WACA,aACA,aACA,qBACA,aACA,YACA,KACA,YACA,GAAG,WACD;CAE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vB,SAAS,SAAS;AAClB,SAAS,OAAO;AAChB,SAAS,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"DropzoneFullScreen.mjs","names":["classes"],"sources":["../src/DropzoneFullScreen.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport {\n BasePortalProps,\n Box,\n BoxProps,\n ElementProps,\n factory,\n Factory,\n getDefaultZIndex,\n OptionalPortal,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { useDisclosure } from '@mantine/hooks';\nimport { Dropzone, DropzoneProps, DropzoneStylesNames, DropzoneVariant } from './Dropzone';\nimport classes from './Dropzone.module.css';\n\nexport type DropzoneFullScreenStylesNames = DropzoneStylesNames | 'fullScreen';\n\nexport interface DropzoneFullScreenProps\n extends\n BoxProps,\n Omit<DropzoneProps, 'styles' | 'classNames' | 'vars' | 'variant' | 'attributes'>,\n StylesApiProps<DropzoneFullScreenFactory>,\n ElementProps<'div', 'onDragLeave' | 'onDragOver' | 'onDrop' | 'onDragEnter'> {\n /** Determines whether user can drop files to browser window @default true */\n active?: boolean;\n\n /** Z-index value @default 9999 */\n zIndex?: React.CSSProperties['zIndex'];\n\n /** Determines whether component should be rendered within `Portal` @default true */\n withinPortal?: boolean;\n\n /** Props to pass down to the portal when withinPortal is `true` */\n portalProps?: Omit<BasePortalProps, 'withinPortal'>;\n}\n\nexport type DropzoneFullScreenFactory = Factory<{\n props: DropzoneFullScreenProps;\n ref: HTMLDivElement;\n stylesNames: DropzoneFullScreenStylesNames;\n variant: DropzoneVariant;\n}>;\n\nconst defaultProps = {\n maxSize: Infinity,\n activateOnDrag: true,\n dragEventsBubbling: true,\n activateOnKeyboard: true,\n active: true,\n zIndex: getDefaultZIndex('max'),\n withinPortal: true,\n} satisfies Partial<DropzoneFullScreenProps>;\n\nexport const DropzoneFullScreen = factory<DropzoneFullScreenFactory>((_props) => {\n const props = useProps('DropzoneFullScreen', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n active,\n onDrop,\n onReject,\n zIndex,\n withinPortal,\n portalProps,\n attributes,\n mod,\n ...others\n } = props;\n\n const getStyles = useStyles<DropzoneFullScreenFactory>({\n name: 'DropzoneFullScreen',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n rootSelector: 'fullScreen',\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<DropzoneFullScreenFactory>({\n classNames,\n styles,\n props,\n });\n\n const [counter, setCounter] = useState(0);\n const [visible, { open, close }] = useDisclosure(false);\n\n const handleDragEnter = (event: DragEvent) => {\n if (event.dataTransfer?.types.includes('Files')) {\n setCounter((prev) => prev + 1);\n open();\n }\n };\n\n const handleDragLeave = () => {\n setCounter((prev) => prev - 1);\n };\n\n useEffect(() => {\n counter === 0 && close();\n }, [counter]);\n\n useEffect(() => {\n if (!active) {\n return undefined;\n }\n\n document.addEventListener('dragenter', handleDragEnter, false);\n document.addEventListener('dragleave', handleDragLeave, false);\n\n return () => {\n document.removeEventListener('dragenter', handleDragEnter, false);\n document.removeEventListener('dragleave', handleDragLeave, false);\n };\n }, [active]);\n\n return (\n <OptionalPortal {...portalProps} withinPortal={withinPortal}>\n <Box\n {...getStyles('fullScreen', {\n style: { opacity: visible ? 1 : 0, pointerEvents: visible ? 'all' : 'none', zIndex },\n })}\n >\n <Dropzone\n activateOnClick={false}\n {...others}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n className={classes.dropzone}\n onDrop={(files: any) => {\n onDrop?.(files);\n close();\n setCounter(0);\n }}\n onReject={(files: any) => {\n onReject?.(files);\n close();\n setCounter(0);\n }}\n />\n </Box>\n </OptionalPortal>\n );\n});\n\nDropzoneFullScreen.classes = classes;\nDropzoneFullScreen.displayName = '@mantine/dropzone/DropzoneFullScreen';\n\nexport type DropzoneFullScreenType = typeof DropzoneFullScreen;\n"],"mappings":";;;;;;;;AA+CA,MAAM,eAAe;CACnB,SAAS;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iBAAiB;IACjB,GAAI;IACJ,YAAY;IACZ,QAAQ;IACE;IACV,WAAWA,wBAAQ;IACnB,SAAS,UAAe;AACtB,cAAS,MAAM;AACf,YAAO;AACP,gBAAW,EAAE;;IAEf,WAAW,UAAe;AACxB,gBAAW,MAAM;AACjB,YAAO;AACP,gBAAW,EAAE;;IAEf,CAAA;GACE,CAAA;EACS,CAAA;EAEnB;AAEF,mBAAmB,UAAUA;AAC7B,mBAAmB,cAAc"}
1
+ {"version":3,"file":"DropzoneFullScreen.mjs","names":["classes"],"sources":["../src/DropzoneFullScreen.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport {\n BasePortalProps,\n Box,\n BoxProps,\n ElementProps,\n factory,\n Factory,\n getDefaultZIndex,\n OptionalPortal,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { useDisclosure } from '@mantine/hooks';\nimport { Dropzone, DropzoneProps, DropzoneStylesNames, DropzoneVariant } from './Dropzone';\nimport classes from './Dropzone.module.css';\n\nexport type DropzoneFullScreenStylesNames = DropzoneStylesNames | 'fullScreen';\n\nexport interface DropzoneFullScreenProps\n extends\n BoxProps,\n Omit<DropzoneProps, 'styles' | 'classNames' | 'vars' | 'variant' | 'attributes'>,\n StylesApiProps<DropzoneFullScreenFactory>,\n ElementProps<'div', 'onDragLeave' | 'onDragOver' | 'onDrop' | 'onDragEnter'> {\n /** Determines whether user can drop files to browser window @default true */\n active?: boolean;\n\n /** Z-index value @default 9999 */\n zIndex?: React.CSSProperties['zIndex'];\n\n /** Determines whether component should be rendered within `Portal` @default true */\n withinPortal?: boolean;\n\n /** Props to pass down to the portal when withinPortal is `true` */\n portalProps?: Omit<BasePortalProps, 'withinPortal'>;\n}\n\nexport type DropzoneFullScreenFactory = Factory<{\n props: DropzoneFullScreenProps;\n ref: HTMLDivElement;\n stylesNames: DropzoneFullScreenStylesNames;\n variant: DropzoneVariant;\n}>;\n\nconst defaultProps = {\n maxSize: Infinity,\n activateOnDrag: true,\n dragEventsBubbling: true,\n activateOnKeyboard: true,\n active: true,\n zIndex: getDefaultZIndex('max'),\n withinPortal: true,\n} satisfies Partial<DropzoneFullScreenProps>;\n\nexport const DropzoneFullScreen = factory<DropzoneFullScreenFactory>((_props) => {\n const props = useProps('DropzoneFullScreen', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n active,\n onDrop,\n onReject,\n zIndex,\n withinPortal,\n portalProps,\n attributes,\n mod,\n ...others\n } = props;\n\n const getStyles = useStyles<DropzoneFullScreenFactory>({\n name: 'DropzoneFullScreen',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n rootSelector: 'fullScreen',\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<DropzoneFullScreenFactory>({\n classNames,\n styles,\n props,\n });\n\n const [counter, setCounter] = useState(0);\n const [visible, { open, close }] = useDisclosure(false);\n\n const handleDragEnter = (event: DragEvent) => {\n if (event.dataTransfer?.types.includes('Files')) {\n setCounter((prev) => prev + 1);\n open();\n }\n };\n\n const handleDragLeave = () => {\n setCounter((prev) => prev - 1);\n };\n\n useEffect(() => {\n counter === 0 && close();\n }, [counter]);\n\n useEffect(() => {\n if (!active) {\n return undefined;\n }\n\n document.addEventListener('dragenter', handleDragEnter, false);\n document.addEventListener('dragleave', handleDragLeave, false);\n\n return () => {\n document.removeEventListener('dragenter', handleDragEnter, false);\n document.removeEventListener('dragleave', handleDragLeave, false);\n };\n }, [active]);\n\n return (\n <OptionalPortal {...portalProps} withinPortal={withinPortal}>\n <Box\n {...getStyles('fullScreen', {\n style: { opacity: visible ? 1 : 0, pointerEvents: visible ? 'all' : 'none', zIndex },\n })}\n >\n <Dropzone\n activateOnClick={false}\n {...others}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n className={classes.dropzone}\n onDrop={(files: any) => {\n onDrop?.(files);\n close();\n setCounter(0);\n }}\n onReject={(files: any) => {\n onReject?.(files);\n close();\n setCounter(0);\n }}\n />\n </Box>\n </OptionalPortal>\n );\n});\n\nDropzoneFullScreen.classes = classes;\nDropzoneFullScreen.displayName = '@mantine/dropzone/DropzoneFullScreen';\n\nexport type DropzoneFullScreenType = typeof DropzoneFullScreen;\n"],"mappings":";;;;;;;;AA+CA,MAAM,eAAe;CACnB,SAAS;CACT,gBAAgB;CAChB,oBAAoB;CACpB,oBAAoB;CACpB,QAAQ;CACR,QAAQ,iBAAiB,KAAK;CAC9B,cAAc;AAChB;AAEA,MAAa,qBAAqB,SAAoC,WAAW;CAC/E,MAAM,QAAQ,SAAS,sBAAsB,cAAc,MAAM;CACjE,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,QACA,QACA,UACA,QACA,cACA,aACA,YACA,KACA,GAAG,WACD;CAEJ,MAAM,YAAY,UAAqC;EACrD,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;CAChB,CAAC;CAED,MAAM,EAAE,oBAAoB,mBAAmB,qBAAgD;EAC7F;EACA;EACA;CACF,CAAC;CAED,MAAM,CAAC,SAAS,cAAc,SAAS,CAAC;CACxC,MAAM,CAAC,SAAS,EAAE,MAAM,WAAW,cAAc,KAAK;CAEtD,MAAM,mBAAmB,UAAqB;EAC5C,IAAI,MAAM,cAAc,MAAM,SAAS,OAAO,GAAG;GAC/C,YAAY,SAAS,OAAO,CAAC;GAC7B,KAAK;EACP;CACF;CAEA,MAAM,wBAAwB;EAC5B,YAAY,SAAS,OAAO,CAAC;CAC/B;CAEA,gBAAgB;EACd,YAAY,KAAK,MAAM;CACzB,GAAG,CAAC,OAAO,CAAC;CAEZ,gBAAgB;EACd,IAAI,CAAC,QACH;EAGF,SAAS,iBAAiB,aAAa,iBAAiB,KAAK;EAC7D,SAAS,iBAAiB,aAAa,iBAAiB,KAAK;EAE7D,aAAa;GACX,SAAS,oBAAoB,aAAa,iBAAiB,KAAK;GAChE,SAAS,oBAAoB,aAAa,iBAAiB,KAAK;EAClE;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,OACE,oBAAC,gBAAD;EAAgB,GAAI;EAA2B;YAC7C,oBAAC,KAAD;GACE,GAAI,UAAU,cAAc,EAC1B,OAAO;IAAE,SAAS,UAAU,IAAI;IAAG,eAAe,UAAU,QAAQ;IAAQ;GAAO,EACrF,CAAC;aAED,oBAAC,UAAD;IACE,iBAAiB;IACjB,GAAI;IACJ,YAAY;IACZ,QAAQ;IACE;IACV,WAAWA,wBAAQ;IACnB,SAAS,UAAe;KACtB,SAAS,KAAK;KACd,MAAM;KACN,WAAW,CAAC;IACd;IACA,WAAW,UAAe;KACxB,WAAW,KAAK;KAChB,MAAM;KACN,WAAW,CAAC;IACd;GACD,CAAA;EACE,CAAA;CACS,CAAA;AAEpB,CAAC;AAED,mBAAmB,UAAUA;AAC7B,mBAAmB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"DropzoneStatus.mjs","names":[],"sources":["../src/DropzoneStatus.tsx"],"sourcesContent":["import { cloneElement } from 'react';\nimport { isElement, useProps } from '@mantine/core';\nimport { upperFirst } from '@mantine/hooks';\nimport { DropzoneContextValue, useDropzoneContext } from './Dropzone.context';\n\nexport interface DropzoneStatusProps {\n children: React.ReactNode;\n}\n\ntype DropzoneStatusComponent = React.FC<DropzoneStatusProps>;\n\nfunction createDropzoneStatus(status: keyof DropzoneContextValue) {\n const Component: DropzoneStatusComponent = (props) => {\n const { children, ...others } = useProps(`Dropzone${upperFirst(status)}`, {}, props);\n\n const ctx = useDropzoneContext();\n const _children = isElement(children) ? children : <span>{children}</span>;\n\n if (ctx[status]) {\n return cloneElement(_children as React.JSX.Element, others);\n }\n\n return null;\n };\n\n Component.displayName = `@mantine/dropzone/${upperFirst(status)}`;\n\n return Component;\n}\n\nexport const DropzoneAccept = createDropzoneStatus('accept');\nexport const DropzoneReject = createDropzoneStatus('reject');\nexport const DropzoneIdle = createDropzoneStatus('idle');\n\nexport type DropzoneAcceptProps = DropzoneStatusProps;\nexport type DropzoneRejectProps = DropzoneStatusProps;\nexport type DropzoneIdleProps = DropzoneStatusProps;\n"],"mappings":";;;;;;;AAWA,SAAS,qBAAqB,QAAoC;CAChE,MAAM,aAAsC,UAAU;EACpD,MAAM,EAAE,UAAU,GAAG,WAAW,SAAS,WAAW,WAAW,OAAO,IAAI,EAAE,EAAE,MAAM;EAEpF,MAAM,MAAM,oBAAoB;EAChC,MAAM,YAAY,UAAU,SAAS,GAAG,WAAW,oBAAC,QAAD,EAAO,UAAgB,CAAA;AAE1E,MAAI,IAAI,QACN,QAAO,aAAa,WAAgC,OAAO;AAG7D,SAAO;;AAGT,WAAU,cAAc,qBAAqB,WAAW,OAAO;AAE/D,QAAO;;AAGT,MAAa,iBAAiB,qBAAqB,SAAS;AAC5D,MAAa,iBAAiB,qBAAqB,SAAS;AAC5D,MAAa,eAAe,qBAAqB,OAAO"}
1
+ {"version":3,"file":"DropzoneStatus.mjs","names":[],"sources":["../src/DropzoneStatus.tsx"],"sourcesContent":["import { cloneElement } from 'react';\nimport { isElement, useProps } from '@mantine/core';\nimport { upperFirst } from '@mantine/hooks';\nimport { DropzoneContextValue, useDropzoneContext } from './Dropzone.context';\n\nexport interface DropzoneStatusProps {\n children: React.ReactNode;\n}\n\ntype DropzoneStatusComponent = React.FC<DropzoneStatusProps>;\n\nfunction createDropzoneStatus(status: keyof DropzoneContextValue) {\n const Component: DropzoneStatusComponent = (props) => {\n const { children, ...others } = useProps(`Dropzone${upperFirst(status)}`, {}, props);\n\n const ctx = useDropzoneContext();\n const _children = isElement(children) ? children : <span>{children}</span>;\n\n if (ctx[status]) {\n return cloneElement(_children as React.JSX.Element, others);\n }\n\n return null;\n };\n\n Component.displayName = `@mantine/dropzone/${upperFirst(status)}`;\n\n return Component;\n}\n\nexport const DropzoneAccept = createDropzoneStatus('accept');\nexport const DropzoneReject = createDropzoneStatus('reject');\nexport const DropzoneIdle = createDropzoneStatus('idle');\n\nexport type DropzoneAcceptProps = DropzoneStatusProps;\nexport type DropzoneRejectProps = DropzoneStatusProps;\nexport type DropzoneIdleProps = DropzoneStatusProps;\n"],"mappings":";;;;;;;AAWA,SAAS,qBAAqB,QAAoC;CAChE,MAAM,aAAsC,UAAU;EACpD,MAAM,EAAE,UAAU,GAAG,WAAW,SAAS,WAAW,WAAW,MAAM,KAAK,CAAC,GAAG,KAAK;EAEnF,MAAM,MAAM,mBAAmB;EAC/B,MAAM,YAAY,UAAU,QAAQ,IAAI,WAAW,oBAAC,QAAD,EAAO,SAAe,CAAA;EAEzE,IAAI,IAAI,SACN,OAAO,aAAa,WAAgC,MAAM;EAG5D,OAAO;CACT;CAEA,UAAU,cAAc,qBAAqB,WAAW,MAAM;CAE9D,OAAO;AACT;AAEA,MAAa,iBAAiB,qBAAqB,QAAQ;AAC3D,MAAa,iBAAiB,qBAAqB,QAAQ;AAC3D,MAAa,eAAe,qBAAqB,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"mime-types.mjs","names":[],"sources":["../src/mime-types.ts"],"sourcesContent":["export const MIME_TYPES = {\n // Images\n png: 'image/png',\n gif: 'image/gif',\n jpeg: 'image/jpeg',\n svg: 'image/svg+xml',\n webp: 'image/webp',\n avif: 'image/avif',\n heic: 'image/heic',\n heif: 'image/heif',\n\n // Documents\n mp4: 'video/mp4',\n zip: 'application/zip',\n rar: 'application/x-rar',\n '7z': 'application/x-7z-compressed',\n csv: 'text/csv',\n pdf: 'application/pdf',\n doc: 'application/msword',\n docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n xls: 'application/vnd.ms-excel',\n xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ppt: 'application/vnd.ms-powerpoint',\n pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n exe: 'application/vnd.microsoft.portable-executable',\n} as const;\n\nexport const IMAGE_MIME_TYPE = [\n MIME_TYPES.png,\n MIME_TYPES.gif,\n MIME_TYPES.jpeg,\n MIME_TYPES.svg,\n MIME_TYPES.webp,\n MIME_TYPES.avif,\n MIME_TYPES.heic,\n MIME_TYPES.heif,\n];\n\nexport const PDF_MIME_TYPE = [MIME_TYPES.pdf];\nexport const MS_WORD_MIME_TYPE = [MIME_TYPES.doc, MIME_TYPES.docx];\nexport const MS_EXCEL_MIME_TYPE = [MIME_TYPES.xls, MIME_TYPES.xlsx];\nexport const MS_POWERPOINT_MIME_TYPE = [MIME_TYPES.ppt, MIME_TYPES.pptx];\nexport const EXE_MIME_TYPE = [MIME_TYPES.exe];\n"],"mappings":";;AAAA,MAAa,aAAa;CAExB,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CAGN,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACN;AAED,MAAa,kBAAkB;CAC7B,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACZ;AAED,MAAa,gBAAgB,CAAC,WAAW,IAAI;AAC7C,MAAa,oBAAoB,CAAC,WAAW,KAAK,WAAW,KAAK;AAClE,MAAa,qBAAqB,CAAC,WAAW,KAAK,WAAW,KAAK;AACnE,MAAa,0BAA0B,CAAC,WAAW,KAAK,WAAW,KAAK;AACxE,MAAa,gBAAgB,CAAC,WAAW,IAAI"}
1
+ {"version":3,"file":"mime-types.mjs","names":[],"sources":["../src/mime-types.ts"],"sourcesContent":["export const MIME_TYPES = {\n // Images\n png: 'image/png',\n gif: 'image/gif',\n jpeg: 'image/jpeg',\n svg: 'image/svg+xml',\n webp: 'image/webp',\n avif: 'image/avif',\n heic: 'image/heic',\n heif: 'image/heif',\n\n // Documents\n mp4: 'video/mp4',\n zip: 'application/zip',\n rar: 'application/x-rar',\n '7z': 'application/x-7z-compressed',\n csv: 'text/csv',\n pdf: 'application/pdf',\n doc: 'application/msword',\n docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n xls: 'application/vnd.ms-excel',\n xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ppt: 'application/vnd.ms-powerpoint',\n pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n exe: 'application/vnd.microsoft.portable-executable',\n} as const;\n\nexport const IMAGE_MIME_TYPE = [\n MIME_TYPES.png,\n MIME_TYPES.gif,\n MIME_TYPES.jpeg,\n MIME_TYPES.svg,\n MIME_TYPES.webp,\n MIME_TYPES.avif,\n MIME_TYPES.heic,\n MIME_TYPES.heif,\n];\n\nexport const PDF_MIME_TYPE = [MIME_TYPES.pdf];\nexport const MS_WORD_MIME_TYPE = [MIME_TYPES.doc, MIME_TYPES.docx];\nexport const MS_EXCEL_MIME_TYPE = [MIME_TYPES.xls, MIME_TYPES.xlsx];\nexport const MS_POWERPOINT_MIME_TYPE = [MIME_TYPES.ppt, MIME_TYPES.pptx];\nexport const EXE_MIME_TYPE = [MIME_TYPES.exe];\n"],"mappings":";;AAAA,MAAa,aAAa;CAExB,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CAGN,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;AACP;AAEA,MAAa,kBAAkB;CAC7B,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;AACb;AAEA,MAAa,gBAAgB,CAAC,WAAW,GAAG;AAC5C,MAAa,oBAAoB,CAAC,WAAW,KAAK,WAAW,IAAI;AACjE,MAAa,qBAAqB,CAAC,WAAW,KAAK,WAAW,IAAI;AAClE,MAAa,0BAA0B,CAAC,WAAW,KAAK,WAAW,IAAI;AACvE,MAAa,gBAAgB,CAAC,WAAW,GAAG"}
package/lib/Dropzone.d.ts CHANGED
@@ -58,7 +58,7 @@ export interface DropzoneProps extends BoxProps, StylesApiProps<DropzoneFactory>
58
58
  onFileDialogOpen?: () => void;
59
59
  /** If `false`, allow dropped items to take over the current browser window */
60
60
  preventDropOnDocument?: boolean;
61
- /** Set to true to use the File System Access API to open the file picker instead of using an `input type="file"` click event @default true */
61
+ /** Set to true to use the File System Access API to open the file picker instead of using an `input type="file"` click event @default false */
62
62
  useFsAccessApi?: boolean;
63
63
  /** Use this to provide a custom file aggregator */
64
64
  getFilesFromEvent?: (event: DropEvent) => Promise<Array<File | DataTransferItem>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/dropzone",
3
- "version": "9.1.1",
3
+ "version": "9.2.1",
4
4
  "description": "Dropzone component built with Mantine theme and components",
5
5
  "homepage": "https://mantine.dev/x/dropzone/",
6
6
  "license": "MIT",
@@ -44,8 +44,8 @@
44
44
  "directory": "packages/@mantine/dropzone"
45
45
  },
46
46
  "peerDependencies": {
47
- "@mantine/core": "9.1.1",
48
- "@mantine/hooks": "9.1.1",
47
+ "@mantine/core": "9.2.1",
48
+ "@mantine/hooks": "9.2.1",
49
49
  "react": "^19.2.0",
50
50
  "react-dom": "^19.2.0"
51
51
  },
@@ -56,7 +56,7 @@
56
56
  "@mantine-tests/core": "workspace:*",
57
57
  "@mantine/core": "workspace:*",
58
58
  "@mantine/hooks": "workspace:*",
59
- "react": "19.2.5",
60
- "react-dom": "19.2.5"
59
+ "react": "19.2.6",
60
+ "react-dom": "19.2.6"
61
61
  }
62
62
  }