hs-uix 1.2.1 → 1.2.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/form.js +129 -3
- package/dist/form.mjs +129 -3
- package/dist/index.js +129 -3
- package/dist/index.mjs +129 -3
- package/package.json +1 -1
package/dist/form.js
CHANGED
|
@@ -509,6 +509,118 @@ var FormBuilder = (0, import_react.forwardRef)(function FormBuilder2(props, ref)
|
|
|
509
509
|
}
|
|
510
510
|
prevSuccessRef.current = formSuccess;
|
|
511
511
|
}, [addAlert, formSuccess, successTitle]);
|
|
512
|
+
if (process.env.NODE_ENV !== "production") {
|
|
513
|
+
const KNOWN_FIELD_PROPS = /* @__PURE__ */ new Set([
|
|
514
|
+
"name",
|
|
515
|
+
"type",
|
|
516
|
+
"label",
|
|
517
|
+
"description",
|
|
518
|
+
"placeholder",
|
|
519
|
+
"tooltip",
|
|
520
|
+
"required",
|
|
521
|
+
"readOnly",
|
|
522
|
+
"disabled",
|
|
523
|
+
"defaultValue",
|
|
524
|
+
"fieldProps",
|
|
525
|
+
"colSpan",
|
|
526
|
+
"width",
|
|
527
|
+
"visible",
|
|
528
|
+
"dependsOn",
|
|
529
|
+
"dependsOnConfig",
|
|
530
|
+
"group",
|
|
531
|
+
"debounce",
|
|
532
|
+
"pattern",
|
|
533
|
+
"patternMessage",
|
|
534
|
+
"minLength",
|
|
535
|
+
"maxLength",
|
|
536
|
+
"min",
|
|
537
|
+
"max",
|
|
538
|
+
"validate",
|
|
539
|
+
"validators",
|
|
540
|
+
"validateDebounce",
|
|
541
|
+
"useDefaultValidators",
|
|
542
|
+
"transformIn",
|
|
543
|
+
"transformOut",
|
|
544
|
+
"onFieldChange",
|
|
545
|
+
"onInput",
|
|
546
|
+
"onBlur",
|
|
547
|
+
"options",
|
|
548
|
+
"variant",
|
|
549
|
+
"inline",
|
|
550
|
+
"render",
|
|
551
|
+
"fields",
|
|
552
|
+
"items",
|
|
553
|
+
"showItemLabel",
|
|
554
|
+
"columns",
|
|
555
|
+
"repeaterProps",
|
|
556
|
+
"size",
|
|
557
|
+
"labelDisplay",
|
|
558
|
+
"textChecked",
|
|
559
|
+
"textUnchecked",
|
|
560
|
+
"rows",
|
|
561
|
+
"cols",
|
|
562
|
+
"resize",
|
|
563
|
+
"stepSize",
|
|
564
|
+
"precision",
|
|
565
|
+
"formatStyle",
|
|
566
|
+
"minValueReachedTooltip",
|
|
567
|
+
"maxValueReachedTooltip",
|
|
568
|
+
"currency",
|
|
569
|
+
"format",
|
|
570
|
+
"timezone",
|
|
571
|
+
"clearButtonLabel",
|
|
572
|
+
"todayButtonLabel",
|
|
573
|
+
"minValidationMessage",
|
|
574
|
+
"maxValidationMessage",
|
|
575
|
+
"interval",
|
|
576
|
+
"properties",
|
|
577
|
+
"direction",
|
|
578
|
+
"objectId",
|
|
579
|
+
"objectTypeId",
|
|
580
|
+
"associationLabels",
|
|
581
|
+
"filters",
|
|
582
|
+
"sort"
|
|
583
|
+
]);
|
|
584
|
+
const FIELD_SUGGESTIONS = {
|
|
585
|
+
fullWidth: 'Use width: "full" or colSpan instead',
|
|
586
|
+
title: "Use label instead",
|
|
587
|
+
maxColumns: "maxColumns is a FormBuilder prop, not a field prop"
|
|
588
|
+
};
|
|
589
|
+
const KNOWN_SECTION_PROPS = /* @__PURE__ */ new Set([
|
|
590
|
+
"id",
|
|
591
|
+
"label",
|
|
592
|
+
"fields",
|
|
593
|
+
"defaultOpen",
|
|
594
|
+
"info",
|
|
595
|
+
"renderBefore",
|
|
596
|
+
"renderAfter"
|
|
597
|
+
]);
|
|
598
|
+
const SECTION_SUGGESTIONS = {
|
|
599
|
+
title: "Use label instead",
|
|
600
|
+
name: "Use id instead",
|
|
601
|
+
open: "Use defaultOpen instead"
|
|
602
|
+
};
|
|
603
|
+
for (const field of fields) {
|
|
604
|
+
for (const key of Object.keys(field)) {
|
|
605
|
+
if (!KNOWN_FIELD_PROPS.has(key)) {
|
|
606
|
+
const suggestion = FIELD_SUGGESTIONS[key];
|
|
607
|
+
const hint = suggestion ? ` ${suggestion}.` : "";
|
|
608
|
+
console.warn(`[hs-uix] Warning: Field "${field.name}" has unknown prop "${key}".${hint}`);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (Array.isArray(sections)) {
|
|
613
|
+
for (const sec of sections) {
|
|
614
|
+
for (const key of Object.keys(sec)) {
|
|
615
|
+
if (!KNOWN_SECTION_PROPS.has(key)) {
|
|
616
|
+
const suggestion = SECTION_SUGGESTIONS[key];
|
|
617
|
+
const hint = suggestion ? ` ${suggestion}.` : "";
|
|
618
|
+
console.warn(`[hs-uix] Warning: Section "${sec.id || "(unnamed)"}" has unknown prop "${key}".${hint}`);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
512
624
|
const computeInitialValues = () => {
|
|
513
625
|
const resolved = transformInitialValues && initialValues ? transformInitialValues(initialValues) : initialValues;
|
|
514
626
|
const vals = {};
|
|
@@ -1199,7 +1311,9 @@ var FormBuilder = (0, import_react.forwardRef)(function FormBuilder2(props, ref)
|
|
|
1199
1311
|
if (field.type === "display") {
|
|
1200
1312
|
if (field.render) {
|
|
1201
1313
|
return field.render({
|
|
1314
|
+
values: formValues,
|
|
1202
1315
|
allValues: formValues,
|
|
1316
|
+
// deprecated — use `values`
|
|
1203
1317
|
setFieldValue: (name, value) => handleFieldChange(name, value),
|
|
1204
1318
|
setFieldError: (name, message) => updateErrors({ [name]: message })
|
|
1205
1319
|
});
|
|
@@ -1347,7 +1461,9 @@ var FormBuilder = (0, import_react.forwardRef)(function FormBuilder2(props, ref)
|
|
|
1347
1461
|
value: fieldValue,
|
|
1348
1462
|
onChange: fieldOnChange,
|
|
1349
1463
|
error: hasError,
|
|
1464
|
+
values: formValues,
|
|
1350
1465
|
allValues: formValues
|
|
1466
|
+
// deprecated — use `values`
|
|
1351
1467
|
});
|
|
1352
1468
|
}
|
|
1353
1469
|
const plugin = fieldTypes && fieldTypes[field.type];
|
|
@@ -1357,7 +1473,9 @@ var FormBuilder = (0, import_react.forwardRef)(function FormBuilder2(props, ref)
|
|
|
1357
1473
|
onChange: fieldOnChange,
|
|
1358
1474
|
error: hasError,
|
|
1359
1475
|
field,
|
|
1476
|
+
values: formValues,
|
|
1360
1477
|
allValues: formValues
|
|
1478
|
+
// deprecated — use `values`
|
|
1361
1479
|
});
|
|
1362
1480
|
}
|
|
1363
1481
|
const commonProps = {
|
|
@@ -1781,13 +1899,21 @@ var FormBuilder = (0, import_react.forwardRef)(function FormBuilder2(props, ref)
|
|
|
1781
1899
|
const elements = [];
|
|
1782
1900
|
let currentRow = [];
|
|
1783
1901
|
let currentRowSpan = 0;
|
|
1902
|
+
const gridColumnWidth = 200;
|
|
1784
1903
|
const flushRow = () => {
|
|
1785
1904
|
if (currentRow.length === 0) return;
|
|
1905
|
+
const allUniform = currentRow.every((f) => getFieldColSpan(f) === 1);
|
|
1786
1906
|
const totalSpan = currentRow.reduce((s, f) => s + getFieldColSpan(f), 0);
|
|
1787
1907
|
const remainder = columns - totalSpan;
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1908
|
+
if (allUniform) {
|
|
1909
|
+
elements.push(
|
|
1910
|
+
/* @__PURE__ */ import_react.default.createElement(import_ui_extensions.AutoGrid, { key: `row-${currentRow[0].name}`, columnWidth: gridColumnWidth, flexible: true, gap }, currentRow.map((f) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, { key: f.name }, renderField(f))), remainder > 0 && Array.from({ length: remainder }, (_, i) => /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Box, { key: `spacer-${i}` })))
|
|
1911
|
+
);
|
|
1912
|
+
} else {
|
|
1913
|
+
elements.push(
|
|
1914
|
+
/* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Flex, { key: `row-${currentRow[0].name}`, direction: "row", gap }, currentRow.map((f) => /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Box, { key: f.name, flex: getFieldColSpan(f) }, renderField(f))), remainder > 0 && /* @__PURE__ */ import_react.default.createElement(import_ui_extensions.Box, { flex: remainder }))
|
|
1915
|
+
);
|
|
1916
|
+
}
|
|
1791
1917
|
currentRow = [];
|
|
1792
1918
|
currentRowSpan = 0;
|
|
1793
1919
|
};
|
package/dist/form.mjs
CHANGED
|
@@ -513,6 +513,118 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
513
513
|
}
|
|
514
514
|
prevSuccessRef.current = formSuccess;
|
|
515
515
|
}, [addAlert, formSuccess, successTitle]);
|
|
516
|
+
if (process.env.NODE_ENV !== "production") {
|
|
517
|
+
const KNOWN_FIELD_PROPS = /* @__PURE__ */ new Set([
|
|
518
|
+
"name",
|
|
519
|
+
"type",
|
|
520
|
+
"label",
|
|
521
|
+
"description",
|
|
522
|
+
"placeholder",
|
|
523
|
+
"tooltip",
|
|
524
|
+
"required",
|
|
525
|
+
"readOnly",
|
|
526
|
+
"disabled",
|
|
527
|
+
"defaultValue",
|
|
528
|
+
"fieldProps",
|
|
529
|
+
"colSpan",
|
|
530
|
+
"width",
|
|
531
|
+
"visible",
|
|
532
|
+
"dependsOn",
|
|
533
|
+
"dependsOnConfig",
|
|
534
|
+
"group",
|
|
535
|
+
"debounce",
|
|
536
|
+
"pattern",
|
|
537
|
+
"patternMessage",
|
|
538
|
+
"minLength",
|
|
539
|
+
"maxLength",
|
|
540
|
+
"min",
|
|
541
|
+
"max",
|
|
542
|
+
"validate",
|
|
543
|
+
"validators",
|
|
544
|
+
"validateDebounce",
|
|
545
|
+
"useDefaultValidators",
|
|
546
|
+
"transformIn",
|
|
547
|
+
"transformOut",
|
|
548
|
+
"onFieldChange",
|
|
549
|
+
"onInput",
|
|
550
|
+
"onBlur",
|
|
551
|
+
"options",
|
|
552
|
+
"variant",
|
|
553
|
+
"inline",
|
|
554
|
+
"render",
|
|
555
|
+
"fields",
|
|
556
|
+
"items",
|
|
557
|
+
"showItemLabel",
|
|
558
|
+
"columns",
|
|
559
|
+
"repeaterProps",
|
|
560
|
+
"size",
|
|
561
|
+
"labelDisplay",
|
|
562
|
+
"textChecked",
|
|
563
|
+
"textUnchecked",
|
|
564
|
+
"rows",
|
|
565
|
+
"cols",
|
|
566
|
+
"resize",
|
|
567
|
+
"stepSize",
|
|
568
|
+
"precision",
|
|
569
|
+
"formatStyle",
|
|
570
|
+
"minValueReachedTooltip",
|
|
571
|
+
"maxValueReachedTooltip",
|
|
572
|
+
"currency",
|
|
573
|
+
"format",
|
|
574
|
+
"timezone",
|
|
575
|
+
"clearButtonLabel",
|
|
576
|
+
"todayButtonLabel",
|
|
577
|
+
"minValidationMessage",
|
|
578
|
+
"maxValidationMessage",
|
|
579
|
+
"interval",
|
|
580
|
+
"properties",
|
|
581
|
+
"direction",
|
|
582
|
+
"objectId",
|
|
583
|
+
"objectTypeId",
|
|
584
|
+
"associationLabels",
|
|
585
|
+
"filters",
|
|
586
|
+
"sort"
|
|
587
|
+
]);
|
|
588
|
+
const FIELD_SUGGESTIONS = {
|
|
589
|
+
fullWidth: 'Use width: "full" or colSpan instead',
|
|
590
|
+
title: "Use label instead",
|
|
591
|
+
maxColumns: "maxColumns is a FormBuilder prop, not a field prop"
|
|
592
|
+
};
|
|
593
|
+
const KNOWN_SECTION_PROPS = /* @__PURE__ */ new Set([
|
|
594
|
+
"id",
|
|
595
|
+
"label",
|
|
596
|
+
"fields",
|
|
597
|
+
"defaultOpen",
|
|
598
|
+
"info",
|
|
599
|
+
"renderBefore",
|
|
600
|
+
"renderAfter"
|
|
601
|
+
]);
|
|
602
|
+
const SECTION_SUGGESTIONS = {
|
|
603
|
+
title: "Use label instead",
|
|
604
|
+
name: "Use id instead",
|
|
605
|
+
open: "Use defaultOpen instead"
|
|
606
|
+
};
|
|
607
|
+
for (const field of fields) {
|
|
608
|
+
for (const key of Object.keys(field)) {
|
|
609
|
+
if (!KNOWN_FIELD_PROPS.has(key)) {
|
|
610
|
+
const suggestion = FIELD_SUGGESTIONS[key];
|
|
611
|
+
const hint = suggestion ? ` ${suggestion}.` : "";
|
|
612
|
+
console.warn(`[hs-uix] Warning: Field "${field.name}" has unknown prop "${key}".${hint}`);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (Array.isArray(sections)) {
|
|
617
|
+
for (const sec of sections) {
|
|
618
|
+
for (const key of Object.keys(sec)) {
|
|
619
|
+
if (!KNOWN_SECTION_PROPS.has(key)) {
|
|
620
|
+
const suggestion = SECTION_SUGGESTIONS[key];
|
|
621
|
+
const hint = suggestion ? ` ${suggestion}.` : "";
|
|
622
|
+
console.warn(`[hs-uix] Warning: Section "${sec.id || "(unnamed)"}" has unknown prop "${key}".${hint}`);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
516
628
|
const computeInitialValues = () => {
|
|
517
629
|
const resolved = transformInitialValues && initialValues ? transformInitialValues(initialValues) : initialValues;
|
|
518
630
|
const vals = {};
|
|
@@ -1203,7 +1315,9 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
1203
1315
|
if (field.type === "display") {
|
|
1204
1316
|
if (field.render) {
|
|
1205
1317
|
return field.render({
|
|
1318
|
+
values: formValues,
|
|
1206
1319
|
allValues: formValues,
|
|
1320
|
+
// deprecated — use `values`
|
|
1207
1321
|
setFieldValue: (name, value) => handleFieldChange(name, value),
|
|
1208
1322
|
setFieldError: (name, message) => updateErrors({ [name]: message })
|
|
1209
1323
|
});
|
|
@@ -1351,7 +1465,9 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
1351
1465
|
value: fieldValue,
|
|
1352
1466
|
onChange: fieldOnChange,
|
|
1353
1467
|
error: hasError,
|
|
1468
|
+
values: formValues,
|
|
1354
1469
|
allValues: formValues
|
|
1470
|
+
// deprecated — use `values`
|
|
1355
1471
|
});
|
|
1356
1472
|
}
|
|
1357
1473
|
const plugin = fieldTypes && fieldTypes[field.type];
|
|
@@ -1361,7 +1477,9 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
1361
1477
|
onChange: fieldOnChange,
|
|
1362
1478
|
error: hasError,
|
|
1363
1479
|
field,
|
|
1480
|
+
values: formValues,
|
|
1364
1481
|
allValues: formValues
|
|
1482
|
+
// deprecated — use `values`
|
|
1365
1483
|
});
|
|
1366
1484
|
}
|
|
1367
1485
|
const commonProps = {
|
|
@@ -1785,13 +1903,21 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
1785
1903
|
const elements = [];
|
|
1786
1904
|
let currentRow = [];
|
|
1787
1905
|
let currentRowSpan = 0;
|
|
1906
|
+
const gridColumnWidth = 200;
|
|
1788
1907
|
const flushRow = () => {
|
|
1789
1908
|
if (currentRow.length === 0) return;
|
|
1909
|
+
const allUniform = currentRow.every((f) => getFieldColSpan(f) === 1);
|
|
1790
1910
|
const totalSpan = currentRow.reduce((s, f) => s + getFieldColSpan(f), 0);
|
|
1791
1911
|
const remainder = columns - totalSpan;
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1912
|
+
if (allUniform) {
|
|
1913
|
+
elements.push(
|
|
1914
|
+
/* @__PURE__ */ React.createElement(AutoGrid, { key: `row-${currentRow[0].name}`, columnWidth: gridColumnWidth, flexible: true, gap }, currentRow.map((f) => /* @__PURE__ */ React.createElement(React.Fragment, { key: f.name }, renderField(f))), remainder > 0 && Array.from({ length: remainder }, (_, i) => /* @__PURE__ */ React.createElement(Box, { key: `spacer-${i}` })))
|
|
1915
|
+
);
|
|
1916
|
+
} else {
|
|
1917
|
+
elements.push(
|
|
1918
|
+
/* @__PURE__ */ React.createElement(Flex, { key: `row-${currentRow[0].name}`, direction: "row", gap }, currentRow.map((f) => /* @__PURE__ */ React.createElement(Box, { key: f.name, flex: getFieldColSpan(f) }, renderField(f))), remainder > 0 && /* @__PURE__ */ React.createElement(Box, { flex: remainder }))
|
|
1919
|
+
);
|
|
1920
|
+
}
|
|
1795
1921
|
currentRow = [];
|
|
1796
1922
|
currentRowSpan = 0;
|
|
1797
1923
|
};
|
package/dist/index.js
CHANGED
|
@@ -1580,6 +1580,118 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
1580
1580
|
}
|
|
1581
1581
|
prevSuccessRef.current = formSuccess;
|
|
1582
1582
|
}, [addAlert, formSuccess, successTitle]);
|
|
1583
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1584
|
+
const KNOWN_FIELD_PROPS = /* @__PURE__ */ new Set([
|
|
1585
|
+
"name",
|
|
1586
|
+
"type",
|
|
1587
|
+
"label",
|
|
1588
|
+
"description",
|
|
1589
|
+
"placeholder",
|
|
1590
|
+
"tooltip",
|
|
1591
|
+
"required",
|
|
1592
|
+
"readOnly",
|
|
1593
|
+
"disabled",
|
|
1594
|
+
"defaultValue",
|
|
1595
|
+
"fieldProps",
|
|
1596
|
+
"colSpan",
|
|
1597
|
+
"width",
|
|
1598
|
+
"visible",
|
|
1599
|
+
"dependsOn",
|
|
1600
|
+
"dependsOnConfig",
|
|
1601
|
+
"group",
|
|
1602
|
+
"debounce",
|
|
1603
|
+
"pattern",
|
|
1604
|
+
"patternMessage",
|
|
1605
|
+
"minLength",
|
|
1606
|
+
"maxLength",
|
|
1607
|
+
"min",
|
|
1608
|
+
"max",
|
|
1609
|
+
"validate",
|
|
1610
|
+
"validators",
|
|
1611
|
+
"validateDebounce",
|
|
1612
|
+
"useDefaultValidators",
|
|
1613
|
+
"transformIn",
|
|
1614
|
+
"transformOut",
|
|
1615
|
+
"onFieldChange",
|
|
1616
|
+
"onInput",
|
|
1617
|
+
"onBlur",
|
|
1618
|
+
"options",
|
|
1619
|
+
"variant",
|
|
1620
|
+
"inline",
|
|
1621
|
+
"render",
|
|
1622
|
+
"fields",
|
|
1623
|
+
"items",
|
|
1624
|
+
"showItemLabel",
|
|
1625
|
+
"columns",
|
|
1626
|
+
"repeaterProps",
|
|
1627
|
+
"size",
|
|
1628
|
+
"labelDisplay",
|
|
1629
|
+
"textChecked",
|
|
1630
|
+
"textUnchecked",
|
|
1631
|
+
"rows",
|
|
1632
|
+
"cols",
|
|
1633
|
+
"resize",
|
|
1634
|
+
"stepSize",
|
|
1635
|
+
"precision",
|
|
1636
|
+
"formatStyle",
|
|
1637
|
+
"minValueReachedTooltip",
|
|
1638
|
+
"maxValueReachedTooltip",
|
|
1639
|
+
"currency",
|
|
1640
|
+
"format",
|
|
1641
|
+
"timezone",
|
|
1642
|
+
"clearButtonLabel",
|
|
1643
|
+
"todayButtonLabel",
|
|
1644
|
+
"minValidationMessage",
|
|
1645
|
+
"maxValidationMessage",
|
|
1646
|
+
"interval",
|
|
1647
|
+
"properties",
|
|
1648
|
+
"direction",
|
|
1649
|
+
"objectId",
|
|
1650
|
+
"objectTypeId",
|
|
1651
|
+
"associationLabels",
|
|
1652
|
+
"filters",
|
|
1653
|
+
"sort"
|
|
1654
|
+
]);
|
|
1655
|
+
const FIELD_SUGGESTIONS = {
|
|
1656
|
+
fullWidth: 'Use width: "full" or colSpan instead',
|
|
1657
|
+
title: "Use label instead",
|
|
1658
|
+
maxColumns: "maxColumns is a FormBuilder prop, not a field prop"
|
|
1659
|
+
};
|
|
1660
|
+
const KNOWN_SECTION_PROPS = /* @__PURE__ */ new Set([
|
|
1661
|
+
"id",
|
|
1662
|
+
"label",
|
|
1663
|
+
"fields",
|
|
1664
|
+
"defaultOpen",
|
|
1665
|
+
"info",
|
|
1666
|
+
"renderBefore",
|
|
1667
|
+
"renderAfter"
|
|
1668
|
+
]);
|
|
1669
|
+
const SECTION_SUGGESTIONS = {
|
|
1670
|
+
title: "Use label instead",
|
|
1671
|
+
name: "Use id instead",
|
|
1672
|
+
open: "Use defaultOpen instead"
|
|
1673
|
+
};
|
|
1674
|
+
for (const field of fields) {
|
|
1675
|
+
for (const key of Object.keys(field)) {
|
|
1676
|
+
if (!KNOWN_FIELD_PROPS.has(key)) {
|
|
1677
|
+
const suggestion = FIELD_SUGGESTIONS[key];
|
|
1678
|
+
const hint = suggestion ? ` ${suggestion}.` : "";
|
|
1679
|
+
console.warn(`[hs-uix] Warning: Field "${field.name}" has unknown prop "${key}".${hint}`);
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
if (Array.isArray(sections)) {
|
|
1684
|
+
for (const sec of sections) {
|
|
1685
|
+
for (const key of Object.keys(sec)) {
|
|
1686
|
+
if (!KNOWN_SECTION_PROPS.has(key)) {
|
|
1687
|
+
const suggestion = SECTION_SUGGESTIONS[key];
|
|
1688
|
+
const hint = suggestion ? ` ${suggestion}.` : "";
|
|
1689
|
+
console.warn(`[hs-uix] Warning: Section "${sec.id || "(unnamed)"}" has unknown prop "${key}".${hint}`);
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1583
1695
|
const computeInitialValues = () => {
|
|
1584
1696
|
const resolved = transformInitialValues && initialValues ? transformInitialValues(initialValues) : initialValues;
|
|
1585
1697
|
const vals = {};
|
|
@@ -2270,7 +2382,9 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2270
2382
|
if (field.type === "display") {
|
|
2271
2383
|
if (field.render) {
|
|
2272
2384
|
return field.render({
|
|
2385
|
+
values: formValues,
|
|
2273
2386
|
allValues: formValues,
|
|
2387
|
+
// deprecated — use `values`
|
|
2274
2388
|
setFieldValue: (name, value) => handleFieldChange(name, value),
|
|
2275
2389
|
setFieldError: (name, message) => updateErrors({ [name]: message })
|
|
2276
2390
|
});
|
|
@@ -2418,7 +2532,9 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2418
2532
|
value: fieldValue,
|
|
2419
2533
|
onChange: fieldOnChange,
|
|
2420
2534
|
error: hasError,
|
|
2535
|
+
values: formValues,
|
|
2421
2536
|
allValues: formValues
|
|
2537
|
+
// deprecated — use `values`
|
|
2422
2538
|
});
|
|
2423
2539
|
}
|
|
2424
2540
|
const plugin = fieldTypes && fieldTypes[field.type];
|
|
@@ -2428,7 +2544,9 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2428
2544
|
onChange: fieldOnChange,
|
|
2429
2545
|
error: hasError,
|
|
2430
2546
|
field,
|
|
2547
|
+
values: formValues,
|
|
2431
2548
|
allValues: formValues
|
|
2549
|
+
// deprecated — use `values`
|
|
2432
2550
|
});
|
|
2433
2551
|
}
|
|
2434
2552
|
const commonProps = {
|
|
@@ -2852,13 +2970,21 @@ var FormBuilder = (0, import_react2.forwardRef)(function FormBuilder2(props, ref
|
|
|
2852
2970
|
const elements = [];
|
|
2853
2971
|
let currentRow = [];
|
|
2854
2972
|
let currentRowSpan = 0;
|
|
2973
|
+
const gridColumnWidth = 200;
|
|
2855
2974
|
const flushRow = () => {
|
|
2856
2975
|
if (currentRow.length === 0) return;
|
|
2976
|
+
const allUniform = currentRow.every((f) => getFieldColSpan(f) === 1);
|
|
2857
2977
|
const totalSpan = currentRow.reduce((s, f) => s + getFieldColSpan(f), 0);
|
|
2858
2978
|
const remainder = columns - totalSpan;
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2979
|
+
if (allUniform) {
|
|
2980
|
+
elements.push(
|
|
2981
|
+
/* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.AutoGrid, { key: `row-${currentRow[0].name}`, columnWidth: gridColumnWidth, flexible: true, gap }, currentRow.map((f) => /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, { key: f.name }, renderField(f))), remainder > 0 && Array.from({ length: remainder }, (_, i) => /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Box, { key: `spacer-${i}` })))
|
|
2982
|
+
);
|
|
2983
|
+
} else {
|
|
2984
|
+
elements.push(
|
|
2985
|
+
/* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Flex, { key: `row-${currentRow[0].name}`, direction: "row", gap }, currentRow.map((f) => /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Box, { key: f.name, flex: getFieldColSpan(f) }, renderField(f))), remainder > 0 && /* @__PURE__ */ import_react2.default.createElement(import_ui_extensions2.Box, { flex: remainder }))
|
|
2986
|
+
);
|
|
2987
|
+
}
|
|
2862
2988
|
currentRow = [];
|
|
2863
2989
|
currentRowSpan = 0;
|
|
2864
2990
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1613,6 +1613,118 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
1613
1613
|
}
|
|
1614
1614
|
prevSuccessRef.current = formSuccess;
|
|
1615
1615
|
}, [addAlert, formSuccess, successTitle]);
|
|
1616
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1617
|
+
const KNOWN_FIELD_PROPS = /* @__PURE__ */ new Set([
|
|
1618
|
+
"name",
|
|
1619
|
+
"type",
|
|
1620
|
+
"label",
|
|
1621
|
+
"description",
|
|
1622
|
+
"placeholder",
|
|
1623
|
+
"tooltip",
|
|
1624
|
+
"required",
|
|
1625
|
+
"readOnly",
|
|
1626
|
+
"disabled",
|
|
1627
|
+
"defaultValue",
|
|
1628
|
+
"fieldProps",
|
|
1629
|
+
"colSpan",
|
|
1630
|
+
"width",
|
|
1631
|
+
"visible",
|
|
1632
|
+
"dependsOn",
|
|
1633
|
+
"dependsOnConfig",
|
|
1634
|
+
"group",
|
|
1635
|
+
"debounce",
|
|
1636
|
+
"pattern",
|
|
1637
|
+
"patternMessage",
|
|
1638
|
+
"minLength",
|
|
1639
|
+
"maxLength",
|
|
1640
|
+
"min",
|
|
1641
|
+
"max",
|
|
1642
|
+
"validate",
|
|
1643
|
+
"validators",
|
|
1644
|
+
"validateDebounce",
|
|
1645
|
+
"useDefaultValidators",
|
|
1646
|
+
"transformIn",
|
|
1647
|
+
"transformOut",
|
|
1648
|
+
"onFieldChange",
|
|
1649
|
+
"onInput",
|
|
1650
|
+
"onBlur",
|
|
1651
|
+
"options",
|
|
1652
|
+
"variant",
|
|
1653
|
+
"inline",
|
|
1654
|
+
"render",
|
|
1655
|
+
"fields",
|
|
1656
|
+
"items",
|
|
1657
|
+
"showItemLabel",
|
|
1658
|
+
"columns",
|
|
1659
|
+
"repeaterProps",
|
|
1660
|
+
"size",
|
|
1661
|
+
"labelDisplay",
|
|
1662
|
+
"textChecked",
|
|
1663
|
+
"textUnchecked",
|
|
1664
|
+
"rows",
|
|
1665
|
+
"cols",
|
|
1666
|
+
"resize",
|
|
1667
|
+
"stepSize",
|
|
1668
|
+
"precision",
|
|
1669
|
+
"formatStyle",
|
|
1670
|
+
"minValueReachedTooltip",
|
|
1671
|
+
"maxValueReachedTooltip",
|
|
1672
|
+
"currency",
|
|
1673
|
+
"format",
|
|
1674
|
+
"timezone",
|
|
1675
|
+
"clearButtonLabel",
|
|
1676
|
+
"todayButtonLabel",
|
|
1677
|
+
"minValidationMessage",
|
|
1678
|
+
"maxValidationMessage",
|
|
1679
|
+
"interval",
|
|
1680
|
+
"properties",
|
|
1681
|
+
"direction",
|
|
1682
|
+
"objectId",
|
|
1683
|
+
"objectTypeId",
|
|
1684
|
+
"associationLabels",
|
|
1685
|
+
"filters",
|
|
1686
|
+
"sort"
|
|
1687
|
+
]);
|
|
1688
|
+
const FIELD_SUGGESTIONS = {
|
|
1689
|
+
fullWidth: 'Use width: "full" or colSpan instead',
|
|
1690
|
+
title: "Use label instead",
|
|
1691
|
+
maxColumns: "maxColumns is a FormBuilder prop, not a field prop"
|
|
1692
|
+
};
|
|
1693
|
+
const KNOWN_SECTION_PROPS = /* @__PURE__ */ new Set([
|
|
1694
|
+
"id",
|
|
1695
|
+
"label",
|
|
1696
|
+
"fields",
|
|
1697
|
+
"defaultOpen",
|
|
1698
|
+
"info",
|
|
1699
|
+
"renderBefore",
|
|
1700
|
+
"renderAfter"
|
|
1701
|
+
]);
|
|
1702
|
+
const SECTION_SUGGESTIONS = {
|
|
1703
|
+
title: "Use label instead",
|
|
1704
|
+
name: "Use id instead",
|
|
1705
|
+
open: "Use defaultOpen instead"
|
|
1706
|
+
};
|
|
1707
|
+
for (const field of fields) {
|
|
1708
|
+
for (const key of Object.keys(field)) {
|
|
1709
|
+
if (!KNOWN_FIELD_PROPS.has(key)) {
|
|
1710
|
+
const suggestion = FIELD_SUGGESTIONS[key];
|
|
1711
|
+
const hint = suggestion ? ` ${suggestion}.` : "";
|
|
1712
|
+
console.warn(`[hs-uix] Warning: Field "${field.name}" has unknown prop "${key}".${hint}`);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
if (Array.isArray(sections)) {
|
|
1717
|
+
for (const sec of sections) {
|
|
1718
|
+
for (const key of Object.keys(sec)) {
|
|
1719
|
+
if (!KNOWN_SECTION_PROPS.has(key)) {
|
|
1720
|
+
const suggestion = SECTION_SUGGESTIONS[key];
|
|
1721
|
+
const hint = suggestion ? ` ${suggestion}.` : "";
|
|
1722
|
+
console.warn(`[hs-uix] Warning: Section "${sec.id || "(unnamed)"}" has unknown prop "${key}".${hint}`);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1616
1728
|
const computeInitialValues = () => {
|
|
1617
1729
|
const resolved = transformInitialValues && initialValues ? transformInitialValues(initialValues) : initialValues;
|
|
1618
1730
|
const vals = {};
|
|
@@ -2303,7 +2415,9 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
2303
2415
|
if (field.type === "display") {
|
|
2304
2416
|
if (field.render) {
|
|
2305
2417
|
return field.render({
|
|
2418
|
+
values: formValues,
|
|
2306
2419
|
allValues: formValues,
|
|
2420
|
+
// deprecated — use `values`
|
|
2307
2421
|
setFieldValue: (name, value) => handleFieldChange(name, value),
|
|
2308
2422
|
setFieldError: (name, message) => updateErrors({ [name]: message })
|
|
2309
2423
|
});
|
|
@@ -2451,7 +2565,9 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
2451
2565
|
value: fieldValue,
|
|
2452
2566
|
onChange: fieldOnChange,
|
|
2453
2567
|
error: hasError,
|
|
2568
|
+
values: formValues,
|
|
2454
2569
|
allValues: formValues
|
|
2570
|
+
// deprecated — use `values`
|
|
2455
2571
|
});
|
|
2456
2572
|
}
|
|
2457
2573
|
const plugin = fieldTypes && fieldTypes[field.type];
|
|
@@ -2461,7 +2577,9 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
2461
2577
|
onChange: fieldOnChange,
|
|
2462
2578
|
error: hasError,
|
|
2463
2579
|
field,
|
|
2580
|
+
values: formValues,
|
|
2464
2581
|
allValues: formValues
|
|
2582
|
+
// deprecated — use `values`
|
|
2465
2583
|
});
|
|
2466
2584
|
}
|
|
2467
2585
|
const commonProps = {
|
|
@@ -2885,13 +3003,21 @@ var FormBuilder = forwardRef(function FormBuilder2(props, ref) {
|
|
|
2885
3003
|
const elements = [];
|
|
2886
3004
|
let currentRow = [];
|
|
2887
3005
|
let currentRowSpan = 0;
|
|
3006
|
+
const gridColumnWidth = 200;
|
|
2888
3007
|
const flushRow = () => {
|
|
2889
3008
|
if (currentRow.length === 0) return;
|
|
3009
|
+
const allUniform = currentRow.every((f) => getFieldColSpan(f) === 1);
|
|
2890
3010
|
const totalSpan = currentRow.reduce((s, f) => s + getFieldColSpan(f), 0);
|
|
2891
3011
|
const remainder = columns - totalSpan;
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
3012
|
+
if (allUniform) {
|
|
3013
|
+
elements.push(
|
|
3014
|
+
/* @__PURE__ */ React2.createElement(AutoGrid, { key: `row-${currentRow[0].name}`, columnWidth: gridColumnWidth, flexible: true, gap }, currentRow.map((f) => /* @__PURE__ */ React2.createElement(React2.Fragment, { key: f.name }, renderField(f))), remainder > 0 && Array.from({ length: remainder }, (_, i) => /* @__PURE__ */ React2.createElement(Box2, { key: `spacer-${i}` })))
|
|
3015
|
+
);
|
|
3016
|
+
} else {
|
|
3017
|
+
elements.push(
|
|
3018
|
+
/* @__PURE__ */ React2.createElement(Flex2, { key: `row-${currentRow[0].name}`, direction: "row", gap }, currentRow.map((f) => /* @__PURE__ */ React2.createElement(Box2, { key: f.name, flex: getFieldColSpan(f) }, renderField(f))), remainder > 0 && /* @__PURE__ */ React2.createElement(Box2, { flex: remainder }))
|
|
3019
|
+
);
|
|
3020
|
+
}
|
|
2895
3021
|
currentRow = [];
|
|
2896
3022
|
currentRowSpan = 0;
|
|
2897
3023
|
};
|