@cronocode/react-box 1.7.0 → 1.7.1

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/box.js CHANGED
@@ -1,7 +1 @@
1
- import r from "./components/dox.js";
2
- import "react";
3
- import "./utils.js";
4
- import "./theme.js";
5
- export {
6
- r as default
7
- };
1
+ import "./components/dox.js";
@@ -1,2 +1,19 @@
1
- import DoxSvg from './doxSvg';
2
- export default DoxSvg;
1
+ /// <reference types="react" />
2
+ import Dox from './dox';
3
+ import ClassNameUtils from '../utils/className/classNameUtils';
4
+ import { DoxSvgStyles } from './dox/doxStyles';
5
+ type SvgTagProps = Required<React.ComponentProps<typeof Dox<'svg'>>>['props'];
6
+ type DoxSvgTagProps = Omit<SvgTagProps, 'viewBox' | 'width' | 'height'>;
7
+ interface Props extends DoxSvgStyles {
8
+ children?: React.ReactNode | ((props: {
9
+ isHover: boolean;
10
+ }) => React.ReactNode);
11
+ props?: DoxSvgTagProps;
12
+ style?: React.ComponentProps<'svg'>['style'];
13
+ className?: ClassNameUtils.ClassNameType;
14
+ viewBox?: string;
15
+ width?: string;
16
+ height?: string;
17
+ }
18
+ declare const _default: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<SVGSVGElement>>;
19
+ export default _default;
@@ -1,6 +1,19 @@
1
- import "./doxSvg.js";
2
- import "react/jsx-runtime";
3
- import "react";
4
- import "./dox.js";
5
- import "../utils.js";
6
- import "../theme.js";
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { forwardRef as m } from "react";
3
+ import { D as n } from "./dox.js";
4
+ function a(o, r) {
5
+ const { viewBox: s = "0 0 24 24", width: t = "1.5rem", height: p, props: e, ...g } = o;
6
+ return /* @__PURE__ */ i(
7
+ n,
8
+ {
9
+ tag: "svg",
10
+ ref: r,
11
+ props: { ...e, viewBox: s, width: t, height: p, xmlns: "http://www.w3.org/2000/svg", fill: "none" },
12
+ ...g
13
+ }
14
+ );
15
+ }
16
+ const x = m(a);
17
+ export {
18
+ x as b
19
+ };
@@ -1,11 +1,13 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as i } from "react";
3
- import m from "./dox.js";
4
- import { O as p } from "../utils.js";
5
- import "../theme.js";
6
- const s = ["type", "onClick", "disabled"];
2
+ import { forwardRef as s } from "react";
3
+ import { D as p } from "./dox.js";
4
+ import { O as i } from "../utils.js";
5
+ const m = ["type", "onClick", "disabled"];
7
6
  function e(o, t) {
8
- const r = p.buildProps(o, s);
9
- return /* @__PURE__ */ n(m, { ref: t, tag: "button", component: "button", ...r });
7
+ const r = i.buildProps(o, m);
8
+ return /* @__PURE__ */ n(p, { ref: t, tag: "button", component: "button", ...r });
10
9
  }
11
- i(e);
10
+ const u = s(e);
11
+ export {
12
+ u as b
13
+ };
@@ -1,10 +1,9 @@
1
1
  import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
2
  import { forwardRef as c } from "react";
3
- import t from "./dox.js";
3
+ import { D as t } from "./dox.js";
4
4
  import { O as a } from "../utils.js";
5
- import l from "./flex.js";
5
+ import { F as l } from "./flex.js";
6
6
  import { c as d } from "../box.module.css.js";
7
- import "../theme.js";
8
7
  const p = [
9
8
  "name",
10
9
  "onInput",
@@ -24,4 +23,7 @@ function m(o, r) {
24
23
  !n && /* @__PURE__ */ e(t, { position: "absolute", pointerEvents: "none", className: d._checkedIcon, children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", width: "100%", viewBox: "0 0 20 20", children: /* @__PURE__ */ e("g", { fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ e("path", { stroke: "#000", strokeLinecap: "round", strokeLinejoin: "round", d: "M6 10.15L8.5 13 14 7" }) }) }) })
25
24
  ] });
26
25
  }
27
- c(m);
26
+ const b = c(m);
27
+ export {
28
+ b as c
29
+ };
@@ -1,5 +1,32 @@
1
- import "react/jsx-runtime";
2
- import "./dox.js";
3
- import "react";
4
- import "../utils.js";
5
- import "../theme.js";
1
+ import { jsx as i, Fragment as m, jsxs as c } from "react/jsx-runtime";
2
+ import { D as t } from "./dox.js";
3
+ function u(n) {
4
+ if (!(n != null && n.length))
5
+ return {
6
+ rows: [],
7
+ columns: []
8
+ };
9
+ const s = Object.keys(n[0]);
10
+ return {
11
+ rows: n.map((r) => ({
12
+ dataRow: r,
13
+ cells: s.map((e) => ({
14
+ key: e,
15
+ value: r[e]
16
+ }))
17
+ })),
18
+ columns: s.map((r) => ({
19
+ key: r
20
+ }))
21
+ };
22
+ }
23
+ function d(n) {
24
+ const { data: s } = n, r = u(s);
25
+ return /* @__PURE__ */ i(t, { display: "grid", b: 1, borderRadius: 1, children: r.columns.length === 0 ? /* @__PURE__ */ i(m, { children: "empty grid" }) : /* @__PURE__ */ c(m, { children: [
26
+ r.columns.map((e, o) => /* @__PURE__ */ i(t, { style: { gridColumn: o + 1 }, children: e.key.toString() }, e.key.toString())),
27
+ r.rows.map((e, o) => e.cells.map((l) => /* @__PURE__ */ i(t, { children: l.value }, l.key.toString() + o)))
28
+ ] }) });
29
+ }
30
+ export {
31
+ d as D
32
+ };
package/components/dox.js CHANGED
@@ -1,6 +1,6 @@
1
- import O, { useMemo as j, useLayoutEffect as I, useEffect as _, forwardRef as D, useState as P } from "react";
1
+ import O, { useMemo as j, useLayoutEffect as I, useEffect as D, forwardRef as _, useState as P } from "react";
2
2
  import { I as M, C as W } from "../utils.js";
3
- import { useTheme as G } from "../theme.js";
3
+ import { u as G } from "../theme.js";
4
4
  var e;
5
5
  ((a) => {
6
6
  ((r) => {
@@ -13,56 +13,56 @@ var e;
13
13
  }
14
14
  r.svg = n;
15
15
  })(a.ClassName || (a.ClassName = {})), ((r) => {
16
- function m(u, t) {
17
- return `${t / 4}rem`;
16
+ function m(u, i) {
17
+ return `${i / 4}rem`;
18
18
  }
19
19
  r.rem = m;
20
- function n(u, t) {
21
- return `${t}px`;
20
+ function n(u, i) {
21
+ return `${i}px`;
22
22
  }
23
23
  r.px = n;
24
- function l(u, t) {
25
- const [o, v] = t.split("/");
24
+ function l(u, i) {
25
+ const [o, v] = i.split("/");
26
26
  return `${+o / +v * 100}%`;
27
27
  }
28
28
  r.fraction = l;
29
- function d(u, t) {
30
- switch (t) {
29
+ function d(u, i) {
30
+ switch (i) {
31
31
  case "fit":
32
32
  return "100%";
33
33
  case "fit-screen":
34
34
  return u.toLocaleLowerCase().includes("height") ? "100vh" : "100vw";
35
35
  default:
36
- return t;
36
+ return i;
37
37
  }
38
38
  }
39
39
  r.widthHeight = d;
40
40
  function g(u) {
41
- return (t, o) => `var(--${u}${o});`;
41
+ return (i, o) => `var(--${u}${o});`;
42
42
  }
43
43
  r.variables = g;
44
44
  function z(u) {
45
- return (t, o) => `var(--${u}${o});`;
45
+ return (i, o) => `var(--${u}${o});`;
46
46
  }
47
47
  r.svgVariables = z;
48
- function x(u, t) {
49
- return `repeat(${t},minmax(0,1fr))`;
48
+ function x(u, i) {
49
+ return `repeat(${i},minmax(0,1fr))`;
50
50
  }
51
51
  r.gridColumns = x;
52
- function f(u, t) {
53
- return t === "full-row" ? "1/-1" : `span ${t}/span ${t}`;
52
+ function f(u, i) {
53
+ return i === "full-row" ? "1/-1" : `span ${i}/span ${i}`;
54
54
  }
55
55
  r.gridColumn = f;
56
- function h(u, t) {
57
- return `${t}ms`;
56
+ function h(u, i) {
57
+ return `${i}ms`;
58
58
  }
59
59
  r.ms = h;
60
- function V(u, t) {
61
- return `${t}deg`;
60
+ function V(u, i) {
61
+ return `${i}deg`;
62
62
  }
63
63
  r.rotate = V;
64
- function b(u, t) {
65
- return t === "xAxis" ? "-1 1" : "1 -1";
64
+ function b(u, i) {
65
+ return i === "xAxis" ? "-1 1" : "1 -1";
66
66
  }
67
67
  r.flip = b;
68
68
  })(a.Value || (a.Value = {}));
@@ -229,7 +229,7 @@ const R = {
229
229
  }, H = {
230
230
  hover: { className: "_h" },
231
231
  focus: { className: "_f" }
232
- }, i = {
232
+ }, t = {
233
233
  display: {
234
234
  cssNames: ["display"],
235
235
  values1: { values: ["none", "block", "inline-block", "flex", "inline-flex", "grid", "inline-grid", "contents"] },
@@ -870,46 +870,46 @@ const R = {
870
870
  }
871
871
  };
872
872
  Object.keys(C).forEach((a) => {
873
- i[a] = C[a];
873
+ t[a] = C[a];
874
874
  });
875
875
  Object.keys(R).forEach((a) => {
876
- i[a] = R[a], i[a].isThemeStyle = !0;
876
+ t[a] = R[a], t[a].isThemeStyle = !0;
877
877
  });
878
878
  Object.keys(A).forEach((a) => {
879
- i[a] = A[a], i[a].isThemeStyle = !0;
879
+ t[a] = A[a], t[a].isThemeStyle = !0;
880
880
  });
881
881
  const y = {
882
- w: { ...i.width, key: "width" },
883
- h: { ...i.height, key: "height" },
884
- m: { ...i.margin, key: "margin" },
885
- mx: { ...i.marginHorizontal, key: "marginHorizontal" },
886
- my: { ...i.marginVertical, key: "marginVertical" },
887
- mt: { ...i.marginTop, key: "marginTop" },
888
- mr: { ...i.marginRight, key: "marginRight" },
889
- mb: { ...i.marginBottom, key: "marginBottom" },
890
- ml: { ...i.marginLeft, key: "marginLeft" },
891
- p: { ...i.padding, key: "padding" },
892
- px: { ...i.paddingHorizontal, key: "paddingHorizontal" },
893
- py: { ...i.paddingVertical, key: "paddingVertical" },
894
- pt: { ...i.paddingTop, key: "paddingTop" },
895
- pr: { ...i.paddingRight, key: "paddingRight" },
896
- pb: { ...i.paddingBottom, key: "paddingBottom" },
897
- pl: { ...i.paddingLeft, key: "paddingLeft" },
898
- b: { ...i.border, key: "border" },
899
- bx: { ...i.borderHorizontal, key: "borderHorizontal" },
900
- by: { ...i.borderVertical, key: "borderVertical" },
901
- bt: { ...i.borderTop, key: "borderTop" },
902
- br: { ...i.borderRight, key: "borderRight" },
903
- bb: { ...i.borderBottom, key: "borderBottom" },
904
- bl: { ...i.borderLeft, key: "borderLeft" },
905
- jc: { ...i.justifyContent, key: "justifyContent" },
906
- ai: { ...i.alignItems, key: "alignItems" },
907
- ac: { ...i.alignContent, key: "alignContent" },
908
- d: { ...i.flexDirection, key: "flexDirection" }
909
- }, U = Object.keys(i), X = Object.keys(y);
882
+ w: { ...t.width, key: "width" },
883
+ h: { ...t.height, key: "height" },
884
+ m: { ...t.margin, key: "margin" },
885
+ mx: { ...t.marginHorizontal, key: "marginHorizontal" },
886
+ my: { ...t.marginVertical, key: "marginVertical" },
887
+ mt: { ...t.marginTop, key: "marginTop" },
888
+ mr: { ...t.marginRight, key: "marginRight" },
889
+ mb: { ...t.marginBottom, key: "marginBottom" },
890
+ ml: { ...t.marginLeft, key: "marginLeft" },
891
+ p: { ...t.padding, key: "padding" },
892
+ px: { ...t.paddingHorizontal, key: "paddingHorizontal" },
893
+ py: { ...t.paddingVertical, key: "paddingVertical" },
894
+ pt: { ...t.paddingTop, key: "paddingTop" },
895
+ pr: { ...t.paddingRight, key: "paddingRight" },
896
+ pb: { ...t.paddingBottom, key: "paddingBottom" },
897
+ pl: { ...t.paddingLeft, key: "paddingLeft" },
898
+ b: { ...t.border, key: "border" },
899
+ bx: { ...t.borderHorizontal, key: "borderHorizontal" },
900
+ by: { ...t.borderVertical, key: "borderVertical" },
901
+ bt: { ...t.borderTop, key: "borderTop" },
902
+ br: { ...t.borderRight, key: "borderRight" },
903
+ bb: { ...t.borderBottom, key: "borderBottom" },
904
+ bl: { ...t.borderLeft, key: "borderLeft" },
905
+ jc: { ...t.justifyContent, key: "justifyContent" },
906
+ ai: { ...t.alignItems, key: "alignItems" },
907
+ ac: { ...t.alignContent, key: "alignContent" },
908
+ d: { ...t.flexDirection, key: "flexDirection" }
909
+ }, U = Object.keys(t), X = Object.keys(y);
910
910
  q.forEach((a) => {
911
911
  U.forEach((r) => {
912
- i[`${r}${a}`] = { ...i[r] }, i[`${r}${a}`].pseudoSuffix = a;
912
+ t[`${r}${a}`] = { ...t[r] }, t[`${r}${a}`].pseudoSuffix = a;
913
913
  }), X.forEach((r) => {
914
914
  y[`${r}${a}`] = { ...y[r], key: `${y[r].key}${a}` }, y[`${r}${a}`].pseudoSuffix = a;
915
915
  });
@@ -923,16 +923,16 @@ body{margin: 0;line-height: var(--lineHeight);font-size: var(--fontSize);}
923
923
  a,ul{all: unset;}
924
924
  .${a.doxClassName}{display: block;border: 0 solid var(--borderColor);outline: 0px solid var(--outlineColor);margin: 0;padding: 0;background-color: initial;transition: all var(--transitionTime);box-sizing: border-box;font-family: inherit;font-size: inherit;}
925
925
  .${a.svgClassName}{transition: all var(--svgTransitionTime);}.${a.svgClassName} path,.${a.svgClassName} circle,.${a.svgClassName} rect,.${a.svgClassName} line {transition: all var(--svgTransitionTime);}
926
- `, m = new M(), n = Object.keys(i), l = b();
926
+ `, m = new M(), n = Object.keys(t), l = b();
927
927
  let d = !1;
928
- const g = n.reduce((u, t) => (u[t] = /* @__PURE__ */ new Set(), u), {});
929
- function z(u, t) {
930
- if (u in i)
931
- return f(u, t);
928
+ const g = n.reduce((u, i) => (u[i] = /* @__PURE__ */ new Set(), u), {});
929
+ function z(u, i) {
930
+ if (u in t)
931
+ return f(u, i);
932
932
  if (u in H)
933
933
  return H[u].className;
934
934
  if (u in C)
935
- return f(u, t);
935
+ return f(u, i);
936
936
  }
937
937
  a.get = z;
938
938
  function x() {
@@ -943,37 +943,37 @@ a,ul{all: unset;}
943
943
  }
944
944
  }
945
945
  a.flush = x;
946
- function f(u, t) {
946
+ function f(u, i) {
947
947
  var c;
948
- g[u].has(t) || (d = !0, g[u].add(t));
949
- const o = V(u, t), v = ((c = o.formatClassName) == null ? void 0 : c.call(o, u, t)) ?? `${u}${t}`;
948
+ g[u].has(i) || (d = !0, g[u].add(i));
949
+ const o = V(u, i), v = ((c = o.formatClassName) == null ? void 0 : c.call(o, u, i)) ?? `${u}${i}`;
950
950
  return `-${m.getIdentity(v)}`;
951
951
  }
952
- function h(u, t) {
952
+ function h(u, i) {
953
953
  return Object.entries(g).filter(([v]) => {
954
954
  var c;
955
- return ((c = i[v]) == null ? void 0 : c.pseudoSuffix) === t;
955
+ return ((c = t[v]) == null ? void 0 : c.pseudoSuffix) === i;
956
956
  }).reduce((v, [c, E]) => (E.forEach((k) => {
957
957
  var T;
958
958
  const p = V(c, k), N = `.${f(c, k)}`;
959
959
  let S = [];
960
- t ? t === "H" ? S = [
960
+ i ? i === "H" ? S = [
961
961
  ...o(`${N}:hover`, p),
962
962
  ...o(`.${H.hover.className}:hover>${N}`, p)
963
- ] : t === "F" ? S = [
963
+ ] : i === "F" ? S = [
964
964
  ...o(`${N}:focus-within`, p),
965
965
  ...o(`.${H.focus.className}:focus-within>${N}`, p)
966
- ] : t === "A" && (S = o(`${N}:active`, p)) : S = o(N, p);
967
- const F = ((T = p.formatValue) == null ? void 0 : T.call(p, c, k)) ?? k, B = i[c].cssNames.map((L) => `${L}:${F};`).join("");
966
+ ] : i === "A" && (S = o(`${N}:active`, p)) : S = o(N, p);
967
+ const F = ((T = p.formatValue) == null ? void 0 : T.call(p, c, k)) ?? k, B = t[c].cssNames.map((L) => `${L}:${F};`).join("");
968
968
  v.push(`${S.join(",")}{${B}}`);
969
969
  }), v), u);
970
970
  function o(v, c) {
971
971
  return c.formatSelector ? c.formatSelector(v) : [v];
972
972
  }
973
973
  }
974
- function V(u, t) {
975
- const o = i[u];
976
- return o.isThemeStyle ? o : o.values1.values.includes(t) ? o.values1 : o.values2.values.includes(t) ? o.values2 : o.values3;
974
+ function V(u, i) {
975
+ const o = t[u];
976
+ return o.isThemeStyle ? o : o.values1.values.includes(i) ? o.values1 : o.values2.values.includes(i) ? o.values2 : o.values3;
977
977
  }
978
978
  function b() {
979
979
  const u = "crono-styles", o = typeof window < "u" && typeof window.document < "u" ? window.document : global.document;
@@ -981,7 +981,7 @@ a,ul{all: unset;}
981
981
  return v || (v = o.createElement("style"), v.setAttribute("id", u), v.setAttribute("type", "text/css"), o.head.insertBefore(v, o.head.firstChild)), v;
982
982
  }
983
983
  })(w || (w = {}));
984
- const Y = typeof window < "u" && typeof window.document < "u", J = Y ? I : _;
984
+ const Y = typeof window < "u" && typeof window.document < "u", J = Y ? I : D;
985
985
  function Q(a, r) {
986
986
  const m = G(a);
987
987
  return J(w.flush, [a]), j(() => {
@@ -1004,7 +1004,7 @@ function Z(a, r) {
1004
1004
  const [h, V] = P(!1), b = typeof n == "function";
1005
1005
  return b && (f.onMouseEnter = () => V(!0), f.onMouseLeave = () => V(!1)), O.createElement(m, f, b ? n({ isHover: h }) : n);
1006
1006
  }
1007
- const le = D(Z);
1007
+ const le = _(Z);
1008
1008
  export {
1009
- le as default
1009
+ le as D
1010
1010
  };
@@ -1,13 +1,11 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { forwardRef as f } from "react";
3
- import n from "./dox.js";
4
- import "../utils.js";
5
- import "../theme.js";
6
- function l(o, r) {
7
- const { inline: t, ...e } = o;
8
- return /* @__PURE__ */ i(n, { ref: r, display: t ? "inline-flex" : "flex", ...e });
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as t } from "react";
3
+ import { D as f } from "./dox.js";
4
+ function s(o, r) {
5
+ const { inline: e, ...i } = o;
6
+ return /* @__PURE__ */ n(f, { ref: r, display: e ? "inline-flex" : "flex", ...i });
9
7
  }
10
- const c = f(l);
8
+ const p = t(s);
11
9
  export {
12
- c as default
10
+ p as F
13
11
  };
@@ -1,5 +1,15 @@
1
- import "react/jsx-runtime";
2
- import "react";
3
- import "./dox.js";
4
- import "../utils.js";
5
- import "../theme.js";
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { useRef as i, useCallback as p } from "react";
3
+ import { D as u } from "./dox.js";
4
+ import { F as c } from "../utils.js";
5
+ function x(o) {
6
+ const { onSubmit: m, props: n } = o, r = i(null), s = p((t) => {
7
+ t.preventDefault();
8
+ const f = c.getFormEntries(r.current);
9
+ m(f, t);
10
+ }, []), e = { ...n, onSubmit: s, ref: r };
11
+ return /* @__PURE__ */ a(u, { tag: "form", ...o, props: e });
12
+ }
13
+ export {
14
+ x as F
15
+ };
@@ -1,10 +1,11 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { forwardRef as n } from "react";
3
- import p from "./dox.js";
4
- import "../utils.js";
5
- import "../theme.js";
6
- function f(r, i) {
7
- const { inline: o, ...t } = r;
8
- return /* @__PURE__ */ m(p, { ref: i, display: o ? "inline-grid" : "grid", ...t });
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { forwardRef as s } from "react";
3
+ import { D as d } from "./dox.js";
4
+ function e(r, i) {
5
+ const { inline: o, ...n } = r;
6
+ return /* @__PURE__ */ t(d, { ref: i, display: o ? "inline-grid" : "grid", ...n });
9
7
  }
10
- n(f);
8
+ const a = s(e);
9
+ export {
10
+ a as g
11
+ };
@@ -1,8 +1,7 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { forwardRef as n } from "react";
3
- import a from "./dox.js";
3
+ import { D as a } from "./dox.js";
4
4
  import { O as i } from "../utils.js";
5
- import "../theme.js";
6
5
  const d = [
7
6
  "name",
8
7
  "onInput",
@@ -15,8 +14,11 @@ const d = [
15
14
  "checked",
16
15
  "defaultChecked"
17
16
  ];
18
- function p(o, t) {
17
+ function s(o, t) {
19
18
  const r = i.buildProps(o, d, { type: "radio" });
20
19
  return /* @__PURE__ */ e(a, { ref: t, tag: "input", component: "radioButton", ...r });
21
20
  }
22
- n(p);
21
+ const f = n(s);
22
+ export {
23
+ f as r
24
+ };
@@ -1,9 +1,8 @@
1
- import { jsx as t } from "react/jsx-runtime";
1
+ import { jsx as r } from "react/jsx-runtime";
2
2
  import { forwardRef as a } from "react";
3
- import n from "./dox.js";
4
- import { O as m } from "../utils.js";
5
- import "../theme.js";
6
- const s = [
3
+ import { D as n } from "./dox.js";
4
+ import { O as s } from "../utils.js";
5
+ const m = [
7
6
  "name",
8
7
  "onInput",
9
8
  "onChange",
@@ -19,8 +18,11 @@ const s = [
19
18
  "readOnly",
20
19
  "required"
21
20
  ];
22
- function i(o, e) {
23
- const r = m.buildProps(o, s);
24
- return /* @__PURE__ */ t(n, { ref: e, tag: "textarea", component: "textarea", ...r });
21
+ function p(t, e) {
22
+ const o = s.buildProps(t, m);
23
+ return /* @__PURE__ */ r(n, { ref: e, tag: "textarea", component: "textarea", ...o });
25
24
  }
26
- a(i);
25
+ const d = a(p);
26
+ export {
27
+ d as t
28
+ };
@@ -1,9 +1,8 @@
1
- import { jsx as e } from "react/jsx-runtime";
1
+ import { jsx as r } from "react/jsx-runtime";
2
2
  import { forwardRef as n } from "react";
3
- import a from "./dox.js";
3
+ import { D as a } from "./dox.js";
4
4
  import { O as p } from "../utils.js";
5
- import "../theme.js";
6
- const i = [
5
+ const s = [
7
6
  "name",
8
7
  "onInput",
9
8
  "onChange",
@@ -17,8 +16,11 @@ const i = [
17
16
  "value",
18
17
  "pattern"
19
18
  ];
20
- function m(o, t) {
21
- const r = p.buildProps(o, i);
22
- return /* @__PURE__ */ e(a, { ref: t, tag: "input", component: "textbox", ...r });
19
+ function u(o, t) {
20
+ const e = p.buildProps(o, s);
21
+ return /* @__PURE__ */ r(a, { ref: t, tag: "input", component: "textbox", ...e });
23
22
  }
24
- n(m);
23
+ const c = n(u);
24
+ export {
25
+ c as t
26
+ };
@@ -1,6 +1,63 @@
1
- import "react/jsx-runtime";
2
- import "react-dom";
3
- import "./dox.js";
4
- import "react";
5
- import "../utils.js";
6
- import "../theme.js";
1
+ import { jsxs as v, Fragment as x, jsx as a } from "react/jsx-runtime";
2
+ import { createPortal as b } from "react-dom";
3
+ import { D as u } from "./dox.js";
4
+ import { useRef as D, useState as E, useCallback as d, useLayoutEffect as L } from "react";
5
+ import { u as g } from "../utils.js";
6
+ const i = 2;
7
+ function y(f) {
8
+ const { onPositionChange: c } = f, s = D(null), [t, p] = E(), m = g(), w = d(
9
+ (o, e) => {
10
+ const r = (n) => {
11
+ n.target.contains(o) && e(o);
12
+ };
13
+ return document.addEventListener("scroll", r, { capture: !0 }), () => {
14
+ document.removeEventListener("scroll", r, { capture: !0 });
15
+ };
16
+ },
17
+ [t]
18
+ ), h = d(
19
+ (o, e) => {
20
+ const r = (n) => {
21
+ e(o);
22
+ };
23
+ return window.addEventListener("resize", r, { capture: !0 }), () => {
24
+ window.removeEventListener("resize", r, { capture: !0 });
25
+ };
26
+ },
27
+ [t]
28
+ ), l = d(
29
+ (o) => {
30
+ const e = o.getBoundingClientRect(), r = Math.round((e.top + window.scrollY) * i) / i, n = Math.round((e.left + window.scrollX) * i) / i;
31
+ ((t == null ? void 0 : t.top) !== r || (t == null ? void 0 : t.left) !== n) && (c == null || c({ top: r, left: n }), p({ top: r, left: n, width: e.width > 0 ? e.width : void 0 }));
32
+ },
33
+ [t]
34
+ );
35
+ return L(() => {
36
+ if (s.current) {
37
+ l(s.current);
38
+ const o = w(s.current, l), e = h(s.current, l);
39
+ return () => {
40
+ o(), e();
41
+ };
42
+ }
43
+ }, [t]), /* @__PURE__ */ v(x, { children: [
44
+ /* @__PURE__ */ a(u, { ref: s }),
45
+ t && b(
46
+ /* @__PURE__ */ a(
47
+ u,
48
+ {
49
+ position: "absolute",
50
+ top: 0,
51
+ left: 0,
52
+ transition: "none",
53
+ style: { transform: `translate(${t.left}px,${t.top}px)`, width: t.width },
54
+ children: /* @__PURE__ */ a(u, { position: "absolute", width: "fit", ...f })
55
+ }
56
+ ),
57
+ m
58
+ )
59
+ ] });
60
+ }
61
+ export {
62
+ y as T
63
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronocode/react-box",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "main": "./box.js",
5
5
  "module": "./box.js",
6
6
  "types": "./box.d.ts",
package/theme.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useMemo as g } from "react";
2
- const $ = {
2
+ const b = {
3
3
  button: {
4
4
  styles: {
5
5
  display: "inline-block",
@@ -42,14 +42,14 @@ const $ = {
42
42
  }
43
43
  }
44
44
  };
45
- let _ = $;
45
+ let _ = b;
46
46
  var u;
47
47
  ((h) => {
48
48
  function d(r) {
49
49
  _ = r, i();
50
50
  }
51
51
  h.setup = d;
52
- function b(r, e) {
52
+ function $(r, e) {
53
53
  const t = Object.entries(r.colors).map(([o, c]) => `--color${o}: ${c};`).join(`
54
54
  `), l = Object.entries(r.shadows).map(([o, c]) => `--shadow${o}: ${c};`).join(`
55
55
  `), n = Object.entries(r.backgrounds).map(([o, c]) => `--background${o}: ${c};`).join(`
@@ -259,16 +259,17 @@ var u;
259
259
  boxDts: T
260
260
  };
261
261
  }
262
- h.setupAugmentedProps = b;
262
+ h.setupAugmentedProps = $;
263
263
  function i() {
264
- Object.keys($).forEach((e) => {
265
- const t = _[e], l = $[e];
266
- t ? (t.styles = { ...l.styles, ...t.styles }, t.disabled && l.disabled && (t.disabled = { ...l.disabled, ...t.disabled })) : _[e] = $[e];
264
+ Object.keys(b).forEach((e) => {
265
+ const t = _[e], l = b[e];
266
+ t ? (t.styles = { ...l.styles, ...t.styles }, t.disabled && l.disabled && (t.disabled = { ...l.disabled, ...t.disabled })) : _[e] = b[e];
267
267
  });
268
268
  }
269
269
  })(u || (u = {}));
270
- function j(h) {
271
- const { clean: d, disabled: b, theme: i, component: r } = h;
270
+ const j = u;
271
+ function x(h) {
272
+ const { clean: d, disabled: $, theme: i, component: r } = h;
272
273
  return g(() => {
273
274
  var l, n, s;
274
275
  if (d)
@@ -277,9 +278,10 @@ function j(h) {
277
278
  if (!e)
278
279
  return;
279
280
  let t = i ? { ...e.styles, ...(n = e.themes) == null ? void 0 : n[i].styles } : e.styles;
280
- return b ? i ? { ...t, ...e.disabled, ...(s = e.themes) == null ? void 0 : s[i].disabled } : { ...t, ...e.disabled } : t;
281
- }, [r, d, b, i]);
281
+ return $ ? i ? { ...t, ...e.disabled, ...(s = e.themes) == null ? void 0 : s[i].disabled } : { ...t, ...e.disabled } : t;
282
+ }, [r, d, $, i]);
282
283
  }
283
284
  export {
284
- j as useTheme
285
+ j as T,
286
+ x as u
285
287
  };
package/utils.js CHANGED
@@ -1,14 +1,14 @@
1
- import "react";
2
- var a;
3
- ((u) => {
4
- function i(...c) {
5
- return c.reduce((s, n) => n ? typeof n == "string" ? (s.push(n), s) : Array.isArray(n) ? (s.push(...i(...n)), s) : (Object.entries(n).forEach(([r, e]) => {
6
- e && s.push(r);
7
- }), s) : s, []);
1
+ import { useMemo as x } from "react";
2
+ var p;
3
+ ((c) => {
4
+ function i(...u) {
5
+ return u.reduce((n, o) => o ? typeof o == "string" ? (n.push(o), n) : Array.isArray(o) ? (n.push(...i(...o)), n) : (Object.entries(o).forEach(([r, e]) => {
6
+ e && n.push(r);
7
+ }), n) : n, []);
8
8
  }
9
- u.classNames = i;
10
- })(a || (a = {}));
11
- const y = a;
9
+ c.classNames = i;
10
+ })(p || (p = {}));
11
+ const y = p;
12
12
  class I {
13
13
  constructor() {
14
14
  this._index = 0, this._cache = {};
@@ -17,81 +17,91 @@ class I {
17
17
  return this._cache[i] || (this._cache[i] = this.getByIndex(this._index++)), this._cache[i];
18
18
  }
19
19
  getByIndex(i) {
20
- const { first: c, next: s } = x, n = i - c.length;
21
- if (n < 0)
22
- return c[i];
23
- const r = Math.floor(n / s.length), e = n - r * s.length;
24
- return this.getByIndex(r) + s[e];
20
+ const { first: u, next: n } = m, o = i - u.length;
21
+ if (o < 0)
22
+ return u[i];
23
+ const r = Math.floor(o / n.length), e = o - r * n.length;
24
+ return this.getByIndex(r) + n[e];
25
25
  }
26
26
  }
27
- const x = {
27
+ const m = {
28
28
  first: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
29
29
  next: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
30
30
  };
31
31
  var l;
32
- ((u) => {
33
- function i(s, ...n) {
34
- const r = { ...s }, e = {};
35
- return n.forEach((t) => {
32
+ ((c) => {
33
+ function i(n, ...o) {
34
+ const r = { ...n }, e = {};
35
+ return o.forEach((t) => {
36
36
  t in r && (e[t] = r[t], delete r[t]);
37
37
  }), [e, r];
38
38
  }
39
- u.moveToTagProps = i;
40
- function c(s, n, r) {
41
- const e = { ...s }, t = e.props || {};
42
- return n.forEach((o) => {
43
- if (o in e) {
44
- if (t[o] = e[o], o === "disabled")
39
+ c.moveToTagProps = i;
40
+ function u(n, o, r) {
41
+ const e = { ...n }, t = e.props || {};
42
+ return o.forEach((s) => {
43
+ if (s in e) {
44
+ if (t[s] = e[s], s === "disabled")
45
45
  return;
46
- delete e[o];
46
+ delete e[s];
47
47
  }
48
- }), r && Object.entries(r).forEach(([o, f]) => {
49
- t[o] = f;
48
+ }), r && Object.entries(r).forEach(([s, f]) => {
49
+ t[s] = f;
50
50
  }), e.props = t, e;
51
51
  }
52
- u.buildProps = c;
52
+ c.buildProps = u;
53
53
  })(l || (l = {}));
54
- const P = l;
54
+ const E = l;
55
55
  var g;
56
- ((u) => {
57
- function i(s) {
58
- const n = Array.from(s.elements).reduce((r, e) => {
56
+ ((c) => {
57
+ function i(n) {
58
+ const o = Array.from(n.elements).reduce((r, e) => {
59
59
  const t = e.name;
60
60
  return t && (r[t] || (r[t] = []), r[t].push(e)), r;
61
61
  }, {});
62
- return Object.entries(n).reduce((r, [e, t]) => {
62
+ return Object.entries(o).reduce((r, [e, t]) => {
63
63
  if (t.length === 1) {
64
- const o = t[0];
65
- c(r, e, o.type === "checkbox" || o.type === "radio" ? o.checked : o.value);
64
+ const s = t[0];
65
+ u(r, e, s.type === "checkbox" || s.type === "radio" ? s.checked : s.value);
66
66
  } else {
67
- const o = t.reduce((f, h) => (h.type === "checkbox" || h.type === "radio" ? h.checked && f.push(h.value) : f.push(h.value), f), []);
68
- c(r, e, o);
67
+ const s = t.reduce((f, d) => (d.type === "checkbox" || d.type === "radio" ? d.checked && f.push(d.value) : f.push(d.value), f), []);
68
+ u(r, e, s);
69
69
  }
70
70
  return r;
71
71
  }, {});
72
72
  }
73
- u.getFormEntries = i;
74
- function c(s, n, r) {
75
- if (n.includes(".")) {
76
- const e = n.split(".");
77
- let t = s;
78
- e.forEach((o, f) => {
73
+ c.getFormEntries = i;
74
+ function u(n, o, r) {
75
+ if (o.includes(".")) {
76
+ const e = o.split(".");
77
+ let t = n;
78
+ e.forEach((s, f) => {
79
79
  if (e.length > f + 1) {
80
- const h = o.match(/^(.+)\[(\d)\]$/);
81
- if (h) {
82
- const [, p, d] = h;
83
- t[p] = t[p] || [], t[p][d] = t[p][d] || {}, t = t[p][d];
80
+ const d = s.match(/^(.+)\[(\d)\]$/);
81
+ if (d) {
82
+ const [, h, a] = d;
83
+ t[h] = t[h] || [], t[h][a] = t[h][a] || {}, t = t[h][a];
84
84
  } else
85
- t[o] = t[o] || {}, t = t[o];
85
+ t[s] = t[s] || {}, t = t[s];
86
86
  } else
87
- t[o] = r;
87
+ t[s] = r;
88
88
  });
89
89
  } else
90
- s[n] = r;
90
+ n[o] = r;
91
91
  }
92
92
  })(g || (g = {}));
93
+ const P = g;
94
+ function v() {
95
+ return x(() => {
96
+ const c = "crono-box";
97
+ let i = document.getElementById(c);
98
+ return i || (i = document.createElement("div"), i.id = c, document.body.appendChild(i)), i;
99
+ }, []);
100
+ }
93
101
  export {
94
102
  y as C,
103
+ P as F,
95
104
  I,
96
- P as O
105
+ E as O,
106
+ v as u
97
107
  };
@@ -1,19 +0,0 @@
1
- /// <reference types="react" />
2
- import Dox from './dox';
3
- import ClassNameUtils from '../utils/className/classNameUtils';
4
- import { DoxSvgStyles } from './dox/doxStyles';
5
- type SvgTagProps = Required<React.ComponentProps<typeof Dox<'svg'>>>['props'];
6
- type DoxSvgTagProps = Omit<SvgTagProps, 'viewBox' | 'width' | 'height'>;
7
- interface Props extends DoxSvgStyles {
8
- children?: React.ReactNode | ((props: {
9
- isHover: boolean;
10
- }) => React.ReactNode);
11
- props?: DoxSvgTagProps;
12
- style?: React.ComponentProps<'svg'>['style'];
13
- className?: ClassNameUtils.ClassNameType;
14
- viewBox?: string;
15
- width?: string;
16
- height?: string;
17
- }
18
- declare const _default: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<SVGSVGElement>>;
19
- export default _default;
@@ -1,18 +0,0 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { forwardRef as f } from "react";
3
- import g from "./dox.js";
4
- import "../utils.js";
5
- import "../theme.js";
6
- function n(o, r) {
7
- const { viewBox: t = "0 0 24 24", width: p = "1.5rem", height: i, props: m, ...s } = o;
8
- return /* @__PURE__ */ e(
9
- g,
10
- {
11
- tag: "svg",
12
- ref: r,
13
- props: { ...m, viewBox: t, width: p, height: i, xmlns: "http://www.w3.org/2000/svg", fill: "none" },
14
- ...s
15
- }
16
- );
17
- }
18
- f(n);