@fewangsit/wangsvue-fats 1.0.1-alpha.64 → 1.0.1-alpha.65
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 +11 -0
- package/image/index.es.js +86 -73
- package/package.json +1 -1
- package/stats.html +1 -1
- package/wangsvue-fats.esm.browser.js +20 -7
- package/wangsvue-fats.system.js +1 -1
package/image/index.d.ts
CHANGED
|
@@ -296,6 +296,17 @@ export interface ImageProps {
|
|
|
296
296
|
* It should be preserved by project configuration.
|
|
297
297
|
*/
|
|
298
298
|
placeholder?: string | undefined;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Use default value for width and height if not specified. The default size is 125px.
|
|
302
|
+
* @defaultValue true
|
|
303
|
+
*/
|
|
304
|
+
useDefaultSize?: boolean;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The size of thumbnail image (in px) if props.width is undefined and props.useDefaultSize is false.
|
|
308
|
+
*/
|
|
309
|
+
thumbnailSize?: number;
|
|
299
310
|
}
|
|
300
311
|
|
|
301
312
|
/**
|
package/image/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as W, computed as I, onMounted as Z, onUnmounted as q, shallowRef as d, watch as
|
|
2
|
-
import { c as
|
|
3
|
-
import { u as
|
|
4
|
-
import { m as
|
|
1
|
+
import { defineComponent as W, computed as I, onMounted as Z, onUnmounted as q, shallowRef as d, watch as H, createBlock as J, openBlock as m, unref as D, withCtx as z, createElementBlock as g, normalizeStyle as k, Fragment as L, createElementVNode as $, renderList as j, withDirectives as K, vShow as Q, withModifiers as P, createVNode as S, normalizeClass as R, mergeProps as T } from "vue";
|
|
2
|
+
import { c as X } from "../vendor/@vueuse/core/index.es.js";
|
|
3
|
+
import { u as Y } from "../plugins/WangsVue.es.js";
|
|
4
|
+
import { m as x } from "../utils/mergePropsWithDefaults.util.es.js";
|
|
5
5
|
import { s as ee } from "../vendor/primevue/image/image.esm.es.js";
|
|
6
6
|
import { _ as E } from "../button/index.es.js";
|
|
7
7
|
import { _ as te } from "../icon/index.es.js";
|
|
8
|
-
const ae = ["src"], oe = ["src"], le = ["src"],
|
|
8
|
+
const ae = ["src"], oe = ["src"], le = ["src"], ie = ["src", "onClick"], de = /* @__PURE__ */ W({
|
|
9
9
|
__name: "Image",
|
|
10
10
|
props: {
|
|
11
11
|
src: {},
|
|
@@ -23,81 +23,88 @@ const ae = ["src"], oe = ["src"], le = ["src"], re = ["src", "onClick"], de = /*
|
|
|
23
23
|
ptOptions: {},
|
|
24
24
|
unstyled: { type: Boolean },
|
|
25
25
|
getImageURL: {},
|
|
26
|
-
placeholder: {}
|
|
26
|
+
placeholder: {},
|
|
27
|
+
useDefaultSize: { type: Boolean, default: !0 },
|
|
28
|
+
thumbnailSize: {}
|
|
27
29
|
},
|
|
28
30
|
setup(F) {
|
|
29
|
-
const
|
|
31
|
+
const t = F, { defaultProps: N } = Y("Image"), s = I(() => x(t, N));
|
|
30
32
|
Z(() => {
|
|
31
33
|
setTimeout(() => {
|
|
32
|
-
|
|
34
|
+
C();
|
|
33
35
|
}, 3e3);
|
|
34
36
|
}), q(() => {
|
|
35
|
-
w(), typeof
|
|
37
|
+
w(), typeof i.value == "string" && i.value.includes("blob") && URL.revokeObjectURL(i.value);
|
|
36
38
|
for (const e of h) URL.revokeObjectURL(e);
|
|
37
39
|
});
|
|
38
|
-
const n = d(0), v = d(),
|
|
40
|
+
const n = d(0), v = d(), U = d(), y = d(!1), h = [], V = I(() => {
|
|
39
41
|
var e;
|
|
40
|
-
return
|
|
42
|
+
return t.preview === !1 ? !1 : !y.value && !((e = i.value) != null && e.toString().includes("data:image/png;base64")) && i.value !== s.value.placeholder;
|
|
41
43
|
}), A = () => {
|
|
42
|
-
const e =
|
|
44
|
+
const e = t.galleries ?? [];
|
|
43
45
|
n.value = (n.value + 1) % e.length, b();
|
|
44
46
|
}, G = () => {
|
|
45
|
-
const e =
|
|
47
|
+
const e = t.galleries ?? [];
|
|
46
48
|
n.value = (n.value - 1 + e.length) % e.length, b();
|
|
47
|
-
},
|
|
49
|
+
}, C = () => {
|
|
48
50
|
var e;
|
|
49
|
-
w(), (e =
|
|
50
|
-
const
|
|
51
|
-
n.value = (n.value + 1) %
|
|
51
|
+
w(), (e = t.galleries) != null && e.length && (v.value = window.setInterval(() => {
|
|
52
|
+
const a = t.galleries ?? [];
|
|
53
|
+
n.value = (n.value + 1) % a.length;
|
|
52
54
|
}, 3e3));
|
|
53
55
|
}, w = () => {
|
|
54
56
|
v.value && (window.clearInterval(v.value), v.value = void 0);
|
|
55
|
-
},
|
|
57
|
+
}, _ = I(() => {
|
|
58
|
+
if (t.width != null) return t.width;
|
|
59
|
+
if (t.size === "small") return 30;
|
|
60
|
+
if (t.size === "medium") return 80;
|
|
61
|
+
if (t.useDefaultSize) return 125;
|
|
62
|
+
}), i = X(
|
|
56
63
|
async () => {
|
|
57
|
-
var e,
|
|
58
|
-
if (!
|
|
59
|
-
if (typeof
|
|
60
|
-
const o =
|
|
61
|
-
/^data:image\/[a-zA-Z0-9.+-]+;base64,/.test(
|
|
64
|
+
var e, a;
|
|
65
|
+
if (!t.src || y.value) return s.value.placeholder;
|
|
66
|
+
if (typeof t.src == "string") {
|
|
67
|
+
const o = t.src.includes("http") || // From public image or ObjectURL from Blob e.g 'blob:http://localhost:5173/ca48705d-1fc1-4a74-af38-353ffce7e02a'
|
|
68
|
+
/^data:image\/[a-zA-Z0-9.+-]+;base64,/.test(t.src) ? t.src : await ((a = (e = s.value).getImageURL) == null ? void 0 : a.call(e, t.src, _.value));
|
|
62
69
|
return typeof o == "string" && o.includes("blob") && h.push(o), o || s.value.placeholder;
|
|
63
70
|
}
|
|
64
|
-
return
|
|
71
|
+
return t.src;
|
|
65
72
|
},
|
|
66
73
|
s.value.placeholder
|
|
67
74
|
// Show placeholder while fetching image
|
|
68
75
|
), p = d(), M = async () => {
|
|
69
|
-
var
|
|
76
|
+
var a, o, l, c;
|
|
70
77
|
if (p.value != null) return;
|
|
71
|
-
let e =
|
|
78
|
+
let e = i.value;
|
|
72
79
|
if (typeof e == "string") {
|
|
73
|
-
const
|
|
74
|
-
|
|
80
|
+
const r = (o = (a = s.value).getImageURL) == null ? void 0 : o.call(
|
|
81
|
+
a,
|
|
75
82
|
"preview",
|
|
76
83
|
void 0,
|
|
77
84
|
void 0,
|
|
78
85
|
!0
|
|
79
|
-
),
|
|
80
|
-
|
|
81
|
-
e = e.includes("http") && !
|
|
82
|
-
e.includes("data:image/svg+xml") ? e : await ((
|
|
86
|
+
), u = typeof r == "string" && !(r != null && r.includes("undefined")) ? new URL(r).origin : "", O = u && e.includes(u) || // For getImageURL that return the image full url
|
|
87
|
+
r instanceof Promise;
|
|
88
|
+
e = e.includes("http") && !O || // From public resource
|
|
89
|
+
e.includes("data:image/svg+xml") ? e : await ((c = (l = s.value).getImageURL) == null ? void 0 : c.call(l, t.src));
|
|
83
90
|
}
|
|
84
91
|
typeof e == "string" && e.includes("blob") && h.push(e), p.value = e || s.value.placeholder;
|
|
85
92
|
}, b = (e) => {
|
|
86
|
-
w(), typeof e == "number" && (n.value = e),
|
|
93
|
+
w(), typeof e == "number" && (n.value = e), U.value ? window.clearTimeout(U.value) : window.setTimeout(C, 3e3);
|
|
87
94
|
}, f = (e) => {
|
|
88
95
|
var o;
|
|
89
|
-
const
|
|
90
|
-
(
|
|
91
|
-
},
|
|
92
|
-
var o, l,
|
|
93
|
-
const
|
|
94
|
-
return typeof
|
|
96
|
+
const a = (o = e.target) == null ? void 0 : o.src;
|
|
97
|
+
(a === i.value || a.includes(i.value.toString())) && (y.value = !0);
|
|
98
|
+
}, B = (e) => {
|
|
99
|
+
var o, l, c;
|
|
100
|
+
const a = e;
|
|
101
|
+
return typeof a == "string" ? a.includes("http") ? a : (c = (l = (o = s.value).getImageURL) == null ? void 0 : l.call(o, a)) == null ? void 0 : c.toString() : a;
|
|
95
102
|
};
|
|
96
|
-
return
|
|
103
|
+
return H(i, () => {
|
|
97
104
|
p.value = void 0;
|
|
98
|
-
}), (e,
|
|
105
|
+
}), (e, a) => {
|
|
99
106
|
var o;
|
|
100
|
-
return m(),
|
|
107
|
+
return m(), J(D(ee), {
|
|
101
108
|
"image-class": e.imageClass,
|
|
102
109
|
"image-style": e.imageStyle,
|
|
103
110
|
preview: V.value,
|
|
@@ -106,41 +113,47 @@ const ae = ["src"], oe = ["src"], le = ["src"], re = ["src", "onClick"], de = /*
|
|
|
106
113
|
"zoom-out-disabled": e.zoomOutDisabled,
|
|
107
114
|
onShow: M
|
|
108
115
|
}, {
|
|
109
|
-
image:
|
|
116
|
+
image: z(() => {
|
|
110
117
|
var l;
|
|
111
118
|
return [
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
$("img", T(
|
|
120
|
+
(l = e.$preset.image) == null ? void 0 : l.image({
|
|
121
|
+
props: e.$props,
|
|
122
|
+
context: { imageSize: _.value ?? e.thumbnailSize }
|
|
123
|
+
}),
|
|
124
|
+
{
|
|
125
|
+
onerror: f,
|
|
126
|
+
src: D(i),
|
|
127
|
+
alt: ""
|
|
128
|
+
}
|
|
129
|
+
), null, 16, ae)
|
|
117
130
|
];
|
|
118
131
|
}),
|
|
119
|
-
indicatoricon:
|
|
120
|
-
|
|
132
|
+
indicatoricon: z(() => [
|
|
133
|
+
S(te, T(e.$preset.image.icon, { icon: "eye" }), null, 16)
|
|
121
134
|
]),
|
|
122
|
-
preview:
|
|
123
|
-
var
|
|
135
|
+
preview: z((l) => {
|
|
136
|
+
var c;
|
|
124
137
|
return [
|
|
125
|
-
(
|
|
126
|
-
(m(!0), g(L, null,
|
|
127
|
-
key:
|
|
138
|
+
(c = e.galleries) != null && c.length ? (m(), g(L, { key: 1 }, [
|
|
139
|
+
(m(!0), g(L, null, j(e.galleries, ({ src: r }, u) => K((m(), g("img", {
|
|
140
|
+
key: u,
|
|
128
141
|
onerror: f,
|
|
129
|
-
src:
|
|
130
|
-
style:
|
|
142
|
+
src: B(r),
|
|
143
|
+
style: k(l.style),
|
|
131
144
|
alt: "",
|
|
132
145
|
"data-wv-section": "image-gallery"
|
|
133
146
|
}, null, 12, le)), [
|
|
134
|
-
[
|
|
147
|
+
[Q, u === n.value]
|
|
135
148
|
])), 128)),
|
|
136
|
-
|
|
137
|
-
onClick:
|
|
149
|
+
$("div", {
|
|
150
|
+
onClick: a[0] || (a[0] = P(() => {
|
|
138
151
|
}, ["stop"])),
|
|
139
152
|
class: "fixed bottom-0 left-0 flex justify-center items-center w-full p-4 mx-auto flex-row bg-black/80",
|
|
140
153
|
"data-wv-section": "gallery-thumbnail"
|
|
141
154
|
}, [
|
|
142
|
-
|
|
143
|
-
class:
|
|
155
|
+
S(E, {
|
|
156
|
+
class: R([
|
|
144
157
|
"text-surface-0 rotate-180 sticky left-0 !w-8 !h-8 [&_i]:w-5 [&_i]:h-5",
|
|
145
158
|
"rounded-full mr-3"
|
|
146
159
|
]),
|
|
@@ -152,21 +165,21 @@ const ae = ["src"], oe = ["src"], le = ["src"], re = ["src", "onClick"], de = /*
|
|
|
152
165
|
severity: "secondary",
|
|
153
166
|
text: ""
|
|
154
167
|
}),
|
|
155
|
-
(m(!0), g(L, null,
|
|
156
|
-
key:
|
|
157
|
-
class:
|
|
168
|
+
(m(!0), g(L, null, j(e.galleries, ({ src: r }, u) => (m(), g("img", {
|
|
169
|
+
key: u,
|
|
170
|
+
class: R([
|
|
158
171
|
"h-10 w-10 object-cover cursor-pointer opacity-50 hover:opacity-100 transition-opacity",
|
|
159
|
-
{ "!opacity-100": n.value ==
|
|
172
|
+
{ "!opacity-100": n.value == u }
|
|
160
173
|
]),
|
|
161
174
|
onerror: f,
|
|
162
|
-
src:
|
|
163
|
-
style:
|
|
164
|
-
onClick: P((
|
|
175
|
+
src: B(r),
|
|
176
|
+
style: k(l.style),
|
|
177
|
+
onClick: P((O) => b(u), ["stop"]),
|
|
165
178
|
alt: "",
|
|
166
179
|
"data-wv-section": "thumbnail-image"
|
|
167
|
-
}, null, 14,
|
|
168
|
-
|
|
169
|
-
class:
|
|
180
|
+
}, null, 14, ie))), 128)),
|
|
181
|
+
S(E, {
|
|
182
|
+
class: R([
|
|
170
183
|
"text-surface-0 sticky !w-8 !h-8 [&_i]:w-5 [&_i]:h-5",
|
|
171
184
|
"rounded-full ml-3"
|
|
172
185
|
]),
|
|
@@ -182,7 +195,7 @@ const ae = ["src"], oe = ["src"], le = ["src"], re = ["src", "onClick"], de = /*
|
|
|
182
195
|
key: 0,
|
|
183
196
|
onerror: f,
|
|
184
197
|
src: p.value,
|
|
185
|
-
style:
|
|
198
|
+
style: k(l.style),
|
|
186
199
|
alt: ""
|
|
187
200
|
}, null, 12, oe))
|
|
188
201
|
];
|