ablok-components 0.3.146 → 0.3.148
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.
- package/dist/ablok-components.css +1 -1
- package/dist/ablok-components.umd.js +2 -2
- package/dist/components/molecules/image-upload/image-upload.vue.d.ts +9 -0
- package/dist/components/molecules/image-upload/image-upload.vue_vue_type_script_setup_true_lang.js +99 -95
- package/dist/components/molecules/rte-editor/rte-editor.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/utilities/helpers.d.ts +12 -0
- package/dist/utilities/helpers.js +7 -2
- package/package.json +1 -1
|
@@ -94,6 +94,10 @@ declare const __VLS_base: import('../../../../vue/dist/vue.esm-bundler.js').Defi
|
|
|
94
94
|
type: NumberConstructor;
|
|
95
95
|
default: number;
|
|
96
96
|
};
|
|
97
|
+
convertSvg: {
|
|
98
|
+
type: BooleanConstructor;
|
|
99
|
+
default: boolean;
|
|
100
|
+
};
|
|
97
101
|
aspectRatio: NumberConstructor;
|
|
98
102
|
localUrlFormat: {
|
|
99
103
|
type: PropType<LocalUrlFormat>;
|
|
@@ -191,6 +195,10 @@ declare const __VLS_base: import('../../../../vue/dist/vue.esm-bundler.js').Defi
|
|
|
191
195
|
type: NumberConstructor;
|
|
192
196
|
default: number;
|
|
193
197
|
};
|
|
198
|
+
convertSvg: {
|
|
199
|
+
type: BooleanConstructor;
|
|
200
|
+
default: boolean;
|
|
201
|
+
};
|
|
194
202
|
aspectRatio: NumberConstructor;
|
|
195
203
|
localUrlFormat: {
|
|
196
204
|
type: PropType<LocalUrlFormat>;
|
|
@@ -222,6 +230,7 @@ declare const __VLS_base: import('../../../../vue/dist/vue.esm-bundler.js').Defi
|
|
|
222
230
|
localUrlFormat: LocalUrlFormat;
|
|
223
231
|
enableReview: boolean;
|
|
224
232
|
maxImageWidth: number;
|
|
233
|
+
convertSvg: boolean;
|
|
225
234
|
}, {}, {}, {}, string, import('../../../../vue/dist/vue.esm-bundler.js').ComponentProvideOptions, true, {}, any>;
|
|
226
235
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
227
236
|
declare const _default: typeof __VLS_export;
|
package/dist/components/molecules/image-upload/image-upload.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import e from "../../atoms/svg-icon/svg-icon.js";
|
|
2
2
|
import t from "../../atoms/base-image/base-image.js";
|
|
3
|
-
import { sanitizeHtml as
|
|
4
|
-
import { resizeImageFileByMaxWidth as
|
|
5
|
-
import
|
|
6
|
-
import { useDragAndDrop as
|
|
7
|
-
import { useUploadTransport as
|
|
8
|
-
import { useLocalFileUrl as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { Fragment as
|
|
3
|
+
import { sanitizeHtml as n } from "../../../composables/useSanitize.js";
|
|
4
|
+
import { convertSvgFileToPng as r, resizeImageFileByMaxWidth as i, srcToFile as ee, uniqueId as a } from "../../../utilities/helpers.js";
|
|
5
|
+
import o from "../../atoms/input-file/input-file.js";
|
|
6
|
+
import { useDragAndDrop as s } from "../../../composables/useDragAndDrop.js";
|
|
7
|
+
import { useUploadTransport as c } from "../../../composables/useUploadTransport.js";
|
|
8
|
+
import { useLocalFileUrl as l } from "../../../composables/useLocalFileUrl.js";
|
|
9
|
+
import u from "../image-crop-resize/image-crop-resize.js";
|
|
10
|
+
import d from "../../templates/modal-dialog/modal-dialog.js";
|
|
11
|
+
import { Fragment as f, Transition as p, computed as m, createBlock as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, createVNode as y, defineComponent as b, normalizeClass as x, normalizeStyle as S, onBeforeUnmount as C, openBlock as w, ref as T, renderSlot as E, toDisplayString as D, toRef as O, unref as k, watch as A, withCtx as j, withModifiers as M } from "vue";
|
|
12
12
|
//#region src/components/molecules/image-upload/image-upload.vue?vue&type=script&setup=true&lang.ts
|
|
13
|
-
var
|
|
13
|
+
var te = { class: "image-upload__controls" }, ne = { class: "d-flex gap-1 align-items-center" }, re = {
|
|
14
14
|
key: 1,
|
|
15
15
|
class: "image-upload__controls"
|
|
16
|
-
},
|
|
16
|
+
}, N = ["for"], P = ["innerHTML"], F = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "image-upload__loading-spinner"
|
|
19
|
-
},
|
|
19
|
+
}, I = /*@__PURE__*/ b({
|
|
20
20
|
__name: "image-upload",
|
|
21
21
|
props: {
|
|
22
22
|
modelValue: {
|
|
@@ -26,11 +26,11 @@ var ne = { class: "image-upload__controls" }, re = { class: "d-flex gap-1 align-
|
|
|
26
26
|
src: { type: String },
|
|
27
27
|
name: {
|
|
28
28
|
type: String,
|
|
29
|
-
default: () =>
|
|
29
|
+
default: () => a()
|
|
30
30
|
},
|
|
31
31
|
id: {
|
|
32
32
|
type: String,
|
|
33
|
-
default: () =>
|
|
33
|
+
default: () => a()
|
|
34
34
|
},
|
|
35
35
|
label: {
|
|
36
36
|
type: String,
|
|
@@ -105,6 +105,10 @@ var ne = { class: "image-upload__controls" }, re = { class: "d-flex gap-1 align-
|
|
|
105
105
|
type: Number,
|
|
106
106
|
default: 4096
|
|
107
107
|
},
|
|
108
|
+
convertSvg: {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
default: !1
|
|
111
|
+
},
|
|
108
112
|
aspectRatio: Number,
|
|
109
113
|
localUrlFormat: {
|
|
110
114
|
type: String,
|
|
@@ -112,110 +116,110 @@ var ne = { class: "image-upload__controls" }, re = { class: "d-flex gap-1 align-
|
|
|
112
116
|
}
|
|
113
117
|
},
|
|
114
118
|
emits: ["update:modelValue", "update:src"],
|
|
115
|
-
setup(
|
|
116
|
-
let
|
|
117
|
-
enabled: () =>
|
|
119
|
+
setup(a, { emit: b }) {
|
|
120
|
+
let I = a, L = b, R = T(), z = T([]), B = T(!1), V = T(!1), H = T(null), U = T(null), W = T(null), G = !1, { pending: K, uploadFile: q } = c(I), { toLocalUrl: J, revoke: Y } = l(O(I, "localUrlFormat")), { isDragging: ie } = s(R, {
|
|
121
|
+
enabled: () => I.dropFiles,
|
|
118
122
|
onDrop: (e) => {
|
|
119
|
-
|
|
123
|
+
z.value = e;
|
|
120
124
|
}
|
|
121
|
-
}), X =
|
|
125
|
+
}), X = m(() => I.modelValue ? I.modelValue : I.src ? {
|
|
122
126
|
type: "",
|
|
123
|
-
src:
|
|
124
|
-
} :
|
|
127
|
+
src: I.src
|
|
128
|
+
} : H.value);
|
|
125
129
|
function Z(e) {
|
|
126
|
-
|
|
130
|
+
Y(H.value?.src), H.value = e;
|
|
127
131
|
}
|
|
128
132
|
function Q() {
|
|
129
|
-
Z(null),
|
|
133
|
+
Z(null), z.value = [], B.value = !1, L("update:modelValue", void 0), L("update:src", "");
|
|
130
134
|
}
|
|
131
135
|
function $() {
|
|
132
136
|
Q();
|
|
133
137
|
}
|
|
134
|
-
|
|
138
|
+
A(() => z.value, async (e) => {
|
|
135
139
|
if (!e || !e.length || !e[0]) return;
|
|
136
|
-
|
|
137
|
-
let t = await
|
|
138
|
-
|
|
139
|
-
src: await
|
|
140
|
-
type:
|
|
141
|
-
},
|
|
142
|
-
src:
|
|
143
|
-
type:
|
|
140
|
+
B.value = !1;
|
|
141
|
+
let t = I.convertSvg ? await r(e[0], I.maxImageWidth) : e[0], n = await i(t, I.maxImageWidth);
|
|
142
|
+
I.enableReview ? (U.value = {
|
|
143
|
+
src: await J(n),
|
|
144
|
+
type: n.type
|
|
145
|
+
}, G = !0, V.value = !0) : Z({
|
|
146
|
+
src: I.toDataUrl ? await J(n) : await q(n),
|
|
147
|
+
type: n.type
|
|
144
148
|
});
|
|
145
|
-
}),
|
|
146
|
-
|
|
147
|
-
}),
|
|
149
|
+
}), A(() => H.value, (e) => {
|
|
150
|
+
L("update:modelValue", e || void 0), L("update:src", e?.src || "");
|
|
151
|
+
}), A(() => W.value, async (e) => {
|
|
148
152
|
if (e) {
|
|
149
153
|
try {
|
|
150
154
|
Z({
|
|
151
|
-
src:
|
|
155
|
+
src: I.toDataUrl ? await J(e) : await q(e),
|
|
152
156
|
type: e.type
|
|
153
157
|
});
|
|
154
158
|
} catch (t) {
|
|
155
159
|
console.error(`Failed to process file "${e.name}"`, t);
|
|
156
160
|
}
|
|
157
|
-
|
|
161
|
+
W.value = null;
|
|
158
162
|
}
|
|
159
|
-
}),
|
|
160
|
-
!e && t &&
|
|
161
|
-
}),
|
|
162
|
-
!e &&
|
|
163
|
+
}), A(() => V.value, (e, t) => {
|
|
164
|
+
!e && t && U.value && (G && (Y(U.value.src), $()), G = !1, U.value = null);
|
|
165
|
+
}), A(() => I.src, (e) => {
|
|
166
|
+
!e && H.value && $();
|
|
163
167
|
});
|
|
164
|
-
function
|
|
165
|
-
|
|
168
|
+
function ae(e, t) {
|
|
169
|
+
G = !1, U.value = {
|
|
166
170
|
src: e,
|
|
167
171
|
type: t
|
|
168
|
-
},
|
|
172
|
+
}, V.value = !0;
|
|
169
173
|
}
|
|
170
|
-
async function
|
|
171
|
-
|
|
174
|
+
async function oe() {
|
|
175
|
+
U.value && (W.value = await ee(U.value.src, "file", U.value.type), G && Y(U.value.src)), G = !1, U.value = null, V.value = !1;
|
|
172
176
|
}
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
}), (
|
|
177
|
+
return C(() => {
|
|
178
|
+
Y(H.value?.src);
|
|
179
|
+
}), (r, i) => (w(), _("div", {
|
|
176
180
|
ref_key: "root",
|
|
177
|
-
ref:
|
|
178
|
-
class:
|
|
179
|
-
"has-dragging":
|
|
180
|
-
"is-dragging":
|
|
181
|
+
ref: R,
|
|
182
|
+
class: x(["image-upload", {
|
|
183
|
+
"has-dragging": a.dropFiles,
|
|
184
|
+
"is-dragging": k(ie)
|
|
181
185
|
}])
|
|
182
186
|
}, [
|
|
183
|
-
!
|
|
187
|
+
!V.value && X.value ? (w(), _("div", {
|
|
184
188
|
key: 0,
|
|
185
|
-
class:
|
|
186
|
-
}, [
|
|
187
|
-
src: `${X.value.src}${
|
|
189
|
+
class: x(["mb-2", a.enablePreview ? "image-upload__thumbnail" : "image-upload__reset"])
|
|
190
|
+
}, [a.enablePreview ? (w(), _(f, { key: 0 }, [y(t, {
|
|
191
|
+
src: `${X.value.src}${a.previewWidth ? `?width=${a.previewWidth}` : ""}`,
|
|
188
192
|
class: "img-thumbnail rounded",
|
|
189
|
-
ready:
|
|
190
|
-
"onUpdate:ready":
|
|
193
|
+
ready: B.value,
|
|
194
|
+
"onUpdate:ready": i[0] ||= (e) => B.value = e,
|
|
191
195
|
animate: !1,
|
|
192
|
-
style:
|
|
193
|
-
maxWidth:
|
|
196
|
+
style: S({
|
|
197
|
+
maxWidth: a.previewWidth ? `${a.previewWidth}px` : "auto",
|
|
194
198
|
height: "auto"
|
|
195
199
|
})
|
|
196
200
|
}, null, 8, [
|
|
197
201
|
"src",
|
|
198
202
|
"ready",
|
|
199
203
|
"style"
|
|
200
|
-
]),
|
|
204
|
+
]), v("div", te, [v("div", ne, [v("button", {
|
|
201
205
|
type: "button",
|
|
202
|
-
onClick:
|
|
206
|
+
onClick: i[1] ||= M((e) => ae(X.value.src, X.value.type), ["prevent", "stop"]),
|
|
203
207
|
class: "btn btn--edit btn-sm btn-light"
|
|
204
|
-
}, [
|
|
208
|
+
}, [y(e, { symbol: "edit-2" })]), v("button", {
|
|
205
209
|
type: "button",
|
|
206
|
-
onClick:
|
|
210
|
+
onClick: i[2] ||= M((e) => Q(), ["prevent", "stop"]),
|
|
207
211
|
class: "btn btn--close btn-sm btn-light"
|
|
208
|
-
}, [
|
|
209
|
-
onClick:
|
|
212
|
+
}, [y(e, { symbol: "x" })])])])], 64)) : (w(), _("div", re, [v("button", {
|
|
213
|
+
onClick: i[3] ||= M((e) => Q(), ["prevent", "stop"]),
|
|
210
214
|
class: "btn btn--close btn-outline-contrast"
|
|
211
|
-
}, [
|
|
212
|
-
|
|
213
|
-
modelValue:
|
|
214
|
-
"onUpdate:modelValue":
|
|
215
|
-
id:
|
|
216
|
-
name:
|
|
217
|
-
accept:
|
|
218
|
-
"max-file-size":
|
|
215
|
+
}, [y(e, { symbol: "x" })])]))], 2)) : g("", !0),
|
|
216
|
+
y(o, {
|
|
217
|
+
modelValue: z.value,
|
|
218
|
+
"onUpdate:modelValue": i[4] ||= (e) => z.value = e,
|
|
219
|
+
id: a.id,
|
|
220
|
+
name: a.name,
|
|
221
|
+
accept: a.accept,
|
|
222
|
+
"max-file-size": a.maxFileSize,
|
|
219
223
|
class: "d-none"
|
|
220
224
|
}, null, 8, [
|
|
221
225
|
"modelValue",
|
|
@@ -224,41 +228,41 @@ var ne = { class: "image-upload__controls" }, re = { class: "d-flex gap-1 align-
|
|
|
224
228
|
"accept",
|
|
225
229
|
"max-file-size"
|
|
226
230
|
]),
|
|
227
|
-
|
|
231
|
+
a.src ? g("", !0) : (w(), _("label", {
|
|
228
232
|
key: 1,
|
|
229
|
-
for:
|
|
233
|
+
for: a.id,
|
|
230
234
|
class: "image-upload__label"
|
|
231
|
-
}, [
|
|
235
|
+
}, [E(r.$slots, "button", {}, () => [v("span", {
|
|
232
236
|
class: "btn btn-outline-contrast",
|
|
233
|
-
innerHTML:
|
|
234
|
-
}, null, 8,
|
|
235
|
-
default:
|
|
237
|
+
innerHTML: k(n)(a.label || r.$t("common.selectFile"))
|
|
238
|
+
}, null, 8, P)]), y(p, { name: "fade" }, {
|
|
239
|
+
default: j(() => [k(K) ? (w(), _("span", F, [...i[7] ||= [v("span", {
|
|
236
240
|
class: "spinner-border",
|
|
237
241
|
role: "status"
|
|
238
|
-
}, [
|
|
242
|
+
}, [v("span", { class: "visually-hidden" }, "Loading...")], -1)]])) : g("", !0)]),
|
|
239
243
|
_: 1
|
|
240
|
-
})], 8,
|
|
241
|
-
|
|
242
|
-
modelValue:
|
|
243
|
-
"onUpdate:modelValue":
|
|
244
|
+
})], 8, N)),
|
|
245
|
+
y(d, {
|
|
246
|
+
modelValue: V.value,
|
|
247
|
+
"onUpdate:modelValue": i[6] ||= (e) => V.value = e,
|
|
244
248
|
footer: !1
|
|
245
249
|
}, {
|
|
246
|
-
default:
|
|
250
|
+
default: j(() => [V.value && U.value ? (w(), h(u, {
|
|
247
251
|
key: 0,
|
|
248
|
-
modelValue:
|
|
249
|
-
"onUpdate:modelValue":
|
|
250
|
-
"aspect-ratio":
|
|
252
|
+
modelValue: U.value.src,
|
|
253
|
+
"onUpdate:modelValue": i[5] ||= (e) => U.value.src = e,
|
|
254
|
+
"aspect-ratio": a.aspectRatio
|
|
251
255
|
}, {
|
|
252
|
-
submit:
|
|
256
|
+
submit: j(() => [v("button", {
|
|
253
257
|
class: "btn btn-primary",
|
|
254
|
-
onClick:
|
|
255
|
-
},
|
|
258
|
+
onClick: M(oe, ["prevent", "stop"])
|
|
259
|
+
}, D(r.$t("common.save")), 1)]),
|
|
256
260
|
_: 1
|
|
257
|
-
}, 8, ["modelValue", "aspect-ratio"])) :
|
|
261
|
+
}, 8, ["modelValue", "aspect-ratio"])) : g("", !0)]),
|
|
258
262
|
_: 1
|
|
259
263
|
}, 8, ["modelValue"])
|
|
260
264
|
], 2));
|
|
261
265
|
}
|
|
262
266
|
});
|
|
263
267
|
//#endregion
|
|
264
|
-
export {
|
|
268
|
+
export { I as default };
|
package/dist/components/molecules/rte-editor/rte-editor.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -77,12 +77,12 @@ var g = {
|
|
|
77
77
|
name: "gradientText",
|
|
78
78
|
inclusive: !0,
|
|
79
79
|
parseHTML() {
|
|
80
|
-
return [{ tag: "span[class~=\"gradient
|
|
80
|
+
return [{ tag: "span[class~=\"text-gradient\"]" }];
|
|
81
81
|
},
|
|
82
82
|
renderHTML({ HTMLAttributes: e }) {
|
|
83
83
|
return [
|
|
84
84
|
"span",
|
|
85
|
-
n({ class: "gradient
|
|
85
|
+
n({ class: "text-gradient" }, e),
|
|
86
86
|
0
|
|
87
87
|
];
|
|
88
88
|
}
|
|
@@ -6,6 +6,18 @@ export declare function srcToFile(src: string, fileName: string, mimeType: strin
|
|
|
6
6
|
export declare function loadImageFromDataUrl(dataUrl: string): Promise<HTMLImageElement>;
|
|
7
7
|
export declare function resizeImageElementToDataUrl(img: HTMLImageElement, width: number, height: number, mimeType?: string, quality?: number): string;
|
|
8
8
|
export declare function resizeImageFileByMaxWidth(file: File, maxWidth: number, quality?: number): Promise<File>;
|
|
9
|
+
/**
|
|
10
|
+
* Converts an SVG file to a PNG file by rasterizing it on a canvas.
|
|
11
|
+
* Non-SVG files are returned unchanged.
|
|
12
|
+
*
|
|
13
|
+
* SVGs without intrinsic dimensions (naturalWidth === 0) are rasterized at
|
|
14
|
+
* `fallbackWidth` (square), so callers can control the output size.
|
|
15
|
+
* @param file - The file to convert
|
|
16
|
+
* @param fallbackWidth - Width used when the SVG has no intrinsic size
|
|
17
|
+
* @param quality - Optional PNG quality passed to canvas.toDataURL
|
|
18
|
+
* @returns A PNG File, or the original file if it is not an SVG
|
|
19
|
+
*/
|
|
20
|
+
export declare function convertSvgFileToPng(file: File, fallbackWidth?: number, quality?: number): Promise<File>;
|
|
9
21
|
/**
|
|
10
22
|
* Basic client-side input cleanup for user-entered text.
|
|
11
23
|
*
|
|
@@ -52,8 +52,13 @@ async function o(e, n, o) {
|
|
|
52
52
|
let d = Math.round(n), f = u / l;
|
|
53
53
|
return await r(a(c, d, Math.round(d * f), e.type || "image/png", o), e.name, e.type || "image/png");
|
|
54
54
|
}
|
|
55
|
-
function s(e) {
|
|
55
|
+
async function s(e, n = 1024, o) {
|
|
56
|
+
if ((e.type || "").toLowerCase() !== "image/svg+xml") return e;
|
|
57
|
+
let s = await i(await t(e));
|
|
58
|
+
return await r(a(s, s.naturalWidth || Math.round(n), s.naturalHeight || Math.round(n), "image/png", o), `${e.name.replace(/\.svg$/i, "")}.png`, "image/png");
|
|
59
|
+
}
|
|
60
|
+
function c(e) {
|
|
56
61
|
return !e || typeof e != "string" ? "" : e.replace(/\0/g, "").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/on\w+\s*=\s*["'][^"']*["']/gi, "").replace(/on\w+\s*=\s*[^\s>]*/gi, "").replace(/javascript:/gi, "").replace(/data:text\/html/gi, "");
|
|
57
62
|
}
|
|
58
63
|
//#endregion
|
|
59
|
-
export { t as fileToDataUrl, n as getExtensionFromMimeType, i as loadImageFromDataUrl, a as resizeImageElementToDataUrl, o as resizeImageFileByMaxWidth,
|
|
64
|
+
export { s as convertSvgFileToPng, t as fileToDataUrl, n as getExtensionFromMimeType, i as loadImageFromDataUrl, a as resizeImageElementToDataUrl, o as resizeImageFileByMaxWidth, c as sanitizeInput, r as srcToFile, e as uniqueId };
|