ablok-components 0.3.117 → 0.3.119

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.
@@ -10,13 +10,15 @@ declare var __VLS_1: {}, __VLS_20: {
10
10
  };
11
11
  index: number;
12
12
  };
13
- }, __VLS_33: {};
13
+ }, __VLS_33: {}, __VLS_35: {};
14
14
  type __VLS_Slots = {} & {
15
15
  'bulk-remove'?: (props: typeof __VLS_1) => any;
16
16
  } & {
17
17
  'upload-progress'?: (props: typeof __VLS_20) => any;
18
18
  } & {
19
19
  button?: (props: typeof __VLS_33) => any;
20
+ } & {
21
+ info?: (props: typeof __VLS_35) => any;
20
22
  };
21
23
  declare const __VLS_base: import('../../../../vue/dist/vue.esm-bundler.js').DefineComponent<import('../../../../vue/dist/vue.esm-bundler.js').ExtractPropTypes<{
22
24
  storeId: StringConstructor;
@@ -130,12 +132,29 @@ declare const __VLS_base: import('../../../../vue/dist/vue.esm-bundler.js').Defi
130
132
  type: NumberConstructor;
131
133
  default: number;
132
134
  };
135
+ minFiles: {
136
+ type: NumberConstructor;
137
+ default: number;
138
+ };
139
+ restrictRemoval: {
140
+ type: BooleanConstructor;
141
+ default: boolean;
142
+ };
133
143
  showProgress: {
134
144
  type: BooleanConstructor;
135
145
  default: boolean;
136
146
  };
147
+ valid: {
148
+ type: BooleanConstructor;
149
+ default: boolean;
150
+ };
151
+ validate: {
152
+ type: BooleanConstructor;
153
+ default: boolean;
154
+ };
137
155
  }>, {}, {}, {}, {}, import('../../../../vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, import('../../../../vue/dist/vue.esm-bundler.js').ComponentOptionsMixin, {
138
156
  "update:modelValue": (...args: any[]) => void;
157
+ "update:valid": (...args: any[]) => void;
139
158
  }, string, import('../../../../vue/dist/vue.esm-bundler.js').PublicProps, Readonly<import('../../../../vue/dist/vue.esm-bundler.js').ExtractPropTypes<{
140
159
  storeId: StringConstructor;
141
160
  id: {
@@ -248,12 +267,29 @@ declare const __VLS_base: import('../../../../vue/dist/vue.esm-bundler.js').Defi
248
267
  type: NumberConstructor;
249
268
  default: number;
250
269
  };
270
+ minFiles: {
271
+ type: NumberConstructor;
272
+ default: number;
273
+ };
274
+ restrictRemoval: {
275
+ type: BooleanConstructor;
276
+ default: boolean;
277
+ };
251
278
  showProgress: {
252
279
  type: BooleanConstructor;
253
280
  default: boolean;
254
281
  };
282
+ valid: {
283
+ type: BooleanConstructor;
284
+ default: boolean;
285
+ };
286
+ validate: {
287
+ type: BooleanConstructor;
288
+ default: boolean;
289
+ };
255
290
  }>> & Readonly<{
256
291
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
292
+ "onUpdate:valid"?: ((...args: any[]) => any) | undefined;
257
293
  }>, {
258
294
  size: number;
259
295
  title: string;
@@ -268,12 +304,16 @@ declare const __VLS_base: import('../../../../vue/dist/vue.esm-bundler.js').Defi
268
304
  uploadProgress?: number;
269
305
  }[];
270
306
  disabled: boolean;
307
+ validate: boolean;
308
+ valid: boolean;
271
309
  hasHeader: boolean;
272
310
  hasBulkRemove: boolean;
273
311
  hasCaptions: boolean;
274
312
  editCaptions: boolean;
275
313
  allowDuplicateFiles: boolean;
276
314
  maxFiles: number;
315
+ minFiles: number;
316
+ restrictRemoval: boolean;
277
317
  showProgress: boolean;
278
318
  }, {}, {}, {}, string, import('../../../../vue/dist/vue.esm-bundler.js').ComponentProvideOptions, true, {}, any>;
279
319
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,17 +1,21 @@
1
1
  import { sanitizeHtml as e } from "../../../composables/useSanitize.js";
2
2
  import t from "../file-upload/file-upload.js";
3
- import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, nextTick as l, normalizeClass as u, openBlock as d, ref as f, renderSlot as p, resolveComponent as m, toDisplayString as h, unref as g, vModelText as _, withCtx as v, withDirectives as y, withModifiers as b } from "vue";
3
+ import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, nextTick as l, normalizeClass as u, openBlock as d, ref as f, renderSlot as p, resolveComponent as m, toDisplayString as h, unref as g, vModelText as ee, watch as _, withCtx as v, withDirectives as te, withModifiers as y } from "vue";
4
+ import { useI18n as ne } from "vue-i18n";
4
5
  //#region src/components/molecules/bulk-upload/bulk-upload.vue?vue&type=script&setup=true&lang.ts
5
- var ee = { class: "container" }, te = { class: "row" }, x = {
6
+ var re = { class: "container-fluid" }, ie = { class: "row" }, ae = {
6
7
  key: 0,
7
8
  class: "col-12"
8
- }, S = { class: "py-4 px-3 d-flex align-items-center border border-bottom-0" }, C = ["innerHTML"], w = { class: "col-12" }, T = {
9
+ }, oe = { class: "py-4 px-3 d-flex align-items-center border border-bottom-0" }, se = ["innerHTML"], ce = { class: "col-12" }, le = {
9
10
  key: 0,
10
11
  class: "grid place-items-center text-center text-muted py-5 border border-bottom-0"
11
- }, E = { class: "m-0" }, D = { class: "preview-item border-bottom p-3" }, O = { class: "d-flex gap-3" }, k = { class: "col-2" }, A = { class: "col d-flex flex-column" }, j = { class: "file-meta text-muted small mb-2" }, M = { class: "fw-semibold" }, N = { key: 0 }, P = { key: 1 }, F = ["onUpdate:modelValue", "id"], I = ["innerHTML"], L = {
12
+ }, b = { class: "m-0" }, x = { class: "preview-item border-bottom p-3" }, S = { class: "d-flex gap-3" }, C = { class: "col-2" }, w = { class: "col d-flex flex-column" }, T = { class: "file-meta text-muted small mb-2" }, E = { class: "fw-semibold" }, D = { key: 0 }, O = { key: 1 }, k = ["onUpdate:modelValue", "id"], A = ["innerHTML"], j = {
12
13
  key: 2,
13
14
  class: "upload-progress mt-3 mb-0"
14
- }, R = ["value"], z = { class: "col-auto d-flex flex-column gap-2" }, B = ["onClick"], ne = ["onClick"], V = { class: "file-upload__label" }, H = { class: "d-flex align-items-end p-3" }, U = ["for"], W = ["innerHTML"], G = /*@__PURE__*/ c({
15
+ }, M = ["value"], N = { class: "col-auto d-flex flex-column gap-2" }, P = ["onClick"], F = ["onClick"], I = { class: "d-flex justify-content-between align-items-center" }, L = { class: "file-upload__info p-3" }, R = {
16
+ key: 0,
17
+ class: "text-muted small"
18
+ }, z = { class: "file-upload__label" }, ue = { class: "d-flex align-items-end p-3" }, B = ["for"], V = ["innerHTML"], H = /*@__PURE__*/ c({
15
19
  __name: "bulk-upload",
16
20
  props: {
17
21
  storeId: String,
@@ -60,17 +64,33 @@ var ee = { class: "container" }, te = { class: "row" }, x = {
60
64
  type: Number,
61
65
  default: 0
62
66
  },
67
+ minFiles: {
68
+ type: Number,
69
+ default: 0
70
+ },
71
+ restrictRemoval: {
72
+ type: Boolean,
73
+ default: !1
74
+ },
63
75
  showProgress: {
64
76
  type: Boolean,
65
77
  default: !0
78
+ },
79
+ valid: {
80
+ type: Boolean,
81
+ default: !0
82
+ },
83
+ validate: {
84
+ type: Boolean,
85
+ default: !0
66
86
  }
67
87
  },
68
- emits: ["update:modelValue"],
69
- setup(c, { emit: G }) {
70
- let K = c, q = G, J = (e) => `${e.name ?? ""}|${e.size ?? 0}|${e.lastModified ?? 0}|${e.type ?? ""}`, Y = r({
88
+ emits: ["update:modelValue", "update:valid"],
89
+ setup(c, { emit: H }) {
90
+ let U = c, W = H, { t: G } = ne(), K = (e) => `${e.name ?? ""}|${e.size ?? 0}|${e.lastModified ?? 0}|${e.type ?? ""}`, q = r({
71
91
  get: () => {
72
- let e = K.modelValue || [];
73
- return Q.value = e.map((e) => e.caption || ""), e.map((e) => ({
92
+ let e = U.modelValue || [];
93
+ return X.value = e.map((e) => e.caption || ""), e.map((e) => ({
74
94
  type: e.type,
75
95
  src: e.src,
76
96
  ...e.name ? { name: e.name } : {},
@@ -80,21 +100,42 @@ var ee = { class: "container" }, te = { class: "row" }, x = {
80
100
  }));
81
101
  },
82
102
  set: (e) => {
83
- let t = Y.value || [], n = Array.isArray(e) ? e : [], r = K.allowDuplicateFiles ? n : n.filter((e) => {
84
- let n = J(e);
85
- return !t.some((e) => J(e) === n);
86
- }), i = K.maxFiles > 0 ? Math.max(0, K.maxFiles - t.length) : void 0, a = typeof i == "number" ? r.slice(0, i) : r;
87
- !K.allowDuplicateFiles && n.length > 0 && a.length === 0 || (a.length <= t.length && a.every((e) => t.some((t) => t.src === e.src)) ? $(a) : $([...t, ...a]));
103
+ let t = q.value || [], n = Array.isArray(e) ? e : [], r = U.allowDuplicateFiles ? n : n.filter((e) => {
104
+ let n = K(e);
105
+ return !t.some((e) => K(e) === n);
106
+ }), i = U.maxFiles > 0 ? Math.max(0, U.maxFiles - t.length) : void 0, a = typeof i == "number" ? r.slice(0, i) : r;
107
+ !U.allowDuplicateFiles && n.length > 0 && a.length === 0 || (a.length <= t.length && a.every((e) => t.some((t) => t.src === e.src)) ? $(a) : $([...t, ...a]));
88
108
  }
89
- }), X = f(null), Z = f({}), Q = f({}), re = r(() => K.disabled || K.maxFiles > 0 && Y.value.length >= K.maxFiles);
90
- function ie(e) {
91
- let t = [...K.modelValue || []];
92
- t.splice(e, 1), q("update:modelValue", t);
109
+ }), J = f(null), Y = f({}), X = f({}), de = r(() => U.disabled || U.maxFiles > 0 && q.value.length >= U.maxFiles), Z = r(() => !U.restrictRemoval || U.minFiles <= 0 || q.value.length > U.minFiles), fe = r(() => !U.restrictRemoval || U.minFiles <= 0), pe = r(() => {
110
+ let e = q.value.length, t = U.minFiles <= 0 || e >= U.minFiles, n = U.maxFiles <= 0 || e <= U.maxFiles;
111
+ return t && n;
112
+ });
113
+ _(() => q.value.length, () => {
114
+ W("update:valid", pe.value);
115
+ });
116
+ let me = r(() => {
117
+ let e = q.value.length;
118
+ return U.minFiles > 0 && U.maxFiles > 0 ? G("fileInput.minMaxFiles", {
119
+ count: e,
120
+ min: U.minFiles,
121
+ max: U.maxFiles
122
+ }) : U.minFiles > 0 ? G("fileInput.minFiles", {
123
+ count: e,
124
+ min: U.minFiles
125
+ }) : G("fileInput.maxFiles", {
126
+ count: e,
127
+ max: U.maxFiles
128
+ });
129
+ });
130
+ function he(e) {
131
+ if (!Z.value) return;
132
+ let t = [...U.modelValue || []];
133
+ t.splice(e, 1), W("update:modelValue", t);
93
134
  }
94
- async function ae(e) {
95
- Z.value[e] = !Z.value[e], Z.value[e] || $(), await l(), (X.value?.querySelector(`#caption-${e}`))?.focus();
135
+ async function ge(e) {
136
+ Y.value[e] = !Y.value[e], Y.value[e] || $(), await l(), (J.value?.querySelector(`#caption-${e}`))?.focus();
96
137
  }
97
- function oe(e) {
138
+ function _e(e) {
98
139
  if (e == null) return "";
99
140
  let t = [
100
141
  "B",
@@ -106,32 +147,32 @@ var ee = { class: "container" }, te = { class: "row" }, x = {
106
147
  for (; n >= 1024 && t.length;) n /= 1024, r = t.shift();
107
148
  return `${n.toFixed(1)} ${r}`;
108
149
  }
109
- function se(e) {
150
+ function Q(e) {
110
151
  return e ? new Date(e).toLocaleDateString() : "";
111
152
  }
112
153
  function $(e) {
113
- q("update:modelValue", (e || Y.value).map((e, t) => ({
154
+ W("update:modelValue", (e || q.value).map((e, t) => ({
114
155
  ...e,
115
- caption: Q.value[t] || ""
156
+ caption: X.value[t] || ""
116
157
  })));
117
158
  }
118
159
  return (r, l) => {
119
- let f = m("svg-icon"), G = m("base-image");
160
+ let f = m("svg-icon"), _ = m("base-image");
120
161
  return d(), a("div", {
121
162
  class: "bulk-upload",
122
163
  ref_key: "root",
123
- ref: X
124
- }, [o("div", ee, [o("div", te, [c.hasHeader ? (d(), a("div", x, [o("div", S, [o("p", {
164
+ ref: J
165
+ }, [o("div", re, [o("div", ie, [c.hasHeader ? (d(), a("div", ae, [o("div", oe, [o("p", {
125
166
  class: "fw-bold m-0",
126
167
  innerHTML: g(e)(c.title || r.$t("fileInput.bulkUploadHeadline"))
127
- }, null, 8, C), p(r.$slots, "bulk-remove", {}, () => [c.hasBulkRemove ? (d(), a("button", {
168
+ }, null, 8, se), p(r.$slots, "bulk-remove", {}, () => [c.hasBulkRemove && fe.value ? (d(), a("button", {
128
169
  key: 0,
129
- onClick: l[0] ||= b((e) => Y.value = [], ["prevent"]),
170
+ onClick: l[0] ||= y((e) => q.value = [], ["prevent"]),
130
171
  class: "btn btn--close ms-auto p-0"
131
- }, [s(f, { symbol: "x" })])) : i("", !0)])])])) : i("", !0), o("div", w, [Y.value.length ? i("", !0) : (d(), a("div", T, [o("p", E, h(r.$t("fileInput.noFilesSelected")), 1)])), s(t, {
172
+ }, [s(f, { symbol: "x" })])) : i("", !0)])])])) : i("", !0), o("div", ce, [q.value.length ? i("", !0) : (d(), a("div", le, [o("p", b, h(r.$t("fileInput.noFilesSelected")), 1)])), s(t, {
132
173
  id: `${c.id}-file-upload`,
133
- modelValue: Y.value,
134
- "onUpdate:modelValue": l[2] ||= (e) => Y.value = e,
174
+ modelValue: q.value,
175
+ "onUpdate:modelValue": l[2] ||= (e) => q.value = e,
135
176
  multiple: !0,
136
177
  accept: "image/*",
137
178
  "drop-files": !0,
@@ -139,50 +180,51 @@ var ee = { class: "container" }, te = { class: "row" }, x = {
139
180
  "local-url-format": "objectUrl",
140
181
  class: "d-flex flex-column border"
141
182
  }, {
142
- "preview-item": v(({ bind: { item: e, index: t } }) => [o("div", D, [o("div", O, [
143
- o("div", k, [s(G, {
183
+ "preview-item": v(({ bind: { item: e, index: t } }) => [o("div", x, [o("div", S, [
184
+ o("div", C, [s(_, {
144
185
  src: e.src,
145
186
  alt: "",
146
187
  class: "img-thumbnail"
147
188
  }, null, 8, ["src"])]),
148
- o("div", A, [o("div", j, [o("div", M, h(e.name || r.$t("fileInput.unknownFile")), 1), o("div", null, [e.size ? (d(), a("span", N, h(oe(e.size)), 1)) : i("", !0), e.lastModified ? (d(), a("span", P, " · " + h(se(e.lastModified)), 1)) : i("", !0)])]), c.hasCaptions ? (d(), a(n, { key: 0 }, [Z.value[t] && c.editCaptions ? y((d(), a("textarea", {
189
+ o("div", w, [o("div", T, [o("div", E, h(e.name || r.$t("fileInput.unknownFile")), 1), o("div", null, [e.size ? (d(), a("span", D, h(_e(e.size)), 1)) : i("", !0), e.lastModified ? (d(), a("span", O, " · " + h(Q(e.lastModified)), 1)) : i("", !0)])]), c.hasCaptions ? (d(), a(n, { key: 0 }, [Y.value[t] && c.editCaptions ? te((d(), a("textarea", {
149
190
  key: 0,
150
- "onUpdate:modelValue": (e) => Q.value[t] = e,
191
+ "onUpdate:modelValue": (e) => X.value[t] = e,
151
192
  id: `caption-${t}`,
152
193
  class: "form-control rounded-0 h-100",
153
194
  onChangeCapture: l[1] ||= (e) => $()
154
- }, null, 40, F)), [[_, Q.value[t]]]) : (d(), a("p", {
195
+ }, null, 40, k)), [[ee, X.value[t]]]) : (d(), a("p", {
155
196
  key: 1,
156
197
  class: "m-0",
157
- innerHTML: Q.value[t] || `<small>${r.$t("fileInput.noCaption")}</small>`
158
- }, null, 8, I)), c.showProgress && e.uploadProgress ? (d(), a("div", L, [p(r.$slots, "upload-progress", { bind: {
198
+ innerHTML: X.value[t] || `<small>${r.$t("fileInput.noCaption")}</small>`
199
+ }, null, 8, A)), c.showProgress && e.uploadProgress ? (d(), a("div", j, [p(r.$slots, "upload-progress", { bind: {
159
200
  item: e,
160
201
  index: t
161
202
  } }, () => [o("progress", {
162
203
  value: e.uploadProgress,
163
204
  max: "100",
164
205
  class: "w-100"
165
- }, null, 8, R)])])) : i("", !0)], 64)) : i("", !0)]),
166
- o("div", z, [o("button", {
167
- onClick: b((e) => ie(t), ["prevent"]),
168
- class: "btn btn--close"
169
- }, [s(f, { symbol: "x" })], 8, B), c.editCaptions ? (d(), a("button", {
206
+ }, null, 8, M)])])) : i("", !0)], 64)) : i("", !0)]),
207
+ o("div", N, [Z.value ? (d(), a("button", {
170
208
  key: 0,
171
- onClick: b((e) => ae(t), ["prevent"]),
209
+ onClick: y((e) => he(t), ["prevent"]),
210
+ class: "btn btn--close"
211
+ }, [s(f, { symbol: "x" })], 8, P)) : i("", !0), c.editCaptions ? (d(), a("button", {
212
+ key: 1,
213
+ onClick: y((e) => ge(t), ["prevent"]),
172
214
  class: "btn btn--close"
173
- }, [s(f, { symbol: Z.value[t] ? "check" : "edit-3" }, null, 8, ["symbol"])], 8, ne)) : i("", !0)])
215
+ }, [s(f, { symbol: Y.value[t] ? "check" : "edit-3" }, null, 8, ["symbol"])], 8, F)) : i("", !0)])
174
216
  ])])]),
175
- label: v(() => [p(r.$slots, "button", {}, () => [o("span", V, [o("span", H, [o("label", {
217
+ label: v(() => [p(r.$slots, "button", {}, () => [o("span", I, [o("span", L, [p(r.$slots, "info", {}, () => [c.maxFiles > 0 || c.minFiles > 0 ? (d(), a("span", R, h(me.value), 1)) : i("", !0)])]), o("span", z, [o("span", ue, [o("label", {
176
218
  for: `${c.id}-file-upload`,
177
- class: u(["btn btn-primary btn-sm ms-auto d-flex align-items-center gap-2", { disabled: re.value }])
219
+ class: u(["btn btn-primary btn-sm ms-auto d-flex align-items-center gap-2", { disabled: de.value }])
178
220
  }, [s(f, {
179
221
  symbol: "upload",
180
222
  size: "small"
181
- }), o("span", { innerHTML: r.$t("common.selectFile") }, null, 8, W)], 10, U)])])])]),
223
+ }), o("span", { innerHTML: r.$t("common.selectFile") }, null, 8, V)], 10, B)])])])])]),
182
224
  _: 3
183
225
  }, 8, ["id", "modelValue"])])])])], 512);
184
226
  };
185
227
  }
186
228
  });
187
229
  //#endregion
188
- export { G as default };
230
+ export { H as default };
@@ -157,7 +157,7 @@ var ne = { class: "image-upload__controls" }, re = { class: "d-flex gap-1 align-
157
157
  U.value = null;
158
158
  }
159
159
  }), O(() => B.value, (e, t) => {
160
- !e && t && H.value && (W && J(H.value.src), W = !1, H.value = null, $());
160
+ !e && t && H.value && (W && (J(H.value.src), $()), W = !1, H.value = null);
161
161
  }), O(() => F.src, (e) => {
162
162
  !e && V.value && $();
163
163
  });
package/dist/i18n.d.ts CHANGED
@@ -99,6 +99,10 @@ declare const i18n: import('vue-i18n').I18n<{
99
99
  noFilesSelected: string;
100
100
  noCaption: string;
101
101
  bulkUploadHeadline: string;
102
+ maxFiles: string;
103
+ minFiles: string;
104
+ minMaxFiles: string;
105
+ unlimitedFiles: string;
102
106
  };
103
107
  editor: {
104
108
  header: {
@@ -98,6 +98,10 @@ export declare const messages: {
98
98
  noFilesSelected: string;
99
99
  noCaption: string;
100
100
  bulkUploadHeadline: string;
101
+ maxFiles: string;
102
+ minFiles: string;
103
+ minMaxFiles: string;
104
+ unlimitedFiles: string;
101
105
  };
102
106
  editor: {
103
107
  header: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ablok-components",
3
3
  "private": false,
4
- "version": "0.3.117",
4
+ "version": "0.3.119",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "@tiptap/core": "^3.30.0",