ablok-components 0.3.79 → 0.3.80

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.
@@ -3,6 +3,13 @@ import { LocalUrlFormat } from '../../../composables/useLocalFileUrl';
3
3
  declare function __VLS_template(): {
4
4
  attrs: Partial<{}>;
5
5
  slots: {
6
+ 'preview-item'?(_: {
7
+ url: {
8
+ type?: string;
9
+ src?: string;
10
+ };
11
+ index: number;
12
+ }): any;
6
13
  button?(_: {}): any;
7
14
  };
8
15
  refs: {
@@ -1,16 +1,16 @@
1
- import { defineComponent as A, ref as f, toRef as L, computed as N, watch as b, openBlock as s, createElementBlock as u, normalizeClass as h, unref as y, Fragment as V, renderList as P, createElementVNode as d, withModifiers as S, createVNode as m, renderSlot as T, Transition as M, withCtx as _, createCommentVNode as H } from "vue";
1
+ import { defineComponent as L, ref as f, toRef as N, computed as P, watch as b, openBlock as u, createElementBlock as d, normalizeClass as h, unref as y, Fragment as V, renderList as T, renderSlot as S, createElementVNode as c, withModifiers as w, createVNode as p, Transition as M, withCtx as H, createCommentVNode as W } from "vue";
2
2
  import k from "../../atoms/svg-icon/svg-icon.vue.js";
3
3
  /* empty css */
4
- import W from "../../atoms/input-file/input-file.vue.js";
5
- import { useDragAndDrop as q } from "../../../composables/useDragAndDrop.js";
6
- import { useUploadTransport as x } from "../../../composables/useUploadTransport.js";
7
- import { useLocalFileUrl as E } from "../../../composables/useLocalFileUrl.js";
8
- import { sanitizeHtml as I } from "../../../composables/useSanitize.js";
9
- import { uniqueId as w } from "../../../utilities/helpers.js";
10
- const R = ["src"], O = ["onClick"], j = ["onClick"], G = ["for"], J = ["innerHTML"], K = {
4
+ import q from "../../atoms/input-file/input-file.vue.js";
5
+ import { useDragAndDrop as E } from "../../../composables/useDragAndDrop.js";
6
+ import { useUploadTransport as I } from "../../../composables/useUploadTransport.js";
7
+ import { useLocalFileUrl as R } from "../../../composables/useLocalFileUrl.js";
8
+ import { sanitizeHtml as O } from "../../../composables/useSanitize.js";
9
+ import { uniqueId as F } from "../../../utilities/helpers.js";
10
+ const _ = ["src"], j = ["onClick"], x = ["onClick"], G = ["for"], J = ["innerHTML"], K = {
11
11
  key: 0,
12
12
  class: "file-upload__loading-spinner"
13
- }, oe = /* @__PURE__ */ A({
13
+ }, ne = /* @__PURE__ */ L({
14
14
  __name: "file-upload",
15
15
  props: {
16
16
  modelValue: {
@@ -22,11 +22,11 @@ const R = ["src"], O = ["onClick"], j = ["onClick"], G = ["for"], J = ["innerHTM
22
22
  },
23
23
  name: {
24
24
  type: String,
25
- default: () => w()
25
+ default: () => F()
26
26
  },
27
27
  id: {
28
28
  type: String,
29
- default: () => w()
29
+ default: () => F()
30
30
  },
31
31
  label: {
32
32
  type: String,
@@ -102,96 +102,102 @@ const R = ["src"], O = ["onClick"], j = ["onClick"], G = ["for"], J = ["innerHTM
102
102
  }
103
103
  },
104
104
  emits: ["update:modelValue", "update:src"],
105
- setup(a, { emit: F }) {
106
- const e = a, i = F, v = f(), c = f([]), o = f([]), { pending: U, uploadFile: B } = x(e), { toLocalUrl: D, revoke: $ } = E(L(e, "localUrlFormat")), { isDragging: C } = q(v, {
105
+ setup(a, { emit: U }) {
106
+ const e = a, i = U, v = f(), m = f([]), n = f([]), { pending: $, uploadFile: B } = I(e), { toLocalUrl: D, revoke: C } = R(N(e, "localUrlFormat")), { isDragging: z } = E(v, {
107
107
  enabled: () => e.dropFiles,
108
108
  onDrop: (t) => {
109
- c.value = t;
109
+ m.value = t;
110
110
  }
111
- }), z = N(() => e.modelValue?.length ? e.modelValue : e.src ? [{ type: "", src: e.src }] : o.value);
111
+ }), A = P(() => e.modelValue?.length ? e.modelValue : e.src ? [{ type: "", src: e.src }] : n.value);
112
112
  function g(t) {
113
- const l = typeof t == "string" ? parseInt(t, 10) : t, n = Array.isArray(e.modelValue) && e.modelValue.length > 0, p = Array.isArray(o.value) && o.value.length > 0;
114
- if (p && l < o.value.length && ($(o.value[l]?.src), o.value.splice(l, 1)), n) {
115
- const r = [...e.modelValue];
116
- l < r.length && r.splice(l, 1), i("update:modelValue", r), e.multiple || i("update:src", r[0]?.src || "");
117
- } else if (p) {
118
- const r = e.multiple ? o.value : o.value[0];
119
- i("update:modelValue", r), e.multiple || i("update:src", o.value[0]?.src || "");
113
+ const l = typeof t == "string" ? parseInt(t, 10) : t, o = Array.isArray(e.modelValue) && e.modelValue.length > 0, r = Array.isArray(n.value) && n.value.length > 0;
114
+ if (r && l < n.value.length && (C(n.value[l]?.src), n.value.splice(l, 1)), o) {
115
+ const s = [...e.modelValue];
116
+ l < s.length && s.splice(l, 1), i("update:modelValue", s), e.multiple || i("update:src", s[0]?.src || "");
117
+ } else if (r) {
118
+ const s = e.multiple ? n.value : n.value[0];
119
+ i("update:modelValue", s), e.multiple || i("update:src", n.value[0]?.src || "");
120
120
  } else
121
121
  i("update:modelValue", e.multiple ? [] : void 0), i("update:src", "");
122
- c.value.splice(l, 1);
122
+ m.value.splice(l, 1);
123
123
  }
124
- return b(() => c.value, async (t) => {
124
+ return b(() => m.value, async (t) => {
125
125
  const l = await Promise.all(
126
- t.map(async (n) => ({
127
- src: e.toDataUrl ? await D(n) : await B(n),
128
- type: n.type
126
+ t.map(async (o) => ({
127
+ src: e.toDataUrl ? await D(o) : await B(o),
128
+ type: o.type
129
129
  }))
130
130
  );
131
- o.value = l.filter((n) => n !== null);
132
- }, { deep: !0 }), b(() => o.value, async (t) => {
131
+ n.value = l.filter((o) => o !== null);
132
+ }, { deep: !0 }), b(() => n.value, async (t) => {
133
133
  const l = e.multiple ? t : t[0];
134
134
  i("update:modelValue", l), e.multiple || i("update:src", t[0] && t[0].src);
135
- }, { deep: !0 }), (t, l) => (s(), u("div", {
135
+ }, { deep: !0 }), (t, l) => (u(), d("div", {
136
136
  ref_key: "root",
137
137
  ref: v,
138
138
  class: h(["file-upload", {
139
139
  "has-dragging": a.dropFiles,
140
- "is-dragging": y(C)
140
+ "is-dragging": y(z)
141
141
  }])
142
142
  }, [
143
- (s(!0), u(V, null, P(z.value, (n, p) => (s(), u("div", {
144
- key: n.src,
143
+ (u(!0), d(V, null, T(A.value, (o, r) => (u(), d("div", {
144
+ key: o.src,
145
145
  class: h(a.enablePreview ? "file-upload__thumbnail" : "file-upload__reset")
146
146
  }, [
147
- a.enablePreview ? (s(), u(V, { key: 0 }, [
148
- d("img", {
149
- src: `${n.src}${a.previewWidth ? `?width=${a.previewWidth}` : ""}`,
150
- class: "img-thumbnail rounded"
151
- }, null, 8, R),
152
- d("button", {
153
- onClick: S((r) => g(p), ["prevent"]),
154
- class: "btn btn--close"
147
+ S(t.$slots, "preview-item", {
148
+ url: o,
149
+ index: r
150
+ }, () => [
151
+ a.enablePreview ? (u(), d(V, { key: 0 }, [
152
+ c("img", {
153
+ src: `${o.src}${a.previewWidth ? `?width=${a.previewWidth}` : ""}`,
154
+ class: "img-thumbnail rounded"
155
+ }, null, 8, _),
156
+ c("button", {
157
+ onClick: w((s) => g(r), ["prevent"]),
158
+ class: "btn btn--close"
159
+ }, [
160
+ p(k, { symbol: "x" })
161
+ ], 8, j)
162
+ ], 64)) : (u(), d("button", {
163
+ key: 1,
164
+ onClick: w((s) => g(r), ["prevent"]),
165
+ class: "btn btn--close btn-outline-contrast"
155
166
  }, [
156
- m(k, { symbol: "x" })
157
- ], 8, O)
158
- ], 64)) : (s(), u("button", {
159
- key: 1,
160
- onClick: S((r) => g(p), ["prevent"]),
161
- class: "btn btn--close btn-outline-contrast"
162
- }, [
163
- m(k, { symbol: "x" })
164
- ], 8, j))
167
+ p(k, { symbol: "x" })
168
+ ], 8, x))
169
+ ])
165
170
  ], 2))), 128)),
166
- m(W, {
167
- modelValue: c.value,
168
- "onUpdate:modelValue": l[0] || (l[0] = (n) => c.value = n),
171
+ p(q, {
172
+ modelValue: m.value,
173
+ "onUpdate:modelValue": l[0] || (l[0] = (o) => m.value = o),
169
174
  id: a.id,
170
175
  name: a.name,
171
176
  accept: a.accept,
172
177
  "max-file-size": a.maxFileSize,
178
+ multiple: a.multiple,
173
179
  class: "d-none"
174
- }, null, 8, ["modelValue", "id", "name", "accept", "max-file-size"]),
175
- d("label", {
180
+ }, null, 8, ["modelValue", "id", "name", "accept", "max-file-size", "multiple"]),
181
+ c("label", {
176
182
  for: a.id,
177
183
  class: "file-upload__label"
178
184
  }, [
179
- T(t.$slots, "button", {}, () => [
180
- d("span", {
185
+ S(t.$slots, "button", {}, () => [
186
+ c("span", {
181
187
  class: "btn btn-outline-contrast",
182
- innerHTML: y(I)(a.label || t.$t("common.selectFile"))
188
+ innerHTML: y(O)(a.label || t.$t("common.selectFile"))
183
189
  }, null, 8, J)
184
190
  ]),
185
- m(M, { name: "fade" }, {
186
- default: _(() => [
187
- y(U) ? (s(), u("span", K, [...l[1] || (l[1] = [
188
- d("span", {
191
+ p(M, { name: "fade" }, {
192
+ default: H(() => [
193
+ y($) ? (u(), d("span", K, [...l[1] || (l[1] = [
194
+ c("span", {
189
195
  class: "spinner-border",
190
196
  role: "status"
191
197
  }, [
192
- d("span", { class: "visually-hidden" }, "Loading...")
198
+ c("span", { class: "visually-hidden" }, "Loading...")
193
199
  ], -1)
194
- ])])) : H("", !0)
200
+ ])])) : W("", !0)
195
201
  ]),
196
202
  _: 1
197
203
  })
@@ -200,5 +206,5 @@ const R = ["src"], O = ["onClick"], j = ["onClick"], G = ["for"], J = ["innerHTM
200
206
  }
201
207
  });
202
208
  export {
203
- oe as default
209
+ ne as default
204
210
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ablok-components",
3
3
  "private": false,
4
- "version": "0.3.79",
4
+ "version": "0.3.80",
5
5
  "scripts": {
6
6
  "dev": "vite --host",
7
7
  "story:dev": "histoire dev",