@yamada-ui/dropzone 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Hirotomo Yamada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @yamada-ui/dropzone
2
+
3
+ ## Installation
4
+
5
+ ```sh
6
+ $ pnpm add @yamada-ui/dropzone
7
+ ```
8
+
9
+ or
10
+
11
+ ```sh
12
+ $ yarn add @yamada-ui/dropzone
13
+ ```
14
+
15
+ or
16
+
17
+ ```sh
18
+ $ npm install @yamada-ui/dropzone
19
+ ```
20
+
21
+ ## Contribution
22
+
23
+ Wouldn't you like to contribute? That's amazing! We have prepared a [contribution guide](https://github.com/hirotomoyamada/yamada-ui/blob/main/CONTRIBUTING.md) to assist you.
24
+
25
+ ## Licence
26
+
27
+ This package is licensed under the terms of the
28
+ [MIT license](https://github.com/hirotomoyamada/yamada-ui/blob/main/LICENSE).
@@ -0,0 +1,26 @@
1
+ declare const ACCEPT_TYPES: {
2
+ readonly png: "image/png";
3
+ readonly gif: "image/gif";
4
+ readonly jpeg: "image/jpeg";
5
+ readonly svg: "image/svg+xml";
6
+ readonly webp: "image/webp";
7
+ readonly mp4: "video/mp4";
8
+ readonly zip: "application/zip";
9
+ readonly csv: "text/csv";
10
+ readonly pdf: "application/pdf";
11
+ readonly doc: "application/msword";
12
+ readonly docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
13
+ readonly xls: "application/vnd.ms-excel";
14
+ readonly xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
15
+ readonly ppt: "application/vnd.ms-powerpoint";
16
+ readonly pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
17
+ readonly exe: "application/vnd.microsoft.portable-executable";
18
+ };
19
+ declare const IMAGE_ACCEPT_TYPE: ("image/png" | "image/gif" | "image/jpeg" | "image/svg+xml" | "image/webp")[];
20
+ declare const PDF_ACCEPT_TYPE: "application/pdf"[];
21
+ declare const MS_WORD_ACCEPT_TYPE: ("application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document")[];
22
+ declare const MS_EXCEL_ACCEPT_TYPE: ("application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")[];
23
+ declare const MS_POWERPOINT_ACCEPT_TYPE: ("application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation")[];
24
+ declare const EXE_ACCEPT_TYPE: "application/vnd.microsoft.portable-executable"[];
25
+
26
+ export { ACCEPT_TYPES, EXE_ACCEPT_TYPE, IMAGE_ACCEPT_TYPE, MS_EXCEL_ACCEPT_TYPE, MS_POWERPOINT_ACCEPT_TYPE, MS_WORD_ACCEPT_TYPE, PDF_ACCEPT_TYPE };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/accept-types.ts
21
+ var accept_types_exports = {};
22
+ __export(accept_types_exports, {
23
+ ACCEPT_TYPES: () => ACCEPT_TYPES,
24
+ EXE_ACCEPT_TYPE: () => EXE_ACCEPT_TYPE,
25
+ IMAGE_ACCEPT_TYPE: () => IMAGE_ACCEPT_TYPE,
26
+ MS_EXCEL_ACCEPT_TYPE: () => MS_EXCEL_ACCEPT_TYPE,
27
+ MS_POWERPOINT_ACCEPT_TYPE: () => MS_POWERPOINT_ACCEPT_TYPE,
28
+ MS_WORD_ACCEPT_TYPE: () => MS_WORD_ACCEPT_TYPE,
29
+ PDF_ACCEPT_TYPE: () => PDF_ACCEPT_TYPE
30
+ });
31
+ module.exports = __toCommonJS(accept_types_exports);
32
+ var ACCEPT_TYPES = {
33
+ png: "image/png",
34
+ gif: "image/gif",
35
+ jpeg: "image/jpeg",
36
+ svg: "image/svg+xml",
37
+ webp: "image/webp",
38
+ mp4: "video/mp4",
39
+ zip: "application/zip",
40
+ csv: "text/csv",
41
+ pdf: "application/pdf",
42
+ doc: "application/msword",
43
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
44
+ xls: "application/vnd.ms-excel",
45
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
46
+ ppt: "application/vnd.ms-powerpoint",
47
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
48
+ exe: "application/vnd.microsoft.portable-executable"
49
+ };
50
+ var IMAGE_ACCEPT_TYPE = [
51
+ ACCEPT_TYPES.png,
52
+ ACCEPT_TYPES.gif,
53
+ ACCEPT_TYPES.jpeg,
54
+ ACCEPT_TYPES.svg,
55
+ ACCEPT_TYPES.webp
56
+ ];
57
+ var PDF_ACCEPT_TYPE = [ACCEPT_TYPES.pdf];
58
+ var MS_WORD_ACCEPT_TYPE = [ACCEPT_TYPES.doc, ACCEPT_TYPES.docx];
59
+ var MS_EXCEL_ACCEPT_TYPE = [ACCEPT_TYPES.xls, ACCEPT_TYPES.xlsx];
60
+ var MS_POWERPOINT_ACCEPT_TYPE = [ACCEPT_TYPES.ppt, ACCEPT_TYPES.pptx];
61
+ var EXE_ACCEPT_TYPE = [ACCEPT_TYPES.exe];
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ ACCEPT_TYPES,
65
+ EXE_ACCEPT_TYPE,
66
+ IMAGE_ACCEPT_TYPE,
67
+ MS_EXCEL_ACCEPT_TYPE,
68
+ MS_POWERPOINT_ACCEPT_TYPE,
69
+ MS_WORD_ACCEPT_TYPE,
70
+ PDF_ACCEPT_TYPE
71
+ });
@@ -0,0 +1,18 @@
1
+ import {
2
+ ACCEPT_TYPES,
3
+ EXE_ACCEPT_TYPE,
4
+ IMAGE_ACCEPT_TYPE,
5
+ MS_EXCEL_ACCEPT_TYPE,
6
+ MS_POWERPOINT_ACCEPT_TYPE,
7
+ MS_WORD_ACCEPT_TYPE,
8
+ PDF_ACCEPT_TYPE
9
+ } from "./chunk-3VSGNLGM.mjs";
10
+ export {
11
+ ACCEPT_TYPES,
12
+ EXE_ACCEPT_TYPE,
13
+ IMAGE_ACCEPT_TYPE,
14
+ MS_EXCEL_ACCEPT_TYPE,
15
+ MS_POWERPOINT_ACCEPT_TYPE,
16
+ MS_WORD_ACCEPT_TYPE,
17
+ PDF_ACCEPT_TYPE
18
+ };
@@ -0,0 +1,41 @@
1
+ // src/accept-types.ts
2
+ var ACCEPT_TYPES = {
3
+ png: "image/png",
4
+ gif: "image/gif",
5
+ jpeg: "image/jpeg",
6
+ svg: "image/svg+xml",
7
+ webp: "image/webp",
8
+ mp4: "video/mp4",
9
+ zip: "application/zip",
10
+ csv: "text/csv",
11
+ pdf: "application/pdf",
12
+ doc: "application/msword",
13
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
14
+ xls: "application/vnd.ms-excel",
15
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
16
+ ppt: "application/vnd.ms-powerpoint",
17
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
18
+ exe: "application/vnd.microsoft.portable-executable"
19
+ };
20
+ var IMAGE_ACCEPT_TYPE = [
21
+ ACCEPT_TYPES.png,
22
+ ACCEPT_TYPES.gif,
23
+ ACCEPT_TYPES.jpeg,
24
+ ACCEPT_TYPES.svg,
25
+ ACCEPT_TYPES.webp
26
+ ];
27
+ var PDF_ACCEPT_TYPE = [ACCEPT_TYPES.pdf];
28
+ var MS_WORD_ACCEPT_TYPE = [ACCEPT_TYPES.doc, ACCEPT_TYPES.docx];
29
+ var MS_EXCEL_ACCEPT_TYPE = [ACCEPT_TYPES.xls, ACCEPT_TYPES.xlsx];
30
+ var MS_POWERPOINT_ACCEPT_TYPE = [ACCEPT_TYPES.ppt, ACCEPT_TYPES.pptx];
31
+ var EXE_ACCEPT_TYPE = [ACCEPT_TYPES.exe];
32
+
33
+ export {
34
+ ACCEPT_TYPES,
35
+ IMAGE_ACCEPT_TYPE,
36
+ PDF_ACCEPT_TYPE,
37
+ MS_WORD_ACCEPT_TYPE,
38
+ MS_EXCEL_ACCEPT_TYPE,
39
+ MS_POWERPOINT_ACCEPT_TYPE,
40
+ EXE_ACCEPT_TYPE
41
+ };
@@ -0,0 +1,139 @@
1
+ // src/dropzone.tsx
2
+ import {
3
+ ui,
4
+ forwardRef,
5
+ omitThemeProps,
6
+ useMultiComponentStyle
7
+ } from "@yamada-ui/core";
8
+ import {
9
+ formControlProperties,
10
+ useFormControlProps
11
+ } from "@yamada-ui/form-control";
12
+ import { Loading } from "@yamada-ui/loading";
13
+ import { Fade } from "@yamada-ui/transitions";
14
+ import { assignRef, createContext, cx, dataAttr, isArray, pickObject } from "@yamada-ui/utils";
15
+ import { Fragment } from "react";
16
+ import { useDropzone } from "react-dropzone";
17
+ import { jsx, jsxs } from "react/jsx-runtime";
18
+ var [DropzoneProvider, useDropzoneContext] = createContext({
19
+ name: "NativeSelectContext",
20
+ errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in "<Dropzone />"`
21
+ });
22
+ var Dropzone = forwardRef((props, ref) => {
23
+ const [styles, mergedProps] = useMultiComponentStyle("Dropzone", props);
24
+ const {
25
+ id,
26
+ name,
27
+ className,
28
+ isLoading,
29
+ overlayProps,
30
+ loadingProps,
31
+ openRef,
32
+ accept,
33
+ onDrop,
34
+ onDropAccepted,
35
+ onDropRejected,
36
+ multiple,
37
+ maxSize,
38
+ maxFiles,
39
+ autoFocus,
40
+ noClick,
41
+ noDrag,
42
+ noDragEventsBubbling,
43
+ noKeyboard,
44
+ onDragEnter,
45
+ onDragLeave,
46
+ onDragOver,
47
+ onFileDialogCancel,
48
+ onFileDialogOpen,
49
+ preventDropOnDocument,
50
+ useFsAccessApi,
51
+ children,
52
+ ...rest
53
+ } = useFormControlProps(omitThemeProps(mergedProps));
54
+ const disabled = isLoading || rest.disabled || rest.readOnly;
55
+ const formControlProps = pickObject(rest, formControlProperties);
56
+ const { getRootProps, getInputProps, isDragAccept, isDragReject, open } = useDropzone({
57
+ disabled,
58
+ accept: isArray(accept) ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {}) : accept,
59
+ onDrop,
60
+ onDropAccepted,
61
+ onDropRejected,
62
+ multiple,
63
+ maxSize,
64
+ maxFiles,
65
+ autoFocus,
66
+ noClick,
67
+ noDrag,
68
+ noDragEventsBubbling,
69
+ noKeyboard,
70
+ onDragEnter,
71
+ onDragLeave,
72
+ onDragOver,
73
+ onFileDialogCancel,
74
+ onFileDialogOpen,
75
+ preventDropOnDocument,
76
+ useFsAccessApi
77
+ });
78
+ assignRef(openRef, open);
79
+ const isDragIdle = !isDragAccept && !isDragReject;
80
+ const css = {
81
+ position: "relative",
82
+ display: "flex",
83
+ justifyContent: "center",
84
+ alignItems: "center",
85
+ ...styles.container
86
+ };
87
+ return /* @__PURE__ */ jsx(DropzoneProvider, { value: { isLoading, isDragAccept, isDragReject, isDragIdle, styles }, children: /* @__PURE__ */ jsxs(
88
+ ui.div,
89
+ {
90
+ className: cx("ui-dropzone", className),
91
+ __css: css,
92
+ ...rest,
93
+ ...getRootProps(),
94
+ "data-accept": dataAttr(isDragAccept),
95
+ "data-reject": dataAttr(isDragReject),
96
+ "data-idle": dataAttr(isDragIdle),
97
+ "data-loading": dataAttr(isLoading),
98
+ children: [
99
+ /* @__PURE__ */ jsx(LoadingOverlay, { loadingProps, ...overlayProps }),
100
+ /* @__PURE__ */ jsx(ui.input, { ref, id, name, ...formControlProps, ...getInputProps() }),
101
+ children
102
+ ]
103
+ }
104
+ ) });
105
+ });
106
+ var LoadingOverlay = ({ loadingProps, ...rest }) => {
107
+ const { isLoading, styles } = useDropzoneContext();
108
+ const css = {
109
+ position: "absolute",
110
+ top: 0,
111
+ left: 0,
112
+ w: "100%",
113
+ h: "100%",
114
+ display: "flex",
115
+ justifyContent: "center",
116
+ alignItems: "center",
117
+ ...styles.overlay
118
+ };
119
+ return /* @__PURE__ */ jsx(Fade, { isOpen: isLoading, unmountOnExit: true, className: "ui-dropzone-overlay", __css: css, ...rest, children: /* @__PURE__ */ jsx(Loading, { className: "ui-dropzone-loading", size: "8", ...loadingProps }) });
120
+ };
121
+ var DropzoneAccept = ({ children }) => {
122
+ const { isDragAccept } = useDropzoneContext();
123
+ return isDragAccept ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
124
+ };
125
+ var DropzoneReject = ({ children }) => {
126
+ const { isDragReject } = useDropzoneContext();
127
+ return isDragReject ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
128
+ };
129
+ var DropzoneIdle = ({ children }) => {
130
+ const { isDragIdle } = useDropzoneContext();
131
+ return isDragIdle ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
132
+ };
133
+
134
+ export {
135
+ Dropzone,
136
+ DropzoneAccept,
137
+ DropzoneReject,
138
+ DropzoneIdle
139
+ };
@@ -0,0 +1,24 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { HTMLUIProps, ThemeProps, CSSUIProps } from '@yamada-ui/core';
3
+ import { FormControlOptions } from '@yamada-ui/form-control';
4
+ import { LoadingProps } from '@yamada-ui/loading';
5
+ import { FadeProps } from '@yamada-ui/transitions';
6
+ import { FC, PropsWithChildren, ForwardedRef } from 'react';
7
+ import { DropzoneOptions as DropzoneOptions$1, Accept } from 'react-dropzone';
8
+
9
+ type DropzoneOptions = {
10
+ focusBorderColor?: CSSUIProps<'unresponsive'>['borderColor'];
11
+ errorBorderColor?: CSSUIProps<'unresponsive'>['borderColor'];
12
+ isLoading?: boolean;
13
+ overlayProps?: FadeProps;
14
+ loadingProps?: LoadingProps;
15
+ accept?: Accept | string[];
16
+ openRef?: ForwardedRef<() => void | undefined>;
17
+ };
18
+ type DropzoneProps = Omit<HTMLUIProps<'div'>, 'onDrop'> & ThemeProps<'Dropzone'> & DropzoneOptions & FormControlOptions & Omit<DropzoneOptions$1, 'accept'>;
19
+ declare const Dropzone: _yamada_ui_core.Component<"input", DropzoneProps>;
20
+ declare const DropzoneAccept: FC<PropsWithChildren>;
21
+ declare const DropzoneReject: FC<PropsWithChildren>;
22
+ declare const DropzoneIdle: FC<PropsWithChildren>;
23
+
24
+ export { Dropzone, DropzoneAccept, DropzoneIdle, DropzoneProps, DropzoneReject };
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/dropzone.tsx
21
+ var dropzone_exports = {};
22
+ __export(dropzone_exports, {
23
+ Dropzone: () => Dropzone,
24
+ DropzoneAccept: () => DropzoneAccept,
25
+ DropzoneIdle: () => DropzoneIdle,
26
+ DropzoneReject: () => DropzoneReject
27
+ });
28
+ module.exports = __toCommonJS(dropzone_exports);
29
+ var import_core = require("@yamada-ui/core");
30
+ var import_form_control = require("@yamada-ui/form-control");
31
+ var import_loading = require("@yamada-ui/loading");
32
+ var import_transitions = require("@yamada-ui/transitions");
33
+ var import_utils = require("@yamada-ui/utils");
34
+ var import_react = require("react");
35
+ var import_react_dropzone = require("react-dropzone");
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var [DropzoneProvider, useDropzoneContext] = (0, import_utils.createContext)({
38
+ name: "NativeSelectContext",
39
+ errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in "<Dropzone />"`
40
+ });
41
+ var Dropzone = (0, import_core.forwardRef)((props, ref) => {
42
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Dropzone", props);
43
+ const {
44
+ id,
45
+ name,
46
+ className,
47
+ isLoading,
48
+ overlayProps,
49
+ loadingProps,
50
+ openRef,
51
+ accept,
52
+ onDrop,
53
+ onDropAccepted,
54
+ onDropRejected,
55
+ multiple,
56
+ maxSize,
57
+ maxFiles,
58
+ autoFocus,
59
+ noClick,
60
+ noDrag,
61
+ noDragEventsBubbling,
62
+ noKeyboard,
63
+ onDragEnter,
64
+ onDragLeave,
65
+ onDragOver,
66
+ onFileDialogCancel,
67
+ onFileDialogOpen,
68
+ preventDropOnDocument,
69
+ useFsAccessApi,
70
+ children,
71
+ ...rest
72
+ } = (0, import_form_control.useFormControlProps)((0, import_core.omitThemeProps)(mergedProps));
73
+ const disabled = isLoading || rest.disabled || rest.readOnly;
74
+ const formControlProps = (0, import_utils.pickObject)(rest, import_form_control.formControlProperties);
75
+ const { getRootProps, getInputProps, isDragAccept, isDragReject, open } = (0, import_react_dropzone.useDropzone)({
76
+ disabled,
77
+ accept: (0, import_utils.isArray)(accept) ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {}) : accept,
78
+ onDrop,
79
+ onDropAccepted,
80
+ onDropRejected,
81
+ multiple,
82
+ maxSize,
83
+ maxFiles,
84
+ autoFocus,
85
+ noClick,
86
+ noDrag,
87
+ noDragEventsBubbling,
88
+ noKeyboard,
89
+ onDragEnter,
90
+ onDragLeave,
91
+ onDragOver,
92
+ onFileDialogCancel,
93
+ onFileDialogOpen,
94
+ preventDropOnDocument,
95
+ useFsAccessApi
96
+ });
97
+ (0, import_utils.assignRef)(openRef, open);
98
+ const isDragIdle = !isDragAccept && !isDragReject;
99
+ const css = {
100
+ position: "relative",
101
+ display: "flex",
102
+ justifyContent: "center",
103
+ alignItems: "center",
104
+ ...styles.container
105
+ };
106
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropzoneProvider, { value: { isLoading, isDragAccept, isDragReject, isDragIdle, styles }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
107
+ import_core.ui.div,
108
+ {
109
+ className: (0, import_utils.cx)("ui-dropzone", className),
110
+ __css: css,
111
+ ...rest,
112
+ ...getRootProps(),
113
+ "data-accept": (0, import_utils.dataAttr)(isDragAccept),
114
+ "data-reject": (0, import_utils.dataAttr)(isDragReject),
115
+ "data-idle": (0, import_utils.dataAttr)(isDragIdle),
116
+ "data-loading": (0, import_utils.dataAttr)(isLoading),
117
+ children: [
118
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingOverlay, { loadingProps, ...overlayProps }),
119
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.input, { ref, id, name, ...formControlProps, ...getInputProps() }),
120
+ children
121
+ ]
122
+ }
123
+ ) });
124
+ });
125
+ var LoadingOverlay = ({ loadingProps, ...rest }) => {
126
+ const { isLoading, styles } = useDropzoneContext();
127
+ const css = {
128
+ position: "absolute",
129
+ top: 0,
130
+ left: 0,
131
+ w: "100%",
132
+ h: "100%",
133
+ display: "flex",
134
+ justifyContent: "center",
135
+ alignItems: "center",
136
+ ...styles.overlay
137
+ };
138
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_transitions.Fade, { isOpen: isLoading, unmountOnExit: true, className: "ui-dropzone-overlay", __css: css, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loading.Loading, { className: "ui-dropzone-loading", size: "8", ...loadingProps }) });
139
+ };
140
+ var DropzoneAccept = ({ children }) => {
141
+ const { isDragAccept } = useDropzoneContext();
142
+ return isDragAccept ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children }) : null;
143
+ };
144
+ var DropzoneReject = ({ children }) => {
145
+ const { isDragReject } = useDropzoneContext();
146
+ return isDragReject ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children }) : null;
147
+ };
148
+ var DropzoneIdle = ({ children }) => {
149
+ const { isDragIdle } = useDropzoneContext();
150
+ return isDragIdle ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children }) : null;
151
+ };
152
+ // Annotate the CommonJS export names for ESM import in node:
153
+ 0 && (module.exports = {
154
+ Dropzone,
155
+ DropzoneAccept,
156
+ DropzoneIdle,
157
+ DropzoneReject
158
+ });
@@ -0,0 +1,12 @@
1
+ import {
2
+ Dropzone,
3
+ DropzoneAccept,
4
+ DropzoneIdle,
5
+ DropzoneReject
6
+ } from "./chunk-V5XO36JL.mjs";
7
+ export {
8
+ Dropzone,
9
+ DropzoneAccept,
10
+ DropzoneIdle,
11
+ DropzoneReject
12
+ };
@@ -0,0 +1,8 @@
1
+ export { Dropzone, DropzoneAccept, DropzoneIdle, DropzoneProps, DropzoneReject } from './dropzone.js';
2
+ export { ACCEPT_TYPES, EXE_ACCEPT_TYPE, IMAGE_ACCEPT_TYPE, MS_EXCEL_ACCEPT_TYPE, MS_POWERPOINT_ACCEPT_TYPE, MS_WORD_ACCEPT_TYPE, PDF_ACCEPT_TYPE } from './accept-types.js';
3
+ import '@yamada-ui/core';
4
+ import '@yamada-ui/form-control';
5
+ import '@yamada-ui/loading';
6
+ import '@yamada-ui/transitions';
7
+ import 'react';
8
+ import 'react-dropzone';
package/dist/index.js ADDED
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ ACCEPT_TYPES: () => ACCEPT_TYPES,
24
+ Dropzone: () => Dropzone,
25
+ DropzoneAccept: () => DropzoneAccept,
26
+ DropzoneIdle: () => DropzoneIdle,
27
+ DropzoneReject: () => DropzoneReject,
28
+ EXE_ACCEPT_TYPE: () => EXE_ACCEPT_TYPE,
29
+ IMAGE_ACCEPT_TYPE: () => IMAGE_ACCEPT_TYPE,
30
+ MS_EXCEL_ACCEPT_TYPE: () => MS_EXCEL_ACCEPT_TYPE,
31
+ MS_POWERPOINT_ACCEPT_TYPE: () => MS_POWERPOINT_ACCEPT_TYPE,
32
+ MS_WORD_ACCEPT_TYPE: () => MS_WORD_ACCEPT_TYPE,
33
+ PDF_ACCEPT_TYPE: () => PDF_ACCEPT_TYPE
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/dropzone.tsx
38
+ var import_core = require("@yamada-ui/core");
39
+ var import_form_control = require("@yamada-ui/form-control");
40
+ var import_loading = require("@yamada-ui/loading");
41
+ var import_transitions = require("@yamada-ui/transitions");
42
+ var import_utils = require("@yamada-ui/utils");
43
+ var import_react = require("react");
44
+ var import_react_dropzone = require("react-dropzone");
45
+ var import_jsx_runtime = require("react/jsx-runtime");
46
+ var [DropzoneProvider, useDropzoneContext] = (0, import_utils.createContext)({
47
+ name: "NativeSelectContext",
48
+ errorMessage: `useDropzoneContext returned is 'undefined'. Seems you forgot to wrap the components in "<Dropzone />"`
49
+ });
50
+ var Dropzone = (0, import_core.forwardRef)((props, ref) => {
51
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Dropzone", props);
52
+ const {
53
+ id,
54
+ name,
55
+ className,
56
+ isLoading,
57
+ overlayProps,
58
+ loadingProps,
59
+ openRef,
60
+ accept,
61
+ onDrop,
62
+ onDropAccepted,
63
+ onDropRejected,
64
+ multiple,
65
+ maxSize,
66
+ maxFiles,
67
+ autoFocus,
68
+ noClick,
69
+ noDrag,
70
+ noDragEventsBubbling,
71
+ noKeyboard,
72
+ onDragEnter,
73
+ onDragLeave,
74
+ onDragOver,
75
+ onFileDialogCancel,
76
+ onFileDialogOpen,
77
+ preventDropOnDocument,
78
+ useFsAccessApi,
79
+ children,
80
+ ...rest
81
+ } = (0, import_form_control.useFormControlProps)((0, import_core.omitThemeProps)(mergedProps));
82
+ const disabled = isLoading || rest.disabled || rest.readOnly;
83
+ const formControlProps = (0, import_utils.pickObject)(rest, import_form_control.formControlProperties);
84
+ const { getRootProps, getInputProps, isDragAccept, isDragReject, open } = (0, import_react_dropzone.useDropzone)({
85
+ disabled,
86
+ accept: (0, import_utils.isArray)(accept) ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {}) : accept,
87
+ onDrop,
88
+ onDropAccepted,
89
+ onDropRejected,
90
+ multiple,
91
+ maxSize,
92
+ maxFiles,
93
+ autoFocus,
94
+ noClick,
95
+ noDrag,
96
+ noDragEventsBubbling,
97
+ noKeyboard,
98
+ onDragEnter,
99
+ onDragLeave,
100
+ onDragOver,
101
+ onFileDialogCancel,
102
+ onFileDialogOpen,
103
+ preventDropOnDocument,
104
+ useFsAccessApi
105
+ });
106
+ (0, import_utils.assignRef)(openRef, open);
107
+ const isDragIdle = !isDragAccept && !isDragReject;
108
+ const css = {
109
+ position: "relative",
110
+ display: "flex",
111
+ justifyContent: "center",
112
+ alignItems: "center",
113
+ ...styles.container
114
+ };
115
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropzoneProvider, { value: { isLoading, isDragAccept, isDragReject, isDragIdle, styles }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
116
+ import_core.ui.div,
117
+ {
118
+ className: (0, import_utils.cx)("ui-dropzone", className),
119
+ __css: css,
120
+ ...rest,
121
+ ...getRootProps(),
122
+ "data-accept": (0, import_utils.dataAttr)(isDragAccept),
123
+ "data-reject": (0, import_utils.dataAttr)(isDragReject),
124
+ "data-idle": (0, import_utils.dataAttr)(isDragIdle),
125
+ "data-loading": (0, import_utils.dataAttr)(isLoading),
126
+ children: [
127
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingOverlay, { loadingProps, ...overlayProps }),
128
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.input, { ref, id, name, ...formControlProps, ...getInputProps() }),
129
+ children
130
+ ]
131
+ }
132
+ ) });
133
+ });
134
+ var LoadingOverlay = ({ loadingProps, ...rest }) => {
135
+ const { isLoading, styles } = useDropzoneContext();
136
+ const css = {
137
+ position: "absolute",
138
+ top: 0,
139
+ left: 0,
140
+ w: "100%",
141
+ h: "100%",
142
+ display: "flex",
143
+ justifyContent: "center",
144
+ alignItems: "center",
145
+ ...styles.overlay
146
+ };
147
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_transitions.Fade, { isOpen: isLoading, unmountOnExit: true, className: "ui-dropzone-overlay", __css: css, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loading.Loading, { className: "ui-dropzone-loading", size: "8", ...loadingProps }) });
148
+ };
149
+ var DropzoneAccept = ({ children }) => {
150
+ const { isDragAccept } = useDropzoneContext();
151
+ return isDragAccept ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children }) : null;
152
+ };
153
+ var DropzoneReject = ({ children }) => {
154
+ const { isDragReject } = useDropzoneContext();
155
+ return isDragReject ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children }) : null;
156
+ };
157
+ var DropzoneIdle = ({ children }) => {
158
+ const { isDragIdle } = useDropzoneContext();
159
+ return isDragIdle ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children }) : null;
160
+ };
161
+
162
+ // src/accept-types.ts
163
+ var ACCEPT_TYPES = {
164
+ png: "image/png",
165
+ gif: "image/gif",
166
+ jpeg: "image/jpeg",
167
+ svg: "image/svg+xml",
168
+ webp: "image/webp",
169
+ mp4: "video/mp4",
170
+ zip: "application/zip",
171
+ csv: "text/csv",
172
+ pdf: "application/pdf",
173
+ doc: "application/msword",
174
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
175
+ xls: "application/vnd.ms-excel",
176
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
177
+ ppt: "application/vnd.ms-powerpoint",
178
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
179
+ exe: "application/vnd.microsoft.portable-executable"
180
+ };
181
+ var IMAGE_ACCEPT_TYPE = [
182
+ ACCEPT_TYPES.png,
183
+ ACCEPT_TYPES.gif,
184
+ ACCEPT_TYPES.jpeg,
185
+ ACCEPT_TYPES.svg,
186
+ ACCEPT_TYPES.webp
187
+ ];
188
+ var PDF_ACCEPT_TYPE = [ACCEPT_TYPES.pdf];
189
+ var MS_WORD_ACCEPT_TYPE = [ACCEPT_TYPES.doc, ACCEPT_TYPES.docx];
190
+ var MS_EXCEL_ACCEPT_TYPE = [ACCEPT_TYPES.xls, ACCEPT_TYPES.xlsx];
191
+ var MS_POWERPOINT_ACCEPT_TYPE = [ACCEPT_TYPES.ppt, ACCEPT_TYPES.pptx];
192
+ var EXE_ACCEPT_TYPE = [ACCEPT_TYPES.exe];
193
+ // Annotate the CommonJS export names for ESM import in node:
194
+ 0 && (module.exports = {
195
+ ACCEPT_TYPES,
196
+ Dropzone,
197
+ DropzoneAccept,
198
+ DropzoneIdle,
199
+ DropzoneReject,
200
+ EXE_ACCEPT_TYPE,
201
+ IMAGE_ACCEPT_TYPE,
202
+ MS_EXCEL_ACCEPT_TYPE,
203
+ MS_POWERPOINT_ACCEPT_TYPE,
204
+ MS_WORD_ACCEPT_TYPE,
205
+ PDF_ACCEPT_TYPE
206
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,28 @@
1
+ import {
2
+ ACCEPT_TYPES,
3
+ EXE_ACCEPT_TYPE,
4
+ IMAGE_ACCEPT_TYPE,
5
+ MS_EXCEL_ACCEPT_TYPE,
6
+ MS_POWERPOINT_ACCEPT_TYPE,
7
+ MS_WORD_ACCEPT_TYPE,
8
+ PDF_ACCEPT_TYPE
9
+ } from "./chunk-3VSGNLGM.mjs";
10
+ import {
11
+ Dropzone,
12
+ DropzoneAccept,
13
+ DropzoneIdle,
14
+ DropzoneReject
15
+ } from "./chunk-V5XO36JL.mjs";
16
+ export {
17
+ ACCEPT_TYPES,
18
+ Dropzone,
19
+ DropzoneAccept,
20
+ DropzoneIdle,
21
+ DropzoneReject,
22
+ EXE_ACCEPT_TYPE,
23
+ IMAGE_ACCEPT_TYPE,
24
+ MS_EXCEL_ACCEPT_TYPE,
25
+ MS_POWERPOINT_ACCEPT_TYPE,
26
+ MS_WORD_ACCEPT_TYPE,
27
+ PDF_ACCEPT_TYPE
28
+ };
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@yamada-ui/dropzone",
3
+ "version": "0.1.0",
4
+ "description": "Yamada UI dropzone component",
5
+ "keywords": [
6
+ "yamada",
7
+ "yamada ui",
8
+ "react",
9
+ "emotion",
10
+ "component",
11
+ "dropzone",
12
+ "ui",
13
+ "uikit",
14
+ "styled",
15
+ "style-props",
16
+ "styled-component",
17
+ "css-in-js"
18
+ ],
19
+ "author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
20
+ "license": "MIT",
21
+ "main": "dist/index.js",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "sideEffects": false,
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/hirotomoyamada/yamada-ui",
32
+ "directory": "packages/components/dropzone"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/hirotomoyamada/yamada-ui/issues"
36
+ },
37
+ "dependencies": {
38
+ "react-dropzone": "14.2.3",
39
+ "@yamada-ui/utils": "0.1.0",
40
+ "@yamada-ui/form-control": "0.1.0",
41
+ "@yamada-ui/core": "0.1.0",
42
+ "@yamada-ui/transitions": "0.1.0",
43
+ "@yamada-ui/loading": "0.1.0"
44
+ },
45
+ "devDependencies": {
46
+ "react": "^18.0.0",
47
+ "clean-package": "2.2.0"
48
+ },
49
+ "peerDependencies": {
50
+ "react": ">=18"
51
+ },
52
+ "clean-package": "../../../clean-package.config.json",
53
+ "tsup": {
54
+ "clean": true,
55
+ "target": "es2019",
56
+ "format": [
57
+ "cjs",
58
+ "esm"
59
+ ]
60
+ },
61
+ "module": "dist/index.mjs",
62
+ "types": "dist/index.d.ts",
63
+ "exports": {
64
+ ".": {
65
+ "types": "./dist/index.d.ts",
66
+ "import": "./dist/index.mjs",
67
+ "require": "./dist/index.js"
68
+ },
69
+ "./package.json": "./package.json"
70
+ },
71
+ "scripts": {
72
+ "dev": "pnpm build:fast -- --watch",
73
+ "build": "tsup src --dts",
74
+ "build:fast": "tsup src",
75
+ "clean": "rimraf dist .turbo",
76
+ "typecheck": "tsc --noEmit",
77
+ "gen:docs": "tsx ../../../scripts/generate-docs"
78
+ }
79
+ }