shadcn-zod-formkit 1.21.0 → 1.22.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 +23 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +23 -40
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.22.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.21.0.tgz +0 -0
package/dist/index.mjs
CHANGED
|
@@ -5551,63 +5551,46 @@ var getFieldLabel = (fieldErrorKey, fields) => {
|
|
|
5551
5551
|
return foundField?.label ?? fieldErrorKey;
|
|
5552
5552
|
};
|
|
5553
5553
|
var isRenderableChild = (c) => c !== void 0 && c !== null && typeof c !== "function";
|
|
5554
|
-
var isFieldProps = (f) =>
|
|
5555
|
-
return !Array.isArray(f);
|
|
5556
|
-
};
|
|
5554
|
+
var isFieldProps = (f) => !Array.isArray(f);
|
|
5557
5555
|
var FormFieldsGrid = ({
|
|
5558
5556
|
fields,
|
|
5559
5557
|
form,
|
|
5560
5558
|
isPending,
|
|
5561
5559
|
readOnly,
|
|
5562
5560
|
className = "",
|
|
5563
|
-
gap = "gap-
|
|
5561
|
+
gap = "gap-4"
|
|
5564
5562
|
}) => {
|
|
5565
5563
|
const renderField = (field) => {
|
|
5566
|
-
const fieldCopy = {
|
|
5567
|
-
...field,
|
|
5568
|
-
disabled: readOnly ? true : field.disabled
|
|
5569
|
-
};
|
|
5564
|
+
const fieldCopy = { ...field, disabled: readOnly ? true : field.disabled };
|
|
5570
5565
|
const renderUp = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
|
|
5571
5566
|
const renderDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
|
|
5572
|
-
const dirClass = fieldCopy.direction === "row" ? "flex flex-row items-center gap-4 w-full
|
|
5567
|
+
const dirClass = fieldCopy.direction === "row" ? "flex flex-col sm:flex-row sm:items-center sm:gap-4 w-full flex-wrap" : "flex flex-col gap-2 w-full";
|
|
5573
5568
|
return /* @__PURE__ */ jsxs("div", { className: dirClass, children: [
|
|
5574
5569
|
renderUp && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children }),
|
|
5575
5570
|
InputFactory.create(fieldCopy, form, isPending),
|
|
5576
5571
|
renderDown && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children })
|
|
5577
5572
|
] });
|
|
5578
5573
|
};
|
|
5579
|
-
const
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
) : null
|
|
5588
|
-
) });
|
|
5574
|
+
const renderColumn = (col) => {
|
|
5575
|
+
if (col.length === 0) return null;
|
|
5576
|
+
const colDirection = isFieldProps(col[0]) && col[0].direction === "row" ? "flex flex-col sm:flex-row sm:items-center sm:gap-4 w-full flex-wrap" : "flex flex-col gap-2 w-full";
|
|
5577
|
+
return /* @__PURE__ */ jsx("div", { className: colDirection, children: col.map((item, idx) => {
|
|
5578
|
+
if (isFieldProps(item)) return renderField(item);
|
|
5579
|
+
if (Array.isArray(item)) return renderColumn(item);
|
|
5580
|
+
return null;
|
|
5581
|
+
}) });
|
|
5589
5582
|
};
|
|
5590
|
-
|
|
5591
|
-
if (
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
if (
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
)
|
|
5602
|
-
},
|
|
5603
|
-
subIdx
|
|
5604
|
-
)) }, idx);
|
|
5605
|
-
} else {
|
|
5606
|
-
const firstField = f[0];
|
|
5607
|
-
const direction = firstField?.direction ?? "row";
|
|
5608
|
-
return /* @__PURE__ */ jsx("div", { children: renderGroup(f, direction) }, idx);
|
|
5609
|
-
}
|
|
5610
|
-
}
|
|
5583
|
+
const renderRow = (row) => {
|
|
5584
|
+
if (row.length === 0) return null;
|
|
5585
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full flex flex-col sm:flex-row sm:gap-4 py-2 flex-wrap", children: row.map((col, idx) => {
|
|
5586
|
+
if (isFieldProps(col)) return renderColumn([col]);
|
|
5587
|
+
if (Array.isArray(col)) return renderColumn(col);
|
|
5588
|
+
return null;
|
|
5589
|
+
}) });
|
|
5590
|
+
};
|
|
5591
|
+
return /* @__PURE__ */ jsx("div", { className: `w-full flex flex-col ${gap} ${className}`, children: fields.map((f, idx) => {
|
|
5592
|
+
if (isFieldProps(f)) return /* @__PURE__ */ jsx("div", { children: renderField(f) }, idx);
|
|
5593
|
+
if (Array.isArray(f)) return /* @__PURE__ */ jsx("div", { children: renderRow(f) }, idx);
|
|
5611
5594
|
return null;
|
|
5612
5595
|
}) });
|
|
5613
5596
|
};
|