@cronocode/react-box 1.0.0 → 1.0.2
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.module.css.js +1 -1
- package/components/buttonCore.d.ts +1 -1
- package/components/formAsync.d.ts +6 -2
- package/components/formAsync.js +11 -28
- package/components/uncontrolledCheckboxCore.d.ts +3 -2
- package/components/uncontrolledCheckboxCore.js +18 -16
- package/components/uncontrolledRadioButtonCore.d.ts +3 -2
- package/components/uncontrolledRadioButtonCore.js +17 -15
- package/components/uncontrolledTextareaCore.d.ts +5 -4
- package/components/uncontrolledTextareaCore.js +35 -33
- package/components/uncontrolledTextboxCore.d.ts +3 -2
- package/components/uncontrolledTextboxCore.js +32 -30
- package/package.json +1 -1
- 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'];
|
|
@@ -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,33 +1,16 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as p, useCallback as
|
|
3
|
-
import
|
|
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 { children: n, onSubmit: r } = u, o = p(null), c = s((e) => {
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
const t = d(o.current);
|
|
27
|
-
r(t, e);
|
|
28
|
-
}, []);
|
|
29
|
-
return /* @__PURE__ */ i(m, { tag: "form", props: { ref: o, onSubmit: c }, children: n });
|
|
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 });
|
|
30
13
|
}
|
|
31
14
|
export {
|
|
32
|
-
|
|
15
|
+
S as default
|
|
33
16
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import Box from '../box';
|
|
2
3
|
declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
|
|
3
4
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
@@ -15,5 +16,5 @@ interface Props extends Omit<BoxProps, 'props'> {
|
|
|
15
16
|
required?: boolean;
|
|
16
17
|
defaultChecked?: boolean;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
export
|
|
19
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
20
|
+
export default _default;
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import "
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as h } from "react";
|
|
3
|
+
import x from "../box.js";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
|
-
function
|
|
7
|
-
const { props:
|
|
8
|
-
...
|
|
6
|
+
function C(o, e) {
|
|
7
|
+
const { props: r, name: t, disabled: n, placeholder: a, value: p, onInput: c, onChange: l, autoFocus: u, readOnly: d, required: i, defaultChecked: s } = o, m = {
|
|
8
|
+
...r,
|
|
9
9
|
type: "checkbox",
|
|
10
|
-
name:
|
|
11
|
-
disabled:
|
|
12
|
-
placeholder:
|
|
13
|
-
onInput:
|
|
14
|
-
onChange:
|
|
10
|
+
name: t,
|
|
11
|
+
disabled: n,
|
|
12
|
+
placeholder: a,
|
|
13
|
+
onInput: c,
|
|
14
|
+
onChange: l,
|
|
15
15
|
value: p,
|
|
16
16
|
autoFocus: u,
|
|
17
|
-
readOnly:
|
|
18
|
-
required:
|
|
19
|
-
defaultChecked:
|
|
17
|
+
readOnly: d,
|
|
18
|
+
required: i,
|
|
19
|
+
defaultChecked: s,
|
|
20
|
+
ref: e
|
|
20
21
|
};
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
+
return /* @__PURE__ */ f(x, { tag: "input", inline: !0, ...o, props: m });
|
|
22
23
|
}
|
|
24
|
+
const P = h(C);
|
|
23
25
|
export {
|
|
24
|
-
|
|
26
|
+
P as default
|
|
25
27
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import Box from '../box';
|
|
2
3
|
declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
|
|
3
4
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
@@ -15,5 +16,5 @@ interface Props extends Omit<BoxProps, 'props'> {
|
|
|
15
16
|
required?: boolean;
|
|
16
17
|
defaultChecked?: boolean;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
export
|
|
19
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
20
|
+
export default _default;
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import "
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as g } from "react";
|
|
3
|
+
import C from "../box.js";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
|
-
function
|
|
7
|
-
const { props: t, name: e, disabled:
|
|
6
|
+
function h(o, r) {
|
|
7
|
+
const { props: t, name: e, disabled: n, placeholder: a, value: d, onInput: i, onChange: p, autoFocus: u, readOnly: l, required: s, defaultChecked: c } = o, m = {
|
|
8
8
|
...t,
|
|
9
9
|
type: "radio",
|
|
10
10
|
name: e,
|
|
11
|
-
disabled:
|
|
12
|
-
placeholder:
|
|
13
|
-
onInput:
|
|
14
|
-
onChange:
|
|
15
|
-
value:
|
|
11
|
+
disabled: n,
|
|
12
|
+
placeholder: a,
|
|
13
|
+
onInput: i,
|
|
14
|
+
onChange: p,
|
|
15
|
+
value: d,
|
|
16
16
|
autoFocus: u,
|
|
17
|
-
readOnly:
|
|
18
|
-
required:
|
|
19
|
-
defaultChecked:
|
|
17
|
+
readOnly: l,
|
|
18
|
+
required: s,
|
|
19
|
+
defaultChecked: c,
|
|
20
|
+
ref: r
|
|
20
21
|
};
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
+
return /* @__PURE__ */ f(C, { tag: "input", inline: !0, ...o, props: m });
|
|
22
23
|
}
|
|
24
|
+
const P = g(h);
|
|
23
25
|
export {
|
|
24
|
-
|
|
26
|
+
P as default
|
|
25
27
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import Box from '../box';
|
|
2
3
|
declare type BoxProps = React.ComponentProps<typeof Box<'textarea'>>;
|
|
3
4
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
@@ -5,8 +6,8 @@ declare type UncontrolledTextareaCoreTagProps = Omit<BoxTagProps, 'name' | 'onIn
|
|
|
5
6
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
6
7
|
name: string;
|
|
7
8
|
props?: UncontrolledTextareaCoreTagProps;
|
|
8
|
-
onInput?: (e: React.FormEvent<
|
|
9
|
-
onChange?: (e: React.FormEvent<
|
|
9
|
+
onInput?: (e: React.FormEvent<HTMLTextAreaElement>) => void;
|
|
10
|
+
onChange?: (e: React.FormEvent<HTMLTextAreaElement>) => void;
|
|
10
11
|
placeholder?: string;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
defaultValue?: string | number;
|
|
@@ -18,5 +19,5 @@ interface Props extends Omit<BoxProps, 'props'> {
|
|
|
18
19
|
readOnly?: boolean;
|
|
19
20
|
required?: boolean;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
export
|
|
22
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLTextAreaElement>>;
|
|
23
|
+
export default _default;
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import "
|
|
1
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as w } from "react";
|
|
3
|
+
import C from "../box.js";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
|
-
function
|
|
6
|
+
function T(o, e) {
|
|
7
7
|
const {
|
|
8
|
-
props:
|
|
9
|
-
name:
|
|
10
|
-
disabled:
|
|
11
|
-
placeholder:
|
|
12
|
-
defaultValue:
|
|
8
|
+
props: r,
|
|
9
|
+
name: t,
|
|
10
|
+
disabled: n,
|
|
11
|
+
placeholder: a,
|
|
12
|
+
defaultValue: l,
|
|
13
13
|
onInput: p,
|
|
14
|
-
onChange:
|
|
15
|
-
rows:
|
|
16
|
-
cols:
|
|
17
|
-
autoFocus:
|
|
18
|
-
maxLength:
|
|
19
|
-
minLength:
|
|
20
|
-
readOnly:
|
|
21
|
-
required:
|
|
22
|
-
} = o,
|
|
23
|
-
...
|
|
24
|
-
name:
|
|
25
|
-
disabled:
|
|
26
|
-
placeholder:
|
|
14
|
+
onChange: s,
|
|
15
|
+
rows: i,
|
|
16
|
+
cols: m,
|
|
17
|
+
autoFocus: u,
|
|
18
|
+
maxLength: d,
|
|
19
|
+
minLength: c,
|
|
20
|
+
readOnly: f,
|
|
21
|
+
required: x
|
|
22
|
+
} = o, g = {
|
|
23
|
+
...r,
|
|
24
|
+
name: t,
|
|
25
|
+
disabled: n,
|
|
26
|
+
placeholder: a,
|
|
27
27
|
onInput: p,
|
|
28
|
-
onChange:
|
|
29
|
-
defaultValue:
|
|
30
|
-
rows:
|
|
31
|
-
cols:
|
|
32
|
-
autoFocus:
|
|
33
|
-
maxLength:
|
|
34
|
-
minLength:
|
|
35
|
-
readOnly:
|
|
36
|
-
required:
|
|
28
|
+
onChange: s,
|
|
29
|
+
defaultValue: l,
|
|
30
|
+
rows: i,
|
|
31
|
+
cols: m,
|
|
32
|
+
autoFocus: u,
|
|
33
|
+
maxLength: d,
|
|
34
|
+
minLength: c,
|
|
35
|
+
readOnly: f,
|
|
36
|
+
required: x,
|
|
37
|
+
ref: e
|
|
37
38
|
};
|
|
38
|
-
return /* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */ h(C, { tag: "textarea", inline: !0, ...o, props: g });
|
|
39
40
|
}
|
|
41
|
+
const y = w(T);
|
|
40
42
|
export {
|
|
41
|
-
|
|
43
|
+
y as default
|
|
42
44
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import Box from '../box';
|
|
2
3
|
declare type BoxProps = React.ComponentProps<typeof Box<'input'>>;
|
|
3
4
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
@@ -17,5 +18,5 @@ interface Props extends Omit<BoxProps, 'props'> {
|
|
|
17
18
|
required?: boolean;
|
|
18
19
|
step?: number | string;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
export
|
|
21
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
22
|
+
export default _default;
|
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import "
|
|
2
|
+
import { forwardRef as g } from "react";
|
|
3
|
+
import b from "../box.js";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
|
-
function
|
|
6
|
+
function y(o, t) {
|
|
7
7
|
const {
|
|
8
|
-
props:
|
|
9
|
-
name:
|
|
10
|
-
type:
|
|
11
|
-
disabled:
|
|
12
|
-
placeholder:
|
|
13
|
-
defaultValue:
|
|
14
|
-
onInput:
|
|
15
|
-
onChange:
|
|
16
|
-
autoFocus:
|
|
17
|
-
readOnly:
|
|
18
|
-
required:
|
|
19
|
-
step:
|
|
20
|
-
} =
|
|
21
|
-
...
|
|
22
|
-
type:
|
|
23
|
-
name:
|
|
24
|
-
disabled:
|
|
25
|
-
placeholder:
|
|
26
|
-
onInput:
|
|
27
|
-
onChange:
|
|
28
|
-
defaultValue:
|
|
29
|
-
autoFocus:
|
|
30
|
-
readOnly:
|
|
31
|
-
required:
|
|
32
|
-
step:
|
|
8
|
+
props: e,
|
|
9
|
+
name: r,
|
|
10
|
+
type: n,
|
|
11
|
+
disabled: p,
|
|
12
|
+
placeholder: a,
|
|
13
|
+
defaultValue: l,
|
|
14
|
+
onInput: u,
|
|
15
|
+
onChange: i,
|
|
16
|
+
autoFocus: s,
|
|
17
|
+
readOnly: d,
|
|
18
|
+
required: m,
|
|
19
|
+
step: c
|
|
20
|
+
} = o, f = {
|
|
21
|
+
...e,
|
|
22
|
+
type: n || "text",
|
|
23
|
+
name: r,
|
|
24
|
+
disabled: p,
|
|
25
|
+
placeholder: a,
|
|
26
|
+
onInput: u,
|
|
27
|
+
onChange: i,
|
|
28
|
+
defaultValue: l,
|
|
29
|
+
autoFocus: s,
|
|
30
|
+
readOnly: d,
|
|
31
|
+
required: m,
|
|
32
|
+
step: c,
|
|
33
|
+
ref: t
|
|
33
34
|
};
|
|
34
|
-
return /* @__PURE__ */ x(
|
|
35
|
+
return /* @__PURE__ */ x(b, { tag: "input", inline: !0, ...o, props: f });
|
|
35
36
|
}
|
|
37
|
+
const j = g(y);
|
|
36
38
|
export {
|
|
37
|
-
|
|
39
|
+
j as default
|
|
38
40
|
};
|