shadcn-zod-formkit 1.25.0 → 1.26.1

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 CHANGED
@@ -233,9 +233,17 @@ var entitiesToGroupedOption = (data, optionValue = "name") => {
233
233
  return entities;
234
234
  };
235
235
  var handleOnChage = (event, input, field) => {
236
- console.log("\u{1F680} ~ handleOnChage ~ event:", event);
237
236
  if (event) field?.onChange(event);
238
- input.onChange?.(event);
237
+ input.onChange?.(event, input.form?.getValues());
238
+ };
239
+ var isValidField = (input, form, defaultValue) => {
240
+ const value = defaultValue ?? form.getValues(input.name);
241
+ const fieldState = form.getFieldState(input.name);
242
+ if (input.zodType) {
243
+ const result = input.zodType.safeParse(value);
244
+ return result.success;
245
+ }
246
+ return !fieldState.error && value !== void 0 && value !== "";
239
247
  };
240
248
 
241
249
  // src/components/custom/form/inputs/base/definitions.ts
@@ -969,7 +977,54 @@ function Separator({
969
977
  }
970
978
  );
971
979
  }
972
- classVarianceAuthority.cva(
980
+ function FieldSet({ className, ...props }) {
981
+ return /* @__PURE__ */ jsxRuntime.jsx(
982
+ "fieldset",
983
+ {
984
+ "data-slot": "field-set",
985
+ className: cn(
986
+ "flex flex-col gap-6",
987
+ "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
988
+ className
989
+ ),
990
+ ...props
991
+ }
992
+ );
993
+ }
994
+ function FieldLegend({
995
+ className,
996
+ variant = "legend",
997
+ ...props
998
+ }) {
999
+ return /* @__PURE__ */ jsxRuntime.jsx(
1000
+ "legend",
1001
+ {
1002
+ "data-slot": "field-legend",
1003
+ "data-variant": variant,
1004
+ className: cn(
1005
+ "mb-3 font-medium",
1006
+ "data-[variant=legend]:text-base",
1007
+ "data-[variant=label]:text-sm",
1008
+ className
1009
+ ),
1010
+ ...props
1011
+ }
1012
+ );
1013
+ }
1014
+ function FieldGroup({ className, ...props }) {
1015
+ return /* @__PURE__ */ jsxRuntime.jsx(
1016
+ "div",
1017
+ {
1018
+ "data-slot": "field-group",
1019
+ className: cn(
1020
+ "group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
1021
+ className
1022
+ ),
1023
+ ...props
1024
+ }
1025
+ );
1026
+ }
1027
+ var fieldVariants = classVarianceAuthority.cva(
973
1028
  "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
974
1029
  {
975
1030
  variants: {
@@ -992,6 +1047,147 @@ classVarianceAuthority.cva(
992
1047
  }
993
1048
  }
994
1049
  );
1050
+ function Field({
1051
+ className,
1052
+ orientation = "vertical",
1053
+ ...props
1054
+ }) {
1055
+ return /* @__PURE__ */ jsxRuntime.jsx(
1056
+ "div",
1057
+ {
1058
+ role: "group",
1059
+ "data-slot": "field",
1060
+ "data-orientation": orientation,
1061
+ className: cn(fieldVariants({ orientation }), className),
1062
+ ...props
1063
+ }
1064
+ );
1065
+ }
1066
+ function FieldContent({ className, ...props }) {
1067
+ return /* @__PURE__ */ jsxRuntime.jsx(
1068
+ "div",
1069
+ {
1070
+ "data-slot": "field-content",
1071
+ className: cn(
1072
+ "group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
1073
+ className
1074
+ ),
1075
+ ...props
1076
+ }
1077
+ );
1078
+ }
1079
+ function FieldLabel({
1080
+ className,
1081
+ ...props
1082
+ }) {
1083
+ return /* @__PURE__ */ jsxRuntime.jsx(
1084
+ Label,
1085
+ {
1086
+ "data-slot": "field-label",
1087
+ className: cn(
1088
+ "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
1089
+ "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
1090
+ "has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",
1091
+ className
1092
+ ),
1093
+ ...props
1094
+ }
1095
+ );
1096
+ }
1097
+ function FieldTitle({ className, ...props }) {
1098
+ return /* @__PURE__ */ jsxRuntime.jsx(
1099
+ "div",
1100
+ {
1101
+ "data-slot": "field-label",
1102
+ className: cn(
1103
+ "flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
1104
+ className
1105
+ ),
1106
+ ...props
1107
+ }
1108
+ );
1109
+ }
1110
+ function FieldDescription({ className, ...props }) {
1111
+ return /* @__PURE__ */ jsxRuntime.jsx(
1112
+ "p",
1113
+ {
1114
+ "data-slot": "field-description",
1115
+ className: cn(
1116
+ "text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance",
1117
+ "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
1118
+ "[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
1119
+ className
1120
+ ),
1121
+ ...props
1122
+ }
1123
+ );
1124
+ }
1125
+ function FieldSeparator({
1126
+ children,
1127
+ className,
1128
+ ...props
1129
+ }) {
1130
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1131
+ "div",
1132
+ {
1133
+ "data-slot": "field-separator",
1134
+ "data-content": !!children,
1135
+ className: cn(
1136
+ "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
1137
+ className
1138
+ ),
1139
+ ...props,
1140
+ children: [
1141
+ /* @__PURE__ */ jsxRuntime.jsx(Separator, { className: "absolute inset-0 top-1/2" }),
1142
+ children && /* @__PURE__ */ jsxRuntime.jsx(
1143
+ "span",
1144
+ {
1145
+ className: "bg-background text-muted-foreground relative mx-auto block w-fit px-2",
1146
+ "data-slot": "field-separator-content",
1147
+ children
1148
+ }
1149
+ )
1150
+ ]
1151
+ }
1152
+ );
1153
+ }
1154
+ function FieldError({
1155
+ className,
1156
+ children,
1157
+ errors,
1158
+ ...props
1159
+ }) {
1160
+ const content = React3.useMemo(() => {
1161
+ if (children) {
1162
+ return children;
1163
+ }
1164
+ if (!errors?.length) {
1165
+ return null;
1166
+ }
1167
+ const uniqueErrors = [
1168
+ ...new Map(errors.map((error) => [error?.message, error])).values()
1169
+ ];
1170
+ if (uniqueErrors?.length == 1) {
1171
+ return uniqueErrors[0]?.message;
1172
+ }
1173
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "ml-4 flex list-disc flex-col gap-1", children: uniqueErrors.map(
1174
+ (error, index) => error?.message && /* @__PURE__ */ jsxRuntime.jsx("li", { children: error.message }, index)
1175
+ ) });
1176
+ }, [children, errors]);
1177
+ if (!content) {
1178
+ return null;
1179
+ }
1180
+ return /* @__PURE__ */ jsxRuntime.jsx(
1181
+ "div",
1182
+ {
1183
+ role: "alert",
1184
+ "data-slot": "field-error",
1185
+ className: cn("text-destructive text-sm font-normal", className),
1186
+ ...props,
1187
+ children: content
1188
+ }
1189
+ );
1190
+ }
995
1191
  var Form = reactHookForm.FormProvider;
996
1192
  var FormFieldContext = React3__namespace.createContext(
997
1193
  {}
@@ -1183,7 +1379,7 @@ function InputGroupAddon({
1183
1379
  }
1184
1380
  );
1185
1381
  }
1186
- classVarianceAuthority.cva(
1382
+ var inputGroupButtonVariants = classVarianceAuthority.cva(
1187
1383
  "text-sm shadow-none flex gap-2 items-center",
1188
1384
  {
1189
1385
  variants: {
@@ -1199,6 +1395,24 @@ classVarianceAuthority.cva(
1199
1395
  }
1200
1396
  }
1201
1397
  );
1398
+ function InputGroupButton({
1399
+ className,
1400
+ type = "button",
1401
+ variant = "ghost",
1402
+ size = "xs",
1403
+ ...props
1404
+ }) {
1405
+ return /* @__PURE__ */ jsxRuntime.jsx(
1406
+ Button,
1407
+ {
1408
+ type,
1409
+ "data-size": size,
1410
+ variant,
1411
+ className: cn(inputGroupButtonVariants({ size }), className),
1412
+ ...props
1413
+ }
1414
+ );
1415
+ }
1202
1416
  function InputGroupText({ className, ...props }) {
1203
1417
  return /* @__PURE__ */ jsxRuntime.jsx(
1204
1418
  "span",
@@ -1227,6 +1441,22 @@ function InputGroupInput({
1227
1441
  }
1228
1442
  );
1229
1443
  }
1444
+ function InputGroupTextarea({
1445
+ className,
1446
+ ...props
1447
+ }) {
1448
+ return /* @__PURE__ */ jsxRuntime.jsx(
1449
+ Textarea,
1450
+ {
1451
+ "data-slot": "input-group-control",
1452
+ className: cn(
1453
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
1454
+ className
1455
+ ),
1456
+ ...props
1457
+ }
1458
+ );
1459
+ }
1230
1460
  function InputOTP({
1231
1461
  className,
1232
1462
  containerClassName,
@@ -1825,6 +2055,41 @@ function ButtonGroup({
1825
2055
  }
1826
2056
  );
1827
2057
  }
2058
+ function ButtonGroupText({
2059
+ className,
2060
+ asChild = false,
2061
+ ...props
2062
+ }) {
2063
+ const Comp = asChild ? reactSlot.Slot : "div";
2064
+ return /* @__PURE__ */ jsxRuntime.jsx(
2065
+ Comp,
2066
+ {
2067
+ className: cn(
2068
+ "bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
2069
+ className
2070
+ ),
2071
+ ...props
2072
+ }
2073
+ );
2074
+ }
2075
+ function ButtonGroupSeparator({
2076
+ className,
2077
+ orientation = "vertical",
2078
+ ...props
2079
+ }) {
2080
+ return /* @__PURE__ */ jsxRuntime.jsx(
2081
+ Separator,
2082
+ {
2083
+ "data-slot": "button-group-separator",
2084
+ orientation,
2085
+ className: cn(
2086
+ "bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto",
2087
+ className
2088
+ ),
2089
+ ...props
2090
+ }
2091
+ );
2092
+ }
1828
2093
  var ButtonGroupInput = class extends BaseInput {
1829
2094
  render() {
1830
2095
  const { input, form, isSubmitting } = this;
@@ -1852,7 +2117,7 @@ var FieldButtonGroup = ({ input, form, isSubmitting, className = "w-full flex-1"
1852
2117
  disabled: isSubmitting,
1853
2118
  children: option.label ?? option.name
1854
2119
  },
1855
- key
2120
+ `${input.name}-${key}-btn-g`
1856
2121
  )) });
1857
2122
  };
1858
2123
  var CheckListInput = class extends BaseInput {
@@ -2028,6 +2293,29 @@ function Command({
2028
2293
  }
2029
2294
  );
2030
2295
  }
2296
+ function CommandDialog({
2297
+ title = "Command Palette",
2298
+ description = "Search for a command to run...",
2299
+ children,
2300
+ className,
2301
+ showCloseButton = true,
2302
+ ...props
2303
+ }) {
2304
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dialog, { ...props, children: [
2305
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { className: "sr-only", children: [
2306
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: title }),
2307
+ /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: description })
2308
+ ] }),
2309
+ /* @__PURE__ */ jsxRuntime.jsx(
2310
+ DialogContent,
2311
+ {
2312
+ className: cn("overflow-hidden p-0", className),
2313
+ showCloseButton,
2314
+ children: /* @__PURE__ */ jsxRuntime.jsx(Command, { className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children })
2315
+ }
2316
+ )
2317
+ ] });
2318
+ }
2031
2319
  function CommandInput({
2032
2320
  className,
2033
2321
  ...props
@@ -2098,6 +2386,19 @@ function CommandGroup({
2098
2386
  }
2099
2387
  );
2100
2388
  }
2389
+ function CommandSeparator({
2390
+ className,
2391
+ ...props
2392
+ }) {
2393
+ return /* @__PURE__ */ jsxRuntime.jsx(
2394
+ cmdk.Command.Separator,
2395
+ {
2396
+ "data-slot": "command-separator",
2397
+ className: cn("bg-border -mx-1 h-px", className),
2398
+ ...props
2399
+ }
2400
+ );
2401
+ }
2101
2402
  function CommandItem({
2102
2403
  className,
2103
2404
  ...props
@@ -2114,6 +2415,22 @@ function CommandItem({
2114
2415
  }
2115
2416
  );
2116
2417
  }
2418
+ function CommandShortcut({
2419
+ className,
2420
+ ...props
2421
+ }) {
2422
+ return /* @__PURE__ */ jsxRuntime.jsx(
2423
+ "span",
2424
+ {
2425
+ "data-slot": "command-shortcut",
2426
+ className: cn(
2427
+ "text-muted-foreground ml-auto text-xs tracking-widest",
2428
+ className
2429
+ ),
2430
+ ...props
2431
+ }
2432
+ );
2433
+ }
2117
2434
  var ComboboxInput = class extends BaseInput {
2118
2435
  render() {
2119
2436
  const { input, form, isSubmitting } = this;
@@ -3895,60 +4212,82 @@ function cleanEscapedString(input) {
3895
4212
  var DateInput = class extends BaseInput {
3896
4213
  render() {
3897
4214
  const { input, form, isSubmitting } = this;
3898
- const formField = /* @__PURE__ */ jsxRuntime.jsx(
3899
- FormField,
3900
- {
3901
- control: form.control,
3902
- name: input.name,
3903
- render: ({ field }) => {
3904
- const [date, setDate] = React3__namespace.useState(
3905
- field.value ? new Date(field.value) : void 0
3906
- );
3907
- React3__namespace.useEffect(() => {
3908
- if (field.value && !date) {
3909
- setDate(new Date(field.value));
3910
- }
3911
- }, [field.value]);
3912
- const handleSelect = (selectedDate) => {
3913
- setDate(selectedDate);
3914
- handleOnChage(selectedDate, input, field);
3915
- };
3916
- return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { children: [
3917
- /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
3918
- /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
3919
- /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs(
3920
- Button,
3921
- {
3922
- variant: "outline",
3923
- className: cn(
3924
- "w-full justify-start text-left font-normal",
3925
- !date && "text-muted-foreground"
3926
- ),
3927
- children: [
4215
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldTimeInput, { input, form, isSubmitting });
4216
+ }
4217
+ };
4218
+ var FieldTimeInput = ({ form, input, isSubmitting }) => {
4219
+ const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
4220
+ const groupConfig = input.inputGroupConfig;
4221
+ const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
4222
+ const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
4223
+ const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
4224
+ const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
4225
+ const iconsRight = groupConfig?.iconsRight ?? [];
4226
+ groupConfig?.iconsLeft ?? [];
4227
+ groupConfig?.textLeft;
4228
+ const textRight = groupConfig?.textRight;
4229
+ const formField = /* @__PURE__ */ jsxRuntime.jsx(
4230
+ FormField,
4231
+ {
4232
+ control: form.control,
4233
+ name: input.name,
4234
+ render: ({ field }) => {
4235
+ setIsValid(isValidField(input, form));
4236
+ const [date, setDate] = React3__namespace.useState(
4237
+ field.value ? new Date(field.value) : void 0
4238
+ );
4239
+ React3__namespace.useEffect(() => {
4240
+ if (field.value && !date) {
4241
+ setDate(new Date(field.value));
4242
+ setIsValid(isValidField(input, form));
4243
+ }
4244
+ }, [field.value]);
4245
+ const handleSelect = (selectedDate) => {
4246
+ setDate(selectedDate);
4247
+ handleOnChage(selectedDate, input, field);
4248
+ };
4249
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { children: [
4250
+ /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
4251
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
4252
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(InputGroup, { className: "flex flex-row gap-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
4253
+ Button,
4254
+ {
4255
+ variant: "outline",
4256
+ className: cn(
4257
+ "w-full justify-start text-left py-0.5 ",
4258
+ !date && "text-muted-foreground"
4259
+ ),
4260
+ children: [
4261
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 items-center gap-1 justify-start text-left ", children: [
3928
4262
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, {}),
3929
4263
  date ? format(date, "PPP") : /* @__PURE__ */ jsxRuntime.jsx("span", { children: input.placeHolder ?? "Fecha" })
3930
- ]
3931
- }
3932
- ) }) }),
3933
- /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
3934
- Calendar,
3935
- {
3936
- mode: "single",
3937
- selected: date,
3938
- onSelect: handleSelect,
3939
- initialFocus: true
3940
- }
3941
- ) })
3942
- ] }),
3943
- /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
3944
- /* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
3945
- ] });
3946
- }
3947
- },
3948
- input.name
3949
- );
3950
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
3951
- }
4264
+ ] }),
4265
+ (iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4266
+ textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
4267
+ iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 24, className: "w-6! h-6!" }, index)),
4268
+ autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
4269
+ ] })
4270
+ ]
4271
+ }
4272
+ ) }) }) }),
4273
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
4274
+ Calendar,
4275
+ {
4276
+ mode: "single",
4277
+ selected: date,
4278
+ onSelect: handleSelect,
4279
+ initialFocus: true
4280
+ }
4281
+ ) })
4282
+ ] }),
4283
+ /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
4284
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
4285
+ ] });
4286
+ }
4287
+ },
4288
+ input.name
4289
+ );
4290
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
3952
4291
  };
3953
4292
  var DateTimeInput = class extends BaseInput {
3954
4293
  render() {
@@ -3958,7 +4297,7 @@ var DateTimeInput = class extends BaseInput {
3958
4297
  };
3959
4298
  var FieldDateTimeInput = ({ form, input, isSubmitting }) => {
3960
4299
  const groupConfig = input.inputGroupConfig;
3961
- const autoValidate = groupConfig?.autoValidIcons;
4300
+ const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
3962
4301
  const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
3963
4302
  const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
3964
4303
  const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
@@ -4009,7 +4348,7 @@ var FieldDateTimeInput = ({ form, input, isSubmitting }) => {
4009
4348
  ),
4010
4349
  (iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
4011
4350
  textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
4012
- iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index)),
4351
+ iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 24 }, index)),
4013
4352
  autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
4014
4353
  ] })
4015
4354
  ] }) }),
@@ -4332,7 +4671,7 @@ var FieldMultiSelect = ({ form, input, isSubmitting }) => {
4332
4671
  const option = lista.find(
4333
4672
  (item) => getValue(item).toString() === val
4334
4673
  );
4335
- return /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", children: option?.name ?? val }, val);
4674
+ return /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", children: option?.name ?? val }, `${input.name}-${val}-ms`);
4336
4675
  }) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: input.placeHolder ?? "Selecciona..." }),
4337
4676
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "ml-2 h-4 w-4 opacity-50" })
4338
4677
  ]
@@ -4365,7 +4704,7 @@ var FieldMultiSelect = ({ form, input, isSubmitting }) => {
4365
4704
  item.name
4366
4705
  ]
4367
4706
  },
4368
- value
4707
+ `${value}-ms`
4369
4708
  );
4370
4709
  }) })
4371
4710
  ] })
@@ -4387,7 +4726,7 @@ var TextInputGroup = class extends BaseInput {
4387
4726
  var FieldTextGroup = ({ form, input, isSubmitting }) => {
4388
4727
  const groupConfig = input.inputGroupConfig;
4389
4728
  const infoTooltip = input?.infoTooltip;
4390
- const autoValidate = groupConfig?.autoValidIcons;
4729
+ const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
4391
4730
  const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
4392
4731
  const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
4393
4732
  const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
@@ -4395,11 +4734,7 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
4395
4734
  const iconsLeft = groupConfig?.iconsLeft ?? [];
4396
4735
  const textLeft = groupConfig?.textLeft;
4397
4736
  const textRight = groupConfig?.textRight;
4398
- const [isValid2, setIsValid] = React3.useState(() => {
4399
- const value = form.getValues(input.name);
4400
- const fieldState = form.getFieldState(input.name);
4401
- return !fieldState.error && value !== void 0 && value !== "";
4402
- });
4737
+ const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
4403
4738
  const [showPassword, setShowPassword] = React3.useState(false);
4404
4739
  const isPasswordField = input.keyboardType === "password" /* PASSWORD */;
4405
4740
  const isNumberField = input.keyboardType === "number" /* NUMBER */;
@@ -4409,9 +4744,8 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
4409
4744
  {
4410
4745
  control: form.control,
4411
4746
  name: input.name,
4412
- render: ({ field, fieldState }) => {
4413
- const validNow = !fieldState.error && field.value !== void 0 && field.value !== "";
4414
- if (validNow !== isValid2) setIsValid(validNow);
4747
+ render: ({ field }) => {
4748
+ setIsValid(isValidField(input, form));
4415
4749
  return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
4416
4750
  /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
4417
4751
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: "shadow-lg", children: /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
@@ -4436,6 +4770,7 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
4436
4770
  }
4437
4771
  handleOnChage(value, input, field);
4438
4772
  field.onChange(value);
4773
+ isValidField(input, form);
4439
4774
  }
4440
4775
  }
4441
4776
  ),
@@ -4903,7 +5238,7 @@ var FieldSelect = ({ form, input, isSubmitting }) => {
4903
5238
  }
4904
5239
  ) }) }),
4905
5240
  /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
4906
- lista.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: getValue(item), children: item.name }, item.id)),
5241
+ lista.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: getValue(item), children: item.name }, `${input.name}-${item.id}-s`)),
4907
5242
  lista.length === 0 && !loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 text-sm text-muted-foreground", children: "No hay opciones disponibles" })
4908
5243
  ] })
4909
5244
  ]
@@ -5513,10 +5848,10 @@ var FieldText = ({ input, form, isSubmitting }) => {
5513
5848
  var TimeInput = class extends BaseInput {
5514
5849
  render() {
5515
5850
  const { input, form, isSubmitting } = this;
5516
- return /* @__PURE__ */ jsxRuntime.jsx(FieldTimeInput, { input, form, isSubmitting });
5851
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldTimeInput2, { input, form, isSubmitting });
5517
5852
  }
5518
5853
  };
5519
- var FieldTimeInput = ({ form, input, isSubmitting }) => {
5854
+ var FieldTimeInput2 = ({ form, input, isSubmitting }) => {
5520
5855
  const groupConfig = input.inputGroupConfig;
5521
5856
  const autoValidate = groupConfig?.autoValidIcons;
5522
5857
  const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
@@ -5624,6 +5959,7 @@ var inputMap = {
5624
5959
  };
5625
5960
  var InputFactory = class {
5626
5961
  static create(input, form, isSubmitting = false) {
5962
+ input.form = form;
5627
5963
  const inputType = input.inputType ?? "text" /* TEXT */;
5628
5964
  const InputClass = inputMap[inputType] ?? TextInput;
5629
5965
  const instance = new InputClass(input, form, isSubmitting);
@@ -5804,7 +6140,7 @@ var DynamicForm = ({
5804
6140
  });
5805
6141
  React3.useEffect(() => {
5806
6142
  form.reset(initialValues);
5807
- }, [initialValues, form]);
6143
+ }, []);
5808
6144
  const handleSubmit = (data) => {
5809
6145
  if (readOnly) return;
5810
6146
  startTransition(() => {
@@ -6085,9 +6421,126 @@ var InputList = ({ handleAddInput, inputsTypes }) => {
6085
6421
  );
6086
6422
  }) });
6087
6423
  };
6424
+ var GenericFilter = ({
6425
+ filters = [],
6426
+ pagination,
6427
+ autoSubmit = false,
6428
+ defaultValues = {},
6429
+ initPage = 1,
6430
+ initLimit = 10,
6431
+ rangeLimit = [10, 25, 50, 100],
6432
+ onChange,
6433
+ withSearch = true,
6434
+ withInitDate = true,
6435
+ withEndDate = true,
6436
+ withActive = true,
6437
+ withLimit = true,
6438
+ wrapInCard = true
6439
+ }) => {
6440
+ const record = {
6441
+ page: initPage,
6442
+ limit: initLimit,
6443
+ ...defaultValues
6444
+ };
6445
+ const [values, setValues] = React3.useState(record);
6446
+ const isFirstRender = React3.useRef(true);
6447
+ React3.useEffect(() => {
6448
+ if (isFirstRender.current) {
6449
+ isFirstRender.current = false;
6450
+ return;
6451
+ }
6452
+ }, [values]);
6453
+ const handleChange = (name, value) => {
6454
+ setValues((prev) => ({ ...prev, [name]: value }));
6455
+ if (autoSubmit && onChange) onChange({ ...values, [name]: value });
6456
+ };
6457
+ const baseFields = [
6458
+ ...withSearch ? [
6459
+ {
6460
+ name: "search",
6461
+ label: "Buscar",
6462
+ inputType: "text_group" /* TEXT_GROUP */,
6463
+ inputGroupConfig: { iconsLeft: [lucideReact.Search] },
6464
+ onChange: (value) => handleChange("search", value)
6465
+ }
6466
+ ] : [],
6467
+ ...withInitDate ? [
6468
+ {
6469
+ name: "initDate",
6470
+ label: "Fecha de Inicio",
6471
+ inputType: "date" /* DATE */,
6472
+ onChange: (value) => handleChange("initDate", value)
6473
+ }
6474
+ ] : [],
6475
+ ...withEndDate ? [
6476
+ {
6477
+ name: "endDate",
6478
+ label: "Fecha Final",
6479
+ inputType: "date" /* DATE */,
6480
+ onChange: (value) => handleChange("endDate", value)
6481
+ }
6482
+ ] : [],
6483
+ ...withActive ? [
6484
+ {
6485
+ wrapInCard: true,
6486
+ name: "active",
6487
+ label: "",
6488
+ inputType: "button_group" /* BUTTON_GROUP */,
6489
+ description: "Estado",
6490
+ listConfig: {
6491
+ list: [
6492
+ { id: 1, name: "Activo", value: true },
6493
+ { id: 2, name: "Inactivo", value: false },
6494
+ { id: 3, name: "Todos", value: void 0 }
6495
+ ],
6496
+ onOptionChange: (item) => {
6497
+ if (Array.isArray(item) && item[0]) handleChange("active", item[0].value);
6498
+ else if (item && "value" in item) handleChange("active", item.value);
6499
+ }
6500
+ }
6501
+ }
6502
+ ] : [],
6503
+ ...withLimit ? [
6504
+ {
6505
+ name: "limit",
6506
+ label: "L\xEDmite por p\xE1gina",
6507
+ inputType: "select" /* SELECT */,
6508
+ listConfig: {
6509
+ list: rangeLimit.map((num) => ({
6510
+ value: String(num),
6511
+ id: num,
6512
+ name: String(num)
6513
+ })),
6514
+ onOptionChange: (item) => handleChange("limit", Number(item?.value ?? 10))
6515
+ }
6516
+ }
6517
+ ] : []
6518
+ ];
6519
+ const fieldsConfig = [
6520
+ ...filters,
6521
+ baseFields
6522
+ ];
6523
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col md:flex-row md:items-end gap-4 py-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
6524
+ DynamicForm,
6525
+ {
6526
+ withCard: wrapInCard,
6527
+ withSubmitBtn: !autoSubmit,
6528
+ formTitle: "",
6529
+ submitBtnLabel: "Buscar",
6530
+ fields: fieldsConfig,
6531
+ record: values,
6532
+ showFormHeader: false,
6533
+ onSubmit: ({ data }) => {
6534
+ if (onChange && !autoSubmit) onChange(data);
6535
+ }
6536
+ }
6537
+ ) }) });
6538
+ };
6088
6539
 
6089
6540
  exports.Accordion = Accordion;
6090
6541
  exports.AccordionContent = AccordionContent;
6542
+ exports.AccordionGroupedSwitchInput = AccordionGroupedSwitchInput;
6543
+ exports.AccordionGroupedSwitches = AccordionGroupedSwitches;
6091
6544
  exports.AccordionItem = AccordionItem;
6092
6545
  exports.AccordionTrigger = AccordionTrigger;
6093
6546
  exports.Alert = Alert;
@@ -6096,6 +6549,10 @@ exports.AlertTitle = AlertTitle;
6096
6549
  exports.Badge = Badge;
6097
6550
  exports.BaseInput = BaseInput;
6098
6551
  exports.Button = Button;
6552
+ exports.ButtonGroup = ButtonGroup;
6553
+ exports.ButtonGroupInput = ButtonGroupInput;
6554
+ exports.ButtonGroupSeparator = ButtonGroupSeparator;
6555
+ exports.ButtonGroupText = ButtonGroupText;
6099
6556
  exports.Calendar = Calendar;
6100
6557
  exports.CalendarDayButton = CalendarDayButton;
6101
6558
  exports.Card = Card;
@@ -6107,10 +6564,23 @@ exports.CardHeader = CardHeader;
6107
6564
  exports.CardTitle = CardTitle;
6108
6565
  exports.CheckListInput = CheckListInput;
6109
6566
  exports.Checkbox = Checkbox;
6567
+ exports.CheckboxInput = CheckboxInput;
6110
6568
  exports.ColorCnInput = ColorCnInput;
6111
6569
  exports.ColorInput = ColorInput;
6570
+ exports.ComboboxInput = ComboboxInput;
6571
+ exports.Command = Command;
6572
+ exports.CommandDialog = CommandDialog;
6573
+ exports.CommandEmpty = CommandEmpty;
6574
+ exports.CommandGroup = CommandGroup;
6575
+ exports.CommandInput = CommandInput;
6576
+ exports.CommandItem = CommandItem;
6577
+ exports.CommandList = CommandList;
6578
+ exports.CommandSeparator = CommandSeparator;
6579
+ exports.CommandShortcut = CommandShortcut;
6580
+ exports.CurrencyInput = CurrencyInput;
6112
6581
  exports.CustomAlert = CustomAlert;
6113
6582
  exports.DateInput = DateInput;
6583
+ exports.DateTimeInput = DateTimeInput;
6114
6584
  exports.Dialog = Dialog;
6115
6585
  exports.DialogClose = DialogClose;
6116
6586
  exports.DialogContent = DialogContent;
@@ -6123,32 +6593,69 @@ exports.DialogTitle = DialogTitle;
6123
6593
  exports.DialogTrigger = DialogTrigger;
6124
6594
  exports.DynamicForm = DynamicForm;
6125
6595
  exports.DynamicFormExample = DynamicFormExample;
6596
+ exports.Field = Field;
6597
+ exports.FieldButtonGroup = FieldButtonGroup;
6598
+ exports.FieldContent = FieldContent;
6599
+ exports.FieldCurrency = FieldCurrency;
6600
+ exports.FieldDateTimeInput = FieldDateTimeInput;
6601
+ exports.FieldDescription = FieldDescription;
6602
+ exports.FieldError = FieldError;
6603
+ exports.FieldFileMultiUpload = FieldFileMultiUpload;
6604
+ exports.FieldGroup = FieldGroup;
6605
+ exports.FieldKeyValueList = FieldKeyValueList;
6606
+ exports.FieldLabel = FieldLabel;
6607
+ exports.FieldLegend = FieldLegend;
6608
+ exports.FieldRepeater = FieldRepeater;
6609
+ exports.FieldSeparator = FieldSeparator;
6610
+ exports.FieldSet = FieldSet;
6611
+ exports.FieldSimpleCheckList = FieldSimpleCheckList;
6612
+ exports.FieldSlider = FieldSlider;
6613
+ exports.FieldStringValueList = FieldStringValueList;
6614
+ exports.FieldTextGroup = FieldTextGroup;
6615
+ exports.FieldTimeInput = FieldTimeInput2;
6616
+ exports.FieldTitle = FieldTitle;
6126
6617
  exports.FileInput = FileInput;
6618
+ exports.FileMultiUploadInput = FileMultiUploadInput;
6127
6619
  exports.Form = Form;
6128
6620
  exports.FormControl = FormControl;
6129
6621
  exports.FormDescription = FormDescription;
6130
6622
  exports.FormErrorsAlert = FormErrorsAlert;
6131
6623
  exports.FormField = FormField;
6624
+ exports.FormFieldsGrid = FormFieldsGrid;
6132
6625
  exports.FormItem = FormItem;
6133
6626
  exports.FormLabel = FormLabel;
6134
6627
  exports.FormMessage = FormMessage;
6628
+ exports.GenericFilter = GenericFilter;
6135
6629
  exports.GroupedSwitchInput = GroupedSwitchInput;
6136
6630
  exports.GroupedSwitches = GroupedSwitches;
6137
6631
  exports.Input = Input;
6138
6632
  exports.InputFactory = InputFactory;
6633
+ exports.InputGroup = InputGroup;
6634
+ exports.InputGroupAddon = InputGroupAddon;
6635
+ exports.InputGroupButton = InputGroupButton;
6636
+ exports.InputGroupInput = InputGroupInput;
6637
+ exports.InputGroupText = InputGroupText;
6638
+ exports.InputGroupTextarea = InputGroupTextarea;
6139
6639
  exports.InputList = InputList;
6140
6640
  exports.InputOTP = InputOTP;
6141
6641
  exports.InputOTPGroup = InputOTPGroup;
6142
6642
  exports.InputOTPSeparator = InputOTPSeparator;
6143
6643
  exports.InputOTPSlot = InputOTPSlot;
6144
6644
  exports.InputTypes = InputTypes;
6645
+ exports.KeyValueListInput = KeyValueListInput;
6145
6646
  exports.Label = Label;
6647
+ exports.MultiSelectInput = MultiSelectInput;
6146
6648
  exports.NumberInput = NumberInput;
6147
6649
  exports.OTPInput = OTPInput2;
6148
6650
  exports.Popover = Popover;
6149
6651
  exports.PopoverAnchor = PopoverAnchor;
6150
6652
  exports.PopoverContent = PopoverContent;
6151
6653
  exports.PopoverTrigger = PopoverTrigger;
6654
+ exports.RadioGroup = RadioGroup;
6655
+ exports.RadioGroupInput = RadioGroupInput;
6656
+ exports.RadioGroupItem = RadioGroupItem;
6657
+ exports.RepeaterInput = RepeaterInput;
6658
+ exports.RepeaterTabsInput = RepeaterTabsInput;
6152
6659
  exports.ResizableHandle = ResizableHandle;
6153
6660
  exports.ResizablePanel = ResizablePanel;
6154
6661
  exports.ResizablePanelGroup = ResizablePanelGroup;
@@ -6166,18 +6673,31 @@ exports.SelectSeparator = SelectSeparator;
6166
6673
  exports.SelectTrigger = SelectTrigger;
6167
6674
  exports.SelectValue = SelectValue;
6168
6675
  exports.Separator = Separator;
6676
+ exports.SimpleCheckListInput = SimpleCheckListInput;
6677
+ exports.Slider = Slider;
6678
+ exports.SliderInput = SliderInput;
6679
+ exports.SortableListInput = SortableListInput;
6680
+ exports.StringValueListInput = StringValueListInput;
6169
6681
  exports.Switch = Switch;
6170
6682
  exports.SwitchInput = SwitchInput;
6683
+ exports.Tabs = Tabs;
6684
+ exports.TabsContent = TabsContent;
6685
+ exports.TabsList = TabsList;
6686
+ exports.TabsTrigger = TabsTrigger;
6687
+ exports.TagInput = TagInput;
6171
6688
  exports.TextAreaInput = TextAreaInput;
6172
6689
  exports.TextInput = TextInput;
6690
+ exports.TextInputGroup = TextInputGroup;
6173
6691
  exports.TextInputType = TextInputType;
6174
6692
  exports.Textarea = Textarea;
6693
+ exports.TimeInput = TimeInput;
6175
6694
  exports.Toaster = Toaster;
6176
6695
  exports.Tooltip = Tooltip;
6177
6696
  exports.TooltipContent = TooltipContent;
6178
6697
  exports.TooltipProvider = TooltipProvider;
6179
6698
  exports.TooltipTrigger = TooltipTrigger;
6180
6699
  exports.badgeVariants = badgeVariants;
6700
+ exports.buttonGroupVariants = buttonGroupVariants;
6181
6701
  exports.buttonVariants = buttonVariants;
6182
6702
  exports.cn = cn;
6183
6703
  exports.entitiesToGroupedOption = entitiesToGroupedOption;
@@ -6190,6 +6710,7 @@ exports.getDynamicSchema = getDynamicSchema;
6190
6710
  exports.getFieldLabel = getFieldLabel;
6191
6711
  exports.handleOnChage = handleOnChage;
6192
6712
  exports.inputFieldComp = inputFieldComp;
6713
+ exports.isValidField = isValidField;
6193
6714
  exports.mockFields = mockFields;
6194
6715
  exports.useFormField = useFormField;
6195
6716
  exports.validationMessages = validationMessages;