@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 +6 -6
- package/components/baseSvg.d.ts +2 -2
- package/components/baseSvg.mjs +12 -12
- package/package.json +1 -1
- package/types.d.ts +2 -0
- package/utils/utils.mjs +55 -45
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,
|
|
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,
|
|
6
|
-
Object.entries(n).forEach(([
|
|
7
|
-
const p = a[
|
|
8
|
-
p ?
|
|
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:
|
|
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);
|
package/components/baseSvg.d.ts
CHANGED
|
@@ -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'>;
|
package/components/baseSvg.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { C as
|
|
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" }
|
|
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:
|
|
6
|
-
Object.entries(c).forEach(([o,
|
|
7
|
-
const f = a[o +
|
|
8
|
-
f ? e.push(f) :
|
|
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
|
-
...
|
|
12
|
-
style: { ...
|
|
11
|
+
...G,
|
|
12
|
+
style: { ...m, width: u, height: v },
|
|
13
13
|
className: e.join(" "),
|
|
14
|
-
viewBox:
|
|
14
|
+
viewBox: h || "0 0 24 24",
|
|
15
15
|
xmlns: "http://www.w3.org/2000/svg",
|
|
16
16
|
fill: "none"
|
|
17
|
-
}, [
|
|
18
|
-
return
|
|
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
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
|
|
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
|
|
38
|
-
((
|
|
39
|
-
function
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
}),
|
|
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
|
-
|
|
45
|
-
})(
|
|
46
|
-
const
|
|
47
|
-
var
|
|
48
|
-
((
|
|
49
|
-
function
|
|
50
|
-
const r = { ...
|
|
51
|
-
return
|
|
52
|
-
|
|
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
|
-
|
|
56
|
-
})(
|
|
57
|
-
const
|
|
58
|
-
var
|
|
59
|
-
((
|
|
60
|
-
function
|
|
61
|
-
const r = Array.from(
|
|
62
|
-
const o =
|
|
63
|
-
return o && (e[o] || (e[o] = []), e[o].push(
|
|
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, [
|
|
74
|
+
return Object.entries(r).reduce((e, [l, o]) => {
|
|
66
75
|
if (o.length === 1) {
|
|
67
76
|
const _ = o[0];
|
|
68
|
-
|
|
77
|
+
i(e, l, _.type === "checkbox" || _.type === "radio" ? _.checked : _.value);
|
|
69
78
|
} else {
|
|
70
|
-
const _ = o.reduce((
|
|
71
|
-
|
|
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
|
-
|
|
77
|
-
function
|
|
85
|
+
n.getFormEntries = c;
|
|
86
|
+
function i(t, r, e) {
|
|
78
87
|
if (r.includes(".")) {
|
|
79
|
-
const
|
|
80
|
-
let o =
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
const [,
|
|
86
|
-
o[
|
|
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
|
-
|
|
102
|
+
t[r] = e;
|
|
94
103
|
}
|
|
95
|
-
})(
|
|
96
|
-
const F =
|
|
104
|
+
})(h || (h = {}));
|
|
105
|
+
const F = h;
|
|
97
106
|
export {
|
|
98
|
-
|
|
107
|
+
p as C,
|
|
99
108
|
F,
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
k as O,
|
|
110
|
+
C as a,
|
|
111
|
+
d as t
|
|
102
112
|
};
|