@destyler/file-upload 0.0.7-beta.9 → 0.2.0-beta.5
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.
|
@@ -5,7 +5,7 @@ import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
|
|
|
5
5
|
import { CommonProperties, LocaleProperties, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
|
|
6
6
|
|
|
7
7
|
//#region src/anatomy.d.ts
|
|
8
|
-
declare const anatomy: _destyler_anatomy0.AnatomyInstance<"root" | "dropzone" | "
|
|
8
|
+
declare const anatomy: _destyler_anatomy0.AnatomyInstance<"root" | "dropzone" | "trigger" | "label" | "item" | "itemName" | "itemSizeText" | "itemPreview" | "itemDeleteTrigger" | "itemGroup" | "itemPreviewImage" | "clearTrigger">;
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/types.d.ts
|
|
11
11
|
interface FileRejection {
|
|
@@ -85,10 +85,9 @@ function connect(state, send, normalize) {
|
|
|
85
85
|
const allowDrop = state.context.allowDrop;
|
|
86
86
|
const translations = state.context.translations;
|
|
87
87
|
const dragging = state.matches("dragging");
|
|
88
|
-
const focused = state.matches("focused") && !disabled;
|
|
89
88
|
return {
|
|
90
89
|
dragging,
|
|
91
|
-
focused,
|
|
90
|
+
focused: state.matches("focused") && !disabled,
|
|
92
91
|
disabled: !!disabled,
|
|
93
92
|
openFilePicker() {
|
|
94
93
|
if (disabled) return;
|
|
@@ -127,8 +126,7 @@ function connect(state, send, normalize) {
|
|
|
127
126
|
},
|
|
128
127
|
setClipboardFiles(dt) {
|
|
129
128
|
if (disabled) return false;
|
|
130
|
-
const
|
|
131
|
-
const files = items.reduce((acc, item) => {
|
|
129
|
+
const files = Array.from(dt?.items ?? []).reduce((acc, item) => {
|
|
132
130
|
if (item.kind !== "file") return acc;
|
|
133
131
|
const file = item.getAsFile();
|
|
134
132
|
if (!file) return acc;
|
|
@@ -189,8 +187,7 @@ function connect(state, send, normalize) {
|
|
|
189
187
|
try {
|
|
190
188
|
event.dataTransfer.dropEffect = "copy";
|
|
191
189
|
} catch {}
|
|
192
|
-
|
|
193
|
-
if (!hasFiles) return;
|
|
190
|
+
if (!isEventWithFiles(event)) return;
|
|
194
191
|
const count = event.dataTransfer.items.length;
|
|
195
192
|
send({
|
|
196
193
|
type: "DROPZONE.DRAG_OVER",
|
|
@@ -314,8 +311,7 @@ function connect(state, send, normalize) {
|
|
|
314
311
|
},
|
|
315
312
|
getItemPreviewImageProps(props$1) {
|
|
316
313
|
const { file, url } = props$1;
|
|
317
|
-
|
|
318
|
-
if (!isImage) throw new Error("Preview Image is only supported for image files");
|
|
314
|
+
if (!file.type.startsWith("image/")) throw new Error("Preview Image is only supported for image files");
|
|
319
315
|
return normalize.img({
|
|
320
316
|
...parts.itemPreviewImage.attrs,
|
|
321
317
|
"alt": translations.itemPreview?.(file),
|
|
@@ -483,8 +479,7 @@ function machine(userContext) {
|
|
|
483
479
|
});
|
|
484
480
|
},
|
|
485
481
|
setFilesFromEvent(ctx$1, evt) {
|
|
486
|
-
const
|
|
487
|
-
const { acceptedFiles, rejectedFiles } = result;
|
|
482
|
+
const { acceptedFiles, rejectedFiles } = getFilesFromEvent(ctx$1, evt.files);
|
|
488
483
|
if (ctx$1.multiple) {
|
|
489
484
|
const files = ref([...ctx$1.acceptedFiles, ...acceptedFiles]);
|
|
490
485
|
set.files(ctx$1, files, rejectedFiles);
|
package/package.json
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/file-upload",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.2.0-beta.5",
|
|
5
5
|
"description": "a component that is used to upload multiple files.",
|
|
6
6
|
"author": "Elone Hoo <elonehoo@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/destyler/destyler",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/destyler/destyler.git",
|
|
12
|
+
"directory": "packages/components/file-upload"
|
|
13
|
+
},
|
|
8
14
|
"exports": {
|
|
9
|
-
".": "./dist/index.
|
|
15
|
+
".": "./dist/index.mjs"
|
|
10
16
|
},
|
|
11
|
-
"main": "dist/index.
|
|
12
|
-
"module": "dist/index.
|
|
13
|
-
"types": "dist/index.d.
|
|
17
|
+
"main": "dist/index.mjs",
|
|
18
|
+
"module": "dist/index.mjs",
|
|
19
|
+
"types": "dist/index.d.mts",
|
|
14
20
|
"files": [
|
|
15
21
|
"*.d.ts",
|
|
16
22
|
"dist"
|
|
17
23
|
],
|
|
18
24
|
"dependencies": {
|
|
19
|
-
"@destyler/anatomy": "0.0
|
|
20
|
-
"@destyler/dom": "0.0
|
|
21
|
-
"@destyler/
|
|
22
|
-
"@destyler/
|
|
23
|
-
"@destyler/
|
|
24
|
-
"@destyler/
|
|
25
|
-
"@destyler/
|
|
25
|
+
"@destyler/anatomy": "0.2.0-beta.5",
|
|
26
|
+
"@destyler/dom": "0.2.0-beta.5",
|
|
27
|
+
"@destyler/types": "0.2.0-beta.5",
|
|
28
|
+
"@destyler/utils": "0.2.0-beta.5",
|
|
29
|
+
"@destyler/xstate": "0.2.0-beta.5",
|
|
30
|
+
"@destyler/file": "0.2.0-beta.5",
|
|
31
|
+
"@destyler/i18n": "0.2.0-beta.5"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
26
35
|
},
|
|
27
36
|
"scripts": {
|
|
28
37
|
"clear": "rimraf ./dist",
|