ablok-components 0.3.89 → 0.3.90
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,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as T, computed as D, ref as _, resolveComponent as C, openBlock as i, createElementBlock as d, createElementVNode as o, unref as L, withModifiers as g, createVNode as p, createCommentVNode as u, toDisplayString as y, withCtx as B, renderSlot as S, 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";
|
|
5
5
|
const K = { class: "container" }, j = { class: "row" }, q = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "col-12"
|
|
8
|
-
}, G = { class: "
|
|
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"], de = ["onClick"], re = { class: "d-flex align-items-end p-3" }, ce = { class: "btn btn-primary btn-sm ms-auto d-flex align-items-center gap-2" }, ue = ["innerHTML"], he = /* @__PURE__ */ T({
|
|
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(c, { emit: w }) {
|
|
57
|
+
const h = c, k = w, M = (e) => `${e.name ?? ""}|${e.size ?? 0}|${e.lastModified ?? 0}|${e.type ?? ""}`, m = D({
|
|
58
58
|
get: () => {
|
|
59
|
-
const e =
|
|
59
|
+
const e = h.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 =
|
|
70
|
-
const
|
|
71
|
-
return !t.some((
|
|
69
|
+
const t = m.value || [], l = Array.isArray(e) ? e : [], a = h.allowDuplicateFiles ? l : l.filter((s) => {
|
|
70
|
+
const r = M(s);
|
|
71
|
+
return !t.some((F) => M(F) === r);
|
|
72
72
|
});
|
|
73
|
-
if (!
|
|
73
|
+
if (!h.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((r) => r.src === s.src));
|
|
76
|
+
b(n ? a : [...t, ...a]);
|
|
77
77
|
}
|
|
78
|
-
}), $ =
|
|
78
|
+
}), $ = _(null), f = _({}), v = _({});
|
|
79
79
|
function V(e) {
|
|
80
|
-
const t = [...
|
|
80
|
+
const t = [...h.modelValue || []];
|
|
81
81
|
t.splice(e, 1), k("update:modelValue", t);
|
|
82
82
|
}
|
|
83
83
|
async function H(e) {
|
|
84
|
-
f.value[e] = !f.value[e], f.value[e] ||
|
|
84
|
+
f.value[e] = !f.value[e], f.value[e] || b(), await A(), $.value?.querySelector(`#caption-${e}`)?.focus();
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function x(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,46 +91,46 @@ 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 z(e) {
|
|
95
95
|
return e ? new Date(e).toLocaleDateString() : "";
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
k("update:modelValue", (e ||
|
|
97
|
+
function b(e) {
|
|
98
|
+
k("update:modelValue", (e || m.value).map((t, l) => ({
|
|
99
99
|
...t,
|
|
100
100
|
caption: v.value[l] || ""
|
|
101
101
|
})));
|
|
102
102
|
}
|
|
103
103
|
return (e, t) => {
|
|
104
|
-
const l =
|
|
105
|
-
return i(),
|
|
104
|
+
const l = C("svg-icon"), a = C("base-image");
|
|
105
|
+
return i(), d("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
|
+
c.hasHeader ? (i(), d("div", q, [
|
|
113
113
|
o("div", G, [
|
|
114
114
|
o("p", {
|
|
115
115
|
class: "fw-bold m-0",
|
|
116
|
-
innerHTML: L(R)(
|
|
116
|
+
innerHTML: L(R)(c.title || e.$t("fileInput.bulkUploadHeadline"))
|
|
117
117
|
}, null, 8, J),
|
|
118
|
-
|
|
118
|
+
c.hasBulkRemove ? (i(), d("button", {
|
|
119
119
|
key: 0,
|
|
120
|
-
onClick: t[0] || (t[0] = g((n) =>
|
|
120
|
+
onClick: t[0] || (t[0] = g((n) => m.value = [], ["prevent"])),
|
|
121
121
|
class: "btn btn--close ms-auto p-0"
|
|
122
122
|
}, [
|
|
123
|
-
|
|
124
|
-
])) :
|
|
123
|
+
p(l, { symbol: "x" })
|
|
124
|
+
])) : u("", !0)
|
|
125
125
|
])
|
|
126
|
-
])) :
|
|
126
|
+
])) : u("", !0),
|
|
127
127
|
o("div", O, [
|
|
128
|
-
|
|
129
|
-
o("p", Q,
|
|
128
|
+
m.value.length ? u("", !0) : (i(), d("div", P, [
|
|
129
|
+
o("p", Q, y(e.$t("fileInput.noFilesSelected")), 1)
|
|
130
130
|
])),
|
|
131
|
-
|
|
132
|
-
modelValue:
|
|
133
|
-
"onUpdate:modelValue": t[2] || (t[2] = (n) =>
|
|
131
|
+
p(E, {
|
|
132
|
+
modelValue: m.value,
|
|
133
|
+
"onUpdate:modelValue": t[2] || (t[2] = (n) => m.value = n),
|
|
134
134
|
multiple: !0,
|
|
135
135
|
accept: "image/*",
|
|
136
136
|
"drop-files": !0,
|
|
@@ -138,11 +138,11 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
138
138
|
"local-url-format": "objectUrl",
|
|
139
139
|
class: "d-flex flex-column border"
|
|
140
140
|
}, {
|
|
141
|
-
"preview-item":
|
|
141
|
+
"preview-item": B(({ bind: { item: n, index: s } }) => [
|
|
142
142
|
o("div", W, [
|
|
143
143
|
o("div", X, [
|
|
144
144
|
o("div", Y, [
|
|
145
|
-
|
|
145
|
+
p(a, {
|
|
146
146
|
src: n.src,
|
|
147
147
|
alt: "",
|
|
148
148
|
class: "img-thumbnail"
|
|
@@ -150,52 +150,53 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
150
150
|
]),
|
|
151
151
|
o("div", Z, [
|
|
152
152
|
o("div", ee, [
|
|
153
|
-
o("div", te,
|
|
153
|
+
o("div", te, y(n.name || e.$t("fileInput.unknownFile")), 1),
|
|
154
154
|
o("div", null, [
|
|
155
|
-
n.size ? (i(),
|
|
156
|
-
n.lastModified ? (i(),
|
|
155
|
+
n.size ? (i(), d("span", oe, y(x(n.size)), 1)) : u("", !0),
|
|
156
|
+
n.lastModified ? (i(), d("span", le, " · " + y(z(n.lastModified)), 1)) : u("", !0)
|
|
157
157
|
])
|
|
158
158
|
]),
|
|
159
|
-
|
|
160
|
-
f.value[s] &&
|
|
159
|
+
c.hasCaptions ? (i(), d(I, { key: 0 }, [
|
|
160
|
+
f.value[s] && c.editCaptions ? U((i(), d("textarea", {
|
|
161
161
|
key: 0,
|
|
162
|
-
"onUpdate:modelValue": (
|
|
162
|
+
"onUpdate:modelValue": (r) => v.value[s] = r,
|
|
163
163
|
id: `caption-${s}`,
|
|
164
164
|
class: "form-control rounded-0 h-100",
|
|
165
|
-
onChangeCapture: t[1] || (t[1] = (
|
|
165
|
+
onChangeCapture: t[1] || (t[1] = (r) => b())
|
|
166
166
|
}, null, 40, se)), [
|
|
167
167
|
[N, v.value[s]]
|
|
168
|
-
]) : (i(),
|
|
168
|
+
]) : (i(), d("p", {
|
|
169
169
|
key: 1,
|
|
170
170
|
class: "m-0",
|
|
171
171
|
innerHTML: v.value[s] || `<small>${e.$t("fileInput.noCaption")}</small>`
|
|
172
172
|
}, null, 8, ne))
|
|
173
|
-
], 64)) :
|
|
173
|
+
], 64)) : u("", !0)
|
|
174
174
|
]),
|
|
175
175
|
o("div", ae, [
|
|
176
176
|
o("button", {
|
|
177
|
-
onClick: g((
|
|
177
|
+
onClick: g((r) => V(s), ["prevent"]),
|
|
178
178
|
class: "btn btn--close"
|
|
179
179
|
}, [
|
|
180
|
-
|
|
180
|
+
p(l, { symbol: "x" })
|
|
181
181
|
], 8, ie),
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
c.editCaptions ? (i(), d("button", {
|
|
183
|
+
key: 0,
|
|
184
|
+
onClick: g((r) => H(s), ["prevent"]),
|
|
184
185
|
class: "btn btn--close"
|
|
185
186
|
}, [
|
|
186
|
-
|
|
187
|
+
p(l, {
|
|
187
188
|
symbol: f.value[s] ? "check" : "edit-3"
|
|
188
189
|
}, null, 8, ["symbol"])
|
|
189
|
-
], 8,
|
|
190
|
+
], 8, de)) : u("", !0)
|
|
190
191
|
])
|
|
191
192
|
])
|
|
192
193
|
])
|
|
193
194
|
]),
|
|
194
|
-
button:
|
|
195
|
+
button: B(() => [
|
|
195
196
|
S(e.$slots, "button", {}, () => [
|
|
196
|
-
o("span",
|
|
197
|
-
o("span",
|
|
198
|
-
|
|
197
|
+
o("span", re, [
|
|
198
|
+
o("span", ce, [
|
|
199
|
+
p(l, {
|
|
199
200
|
symbol: "upload",
|
|
200
201
|
size: "small"
|
|
201
202
|
}),
|
|
@@ -216,5 +217,5 @@ const K = { class: "container" }, j = { class: "row" }, q = {
|
|
|
216
217
|
}
|
|
217
218
|
});
|
|
218
219
|
export {
|
|
219
|
-
|
|
220
|
+
he as default
|
|
220
221
|
};
|