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.cjs
CHANGED
|
@@ -5589,63 +5589,46 @@ var getFieldLabel = (fieldErrorKey, fields) => {
|
|
|
5589
5589
|
return foundField?.label ?? fieldErrorKey;
|
|
5590
5590
|
};
|
|
5591
5591
|
var isRenderableChild = (c) => c !== void 0 && c !== null && typeof c !== "function";
|
|
5592
|
-
var isFieldProps = (f) =>
|
|
5593
|
-
return !Array.isArray(f);
|
|
5594
|
-
};
|
|
5592
|
+
var isFieldProps = (f) => !Array.isArray(f);
|
|
5595
5593
|
var FormFieldsGrid = ({
|
|
5596
5594
|
fields,
|
|
5597
5595
|
form,
|
|
5598
5596
|
isPending,
|
|
5599
5597
|
readOnly,
|
|
5600
5598
|
className = "",
|
|
5601
|
-
gap = "gap-
|
|
5599
|
+
gap = "gap-4"
|
|
5602
5600
|
}) => {
|
|
5603
5601
|
const renderField = (field) => {
|
|
5604
|
-
const fieldCopy = {
|
|
5605
|
-
...field,
|
|
5606
|
-
disabled: readOnly ? true : field.disabled
|
|
5607
|
-
};
|
|
5602
|
+
const fieldCopy = { ...field, disabled: readOnly ? true : field.disabled };
|
|
5608
5603
|
const renderUp = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
|
|
5609
5604
|
const renderDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
|
|
5610
|
-
const dirClass = fieldCopy.direction === "row" ? "flex flex-row items-center gap-4 w-full
|
|
5605
|
+
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";
|
|
5611
5606
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: dirClass, children: [
|
|
5612
5607
|
renderUp && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children }),
|
|
5613
5608
|
InputFactory.create(fieldCopy, form, isPending),
|
|
5614
5609
|
renderDown && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children })
|
|
5615
5610
|
] });
|
|
5616
5611
|
};
|
|
5617
|
-
const
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
) : null
|
|
5626
|
-
) });
|
|
5612
|
+
const renderColumn = (col) => {
|
|
5613
|
+
if (col.length === 0) return null;
|
|
5614
|
+
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";
|
|
5615
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: colDirection, children: col.map((item, idx) => {
|
|
5616
|
+
if (isFieldProps(item)) return renderField(item);
|
|
5617
|
+
if (Array.isArray(item)) return renderColumn(item);
|
|
5618
|
+
return null;
|
|
5619
|
+
}) });
|
|
5627
5620
|
};
|
|
5628
|
-
|
|
5629
|
-
if (
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
if (
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
)
|
|
5640
|
-
},
|
|
5641
|
-
subIdx
|
|
5642
|
-
)) }, idx);
|
|
5643
|
-
} else {
|
|
5644
|
-
const firstField = f[0];
|
|
5645
|
-
const direction = firstField?.direction ?? "row";
|
|
5646
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderGroup(f, direction) }, idx);
|
|
5647
|
-
}
|
|
5648
|
-
}
|
|
5621
|
+
const renderRow = (row) => {
|
|
5622
|
+
if (row.length === 0) return null;
|
|
5623
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex flex-col sm:flex-row sm:gap-4 py-2 flex-wrap", children: row.map((col, idx) => {
|
|
5624
|
+
if (isFieldProps(col)) return renderColumn([col]);
|
|
5625
|
+
if (Array.isArray(col)) return renderColumn(col);
|
|
5626
|
+
return null;
|
|
5627
|
+
}) });
|
|
5628
|
+
};
|
|
5629
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full flex flex-col ${gap} ${className}`, children: fields.map((f, idx) => {
|
|
5630
|
+
if (isFieldProps(f)) return /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderField(f) }, idx);
|
|
5631
|
+
if (Array.isArray(f)) return /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderRow(f) }, idx);
|
|
5649
5632
|
return null;
|
|
5650
5633
|
}) });
|
|
5651
5634
|
};
|