@dotss/tictoccroc 0.0.33 → 0.0.34

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.
@@ -1,116 +1,115 @@
1
- import { jsxs as U, jsx as c, Fragment as tt } from "react/jsx-runtime";
2
- import { forwardRef as et, useRef as b, useImperativeHandle as nt, useState as S, useEffect as M } from "react";
3
- import { Flexbox as z, Skeleton as w } from "@dotss/ui";
4
- import ot from "../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
5
- import R from "../../utils/getImageUrl/getImageUrl.mjs";
6
- import F from "./Image.error.mjs";
7
- const it = 100, dt = et(
1
+ import { jsxs as T, jsx as s, Fragment as tt } from "react/jsx-runtime";
2
+ import { forwardRef as et, useRef as U, useImperativeHandle as nt, useState as g, useEffect as V } from "react";
3
+ import { Flexbox as _, Skeleton as z } from "@dotss/ui";
4
+ import ot from "../../hooks/useInView/useInView.mjs";
5
+ import it from "../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
6
+ import O from "../../utils/getImageUrl/getImageUrl.mjs";
7
+ import B from "./Image.error.mjs";
8
+ const mt = et(
8
9
  ({
9
10
  src: l,
10
11
  width: e,
11
12
  height: o,
12
- fit: r = "cover",
13
+ fit: m = "cover",
13
14
  position: y = "center",
14
- alt: V,
15
+ alt: b,
15
16
  scale: W = 2,
16
- onLoad: _,
17
+ onLoad: q,
17
18
  onLazyLoad: j,
18
- lazy: q = !1,
19
+ lazy: A = !1,
19
20
  borderRadius: u,
20
- disabledResizing: L = !1,
21
- withIntrinsicRatio: A = !1,
22
- enableBlurPlaceholder: g = !1,
23
- enableFallback: B = !1,
24
- enableErrorFallback: D = !0,
25
- renderErrorFallback: d,
21
+ disabledResizing: S = !1,
22
+ withIntrinsicRatio: D = !1,
23
+ enableBlurPlaceholder: r = !1,
24
+ enableFallback: G = !1,
25
+ enableErrorFallback: J = !0,
26
+ renderErrorFallback: c,
26
27
  wrapperProps: n = {},
27
- onError: G,
28
- ...C
29
- }, p) => {
30
- const I = b(null), J = b(!1), i = b(null);
31
- nt(p, () => i.current);
32
- const [v, k] = S(!1), [E, m] = S(!1), [h, f] = S(!1), [x, P] = S(!1), [K, N] = S(
33
- R({
28
+ onError: K,
29
+ ...L
30
+ }, w) => {
31
+ const C = U(null), M = U(!1), i = U(null);
32
+ nt(w, () => i.current);
33
+ const { isInView: F } = ot(C, {
34
+ threshold: 0.4
35
+ }), [v, k] = g(!1), [I, d] = g(!1), [h, a] = g(!1), [x, p] = g(!1), [N, Q] = g(
36
+ O({
34
37
  mode: "original",
35
38
  src: l,
36
39
  width: e,
37
40
  height: o,
38
- fit: r,
41
+ fit: m,
39
42
  position: y,
40
43
  scale: W,
41
- disabledResizing: L
44
+ disabledResizing: S
42
45
  })
43
- ), Q = l == null ? void 0 : l.endsWith(".heic"), T = g ? R({
46
+ ), R = l == null ? void 0 : l.endsWith(".heic"), E = r ? O({
44
47
  mode: "blur",
45
48
  src: l,
46
49
  width: e,
47
- fit: r,
50
+ fit: m,
48
51
  position: y,
49
52
  scale: 1 / 3,
50
- disabledResizing: L
53
+ disabledResizing: S
51
54
  }) : null, X = (t) => {
52
- m(!0), f(!1), typeof _ == "function" && _(t);
55
+ d(!0), a(!1), typeof q == "function" && q(t);
53
56
  }, Y = (t) => {
54
- typeof G == "function" && G(t.nativeEvent), f(!0), m(!1);
55
- }, Z = () => P(!0);
56
- return M(() => {
57
- if (q && I.current) {
58
- const t = I.current, H = () => {
59
- if (!t) return !1;
60
- const a = t.getBoundingClientRect();
61
- return a.bottom >= 0 && a.top <= (window.innerHeight || document.documentElement.clientHeight) + it;
62
- }, s = () => {
63
- H() && k(!0);
64
- }, O = () => {
65
- var a;
66
- (a = window.appScreenContent) == null || a.addEventListener("scroll", s), window.addEventListener("resize", s), window.addEventListener("orientationchange", s);
57
+ typeof K == "function" && K(t.nativeEvent), a(!0), d(!1);
58
+ }, Z = () => p(!0);
59
+ return V(() => {
60
+ if (A && C.current) {
61
+ const t = () => {
62
+ F && k(!0);
67
63
  }, $ = () => {
68
- var a;
69
- (a = window.appScreenContent) == null || a.removeEventListener("scroll", s), window.removeEventListener("resize", s), window.removeEventListener("orientationchange", s);
64
+ var f;
65
+ (f = window.appScreenContent) == null || f.addEventListener("scroll", t), window.addEventListener("resize", t), window.addEventListener("orientationchange", t);
66
+ }, H = () => {
67
+ var f;
68
+ (f = window.appScreenContent) == null || f.removeEventListener("scroll", t), window.removeEventListener("resize", t), window.removeEventListener("orientationchange", t);
70
69
  };
71
- return s(), O(), $;
70
+ return t(), $(), H;
72
71
  }
73
- }), M(() => {
74
- typeof j == "function" && v && !J.current && (J.current = !0, j());
75
- }, [j, v]), ot(() => {
72
+ }), V(() => {
73
+ typeof j == "function" && v && !M.current && (M.current = !0, j());
74
+ }, [j, v]), it(() => {
76
75
  const t = i.current;
77
- return t != null && t.complete ? t.naturalWidth > 0 ? (t.style.transition = "none", t.style.opacity = "1", m(!0)) : (t.style.opacity = "0", f(!0)) : t && (t.style.transition = "opacity 0.3s", t.style.opacity = "0", t.onload = () => {
78
- t.style.opacity = "1", m(!0), t.onload = null;
76
+ return t != null && t.complete ? t.naturalWidth > 0 ? (t.style.transition = "none", t.style.opacity = "1", d(!0)) : (t.style.opacity = "0", a(!0)) : t && (t.style.transition = "opacity 0.3s", t.style.opacity = "0", t.onload = () => {
77
+ t.style.opacity = "1", d(!0), t.onload = null;
79
78
  }, t.onerror = () => {
80
- if (!Q) {
81
- f(!0), t.onerror = null;
79
+ if (!R) {
80
+ a(!0), t.onerror = null;
82
81
  return;
83
82
  }
84
- f(!1), window.fetch(l).then(async (H) => {
85
- const s = await H.blob(), O = (await import("heic2any")).default, $ = await O({ blob: s, toType: "image/png" });
86
- N(URL.createObjectURL($)), i.current.onload = () => {
87
- t.style.opacity = "1", m(!0), f(!1), i.current.onload = null, i.current.onerror = null;
83
+ a(!1), window.fetch(l).then(async ($) => {
84
+ const H = await $.blob(), f = (await import("heic2any")).default, P = await f({ blob: H, toType: "image/png" });
85
+ Q(URL.createObjectURL(P)), i.current.onload = () => {
86
+ t.style.opacity = "1", d(!0), a(!1), i.current.onload = null, i.current.onerror = null;
88
87
  }, i.current.onerror = () => {
89
- f(!0), m(!1), i.current.onload = null, i.current.onerror = null;
88
+ a(!0), d(!1), i.current.onload = null, i.current.onerror = null;
90
89
  };
91
90
  });
92
91
  }), () => {
93
92
  t && (t.onload = null, t.onerror = null);
94
93
  };
95
- }, [v, l, Q]), M(() => {
96
- N(
97
- R({
94
+ }, [v, l, R]), V(() => {
95
+ Q(
96
+ O({
98
97
  mode: "original",
99
98
  src: l,
100
99
  width: e,
101
100
  height: o,
102
- fit: r,
101
+ fit: m,
103
102
  position: y,
104
103
  scale: W,
105
- disabledResizing: L
104
+ disabledResizing: S
106
105
  })
107
106
  );
108
- }, [l, e, o, r, y, W, L]), q ? /* @__PURE__ */ U(
109
- z,
107
+ }, [l, e, o, m, y, W, S]), A ? /* @__PURE__ */ T(
108
+ _,
110
109
  {
111
110
  ...n,
112
- ref: I,
113
- inlineCSS: A ? {
111
+ ref: C,
112
+ inlineCSS: D ? {
114
113
  position: "relative",
115
114
  paddingTop: `calc(100% / ${e} * ${o})`,
116
115
  minWidth: "100%",
@@ -127,8 +126,8 @@ const it = 100, dt = et(
127
126
  ...n == null ? void 0 : n.inlineCSS
128
127
  },
129
128
  children: [
130
- B && /* @__PURE__ */ c(
131
- w,
129
+ G && /* @__PURE__ */ s(
130
+ z,
132
131
  {
133
132
  width: "100%",
134
133
  height: "100%",
@@ -137,15 +136,15 @@ const it = 100, dt = et(
137
136
  position: "absolute",
138
137
  top: 0,
139
138
  left: 0,
140
- opacity: E || g && x ? 0 : 1,
139
+ opacity: I || r && x ? 0 : 1,
141
140
  transition: "opacity 0.3s"
142
141
  }
143
142
  }
144
143
  ),
145
- g && T && v && /* @__PURE__ */ c(
144
+ r && E && v && /* @__PURE__ */ s(
146
145
  "img",
147
146
  {
148
- src: T,
147
+ src: E,
149
148
  alt: "",
150
149
  width: e,
151
150
  height: o,
@@ -158,27 +157,27 @@ const it = 100, dt = et(
158
157
  width: "100%",
159
158
  height: "100%",
160
159
  filter: "blur(5px)",
161
- opacity: x && !E ? 1 : 0,
160
+ opacity: x && !I ? 1 : 0,
162
161
  transition: "opacity 0.3s",
163
- objectFit: r,
162
+ objectFit: m,
164
163
  objectPosition: y
165
164
  }
166
165
  }
167
166
  ),
168
- v && /* @__PURE__ */ U(tt, { children: [
169
- /* @__PURE__ */ c(
167
+ v && /* @__PURE__ */ T(tt, { children: [
168
+ /* @__PURE__ */ s(
170
169
  "img",
171
170
  {
172
171
  ref: i,
173
- src: K,
174
- alt: V,
172
+ src: N,
173
+ alt: b,
175
174
  width: e,
176
175
  height: o,
177
176
  onLoad: X,
178
177
  onError: Y,
179
178
  "aria-hidden": h,
180
179
  draggable: !1,
181
- ...C,
180
+ ...L,
182
181
  style: {
183
182
  position: "absolute",
184
183
  top: 0,
@@ -186,20 +185,20 @@ const it = 100, dt = et(
186
185
  width: "100%",
187
186
  height: "100%",
188
187
  transition: "opacity 0.3s",
189
- ...C.style
188
+ ...L.style
190
189
  }
191
190
  }
192
191
  ),
193
- D && h && ((d == null ? void 0 : d()) || /* @__PURE__ */ c(F, {}))
192
+ J && h && ((c == null ? void 0 : c()) || /* @__PURE__ */ s(B, {}))
194
193
  ] })
195
194
  ]
196
195
  }
197
- ) : /* @__PURE__ */ U(
198
- z,
196
+ ) : /* @__PURE__ */ T(
197
+ _,
199
198
  {
200
199
  ...n,
201
- ref: I,
202
- inlineCSS: A ? {
200
+ ref: C,
201
+ inlineCSS: D ? {
203
202
  position: "relative",
204
203
  paddingTop: `calc(100% / ${e} * ${o})`,
205
204
  minWidth: "100%",
@@ -217,8 +216,8 @@ const it = 100, dt = et(
217
216
  ...n == null ? void 0 : n.inlineCSS
218
217
  },
219
218
  children: [
220
- B && /* @__PURE__ */ c(
221
- w,
219
+ G && /* @__PURE__ */ s(
220
+ z,
222
221
  {
223
222
  width: "100%",
224
223
  height: "100%",
@@ -227,15 +226,15 @@ const it = 100, dt = et(
227
226
  position: "absolute",
228
227
  top: 0,
229
228
  left: 0,
230
- opacity: E || g && x ? 0 : 1,
229
+ opacity: I || r && x ? 0 : 1,
231
230
  transition: "opacity 0.3s"
232
231
  }
233
232
  }
234
233
  ),
235
- g && T && /* @__PURE__ */ c(
234
+ r && E && /* @__PURE__ */ s(
236
235
  "img",
237
236
  {
238
- src: T,
237
+ src: E,
239
238
  alt: "",
240
239
  width: e,
241
240
  height: o,
@@ -248,24 +247,24 @@ const it = 100, dt = et(
248
247
  width: "100%",
249
248
  height: "100%",
250
249
  filter: "blur(5px)",
251
- opacity: x && !E ? 1 : 0,
250
+ opacity: x && !I ? 1 : 0,
252
251
  transition: "opacity 0.3s"
253
252
  }
254
253
  }
255
254
  ),
256
- /* @__PURE__ */ c(
255
+ /* @__PURE__ */ s(
257
256
  "img",
258
257
  {
259
258
  ref: i,
260
- src: K,
261
- alt: V,
259
+ src: N,
260
+ alt: b,
262
261
  width: e,
263
262
  height: o,
264
263
  onLoad: X,
265
264
  onError: Y,
266
265
  "aria-hidden": h,
267
266
  draggable: !1,
268
- ...C,
267
+ ...L,
269
268
  style: {
270
269
  position: "absolute",
271
270
  top: 0,
@@ -273,16 +272,16 @@ const it = 100, dt = et(
273
272
  width: "100%",
274
273
  height: "100%",
275
274
  transition: "opacity 0.3s",
276
- ...C.style
275
+ ...L.style
277
276
  }
278
277
  }
279
278
  ),
280
- D && h && ((d == null ? void 0 : d()) || /* @__PURE__ */ c(F, {}))
279
+ J && h && ((c == null ? void 0 : c()) || /* @__PURE__ */ s(B, {}))
281
280
  ]
282
281
  }
283
282
  );
284
283
  }
285
284
  );
286
285
  export {
287
- dt as default
286
+ mt as default
288
287
  };