@yamada-ui/dropzone 1.0.52-dev-20241117124902 → 1.0.52-dev-20241118161617
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-3QSKWUOX.mjs → chunk-ZCUDAOHK.mjs} +7 -5
- package/dist/chunk-ZCUDAOHK.mjs.map +1 -0
- package/dist/dropzone.js +6 -4
- package/dist/dropzone.js.map +1 -1
- package/dist/dropzone.mjs +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
- package/dist/chunk-3QSKWUOX.mjs.map +0 -1
@@ -60,10 +60,10 @@ var Dropzone = forwardRef((props, ref) => {
|
|
60
60
|
...rest
|
61
61
|
} = useFormControlProps(omitThemeProps(mergedProps));
|
62
62
|
const disabled = isLoading || rest.disabled || rest.readOnly;
|
63
|
-
const [
|
64
|
-
|
65
|
-
|
66
|
-
);
|
63
|
+
const [
|
64
|
+
{ "aria-readonly": ariaReadOnly, ...formControlProps },
|
65
|
+
containerProps
|
66
|
+
] = splitObject(rest, formControlProperties);
|
67
67
|
const { isDragAccept, isDragReject, open, getInputProps, getRootProps } = useDropzone({
|
68
68
|
accept: isArray(accept) ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {}) : accept,
|
69
69
|
autoFocus,
|
@@ -104,6 +104,7 @@ var Dropzone = forwardRef((props, ref) => {
|
|
104
104
|
{
|
105
105
|
className: cx("ui-dropzone", className),
|
106
106
|
__css: css,
|
107
|
+
...formControlProps,
|
107
108
|
...containerProps,
|
108
109
|
...getRootProps({}),
|
109
110
|
"data-accept": dataAttr(isDragAccept),
|
@@ -118,6 +119,7 @@ var Dropzone = forwardRef((props, ref) => {
|
|
118
119
|
id,
|
119
120
|
ref,
|
120
121
|
name,
|
122
|
+
"aria-readonly": ariaReadOnly,
|
121
123
|
...formControlProps,
|
122
124
|
...getInputProps()
|
123
125
|
}
|
@@ -193,4 +195,4 @@ export {
|
|
193
195
|
DropzoneReject,
|
194
196
|
DropzoneIdle
|
195
197
|
};
|
196
|
-
//# sourceMappingURL=chunk-
|
198
|
+
//# sourceMappingURL=chunk-ZCUDAOHK.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/dropzone.tsx"],"sourcesContent":["import type {\n ColorModeToken,\n CSS,\n CSSUIObject,\n FC,\n HTMLUIProps,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { LoadingProps } from \"@yamada-ui/loading\"\nimport type { FadeProps } from \"@yamada-ui/transitions\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, PropsWithChildren } from \"react\"\nimport type {\n Accept,\n DropzoneOptions as ReactDropzoneOptions,\n} from \"react-dropzone-esm\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { Loading } from \"@yamada-ui/loading\"\nimport { Fade } from \"@yamada-ui/transitions\"\nimport {\n assignRef,\n createContext,\n cx,\n dataAttr,\n isArray,\n splitObject,\n} from \"@yamada-ui/utils\"\nimport { useDropzone } from \"react-dropzone-esm\"\n\ninterface DropzoneContext {\n isDragAccept: boolean\n isDragIdle: boolean\n isDragReject: boolean\n styles: { [key: string]: CSSUIObject | undefined }\n isLoading?: boolean\n}\n\nconst [DropzoneProvider, useDropzoneContext] = createContext<DropzoneContext>({\n name: \"DropzoneContext\",\n errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Dropzone />\"`,\n})\n\ninterface DropzoneOptions {\n /**\n * File types to accept.\n */\n accept?: Accept | string[]\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * If `true`, display the dropzone loading icon.\n *\n * @default false\n */\n isLoading?: boolean\n /**\n * Ref to a open function.\n */\n openRef?: ForwardedRef<() => undefined | void>\n /**\n * Props for dropzone loading icon element.\n */\n loadingProps?: LoadingProps\n /**\n * Props for dropzone overlay element.\n */\n overlayProps?: FadeProps\n}\n\nexport interface DropzoneProps\n extends Merge<HTMLUIProps, Omit<ReactDropzoneOptions, \"accept\">>,\n ThemeProps<\"Dropzone\">,\n DropzoneOptions,\n FormControlOptions {}\n\n/**\n * `Dropzone` is a component used for uploading files via drag and drop.\n *\n * @see Docs https://yamada-ui.com/components/forms/dropzone\n */\nexport const Dropzone = forwardRef<DropzoneProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Dropzone\", props)\n const {\n id,\n name,\n className,\n accept,\n autoFocus,\n children,\n isLoading,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n openRef,\n preventDropOnDocument,\n useFsAccessApi,\n loadingProps,\n overlayProps,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n ...rest\n } = useFormControlProps(omitThemeProps(mergedProps))\n\n const disabled = isLoading || rest.disabled || rest.readOnly\n\n const [\n { \"aria-readonly\": ariaReadOnly, ...formControlProps },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const { isDragAccept, isDragReject, open, getInputProps, getRootProps } =\n useDropzone({\n accept: isArray(accept)\n ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {})\n : accept,\n autoFocus,\n disabled,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n preventDropOnDocument,\n useFsAccessApi,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n })\n\n assignRef(openRef, open)\n\n const isDragIdle = !isDragAccept && !isDragReject\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n position: \"relative\",\n ...styles.container,\n }\n\n return (\n <DropzoneProvider\n value={{ isDragAccept, isDragIdle, isDragReject, isLoading, styles }}\n >\n <ui.div\n className={cx(\"ui-dropzone\", className)}\n __css={css}\n {...formControlProps}\n {...containerProps}\n {...getRootProps({})}\n data-accept={dataAttr(isDragAccept)}\n data-idle={dataAttr(isDragIdle)}\n data-loading={dataAttr(isLoading)}\n data-reject={dataAttr(isDragReject)}\n >\n <DropzoneLoadingOverlay loadingProps={loadingProps} {...overlayProps} />\n\n <ui.input\n id={id}\n ref={ref}\n name={name}\n aria-readonly={ariaReadOnly}\n {...formControlProps}\n {...getInputProps()}\n />\n {children}\n </ui.div>\n </DropzoneProvider>\n )\n})\n\nDropzone.displayName = \"Dropzone\"\nDropzone.__ui__ = \"Dropzone\"\n\ninterface DropzoneLoadingOverlayProps extends FadeProps {\n loadingProps?: LoadingProps\n}\n\nconst DropzoneLoadingOverlay: FC<DropzoneLoadingOverlayProps> = ({\n loadingProps,\n ...rest\n}) => {\n const { isLoading, styles } = useDropzoneContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n h: \"100%\",\n justifyContent: \"center\",\n left: 0,\n position: \"absolute\",\n top: 0,\n w: \"100%\",\n ...styles.overlay,\n }\n\n return (\n <Fade\n className=\"ui-dropzone__overlay\"\n isOpen={isLoading}\n unmountOnExit\n __css={css}\n {...rest}\n >\n <Loading\n className=\"ui-dropzone__overlay__loading\"\n fontSize=\"4xl\"\n {...loadingProps}\n />\n </Fade>\n )\n}\n\nDropzoneLoadingOverlay.displayName = \"DropzoneLoadingOverlay\"\nDropzoneLoadingOverlay.__ui__ = \"DropzoneLoadingOverlay\"\n\nexport const DropzoneAccept: FC<PropsWithChildren> = ({ children }) => {\n const { isDragAccept } = useDropzoneContext()\n\n return isDragAccept ? children : null\n}\n\nDropzoneAccept.displayName = \"DropzoneAccept\"\nDropzoneAccept.__ui__ = \"DropzoneAccept\"\n\nexport const DropzoneReject: FC<PropsWithChildren> = ({ children }) => {\n const { isDragReject } = useDropzoneContext()\n\n return isDragReject ? children : null\n}\n\nDropzoneReject.displayName = \"DropzoneReject\"\nDropzoneReject.__ui__ = \"DropzoneReject\"\n\nexport const DropzoneIdle: FC<PropsWithChildren> = ({ children }) => {\n const { isDragIdle } = useDropzoneContext()\n\n return isDragIdle ? children : null\n}\n\nDropzoneIdle.displayName = \"DropzoneIdle\"\nDropzoneIdle.__ui__ = \"DropzoneIdle\"\n"],"mappings":";;;AAiBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AA6ItB,SAWE,KAXF;AAnIN,IAAM,CAAC,kBAAkB,kBAAkB,IAAI,cAA+B;AAAA,EAC5E,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA8CM,IAAM,WAAW,WAAmC,CAAC,OAAO,QAAQ;AACzE,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,YAAY,KAAK;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,oBAAoB,eAAe,WAAW,CAAC;AAEnD,QAAM,WAAW,aAAa,KAAK,YAAY,KAAK;AAEpD,QAAM;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ANGED
@@ -71,10 +71,10 @@ var Dropzone = (0, import_core.forwardRef)((props, ref) => {
|
|
71
71
|
...rest
|
72
72
|
} = (0, import_form_control.useFormControlProps)((0, import_core.omitThemeProps)(mergedProps));
|
73
73
|
const disabled = isLoading || rest.disabled || rest.readOnly;
|
74
|
-
const [
|
75
|
-
|
76
|
-
|
77
|
-
);
|
74
|
+
const [
|
75
|
+
{ "aria-readonly": ariaReadOnly, ...formControlProps },
|
76
|
+
containerProps
|
77
|
+
] = (0, import_utils.splitObject)(rest, import_form_control.formControlProperties);
|
78
78
|
const { isDragAccept, isDragReject, open, getInputProps, getRootProps } = (0, import_react_dropzone_esm.useDropzone)({
|
79
79
|
accept: (0, import_utils.isArray)(accept) ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {}) : accept,
|
80
80
|
autoFocus,
|
@@ -115,6 +115,7 @@ var Dropzone = (0, import_core.forwardRef)((props, ref) => {
|
|
115
115
|
{
|
116
116
|
className: (0, import_utils.cx)("ui-dropzone", className),
|
117
117
|
__css: css,
|
118
|
+
...formControlProps,
|
118
119
|
...containerProps,
|
119
120
|
...getRootProps({}),
|
120
121
|
"data-accept": (0, import_utils.dataAttr)(isDragAccept),
|
@@ -129,6 +130,7 @@ var Dropzone = (0, import_core.forwardRef)((props, ref) => {
|
|
129
130
|
id,
|
130
131
|
ref,
|
131
132
|
name,
|
133
|
+
"aria-readonly": ariaReadOnly,
|
132
134
|
...formControlProps,
|
133
135
|
...getInputProps()
|
134
136
|
}
|
package/dist/dropzone.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/dropzone.tsx"],"sourcesContent":["import type {\n ColorModeToken,\n CSS,\n CSSUIObject,\n FC,\n HTMLUIProps,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { LoadingProps } from \"@yamada-ui/loading\"\nimport type { FadeProps } from \"@yamada-ui/transitions\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, PropsWithChildren } from \"react\"\nimport type {\n Accept,\n DropzoneOptions as ReactDropzoneOptions,\n} from \"react-dropzone-esm\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { Loading } from \"@yamada-ui/loading\"\nimport { Fade } from \"@yamada-ui/transitions\"\nimport {\n assignRef,\n createContext,\n cx,\n dataAttr,\n isArray,\n splitObject,\n} from \"@yamada-ui/utils\"\nimport { useDropzone } from \"react-dropzone-esm\"\n\ninterface DropzoneContext {\n isDragAccept: boolean\n isDragIdle: boolean\n isDragReject: boolean\n styles: { [key: string]: CSSUIObject | undefined }\n isLoading?: boolean\n}\n\nconst [DropzoneProvider, useDropzoneContext] = createContext<DropzoneContext>({\n name: \"DropzoneContext\",\n errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Dropzone />\"`,\n})\n\ninterface DropzoneOptions {\n /**\n * File types to accept.\n */\n accept?: Accept | string[]\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * If `true`, display the dropzone loading icon.\n *\n * @default false\n */\n isLoading?: boolean\n /**\n * Ref to a open function.\n */\n openRef?: ForwardedRef<() => undefined | void>\n /**\n * Props for dropzone loading icon element.\n */\n loadingProps?: LoadingProps\n /**\n * Props for dropzone overlay element.\n */\n overlayProps?: FadeProps\n}\n\nexport interface DropzoneProps\n extends Merge<HTMLUIProps, Omit<ReactDropzoneOptions, \"accept\">>,\n ThemeProps<\"Dropzone\">,\n DropzoneOptions,\n FormControlOptions {}\n\n/**\n * `Dropzone` is a component used for uploading files via drag and drop.\n *\n * @see Docs https://yamada-ui.com/components/forms/dropzone\n */\nexport const Dropzone = forwardRef<DropzoneProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Dropzone\", props)\n const {\n id,\n name,\n className,\n accept,\n autoFocus,\n children,\n isLoading,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n openRef,\n preventDropOnDocument,\n useFsAccessApi,\n loadingProps,\n overlayProps,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n ...rest\n } = useFormControlProps(omitThemeProps(mergedProps))\n\n const disabled = isLoading || rest.disabled || rest.readOnly\n\n const [
|
1
|
+
{"version":3,"sources":["../src/dropzone.tsx"],"sourcesContent":["import type {\n ColorModeToken,\n CSS,\n CSSUIObject,\n FC,\n HTMLUIProps,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { LoadingProps } from \"@yamada-ui/loading\"\nimport type { FadeProps } from \"@yamada-ui/transitions\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, PropsWithChildren } from \"react\"\nimport type {\n Accept,\n DropzoneOptions as ReactDropzoneOptions,\n} from \"react-dropzone-esm\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { Loading } from \"@yamada-ui/loading\"\nimport { Fade } from \"@yamada-ui/transitions\"\nimport {\n assignRef,\n createContext,\n cx,\n dataAttr,\n isArray,\n splitObject,\n} from \"@yamada-ui/utils\"\nimport { useDropzone } from \"react-dropzone-esm\"\n\ninterface DropzoneContext {\n isDragAccept: boolean\n isDragIdle: boolean\n isDragReject: boolean\n styles: { [key: string]: CSSUIObject | undefined }\n isLoading?: boolean\n}\n\nconst [DropzoneProvider, useDropzoneContext] = createContext<DropzoneContext>({\n name: \"DropzoneContext\",\n errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Dropzone />\"`,\n})\n\ninterface DropzoneOptions {\n /**\n * File types to accept.\n */\n accept?: Accept | string[]\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * If `true`, display the dropzone loading icon.\n *\n * @default false\n */\n isLoading?: boolean\n /**\n * Ref to a open function.\n */\n openRef?: ForwardedRef<() => undefined | void>\n /**\n * Props for dropzone loading icon element.\n */\n loadingProps?: LoadingProps\n /**\n * Props for dropzone overlay element.\n */\n overlayProps?: FadeProps\n}\n\nexport interface DropzoneProps\n extends Merge<HTMLUIProps, Omit<ReactDropzoneOptions, \"accept\">>,\n ThemeProps<\"Dropzone\">,\n DropzoneOptions,\n FormControlOptions {}\n\n/**\n * `Dropzone` is a component used for uploading files via drag and drop.\n *\n * @see Docs https://yamada-ui.com/components/forms/dropzone\n */\nexport const Dropzone = forwardRef<DropzoneProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Dropzone\", props)\n const {\n id,\n name,\n className,\n accept,\n autoFocus,\n children,\n isLoading,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n openRef,\n preventDropOnDocument,\n useFsAccessApi,\n loadingProps,\n overlayProps,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n ...rest\n } = useFormControlProps(omitThemeProps(mergedProps))\n\n const disabled = isLoading || rest.disabled || rest.readOnly\n\n const [\n { \"aria-readonly\": ariaReadOnly, ...formControlProps },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const { isDragAccept, isDragReject, open, getInputProps, getRootProps } =\n useDropzone({\n accept: isArray(accept)\n ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {})\n : accept,\n autoFocus,\n disabled,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n preventDropOnDocument,\n useFsAccessApi,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n })\n\n assignRef(openRef, open)\n\n const isDragIdle = !isDragAccept && !isDragReject\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n position: \"relative\",\n ...styles.container,\n }\n\n return (\n <DropzoneProvider\n value={{ isDragAccept, isDragIdle, isDragReject, isLoading, styles }}\n >\n <ui.div\n className={cx(\"ui-dropzone\", className)}\n __css={css}\n {...formControlProps}\n {...containerProps}\n {...getRootProps({})}\n data-accept={dataAttr(isDragAccept)}\n data-idle={dataAttr(isDragIdle)}\n data-loading={dataAttr(isLoading)}\n data-reject={dataAttr(isDragReject)}\n >\n <DropzoneLoadingOverlay loadingProps={loadingProps} {...overlayProps} />\n\n <ui.input\n id={id}\n ref={ref}\n name={name}\n aria-readonly={ariaReadOnly}\n {...formControlProps}\n {...getInputProps()}\n />\n {children}\n </ui.div>\n </DropzoneProvider>\n )\n})\n\nDropzone.displayName = \"Dropzone\"\nDropzone.__ui__ = \"Dropzone\"\n\ninterface DropzoneLoadingOverlayProps extends FadeProps {\n loadingProps?: LoadingProps\n}\n\nconst DropzoneLoadingOverlay: FC<DropzoneLoadingOverlayProps> = ({\n loadingProps,\n ...rest\n}) => {\n const { isLoading, styles } = useDropzoneContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n h: \"100%\",\n justifyContent: \"center\",\n left: 0,\n position: \"absolute\",\n top: 0,\n w: \"100%\",\n ...styles.overlay,\n }\n\n return (\n <Fade\n className=\"ui-dropzone__overlay\"\n isOpen={isLoading}\n unmountOnExit\n __css={css}\n {...rest}\n >\n <Loading\n className=\"ui-dropzone__overlay__loading\"\n fontSize=\"4xl\"\n {...loadingProps}\n />\n </Fade>\n )\n}\n\nDropzoneLoadingOverlay.displayName = \"DropzoneLoadingOverlay\"\nDropzoneLoadingOverlay.__ui__ = \"DropzoneLoadingOverlay\"\n\nexport const DropzoneAccept: FC<PropsWithChildren> = ({ children }) => {\n const { isDragAccept } = useDropzoneContext()\n\n return isDragAccept ? children : null\n}\n\nDropzoneAccept.displayName = \"DropzoneAccept\"\nDropzoneAccept.__ui__ = \"DropzoneAccept\"\n\nexport const DropzoneReject: FC<PropsWithChildren> = ({ children }) => {\n const { isDragReject } = useDropzoneContext()\n\n return isDragReject ? children : null\n}\n\nDropzoneReject.displayName = \"DropzoneReject\"\nDropzoneReject.__ui__ = \"DropzoneReject\"\n\nexport const DropzoneIdle: FC<PropsWithChildren> = ({ children }) => {\n const { isDragIdle } = useDropzoneContext()\n\n return isDragIdle ? children : null\n}\n\nDropzoneIdle.displayName = \"DropzoneIdle\"\nDropzoneIdle.__ui__ = \"DropzoneIdle\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,kBAKO;AACP,0BAGO;AACP,qBAAwB;AACxB,yBAAqB;AACrB,mBAOO;AACP,gCAA4B;AA6ItB;AAnIN,IAAM,CAAC,kBAAkB,kBAAkB,QAAI,4BAA+B;AAAA,EAC5E,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA8CM,IAAM,eAAW,wBAAmC,CAAC,OAAO,QAAQ;AACzE,QAAM,CAAC,QAAQ,WAAW,QAAI,oCAAuB,YAAY,KAAK;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAC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Ae,WAAW;AACnC;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;AAEjB,IAAM,eAAsC,CAAC,EAAE,SAAS,MAAM;AACnE,QAAM,EAAE,WAAW,IAAI,mBAAmB;AAE1C,SAAO,aAAa,WAAW;AACjC;AAEA,aAAa,cAAc;AAC3B,aAAa,SAAS;","names":[]}
|
package/dist/dropzone.mjs
CHANGED
package/dist/index.js
CHANGED
@@ -116,10 +116,10 @@ var Dropzone = (0, import_core.forwardRef)((props, ref) => {
|
|
116
116
|
...rest
|
117
117
|
} = (0, import_form_control.useFormControlProps)((0, import_core.omitThemeProps)(mergedProps));
|
118
118
|
const disabled = isLoading || rest.disabled || rest.readOnly;
|
119
|
-
const [
|
120
|
-
|
121
|
-
|
122
|
-
);
|
119
|
+
const [
|
120
|
+
{ "aria-readonly": ariaReadOnly, ...formControlProps },
|
121
|
+
containerProps
|
122
|
+
] = (0, import_utils.splitObject)(rest, import_form_control.formControlProperties);
|
123
123
|
const { isDragAccept, isDragReject, open, getInputProps, getRootProps } = (0, import_react_dropzone_esm.useDropzone)({
|
124
124
|
accept: (0, import_utils.isArray)(accept) ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {}) : accept,
|
125
125
|
autoFocus,
|
@@ -160,6 +160,7 @@ var Dropzone = (0, import_core.forwardRef)((props, ref) => {
|
|
160
160
|
{
|
161
161
|
className: (0, import_utils.cx)("ui-dropzone", className),
|
162
162
|
__css: css,
|
163
|
+
...formControlProps,
|
163
164
|
...containerProps,
|
164
165
|
...getRootProps({}),
|
165
166
|
"data-accept": (0, import_utils.dataAttr)(isDragAccept),
|
@@ -174,6 +175,7 @@ var Dropzone = (0, import_core.forwardRef)((props, ref) => {
|
|
174
175
|
id,
|
175
176
|
ref,
|
176
177
|
name,
|
178
|
+
"aria-readonly": ariaReadOnly,
|
177
179
|
...formControlProps,
|
178
180
|
...getInputProps()
|
179
181
|
}
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/accept-types.ts","../src/dropzone.tsx"],"sourcesContent":["export * from \"./accept-types\"\nexport {\n Dropzone,\n DropzoneAccept,\n DropzoneIdle,\n DropzoneReject,\n} from \"./dropzone\"\nexport type { DropzoneProps } from \"./dropzone\"\nexport type {\n DropEvent,\n ErrorCode,\n FileError,\n FileRejection,\n} from \"react-dropzone-esm\"\n","export const ACCEPT_TYPES = {\n csv: \"text/csv\",\n doc: \"application/msword\",\n docx: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n exe: \"application/vnd.microsoft.portable-executable\",\n gif: \"image/gif\",\n html: \"text/html\",\n jpeg: \"image/jpeg\",\n mp3: \"audio/mpeg\",\n mp4: \"video/mp4\",\n mpeg: \"video/mpeg\",\n pdf: \"application/pdf\",\n png: \"image/png\",\n ppt: \"application/vnd.ms-powerpoint\",\n pptx: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n svg: \"image/svg+xml\",\n txt: \"text/plain\",\n webp: \"image/webp\",\n xls: \"application/vnd.ms-excel\",\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n zip: \"application/zip\",\n} as const\n\nexport const IMAGE_ACCEPT_TYPE = [\n ACCEPT_TYPES.png,\n ACCEPT_TYPES.gif,\n ACCEPT_TYPES.jpeg,\n ACCEPT_TYPES.svg,\n ACCEPT_TYPES.webp,\n]\nexport const PDF_ACCEPT_TYPE = [ACCEPT_TYPES.pdf]\nexport const MS_WORD_ACCEPT_TYPE = [ACCEPT_TYPES.doc, ACCEPT_TYPES.docx]\nexport const MS_EXCEL_ACCEPT_TYPE = [ACCEPT_TYPES.xls, ACCEPT_TYPES.xlsx]\nexport const MS_POWER_POINT_ACCEPT_TYPE = [ACCEPT_TYPES.ppt, ACCEPT_TYPES.pptx]\nexport const EXE_ACCEPT_TYPE = [ACCEPT_TYPES.exe]\n","import type {\n ColorModeToken,\n CSS,\n CSSUIObject,\n FC,\n HTMLUIProps,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { LoadingProps } from \"@yamada-ui/loading\"\nimport type { FadeProps } from \"@yamada-ui/transitions\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, PropsWithChildren } from \"react\"\nimport type {\n Accept,\n DropzoneOptions as ReactDropzoneOptions,\n} from \"react-dropzone-esm\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { Loading } from \"@yamada-ui/loading\"\nimport { Fade } from \"@yamada-ui/transitions\"\nimport {\n assignRef,\n createContext,\n cx,\n dataAttr,\n isArray,\n splitObject,\n} from \"@yamada-ui/utils\"\nimport { useDropzone } from \"react-dropzone-esm\"\n\ninterface DropzoneContext {\n isDragAccept: boolean\n isDragIdle: boolean\n isDragReject: boolean\n styles: { [key: string]: CSSUIObject | undefined }\n isLoading?: boolean\n}\n\nconst [DropzoneProvider, useDropzoneContext] = createContext<DropzoneContext>({\n name: \"DropzoneContext\",\n errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Dropzone />\"`,\n})\n\ninterface DropzoneOptions {\n /**\n * File types to accept.\n */\n accept?: Accept | string[]\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * If `true`, display the dropzone loading icon.\n *\n * @default false\n */\n isLoading?: boolean\n /**\n * Ref to a open function.\n */\n openRef?: ForwardedRef<() => undefined | void>\n /**\n * Props for dropzone loading icon element.\n */\n loadingProps?: LoadingProps\n /**\n * Props for dropzone overlay element.\n */\n overlayProps?: FadeProps\n}\n\nexport interface DropzoneProps\n extends Merge<HTMLUIProps, Omit<ReactDropzoneOptions, \"accept\">>,\n ThemeProps<\"Dropzone\">,\n DropzoneOptions,\n FormControlOptions {}\n\n/**\n * `Dropzone` is a component used for uploading files via drag and drop.\n *\n * @see Docs https://yamada-ui.com/components/forms/dropzone\n */\nexport const Dropzone = forwardRef<DropzoneProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Dropzone\", props)\n const {\n id,\n name,\n className,\n accept,\n autoFocus,\n children,\n isLoading,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n openRef,\n preventDropOnDocument,\n useFsAccessApi,\n loadingProps,\n overlayProps,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n ...rest\n } = useFormControlProps(omitThemeProps(mergedProps))\n\n const disabled = isLoading || rest.disabled || rest.readOnly\n\n const [formControlProps, containerProps] = splitObject(\n rest,\n formControlProperties,\n )\n\n const { isDragAccept, isDragReject, open, getInputProps, getRootProps } =\n useDropzone({\n accept: isArray(accept)\n ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {})\n : accept,\n autoFocus,\n disabled,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n preventDropOnDocument,\n useFsAccessApi,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n })\n\n assignRef(openRef, open)\n\n const isDragIdle = !isDragAccept && !isDragReject\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n position: \"relative\",\n ...styles.container,\n }\n\n return (\n <DropzoneProvider\n value={{ isDragAccept, isDragIdle, isDragReject, isLoading, styles }}\n >\n <ui.div\n className={cx(\"ui-dropzone\", className)}\n __css={css}\n {...containerProps}\n {...getRootProps({})}\n data-accept={dataAttr(isDragAccept)}\n data-idle={dataAttr(isDragIdle)}\n data-loading={dataAttr(isLoading)}\n data-reject={dataAttr(isDragReject)}\n >\n <DropzoneLoadingOverlay loadingProps={loadingProps} {...overlayProps} />\n\n <ui.input\n id={id}\n ref={ref}\n name={name}\n {...formControlProps}\n {...getInputProps()}\n />\n {children}\n </ui.div>\n </DropzoneProvider>\n )\n})\n\nDropzone.displayName = \"Dropzone\"\nDropzone.__ui__ = \"Dropzone\"\n\ninterface DropzoneLoadingOverlayProps extends FadeProps {\n loadingProps?: LoadingProps\n}\n\nconst DropzoneLoadingOverlay: FC<DropzoneLoadingOverlayProps> = ({\n loadingProps,\n ...rest\n}) => {\n const { isLoading, styles } = useDropzoneContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n h: \"100%\",\n justifyContent: \"center\",\n left: 0,\n position: \"absolute\",\n top: 0,\n w: \"100%\",\n ...styles.overlay,\n }\n\n return (\n <Fade\n className=\"ui-dropzone__overlay\"\n isOpen={isLoading}\n unmountOnExit\n __css={css}\n {...rest}\n >\n <Loading\n className=\"ui-dropzone__overlay__loading\"\n fontSize=\"4xl\"\n {...loadingProps}\n />\n </Fade>\n )\n}\n\nDropzoneLoadingOverlay.displayName = \"DropzoneLoadingOverlay\"\nDropzoneLoadingOverlay.__ui__ = \"DropzoneLoadingOverlay\"\n\nexport const DropzoneAccept: FC<PropsWithChildren> = ({ children }) => {\n const { isDragAccept } = useDropzoneContext()\n\n return isDragAccept ? children : null\n}\n\nDropzoneAccept.displayName = \"DropzoneAccept\"\nDropzoneAccept.__ui__ = \"DropzoneAccept\"\n\nexport const DropzoneReject: FC<PropsWithChildren> = ({ children }) => {\n const { isDragReject } = useDropzoneContext()\n\n return isDragReject ? children : null\n}\n\nDropzoneReject.displayName = \"DropzoneReject\"\nDropzoneReject.__ui__ = \"DropzoneReject\"\n\nexport const DropzoneIdle: FC<PropsWithChildren> = ({ children }) => {\n const { isDragIdle } = useDropzoneContext()\n\n return isDragIdle ? children : null\n}\n\nDropzoneIdle.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,CAAC,EAAE,SAAS,MAAM;AACrE,QAAM,EAAE,aAAa,IAAI,mBAAmB;AAE5C,SAAO,eAAe,WAAW;AACnC;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;AAEjB,IAAM,eAAsC,CAAC,EAAE,SAAS,MAAM;AACnE,QAAM,EAAE,WAAW,IAAI,mBAAmB;AAE1C,SAAO,aAAa,WAAW;AACjC;AAEA,aAAa,cAAc;AAC3B,aAAa,SAAS;","names":[]}
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/accept-types.ts","../src/dropzone.tsx"],"sourcesContent":["export * from \"./accept-types\"\nexport {\n Dropzone,\n DropzoneAccept,\n DropzoneIdle,\n DropzoneReject,\n} from \"./dropzone\"\nexport type { DropzoneProps } from \"./dropzone\"\nexport type {\n DropEvent,\n ErrorCode,\n FileError,\n FileRejection,\n} from \"react-dropzone-esm\"\n","export const ACCEPT_TYPES = {\n csv: \"text/csv\",\n doc: \"application/msword\",\n docx: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n exe: \"application/vnd.microsoft.portable-executable\",\n gif: \"image/gif\",\n html: \"text/html\",\n jpeg: \"image/jpeg\",\n mp3: \"audio/mpeg\",\n mp4: \"video/mp4\",\n mpeg: \"video/mpeg\",\n pdf: \"application/pdf\",\n png: \"image/png\",\n ppt: \"application/vnd.ms-powerpoint\",\n pptx: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n svg: \"image/svg+xml\",\n txt: \"text/plain\",\n webp: \"image/webp\",\n xls: \"application/vnd.ms-excel\",\n xlsx: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n zip: \"application/zip\",\n} as const\n\nexport const IMAGE_ACCEPT_TYPE = [\n ACCEPT_TYPES.png,\n ACCEPT_TYPES.gif,\n ACCEPT_TYPES.jpeg,\n ACCEPT_TYPES.svg,\n ACCEPT_TYPES.webp,\n]\nexport const PDF_ACCEPT_TYPE = [ACCEPT_TYPES.pdf]\nexport const MS_WORD_ACCEPT_TYPE = [ACCEPT_TYPES.doc, ACCEPT_TYPES.docx]\nexport const MS_EXCEL_ACCEPT_TYPE = [ACCEPT_TYPES.xls, ACCEPT_TYPES.xlsx]\nexport const MS_POWER_POINT_ACCEPT_TYPE = [ACCEPT_TYPES.ppt, ACCEPT_TYPES.pptx]\nexport const EXE_ACCEPT_TYPE = [ACCEPT_TYPES.exe]\n","import type {\n ColorModeToken,\n CSS,\n CSSUIObject,\n FC,\n HTMLUIProps,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { LoadingProps } from \"@yamada-ui/loading\"\nimport type { FadeProps } from \"@yamada-ui/transitions\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, PropsWithChildren } from \"react\"\nimport type {\n Accept,\n DropzoneOptions as ReactDropzoneOptions,\n} from \"react-dropzone-esm\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { Loading } from \"@yamada-ui/loading\"\nimport { Fade } from \"@yamada-ui/transitions\"\nimport {\n assignRef,\n createContext,\n cx,\n dataAttr,\n isArray,\n splitObject,\n} from \"@yamada-ui/utils\"\nimport { useDropzone } from \"react-dropzone-esm\"\n\ninterface DropzoneContext {\n isDragAccept: boolean\n isDragIdle: boolean\n isDragReject: boolean\n styles: { [key: string]: CSSUIObject | undefined }\n isLoading?: boolean\n}\n\nconst [DropzoneProvider, useDropzoneContext] = createContext<DropzoneContext>({\n name: \"DropzoneContext\",\n errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Dropzone />\"`,\n})\n\ninterface DropzoneOptions {\n /**\n * File types to accept.\n */\n accept?: Accept | string[]\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * If `true`, display the dropzone loading icon.\n *\n * @default false\n */\n isLoading?: boolean\n /**\n * Ref to a open function.\n */\n openRef?: ForwardedRef<() => undefined | void>\n /**\n * Props for dropzone loading icon element.\n */\n loadingProps?: LoadingProps\n /**\n * Props for dropzone overlay element.\n */\n overlayProps?: FadeProps\n}\n\nexport interface DropzoneProps\n extends Merge<HTMLUIProps, Omit<ReactDropzoneOptions, \"accept\">>,\n ThemeProps<\"Dropzone\">,\n DropzoneOptions,\n FormControlOptions {}\n\n/**\n * `Dropzone` is a component used for uploading files via drag and drop.\n *\n * @see Docs https://yamada-ui.com/components/forms/dropzone\n */\nexport const Dropzone = forwardRef<DropzoneProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Dropzone\", props)\n const {\n id,\n name,\n className,\n accept,\n autoFocus,\n children,\n isLoading,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n openRef,\n preventDropOnDocument,\n useFsAccessApi,\n loadingProps,\n overlayProps,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n ...rest\n } = useFormControlProps(omitThemeProps(mergedProps))\n\n const disabled = isLoading || rest.disabled || rest.readOnly\n\n const [\n { \"aria-readonly\": ariaReadOnly, ...formControlProps },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const { isDragAccept, isDragReject, open, getInputProps, getRootProps } =\n useDropzone({\n accept: isArray(accept)\n ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {})\n : accept,\n autoFocus,\n disabled,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n preventDropOnDocument,\n useFsAccessApi,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n })\n\n assignRef(openRef, open)\n\n const isDragIdle = !isDragAccept && !isDragReject\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n position: \"relative\",\n ...styles.container,\n }\n\n return (\n <DropzoneProvider\n value={{ isDragAccept, isDragIdle, isDragReject, isLoading, styles }}\n >\n <ui.div\n className={cx(\"ui-dropzone\", className)}\n __css={css}\n {...formControlProps}\n {...containerProps}\n {...getRootProps({})}\n data-accept={dataAttr(isDragAccept)}\n data-idle={dataAttr(isDragIdle)}\n data-loading={dataAttr(isLoading)}\n data-reject={dataAttr(isDragReject)}\n >\n <DropzoneLoadingOverlay loadingProps={loadingProps} {...overlayProps} />\n\n <ui.input\n id={id}\n ref={ref}\n name={name}\n aria-readonly={ariaReadOnly}\n {...formControlProps}\n {...getInputProps()}\n />\n {children}\n </ui.div>\n </DropzoneProvider>\n )\n})\n\nDropzone.displayName = \"Dropzone\"\nDropzone.__ui__ = \"Dropzone\"\n\ninterface DropzoneLoadingOverlayProps extends FadeProps {\n loadingProps?: LoadingProps\n}\n\nconst DropzoneLoadingOverlay: FC<DropzoneLoadingOverlayProps> = ({\n loadingProps,\n ...rest\n}) => {\n const { isLoading, styles } = useDropzoneContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n h: \"100%\",\n justifyContent: \"center\",\n left: 0,\n position: \"absolute\",\n top: 0,\n w: \"100%\",\n ...styles.overlay,\n }\n\n return (\n <Fade\n className=\"ui-dropzone__overlay\"\n isOpen={isLoading}\n unmountOnExit\n __css={css}\n {...rest}\n >\n <Loading\n className=\"ui-dropzone__overlay__loading\"\n fontSize=\"4xl\"\n {...loadingProps}\n />\n </Fade>\n )\n}\n\nDropzoneLoadingOverlay.displayName = \"DropzoneLoadingOverlay\"\nDropzoneLoadingOverlay.__ui__ = \"DropzoneLoadingOverlay\"\n\nexport const DropzoneAccept: FC<PropsWithChildren> = ({ children }) => {\n const { isDragAccept } = useDropzoneContext()\n\n return isDragAccept ? children : null\n}\n\nDropzoneAccept.displayName = \"DropzoneAccept\"\nDropzoneAccept.__ui__ = \"DropzoneAccept\"\n\nexport const DropzoneReject: FC<PropsWithChildren> = ({ children }) => {\n const { isDragReject } = useDropzoneContext()\n\n return isDragReject ? children : null\n}\n\nDropzoneReject.displayName = \"DropzoneReject\"\nDropzoneReject.__ui__ = \"DropzoneReject\"\n\nexport const DropzoneIdle: FC<PropsWithChildren> = ({ children }) => {\n const { isDragIdle } = useDropzoneContext()\n\n return isDragIdle ? children : null\n}\n\nDropzoneIdle.displayName = \"DropzoneIdle\"\nDropzoneIdle.__ui__ = \"DropzoneIdle\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,eAAe;AAAA,EAC1B,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AACP;AAEO,IAAM,oBAAoB;AAAA,EAC/B,aAAa;AAAA,EACb,aAAa;AAAA,EACb,aAAa;AAAA,EACb,aAAa;AAAA,EACb,aAAa;AACf;AACO,IAAM,kBAAkB,CAAC,aAAa,GAAG;AACzC,IAAM,sBAAsB,CAAC,aAAa,KAAK,aAAa,IAAI;AAChE,IAAM,uBAAuB,CAAC,aAAa,KAAK,aAAa,IAAI;AACjE,IAAM,6BAA6B,CAAC,aAAa,KAAK,aAAa,IAAI;AACvE,IAAM,kBAAkB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;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,QAAQ;AAAA,MACR,eAAa;AAAA,MACb,OAAO;AAAA,MACN,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,UAAS;AAAA,UACR,GAAG;AAAA;AAAA,MACN;AAAA;AAAA,EACF;AAEJ;AAEA,uBAAuB,cAAc;AACrC,uBAAuB,SAAS;AAEzB,IAAM,iBAAwC,CAAC,EAAE,SAAS,MAAM;AACrE,QAAM,EAAE,aAAa,IAAI,mBAAmB;AAE5C,SAAO,eAAe,WAAW;AACnC;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;AAEjB,IAAM,iBAAwC,CAAC,EAAE,SAAS,MAAM;AACrE,QAAM,EAAE,aAAa,IAAI,mBAAmB;AAE5C,SAAO,eAAe,WAAW;AACnC;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;AAEjB,IAAM,eAAsC,CAAC,EAAE,SAAS,MAAM;AACnE,QAAM,EAAE,WAAW,IAAI,mBAAmB;AAE1C,SAAO,aAAa,WAAW;AACjC;AAEA,aAAa,cAAc;AAC3B,aAAa,SAAS;","names":[]}
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yamada-ui/dropzone",
|
3
|
-
"version": "1.0.52-dev-
|
3
|
+
"version": "1.0.52-dev-20241118161617",
|
4
4
|
"description": "Yamada UI dropzone component",
|
5
5
|
"keywords": [
|
6
6
|
"yamada",
|
@@ -38,10 +38,10 @@
|
|
38
38
|
"dependencies": {
|
39
39
|
"react-dropzone-esm": "^15.0.1",
|
40
40
|
"@yamada-ui/core": "1.15.5",
|
41
|
-
"@yamada-ui/utils": "1.5.4",
|
42
41
|
"@yamada-ui/form-control": "2.1.7",
|
43
|
-
"@yamada-ui/loading": "1.1.24-dev-
|
44
|
-
"@yamada-ui/transitions": "1.1.11-dev-
|
42
|
+
"@yamada-ui/loading": "1.1.24-dev-20241118161617",
|
43
|
+
"@yamada-ui/transitions": "1.1.11-dev-20241118161617",
|
44
|
+
"@yamada-ui/utils": "1.5.4"
|
45
45
|
},
|
46
46
|
"devDependencies": {
|
47
47
|
"clean-package": "2.2.0",
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/dropzone.tsx"],"sourcesContent":["import type {\n ColorModeToken,\n CSS,\n CSSUIObject,\n FC,\n HTMLUIProps,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { LoadingProps } from \"@yamada-ui/loading\"\nimport type { FadeProps } from \"@yamada-ui/transitions\"\nimport type { Merge } from \"@yamada-ui/utils\"\nimport type { ForwardedRef, PropsWithChildren } from \"react\"\nimport type {\n Accept,\n DropzoneOptions as ReactDropzoneOptions,\n} from \"react-dropzone-esm\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { Loading } from \"@yamada-ui/loading\"\nimport { Fade } from \"@yamada-ui/transitions\"\nimport {\n assignRef,\n createContext,\n cx,\n dataAttr,\n isArray,\n splitObject,\n} from \"@yamada-ui/utils\"\nimport { useDropzone } from \"react-dropzone-esm\"\n\ninterface DropzoneContext {\n isDragAccept: boolean\n isDragIdle: boolean\n isDragReject: boolean\n styles: { [key: string]: CSSUIObject | undefined }\n isLoading?: boolean\n}\n\nconst [DropzoneProvider, useDropzoneContext] = createContext<DropzoneContext>({\n name: \"DropzoneContext\",\n errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Dropzone />\"`,\n})\n\ninterface DropzoneOptions {\n /**\n * File types to accept.\n */\n accept?: Accept | string[]\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * If `true`, display the dropzone loading icon.\n *\n * @default false\n */\n isLoading?: boolean\n /**\n * Ref to a open function.\n */\n openRef?: ForwardedRef<() => undefined | void>\n /**\n * Props for dropzone loading icon element.\n */\n loadingProps?: LoadingProps\n /**\n * Props for dropzone overlay element.\n */\n overlayProps?: FadeProps\n}\n\nexport interface DropzoneProps\n extends Merge<HTMLUIProps, Omit<ReactDropzoneOptions, \"accept\">>,\n ThemeProps<\"Dropzone\">,\n DropzoneOptions,\n FormControlOptions {}\n\n/**\n * `Dropzone` is a component used for uploading files via drag and drop.\n *\n * @see Docs https://yamada-ui.com/components/forms/dropzone\n */\nexport const Dropzone = forwardRef<DropzoneProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Dropzone\", props)\n const {\n id,\n name,\n className,\n accept,\n autoFocus,\n children,\n isLoading,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n openRef,\n preventDropOnDocument,\n useFsAccessApi,\n loadingProps,\n overlayProps,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n ...rest\n } = useFormControlProps(omitThemeProps(mergedProps))\n\n const disabled = isLoading || rest.disabled || rest.readOnly\n\n const [formControlProps, containerProps] = splitObject(\n rest,\n formControlProperties,\n )\n\n const { isDragAccept, isDragReject, open, getInputProps, getRootProps } =\n useDropzone({\n accept: isArray(accept)\n ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {})\n : accept,\n autoFocus,\n disabled,\n maxFiles,\n maxSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n preventDropOnDocument,\n useFsAccessApi,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onFileDialogCancel,\n onFileDialogOpen,\n })\n\n assignRef(openRef, open)\n\n const isDragIdle = !isDragAccept && !isDragReject\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n position: \"relative\",\n ...styles.container,\n }\n\n return (\n <DropzoneProvider\n value={{ isDragAccept, isDragIdle, isDragReject, isLoading, styles }}\n >\n <ui.div\n className={cx(\"ui-dropzone\", className)}\n __css={css}\n {...containerProps}\n {...getRootProps({})}\n data-accept={dataAttr(isDragAccept)}\n data-idle={dataAttr(isDragIdle)}\n data-loading={dataAttr(isLoading)}\n data-reject={dataAttr(isDragReject)}\n >\n <DropzoneLoadingOverlay loadingProps={loadingProps} {...overlayProps} />\n\n <ui.input\n id={id}\n ref={ref}\n name={name}\n {...formControlProps}\n {...getInputProps()}\n />\n {children}\n </ui.div>\n </DropzoneProvider>\n )\n})\n\nDropzone.displayName = \"Dropzone\"\nDropzone.__ui__ = \"Dropzone\"\n\ninterface DropzoneLoadingOverlayProps extends FadeProps {\n loadingProps?: LoadingProps\n}\n\nconst DropzoneLoadingOverlay: FC<DropzoneLoadingOverlayProps> = ({\n loadingProps,\n ...rest\n}) => {\n const { isLoading, styles } = useDropzoneContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n h: \"100%\",\n justifyContent: \"center\",\n left: 0,\n position: \"absolute\",\n top: 0,\n w: \"100%\",\n ...styles.overlay,\n }\n\n return (\n <Fade\n className=\"ui-dropzone__overlay\"\n isOpen={isLoading}\n unmountOnExit\n __css={css}\n {...rest}\n >\n <Loading\n className=\"ui-dropzone__overlay__loading\"\n fontSize=\"4xl\"\n {...loadingProps}\n />\n </Fade>\n )\n}\n\nDropzoneLoadingOverlay.displayName = \"DropzoneLoadingOverlay\"\nDropzoneLoadingOverlay.__ui__ = \"DropzoneLoadingOverlay\"\n\nexport const DropzoneAccept: FC<PropsWithChildren> = ({ children }) => {\n const { isDragAccept } = useDropzoneContext()\n\n return isDragAccept ? children : null\n}\n\nDropzoneAccept.displayName = \"DropzoneAccept\"\nDropzoneAccept.__ui__ = \"DropzoneAccept\"\n\nexport const DropzoneReject: FC<PropsWithChildren> = ({ children }) => {\n const { isDragReject } = useDropzoneContext()\n\n return isDragReject ? children : null\n}\n\nDropzoneReject.displayName = \"DropzoneReject\"\nDropzoneReject.__ui__ = \"DropzoneReject\"\n\nexport const DropzoneIdle: FC<PropsWithChildren> = ({ children }) => {\n const { isDragIdle } = useDropzoneContext()\n\n return isDragIdle ? children : null\n}\n\nDropzoneIdle.displayName = \"DropzoneIdle\"\nDropzoneIdle.__ui__ = \"DropzoneIdle\"\n"],"mappings":";;;AAiBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AA6ItB,SAUE,KAVF;AAnIN,IAAM,CAAC,kBAAkB,kBAAkB,IAAI,cAA+B;AAAA,EAC5E,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA8CM,IAAM,WAAW,WAAmC,CAAC,OAAO,QAAQ;AACzE,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,YAAY,KAAK;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,oBAAoB,eAAe,WAAW,CAAC;AAEnD,QAAM,WAAW,aAAa,KAAK,YAA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