shadcn-zod-formkit 1.30.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,8 @@ var ColorInput = class extends BaseInput {
2221
2221
  }
2222
2222
  };
2223
2223
  var PRESET_COLORS = [
2224
+ "#9A275A",
2225
+ // QuinaMagenta
2224
2226
  "#800000",
2225
2227
  // Maroon
2226
2228
  "#ef4444",
@@ -2231,6 +2233,8 @@ var PRESET_COLORS = [
2231
2233
  // yellow
2232
2234
  "#22c55e",
2233
2235
  // green
2236
+ "#99EDCC",
2237
+ // Aquamarine
2234
2238
  "#00FF00",
2235
2239
  // lime
2236
2240
  "#00FFFF",
@@ -2249,10 +2253,12 @@ var PRESET_COLORS = [
2249
2253
  // pink
2250
2254
  "#64748b",
2251
2255
  // slate
2256
+ "#000000",
2257
+ // black
2252
2258
  "#808080",
2253
2259
  // Gray
2254
- "#000000"
2255
- // black
2260
+ "#FFFFFF"
2261
+ // White
2256
2262
  ];
2257
2263
  var FieldColor = ({ form, input, isSubmitting }) => {
2258
2264
  const [ColorCmp, _setColorCmp] = React3.useState(ColorComp);
@@ -2305,13 +2311,13 @@ var ColorComp = React3__namespace.default.forwardRef(
2305
2311
  }
2306
2312
  };
2307
2313
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
2308
- /* @__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(
2309
2315
  "button",
2310
2316
  {
2311
2317
  type: "button",
2312
2318
  disabled,
2313
2319
  className: cn(
2314
- "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",
2315
2321
  color.hex === presetColor ? "border-foreground ring-2 ring-foreground/20" : "border-border hover:border-foreground/50"
2316
2322
  ),
2317
2323
  style: { backgroundColor: presetColor },
@@ -4752,7 +4758,7 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
4752
4758
  ] }),
4753
4759
  /* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup, { className: "w-full", children: [
4754
4760
  /* @__PURE__ */ jsxRuntime.jsx(ButtonGroupText, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive.Label, { htmlFor: "value", children: "Value" }) }),
4755
- /* @__PURE__ */ jsxRuntime.jsx(InputGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(
4761
+ /* @__PURE__ */ jsxRuntime.jsx(
4756
4762
  CustomInputGroup,
4757
4763
  {
4758
4764
  autoValidate: true,
@@ -4763,7 +4769,7 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
4763
4769
  onChange: (e) => handleChange(index, "value", e.target.value),
4764
4770
  form
4765
4771
  }
4766
- ) })
4772
+ )
4767
4773
  ] }),
4768
4774
  input.isRemovebleOption && /* @__PURE__ */ jsxRuntime.jsx(
4769
4775
  Button,
@@ -5763,7 +5769,7 @@ var FieldSwitch = ({ input, form, isSubmitting }) => {
5763
5769
  onCheckedChange: (event) => {
5764
5770
  handleOnChage(event, input, field);
5765
5771
  },
5766
- disabled: false
5772
+ disabled: input.disabled || isSubmitting
5767
5773
  }
5768
5774
  ) })
5769
5775
  ] }) })
@@ -6355,6 +6361,122 @@ var FormWrapper = ({ form, handleSubmit, children, readOnly }) => {
6355
6361
  }
6356
6362
  ) });
6357
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
+ };
6358
6480
  var DynamicFormExample = () => {
6359
6481
  const record = {
6360
6482
  username: "John Doe ",
@@ -6805,6 +6927,7 @@ exports.Tooltip = Tooltip;
6805
6927
  exports.TooltipContent = TooltipContent;
6806
6928
  exports.TooltipProvider = TooltipProvider;
6807
6929
  exports.TooltipTrigger = TooltipTrigger;
6930
+ exports.WizardForm = WizardForm;
6808
6931
  exports.badgeVariants = badgeVariants;
6809
6932
  exports.buttonGroupVariants = buttonGroupVariants;
6810
6933
  exports.buttonVariants = buttonVariants;