ablok-components 0.3.79 → 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.
|
@@ -3,6 +3,13 @@ import { LocalUrlFormat } from '../../../composables/useLocalFileUrl';
|
|
|
3
3
|
declare function __VLS_template(): {
|
|
4
4
|
attrs: Partial<{}>;
|
|
5
5
|
slots: {
|
|
6
|
+
'preview-item'?(_: {
|
|
7
|
+
url: {
|
|
8
|
+
type?: string;
|
|
9
|
+
src?: string;
|
|
10
|
+
};
|
|
11
|
+
index: number;
|
|
12
|
+
}): any;
|
|
6
13
|
button?(_: {}): any;
|
|
7
14
|
};
|
|
8
15
|
refs: {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as L, ref as f, toRef as N, computed as P, watch as b, openBlock as u, createElementBlock as d, normalizeClass as h, unref as y, Fragment as V, renderList as T, renderSlot as S, createElementVNode as c, withModifiers as w, createVNode as p, Transition as M, withCtx as H, createCommentVNode as W } from "vue";
|
|
2
2
|
import k from "../../atoms/svg-icon/svg-icon.vue.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import
|
|
5
|
-
import { useDragAndDrop as
|
|
6
|
-
import { useUploadTransport as
|
|
7
|
-
import { useLocalFileUrl as
|
|
8
|
-
import { sanitizeHtml as
|
|
9
|
-
import { uniqueId as
|
|
10
|
-
const
|
|
4
|
+
import q from "../../atoms/input-file/input-file.vue.js";
|
|
5
|
+
import { useDragAndDrop as E } from "../../../composables/useDragAndDrop.js";
|
|
6
|
+
import { useUploadTransport as I } from "../../../composables/useUploadTransport.js";
|
|
7
|
+
import { useLocalFileUrl as R } from "../../../composables/useLocalFileUrl.js";
|
|
8
|
+
import { sanitizeHtml as O } from "../../../composables/useSanitize.js";
|
|
9
|
+
import { uniqueId as F } from "../../../utilities/helpers.js";
|
|
10
|
+
const _ = ["src"], j = ["onClick"], x = ["onClick"], G = ["for"], J = ["innerHTML"], K = {
|
|
11
11
|
key: 0,
|
|
12
12
|
class: "file-upload__loading-spinner"
|
|
13
|
-
},
|
|
13
|
+
}, ne = /* @__PURE__ */ L({
|
|
14
14
|
__name: "file-upload",
|
|
15
15
|
props: {
|
|
16
16
|
modelValue: {
|
|
@@ -22,11 +22,11 @@ const R = ["src"], O = ["onClick"], j = ["onClick"], G = ["for"], J = ["innerHTM
|
|
|
22
22
|
},
|
|
23
23
|
name: {
|
|
24
24
|
type: String,
|
|
25
|
-
default: () =>
|
|
25
|
+
default: () => F()
|
|
26
26
|
},
|
|
27
27
|
id: {
|
|
28
28
|
type: String,
|
|
29
|
-
default: () =>
|
|
29
|
+
default: () => F()
|
|
30
30
|
},
|
|
31
31
|
label: {
|
|
32
32
|
type: String,
|
|
@@ -102,96 +102,102 @@ const R = ["src"], O = ["onClick"], j = ["onClick"], G = ["for"], J = ["innerHTM
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
emits: ["update:modelValue", "update:src"],
|
|
105
|
-
setup(a, { emit:
|
|
106
|
-
const e = a, i =
|
|
105
|
+
setup(a, { emit: U }) {
|
|
106
|
+
const e = a, i = U, v = f(), m = f([]), n = f([]), { pending: $, uploadFile: B } = I(e), { toLocalUrl: D, revoke: C } = R(N(e, "localUrlFormat")), { isDragging: z } = E(v, {
|
|
107
107
|
enabled: () => e.dropFiles,
|
|
108
108
|
onDrop: (t) => {
|
|
109
|
-
|
|
109
|
+
m.value = t;
|
|
110
110
|
}
|
|
111
|
-
}),
|
|
111
|
+
}), A = P(() => e.modelValue?.length ? e.modelValue : e.src ? [{ type: "", src: e.src }] : n.value);
|
|
112
112
|
function g(t) {
|
|
113
|
-
const l = typeof t == "string" ? parseInt(t, 10) : t,
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
l <
|
|
117
|
-
} else if (
|
|
118
|
-
const
|
|
119
|
-
i("update:modelValue",
|
|
113
|
+
const l = typeof t == "string" ? parseInt(t, 10) : t, o = Array.isArray(e.modelValue) && e.modelValue.length > 0, r = Array.isArray(n.value) && n.value.length > 0;
|
|
114
|
+
if (r && l < n.value.length && (C(n.value[l]?.src), n.value.splice(l, 1)), o) {
|
|
115
|
+
const s = [...e.modelValue];
|
|
116
|
+
l < s.length && s.splice(l, 1), i("update:modelValue", s), e.multiple || i("update:src", s[0]?.src || "");
|
|
117
|
+
} else if (r) {
|
|
118
|
+
const s = e.multiple ? n.value : n.value[0];
|
|
119
|
+
i("update:modelValue", s), e.multiple || i("update:src", n.value[0]?.src || "");
|
|
120
120
|
} else
|
|
121
121
|
i("update:modelValue", e.multiple ? [] : void 0), i("update:src", "");
|
|
122
|
-
|
|
122
|
+
m.value.splice(l, 1);
|
|
123
123
|
}
|
|
124
|
-
return b(() =>
|
|
124
|
+
return b(() => m.value, async (t) => {
|
|
125
125
|
const l = await Promise.all(
|
|
126
|
-
t.map(async (
|
|
127
|
-
src: e.toDataUrl ? await D(
|
|
128
|
-
type:
|
|
126
|
+
t.map(async (o) => ({
|
|
127
|
+
src: e.toDataUrl ? await D(o) : await B(o),
|
|
128
|
+
type: o.type
|
|
129
129
|
}))
|
|
130
130
|
);
|
|
131
|
-
|
|
132
|
-
}, { deep: !0 }), b(() =>
|
|
131
|
+
n.value = l.filter((o) => o !== null);
|
|
132
|
+
}, { deep: !0 }), b(() => n.value, async (t) => {
|
|
133
133
|
const l = e.multiple ? t : t[0];
|
|
134
134
|
i("update:modelValue", l), e.multiple || i("update:src", t[0] && t[0].src);
|
|
135
|
-
}, { deep: !0 }), (t, l) => (
|
|
135
|
+
}, { deep: !0 }), (t, l) => (u(), d("div", {
|
|
136
136
|
ref_key: "root",
|
|
137
137
|
ref: v,
|
|
138
138
|
class: h(["file-upload", {
|
|
139
139
|
"has-dragging": a.dropFiles,
|
|
140
|
-
"is-dragging": y(
|
|
140
|
+
"is-dragging": y(z)
|
|
141
141
|
}])
|
|
142
142
|
}, [
|
|
143
|
-
(
|
|
144
|
-
key:
|
|
143
|
+
(u(!0), d(V, null, T(A.value, (o, r) => (u(), d("div", {
|
|
144
|
+
key: o.src,
|
|
145
145
|
class: h(a.enablePreview ? "file-upload__thumbnail" : "file-upload__reset")
|
|
146
146
|
}, [
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
S(t.$slots, "preview-item", {
|
|
148
|
+
url: o,
|
|
149
|
+
index: r
|
|
150
|
+
}, () => [
|
|
151
|
+
a.enablePreview ? (u(), d(V, { key: 0 }, [
|
|
152
|
+
c("img", {
|
|
153
|
+
src: `${o.src}${a.previewWidth ? `?width=${a.previewWidth}` : ""}`,
|
|
154
|
+
class: "img-thumbnail rounded"
|
|
155
|
+
}, null, 8, _),
|
|
156
|
+
c("button", {
|
|
157
|
+
onClick: w((s) => g(r), ["prevent"]),
|
|
158
|
+
class: "btn btn--close"
|
|
159
|
+
}, [
|
|
160
|
+
p(k, { symbol: "x" })
|
|
161
|
+
], 8, j)
|
|
162
|
+
], 64)) : (u(), d("button", {
|
|
163
|
+
key: 1,
|
|
164
|
+
onClick: w((s) => g(r), ["prevent"]),
|
|
165
|
+
class: "btn btn--close btn-outline-contrast"
|
|
155
166
|
}, [
|
|
156
|
-
|
|
157
|
-
], 8,
|
|
158
|
-
]
|
|
159
|
-
key: 1,
|
|
160
|
-
onClick: S((r) => g(p), ["prevent"]),
|
|
161
|
-
class: "btn btn--close btn-outline-contrast"
|
|
162
|
-
}, [
|
|
163
|
-
m(k, { symbol: "x" })
|
|
164
|
-
], 8, j))
|
|
167
|
+
p(k, { symbol: "x" })
|
|
168
|
+
], 8, x))
|
|
169
|
+
])
|
|
165
170
|
], 2))), 128)),
|
|
166
|
-
|
|
167
|
-
modelValue:
|
|
168
|
-
"onUpdate:modelValue": l[0] || (l[0] = (
|
|
171
|
+
p(q, {
|
|
172
|
+
modelValue: m.value,
|
|
173
|
+
"onUpdate:modelValue": l[0] || (l[0] = (o) => m.value = o),
|
|
169
174
|
id: a.id,
|
|
170
175
|
name: a.name,
|
|
171
176
|
accept: a.accept,
|
|
172
177
|
"max-file-size": a.maxFileSize,
|
|
178
|
+
multiple: a.multiple,
|
|
173
179
|
class: "d-none"
|
|
174
|
-
}, null, 8, ["modelValue", "id", "name", "accept", "max-file-size"]),
|
|
175
|
-
|
|
180
|
+
}, null, 8, ["modelValue", "id", "name", "accept", "max-file-size", "multiple"]),
|
|
181
|
+
c("label", {
|
|
176
182
|
for: a.id,
|
|
177
183
|
class: "file-upload__label"
|
|
178
184
|
}, [
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
S(t.$slots, "button", {}, () => [
|
|
186
|
+
c("span", {
|
|
181
187
|
class: "btn btn-outline-contrast",
|
|
182
|
-
innerHTML: y(
|
|
188
|
+
innerHTML: y(O)(a.label || t.$t("common.selectFile"))
|
|
183
189
|
}, null, 8, J)
|
|
184
190
|
]),
|
|
185
|
-
|
|
186
|
-
default:
|
|
187
|
-
y(
|
|
188
|
-
|
|
191
|
+
p(M, { name: "fade" }, {
|
|
192
|
+
default: H(() => [
|
|
193
|
+
y($) ? (u(), d("span", K, [...l[1] || (l[1] = [
|
|
194
|
+
c("span", {
|
|
189
195
|
class: "spinner-border",
|
|
190
196
|
role: "status"
|
|
191
197
|
}, [
|
|
192
|
-
|
|
198
|
+
c("span", { class: "visually-hidden" }, "Loading...")
|
|
193
199
|
], -1)
|
|
194
|
-
])])) :
|
|
200
|
+
])])) : W("", !0)
|
|
195
201
|
]),
|
|
196
202
|
_: 1
|
|
197
203
|
})
|
|
@@ -200,5 +206,5 @@ const R = ["src"], O = ["onClick"], j = ["onClick"], G = ["for"], J = ["innerHTM
|
|
|
200
206
|
}
|
|
201
207
|
});
|
|
202
208
|
export {
|
|
203
|
-
|
|
209
|
+
ne as default
|
|
204
210
|
};
|