ablok-components 0.3.78 → 0.3.80
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/dist/ablok-components.umd.js +2 -2
- package/dist/components/molecules/file-upload/file-upload.vue.d.ts +24 -2
- package/dist/components/molecules/file-upload/file-upload.vue.js +98 -65
- package/dist/components/molecules/image-upload/image-upload.vue.d.ts +17 -2
- package/dist/components/molecules/image-upload/image-upload.vue.js +121 -106
- package/dist/components/molecules/upload-group/upload-group.vue.d.ts +14 -33
- package/dist/components/molecules/upload-group/upload-group.vue.js +58 -49
- package/dist/composables/useDragAndDrop.d.ts +10 -0
- package/dist/composables/useDragAndDrop.js +29 -0
- package/dist/composables/useLocalFileUrl.d.ts +17 -0
- package/dist/composables/useLocalFileUrl.js +14 -0
- package/dist/composables/useUploadTransport.d.ts +10 -0
- package/dist/composables/useUploadTransport.js +28 -0
- package/package.json +19 -19
- package/dist/composables/useFileUpload.d.ts +0 -46
- package/dist/composables/useFileUpload.js +0 -79
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PropType } from '../../../../vue/dist/vue.esm-bundler.js';
|
|
2
|
+
import { LocalUrlFormat } from '../../../composables/useLocalFileUrl';
|
|
1
3
|
declare function __VLS_template(): {
|
|
2
4
|
attrs: Partial<{}>;
|
|
3
5
|
slots: {
|
|
@@ -12,22 +14,7 @@ declare function __VLS_template(): {
|
|
|
12
14
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
13
15
|
declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js').DefineComponent<import('../../../../vue/dist/vue.esm-bundler.js').ExtractPropTypes<{
|
|
14
16
|
modelValue: {
|
|
15
|
-
type:
|
|
16
|
-
(arrayLength: number): String[];
|
|
17
|
-
(...items: String[]): String[];
|
|
18
|
-
new (arrayLength: number): String[];
|
|
19
|
-
new (...items: String[]): String[];
|
|
20
|
-
isArray(arg: any): arg is any[];
|
|
21
|
-
readonly prototype: any[];
|
|
22
|
-
from<T>(arrayLike: ArrayLike<T>): T[];
|
|
23
|
-
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
24
|
-
from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
25
|
-
from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
26
|
-
of<T>(...items: T[]): T[];
|
|
27
|
-
fromAsync<T>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T | PromiseLike<T>> | ArrayLike<T | PromiseLike<T>>): Promise<T[]>;
|
|
28
|
-
fromAsync<T, U>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T> | ArrayLike<T>, mapFn: (value: Awaited<T>, index: number) => U, thisArg?: any): Promise<Awaited<U>[]>;
|
|
29
|
-
readonly [Symbol.species]: ArrayConstructor;
|
|
30
|
-
};
|
|
17
|
+
type: PropType<string[]>;
|
|
31
18
|
default: () => never[];
|
|
32
19
|
};
|
|
33
20
|
name: {
|
|
@@ -87,26 +74,15 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
87
74
|
default: number;
|
|
88
75
|
};
|
|
89
76
|
aspectRatio: NumberConstructor;
|
|
77
|
+
localUrlFormat: {
|
|
78
|
+
type: PropType<LocalUrlFormat>;
|
|
79
|
+
default: string;
|
|
80
|
+
};
|
|
90
81
|
}>, {}, {}, {}, {}, import('../../../../vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, import('../../../../vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, {
|
|
91
82
|
"update:modelValue": (...args: any[]) => void;
|
|
92
83
|
}, string, import('../../../../vue/dist/vue.esm-bundler.js').PublicProps, Readonly<import('../../../../vue/dist/vue.esm-bundler.js').ExtractPropTypes<{
|
|
93
84
|
modelValue: {
|
|
94
|
-
type:
|
|
95
|
-
(arrayLength: number): String[];
|
|
96
|
-
(...items: String[]): String[];
|
|
97
|
-
new (arrayLength: number): String[];
|
|
98
|
-
new (...items: String[]): String[];
|
|
99
|
-
isArray(arg: any): arg is any[];
|
|
100
|
-
readonly prototype: any[];
|
|
101
|
-
from<T>(arrayLike: ArrayLike<T>): T[];
|
|
102
|
-
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
103
|
-
from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
104
|
-
from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
105
|
-
of<T>(...items: T[]): T[];
|
|
106
|
-
fromAsync<T>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T | PromiseLike<T>> | ArrayLike<T | PromiseLike<T>>): Promise<T[]>;
|
|
107
|
-
fromAsync<T, U>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T> | ArrayLike<T>, mapFn: (value: Awaited<T>, index: number) => U, thisArg?: any): Promise<Awaited<U>[]>;
|
|
108
|
-
readonly [Symbol.species]: ArrayConstructor;
|
|
109
|
-
};
|
|
85
|
+
type: PropType<string[]>;
|
|
110
86
|
default: () => never[];
|
|
111
87
|
};
|
|
112
88
|
name: {
|
|
@@ -166,6 +142,10 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
166
142
|
default: number;
|
|
167
143
|
};
|
|
168
144
|
aspectRatio: NumberConstructor;
|
|
145
|
+
localUrlFormat: {
|
|
146
|
+
type: PropType<LocalUrlFormat>;
|
|
147
|
+
default: string;
|
|
148
|
+
};
|
|
169
149
|
}>> & Readonly<{
|
|
170
150
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
171
151
|
}>, {
|
|
@@ -173,7 +153,7 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
173
153
|
required: boolean;
|
|
174
154
|
variant: string;
|
|
175
155
|
id: string;
|
|
176
|
-
modelValue:
|
|
156
|
+
modelValue: string[];
|
|
177
157
|
name: string;
|
|
178
158
|
disabled: boolean;
|
|
179
159
|
maxFileSize: number;
|
|
@@ -181,6 +161,7 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
181
161
|
authToken: string;
|
|
182
162
|
baseResponsePath: string;
|
|
183
163
|
previewWidth: number;
|
|
164
|
+
localUrlFormat: LocalUrlFormat;
|
|
184
165
|
maxImageWidth: number;
|
|
185
166
|
useImageUpload: boolean;
|
|
186
167
|
}, {}, {}, {}, string, import('../../../../vue/dist/vue.esm-bundler.js').ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineComponent as v, ref as
|
|
2
|
-
import { uniqueId as
|
|
3
|
-
import { sanitizeHtml as
|
|
4
|
-
import
|
|
1
|
+
import { defineComponent as v, ref as k, computed as x, watch as V, nextTick as w, openBlock as n, createElementBlock as p, unref as S, createCommentVNode as F, createElementVNode as i, createVNode as s, withCtx as m, createBlock as h, withModifiers as U, renderSlot as $ } from "vue";
|
|
2
|
+
import { uniqueId as b } from "../../../utilities/helpers.js";
|
|
3
|
+
import { sanitizeHtml as z } from "../../../composables/useSanitize.js";
|
|
4
|
+
import N from "../../templates/sortable-list/sortable-list.vue.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import
|
|
6
|
+
import B from "../image-upload/image-upload.vue.js";
|
|
7
7
|
/* empty css */
|
|
8
|
-
import
|
|
8
|
+
import I from "../file-upload/file-upload.vue.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import
|
|
10
|
+
import r from "../../atoms/svg-icon/svg-icon.vue.js";
|
|
11
11
|
/* empty css */
|
|
12
|
-
const
|
|
12
|
+
const T = { class: "upload-group" }, W = ["innerHTML"], C = { class: "upload-group__list" }, R = { class: "img-container" }, H = ["src"], M = { class: "item-overlay" }, P = ["onClick"], j = {
|
|
13
13
|
role: "button",
|
|
14
14
|
class: "img-thumbnail d-flex justify-content-center align-items-center"
|
|
15
15
|
}, q = {
|
|
@@ -24,11 +24,11 @@ const W = { class: "upload-group" }, C = ["innerHTML"], R = { class: "upload-gro
|
|
|
24
24
|
},
|
|
25
25
|
name: {
|
|
26
26
|
type: String,
|
|
27
|
-
default: () =>
|
|
27
|
+
default: () => b()
|
|
28
28
|
},
|
|
29
29
|
id: {
|
|
30
30
|
type: String,
|
|
31
|
-
default: () =>
|
|
31
|
+
default: () => b()
|
|
32
32
|
},
|
|
33
33
|
label: {
|
|
34
34
|
type: String,
|
|
@@ -78,60 +78,67 @@ const W = { class: "upload-group" }, C = ["innerHTML"], R = { class: "upload-gro
|
|
|
78
78
|
type: Number,
|
|
79
79
|
default: 0
|
|
80
80
|
},
|
|
81
|
-
aspectRatio: Number
|
|
81
|
+
aspectRatio: Number,
|
|
82
|
+
localUrlFormat: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: "dataUrl"
|
|
85
|
+
}
|
|
82
86
|
},
|
|
83
87
|
emits: ["update:modelValue"],
|
|
84
|
-
setup(e, { emit:
|
|
85
|
-
const
|
|
88
|
+
setup(e, { emit: g }) {
|
|
89
|
+
const d = e, u = g, o = k(""), c = x({
|
|
86
90
|
get() {
|
|
87
|
-
return
|
|
91
|
+
return d.modelValue;
|
|
88
92
|
},
|
|
89
93
|
set(t) {
|
|
90
94
|
u("update:modelValue", t);
|
|
91
95
|
}
|
|
92
96
|
});
|
|
93
97
|
function y(t) {
|
|
94
|
-
|
|
98
|
+
u("update:modelValue", [
|
|
99
|
+
...d.modelValue.slice(0, t),
|
|
100
|
+
...d.modelValue.slice(t + 1)
|
|
101
|
+
]);
|
|
95
102
|
}
|
|
96
|
-
return
|
|
97
|
-
t && a !== t && (u("update:modelValue", [...
|
|
98
|
-
}), (t, a) => (
|
|
99
|
-
e.label ? (
|
|
103
|
+
return V(o, async (t, a) => {
|
|
104
|
+
t && a !== t && (u("update:modelValue", [...c.value, t]), await w(), o.value = "");
|
|
105
|
+
}), (t, a) => (n(), p("div", T, [
|
|
106
|
+
e.label ? (n(), p("label", {
|
|
100
107
|
key: 0,
|
|
101
|
-
innerHTML:
|
|
102
|
-
}, null, 8,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
modelValue:
|
|
106
|
-
"onUpdate:modelValue": a[2] || (a[2] = (
|
|
108
|
+
innerHTML: S(z)(e.label)
|
|
109
|
+
}, null, 8, W)) : F("", !0),
|
|
110
|
+
i("div", C, [
|
|
111
|
+
s(N, {
|
|
112
|
+
modelValue: c.value,
|
|
113
|
+
"onUpdate:modelValue": a[2] || (a[2] = (l) => c.value = l),
|
|
107
114
|
vertical: !1,
|
|
108
115
|
class: "mb-3"
|
|
109
116
|
}, {
|
|
110
|
-
"list-item": m(({ item:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
src: `${
|
|
117
|
+
"list-item": m(({ item: l, index: f }) => [
|
|
118
|
+
i("div", R, [
|
|
119
|
+
i("img", {
|
|
120
|
+
src: `${l}${e.previewWidth ? `?width=${e.previewWidth}` : ""}`,
|
|
114
121
|
class: "img-thumbnail"
|
|
115
122
|
}, null, 8, H),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
onClick:
|
|
123
|
+
i("div", M, [
|
|
124
|
+
i("button", {
|
|
125
|
+
onClick: U((E) => y(f), ["prevent"]),
|
|
119
126
|
class: "btn btn--close"
|
|
120
127
|
}, [
|
|
121
|
-
|
|
128
|
+
s(r, { symbol: "x" })
|
|
122
129
|
], 8, P),
|
|
123
|
-
|
|
124
|
-
item:
|
|
125
|
-
index:
|
|
130
|
+
$(t.$slots, "item-overlay", {
|
|
131
|
+
item: l,
|
|
132
|
+
index: f
|
|
126
133
|
})
|
|
127
134
|
])
|
|
128
135
|
])
|
|
129
136
|
]),
|
|
130
137
|
"list-append": m(() => [
|
|
131
|
-
e.useImageUpload ? (
|
|
138
|
+
e.useImageUpload ? (n(), h(B, {
|
|
132
139
|
key: 0,
|
|
133
|
-
src:
|
|
134
|
-
"onUpdate:src": a[0] || (a[0] = (
|
|
140
|
+
src: o.value,
|
|
141
|
+
"onUpdate:src": a[0] || (a[0] = (l) => o.value = l),
|
|
135
142
|
endpoint: e.endpoint,
|
|
136
143
|
"custom-fetch": e.customFetch,
|
|
137
144
|
"to-data-url": !e.endpoint,
|
|
@@ -142,18 +149,19 @@ const W = { class: "upload-group" }, C = ["innerHTML"], R = { class: "upload-gro
|
|
|
142
149
|
"max-file-size": e.maxFileSize,
|
|
143
150
|
"max-image-width": e.maxImageWidth,
|
|
144
151
|
"enable-preview": !1,
|
|
145
|
-
"aspect-ratio": e.aspectRatio
|
|
152
|
+
"aspect-ratio": e.aspectRatio,
|
|
153
|
+
"local-url-format": e.localUrlFormat
|
|
146
154
|
}, {
|
|
147
155
|
button: m(() => [
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
i("span", j, [
|
|
157
|
+
s(r, { symbol: "plus" })
|
|
150
158
|
])
|
|
151
159
|
]),
|
|
152
160
|
_: 1
|
|
153
|
-
}, 8, ["src", "endpoint", "custom-fetch", "to-data-url", "auth-token", "disabled", "base-response-path", "accept", "max-file-size", "max-image-width", "aspect-ratio"])) : (
|
|
161
|
+
}, 8, ["src", "endpoint", "custom-fetch", "to-data-url", "auth-token", "disabled", "base-response-path", "accept", "max-file-size", "max-image-width", "aspect-ratio", "local-url-format"])) : (n(), h(I, {
|
|
154
162
|
key: 1,
|
|
155
|
-
src:
|
|
156
|
-
"onUpdate:src": a[1] || (a[1] = (
|
|
163
|
+
src: o.value,
|
|
164
|
+
"onUpdate:src": a[1] || (a[1] = (l) => o.value = l),
|
|
157
165
|
multiple: !1,
|
|
158
166
|
endpoint: e.endpoint,
|
|
159
167
|
"custom-fetch": e.customFetch,
|
|
@@ -163,15 +171,16 @@ const W = { class: "upload-group" }, C = ["innerHTML"], R = { class: "upload-gro
|
|
|
163
171
|
"base-response-path": e.baseResponsePath,
|
|
164
172
|
accept: e.accept,
|
|
165
173
|
"max-file-size": e.maxFileSize,
|
|
166
|
-
"max-image-width": e.maxImageWidth
|
|
174
|
+
"max-image-width": e.maxImageWidth,
|
|
175
|
+
"local-url-format": e.localUrlFormat
|
|
167
176
|
}, {
|
|
168
177
|
button: m(() => [
|
|
169
|
-
|
|
170
|
-
|
|
178
|
+
i("span", q, [
|
|
179
|
+
s(r, { symbol: "plus" })
|
|
171
180
|
])
|
|
172
181
|
]),
|
|
173
182
|
_: 1
|
|
174
|
-
}, 8, ["src", "endpoint", "custom-fetch", "to-data-url", "auth-token", "disabled", "base-response-path", "accept", "max-file-size", "max-image-width"]))
|
|
183
|
+
}, 8, ["src", "endpoint", "custom-fetch", "to-data-url", "auth-token", "disabled", "base-response-path", "accept", "max-file-size", "max-image-width", "local-url-format"]))
|
|
175
184
|
]),
|
|
176
185
|
_: 3
|
|
177
186
|
}, 8, ["modelValue"])
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Ref } from '../../vue/dist/vue.esm-bundler.js';
|
|
2
|
+
export interface UseDragAndDropOptions {
|
|
3
|
+
/** Whether drag-and-drop handling is active. */
|
|
4
|
+
enabled: () => boolean;
|
|
5
|
+
/** Called with the dropped files when a drop occurs while enabled. */
|
|
6
|
+
onDrop: (files: File[]) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function useDragAndDrop(target: Ref<HTMLElement | null | undefined>, options: UseDragAndDropOptions): {
|
|
9
|
+
isDragging: Ref<boolean, boolean>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ref as d, onMounted as D, onBeforeUnmount as c } from "vue";
|
|
2
|
+
function E(n, r) {
|
|
3
|
+
const u = d(!1), a = d(0);
|
|
4
|
+
function v(e) {
|
|
5
|
+
r.enabled() && (e.preventDefault(), a.value++, u.value = !0);
|
|
6
|
+
}
|
|
7
|
+
function l(e) {
|
|
8
|
+
r.enabled() && e.preventDefault();
|
|
9
|
+
}
|
|
10
|
+
function t(e) {
|
|
11
|
+
r.enabled() && (e.preventDefault(), a.value = Math.max(0, a.value - 1), a.value === 0 && (u.value = !1));
|
|
12
|
+
}
|
|
13
|
+
function o(e) {
|
|
14
|
+
if (!r.enabled()) return;
|
|
15
|
+
e.preventDefault(), a.value = 0, u.value = !1;
|
|
16
|
+
const s = e.dataTransfer ? Array.from(e.dataTransfer.files || []) : [];
|
|
17
|
+
r.onDrop(s);
|
|
18
|
+
}
|
|
19
|
+
function f() {
|
|
20
|
+
n.value?.addEventListener("dragenter", v), n.value?.addEventListener("dragover", l), n.value?.addEventListener("dragleave", t), n.value?.addEventListener("drop", o);
|
|
21
|
+
}
|
|
22
|
+
function i() {
|
|
23
|
+
n.value?.removeEventListener("dragenter", v), n.value?.removeEventListener("dragover", l), n.value?.removeEventListener("dragleave", t), n.value?.removeEventListener("drop", o);
|
|
24
|
+
}
|
|
25
|
+
return D(f), c(i), { isDragging: u };
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
E as useDragAndDrop
|
|
29
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Ref } from '../../vue/dist/vue.esm-bundler.js';
|
|
2
|
+
export type LocalUrlFormat = 'dataUrl' | 'objectUrl';
|
|
3
|
+
/**
|
|
4
|
+
* Produces a local, non-uploaded URL for a File, in either of two formats:
|
|
5
|
+
* - 'dataUrl' (default): base64 data URL via FileReader. Persistable as a
|
|
6
|
+
* plain string (e.g. stored as the final value when no upload endpoint
|
|
7
|
+
* is configured), at the cost of a ~33% size increase and a synchronous
|
|
8
|
+
* FileReader round-trip.
|
|
9
|
+
* - 'objectUrl': `URL.createObjectURL`. Cheap and synchronous, but only
|
|
10
|
+
* valid for the lifetime of the current document — must be revoked with
|
|
11
|
+
* `revoke()` when no longer displayed (on removal, replacement, or
|
|
12
|
+
* unmount) to avoid leaking memory, and isn't safe to persist/serialize.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useLocalFileUrl(format: Ref<LocalUrlFormat> | LocalUrlFormat): {
|
|
15
|
+
toLocalUrl: (file: File) => Promise<string>;
|
|
16
|
+
revoke: (url: string | undefined | null) => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { unref as c } from "vue";
|
|
2
|
+
import { fileToDataUrl as n } from "../utilities/helpers.js";
|
|
3
|
+
function U(o) {
|
|
4
|
+
async function r(t) {
|
|
5
|
+
return c(o) === "objectUrl" ? URL.createObjectURL(t) : await n(t);
|
|
6
|
+
}
|
|
7
|
+
function e(t) {
|
|
8
|
+
t && t.startsWith("blob:") && URL.revokeObjectURL(t);
|
|
9
|
+
}
|
|
10
|
+
return { toLocalUrl: r, revoke: e };
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
U as useLocalFileUrl
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface UploadTransportProps {
|
|
2
|
+
endpoint?: string;
|
|
3
|
+
customFetch?: ((...args: any[]) => any) | null;
|
|
4
|
+
authToken?: string;
|
|
5
|
+
baseResponsePath?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useUploadTransport(props: UploadTransportProps): {
|
|
8
|
+
pending: import('../../vue/dist/vue.esm-bundler.js').Ref<boolean, boolean>;
|
|
9
|
+
uploadFile: (file: File) => Promise<string>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ref as c } from "vue";
|
|
2
|
+
import { ofetch as r } from "ofetch";
|
|
3
|
+
function l(e) {
|
|
4
|
+
const t = c(!1);
|
|
5
|
+
async function n(o) {
|
|
6
|
+
const a = new FormData();
|
|
7
|
+
a.append("file", o), t.value = !0;
|
|
8
|
+
try {
|
|
9
|
+
const s = await (e.customFetch || r)(e.endpoint, {
|
|
10
|
+
method: "POST",
|
|
11
|
+
...e.customFetch ? {} : {
|
|
12
|
+
headers: {
|
|
13
|
+
Accept: "application/json",
|
|
14
|
+
...e.authToken ? { Authorization: `Bearer ${e.authToken}` } : {}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
body: a
|
|
18
|
+
});
|
|
19
|
+
return `${e.baseResponsePath || "/api/v1/assets"}/${s.path}`;
|
|
20
|
+
} finally {
|
|
21
|
+
t.value = !1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { pending: t, uploadFile: n };
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
l as useUploadTransport
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ablok-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.80",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite --host",
|
|
7
|
+
"story:dev": "histoire dev",
|
|
8
|
+
"story:build": "histoire build",
|
|
9
|
+
"story:preview": "histoire preview",
|
|
10
|
+
"build": "vue-tsc --noEmit --project tsconfig.build.json && vite build",
|
|
11
|
+
"build:watch": "vue-tsc --noEmit --watch --project tsconfig.build.json & vite build --watch",
|
|
12
|
+
"preview": "vite preview",
|
|
13
|
+
"build-lib-bak": "vite build && vue-tsc --emitDeclarationOnly && mv dist/src dist/types",
|
|
14
|
+
"build-lib": "vite build && vue-tsc --emitDeclarationOnly",
|
|
15
|
+
"release": "bash ./scripts/release.sh",
|
|
16
|
+
"postrelease": "bash ./scripts/publish.sh",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest",
|
|
19
|
+
"test:ui": "vitest --ui"
|
|
20
|
+
},
|
|
5
21
|
"dependencies": {
|
|
6
22
|
"date-fns": "^3.0.0",
|
|
7
23
|
"dompurify": "^3.3.1",
|
|
@@ -120,21 +136,5 @@
|
|
|
120
136
|
"./package.json": "./package.json"
|
|
121
137
|
},
|
|
122
138
|
"types": "./dist/index.d.ts",
|
|
123
|
-
"sideEffects": false
|
|
124
|
-
|
|
125
|
-
"dev": "vite --host",
|
|
126
|
-
"story:dev": "histoire dev",
|
|
127
|
-
"story:build": "histoire build",
|
|
128
|
-
"story:preview": "histoire preview",
|
|
129
|
-
"build": "vue-tsc --noEmit --project tsconfig.build.json && vite build",
|
|
130
|
-
"build:watch": "vue-tsc --noEmit --watch --project tsconfig.build.json & vite build --watch",
|
|
131
|
-
"preview": "vite preview",
|
|
132
|
-
"build-lib-bak": "vite build && vue-tsc --emitDeclarationOnly && mv dist/src dist/types",
|
|
133
|
-
"build-lib": "vite build && vue-tsc --emitDeclarationOnly",
|
|
134
|
-
"release": "bash ./scripts/release.sh",
|
|
135
|
-
"postrelease": "bash ./scripts/publish.sh",
|
|
136
|
-
"test": "vitest run",
|
|
137
|
-
"test:watch": "vitest",
|
|
138
|
-
"test:ui": "vitest --ui"
|
|
139
|
-
}
|
|
140
|
-
}
|
|
139
|
+
"sideEffects": false
|
|
140
|
+
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export declare function useFileUpload(props?: any, emit?: any): {
|
|
2
|
-
pending: import('../../vue/dist/vue.esm-bundler.js').Ref<boolean, boolean>;
|
|
3
|
-
files: import('../../vue/dist/vue.esm-bundler.js').Ref<{
|
|
4
|
-
readonly lastModified: number;
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly webkitRelativePath: string;
|
|
7
|
-
readonly size: number;
|
|
8
|
-
readonly type: string;
|
|
9
|
-
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
10
|
-
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
11
|
-
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
12
|
-
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
13
|
-
text: () => Promise<string>;
|
|
14
|
-
}[], File[] | {
|
|
15
|
-
readonly lastModified: number;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly webkitRelativePath: string;
|
|
18
|
-
readonly size: number;
|
|
19
|
-
readonly type: string;
|
|
20
|
-
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
21
|
-
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
22
|
-
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
23
|
-
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
24
|
-
text: () => Promise<string>;
|
|
25
|
-
}[]>;
|
|
26
|
-
dataUrls: import('../../vue/dist/vue.esm-bundler.js').Ref<{
|
|
27
|
-
type: string;
|
|
28
|
-
src: string;
|
|
29
|
-
}[], {
|
|
30
|
-
type: string;
|
|
31
|
-
src: string;
|
|
32
|
-
}[] | {
|
|
33
|
-
type: string;
|
|
34
|
-
src: string;
|
|
35
|
-
}[]>;
|
|
36
|
-
imgLoaded: import('../../vue/dist/vue.esm-bundler.js').Ref<boolean, boolean>;
|
|
37
|
-
isDragging: import('../../vue/dist/vue.esm-bundler.js').Ref<boolean, boolean>;
|
|
38
|
-
thumbnails: import('../../vue/dist/vue.esm-bundler.js').ComputedRef<any>;
|
|
39
|
-
uploadFile: (file: File) => Promise<string>;
|
|
40
|
-
removeFile: (index: number | string) => void;
|
|
41
|
-
dragStart: (event: DragEvent) => void;
|
|
42
|
-
dragStop: (event: DragEvent) => void;
|
|
43
|
-
dragDrop: (event: DragEvent) => void;
|
|
44
|
-
setupDragAndDrop: () => void;
|
|
45
|
-
cleanupDragAndDrop: () => void;
|
|
46
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { ref as r, computed as A, onMounted as V, onBeforeUnmount as F } from "vue";
|
|
2
|
-
import { ofetch as L } from "ofetch";
|
|
3
|
-
function U(a = null, o) {
|
|
4
|
-
const c = r(!1), f = r([]), n = r([]), h = r(!1), u = r(!1), y = A(() => a.modelValue?.length ? a.modelValue : a.src ? [{ type: "", src: a.src }] : n.value);
|
|
5
|
-
async function D(e) {
|
|
6
|
-
const t = new FormData();
|
|
7
|
-
t.append("file", e), c.value = !0;
|
|
8
|
-
const d = await (a.customFetch || L)(a.endpoint, {
|
|
9
|
-
method: "POST",
|
|
10
|
-
...a.customFetch ? {} : { headers: {
|
|
11
|
-
Accept: "application/json",
|
|
12
|
-
...a.authToken ? { Authorization: `Bearer ${a.authToken}` } : {}
|
|
13
|
-
} },
|
|
14
|
-
body: t
|
|
15
|
-
}).catch((E) => {
|
|
16
|
-
console.error("Error", E);
|
|
17
|
-
});
|
|
18
|
-
return c.value = !1, `${a.baseResponsePath || "/api/v1/assets"}/${d.path}`;
|
|
19
|
-
}
|
|
20
|
-
function b(e) {
|
|
21
|
-
const t = typeof e == "string" ? parseInt(e, 10) : e, s = Array.isArray(a.modelValue) && a.modelValue.length > 0, d = Array.isArray(n.value) && n.value.length > 0;
|
|
22
|
-
if (d && t < n.value.length && n.value.splice(t, 1), s) {
|
|
23
|
-
const l = [...a.modelValue];
|
|
24
|
-
t < l.length && l.splice(t, 1), o?.("update:modelValue", l), a.multiple || o?.("update:src", l[0]?.src || "");
|
|
25
|
-
} else if (d) {
|
|
26
|
-
const l = a.multiple ? n.value : n.value[0];
|
|
27
|
-
o?.("update:modelValue", l), a.multiple || o?.("update:src", n.value[0]?.src || "");
|
|
28
|
-
} else
|
|
29
|
-
o?.("update:modelValue", a.multiple ? [] : void 0), o?.("update:src", "");
|
|
30
|
-
f.value.splice(t, 1), h.value = !1;
|
|
31
|
-
}
|
|
32
|
-
function i(e) {
|
|
33
|
-
e.preventDefault(), u.value = !0;
|
|
34
|
-
}
|
|
35
|
-
function v(e) {
|
|
36
|
-
e.preventDefault(), u.value = !1;
|
|
37
|
-
}
|
|
38
|
-
function m(e) {
|
|
39
|
-
e.preventDefault(), u.value = !1;
|
|
40
|
-
const t = e.dataTransfer, s = t && Array.from(t.files || []);
|
|
41
|
-
f.value = s || [];
|
|
42
|
-
}
|
|
43
|
-
function g() {
|
|
44
|
-
a.dropFiles && (["dragenter", "dragover"].forEach((e) => {
|
|
45
|
-
document.body.addEventListener(e, i, !1);
|
|
46
|
-
}), ["dragleave", "drop"].forEach((e) => {
|
|
47
|
-
document.body.addEventListener(e, v, !1);
|
|
48
|
-
}), document.body.addEventListener("drop", m, !1));
|
|
49
|
-
}
|
|
50
|
-
function p() {
|
|
51
|
-
a.dropFiles && (["dragenter", "dragover"].forEach((e) => {
|
|
52
|
-
document.body.removeEventListener(e, i, !1);
|
|
53
|
-
}), ["dragleave", "drop"].forEach((e) => {
|
|
54
|
-
document.body.removeEventListener(e, v, !1);
|
|
55
|
-
}), document.body.removeEventListener("drop", m, !1));
|
|
56
|
-
}
|
|
57
|
-
return V(() => {
|
|
58
|
-
g();
|
|
59
|
-
}), F(() => {
|
|
60
|
-
p();
|
|
61
|
-
}), {
|
|
62
|
-
pending: c,
|
|
63
|
-
files: f,
|
|
64
|
-
dataUrls: n,
|
|
65
|
-
imgLoaded: h,
|
|
66
|
-
isDragging: u,
|
|
67
|
-
thumbnails: y,
|
|
68
|
-
uploadFile: D,
|
|
69
|
-
removeFile: b,
|
|
70
|
-
dragStart: i,
|
|
71
|
-
dragStop: v,
|
|
72
|
-
dragDrop: m,
|
|
73
|
-
setupDragAndDrop: g,
|
|
74
|
-
cleanupDragAndDrop: p
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
export {
|
|
78
|
-
U as useFileUpload
|
|
79
|
-
};
|