@fewangsit/wangsvue-fats 1.0.1-alpha.35 → 1.0.1-alpha.37

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.
@@ -50,8 +50,8 @@ const I = (i, s) => {
50
50
  _: 3
51
51
  }, 8, ["mouse-move", "touch-move", "touch-resize", "wheel-resize"]));
52
52
  }
53
- }), S = /* @__PURE__ */ I(R, [["__scopeId", "data-v-9031c32d"]]);
53
+ }), b = /* @__PURE__ */ I(R, [["__scopeId", "data-v-5cd98b2d"]]);
54
54
  export {
55
- S as B,
55
+ b as B,
56
56
  I as _
57
57
  };
@@ -988,7 +988,7 @@ const zt = (W, $) => W.every((t) => $.includes(t)), jt = ["id"], Vt = ["onClick"
988
988
  ], 16);
989
989
  };
990
990
  }
991
- }), Fl = /* @__PURE__ */ Lt(sl, [["__scopeId", "data-v-015be0a0"]]);
991
+ }), Fl = /* @__PURE__ */ Lt(sl, [["__scopeId", "data-v-37d9df20"]]);
992
992
  export {
993
993
  Fl as D
994
994
  };
@@ -231,8 +231,8 @@ const H = /* @__PURE__ */ nA(vA), j = "data:image/png;base64,iVBORw0KGgoAAAANSUh
231
231
  t[4] || (t[4] = e("span", null, "Preview", -1)),
232
232
  a(eA, {
233
233
  icon: "info",
234
- info: `This preview is only for showing the side of the\r
235
- label that printed or not. It does not show the\r
234
+ info: `This preview is only for showing the side of the
235
+ label that printed or not. It does not show the
236
236
  exact amount you entered.`,
237
237
  severity: "primary"
238
238
  })
package/image/index.d.ts CHANGED
@@ -271,17 +271,25 @@ export interface ImageProps {
271
271
  unstyled?: boolean;
272
272
 
273
273
  /**
274
- * Get image url for specifics project from its server.
275
- * @returns The full URL of the image from the server.
276
- * @param path - the Image path from API Response JSON
277
- * @param width - the image width in pixels
278
- * @param height - the image height in pixels
274
+ * Returns the full image URL or a ObjetctURL from Blob for an image resource, based on the provided path and dimensions.
275
+ *
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 ObjetctURL from Blob (e.g., Base64-encoded).
278
+ *
279
+ * @param path - The image path as provided in the API response JSON. Can be null or undefined.
280
+ * @param width - Optional width of the image in pixels.
281
+ * @param height - Optional height of the image in pixels.
282
+ *
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
+ *
279
286
  */
280
287
  getImageURL?: (
281
288
  path?: string | null,
282
289
  width?: number,
283
290
  height?: number,
284
- ) => string | undefined;
291
+ returnURLOnly?: boolean, // Default is undefined or will return Promise when using Auth, when it manually sets to true, return the url only
292
+ ) => string | undefined | Promise<string | undefined>;
285
293
 
286
294
  /**
287
295
  * The placeholder to be shown when the image failed to load, or the src is not provided.
package/image/index.es.js CHANGED
@@ -1,10 +1,11 @@
1
- import { defineComponent as j, computed as p, onMounted as G, onUnmounted as M, shallowRef as f, createBlock as W, openBlock as n, unref as q, mergeProps as I, withCtx as b, createElementBlock as m, normalizeStyle as k, Fragment as _, createElementVNode as U, renderList as T, withDirectives as A, vShow as H, withModifiers as D, createVNode as C, normalizeClass as z } from "vue";
2
- import { u as J } from "../plugins/WangsVue.es.js";
3
- import { m as K } from "../utils/mergePropsWithDefaults.util.es.js";
4
- import { s as Q } from "../vendor/primevue/image/image.esm.es.js";
5
- import { _ as O } from "../button/index.es.js";
6
- import { _ as X } from "../icon/index.es.js";
7
- const Y = ["src"], Z = ["src"], ee = ["src"], te = ["src", "onClick"], ne = /* @__PURE__ */ j({
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";
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({
8
9
  __name: "Image",
9
10
  props: {
10
11
  src: {},
@@ -24,101 +25,118 @@ const Y = ["src"], Z = ["src"], ee = ["src"], te = ["src", "onClick"], ne = /* @
24
25
  getImageURL: {},
25
26
  placeholder: {}
26
27
  },
27
- setup(x) {
28
- const r = x, { defaultProps: E } = J("Image"), c = p(() => K(r, E));
29
- G(() => {
28
+ setup(F) {
29
+ const a = F, { defaultProps: N } = K("Image"), i = I(() => Q(a, N));
30
+ W(() => {
30
31
  setTimeout(() => {
31
- $();
32
+ L();
32
33
  }, 3e3);
33
- }), M(() => {
34
- h();
34
+ }), Z(() => {
35
+ w();
35
36
  });
36
- const o = f(0), v = f(), L = f(), w = f(!1), F = p(() => {
37
+ const s = d(0), p = d(), S = d(), f = d(!1), V = I(() => {
37
38
  var e;
38
- return r.preview === !1 ? !1 : !w.value && !((e = u.value) != null && e.toString().includes("data:image/png;base64")) && u.value !== c.value.placeholder;
39
- }), N = () => {
40
- const e = r.galleries ?? [];
41
- o.value = (o.value + 1) % e.length, y();
42
- }, P = () => {
43
- const e = r.galleries ?? [];
44
- o.value = (o.value - 1 + e.length) % e.length, y();
45
- }, $ = () => {
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 = () => {
41
+ const e = a.galleries ?? [];
42
+ s.value = (s.value + 1) % e.length, h();
43
+ }, A = () => {
44
+ const e = a.galleries ?? [];
45
+ s.value = (s.value - 1 + e.length) % e.length, h();
46
+ }, L = () => {
46
47
  var e;
47
- h(), (e = r.galleries) != null && e.length && (v.value = window.setInterval(() => {
48
- const t = r.galleries ?? [];
49
- o.value = (o.value + 1) % t.length;
48
+ w(), (e = a.galleries) != null && e.length && (p.value = window.setInterval(() => {
49
+ const t = a.galleries ?? [];
50
+ s.value = (s.value + 1) % t.length;
50
51
  }, 3e3));
51
- }, h = () => {
52
- v.value && (window.clearInterval(v.value), v.value = void 0);
53
- }, B = p(() => r.width != null ? r.width : r.size === "small" ? 30 : r.size === "medium" ? 80 : 125), u = p(() => {
54
- var e, t;
55
- return !r.src || w.value ? c.value.placeholder : typeof r.src == "string" ? r.src.includes("http") || // From public image
56
- r.src.includes("data:image/png;base64") ? r.src : (t = (e = c.value).getImageURL) == null ? void 0 : t.call(e, r.src, B.value) : r.src;
57
- }), V = p(() => {
58
- var t, l, a, g;
59
- const e = u.value;
52
+ }, w = () => {
53
+ 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
+ async () => {
56
+ var e, t;
57
+ return !a.src || f.value ? i.value.placeholder : typeof a.src == "string" ? (a.src.includes("http") || // From public image or ObjectURL from Blob e.g 'blob:http://localhost:5173/ca48705d-1fc1-4a74-af38-353ffce7e02a'
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;
59
+ },
60
+ i.value.placeholder
61
+ // 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;
60
66
  if (typeof e == "string") {
61
- const s = (l = (t = c.value).getImageURL) == null ? void 0 : l.call(t, "preview"), i = s && !(s != null && s.includes("undefined")) ? new URL(s).origin : "", R = i && e.includes(i);
62
- return e.includes("http") && !R || // From public resource
63
- e.includes("data:image/svg+xml") ? e : (g = (a = c.value).getImageURL) == null ? void 0 : g.call(a, r.src);
67
+ const l = (r = (t = i.value).getImageURL) == null ? void 0 : r.call(
68
+ t,
69
+ "preview",
70
+ void 0,
71
+ void 0,
72
+ !0
73
+ ), 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
74
+ l instanceof Promise;
75
+ e = e.includes("http") && !B || // From public resource
76
+ e.includes("data:image/svg+xml") ? e : await ((c = (o = i.value).getImageURL) == null ? void 0 : c.call(o, a.src));
64
77
  }
65
- return e;
66
- }), y = (e) => {
67
- h(), typeof e == "number" && (o.value = e), L.value ? window.clearTimeout(L.value) : window.setTimeout($, 3e3);
68
- }, d = (e) => {
69
- var l;
70
- const t = (l = e.target) == null ? void 0 : l.src;
71
- (t === u.value || t.includes(u.value.toString())) && (w.value = !0);
72
- }, S = (e) => {
73
- var l, a;
78
+ y.value = e || i.value.placeholder;
79
+ }, h = (e) => {
80
+ w(), typeof e == "number" && (s.value = e), S.value ? window.clearTimeout(S.value) : window.setTimeout(L, 3e3);
81
+ }, v = (e) => {
82
+ var r;
83
+ const t = (r = e.target) == null ? void 0 : r.src;
84
+ (t === m.value || t.includes(m.value.toString())) && (f.value = !0);
85
+ }, U = (e) => {
86
+ var r, o, c;
74
87
  const t = e;
75
- return typeof t == "string" ? t.includes("http") ? t : (a = (l = c.value).getImageURL) == null ? void 0 : a.call(l, t) : t;
88
+ 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;
76
89
  };
77
90
  return (e, t) => {
78
- var l;
79
- return n(), W(q(Q), I(e.$props, {
80
- preview: F.value,
81
- pt: { root: (l = e.$preset.image) == null ? void 0 : l.root({ props: e.$props }) }
82
- }), {
91
+ var r;
92
+ return u(), q(D(X), {
93
+ "image-class": e.imageClass,
94
+ "image-style": e.imageStyle,
95
+ preview: V.value,
96
+ pt: { root: (r = e.$preset.image) == null ? void 0 : r.root({ props: e.$props }) },
97
+ "zoom-in-disabled": e.zoomInDisabled,
98
+ "zoom-out-disabled": e.zoomOutDisabled,
99
+ onShow: G
100
+ }, {
83
101
  image: b(() => {
84
- var a;
102
+ var o;
85
103
  return [
86
- U("img", I((a = e.$preset.image) == null ? void 0 : a.image({ props: e.$props, context: { imageSize: B.value } }), {
87
- onerror: d,
88
- src: u.value,
104
+ $("img", T((o = e.$preset.image) == null ? void 0 : o.image({ props: e.$props, context: { imageSize: R.value } }), {
105
+ onerror: v,
106
+ src: D(m),
89
107
  alt: ""
90
- }), null, 16, Y)
108
+ }), null, 16, ee)
91
109
  ];
92
110
  }),
93
111
  indicatoricon: b(() => [
94
- C(X, I(e.$preset.image.icon, { icon: "eye" }), null, 16)
112
+ C(Y, T(e.$preset.image.icon, { icon: "eye" }), null, 16)
95
113
  ]),
96
- preview: b((a) => {
97
- var g;
114
+ preview: b((o) => {
115
+ var c;
98
116
  return [
99
- (g = e.galleries) != null && g.length ? (n(), m(_, { key: 1 }, [
100
- (n(!0), m(_, null, T(e.galleries, ({ src: s }, i) => A((n(), m("img", {
101
- key: i,
102
- onerror: d,
103
- src: S(s),
104
- style: k(a.style),
117
+ (c = e.galleries) != null && c.length ? (u(), g(z, { key: 1 }, [
118
+ (u(!0), g(z, null, O(e.galleries, ({ src: l }, n) => x((u(), g("img", {
119
+ key: n,
120
+ onerror: v,
121
+ src: U(l),
122
+ style: k(o.style),
105
123
  alt: "",
106
124
  "data-wv-section": "image-gallery"
107
- }, null, 12, ee)), [
108
- [H, i === o.value]
125
+ }, null, 12, ae)), [
126
+ [H, n === s.value]
109
127
  ])), 128)),
110
- U("div", {
111
- onClick: t[0] || (t[0] = D(() => {
128
+ $("div", {
129
+ onClick: t[0] || (t[0] = P(() => {
112
130
  }, ["stop"])),
113
131
  class: "fixed bottom-0 left-0 flex justify-center items-center w-full p-4 mx-auto flex-row bg-black/80",
114
132
  "data-wv-section": "gallery-thumbnail"
115
133
  }, [
116
- C(O, {
117
- class: z([
134
+ C(E, {
135
+ class: _([
118
136
  "text-surface-0 rotate-180 sticky left-0 !w-8 !h-8 [&_i]:w-5 [&_i]:h-5",
119
137
  "rounded-full mr-3"
120
138
  ]),
121
- onClick: P,
139
+ onClick: A,
122
140
  "aria-label": "Previous Image",
123
141
  "data-wv-section": "prev-button",
124
142
  icon: "arrow-right",
@@ -126,25 +144,25 @@ const Y = ["src"], Z = ["src"], ee = ["src"], te = ["src", "onClick"], ne = /* @
126
144
  severity: "secondary",
127
145
  text: ""
128
146
  }),
129
- (n(!0), m(_, null, T(e.galleries, ({ src: s }, i) => (n(), m("img", {
130
- key: i,
131
- class: z([
147
+ (u(!0), g(z, null, O(e.galleries, ({ src: l }, n) => (u(), g("img", {
148
+ key: n,
149
+ class: _([
132
150
  "h-10 w-10 object-cover cursor-pointer opacity-50 hover:opacity-100 transition-opacity",
133
- { "!opacity-100": o.value == i }
151
+ { "!opacity-100": s.value == n }
134
152
  ]),
135
- onerror: d,
136
- src: S(s),
137
- style: k(a.style),
138
- onClick: D((R) => y(i), ["stop"]),
153
+ onerror: v,
154
+ src: U(l),
155
+ style: k(o.style),
156
+ onClick: P((B) => h(n), ["stop"]),
139
157
  alt: "",
140
158
  "data-wv-section": "thumbnail-image"
141
- }, null, 14, te))), 128)),
142
- C(O, {
143
- class: z([
159
+ }, null, 14, re))), 128)),
160
+ C(E, {
161
+ class: _([
144
162
  "text-surface-0 sticky !w-8 !h-8 [&_i]:w-5 [&_i]:h-5",
145
163
  "rounded-full ml-3"
146
164
  ]),
147
- onClick: N,
165
+ onClick: j,
148
166
  "aria-label": "Next Image",
149
167
  "data-wv-section": "next-button",
150
168
  icon: "arrow-right",
@@ -152,20 +170,20 @@ const Y = ["src"], Z = ["src"], ee = ["src"], te = ["src", "onClick"], ne = /* @
152
170
  text: ""
153
171
  })
154
172
  ])
155
- ], 64)) : (n(), m("img", {
173
+ ], 64)) : (u(), g("img", {
156
174
  key: 0,
157
- onerror: d,
158
- src: V.value,
159
- style: k(a.style),
175
+ onerror: v,
176
+ src: y.value,
177
+ style: k(o.style),
160
178
  alt: ""
161
- }, null, 12, Z))
179
+ }, null, 12, te))
162
180
  ];
163
181
  }),
164
182
  _: 1
165
- }, 16, ["preview", "pt"]);
183
+ }, 8, ["image-class", "image-style", "preview", "pt", "zoom-in-disabled", "zoom-out-disabled"]);
166
184
  };
167
185
  }
168
186
  });
169
187
  export {
170
- ne as _
188
+ me as _
171
189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fewangsit/wangsvue-fats",
3
- "version": "1.0.1-alpha.35",
3
+ "version": "1.0.1-alpha.37",
4
4
  "author": "Wangsit FE Developer",
5
5
  "description": "Fixed Asset Tagsamurai VueJS Component Library",
6
6
  "type": "module",