@cronocode/react-box 1.2.3 → 1.2.5
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/buildHelpers/mixins/boxStyles.d.ts +4 -0
- package/buildHelpers/mixins/svgStyles.d.ts +4 -0
- package/buildHelpers/plugins/moduleCssPlugin.d.ts +2 -0
- package/components/baseSvg.mjs +2 -22
- package/components/buttonCore.mjs +8 -11
- package/components/checkboxCore.mjs +7 -10
- package/components/flex.mjs +2 -9
- package/components/formAsync.mjs +4 -15
- package/components/radioButtonCore.mjs +6 -9
- package/components/textareaCore.mjs +7 -10
- package/components/textbox.mjs +25 -0
- package/components/textboxCore.mjs +7 -10
- package/dev/main.d.ts +0 -0
- package/package.json +18 -13
- package/{components → src/components}/buttonCore.d.ts +1 -0
- package/{components → src/components}/flex.d.ts +2 -1
- package/{components → src/components}/formAsync.d.ts +2 -1
- package/src/components/textbox.d.ts +26 -0
- package/src/index.d.ts +0 -0
- package/src/theme.d.ts +25 -0
- package/src/utils/object/objectUtils.d.ts +445 -0
- package/style.css +1 -1
- package/theme.mjs +27 -0
- package/utils/utils.mjs +51 -56
- package/utils/object/objectUtils.d.ts +0 -4
- /package/{box.d.ts → src/box.d.ts} +0 -0
- /package/{components → src/components}/baseSvg.d.ts +0 -0
- /package/{components → src/components}/checkboxCore.d.ts +0 -0
- /package/{components → src/components}/radioButtonCore.d.ts +0 -0
- /package/{components → src/components}/textareaCore.d.ts +0 -0
- /package/{components → src/components}/textboxCore.d.ts +0 -0
- /package/{types.d.ts → src/types.d.ts} +0 -0
- /package/{utils → src/utils}/className/classNameUtils.d.ts +0 -0
- /package/{utils → src/utils}/form/formUtils.d.ts +0 -0
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, t 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, 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}`);
|
|
9
9
|
});
|
|
10
|
-
const s = { ...h, className:
|
|
10
|
+
const s = { ...h, className: t.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.mjs
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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", rotateF0: "cGU", focustrue: "_f", rotateF90: "cGV", rotateF180: "cGW", rotateF270: "cGX", flipFxAxis: "cGY", flipFyAxis: "cGZ" };
|
|
4
|
-
function F(c) {
|
|
5
|
-
const { children: e, props: p, className: r, style: x, viewBox: m, width: u, height: h } = c, t = r ? w.classNames(r, a.base) : [a.base];
|
|
6
|
-
Object.entries(c).forEach(([o, n]) => {
|
|
7
|
-
const f = a[o + n];
|
|
8
|
-
f ? t.push(f) : o in G && t.push(`${G[o]}${n}`);
|
|
9
|
-
});
|
|
10
|
-
const s = {
|
|
11
|
-
...p,
|
|
12
|
-
style: { ...x, width: u, height: h },
|
|
13
|
-
className: t.join(" "),
|
|
14
|
-
viewBox: m || "0 0 24 24",
|
|
15
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
16
|
-
fill: "none"
|
|
17
|
-
}, [v, i] = g(!1), l = typeof e == "function";
|
|
18
|
-
return l && (s.onMouseEnter = () => i(!0), s.onMouseLeave = () => i(!1)), H.createElement("svg", s, l ? e({ isHover: v }) : e);
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
F as default
|
|
22
|
-
};
|
|
1
|
+
import "react";
|
|
2
|
+
import "../utils/utils.mjs";
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { O as
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as e } from "react";
|
|
3
|
+
import n from "../box.mjs";
|
|
4
|
+
import { O as m } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
|
-
function
|
|
7
|
-
const [t,
|
|
8
|
-
return /* @__PURE__ */ n
|
|
6
|
+
function s(o, r) {
|
|
7
|
+
const [t, i] = m.moveToTagProps(o, "type", "onClick", "disabled");
|
|
8
|
+
return /* @__PURE__ */ p(n, { ref: r, tag: "button", cursor: "pointer", inline: !0, ...i, props: { ...o.props, ...t } });
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
b as default
|
|
13
|
-
};
|
|
10
|
+
e(s);
|
|
@@ -1,10 +1,10 @@
|
|
|
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 a from "../box.mjs";
|
|
4
|
+
import { O as i } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
|
-
function
|
|
7
|
-
const [r, t] =
|
|
6
|
+
function m(o, e) {
|
|
7
|
+
const [r, t] = i.moveToTagProps(
|
|
8
8
|
o,
|
|
9
9
|
"name",
|
|
10
10
|
"onInput",
|
|
@@ -17,9 +17,6 @@ function i(o, e) {
|
|
|
17
17
|
"checked",
|
|
18
18
|
"defaultChecked"
|
|
19
19
|
);
|
|
20
|
-
return /* @__PURE__ */ n(
|
|
20
|
+
return /* @__PURE__ */ n(a, { ref: e, tag: "input", inline: !0, ...t, props: { ...o.props, ...r, type: "checkbox" } });
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
l as default
|
|
25
|
-
};
|
|
22
|
+
p(m);
|
package/components/flex.mjs
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "../box.mjs";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../box.module.css.mjs";
|
|
5
5
|
import "../utils/utils.mjs";
|
|
6
|
-
function x(i) {
|
|
7
|
-
const { inline: o } = i;
|
|
8
|
-
return /* @__PURE__ */ t(r, { display: o ? "inline-flex" : "flex", ...i });
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
x as default
|
|
12
|
-
};
|
package/components/formAsync.mjs
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "../box.mjs";
|
|
4
|
+
import "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
|
-
function S(o) {
|
|
7
|
-
const { onSubmit: m, props: n } = o, r = p(null), s = u((t) => {
|
|
8
|
-
t.preventDefault();
|
|
9
|
-
const f = c.getFormEntries(r.current);
|
|
10
|
-
m(f, t);
|
|
11
|
-
}, []), e = { ...n, onSubmit: s, ref: r };
|
|
12
|
-
return /* @__PURE__ */ i(a, { tag: "form", ...o, props: e });
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
S as default
|
|
16
|
-
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as a } from "react";
|
|
3
3
|
import i from "../box.mjs";
|
|
4
4
|
import { O as p } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
|
-
function
|
|
7
|
-
const [
|
|
6
|
+
function m(o, r) {
|
|
7
|
+
const [e, t] = p.moveToTagProps(
|
|
8
8
|
o,
|
|
9
9
|
"name",
|
|
10
10
|
"onInput",
|
|
@@ -17,9 +17,6 @@ function u(o, r) {
|
|
|
17
17
|
"checked",
|
|
18
18
|
"defaultChecked"
|
|
19
19
|
);
|
|
20
|
-
return /* @__PURE__ */
|
|
20
|
+
return /* @__PURE__ */ n(i, { ref: r, tag: "input", inline: !0, ...t, props: { ...o.props, ...e, type: "radio" } });
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
l as default
|
|
25
|
-
};
|
|
22
|
+
a(m);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as n } from "react";
|
|
3
|
-
import
|
|
4
|
-
import { O as
|
|
3
|
+
import m from "../box.mjs";
|
|
4
|
+
import { O as i } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
|
-
function p(
|
|
7
|
-
const [
|
|
8
|
-
|
|
6
|
+
function p(o, r) {
|
|
7
|
+
const [e, t] = i.moveToTagProps(
|
|
8
|
+
o,
|
|
9
9
|
"name",
|
|
10
10
|
"onInput",
|
|
11
11
|
"onChange",
|
|
@@ -21,9 +21,6 @@ function p(e, o) {
|
|
|
21
21
|
"readOnly",
|
|
22
22
|
"required"
|
|
23
23
|
);
|
|
24
|
-
return /* @__PURE__ */ a(
|
|
24
|
+
return /* @__PURE__ */ a(m, { ref: r, tag: "textarea", inline: !0, ...t, props: { ...o.props, ...e } });
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
c as default
|
|
29
|
-
};
|
|
26
|
+
n(p);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as a } from "react";
|
|
3
|
+
import m from "../box.mjs";
|
|
4
|
+
import { O as i } from "../utils/utils.mjs";
|
|
5
|
+
import { T as s } from "../theme.mjs";
|
|
6
|
+
import "../box.module.css.mjs";
|
|
7
|
+
const u = [
|
|
8
|
+
"name",
|
|
9
|
+
"onInput",
|
|
10
|
+
"onChange",
|
|
11
|
+
"type",
|
|
12
|
+
"placeholder",
|
|
13
|
+
"disabled",
|
|
14
|
+
"defaultValue",
|
|
15
|
+
"autoFocus",
|
|
16
|
+
"readOnly",
|
|
17
|
+
"required",
|
|
18
|
+
"value",
|
|
19
|
+
"pattern"
|
|
20
|
+
];
|
|
21
|
+
function p(e, t) {
|
|
22
|
+
const o = s.useTheme("textbox", e), r = i.buildProps(e, u, o);
|
|
23
|
+
return /* @__PURE__ */ n(m, { ref: t, tag: "input", inline: !0, ...r });
|
|
24
|
+
}
|
|
25
|
+
a(p);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as a } from "react";
|
|
3
3
|
import n from "../box.mjs";
|
|
4
|
-
import { O as
|
|
4
|
+
import { O as i } from "../utils/utils.mjs";
|
|
5
5
|
import "../box.module.css.mjs";
|
|
6
|
-
function
|
|
7
|
-
const [
|
|
6
|
+
function m(o, r) {
|
|
7
|
+
const [e, t] = i.moveToTagProps(
|
|
8
8
|
o,
|
|
9
9
|
"name",
|
|
10
10
|
"onInput",
|
|
@@ -20,9 +20,6 @@ function i(o, e) {
|
|
|
20
20
|
"required",
|
|
21
21
|
"step"
|
|
22
22
|
);
|
|
23
|
-
return /* @__PURE__ */
|
|
23
|
+
return /* @__PURE__ */ p(n, { ref: r, tag: "input", inline: !0, ...t, props: { ...o.props, ...e } });
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
x as default
|
|
28
|
-
};
|
|
25
|
+
a(m);
|
package/dev/main.d.ts
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cronocode/react-box",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"main": "./box.mjs",
|
|
5
5
|
"module": "./box.mjs",
|
|
6
6
|
"types": "./box.d.ts",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"types": "./box.d.ts"
|
|
12
12
|
},
|
|
13
13
|
"./style.css": "./style.css",
|
|
14
|
+
"./theme": {
|
|
15
|
+
"import": "./theme.mjs",
|
|
16
|
+
"require": "./theme.mjs",
|
|
17
|
+
"types": "./theme.d.ts"
|
|
18
|
+
},
|
|
14
19
|
"./components/*": {
|
|
15
20
|
"import": "./components/*.mjs",
|
|
16
21
|
"require": "./components/*.mjs",
|
|
@@ -42,23 +47,23 @@
|
|
|
42
47
|
"description": "",
|
|
43
48
|
"devDependencies": {
|
|
44
49
|
"@cronocode/identity-factory": "^0.0.6",
|
|
45
|
-
"@rollup/pluginutils": "^5.0.
|
|
46
|
-
"@types/node": "^
|
|
50
|
+
"@rollup/pluginutils": "^5.0.4",
|
|
51
|
+
"@types/node": "^20.6.0",
|
|
47
52
|
"@types/postcss-mixins": "^9.0.0",
|
|
48
|
-
"@types/react": "^18.
|
|
49
|
-
"@types/react-dom": "^18.
|
|
50
|
-
"@vitejs/plugin-react": "^
|
|
51
|
-
"autoprefixer": "^10.4.
|
|
52
|
-
"postcss": "^8.4.
|
|
53
|
+
"@types/react": "^18.2.21",
|
|
54
|
+
"@types/react-dom": "^18.2.7",
|
|
55
|
+
"@vitejs/plugin-react": "^4.0.4",
|
|
56
|
+
"autoprefixer": "^10.4.15",
|
|
57
|
+
"postcss": "^8.4.29",
|
|
53
58
|
"postcss-each": "^1.1.0",
|
|
54
59
|
"postcss-mixins": "^9.0.4",
|
|
55
60
|
"postcss-nested": "^6.0.1",
|
|
56
61
|
"postcss-simple-vars": "^7.0.1",
|
|
57
|
-
"prettier": "^
|
|
58
|
-
"react": "^18.
|
|
62
|
+
"prettier": "^3.0.3",
|
|
63
|
+
"react": "^18.2.0",
|
|
59
64
|
"react-dom": "^18.2.0",
|
|
60
|
-
"typescript": "^5.
|
|
61
|
-
"vite": "^4.
|
|
62
|
-
"vite-plugin-dts": "^
|
|
65
|
+
"typescript": "^5.2.2",
|
|
66
|
+
"vite": "^4.4.9",
|
|
67
|
+
"vite-plugin-dts": "^3.5.3"
|
|
63
68
|
}
|
|
64
69
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import Box from '../box';
|
|
2
3
|
import { Activated, Focused, Hovered } from '../types';
|
|
3
4
|
type BoxProps = React.ComponentProps<typeof Box>;
|
|
@@ -13,5 +14,5 @@ interface FlexStylesShortCuts {
|
|
|
13
14
|
js?: BoxProps['justifySelf'];
|
|
14
15
|
}
|
|
15
16
|
type Props = BoxProps & FlexStylesShortCuts & Hovered<FlexStylesShortCuts> & Focused<FlexStylesShortCuts> & Activated<FlexStylesShortCuts>;
|
|
16
|
-
export default function Flex(props: Props): JSX.Element;
|
|
17
|
+
export default function Flex(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import Box from '../box';
|
|
2
3
|
type BoxProps = React.ComponentProps<typeof Box<'form'>>;
|
|
3
4
|
type BoxTagProps = Required<BoxProps>['props'];
|
|
@@ -6,5 +7,5 @@ interface Props<T> extends Omit<BoxProps, 'props' | 'tag'> {
|
|
|
6
7
|
props?: FormAsyncTagProps;
|
|
7
8
|
onSubmit: (obj: T, e: React.FormEvent<HTMLFormElement>) => void;
|
|
8
9
|
}
|
|
9
|
-
export default function FormAsync<T>(props: Props<T>): JSX.Element;
|
|
10
|
+
export default function FormAsync<T>(props: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Box from '../box';
|
|
3
|
+
import Theme from '../theme';
|
|
4
|
+
type BoxProps = Omit<React.ComponentProps<typeof Box<'input'>>, 'ref' | 'tag'>;
|
|
5
|
+
type BoxTagProps = Required<BoxProps>['props'];
|
|
6
|
+
declare const tagProps: readonly ["name", "onInput", "onChange", "type", "placeholder", "disabled", "defaultValue", "autoFocus", "readOnly", "required", "value", "pattern"];
|
|
7
|
+
type TagPropsType = (typeof tagProps)[number];
|
|
8
|
+
type TextboxTagProps = Omit<BoxTagProps, TagPropsType>;
|
|
9
|
+
type TextboxType = 'date' | 'datetime-local' | 'email' | 'hidden' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
|
|
10
|
+
interface Props extends Omit<BoxProps, 'props'>, Theme.ThemeComponentProps {
|
|
11
|
+
name?: string;
|
|
12
|
+
props?: TextboxTagProps;
|
|
13
|
+
onInput?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
14
|
+
onChange?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
15
|
+
type?: TextboxType;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
value?: string | number;
|
|
18
|
+
defaultValue?: string | number;
|
|
19
|
+
pattern?: string;
|
|
20
|
+
autoFocus?: boolean;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
step?: number | string;
|
|
24
|
+
}
|
|
25
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
26
|
+
export default _default;
|
package/src/index.d.ts
ADDED
|
File without changes
|
package/src/theme.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BoxStyles } from './types';
|
|
2
|
+
declare namespace Theme {
|
|
3
|
+
export interface ThemeComponentProps {
|
|
4
|
+
clean?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
theme?: string;
|
|
7
|
+
}
|
|
8
|
+
interface Styles {
|
|
9
|
+
styles: BoxStyles;
|
|
10
|
+
disabled?: BoxStyles;
|
|
11
|
+
}
|
|
12
|
+
export interface ThemeStyles extends Styles {
|
|
13
|
+
themes?: {
|
|
14
|
+
[name: string]: Styles;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface ThemeComponentStyles {
|
|
18
|
+
textbox?: ThemeStyles;
|
|
19
|
+
}
|
|
20
|
+
export let Styles: ThemeComponentStyles;
|
|
21
|
+
export function setup(styles: ThemeComponentStyles): void;
|
|
22
|
+
export function useTheme(component: keyof ThemeComponentStyles, props: ThemeComponentProps): BoxStyles;
|
|
23
|
+
export {};
|
|
24
|
+
}
|
|
25
|
+
export default Theme;
|