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 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-2"
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 px-2" : "flex flex-col gap-2 w-full px-2";
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 renderGroup = (group, groupDirection = "row") => {
5618
- const dirClass = groupDirection === "row" ? "flex flex-row items-start gap-4 py-3 w-full" : "flex flex-col gap-4 py-3 w-full";
5619
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: dirClass, children: group.map(
5620
- (f, idx) => isFieldProps(f) ? renderField(f) : Array.isArray(f) ? (
5621
- // Solo soportamos [[FieldProps]] como subgrupo
5622
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex flex-row items-start gap-4", children: f.map(
5623
- (subField) => isFieldProps(subField) ? renderField(subField) : null
5624
- ) }, idx)
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
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full grid grid-cols-1 ${gap} ${className}`, children: fields.map((f, idx) => {
5629
- if (isFieldProps(f)) {
5630
- return renderField(f);
5631
- } else if (Array.isArray(f)) {
5632
- if (f.length > 0 && Array.isArray(f[0])) {
5633
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4 py-3", children: f.map((subGroup, subIdx) => /* @__PURE__ */ jsxRuntime.jsx(
5634
- "div",
5635
- {
5636
- className: "w-full flex flex-row items-start gap-4",
5637
- children: Array.isArray(subGroup) && subGroup.map(
5638
- (subField) => isFieldProps(subField) ? renderField(subField) : null
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
  };