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