@spesia/ui 1.10.4 → 1.10.5

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.
@@ -0,0 +1,370 @@
1
+ import z from "../../../../../../_virtual/lottie.js";
2
+ import G, { useEffect as C, useState as J, useRef as j } from "react";
3
+ function E(t, e) {
4
+ (e == null || e > t.length) && (e = t.length);
5
+ for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
6
+ return n;
7
+ }
8
+ function Q(t) {
9
+ if (Array.isArray(t)) return t;
10
+ }
11
+ function Z(t, e, r) {
12
+ return (e = oe(e)) in t ? Object.defineProperty(t, e, {
13
+ value: r,
14
+ enumerable: !0,
15
+ configurable: !0,
16
+ writable: !0
17
+ }) : t[e] = r, t;
18
+ }
19
+ function ee(t, e) {
20
+ var r = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
21
+ if (r != null) {
22
+ var n, c, f, i, b = [], d = !0, A = !1;
23
+ try {
24
+ if (f = (r = r.call(t)).next, e !== 0) for (; !(d = (n = f.call(r)).done) && (b.push(n.value), b.length !== e); d = !0) ;
25
+ } catch (g) {
26
+ A = !0, c = g;
27
+ } finally {
28
+ try {
29
+ if (!d && r.return != null && (i = r.return(), Object(i) !== i)) return;
30
+ } finally {
31
+ if (A) throw c;
32
+ }
33
+ }
34
+ return b;
35
+ }
36
+ }
37
+ function te() {
38
+ throw new TypeError(`Invalid attempt to destructure non-iterable instance.
39
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
40
+ }
41
+ function x(t, e) {
42
+ var r = Object.keys(t);
43
+ if (Object.getOwnPropertySymbols) {
44
+ var n = Object.getOwnPropertySymbols(t);
45
+ e && (n = n.filter(function(c) {
46
+ return Object.getOwnPropertyDescriptor(t, c).enumerable;
47
+ })), r.push.apply(r, n);
48
+ }
49
+ return r;
50
+ }
51
+ function I(t) {
52
+ for (var e = 1; e < arguments.length; e++) {
53
+ var r = arguments[e] != null ? arguments[e] : {};
54
+ e % 2 ? x(Object(r), !0).forEach(function(n) {
55
+ Z(t, n, r[n]);
56
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : x(Object(r)).forEach(function(n) {
57
+ Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
58
+ });
59
+ }
60
+ return t;
61
+ }
62
+ function H(t, e) {
63
+ if (t == null) return {};
64
+ var r, n, c = ne(t, e);
65
+ if (Object.getOwnPropertySymbols) {
66
+ var f = Object.getOwnPropertySymbols(t);
67
+ for (n = 0; n < f.length; n++) r = f[n], e.includes(r) || {}.propertyIsEnumerable.call(t, r) && (c[r] = t[r]);
68
+ }
69
+ return c;
70
+ }
71
+ function ne(t, e) {
72
+ if (t == null) return {};
73
+ var r = {};
74
+ for (var n in t) if ({}.hasOwnProperty.call(t, n)) {
75
+ if (e.includes(n)) continue;
76
+ r[n] = t[n];
77
+ }
78
+ return r;
79
+ }
80
+ function re(t, e) {
81
+ return Q(t) || ee(t, e) || ie(t, e) || te();
82
+ }
83
+ function ae(t, e) {
84
+ if (typeof t != "object" || !t) return t;
85
+ var r = t[Symbol.toPrimitive];
86
+ if (r !== void 0) {
87
+ var n = r.call(t, e);
88
+ if (typeof n != "object") return n;
89
+ throw new TypeError("@@toPrimitive must return a primitive value.");
90
+ }
91
+ return (e === "string" ? String : Number)(t);
92
+ }
93
+ function oe(t) {
94
+ var e = ae(t, "string");
95
+ return typeof e == "symbol" ? e : e + "";
96
+ }
97
+ function ie(t, e) {
98
+ if (t) {
99
+ if (typeof t == "string") return E(t, e);
100
+ var r = {}.toString.call(t).slice(8, -1);
101
+ return r === "Object" && t.constructor && (r = t.constructor.name), r === "Map" || r === "Set" ? Array.from(t) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? E(t, e) : void 0;
102
+ }
103
+ }
104
+ var ue = ["animationData", "loop", "autoplay", "initialSegment", "onComplete", "onLoopComplete", "onEnterFrame", "onSegmentStart", "onConfigReady", "onDataReady", "onDataFailed", "onLoadedImages", "onDOMLoaded", "onDestroy", "lottieRef", "renderer", "name", "assetsPath", "rendererSettings"], le = function(e, r) {
105
+ var n = e.animationData, c = e.loop, f = e.autoplay, i = e.initialSegment, b = e.onComplete, d = e.onLoopComplete, A = e.onEnterFrame, g = e.onSegmentStart, L = e.onConfigReady, w = e.onDataReady, h = e.onDataFailed, u = e.onLoadedImages, D = e.onDOMLoaded, S = e.onDestroy;
106
+ e.lottieRef, e.renderer, e.name, e.assetsPath, e.rendererSettings;
107
+ var p = H(e, ue), P = J(!1), l = re(P, 2), O = l[0], R = l[1], o = j(), v = j(null), M = function() {
108
+ var a;
109
+ (a = o.current) === null || a === void 0 || a.play();
110
+ }, F = function() {
111
+ var a;
112
+ (a = o.current) === null || a === void 0 || a.stop();
113
+ }, V = function() {
114
+ var a;
115
+ (a = o.current) === null || a === void 0 || a.pause();
116
+ }, N = function(a) {
117
+ var s;
118
+ (s = o.current) === null || s === void 0 || s.setSpeed(a);
119
+ }, k = function(a, s) {
120
+ var m;
121
+ (m = o.current) === null || m === void 0 || m.goToAndPlay(a, s);
122
+ }, B = function(a, s) {
123
+ var m;
124
+ (m = o.current) === null || m === void 0 || m.goToAndStop(a, s);
125
+ }, $ = function(a) {
126
+ var s;
127
+ (s = o.current) === null || s === void 0 || s.setDirection(a);
128
+ }, W = function(a, s) {
129
+ var m;
130
+ (m = o.current) === null || m === void 0 || m.playSegments(a, s);
131
+ }, K = function(a) {
132
+ var s;
133
+ (s = o.current) === null || s === void 0 || s.setSubframe(a);
134
+ }, U = function(a) {
135
+ var s;
136
+ return (s = o.current) === null || s === void 0 ? void 0 : s.getDuration(a);
137
+ }, X = function() {
138
+ var a;
139
+ (a = o.current) === null || a === void 0 || a.destroy(), o.current = void 0;
140
+ }, Y = function() {
141
+ var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, s;
142
+ if (v.current) {
143
+ (s = o.current) === null || s === void 0 || s.destroy();
144
+ var m = I(I(I({}, e), a), {}, {
145
+ container: v.current
146
+ });
147
+ return o.current = z.loadAnimation(m), R(!!o.current), function() {
148
+ var _;
149
+ (_ = o.current) === null || _ === void 0 || _.destroy(), o.current = void 0;
150
+ };
151
+ }
152
+ };
153
+ C(function() {
154
+ var y = Y();
155
+ return function() {
156
+ return y == null ? void 0 : y();
157
+ };
158
+ }, [n, c]), C(function() {
159
+ o.current && (o.current.autoplay = !!f);
160
+ }, [f]), C(function() {
161
+ if (o.current) {
162
+ if (!i) {
163
+ o.current.resetSegments(!0);
164
+ return;
165
+ }
166
+ !Array.isArray(i) || !i.length || ((o.current.currentRawFrame < i[0] || o.current.currentRawFrame > i[1]) && (o.current.currentRawFrame = i[0]), o.current.setSegment(i[0], i[1]));
167
+ }
168
+ }, [i]), C(function() {
169
+ var y = [{
170
+ name: "complete",
171
+ handler: b
172
+ }, {
173
+ name: "loopComplete",
174
+ handler: d
175
+ }, {
176
+ name: "enterFrame",
177
+ handler: A
178
+ }, {
179
+ name: "segmentStart",
180
+ handler: g
181
+ }, {
182
+ name: "config_ready",
183
+ handler: L
184
+ }, {
185
+ name: "data_ready",
186
+ handler: w
187
+ }, {
188
+ name: "data_failed",
189
+ handler: h
190
+ }, {
191
+ name: "loaded_images",
192
+ handler: u
193
+ }, {
194
+ name: "DOMLoaded",
195
+ handler: D
196
+ }, {
197
+ name: "destroy",
198
+ handler: S
199
+ }], a = y.filter(function(m) {
200
+ return m.handler != null;
201
+ });
202
+ if (a.length) {
203
+ var s = a.map(
204
+ /**
205
+ * Handle the process of adding an event listener
206
+ * @param {Listener} listener
207
+ * @return {Function} Function that deregister the listener
208
+ */
209
+ function(m) {
210
+ var _;
211
+ return (_ = o.current) === null || _ === void 0 || _.addEventListener(m.name, m.handler), function() {
212
+ var T;
213
+ (T = o.current) === null || T === void 0 || T.removeEventListener(m.name, m.handler);
214
+ };
215
+ }
216
+ );
217
+ return function() {
218
+ s.forEach(function(m) {
219
+ return m();
220
+ });
221
+ };
222
+ }
223
+ }, [b, d, A, g, L, w, h, u, D, S]);
224
+ var q = /* @__PURE__ */ G.createElement("div", I({
225
+ style: r,
226
+ ref: v
227
+ }, p));
228
+ return {
229
+ View: q,
230
+ play: M,
231
+ stop: F,
232
+ pause: V,
233
+ setSpeed: N,
234
+ goToAndStop: B,
235
+ goToAndPlay: k,
236
+ setDirection: $,
237
+ playSegments: W,
238
+ setSubframe: K,
239
+ getDuration: U,
240
+ destroy: X,
241
+ animationContainerRef: v,
242
+ animationLoaded: O,
243
+ animationItem: o.current
244
+ };
245
+ };
246
+ function se(t) {
247
+ var e = t.getBoundingClientRect(), r = e.top, n = e.height, c = window.innerHeight - r, f = window.innerHeight + n;
248
+ return c / f;
249
+ }
250
+ function de(t, e, r) {
251
+ var n = t.getBoundingClientRect(), c = n.top, f = n.left, i = n.width, b = n.height, d = (e - f) / i, A = (r - c) / b;
252
+ return {
253
+ x: d,
254
+ y: A
255
+ };
256
+ }
257
+ var ce = function(e) {
258
+ var r = e.wrapperRef, n = e.animationItem, c = e.mode, f = e.actions;
259
+ C(function() {
260
+ var i = r.current;
261
+ if (!(!i || !n || !f.length)) {
262
+ n.stop();
263
+ var b = function() {
264
+ var g = null, L = function() {
265
+ var h = se(i), u = f.find(function(S) {
266
+ var p = S.visibility;
267
+ return p && h >= p[0] && h <= p[1];
268
+ });
269
+ if (u) {
270
+ if (u.type === "seek" && u.visibility && u.frames.length === 2) {
271
+ var D = u.frames[0] + Math.ceil((h - u.visibility[0]) / (u.visibility[1] - u.visibility[0]) * u.frames[1]);
272
+ //! goToAndStop must be relative to the start of the current segment
273
+ n.goToAndStop(D - n.firstFrame - 1, !0);
274
+ }
275
+ u.type === "loop" && (g === null || g !== u.frames || n.isPaused) && (n.playSegments(u.frames, !0), g = u.frames), u.type === "play" && n.isPaused && (n.resetSegments(!0), n.play()), u.type === "stop" && n.goToAndStop(u.frames[0] - n.firstFrame - 1, !0);
276
+ }
277
+ };
278
+ return document.addEventListener("scroll", L), function() {
279
+ document.removeEventListener("scroll", L);
280
+ };
281
+ }, d = function() {
282
+ var g = function(u, D) {
283
+ var S = u, p = D;
284
+ if (S !== -1 && p !== -1) {
285
+ var P = de(i, S, p);
286
+ S = P.x, p = P.y;
287
+ }
288
+ var l = f.find(function(o) {
289
+ var v = o.position;
290
+ return v && Array.isArray(v.x) && Array.isArray(v.y) ? S >= v.x[0] && S <= v.x[1] && p >= v.y[0] && p <= v.y[1] : v && !Number.isNaN(v.x) && !Number.isNaN(v.y) ? S === v.x && p === v.y : !1;
291
+ });
292
+ if (l) {
293
+ if (l.type === "seek" && l.position && Array.isArray(l.position.x) && Array.isArray(l.position.y) && l.frames.length === 2) {
294
+ var O = (S - l.position.x[0]) / (l.position.x[1] - l.position.x[0]), R = (p - l.position.y[0]) / (l.position.y[1] - l.position.y[0]);
295
+ n.playSegments(l.frames, !0), n.goToAndStop(Math.ceil((O + R) / 2 * (l.frames[1] - l.frames[0])), !0);
296
+ }
297
+ l.type === "loop" && n.playSegments(l.frames, !0), l.type === "play" && (n.isPaused && n.resetSegments(!1), n.playSegments(l.frames)), l.type === "stop" && n.goToAndStop(l.frames[0], !0);
298
+ }
299
+ }, L = function(u) {
300
+ g(u.clientX, u.clientY);
301
+ }, w = function() {
302
+ g(-1, -1);
303
+ };
304
+ return i.addEventListener("mousemove", L), i.addEventListener("mouseout", w), function() {
305
+ i.removeEventListener("mousemove", L), i.removeEventListener("mouseout", w);
306
+ };
307
+ };
308
+ switch (c) {
309
+ case "scroll":
310
+ return b();
311
+ case "cursor":
312
+ return d();
313
+ }
314
+ }
315
+ }, [c, n]);
316
+ }, me = function(e) {
317
+ var r = e.actions, n = e.mode, c = e.lottieObj, f = c.animationItem, i = c.View, b = c.animationContainerRef;
318
+ return ce({
319
+ actions: r,
320
+ animationItem: f,
321
+ mode: n,
322
+ wrapperRef: b
323
+ }), i;
324
+ }, fe = ["style", "interactivity"], ge = function(e) {
325
+ var r, n, c, f = e.style, i = e.interactivity, b = H(e, fe), d = le(b, f), A = d.View, g = d.play, L = d.stop, w = d.pause, h = d.setSpeed, u = d.goToAndStop, D = d.goToAndPlay, S = d.setDirection, p = d.playSegments, P = d.setSubframe, l = d.getDuration, O = d.destroy, R = d.animationContainerRef, o = d.animationLoaded, v = d.animationItem;
326
+ return C(function() {
327
+ e.lottieRef && (e.lottieRef.current = {
328
+ play: g,
329
+ stop: L,
330
+ pause: w,
331
+ setSpeed: h,
332
+ goToAndPlay: D,
333
+ goToAndStop: u,
334
+ setDirection: S,
335
+ playSegments: p,
336
+ setSubframe: P,
337
+ getDuration: l,
338
+ destroy: O,
339
+ animationContainerRef: R,
340
+ animationLoaded: o,
341
+ animationItem: v
342
+ });
343
+ }, [(r = e.lottieRef) === null || r === void 0 ? void 0 : r.current]), me({
344
+ lottieObj: {
345
+ View: A,
346
+ play: g,
347
+ stop: L,
348
+ pause: w,
349
+ setSpeed: h,
350
+ goToAndStop: u,
351
+ goToAndPlay: D,
352
+ setDirection: S,
353
+ playSegments: p,
354
+ setSubframe: P,
355
+ getDuration: l,
356
+ destroy: O,
357
+ animationContainerRef: R,
358
+ animationLoaded: o,
359
+ animationItem: v
360
+ },
361
+ actions: (n = i == null ? void 0 : i.actions) !== null && n !== void 0 ? n : [],
362
+ mode: (c = i == null ? void 0 : i.mode) !== null && c !== void 0 ? c : "scroll"
363
+ });
364
+ };
365
+ export {
366
+ z as LottiePlayer,
367
+ ge as default,
368
+ le as useLottie,
369
+ me as useLottieInteractivity
370
+ };