@cronocode/react-box 0.4.8 → 1.0.0
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.d.ts +4 -1
- package/box.js +5 -17
- package/components/buttonCore.js +4 -21
- package/components/flex.js +4 -9
- package/components/formAsync.js +16 -26
- package/components/uncontrolledCheckboxCore.d.ts +1 -1
- package/components/uncontrolledCheckboxCore.js +4 -21
- package/components/uncontrolledRadioButtonCore.d.ts +1 -1
- package/components/uncontrolledRadioButtonCore.js +4 -21
- package/components/uncontrolledTextareaCore.d.ts +1 -1
- package/components/uncontrolledTextareaCore.js +3 -8
- package/components/uncontrolledTextboxCore.d.ts +1 -1
- package/components/uncontrolledTextboxCore.js +3 -8
- package/package.json +11 -11
- package/style.css +1 -1
package/box.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ interface Props<TTag extends keyof React.ReactHTML> extends BoxStyles {
|
|
|
8
8
|
}) => React.ReactNode);
|
|
9
9
|
tag?: TTag;
|
|
10
10
|
props?: TagPropsType<TTag>;
|
|
11
|
-
|
|
11
|
+
style?: React.ComponentProps<TTag>['style'];
|
|
12
12
|
className?: ClassNameUtils.ClassNameType;
|
|
13
13
|
}
|
|
14
14
|
export default function Box<TTag extends keyof React.ReactHTML = 'div'>(props: Props<TTag>): React.DetailedReactHTMLElement<{
|
|
@@ -32,6 +32,7 @@ export default function Box<TTag extends keyof React.ReactHTML = 'div'>(props: P
|
|
|
32
32
|
hidden?: React.ComponentProps<TTag>["hidden"] | undefined;
|
|
33
33
|
id?: React.ComponentProps<TTag>["id"] | undefined;
|
|
34
34
|
lang?: React.ComponentProps<TTag>["lang"] | undefined;
|
|
35
|
+
nonce?: React.ComponentProps<TTag>["nonce"] | undefined;
|
|
35
36
|
placeholder?: React.ComponentProps<TTag>["placeholder"] | undefined;
|
|
36
37
|
spellCheck?: React.ComponentProps<TTag>["spellCheck"] | undefined;
|
|
37
38
|
tabIndex?: React.ComponentProps<TTag>["tabIndex"] | undefined;
|
|
@@ -176,6 +177,8 @@ export default function Box<TTag extends keyof React.ReactHTML = 'div'>(props: P
|
|
|
176
177
|
onProgressCapture?: React.ComponentProps<TTag>["onProgressCapture"] | undefined;
|
|
177
178
|
onRateChange?: React.ComponentProps<TTag>["onRateChange"] | undefined;
|
|
178
179
|
onRateChangeCapture?: React.ComponentProps<TTag>["onRateChangeCapture"] | undefined;
|
|
180
|
+
onResize?: React.ComponentProps<TTag>["onResize"] | undefined;
|
|
181
|
+
onResizeCapture?: React.ComponentProps<TTag>["onResizeCapture"] | undefined;
|
|
179
182
|
onSeeked?: React.ComponentProps<TTag>["onSeeked"] | undefined;
|
|
180
183
|
onSeekedCapture?: React.ComponentProps<TTag>["onSeekedCapture"] | undefined;
|
|
181
184
|
onSeeking?: React.ComponentProps<TTag>["onSeeking"] | undefined;
|
package/box.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import x, { useState as N } from "react";
|
|
2
2
|
import { c as o } from "./box.module.css.js";
|
|
3
3
|
import { C as b } from "./utils/utils.js";
|
|
4
|
-
function
|
|
5
|
-
const {
|
|
6
|
-
tag: i,
|
|
7
|
-
children: s,
|
|
8
|
-
props: f,
|
|
9
|
-
className: a,
|
|
10
|
-
styles: m
|
|
11
|
-
} = t, c = a ? b.classNames(a, o.box) : [o.box];
|
|
4
|
+
function H(t) {
|
|
5
|
+
const { tag: i, children: s, props: f, className: a, style: m } = t, c = a ? b.classNames(a, o.box) : [o.box];
|
|
12
6
|
Object.entries(t).forEach(([d, v]) => {
|
|
13
7
|
const l = o[d + v];
|
|
14
8
|
l && c.push(l);
|
|
15
9
|
});
|
|
16
|
-
const u = i || "div", e = {
|
|
17
|
-
|
|
18
|
-
style: m,
|
|
19
|
-
className: c.join(" ")
|
|
20
|
-
}, [p, n] = N(!1), r = typeof s == "function";
|
|
21
|
-
return r && (e.onMouseEnter = () => n(!0), e.onMouseLeave = () => n(!1)), x.createElement(u, e, r ? s({
|
|
22
|
-
isHover: p
|
|
23
|
-
}) : s);
|
|
10
|
+
const u = i || "div", e = { ...f, style: m, className: c.join(" ") }, [p, n] = N(!1), r = typeof s == "function";
|
|
11
|
+
return r && (e.onMouseEnter = () => n(!0), e.onMouseLeave = () => n(!1)), x.createElement(u, e, r ? s({ isHover: p }) : s);
|
|
24
12
|
}
|
|
25
13
|
export {
|
|
26
|
-
|
|
14
|
+
H as default
|
|
27
15
|
};
|
package/components/buttonCore.js
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
import s from "
|
|
2
|
-
import
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import u from "../box.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
6
|
function l(t) {
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
type: r,
|
|
10
|
-
onClick: n,
|
|
11
|
-
disabled: p,
|
|
12
|
-
props: e
|
|
13
|
-
} = t, i = {
|
|
14
|
-
...e,
|
|
15
|
-
type: r || "button",
|
|
16
|
-
onClick: n,
|
|
17
|
-
disabled: p
|
|
18
|
-
};
|
|
19
|
-
return /* @__PURE__ */ u(s, {
|
|
20
|
-
tag: o || "button",
|
|
21
|
-
cursor: "pointer",
|
|
22
|
-
inline: !0,
|
|
23
|
-
...t,
|
|
24
|
-
props: i
|
|
25
|
-
});
|
|
7
|
+
const { tag: o, type: r, onClick: n, disabled: p, props: e } = t, i = { ...e, type: r || "button", onClick: n, disabled: p };
|
|
8
|
+
return /* @__PURE__ */ s(u, { tag: o || "button", cursor: "pointer", inline: !0, ...t, props: i });
|
|
26
9
|
}
|
|
27
10
|
export {
|
|
28
11
|
l as default
|
package/components/flex.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import t from "
|
|
2
|
-
import
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import r from "../box.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
6
|
function x(i) {
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
} = i;
|
|
10
|
-
return /* @__PURE__ */ r(t, {
|
|
11
|
-
display: o ? "inline-flex" : "flex",
|
|
12
|
-
...i
|
|
13
|
-
});
|
|
7
|
+
const { inline: o } = i;
|
|
8
|
+
return /* @__PURE__ */ t(r, { display: o ? "inline-flex" : "flex", ...i });
|
|
14
9
|
}
|
|
15
10
|
export {
|
|
16
11
|
x as default
|
package/components/formAsync.js
CHANGED
|
@@ -1,42 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import s from "
|
|
3
|
-
import
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as p, useCallback as s } from "react";
|
|
3
|
+
import m from "../box.js";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
|
-
function
|
|
6
|
+
function d(u) {
|
|
7
7
|
const n = Array.from(u.elements).reduce((r, o) => {
|
|
8
|
-
const
|
|
9
|
-
return r[
|
|
8
|
+
const c = o.name;
|
|
9
|
+
return c && (r[c] || (r[c] = []), r[c].push(o)), r;
|
|
10
10
|
}, {});
|
|
11
|
-
return Object.entries(n).reduce((r, [o,
|
|
12
|
-
if (
|
|
13
|
-
const e =
|
|
11
|
+
return Object.entries(n).reduce((r, [o, c]) => {
|
|
12
|
+
if (c.length === 1) {
|
|
13
|
+
const e = c[0];
|
|
14
14
|
r[o] = e.type === "checkbox" || e.type === "radio" ? e.checked : e.value;
|
|
15
15
|
} else
|
|
16
|
-
r[o] = [],
|
|
17
|
-
var
|
|
18
|
-
e.type === "checkbox" ? e.checked && r[o].push(e.value) : e.type === "radio" ? r[o] = (
|
|
16
|
+
r[o] = [], c.forEach((e) => {
|
|
17
|
+
var t;
|
|
18
|
+
e.type === "checkbox" ? e.checked && r[o].push(e.value) : e.type === "radio" ? r[o] = (t = c.find((f) => f.checked)) == null ? void 0 : t.value : r[o].push(e.value);
|
|
19
19
|
});
|
|
20
20
|
return r;
|
|
21
21
|
}, {});
|
|
22
22
|
}
|
|
23
23
|
function v(u) {
|
|
24
|
-
const {
|
|
25
|
-
children: n,
|
|
26
|
-
onSubmit: r
|
|
27
|
-
} = u, o = i(null), t = p((e) => {
|
|
24
|
+
const { children: n, onSubmit: r } = u, o = p(null), c = s((e) => {
|
|
28
25
|
e.preventDefault();
|
|
29
|
-
const
|
|
30
|
-
r(
|
|
26
|
+
const t = d(o.current);
|
|
27
|
+
r(t, e);
|
|
31
28
|
}, []);
|
|
32
|
-
return /* @__PURE__ */ m
|
|
33
|
-
tag: "form",
|
|
34
|
-
props: {
|
|
35
|
-
ref: o,
|
|
36
|
-
onSubmit: t
|
|
37
|
-
},
|
|
38
|
-
children: n
|
|
39
|
-
});
|
|
29
|
+
return /* @__PURE__ */ i(m, { tag: "form", props: { ref: o, onSubmit: c }, children: n });
|
|
40
30
|
}
|
|
41
31
|
export {
|
|
42
32
|
v as default
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Box from '../box';
|
|
2
|
-
declare type BoxProps = React.ComponentProps<typeof Box
|
|
2
|
+
declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
|
|
3
3
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
4
|
declare type UncontrolledCheckboxCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'value' | 'autoFocus' | 'readOnly' | 'required' | 'defaultChecked'>;
|
|
5
5
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import m from "
|
|
2
|
-
import
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import f from "../box.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
6
|
function k(o) {
|
|
7
|
-
const {
|
|
8
|
-
props: e,
|
|
9
|
-
name: r,
|
|
10
|
-
disabled: t,
|
|
11
|
-
placeholder: n,
|
|
12
|
-
value: p,
|
|
13
|
-
onInput: a,
|
|
14
|
-
onChange: i,
|
|
15
|
-
autoFocus: u,
|
|
16
|
-
readOnly: c,
|
|
17
|
-
required: l,
|
|
18
|
-
defaultChecked: d
|
|
19
|
-
} = o, s = {
|
|
7
|
+
const { props: e, name: r, disabled: t, placeholder: n, value: p, onInput: a, onChange: i, autoFocus: u, readOnly: c, required: l, defaultChecked: d } = o, s = {
|
|
20
8
|
...e,
|
|
21
9
|
type: "checkbox",
|
|
22
10
|
name: r,
|
|
@@ -30,12 +18,7 @@ function k(o) {
|
|
|
30
18
|
required: l,
|
|
31
19
|
defaultChecked: d
|
|
32
20
|
};
|
|
33
|
-
return /* @__PURE__ */ f
|
|
34
|
-
tag: "input",
|
|
35
|
-
inline: !0,
|
|
36
|
-
...o,
|
|
37
|
-
props: s
|
|
38
|
-
});
|
|
21
|
+
return /* @__PURE__ */ m(f, { tag: "input", inline: !0, ...o, props: s });
|
|
39
22
|
}
|
|
40
23
|
export {
|
|
41
24
|
k as default
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Box from '../box';
|
|
2
|
-
declare type BoxProps = React.ComponentProps<typeof Box
|
|
2
|
+
declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
|
|
3
3
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
4
|
declare type UncontrolledRadioButtonCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'value' | 'autoFocus' | 'readOnly' | 'required' | 'defaultChecked'>;
|
|
5
5
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import c from "
|
|
2
|
-
import
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import f from "../box.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
6
|
function B(o) {
|
|
7
|
-
const {
|
|
8
|
-
props: t,
|
|
9
|
-
name: e,
|
|
10
|
-
disabled: r,
|
|
11
|
-
placeholder: n,
|
|
12
|
-
value: a,
|
|
13
|
-
onInput: p,
|
|
14
|
-
onChange: i,
|
|
15
|
-
autoFocus: u,
|
|
16
|
-
readOnly: d,
|
|
17
|
-
required: l,
|
|
18
|
-
defaultChecked: s
|
|
19
|
-
} = o, m = {
|
|
7
|
+
const { props: t, name: e, disabled: r, placeholder: n, value: a, onInput: p, onChange: i, autoFocus: u, readOnly: d, required: l, defaultChecked: s } = o, m = {
|
|
20
8
|
...t,
|
|
21
9
|
type: "radio",
|
|
22
10
|
name: e,
|
|
@@ -30,12 +18,7 @@ function B(o) {
|
|
|
30
18
|
required: l,
|
|
31
19
|
defaultChecked: s
|
|
32
20
|
};
|
|
33
|
-
return /* @__PURE__ */ f
|
|
34
|
-
tag: "input",
|
|
35
|
-
inline: !0,
|
|
36
|
-
...o,
|
|
37
|
-
props: m
|
|
38
|
-
});
|
|
21
|
+
return /* @__PURE__ */ c(f, { tag: "input", inline: !0, ...o, props: m });
|
|
39
22
|
}
|
|
40
23
|
export {
|
|
41
24
|
B as default
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Box from '../box';
|
|
2
|
-
declare type BoxProps = React.ComponentProps<typeof Box
|
|
2
|
+
declare type BoxProps = React.ComponentProps<typeof Box<'textarea'>>;
|
|
3
3
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
4
|
declare type UncontrolledTextareaCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'placeholder' | 'disabled' | 'defaultValue' | 'rows' | 'cols' | 'autoFocus' | 'maxLength' | 'minLength' | 'readOnly' | 'required'>;
|
|
5
5
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import f from "
|
|
2
|
-
import
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import h from "../box.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
@@ -35,12 +35,7 @@ function b(o) {
|
|
|
35
35
|
readOnly: c,
|
|
36
36
|
required: g
|
|
37
37
|
};
|
|
38
|
-
return /* @__PURE__ */ h
|
|
39
|
-
tag: "textarea",
|
|
40
|
-
inline: !0,
|
|
41
|
-
...o,
|
|
42
|
-
props: x
|
|
43
|
-
});
|
|
38
|
+
return /* @__PURE__ */ f(h, { tag: "textarea", inline: !0, ...o, props: x });
|
|
44
39
|
}
|
|
45
40
|
export {
|
|
46
41
|
b as default
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Box from '../box';
|
|
2
|
-
declare type BoxProps = React.ComponentProps<typeof Box
|
|
2
|
+
declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
|
|
3
3
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
4
|
declare type UncontrolledTextboxCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'defaultValue' | 'autoFocus' | 'readOnly' | 'required'>;
|
|
5
5
|
declare type UncontrolledTextboxCoreType = 'date' | 'datetime-local' | 'email' | 'hidden' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import x from "
|
|
2
|
-
import
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import f from "../box.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
@@ -31,12 +31,7 @@ function P(t) {
|
|
|
31
31
|
required: d,
|
|
32
32
|
step: m
|
|
33
33
|
};
|
|
34
|
-
return /* @__PURE__ */ f
|
|
35
|
-
tag: "input",
|
|
36
|
-
inline: !0,
|
|
37
|
-
...t,
|
|
38
|
-
props: c
|
|
39
|
-
});
|
|
34
|
+
return /* @__PURE__ */ x(f, { tag: "input", inline: !0, ...t, props: c });
|
|
40
35
|
}
|
|
41
36
|
export {
|
|
42
37
|
P as default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cronocode/react-box",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"main": "./box.js",
|
|
5
5
|
"module": "./box.js",
|
|
6
6
|
"types": "./box.d.ts",
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@cronocode/identity-factory": "^0.0.6",
|
|
45
45
|
"@rollup/pluginutils": "^5.0.2",
|
|
46
|
-
"@types/node": "^18.
|
|
46
|
+
"@types/node": "^18.11.18",
|
|
47
47
|
"@types/postcss-mixins": "^9.0.0",
|
|
48
|
-
"@types/react": "^18.0.
|
|
49
|
-
"@types/react-dom": "^18.0.
|
|
50
|
-
"@vitejs/plugin-react": "^
|
|
51
|
-
"autoprefixer": "^10.4.
|
|
52
|
-
"postcss": "^8.4.
|
|
48
|
+
"@types/react": "^18.0.27",
|
|
49
|
+
"@types/react-dom": "^18.0.10",
|
|
50
|
+
"@vitejs/plugin-react": "^3.0.1",
|
|
51
|
+
"autoprefixer": "^10.4.13",
|
|
52
|
+
"postcss": "^8.4.21",
|
|
53
53
|
"postcss-mixins": "^9.0.4",
|
|
54
|
-
"prettier": "^2.
|
|
54
|
+
"prettier": "^2.8.3",
|
|
55
55
|
"react": "^18.1.0",
|
|
56
56
|
"react-dom": "^18.2.0",
|
|
57
|
-
"typescript": "^4.
|
|
58
|
-
"vite": "^
|
|
59
|
-
"vite-plugin-dts": "^1.
|
|
57
|
+
"typescript": "^4.9.4",
|
|
58
|
+
"vite": "^4.0.4",
|
|
59
|
+
"vite-plugin-dts": "^1.7.1"
|
|
60
60
|
}
|
|
61
61
|
}
|