@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 CHANGED
@@ -271,21 +271,24 @@ export interface ImageProps {
271
271
  unstyled?: boolean;
272
272
 
273
273
  /**
274
- * Returns the full image URL or a Data URI for an image resource, based on the provided path and dimensions.
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 Data URI (e.g., Base64-encoded).
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 Data URI. Returns `undefined` if the path is invalid.
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 M, computed as I, onMounted as W, onUnmounted as Z, shallowRef as d, createBlock as q, openBlock as u, unref as D, withCtx as b, createElementBlock as g, normalizeStyle as k, Fragment as z, createElementVNode as $, renderList as O, withDirectives as x, vShow as H, withModifiers as P, createVNode as C, normalizeClass as _, mergeProps as T } from "vue";
2
- import { c as J } from "../vendor/@vueuse/core/index.es.js";
3
- import { u as K } from "../plugins/WangsVue.es.js";
4
- import { m as Q } from "../utils/mergePropsWithDefaults.util.es.js";
5
- import { s as X } from "../vendor/primevue/image/image.esm.es.js";
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 Y } from "../icon/index.es.js";
8
- const ee = ["src"], te = ["src"], ae = ["src"], re = ["src", "onClick"], me = /* @__PURE__ */ M({
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 } = K("Image"), i = I(() => Q(a, N));
30
- W(() => {
29
+ const a = F, { defaultProps: N } = Q("Image"), i = I(() => X(a, N));
30
+ Z(() => {
31
31
  setTimeout(() => {
32
- L();
32
+ _();
33
33
  }, 3e3);
34
- }), Z(() => {
35
- w();
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(), S = d(), f = d(!1), V = I(() => {
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 = m.value) != null && e.toString().includes("data:image/png;base64")) && m.value !== i.value.placeholder;
40
- }), j = () => {
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, h();
43
- }, A = () => {
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, h();
46
- }, L = () => {
46
+ s.value = (s.value - 1 + e.length) % e.length, b();
47
+ }, _ = () => {
47
48
  var e;
48
- w(), (e = a.galleries) != null && e.length && (p.value = window.setInterval(() => {
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
- }, w = () => {
53
+ }, h = () => {
53
54
  p.value && (window.clearInterval(p.value), p.value = void 0);
54
- }, R = I(() => a.width != null ? a.width : a.size === "small" ? 30 : a.size === "medium" ? 80 : 125), m = J(
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
- return !a.src || f.value ? i.value.placeholder : typeof a.src == "string" ? (a.src.includes("http") || // From public image
58
- /^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, R.value))) || i.value.placeholder : a.src;
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
- ), y = d(), G = async () => {
63
- var t, r, o, c;
64
- if (y.value != null) return;
65
- let e = m.value;
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 l = (r = (t = i.value).getImageURL) == null ? void 0 : r.call(t, "preview"), n = typeof l == "string" && !(l != null && l.includes("undefined")) ? new URL(l).origin : "", B = n && e.includes(n) || // For getImageURL that return the image full url
68
- l instanceof Promise;
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 ((c = (o = i.value).getImageURL) == null ? void 0 : c.call(o, a.src));
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
- }, h = (e) => {
74
- w(), typeof e == "number" && (s.value = e), S.value ? window.clearTimeout(S.value) : window.setTimeout(L, 3e3);
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 r;
77
- const t = (r = e.target) == null ? void 0 : r.src;
78
- (t === m.value || t.includes(m.value.toString())) && (f.value = !0);
79
- }, U = (e) => {
80
- var r, o, c;
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 : (c = (o = (r = i.value).getImageURL) == null ? void 0 : o.call(r, t)) == null ? void 0 : c.toString() : 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 r;
86
- return u(), q(D(X), {
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: (r = e.$preset.image) == null ? void 0 : r.root({ props: e.$props }) },
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: G
105
+ onShow: M
94
106
  }, {
95
- image: b(() => {
96
- var o;
107
+ image: k(() => {
108
+ var l;
97
109
  return [
98
- $("img", T((o = e.$preset.image) == null ? void 0 : o.image({ props: e.$props, context: { imageSize: R.value } }), {
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: D(m),
112
+ src: $(n),
101
113
  alt: ""
102
- }), null, 16, ee)
114
+ }), null, 16, te)
103
115
  ];
104
116
  }),
105
- indicatoricon: b(() => [
106
- C(Y, T(e.$preset.image.icon, { icon: "eye" }), null, 16)
117
+ indicatoricon: k(() => [
118
+ R(ee, T(e.$preset.image.icon, { icon: "eye" }), null, 16)
107
119
  ]),
108
- preview: b((o) => {
109
- var c;
120
+ preview: k((l) => {
121
+ var u;
110
122
  return [
111
- (c = e.galleries) != null && c.length ? (u(), g(z, { key: 1 }, [
112
- (u(!0), g(z, null, O(e.galleries, ({ src: l }, n) => x((u(), g("img", {
113
- key: n,
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: U(l),
116
- style: k(o.style),
127
+ src: O(r),
128
+ style: z(l.style),
117
129
  alt: "",
118
130
  "data-wv-section": "image-gallery"
119
- }, null, 12, ae)), [
120
- [H, n === s.value]
131
+ }, null, 12, oe)), [
132
+ [J, c === s.value]
121
133
  ])), 128)),
122
- $("div", {
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
- C(E, {
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: A,
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
- (u(!0), g(z, null, O(e.galleries, ({ src: l }, n) => (u(), g("img", {
142
- key: n,
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 == n }
157
+ { "!opacity-100": s.value == c }
146
158
  ]),
147
159
  onerror: v,
148
- src: U(l),
149
- style: k(o.style),
150
- onClick: P((B) => h(n), ["stop"]),
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, re))), 128)),
154
- C(E, {
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: j,
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)) : (u(), g("img", {
179
+ ], 64)) : (m(), g("img", {
168
180
  key: 0,
169
181
  onerror: v,
170
- src: y.value,
171
- style: k(o.style),
182
+ src: w.value,
183
+ style: z(l.style),
172
184
  alt: ""
173
- }, null, 12, te))
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
- me as _
194
+ ge as _
183
195
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fewangsit/wangsvue-fats",
3
- "version": "1.0.1-alpha.36",
3
+ "version": "1.0.1-alpha.38",
4
4
  "author": "Wangsit FE Developer",
5
5
  "description": "Fixed Asset Tagsamurai VueJS Component Library",
6
6
  "type": "module",