shadcn-zod-formkit 1.23.2 → 1.25.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/dist/index.cjs +160 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.mjs +160 -32
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.25.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.23.2.tgz +0 -0
package/dist/index.cjs
CHANGED
|
@@ -232,6 +232,11 @@ var entitiesToGroupedOption = (data, optionValue = "name") => {
|
|
|
232
232
|
}
|
|
233
233
|
return entities;
|
|
234
234
|
};
|
|
235
|
+
var handleOnChage = (event, input, field) => {
|
|
236
|
+
console.log("\u{1F680} ~ handleOnChage ~ event:", event);
|
|
237
|
+
if (event) field?.onChange(event);
|
|
238
|
+
input.onChange?.(event);
|
|
239
|
+
};
|
|
235
240
|
|
|
236
241
|
// src/components/custom/form/inputs/base/definitions.ts
|
|
237
242
|
var flattenFields = (fields) => {
|
|
@@ -289,9 +294,11 @@ var InputTypes = /* @__PURE__ */ ((InputTypes2) => {
|
|
|
289
294
|
InputTypes2["COMBOBOX"] = "COMBO_BOX";
|
|
290
295
|
InputTypes2["SORTABLE_LIST"] = "sortable_list";
|
|
291
296
|
InputTypes2["REPEATER_TABS"] = "repeater_tabs";
|
|
297
|
+
InputTypes2["STRING_LIST"] = "string_list";
|
|
292
298
|
return InputTypes2;
|
|
293
299
|
})(InputTypes || {});
|
|
294
300
|
var inputFieldComp = [
|
|
301
|
+
"string_list" /* STRING_LIST */,
|
|
295
302
|
"repeater_tabs" /* REPEATER_TABS */,
|
|
296
303
|
"sortable_list" /* SORTABLE_LIST */,
|
|
297
304
|
"COMBO_BOX" /* COMBOBOX */,
|
|
@@ -1667,13 +1674,14 @@ var GroupedSwitches = ({ options, onChange, input, isSubmitting }) => {
|
|
|
1667
1674
|
setAllChecked(checked);
|
|
1668
1675
|
onChange?.(updated.filter((opt) => opt.checked));
|
|
1669
1676
|
};
|
|
1670
|
-
const handleChildToggle = (option, checked) => {
|
|
1677
|
+
const handleChildToggle = (option, checked, input2) => {
|
|
1671
1678
|
const updated = switches.map(
|
|
1672
1679
|
(opt) => opt.id === option.id ? { ...opt, checked } : opt
|
|
1673
1680
|
);
|
|
1674
1681
|
setSwitches(updated);
|
|
1675
1682
|
setAllChecked(updated.every((opt) => opt.checked));
|
|
1676
1683
|
onChange?.(updated.filter((opt) => opt.checked));
|
|
1684
|
+
handleOnChage(updated.filter((opt) => opt.checked), input2);
|
|
1677
1685
|
};
|
|
1678
1686
|
return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(`w-full h-full space-y-4 p-4 border-2 rounded-xl bg-green-500 ${allChecked ? "bg-green-500/5 border-green-400/10" : "bg-black/5"}`), children: [
|
|
1679
1687
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b p-2", children: [
|
|
@@ -1691,7 +1699,7 @@ var GroupedSwitches = ({ options, onChange, input, isSubmitting }) => {
|
|
|
1691
1699
|
disabled: input.disabled || isSubmitting,
|
|
1692
1700
|
id: String(opt.id),
|
|
1693
1701
|
checked: opt?.checked || false,
|
|
1694
|
-
onCheckedChange: (checked) => handleChildToggle(opt, checked)
|
|
1702
|
+
onCheckedChange: (checked) => handleChildToggle(opt, checked, input)
|
|
1695
1703
|
}
|
|
1696
1704
|
)
|
|
1697
1705
|
] }, opt.id))
|
|
@@ -1732,7 +1740,7 @@ var AccordionGroupedSwitches = ({ form, input, groups = [], onChange, isSubmitti
|
|
|
1732
1740
|
const countCheckedByGroup = (group) => {
|
|
1733
1741
|
return group.options.filter((opt) => opt.checked).length;
|
|
1734
1742
|
};
|
|
1735
|
-
const handleOptionChange = (field, updatedGroupLabel, updatedOptions) => {
|
|
1743
|
+
const handleOptionChange = (field, updatedGroupLabel, updatedOptions, input2) => {
|
|
1736
1744
|
const newGroups = groupsState.map(
|
|
1737
1745
|
(group) => group.label === updatedGroupLabel ? { ...group, options: updatedOptions } : group
|
|
1738
1746
|
);
|
|
@@ -1741,6 +1749,7 @@ var AccordionGroupedSwitches = ({ form, input, groups = [], onChange, isSubmitti
|
|
|
1741
1749
|
setSelectedOptions(allChecked);
|
|
1742
1750
|
field.onChange(allChecked);
|
|
1743
1751
|
onChange?.(allChecked);
|
|
1752
|
+
handleOnChage(allChecked, input2, field);
|
|
1744
1753
|
};
|
|
1745
1754
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1746
1755
|
FormField,
|
|
@@ -1771,7 +1780,7 @@ var AccordionGroupedSwitches = ({ form, input, groups = [], onChange, isSubmitti
|
|
|
1771
1780
|
isSubmitting,
|
|
1772
1781
|
input,
|
|
1773
1782
|
options: group.options,
|
|
1774
|
-
onChange: (updated) => handleOptionChange(field, group.label, updated)
|
|
1783
|
+
onChange: (updated) => handleOptionChange(field, group.label, updated, input)
|
|
1775
1784
|
}
|
|
1776
1785
|
) })
|
|
1777
1786
|
]
|
|
@@ -1836,7 +1845,10 @@ var FieldButtonGroup = ({ input, form, isSubmitting, className = "w-full flex-1"
|
|
|
1836
1845
|
type: "button",
|
|
1837
1846
|
className,
|
|
1838
1847
|
variant: selectedValue === option.value ? "default" : "outline",
|
|
1839
|
-
onClick: () =>
|
|
1848
|
+
onClick: () => {
|
|
1849
|
+
handleSelect(option.value);
|
|
1850
|
+
handleOnChage(option.value, input);
|
|
1851
|
+
},
|
|
1840
1852
|
disabled: isSubmitting,
|
|
1841
1853
|
children: option.label ?? option.name
|
|
1842
1854
|
},
|
|
@@ -1861,6 +1873,7 @@ var CheckListInput = class extends BaseInput {
|
|
|
1861
1873
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1862
1874
|
Checkbox,
|
|
1863
1875
|
{
|
|
1876
|
+
onChange: (e) => handleOnChage(e, input),
|
|
1864
1877
|
disabled: input.disabled || isSubmitting,
|
|
1865
1878
|
id: String(item[optionValue]),
|
|
1866
1879
|
checked: value.includes(item[optionValue]),
|
|
@@ -1912,7 +1925,7 @@ var FieldCheckbox = ({ input, form, isSubmitting }) => {
|
|
|
1912
1925
|
{
|
|
1913
1926
|
id: input.name,
|
|
1914
1927
|
checked: field.value,
|
|
1915
|
-
onCheckedChange: field
|
|
1928
|
+
onCheckedChange: (e) => handleOnChage(e, input, field),
|
|
1916
1929
|
disabled: input.disabled || isSubmitting,
|
|
1917
1930
|
className: "data-[state=checked]:border-blue-600 data-[state=checked]:bg-blue-600 data-[state=checked]:text-white \n dark:data-[state=checked]:border-blue-700 dark:data-[state=checked]:bg-blue-700"
|
|
1918
1931
|
}
|
|
@@ -1948,23 +1961,14 @@ var FieldColor = ({ form, input, isSubmitting }) => {
|
|
|
1948
1961
|
ColorCmp,
|
|
1949
1962
|
{
|
|
1950
1963
|
value: field.value || "#000000",
|
|
1951
|
-
onChange:
|
|
1964
|
+
onChange: (event) => {
|
|
1965
|
+
handleOnChage(event, input, field);
|
|
1966
|
+
},
|
|
1952
1967
|
onBlur: field.onBlur,
|
|
1953
1968
|
disabled: input.disabled || isSubmitting,
|
|
1954
1969
|
placeholder: input.placeHolder
|
|
1955
1970
|
}
|
|
1956
|
-
) :
|
|
1957
|
-
"input",
|
|
1958
|
-
{
|
|
1959
|
-
type: "color",
|
|
1960
|
-
value: field.value || "#000000",
|
|
1961
|
-
onChange: (e) => field.onChange(e.target.value),
|
|
1962
|
-
onBlur: () => field.onBlur(),
|
|
1963
|
-
disabled: input.disabled || isSubmitting,
|
|
1964
|
-
placeholder: input.placeHolder,
|
|
1965
|
-
style: { width: 48, height: 28 }
|
|
1966
|
-
}
|
|
1967
|
-
) }),
|
|
1971
|
+
) : "N/A" }),
|
|
1968
1972
|
/* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
|
|
1969
1973
|
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
|
|
1970
1974
|
] })
|
|
@@ -2185,6 +2189,7 @@ var FieldCombobox = ({ form, input, isSubmitting }) => {
|
|
|
2185
2189
|
const newValue = currentValue === value ? "" : currentValue;
|
|
2186
2190
|
setValue(newValue);
|
|
2187
2191
|
form.setValue(input.name, newValue);
|
|
2192
|
+
handleOnChage(options.find((o) => getValue(o) === newValue), input);
|
|
2188
2193
|
input.listConfig?.onOptionChange?.(
|
|
2189
2194
|
options.find((o) => getValue(o) === newValue)
|
|
2190
2195
|
);
|
|
@@ -2307,6 +2312,7 @@ var FieldCurrency = ({ form, input, isSubmitting }) => {
|
|
|
2307
2312
|
setRawValue(newVal);
|
|
2308
2313
|
const parsed = parseValue(newVal);
|
|
2309
2314
|
if (parsed !== null) field.onChange(parsed);
|
|
2315
|
+
handleOnChage(parsed, input, field);
|
|
2310
2316
|
},
|
|
2311
2317
|
onBlur: (e) => {
|
|
2312
2318
|
const formatted = formatValue(e.target.value);
|
|
@@ -3905,7 +3911,7 @@ var DateInput = class extends BaseInput {
|
|
|
3905
3911
|
}, [field.value]);
|
|
3906
3912
|
const handleSelect = (selectedDate) => {
|
|
3907
3913
|
setDate(selectedDate);
|
|
3908
|
-
|
|
3914
|
+
handleOnChage(selectedDate, input, field);
|
|
3909
3915
|
};
|
|
3910
3916
|
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { children: [
|
|
3911
3917
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
@@ -3995,7 +4001,10 @@ var FieldDateTimeInput = ({ form, input, isSubmitting }) => {
|
|
|
3995
4001
|
type: "datetime-local",
|
|
3996
4002
|
value: dateTime,
|
|
3997
4003
|
disabled: input.disabled || isSubmitting,
|
|
3998
|
-
onChange: (e) =>
|
|
4004
|
+
onChange: (e) => {
|
|
4005
|
+
handleOnChage(e.target.value, input, field);
|
|
4006
|
+
handleChange(e.target.value);
|
|
4007
|
+
}
|
|
3999
4008
|
}
|
|
4000
4009
|
),
|
|
4001
4010
|
(iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
|
|
@@ -4055,6 +4064,7 @@ var FieldFile = ({ form, input, isSubmitting }) => {
|
|
|
4055
4064
|
onChange: (e) => {
|
|
4056
4065
|
field.onChange(e.target.files?.[0]);
|
|
4057
4066
|
handleFileChange(e);
|
|
4067
|
+
handleOnChage(e.target.files?.[0], input, field);
|
|
4058
4068
|
}
|
|
4059
4069
|
}
|
|
4060
4070
|
) }),
|
|
@@ -4212,7 +4222,7 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
|
|
|
4212
4222
|
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
4213
4223
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
4214
4224
|
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {}),
|
|
4215
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3
|
|
4225
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 rounded-xl p-3 ", children: [
|
|
4216
4226
|
pairs.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "No pairs have been added yet." }),
|
|
4217
4227
|
pairs.map((pair, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4218
4228
|
"div",
|
|
@@ -4338,7 +4348,10 @@ var FieldMultiSelect = ({ form, input, isSubmitting }) => {
|
|
|
4338
4348
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4339
4349
|
CommandItem,
|
|
4340
4350
|
{
|
|
4341
|
-
onSelect: () =>
|
|
4351
|
+
onSelect: () => {
|
|
4352
|
+
handleOnChage(value, input, field);
|
|
4353
|
+
toggleOption(value);
|
|
4354
|
+
},
|
|
4342
4355
|
children: [
|
|
4343
4356
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4344
4357
|
lucideReact.Check,
|
|
@@ -4421,6 +4434,7 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
|
|
|
4421
4434
|
if (isNumberField) {
|
|
4422
4435
|
value = e.target.value === "" ? "" : Number(e.target.value);
|
|
4423
4436
|
}
|
|
4437
|
+
handleOnChage(value, input, field);
|
|
4424
4438
|
field.onChange(value);
|
|
4425
4439
|
}
|
|
4426
4440
|
}
|
|
@@ -4478,7 +4492,7 @@ var FieldOTP = ({ form, input, isSubmitting }) => {
|
|
|
4478
4492
|
name: input.name,
|
|
4479
4493
|
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { children: [
|
|
4480
4494
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
4481
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(InputOTP, { maxLength: totalPositions.length, ...field, children: /* @__PURE__ */ jsxRuntime.jsx(InputOTPGroup, { children: totalPositions.map((position) => /* @__PURE__ */ jsxRuntime.jsx(InputOTPSlot, { index: position }, position)) }) }) }),
|
|
4495
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(InputOTP, { maxLength: totalPositions.length, ...field, onChange: (event) => handleOnChage(event, input, field), children: /* @__PURE__ */ jsxRuntime.jsx(InputOTPGroup, { children: totalPositions.map((position) => /* @__PURE__ */ jsxRuntime.jsx(InputOTPSlot, { index: position }, position)) }) }) }),
|
|
4482
4496
|
/* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
|
|
4483
4497
|
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
|
|
4484
4498
|
] })
|
|
@@ -4519,7 +4533,7 @@ var FieldRadioGroup = ({ input, form, isSubmitting }) => {
|
|
|
4519
4533
|
{
|
|
4520
4534
|
...field,
|
|
4521
4535
|
value: field.value ?? "",
|
|
4522
|
-
onValueChange: field
|
|
4536
|
+
onValueChange: (e) => handleOnChage(e, input, field),
|
|
4523
4537
|
className: "space-y-2 mt-3",
|
|
4524
4538
|
children: options.map((opt, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4525
4539
|
"div",
|
|
@@ -4871,7 +4885,7 @@ var FieldSelect = ({ form, input, isSubmitting }) => {
|
|
|
4871
4885
|
{
|
|
4872
4886
|
disabled: input.disabled || isSubmitting || loading,
|
|
4873
4887
|
onValueChange: (val) => {
|
|
4874
|
-
|
|
4888
|
+
handleOnChage(val, input, field);
|
|
4875
4889
|
setValue(val);
|
|
4876
4890
|
if (input.listConfig?.onOptionChange) {
|
|
4877
4891
|
const selectedItem = lista.find(
|
|
@@ -4915,7 +4929,7 @@ var SimpleCheckListInput = class extends BaseInput {
|
|
|
4915
4929
|
isSubmitting,
|
|
4916
4930
|
input,
|
|
4917
4931
|
value: field.value || [],
|
|
4918
|
-
onChange: field
|
|
4932
|
+
onChange: (e) => handleOnChage(e, input, field)
|
|
4919
4933
|
}
|
|
4920
4934
|
)
|
|
4921
4935
|
}
|
|
@@ -4937,12 +4951,14 @@ var FieldSimpleCheckList = ({ input, value, onChange, isSubmitting }) => {
|
|
|
4937
4951
|
const handleMainToggle = (checked) => {
|
|
4938
4952
|
const updated = options.map((opt) => ({ ...opt, checked }));
|
|
4939
4953
|
setOptions(updated);
|
|
4954
|
+
handleOnChage(updated, input);
|
|
4940
4955
|
onChange(updated);
|
|
4941
4956
|
};
|
|
4942
4957
|
const handleChildToggle = (option, checked) => {
|
|
4943
4958
|
const updated = options.map(
|
|
4944
4959
|
(opt) => opt.id === option.id ? { ...opt, checked } : opt
|
|
4945
4960
|
);
|
|
4961
|
+
handleOnChage(updated, input);
|
|
4946
4962
|
setOptions(updated);
|
|
4947
4963
|
onChange(updated);
|
|
4948
4964
|
};
|
|
@@ -5184,6 +5200,102 @@ function SortableWrapper({
|
|
|
5184
5200
|
}
|
|
5185
5201
|
);
|
|
5186
5202
|
}
|
|
5203
|
+
var StringValueListInput = class extends BaseInput {
|
|
5204
|
+
render() {
|
|
5205
|
+
const { input, form, isSubmitting } = this;
|
|
5206
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5207
|
+
FieldStringValueList,
|
|
5208
|
+
{
|
|
5209
|
+
input,
|
|
5210
|
+
form,
|
|
5211
|
+
isSubmitting
|
|
5212
|
+
}
|
|
5213
|
+
);
|
|
5214
|
+
}
|
|
5215
|
+
};
|
|
5216
|
+
var FieldStringValueList = ({ form, input, isSubmitting }) => {
|
|
5217
|
+
const fieldName = input.name;
|
|
5218
|
+
React3.useEffect(() => {
|
|
5219
|
+
const current = form.getValues(fieldName);
|
|
5220
|
+
if (!Array.isArray(current)) {
|
|
5221
|
+
form.setValue(fieldName, []);
|
|
5222
|
+
}
|
|
5223
|
+
}, [form, fieldName]);
|
|
5224
|
+
const handleAddItem = () => {
|
|
5225
|
+
const current = form.getValues(fieldName) || [];
|
|
5226
|
+
form.setValue(fieldName, [...current, ""]);
|
|
5227
|
+
};
|
|
5228
|
+
const handleRemoveItem = (index) => {
|
|
5229
|
+
const current = form.getValues(fieldName) || [];
|
|
5230
|
+
const updated = current.filter((_, i) => i !== index);
|
|
5231
|
+
form.setValue(fieldName, updated);
|
|
5232
|
+
};
|
|
5233
|
+
const handleChange = (index, newValue) => {
|
|
5234
|
+
const current = form.getValues(fieldName) || [];
|
|
5235
|
+
const updated = current.map(
|
|
5236
|
+
(item, i) => i === index ? newValue : item
|
|
5237
|
+
);
|
|
5238
|
+
form.setValue(fieldName, updated);
|
|
5239
|
+
};
|
|
5240
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5241
|
+
FormField,
|
|
5242
|
+
{
|
|
5243
|
+
control: form.control,
|
|
5244
|
+
name: fieldName,
|
|
5245
|
+
render: () => {
|
|
5246
|
+
const items = form.watch(fieldName) || [];
|
|
5247
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
5248
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
5249
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {}),
|
|
5250
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 rounded-xl ", children: [
|
|
5251
|
+
items.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "No items have been added yet." }),
|
|
5252
|
+
items.map((value, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5253
|
+
"div",
|
|
5254
|
+
{
|
|
5255
|
+
className: "flex gap-2 items-center",
|
|
5256
|
+
children: [
|
|
5257
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5258
|
+
Input,
|
|
5259
|
+
{
|
|
5260
|
+
placeholder: `Item ${index + 1}`,
|
|
5261
|
+
value,
|
|
5262
|
+
disabled: isSubmitting,
|
|
5263
|
+
onChange: (e) => handleChange(index, e.target.value)
|
|
5264
|
+
}
|
|
5265
|
+
),
|
|
5266
|
+
input.isRemovebleOption && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5267
|
+
Button,
|
|
5268
|
+
{
|
|
5269
|
+
type: "button",
|
|
5270
|
+
variant: "destructive",
|
|
5271
|
+
size: "icon",
|
|
5272
|
+
onClick: () => handleRemoveItem(index),
|
|
5273
|
+
disabled: isSubmitting,
|
|
5274
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 18 })
|
|
5275
|
+
}
|
|
5276
|
+
)
|
|
5277
|
+
]
|
|
5278
|
+
},
|
|
5279
|
+
index
|
|
5280
|
+
)),
|
|
5281
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end mt-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5282
|
+
Button,
|
|
5283
|
+
{
|
|
5284
|
+
type: "button",
|
|
5285
|
+
variant: "outline",
|
|
5286
|
+
size: "sm",
|
|
5287
|
+
onClick: handleAddItem,
|
|
5288
|
+
disabled: isSubmitting,
|
|
5289
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 18, className: "mr-1" })
|
|
5290
|
+
}
|
|
5291
|
+
) })
|
|
5292
|
+
] }) }),
|
|
5293
|
+
input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description })
|
|
5294
|
+
] });
|
|
5295
|
+
}
|
|
5296
|
+
}
|
|
5297
|
+
);
|
|
5298
|
+
};
|
|
5187
5299
|
var SwitchInput = class extends BaseInput {
|
|
5188
5300
|
render() {
|
|
5189
5301
|
const { input, form, isSubmitting } = this;
|
|
@@ -5207,7 +5319,7 @@ var FieldSwitch = ({ input, form, isSubmitting }) => {
|
|
|
5207
5319
|
Switch,
|
|
5208
5320
|
{
|
|
5209
5321
|
checked: field.value,
|
|
5210
|
-
onCheckedChange: field
|
|
5322
|
+
onCheckedChange: (event) => handleOnChage(event, input, field),
|
|
5211
5323
|
"aria-disabled": true,
|
|
5212
5324
|
disabled: input.disabled || isSubmitting
|
|
5213
5325
|
}
|
|
@@ -5234,8 +5346,9 @@ var FieldTags = ({ input, form, isSubmitting }) => {
|
|
|
5234
5346
|
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5235
5347
|
TagsInput,
|
|
5236
5348
|
{
|
|
5349
|
+
input,
|
|
5237
5350
|
value: field.value ?? [],
|
|
5238
|
-
onValueChange: field
|
|
5351
|
+
onValueChange: (event) => handleOnChage(event, input, field),
|
|
5239
5352
|
placeholder: "Enter for add tag"
|
|
5240
5353
|
}
|
|
5241
5354
|
) }),
|
|
@@ -5250,6 +5363,7 @@ var SPLITTER_REGEX = /[\n#?=&\t,./-]+/;
|
|
|
5250
5363
|
var FORMATTING_REGEX = /^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g;
|
|
5251
5364
|
var TagsInput = React3__namespace.default.forwardRef(
|
|
5252
5365
|
({
|
|
5366
|
+
input,
|
|
5253
5367
|
value,
|
|
5254
5368
|
onValueChange,
|
|
5255
5369
|
placeholder,
|
|
@@ -5264,7 +5378,7 @@ var TagsInput = React3__namespace.default.forwardRef(
|
|
|
5264
5378
|
const parseMinItems = minItems ?? 0;
|
|
5265
5379
|
const parseMaxItems = maxItems ?? Infinity;
|
|
5266
5380
|
const addTag = (val) => {
|
|
5267
|
-
if (!value.includes(val) && value.length < parseMaxItems) {
|
|
5381
|
+
if (!value.includes(val) && value.length < parseMaxItems || input.withDuplicatTag) {
|
|
5268
5382
|
onValueChange([...value, val]);
|
|
5269
5383
|
}
|
|
5270
5384
|
};
|
|
@@ -5339,7 +5453,18 @@ function FieldTextArea({ form, input, isSubmitting }) {
|
|
|
5339
5453
|
name: input.name,
|
|
5340
5454
|
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "shadow-lg", children: [
|
|
5341
5455
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
5342
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5456
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5457
|
+
Textarea,
|
|
5458
|
+
{
|
|
5459
|
+
className: "min-w-[260px] bg-white",
|
|
5460
|
+
placeholder: input.placeHolder,
|
|
5461
|
+
...field,
|
|
5462
|
+
onChange: (event) => {
|
|
5463
|
+
handleOnChage(event, input, field);
|
|
5464
|
+
},
|
|
5465
|
+
disabled: input.disabled || isSubmitting
|
|
5466
|
+
}
|
|
5467
|
+
) }),
|
|
5343
5468
|
input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
|
|
5344
5469
|
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
|
|
5345
5470
|
] })
|
|
@@ -5370,6 +5495,7 @@ var FieldText = ({ input, form, isSubmitting }) => {
|
|
|
5370
5495
|
placeholder: input.placeHolder,
|
|
5371
5496
|
...field,
|
|
5372
5497
|
type,
|
|
5498
|
+
onChange: (e) => handleOnChage(e, input, field),
|
|
5373
5499
|
disabled: input.disabled || isSubmitting
|
|
5374
5500
|
}
|
|
5375
5501
|
) }),
|
|
@@ -5420,6 +5546,7 @@ var FieldTimeInput = ({ form, input, isSubmitting }) => {
|
|
|
5420
5546
|
if (validNow !== isValid2) setIsValid(validNow);
|
|
5421
5547
|
const handleChange = (val) => {
|
|
5422
5548
|
setTime(val);
|
|
5549
|
+
handleOnChage(val, input, field);
|
|
5423
5550
|
field.onChange(val);
|
|
5424
5551
|
};
|
|
5425
5552
|
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
@@ -5480,6 +5607,7 @@ var inputMap = {
|
|
|
5480
5607
|
["COMBO_BOX" /* COMBOBOX */]: ComboboxInput,
|
|
5481
5608
|
["sortable_list" /* SORTABLE_LIST */]: SortableListInput,
|
|
5482
5609
|
["repeater_tabs" /* REPEATER_TABS */]: RepeaterTabsInput,
|
|
5610
|
+
["string_list" /* STRING_LIST */]: StringValueListInput,
|
|
5483
5611
|
//ToDos: ============================================================
|
|
5484
5612
|
["slider" /* SLIDER */]: SliderInput,
|
|
5485
5613
|
//ToDo: // PENDIENTE ... VISUALMENTE NO SE VE BIEN.!!!
|
|
@@ -6060,6 +6188,7 @@ exports.flattenFields = flattenFields;
|
|
|
6060
6188
|
exports.getDefaultValues = getDefaultValues;
|
|
6061
6189
|
exports.getDynamicSchema = getDynamicSchema;
|
|
6062
6190
|
exports.getFieldLabel = getFieldLabel;
|
|
6191
|
+
exports.handleOnChage = handleOnChage;
|
|
6063
6192
|
exports.inputFieldComp = inputFieldComp;
|
|
6064
6193
|
exports.mockFields = mockFields;
|
|
6065
6194
|
exports.useFormField = useFormField;
|