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.d.mts CHANGED
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
3
  import { ReactNode, JSX } from 'react';
4
4
  import * as react_hook_form from 'react-hook-form';
5
- import { UseFormReturn, FieldValues, FormState, FieldPath, ControllerProps } from 'react-hook-form';
5
+ import { UseFormReturn, ControllerRenderProps, FieldValues, FormState, FieldPath, ControllerProps } from 'react-hook-form';
6
6
  import { ZodTypeAny, z, ZodObject } from 'zod';
7
7
  import { LucideProps } from 'lucide-react';
8
8
  import * as AccordionPrimitive from '@radix-ui/react-accordion';
@@ -74,7 +74,8 @@ declare enum InputTypes {
74
74
  MULTI_SELECT = "multi_select",
75
75
  COMBOBOX = "COMBO_BOX",
76
76
  SORTABLE_LIST = "sortable_list",
77
- REPEATER_TABS = "repeater_tabs"
77
+ REPEATER_TABS = "repeater_tabs",
78
+ STRING_LIST = "string_list"
78
79
  }
79
80
  declare const inputFieldComp: InputTypes[];
80
81
 
@@ -83,13 +84,15 @@ type FieldConfig<T, RT = Record<string, any>> = FieldProps<T, RT> | FieldConfig<
83
84
  interface FieldProps<T = Record<string, any>, RT = Record<string, any>> {
84
85
  name: keyof T;
85
86
  label: string;
87
+ isRemovebleOption?: boolean;
88
+ withDuplicatTag?: boolean;
86
89
  onChange?: (...event: any[]) => void;
87
90
  tabLabelField?: string;
88
91
  childrenPosition?: 'up' | 'down';
89
92
  children?: ReactNode | ((item: any, index: number) => ReactNode);
90
93
  defaultValue?: any;
91
94
  direction?: 'row' | 'col';
92
- repeaterFields?: FieldConfig<RT>;
95
+ repeaterFields?: Array<FieldProps<RT> | FieldProps<RT>[]>;
93
96
  minItems?: number;
94
97
  maxItems?: number;
95
98
  currencyFormat?: Intl.NumberFormatOptions;
@@ -199,6 +202,7 @@ declare const entityToInputOption: (entitiy: any, name?: string, description?: s
199
202
  declare const entitiesToInputOption: (data: any[], optionValue?: string, groupedLabel?: string) => InputOption[];
200
203
  declare const entityToGroupedOption: (entitiy: any, name?: string) => GroupedOption;
201
204
  declare const entitiesToGroupedOption: (data: any[], optionValue?: string) => GroupedOption[];
205
+ declare const handleOnChage: (event: any[] | any, input: FieldProps, field?: ControllerRenderProps<FieldValues, string>) => void;
202
206
 
203
207
  type alertPositionType = 'up' | 'down';
204
208
  interface FormResp<T> {
@@ -454,4 +458,4 @@ declare function TooltipContent({ className, sideOffset, children, ...props }: R
454
458
 
455
459
  declare function cn(...inputs: ClassValue[]): string;
456
460
 
457
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, type ColorCompProps, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldConfig, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, type FormResp, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, Label, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, inputFieldComp, mockFields, useFormField, validationMessages };
461
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, type ColorCompProps, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldConfig, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, type FormResp, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, Label, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, mockFields, useFormField, validationMessages };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
3
  import { ReactNode, JSX } from 'react';
4
4
  import * as react_hook_form from 'react-hook-form';
5
- import { UseFormReturn, FieldValues, FormState, FieldPath, ControllerProps } from 'react-hook-form';
5
+ import { UseFormReturn, ControllerRenderProps, FieldValues, FormState, FieldPath, ControllerProps } from 'react-hook-form';
6
6
  import { ZodTypeAny, z, ZodObject } from 'zod';
7
7
  import { LucideProps } from 'lucide-react';
8
8
  import * as AccordionPrimitive from '@radix-ui/react-accordion';
@@ -74,7 +74,8 @@ declare enum InputTypes {
74
74
  MULTI_SELECT = "multi_select",
75
75
  COMBOBOX = "COMBO_BOX",
76
76
  SORTABLE_LIST = "sortable_list",
77
- REPEATER_TABS = "repeater_tabs"
77
+ REPEATER_TABS = "repeater_tabs",
78
+ STRING_LIST = "string_list"
78
79
  }
79
80
  declare const inputFieldComp: InputTypes[];
80
81
 
@@ -83,13 +84,15 @@ type FieldConfig<T, RT = Record<string, any>> = FieldProps<T, RT> | FieldConfig<
83
84
  interface FieldProps<T = Record<string, any>, RT = Record<string, any>> {
84
85
  name: keyof T;
85
86
  label: string;
87
+ isRemovebleOption?: boolean;
88
+ withDuplicatTag?: boolean;
86
89
  onChange?: (...event: any[]) => void;
87
90
  tabLabelField?: string;
88
91
  childrenPosition?: 'up' | 'down';
89
92
  children?: ReactNode | ((item: any, index: number) => ReactNode);
90
93
  defaultValue?: any;
91
94
  direction?: 'row' | 'col';
92
- repeaterFields?: FieldConfig<RT>;
95
+ repeaterFields?: Array<FieldProps<RT> | FieldProps<RT>[]>;
93
96
  minItems?: number;
94
97
  maxItems?: number;
95
98
  currencyFormat?: Intl.NumberFormatOptions;
@@ -199,6 +202,7 @@ declare const entityToInputOption: (entitiy: any, name?: string, description?: s
199
202
  declare const entitiesToInputOption: (data: any[], optionValue?: string, groupedLabel?: string) => InputOption[];
200
203
  declare const entityToGroupedOption: (entitiy: any, name?: string) => GroupedOption;
201
204
  declare const entitiesToGroupedOption: (data: any[], optionValue?: string) => GroupedOption[];
205
+ declare const handleOnChage: (event: any[] | any, input: FieldProps, field?: ControllerRenderProps<FieldValues, string>) => void;
202
206
 
203
207
  type alertPositionType = 'up' | 'down';
204
208
  interface FormResp<T> {
@@ -454,4 +458,4 @@ declare function TooltipContent({ className, sideOffset, children, ...props }: R
454
458
 
455
459
  declare function cn(...inputs: ClassValue[]): string;
456
460
 
457
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, type ColorCompProps, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldConfig, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, type FormResp, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, Label, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, inputFieldComp, mockFields, useFormField, validationMessages };
461
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, type ColorCompProps, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, type FieldConfig, type FieldProps, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, type FormResp, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, Label, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, mockFields, useFormField, validationMessages };
package/dist/index.mjs CHANGED
@@ -194,6 +194,11 @@ var entitiesToGroupedOption = (data, optionValue = "name") => {
194
194
  }
195
195
  return entities;
196
196
  };
197
+ var handleOnChage = (event, input, field) => {
198
+ console.log("\u{1F680} ~ handleOnChage ~ event:", event);
199
+ if (event) field?.onChange(event);
200
+ input.onChange?.(event);
201
+ };
197
202
 
198
203
  // src/components/custom/form/inputs/base/definitions.ts
199
204
  var flattenFields = (fields) => {
@@ -251,9 +256,11 @@ var InputTypes = /* @__PURE__ */ ((InputTypes2) => {
251
256
  InputTypes2["COMBOBOX"] = "COMBO_BOX";
252
257
  InputTypes2["SORTABLE_LIST"] = "sortable_list";
253
258
  InputTypes2["REPEATER_TABS"] = "repeater_tabs";
259
+ InputTypes2["STRING_LIST"] = "string_list";
254
260
  return InputTypes2;
255
261
  })(InputTypes || {});
256
262
  var inputFieldComp = [
263
+ "string_list" /* STRING_LIST */,
257
264
  "repeater_tabs" /* REPEATER_TABS */,
258
265
  "sortable_list" /* SORTABLE_LIST */,
259
266
  "COMBO_BOX" /* COMBOBOX */,
@@ -1629,13 +1636,14 @@ var GroupedSwitches = ({ options, onChange, input, isSubmitting }) => {
1629
1636
  setAllChecked(checked);
1630
1637
  onChange?.(updated.filter((opt) => opt.checked));
1631
1638
  };
1632
- const handleChildToggle = (option, checked) => {
1639
+ const handleChildToggle = (option, checked, input2) => {
1633
1640
  const updated = switches.map(
1634
1641
  (opt) => opt.id === option.id ? { ...opt, checked } : opt
1635
1642
  );
1636
1643
  setSwitches(updated);
1637
1644
  setAllChecked(updated.every((opt) => opt.checked));
1638
1645
  onChange?.(updated.filter((opt) => opt.checked));
1646
+ handleOnChage(updated.filter((opt) => opt.checked), input2);
1639
1647
  };
1640
1648
  return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ 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: [
1641
1649
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b p-2", children: [
@@ -1653,7 +1661,7 @@ var GroupedSwitches = ({ options, onChange, input, isSubmitting }) => {
1653
1661
  disabled: input.disabled || isSubmitting,
1654
1662
  id: String(opt.id),
1655
1663
  checked: opt?.checked || false,
1656
- onCheckedChange: (checked) => handleChildToggle(opt, checked)
1664
+ onCheckedChange: (checked) => handleChildToggle(opt, checked, input)
1657
1665
  }
1658
1666
  )
1659
1667
  ] }, opt.id))
@@ -1694,7 +1702,7 @@ var AccordionGroupedSwitches = ({ form, input, groups = [], onChange, isSubmitti
1694
1702
  const countCheckedByGroup = (group) => {
1695
1703
  return group.options.filter((opt) => opt.checked).length;
1696
1704
  };
1697
- const handleOptionChange = (field, updatedGroupLabel, updatedOptions) => {
1705
+ const handleOptionChange = (field, updatedGroupLabel, updatedOptions, input2) => {
1698
1706
  const newGroups = groupsState.map(
1699
1707
  (group) => group.label === updatedGroupLabel ? { ...group, options: updatedOptions } : group
1700
1708
  );
@@ -1703,6 +1711,7 @@ var AccordionGroupedSwitches = ({ form, input, groups = [], onChange, isSubmitti
1703
1711
  setSelectedOptions(allChecked);
1704
1712
  field.onChange(allChecked);
1705
1713
  onChange?.(allChecked);
1714
+ handleOnChage(allChecked, input2, field);
1706
1715
  };
1707
1716
  return /* @__PURE__ */ jsx(
1708
1717
  FormField,
@@ -1733,7 +1742,7 @@ var AccordionGroupedSwitches = ({ form, input, groups = [], onChange, isSubmitti
1733
1742
  isSubmitting,
1734
1743
  input,
1735
1744
  options: group.options,
1736
- onChange: (updated) => handleOptionChange(field, group.label, updated)
1745
+ onChange: (updated) => handleOptionChange(field, group.label, updated, input)
1737
1746
  }
1738
1747
  ) })
1739
1748
  ]
@@ -1798,7 +1807,10 @@ var FieldButtonGroup = ({ input, form, isSubmitting, className = "w-full flex-1"
1798
1807
  type: "button",
1799
1808
  className,
1800
1809
  variant: selectedValue === option.value ? "default" : "outline",
1801
- onClick: () => handleSelect(option.value),
1810
+ onClick: () => {
1811
+ handleSelect(option.value);
1812
+ handleOnChage(option.value, input);
1813
+ },
1802
1814
  disabled: isSubmitting,
1803
1815
  children: option.label ?? option.name
1804
1816
  },
@@ -1823,6 +1835,7 @@ var CheckListInput = class extends BaseInput {
1823
1835
  /* @__PURE__ */ jsx(
1824
1836
  Checkbox,
1825
1837
  {
1838
+ onChange: (e) => handleOnChage(e, input),
1826
1839
  disabled: input.disabled || isSubmitting,
1827
1840
  id: String(item[optionValue]),
1828
1841
  checked: value.includes(item[optionValue]),
@@ -1874,7 +1887,7 @@ var FieldCheckbox = ({ input, form, isSubmitting }) => {
1874
1887
  {
1875
1888
  id: input.name,
1876
1889
  checked: field.value,
1877
- onCheckedChange: field.onChange,
1890
+ onCheckedChange: (e) => handleOnChage(e, input, field),
1878
1891
  disabled: input.disabled || isSubmitting,
1879
1892
  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"
1880
1893
  }
@@ -1910,23 +1923,14 @@ var FieldColor = ({ form, input, isSubmitting }) => {
1910
1923
  ColorCmp,
1911
1924
  {
1912
1925
  value: field.value || "#000000",
1913
- onChange: field.onChange,
1926
+ onChange: (event) => {
1927
+ handleOnChage(event, input, field);
1928
+ },
1914
1929
  onBlur: field.onBlur,
1915
1930
  disabled: input.disabled || isSubmitting,
1916
1931
  placeholder: input.placeHolder
1917
1932
  }
1918
- ) : /* @__PURE__ */ jsx(
1919
- "input",
1920
- {
1921
- type: "color",
1922
- value: field.value || "#000000",
1923
- onChange: (e) => field.onChange(e.target.value),
1924
- onBlur: () => field.onBlur(),
1925
- disabled: input.disabled || isSubmitting,
1926
- placeholder: input.placeHolder,
1927
- style: { width: 48, height: 28 }
1928
- }
1929
- ) }),
1933
+ ) : "N/A" }),
1930
1934
  /* @__PURE__ */ jsx(FormDescription, { children: input.description }),
1931
1935
  /* @__PURE__ */ jsx(FormMessage, {})
1932
1936
  ] })
@@ -2147,6 +2151,7 @@ var FieldCombobox = ({ form, input, isSubmitting }) => {
2147
2151
  const newValue = currentValue === value ? "" : currentValue;
2148
2152
  setValue(newValue);
2149
2153
  form.setValue(input.name, newValue);
2154
+ handleOnChage(options.find((o) => getValue(o) === newValue), input);
2150
2155
  input.listConfig?.onOptionChange?.(
2151
2156
  options.find((o) => getValue(o) === newValue)
2152
2157
  );
@@ -2269,6 +2274,7 @@ var FieldCurrency = ({ form, input, isSubmitting }) => {
2269
2274
  setRawValue(newVal);
2270
2275
  const parsed = parseValue(newVal);
2271
2276
  if (parsed !== null) field.onChange(parsed);
2277
+ handleOnChage(parsed, input, field);
2272
2278
  },
2273
2279
  onBlur: (e) => {
2274
2280
  const formatted = formatValue(e.target.value);
@@ -3867,7 +3873,7 @@ var DateInput = class extends BaseInput {
3867
3873
  }, [field.value]);
3868
3874
  const handleSelect = (selectedDate) => {
3869
3875
  setDate(selectedDate);
3870
- field.onChange(selectedDate);
3876
+ handleOnChage(selectedDate, input, field);
3871
3877
  };
3872
3878
  return /* @__PURE__ */ jsxs(FormItem, { children: [
3873
3879
  /* @__PURE__ */ jsx(FormLabel, { children: /* @__PURE__ */ jsx("b", { children: input.label }) }),
@@ -3957,7 +3963,10 @@ var FieldDateTimeInput = ({ form, input, isSubmitting }) => {
3957
3963
  type: "datetime-local",
3958
3964
  value: dateTime,
3959
3965
  disabled: input.disabled || isSubmitting,
3960
- onChange: (e) => handleChange(e.target.value)
3966
+ onChange: (e) => {
3967
+ handleOnChage(e.target.value, input, field);
3968
+ handleChange(e.target.value);
3969
+ }
3961
3970
  }
3962
3971
  ),
3963
3972
  (iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxs(InputGroupAddon, { align: "inline-end", children: [
@@ -4017,6 +4026,7 @@ var FieldFile = ({ form, input, isSubmitting }) => {
4017
4026
  onChange: (e) => {
4018
4027
  field.onChange(e.target.files?.[0]);
4019
4028
  handleFileChange(e);
4029
+ handleOnChage(e.target.files?.[0], input, field);
4020
4030
  }
4021
4031
  }
4022
4032
  ) }),
@@ -4174,7 +4184,7 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
4174
4184
  return /* @__PURE__ */ jsxs(FormItem, { className: input.className, children: [
4175
4185
  /* @__PURE__ */ jsx(FormLabel, { children: /* @__PURE__ */ jsx("b", { children: input.label }) }),
4176
4186
  /* @__PURE__ */ jsx(FormMessage, {}),
4177
- /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 shadow-lg rounded-xl p-3 bg-white", children: [
4187
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 rounded-xl p-3 ", children: [
4178
4188
  pairs.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No pairs have been added yet." }),
4179
4189
  pairs.map((pair, index) => /* @__PURE__ */ jsxs(
4180
4190
  "div",
@@ -4300,7 +4310,10 @@ var FieldMultiSelect = ({ form, input, isSubmitting }) => {
4300
4310
  return /* @__PURE__ */ jsxs(
4301
4311
  CommandItem,
4302
4312
  {
4303
- onSelect: () => toggleOption(value),
4313
+ onSelect: () => {
4314
+ handleOnChage(value, input, field);
4315
+ toggleOption(value);
4316
+ },
4304
4317
  children: [
4305
4318
  /* @__PURE__ */ jsx(
4306
4319
  Check,
@@ -4383,6 +4396,7 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
4383
4396
  if (isNumberField) {
4384
4397
  value = e.target.value === "" ? "" : Number(e.target.value);
4385
4398
  }
4399
+ handleOnChage(value, input, field);
4386
4400
  field.onChange(value);
4387
4401
  }
4388
4402
  }
@@ -4440,7 +4454,7 @@ var FieldOTP = ({ form, input, isSubmitting }) => {
4440
4454
  name: input.name,
4441
4455
  render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
4442
4456
  /* @__PURE__ */ jsx(FormLabel, { children: /* @__PURE__ */ jsx("b", { children: input.label }) }),
4443
- /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(InputOTP, { maxLength: totalPositions.length, ...field, children: /* @__PURE__ */ jsx(InputOTPGroup, { children: totalPositions.map((position) => /* @__PURE__ */ jsx(InputOTPSlot, { index: position }, position)) }) }) }),
4457
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(InputOTP, { maxLength: totalPositions.length, ...field, onChange: (event) => handleOnChage(event, input, field), children: /* @__PURE__ */ jsx(InputOTPGroup, { children: totalPositions.map((position) => /* @__PURE__ */ jsx(InputOTPSlot, { index: position }, position)) }) }) }),
4444
4458
  /* @__PURE__ */ jsx(FormDescription, { children: input.description }),
4445
4459
  /* @__PURE__ */ jsx(FormMessage, {})
4446
4460
  ] })
@@ -4481,7 +4495,7 @@ var FieldRadioGroup = ({ input, form, isSubmitting }) => {
4481
4495
  {
4482
4496
  ...field,
4483
4497
  value: field.value ?? "",
4484
- onValueChange: field.onChange,
4498
+ onValueChange: (e) => handleOnChage(e, input, field),
4485
4499
  className: "space-y-2 mt-3",
4486
4500
  children: options.map((opt, index) => /* @__PURE__ */ jsxs(
4487
4501
  "div",
@@ -4833,7 +4847,7 @@ var FieldSelect = ({ form, input, isSubmitting }) => {
4833
4847
  {
4834
4848
  disabled: input.disabled || isSubmitting || loading,
4835
4849
  onValueChange: (val) => {
4836
- field.onChange(val);
4850
+ handleOnChage(val, input, field);
4837
4851
  setValue(val);
4838
4852
  if (input.listConfig?.onOptionChange) {
4839
4853
  const selectedItem = lista.find(
@@ -4877,7 +4891,7 @@ var SimpleCheckListInput = class extends BaseInput {
4877
4891
  isSubmitting,
4878
4892
  input,
4879
4893
  value: field.value || [],
4880
- onChange: field.onChange
4894
+ onChange: (e) => handleOnChage(e, input, field)
4881
4895
  }
4882
4896
  )
4883
4897
  }
@@ -4899,12 +4913,14 @@ var FieldSimpleCheckList = ({ input, value, onChange, isSubmitting }) => {
4899
4913
  const handleMainToggle = (checked) => {
4900
4914
  const updated = options.map((opt) => ({ ...opt, checked }));
4901
4915
  setOptions(updated);
4916
+ handleOnChage(updated, input);
4902
4917
  onChange(updated);
4903
4918
  };
4904
4919
  const handleChildToggle = (option, checked) => {
4905
4920
  const updated = options.map(
4906
4921
  (opt) => opt.id === option.id ? { ...opt, checked } : opt
4907
4922
  );
4923
+ handleOnChage(updated, input);
4908
4924
  setOptions(updated);
4909
4925
  onChange(updated);
4910
4926
  };
@@ -5146,6 +5162,102 @@ function SortableWrapper({
5146
5162
  }
5147
5163
  );
5148
5164
  }
5165
+ var StringValueListInput = class extends BaseInput {
5166
+ render() {
5167
+ const { input, form, isSubmitting } = this;
5168
+ return /* @__PURE__ */ jsx(
5169
+ FieldStringValueList,
5170
+ {
5171
+ input,
5172
+ form,
5173
+ isSubmitting
5174
+ }
5175
+ );
5176
+ }
5177
+ };
5178
+ var FieldStringValueList = ({ form, input, isSubmitting }) => {
5179
+ const fieldName = input.name;
5180
+ useEffect(() => {
5181
+ const current = form.getValues(fieldName);
5182
+ if (!Array.isArray(current)) {
5183
+ form.setValue(fieldName, []);
5184
+ }
5185
+ }, [form, fieldName]);
5186
+ const handleAddItem = () => {
5187
+ const current = form.getValues(fieldName) || [];
5188
+ form.setValue(fieldName, [...current, ""]);
5189
+ };
5190
+ const handleRemoveItem = (index) => {
5191
+ const current = form.getValues(fieldName) || [];
5192
+ const updated = current.filter((_, i) => i !== index);
5193
+ form.setValue(fieldName, updated);
5194
+ };
5195
+ const handleChange = (index, newValue) => {
5196
+ const current = form.getValues(fieldName) || [];
5197
+ const updated = current.map(
5198
+ (item, i) => i === index ? newValue : item
5199
+ );
5200
+ form.setValue(fieldName, updated);
5201
+ };
5202
+ return /* @__PURE__ */ jsx(
5203
+ FormField,
5204
+ {
5205
+ control: form.control,
5206
+ name: fieldName,
5207
+ render: () => {
5208
+ const items = form.watch(fieldName) || [];
5209
+ return /* @__PURE__ */ jsxs(FormItem, { className: input.className, children: [
5210
+ /* @__PURE__ */ jsx(FormLabel, { children: /* @__PURE__ */ jsx("b", { children: input.label }) }),
5211
+ /* @__PURE__ */ jsx(FormMessage, {}),
5212
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 rounded-xl ", children: [
5213
+ items.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No items have been added yet." }),
5214
+ items.map((value, index) => /* @__PURE__ */ jsxs(
5215
+ "div",
5216
+ {
5217
+ className: "flex gap-2 items-center",
5218
+ children: [
5219
+ /* @__PURE__ */ jsx(
5220
+ Input,
5221
+ {
5222
+ placeholder: `Item ${index + 1}`,
5223
+ value,
5224
+ disabled: isSubmitting,
5225
+ onChange: (e) => handleChange(index, e.target.value)
5226
+ }
5227
+ ),
5228
+ input.isRemovebleOption && /* @__PURE__ */ jsx(
5229
+ Button,
5230
+ {
5231
+ type: "button",
5232
+ variant: "destructive",
5233
+ size: "icon",
5234
+ onClick: () => handleRemoveItem(index),
5235
+ disabled: isSubmitting,
5236
+ children: /* @__PURE__ */ jsx(Trash2, { size: 18 })
5237
+ }
5238
+ )
5239
+ ]
5240
+ },
5241
+ index
5242
+ )),
5243
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end mt-2", children: /* @__PURE__ */ jsx(
5244
+ Button,
5245
+ {
5246
+ type: "button",
5247
+ variant: "outline",
5248
+ size: "sm",
5249
+ onClick: handleAddItem,
5250
+ disabled: isSubmitting,
5251
+ children: /* @__PURE__ */ jsx(Plus, { size: 18, className: "mr-1" })
5252
+ }
5253
+ ) })
5254
+ ] }) }),
5255
+ input.description && /* @__PURE__ */ jsx(FormDescription, { children: input.description })
5256
+ ] });
5257
+ }
5258
+ }
5259
+ );
5260
+ };
5149
5261
  var SwitchInput = class extends BaseInput {
5150
5262
  render() {
5151
5263
  const { input, form, isSubmitting } = this;
@@ -5169,7 +5281,7 @@ var FieldSwitch = ({ input, form, isSubmitting }) => {
5169
5281
  Switch,
5170
5282
  {
5171
5283
  checked: field.value,
5172
- onCheckedChange: field.onChange,
5284
+ onCheckedChange: (event) => handleOnChage(event, input, field),
5173
5285
  "aria-disabled": true,
5174
5286
  disabled: input.disabled || isSubmitting
5175
5287
  }
@@ -5196,8 +5308,9 @@ var FieldTags = ({ input, form, isSubmitting }) => {
5196
5308
  /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
5197
5309
  TagsInput,
5198
5310
  {
5311
+ input,
5199
5312
  value: field.value ?? [],
5200
- onValueChange: field.onChange,
5313
+ onValueChange: (event) => handleOnChage(event, input, field),
5201
5314
  placeholder: "Enter for add tag"
5202
5315
  }
5203
5316
  ) }),
@@ -5212,6 +5325,7 @@ var SPLITTER_REGEX = /[\n#?=&\t,./-]+/;
5212
5325
  var FORMATTING_REGEX = /^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g;
5213
5326
  var TagsInput = React3__default.forwardRef(
5214
5327
  ({
5328
+ input,
5215
5329
  value,
5216
5330
  onValueChange,
5217
5331
  placeholder,
@@ -5226,7 +5340,7 @@ var TagsInput = React3__default.forwardRef(
5226
5340
  const parseMinItems = minItems ?? 0;
5227
5341
  const parseMaxItems = maxItems ?? Infinity;
5228
5342
  const addTag = (val) => {
5229
- if (!value.includes(val) && value.length < parseMaxItems) {
5343
+ if (!value.includes(val) && value.length < parseMaxItems || input.withDuplicatTag) {
5230
5344
  onValueChange([...value, val]);
5231
5345
  }
5232
5346
  };
@@ -5301,7 +5415,18 @@ function FieldTextArea({ form, input, isSubmitting }) {
5301
5415
  name: input.name,
5302
5416
  render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { className: "shadow-lg", children: [
5303
5417
  /* @__PURE__ */ jsx(FormLabel, { children: /* @__PURE__ */ jsx("b", { children: input.label }) }),
5304
- /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Textarea, { className: "min-w-[260px] bg-white", placeholder: input.placeHolder, ...field, disabled: input.disabled || isSubmitting }) }),
5418
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
5419
+ Textarea,
5420
+ {
5421
+ className: "min-w-[260px] bg-white",
5422
+ placeholder: input.placeHolder,
5423
+ ...field,
5424
+ onChange: (event) => {
5425
+ handleOnChage(event, input, field);
5426
+ },
5427
+ disabled: input.disabled || isSubmitting
5428
+ }
5429
+ ) }),
5305
5430
  input.description && /* @__PURE__ */ jsx(FormDescription, { children: input.description }),
5306
5431
  /* @__PURE__ */ jsx(FormMessage, {})
5307
5432
  ] })
@@ -5332,6 +5457,7 @@ var FieldText = ({ input, form, isSubmitting }) => {
5332
5457
  placeholder: input.placeHolder,
5333
5458
  ...field,
5334
5459
  type,
5460
+ onChange: (e) => handleOnChage(e, input, field),
5335
5461
  disabled: input.disabled || isSubmitting
5336
5462
  }
5337
5463
  ) }),
@@ -5382,6 +5508,7 @@ var FieldTimeInput = ({ form, input, isSubmitting }) => {
5382
5508
  if (validNow !== isValid2) setIsValid(validNow);
5383
5509
  const handleChange = (val) => {
5384
5510
  setTime(val);
5511
+ handleOnChage(val, input, field);
5385
5512
  field.onChange(val);
5386
5513
  };
5387
5514
  return /* @__PURE__ */ jsxs(FormItem, { className: input.className, children: [
@@ -5442,6 +5569,7 @@ var inputMap = {
5442
5569
  ["COMBO_BOX" /* COMBOBOX */]: ComboboxInput,
5443
5570
  ["sortable_list" /* SORTABLE_LIST */]: SortableListInput,
5444
5571
  ["repeater_tabs" /* REPEATER_TABS */]: RepeaterTabsInput,
5572
+ ["string_list" /* STRING_LIST */]: StringValueListInput,
5445
5573
  //ToDos: ============================================================
5446
5574
  ["slider" /* SLIDER */]: SliderInput,
5447
5575
  //ToDo: // PENDIENTE ... VISUALMENTE NO SE VE BIEN.!!!
@@ -5920,6 +6048,6 @@ var InputList = ({ handleAddInput, inputsTypes }) => {
5920
6048
  }) });
5921
6049
  };
5922
6050
 
5923
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, InputTypes, Label, NumberInput, OTPInput2 as OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, inputFieldComp, mockFields, useFormField, validationMessages };
6051
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, ColorCnInput, ColorInput, CustomAlert, DateInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, FileInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormItem, FormLabel, FormMessage, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, InputTypes, Label, NumberInput, OTPInput2 as OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Switch, SwitchInput, TextAreaInput, TextInput, TextInputType, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, mockFields, useFormField, validationMessages };
5924
6052
  //# sourceMappingURL=index.mjs.map
5925
6053
  //# sourceMappingURL=index.mjs.map