@cronocode/react-box 1.6.2 → 1.6.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.
@@ -1,57 +1,73 @@
1
- import E, { useLayoutEffect as B, useMemo as T, forwardRef as O, useState as I } from "react";
2
- import { I as A, C as F } from "../utils/utils.mjs";
3
- import { useTheme as _ } from "../theme.mjs";
1
+ import F, { useLayoutEffect as I, useMemo as E, forwardRef as _, useState as D } from "react";
2
+ import { I as P, C as M } from "../utils/utils.mjs";
3
+ import { useTheme as W } from "../theme.mjs";
4
4
  var e;
5
5
  ((a) => {
6
- ((u) => {
7
- function c(n, m) {
8
- return `${n}${m.replace("/", "-")}`;
6
+ ((r) => {
7
+ function n(o, d) {
8
+ return `${o}${d.replace("/", "-")}`;
9
9
  }
10
- u.fraction = c;
11
- })(a.ClassName || (a.ClassName = {})), ((u) => {
12
- function c(o, i) {
13
- return `${i / 4}rem`;
10
+ r.fraction = n;
11
+ function v(o) {
12
+ return [`${o} path`, `${o} circle`, `${o} rect`, `${o} line`];
14
13
  }
15
- u.rem = c;
16
- function n(o, i) {
17
- return `${i}px`;
14
+ r.svg = v;
15
+ })(a.ClassName || (a.ClassName = {})), ((r) => {
16
+ function n(u, l) {
17
+ return `${l / 4}rem`;
18
18
  }
19
- u.px = n;
20
- function m(o, i) {
21
- const [V, t] = i.split("/");
22
- return `${+V / +t * 100}%`;
19
+ r.rem = n;
20
+ function v(u, l) {
21
+ return `${l}px`;
23
22
  }
24
- u.fraction = m;
25
- function g(o, i) {
26
- switch (i) {
23
+ r.px = v;
24
+ function o(u, l) {
25
+ const [i, c] = l.split("/");
26
+ return `${+i / +c * 100}%`;
27
+ }
28
+ r.fraction = o;
29
+ function d(u, l) {
30
+ switch (l) {
27
31
  case "fit":
28
32
  return "100%";
29
33
  case "fit-screen":
30
- return o.toLocaleLowerCase().includes("height") ? "100vh" : "100vw";
34
+ return u.toLocaleLowerCase().includes("height") ? "100vh" : "100vw";
31
35
  default:
32
- return i;
36
+ return l;
33
37
  }
34
38
  }
35
- u.widthHeight = g;
36
- function h(o) {
37
- return (i, V) => `var(--${o}${V});`;
39
+ r.widthHeight = d;
40
+ function g(u) {
41
+ return (l, i) => `var(--${u}${i});`;
42
+ }
43
+ r.variables = g;
44
+ function y(u) {
45
+ return (l, i) => `var(--${u}${i});`;
46
+ }
47
+ r.svgVariables = y;
48
+ function x(u, l) {
49
+ return `repeat(${l},minmax(0,1fr))`;
50
+ }
51
+ r.gridColumns = x;
52
+ function f(u, l) {
53
+ return l === "full-row" ? "1/-1" : `span ${l}/span ${l}`;
38
54
  }
39
- u.variables = h;
40
- function N(o, i) {
41
- return `repeat(${i},minmax(0,1fr))`;
55
+ r.gridColumn = f;
56
+ function h(u, l) {
57
+ return `${l}ms`;
42
58
  }
43
- u.gridColumns = N;
44
- function z(o, i) {
45
- return i === "full-row" ? "1/-1" : `span ${i}/span ${i}`;
59
+ r.ms = h;
60
+ function V(u, l) {
61
+ return `${l}deg`;
46
62
  }
47
- u.gridColumn = z;
48
- function d(o, i) {
49
- return `${i}ms`;
63
+ r.rotate = V;
64
+ function b(u, l) {
65
+ return l === "xAxis" ? "-1 1" : "1 -1";
50
66
  }
51
- u.ms = d;
67
+ r.flip = b;
52
68
  })(a.Value || (a.Value = {}));
53
69
  })(e || (e = {}));
54
- const D = ["H", "F", "A"];
70
+ const G = ["H", "F", "A"];
55
71
  var s;
56
72
  ((a) => {
57
73
  a.positiveSizes = [
@@ -192,17 +208,28 @@ var s;
192
208
  "11/12"
193
209
  ], a.widthHeightValues = ["fit", "fit-screen", "auto", "fit-content", "max-content", "min-content"], a.alignSelf = ["auto", "flex-start", "flex-end", "center", "baseline", "stretch"];
194
210
  })(s || (s = {}));
195
- const H = {
211
+ const R = {
196
212
  shadow: { cssNames: ["box-shadow"], formatValue: e.Value.variables("shadow") },
197
213
  background: { cssNames: ["background"], formatValue: e.Value.variables("background") },
198
214
  color: { cssNames: ["color"], formatValue: e.Value.variables("color") },
199
215
  bgColor: { cssNames: ["background-color"], formatValue: e.Value.variables("color") },
200
216
  borderColor: { cssNames: ["border-color"], formatValue: e.Value.variables("color") },
201
217
  outlineColor: { cssNames: ["outline-color"], formatValue: e.Value.variables("color") }
202
- }, S = {
218
+ }, j = {
219
+ fill: {
220
+ cssNames: ["fill"],
221
+ formatValue: e.Value.svgVariables("color"),
222
+ formatSelector: e.ClassName.svg
223
+ },
224
+ stroke: {
225
+ cssNames: ["stroke"],
226
+ formatValue: e.Value.svgVariables("color"),
227
+ formatSelector: e.ClassName.svg
228
+ }
229
+ }, $ = {
203
230
  hover: { className: "_h" },
204
231
  focus: { className: "_f" }
205
- }, l = {
232
+ }, t = {
206
233
  display: {
207
234
  cssNames: ["display"],
208
235
  values1: { values: ["none", "block", "inline-block", "flex", "inline-flex", "grid", "inline-grid", "contents"] },
@@ -221,8 +248,8 @@ const H = {
221
248
  values2: { values: s.positiveSizes, formatValue: e.Value.rem },
222
249
  values3: {
223
250
  values: s.widthHeightFractions,
224
- formatValue: e.Value.fraction,
225
- formatClassName: e.ClassName.fraction
251
+ formatValue: e.Value.fraction
252
+ // formatClassName: DoxStylesFormatters.ClassName.fraction,
226
253
  }
227
254
  },
228
255
  minWidth: {
@@ -231,8 +258,8 @@ const H = {
231
258
  values2: { values: s.positiveSizes, formatValue: e.Value.rem },
232
259
  values3: {
233
260
  values: s.widthHeightFractions,
234
- formatValue: e.Value.fraction,
235
- formatClassName: e.ClassName.fraction
261
+ formatValue: e.Value.fraction
262
+ // formatClassName: DoxStylesFormatters.ClassName.fraction,
236
263
  }
237
264
  },
238
265
  maxWidth: {
@@ -241,8 +268,8 @@ const H = {
241
268
  values2: { values: s.positiveSizes, formatValue: e.Value.rem },
242
269
  values3: {
243
270
  values: s.widthHeightFractions,
244
- formatValue: e.Value.fraction,
245
- formatClassName: e.ClassName.fraction
271
+ formatValue: e.Value.fraction
272
+ // formatClassName: DoxStylesFormatters.ClassName.fraction,
246
273
  }
247
274
  },
248
275
  height: {
@@ -251,8 +278,8 @@ const H = {
251
278
  values2: { values: s.positiveSizes, formatValue: e.Value.rem },
252
279
  values3: {
253
280
  values: s.widthHeightFractions,
254
- formatValue: e.Value.fraction,
255
- formatClassName: e.ClassName.fraction
281
+ formatValue: e.Value.fraction
282
+ // formatClassName: DoxStylesFormatters.ClassName.fraction,
256
283
  }
257
284
  },
258
285
  minHeight: {
@@ -261,8 +288,8 @@ const H = {
261
288
  values2: { values: s.positiveSizes, formatValue: e.Value.rem },
262
289
  values3: {
263
290
  values: s.widthHeightFractions,
264
- formatValue: e.Value.fraction,
265
- formatClassName: e.ClassName.fraction
291
+ formatValue: e.Value.fraction
292
+ // formatClassName: DoxStylesFormatters.ClassName.fraction,
266
293
  }
267
294
  },
268
295
  maxHeight: {
@@ -271,8 +298,8 @@ const H = {
271
298
  values2: { values: s.positiveSizes, formatValue: e.Value.rem },
272
299
  values3: {
273
300
  values: s.widthHeightFractions,
274
- formatValue: e.Value.fraction,
275
- formatClassName: e.ClassName.fraction
301
+ formatValue: e.Value.fraction
302
+ // formatClassName: DoxStylesFormatters.ClassName.fraction,
276
303
  }
277
304
  },
278
305
  position: {
@@ -822,122 +849,155 @@ const H = {
822
849
  values2: { values: [] },
823
850
  values3: { values: [] }
824
851
  }
852
+ }, C = {
853
+ rotate: {
854
+ cssNames: ["rotate"],
855
+ values1: { values: [0, 90, 180, 270, -90, -180, -270], formatValue: e.Value.rotate },
856
+ values2: { values: [] },
857
+ values3: { values: [] }
858
+ },
859
+ flip: {
860
+ cssNames: ["scale"],
861
+ values1: { values: ["xAxis", "yAxis"], formatValue: e.Value.flip },
862
+ values2: { values: [] },
863
+ values3: { values: [] }
864
+ }
825
865
  };
826
- Object.keys(H).forEach((a) => {
827
- l[a] = H[a], l[a].isThemeStyle = !0;
866
+ Object.keys(C).forEach((a) => {
867
+ t[a] = C[a];
828
868
  });
829
- const b = {
830
- m: { ...l.margin, key: "margin" },
831
- mx: { ...l.marginHorizontal, key: "marginHorizontal" },
832
- my: { ...l.marginVertical, key: "marginVertical" },
833
- mt: { ...l.marginTop, key: "marginTop" },
834
- mr: { ...l.marginRight, key: "marginRight" },
835
- mb: { ...l.marginBottom, key: "marginBottom" },
836
- ml: { ...l.marginLeft, key: "marginLeft" },
837
- p: { ...l.padding, key: "padding" },
838
- px: { ...l.paddingHorizontal, key: "paddingHorizontal" },
839
- py: { ...l.paddingVertical, key: "paddingVertical" },
840
- pt: { ...l.paddingTop, key: "paddingTop" },
841
- pr: { ...l.paddingRight, key: "paddingRight" },
842
- pb: { ...l.paddingBottom, key: "paddingBottom" },
843
- pl: { ...l.paddingLeft, key: "paddingLeft" },
844
- b: { ...l.border, key: "border" },
845
- bx: { ...l.borderHorizontal, key: "borderHorizontal" },
846
- by: { ...l.borderVertical, key: "borderVertical" },
847
- bt: { ...l.borderTop, key: "borderTop" },
848
- br: { ...l.borderRight, key: "borderRight" },
849
- bb: { ...l.borderBottom, key: "borderBottom" },
850
- bl: { ...l.borderLeft, key: "borderLeft" },
851
- jc: { ...l.justifyContent, key: "justifyContent" },
852
- ai: { ...l.alignItems, key: "alignItems" },
853
- ac: { ...l.alignContent, key: "alignContent" },
854
- d: { ...l.flexDirection, key: "flexDirection" }
855
- }, P = Object.keys(l), M = Object.keys(b);
856
- D.forEach((a) => {
857
- P.forEach((u) => {
858
- l[`${u}${a}`] = { ...l[u] }, l[`${u}${a}`].pseudoSuffix = a;
859
- }), M.forEach((u) => {
860
- b[`${u}${a}`] = { ...b[u], key: `${b[u].key}${a}` }, b[`${u}${a}`].pseudoSuffix = a;
869
+ Object.keys(R).forEach((a) => {
870
+ t[a] = R[a], t[a].isThemeStyle = !0;
871
+ });
872
+ Object.keys(j).forEach((a) => {
873
+ t[a] = j[a], t[a].isThemeStyle = !0;
874
+ });
875
+ const z = {
876
+ w: { ...t.width, key: "width" },
877
+ h: { ...t.height, key: "height" },
878
+ m: { ...t.margin, key: "margin" },
879
+ mx: { ...t.marginHorizontal, key: "marginHorizontal" },
880
+ my: { ...t.marginVertical, key: "marginVertical" },
881
+ mt: { ...t.marginTop, key: "marginTop" },
882
+ mr: { ...t.marginRight, key: "marginRight" },
883
+ mb: { ...t.marginBottom, key: "marginBottom" },
884
+ ml: { ...t.marginLeft, key: "marginLeft" },
885
+ p: { ...t.padding, key: "padding" },
886
+ px: { ...t.paddingHorizontal, key: "paddingHorizontal" },
887
+ py: { ...t.paddingVertical, key: "paddingVertical" },
888
+ pt: { ...t.paddingTop, key: "paddingTop" },
889
+ pr: { ...t.paddingRight, key: "paddingRight" },
890
+ pb: { ...t.paddingBottom, key: "paddingBottom" },
891
+ pl: { ...t.paddingLeft, key: "paddingLeft" },
892
+ b: { ...t.border, key: "border" },
893
+ bx: { ...t.borderHorizontal, key: "borderHorizontal" },
894
+ by: { ...t.borderVertical, key: "borderVertical" },
895
+ bt: { ...t.borderTop, key: "borderTop" },
896
+ br: { ...t.borderRight, key: "borderRight" },
897
+ bb: { ...t.borderBottom, key: "borderBottom" },
898
+ bl: { ...t.borderLeft, key: "borderLeft" },
899
+ jc: { ...t.justifyContent, key: "justifyContent" },
900
+ ai: { ...t.alignItems, key: "alignItems" },
901
+ ac: { ...t.alignContent, key: "alignContent" },
902
+ d: { ...t.flexDirection, key: "flexDirection" }
903
+ }, q = Object.keys(t), U = Object.keys(z);
904
+ G.forEach((a) => {
905
+ q.forEach((r) => {
906
+ t[`${r}${a}`] = { ...t[r] }, t[`${r}${a}`].pseudoSuffix = a;
907
+ }), U.forEach((r) => {
908
+ z[`${r}${a}`] = { ...z[r], key: `${z[r].key}${a}` }, z[`${r}${a}`].pseudoSuffix = a;
861
909
  });
862
910
  });
863
911
  var w;
864
912
  ((a) => {
865
913
  a.doxClassName = "_dox", a.svgClassName = "_svg";
866
- const u = `:root{--borderColor: black;--outlineColor: black;--lineHeight: 1.2;--fontSize: 14px;--transitionTime: 0.25s;--svgTransitionTime: 0.3s;#crono-box {position: absolute;top: 0;left: 0;height: 0;}}
914
+ const r = `:root{--borderColor: black;--outlineColor: black;--lineHeight: 1.2;--fontSize: 14px;--transitionTime: 0.25s;--svgTransitionTime: 0.3s;#crono-box {position: absolute;top: 0;left: 0;height: 0;}}
867
915
  html{font-size: 16px;font-family: Arial, sans-serif;}
868
916
  body{margin: 0;line-height: var(--lineHeight);font-size: var(--fontSize);}
869
917
  a,ul{all: unset;}
870
918
  .${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;}
871
- .${a.svgClassName}{width: 1.5rem;transition: all var(--svgTransitionTime);path,circle,rect,line {transition: all var(--svgTransitionTime);}}
872
- `, c = new A(), n = [...Object.keys(l), ...Object.keys(H)], m = V();
873
- let g = !1;
874
- const h = n.reduce((t, r) => (t[r] = /* @__PURE__ */ new Set(), t), {});
875
- function N(t, r) {
876
- if (t in l)
877
- return d(t, r);
878
- if (t in S)
879
- return S[t].className;
919
+ .${a.svgClassName}{width: 1.5rem;transition: all var(--svgTransitionTime);}.${a.svgClassName} path,.${a.svgClassName} circle,.${a.svgClassName} rect,.${a.svgClassName} line {transition: all var(--svgTransitionTime);}
920
+ `, n = new P(), v = Object.keys(t), o = b();
921
+ let d = !1;
922
+ const g = v.reduce((u, l) => (u[l] = /* @__PURE__ */ new Set(), u), {});
923
+ function y(u, l) {
924
+ if (u in t)
925
+ return f(u, l);
926
+ if (u in $)
927
+ return $[u].className;
928
+ if (u in C)
929
+ return f(u, l);
880
930
  }
881
- a.get = N;
882
- function z() {
883
- if (g) {
931
+ a.get = y;
932
+ function x() {
933
+ if (d) {
884
934
  console.info("%c💬Flush Dox Styles", "color: #00ffff");
885
- let t = o([u]);
886
- t = o(t, "H"), t = o(t, "F"), t = o(t, "A"), m.innerHTML = t.join(""), g = !1;
935
+ let u = h([r]);
936
+ u = h(u, "H"), u = h(u, "F"), u = h(u, "A"), o.innerHTML = u.join(""), d = !1;
887
937
  }
888
938
  }
889
- a.flush = z;
890
- function d(t, r) {
891
- var y;
892
- h[t].has(r) || (g = !0, h[t].add(r));
893
- const v = i(t, r), f = ((y = v.formatClassName) == null ? void 0 : y.call(v, t, r)) ?? `${t}${r}`;
894
- return `-${c.getIdentity(f)}`;
939
+ a.flush = x;
940
+ function f(u, l) {
941
+ var m;
942
+ g[u].has(l) || (d = !0, g[u].add(l));
943
+ const i = V(u, l), c = ((m = i.formatClassName) == null ? void 0 : m.call(i, u, l)) ?? `${u}${l}`;
944
+ return `-${n.getIdentity(c)}`;
895
945
  }
896
- function o(t, r) {
897
- return Object.entries(h).filter(([v]) => {
898
- var f;
899
- return ((f = l[v]) == null ? void 0 : f.pseudoSuffix) === r;
900
- }).reduce((v, [f, y]) => (y.forEach((x) => {
901
- var $;
902
- let p = d(f, x);
903
- r === "H" && (p = `${p}:hover,.${S.hover.className}:hover>.${p}`), r === "F" && (p = `${p}:focus-within,.${S.focus.className}:focus-within>.${p}`), r === "A" && (p = `${p}:active`);
904
- const C = i(f, x), R = (($ = C.formatValue) == null ? void 0 : $.call(C, f, x)) ?? x, j = l[f].cssNames.map((L) => `${L}:${R};`).join("");
905
- v.push(`.${p}{${j}}`);
906
- }), v), t);
946
+ function h(u, l) {
947
+ return Object.entries(g).filter(([c]) => {
948
+ var m;
949
+ return ((m = t[c]) == null ? void 0 : m.pseudoSuffix) === l;
950
+ }).reduce((c, [m, L]) => (L.forEach((k) => {
951
+ var T;
952
+ const p = V(m, k), N = `.${f(m, k)}`;
953
+ let S = [];
954
+ l ? l === "H" ? S = [
955
+ ...i(`${N}:hover`, p),
956
+ ...i(`.${$.hover.className}:hover>${N}`, p)
957
+ ] : l === "F" ? S = [
958
+ ...i(`${N}:focus-within`, p),
959
+ ...i(`.${$.focus.className}:focus-within>${N}`, p)
960
+ ] : l === "A" && (S = i(`${N}:active`, p)) : S = i(N, p);
961
+ const A = ((T = p.formatValue) == null ? void 0 : T.call(p, m, k)) ?? k, B = t[m].cssNames.map((O) => `${O}:${A};`).join("");
962
+ c.push(`${S.join(",")}{${B}}`);
963
+ }), c), u);
964
+ function i(c, m) {
965
+ return m.formatSelector ? m.formatSelector(c) : [c];
966
+ }
907
967
  }
908
- function i(t, r) {
909
- const v = l[t];
910
- return v.isThemeStyle ? v : v.values1.values.includes(r) ? v.values1 : v.values2.values.includes(r) ? v.values2 : v.values3;
968
+ function V(u, l) {
969
+ const i = t[u];
970
+ return i.isThemeStyle ? i : i.values1.values.includes(l) ? i.values1 : i.values2.values.includes(l) ? i.values2 : i.values3;
911
971
  }
912
- function V() {
913
- const t = "crono-styles";
914
- let r = document.getElementById(t);
915
- return r || (r = document.createElement("style"), r.setAttribute("id", t), r.setAttribute("type", "text/css"), document.head.insertBefore(r, document.head.firstChild)), r;
972
+ function b() {
973
+ const u = "crono-styles";
974
+ let l = document.getElementById(u);
975
+ return l || (l = document.createElement("style"), l.setAttribute("id", u), l.setAttribute("type", "text/css"), document.head.insertBefore(l, document.head.firstChild)), l;
916
976
  }
917
977
  })(w || (w = {}));
918
- function W(a) {
919
- const u = _(a);
920
- return B(w.flush, [a]), T(() => {
921
- const c = [w.doxClassName], n = u ? { ...k(u), ...k(a) } : k(a);
922
- return Object.entries(n).forEach(([m, g]) => {
923
- c.push(w.get(m, g));
924
- }), c;
925
- }, [a, u]);
978
+ function X(a, r) {
979
+ const n = W(a);
980
+ return I(w.flush, [a]), E(() => {
981
+ const v = [r ? w.svgClassName : w.doxClassName], o = n ? { ...H(n), ...H(a) } : H(a);
982
+ return Object.entries(o).forEach(([d, g]) => {
983
+ v.push(w.get(d, g));
984
+ }), v;
985
+ }, [a, n]);
926
986
  }
927
- function k(a) {
928
- const u = { ...a };
929
- return Object.keys(u).forEach((n) => {
930
- const m = b[n];
931
- m && (m.key in u || (u[m.key] = u[n]), delete u[n]);
932
- }), u;
987
+ function H(a) {
988
+ const r = { ...a };
989
+ return Object.keys(r).forEach((v) => {
990
+ const o = z[v];
991
+ o && (o.key in r || (r[o.key] = r[v]), delete r[v]);
992
+ }), r;
933
993
  }
934
- function G(a, u) {
935
- const { tag: c, children: n, props: m, className: g, style: h } = a, N = W(a), z = T(() => F.classNames(g, N).join(" "), [a]), d = { ...m, className: z };
936
- h && (d.style = h), u && (d.ref = u);
937
- const [o, i] = I(!1), V = typeof n == "function";
938
- return V && (d.onMouseEnter = () => i(!0), d.onMouseLeave = () => i(!1)), E.createElement(c || "div", d, V ? n({ isHover: o }) : n);
994
+ function Y(a, r) {
995
+ const { tag: n, children: v, props: o, className: d, style: g } = a, y = X(a, n === "svg"), x = E(() => M.classNames(d, y).join(" "), [a]), f = { ...o, className: x };
996
+ g && (f.style = g), r && (f.ref = r);
997
+ const [h, V] = D(!1), b = typeof v == "function";
998
+ return b && (f.onMouseEnter = () => V(!0), f.onMouseLeave = () => V(!1)), F.createElement(n || "div", f, b ? v({ isHover: h }) : v);
939
999
  }
940
- const J = O(G);
1000
+ const ee = _(Y);
941
1001
  export {
942
- J as default
1002
+ ee as default
943
1003
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronocode/react-box",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "main": "./box.cjs",
5
5
  "module": "./box.mjs",
6
6
  "types": "./box.d.ts",