@cronocode/react-box 0.4.9 → 1.0.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.d.ts +4 -1
- package/box.js +5 -17
- package/box.module.css.js +1 -1
- package/components/buttonCore.d.ts +1 -1
- package/components/buttonCore.js +4 -21
- package/components/flex.js +4 -9
- package/components/formAsync.d.ts +6 -2
- package/components/formAsync.js +12 -39
- 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/types.d.ts +36 -36
- package/utils/form/formUtils.d.ts +5 -0
- package/utils/utils.js +33 -10
|
@@ -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<'button'>>;
|
|
3
3
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
4
|
declare type ButtonTagProps = Omit<BoxTagProps, 'type' | 'onClick' | 'disabled'>;
|
|
5
5
|
declare type ButtonType = Required<React.ComponentProps<'button'>>['type'];
|
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
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import Box from '../box';
|
|
2
|
+
declare type BoxProps = React.ComponentProps<typeof Box<'form'>>;
|
|
3
|
+
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
|
+
declare type FormAsyncTagProps = Omit<BoxTagProps, 'onSubmit' | 'ref'>;
|
|
5
|
+
interface Props<T> extends Omit<BoxProps, 'props' | 'tag'> {
|
|
6
|
+
props?: FormAsyncTagProps;
|
|
3
7
|
onSubmit: (obj: T, e: React.FormEvent<HTMLFormElement>) => void;
|
|
4
8
|
}
|
|
5
9
|
export default function FormAsync<T>(props: Props<T>): JSX.Element;
|
package/components/formAsync.js
CHANGED
|
@@ -1,43 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as p, useCallback as u } from "react";
|
|
3
|
+
import a from "../box.js";
|
|
4
|
+
import { F as c } from "../utils/utils.js";
|
|
4
5
|
import "../box.module.css.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
}, {}
|
|
11
|
-
return
|
|
12
|
-
if (c.length === 1) {
|
|
13
|
-
const e = c[0];
|
|
14
|
-
r[o] = e.type === "checkbox" || e.type === "radio" ? e.checked : e.value;
|
|
15
|
-
} else
|
|
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
|
-
});
|
|
20
|
-
return r;
|
|
21
|
-
}, {});
|
|
22
|
-
}
|
|
23
|
-
function v(u) {
|
|
24
|
-
const {
|
|
25
|
-
children: n,
|
|
26
|
-
onSubmit: r
|
|
27
|
-
} = u, o = i(null), c = p((e) => {
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
const t = d(o.current);
|
|
30
|
-
r(t, e);
|
|
31
|
-
}, []);
|
|
32
|
-
return /* @__PURE__ */ m(s, {
|
|
33
|
-
tag: "form",
|
|
34
|
-
props: {
|
|
35
|
-
ref: o,
|
|
36
|
-
onSubmit: c
|
|
37
|
-
},
|
|
38
|
-
children: n
|
|
39
|
-
});
|
|
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 });
|
|
40
13
|
}
|
|
41
14
|
export {
|
|
42
|
-
|
|
15
|
+
S as default
|
|
43
16
|
};
|
|
@@ -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.1",
|
|
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
|
}
|