shadcn-zod-formkit 1.13.0 → 1.15.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 +50 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.mjs +50 -18
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.15.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.13.0.tgz +0 -0
package/dist/index.cjs
CHANGED
|
@@ -196,11 +196,10 @@ var validationMessages = {
|
|
|
196
196
|
|
|
197
197
|
// src/components/custom/form/inputs/base/base-input.ts
|
|
198
198
|
var BaseInput = class {
|
|
199
|
-
constructor(input, form, isSubmitting
|
|
199
|
+
constructor(input, form, isSubmitting) {
|
|
200
200
|
this.input = input;
|
|
201
201
|
this.form = form;
|
|
202
202
|
this.isSubmitting = isSubmitting;
|
|
203
|
-
this.children = children;
|
|
204
203
|
}
|
|
205
204
|
};
|
|
206
205
|
var entityToInputOption = (entitiy, name = "name", description = "description", groupedLabel) => ({
|
|
@@ -5403,6 +5402,7 @@ var getFieldLabel = (fieldErrorKey, fields) => {
|
|
|
5403
5402
|
const foundField = fields.find((field) => field.name === fieldErrorKey);
|
|
5404
5403
|
return foundField?.label ?? fieldErrorKey;
|
|
5405
5404
|
};
|
|
5405
|
+
var isRenderableChild = (c) => c !== void 0 && c !== null && typeof c !== "function";
|
|
5406
5406
|
var FormFieldsGrid = ({
|
|
5407
5407
|
fields,
|
|
5408
5408
|
form,
|
|
@@ -5412,23 +5412,44 @@ var FormFieldsGrid = ({
|
|
|
5412
5412
|
gap = "gap-2"
|
|
5413
5413
|
}) => {
|
|
5414
5414
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full grid grid-cols-1 ${gap} ${className}`, children: fields.map(
|
|
5415
|
-
(
|
|
5416
|
-
"
|
|
5415
|
+
(inputOrGroup, idx) => Array.isArray(inputOrGroup) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5416
|
+
"div",
|
|
5417
5417
|
{
|
|
5418
|
-
className: "w-full flex flex-row
|
|
5419
|
-
children:
|
|
5420
|
-
|
|
5421
|
-
|
|
5418
|
+
className: "w-full flex flex-row items-start gap-4 py-3",
|
|
5419
|
+
children: inputOrGroup.map((field, subIdx) => {
|
|
5420
|
+
const fieldCopy = {
|
|
5421
|
+
...field,
|
|
5422
|
+
disabled: readOnly ? true : field.disabled
|
|
5423
|
+
};
|
|
5424
|
+
const renderInlineChild = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
|
|
5425
|
+
const renderInlineChildDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
|
|
5426
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full px-2", children: [
|
|
5427
|
+
renderInlineChild && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children }),
|
|
5428
|
+
InputFactory.create(fieldCopy, form, isPending),
|
|
5429
|
+
renderInlineChildDown && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children })
|
|
5430
|
+
] }, `field-${idx}-${subIdx}`);
|
|
5422
5431
|
})
|
|
5423
5432
|
},
|
|
5424
5433
|
`field-group-${idx}`
|
|
5425
5434
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
5426
|
-
"
|
|
5435
|
+
"div",
|
|
5427
5436
|
{
|
|
5428
5437
|
className: "flex flex-col justify-between py-3 w-full px-2",
|
|
5429
|
-
children:
|
|
5438
|
+
children: (() => {
|
|
5439
|
+
const fieldCopy = {
|
|
5440
|
+
...inputOrGroup,
|
|
5441
|
+
disabled: readOnly ? true : inputOrGroup.disabled
|
|
5442
|
+
};
|
|
5443
|
+
const renderUp = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
|
|
5444
|
+
const renderDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
|
|
5445
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5446
|
+
renderUp && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children }),
|
|
5447
|
+
InputFactory.create(fieldCopy, form, isPending),
|
|
5448
|
+
renderDown && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children })
|
|
5449
|
+
] });
|
|
5450
|
+
})()
|
|
5430
5451
|
},
|
|
5431
|
-
`field-
|
|
5452
|
+
`field-single-${idx}`
|
|
5432
5453
|
)
|
|
5433
5454
|
) });
|
|
5434
5455
|
};
|
|
@@ -5440,6 +5461,8 @@ var DynamicForm = ({
|
|
|
5440
5461
|
record = {},
|
|
5441
5462
|
onSubmit,
|
|
5442
5463
|
extraValidations,
|
|
5464
|
+
children,
|
|
5465
|
+
childrenHeader,
|
|
5443
5466
|
withErrorsAlert = true,
|
|
5444
5467
|
errorAlertPosition = "up",
|
|
5445
5468
|
withCard = false,
|
|
@@ -5469,12 +5492,18 @@ var DynamicForm = ({
|
|
|
5469
5492
|
}
|
|
5470
5493
|
};
|
|
5471
5494
|
const formContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
5472
|
-
/* @__PURE__ */ jsxRuntime.jsxs(CardTitle, { className: "flex items-center gap-2 p-2 border-b", children: [
|
|
5473
|
-
/* @__PURE__ */ jsxRuntime.
|
|
5474
|
-
|
|
5475
|
-
/* @__PURE__ */ jsxRuntime.
|
|
5476
|
-
|
|
5477
|
-
|
|
5495
|
+
/* @__PURE__ */ jsxRuntime.jsxs(CardTitle, { className: "flex flex-row items-center gap-2 p-2 border-b", children: [
|
|
5496
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-2 w-full", children: [
|
|
5497
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pencil, { className: "h-5 w-5" }),
|
|
5498
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
5499
|
+
/* @__PURE__ */ jsxRuntime.jsxs(CardTitle, { className: "text-xl", children: [
|
|
5500
|
+
formTitle,
|
|
5501
|
+
" "
|
|
5502
|
+
] }),
|
|
5503
|
+
formSubTitle && /* @__PURE__ */ jsxRuntime.jsx(CardDescription, { children: formSubTitle })
|
|
5504
|
+
] })
|
|
5505
|
+
] }),
|
|
5506
|
+
childrenHeader && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row items-center gap-2 w-full h-full", children: childrenHeader })
|
|
5478
5507
|
] }),
|
|
5479
5508
|
withErrorsAlert && errorAlertPosition === "up" && /* @__PURE__ */ jsxRuntime.jsx(FormErrorsAlert, { formState: form.formState, fields }),
|
|
5480
5509
|
/* @__PURE__ */ jsxRuntime.jsx(Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -5483,7 +5512,10 @@ var DynamicForm = ({
|
|
|
5483
5512
|
onSubmit: form.handleSubmit(handleSubmit),
|
|
5484
5513
|
className: `flex flex-col gap-2 ${readOnly ? "opacity-70 pointer-events-none select-none" : ""}`,
|
|
5485
5514
|
children: [
|
|
5486
|
-
/* @__PURE__ */ jsxRuntime.
|
|
5515
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full grid grid-cols-1", children: [
|
|
5516
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormFieldsGrid, { fields, form, readOnly }),
|
|
5517
|
+
children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row items-center gap-2 w-full h-full", children })
|
|
5518
|
+
] }),
|
|
5487
5519
|
!readOnly && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 justify-end items-end", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", size: "lg", className: submitBtnClass, disabled: isPending, children: isPending ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5488
5520
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
|
|
5489
5521
|
"Guardando..."
|