fiboui 2.1.0 → 2.2.0

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,331 @@
1
+ "use client";
2
+ var q = Object.defineProperty;
3
+ var I = (e, t, n) => t in e ? q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
4
+ var w = (e, t, n) => I(e, typeof t != "symbol" ? t + "" : t, n);
5
+ import p, { useCallback as S, useSyncExternalStore as F, useState as g, useRef as y, useEffect as v, StrictMode as T } from "react";
6
+ import { p as L, S as A, v as k, x as j, y as z, F as $, R, z as H, P as N, A as W, B as D } from "./builder-KLTu7nAI.js";
7
+ import { createRoot as x } from "react-dom/client";
8
+ import { P as Y } from "./PluginManager-D5-ApsSN.js";
9
+ function G(e) {
10
+ return (t) => e.subscribe(t);
11
+ }
12
+ function ae(e) {
13
+ const t = S(G(e), [e]);
14
+ return F(t, () => e.value, () => e.value);
15
+ }
16
+ function ce(e) {
17
+ const t = S(
18
+ (n) => e.subscribe(n),
19
+ [e]
20
+ );
21
+ return F(t, () => e.getState(), () => e.getState());
22
+ }
23
+ function le(e) {
24
+ const t = S(
25
+ (n) => e.subscribe(n),
26
+ [e]
27
+ );
28
+ return F(t, () => e.get(), () => e.get());
29
+ }
30
+ const J = {
31
+ linear: (e) => e,
32
+ easeIn: (e) => e * e,
33
+ easeOut: (e) => e * (2 - e),
34
+ easeInOut: (e) => e < 0.5 ? 2 * e * e : -1 + (4 - 2 * e) * e,
35
+ easeInCubic: (e) => e * e * e,
36
+ easeOutCubic: (e) => --e * e * e + 1,
37
+ elastic: (e) => e === 0 || e === 1 ? e : Math.pow(2, -10 * e) * Math.sin((e - 0.075) * (2 * Math.PI) / 0.3) + 1,
38
+ bounce: (e) => e < 1 / 2.75 ? 7.5625 * e * e : e < 2 / 2.75 ? 7.5625 * (e -= 1.5 / 2.75) * e + 0.75 : e < 2.5 / 2.75 ? 7.5625 * (e -= 2.25 / 2.75) * e + 0.9375 : 7.5625 * (e -= 2.625 / 2.75) * e + 0.984375
39
+ };
40
+ function de(e, t) {
41
+ const { duration: n = 300, delay: r = 0, easing: l = J.easeOut } = t || {}, [i, a] = g(e), s = y(), d = y(i);
42
+ return d.current = i, v(() => {
43
+ s.current && cancelAnimationFrame(s.current);
44
+ let o = null;
45
+ const u = d.current, c = (m) => {
46
+ o || (o = m);
47
+ const f = m - o - r;
48
+ if (f < 0) {
49
+ s.current = requestAnimationFrame(c);
50
+ return;
51
+ }
52
+ const h = Math.min(f / n, 1), M = l(h), _ = u + (e - u) * M;
53
+ a(_), h < 1 && (s.current = requestAnimationFrame(c));
54
+ };
55
+ return s.current = requestAnimationFrame(c), () => {
56
+ s.current && cancelAnimationFrame(s.current);
57
+ };
58
+ }, [e, n, r]), i;
59
+ }
60
+ function fe(e, t) {
61
+ const { stiffness: n = 170, damping: r = 26, mass: l = 1 } = t || {}, [i, a] = g(e), s = y(0), d = y();
62
+ return v(() => {
63
+ let o = i, u = s.current;
64
+ const c = () => {
65
+ const m = -n * (o - e), f = -r * u, h = (m + f) / l;
66
+ u += h * (1 / 60), o += u * (1 / 60), a(o), s.current = u, (Math.abs(u) > 0.01 || Math.abs(o - e) > 0.01) && (d.current = requestAnimationFrame(c));
67
+ };
68
+ return d.current = requestAnimationFrame(c), () => {
69
+ d.current && cancelAnimationFrame(d.current);
70
+ };
71
+ }, [e, n, r, l]), i;
72
+ }
73
+ function me(e, t = 300) {
74
+ const [n, r] = g(e), [l, i] = g(
75
+ e ? "entered" : "exited"
76
+ );
77
+ return v(() => {
78
+ if (e) {
79
+ r(!0), i("entering");
80
+ const a = setTimeout(() => i("entered"), 50);
81
+ return () => clearTimeout(a);
82
+ } else {
83
+ i("exiting");
84
+ const a = setTimeout(() => {
85
+ i("exited"), r(!1);
86
+ }, t);
87
+ return () => clearTimeout(a);
88
+ }
89
+ }, [e, t]), { shouldRender: n, stage: l };
90
+ }
91
+ function he(e, t = 50) {
92
+ return Array.from({ length: e }, (n, r) => r * t);
93
+ }
94
+ function pe() {
95
+ const [e, t] = g(
96
+ () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches
97
+ );
98
+ return v(() => {
99
+ if (typeof window > "u" || typeof window.matchMedia != "function") return;
100
+ const n = window.matchMedia("(prefers-reduced-motion: reduce)"), r = () => t(n.matches);
101
+ return r(), n.addEventListener("change", r), () => n.removeEventListener("change", r);
102
+ }, []), e;
103
+ }
104
+ function ge() {
105
+ const [e, t] = g(0);
106
+ return v(() => {
107
+ if (typeof window > "u") return;
108
+ const n = () => {
109
+ const r = document.documentElement.scrollHeight - window.innerHeight;
110
+ t(r > 0 ? Math.min(1, Math.max(0, window.scrollY / r)) : 0);
111
+ };
112
+ return n(), window.addEventListener("scroll", n, { passive: !0 }), window.addEventListener("resize", n), () => {
113
+ window.removeEventListener("scroll", n), window.removeEventListener("resize", n);
114
+ };
115
+ }, []), e;
116
+ }
117
+ const P = {
118
+ linear: (e) => e,
119
+ easeIn: (e) => e * e,
120
+ easeOut: (e) => e * (2 - e),
121
+ easeInOut: (e) => e < 0.5 ? 2 * e * e : -1 + (4 - 2 * e) * e
122
+ };
123
+ function K(e, t, n) {
124
+ return e + (t - e) * n;
125
+ }
126
+ const b = /* @__PURE__ */ new WeakMap();
127
+ A.prototype.spring = function(e, t = {}) {
128
+ this.animate(e, { ...t, curve: "spring", damping: t.damping ?? 26, stiffness: t.stiffness ?? 170 });
129
+ };
130
+ A.prototype.animate = function(e, t = {}) {
131
+ const n = this.value, r = e, l = b.get(this);
132
+ if (l && cancelAnimationFrame(l), t.curve === "spring") {
133
+ const o = t.stiffness ?? 170, u = t.damping ?? 26, c = t.mass ?? 1;
134
+ let m = n, f = t.velocity ?? 0;
135
+ const h = 1 / 60, M = () => {
136
+ var C;
137
+ const _ = -o * (m - r) - u * f;
138
+ f += _ / c * h, m += f * h, this.value = m, Math.abs(m - r) > 0.01 || Math.abs(f) > 0.01 ? b.set(this, requestAnimationFrame(M)) : (this.value = r, b.delete(this), (C = t.onComplete) == null || C.call(t));
139
+ };
140
+ b.set(this, requestAnimationFrame(M));
141
+ return;
142
+ }
143
+ const i = t.duration || 300, a = P[t.curve || "easeOut"] ?? P.easeOut;
144
+ let s = null;
145
+ const d = (o) => {
146
+ var c;
147
+ s || (s = o);
148
+ const u = Math.min((o - s) / i, 1);
149
+ this.value = K(n, r, a(u)), u < 1 ? b.set(this, requestAnimationFrame(d)) : (b.delete(this), (c = t.onComplete) == null || c.call(t));
150
+ };
151
+ b.set(this, requestAnimationFrame(d));
152
+ };
153
+ A.prototype.snapTo = function(e, t = {}) {
154
+ this.animate(e, { duration: 300, curve: "easeOut", ...t });
155
+ };
156
+ function we(e = {}) {
157
+ return L(e.curve ?? "easeOut", {
158
+ stiffness: e.stiffness,
159
+ damping: e.damping,
160
+ mass: e.mass
161
+ });
162
+ }
163
+ function E(e) {
164
+ return !!e && typeof e == "object" && "value" in e && typeof e.subscribe == "function";
165
+ }
166
+ function Q(e) {
167
+ return !e || typeof e != "object" || E(e) ? !1 : Object.prototype.hasOwnProperty.call(e, "show");
168
+ }
169
+ function U() {
170
+ return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
171
+ }
172
+ function X(e) {
173
+ return E(e) ? !!e.value : !!e;
174
+ }
175
+ function Z(e) {
176
+ const [t, n] = g(() => X(e));
177
+ return v(() => {
178
+ if (!E(e)) {
179
+ n(!!e);
180
+ return;
181
+ }
182
+ return n(!!e.value), e.subscribe((r) => n(!!r));
183
+ }, [e]), E(e) ? t : !!e;
184
+ }
185
+ function B({
186
+ show: e,
187
+ enter: t = "fadeIn",
188
+ exit: n = "fadeOut",
189
+ duration: r = 200,
190
+ reducedMotion: l = "reduce",
191
+ children: i
192
+ }) {
193
+ const a = Z(e), [s, d] = g(a), [o, u] = g(a ? "enter" : "idle"), c = l !== "never" && U();
194
+ if (v(() => {
195
+ if (j(), a) {
196
+ d(!0), u(c ? "idle" : "enter");
197
+ return;
198
+ }
199
+ if (s) {
200
+ if (c) {
201
+ d(!1), u("idle");
202
+ return;
203
+ }
204
+ u("exit");
205
+ }
206
+ }, [a, c]), !s) return null;
207
+ const m = o === "exit" ? n : o === "enter" ? t : void 0, f = m && !c ? z(m) : void 0;
208
+ return p.createElement(
209
+ "div",
210
+ {
211
+ className: f ? `fibo-anim fibo-anim-${f}` : void 0,
212
+ style: f ? { "--fibo-dur": `${r}ms`, "--fibo-ease": "ease" } : void 0,
213
+ "data-fibo-presence": o,
214
+ onAnimationEnd: (h) => {
215
+ h.target === h.currentTarget && (o === "exit" && d(!1), o === "enter" && u("idle"));
216
+ }
217
+ },
218
+ i
219
+ );
220
+ }
221
+ class V extends $ {
222
+ constructor(n = !0) {
223
+ super();
224
+ w(this, "_show", !0);
225
+ w(this, "_enter", "fadeIn");
226
+ w(this, "_exit", "fadeOut");
227
+ this.show(n);
228
+ }
229
+ show(n) {
230
+ return this._show = n, E(n) && (this.bindSignal(n), this.observer()), this;
231
+ }
232
+ enter(n) {
233
+ return this._enter = n, this;
234
+ }
235
+ exit(n) {
236
+ return this._exit = n, this;
237
+ }
238
+ duration(n) {
239
+ return this._transitionDuration = n, this;
240
+ }
241
+ build() {
242
+ return p.createElement(B, {
243
+ show: this._show,
244
+ enter: this._enter,
245
+ exit: this._exit,
246
+ duration: this._transitionDuration,
247
+ reducedMotion: this._reducedMotion,
248
+ children: this.processChildren()
249
+ });
250
+ }
251
+ }
252
+ const ee = k(V);
253
+ function te(e) {
254
+ return Q(e) ? p.createElement(B, e) : ee(e ?? !0);
255
+ }
256
+ te.displayName = "Presence";
257
+ class ne {
258
+ constructor() {
259
+ w(this, "_rootComponent", null);
260
+ w(this, "_rootElement", null);
261
+ w(this, "_plugins", []);
262
+ }
263
+ use(t) {
264
+ return this._plugins.push(t), this;
265
+ }
266
+ plugins(t) {
267
+ return this._plugins.push(...t), this;
268
+ }
269
+ root(t) {
270
+ return this._rootComponent = t, this;
271
+ }
272
+ mount(t) {
273
+ const n = document.getElementById(t);
274
+ if (!n)
275
+ throw new Error(`Root element with id "${t}" not found`);
276
+ this._rootElement = n, this.build();
277
+ }
278
+ build() {
279
+ if (!this._rootComponent || !this._rootElement)
280
+ throw new Error("Root component and mount element must be provided");
281
+ const t = Y.getInstance();
282
+ this._plugins.forEach((i) => {
283
+ t.use(i);
284
+ });
285
+ const n = this._rootComponent, r = () => p.createElement(R, {
286
+ children: p.createElement(H, {
287
+ stateMap: /* @__PURE__ */ new Map(),
288
+ children: p.createElement(N, {
289
+ providers: /* @__PURE__ */ new Map(),
290
+ children: p.createElement(n, null)
291
+ })
292
+ })
293
+ });
294
+ x(this._rootElement).render(p.createElement(r));
295
+ }
296
+ }
297
+ const be = () => new ne();
298
+ function O(e) {
299
+ return D(e);
300
+ }
301
+ function ve({ children: e }) {
302
+ return O(e);
303
+ }
304
+ function Ee(e, t, n) {
305
+ const r = typeof e == "string" ? document.querySelector(e) : e;
306
+ if (!r)
307
+ throw new Error(`mount: element not found: ${String(e)}`);
308
+ const l = typeof t == "function" && !W(t) ? t() : t, i = O(l), a = x(r), s = p.createElement(R, { children: i });
309
+ return a.render(
310
+ (n == null ? void 0 : n.strict) === !1 ? s : p.createElement(T, null, s)
311
+ ), a;
312
+ }
313
+ export {
314
+ J as E,
315
+ be as F,
316
+ te as P,
317
+ ce as a,
318
+ le as b,
319
+ de as c,
320
+ fe as d,
321
+ he as e,
322
+ me as f,
323
+ pe as g,
324
+ ge as h,
325
+ we as i,
326
+ ne as j,
327
+ ve as k,
328
+ Ee as m,
329
+ O as t,
330
+ ae as u
331
+ };
package/dist/structure.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { B as e } from "./index-BaX5zy8O.js";
3
- import { B as i, C as o, c as t, G as l, d, L as B, a as T, T as m, b as n } from "./index-C4xZywsh.js";
2
+ import { B as e } from "./index-CYnY7jAX.js";
3
+ import { B as i, C as o, c as t, G as l, d, L as B, a as T, T as m, b as n } from "./index-CdJvNseK.js";
4
4
  export {
5
5
  i as Banner,
6
6
  e as Box,