@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 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 x, createBlock as H, 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 J, vShow as K, withModifiers as P, createVNode as R, normalizeClass as U, mergeProps as T } from "vue";
2
- import { c as Q } from "../vendor/@vueuse/core/index.es.js";
3
- import { u as X } from "../plugins/WangsVue.es.js";
4
- import { m as Y } from "../utils/mergePropsWithDefaults.util.es.js";
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"], re = ["src", "onClick"], de = /* @__PURE__ */ W({
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 a = F, { defaultProps: N } = X("Image"), s = I(() => Y(a, N));
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 r.value == "string" && r.value.includes("blob") && URL.revokeObjectURL(r.value);
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(), C = d(), y = d(!1), h = [], V = I(() => {
40
+ const n = d(0), v = d(), U = d(), y = d(!1), h = [], V = I(() => {
39
41
  var e;
40
- return a.preview === !1 ? !1 : !y.value && !((e = r.value) != null && e.toString().includes("data:image/png;base64")) && r.value !== s.value.placeholder;
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 = a.galleries ?? [];
44
+ const e = t.galleries ?? [];
43
45
  n.value = (n.value + 1) % e.length, b();
44
46
  }, G = () => {
45
- const e = a.galleries ?? [];
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 = a.galleries) != null && e.length && (v.value = window.setInterval(() => {
50
- const t = a.galleries ?? [];
51
- n.value = (n.value + 1) % t.length;
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
- }, S = I(() => a.width != null ? a.width : a.size === "small" ? 30 : a.size === "medium" ? 80 : 125), r = Q(
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, t;
58
- if (!a.src || y.value) return s.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 = s.value).getImageURL) == null ? void 0 : t.call(e, a.src, S.value));
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 a.src;
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 t, o, l, u;
76
+ var a, o, l, c;
70
77
  if (p.value != null) return;
71
- let e = r.value;
78
+ let e = i.value;
72
79
  if (typeof e == "string") {
73
- const i = (o = (t = s.value).getImageURL) == null ? void 0 : o.call(
74
- t,
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
- ), c = typeof i == "string" && !(i != null && i.includes("undefined")) ? new URL(i).origin : "", B = c && e.includes(c) || // For getImageURL that return the image full url
80
- i instanceof Promise;
81
- e = e.includes("http") && !B || // From public resource
82
- e.includes("data:image/svg+xml") ? e : await ((u = (l = s.value).getImageURL) == null ? void 0 : u.call(l, a.src));
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), C.value ? window.clearTimeout(C.value) : window.setTimeout(_, 3e3);
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 t = (o = e.target) == null ? void 0 : o.src;
90
- (t === r.value || t.includes(r.value.toString())) && (y.value = !0);
91
- }, O = (e) => {
92
- var o, l, u;
93
- const t = e;
94
- return typeof t == "string" ? t.includes("http") ? t : (u = (l = (o = s.value).getImageURL) == null ? void 0 : l.call(o, t)) == null ? void 0 : u.toString() : t;
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 x(r, () => {
103
+ return H(i, () => {
97
104
  p.value = void 0;
98
- }), (e, t) => {
105
+ }), (e, a) => {
99
106
  var o;
100
- return m(), H($(ee), {
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: k(() => {
116
+ image: z(() => {
110
117
  var l;
111
118
  return [
112
- j("img", T((l = e.$preset.image) == null ? void 0 : l.image({ props: e.$props, context: { imageSize: S.value } }), {
113
- onerror: f,
114
- src: $(r),
115
- alt: ""
116
- }), null, 16, ae)
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: k(() => [
120
- R(te, T(e.$preset.image.icon, { icon: "eye" }), null, 16)
132
+ indicatoricon: z(() => [
133
+ S(te, T(e.$preset.image.icon, { icon: "eye" }), null, 16)
121
134
  ]),
122
- preview: k((l) => {
123
- var u;
135
+ preview: z((l) => {
136
+ var c;
124
137
  return [
125
- (u = e.galleries) != null && u.length ? (m(), g(L, { key: 1 }, [
126
- (m(!0), g(L, null, D(e.galleries, ({ src: i }, c) => J((m(), g("img", {
127
- key: c,
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: O(i),
130
- style: z(l.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
- [K, c === n.value]
147
+ [Q, u === n.value]
135
148
  ])), 128)),
136
- j("div", {
137
- onClick: t[0] || (t[0] = P(() => {
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
- R(E, {
143
- class: U([
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, D(e.galleries, ({ src: i }, c) => (m(), g("img", {
156
- key: c,
157
- class: U([
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 == c }
172
+ { "!opacity-100": n.value == u }
160
173
  ]),
161
174
  onerror: f,
162
- src: O(i),
163
- style: z(l.style),
164
- onClick: P((B) => b(c), ["stop"]),
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, re))), 128)),
168
- R(E, {
169
- class: U([
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: z(l.style),
198
+ style: k(l.style),
186
199
  alt: ""
187
200
  }, null, 12, oe))
188
201
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fewangsit/wangsvue-fats",
3
- "version": "1.0.1-alpha.64",
3
+ "version": "1.0.1-alpha.65",
4
4
  "author": "Wangsit FE Developer",
5
5
  "description": "Fixed Asset Tagsamurai VueJS Component Library",
6
6
  "type": "module",