ablok-components 0.3.78 → 0.3.79
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 +17 -2
- package/dist/components/molecules/file-upload/file-upload.vue.js +86 -59
- 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,9 +1,13 @@
|
|
|
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: {
|
|
4
6
|
button?(_: {}): any;
|
|
5
7
|
};
|
|
6
|
-
refs: {
|
|
8
|
+
refs: {
|
|
9
|
+
root: HTMLDivElement;
|
|
10
|
+
};
|
|
7
11
|
rootEl: HTMLDivElement;
|
|
8
12
|
};
|
|
9
13
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
@@ -124,6 +128,10 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
124
128
|
type: BooleanConstructor;
|
|
125
129
|
default: boolean;
|
|
126
130
|
};
|
|
131
|
+
localUrlFormat: {
|
|
132
|
+
type: PropType<LocalUrlFormat>;
|
|
133
|
+
default: string;
|
|
134
|
+
};
|
|
127
135
|
}>, {}, {}, {}, {}, import('../../../../vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, import('../../../../vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, {
|
|
128
136
|
"update:modelValue": (...args: any[]) => void;
|
|
129
137
|
"update:src": (...args: any[]) => void;
|
|
@@ -244,6 +252,10 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
244
252
|
type: BooleanConstructor;
|
|
245
253
|
default: boolean;
|
|
246
254
|
};
|
|
255
|
+
localUrlFormat: {
|
|
256
|
+
type: PropType<LocalUrlFormat>;
|
|
257
|
+
default: string;
|
|
258
|
+
};
|
|
247
259
|
}>> & Readonly<{
|
|
248
260
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
249
261
|
"onUpdate:src"?: ((...args: any[]) => any) | undefined;
|
|
@@ -270,7 +282,10 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
270
282
|
enablePreview: boolean;
|
|
271
283
|
previewWidth: number;
|
|
272
284
|
dropFiles: boolean;
|
|
273
|
-
|
|
285
|
+
localUrlFormat: LocalUrlFormat;
|
|
286
|
+
}, {}, {}, {}, string, import('../../../../vue/dist/vue.esm-bundler.js').ComponentProvideOptions, true, {
|
|
287
|
+
root: HTMLDivElement;
|
|
288
|
+
}, HTMLDivElement>;
|
|
274
289
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
275
290
|
export default _default;
|
|
276
291
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
1
|
+
import { defineComponent as A, ref as f, toRef as L, computed as N, watch as b, openBlock as s, createElementBlock as u, normalizeClass as h, unref as y, Fragment as V, renderList as P, createElementVNode as d, withModifiers as S, createVNode as m, renderSlot as T, Transition as M, withCtx as _, createCommentVNode as H } from "vue";
|
|
2
|
+
import k from "../../atoms/svg-icon/svg-icon.vue.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
4
|
+
import W from "../../atoms/input-file/input-file.vue.js";
|
|
5
|
+
import { useDragAndDrop as q } from "../../../composables/useDragAndDrop.js";
|
|
6
|
+
import { useUploadTransport as x } from "../../../composables/useUploadTransport.js";
|
|
7
|
+
import { useLocalFileUrl as E } from "../../../composables/useLocalFileUrl.js";
|
|
8
|
+
import { sanitizeHtml as I } from "../../../composables/useSanitize.js";
|
|
9
|
+
import { uniqueId as w } from "../../../utilities/helpers.js";
|
|
10
|
+
const R = ["src"], O = ["onClick"], j = ["onClick"], G = ["for"], J = ["innerHTML"], K = {
|
|
8
11
|
key: 0,
|
|
9
12
|
class: "file-upload__loading-spinner"
|
|
10
|
-
},
|
|
13
|
+
}, oe = /* @__PURE__ */ A({
|
|
11
14
|
__name: "file-upload",
|
|
12
15
|
props: {
|
|
13
16
|
modelValue: {
|
|
@@ -19,11 +22,11 @@ const W = ["src"], _ = ["onClick"], q = ["onClick"], E = ["for"], H = ["innerHTM
|
|
|
19
22
|
},
|
|
20
23
|
name: {
|
|
21
24
|
type: String,
|
|
22
|
-
default: () =>
|
|
25
|
+
default: () => w()
|
|
23
26
|
},
|
|
24
27
|
id: {
|
|
25
28
|
type: String,
|
|
26
|
-
default: () =>
|
|
29
|
+
default: () => w()
|
|
27
30
|
},
|
|
28
31
|
label: {
|
|
29
32
|
type: String,
|
|
@@ -92,86 +95,110 @@ const W = ["src"], _ = ["onClick"], q = ["onClick"], E = ["for"], H = ["innerHTM
|
|
|
92
95
|
dropFiles: {
|
|
93
96
|
type: Boolean,
|
|
94
97
|
default: !1
|
|
98
|
+
},
|
|
99
|
+
localUrlFormat: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: "dataUrl"
|
|
95
102
|
}
|
|
96
103
|
},
|
|
97
104
|
emits: ["update:modelValue", "update:src"],
|
|
98
|
-
setup(
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
setup(a, { emit: F }) {
|
|
106
|
+
const e = a, i = F, v = f(), c = f([]), o = f([]), { pending: U, uploadFile: B } = x(e), { toLocalUrl: D, revoke: $ } = E(L(e, "localUrlFormat")), { isDragging: C } = q(v, {
|
|
107
|
+
enabled: () => e.dropFiles,
|
|
108
|
+
onDrop: (t) => {
|
|
109
|
+
c.value = t;
|
|
110
|
+
}
|
|
111
|
+
}), z = N(() => e.modelValue?.length ? e.modelValue : e.src ? [{ type: "", src: e.src }] : o.value);
|
|
112
|
+
function g(t) {
|
|
113
|
+
const l = typeof t == "string" ? parseInt(t, 10) : t, n = Array.isArray(e.modelValue) && e.modelValue.length > 0, p = Array.isArray(o.value) && o.value.length > 0;
|
|
114
|
+
if (p && l < o.value.length && ($(o.value[l]?.src), o.value.splice(l, 1)), n) {
|
|
115
|
+
const r = [...e.modelValue];
|
|
116
|
+
l < r.length && r.splice(l, 1), i("update:modelValue", r), e.multiple || i("update:src", r[0]?.src || "");
|
|
117
|
+
} else if (p) {
|
|
118
|
+
const r = e.multiple ? o.value : o.value[0];
|
|
119
|
+
i("update:modelValue", r), e.multiple || i("update:src", o.value[0]?.src || "");
|
|
120
|
+
} else
|
|
121
|
+
i("update:modelValue", e.multiple ? [] : void 0), i("update:src", "");
|
|
122
|
+
c.value.splice(l, 1);
|
|
123
|
+
}
|
|
124
|
+
return b(() => c.value, async (t) => {
|
|
125
|
+
const l = await Promise.all(
|
|
126
|
+
t.map(async (n) => ({
|
|
127
|
+
src: e.toDataUrl ? await D(n) : await B(n),
|
|
128
|
+
type: n.type
|
|
105
129
|
}))
|
|
106
130
|
);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
131
|
+
o.value = l.filter((n) => n !== null);
|
|
132
|
+
}, { deep: !0 }), b(() => o.value, async (t) => {
|
|
133
|
+
const l = e.multiple ? t : t[0];
|
|
134
|
+
i("update:modelValue", l), e.multiple || i("update:src", t[0] && t[0].src);
|
|
135
|
+
}, { deep: !0 }), (t, l) => (s(), u("div", {
|
|
136
|
+
ref_key: "root",
|
|
137
|
+
ref: v,
|
|
138
|
+
class: h(["file-upload", {
|
|
139
|
+
"has-dragging": a.dropFiles,
|
|
140
|
+
"is-dragging": y(C)
|
|
114
141
|
}])
|
|
115
142
|
}, [
|
|
116
|
-
(
|
|
117
|
-
key:
|
|
118
|
-
class:
|
|
143
|
+
(s(!0), u(V, null, P(z.value, (n, p) => (s(), u("div", {
|
|
144
|
+
key: n.src,
|
|
145
|
+
class: h(a.enablePreview ? "file-upload__thumbnail" : "file-upload__reset")
|
|
119
146
|
}, [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
src: `${
|
|
147
|
+
a.enablePreview ? (s(), u(V, { key: 0 }, [
|
|
148
|
+
d("img", {
|
|
149
|
+
src: `${n.src}${a.previewWidth ? `?width=${a.previewWidth}` : ""}`,
|
|
123
150
|
class: "img-thumbnail rounded"
|
|
124
|
-
}, null, 8,
|
|
125
|
-
|
|
126
|
-
onClick:
|
|
151
|
+
}, null, 8, R),
|
|
152
|
+
d("button", {
|
|
153
|
+
onClick: S((r) => g(p), ["prevent"]),
|
|
127
154
|
class: "btn btn--close"
|
|
128
155
|
}, [
|
|
129
|
-
|
|
130
|
-
], 8,
|
|
131
|
-
], 64)) : (
|
|
156
|
+
m(k, { symbol: "x" })
|
|
157
|
+
], 8, O)
|
|
158
|
+
], 64)) : (s(), u("button", {
|
|
132
159
|
key: 1,
|
|
133
|
-
onClick:
|
|
160
|
+
onClick: S((r) => g(p), ["prevent"]),
|
|
134
161
|
class: "btn btn--close btn-outline-contrast"
|
|
135
162
|
}, [
|
|
136
|
-
|
|
137
|
-
], 8,
|
|
163
|
+
m(k, { symbol: "x" })
|
|
164
|
+
], 8, j))
|
|
138
165
|
], 2))), 128)),
|
|
139
|
-
|
|
140
|
-
modelValue:
|
|
141
|
-
"onUpdate:modelValue":
|
|
142
|
-
id:
|
|
143
|
-
name:
|
|
144
|
-
accept:
|
|
145
|
-
"max-file-size":
|
|
166
|
+
m(W, {
|
|
167
|
+
modelValue: c.value,
|
|
168
|
+
"onUpdate:modelValue": l[0] || (l[0] = (n) => c.value = n),
|
|
169
|
+
id: a.id,
|
|
170
|
+
name: a.name,
|
|
171
|
+
accept: a.accept,
|
|
172
|
+
"max-file-size": a.maxFileSize,
|
|
146
173
|
class: "d-none"
|
|
147
174
|
}, null, 8, ["modelValue", "id", "name", "accept", "max-file-size"]),
|
|
148
|
-
|
|
149
|
-
for:
|
|
175
|
+
d("label", {
|
|
176
|
+
for: a.id,
|
|
150
177
|
class: "file-upload__label"
|
|
151
178
|
}, [
|
|
152
|
-
|
|
153
|
-
|
|
179
|
+
T(t.$slots, "button", {}, () => [
|
|
180
|
+
d("span", {
|
|
154
181
|
class: "btn btn-outline-contrast",
|
|
155
|
-
innerHTML:
|
|
156
|
-
}, null, 8,
|
|
182
|
+
innerHTML: y(I)(a.label || t.$t("common.selectFile"))
|
|
183
|
+
}, null, 8, J)
|
|
157
184
|
]),
|
|
158
|
-
|
|
159
|
-
default:
|
|
160
|
-
|
|
161
|
-
|
|
185
|
+
m(M, { name: "fade" }, {
|
|
186
|
+
default: _(() => [
|
|
187
|
+
y(U) ? (s(), u("span", K, [...l[1] || (l[1] = [
|
|
188
|
+
d("span", {
|
|
162
189
|
class: "spinner-border",
|
|
163
190
|
role: "status"
|
|
164
191
|
}, [
|
|
165
|
-
|
|
192
|
+
d("span", { class: "visually-hidden" }, "Loading...")
|
|
166
193
|
], -1)
|
|
167
|
-
])])) :
|
|
194
|
+
])])) : H("", !0)
|
|
168
195
|
]),
|
|
169
196
|
_: 1
|
|
170
197
|
})
|
|
171
|
-
], 8,
|
|
198
|
+
], 8, G)
|
|
172
199
|
], 2));
|
|
173
200
|
}
|
|
174
201
|
});
|
|
175
202
|
export {
|
|
176
|
-
|
|
203
|
+
oe as default
|
|
177
204
|
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { PropType } from '../../../../vue/dist/vue.esm-bundler.js';
|
|
2
|
+
import { LocalUrlFormat } from '../../../composables/useLocalFileUrl';
|
|
1
3
|
import { IMediaObject } from '../../../types/media';
|
|
2
4
|
declare function __VLS_template(): {
|
|
3
5
|
attrs: Partial<{}>;
|
|
4
6
|
slots: {
|
|
5
7
|
button?(_: {}): any;
|
|
6
8
|
};
|
|
7
|
-
refs: {
|
|
9
|
+
refs: {
|
|
10
|
+
root: HTMLDivElement;
|
|
11
|
+
};
|
|
8
12
|
rootEl: HTMLDivElement;
|
|
9
13
|
};
|
|
10
14
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
@@ -98,6 +102,10 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
98
102
|
default: number;
|
|
99
103
|
};
|
|
100
104
|
aspectRatio: NumberConstructor;
|
|
105
|
+
localUrlFormat: {
|
|
106
|
+
type: PropType<LocalUrlFormat>;
|
|
107
|
+
default: string;
|
|
108
|
+
};
|
|
101
109
|
}>, {}, {}, {}, {}, import('../../../../vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, import('../../../../vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, {
|
|
102
110
|
"update:modelValue": (...args: any[]) => void;
|
|
103
111
|
"update:src": (...args: any[]) => void;
|
|
@@ -191,6 +199,10 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
191
199
|
default: number;
|
|
192
200
|
};
|
|
193
201
|
aspectRatio: NumberConstructor;
|
|
202
|
+
localUrlFormat: {
|
|
203
|
+
type: PropType<LocalUrlFormat>;
|
|
204
|
+
default: string;
|
|
205
|
+
};
|
|
194
206
|
}>> & Readonly<{
|
|
195
207
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
196
208
|
"onUpdate:src"?: ((...args: any[]) => any) | undefined;
|
|
@@ -214,9 +226,12 @@ declare const __VLS_component: import('../../../../vue/dist/vue.esm-bundler.js')
|
|
|
214
226
|
enablePreview: boolean;
|
|
215
227
|
previewWidth: number;
|
|
216
228
|
dropFiles: boolean;
|
|
229
|
+
localUrlFormat: LocalUrlFormat;
|
|
217
230
|
enableReview: boolean;
|
|
218
231
|
maxImageWidth: number;
|
|
219
|
-
}, {}, {}, {}, string, import('../../../../vue/dist/vue.esm-bundler.js').ComponentProvideOptions, true, {
|
|
232
|
+
}, {}, {}, {}, string, import('../../../../vue/dist/vue.esm-bundler.js').ComponentProvideOptions, true, {
|
|
233
|
+
root: HTMLDivElement;
|
|
234
|
+
}, HTMLDivElement>;
|
|
220
235
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
221
236
|
export default _default;
|
|
222
237
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as P, ref as u, toRef as Q, computed as H, watch as v, onBeforeUnmount as O, openBlock as s, createElementBlock as p, normalizeClass as C, unref as $, Fragment as q, createVNode as d, normalizeStyle as E, createElementVNode as n, withModifiers as h, createCommentVNode as V, renderSlot as j, Transition as A, withCtx as B, createBlock as G, toDisplayString as J } from "vue";
|
|
2
|
+
import K from "../image-crop-resize/image-crop-resize.vue.js";
|
|
3
|
+
import X from "../../atoms/base-image/base-image.vue.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import
|
|
5
|
+
import z from "../../atoms/svg-icon/svg-icon.vue.js";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import Y from "../../atoms/input-file/input-file.vue.js";
|
|
8
|
+
import Z from "../../templates/modal-dialog/modal-dialog.vue.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
10
|
+
import { useDragAndDrop as _ } from "../../../composables/useDragAndDrop.js";
|
|
11
|
+
import { useUploadTransport as ee } from "../../../composables/useUploadTransport.js";
|
|
12
|
+
import { useLocalFileUrl as te } from "../../../composables/useLocalFileUrl.js";
|
|
13
|
+
import { sanitizeHtml as ae } from "../../../composables/useSanitize.js";
|
|
14
|
+
import { resizeImageFileByMaxWidth as le, uniqueId as N, srcToFile as oe } from "../../../utilities/helpers.js";
|
|
15
|
+
const ie = { class: "image-upload__controls" }, ne = { class: "d-flex gap-1 align-items-center" }, re = {
|
|
13
16
|
key: 1,
|
|
14
17
|
class: "image-upload__controls"
|
|
15
|
-
},
|
|
18
|
+
}, ue = ["for"], se = ["innerHTML"], de = {
|
|
16
19
|
key: 0,
|
|
17
20
|
class: "image-upload__loading-spinner"
|
|
18
|
-
},
|
|
21
|
+
}, ke = /* @__PURE__ */ P({
|
|
19
22
|
__name: "image-upload",
|
|
20
23
|
props: {
|
|
21
24
|
modelValue: {
|
|
@@ -27,11 +30,11 @@ const te = { class: "image-upload__controls" }, ae = { class: "d-flex gap-1 alig
|
|
|
27
30
|
},
|
|
28
31
|
name: {
|
|
29
32
|
type: String,
|
|
30
|
-
default: () =>
|
|
33
|
+
default: () => N()
|
|
31
34
|
},
|
|
32
35
|
id: {
|
|
33
36
|
type: String,
|
|
34
|
-
default: () =>
|
|
37
|
+
default: () => N()
|
|
35
38
|
},
|
|
36
39
|
label: {
|
|
37
40
|
type: String,
|
|
@@ -106,163 +109,175 @@ const te = { class: "image-upload__controls" }, ae = { class: "d-flex gap-1 alig
|
|
|
106
109
|
type: Number,
|
|
107
110
|
default: 4096
|
|
108
111
|
},
|
|
109
|
-
aspectRatio: Number
|
|
112
|
+
aspectRatio: Number,
|
|
113
|
+
localUrlFormat: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: "dataUrl"
|
|
116
|
+
}
|
|
110
117
|
},
|
|
111
118
|
emits: ["update:modelValue", "update:src"],
|
|
112
|
-
setup(a, { emit:
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
setup(a, { emit: T }) {
|
|
120
|
+
const o = a, y = T, D = u(), f = u([]), b = u(!1), r = u(!1), m = u(null), l = u(null), F = u(null);
|
|
121
|
+
let c = !1;
|
|
122
|
+
const { pending: L, uploadFile: R } = ee(o), { toLocalUrl: S, revoke: g } = te(Q(o, "localUrlFormat")), { isDragging: x } = _(D, {
|
|
123
|
+
enabled: () => o.dropFiles,
|
|
124
|
+
onDrop: (t) => {
|
|
125
|
+
f.value = t;
|
|
126
|
+
}
|
|
127
|
+
}), w = H(() => o.modelValue ? o.modelValue : o.src ? { type: "", src: o.src } : m.value);
|
|
128
|
+
function U(t) {
|
|
129
|
+
g(m.value?.src), m.value = t;
|
|
130
|
+
}
|
|
131
|
+
function k() {
|
|
132
|
+
U(null), f.value = [], b.value = !1, y("update:modelValue", void 0), y("update:src", "");
|
|
125
133
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
134
|
+
function W() {
|
|
135
|
+
k();
|
|
128
136
|
}
|
|
129
137
|
v(() => f.value, async (t) => {
|
|
130
138
|
if (!t || !t.length || !t[0]) return;
|
|
131
|
-
|
|
132
|
-
const e = await
|
|
133
|
-
|
|
134
|
-
src: await
|
|
139
|
+
b.value = !1;
|
|
140
|
+
const e = await le(t[0], o.maxImageWidth);
|
|
141
|
+
o.enableReview ? (l.value = {
|
|
142
|
+
src: await S(e),
|
|
135
143
|
type: e.type
|
|
136
|
-
},
|
|
137
|
-
src:
|
|
144
|
+
}, c = !0, r.value = !0) : U({
|
|
145
|
+
src: o.toDataUrl ? await S(e) : await R(e),
|
|
138
146
|
type: e.type
|
|
139
|
-
};
|
|
140
|
-
}), v(() =>
|
|
141
|
-
|
|
142
|
-
}), v(() =>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
});
|
|
148
|
+
}), v(() => m.value, (t) => {
|
|
149
|
+
y("update:modelValue", t || void 0), y("update:src", t?.src || "");
|
|
150
|
+
}), v(() => F.value, async (t) => {
|
|
151
|
+
if (t) {
|
|
152
|
+
try {
|
|
153
|
+
U({
|
|
154
|
+
src: o.toDataUrl ? await S(t) : await R(t),
|
|
155
|
+
type: t.type
|
|
156
|
+
});
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.error(`Failed to process file "${t.name}"`, e);
|
|
159
|
+
}
|
|
160
|
+
F.value = null;
|
|
161
|
+
}
|
|
162
|
+
}), v(() => r.value, (t, e) => {
|
|
163
|
+
!t && e && l.value && (c && g(l.value.src), c = !1, l.value = null, W());
|
|
164
|
+
}), v(() => o.src, (t) => {
|
|
165
|
+
!t && m.value && W();
|
|
151
166
|
});
|
|
152
|
-
function
|
|
153
|
-
l.value = { src: t, type: e },
|
|
167
|
+
function I(t, e) {
|
|
168
|
+
c = !1, l.value = { src: t, type: e }, r.value = !0;
|
|
154
169
|
}
|
|
155
|
-
async function
|
|
156
|
-
l.value && (
|
|
170
|
+
async function M() {
|
|
171
|
+
l.value && (F.value = await oe(
|
|
157
172
|
l.value.src,
|
|
158
173
|
"file",
|
|
159
174
|
l.value.type
|
|
160
|
-
)), l.value = null,
|
|
175
|
+
), c && g(l.value.src)), c = !1, l.value = null, r.value = !1;
|
|
161
176
|
}
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
}),
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
class:
|
|
177
|
+
return O(() => {
|
|
178
|
+
g(m.value?.src);
|
|
179
|
+
}), (t, e) => (s(), p("div", {
|
|
180
|
+
ref_key: "root",
|
|
181
|
+
ref: D,
|
|
182
|
+
class: C(["image-upload", {
|
|
168
183
|
"has-dragging": a.dropFiles,
|
|
169
|
-
"is-dragging":
|
|
184
|
+
"is-dragging": $(x)
|
|
170
185
|
}])
|
|
171
186
|
}, [
|
|
172
|
-
!
|
|
187
|
+
!r.value && w.value ? (s(), p("div", {
|
|
173
188
|
key: 0,
|
|
174
|
-
class:
|
|
189
|
+
class: C(["mb-2", a.enablePreview ? "image-upload__thumbnail" : "image-upload__reset"])
|
|
175
190
|
}, [
|
|
176
|
-
a.enablePreview ? (s(),
|
|
177
|
-
|
|
178
|
-
src: `${
|
|
191
|
+
a.enablePreview ? (s(), p(q, { key: 0 }, [
|
|
192
|
+
d(X, {
|
|
193
|
+
src: `${w.value.src}${a.previewWidth ? `?width=${a.previewWidth}` : ""}`,
|
|
179
194
|
class: "img-thumbnail rounded",
|
|
180
|
-
ready:
|
|
181
|
-
"onUpdate:ready": e[0] || (e[0] = (
|
|
195
|
+
ready: b.value,
|
|
196
|
+
"onUpdate:ready": e[0] || (e[0] = (i) => b.value = i),
|
|
182
197
|
animate: !1,
|
|
183
198
|
style: E({ maxWidth: a.previewWidth ? `${a.previewWidth}px` : "auto", height: "auto" })
|
|
184
199
|
}, null, 8, ["src", "ready", "style"]),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
200
|
+
n("div", ie, [
|
|
201
|
+
n("div", ne, [
|
|
202
|
+
n("button", {
|
|
188
203
|
type: "button",
|
|
189
|
-
onClick: e[1] || (e[1] =
|
|
204
|
+
onClick: e[1] || (e[1] = h((i) => I(w.value.src, w.value.type), ["prevent", "stop"])),
|
|
190
205
|
class: "btn btn--edit btn-sm btn-light"
|
|
191
206
|
}, [
|
|
192
|
-
|
|
207
|
+
d(z, { symbol: "edit-2" })
|
|
193
208
|
]),
|
|
194
|
-
|
|
209
|
+
n("button", {
|
|
195
210
|
type: "button",
|
|
196
|
-
onClick: e[2] || (e[2] =
|
|
211
|
+
onClick: e[2] || (e[2] = h((i) => k(), ["prevent", "stop"])),
|
|
197
212
|
class: "btn btn--close btn-sm btn-light"
|
|
198
213
|
}, [
|
|
199
|
-
|
|
214
|
+
d(z, { symbol: "x" })
|
|
200
215
|
])
|
|
201
216
|
])
|
|
202
217
|
])
|
|
203
|
-
], 64)) : (s(),
|
|
204
|
-
|
|
205
|
-
onClick: e[3] || (e[3] =
|
|
218
|
+
], 64)) : (s(), p("div", re, [
|
|
219
|
+
n("button", {
|
|
220
|
+
onClick: e[3] || (e[3] = h((i) => k(), ["prevent", "stop"])),
|
|
206
221
|
class: "btn btn--close btn-outline-contrast"
|
|
207
222
|
}, [
|
|
208
|
-
|
|
223
|
+
d(z, { symbol: "x" })
|
|
209
224
|
])
|
|
210
225
|
]))
|
|
211
|
-
], 2)) :
|
|
212
|
-
|
|
213
|
-
modelValue:
|
|
214
|
-
"onUpdate:modelValue": e[4] || (e[4] = (
|
|
226
|
+
], 2)) : V("", !0),
|
|
227
|
+
d(Y, {
|
|
228
|
+
modelValue: f.value,
|
|
229
|
+
"onUpdate:modelValue": e[4] || (e[4] = (i) => f.value = i),
|
|
215
230
|
id: a.id,
|
|
216
231
|
name: a.name,
|
|
217
232
|
accept: a.accept,
|
|
218
233
|
"max-file-size": a.maxFileSize,
|
|
219
234
|
class: "d-none"
|
|
220
235
|
}, null, 8, ["modelValue", "id", "name", "accept", "max-file-size"]),
|
|
221
|
-
a.src ?
|
|
236
|
+
a.src ? V("", !0) : (s(), p("label", {
|
|
222
237
|
key: 1,
|
|
223
238
|
for: a.id,
|
|
224
239
|
class: "image-upload__label"
|
|
225
240
|
}, [
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
j(t.$slots, "button", {}, () => [
|
|
242
|
+
n("span", {
|
|
228
243
|
class: "btn btn-outline-contrast",
|
|
229
|
-
innerHTML: a.label || t.$t("common.selectFile")
|
|
230
|
-
}, null, 8,
|
|
244
|
+
innerHTML: $(ae)(a.label || t.$t("common.selectFile"))
|
|
245
|
+
}, null, 8, se)
|
|
231
246
|
]),
|
|
232
|
-
|
|
233
|
-
default:
|
|
234
|
-
|
|
235
|
-
|
|
247
|
+
d(A, { name: "fade" }, {
|
|
248
|
+
default: B(() => [
|
|
249
|
+
$(L) ? (s(), p("span", de, [...e[7] || (e[7] = [
|
|
250
|
+
n("span", {
|
|
236
251
|
class: "spinner-border",
|
|
237
252
|
role: "status"
|
|
238
253
|
}, [
|
|
239
|
-
|
|
254
|
+
n("span", { class: "visually-hidden" }, "Loading...")
|
|
240
255
|
], -1)
|
|
241
|
-
])])) :
|
|
256
|
+
])])) : V("", !0)
|
|
242
257
|
]),
|
|
243
258
|
_: 1
|
|
244
259
|
})
|
|
245
|
-
], 8,
|
|
246
|
-
|
|
247
|
-
modelValue:
|
|
248
|
-
"onUpdate:modelValue": e[6] || (e[6] = (
|
|
260
|
+
], 8, ue)),
|
|
261
|
+
d(Z, {
|
|
262
|
+
modelValue: r.value,
|
|
263
|
+
"onUpdate:modelValue": e[6] || (e[6] = (i) => r.value = i),
|
|
249
264
|
footer: !1
|
|
250
265
|
}, {
|
|
251
|
-
default:
|
|
252
|
-
|
|
266
|
+
default: B(() => [
|
|
267
|
+
r.value && l.value ? (s(), G(K, {
|
|
253
268
|
key: 0,
|
|
254
269
|
modelValue: l.value.src,
|
|
255
|
-
"onUpdate:modelValue": e[5] || (e[5] = (
|
|
270
|
+
"onUpdate:modelValue": e[5] || (e[5] = (i) => l.value.src = i),
|
|
256
271
|
"aspect-ratio": a.aspectRatio
|
|
257
272
|
}, {
|
|
258
|
-
submit:
|
|
259
|
-
|
|
273
|
+
submit: B(() => [
|
|
274
|
+
n("button", {
|
|
260
275
|
class: "btn btn-primary",
|
|
261
|
-
onClick:
|
|
262
|
-
},
|
|
276
|
+
onClick: h(M, ["prevent", "stop"])
|
|
277
|
+
}, J(t.$t("common.save")), 1)
|
|
263
278
|
]),
|
|
264
279
|
_: 1
|
|
265
|
-
}, 8, ["modelValue", "aspect-ratio"])) :
|
|
280
|
+
}, 8, ["modelValue", "aspect-ratio"])) : V("", !0)
|
|
266
281
|
]),
|
|
267
282
|
_: 1
|
|
268
283
|
}, 8, ["modelValue"])
|
|
@@ -270,5 +285,5 @@ const te = { class: "image-upload__controls" }, ae = { class: "d-flex gap-1 alig
|
|
|
270
285
|
}
|
|
271
286
|
});
|
|
272
287
|
export {
|
|
273
|
-
|
|
288
|
+
ke as default
|
|
274
289
|
};
|