@mekari/pixel3-dropzone 0.0.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.
@@ -0,0 +1,109 @@
1
+ import * as vue from 'vue';
2
+ import { DropzoneProps, DropzoenEmits } from './dropzone.props.js';
3
+
4
+ declare function useDropzone(props: DropzoneProps, emit: DropzoenEmits): {
5
+ rootAttrs: vue.ComputedRef<{
6
+ 'data-pixel-component': string;
7
+ id: string | undefined;
8
+ class: string;
9
+ onClick: (e: Event) => void;
10
+ onDragover: (e: DragEvent) => void;
11
+ onDragleave: (e: DragEvent) => void;
12
+ onDrop: (e: DragEvent) => void;
13
+ }>;
14
+ wrapperAttrs: vue.ComputedRef<{
15
+ 'data-invalid': true | undefined;
16
+ 'data-disabled': true | undefined;
17
+ 'data-variant': "default" | "logo" | "product" | "avatar";
18
+ tabindex: number;
19
+ class: string;
20
+ style: {
21
+ background: string;
22
+ borderRadius: string;
23
+ };
24
+ }>;
25
+ boxAttrs: vue.ComputedRef<{
26
+ class: string;
27
+ }>;
28
+ logoBoxAttrs: vue.ComputedRef<{
29
+ class: string;
30
+ onClick: () => void;
31
+ }>;
32
+ productBoxAttrs: vue.ComputedRef<{
33
+ class: string;
34
+ onClick: () => void;
35
+ }>;
36
+ avatarBoxAttrs: vue.ComputedRef<{
37
+ class: string;
38
+ onClick: () => void;
39
+ }>;
40
+ overlayWrapperAttrs: vue.ComputedRef<{
41
+ class: string;
42
+ }>;
43
+ overlayAttrs: vue.ComputedRef<{
44
+ ref: vue.Ref<any>;
45
+ class: string;
46
+ style: {
47
+ display: string;
48
+ background: string;
49
+ };
50
+ }>;
51
+ inputAttrs: vue.ComputedRef<{
52
+ ref: vue.Ref<any>;
53
+ id: string;
54
+ class: string;
55
+ type: string;
56
+ name: string | undefined;
57
+ accept: string | undefined;
58
+ multiple: boolean;
59
+ disabled: boolean;
60
+ required: boolean;
61
+ onChange: (e: Event) => void;
62
+ }>;
63
+ imageAttrs: vue.ComputedRef<{
64
+ src: string;
65
+ style: {
66
+ borderRadius: string;
67
+ height: string;
68
+ objectFit: "cover";
69
+ };
70
+ }>;
71
+ cancelButtonAttrs: vue.ComputedRef<{
72
+ color: string;
73
+ style: {
74
+ cursor: string;
75
+ };
76
+ onClick: (e: Event) => void;
77
+ }>;
78
+ browseButtonAttrs: vue.ComputedRef<{
79
+ as: "span";
80
+ weight: "semiBold";
81
+ color: string;
82
+ style: {
83
+ cursor: string;
84
+ };
85
+ onClick: () => void;
86
+ }>;
87
+ previewAttrs: vue.ComputedRef<{
88
+ class: string;
89
+ }>;
90
+ overlayPreviewAttrs: vue.ComputedRef<{
91
+ 'data-overlay-preview': boolean;
92
+ class: string;
93
+ onClick: () => void;
94
+ }>;
95
+ clearButtonAttrs: vue.ComputedRef<{
96
+ class: string;
97
+ name: string;
98
+ variant: "fill";
99
+ color: "red.400";
100
+ style: {
101
+ top: string;
102
+ right: string;
103
+ };
104
+ onClick: (e: Event) => void;
105
+ }>;
106
+ hasPreview: vue.ComputedRef<string | false>;
107
+ };
108
+
109
+ export { useDropzone };
@@ -0,0 +1,312 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/modules/dropzone.hooks.ts
22
+ var dropzone_hooks_exports = {};
23
+ __export(dropzone_hooks_exports, {
24
+ useDropzone: () => useDropzone
25
+ });
26
+ module.exports = __toCommonJS(dropzone_hooks_exports);
27
+ var import_vue = require("vue");
28
+ var import_pixel3_utils = require("@mekari/pixel3-utils");
29
+ var import_recipes = require("@mekari/pixel3-styled-system/recipes");
30
+ function useDropzone(props, emit) {
31
+ const {
32
+ id,
33
+ variant,
34
+ name,
35
+ accept,
36
+ isMultiple,
37
+ hasCustomUpload,
38
+ overlayVariant,
39
+ isEnableInputFile,
40
+ isEnableDragAndDrop,
41
+ isShowPreview,
42
+ isShowOverlay,
43
+ isLoading,
44
+ isInvalid,
45
+ isDisabled,
46
+ isRequired
47
+ } = (0, import_vue.toRefs)(props);
48
+ const files = (0, import_vue.ref)();
49
+ const fileInput = (0, import_vue.ref)();
50
+ const preview = (0, import_vue.ref)("");
51
+ const showOverlay = (0, import_vue.ref)(isShowOverlay.value);
52
+ const overlay = (0, import_vue.ref)();
53
+ const getId = id.value || (0, import_pixel3_utils.getUniqueId)("", "dropzone").value;
54
+ const hasPreview = (0, import_vue.computed)(() => {
55
+ return isShowPreview.value && preview.value;
56
+ });
57
+ const rootAttrs = (0, import_vue.computed)(() => {
58
+ return {
59
+ "data-pixel-component": "MpDropzone",
60
+ id: getId,
61
+ class: (0, import_recipes.dropzoneSlotRecipe)().root,
62
+ onClick: handleClick,
63
+ onDragover: handleDragover,
64
+ onDragleave: handleDragleave,
65
+ onDrop: handleDrop
66
+ };
67
+ });
68
+ const wrapperAttrs = (0, import_vue.computed)(() => {
69
+ return {
70
+ "data-invalid": isInvalid.value || void 0,
71
+ "data-disabled": isDisabled.value || void 0,
72
+ "data-variant": variant.value,
73
+ tabindex: isDisabled.value ? -1 : 0,
74
+ class: (0, import_recipes.dropzoneSlotRecipe)().wrapper,
75
+ style: {
76
+ background: variant.value === "default" ? "var(--mp-colors-white)" : "var(--mp-colors-background)",
77
+ borderRadius: variant.value === "avatar" ? "var(--mp-radii-full)" : "var(--mp-radii-md)"
78
+ }
79
+ };
80
+ });
81
+ const boxAttrs = (0, import_vue.computed)(() => {
82
+ return {
83
+ class: (0, import_recipes.dropzoneSlotRecipe)().box
84
+ };
85
+ });
86
+ const logoBoxAttrs = (0, import_vue.computed)(() => {
87
+ return {
88
+ class: (0, import_recipes.dropzoneSlotRecipe)().logoBox,
89
+ onClick: handleClickInput
90
+ };
91
+ });
92
+ const productBoxAttrs = (0, import_vue.computed)(() => {
93
+ return {
94
+ class: (0, import_recipes.dropzoneSlotRecipe)().productBox,
95
+ onClick: handleClickInput
96
+ };
97
+ });
98
+ const avatarBoxAttrs = (0, import_vue.computed)(() => {
99
+ return {
100
+ class: (0, import_recipes.dropzoneSlotRecipe)().avatarBox,
101
+ onClick: handleClickInput
102
+ };
103
+ });
104
+ const overlayWrapperAttrs = (0, import_vue.computed)(() => {
105
+ return {
106
+ class: (0, import_recipes.dropzoneSlotRecipe)().overlayWrapper
107
+ };
108
+ });
109
+ const overlayAttrs = (0, import_vue.computed)(() => {
110
+ return {
111
+ ref: overlay,
112
+ class: (0, import_recipes.dropzoneSlotRecipe)().overlay,
113
+ style: {
114
+ display: showOverlay.value ? "flex" : "none",
115
+ background: overlayVariant.value === "white" ? "var(--mp-colors-whiteAlpha.300)" : "var(--mp-colors-overlay)"
116
+ }
117
+ };
118
+ });
119
+ const inputAttrs = (0, import_vue.computed)(() => {
120
+ return {
121
+ ref: fileInput,
122
+ id: `input-${getId}`,
123
+ class: (0, import_recipes.sharedSlotRecipe)().hidden,
124
+ type: "file",
125
+ name: name == null ? void 0 : name.value,
126
+ accept: accept == null ? void 0 : accept.value,
127
+ multiple: isMultiple.value,
128
+ disabled: isDisabled.value,
129
+ required: isRequired.value,
130
+ onChange: handleChangeInput
131
+ };
132
+ });
133
+ const cancelButtonAttrs = (0, import_vue.computed)(() => {
134
+ return {
135
+ color: "red.400",
136
+ style: {
137
+ cursor: "pointer"
138
+ },
139
+ onClick: handleCancel
140
+ };
141
+ });
142
+ const browseButtonAttrs = (0, import_vue.computed)(() => {
143
+ return {
144
+ as: "span",
145
+ weight: "semiBold",
146
+ color: "blue.400",
147
+ style: {
148
+ cursor: "pointer"
149
+ },
150
+ onClick: handleClickInput
151
+ };
152
+ });
153
+ const previewAttrs = (0, import_vue.computed)(() => {
154
+ return {
155
+ class: (0, import_recipes.dropzoneSlotRecipe)().preview
156
+ };
157
+ });
158
+ const overlayPreviewAttrs = (0, import_vue.computed)(() => {
159
+ return {
160
+ "data-overlay-preview": true,
161
+ class: (0, import_recipes.dropzoneSlotRecipe)().overlayPreview,
162
+ onClick: handleClickInput
163
+ };
164
+ });
165
+ const imageAttrs = (0, import_vue.computed)(() => {
166
+ return {
167
+ src: preview.value,
168
+ style: {
169
+ borderRadius: "inherit",
170
+ height: "100%",
171
+ objectFit: "cover"
172
+ }
173
+ };
174
+ });
175
+ const clearButtonAttrs = (0, import_vue.computed)(() => {
176
+ return {
177
+ class: (0, import_recipes.dropzoneSlotRecipe)().clearButton,
178
+ name: "minus-circular",
179
+ variant: "fill",
180
+ color: "red.400",
181
+ style: {
182
+ top: variant.value === "avatar" ? "-4px" : "-10px",
183
+ right: variant.value === "avatar" ? "-4px" : "-10px"
184
+ },
185
+ onClick: handleClear
186
+ };
187
+ });
188
+ function handleClick(e) {
189
+ if (!isEnableInputFile.value) {
190
+ return;
191
+ }
192
+ handleClickInput();
193
+ emit("click", e);
194
+ }
195
+ __name(handleClick, "handleClick");
196
+ function handleClickInput() {
197
+ if (isDisabled.value) {
198
+ return;
199
+ }
200
+ files.value = null;
201
+ fileInput.value.value = null;
202
+ fileInput.value.click();
203
+ }
204
+ __name(handleClickInput, "handleClickInput");
205
+ function handleDragover(e) {
206
+ e.preventDefault();
207
+ if (!isEnableDragAndDrop.value) {
208
+ return;
209
+ }
210
+ emit("dragover", e);
211
+ if (hasCustomUpload.value) {
212
+ showOverlay.value = true;
213
+ }
214
+ }
215
+ __name(handleDragover, "handleDragover");
216
+ function handleDragleave(e) {
217
+ if (!isEnableDragAndDrop.value) {
218
+ return;
219
+ }
220
+ emit("dragleave", e);
221
+ if (e.target === overlay.value) {
222
+ showOverlay.value = false;
223
+ }
224
+ }
225
+ __name(handleDragleave, "handleDragleave");
226
+ function handleDrop(e) {
227
+ e.preventDefault();
228
+ if (!isEnableDragAndDrop.value) {
229
+ return;
230
+ }
231
+ emit("drop", e);
232
+ const target = e.dataTransfer;
233
+ if (target && target.files) {
234
+ const {
235
+ files: files2
236
+ } = target;
237
+ handleFiles(files2);
238
+ }
239
+ if (hasCustomUpload.value) {
240
+ showOverlay.value = false;
241
+ }
242
+ }
243
+ __name(handleDrop, "handleDrop");
244
+ function handleChangeInput(e) {
245
+ const target = e.target;
246
+ if (target && target.files) {
247
+ const {
248
+ files: files2
249
+ } = target;
250
+ handleFiles(files2);
251
+ }
252
+ }
253
+ __name(handleChangeInput, "handleChangeInput");
254
+ function handleFiles(item) {
255
+ if (isDisabled.value) {
256
+ return;
257
+ }
258
+ if (item && item.length > 0) {
259
+ files.value = item;
260
+ }
261
+ emit("change", files.value);
262
+ if (files.value && files.value.length === 1) {
263
+ handlePreview(files.value[0]);
264
+ }
265
+ }
266
+ __name(handleFiles, "handleFiles");
267
+ function handlePreview(item) {
268
+ if (isLoading.value) {
269
+ return;
270
+ }
271
+ const REGEXP_MIME_TYPE_IMAGES = /^image\/\w+$/;
272
+ if (REGEXP_MIME_TYPE_IMAGES.test(item.type)) {
273
+ preview.value = URL.createObjectURL(item);
274
+ }
275
+ }
276
+ __name(handlePreview, "handlePreview");
277
+ function handleClear(e) {
278
+ e.stopPropagation();
279
+ emit("clear", e);
280
+ files.value = null;
281
+ preview.value = "";
282
+ }
283
+ __name(handleClear, "handleClear");
284
+ function handleCancel(e) {
285
+ e.stopPropagation();
286
+ emit("cancel", e);
287
+ }
288
+ __name(handleCancel, "handleCancel");
289
+ return {
290
+ rootAttrs,
291
+ wrapperAttrs,
292
+ boxAttrs,
293
+ logoBoxAttrs,
294
+ productBoxAttrs,
295
+ avatarBoxAttrs,
296
+ overlayWrapperAttrs,
297
+ overlayAttrs,
298
+ inputAttrs,
299
+ imageAttrs,
300
+ cancelButtonAttrs,
301
+ browseButtonAttrs,
302
+ previewAttrs,
303
+ overlayPreviewAttrs,
304
+ clearButtonAttrs,
305
+ hasPreview
306
+ };
307
+ }
308
+ __name(useDropzone, "useDropzone");
309
+ // Annotate the CommonJS export names for ESM import in node:
310
+ 0 && (module.exports = {
311
+ useDropzone
312
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ useDropzone
3
+ } from "../chunk-PB3KHIIV.mjs";
4
+ import "../chunk-QZ7VFGWC.mjs";
5
+ export {
6
+ useDropzone
7
+ };
@@ -0,0 +1,83 @@
1
+ import { PropType, ExtractPropTypes } from 'vue';
2
+
3
+ declare const dropzoneProps: {
4
+ id: {
5
+ type: PropType<string>;
6
+ default: string;
7
+ };
8
+ variant: {
9
+ type: PropType<"default" | "logo" | "product" | "avatar">;
10
+ default: string;
11
+ };
12
+ accept: {
13
+ type: PropType<string>;
14
+ };
15
+ name: {
16
+ type: PropType<string>;
17
+ };
18
+ placeholder: {
19
+ type: PropType<string>;
20
+ default: string;
21
+ };
22
+ description: {
23
+ type: PropType<string>;
24
+ default: string;
25
+ };
26
+ loadingText: {
27
+ type: PropType<string>;
28
+ default: string;
29
+ };
30
+ buttonText: {
31
+ type: PropType<string>;
32
+ default: string;
33
+ };
34
+ overlayVariant: {
35
+ type: PropType<"white" | "black">;
36
+ default: string;
37
+ };
38
+ isShowPreview: {
39
+ type: PropType<boolean>;
40
+ default: boolean;
41
+ };
42
+ isMultiple: {
43
+ type: PropType<boolean>;
44
+ default: boolean;
45
+ };
46
+ isLoading: {
47
+ type: PropType<boolean>;
48
+ default: boolean;
49
+ };
50
+ isDisabled: {
51
+ type: PropType<boolean>;
52
+ default: boolean;
53
+ };
54
+ isInvalid: {
55
+ type: PropType<boolean>;
56
+ default: boolean;
57
+ };
58
+ isRequired: {
59
+ type: PropType<boolean>;
60
+ default: boolean;
61
+ };
62
+ hasCustomUpload: {
63
+ type: PropType<boolean>;
64
+ default: boolean;
65
+ };
66
+ isEnableDragAndDrop: {
67
+ type: PropType<boolean>;
68
+ default: boolean;
69
+ };
70
+ isEnableInputFile: {
71
+ type: PropType<boolean>;
72
+ default: boolean;
73
+ };
74
+ isShowOverlay: {
75
+ type: PropType<boolean>;
76
+ default: boolean;
77
+ };
78
+ };
79
+ declare const dropzoneEmit: string[];
80
+ type DropzoneProps = ExtractPropTypes<typeof dropzoneProps>;
81
+ type DropzoenEmits = (event: (typeof dropzoneEmit)[number], value?: unknown) => void;
82
+
83
+ export { DropzoenEmits, DropzoneProps, dropzoneEmit, dropzoneProps };
@@ -0,0 +1,83 @@
1
+ import { PropType, ExtractPropTypes } from 'vue';
2
+
3
+ declare const dropzoneProps: {
4
+ id: {
5
+ type: PropType<string>;
6
+ default: string;
7
+ };
8
+ variant: {
9
+ type: PropType<"default" | "logo" | "product" | "avatar">;
10
+ default: string;
11
+ };
12
+ accept: {
13
+ type: PropType<string>;
14
+ };
15
+ name: {
16
+ type: PropType<string>;
17
+ };
18
+ placeholder: {
19
+ type: PropType<string>;
20
+ default: string;
21
+ };
22
+ description: {
23
+ type: PropType<string>;
24
+ default: string;
25
+ };
26
+ loadingText: {
27
+ type: PropType<string>;
28
+ default: string;
29
+ };
30
+ buttonText: {
31
+ type: PropType<string>;
32
+ default: string;
33
+ };
34
+ overlayVariant: {
35
+ type: PropType<"white" | "black">;
36
+ default: string;
37
+ };
38
+ isShowPreview: {
39
+ type: PropType<boolean>;
40
+ default: boolean;
41
+ };
42
+ isMultiple: {
43
+ type: PropType<boolean>;
44
+ default: boolean;
45
+ };
46
+ isLoading: {
47
+ type: PropType<boolean>;
48
+ default: boolean;
49
+ };
50
+ isDisabled: {
51
+ type: PropType<boolean>;
52
+ default: boolean;
53
+ };
54
+ isInvalid: {
55
+ type: PropType<boolean>;
56
+ default: boolean;
57
+ };
58
+ isRequired: {
59
+ type: PropType<boolean>;
60
+ default: boolean;
61
+ };
62
+ hasCustomUpload: {
63
+ type: PropType<boolean>;
64
+ default: boolean;
65
+ };
66
+ isEnableDragAndDrop: {
67
+ type: PropType<boolean>;
68
+ default: boolean;
69
+ };
70
+ isEnableInputFile: {
71
+ type: PropType<boolean>;
72
+ default: boolean;
73
+ };
74
+ isShowOverlay: {
75
+ type: PropType<boolean>;
76
+ default: boolean;
77
+ };
78
+ };
79
+ declare const dropzoneEmit: string[];
80
+ type DropzoneProps = ExtractPropTypes<typeof dropzoneProps>;
81
+ type DropzoenEmits = (event: (typeof dropzoneEmit)[number], value?: unknown) => void;
82
+
83
+ export { DropzoenEmits, DropzoneProps, dropzoneEmit, dropzoneProps };
@@ -0,0 +1,108 @@
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/modules/dropzone.props.ts
21
+ var dropzone_props_exports = {};
22
+ __export(dropzone_props_exports, {
23
+ dropzoneEmit: () => dropzoneEmit,
24
+ dropzoneProps: () => dropzoneProps
25
+ });
26
+ module.exports = __toCommonJS(dropzone_props_exports);
27
+ var dropzoneProps = {
28
+ id: {
29
+ type: String,
30
+ default: ""
31
+ },
32
+ variant: {
33
+ type: String,
34
+ default: "default"
35
+ },
36
+ accept: {
37
+ type: String
38
+ },
39
+ name: {
40
+ type: String
41
+ },
42
+ placeholder: {
43
+ type: String,
44
+ default: "Drop your file(s) here or "
45
+ },
46
+ description: {
47
+ type: String,
48
+ default: "Description of dropzone"
49
+ },
50
+ loadingText: {
51
+ type: String,
52
+ default: "Uploading..."
53
+ },
54
+ buttonText: {
55
+ type: String,
56
+ default: "Change file"
57
+ },
58
+ overlayVariant: {
59
+ type: String,
60
+ default: "white"
61
+ },
62
+ isShowPreview: {
63
+ type: Boolean,
64
+ default: true
65
+ },
66
+ isMultiple: {
67
+ type: Boolean,
68
+ default: false
69
+ },
70
+ isLoading: {
71
+ type: Boolean,
72
+ default: false
73
+ },
74
+ isDisabled: {
75
+ type: Boolean,
76
+ default: false
77
+ },
78
+ isInvalid: {
79
+ type: Boolean,
80
+ default: false
81
+ },
82
+ isRequired: {
83
+ type: Boolean,
84
+ default: false
85
+ },
86
+ hasCustomUpload: {
87
+ type: Boolean,
88
+ default: false
89
+ },
90
+ isEnableDragAndDrop: {
91
+ type: Boolean,
92
+ default: true
93
+ },
94
+ isEnableInputFile: {
95
+ type: Boolean,
96
+ default: false
97
+ },
98
+ isShowOverlay: {
99
+ type: Boolean,
100
+ default: false
101
+ }
102
+ };
103
+ var dropzoneEmit = ["click", "dragover", "dragleave", "drop", "change", "clear", "cancel"];
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ dropzoneEmit,
107
+ dropzoneProps
108
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ dropzoneEmit,
3
+ dropzoneProps
4
+ } from "../chunk-CQO276YD.mjs";
5
+ import "../chunk-QZ7VFGWC.mjs";
6
+ export {
7
+ dropzoneEmit,
8
+ dropzoneProps
9
+ };