shadcn-zod-formkit 1.31.0 → 1.33.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.cjs +70 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.mjs +71 -65
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.33.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.31.0.tgz +0 -0
package/dist/index.cjs
CHANGED
|
@@ -4285,6 +4285,7 @@ var DateInput = class extends BaseInput {
|
|
|
4285
4285
|
};
|
|
4286
4286
|
var FieldTimeInput = ({ form, input, isSubmitting }) => {
|
|
4287
4287
|
const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
|
|
4288
|
+
const infoTooltip = input?.infoTooltip;
|
|
4288
4289
|
const groupConfig = input.inputGroupConfig;
|
|
4289
4290
|
const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
|
|
4290
4291
|
const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
|
|
@@ -4317,27 +4318,34 @@ var FieldTimeInput = ({ form, input, isSubmitting }) => {
|
|
|
4317
4318
|
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { children: [
|
|
4318
4319
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
4319
4320
|
/* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
|
|
4320
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4321
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { className: "flex flex-row gap-1", children: [
|
|
4322
|
+
infoTooltip && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
4323
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { size: 20 }) }),
|
|
4324
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: infoTooltip }) })
|
|
4325
|
+
] }),
|
|
4326
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4327
|
+
Button,
|
|
4328
|
+
{
|
|
4329
|
+
variant: "outline",
|
|
4330
|
+
type: "button",
|
|
4331
|
+
className: cn(
|
|
4332
|
+
"w-full justify-start text-left py-0.5 ",
|
|
4333
|
+
!date && "text-muted-foreground"
|
|
4334
|
+
),
|
|
4335
|
+
children: [
|
|
4336
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 items-center gap-1 justify-start text-left ", children: [
|
|
4337
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, {}),
|
|
4338
|
+
date ? format(date, "PPP") : /* @__PURE__ */ jsxRuntime.jsx("span", { children: input.placeHolder ?? "Fecha" })
|
|
4339
|
+
] }),
|
|
4340
|
+
(iconsRight.length > 0 || textRight || autoValidate) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4341
|
+
textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
|
|
4342
|
+
iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 24, className: "w-6! h-6!" }, index)),
|
|
4343
|
+
autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
|
|
4344
|
+
] })
|
|
4345
|
+
]
|
|
4346
|
+
}
|
|
4347
|
+
)
|
|
4348
|
+
] }) }) }),
|
|
4341
4349
|
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4342
4350
|
Calendar,
|
|
4343
4351
|
{
|
|
@@ -6257,7 +6265,10 @@ var DynamicForm = ({
|
|
|
6257
6265
|
withFormWrapper = true,
|
|
6258
6266
|
btnGroupDirection = "flex-end",
|
|
6259
6267
|
withSubmitBtn = true,
|
|
6260
|
-
debug = false
|
|
6268
|
+
debug = false,
|
|
6269
|
+
isWrapInWizard = false,
|
|
6270
|
+
totalSteps = 0,
|
|
6271
|
+
currentStep = 1
|
|
6261
6272
|
}) => {
|
|
6262
6273
|
const [isPending, startTransition] = React3.useTransition();
|
|
6263
6274
|
const schema = React3.useMemo(() => {
|
|
@@ -6328,11 +6339,11 @@ var DynamicForm = ({
|
|
|
6328
6339
|
disabled: isPending,
|
|
6329
6340
|
onClick: onClick ? handleClick : void 0,
|
|
6330
6341
|
children: isPending ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6331
|
-
|
|
6332
|
-
|
|
6342
|
+
submitBtnLabelSubmiting,
|
|
6343
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-5 w-5 mr-2 animate-spin" })
|
|
6333
6344
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6334
|
-
|
|
6335
|
-
|
|
6345
|
+
submitBtnLabel,
|
|
6346
|
+
(totalSteps == 0 || totalSteps == currentStep) && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "h-5 w-5 mr-2" })
|
|
6336
6347
|
] })
|
|
6337
6348
|
}
|
|
6338
6349
|
)
|
|
@@ -6356,7 +6367,15 @@ var DynamicForm = ({
|
|
|
6356
6367
|
fields
|
|
6357
6368
|
}
|
|
6358
6369
|
),
|
|
6359
|
-
withFormWrapper && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6370
|
+
withFormWrapper && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6371
|
+
FormWrapper,
|
|
6372
|
+
{
|
|
6373
|
+
form,
|
|
6374
|
+
isWrapInWizard,
|
|
6375
|
+
handleSubmit,
|
|
6376
|
+
children: formBody
|
|
6377
|
+
}
|
|
6378
|
+
),
|
|
6360
6379
|
!withFormWrapper && formBody,
|
|
6361
6380
|
withErrorsAlert && errorAlertPosition === "down" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6362
6381
|
FormErrorsAlert,
|
|
@@ -6369,7 +6388,7 @@ var DynamicForm = ({
|
|
|
6369
6388
|
if (!withCard) return formContent;
|
|
6370
6389
|
return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { children: formContent }) });
|
|
6371
6390
|
};
|
|
6372
|
-
var FormWrapper = ({ form, handleSubmit, children, readOnly, debug }) => {
|
|
6391
|
+
var FormWrapper = ({ form, handleSubmit, children, readOnly, debug, isWrapInWizard }) => {
|
|
6373
6392
|
const allValues = form.watch();
|
|
6374
6393
|
return /* @__PURE__ */ jsxRuntime.jsx(Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6375
6394
|
"form",
|
|
@@ -6441,7 +6460,10 @@ function Stepper({ steps, currentStep, clickable = false, onStepClick }) {
|
|
|
6441
6460
|
var WizardForm = ({
|
|
6442
6461
|
fields,
|
|
6443
6462
|
record,
|
|
6444
|
-
onSubmit
|
|
6463
|
+
onSubmit,
|
|
6464
|
+
children,
|
|
6465
|
+
isWrapInWizard = true,
|
|
6466
|
+
skipSteps = false
|
|
6445
6467
|
}) => {
|
|
6446
6468
|
const [currentStep, setCurrentStep] = React3.useState(1);
|
|
6447
6469
|
const flattenFields4 = (list) => list.flatMap((f) => Array.isArray(f) ? flattenFields4(f) : f);
|
|
@@ -6452,40 +6474,21 @@ var WizardForm = ({
|
|
|
6452
6474
|
);
|
|
6453
6475
|
const stepFields = allFields.filter((f) => (f.step ?? 1) === currentStep);
|
|
6454
6476
|
return /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: "flex flex-col gap-4 px-4", children: [
|
|
6455
|
-
/* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
{
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
className: "w-32",
|
|
6471
|
-
onClick: () => setCurrentStep((prev) => prev - 1),
|
|
6472
|
-
disabled: currentStep === 1,
|
|
6473
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeftIcon, {})
|
|
6474
|
-
}
|
|
6475
|
-
),
|
|
6476
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6477
|
-
Button,
|
|
6478
|
-
{
|
|
6479
|
-
variant: "outline",
|
|
6480
|
-
className: "w-32",
|
|
6481
|
-
onClick: () => setCurrentStep((prev) => prev + 1),
|
|
6482
|
-
disabled: currentStep > totalSteps,
|
|
6483
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRightIcon, {})
|
|
6484
|
-
}
|
|
6485
|
-
)
|
|
6486
|
-
] })
|
|
6487
|
-
] }) }),
|
|
6488
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6477
|
+
/* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-between mb-4 gap-2 px-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6478
|
+
Stepper,
|
|
6479
|
+
{
|
|
6480
|
+
steps: Array(totalSteps).fill({}),
|
|
6481
|
+
currentStep,
|
|
6482
|
+
clickable: skipSteps,
|
|
6483
|
+
onStepClick: setCurrentStep
|
|
6484
|
+
}
|
|
6485
|
+
) }) }),
|
|
6486
|
+
children ? children({
|
|
6487
|
+
stepFields,
|
|
6488
|
+
currentStep,
|
|
6489
|
+
totalSteps,
|
|
6490
|
+
setCurrentStep
|
|
6491
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
6489
6492
|
DynamicForm,
|
|
6490
6493
|
{
|
|
6491
6494
|
record,
|
|
@@ -6494,7 +6497,10 @@ var WizardForm = ({
|
|
|
6494
6497
|
withCard: false,
|
|
6495
6498
|
errorAlertPosition: "down",
|
|
6496
6499
|
fields: stepFields,
|
|
6497
|
-
onSubmit
|
|
6500
|
+
onSubmit,
|
|
6501
|
+
isWrapInWizard: true,
|
|
6502
|
+
currentStep,
|
|
6503
|
+
totalSteps
|
|
6498
6504
|
}
|
|
6499
6505
|
)
|
|
6500
6506
|
] });
|