ablok-components 0.3.90 → 0.3.91
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as D, computed as L, ref as _, resolveComponent as C, openBlock as i, createElementBlock as r, createElementVNode as o, unref as S, renderSlot as B, withModifiers as g, createVNode as p, createCommentVNode as c, toDisplayString as y, withCtx as w, Fragment as I, withDirectives as U, vModelText as N, nextTick as A } from "vue";
|
|
2
2
|
import E from "../file-upload/file-upload.vue.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import { sanitizeHtml as R } from "../../../composables/useSanitize.js";
|
|
@@ -8,7 +8,7 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
8
8
|
}, G = { class: "py-4 px-3 d-flex align-items-center border border-bottom-0" }, J = ["innerHTML"], O = { class: "col-12" }, P = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "grid place-items-center text-center text-muted py-5 border border-bottom-0"
|
|
11
|
-
}, Q = { class: "m-0" }, W = { class: "preview-item border-bottom p-3" }, X = { class: "d-flex gap-3" }, Y = { class: "col-2" }, Z = { class: "col d-flex flex-column" }, ee = { class: "file-meta text-muted small mb-2" }, te = { class: "fw-semibold" }, oe = { key: 0 }, le = { key: 1 }, se = ["onUpdate:modelValue", "id"], ne = ["innerHTML"], ae = { class: "col-auto d-flex flex-column gap-2" }, ie = ["onClick"],
|
|
11
|
+
}, Q = { class: "m-0" }, W = { class: "preview-item border-bottom p-3" }, X = { class: "d-flex gap-3" }, Y = { class: "col-2" }, Z = { class: "col d-flex flex-column" }, ee = { class: "file-meta text-muted small mb-2" }, te = { class: "fw-semibold" }, oe = { key: 0 }, le = { key: 1 }, se = ["onUpdate:modelValue", "id"], ne = ["innerHTML"], ae = { class: "col-auto d-flex flex-column gap-2" }, ie = ["onClick"], re = ["onClick"], de = { class: "d-flex align-items-end p-3" }, ue = { class: "btn btn-primary btn-sm ms-auto d-flex align-items-center gap-2" }, ce = ["innerHTML"], be = /* @__PURE__ */ D({
|
|
12
12
|
__name: "bulk-upload",
|
|
13
13
|
props: {
|
|
14
14
|
storeId: String,
|
|
@@ -53,10 +53,10 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
emits: ["update:modelValue"],
|
|
56
|
-
setup(
|
|
57
|
-
const
|
|
56
|
+
setup(u, { emit: V }) {
|
|
57
|
+
const b = u, k = V, M = (e) => `${e.name ?? ""}|${e.size ?? 0}|${e.lastModified ?? 0}|${e.type ?? ""}`, m = L({
|
|
58
58
|
get: () => {
|
|
59
|
-
const e =
|
|
59
|
+
const e = b.modelValue || [];
|
|
60
60
|
return v.value = e.map((t) => t.caption || ""), e.map((t) => ({
|
|
61
61
|
type: t.type,
|
|
62
62
|
src: t.src,
|
|
@@ -66,24 +66,24 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
66
66
|
}));
|
|
67
67
|
},
|
|
68
68
|
set: (e) => {
|
|
69
|
-
const t = m.value || [], l = Array.isArray(e) ? e : [], a =
|
|
70
|
-
const
|
|
71
|
-
return !t.some((
|
|
69
|
+
const t = m.value || [], l = Array.isArray(e) ? e : [], a = b.allowDuplicateFiles ? l : l.filter((s) => {
|
|
70
|
+
const d = M(s);
|
|
71
|
+
return !t.some((x) => M(x) === d);
|
|
72
72
|
});
|
|
73
|
-
if (!
|
|
73
|
+
if (!b.allowDuplicateFiles && l.length > 0 && a.length === 0)
|
|
74
74
|
return;
|
|
75
|
-
const n = a.length <= t.length && a.every((s) => t.some((
|
|
76
|
-
|
|
75
|
+
const n = a.length <= t.length && a.every((s) => t.some((d) => d.src === s.src));
|
|
76
|
+
h(n ? a : [...t, ...a]);
|
|
77
77
|
}
|
|
78
78
|
}), $ = _(null), f = _({}), v = _({});
|
|
79
|
-
function
|
|
80
|
-
const t = [...
|
|
79
|
+
function H(e) {
|
|
80
|
+
const t = [...b.modelValue || []];
|
|
81
81
|
t.splice(e, 1), k("update:modelValue", t);
|
|
82
82
|
}
|
|
83
|
-
async function
|
|
84
|
-
f.value[e] = !f.value[e], f.value[e] ||
|
|
83
|
+
async function z(e) {
|
|
84
|
+
f.value[e] = !f.value[e], f.value[e] || h(), await A(), $.value?.querySelector(`#caption-${e}`)?.focus();
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function F(e) {
|
|
87
87
|
if (e == null) return "";
|
|
88
88
|
const t = ["B", "KB", "MB", "GB", "TB"];
|
|
89
89
|
let l = e, a = t.shift();
|
|
@@ -91,10 +91,10 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
91
91
|
l /= 1024, a = t.shift();
|
|
92
92
|
return `${l.toFixed(1)} ${a}`;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function T(e) {
|
|
95
95
|
return e ? new Date(e).toLocaleDateString() : "";
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function h(e) {
|
|
98
98
|
k("update:modelValue", (e || m.value).map((t, l) => ({
|
|
99
99
|
...t,
|
|
100
100
|
caption: v.value[l] || ""
|
|
@@ -102,30 +102,32 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
102
102
|
}
|
|
103
103
|
return (e, t) => {
|
|
104
104
|
const l = C("svg-icon"), a = C("base-image");
|
|
105
|
-
return i(),
|
|
105
|
+
return i(), r("div", {
|
|
106
106
|
class: "bulk-upload",
|
|
107
107
|
ref_key: "root",
|
|
108
108
|
ref: $
|
|
109
109
|
}, [
|
|
110
110
|
o("div", K, [
|
|
111
111
|
o("div", j, [
|
|
112
|
-
|
|
112
|
+
u.hasHeader ? (i(), r("div", q, [
|
|
113
113
|
o("div", G, [
|
|
114
114
|
o("p", {
|
|
115
115
|
class: "fw-bold m-0",
|
|
116
|
-
innerHTML:
|
|
116
|
+
innerHTML: S(R)(u.title || e.$t("fileInput.bulkUploadHeadline"))
|
|
117
117
|
}, null, 8, J),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
B(e.$slots, "bulk-remove", {}, () => [
|
|
119
|
+
u.hasBulkRemove ? (i(), r("button", {
|
|
120
|
+
key: 0,
|
|
121
|
+
onClick: t[0] || (t[0] = g((n) => m.value = [], ["prevent"])),
|
|
122
|
+
class: "btn btn--close ms-auto p-0"
|
|
123
|
+
}, [
|
|
124
|
+
p(l, { symbol: "x" })
|
|
125
|
+
])) : c("", !0)
|
|
126
|
+
])
|
|
125
127
|
])
|
|
126
|
-
])) :
|
|
128
|
+
])) : c("", !0),
|
|
127
129
|
o("div", O, [
|
|
128
|
-
m.value.length ?
|
|
130
|
+
m.value.length ? c("", !0) : (i(), r("div", P, [
|
|
129
131
|
o("p", Q, y(e.$t("fileInput.noFilesSelected")), 1)
|
|
130
132
|
])),
|
|
131
133
|
p(E, {
|
|
@@ -138,7 +140,7 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
138
140
|
"local-url-format": "objectUrl",
|
|
139
141
|
class: "d-flex flex-column border"
|
|
140
142
|
}, {
|
|
141
|
-
"preview-item":
|
|
143
|
+
"preview-item": w(({ bind: { item: n, index: s } }) => [
|
|
142
144
|
o("div", W, [
|
|
143
145
|
o("div", X, [
|
|
144
146
|
o("div", Y, [
|
|
@@ -152,57 +154,57 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
152
154
|
o("div", ee, [
|
|
153
155
|
o("div", te, y(n.name || e.$t("fileInput.unknownFile")), 1),
|
|
154
156
|
o("div", null, [
|
|
155
|
-
n.size ? (i(),
|
|
156
|
-
n.lastModified ? (i(),
|
|
157
|
+
n.size ? (i(), r("span", oe, y(F(n.size)), 1)) : c("", !0),
|
|
158
|
+
n.lastModified ? (i(), r("span", le, " · " + y(T(n.lastModified)), 1)) : c("", !0)
|
|
157
159
|
])
|
|
158
160
|
]),
|
|
159
|
-
|
|
160
|
-
f.value[s] &&
|
|
161
|
+
u.hasCaptions ? (i(), r(I, { key: 0 }, [
|
|
162
|
+
f.value[s] && u.editCaptions ? U((i(), r("textarea", {
|
|
161
163
|
key: 0,
|
|
162
|
-
"onUpdate:modelValue": (
|
|
164
|
+
"onUpdate:modelValue": (d) => v.value[s] = d,
|
|
163
165
|
id: `caption-${s}`,
|
|
164
166
|
class: "form-control rounded-0 h-100",
|
|
165
|
-
onChangeCapture: t[1] || (t[1] = (
|
|
167
|
+
onChangeCapture: t[1] || (t[1] = (d) => h())
|
|
166
168
|
}, null, 40, se)), [
|
|
167
169
|
[N, v.value[s]]
|
|
168
|
-
]) : (i(),
|
|
170
|
+
]) : (i(), r("p", {
|
|
169
171
|
key: 1,
|
|
170
172
|
class: "m-0",
|
|
171
173
|
innerHTML: v.value[s] || `<small>${e.$t("fileInput.noCaption")}</small>`
|
|
172
174
|
}, null, 8, ne))
|
|
173
|
-
], 64)) :
|
|
175
|
+
], 64)) : c("", !0)
|
|
174
176
|
]),
|
|
175
177
|
o("div", ae, [
|
|
176
178
|
o("button", {
|
|
177
|
-
onClick: g((
|
|
179
|
+
onClick: g((d) => H(s), ["prevent"]),
|
|
178
180
|
class: "btn btn--close"
|
|
179
181
|
}, [
|
|
180
182
|
p(l, { symbol: "x" })
|
|
181
183
|
], 8, ie),
|
|
182
|
-
|
|
184
|
+
u.editCaptions ? (i(), r("button", {
|
|
183
185
|
key: 0,
|
|
184
|
-
onClick: g((
|
|
186
|
+
onClick: g((d) => z(s), ["prevent"]),
|
|
185
187
|
class: "btn btn--close"
|
|
186
188
|
}, [
|
|
187
189
|
p(l, {
|
|
188
190
|
symbol: f.value[s] ? "check" : "edit-3"
|
|
189
191
|
}, null, 8, ["symbol"])
|
|
190
|
-
], 8,
|
|
192
|
+
], 8, re)) : c("", !0)
|
|
191
193
|
])
|
|
192
194
|
])
|
|
193
195
|
])
|
|
194
196
|
]),
|
|
195
|
-
button:
|
|
196
|
-
|
|
197
|
-
o("span",
|
|
198
|
-
o("span",
|
|
197
|
+
button: w(() => [
|
|
198
|
+
B(e.$slots, "button", {}, () => [
|
|
199
|
+
o("span", de, [
|
|
200
|
+
o("span", ue, [
|
|
199
201
|
p(l, {
|
|
200
202
|
symbol: "upload",
|
|
201
203
|
size: "small"
|
|
202
204
|
}),
|
|
203
205
|
o("span", {
|
|
204
206
|
innerHTML: e.$t("common.selectFile")
|
|
205
|
-
}, null, 8,
|
|
207
|
+
}, null, 8, ce)
|
|
206
208
|
])
|
|
207
209
|
])
|
|
208
210
|
])
|
|
@@ -217,5 +219,5 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
217
219
|
}
|
|
218
220
|
});
|
|
219
221
|
export {
|
|
220
|
-
|
|
222
|
+
be as default
|
|
221
223
|
};
|