@cronocode/react-box 0.4.5 → 0.4.7
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/components/formAsync.js +32 -12
- package/components/uncontrolledCheckboxCore.d.ts +19 -0
- package/components/uncontrolledCheckboxCore.js +42 -0
- package/components/uncontrolledRadioButtonCore.d.ts +19 -0
- package/components/uncontrolledRadioButtonCore.js +42 -0
- package/components/uncontrolledTextareaCore.d.ts +22 -0
- package/components/uncontrolledTextareaCore.js +47 -0
- package/components/uncontrolledTextboxCore.d.ts +5 -1
- package/components/uncontrolledTextboxCore.js +18 -10
- package/package.json +1 -1
- package/style.css +1 -1
package/components/formAsync.js
CHANGED
|
@@ -1,26 +1,46 @@
|
|
|
1
|
-
import { useRef as i, useCallback as
|
|
2
|
-
import
|
|
3
|
-
import { jsx as
|
|
1
|
+
import { useRef as i, useCallback as p } from "react";
|
|
2
|
+
import s from "../box.js";
|
|
3
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
|
-
function
|
|
6
|
+
function a(u) {
|
|
7
|
+
const n = Array.from(u.elements).reduce((r, o) => {
|
|
8
|
+
if (o.nodeName === "INPUT") {
|
|
9
|
+
const c = o.name;
|
|
10
|
+
r[c] || (r[c] = []), r[c].push(o);
|
|
11
|
+
}
|
|
12
|
+
return r;
|
|
13
|
+
}, {});
|
|
14
|
+
return Object.entries(n).reduce((r, [o, c]) => {
|
|
15
|
+
if (c.length === 1) {
|
|
16
|
+
const e = c[0];
|
|
17
|
+
r[o] = e.type === "checkbox" || e.type === "radio" ? e.checked : e.value;
|
|
18
|
+
} else
|
|
19
|
+
r[o] = [], c.forEach((e) => {
|
|
20
|
+
var t;
|
|
21
|
+
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);
|
|
22
|
+
});
|
|
23
|
+
return r;
|
|
24
|
+
}, {});
|
|
25
|
+
}
|
|
26
|
+
function v(u) {
|
|
7
27
|
const {
|
|
8
28
|
children: n,
|
|
9
|
-
onSubmit:
|
|
10
|
-
} =
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
29
|
+
onSubmit: r
|
|
30
|
+
} = u, o = i(null), c = p((e) => {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
const t = a(o.current);
|
|
33
|
+
r(t, e);
|
|
14
34
|
}, []);
|
|
15
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ m(s, {
|
|
16
36
|
tag: "form",
|
|
17
37
|
props: {
|
|
18
38
|
ref: o,
|
|
19
|
-
onSubmit:
|
|
39
|
+
onSubmit: c
|
|
20
40
|
},
|
|
21
41
|
children: n
|
|
22
42
|
});
|
|
23
43
|
}
|
|
24
44
|
export {
|
|
25
|
-
|
|
45
|
+
v as default
|
|
26
46
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Box from '../box';
|
|
2
|
+
declare type BoxProps = React.ComponentProps<typeof Box>;
|
|
3
|
+
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
|
+
declare type UncontrolledCheckboxCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'value' | 'autoFocus' | 'readOnly' | 'required' | 'defaultChecked'>;
|
|
5
|
+
interface Props extends Omit<BoxProps, 'props'> {
|
|
6
|
+
name: string;
|
|
7
|
+
props?: UncontrolledCheckboxCoreTagProps;
|
|
8
|
+
onInput?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
9
|
+
onChange?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
value?: string | number;
|
|
13
|
+
autoFocus?: boolean;
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
defaultChecked?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export default function UncontrolledCheckboxCore(props: Props): JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import m from "../box.js";
|
|
2
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
3
|
+
import "react";
|
|
4
|
+
import "../box.module.css.js";
|
|
5
|
+
import "../utils/utils.js";
|
|
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 = {
|
|
20
|
+
...e,
|
|
21
|
+
type: "checkbox",
|
|
22
|
+
name: r,
|
|
23
|
+
disabled: t,
|
|
24
|
+
placeholder: n,
|
|
25
|
+
onInput: a,
|
|
26
|
+
onChange: i,
|
|
27
|
+
value: p,
|
|
28
|
+
autoFocus: u,
|
|
29
|
+
readOnly: c,
|
|
30
|
+
required: l,
|
|
31
|
+
defaultChecked: d
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ f(m, {
|
|
34
|
+
tag: "input",
|
|
35
|
+
inline: !0,
|
|
36
|
+
...o,
|
|
37
|
+
props: s
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
k as default
|
|
42
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Box from '../box';
|
|
2
|
+
declare type BoxProps = React.ComponentProps<typeof Box>;
|
|
3
|
+
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
|
+
declare type UncontrolledRadioButtonCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'value' | 'autoFocus' | 'readOnly' | 'required' | 'defaultChecked'>;
|
|
5
|
+
interface Props extends Omit<BoxProps, 'props'> {
|
|
6
|
+
name: string;
|
|
7
|
+
props?: UncontrolledRadioButtonCoreTagProps;
|
|
8
|
+
onInput?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
9
|
+
onChange?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
value?: string | number;
|
|
13
|
+
autoFocus?: boolean;
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
defaultChecked?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export default function UncontrolledRadioButtonCore(props: Props): JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import c from "../box.js";
|
|
2
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
3
|
+
import "react";
|
|
4
|
+
import "../box.module.css.js";
|
|
5
|
+
import "../utils/utils.js";
|
|
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 = {
|
|
20
|
+
...t,
|
|
21
|
+
type: "radio",
|
|
22
|
+
name: e,
|
|
23
|
+
disabled: r,
|
|
24
|
+
placeholder: n,
|
|
25
|
+
onInput: p,
|
|
26
|
+
onChange: i,
|
|
27
|
+
value: a,
|
|
28
|
+
autoFocus: u,
|
|
29
|
+
readOnly: d,
|
|
30
|
+
required: l,
|
|
31
|
+
defaultChecked: s
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ f(c, {
|
|
34
|
+
tag: "input",
|
|
35
|
+
inline: !0,
|
|
36
|
+
...o,
|
|
37
|
+
props: m
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
B as default
|
|
42
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Box from '../box';
|
|
2
|
+
declare type BoxProps = React.ComponentProps<typeof Box>;
|
|
3
|
+
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
|
+
declare type UncontrolledTextareaCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'placeholder' | 'disabled' | 'defaultValue' | 'rows' | 'cols' | 'autoFocus' | 'maxLength' | 'minLength' | 'readOnly' | 'required'>;
|
|
5
|
+
interface Props extends Omit<BoxProps, 'props'> {
|
|
6
|
+
name: string;
|
|
7
|
+
props?: UncontrolledTextareaCoreTagProps;
|
|
8
|
+
onInput?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
9
|
+
onChange?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
defaultValue?: string | number;
|
|
13
|
+
rows?: number;
|
|
14
|
+
cols?: number;
|
|
15
|
+
autoFocus?: boolean;
|
|
16
|
+
maxLength?: number;
|
|
17
|
+
minLength?: number;
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export default function UncontrolledTextareaCore(props: Props): JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import f from "../box.js";
|
|
2
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
3
|
+
import "react";
|
|
4
|
+
import "../box.module.css.js";
|
|
5
|
+
import "../utils/utils.js";
|
|
6
|
+
function b(o) {
|
|
7
|
+
const {
|
|
8
|
+
props: e,
|
|
9
|
+
name: r,
|
|
10
|
+
disabled: t,
|
|
11
|
+
placeholder: n,
|
|
12
|
+
defaultValue: a,
|
|
13
|
+
onInput: p,
|
|
14
|
+
onChange: i,
|
|
15
|
+
rows: l,
|
|
16
|
+
cols: s,
|
|
17
|
+
autoFocus: m,
|
|
18
|
+
maxLength: u,
|
|
19
|
+
minLength: d,
|
|
20
|
+
readOnly: c,
|
|
21
|
+
required: g
|
|
22
|
+
} = o, x = {
|
|
23
|
+
...e,
|
|
24
|
+
name: r,
|
|
25
|
+
disabled: t,
|
|
26
|
+
placeholder: n,
|
|
27
|
+
onInput: p,
|
|
28
|
+
onChange: i,
|
|
29
|
+
defaultValue: a,
|
|
30
|
+
rows: l,
|
|
31
|
+
cols: s,
|
|
32
|
+
autoFocus: m,
|
|
33
|
+
maxLength: u,
|
|
34
|
+
minLength: d,
|
|
35
|
+
readOnly: c,
|
|
36
|
+
required: g
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ h(f, {
|
|
39
|
+
tag: "textarea",
|
|
40
|
+
inline: !0,
|
|
41
|
+
...o,
|
|
42
|
+
props: x
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
b as default
|
|
47
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Box from '../box';
|
|
2
2
|
declare type BoxProps = React.ComponentProps<typeof Box>;
|
|
3
3
|
declare type BoxTagProps = Required<BoxProps>['props'];
|
|
4
|
-
declare type UncontrolledTextboxCoreTagProps = Omit<BoxTagProps, 'name' | 'onInput' | 'onChange' | 'type' | 'placeholder' | 'disabled' | 'defaultValue'>;
|
|
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';
|
|
6
6
|
interface Props extends Omit<BoxProps, 'props'> {
|
|
7
7
|
name: string;
|
|
@@ -12,6 +12,10 @@ interface Props extends Omit<BoxProps, 'props'> {
|
|
|
12
12
|
placeholder?: string;
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
defaultValue?: string | number;
|
|
15
|
+
autoFocus?: boolean;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
step?: number | string;
|
|
15
19
|
}
|
|
16
20
|
export default function UncontrolledTextboxCore(props: Props): JSX.Element;
|
|
17
21
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { jsx as
|
|
1
|
+
import x from "../box.js";
|
|
2
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../box.module.css.js";
|
|
5
5
|
import "../utils/utils.js";
|
|
6
|
-
function
|
|
6
|
+
function P(t) {
|
|
7
7
|
const {
|
|
8
8
|
props: o,
|
|
9
9
|
name: e,
|
|
@@ -12,24 +12,32 @@ function b(t) {
|
|
|
12
12
|
placeholder: p,
|
|
13
13
|
defaultValue: a,
|
|
14
14
|
onInput: i,
|
|
15
|
-
onChange:
|
|
16
|
-
|
|
15
|
+
onChange: u,
|
|
16
|
+
autoFocus: l,
|
|
17
|
+
readOnly: s,
|
|
18
|
+
required: d,
|
|
19
|
+
step: m
|
|
20
|
+
} = t, c = {
|
|
17
21
|
...o,
|
|
18
22
|
type: r || "text",
|
|
19
23
|
name: e,
|
|
20
24
|
disabled: n,
|
|
21
25
|
placeholder: p,
|
|
22
26
|
onInput: i,
|
|
23
|
-
onChange:
|
|
24
|
-
defaultValue: a
|
|
27
|
+
onChange: u,
|
|
28
|
+
defaultValue: a,
|
|
29
|
+
autoFocus: l,
|
|
30
|
+
readOnly: s,
|
|
31
|
+
required: d,
|
|
32
|
+
step: m
|
|
25
33
|
};
|
|
26
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ f(x, {
|
|
27
35
|
tag: "input",
|
|
28
36
|
inline: !0,
|
|
29
37
|
...t,
|
|
30
|
-
props:
|
|
38
|
+
props: c
|
|
31
39
|
});
|
|
32
40
|
}
|
|
33
41
|
export {
|
|
34
|
-
|
|
42
|
+
P as default
|
|
35
43
|
};
|