@cripty2001/utils 0.0.110 → 0.0.111
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/dist/react-ui/form.js +3 -3
- package/package.json +1 -1
package/dist/react-ui/form.js
CHANGED
|
@@ -12,7 +12,7 @@ function FormComponent(props) {
|
|
|
12
12
|
const variants = (0, react_1.useMemo)(() => ({
|
|
13
13
|
default: props.variant
|
|
14
14
|
}), [props.variant]);
|
|
15
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem' }, children: [props.inputs.map(input => (() => {
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem' }, children: [props.inputs.map((input, index) => (() => {
|
|
16
16
|
const value = props.value[input.key];
|
|
17
17
|
const setValue = (v) => props.setValue(prev => ({
|
|
18
18
|
...prev,
|
|
@@ -23,12 +23,12 @@ function FormComponent(props) {
|
|
|
23
23
|
case "email":
|
|
24
24
|
case "password":
|
|
25
25
|
case "tel":
|
|
26
|
-
return (0, jsx_runtime_1.jsx)(input_1.default, { label: input.label, value: value, setValue: setValue, variant: "default", variants: variants, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("input", { type: input.type, value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, placeholder: input.label })) });
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(input_1.default, { label: input.label, value: value, setValue: setValue, variant: "default", variants: variants, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("input", { type: input.type, value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, placeholder: input.label })) }, index);
|
|
27
27
|
case "select":
|
|
28
28
|
return (0, jsx_runtime_1.jsx)(input_1.default, { label: input.label, value: value, setValue: setValue, variant: "default", variants: variants, required: input.required, validate: (v) => {
|
|
29
29
|
if (!input.options.includes(v))
|
|
30
30
|
throw new Error("Invalid option");
|
|
31
|
-
}, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("select", { value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, children: input.options.map(option => ((0, jsx_runtime_1.jsx)("option", { value: option, children: option }, option))) })) });
|
|
31
|
+
}, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("select", { value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, children: input.options.map(option => ((0, jsx_runtime_1.jsx)("option", { value: option, children: option }, option))) })) }, index);
|
|
32
32
|
default:
|
|
33
33
|
return (0, jsx_runtime_1.jsx)("div", { style: { color: '#ef4444', backgroundColor: 'white' }, children: "Unknown input type" });
|
|
34
34
|
}
|
package/package.json
CHANGED