@cripty2001/utils 0.0.126 → 0.0.127
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 +13 -3
- package/package.json +1 -1
package/dist/react-ui/form.js
CHANGED
|
@@ -18,17 +18,27 @@ function FormComponent(props) {
|
|
|
18
18
|
...prev,
|
|
19
19
|
[input.key]: v
|
|
20
20
|
}));
|
|
21
|
+
const baseProps = {
|
|
22
|
+
label: input.label,
|
|
23
|
+
value: value,
|
|
24
|
+
setValue: setValue,
|
|
25
|
+
variant: "default",
|
|
26
|
+
variants: variants,
|
|
27
|
+
key: index,
|
|
28
|
+
required: input.required,
|
|
29
|
+
icon: input.icon,
|
|
30
|
+
};
|
|
21
31
|
switch (input.type) {
|
|
22
32
|
case "text":
|
|
23
33
|
case "email":
|
|
24
34
|
case "password":
|
|
25
35
|
case "tel":
|
|
26
|
-
return (0, jsx_runtime_1.jsx)(input_1.default, {
|
|
36
|
+
return (0, jsx_runtime_1.jsx)(input_1.default, { ...baseProps, 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 })) });
|
|
27
37
|
case "select":
|
|
28
|
-
return (0, jsx_runtime_1.jsx)(input_1.default, {
|
|
38
|
+
return (0, jsx_runtime_1.jsx)(input_1.default, { ...baseProps, required: input.required, validate: (v) => {
|
|
29
39
|
if (!input.options.includes(v))
|
|
30
40
|
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))) })) }
|
|
41
|
+
}, 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))) })) });
|
|
32
42
|
default:
|
|
33
43
|
return (0, jsx_runtime_1.jsx)("div", { style: { color: '#ef4444', backgroundColor: 'white' }, children: "Unknown input type" });
|
|
34
44
|
}
|
package/package.json
CHANGED