shadcn-zod-formkit 1.29.0 → 1.30.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
@@ -2221,6 +2221,10 @@ var ColorInput = class extends BaseInput {
2221
2221
  }
2222
2222
  };
2223
2223
  var PRESET_COLORS = [
2224
+ "#9A275A",
2225
+ // QuinaMagenta
2226
+ "#800000",
2227
+ // Maroon
2224
2228
  "#ef4444",
2225
2229
  // red
2226
2230
  "#f97316",
@@ -2229,18 +2233,32 @@ var PRESET_COLORS = [
2229
2233
  // yellow
2230
2234
  "#22c55e",
2231
2235
  // green
2236
+ "#99EDCC",
2237
+ // Aquamarine
2238
+ "#00FF00",
2239
+ // lime
2240
+ "#00FFFF",
2241
+ // Aqua
2232
2242
  "#06b6d4",
2233
2243
  // cyan
2234
2244
  "#3b82f6",
2235
2245
  // blue
2236
2246
  "#8b5cf6",
2237
2247
  // purple
2248
+ "#800080",
2249
+ // purple
2250
+ "#FF00FF",
2251
+ // Fuchsia
2238
2252
  "#ec4899",
2239
2253
  // pink
2240
2254
  "#64748b",
2241
2255
  // slate
2242
- "#000000"
2256
+ "#000000",
2243
2257
  // black
2258
+ "#808080",
2259
+ // Gray
2260
+ "#FFFFFF"
2261
+ // White
2244
2262
  ];
2245
2263
  var FieldColor = ({ form, input, isSubmitting }) => {
2246
2264
  const [ColorCmp, _setColorCmp] = React3.useState(ColorComp);
@@ -2293,13 +2311,13 @@ var ColorComp = React3__namespace.default.forwardRef(
2293
2311
  }
2294
2312
  };
2295
2313
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
2296
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 p-2", children: PRESET_COLORS.map((presetColor) => /* @__PURE__ */ jsxRuntime.jsx(
2314
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 p-2", children: PRESET_COLORS.map((presetColor) => /* @__PURE__ */ jsxRuntime.jsx(
2297
2315
  "button",
2298
2316
  {
2299
2317
  type: "button",
2300
2318
  disabled,
2301
2319
  className: cn(
2302
- "size-6 rounded-md border-2 transition-all hover:scale-110 disabled:opacity-50 disabled:cursor-not-allowed",
2320
+ "flex-1 size-4 shadow-lg rounded-md border-2 border-black transition-all hover:scale-110 disabled:opacity-50 disabled:cursor-not-allowed",
2303
2321
  color.hex === presetColor ? "border-foreground ring-2 ring-foreground/20" : "border-border hover:border-foreground/50"
2304
2322
  ),
2305
2323
  style: { backgroundColor: presetColor },
@@ -4564,6 +4582,111 @@ var FieldFileMultiUpload = ({ input, form, isSubmitting }) => {
4564
4582
  );
4565
4583
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
4566
4584
  };
4585
+ var TextInputGroup = class extends BaseInput {
4586
+ render() {
4587
+ const { input, form, isSubmitting } = this;
4588
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldTextGroup, { input, form, isSubmitting });
4589
+ }
4590
+ };
4591
+ var FieldTextGroup = ({ form, input, isSubmitting }) => {
4592
+ const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
4593
+ const formField = /* @__PURE__ */ jsxRuntime.jsx(
4594
+ FormField,
4595
+ {
4596
+ control: form.control,
4597
+ name: input.name,
4598
+ render: ({ field }) => {
4599
+ setIsValid(isValidField(input, form));
4600
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
4601
+ /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
4602
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: "shadow-lg", children: CustomInputGroup({
4603
+ input,
4604
+ isSubmitting,
4605
+ field,
4606
+ form,
4607
+ isValid: isValid2
4608
+ }) }),
4609
+ input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
4610
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
4611
+ ] });
4612
+ }
4613
+ },
4614
+ input.name
4615
+ );
4616
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
4617
+ };
4618
+ var CustomInputGroup = ({
4619
+ value,
4620
+ input,
4621
+ field,
4622
+ form,
4623
+ isSubmitting,
4624
+ onChange,
4625
+ isValid: isValid2
4626
+ }) => {
4627
+ const groupConfig = input.inputGroupConfig;
4628
+ const infoTooltip = input?.infoTooltip;
4629
+ const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
4630
+ const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
4631
+ const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
4632
+ const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
4633
+ const iconsRight = groupConfig?.iconsRight ?? [];
4634
+ const iconsLeft = groupConfig?.iconsLeft ?? [];
4635
+ const textLeft = groupConfig?.textLeft;
4636
+ const textRight = groupConfig?.textRight;
4637
+ const [showPassword, setShowPassword] = React3.useState(false);
4638
+ const isPasswordField = input.keyboardType === "password" /* PASSWORD */;
4639
+ const isNumberField = input.keyboardType === "number" /* NUMBER */;
4640
+ const showInputGroupAddons = iconsRight.length > 0 || textRight || autoValidate || infoTooltip || isPasswordField;
4641
+ return /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
4642
+ (iconsLeft.length > 0 || textLeft) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { children: [
4643
+ textLeft && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textLeft }),
4644
+ iconsLeft.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index))
4645
+ ] }),
4646
+ /* @__PURE__ */ jsxRuntime.jsx(
4647
+ InputGroupInput,
4648
+ {
4649
+ placeholder: input.placeHolder,
4650
+ disabled: input.disabled || isSubmitting,
4651
+ onBlur: field?.onBlur,
4652
+ name: field?.name,
4653
+ ref: field?.ref,
4654
+ type: isPasswordField && !showPassword ? "password" : isNumberField ? "number" : "text",
4655
+ value: field?.value ?? value ?? "",
4656
+ onChange: (e) => {
4657
+ if (onChange) {
4658
+ onChange(e);
4659
+ }
4660
+ let value2 = e.target.value;
4661
+ if (isNumberField) {
4662
+ value2 = e.target.value === "" ? "" : Number(e.target.value);
4663
+ }
4664
+ field?.onChange(value2);
4665
+ isValidField(input, form);
4666
+ handleOnChage(value2, input, field);
4667
+ }
4668
+ }
4669
+ ),
4670
+ showInputGroupAddons && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
4671
+ infoTooltip && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
4672
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { size: 20 }) }),
4673
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: infoTooltip }) })
4674
+ ] }),
4675
+ textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
4676
+ iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index)),
4677
+ isPasswordField && /* @__PURE__ */ jsxRuntime.jsx(
4678
+ "button",
4679
+ {
4680
+ type: "button",
4681
+ onClick: () => setShowPassword(!showPassword),
4682
+ className: "p-1",
4683
+ children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: 20 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { size: 20 })
4684
+ }
4685
+ ),
4686
+ autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
4687
+ ] })
4688
+ ] });
4689
+ };
4567
4690
  var KeyValueListInput = class extends BaseInput {
4568
4691
  render() {
4569
4692
  const { input, form, isSubmitting } = this;
@@ -4620,29 +4743,33 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
4620
4743
  children: [
4621
4744
  /* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup, { className: "w-full", children: [
4622
4745
  /* @__PURE__ */ jsxRuntime.jsx(ButtonGroupText, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive.Label, { htmlFor: "key", children: "Key" }) }),
4623
- /* @__PURE__ */ jsxRuntime.jsx(InputGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(
4624
- InputGroupInput,
4746
+ /* @__PURE__ */ jsxRuntime.jsx(
4747
+ CustomInputGroup,
4625
4748
  {
4626
- placeholder: "Key",
4749
+ autoValidate: true,
4627
4750
  value: pair.key,
4628
- disabled: isSubmitting,
4751
+ input,
4752
+ isValid: pair.key.trim() != "",
4753
+ isSubmitting,
4629
4754
  onChange: (e) => handleChange(index, "key", e.target.value),
4630
- className: "flex-1"
4755
+ form
4631
4756
  }
4632
- ) })
4757
+ )
4633
4758
  ] }),
4634
4759
  /* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup, { className: "w-full", children: [
4635
4760
  /* @__PURE__ */ jsxRuntime.jsx(ButtonGroupText, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive.Label, { htmlFor: "value", children: "Value" }) }),
4636
- /* @__PURE__ */ jsxRuntime.jsx(InputGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(
4637
- InputGroupInput,
4761
+ /* @__PURE__ */ jsxRuntime.jsx(
4762
+ CustomInputGroup,
4638
4763
  {
4639
- placeholder: "Value",
4764
+ autoValidate: true,
4640
4765
  value: pair.value,
4641
- disabled: isSubmitting,
4766
+ input,
4767
+ isValid: pair.value.trim() != "",
4768
+ isSubmitting,
4642
4769
  onChange: (e) => handleChange(index, "value", e.target.value),
4643
- className: "flex-1"
4770
+ form
4644
4771
  }
4645
- ) })
4772
+ )
4646
4773
  ] }),
4647
4774
  input.isRemovebleOption && /* @__PURE__ */ jsxRuntime.jsx(
4648
4775
  Button,
@@ -4773,111 +4900,6 @@ var FieldMultiSelect = ({ form, input, isSubmitting }) => {
4773
4900
  input.name
4774
4901
  );
4775
4902
  };
4776
- var TextInputGroup = class extends BaseInput {
4777
- render() {
4778
- const { input, form, isSubmitting } = this;
4779
- return /* @__PURE__ */ jsxRuntime.jsx(FieldTextGroup, { input, form, isSubmitting });
4780
- }
4781
- };
4782
- var FieldTextGroup = ({ form, input, isSubmitting }) => {
4783
- const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
4784
- const formField = /* @__PURE__ */ jsxRuntime.jsx(
4785
- FormField,
4786
- {
4787
- control: form.control,
4788
- name: input.name,
4789
- render: ({ field }) => {
4790
- setIsValid(isValidField(input, form));
4791
- return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
4792
- /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
4793
- /* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: "shadow-lg", children: CustomInputGroup({
4794
- input,
4795
- isSubmitting,
4796
- field,
4797
- form,
4798
- isValid: isValid2
4799
- }) }),
4800
- input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
4801
- /* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
4802
- ] });
4803
- }
4804
- },
4805
- input.name
4806
- );
4807
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
4808
- };
4809
- var CustomInputGroup = ({
4810
- value,
4811
- input,
4812
- field,
4813
- form,
4814
- isSubmitting,
4815
- onChange,
4816
- isValid: isValid2
4817
- }) => {
4818
- const groupConfig = input.inputGroupConfig;
4819
- const infoTooltip = input?.infoTooltip;
4820
- const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
4821
- const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
4822
- const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
4823
- const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
4824
- const iconsRight = groupConfig?.iconsRight ?? [];
4825
- const iconsLeft = groupConfig?.iconsLeft ?? [];
4826
- const textLeft = groupConfig?.textLeft;
4827
- const textRight = groupConfig?.textRight;
4828
- const [showPassword, setShowPassword] = React3.useState(false);
4829
- const isPasswordField = input.keyboardType === "password" /* PASSWORD */;
4830
- const isNumberField = input.keyboardType === "number" /* NUMBER */;
4831
- const showInputGroupAddons = iconsRight.length > 0 || textRight || autoValidate || infoTooltip || isPasswordField;
4832
- return /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
4833
- (iconsLeft.length > 0 || textLeft) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { children: [
4834
- textLeft && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textLeft }),
4835
- iconsLeft.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index))
4836
- ] }),
4837
- /* @__PURE__ */ jsxRuntime.jsx(
4838
- InputGroupInput,
4839
- {
4840
- placeholder: input.placeHolder,
4841
- disabled: input.disabled || isSubmitting,
4842
- onBlur: field?.onBlur,
4843
- name: field?.name,
4844
- ref: field?.ref,
4845
- type: isPasswordField && !showPassword ? "password" : isNumberField ? "number" : "text",
4846
- value: field?.value ?? value ?? "",
4847
- onChange: (e) => {
4848
- if (onChange) {
4849
- onChange(e);
4850
- }
4851
- let value2 = e.target.value;
4852
- if (isNumberField) {
4853
- value2 = e.target.value === "" ? "" : Number(e.target.value);
4854
- }
4855
- field?.onChange(value2);
4856
- isValidField(input, form);
4857
- handleOnChage(value2, input, field);
4858
- }
4859
- }
4860
- ),
4861
- showInputGroupAddons && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
4862
- infoTooltip && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
4863
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { size: 20 }) }),
4864
- /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: infoTooltip }) })
4865
- ] }),
4866
- textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
4867
- iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index)),
4868
- isPasswordField && /* @__PURE__ */ jsxRuntime.jsx(
4869
- "button",
4870
- {
4871
- type: "button",
4872
- onClick: () => setShowPassword(!showPassword),
4873
- className: "p-1",
4874
- children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: 20 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { size: 20 })
4875
- }
4876
- ),
4877
- autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
4878
- ] })
4879
- ] });
4880
- };
4881
4903
  var NumberInput = class extends BaseInput {
4882
4904
  render() {
4883
4905
  const { input, form, isSubmitting } = this;
@@ -4990,6 +5012,10 @@ var FieldRepeater = ({ form, input, isSubmitting }) => {
4990
5012
  });
4991
5013
  const canAdd = !input.maxItems || fields.length < input.maxItems;
4992
5014
  const canRemove = fields.length > (input.minItems ?? 0);
5015
+ const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
5016
+ React3.useEffect(() => {
5017
+ setIsValid(isValidField(input, form));
5018
+ }, [input]);
4993
5019
  return /* @__PURE__ */ jsxRuntime.jsx(
4994
5020
  FormField,
4995
5021
  {
@@ -5009,7 +5035,7 @@ var FieldRepeater = ({ form, input, isSubmitting }) => {
5009
5035
  return /* @__PURE__ */ jsxRuntime.jsx(
5010
5036
  "div",
5011
5037
  {
5012
- className: `grid gap-3 grid-cols-${cols}`,
5038
+ className: `grid gap-1 grid-cols-${cols}`,
5013
5039
  children: group.map((subField) => /* @__PURE__ */ jsxRuntime.jsx(
5014
5040
  FormField,
5015
5041
  {
@@ -5018,11 +5044,14 @@ var FieldRepeater = ({ form, input, isSubmitting }) => {
5018
5044
  render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "flex-1", children: [
5019
5045
  /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: subField.label }),
5020
5046
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
5021
- Input,
5047
+ CustomInputGroup,
5022
5048
  {
5023
- placeholder: subField.placeHolder,
5024
- disabled: subField.disabled || isSubmitting,
5025
- ...field
5049
+ autoValidate: true,
5050
+ value: field.value,
5051
+ input: subField,
5052
+ isValid: isValid2,
5053
+ field,
5054
+ form
5026
5055
  }
5027
5056
  ) }),
5028
5057
  /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { children: fieldState.error?.message })
@@ -5740,7 +5769,7 @@ var FieldSwitch = ({ input, form, isSubmitting }) => {
5740
5769
  onCheckedChange: (event) => {
5741
5770
  handleOnChage(event, input, field);
5742
5771
  },
5743
- disabled: false
5772
+ disabled: input.disabled || isSubmitting
5744
5773
  }
5745
5774
  ) })
5746
5775
  ] }) })
@@ -6332,6 +6361,122 @@ var FormWrapper = ({ form, handleSubmit, children, readOnly }) => {
6332
6361
  }
6333
6362
  ) });
6334
6363
  };
6364
+ function Stepper({ steps, currentStep, clickable = false, onStepClick }) {
6365
+ const handleStepClick = (stepNumber) => {
6366
+ if (clickable && onStepClick) {
6367
+ onStepClick(stepNumber);
6368
+ }
6369
+ };
6370
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-4 items-center justify-around", children: steps.map((step, index) => {
6371
+ const stepNumber = index + 1;
6372
+ const isCompleted = stepNumber < currentStep;
6373
+ const isCurrent = stepNumber === currentStep;
6374
+ const isUpcoming = stepNumber > currentStep;
6375
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 items-center", children: [
6376
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
6377
+ /* @__PURE__ */ jsxRuntime.jsx(
6378
+ "div",
6379
+ {
6380
+ onClick: () => handleStepClick(stepNumber),
6381
+ className: cn(
6382
+ "flex size-10 items-center shadow-lg justify-center rounded-full border-2 transition-all duration-300",
6383
+ isCompleted && "border-primary bg-primary text-primary-foreground",
6384
+ isCurrent && "border-primary bg-background text-primary scale-110",
6385
+ isUpcoming && "border-muted-foreground/60 bg-background border-b text-muted-foreground",
6386
+ clickable && "cursor-pointer hover:scale-125 hover:shadow-xl",
6387
+ !clickable && "cursor-default"
6388
+ ),
6389
+ children: isCompleted ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-5" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: stepNumber })
6390
+ }
6391
+ ),
6392
+ step.title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 text-center", children: [
6393
+ /* @__PURE__ */ jsxRuntime.jsx(
6394
+ "p",
6395
+ {
6396
+ className: cn(
6397
+ "text-sm font-medium transition-colors",
6398
+ (isCompleted || isCurrent) && "text-foreground",
6399
+ isUpcoming && "text-muted-foreground"
6400
+ ),
6401
+ children: step.title
6402
+ }
6403
+ ),
6404
+ step.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground max-w-[120px]", children: step.description })
6405
+ ] })
6406
+ ] }),
6407
+ index < steps.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-2 flex-1 mb-8", children: /* @__PURE__ */ jsxRuntime.jsx(
6408
+ "div",
6409
+ {
6410
+ className: cn(
6411
+ "h-0.5 w-full transition-all duration-300",
6412
+ stepNumber < currentStep ? "bg-primary" : "bg-muted-foreground/30"
6413
+ )
6414
+ }
6415
+ ) })
6416
+ ] }, index);
6417
+ }) }) });
6418
+ }
6419
+ var WizardForm = ({
6420
+ fields,
6421
+ record,
6422
+ onSubmit
6423
+ }) => {
6424
+ const [currentStep, setCurrentStep] = React3.useState(1);
6425
+ const flattenFields4 = (list) => list.flatMap((f) => Array.isArray(f) ? flattenFields4(f) : f);
6426
+ const allFields = flattenFields4(fields);
6427
+ const totalSteps = allFields.reduce(
6428
+ (max, f) => Math.max(max, f.step ?? 1),
6429
+ 1
6430
+ );
6431
+ const stepFields = allFields.filter((f) => (f.step ?? 1) === currentStep);
6432
+ return /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: "flex flex-col gap-4 px-4", children: [
6433
+ /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between mb-4 gap-2 px-4", children: [
6434
+ /* @__PURE__ */ jsxRuntime.jsx(
6435
+ Stepper,
6436
+ {
6437
+ steps: Array(totalSteps).fill({}),
6438
+ currentStep,
6439
+ clickable: true,
6440
+ onStepClick: setCurrentStep
6441
+ }
6442
+ ),
6443
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-center space-x-4 gap-2", children: [
6444
+ /* @__PURE__ */ jsxRuntime.jsx(
6445
+ Button,
6446
+ {
6447
+ variant: "outline",
6448
+ className: "w-32",
6449
+ onClick: () => setCurrentStep((prev) => prev - 1),
6450
+ disabled: currentStep === 1,
6451
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeftIcon, {})
6452
+ }
6453
+ ),
6454
+ /* @__PURE__ */ jsxRuntime.jsx(
6455
+ Button,
6456
+ {
6457
+ variant: "outline",
6458
+ className: "w-32",
6459
+ onClick: () => setCurrentStep((prev) => prev + 1),
6460
+ disabled: currentStep > totalSteps,
6461
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRightIcon, {})
6462
+ }
6463
+ )
6464
+ ] })
6465
+ ] }) }),
6466
+ /* @__PURE__ */ jsxRuntime.jsx(
6467
+ DynamicForm,
6468
+ {
6469
+ record,
6470
+ formSubTitle: "This is a subtitle",
6471
+ formTitle: "Wizard Form Example",
6472
+ withCard: false,
6473
+ errorAlertPosition: "down",
6474
+ fields: stepFields,
6475
+ onSubmit
6476
+ }
6477
+ )
6478
+ ] });
6479
+ };
6335
6480
  var DynamicFormExample = () => {
6336
6481
  const record = {
6337
6482
  username: "John Doe ",
@@ -6782,6 +6927,7 @@ exports.Tooltip = Tooltip;
6782
6927
  exports.TooltipContent = TooltipContent;
6783
6928
  exports.TooltipProvider = TooltipProvider;
6784
6929
  exports.TooltipTrigger = TooltipTrigger;
6930
+ exports.WizardForm = WizardForm;
6785
6931
  exports.badgeVariants = badgeVariants;
6786
6932
  exports.buttonGroupVariants = buttonGroupVariants;
6787
6933
  exports.buttonVariants = buttonVariants;