fiboui 2.2.0 → 2.2.3

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # FiboUI v2.2.0
1
+ # FiboUI v2.2.3
2
2
 
3
3
  **A Flutter & SwiftUI-inspired React UI framework featuring a fluent builder API and fine-grained reactivity.**
4
4
 
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import s, { useRef as l, useEffect as p } from "react";
3
- import { w as x, r as m, E } from "./builder-KLTu7nAI.js";
3
+ import { y as x, r as m, E } from "./builder-3Bc2PfP9.js";
4
4
  function R({
5
5
  compute: e,
6
6
  as: n = "span",
@@ -0,0 +1,89 @@
1
+ "use client";
2
+ import { jsx as m } from "react/jsx-runtime";
3
+ import { createContext as x, useContext as p } from "react";
4
+ const v = x(null);
5
+ function o() {
6
+ const t = p(v);
7
+ if (!t)
8
+ throw new Error("useRouter must be used within a Router");
9
+ return t;
10
+ }
11
+ function C() {
12
+ return p(v);
13
+ }
14
+ function R() {
15
+ const { navigate: t } = o();
16
+ return t;
17
+ }
18
+ function g() {
19
+ const { params: t } = o();
20
+ return t;
21
+ }
22
+ function k() {
23
+ const { query: t } = o();
24
+ return t;
25
+ }
26
+ function L() {
27
+ var r;
28
+ const { currentPath: t, query: n, hash: a } = o(), e = ((r = n == null ? void 0 : n.toString) == null ? void 0 : r.call(n)) ?? "";
29
+ return {
30
+ pathname: t,
31
+ search: e ? `?${e}` : "",
32
+ hash: a ?? ""
33
+ };
34
+ }
35
+ const $ = ({
36
+ to: t,
37
+ children: n,
38
+ replace: a = !1,
39
+ state: e,
40
+ className: r,
41
+ style: h,
42
+ onClick: i
43
+ }) => {
44
+ const f = R(), c = C(), u = t.startsWith("http") || t.startsWith("//") || t.startsWith("#") ? t : `${(c == null ? void 0 : c.basename) ?? ""}${t}`;
45
+ return /* @__PURE__ */ m(
46
+ "a",
47
+ {
48
+ href: u,
49
+ onClick: (s) => {
50
+ s.ctrlKey || s.metaKey || s.shiftKey || s.button !== 0 || (s.preventDefault(), i && i(s), f(t, { replace: a, state: e }));
51
+ },
52
+ className: r,
53
+ style: h,
54
+ children: n
55
+ }
56
+ );
57
+ }, N = ({
58
+ to: t,
59
+ children: n,
60
+ className: a = "",
61
+ style: e = {},
62
+ activeClassName: r = "active",
63
+ activeStyle: h = {},
64
+ exact: i = !1,
65
+ ...f
66
+ }) => {
67
+ const { currentPath: c } = o(), u = i ? c === t : c.startsWith(t), l = u ? `${a} ${r}`.trim() : a, s = u ? { ...e, ...h } : e;
68
+ return /* @__PURE__ */ m(
69
+ $,
70
+ {
71
+ to: t,
72
+ className: l,
73
+ style: s,
74
+ ...f,
75
+ children: n
76
+ }
77
+ );
78
+ };
79
+ export {
80
+ $ as L,
81
+ N,
82
+ v as R,
83
+ R as a,
84
+ g as b,
85
+ L as c,
86
+ k as d,
87
+ C as e,
88
+ o as u
89
+ };
@@ -1,44 +1,44 @@
1
1
  "use client";
2
- var W = Object.defineProperty;
3
- var B = (o, n, e) => n in o ? W(o, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[n] = e;
4
- var R = (o, n, e) => B(o, typeof n != "symbol" ? n + "" : n, e);
5
- import { jsxs as m, jsx as r } from "react/jsx-runtime";
6
- import z, { Component as M, useState as S, useCallback as y, useEffect as j, Suspense as A, createContext as D } from "react";
7
- import { R as H } from "./Link-DDzSPY1Q.js";
8
- function U(o, n) {
9
- const e = n.split("/").filter(Boolean), a = o.split("/").filter(Boolean);
10
- if (e.length !== a.length)
2
+ var A = Object.defineProperty;
3
+ var D = (e, o, r) => o in e ? A(e, o, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[o] = r;
4
+ var E = (e, o, r) => D(e, typeof o != "symbol" ? o + "" : o, r);
5
+ import { jsxs as p, jsx as t } from "react/jsx-runtime";
6
+ import F, { Component as I, useState as w, useCallback as b, useEffect as U, Suspense as G, createContext as N } from "react";
7
+ import { R as q } from "./Link-ElmaMZB8.js";
8
+ function O(e, o) {
9
+ const r = o.split("/").filter(Boolean), i = e.split("/").filter(Boolean);
10
+ if (r.length !== i.length)
11
11
  return { match: !1, params: {} };
12
- const t = {};
13
- for (let i = 0; i < e.length; i++) {
14
- const u = e[i], h = a[i];
15
- if (u.startsWith(":")) {
16
- const w = u.slice(1);
17
- t[w] = h;
12
+ const n = {};
13
+ for (let a = 0; a < r.length; a++) {
14
+ const f = r[a], m = i[a];
15
+ if (f.startsWith(":")) {
16
+ const y = f.slice(1);
17
+ n[y] = m;
18
18
  continue;
19
19
  }
20
- if (u !== h)
20
+ if (f !== m)
21
21
  return { match: !1, params: {} };
22
22
  }
23
- return { match: !0, params: t };
23
+ return { match: !0, params: n };
24
24
  }
25
- function b(o, n) {
26
- for (const e of o) {
27
- const { match: a, params: t } = U(n, e.path);
28
- if (a)
29
- return { route: e, params: t };
30
- if (e.children) {
31
- const i = b(e.children, n);
32
- if (i.route)
33
- return i;
25
+ function x(e, o) {
26
+ for (const r of e) {
27
+ const { match: i, params: n } = O(o, r.path);
28
+ if (i)
29
+ return { route: r, params: n };
30
+ if (r.children) {
31
+ const a = x(r.children, o);
32
+ if (a.route)
33
+ return a;
34
34
  }
35
35
  }
36
36
  return { route: null, params: {} };
37
37
  }
38
- class F extends M {
39
- constructor(e) {
40
- super(e);
41
- R(this, "reset", () => {
38
+ class Q extends I {
39
+ constructor(r) {
40
+ super(r);
41
+ E(this, "reset", () => {
42
42
  this.setState({
43
43
  hasError: !1,
44
44
  error: null,
@@ -51,36 +51,36 @@ class F extends M {
51
51
  errorInfo: null
52
52
  };
53
53
  }
54
- static getDerivedStateFromError(e) {
54
+ static getDerivedStateFromError(r) {
55
55
  return {
56
56
  hasError: !0,
57
- error: e
57
+ error: r
58
58
  };
59
59
  }
60
- componentDidCatch(e, a) {
61
- var t, i;
62
- console.error("RouteErrorBoundary caught error:", e, a), (i = (t = this.props).onError) == null || i.call(t, e, a), this.setState({
63
- errorInfo: a
60
+ componentDidCatch(r, i) {
61
+ var n, a;
62
+ console.error("RouteErrorBoundary caught error:", r, i), (a = (n = this.props).onError) == null || a.call(n, r, i), this.setState({
63
+ errorInfo: i
64
64
  });
65
65
  }
66
66
  render() {
67
67
  if (this.state.hasError && this.state.error) {
68
- const { fallback: e } = this.props;
69
- return typeof e == "function" ? e(this.state.error, this.state.errorInfo) : e || /* @__PURE__ */ m("div", { style: { padding: "2rem", textAlign: "center" }, children: [
70
- /* @__PURE__ */ r("h1", { children: "Something went wrong" }),
71
- /* @__PURE__ */ r("p", { children: this.state.error.message })
68
+ const { fallback: r } = this.props;
69
+ return typeof r == "function" ? r(this.state.error, this.state.errorInfo) : r || /* @__PURE__ */ p("div", { style: { padding: "2rem", textAlign: "center" }, children: [
70
+ /* @__PURE__ */ t("h1", { children: "Something went wrong" }),
71
+ /* @__PURE__ */ t("p", { children: this.state.error.message })
72
72
  ] });
73
73
  }
74
74
  return this.props.children;
75
75
  }
76
76
  }
77
- const I = ({ error: o, onReset: n }) => {
78
- const e = () => {
77
+ const V = ({ error: e, onReset: o }) => {
78
+ const r = () => {
79
79
  window.location.href = "/";
80
- }, a = () => {
80
+ }, i = () => {
81
81
  window.location.reload();
82
82
  };
83
- return /* @__PURE__ */ r(
83
+ return /* @__PURE__ */ t(
84
84
  "div",
85
85
  {
86
86
  style: {
@@ -93,7 +93,7 @@ const I = ({ error: o, onReset: n }) => {
93
93
  backgroundColor: "#f9fafb",
94
94
  fontFamily: "system-ui, -apple-system, sans-serif"
95
95
  },
96
- children: /* @__PURE__ */ m(
96
+ children: /* @__PURE__ */ p(
97
97
  "div",
98
98
  {
99
99
  style: {
@@ -106,7 +106,7 @@ const I = ({ error: o, onReset: n }) => {
106
106
  textAlign: "center"
107
107
  },
108
108
  children: [
109
- /* @__PURE__ */ r(
109
+ /* @__PURE__ */ t(
110
110
  "div",
111
111
  {
112
112
  style: {
@@ -119,7 +119,7 @@ const I = ({ error: o, onReset: n }) => {
119
119
  alignItems: "center",
120
120
  justifyContent: "center"
121
121
  },
122
- children: /* @__PURE__ */ m(
122
+ children: /* @__PURE__ */ p(
123
123
  "svg",
124
124
  {
125
125
  width: "32",
@@ -131,15 +131,15 @@ const I = ({ error: o, onReset: n }) => {
131
131
  strokeLinecap: "round",
132
132
  strokeLinejoin: "round",
133
133
  children: [
134
- /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "10" }),
135
- /* @__PURE__ */ r("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
136
- /* @__PURE__ */ r("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
134
+ /* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "10" }),
135
+ /* @__PURE__ */ t("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
136
+ /* @__PURE__ */ t("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
137
137
  ]
138
138
  }
139
139
  )
140
140
  }
141
141
  ),
142
- /* @__PURE__ */ r(
142
+ /* @__PURE__ */ t(
143
143
  "h1",
144
144
  {
145
145
  style: {
@@ -151,7 +151,7 @@ const I = ({ error: o, onReset: n }) => {
151
151
  children: "Oops! Something went wrong"
152
152
  }
153
153
  ),
154
- o && /* @__PURE__ */ r(
154
+ e && /* @__PURE__ */ t(
155
155
  "div",
156
156
  {
157
157
  style: {
@@ -161,7 +161,7 @@ const I = ({ error: o, onReset: n }) => {
161
161
  borderRadius: "8px",
162
162
  border: "1px solid #fecaca"
163
163
  },
164
- children: /* @__PURE__ */ r(
164
+ children: /* @__PURE__ */ t(
165
165
  "p",
166
166
  {
167
167
  style: {
@@ -171,12 +171,12 @@ const I = ({ error: o, onReset: n }) => {
171
171
  margin: 0,
172
172
  wordBreak: "break-word"
173
173
  },
174
- children: o.message
174
+ children: e.message
175
175
  }
176
176
  )
177
177
  }
178
178
  ),
179
- /* @__PURE__ */ r(
179
+ /* @__PURE__ */ t(
180
180
  "p",
181
181
  {
182
182
  style: {
@@ -188,7 +188,7 @@ const I = ({ error: o, onReset: n }) => {
188
188
  children: "We're sorry for the inconvenience. Please try one of the options below."
189
189
  }
190
190
  ),
191
- /* @__PURE__ */ m(
191
+ /* @__PURE__ */ p(
192
192
  "div",
193
193
  {
194
194
  style: {
@@ -198,10 +198,10 @@ const I = ({ error: o, onReset: n }) => {
198
198
  flexWrap: "wrap"
199
199
  },
200
200
  children: [
201
- n && /* @__PURE__ */ r(
201
+ o && /* @__PURE__ */ t(
202
202
  "button",
203
203
  {
204
- onClick: n,
204
+ onClick: o,
205
205
  style: {
206
206
  padding: "0.75rem 1.5rem",
207
207
  backgroundColor: "#3b82f6",
@@ -213,19 +213,19 @@ const I = ({ error: o, onReset: n }) => {
213
213
  cursor: "pointer",
214
214
  transition: "background-color 0.2s"
215
215
  },
216
- onMouseEnter: (t) => {
217
- t.currentTarget.style.backgroundColor = "#2563eb";
216
+ onMouseEnter: (n) => {
217
+ n.currentTarget.style.backgroundColor = "#2563eb";
218
218
  },
219
- onMouseLeave: (t) => {
220
- t.currentTarget.style.backgroundColor = "#3b82f6";
219
+ onMouseLeave: (n) => {
220
+ n.currentTarget.style.backgroundColor = "#3b82f6";
221
221
  },
222
222
  children: "Try Again"
223
223
  }
224
224
  ),
225
- /* @__PURE__ */ r(
225
+ /* @__PURE__ */ t(
226
226
  "button",
227
227
  {
228
- onClick: a,
228
+ onClick: i,
229
229
  style: {
230
230
  padding: "0.75rem 1.5rem",
231
231
  backgroundColor: "#6b7280",
@@ -237,19 +237,19 @@ const I = ({ error: o, onReset: n }) => {
237
237
  cursor: "pointer",
238
238
  transition: "background-color 0.2s"
239
239
  },
240
- onMouseEnter: (t) => {
241
- t.currentTarget.style.backgroundColor = "#4b5563";
240
+ onMouseEnter: (n) => {
241
+ n.currentTarget.style.backgroundColor = "#4b5563";
242
242
  },
243
- onMouseLeave: (t) => {
244
- t.currentTarget.style.backgroundColor = "#6b7280";
243
+ onMouseLeave: (n) => {
244
+ n.currentTarget.style.backgroundColor = "#6b7280";
245
245
  },
246
246
  children: "Reload Page"
247
247
  }
248
248
  ),
249
- /* @__PURE__ */ r(
249
+ /* @__PURE__ */ t(
250
250
  "button",
251
251
  {
252
- onClick: e,
252
+ onClick: r,
253
253
  style: {
254
254
  padding: "0.75rem 1.5rem",
255
255
  backgroundColor: "white",
@@ -261,11 +261,11 @@ const I = ({ error: o, onReset: n }) => {
261
261
  cursor: "pointer",
262
262
  transition: "all 0.2s"
263
263
  },
264
- onMouseEnter: (t) => {
265
- t.currentTarget.style.backgroundColor = "#f9fafb", t.currentTarget.style.borderColor = "#9ca3af";
264
+ onMouseEnter: (n) => {
265
+ n.currentTarget.style.backgroundColor = "#f9fafb", n.currentTarget.style.borderColor = "#9ca3af";
266
266
  },
267
- onMouseLeave: (t) => {
268
- t.currentTarget.style.backgroundColor = "white", t.currentTarget.style.borderColor = "#d1d5db";
267
+ onMouseLeave: (n) => {
268
+ n.currentTarget.style.backgroundColor = "white", n.currentTarget.style.borderColor = "#d1d5db";
269
269
  },
270
270
  children: "Go Home"
271
271
  }
@@ -273,7 +273,7 @@ const I = ({ error: o, onReset: n }) => {
273
273
  ]
274
274
  }
275
275
  ),
276
- (o == null ? void 0 : o.stack) && /* @__PURE__ */ m(
276
+ (e == null ? void 0 : e.stack) && /* @__PURE__ */ p(
277
277
  "details",
278
278
  {
279
279
  style: {
@@ -281,7 +281,7 @@ const I = ({ error: o, onReset: n }) => {
281
281
  textAlign: "left"
282
282
  },
283
283
  children: [
284
- /* @__PURE__ */ r(
284
+ /* @__PURE__ */ t(
285
285
  "summary",
286
286
  {
287
287
  style: {
@@ -293,7 +293,7 @@ const I = ({ error: o, onReset: n }) => {
293
293
  children: "Stack Trace"
294
294
  }
295
295
  ),
296
- /* @__PURE__ */ r(
296
+ /* @__PURE__ */ t(
297
297
  "pre",
298
298
  {
299
299
  style: {
@@ -306,7 +306,7 @@ const I = ({ error: o, onReset: n }) => {
306
306
  overflow: "auto",
307
307
  maxHeight: "300px"
308
308
  },
309
- children: o.stack
309
+ children: e.stack
310
310
  }
311
311
  )
312
312
  ]
@@ -317,70 +317,82 @@ const I = ({ error: o, onReset: n }) => {
317
317
  )
318
318
  }
319
319
  );
320
- }, G = D(null), V = ({
321
- routes: o,
322
- fallback: n,
323
- loading: e,
324
- basename: a = "",
325
- errorBoundary: t,
326
- onError: i
320
+ };
321
+ function T(e, o) {
322
+ return o && e.startsWith(o) ? e.slice(o.length) || "/" : e || "/";
323
+ }
324
+ function $(e) {
325
+ return e ? e.startsWith("?") ? e.slice(1) : e : "";
326
+ }
327
+ function J(e) {
328
+ return e ? e.startsWith("#") ? e : `#${e}` : "";
329
+ }
330
+ const K = N(null), ee = ({
331
+ routes: e,
332
+ fallback: o,
333
+ loading: r,
334
+ basename: i = "",
335
+ initialPath: n = "/",
336
+ initialSearch: a = "",
337
+ initialHash: f = "",
338
+ errorBoundary: m,
339
+ onError: y
327
340
  }) => {
328
- const [u, h] = S(() => typeof window > "u" ? "/" : window.location.pathname.replace(a, "") || "/"), [w, x] = S(
329
- () => typeof window > "u" ? new URLSearchParams() : new URLSearchParams(window.location.search)
330
- ), { route: p, params: P } = b(o, u), k = z.useRef(p);
331
- k.current = p;
332
- const g = y(async (s, c = {}) => {
333
- const f = k.current, { route: l } = b(o, s);
334
- if (f != null && f.beforeLeave && l) {
335
- const d = await f.beforeLeave(l, f);
336
- if (d === !1)
341
+ const [k, C] = w(() => T(n, i)), [W, v] = w(() => new URLSearchParams($(a))), [L, z] = w(() => J(f)), { route: h, params: B } = x(e, k), R = F.useRef(h);
342
+ R.current = h;
343
+ const g = b(async (s, d = {}) => {
344
+ const u = R.current, { route: c } = x(e, s);
345
+ if (u != null && u.beforeLeave && c) {
346
+ const l = await u.beforeLeave(c, u);
347
+ if (l === !1)
337
348
  return;
338
- if (typeof d == "string")
339
- return g(d, c);
349
+ if (typeof l == "string")
350
+ return g(l, d);
340
351
  }
341
- if (l != null && l.beforeEnter) {
342
- const d = await l.beforeEnter(l, f);
343
- if (d === !1)
352
+ if (c != null && c.beforeEnter) {
353
+ const l = await c.beforeEnter(c, u);
354
+ if (l === !1)
344
355
  return;
345
- typeof d == "string" && (s = d);
356
+ typeof l == "string" && (s = l);
346
357
  }
347
- const v = a + s;
348
- typeof window < "u" && (c.replace ? window.history.replaceState(c.state || {}, "", v) : window.history.pushState(c.state || {}, "", v), x(new URLSearchParams(window.location.search))), h(s);
349
- }, [a, o]), E = y(() => {
358
+ const P = i + s;
359
+ typeof window < "u" && (d.replace ? window.history.replaceState(d.state || {}, "", P) : window.history.pushState(d.state || {}, "", P), v(new URLSearchParams(window.location.search))), C(s);
360
+ }, [i, e]), M = b(() => {
350
361
  typeof window < "u" && window.history.back();
351
- }, []), T = y((s) => {
362
+ }, []), j = b((s) => {
352
363
  g(s, { replace: !0 });
353
364
  }, [g]);
354
- j(() => {
365
+ U(() => {
366
+ if (typeof window > "u") return;
355
367
  const s = () => {
356
- const c = window.location.pathname.replace(a, "") || "/";
357
- h(c), x(new URLSearchParams(window.location.search));
368
+ C(T(window.location.pathname, i)), v(new URLSearchParams(window.location.search)), z(window.location.hash || "");
358
369
  };
359
- return window.addEventListener("popstate", s), () => window.removeEventListener("popstate", s);
360
- }, [a]);
361
- const L = {
362
- currentPath: u,
363
- basename: a,
370
+ return s(), window.addEventListener("popstate", s), () => window.removeEventListener("popstate", s);
371
+ }, [i]);
372
+ const H = {
373
+ currentPath: k,
374
+ basename: i,
364
375
  navigate: g,
365
- goBack: E,
366
- replace: T,
367
- params: P,
368
- query: w
369
- }, C = () => {
370
- if (!p)
371
- return n ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("div", { children: "404 - Page Not Found" });
372
- const s = p.component, c = /* @__PURE__ */ r(G.Provider, { value: p, children: /* @__PURE__ */ r(s, {}) });
373
- return /* @__PURE__ */ r(
374
- F,
376
+ goBack: M,
377
+ replace: j,
378
+ params: B,
379
+ query: W,
380
+ hash: L
381
+ }, S = () => {
382
+ if (!h)
383
+ return o ? /* @__PURE__ */ t(o, {}) : /* @__PURE__ */ t("div", { children: "404 - Page Not Found" });
384
+ const s = h.component, d = /* @__PURE__ */ t(K.Provider, { value: h, children: /* @__PURE__ */ t(s, {}) });
385
+ return /* @__PURE__ */ t(
386
+ Q,
375
387
  {
376
- fallback: t || /* @__PURE__ */ r(I, {}),
377
- onError: i,
378
- children: c
388
+ fallback: m || /* @__PURE__ */ t(V, {}),
389
+ onError: y,
390
+ children: d
379
391
  }
380
392
  );
381
393
  };
382
- return /* @__PURE__ */ r(H.Provider, { value: L, children: e ? /* @__PURE__ */ r(A, { fallback: e, children: C() }) : C() });
394
+ return /* @__PURE__ */ t(q.Provider, { value: H, children: r ? /* @__PURE__ */ t(G, { fallback: r, children: S() }) : S() });
383
395
  };
384
396
  export {
385
- V as R
397
+ ee as R
386
398
  };