shadcn-zod-formkit 1.3.0 → 1.5.0
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/README.md +2 -0
- package/dist/index.cjs +334 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.mjs +336 -6
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.5.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.3.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -115,6 +115,8 @@ const mockFields: Array<FieldProps |FieldProps[]> = [
|
|
|
115
115
|
| **Input Time** | `InputTypes.TIME` |
|
|
116
116
|
| **Upload Multi File** | `InputTypes.FILE_MULTI_UPLOAD` |
|
|
117
117
|
| **Button Group** | `InputTypes.BUTTON_GROUP` |
|
|
118
|
+
| **Input Currency** | `InputTypes.CURRENCY` |
|
|
119
|
+
| **Input Key Value** | `InputTypes.KEY_VALUE` |
|
|
118
120
|
|
|
119
121
|
|
|
120
122
|
|
package/dist/index.cjs
CHANGED
|
@@ -263,9 +263,15 @@ var InputTypes = /* @__PURE__ */ ((InputTypes2) => {
|
|
|
263
263
|
InputTypes2["FILE_MULTI_UPLOAD"] = "file_multi_upload";
|
|
264
264
|
InputTypes2["SLIDER"] = "slider";
|
|
265
265
|
InputTypes2["BUTTON_GROUP"] = "button_group";
|
|
266
|
+
InputTypes2["CURRENCY"] = "currency";
|
|
267
|
+
InputTypes2["KEY_VALUE"] = "key_value";
|
|
268
|
+
InputTypes2["REPEATER"] = "repeater";
|
|
266
269
|
return InputTypes2;
|
|
267
270
|
})(InputTypes || {});
|
|
268
271
|
var inputFieldComp = [
|
|
272
|
+
"repeater" /* REPEATER */,
|
|
273
|
+
"key_value" /* KEY_VALUE */,
|
|
274
|
+
"currency" /* CURRENCY */,
|
|
269
275
|
"button_group" /* BUTTON_GROUP */,
|
|
270
276
|
"slider" /* SLIDER */,
|
|
271
277
|
"file_multi_upload" /* FILE_MULTI_UPLOAD */,
|
|
@@ -1977,6 +1983,124 @@ var ColorComp = React3__namespace.default.forwardRef(
|
|
|
1977
1983
|
] });
|
|
1978
1984
|
}
|
|
1979
1985
|
);
|
|
1986
|
+
var CurrencyInput = class extends BaseInput {
|
|
1987
|
+
render() {
|
|
1988
|
+
const { input, form, isSubmitting } = this;
|
|
1989
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FieldCurrency, { input, form, isSubmitting });
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
var FieldCurrency = ({ form, input, isSubmitting }) => {
|
|
1993
|
+
const groupConfig = input.inputGroupConfig;
|
|
1994
|
+
input?.infoTooltip;
|
|
1995
|
+
const autoValidate = groupConfig?.autoValidIcons;
|
|
1996
|
+
const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
|
|
1997
|
+
const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
|
|
1998
|
+
const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
|
|
1999
|
+
const [isValid2, setIsValid] = React3.useState(() => {
|
|
2000
|
+
const value = form.getValues(input.name);
|
|
2001
|
+
const fieldState = form.getFieldState(input.name);
|
|
2002
|
+
return !fieldState.error && value !== void 0 && value !== "";
|
|
2003
|
+
});
|
|
2004
|
+
const defaultCurrencyFormat = {
|
|
2005
|
+
style: "currency",
|
|
2006
|
+
currency: "USD",
|
|
2007
|
+
minimumFractionDigits: 2,
|
|
2008
|
+
maximumFractionDigits: 2
|
|
2009
|
+
};
|
|
2010
|
+
const mask = input?.mask;
|
|
2011
|
+
const currencyFormat = input?.currencyFormat ?? defaultCurrencyFormat;
|
|
2012
|
+
const [rawValue, setRawValue] = React3.useState(form.getValues(input.name) ?? "");
|
|
2013
|
+
const formatter = React3.useMemo(() => {
|
|
2014
|
+
return new Intl.NumberFormat("es-DO", currencyFormat);
|
|
2015
|
+
}, [currencyFormat]);
|
|
2016
|
+
const parseValue = (formatted) => {
|
|
2017
|
+
const numeric = parseFloat(formatted.replace(/[^0-9.-]/g, ""));
|
|
2018
|
+
return isNaN(numeric) ? null : numeric;
|
|
2019
|
+
};
|
|
2020
|
+
const formatValue = (value) => {
|
|
2021
|
+
if (!value) return "";
|
|
2022
|
+
const numeric = parseFloat(value.replace(/[^0-9.-]/g, ""));
|
|
2023
|
+
if (isNaN(numeric)) return "";
|
|
2024
|
+
if (typeof mask === "string") {
|
|
2025
|
+
return mask.replace(/0+(?:[.,]0+)?/, formatter.format(numeric).replace(/[^\d.,]/g, ""));
|
|
2026
|
+
}
|
|
2027
|
+
if (mask instanceof RegExp) {
|
|
2028
|
+
const valid = mask.test(value);
|
|
2029
|
+
return valid ? value : rawValue;
|
|
2030
|
+
}
|
|
2031
|
+
return formatter.format(numeric);
|
|
2032
|
+
};
|
|
2033
|
+
const handleKeyDown = (e) => {
|
|
2034
|
+
const allowedKeys = [
|
|
2035
|
+
"Backspace",
|
|
2036
|
+
"Delete",
|
|
2037
|
+
"Tab",
|
|
2038
|
+
"ArrowLeft",
|
|
2039
|
+
"ArrowRight",
|
|
2040
|
+
"Home",
|
|
2041
|
+
"End"
|
|
2042
|
+
];
|
|
2043
|
+
if (allowedKeys.includes(e.key)) return;
|
|
2044
|
+
if (!/^[0-9.]$/.test(e.key)) {
|
|
2045
|
+
e.preventDefault();
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
if (e.key === "." && rawValue.includes(".")) {
|
|
2049
|
+
e.preventDefault();
|
|
2050
|
+
}
|
|
2051
|
+
};
|
|
2052
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2053
|
+
FormField,
|
|
2054
|
+
{
|
|
2055
|
+
control: form.control,
|
|
2056
|
+
name: input.name,
|
|
2057
|
+
render: ({ field, fieldState }) => {
|
|
2058
|
+
const validNow = !fieldState.error && field.value !== void 0 && field.value !== "";
|
|
2059
|
+
if (validNow !== isValid2) setIsValid(validNow);
|
|
2060
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
2061
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
2062
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
|
|
2063
|
+
/* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { children: [
|
|
2064
|
+
/* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: "$" }),
|
|
2065
|
+
input.inputGroupConfig?.textLeft && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: input.inputGroupConfig.textLeft })
|
|
2066
|
+
] }),
|
|
2067
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2068
|
+
InputGroupInput,
|
|
2069
|
+
{
|
|
2070
|
+
...field,
|
|
2071
|
+
disabled: input.disabled || isSubmitting,
|
|
2072
|
+
placeholder: input.placeHolder ?? "0.00",
|
|
2073
|
+
inputMode: "decimal",
|
|
2074
|
+
value: rawValue,
|
|
2075
|
+
onKeyDown: handleKeyDown,
|
|
2076
|
+
onChange: (e) => {
|
|
2077
|
+
const newVal = e.target.value;
|
|
2078
|
+
setRawValue(newVal);
|
|
2079
|
+
const parsed = parseValue(newVal);
|
|
2080
|
+
if (parsed !== null) field.onChange(parsed);
|
|
2081
|
+
},
|
|
2082
|
+
onBlur: (e) => {
|
|
2083
|
+
const formatted = formatValue(e.target.value);
|
|
2084
|
+
setRawValue(formatted);
|
|
2085
|
+
},
|
|
2086
|
+
onFocus: (e) => {
|
|
2087
|
+
const numeric = e.target.value.replace(/[^0-9.-]/g, "");
|
|
2088
|
+
setRawValue(numeric);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
),
|
|
2092
|
+
/* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
|
|
2093
|
+
/* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: currencyFormat.currency }),
|
|
2094
|
+
input.inputGroupConfig?.textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: input.inputGroupConfig.textRight }),
|
|
2095
|
+
autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
|
|
2096
|
+
] })
|
|
2097
|
+
] }) }),
|
|
2098
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
|
|
2099
|
+
] });
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
);
|
|
2103
|
+
};
|
|
1980
2104
|
var millisecondsInWeek = 6048e5;
|
|
1981
2105
|
var millisecondsInDay = 864e5;
|
|
1982
2106
|
var constructFromSymbol = Symbol.for("constructDateFrom");
|
|
@@ -3813,6 +3937,113 @@ var FieldFileMultiUpload = ({ input, form, isSubmitting }) => {
|
|
|
3813
3937
|
);
|
|
3814
3938
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
|
|
3815
3939
|
};
|
|
3940
|
+
var KeyValueListInput = class extends BaseInput {
|
|
3941
|
+
render() {
|
|
3942
|
+
const { input, form, isSubmitting } = this;
|
|
3943
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3944
|
+
FieldKeyValueList,
|
|
3945
|
+
{
|
|
3946
|
+
input,
|
|
3947
|
+
form,
|
|
3948
|
+
isSubmitting
|
|
3949
|
+
}
|
|
3950
|
+
);
|
|
3951
|
+
}
|
|
3952
|
+
};
|
|
3953
|
+
var FieldKeyValueList = ({ form, input, isSubmitting }) => {
|
|
3954
|
+
const fieldName = input.name;
|
|
3955
|
+
React3.useEffect(() => {
|
|
3956
|
+
const current = form.getValues(fieldName);
|
|
3957
|
+
if (!Array.isArray(current)) {
|
|
3958
|
+
form.setValue(fieldName, []);
|
|
3959
|
+
}
|
|
3960
|
+
}, [form, fieldName]);
|
|
3961
|
+
const handleAddPair = () => {
|
|
3962
|
+
const current = form.getValues(fieldName) || [];
|
|
3963
|
+
form.setValue(fieldName, [...current, { key: "", value: "" }]);
|
|
3964
|
+
};
|
|
3965
|
+
const handleRemovePair = (index) => {
|
|
3966
|
+
const current = form.getValues(fieldName) || [];
|
|
3967
|
+
const updated = current.filter((_, i) => i !== index);
|
|
3968
|
+
form.setValue(fieldName, updated);
|
|
3969
|
+
};
|
|
3970
|
+
const handleChange = (index, fieldType, newValue) => {
|
|
3971
|
+
const current = form.getValues(fieldName) || [];
|
|
3972
|
+
const updated = current.map(
|
|
3973
|
+
(item, i) => i === index ? { ...item, [fieldType]: newValue } : item
|
|
3974
|
+
);
|
|
3975
|
+
form.setValue(fieldName, updated);
|
|
3976
|
+
};
|
|
3977
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3978
|
+
FormField,
|
|
3979
|
+
{
|
|
3980
|
+
control: form.control,
|
|
3981
|
+
name: fieldName,
|
|
3982
|
+
render: () => {
|
|
3983
|
+
const pairs = form.watch(fieldName) || [];
|
|
3984
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
3985
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
3986
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {}),
|
|
3987
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 shadow-lg rounded-xl p-3 bg-white", children: [
|
|
3988
|
+
pairs.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "No pairs have been added yet." }),
|
|
3989
|
+
pairs.map((pair, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3990
|
+
"div",
|
|
3991
|
+
{
|
|
3992
|
+
className: "flex gap-2 items-center",
|
|
3993
|
+
children: [
|
|
3994
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3995
|
+
Input,
|
|
3996
|
+
{
|
|
3997
|
+
placeholder: "Key",
|
|
3998
|
+
value: pair.key,
|
|
3999
|
+
disabled: isSubmitting,
|
|
4000
|
+
onChange: (e) => handleChange(index, "key", e.target.value),
|
|
4001
|
+
className: "w-1/2"
|
|
4002
|
+
}
|
|
4003
|
+
),
|
|
4004
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4005
|
+
Input,
|
|
4006
|
+
{
|
|
4007
|
+
placeholder: "Value",
|
|
4008
|
+
value: pair.value,
|
|
4009
|
+
disabled: isSubmitting,
|
|
4010
|
+
onChange: (e) => handleChange(index, "value", e.target.value),
|
|
4011
|
+
className: "w-1/2"
|
|
4012
|
+
}
|
|
4013
|
+
),
|
|
4014
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4015
|
+
Button,
|
|
4016
|
+
{
|
|
4017
|
+
type: "button",
|
|
4018
|
+
variant: "destructive",
|
|
4019
|
+
size: "icon",
|
|
4020
|
+
onClick: () => handleRemovePair(index),
|
|
4021
|
+
disabled: isSubmitting,
|
|
4022
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 18 })
|
|
4023
|
+
}
|
|
4024
|
+
)
|
|
4025
|
+
]
|
|
4026
|
+
},
|
|
4027
|
+
index
|
|
4028
|
+
)),
|
|
4029
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end mt-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4030
|
+
Button,
|
|
4031
|
+
{
|
|
4032
|
+
type: "button",
|
|
4033
|
+
variant: "outline",
|
|
4034
|
+
size: "sm",
|
|
4035
|
+
onClick: handleAddPair,
|
|
4036
|
+
disabled: isSubmitting,
|
|
4037
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 18, className: "mr-1" })
|
|
4038
|
+
}
|
|
4039
|
+
) })
|
|
4040
|
+
] }) }),
|
|
4041
|
+
input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description })
|
|
4042
|
+
] });
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
);
|
|
4046
|
+
};
|
|
3816
4047
|
var TextInputGroup = class extends BaseInput {
|
|
3817
4048
|
render() {
|
|
3818
4049
|
const { input, form, isSubmitting } = this;
|
|
@@ -3988,6 +4219,100 @@ var FieldRadioGroup = ({ input, form, isSubmitting }) => {
|
|
|
3988
4219
|
);
|
|
3989
4220
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
|
|
3990
4221
|
};
|
|
4222
|
+
var RepeaterInput = class extends BaseInput {
|
|
4223
|
+
render() {
|
|
4224
|
+
const { input, form, isSubmitting } = this;
|
|
4225
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FieldRepeater, { form, input, isSubmitting });
|
|
4226
|
+
}
|
|
4227
|
+
};
|
|
4228
|
+
var FieldRepeater = ({ form, input, isSubmitting }) => {
|
|
4229
|
+
const { control } = form;
|
|
4230
|
+
const { fields, append, remove } = reactHookForm.useFieldArray({
|
|
4231
|
+
control,
|
|
4232
|
+
name: input.name
|
|
4233
|
+
});
|
|
4234
|
+
const canAdd = !input.maxItems || fields.length < input.maxItems;
|
|
4235
|
+
const canRemove = fields.length > (input.minItems ?? 0);
|
|
4236
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4237
|
+
FormField,
|
|
4238
|
+
{
|
|
4239
|
+
control,
|
|
4240
|
+
name: input.name,
|
|
4241
|
+
render: () => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
4242
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
4243
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
4244
|
+
fields.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4245
|
+
"div",
|
|
4246
|
+
{
|
|
4247
|
+
className: "border p-3 rounded-md flex flex-col gap-3",
|
|
4248
|
+
children: [
|
|
4249
|
+
input.repeaterFields?.map((fieldGroup, groupIndex) => {
|
|
4250
|
+
const group = Array.isArray(fieldGroup) ? fieldGroup : [fieldGroup];
|
|
4251
|
+
const cols = group.length;
|
|
4252
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4253
|
+
"div",
|
|
4254
|
+
{
|
|
4255
|
+
className: `grid gap-3 grid-cols-${cols}`,
|
|
4256
|
+
children: group.map((subField) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4257
|
+
FormField,
|
|
4258
|
+
{
|
|
4259
|
+
control,
|
|
4260
|
+
name: `${input.name}.${index}.${subField.name}`,
|
|
4261
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "flex-1", children: [
|
|
4262
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: subField.label }),
|
|
4263
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4264
|
+
Input,
|
|
4265
|
+
{
|
|
4266
|
+
placeholder: subField.placeHolder,
|
|
4267
|
+
disabled: subField.disabled || isSubmitting,
|
|
4268
|
+
...field
|
|
4269
|
+
}
|
|
4270
|
+
) }),
|
|
4271
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { children: fieldState.error?.message })
|
|
4272
|
+
] })
|
|
4273
|
+
},
|
|
4274
|
+
`${input.name}.${index}.${subField.name}`
|
|
4275
|
+
))
|
|
4276
|
+
},
|
|
4277
|
+
groupIndex
|
|
4278
|
+
);
|
|
4279
|
+
}),
|
|
4280
|
+
canRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4281
|
+
Button,
|
|
4282
|
+
{
|
|
4283
|
+
type: "button",
|
|
4284
|
+
variant: "destructive",
|
|
4285
|
+
size: "icon",
|
|
4286
|
+
onClick: () => remove(index),
|
|
4287
|
+
className: "self-end",
|
|
4288
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 18 })
|
|
4289
|
+
}
|
|
4290
|
+
)
|
|
4291
|
+
]
|
|
4292
|
+
},
|
|
4293
|
+
item.id
|
|
4294
|
+
)),
|
|
4295
|
+
canAdd && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4296
|
+
Button,
|
|
4297
|
+
{
|
|
4298
|
+
type: "button",
|
|
4299
|
+
variant: "secondary",
|
|
4300
|
+
onClick: () => append({}),
|
|
4301
|
+
disabled: isSubmitting,
|
|
4302
|
+
className: "w-full",
|
|
4303
|
+
children: [
|
|
4304
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 16, className: "mr-2" }),
|
|
4305
|
+
"Agregar"
|
|
4306
|
+
]
|
|
4307
|
+
}
|
|
4308
|
+
)
|
|
4309
|
+
] }) }),
|
|
4310
|
+
input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
|
|
4311
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
|
|
4312
|
+
] })
|
|
4313
|
+
}
|
|
4314
|
+
);
|
|
4315
|
+
};
|
|
3991
4316
|
var SelectInput = class extends BaseInput {
|
|
3992
4317
|
render() {
|
|
3993
4318
|
const { input, form, isSubmitting } = this;
|
|
@@ -4513,6 +4838,9 @@ var inputMap = {
|
|
|
4513
4838
|
["time" /* TIME */]: TimeInput,
|
|
4514
4839
|
["file_multi_upload" /* FILE_MULTI_UPLOAD */]: FileMultiUploadInput,
|
|
4515
4840
|
["button_group" /* BUTTON_GROUP */]: ButtonGroupInput,
|
|
4841
|
+
["currency" /* CURRENCY */]: CurrencyInput,
|
|
4842
|
+
["key_value" /* KEY_VALUE */]: KeyValueListInput,
|
|
4843
|
+
["repeater" /* REPEATER */]: RepeaterInput,
|
|
4516
4844
|
//ToDos: ============================================================
|
|
4517
4845
|
["slider" /* SLIDER */]: SliderInput,
|
|
4518
4846
|
//ToDo: // PENDIENTE ... VISUALMENTE NO SE VE BIEN.!!!
|
|
@@ -4522,7 +4850,6 @@ var inputMap = {
|
|
|
4522
4850
|
// [InputTypes.SWITCH_LIST]: SwitchListInput,
|
|
4523
4851
|
// [InputTypes.RANGE]: TextInput,
|
|
4524
4852
|
// [InputTypes.MULTISELECT]: TextInput,
|
|
4525
|
-
// [InputTypes.CURRENCY]: TextInput,
|
|
4526
4853
|
// [InputTypes.IMAGE_UPLOAD]: TextInput,
|
|
4527
4854
|
// [InputTypes.AUDIO_UPLOAD]: TextInput,
|
|
4528
4855
|
// [InputTypes.VIDEO_UPLOAD]: TextInput,
|
|
@@ -4605,6 +4932,11 @@ var getFieldLabel = (fieldErrorKey, fields) => {
|
|
|
4605
4932
|
const findedField = fields.find((field) => field.name == fieldErrorKey);
|
|
4606
4933
|
return findedField?.label ?? fieldErrorKey;
|
|
4607
4934
|
};
|
|
4935
|
+
var FormFieldsGrid = ({ fields, form, isPending, className = "", gap = "gap-2" }) => {
|
|
4936
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fields.map(
|
|
4937
|
+
(input, idx) => Array.isArray(input) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-full flex flex-row justify-between py-3", children: input.map((field, subIdx) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full px-2", children: InputFactory.create(field, form, isPending) }, subIdx)) }, `field-group-${idx}`) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex flex-col justify-between py-3 w-full px-2", children: InputFactory.create(input, form, isPending) }, `field-group-${idx}`)
|
|
4938
|
+
) });
|
|
4939
|
+
};
|
|
4608
4940
|
var DynamicForm = ({
|
|
4609
4941
|
formTitle,
|
|
4610
4942
|
formSubTitle,
|
|
@@ -4647,9 +4979,7 @@ var DynamicForm = ({
|
|
|
4647
4979
|
] }),
|
|
4648
4980
|
withErrorsAlert && errorAlertPosition == "up" && /* @__PURE__ */ jsxRuntime.jsx(FormErrorsAlert, { formState: form.formState, fields }),
|
|
4649
4981
|
/* @__PURE__ */ jsxRuntime.jsx(Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(handleSubmit), className: "flex flex-col gap-2", children: [
|
|
4650
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full grid grid-cols-1", children:
|
|
4651
|
-
(input, idx) => Array.isArray(input) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-full flex flex-row justify-between py-3", children: input.map((field, subIdx) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full px-2", children: InputFactory.create(field, form, isPending) }, subIdx)) }, `field-group-${idx}`) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex flex-col justify-between py-3 w-full px-2", children: InputFactory.create(input, form, isPending) }, `field-group-${idx}`)
|
|
4652
|
-
) }),
|
|
4982
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full grid grid-cols-1", children: /* @__PURE__ */ jsxRuntime.jsx(FormFieldsGrid, { fields, form }) }),
|
|
4653
4983
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 justify-end items-end justify-items-end", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "lg", className: submitBtnClass, disabled: isPending, children: isPending ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4654
4984
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
|
|
4655
4985
|
submitBtnLabel ?? "Saving..."
|