@fewangsit/wangsvue-fats 1.0.1-alpha.36 → 1.0.1-alpha.38
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/image/index.d.ts +6 -3
- package/image/index.es.js +92 -80
- package/package.json +1 -1
- package/stats.html +1 -1
- package/wangsvue-fats.esm.browser.js +2675 -2663
- package/wangsvue-fats.system.js +42 -42
package/image/index.d.ts
CHANGED
|
@@ -271,21 +271,24 @@ export interface ImageProps {
|
|
|
271
271
|
unstyled?: boolean;
|
|
272
272
|
|
|
273
273
|
/**
|
|
274
|
-
* Returns the full image URL or a
|
|
274
|
+
* Returns the full image URL or a ObjetctURL from Blob for an image resource, based on the provided path and dimensions.
|
|
275
275
|
*
|
|
276
276
|
* If the image is publicly accessible, this typically returns a fully qualified URL.
|
|
277
|
-
* If the image requires authentication or protected access, this may return a
|
|
277
|
+
* If the image requires authentication or protected access, this may return a ObjetctURL from Blob (e.g., Base64-encoded).
|
|
278
278
|
*
|
|
279
279
|
* @param path - The image path as provided in the API response JSON. Can be null or undefined.
|
|
280
280
|
* @param width - Optional width of the image in pixels.
|
|
281
281
|
* @param height - Optional height of the image in pixels.
|
|
282
282
|
*
|
|
283
|
-
* @returns A string representing either the full image URL or a
|
|
283
|
+
* @returns A string representing either the full image URL or a ObjetctURL from Blob. Returns `undefined` if the path is invalid.
|
|
284
|
+
* @example res.blob().then((blob) => resolve(URL.createObjectURL(blob)))
|
|
285
|
+
*
|
|
284
286
|
*/
|
|
285
287
|
getImageURL?: (
|
|
286
288
|
path?: string | null,
|
|
287
289
|
width?: number,
|
|
288
290
|
height?: number,
|
|
291
|
+
returnURLOnly?: boolean, // Default is undefined or will return Promise when using Auth, when it manually sets to true, return the url only
|
|
289
292
|
) => string | undefined | Promise<string | undefined>;
|
|
290
293
|
|
|
291
294
|
/**
|
package/image/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { c as
|
|
3
|
-
import { u as
|
|
4
|
-
import { m as
|
|
5
|
-
import { s as
|
|
1
|
+
import { defineComponent as W, computed as I, onMounted as Z, onUnmounted as q, shallowRef as d, createBlock as x, openBlock as m, unref as $, withCtx as k, createElementBlock as g, normalizeStyle as z, Fragment as L, createElementVNode as j, renderList as D, withDirectives as H, vShow as J, withModifiers as P, createVNode as R, normalizeClass as U, mergeProps as T } from "vue";
|
|
2
|
+
import { c as K } from "../vendor/@vueuse/core/index.es.js";
|
|
3
|
+
import { u as Q } from "../plugins/WangsVue.es.js";
|
|
4
|
+
import { m as X } from "../utils/mergePropsWithDefaults.util.es.js";
|
|
5
|
+
import { s as Y } from "../vendor/primevue/image/image.esm.es.js";
|
|
6
6
|
import { _ as E } from "../button/index.es.js";
|
|
7
|
-
import { _ as
|
|
8
|
-
const
|
|
7
|
+
import { _ as ee } from "../icon/index.es.js";
|
|
8
|
+
const te = ["src"], ae = ["src"], oe = ["src"], le = ["src", "onClick"], ge = /* @__PURE__ */ W({
|
|
9
9
|
__name: "Image",
|
|
10
10
|
props: {
|
|
11
11
|
src: {},
|
|
@@ -26,111 +26,123 @@ const ee = ["src"], te = ["src"], ae = ["src"], re = ["src", "onClick"], me = /*
|
|
|
26
26
|
placeholder: {}
|
|
27
27
|
},
|
|
28
28
|
setup(F) {
|
|
29
|
-
const a = F, { defaultProps: N } =
|
|
30
|
-
|
|
29
|
+
const a = F, { defaultProps: N } = Q("Image"), i = I(() => X(a, N));
|
|
30
|
+
Z(() => {
|
|
31
31
|
setTimeout(() => {
|
|
32
|
-
|
|
32
|
+
_();
|
|
33
33
|
}, 3e3);
|
|
34
|
-
}),
|
|
35
|
-
|
|
34
|
+
}), q(() => {
|
|
35
|
+
h(), typeof n.value == "string" && n.value.includes("blob") && URL.revokeObjectURL(n.value);
|
|
36
|
+
for (const e of y) URL.revokeObjectURL(e);
|
|
36
37
|
});
|
|
37
|
-
const s = d(0), p = d(),
|
|
38
|
+
const s = d(0), p = d(), C = d(), f = d(!1), y = [], V = I(() => {
|
|
38
39
|
var e;
|
|
39
|
-
return a.preview === !1 ? !1 : !f.value && !((e =
|
|
40
|
-
}),
|
|
40
|
+
return a.preview === !1 ? !1 : !f.value && !((e = n.value) != null && e.toString().includes("data:image/png;base64")) && n.value !== i.value.placeholder;
|
|
41
|
+
}), A = () => {
|
|
41
42
|
const e = a.galleries ?? [];
|
|
42
|
-
s.value = (s.value + 1) % e.length,
|
|
43
|
-
},
|
|
43
|
+
s.value = (s.value + 1) % e.length, b();
|
|
44
|
+
}, G = () => {
|
|
44
45
|
const e = a.galleries ?? [];
|
|
45
|
-
s.value = (s.value - 1 + e.length) % e.length,
|
|
46
|
-
},
|
|
46
|
+
s.value = (s.value - 1 + e.length) % e.length, b();
|
|
47
|
+
}, _ = () => {
|
|
47
48
|
var e;
|
|
48
|
-
|
|
49
|
+
h(), (e = a.galleries) != null && e.length && (p.value = window.setInterval(() => {
|
|
49
50
|
const t = a.galleries ?? [];
|
|
50
51
|
s.value = (s.value + 1) % t.length;
|
|
51
52
|
}, 3e3));
|
|
52
|
-
},
|
|
53
|
+
}, h = () => {
|
|
53
54
|
p.value && (window.clearInterval(p.value), p.value = void 0);
|
|
54
|
-
},
|
|
55
|
+
}, S = I(() => a.width != null ? a.width : a.size === "small" ? 30 : a.size === "medium" ? 80 : 125), n = K(
|
|
55
56
|
async () => {
|
|
56
57
|
var e, t;
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
if (!a.src || f.value) return i.value.placeholder;
|
|
59
|
+
if (typeof a.src == "string") {
|
|
60
|
+
const o = a.src.includes("http") || // From public image or ObjectURL from Blob e.g 'blob:http://localhost:5173/ca48705d-1fc1-4a74-af38-353ffce7e02a'
|
|
61
|
+
/^data:image\/[a-zA-Z0-9.+-]+;base64,/.test(a.src) ? a.src : await ((t = (e = i.value).getImageURL) == null ? void 0 : t.call(e, a.src, S.value));
|
|
62
|
+
return typeof o == "string" && o.includes("blob") && y.push(o), o || i.value.placeholder;
|
|
63
|
+
}
|
|
64
|
+
return a.src;
|
|
59
65
|
},
|
|
60
66
|
i.value.placeholder
|
|
61
67
|
// Show placeholder while fetching image
|
|
62
|
-
),
|
|
63
|
-
var t,
|
|
64
|
-
if (
|
|
65
|
-
let e =
|
|
68
|
+
), w = d(), M = async () => {
|
|
69
|
+
var t, o, l, u;
|
|
70
|
+
if (w.value != null) return;
|
|
71
|
+
let e = n.value;
|
|
66
72
|
if (typeof e == "string") {
|
|
67
|
-
const
|
|
68
|
-
|
|
73
|
+
const r = (o = (t = i.value).getImageURL) == null ? void 0 : o.call(
|
|
74
|
+
t,
|
|
75
|
+
"preview",
|
|
76
|
+
void 0,
|
|
77
|
+
void 0,
|
|
78
|
+
!0
|
|
79
|
+
), c = typeof r == "string" && !(r != null && r.includes("undefined")) ? new URL(r).origin : "", B = c && e.includes(c) || // For getImageURL that return the image full url
|
|
80
|
+
r instanceof Promise;
|
|
69
81
|
e = e.includes("http") && !B || // From public resource
|
|
70
|
-
e.includes("data:image/svg+xml") ? e : await ((
|
|
82
|
+
e.includes("data:image/svg+xml") ? e : await ((u = (l = i.value).getImageURL) == null ? void 0 : u.call(l, a.src));
|
|
71
83
|
}
|
|
72
|
-
y.value = e || i.value.placeholder;
|
|
73
|
-
},
|
|
74
|
-
|
|
84
|
+
typeof e == "string" && e.includes("blob") && y.push(e), w.value = e || i.value.placeholder;
|
|
85
|
+
}, b = (e) => {
|
|
86
|
+
h(), typeof e == "number" && (s.value = e), C.value ? window.clearTimeout(C.value) : window.setTimeout(_, 3e3);
|
|
75
87
|
}, v = (e) => {
|
|
76
|
-
var
|
|
77
|
-
const t = (
|
|
78
|
-
(t ===
|
|
79
|
-
},
|
|
80
|
-
var
|
|
88
|
+
var o;
|
|
89
|
+
const t = (o = e.target) == null ? void 0 : o.src;
|
|
90
|
+
(t === n.value || t.includes(n.value.toString())) && (f.value = !0);
|
|
91
|
+
}, O = (e) => {
|
|
92
|
+
var o, l, u;
|
|
81
93
|
const t = e;
|
|
82
|
-
return typeof t == "string" ? t.includes("http") ? t : (
|
|
94
|
+
return typeof t == "string" ? t.includes("http") ? t : (u = (l = (o = i.value).getImageURL) == null ? void 0 : l.call(o, t)) == null ? void 0 : u.toString() : t;
|
|
83
95
|
};
|
|
84
96
|
return (e, t) => {
|
|
85
|
-
var
|
|
86
|
-
return
|
|
97
|
+
var o;
|
|
98
|
+
return m(), x($(Y), {
|
|
87
99
|
"image-class": e.imageClass,
|
|
88
100
|
"image-style": e.imageStyle,
|
|
89
101
|
preview: V.value,
|
|
90
|
-
pt: { root: (
|
|
102
|
+
pt: { root: (o = e.$preset.image) == null ? void 0 : o.root({ props: e.$props }) },
|
|
91
103
|
"zoom-in-disabled": e.zoomInDisabled,
|
|
92
104
|
"zoom-out-disabled": e.zoomOutDisabled,
|
|
93
|
-
onShow:
|
|
105
|
+
onShow: M
|
|
94
106
|
}, {
|
|
95
|
-
image:
|
|
96
|
-
var
|
|
107
|
+
image: k(() => {
|
|
108
|
+
var l;
|
|
97
109
|
return [
|
|
98
|
-
|
|
110
|
+
j("img", T((l = e.$preset.image) == null ? void 0 : l.image({ props: e.$props, context: { imageSize: S.value } }), {
|
|
99
111
|
onerror: v,
|
|
100
|
-
src:
|
|
112
|
+
src: $(n),
|
|
101
113
|
alt: ""
|
|
102
|
-
}), null, 16,
|
|
114
|
+
}), null, 16, te)
|
|
103
115
|
];
|
|
104
116
|
}),
|
|
105
|
-
indicatoricon:
|
|
106
|
-
|
|
117
|
+
indicatoricon: k(() => [
|
|
118
|
+
R(ee, T(e.$preset.image.icon, { icon: "eye" }), null, 16)
|
|
107
119
|
]),
|
|
108
|
-
preview:
|
|
109
|
-
var
|
|
120
|
+
preview: k((l) => {
|
|
121
|
+
var u;
|
|
110
122
|
return [
|
|
111
|
-
(
|
|
112
|
-
(
|
|
113
|
-
key:
|
|
123
|
+
(u = e.galleries) != null && u.length ? (m(), g(L, { key: 1 }, [
|
|
124
|
+
(m(!0), g(L, null, D(e.galleries, ({ src: r }, c) => H((m(), g("img", {
|
|
125
|
+
key: c,
|
|
114
126
|
onerror: v,
|
|
115
|
-
src:
|
|
116
|
-
style:
|
|
127
|
+
src: O(r),
|
|
128
|
+
style: z(l.style),
|
|
117
129
|
alt: "",
|
|
118
130
|
"data-wv-section": "image-gallery"
|
|
119
|
-
}, null, 12,
|
|
120
|
-
[
|
|
131
|
+
}, null, 12, oe)), [
|
|
132
|
+
[J, c === s.value]
|
|
121
133
|
])), 128)),
|
|
122
|
-
|
|
134
|
+
j("div", {
|
|
123
135
|
onClick: t[0] || (t[0] = P(() => {
|
|
124
136
|
}, ["stop"])),
|
|
125
137
|
class: "fixed bottom-0 left-0 flex justify-center items-center w-full p-4 mx-auto flex-row bg-black/80",
|
|
126
138
|
"data-wv-section": "gallery-thumbnail"
|
|
127
139
|
}, [
|
|
128
|
-
|
|
129
|
-
class:
|
|
140
|
+
R(E, {
|
|
141
|
+
class: U([
|
|
130
142
|
"text-surface-0 rotate-180 sticky left-0 !w-8 !h-8 [&_i]:w-5 [&_i]:h-5",
|
|
131
143
|
"rounded-full mr-3"
|
|
132
144
|
]),
|
|
133
|
-
onClick:
|
|
145
|
+
onClick: G,
|
|
134
146
|
"aria-label": "Previous Image",
|
|
135
147
|
"data-wv-section": "prev-button",
|
|
136
148
|
icon: "arrow-right",
|
|
@@ -138,25 +150,25 @@ const ee = ["src"], te = ["src"], ae = ["src"], re = ["src", "onClick"], me = /*
|
|
|
138
150
|
severity: "secondary",
|
|
139
151
|
text: ""
|
|
140
152
|
}),
|
|
141
|
-
(
|
|
142
|
-
key:
|
|
143
|
-
class:
|
|
153
|
+
(m(!0), g(L, null, D(e.galleries, ({ src: r }, c) => (m(), g("img", {
|
|
154
|
+
key: c,
|
|
155
|
+
class: U([
|
|
144
156
|
"h-10 w-10 object-cover cursor-pointer opacity-50 hover:opacity-100 transition-opacity",
|
|
145
|
-
{ "!opacity-100": s.value ==
|
|
157
|
+
{ "!opacity-100": s.value == c }
|
|
146
158
|
]),
|
|
147
159
|
onerror: v,
|
|
148
|
-
src:
|
|
149
|
-
style:
|
|
150
|
-
onClick: P((B) =>
|
|
160
|
+
src: O(r),
|
|
161
|
+
style: z(l.style),
|
|
162
|
+
onClick: P((B) => b(c), ["stop"]),
|
|
151
163
|
alt: "",
|
|
152
164
|
"data-wv-section": "thumbnail-image"
|
|
153
|
-
}, null, 14,
|
|
154
|
-
|
|
155
|
-
class:
|
|
165
|
+
}, null, 14, le))), 128)),
|
|
166
|
+
R(E, {
|
|
167
|
+
class: U([
|
|
156
168
|
"text-surface-0 sticky !w-8 !h-8 [&_i]:w-5 [&_i]:h-5",
|
|
157
169
|
"rounded-full ml-3"
|
|
158
170
|
]),
|
|
159
|
-
onClick:
|
|
171
|
+
onClick: A,
|
|
160
172
|
"aria-label": "Next Image",
|
|
161
173
|
"data-wv-section": "next-button",
|
|
162
174
|
icon: "arrow-right",
|
|
@@ -164,13 +176,13 @@ const ee = ["src"], te = ["src"], ae = ["src"], re = ["src", "onClick"], me = /*
|
|
|
164
176
|
text: ""
|
|
165
177
|
})
|
|
166
178
|
])
|
|
167
|
-
], 64)) : (
|
|
179
|
+
], 64)) : (m(), g("img", {
|
|
168
180
|
key: 0,
|
|
169
181
|
onerror: v,
|
|
170
|
-
src:
|
|
171
|
-
style:
|
|
182
|
+
src: w.value,
|
|
183
|
+
style: z(l.style),
|
|
172
184
|
alt: ""
|
|
173
|
-
}, null, 12,
|
|
185
|
+
}, null, 12, ae))
|
|
174
186
|
];
|
|
175
187
|
}),
|
|
176
188
|
_: 1
|
|
@@ -179,5 +191,5 @@ const ee = ["src"], te = ["src"], ae = ["src"], re = ["src", "onClick"], me = /*
|
|
|
179
191
|
}
|
|
180
192
|
});
|
|
181
193
|
export {
|
|
182
|
-
|
|
194
|
+
ge as _
|
|
183
195
|
};
|