@cronocode/react-box 1.3.3 → 1.3.4
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 +17 -19
- package/components/button.mjs +8 -8
- package/components/checkbox.mjs +1 -1
- package/components/radioButton.d.ts +0 -1
- package/components/radioButton.mjs +9 -9
- package/components/textarea.mjs +6 -6
- package/components/textbox.mjs +4 -4
- package/components/tooltip.mjs +39 -31
- package/package.json +1 -1
- package/theme.mjs +67 -17
package/box.mjs
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { c } from "./box.module.css.mjs";
|
|
3
|
-
import { C as
|
|
4
|
-
import { useTheme as
|
|
5
|
-
function
|
|
6
|
-
const { tag:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const [N, u] = E(!1), h = typeof i == "function";
|
|
17
|
-
return h && (t.onMouseEnter = () => u(!0), t.onMouseLeave = () => u(!1)), $.createElement(p || "div", t, h ? i({ isHover: N }) : i);
|
|
1
|
+
import b, { forwardRef as g, useMemo as E, useState as H } from "react";
|
|
2
|
+
import { c as n } from "./box.module.css.mjs";
|
|
3
|
+
import { C as M, a as d } from "./utils/utils.mjs";
|
|
4
|
+
import { useTheme as P } from "./theme.mjs";
|
|
5
|
+
function S(e, r) {
|
|
6
|
+
const { tag: h, children: t, props: p, className: c, style: l } = e, N = P(e), x = E(() => {
|
|
7
|
+
const o = c ? M.classNames(n.box, c) : [n.box], C = { ...N, ...e };
|
|
8
|
+
return Object.entries(C).forEach(([a, i]) => {
|
|
9
|
+
const u = n[a + i];
|
|
10
|
+
u ? o.push(u) : a in d && o.push(`${d[a]}${i}`);
|
|
11
|
+
}), o.join(" ");
|
|
12
|
+
}, [e]), s = { ...p, className: x };
|
|
13
|
+
l && (s.style = l), r && (s.ref = r);
|
|
14
|
+
const [v, m] = H(!1), f = typeof t == "function";
|
|
15
|
+
return f && (s.onMouseEnter = () => m(!0), s.onMouseLeave = () => m(!1)), b.createElement(h || "div", s, f ? t({ isHover: v }) : t);
|
|
18
16
|
}
|
|
19
|
-
const
|
|
17
|
+
const y = g(S);
|
|
20
18
|
export {
|
|
21
|
-
|
|
19
|
+
y as default
|
|
22
20
|
};
|
package/components/button.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { O as
|
|
2
|
+
import { forwardRef as p } from "react";
|
|
3
|
+
import i from "../box.mjs";
|
|
4
|
+
import { O as m } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
6
|
import "../theme.mjs";
|
|
7
7
|
const s = ["type", "onClick", "disabled"];
|
|
8
|
-
function
|
|
9
|
-
const r =
|
|
10
|
-
return /* @__PURE__ */ n(
|
|
8
|
+
function e(o, t) {
|
|
9
|
+
const r = m.buildProps(o, s);
|
|
10
|
+
return /* @__PURE__ */ n(i, { ref: t, tag: "button", component: "button", ...r });
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const l = p(e);
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
l as default
|
|
15
15
|
};
|
package/components/checkbox.mjs
CHANGED
|
@@ -20,7 +20,7 @@ const p = [
|
|
|
20
20
|
function m(o, r) {
|
|
21
21
|
const { native: n } = o, i = a.buildProps(o, p, { type: "checkbox" });
|
|
22
22
|
return /* @__PURE__ */ c(l, { inline: !0, position: "relative", children: [
|
|
23
|
-
/* @__PURE__ */ e(t, { ref: r, tag: "input",
|
|
23
|
+
/* @__PURE__ */ e(t, { ref: r, tag: "input", component: "checkbox", ...i, appearance: n ? void 0 : "none" }),
|
|
24
24
|
!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
25
|
] });
|
|
26
26
|
}
|
|
@@ -16,7 +16,6 @@ interface Props extends Omit<BoxProps, 'props'> {
|
|
|
16
16
|
required?: boolean;
|
|
17
17
|
checked?: boolean;
|
|
18
18
|
defaultChecked?: boolean;
|
|
19
|
-
native?: boolean;
|
|
20
19
|
}
|
|
21
20
|
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
22
21
|
export default _default;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { O as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as n } from "react";
|
|
3
|
+
import a from "../box.mjs";
|
|
4
|
+
import { O as i } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
6
|
import "../theme.mjs";
|
|
7
|
-
const
|
|
7
|
+
const d = [
|
|
8
8
|
"name",
|
|
9
9
|
"onInput",
|
|
10
10
|
"onChange",
|
|
@@ -16,11 +16,11 @@ const p = [
|
|
|
16
16
|
"checked",
|
|
17
17
|
"defaultChecked"
|
|
18
18
|
];
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
return /* @__PURE__ */
|
|
19
|
+
function p(o, t) {
|
|
20
|
+
const r = i.buildProps(o, d, { type: "radio" });
|
|
21
|
+
return /* @__PURE__ */ e(a, { ref: t, tag: "input", component: "radioButton", ...r });
|
|
22
22
|
}
|
|
23
|
-
const B =
|
|
23
|
+
const B = n(p);
|
|
24
24
|
export {
|
|
25
25
|
B as default
|
|
26
26
|
};
|
package/components/textarea.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as a } from "react";
|
|
3
3
|
import n from "../box.mjs";
|
|
4
|
-
import { O as
|
|
4
|
+
import { O as m } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
6
|
import "../theme.mjs";
|
|
7
|
-
const
|
|
7
|
+
const s = [
|
|
8
8
|
"name",
|
|
9
9
|
"onInput",
|
|
10
10
|
"onChange",
|
|
@@ -20,11 +20,11 @@ const m = [
|
|
|
20
20
|
"readOnly",
|
|
21
21
|
"required"
|
|
22
22
|
];
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
return /* @__PURE__ */ r(n, { ref:
|
|
23
|
+
function p(t, o) {
|
|
24
|
+
const e = m.buildProps(t, s);
|
|
25
|
+
return /* @__PURE__ */ r(n, { ref: o, tag: "textarea", component: "textarea", ...e });
|
|
26
26
|
}
|
|
27
|
-
const x = a(
|
|
27
|
+
const x = a(p);
|
|
28
28
|
export {
|
|
29
29
|
x as default
|
|
30
30
|
};
|
package/components/textbox.mjs
CHANGED
|
@@ -18,11 +18,11 @@ const i = [
|
|
|
18
18
|
"value",
|
|
19
19
|
"pattern"
|
|
20
20
|
];
|
|
21
|
-
function
|
|
22
|
-
const e = p.buildProps(
|
|
23
|
-
return /* @__PURE__ */ r(a, { ref:
|
|
21
|
+
function m(o, t) {
|
|
22
|
+
const e = p.buildProps(o, i);
|
|
23
|
+
return /* @__PURE__ */ r(a, { ref: t, tag: "input", component: "textbox", ...e });
|
|
24
24
|
}
|
|
25
|
-
const c = n(
|
|
25
|
+
const c = n(m);
|
|
26
26
|
export {
|
|
27
27
|
c as default
|
|
28
28
|
};
|
package/components/tooltip.mjs
CHANGED
|
@@ -1,49 +1,57 @@
|
|
|
1
1
|
import { jsxs as x, Fragment as b, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { createPortal as E } from "react-dom";
|
|
3
|
-
import
|
|
4
|
-
import { useRef as L, useState as z, useCallback as
|
|
3
|
+
import f from "../box.mjs";
|
|
4
|
+
import { useRef as L, useState as z, useCallback as c, useLayoutEffect as g } from "react";
|
|
5
5
|
import { u as C } from "../utils/utils.mjs";
|
|
6
6
|
import "../box.module.css.mjs";
|
|
7
7
|
import "../theme.mjs";
|
|
8
|
-
function P(
|
|
9
|
-
const { children:
|
|
10
|
-
|
|
11
|
-
u
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
document.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
function P(i) {
|
|
9
|
+
const { children: p, onPositionChange: s } = i, n = L(null), [t, d] = z(), m = C(), w = c(
|
|
10
|
+
(e, r) => {
|
|
11
|
+
const o = (u) => {
|
|
12
|
+
u.target.contains(e) && r();
|
|
13
|
+
};
|
|
14
|
+
return document.addEventListener("scroll", o, { capture: !0 }), () => {
|
|
15
|
+
document.removeEventListener("scroll", o, { capture: !0 });
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
[t]
|
|
19
|
+
), v = c(
|
|
20
|
+
(e, r) => {
|
|
21
|
+
const o = (u) => {
|
|
22
|
+
r();
|
|
23
|
+
};
|
|
24
|
+
return window.addEventListener("resize", o, { capture: !0 }), () => {
|
|
25
|
+
window.removeEventListener("resize", o, { capture: !0 });
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
[t]
|
|
29
|
+
), l = c(() => {
|
|
30
|
+
if (n.current) {
|
|
31
|
+
const e = n.current.getBoundingClientRect(), r = e.top + window.scrollY, o = e.left + window.scrollX;
|
|
32
|
+
((t == null ? void 0 : t.top) !== r || (t == null ? void 0 : t.left) !== o) && (s == null || s({ top: r, left: o }), d({ top: e.top + window.scrollY, left: e.left + window.scrollX }));
|
|
33
|
+
}
|
|
34
|
+
}, [t]);
|
|
27
35
|
return g(() => {
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
const
|
|
36
|
+
if (n.current) {
|
|
37
|
+
l();
|
|
38
|
+
const e = w(n.current, l), r = v(n.current, l);
|
|
31
39
|
return () => {
|
|
32
|
-
|
|
40
|
+
e(), r();
|
|
33
41
|
};
|
|
34
42
|
}
|
|
35
|
-
}, []), /* @__PURE__ */ x(b, { children: [
|
|
36
|
-
/* @__PURE__ */ a(
|
|
37
|
-
|
|
43
|
+
}, [t]), /* @__PURE__ */ x(b, { children: [
|
|
44
|
+
/* @__PURE__ */ a(f, { ref: n, position: "absolute", top: 0, left: 0, ...i, children: void 0 }),
|
|
45
|
+
t && E(
|
|
38
46
|
/* @__PURE__ */ a(
|
|
39
|
-
|
|
47
|
+
f,
|
|
40
48
|
{
|
|
41
49
|
position: "absolute",
|
|
42
50
|
top: 0,
|
|
43
51
|
left: 0,
|
|
44
52
|
transition: "none",
|
|
45
|
-
style: { transform: `translate(${
|
|
46
|
-
children:
|
|
53
|
+
style: { transform: `translate(${t.left}px,${t.top}px)` },
|
|
54
|
+
children: p
|
|
47
55
|
}
|
|
48
56
|
),
|
|
49
57
|
m
|
package/package.json
CHANGED
package/theme.mjs
CHANGED
|
@@ -1,27 +1,77 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
|
|
1
|
+
import { useMemo as y } from "react";
|
|
2
|
+
const r = {
|
|
3
|
+
button: {
|
|
4
|
+
styles: {
|
|
5
|
+
inline: !0,
|
|
6
|
+
p: 3,
|
|
7
|
+
cursor: "pointer",
|
|
8
|
+
b: 1,
|
|
9
|
+
borderRadius: 1
|
|
10
|
+
},
|
|
11
|
+
disabled: {
|
|
12
|
+
cursor: "default"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
checkbox: {
|
|
16
|
+
styles: {
|
|
17
|
+
inline: !0,
|
|
18
|
+
b: 1,
|
|
19
|
+
p: 2
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
radioButton: {
|
|
23
|
+
styles: {
|
|
24
|
+
inline: !0,
|
|
25
|
+
b: 1,
|
|
26
|
+
p: 2
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
textbox: {
|
|
30
|
+
styles: {
|
|
31
|
+
inline: !0,
|
|
32
|
+
b: 1,
|
|
33
|
+
borderRadius: 1,
|
|
34
|
+
p: 3
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
textarea: {
|
|
38
|
+
styles: {
|
|
39
|
+
inline: !0,
|
|
40
|
+
b: 1,
|
|
41
|
+
borderRadius: 1
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
let n = r;
|
|
3
46
|
var u;
|
|
4
|
-
((
|
|
5
|
-
function
|
|
6
|
-
|
|
47
|
+
((d) => {
|
|
48
|
+
function o(t) {
|
|
49
|
+
n = t, i();
|
|
50
|
+
}
|
|
51
|
+
d.setup = o;
|
|
52
|
+
function i() {
|
|
53
|
+
Object.keys(r).forEach((s) => {
|
|
54
|
+
console.log(s);
|
|
55
|
+
const e = n[s], l = r[s];
|
|
56
|
+
e ? (e.styles = { ...l.styles, ...e.styles }, console.log(e.styles), e.disabled && l.disabled && (e.disabled = { ...l.disabled, ...e.disabled })) : n[s] = r[s];
|
|
57
|
+
});
|
|
7
58
|
}
|
|
8
|
-
l.setup = s;
|
|
9
59
|
})(u || (u = {}));
|
|
10
|
-
const
|
|
11
|
-
function p(
|
|
12
|
-
const { clean:
|
|
13
|
-
return
|
|
14
|
-
var
|
|
15
|
-
if (
|
|
60
|
+
const m = u;
|
|
61
|
+
function p(d) {
|
|
62
|
+
const { clean: o, disabled: i, theme: t, component: s } = d;
|
|
63
|
+
return y(() => {
|
|
64
|
+
var a, b, c;
|
|
65
|
+
if (o)
|
|
16
66
|
return {};
|
|
17
|
-
let e =
|
|
67
|
+
let e = n[s] ?? ((a = n.components) == null ? void 0 : a[s]);
|
|
18
68
|
if (!e)
|
|
19
69
|
return {};
|
|
20
|
-
let
|
|
21
|
-
return
|
|
22
|
-
}, [
|
|
70
|
+
let l = t ? { ...e.styles, ...(b = e.themes) == null ? void 0 : b[t].styles } : e.styles;
|
|
71
|
+
return i ? t ? { ...l, ...e.disabled, ...(c = e.themes) == null ? void 0 : c[t].disabled } : { ...l, ...e.disabled } : l;
|
|
72
|
+
}, [s, o, i, t]);
|
|
23
73
|
}
|
|
24
74
|
export {
|
|
25
|
-
|
|
75
|
+
m as default,
|
|
26
76
|
p as useTheme
|
|
27
77
|
};
|