shadcn-zod-formkit 1.22.3 → 1.22.4

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
@@ -5589,49 +5589,55 @@ 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) => !Array.isArray(f);
5593
5592
  var FormFieldsGrid = ({
5594
5593
  fields,
5595
5594
  form,
5596
5595
  isPending,
5597
5596
  readOnly,
5598
5597
  className = "",
5599
- gap = "gap-4"
5598
+ gap = "gap-2"
5600
5599
  }) => {
5601
- const renderField = (field) => {
5602
- const fieldCopy = { ...field, disabled: readOnly ? true : field.disabled };
5603
- const renderUp = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
5604
- const renderDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
5605
- const dirClass = fieldCopy.direction === "row" ? "flex flex-col sm:flex-row sm:items-center sm:gap-x-4 gap-y-2 flex-wrap" : "flex flex-col gap-2";
5606
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: dirClass, children: [
5607
- renderUp && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children }),
5608
- InputFactory.create(fieldCopy, form, isPending),
5609
- renderDown && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children })
5610
- ] });
5611
- };
5612
- const renderColumn = (col, parentKey = "") => {
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-x-4 gap-y-2 flex-wrap" : "flex flex-col w-full";
5615
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: colDirection, children: col.map((item, idx) => {
5616
- if (isFieldProps(item))
5617
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-[200px]", children: renderField(item) }, `${parentKey}${item.name.toString()}-${idx}`);
5618
- if (Array.isArray(item)) return renderColumn(item, `${parentKey}col${idx}-`);
5619
- return null;
5620
- }) });
5621
- };
5622
- const renderRow = (row, parentKey = "") => {
5623
- if (row.length === 0) return null;
5624
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex flex-col sm:flex-row sm:gap-x-4 gap-y-2 py-2 flex-wrap gap-4", children: row.map((col, idx) => {
5625
- if (isFieldProps(col)) return renderColumn([col], `${parentKey}row${idx}-`);
5626
- if (Array.isArray(col)) return renderColumn(col, `${parentKey}row${idx}-`);
5627
- return null;
5628
- }) });
5629
- };
5630
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full flex flex-col ${gap} ${className}`, children: fields.map((f, idx) => {
5631
- if (isFieldProps(f)) return /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderField(f) }, `field-${f.name.toString()}-${idx}`);
5632
- if (Array.isArray(f)) return /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderRow(f, `row-${idx}-`) }, `row-${idx}`);
5633
- return null;
5634
- }) });
5600
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full grid grid-cols-1 ${gap} ${className}`, children: fields.map(
5601
+ (inputOrGroup, idx) => Array.isArray(inputOrGroup) ? /* @__PURE__ */ jsxRuntime.jsx(
5602
+ "div",
5603
+ {
5604
+ className: "w-full flex flex-row items-start gap-4 py-3",
5605
+ children: inputOrGroup.map((field, subIdx) => {
5606
+ const fieldCopy = {
5607
+ ...field,
5608
+ disabled: readOnly ? true : field.disabled
5609
+ };
5610
+ const renderInlineChild = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
5611
+ const renderInlineChildDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
5612
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full px-2", children: [
5613
+ renderInlineChild && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children }),
5614
+ InputFactory.create(fieldCopy, form, isPending),
5615
+ renderInlineChildDown && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children })
5616
+ ] }, `field-${idx}-${subIdx}`);
5617
+ })
5618
+ },
5619
+ `field-group-${idx}`
5620
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
5621
+ "div",
5622
+ {
5623
+ className: "flex flex-col justify-between py-3 w-full px-2",
5624
+ children: (() => {
5625
+ const fieldCopy = {
5626
+ ...inputOrGroup,
5627
+ disabled: readOnly ? true : inputOrGroup.disabled
5628
+ };
5629
+ const renderUp = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
5630
+ const renderDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
5631
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5632
+ renderUp && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children }),
5633
+ InputFactory.create(fieldCopy, form, isPending),
5634
+ renderDown && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fieldCopy.children })
5635
+ ] });
5636
+ })()
5637
+ },
5638
+ `field-single-${idx}`
5639
+ )
5640
+ ) });
5635
5641
  };
5636
5642
  var DynamicForm = ({
5637
5643
  formTitle,