hs-uix 1.1.0 → 1.2.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/datatable.js +21 -8
- package/dist/datatable.mjs +21 -8
- package/dist/form.js +187 -44
- package/dist/form.mjs +187 -44
- package/dist/index.js +208 -52
- package/dist/index.mjs +208 -52
- package/form.d.ts +1 -0
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -91,12 +91,19 @@ var computeAutoWidths = (columns, data) => {
|
|
|
91
91
|
columns.forEach((col) => {
|
|
92
92
|
if (col.width && col.cellWidth) return;
|
|
93
93
|
const values = sample.map((row) => row[col.field]).filter((v) => v != null);
|
|
94
|
-
const strings = values.map((v) =>
|
|
94
|
+
const strings = values.map((v) => {
|
|
95
|
+
const s = String(v);
|
|
96
|
+
const truncLen = typeof col.truncate === "number" ? col.truncate : col.truncate && typeof col.truncate === "object" ? col.truncate.maxLength : null;
|
|
97
|
+
return truncLen && s.length > truncLen ? s.slice(0, truncLen) : s;
|
|
98
|
+
});
|
|
95
99
|
let widthHint = null;
|
|
96
100
|
let cellWidthHint = null;
|
|
97
101
|
if (col.editable && col.editType && NARROW_EDIT_TYPES.has(col.editType)) {
|
|
98
102
|
cellWidthHint = "min";
|
|
99
103
|
}
|
|
104
|
+
if (col.truncate === true) {
|
|
105
|
+
cellWidthHint = cellWidthHint || "min";
|
|
106
|
+
}
|
|
100
107
|
if (strings.length > 0) {
|
|
101
108
|
const lengths = strings.map((s) => s.length);
|
|
102
109
|
const maxLen = Math.max(...lengths);
|
|
@@ -870,20 +877,26 @@ var DataTable = ({
|
|
|
870
877
|
const rawStr = String(rawValue ?? "");
|
|
871
878
|
if (col.truncate && rawStr.length > 0) {
|
|
872
879
|
if (col.truncate === true) {
|
|
873
|
-
|
|
880
|
+
if (col.renderCell) {
|
|
881
|
+
const content2 = col.renderCell(rawValue, row);
|
|
882
|
+
if (col.editable) {
|
|
883
|
+
return /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Link, { variant: "dark", onClick: () => startEditing(rowId, col.field, rawValue) }, content2 || "--");
|
|
884
|
+
}
|
|
885
|
+
return content2;
|
|
886
|
+
}
|
|
874
887
|
if (col.editable) {
|
|
875
|
-
return /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Text, { truncate: { tooltipText: rawStr } }, /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Link, { variant: "dark", onClick: () => startEditing(rowId, col.field, rawValue) },
|
|
888
|
+
return /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Text, { truncate: { tooltipText: rawStr } }, /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Link, { variant: "dark", onClick: () => startEditing(rowId, col.field, rawValue) }, rawStr || "--"));
|
|
876
889
|
}
|
|
877
|
-
return /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Text, { truncate: { tooltipText: rawStr } },
|
|
890
|
+
return /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Text, { truncate: { tooltipText: rawStr } }, rawStr);
|
|
878
891
|
}
|
|
879
|
-
const maxLen = col.truncate.maxLength || 100;
|
|
892
|
+
const maxLen = typeof col.truncate === "number" ? col.truncate : col.truncate.maxLength || 100;
|
|
880
893
|
if (rawStr.length > maxLen) {
|
|
881
894
|
const truncatedStr = rawStr.slice(0, maxLen) + "\u2026";
|
|
882
|
-
const
|
|
895
|
+
const content2 = col.renderCell ? col.renderCell(truncatedStr, row) : truncatedStr;
|
|
883
896
|
if (col.editable) {
|
|
884
|
-
return /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Link, { variant: "dark", onClick: () => startEditing(rowId, col.field, rawValue) },
|
|
897
|
+
return /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Link, { variant: "dark", onClick: () => startEditing(rowId, col.field, rawValue) }, content2 || "--");
|
|
885
898
|
}
|
|
886
|
-
return /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Text, { truncate: { tooltipText: rawStr } },
|
|
899
|
+
return col.renderCell ? content2 : /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Text, { truncate: { tooltipText: rawStr } }, content2 || "--");
|
|
887
900
|
}
|
|
888
901
|
}
|
|
889
902
|
const content = col.renderCell ? col.renderCell(rawValue, row) : rawValue;
|
|
@@ -1189,7 +1202,6 @@ var runDefaultFieldValidator = (value, field, allValues) => {
|
|
|
1189
1202
|
if (!isTimeValueObject(value)) return `${errorPrefix} has an invalid time`;
|
|
1190
1203
|
break;
|
|
1191
1204
|
case "datetime": {
|
|
1192
|
-
if (isDateValueObject(value)) break;
|
|
1193
1205
|
if (!isPlainObject(value)) return `${errorPrefix} has an invalid date/time`;
|
|
1194
1206
|
const hasDate = value.date !== void 0;
|
|
1195
1207
|
const hasTime = value.time !== void 0;
|
|
@@ -1256,7 +1268,7 @@ var collectAsyncValidatorPromises = (value, field, allValues, context) => {
|
|
|
1256
1268
|
var runValidators = (value, field, allValues, fieldTypes, options = {}) => {
|
|
1257
1269
|
const includeCustomValidators = options.includeCustomValidators !== false;
|
|
1258
1270
|
const msg = options.messages || {};
|
|
1259
|
-
if (field.type === "display" || field.type === "crmPropertyList" || field.type === "crmAssociationPropertyList") return null;
|
|
1271
|
+
if (field.type === "display" || field.type === "crmPropertyList" || field.type === "crmAssociationPropertyList" || field.type === "fieldGroup") return null;
|
|
1260
1272
|
const isRequired = resolveRequired(field, allValues);
|
|
1261
1273
|
const plugin = fieldTypes && fieldTypes[field.type];
|
|
1262
1274
|
const empty = plugin && plugin.isEmpty ? plugin.isEmpty(value) : isValueEmpty(value, field);
|
|
@@ -1403,6 +1415,8 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
1403
1415
|
// (values, { reset, rawValues }) => void | Promise
|
|
1404
1416
|
transformValues,
|
|
1405
1417
|
// (values) => values — reshape before submit
|
|
1418
|
+
transformInitialValues,
|
|
1419
|
+
// (rawInitialValues) => values — reshape raw data on load
|
|
1406
1420
|
onBeforeSubmit,
|
|
1407
1421
|
// (values) => boolean | Promise<boolean> — intercept submit
|
|
1408
1422
|
onSubmitSuccess,
|
|
@@ -1566,12 +1580,27 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
1566
1580
|
prevSuccessRef.current = formSuccess;
|
|
1567
1581
|
}, [addAlert, formSuccess, successTitle]);
|
|
1568
1582
|
const computeInitialValues = () => {
|
|
1583
|
+
const resolved = transformInitialValues && initialValues ? transformInitialValues(initialValues) : initialValues;
|
|
1569
1584
|
const vals = {};
|
|
1570
1585
|
for (const field of fields) {
|
|
1571
1586
|
if (field.type === "display" || field.type === "crmPropertyList" || field.type === "crmAssociationPropertyList") continue;
|
|
1587
|
+
if (field.type === "fieldGroup" && field.items && field.fields) {
|
|
1588
|
+
for (const item of field.items) {
|
|
1589
|
+
const subFields = field.fields(item);
|
|
1590
|
+
for (const sf of subFields) {
|
|
1591
|
+
const plugin2 = fieldTypes && fieldTypes[sf.type];
|
|
1592
|
+
const emptyValue2 = plugin2 && plugin2.getEmptyValue ? plugin2.getEmptyValue() : getEmptyValue(sf);
|
|
1593
|
+
let init2 = resolved && resolved[sf.name] !== void 0 ? resolved[sf.name] : sf.defaultValue !== void 0 ? sf.defaultValue : emptyValue2;
|
|
1594
|
+
if (sf.transformIn) init2 = sf.transformIn(init2);
|
|
1595
|
+
vals[sf.name] = init2;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
continue;
|
|
1599
|
+
}
|
|
1572
1600
|
const plugin = fieldTypes && fieldTypes[field.type];
|
|
1573
1601
|
const emptyValue = plugin && plugin.getEmptyValue ? plugin.getEmptyValue() : getEmptyValue(field);
|
|
1574
|
-
|
|
1602
|
+
let init = resolved && resolved[field.name] !== void 0 ? resolved[field.name] : field.defaultValue !== void 0 ? field.defaultValue : emptyValue;
|
|
1603
|
+
if (field.transformIn) init = field.transformIn(init);
|
|
1575
1604
|
vals[field.name] = init;
|
|
1576
1605
|
}
|
|
1577
1606
|
return vals;
|
|
@@ -1604,7 +1633,14 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
1604
1633
|
formErrorsRef.current = formErrors;
|
|
1605
1634
|
const fieldByName = (0, import_react2.useMemo)(() => {
|
|
1606
1635
|
const map = /* @__PURE__ */ new Map();
|
|
1607
|
-
for (const field of fields)
|
|
1636
|
+
for (const field of fields) {
|
|
1637
|
+
map.set(field.name, field);
|
|
1638
|
+
if (field.type === "fieldGroup" && field.items && field.fields) {
|
|
1639
|
+
for (const item of field.items) {
|
|
1640
|
+
for (const sf of field.fields(item)) map.set(sf.name, sf);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1608
1644
|
return map;
|
|
1609
1645
|
}, [fields]);
|
|
1610
1646
|
const isDev = typeof process === "undefined" || !process.env || process.env.NODE_ENV !== "production";
|
|
@@ -2026,23 +2062,27 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2026
2062
|
);
|
|
2027
2063
|
const handleFieldInput = (0, import_react2.useCallback)(
|
|
2028
2064
|
(name, value) => {
|
|
2065
|
+
handleFieldChange(name, value);
|
|
2029
2066
|
if (!validateOnChange) return;
|
|
2030
2067
|
const err = validateField(name, value);
|
|
2031
2068
|
updateErrors({ [name]: err });
|
|
2032
2069
|
},
|
|
2033
|
-
[validateOnChange, validateField, updateErrors]
|
|
2070
|
+
[validateOnChange, validateField, updateErrors, handleFieldChange]
|
|
2034
2071
|
);
|
|
2035
2072
|
const handleFieldBlur = (0, import_react2.useCallback)(
|
|
2036
2073
|
(name, value) => {
|
|
2037
|
-
if (!validateOnBlur) return;
|
|
2038
2074
|
const resolvedValue = value != null ? value : formValuesRef.current[name];
|
|
2075
|
+
if (value != null && value !== formValuesRef.current[name]) {
|
|
2076
|
+
handleFieldChange(name, value);
|
|
2077
|
+
}
|
|
2078
|
+
if (!validateOnBlur) return;
|
|
2039
2079
|
const err = validateField(name, resolvedValue);
|
|
2040
2080
|
updateErrors({ [name]: err });
|
|
2041
2081
|
if (!err) {
|
|
2042
2082
|
triggerAsyncValidation(name, resolvedValue);
|
|
2043
2083
|
}
|
|
2044
2084
|
},
|
|
2045
|
-
[validateOnBlur, validateField, updateErrors, triggerAsyncValidation]
|
|
2085
|
+
[validateOnBlur, validateField, updateErrors, triggerAsyncValidation, handleFieldChange]
|
|
2046
2086
|
);
|
|
2047
2087
|
const handleSubmit = (0, import_react2.useCallback)(
|
|
2048
2088
|
async (e) => {
|
|
@@ -2075,8 +2115,17 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2075
2115
|
const rawValues = {};
|
|
2076
2116
|
for (const key of Object.keys(formValues)) {
|
|
2077
2117
|
const f = fieldByName.get(key);
|
|
2078
|
-
if (f && (f.type === "display" || f.type === "crmPropertyList" || f.type === "crmAssociationPropertyList")) continue;
|
|
2079
|
-
rawValues[key] = formValues[key];
|
|
2118
|
+
if (f && (f.type === "display" || f.type === "crmPropertyList" || f.type === "crmAssociationPropertyList" || f.type === "fieldGroup")) continue;
|
|
2119
|
+
rawValues[key] = f && f.transformOut ? f.transformOut(formValues[key]) : formValues[key];
|
|
2120
|
+
}
|
|
2121
|
+
for (const f of fields) {
|
|
2122
|
+
if (f.type !== "fieldGroup" || !f.items || !f.fields) continue;
|
|
2123
|
+
for (const item of f.items) {
|
|
2124
|
+
for (const sf of f.fields(item)) {
|
|
2125
|
+
if (formValues[sf.name] === void 0) continue;
|
|
2126
|
+
rawValues[sf.name] = sf.transformOut ? sf.transformOut(formValues[sf.name]) : formValues[sf.name];
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2080
2129
|
}
|
|
2081
2130
|
const submitValues = transformValues ? transformValues(rawValues) : rawValues;
|
|
2082
2131
|
if (onBeforeSubmit) {
|
|
@@ -2219,10 +2268,125 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2219
2268
|
const fieldOnChange = field.debounce ? (v) => handleDebouncedFieldChange(field.name, v) : (v) => handleFieldChange(field.name, v);
|
|
2220
2269
|
if (field.type === "display") {
|
|
2221
2270
|
if (field.render) {
|
|
2222
|
-
return field.render({
|
|
2271
|
+
return field.render({
|
|
2272
|
+
allValues: formValues,
|
|
2273
|
+
setFieldValue: (name, value) => handleFieldChange(name, value),
|
|
2274
|
+
setFieldError: (name, message) => updateErrors({ [name]: message })
|
|
2275
|
+
});
|
|
2223
2276
|
}
|
|
2224
2277
|
return null;
|
|
2225
2278
|
}
|
|
2279
|
+
if (field.type === "fieldGroup") {
|
|
2280
|
+
const items = field.items || [];
|
|
2281
|
+
const fieldsFn = field.fields;
|
|
2282
|
+
if (!fieldsFn) return null;
|
|
2283
|
+
const groupColumns = field.columns || 1;
|
|
2284
|
+
const showItemLabel = field.showItemLabel !== false;
|
|
2285
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Flex, { direction: "column", gap: "xs" }, field.label && /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Text, { format: { fontWeight: "demibold" } }, field.label), field.description && /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Text, { variant: "microcopy" }, field.description), items.map((item, itemIdx) => {
|
|
2286
|
+
const subFields = fieldsFn(item);
|
|
2287
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Flex, { key: item.key || itemIdx, direction: "row", gap: "xs", align: "end" }, showItemLabel && item.label && /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Box, { flex: 1 }, itemIdx === 0 ? /* @__PURE__ */ import_react2.default.createElement(
|
|
2288
|
+
import_ui_extensions2.Input,
|
|
2289
|
+
{
|
|
2290
|
+
name: `_fieldGroup-label-${field.name}-${itemIdx}`,
|
|
2291
|
+
label: "\xA0",
|
|
2292
|
+
value: item.label,
|
|
2293
|
+
readOnly: true,
|
|
2294
|
+
disabled: true
|
|
2295
|
+
}
|
|
2296
|
+
) : /* @__PURE__ */ import_react2.default.createElement(
|
|
2297
|
+
import_ui_extensions2.Input,
|
|
2298
|
+
{
|
|
2299
|
+
name: `_fieldGroup-label-${field.name}-${itemIdx}`,
|
|
2300
|
+
value: item.label,
|
|
2301
|
+
readOnly: true,
|
|
2302
|
+
disabled: true
|
|
2303
|
+
}
|
|
2304
|
+
)), subFields.map((sf) => {
|
|
2305
|
+
const sfValue = formValues[sf.name];
|
|
2306
|
+
const sfError = formErrors[sf.name] || null;
|
|
2307
|
+
const sfLabel = itemIdx === 0 ? sf.label : void 0;
|
|
2308
|
+
const sfReadOnly = sf.readOnly || formReadOnly;
|
|
2309
|
+
const sfDisabled = disabled || sf.disabled || formReadOnly;
|
|
2310
|
+
const sfOnChange = sf.debounce ? (v) => handleDebouncedFieldChange(sf.name, v) : (v) => handleFieldChange(sf.name, v);
|
|
2311
|
+
const sfProps = {
|
|
2312
|
+
name: sf.name,
|
|
2313
|
+
label: sfLabel,
|
|
2314
|
+
placeholder: sf.placeholder,
|
|
2315
|
+
description: itemIdx === 0 ? sf.description : void 0,
|
|
2316
|
+
readOnly: sfReadOnly,
|
|
2317
|
+
disabled: sfDisabled,
|
|
2318
|
+
error: !!sfError,
|
|
2319
|
+
validationMessage: sfError || void 0,
|
|
2320
|
+
...sf.fieldProps || {}
|
|
2321
|
+
};
|
|
2322
|
+
let sfElement;
|
|
2323
|
+
switch (sf.type) {
|
|
2324
|
+
case "select":
|
|
2325
|
+
sfElement = /* @__PURE__ */ import_react2.default.createElement(
|
|
2326
|
+
import_ui_extensions2.Select,
|
|
2327
|
+
{
|
|
2328
|
+
...sfProps,
|
|
2329
|
+
value: sfValue,
|
|
2330
|
+
options: resolveOptions(sf, formValues),
|
|
2331
|
+
onChange: sfOnChange
|
|
2332
|
+
}
|
|
2333
|
+
);
|
|
2334
|
+
break;
|
|
2335
|
+
case "number":
|
|
2336
|
+
sfElement = /* @__PURE__ */ import_react2.default.createElement(
|
|
2337
|
+
import_ui_extensions2.NumberInput,
|
|
2338
|
+
{
|
|
2339
|
+
...sfProps,
|
|
2340
|
+
value: sfValue,
|
|
2341
|
+
onChange: sfOnChange,
|
|
2342
|
+
onBlur: (v) => handleFieldBlur(sf.name, v)
|
|
2343
|
+
}
|
|
2344
|
+
);
|
|
2345
|
+
break;
|
|
2346
|
+
case "toggle":
|
|
2347
|
+
sfElement = /* @__PURE__ */ import_react2.default.createElement(
|
|
2348
|
+
import_ui_extensions2.Toggle,
|
|
2349
|
+
{
|
|
2350
|
+
name: sf.name,
|
|
2351
|
+
label: sfLabel || sf.label,
|
|
2352
|
+
checked: !!sfValue,
|
|
2353
|
+
size: sf.size || "md",
|
|
2354
|
+
labelDisplay: sf.labelDisplay || "top",
|
|
2355
|
+
readonly: sfReadOnly,
|
|
2356
|
+
disabled: sfDisabled,
|
|
2357
|
+
onChange: sfOnChange,
|
|
2358
|
+
...sf.fieldProps || {}
|
|
2359
|
+
}
|
|
2360
|
+
);
|
|
2361
|
+
break;
|
|
2362
|
+
case "time":
|
|
2363
|
+
sfElement = /* @__PURE__ */ import_react2.default.createElement(
|
|
2364
|
+
import_ui_extensions2.TimeInput,
|
|
2365
|
+
{
|
|
2366
|
+
...sfProps,
|
|
2367
|
+
value: sfValue,
|
|
2368
|
+
interval: sf.interval,
|
|
2369
|
+
onChange: sfOnChange,
|
|
2370
|
+
onBlur: (v) => handleFieldBlur(sf.name, v)
|
|
2371
|
+
}
|
|
2372
|
+
);
|
|
2373
|
+
break;
|
|
2374
|
+
default:
|
|
2375
|
+
sfElement = /* @__PURE__ */ import_react2.default.createElement(
|
|
2376
|
+
import_ui_extensions2.Input,
|
|
2377
|
+
{
|
|
2378
|
+
...sfProps,
|
|
2379
|
+
value: sfValue || "",
|
|
2380
|
+
onChange: sfOnChange,
|
|
2381
|
+
onInput: (v) => handleFieldInput(sf.name, v),
|
|
2382
|
+
onBlur: (v) => handleFieldBlur(sf.name, v)
|
|
2383
|
+
}
|
|
2384
|
+
);
|
|
2385
|
+
}
|
|
2386
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Box, { key: sf.name, flex: 1 }, sfElement);
|
|
2387
|
+
}));
|
|
2388
|
+
}));
|
|
2389
|
+
}
|
|
2226
2390
|
if (field.type === "crmPropertyList") {
|
|
2227
2391
|
return /* @__PURE__ */ import_react2.default.createElement(
|
|
2228
2392
|
import_crm.CrmPropertyList,
|
|
@@ -2767,38 +2931,19 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2767
2931
|
}
|
|
2768
2932
|
return elements;
|
|
2769
2933
|
};
|
|
2770
|
-
const
|
|
2934
|
+
const renderSingleColumnLayout = (fieldSubset) => {
|
|
2771
2935
|
const fieldList = fieldSubset || visibleFields;
|
|
2772
|
-
const rows = [];
|
|
2773
|
-
let i = 0;
|
|
2774
|
-
while (i < fieldList.length) {
|
|
2775
|
-
const field = fieldList[i];
|
|
2776
|
-
if (field.width === "half" && i + 1 < fieldList.length && fieldList[i + 1].width === "half" && !getDependsOnName(field)) {
|
|
2777
|
-
rows.push({ type: "pair", fields: [fieldList[i], fieldList[i + 1]] });
|
|
2778
|
-
i += 2;
|
|
2779
|
-
} else {
|
|
2780
|
-
rows.push({ type: "single", field });
|
|
2781
|
-
i++;
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
2936
|
const elements = [];
|
|
2785
2937
|
const processedDeps = /* @__PURE__ */ new Set();
|
|
2786
|
-
for (const
|
|
2787
|
-
if (
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
elements.push(
|
|
2795
|
-
/* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, { key: field.name }, renderField(field))
|
|
2796
|
-
);
|
|
2797
|
-
const dependents = getDependents(field);
|
|
2798
|
-
if (dependents.length > 0) {
|
|
2799
|
-
for (const dep of dependents) processedDeps.add(dep.name);
|
|
2800
|
-
elements.push(renderDependentGroup(field, dependents));
|
|
2801
|
-
}
|
|
2938
|
+
for (const field of fieldList) {
|
|
2939
|
+
if (processedDeps.has(field.name)) continue;
|
|
2940
|
+
elements.push(
|
|
2941
|
+
/* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, { key: field.name }, renderField(field))
|
|
2942
|
+
);
|
|
2943
|
+
const dependents = getDependents(field);
|
|
2944
|
+
if (dependents.length > 0) {
|
|
2945
|
+
for (const dep of dependents) processedDeps.add(dep.name);
|
|
2946
|
+
elements.push(renderDependentGroup(field, dependents));
|
|
2802
2947
|
}
|
|
2803
2948
|
}
|
|
2804
2949
|
return elements;
|
|
@@ -2809,10 +2954,20 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2809
2954
|
let batch = [];
|
|
2810
2955
|
const flushBatch = () => {
|
|
2811
2956
|
if (batch.length === 0) return;
|
|
2812
|
-
|
|
2813
|
-
|
|
2957
|
+
if (maxColumns) {
|
|
2958
|
+
const chunks = Array.from(
|
|
2959
|
+
{ length: Math.ceil(batch.length / maxColumns) },
|
|
2960
|
+
(_, i) => batch.slice(i * maxColumns, i * maxColumns + maxColumns)
|
|
2961
|
+
);
|
|
2962
|
+
for (const chunk of chunks) {
|
|
2963
|
+
const remainder = maxColumns - chunk.length;
|
|
2964
|
+
elements.push(
|
|
2965
|
+
/* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Flex, { key: `ag-${chunk[0].name}`, direction: "row", gap }, chunk.map((f) => /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Box, { key: f.name, flex: 1 }, renderField(f))), remainder > 0 && /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Box, { flex: remainder }))
|
|
2966
|
+
);
|
|
2967
|
+
}
|
|
2968
|
+
} else {
|
|
2814
2969
|
elements.push(
|
|
2815
|
-
/* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.AutoGrid, { key: `ag-${
|
|
2970
|
+
/* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.AutoGrid, { key: `ag-${batch[0].name}`, columnWidth, flexible: true, gap }, batch.map((f) => /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, { key: f.name }, renderField(f))))
|
|
2816
2971
|
);
|
|
2817
2972
|
}
|
|
2818
2973
|
batch = [];
|
|
@@ -2871,7 +3026,7 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2871
3026
|
if (layout && fieldSubset === visibleFields) return renderExplicitLayout();
|
|
2872
3027
|
if (columnWidth) return renderAutoGridLayout(fieldSubset);
|
|
2873
3028
|
if (columns > 1) return renderGridLayout(fieldSubset);
|
|
2874
|
-
return
|
|
3029
|
+
return renderSingleColumnLayout(fieldSubset);
|
|
2875
3030
|
};
|
|
2876
3031
|
const renderSections = () => {
|
|
2877
3032
|
const hasSections = Array.isArray(sections) && sections.length > 0;
|
|
@@ -2884,7 +3039,8 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2884
3039
|
for (const sec of sections) {
|
|
2885
3040
|
const sectionFields = sec.fields ? visibleFields.filter((f) => sec.fields.includes(f.name)) : [];
|
|
2886
3041
|
if (sectionFields.length === 0) continue;
|
|
2887
|
-
const
|
|
3042
|
+
const sectionContext = { values: formValues, errors: formErrors };
|
|
3043
|
+
const accordionContent = /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Flex, { direction: "column", gap }, sec.renderBefore && sec.renderBefore(sectionContext), renderFieldSubset(sectionFields), sec.renderAfter && sec.renderAfter(sectionContext));
|
|
2888
3044
|
const accordion = /* @__PURE__ */ import_react2.default.createElement(
|
|
2889
3045
|
import_ui_extensions2.Accordion,
|
|
2890
3046
|
{
|