@mateosuarezdev/react-ui 1.0.6 → 1.0.9

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as f, jsxs as w, Fragment as Te } from "react/jsx-runtime";
2
- import { useRef as N, useEffect as j, useState as L, useSyncExternalStore as Ke, useCallback as K, useId as ve, forwardRef as H, memo as Be, useContext as xe, createContext as we } from "react";
2
+ import { useRef as N, useEffect as j, useState as L, useSyncExternalStore as Ke, useCallback as K, useId as xe, forwardRef as H, memo as Be, useContext as ve, createContext as we } from "react";
3
3
  import { createPortal as ye } from "react-dom";
4
4
  import { clsx as Ve } from "clsx";
5
5
  import { twMerge as Xe } from "tailwind-merge";
@@ -195,7 +195,7 @@ const Q = (e) => {
195
195
  t
196
196
  ),
197
197
  children: /* @__PURE__ */ w(
198
- xt,
198
+ vt,
199
199
  {
200
200
  size: r === "xs" ? 16 : r === "sm" ? 20 : 24,
201
201
  fill: "none",
@@ -293,7 +293,7 @@ const at = (e = !0, n) => {
293
293
  const [c, u] = L(!1), [d, b] = L({
294
294
  width: 192,
295
295
  height: 300
296
- }), m = N(null), g = N(null), v = N({
296
+ }), m = N(null), g = N(null), x = N({
297
297
  left: 0,
298
298
  right: 0,
299
299
  top: 0,
@@ -302,9 +302,9 @@ const at = (e = !0, n) => {
302
302
  y: 0,
303
303
  width: 0,
304
304
  height: 0
305
- }), x = N(null), A = ve(), F = K(
305
+ }), v = N(null), A = xe(), F = K(
306
306
  (E) => {
307
- const z = E ?? v.current;
307
+ const z = E ?? x.current;
308
308
  if (!z) return { x: 0, top: 0, bottom: void 0 };
309
309
  const _ = d.width, B = d.height;
310
310
  return ut({
@@ -318,18 +318,18 @@ const at = (e = !0, n) => {
318
318
  avoidCollisions: l
319
319
  });
320
320
  },
321
- [v.current, d, n, r]
321
+ [x.current, d, n, r]
322
322
  );
323
323
  j(() => {
324
- if (!c || !e || (x.current = document.getElementById(e), !x.current)) return;
324
+ if (!c || !e || (v.current = document.getElementById(e), !v.current)) return;
325
325
  c && O();
326
326
  const E = () => {
327
- x.current && (u(!1), o?.(), x.current.removeEventListener("scroll", E));
327
+ v.current && (u(!1), o?.(), v.current.removeEventListener("scroll", E));
328
328
  };
329
- return s && x.current.addEventListener("scroll", E, {
329
+ return s && v.current.addEventListener("scroll", E, {
330
330
  passive: !0
331
331
  }), () => {
332
- x.current && x.current.removeEventListener("scroll", E);
332
+ v.current && v.current.removeEventListener("scroll", E);
333
333
  };
334
334
  }, [c, e]);
335
335
  const O = () => {
@@ -340,7 +340,7 @@ const at = (e = !0, n) => {
340
340
  }, S = K(() => {
341
341
  if (!m.current) return;
342
342
  const E = m.current.getBoundingClientRect();
343
- v.current = {
343
+ x.current = {
344
344
  left: E.left,
345
345
  right: E.right,
346
346
  top: E.top,
@@ -387,25 +387,25 @@ const at = (e = !0, n) => {
387
387
  let c = 0, u = 0;
388
388
  if (o) {
389
389
  if (i === "right") {
390
- const m = e.right + l, g = e.left - n - l, v = Math.max(
390
+ const m = e.right + l, g = e.left - n - l, x = Math.max(
391
391
  0,
392
392
  m + n - (a.width - s)
393
- ), x = Math.max(0, s - g);
394
- v <= x ? (c = m, v > 0 && (c = a.width - n - s)) : (c = g, x > 0 && (c = s)), u = e.top, u + r > a.height - s && (u = a.height - r - s), u < s && (u = s);
393
+ ), v = Math.max(0, s - g);
394
+ x <= v ? (c = m, x > 0 && (c = a.width - n - s)) : (c = g, v > 0 && (c = s)), u = e.top, u + r > a.height - s && (u = a.height - r - s), u < s && (u = s);
395
395
  } else if (i === "left") {
396
- const m = e.left - n - l, g = e.right + l, v = Math.max(0, s - m), x = Math.max(
396
+ const m = e.left - n - l, g = e.right + l, x = Math.max(0, s - m), v = Math.max(
397
397
  0,
398
398
  g + n - (a.width - s)
399
399
  );
400
- v <= x ? (c = m, v > 0 && (c = s)) : (c = g, x > 0 && (c = a.width - n - s)), u = e.top, u + r > a.height - s && (u = a.height - r - s), u < s && (u = s);
400
+ x <= v ? (c = m, x > 0 && (c = s)) : (c = g, v > 0 && (c = a.width - n - s)), u = e.top, u + r > a.height - s && (u = a.height - r - s), u < s && (u = s);
401
401
  } else if (i === "bottom") {
402
402
  const m = a.height - e.bottom, g = e.top;
403
403
  m >= r + l ? u = e.bottom + l : g >= r + l ? u = e.top - r - l : (u = e.bottom + l, u = Math.min(u, a.height - r - s));
404
- const v = a.width - e.left, x = e.right;
404
+ const x = a.width - e.left, v = e.right;
405
405
  if (t === "start")
406
- c = e.left, c + n > a.width - s && (x >= n ? c = e.right - n : c = a.width - n - s);
406
+ c = e.left, c + n > a.width - s && (v >= n ? c = e.right - n : c = a.width - n - s);
407
407
  else if (t === "end")
408
- c = e.right - n, c < s && (v >= n ? c = e.left : c = s);
408
+ c = e.right - n, c < s && (x >= n ? c = e.left : c = s);
409
409
  else {
410
410
  const A = e.left + e.width / 2 - n / 2;
411
411
  A >= s && A + n <= a.width - s ? c = A : A < s ? c = s : c = a.width - n - s;
@@ -413,11 +413,11 @@ const at = (e = !0, n) => {
413
413
  } else {
414
414
  const m = e.top, g = a.height - e.bottom;
415
415
  m >= r + l ? u = e.top - r - l : g >= r + l ? u = e.bottom + l : (u = e.top - r - l, u = Math.max(s, u));
416
- const v = a.width - e.left, x = e.right;
416
+ const x = a.width - e.left, v = e.right;
417
417
  if (t === "start")
418
- c = e.left, c + n > a.width - s && (x >= n ? c = e.right - n : c = a.width - n - s);
418
+ c = e.left, c + n > a.width - s && (v >= n ? c = e.right - n : c = a.width - n - s);
419
419
  else if (t === "end")
420
- c = e.right - n, c < s && (v >= n ? c = e.left : c = s);
420
+ c = e.right - n, c < s && (x >= n ? c = e.left : c = s);
421
421
  else {
422
422
  const A = e.left + e.width / 2 - n / 2;
423
423
  A >= s && A + n <= a.width - s ? c = A : A < s ? c = s : c = a.width - n - s;
@@ -532,7 +532,7 @@ const dt = "relative shrink-0 select-none transition outline-none duration-200 e
532
532
  danger: "bg-red-4 text-red-9 lg:hover:bg-red-5 focus:ring-red-9 border border-transparent",
533
533
  dangersolid: "bg-red-9 text-base-1 dark-theme:text-base-12 lg:hover:bg-red-8 focus:ring-base-6 border border-transparent",
534
534
  disabled: "bg-base-3 text-base-11 border border-transparent"
535
- }, vt = {
535
+ }, xt = {
536
536
  enabled: "",
537
537
  disabled: "opacity-75",
538
538
  loading: ""
@@ -553,8 +553,8 @@ const dt = "relative shrink-0 select-none transition outline-none duration-200 e
553
553
  type: b = "button",
554
554
  ...m
555
555
  }, g) => {
556
- const [v, x] = L(!1), A = ($) => {
557
- i === "enabled" && (d ? (x(!0), l && l($), setTimeout(() => x(!1), 1e3)) : l && l($));
556
+ const [x, v] = L(!1), A = ($) => {
557
+ i === "enabled" && (d ? (v(!0), l && l($), setTimeout(() => v(!1), 1e3)) : l && l($));
558
558
  }, { ref: F, ripple: O } = at(
559
559
  a,
560
560
  e === "contrast" || c
@@ -566,7 +566,7 @@ const dt = "relative shrink-0 select-none transition outline-none duration-200 e
566
566
  type: b,
567
567
  disabled: m.disabled ? m.disabled : i === "disabled" || i === "loading",
568
568
  onMouseDown: O,
569
- onClick: ($) => v ? null : A($),
569
+ onClick: ($) => x ? null : A($),
570
570
  className: p(
571
571
  dt,
572
572
  ht[n],
@@ -574,7 +574,7 @@ const dt = "relative shrink-0 select-none transition outline-none duration-200 e
574
574
  pt[t],
575
575
  mt[u],
576
576
  gt[e],
577
- vt[i],
577
+ xt[i],
578
578
  m.disabled && "opacity-50",
579
579
  s
580
580
  ),
@@ -585,7 +585,7 @@ const dt = "relative shrink-0 select-none transition outline-none duration-200 e
585
585
  }
586
586
  );
587
587
  ie.displayName = "Button";
588
- const ur = ({ className: e }) => /* @__PURE__ */ f("div", { className: p("w-full h-px bg-base-4", e) }), xt = ({
588
+ const ur = ({ className: e }) => /* @__PURE__ */ f("div", { className: p("w-full h-px bg-base-4", e) }), vt = ({
589
589
  children: e,
590
590
  size: n = 24,
591
591
  strokeWidth: r = 2,
@@ -847,8 +847,8 @@ const G = {
847
847
  }, u) => {
848
848
  const d = () => {
849
849
  r || n?.(e === "indeterminate" ? !0 : !e);
850
- }, b = (v) => {
851
- (v.key === " " || v.key === "Enter") && (v.preventDefault(), d());
850
+ }, b = (x) => {
851
+ (x.key === " " || x.key === "Enter") && (x.preventDefault(), d());
852
852
  }, m = {
853
853
  xs: "h-3.5 w-3.5",
854
854
  sm: "h-4 w-4",
@@ -948,10 +948,10 @@ const Mt = {
948
948
  containerClassName: b,
949
949
  className: m,
950
950
  type: g = "text",
951
- value: v,
952
- ...x
951
+ value: x,
952
+ ...v
953
953
  }, A) => {
954
- const F = N(null), O = N(!1), [S, $] = L(!1), [E, z] = L(!1), _ = g === "password", B = _ && S ? "text" : c ? "number" : g, U = v !== "" && v !== null && v !== void 0;
954
+ const F = N(null), O = N(!1), [S, $] = L(!1), [E, z] = L(!1), _ = g === "password", B = _ && S ? "text" : c ? "number" : g, U = x !== "" && x !== null && x !== void 0;
955
955
  return j(() => {
956
956
  if (!O.current) {
957
957
  O.current = !0;
@@ -1025,11 +1025,11 @@ const Mt = {
1025
1025
  },
1026
1026
  m
1027
1027
  ),
1028
- value: v,
1028
+ value: x,
1029
1029
  placeholder: l,
1030
1030
  onFocus: () => z(!0),
1031
1031
  onBlur: () => z(!1),
1032
- ...x
1032
+ ...v
1033
1033
  }
1034
1034
  )
1035
1035
  ]
@@ -1235,7 +1235,7 @@ const mr = ({
1235
1235
  maxTags: a,
1236
1236
  validateTag: c
1237
1237
  }) => {
1238
- const [u, d] = L(""), [b, m] = L(!1), [g, v] = L(null), x = N(null), A = N(null), F = N([]), O = t.length > 0, S = N(
1238
+ const [u, d] = L(""), [b, m] = L(!1), [g, x] = L(null), v = N(null), A = N(null), F = N([]), O = t.length > 0, S = N(
1239
1239
  `taginput-${Math.random().toString(36).substr(2, 9)}`
1240
1240
  ).current, $ = N(
1241
1241
  `label-${Math.random().toString(36).substr(2, 9)}`
@@ -1250,24 +1250,24 @@ const mr = ({
1250
1250
  k.preventDefault();
1251
1251
  const C = u.trim();
1252
1252
  if (a && t.length >= a) {
1253
- v(`Maximum of ${a} tags allowed`);
1253
+ x(`Maximum of ${a} tags allowed`);
1254
1254
  return;
1255
1255
  }
1256
1256
  if (t.includes(C)) {
1257
- v("Tag already exists");
1257
+ x("Tag already exists");
1258
1258
  return;
1259
1259
  }
1260
1260
  if (c) {
1261
1261
  const I = c(C);
1262
1262
  if (typeof I == "string") {
1263
- v(I);
1263
+ x(I);
1264
1264
  return;
1265
1265
  } else if (I === !1) {
1266
- v("Invalid tag");
1266
+ x("Invalid tag");
1267
1267
  return;
1268
1268
  }
1269
1269
  }
1270
- i([...t, C]), d(""), v(null), M(`Added tag ${C}`);
1270
+ i([...t, C]), d(""), x(null), M(`Added tag ${C}`);
1271
1271
  } else if (k.key === "Backspace" && !u && t.length > 0) {
1272
1272
  const C = t[t.length - 1];
1273
1273
  i(t.slice(0, -1)), M(`Removed tag ${C}`);
@@ -1277,17 +1277,17 @@ const mr = ({
1277
1277
  k.preventDefault();
1278
1278
  const I = t[C], Z = [...t];
1279
1279
  Z.splice(C, 1), i(Z), setTimeout(() => {
1280
- x.current && x.current.focus();
1280
+ v.current && v.current.focus();
1281
1281
  }, 0), M(`Removed tag ${I}`);
1282
- } else k.key === "ArrowRight" ? (k.preventDefault(), C < t.length - 1 ? F.current[C + 1]?.focus() : x.current?.focus()) : k.key === "ArrowLeft" && (k.preventDefault(), C > 0 && F.current[C - 1]?.focus());
1282
+ } else k.key === "ArrowRight" ? (k.preventDefault(), C < t.length - 1 ? F.current[C + 1]?.focus() : v.current?.focus()) : k.key === "ArrowLeft" && (k.preventDefault(), C > 0 && F.current[C - 1]?.focus());
1283
1283
  }, B = (k, C) => {
1284
1284
  i(t.filter((I) => I !== k)), setTimeout(() => {
1285
- C < t.length - 1 ? F.current[C]?.focus() : C > 0 ? F.current[C - 1]?.focus() : x.current?.focus();
1285
+ C < t.length - 1 ? F.current[C]?.focus() : C > 0 ? F.current[C - 1]?.focus() : v.current?.focus();
1286
1286
  }, 0), M(`Removed tag ${k}`);
1287
1287
  }, U = (k) => {
1288
- d(k.target.value), v(null);
1288
+ d(k.target.value), x(null);
1289
1289
  }, V = () => {
1290
- x.current && x.current.focus();
1290
+ v.current && v.current.focus();
1291
1291
  }, M = (k) => {
1292
1292
  console.log(`Accessibility announcement: ${k}`);
1293
1293
  };
@@ -1390,7 +1390,7 @@ const mr = ({
1390
1390
  "input",
1391
1391
  {
1392
1392
  id: S,
1393
- ref: x,
1393
+ ref: v,
1394
1394
  type: "text",
1395
1395
  className: "flex-grow min-w-[60px] bg-transparent outline-none placeholder:text-sm placeholder:text-secondarytext",
1396
1396
  value: u,
@@ -1463,7 +1463,7 @@ const mr = ({
1463
1463
  disabled: m = !1,
1464
1464
  className: g
1465
1465
  }) => {
1466
- const [v, x] = L(""), [A, F] = L(!1), [O, S] = L(-1), $ = N(null), E = N(null), z = N([]), {
1466
+ const [x, v] = L(""), [A, F] = L(!1), [O, S] = L(-1), $ = N(null), E = N(null), z = N([]), {
1467
1467
  triggerRef: _,
1468
1468
  triggerProps: B,
1469
1469
  popoverRef: U,
@@ -1479,7 +1479,7 @@ const mr = ({
1479
1479
  F(!0), b && $.current && setTimeout(() => $.current?.focus(), 10);
1480
1480
  },
1481
1481
  onClose: () => {
1482
- F(!1), x(""), S(-1);
1482
+ F(!1), v(""), S(-1);
1483
1483
  }
1484
1484
  }), I = N(
1485
1485
  `multiselect-${Math.random().toString(36).substr(2, 9)}`
@@ -1492,7 +1492,7 @@ const mr = ({
1492
1492
  ).current, T = o ? t.map((h) => r.find(
1493
1493
  (D) => l(D) === h || l(D) === l(h)
1494
1494
  )).filter(Boolean) : t, te = T.length > 0, X = b ? r.filter(
1495
- (h) => s(h).toLowerCase().includes(v.toLowerCase())
1495
+ (h) => s(h).toLowerCase().includes(x.toLowerCase())
1496
1496
  ) : r;
1497
1497
  j(() => {
1498
1498
  z.current = z.current.slice(0, X.length);
@@ -1560,14 +1560,14 @@ const mr = ({
1560
1560
  }
1561
1561
  break;
1562
1562
  case "Backspace":
1563
- if (b && v === "" && T.length > 0) {
1563
+ if (b && x === "" && T.length > 0) {
1564
1564
  const y = T[T.length - 1];
1565
1565
  de(y);
1566
1566
  }
1567
1567
  break;
1568
1568
  }
1569
1569
  }, Ie = (h) => {
1570
- x(h.target.value), S(-1);
1570
+ v(h.target.value), S(-1);
1571
1571
  }, je = () => {
1572
1572
  m || (b && $.current && $.current.focus(), k());
1573
1573
  }, Y = (h) => {
@@ -1677,7 +1677,7 @@ const mr = ({
1677
1677
  id: I,
1678
1678
  type: "text",
1679
1679
  className: "flex-grow min-w-[60px] bg-transparent outline-none placeholder:text-sm",
1680
- value: v,
1680
+ value: x,
1681
1681
  onChange: Ie,
1682
1682
  onKeyDown: he,
1683
1683
  placeholder: te ? "" : u,
@@ -1730,7 +1730,7 @@ const mr = ({
1730
1730
  role: "listbox",
1731
1731
  id: ee,
1732
1732
  "aria-labelledby": Z,
1733
- children: X.length === 0 ? /* @__PURE__ */ f("div", { className: "px-3 py-2 text-sm text-secondarytext", children: v ? "No results found" : "No options available" }) : X.map((h, y) => {
1733
+ children: X.length === 0 ? /* @__PURE__ */ f("div", { className: "px-3 py-2 text-sm text-secondarytext", children: x ? "No results found" : "No options available" }) : X.map((h, y) => {
1734
1734
  const D = ue(h);
1735
1735
  return /* @__PURE__ */ w(
1736
1736
  "div",
@@ -1840,7 +1840,7 @@ const mr = ({
1840
1840
  )
1841
1841
  ] });
1842
1842
  };
1843
- function vr({
1843
+ function xr({
1844
1844
  checked: e,
1845
1845
  onCheckedChange: n,
1846
1846
  disabled: r = !1,
@@ -1848,7 +1848,7 @@ function vr({
1848
1848
  required: i,
1849
1849
  className: l = ""
1850
1850
  }) {
1851
- const s = ve();
1851
+ const s = xe();
1852
1852
  return /* @__PURE__ */ w(
1853
1853
  "button",
1854
1854
  {
@@ -1863,12 +1863,11 @@ function vr({
1863
1863
  r || n(!e);
1864
1864
  },
1865
1865
  className: p(
1866
- `
1867
- relative inline-flex h-6 w-11 items-center rounded-full
1866
+ `relative inline-flex h-[28px] w-[48px] items-center rounded-full
1868
1867
  transition-colors duration-200 ease-in-out
1869
- focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2
1870
- focus-visible:ring-blue-500`,
1871
- e ? "bg-blue-600" : "bg-gray-200",
1868
+ focus-visible:outline-none focus-visible:ring-1
1869
+ focus-visible:ring-base-6`,
1870
+ e ? "bg-brand" : "bg-base-3",
1872
1871
  r ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
1873
1872
  l
1874
1873
  ),
@@ -1877,10 +1876,10 @@ function vr({
1877
1876
  "span",
1878
1877
  {
1879
1878
  className: p(
1880
- `inline-block h-5 w-5 transform rounded-full bg-white
1879
+ `inline-block h-6 w-6 transform rounded-full
1881
1880
  transition-transform duration-200 ease-in-out
1882
- shadow-lg`,
1883
- e ? "translate-x-6" : "translate-x-0.5"
1881
+ shadow`,
1882
+ e ? "bg-brand-text translate-x-[22px]" : "bg-base-1 dark-theme:bg-base-12 translate-x-[2px]"
1884
1883
  )
1885
1884
  }
1886
1885
  ),
@@ -1907,11 +1906,11 @@ const Le = we(null), Kt = ({
1907
1906
  children: e,
1908
1907
  value: n
1909
1908
  }) => /* @__PURE__ */ f(Le.Provider, { value: n, children: e }), Bt = () => {
1910
- const e = xe(Le);
1909
+ const e = ve(Le);
1911
1910
  if (!e)
1912
1911
  throw new Error("useAliveScope must be wrapped within AliveScopeProvider");
1913
1912
  return e;
1914
- }, xr = ({ children: e }) => {
1913
+ }, vr = ({ children: e }) => {
1915
1914
  const [n, r] = L({}), t = N(
1916
1915
  {}
1917
1916
  ), i = N(
@@ -1993,7 +1992,7 @@ const Le = we(null), Kt = ({
1993
1992
  children: ye(t, i, e)
1994
1993
  }
1995
1994
  )), wr = () => {
1996
- const e = xe(Me);
1995
+ const e = ve(Me);
1997
1996
  if (!e)
1998
1997
  throw new Error("useKeepAlive must be used within KeepAliveProvider");
1999
1998
  return e;
@@ -2011,7 +2010,7 @@ const Le = we(null), Kt = ({
2011
2010
  }, [e, n, r, t]), /* @__PURE__ */ f("div", { ...t, ref: i, children: n });
2012
2011
  };
2013
2012
  export {
2014
- xr as AliveScope,
2013
+ vr as AliveScope,
2015
2014
  lr as Avatar,
2016
2015
  ir as AvatarsGroup,
2017
2016
  ie as Button,
@@ -2023,14 +2022,14 @@ export {
2023
2022
  gr as FormSubmit,
2024
2023
  br as FormTags,
2025
2024
  mr as FormTextArea,
2026
- xt as Icon,
2025
+ vt as Icon,
2027
2026
  ze as Input,
2028
2027
  yr as KeepAlive,
2029
2028
  Tt as MultiSelect,
2030
2029
  yt as Portal,
2031
2030
  ur as Separator,
2032
2031
  wt as Spinner,
2033
- vr as Switch,
2032
+ xr as Switch,
2034
2033
  _t as Tags,
2035
2034
  De as TextArea,
2036
2035
  ut as calculatePopoverPosition,