formanitor 0.0.2 → 0.0.3
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 +49 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.mjs +49 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -2180,6 +2180,21 @@ var Section = ({ title, children }) => {
|
|
|
2180
2180
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: contentClassName, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 pt-4 space-y-4 border-t-0", children }) })
|
|
2181
2181
|
] });
|
|
2182
2182
|
};
|
|
2183
|
+
var ColumnLayout = ({
|
|
2184
|
+
columns,
|
|
2185
|
+
label,
|
|
2186
|
+
children
|
|
2187
|
+
}) => {
|
|
2188
|
+
const gridCols = Math.max(1, Math.min(columns, 12));
|
|
2189
|
+
const gridClass = `grid gap-4 w-full`;
|
|
2190
|
+
const style = {
|
|
2191
|
+
gridTemplateColumns: `repeat(${gridCols}, minmax(0, 1fr))`
|
|
2192
|
+
};
|
|
2193
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-6", children: [
|
|
2194
|
+
label != null && label !== "" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2 text-sm font-medium text-gray-700", children: label }),
|
|
2195
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: gridClass, style, children })
|
|
2196
|
+
] });
|
|
2197
|
+
};
|
|
2183
2198
|
var DynamicForm = () => {
|
|
2184
2199
|
const store = useFormStore();
|
|
2185
2200
|
const schema = store.getSchema();
|
|
@@ -2198,6 +2213,17 @@ var DynamicForm = () => {
|
|
|
2198
2213
|
if (node.type === "section") {
|
|
2199
2214
|
return /* @__PURE__ */ jsxRuntime.jsx(Section, { title: node.title, children: node.children.map((fieldId) => /* @__PURE__ */ jsxRuntime.jsx(FieldRenderer, { fieldId }, fieldId)) }, node.id);
|
|
2200
2215
|
}
|
|
2216
|
+
if (node.type === "column_layout") {
|
|
2217
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2218
|
+
ColumnLayout,
|
|
2219
|
+
{
|
|
2220
|
+
columns: node.columns,
|
|
2221
|
+
label: node.label,
|
|
2222
|
+
children: node.children.map((fieldId) => /* @__PURE__ */ jsxRuntime.jsx(FieldRenderer, { fieldId }, fieldId))
|
|
2223
|
+
},
|
|
2224
|
+
node.id
|
|
2225
|
+
);
|
|
2226
|
+
}
|
|
2201
2227
|
return null;
|
|
2202
2228
|
})
|
|
2203
2229
|
] });
|
|
@@ -2570,6 +2596,29 @@ var ReadOnlyForm = ({ schema, submission }) => {
|
|
|
2570
2596
|
fieldId
|
|
2571
2597
|
)) }, node.id);
|
|
2572
2598
|
}
|
|
2599
|
+
if (node.type === "column_layout") {
|
|
2600
|
+
const visibleFields = node.children.map((fieldId) => {
|
|
2601
|
+
const fieldDef = fieldMap.get(fieldId);
|
|
2602
|
+
return fieldDef ? { fieldId, fieldDef } : null;
|
|
2603
|
+
}).filter((f) => f !== null);
|
|
2604
|
+
if (visibleFields.length === 0) return null;
|
|
2605
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2606
|
+
ColumnLayout,
|
|
2607
|
+
{
|
|
2608
|
+
columns: node.columns,
|
|
2609
|
+
label: node.label,
|
|
2610
|
+
children: visibleFields.map(({ fieldId, fieldDef }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2611
|
+
ReadOnlyFieldRenderer,
|
|
2612
|
+
{
|
|
2613
|
+
fieldDef,
|
|
2614
|
+
value: formData[fieldId]
|
|
2615
|
+
},
|
|
2616
|
+
fieldId
|
|
2617
|
+
))
|
|
2618
|
+
},
|
|
2619
|
+
node.id
|
|
2620
|
+
);
|
|
2621
|
+
}
|
|
2573
2622
|
return null;
|
|
2574
2623
|
})
|
|
2575
2624
|
] });
|