shadcn-zod-formkit 1.30.0 → 1.31.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
@@ -28,13 +28,13 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
28
28
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
29
29
  import { ClassValue } from 'clsx';
30
30
 
31
- interface Props$i {
31
+ interface Props$j {
32
32
  title: string;
33
33
  description: string | ReactNode;
34
34
  className?: string;
35
35
  variant?: "info" | "warning" | "error" | "success";
36
36
  }
37
- declare const CustomAlert: ({ title, description, className, variant, }: Props$i) => react_jsx_runtime.JSX.Element;
37
+ declare const CustomAlert: ({ title, description, className, variant, }: Props$j) => react_jsx_runtime.JSX.Element;
38
38
 
39
39
  declare const validationMessages: {
40
40
  required: string;
@@ -88,6 +88,8 @@ type FieldConfig<T, RT = Record<string, any>> = FieldProps<T, RT> | FieldConfig<
88
88
  interface FieldProps<T = Record<string, any>, RT = Record<string, any>> {
89
89
  name: keyof T;
90
90
  label: string;
91
+ showWhen?: (values: Record<string, any>) => boolean;
92
+ step?: number;
91
93
  withAddBtn?: boolean;
92
94
  form?: UseFormReturn<any>;
93
95
  isRemovebleOption?: boolean;
@@ -217,7 +219,7 @@ interface FormResp<T> {
217
219
  form?: UseFormReturn<any>;
218
220
  data: T;
219
221
  }
220
- interface Props$h<T extends Record<string, any>> {
222
+ interface Props$i<T extends Record<string, any>> {
221
223
  showIcon?: boolean;
222
224
  showFormHeader?: boolean;
223
225
  formTitle: string;
@@ -241,8 +243,16 @@ interface Props$h<T extends Record<string, any>> {
241
243
  children?: ReactNode;
242
244
  childrenHeader?: ReactNode;
243
245
  listBtnConfig?: BtnConfig[];
246
+ debug?: boolean;
244
247
  }
245
- declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onAnyFieldChange, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, listBtnConfig, submitBtnLabel, submitBtnLabelSubmiting, withFormWrapper, btnGroupDirection, withSubmitBtn }: Props$h<T>) => react_jsx_runtime.JSX.Element;
248
+ declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onAnyFieldChange, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, listBtnConfig, submitBtnLabel, submitBtnLabelSubmiting, withFormWrapper, btnGroupDirection, withSubmitBtn, debug }: Props$i<T>) => react_jsx_runtime.JSX.Element;
249
+
250
+ interface Props$h<T> {
251
+ onSubmit?: (resp: FormResp<T>) => void;
252
+ fields: FieldConfig<T>[];
253
+ record: any;
254
+ }
255
+ declare const WizardForm: <T extends Record<string, any>>({ fields, record, onSubmit, }: Props$h<T>) => react_jsx_runtime.JSX.Element;
246
256
 
247
257
  declare const DynamicFormExample: () => react_jsx_runtime.JSX.Element;
248
258
  declare const mockFields: Array<FieldProps | FieldProps[]>;
@@ -255,12 +265,6 @@ interface Props$g<T extends Record<string, any> = Record<string, any>> {
255
265
  className?: string;
256
266
  gap?: string;
257
267
  }
258
- /**
259
- * 📋 FormFieldsGrid
260
- * Componente reutilizable para renderizar campos en una cuadrícula flexible.
261
- * - Si un elemento del arreglo es un solo FieldProps → muestra en una línea.
262
- * - Si es un arreglo de FieldProps → los muestra en una misma fila.
263
- */
264
268
  declare const FormFieldsGrid: <T extends Record<string, any> = Record<string, any>>({ fields, form, isPending, readOnly, className, gap, }: Props$g<T>) => JSX.Element;
265
269
 
266
270
  interface Props$f<T extends FieldValues = Record<string, any>> {
@@ -751,4 +755,4 @@ declare function TooltipContent({ className, sideOffset, children, ...props }: R
751
755
 
752
756
  declare function cn(...inputs: ClassValue[]): string;
753
757
 
754
- export { Accordion, AccordionContent, AccordionGroupedSwitchInput, AccordionGroupedSwitches, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, ButtonGroup, ButtonGroupInput, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, CheckboxInput, ColorCnInput, type ColorCompProps, ColorInput, ComboboxInput, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CurrencyInput, CustomAlert, CustomInputGroup, DateInput, DateTimeInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, Field, FieldButtonGroup, type FieldConfig, FieldContent, FieldCurrency, FieldDateTimeInput, FieldDescription, FieldError, FieldFileMultiUpload, FieldGroup, FieldKeyValueList, FieldLabel, FieldLegend, type FieldProps, FieldRepeater, FieldSeparator, FieldSet, FieldSimpleCheckList, FieldSlider, FieldStringValueList, FieldTextGroup, FieldTimeInput, FieldTitle, FileInput, FileMultiUploadInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormFieldsGrid, FormItem, FormLabel, FormMessage, type FormResp, GenericFilter, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, KeyValueListInput, Label, MultiSelectInput, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, RadioGroup, RadioGroupInput, RadioGroupItem, RepeaterInput, RepeaterTabsInput, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SimpleCheckListInput, Slider, SliderInput, SortableListInput, StringValueListInput, Switch, SwitchInput, Tabs, TabsContent, TabsList, TabsTrigger, TagInput, TextAreaInput, TextInput, TextInputGroup, TextInputType, Textarea, TimeInput, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonGroupVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, isValidField, mockFields, useFormField, validationMessages };
758
+ export { Accordion, AccordionContent, AccordionGroupedSwitchInput, AccordionGroupedSwitches, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, ButtonGroup, ButtonGroupInput, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, CheckboxInput, ColorCnInput, type ColorCompProps, ColorInput, ComboboxInput, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CurrencyInput, CustomAlert, CustomInputGroup, DateInput, DateTimeInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, Field, FieldButtonGroup, type FieldConfig, FieldContent, FieldCurrency, FieldDateTimeInput, FieldDescription, FieldError, FieldFileMultiUpload, FieldGroup, FieldKeyValueList, FieldLabel, FieldLegend, type FieldProps, FieldRepeater, FieldSeparator, FieldSet, FieldSimpleCheckList, FieldSlider, FieldStringValueList, FieldTextGroup, FieldTimeInput, FieldTitle, FileInput, FileMultiUploadInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormFieldsGrid, FormItem, FormLabel, FormMessage, type FormResp, GenericFilter, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, KeyValueListInput, Label, MultiSelectInput, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, RadioGroup, RadioGroupInput, RadioGroupItem, RepeaterInput, RepeaterTabsInput, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SimpleCheckListInput, Slider, SliderInput, SortableListInput, StringValueListInput, Switch, SwitchInput, Tabs, TabsContent, TabsList, TabsTrigger, TagInput, TextAreaInput, TextInput, TextInputGroup, TextInputType, Textarea, TimeInput, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, WizardForm, badgeVariants, buttonGroupVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, isValidField, mockFields, useFormField, validationMessages };
package/dist/index.d.ts CHANGED
@@ -28,13 +28,13 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
28
28
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
29
29
  import { ClassValue } from 'clsx';
30
30
 
31
- interface Props$i {
31
+ interface Props$j {
32
32
  title: string;
33
33
  description: string | ReactNode;
34
34
  className?: string;
35
35
  variant?: "info" | "warning" | "error" | "success";
36
36
  }
37
- declare const CustomAlert: ({ title, description, className, variant, }: Props$i) => react_jsx_runtime.JSX.Element;
37
+ declare const CustomAlert: ({ title, description, className, variant, }: Props$j) => react_jsx_runtime.JSX.Element;
38
38
 
39
39
  declare const validationMessages: {
40
40
  required: string;
@@ -88,6 +88,8 @@ type FieldConfig<T, RT = Record<string, any>> = FieldProps<T, RT> | FieldConfig<
88
88
  interface FieldProps<T = Record<string, any>, RT = Record<string, any>> {
89
89
  name: keyof T;
90
90
  label: string;
91
+ showWhen?: (values: Record<string, any>) => boolean;
92
+ step?: number;
91
93
  withAddBtn?: boolean;
92
94
  form?: UseFormReturn<any>;
93
95
  isRemovebleOption?: boolean;
@@ -217,7 +219,7 @@ interface FormResp<T> {
217
219
  form?: UseFormReturn<any>;
218
220
  data: T;
219
221
  }
220
- interface Props$h<T extends Record<string, any>> {
222
+ interface Props$i<T extends Record<string, any>> {
221
223
  showIcon?: boolean;
222
224
  showFormHeader?: boolean;
223
225
  formTitle: string;
@@ -241,8 +243,16 @@ interface Props$h<T extends Record<string, any>> {
241
243
  children?: ReactNode;
242
244
  childrenHeader?: ReactNode;
243
245
  listBtnConfig?: BtnConfig[];
246
+ debug?: boolean;
244
247
  }
245
- declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onAnyFieldChange, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, listBtnConfig, submitBtnLabel, submitBtnLabelSubmiting, withFormWrapper, btnGroupDirection, withSubmitBtn }: Props$h<T>) => react_jsx_runtime.JSX.Element;
248
+ declare const DynamicForm: <T extends Record<string, any>>({ formTitle, formSubTitle, fields, readOnly, record, onAnyFieldChange, onSubmit, onClick, extraValidations, children, childrenHeader, showIcon, showFormHeader, withErrorsAlert, errorAlertPosition, withCard, submitBtnClass, listBtnConfig, submitBtnLabel, submitBtnLabelSubmiting, withFormWrapper, btnGroupDirection, withSubmitBtn, debug }: Props$i<T>) => react_jsx_runtime.JSX.Element;
249
+
250
+ interface Props$h<T> {
251
+ onSubmit?: (resp: FormResp<T>) => void;
252
+ fields: FieldConfig<T>[];
253
+ record: any;
254
+ }
255
+ declare const WizardForm: <T extends Record<string, any>>({ fields, record, onSubmit, }: Props$h<T>) => react_jsx_runtime.JSX.Element;
246
256
 
247
257
  declare const DynamicFormExample: () => react_jsx_runtime.JSX.Element;
248
258
  declare const mockFields: Array<FieldProps | FieldProps[]>;
@@ -255,12 +265,6 @@ interface Props$g<T extends Record<string, any> = Record<string, any>> {
255
265
  className?: string;
256
266
  gap?: string;
257
267
  }
258
- /**
259
- * 📋 FormFieldsGrid
260
- * Componente reutilizable para renderizar campos en una cuadrícula flexible.
261
- * - Si un elemento del arreglo es un solo FieldProps → muestra en una línea.
262
- * - Si es un arreglo de FieldProps → los muestra en una misma fila.
263
- */
264
268
  declare const FormFieldsGrid: <T extends Record<string, any> = Record<string, any>>({ fields, form, isPending, readOnly, className, gap, }: Props$g<T>) => JSX.Element;
265
269
 
266
270
  interface Props$f<T extends FieldValues = Record<string, any>> {
@@ -751,4 +755,4 @@ declare function TooltipContent({ className, sideOffset, children, ...props }: R
751
755
 
752
756
  declare function cn(...inputs: ClassValue[]): string;
753
757
 
754
- export { Accordion, AccordionContent, AccordionGroupedSwitchInput, AccordionGroupedSwitches, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, ButtonGroup, ButtonGroupInput, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, CheckboxInput, ColorCnInput, type ColorCompProps, ColorInput, ComboboxInput, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CurrencyInput, CustomAlert, CustomInputGroup, DateInput, DateTimeInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, Field, FieldButtonGroup, type FieldConfig, FieldContent, FieldCurrency, FieldDateTimeInput, FieldDescription, FieldError, FieldFileMultiUpload, FieldGroup, FieldKeyValueList, FieldLabel, FieldLegend, type FieldProps, FieldRepeater, FieldSeparator, FieldSet, FieldSimpleCheckList, FieldSlider, FieldStringValueList, FieldTextGroup, FieldTimeInput, FieldTitle, FileInput, FileMultiUploadInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormFieldsGrid, FormItem, FormLabel, FormMessage, type FormResp, GenericFilter, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, KeyValueListInput, Label, MultiSelectInput, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, RadioGroup, RadioGroupInput, RadioGroupItem, RepeaterInput, RepeaterTabsInput, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SimpleCheckListInput, Slider, SliderInput, SortableListInput, StringValueListInput, Switch, SwitchInput, Tabs, TabsContent, TabsList, TabsTrigger, TagInput, TextAreaInput, TextInput, TextInputGroup, TextInputType, Textarea, TimeInput, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonGroupVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, isValidField, mockFields, useFormField, validationMessages };
758
+ export { Accordion, AccordionContent, AccordionGroupedSwitchInput, AccordionGroupedSwitches, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, type BtnConfig, Button, ButtonGroup, ButtonGroupInput, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, CheckboxInput, ColorCnInput, type ColorCompProps, ColorInput, ComboboxInput, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CurrencyInput, CustomAlert, CustomInputGroup, DateInput, DateTimeInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, Field, FieldButtonGroup, type FieldConfig, FieldContent, FieldCurrency, FieldDateTimeInput, FieldDescription, FieldError, FieldFileMultiUpload, FieldGroup, FieldKeyValueList, FieldLabel, FieldLegend, type FieldProps, FieldRepeater, FieldSeparator, FieldSet, FieldSimpleCheckList, FieldSlider, FieldStringValueList, FieldTextGroup, FieldTimeInput, FieldTitle, FileInput, FileMultiUploadInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormFieldsGrid, FormItem, FormLabel, FormMessage, type FormResp, GenericFilter, type GroupedOption, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, type InputOption, type InputSetup, InputTypes, KeyValueListInput, Label, MultiSelectInput, NumberInput, OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type Props, RadioGroup, RadioGroupInput, RadioGroupItem, RepeaterInput, RepeaterTabsInput, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SimpleCheckListInput, Slider, SliderInput, SortableListInput, StringValueListInput, Switch, SwitchInput, Tabs, TabsContent, TabsList, TabsTrigger, TagInput, TextAreaInput, TextInput, TextInputGroup, TextInputType, Textarea, TimeInput, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, WizardForm, badgeVariants, buttonGroupVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, isValidField, mockFields, useFormField, validationMessages };
package/dist/index.mjs CHANGED
@@ -2184,6 +2184,8 @@ var ColorInput = class extends BaseInput {
2184
2184
  }
2185
2185
  };
2186
2186
  var PRESET_COLORS = [
2187
+ "#9A275A",
2188
+ // QuinaMagenta
2187
2189
  "#800000",
2188
2190
  // Maroon
2189
2191
  "#ef4444",
@@ -2194,6 +2196,8 @@ var PRESET_COLORS = [
2194
2196
  // yellow
2195
2197
  "#22c55e",
2196
2198
  // green
2199
+ "#99EDCC",
2200
+ // Aquamarine
2197
2201
  "#00FF00",
2198
2202
  // lime
2199
2203
  "#00FFFF",
@@ -2212,10 +2216,12 @@ var PRESET_COLORS = [
2212
2216
  // pink
2213
2217
  "#64748b",
2214
2218
  // slate
2219
+ "#000000",
2220
+ // black
2215
2221
  "#808080",
2216
2222
  // Gray
2217
- "#000000"
2218
- // black
2223
+ "#FFFFFF"
2224
+ // White
2219
2225
  ];
2220
2226
  var FieldColor = ({ form, input, isSubmitting }) => {
2221
2227
  const [ColorCmp, _setColorCmp] = useState(ColorComp);
@@ -2268,13 +2274,13 @@ var ColorComp = React3__default.forwardRef(
2268
2274
  }
2269
2275
  };
2270
2276
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
2271
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2 p-2", children: PRESET_COLORS.map((presetColor) => /* @__PURE__ */ jsx(
2277
+ /* @__PURE__ */ jsx("div", { className: "flex flex-row gap-2 p-2", children: PRESET_COLORS.map((presetColor) => /* @__PURE__ */ jsx(
2272
2278
  "button",
2273
2279
  {
2274
2280
  type: "button",
2275
2281
  disabled,
2276
2282
  className: cn(
2277
- "size-6 rounded-md border-2 transition-all hover:scale-110 disabled:opacity-50 disabled:cursor-not-allowed",
2283
+ "flex-1 size-4 shadow-lg rounded-md border-2 border-black transition-all hover:scale-110 disabled:opacity-50 disabled:cursor-not-allowed",
2278
2284
  color.hex === presetColor ? "border-foreground ring-2 ring-foreground/20" : "border-border hover:border-foreground/50"
2279
2285
  ),
2280
2286
  style: { backgroundColor: presetColor },
@@ -4715,7 +4721,7 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
4715
4721
  ] }),
4716
4722
  /* @__PURE__ */ jsxs(ButtonGroup, { className: "w-full", children: [
4717
4723
  /* @__PURE__ */ jsx(ButtonGroupText, { asChild: true, children: /* @__PURE__ */ jsx(Label$1, { htmlFor: "value", children: "Value" }) }),
4718
- /* @__PURE__ */ jsx(InputGroup, { children: /* @__PURE__ */ jsx(
4724
+ /* @__PURE__ */ jsx(
4719
4725
  CustomInputGroup,
4720
4726
  {
4721
4727
  autoValidate: true,
@@ -4726,7 +4732,7 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
4726
4732
  onChange: (e) => handleChange(index, "value", e.target.value),
4727
4733
  form
4728
4734
  }
4729
- ) })
4735
+ )
4730
4736
  ] }),
4731
4737
  input.isRemovebleOption && /* @__PURE__ */ jsx(
4732
4738
  Button,
@@ -5726,7 +5732,7 @@ var FieldSwitch = ({ input, form, isSubmitting }) => {
5726
5732
  onCheckedChange: (event) => {
5727
5733
  handleOnChage(event, input, field);
5728
5734
  },
5729
- disabled: false
5735
+ disabled: input.disabled || isSubmitting
5730
5736
  }
5731
5737
  ) })
5732
5738
  ] }) })
@@ -6123,6 +6129,16 @@ var getFieldLabel = (fieldErrorKey, fields) => {
6123
6129
  return foundField?.label ?? fieldErrorKey;
6124
6130
  };
6125
6131
  var isRenderableChild = (c) => c !== void 0 && c !== null && typeof c !== "function";
6132
+ var shouldShowField = (field, values) => {
6133
+ if (typeof field.showWhen === "function") {
6134
+ try {
6135
+ return !!field.showWhen(values);
6136
+ } catch {
6137
+ return true;
6138
+ }
6139
+ }
6140
+ return true;
6141
+ };
6126
6142
  var FormFieldsGrid = ({
6127
6143
  fields,
6128
6144
  form,
@@ -6131,47 +6147,54 @@ var FormFieldsGrid = ({
6131
6147
  className = "",
6132
6148
  gap = "gap-2"
6133
6149
  }) => {
6134
- return /* @__PURE__ */ jsx("div", { className: `w-full grid grid-cols-1 ${gap} ${className}`, children: fields.map(
6135
- (inputOrGroup, idx) => Array.isArray(inputOrGroup) ? /* @__PURE__ */ jsx(
6136
- "div",
6137
- {
6138
- className: "w-full flex flex-row items-start gap-4 py-3",
6139
- children: inputOrGroup.map((field, subIdx) => {
6140
- const fieldCopy = {
6141
- ...field,
6142
- disabled: readOnly ? true : field.disabled
6143
- };
6144
- const renderInlineChild = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
6145
- const renderInlineChildDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
6146
- return /* @__PURE__ */ jsxs("div", { className: "w-full px-2", children: [
6147
- renderInlineChild && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children }),
6148
- InputFactory.create(fieldCopy, form, isPending),
6149
- renderInlineChildDown && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children })
6150
- ] }, `field-${idx}-${subIdx}`);
6151
- })
6152
- },
6153
- `field-group-${idx}`
6154
- ) : /* @__PURE__ */ jsx(
6150
+ const values = form.watch();
6151
+ return /* @__PURE__ */ jsx("div", { className: `w-full grid grid-cols-1 ${gap} ${className}`, children: fields.map((inputOrGroup, idx) => {
6152
+ if (Array.isArray(inputOrGroup)) {
6153
+ const visibleFields = inputOrGroup.filter(
6154
+ (f) => shouldShowField(f, values)
6155
+ );
6156
+ if (visibleFields.length === 0) return null;
6157
+ return /* @__PURE__ */ jsx(
6158
+ "div",
6159
+ {
6160
+ className: "w-full flex flex-row items-start gap-4 py-3",
6161
+ children: visibleFields.map((field, subIdx) => {
6162
+ const fieldCopy2 = {
6163
+ ...field,
6164
+ disabled: readOnly ? true : field.disabled
6165
+ };
6166
+ const renderUp2 = fieldCopy2.childrenPosition !== "down" && isRenderableChild(fieldCopy2.children);
6167
+ const renderDown2 = fieldCopy2.childrenPosition === "down" && isRenderableChild(fieldCopy2.children);
6168
+ return /* @__PURE__ */ jsxs("div", { className: "w-full px-2", children: [
6169
+ renderUp2 && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy2.children }),
6170
+ InputFactory.create(fieldCopy2, form, isPending),
6171
+ renderDown2 && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy2.children })
6172
+ ] }, `field-${idx}-${subIdx}`);
6173
+ })
6174
+ },
6175
+ `field-group-${idx}`
6176
+ );
6177
+ }
6178
+ if (!shouldShowField(inputOrGroup, values)) return null;
6179
+ const fieldCopy = {
6180
+ ...inputOrGroup,
6181
+ disabled: readOnly ? true : inputOrGroup.disabled
6182
+ };
6183
+ const renderUp = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
6184
+ const renderDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
6185
+ return /* @__PURE__ */ jsxs(
6155
6186
  "div",
6156
6187
  {
6157
6188
  className: "flex flex-col justify-between py-3 w-full px-2",
6158
- children: (() => {
6159
- const fieldCopy = {
6160
- ...inputOrGroup,
6161
- disabled: readOnly ? true : inputOrGroup.disabled
6162
- };
6163
- const renderUp = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
6164
- const renderDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
6165
- return /* @__PURE__ */ jsxs(Fragment, { children: [
6166
- renderUp && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children }),
6167
- InputFactory.create(fieldCopy, form, isPending),
6168
- renderDown && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children })
6169
- ] });
6170
- })()
6189
+ children: [
6190
+ renderUp && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children }),
6191
+ InputFactory.create(fieldCopy, form, isPending),
6192
+ renderDown && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children })
6193
+ ]
6171
6194
  },
6172
6195
  `field-single-${idx}`
6173
- )
6174
- ) });
6196
+ );
6197
+ }) });
6175
6198
  };
6176
6199
  var DynamicForm = ({
6177
6200
  formTitle,
@@ -6196,7 +6219,8 @@ var DynamicForm = ({
6196
6219
  submitBtnLabelSubmiting = "Guardando...",
6197
6220
  withFormWrapper = true,
6198
6221
  btnGroupDirection = "flex-end",
6199
- withSubmitBtn = true
6222
+ withSubmitBtn = true,
6223
+ debug = false
6200
6224
  }) => {
6201
6225
  const [isPending, startTransition] = useTransition();
6202
6226
  const schema = useMemo(() => {
@@ -6223,7 +6247,7 @@ var DynamicForm = ({
6223
6247
  if (!onClick) return;
6224
6248
  const isValid2 = await form.trigger();
6225
6249
  if (!isValid2) return;
6226
- const data = form.getValues();
6250
+ const data = form.watch();
6227
6251
  const resp = { data, form };
6228
6252
  onClick(resp);
6229
6253
  };
@@ -6308,16 +6332,136 @@ var DynamicForm = ({
6308
6332
  if (!withCard) return formContent;
6309
6333
  return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { children: formContent }) });
6310
6334
  };
6311
- var FormWrapper = ({ form, handleSubmit, children, readOnly }) => {
6312
- return /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsx(
6335
+ var FormWrapper = ({ form, handleSubmit, children, readOnly, debug }) => {
6336
+ const allValues = form.watch();
6337
+ return /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs(
6313
6338
  "form",
6314
6339
  {
6315
6340
  onSubmit: form.handleSubmit(handleSubmit),
6316
6341
  className: `flex flex-col gap-2 ${readOnly ? "opacity-70 pointer-events-none select-none" : ""}`,
6317
- children
6342
+ children: [
6343
+ children,
6344
+ debug && /* @__PURE__ */ jsx("pre", { className: "mt-4 p-3 bg-muted text-xs rounded", children: JSON.stringify(allValues, null, 2) })
6345
+ ]
6318
6346
  }
6319
6347
  ) });
6320
6348
  };
6349
+ function Stepper({ steps, currentStep, clickable = false, onStepClick }) {
6350
+ const handleStepClick = (stepNumber) => {
6351
+ if (clickable && onStepClick) {
6352
+ onStepClick(stepNumber);
6353
+ }
6354
+ };
6355
+ return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx("div", { className: "flex flex-row gap-4 items-center justify-around", children: steps.map((step, index) => {
6356
+ const stepNumber = index + 1;
6357
+ const isCompleted = stepNumber < currentStep;
6358
+ const isCurrent = stepNumber === currentStep;
6359
+ const isUpcoming = stepNumber > currentStep;
6360
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center", children: [
6361
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
6362
+ /* @__PURE__ */ jsx(
6363
+ "div",
6364
+ {
6365
+ onClick: () => handleStepClick(stepNumber),
6366
+ className: cn(
6367
+ "flex size-10 items-center shadow-lg justify-center rounded-full border-2 transition-all duration-300",
6368
+ isCompleted && "border-primary bg-primary text-primary-foreground",
6369
+ isCurrent && "border-primary bg-background text-primary scale-110",
6370
+ isUpcoming && "border-muted-foreground/60 bg-background border-b text-muted-foreground",
6371
+ clickable && "cursor-pointer hover:scale-125 hover:shadow-xl",
6372
+ !clickable && "cursor-default"
6373
+ ),
6374
+ children: isCompleted ? /* @__PURE__ */ jsx(Check, { className: "size-5" }) : /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: stepNumber })
6375
+ }
6376
+ ),
6377
+ step.title && /* @__PURE__ */ jsxs("div", { className: "mt-3 text-center", children: [
6378
+ /* @__PURE__ */ jsx(
6379
+ "p",
6380
+ {
6381
+ className: cn(
6382
+ "text-sm font-medium transition-colors",
6383
+ (isCompleted || isCurrent) && "text-foreground",
6384
+ isUpcoming && "text-muted-foreground"
6385
+ ),
6386
+ children: step.title
6387
+ }
6388
+ ),
6389
+ step.description && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground max-w-[120px]", children: step.description })
6390
+ ] })
6391
+ ] }),
6392
+ index < steps.length - 1 && /* @__PURE__ */ jsx("div", { className: "mx-2 flex-1 mb-8", children: /* @__PURE__ */ jsx(
6393
+ "div",
6394
+ {
6395
+ className: cn(
6396
+ "h-0.5 w-full transition-all duration-300",
6397
+ stepNumber < currentStep ? "bg-primary" : "bg-muted-foreground/30"
6398
+ )
6399
+ }
6400
+ ) })
6401
+ ] }, index);
6402
+ }) }) });
6403
+ }
6404
+ var WizardForm = ({
6405
+ fields,
6406
+ record,
6407
+ onSubmit
6408
+ }) => {
6409
+ const [currentStep, setCurrentStep] = useState(1);
6410
+ const flattenFields4 = (list) => list.flatMap((f) => Array.isArray(f) ? flattenFields4(f) : f);
6411
+ const allFields = flattenFields4(fields);
6412
+ const totalSteps = allFields.reduce(
6413
+ (max, f) => Math.max(max, f.step ?? 1),
6414
+ 1
6415
+ );
6416
+ const stepFields = allFields.filter((f) => (f.step ?? 1) === currentStep);
6417
+ return /* @__PURE__ */ jsxs(Card, { className: "flex flex-col gap-4 px-4", children: [
6418
+ /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-between mb-4 gap-2 px-4", children: [
6419
+ /* @__PURE__ */ jsx(
6420
+ Stepper,
6421
+ {
6422
+ steps: Array(totalSteps).fill({}),
6423
+ currentStep,
6424
+ clickable: true,
6425
+ onStepClick: setCurrentStep
6426
+ }
6427
+ ),
6428
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-center space-x-4 gap-2", children: [
6429
+ /* @__PURE__ */ jsx(
6430
+ Button,
6431
+ {
6432
+ variant: "outline",
6433
+ className: "w-32",
6434
+ onClick: () => setCurrentStep((prev) => prev - 1),
6435
+ disabled: currentStep === 1,
6436
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
6437
+ }
6438
+ ),
6439
+ /* @__PURE__ */ jsx(
6440
+ Button,
6441
+ {
6442
+ variant: "outline",
6443
+ className: "w-32",
6444
+ onClick: () => setCurrentStep((prev) => prev + 1),
6445
+ disabled: currentStep > totalSteps,
6446
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
6447
+ }
6448
+ )
6449
+ ] })
6450
+ ] }) }),
6451
+ /* @__PURE__ */ jsx(
6452
+ DynamicForm,
6453
+ {
6454
+ record,
6455
+ formSubTitle: "This is a subtitle",
6456
+ formTitle: "Wizard Form Example",
6457
+ withCard: false,
6458
+ errorAlertPosition: "down",
6459
+ fields: stepFields,
6460
+ onSubmit
6461
+ }
6462
+ )
6463
+ ] });
6464
+ };
6321
6465
  var DynamicFormExample = () => {
6322
6466
  const record = {
6323
6467
  username: "John Doe ",
@@ -6608,6 +6752,6 @@ var GenericFilter = ({
6608
6752
  ) }) });
6609
6753
  };
6610
6754
 
6611
- export { Accordion, AccordionContent, AccordionGroupedSwitchInput, AccordionGroupedSwitches, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, Button, ButtonGroup, ButtonGroupInput, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, CheckboxInput, ColorCnInput, ColorInput, ComboboxInput, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CurrencyInput, CustomAlert, CustomInputGroup, DateInput, DateTimeInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, Field, FieldButtonGroup, FieldContent, FieldCurrency, FieldDateTimeInput, FieldDescription, FieldError, FieldFileMultiUpload, FieldGroup, FieldKeyValueList, FieldLabel, FieldLegend, FieldRepeater, FieldSeparator, FieldSet, FieldSimpleCheckList, FieldSlider, FieldStringValueList, FieldTextGroup, FieldTimeInput2 as FieldTimeInput, FieldTitle, FileInput, FileMultiUploadInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormFieldsGrid, FormItem, FormLabel, FormMessage, GenericFilter, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, InputTypes, KeyValueListInput, Label, MultiSelectInput, NumberInput, OTPInput2 as OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, RadioGroup, RadioGroupInput, RadioGroupItem, RepeaterInput, RepeaterTabsInput, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SimpleCheckListInput, Slider, SliderInput, SortableListInput, StringValueListInput, Switch, SwitchInput, Tabs, TabsContent, TabsList, TabsTrigger, TagInput, TextAreaInput, TextInput, TextInputGroup, TextInputType, Textarea, TimeInput, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonGroupVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, isValidField, mockFields, useFormField, validationMessages };
6755
+ export { Accordion, AccordionContent, AccordionGroupedSwitchInput, AccordionGroupedSwitches, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Badge, BaseInput, Button, ButtonGroup, ButtonGroupInput, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckListInput, Checkbox, CheckboxInput, ColorCnInput, ColorInput, ComboboxInput, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CurrencyInput, CustomAlert, CustomInputGroup, DateInput, DateTimeInput, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DynamicForm, DynamicFormExample, Field, FieldButtonGroup, FieldContent, FieldCurrency, FieldDateTimeInput, FieldDescription, FieldError, FieldFileMultiUpload, FieldGroup, FieldKeyValueList, FieldLabel, FieldLegend, FieldRepeater, FieldSeparator, FieldSet, FieldSimpleCheckList, FieldSlider, FieldStringValueList, FieldTextGroup, FieldTimeInput2 as FieldTimeInput, FieldTitle, FileInput, FileMultiUploadInput, Form, FormControl, FormDescription, FormErrorsAlert, FormField, FormFieldsGrid, FormItem, FormLabel, FormMessage, GenericFilter, GroupedSwitchInput, GroupedSwitches, Input, InputFactory, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputList, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, InputTypes, KeyValueListInput, Label, MultiSelectInput, NumberInput, OTPInput2 as OTPInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, RadioGroup, RadioGroupInput, RadioGroupItem, RepeaterInput, RepeaterTabsInput, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SimpleCheckListInput, Slider, SliderInput, SortableListInput, StringValueListInput, Switch, SwitchInput, Tabs, TabsContent, TabsList, TabsTrigger, TagInput, TextAreaInput, TextInput, TextInputGroup, TextInputType, Textarea, TimeInput, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, WizardForm, badgeVariants, buttonGroupVariants, buttonVariants, cn, entitiesToGroupedOption, entitiesToInputOption, entityToGroupedOption, entityToInputOption, flattenFields, getDefaultValues, getDynamicSchema, getFieldLabel, handleOnChage, inputFieldComp, isValidField, mockFields, useFormField, validationMessages };
6612
6756
  //# sourceMappingURL=index.mjs.map
6613
6757
  //# sourceMappingURL=index.mjs.map