@cronocode/react-box 1.2.0 → 1.2.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.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import N, { forwardRef as v, useState as b } from "react";
2
2
  import { c as a } from "./box.module.css.mjs";
3
- import { C as g, t as u } from "./utils/utils.mjs";
3
+ import { C as g, a as u } from "./utils/utils.mjs";
4
4
  function C(n, r) {
5
- const { tag: d, children: e, props: h, className: c, style: l } = n, t = c ? g.classNames(a.box, c) : [a.box];
6
- Object.entries(n).forEach(([o, m]) => {
7
- const p = a[o + m];
8
- p ? t.push(p) : o in u && t.push(`${u[o]}${m}`);
5
+ const { tag: d, children: e, props: h, className: c, style: l } = n, o = c ? g.classNames(a.box, c) : [a.box];
6
+ Object.entries(n).forEach(([t, m]) => {
7
+ const p = a[t + m];
8
+ p ? o.push(p) : t in u && o.push(`${u[t]}${m}`);
9
9
  });
10
- const s = { ...h, className: t.join(" ") };
10
+ const s = { ...h, className: o.join(" ") };
11
11
  l && (s.style = l), r && (s.ref = r);
12
12
  const [x, f] = b(!1), i = typeof e == "function";
13
13
  return i && (s.onMouseEnter = () => f(!0), s.onMouseLeave = () => f(!1)), N.createElement(d || "div", s, i ? e({ isHover: x }) : e);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ColorType, Hovered } from '../types';
2
+ import { Activated, ColorType, Focused, Hovered } from '../types';
3
3
  import ClassNameUtils from '../utils/className/classNameUtils';
4
4
  interface SvgNormalStyles {
5
5
  fill?: ColorType | string;
@@ -7,7 +7,7 @@ interface SvgNormalStyles {
7
7
  rotate?: 0 | 90 | 180 | 270;
8
8
  flip?: 'xAxis' | 'yAxis';
9
9
  }
10
- export type SvgStyles = SvgNormalStyles & Hovered<SvgNormalStyles>;
10
+ export type SvgStyles = SvgNormalStyles & Hovered<SvgNormalStyles> & Focused<SvgNormalStyles> & Activated<SvgNormalStyles>;
11
11
  type AllSvgProps = React.SVGProps<SVGElement>;
12
12
  type SvgPropsType = Omit<AllSvgProps, 'className' | 'style' | 'width' | 'height'>;
13
13
  type SvgStyleType = Omit<React.CSSProperties, 'width' | 'height'>;
@@ -1,21 +1,21 @@
1
- import x, { useState as v } from "react";
2
- import { C as d } from "../utils/utils.mjs";
3
- const a = { base: "cGH", rotate0: "cGI", rotateH0: "cGJ", hovertrue: "_h", rotate90: "cGK", rotateH90: "cGL", rotate180: "cGM", rotateH180: "cGN", rotate270: "cGO", rotateH270: "cGP", flipxAxis: "cGQ", flipHxAxis: "cGR", flipyAxis: "cGS", flipHyAxis: "cGT" }, g = ["fill", "fillH", "stroke", "strokeH"];
1
+ import H, { useState as g } from "react";
2
+ import { C as w, t as p } from "../utils/utils.mjs";
3
+ const a = { base: "cGH", rotate0: "cGI", rotateH0: "cGJ", hovertrue: "_h", rotate90: "cGK", rotateH90: "cGL", rotate180: "cGM", rotateH180: "cGN", rotate270: "cGO", rotateH270: "cGP", flipxAxis: "cGQ", flipHxAxis: "cGR", flipyAxis: "cGS", flipHyAxis: "cGT" };
4
4
  function A(c) {
5
- const { children: s, props: m, className: r, style: p, viewBox: G, width: u, height: H } = c, e = r ? d.classNames(r, a.base) : [a.base];
6
- Object.entries(c).forEach(([o, n]) => {
7
- const f = a[o + n];
8
- f ? e.push(f) : g.includes(o) && e.push(`${o}${n}`);
5
+ const { children: s, props: G, className: r, style: m, viewBox: h, width: u, height: v } = c, e = r ? w.classNames(r, a.base) : [a.base];
6
+ Object.entries(c).forEach(([o, l]) => {
7
+ const f = a[o + l];
8
+ f ? e.push(f) : o in p && e.push(`${p[o]}${l}`);
9
9
  });
10
10
  const t = {
11
- ...m,
12
- style: { ...p, width: u, height: H },
11
+ ...G,
12
+ style: { ...m, width: u, height: v },
13
13
  className: e.join(" "),
14
- viewBox: G || "0 0 24 24",
14
+ viewBox: h || "0 0 24 24",
15
15
  xmlns: "http://www.w3.org/2000/svg",
16
16
  fill: "none"
17
- }, [h, i] = v(!1), l = typeof s == "function";
18
- return l && (t.onMouseEnter = () => i(!0), t.onMouseLeave = () => i(!1)), x.createElement("svg", t, l ? s({ isHover: h }) : s);
17
+ }, [x, i] = g(!1), n = typeof s == "function";
18
+ return n && (t.onMouseEnter = () => i(!0), t.onMouseLeave = () => i(!1)), H.createElement("svg", t, n ? s({ isHover: x }) : s);
19
19
  }
20
20
  export {
21
21
  A as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronocode/react-box",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "main": "./box.mjs",
5
5
  "module": "./box.mjs",
6
6
  "types": "./box.d.ts",
package/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SvgStyles } from './components/baseSvg/baseSvg';
1
2
  export type Hovered<T> = {
2
3
  [K in keyof T as K extends string ? `${K}H` : never]: T[K];
3
4
  };
@@ -212,4 +213,5 @@ interface BoxUserSelect {
212
213
  type BoxNormalStyles = BoxPseudoClasses & BoxDisplay & BoxSizing & BoxPosition & BoxSize & BoxMargin & BoxPadding & BoxBorder & BoxShadow & BoxBackground & BoxColors & BoxCursor & BoxZIndex & BoxOverflow & BoxOpacity & BoxFont & BoxText & BoxFlex & BoxOutline & BoxTransition & BoxUserSelect;
213
214
  export type BoxStyles = BoxNormalStyles & Hovered<BoxNormalStyles> & Focused<BoxNormalStyles> & Activated<BoxNormalStyles>;
214
215
  export declare const themeClasses: Partial<Record<keyof BoxStyles, string>>;
216
+ export declare const themeSvgClasses: Partial<Record<keyof SvgStyles, string>>;
215
217
  export {};
package/utils/utils.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const h = {
1
+ const C = {
2
2
  hover: "_h",
3
3
  focus: "_f",
4
4
  shadow: "shadow_",
@@ -33,70 +33,80 @@ const h = {
33
33
  outlineColorH: "outlineColor_h_",
34
34
  outlineColorF: "outlineColor_f_",
35
35
  outlineColorA: "outlineColor_a_"
36
+ }, d = {
37
+ fill: "fill_",
38
+ fillH: "fill_h_",
39
+ fillF: "fill_f_",
40
+ fillA: "fill_a_",
41
+ stroke: "stroke_",
42
+ strokeH: "stroke_h_",
43
+ strokeF: "stroke_f_",
44
+ strokeA: "stroke_a_"
36
45
  };
37
- var a;
38
- ((b) => {
39
- function s(...n) {
40
- return n.reduce((l, r) => r ? typeof r == "string" ? (l.push(r), l) : Array.isArray(r) ? (l.push(...s(...r)), l) : (Object.entries(r).forEach(([e, t]) => {
41
- t && l.push(e);
42
- }), l) : l, []);
46
+ var g;
47
+ ((n) => {
48
+ function c(...i) {
49
+ return i.reduce((t, r) => r ? typeof r == "string" ? (t.push(r), t) : Array.isArray(r) ? (t.push(...c(...r)), t) : (Object.entries(r).forEach(([e, l]) => {
50
+ l && t.push(e);
51
+ }), t) : t, []);
43
52
  }
44
- b.classNames = s;
45
- })(a || (a = {}));
46
- const f = a;
47
- var d;
48
- ((b) => {
49
- function s(n, ...l) {
50
- const r = { ...n }, e = {};
51
- return l.forEach((t) => {
52
- t in r && (e[t] = r[t], delete r[t]);
53
+ n.classNames = c;
54
+ })(g || (g = {}));
55
+ const p = g;
56
+ var u;
57
+ ((n) => {
58
+ function c(i, ...t) {
59
+ const r = { ...i }, e = {};
60
+ return t.forEach((l) => {
61
+ l in r && (e[l] = r[l], delete r[l]);
53
62
  }), [e, r];
54
63
  }
55
- b.moveToTagProps = s;
56
- })(d || (d = {}));
57
- const p = d;
58
- var C;
59
- ((b) => {
60
- function s(l) {
61
- const r = Array.from(l.elements).reduce((e, t) => {
62
- const o = t.name;
63
- return o && (e[o] || (e[o] = []), e[o].push(t)), e;
64
+ n.moveToTagProps = c;
65
+ })(u || (u = {}));
66
+ const k = u;
67
+ var h;
68
+ ((n) => {
69
+ function c(t) {
70
+ const r = Array.from(t.elements).reduce((e, l) => {
71
+ const o = l.name;
72
+ return o && (e[o] || (e[o] = []), e[o].push(l)), e;
64
73
  }, {});
65
- return Object.entries(r).reduce((e, [t, o]) => {
74
+ return Object.entries(r).reduce((e, [l, o]) => {
66
75
  if (o.length === 1) {
67
76
  const _ = o[0];
68
- n(e, t, _.type === "checkbox" || _.type === "radio" ? _.checked : _.value);
77
+ i(e, l, _.type === "checkbox" || _.type === "radio" ? _.checked : _.value);
69
78
  } else {
70
- const _ = o.reduce((i, c) => (c.type === "checkbox" || c.type === "radio" ? c.checked && i.push(c.value) : i.push(c.value), i), []);
71
- n(e, t, _);
79
+ const _ = o.reduce((b, s) => (s.type === "checkbox" || s.type === "radio" ? s.checked && b.push(s.value) : b.push(s.value), b), []);
80
+ i(e, l, _);
72
81
  }
73
82
  return e;
74
83
  }, {});
75
84
  }
76
- b.getFormEntries = s;
77
- function n(l, r, e) {
85
+ n.getFormEntries = c;
86
+ function i(t, r, e) {
78
87
  if (r.includes(".")) {
79
- const t = r.split(".");
80
- let o = l;
81
- t.forEach((_, i) => {
82
- if (t.length > i + 1) {
83
- const c = _.match(/^(.+)\[(\d)\]$/);
84
- if (c) {
85
- const [, u, g] = c;
86
- o[u] = o[u] || [], o[u][g] = o[u][g] || {}, o = o[u][g];
88
+ const l = r.split(".");
89
+ let o = t;
90
+ l.forEach((_, b) => {
91
+ if (l.length > b + 1) {
92
+ const s = _.match(/^(.+)\[(\d)\]$/);
93
+ if (s) {
94
+ const [, a, f] = s;
95
+ o[a] = o[a] || [], o[a][f] = o[a][f] || {}, o = o[a][f];
87
96
  } else
88
97
  o[_] = o[_] || {}, o = o[_];
89
98
  } else
90
99
  o[_] = e;
91
100
  });
92
101
  } else
93
- l[r] = e;
102
+ t[r] = e;
94
103
  }
95
- })(C || (C = {}));
96
- const F = C;
104
+ })(h || (h = {}));
105
+ const F = h;
97
106
  export {
98
- f as C,
107
+ p as C,
99
108
  F,
100
- p as O,
101
- h as t
109
+ k as O,
110
+ C as a,
111
+ d as t
102
112
  };