ablok-components 0.3.88 → 0.3.89

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