@insticc/genericform 2.0.8 → 2.1.1
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/build/Demo.js +37 -37
- package/build/Demo2.js +15 -15
- package/build/FormFields/CustomAction.js +38 -0
- package/build/FormFields/CustomCheckbox.js +11 -3
- package/build/FormFields/CustomCheckboxGroup.js +10 -3
- package/build/FormFields/CustomComponent.js +10 -3
- package/build/FormFields/CustomDatePicker.js +21 -5
- package/build/FormFields/CustomDropdown.js +18 -4
- package/build/FormFields/CustomFileInput.js +131 -0
- package/build/FormFields/CustomInput.js +12 -4
- package/build/FormFields/CustomJson.js +11 -3
- package/build/FormFields/CustomLabel.js +8 -3
- package/build/FormFields/CustomMobilePhone.js +117 -0
- package/build/FormFields/CustomMultiDropdown.js +12 -4
- package/build/FormFields/CustomNumberInput.js +12 -4
- package/build/FormFields/CustomRadioGroup.js +26 -12
- package/build/FormFields/CustomSearch.js +12 -4
- package/build/FormFields/CustomTextArea.js +12 -4
- package/build/FormFields/CustomToggle.js +11 -3
- package/build/FormFields/defaults.js +22 -6
- package/build/index.css +11 -7
- package/build/index.js +198 -58
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -7,12 +8,27 @@ exports.errorJsx = errorJsx;
|
|
|
7
8
|
exports.labelJsx = labelJsx;
|
|
8
9
|
exports.tooltipJsx = tooltipJsx;
|
|
9
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
function
|
|
11
|
-
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
function labelJsx(_ref) {
|
|
17
|
+
var name = _ref.name,
|
|
18
|
+
labelStyle = _ref.labelStyle,
|
|
19
|
+
label = _ref.label,
|
|
20
|
+
required = _ref.required,
|
|
21
|
+
spanStyle = _ref.spanStyle,
|
|
22
|
+
showHelp = _ref.showHelp,
|
|
23
|
+
helpText = _ref.helpText,
|
|
24
|
+
disableHtmlFor = _ref.disableHtmlFor;
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", _objectSpread(_objectSpread({
|
|
12
26
|
className: "ufg-label",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
style: labelStyle
|
|
28
|
+
}, disableHtmlFor ? {} : {
|
|
29
|
+
htmlFor: "form-input-".concat(name)
|
|
30
|
+
}), {}, {
|
|
31
|
+
children: [label, required && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
16
32
|
className: "ufg-required",
|
|
17
33
|
style: spanStyle,
|
|
18
34
|
children: " *"
|
|
@@ -21,7 +37,7 @@ function labelJsx(name, labelStyle, displayName, required, spanStyle, showHelp,
|
|
|
21
37
|
title: helpText,
|
|
22
38
|
children: " \u24D8"
|
|
23
39
|
})]
|
|
24
|
-
});
|
|
40
|
+
}));
|
|
25
41
|
}
|
|
26
42
|
function errorJsx(error) {
|
|
27
43
|
return error && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
package/build/index.css
CHANGED
|
@@ -85,11 +85,9 @@
|
|
|
85
85
|
Form layout
|
|
86
86
|
-------------------------------------------------------------------------- */
|
|
87
87
|
.ufg-form-columns {
|
|
88
|
-
display:
|
|
89
|
-
|
|
88
|
+
display: grid;
|
|
89
|
+
/* grid-template-columns: repeat(2, 1fr); */
|
|
90
90
|
gap: 2rem;
|
|
91
|
-
align-items: flex-start;
|
|
92
|
-
flex-wrap: wrap;
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
.ufg-form {
|
|
@@ -111,7 +109,8 @@
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
.ufg-field-row {
|
|
114
|
-
display:
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-wrap: wrap;
|
|
115
114
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
116
115
|
gap: 16px;
|
|
117
116
|
}
|
|
@@ -150,6 +149,7 @@
|
|
|
150
149
|
background: var(--ufg-surface);
|
|
151
150
|
transition: all 0.12s ease;
|
|
152
151
|
font-family: inherit;
|
|
152
|
+
line-height: normal;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
.ufg-input:hover,
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
.ufg-radio-item {
|
|
255
255
|
display: flex;
|
|
256
256
|
align-items: center;
|
|
257
|
-
gap:
|
|
257
|
+
gap: 0.5em;
|
|
258
258
|
margin: 0;
|
|
259
259
|
}
|
|
260
260
|
|
|
@@ -329,6 +329,10 @@
|
|
|
329
329
|
flex-wrap: wrap;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
+
.ufg-button:hover:not(:disabled) {
|
|
333
|
+
transform: translateY(-1px);
|
|
334
|
+
}
|
|
335
|
+
|
|
332
336
|
.ufg-button {
|
|
333
337
|
padding: 12px 24px;
|
|
334
338
|
border-radius: var(--ufg-radius);
|
|
@@ -451,7 +455,7 @@
|
|
|
451
455
|
Misc wrappers
|
|
452
456
|
-------------------------------------------------------------------------- */
|
|
453
457
|
.ufg-component-wrapper {
|
|
454
|
-
margin:
|
|
458
|
+
margin: 6px 0 0;
|
|
455
459
|
}
|
|
456
460
|
|
|
457
461
|
/* --------------------------------------------------------------------------
|
package/build/index.js
CHANGED
|
@@ -3,6 +3,96 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "CustomAccordion", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _CustomAccordion["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "CustomAction", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _CustomAction["default"];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "CustomCheckbox", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _CustomCheckbox["default"];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "CustomCheckboxGroup", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _CustomCheckboxGroup["default"];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "CustomDatePicker", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _CustomDatePicker["default"];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "CustomDropdown", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _CustomDropdown["default"];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "CustomFileInput", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _CustomFileInput["default"];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "CustomInput", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _CustomInput["default"];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "CustomJson", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _CustomJson["default"];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "CustomMobilePhone", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _CustomMobilePhone["default"];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "CustomMultiDropdown", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _CustomMultiDropdown["default"];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "CustomNumberInput", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _CustomNumberInput["default"];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "CustomRadioGroup", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _CustomRadioGroup["default"];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "CustomTextArea", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _CustomTextArea["default"];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "CustomToggle", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _CustomToggle["default"];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
6
96
|
Object.defineProperty(exports, "Demo", {
|
|
7
97
|
enumerable: true,
|
|
8
98
|
get: function get() {
|
|
@@ -19,14 +109,17 @@ exports["default"] = void 0;
|
|
|
19
109
|
var _react = require("react");
|
|
20
110
|
var _reactBootstrap = require("react-bootstrap");
|
|
21
111
|
var _CustomAccordion = _interopRequireDefault(require("./FormFields/CustomAccordion"));
|
|
112
|
+
var _CustomAction = _interopRequireDefault(require("./FormFields/CustomAction"));
|
|
22
113
|
var _CustomCheckbox = _interopRequireDefault(require("./FormFields/CustomCheckbox"));
|
|
23
114
|
var _CustomCheckboxGroup = _interopRequireDefault(require("./FormFields/CustomCheckboxGroup"));
|
|
24
115
|
var _CustomComponent = _interopRequireDefault(require("./FormFields/CustomComponent"));
|
|
25
116
|
var _CustomDatePicker = _interopRequireDefault(require("./FormFields/CustomDatePicker"));
|
|
26
117
|
var _CustomDropdown = _interopRequireDefault(require("./FormFields/CustomDropdown"));
|
|
118
|
+
var _CustomFileInput = _interopRequireDefault(require("./FormFields/CustomFileInput"));
|
|
27
119
|
var _CustomInput = _interopRequireDefault(require("./FormFields/CustomInput"));
|
|
28
120
|
var _CustomJson = _interopRequireDefault(require("./FormFields/CustomJson"));
|
|
29
121
|
var _CustomLabel = _interopRequireDefault(require("./FormFields/CustomLabel"));
|
|
122
|
+
var _CustomMobilePhone = _interopRequireDefault(require("./FormFields/CustomMobilePhone"));
|
|
30
123
|
var _CustomMultiDropdown = _interopRequireDefault(require("./FormFields/CustomMultiDropdown"));
|
|
31
124
|
var _CustomNumberInput = _interopRequireDefault(require("./FormFields/CustomNumberInput"));
|
|
32
125
|
var _CustomRadioGroup = _interopRequireDefault(require("./FormFields/CustomRadioGroup"));
|
|
@@ -116,10 +209,14 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
116
209
|
fieldsStyle = _ref.fieldsStyle,
|
|
117
210
|
actionsDivStyle = _ref.actionsDivStyle,
|
|
118
211
|
actionsStyle = _ref.actionsStyle,
|
|
212
|
+
inlineStyle = _ref.inlineStyle,
|
|
119
213
|
_ref$splitForm = _ref.splitForm,
|
|
120
214
|
splitForm = _ref$splitForm === void 0 ? false : _ref$splitForm,
|
|
121
|
-
|
|
215
|
+
_ref$splitFields = _ref.splitFields,
|
|
216
|
+
splitFields = _ref$splitFields === void 0 ? [] : _ref$splitFields,
|
|
122
217
|
splitGroup = _ref.splitGroup,
|
|
218
|
+
_ref$splitColumns = _ref.splitColumns,
|
|
219
|
+
splitColumns = _ref$splitColumns === void 0 ? 2 : _ref$splitColumns,
|
|
123
220
|
_ref$disableDefaultCo = _ref.disableDefaultContainer,
|
|
124
221
|
disableDefaultContainer = _ref$disableDefaultCo === void 0 ? false : _ref$disableDefaultCo,
|
|
125
222
|
handleSubmit = _ref.handleSubmit,
|
|
@@ -155,7 +252,9 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
155
252
|
_ref$modalShow = _ref.modalShow,
|
|
156
253
|
modalShow = _ref$modalShow === void 0 ? false : _ref$modalShow,
|
|
157
254
|
_ref$modalSize = _ref.modalSize,
|
|
158
|
-
modalSize = _ref$modalSize === void 0 ? 'lg' : _ref$modalSize
|
|
255
|
+
modalSize = _ref$modalSize === void 0 ? 'lg' : _ref$modalSize,
|
|
256
|
+
_ref$disableFormTag = _ref.disableFormTag,
|
|
257
|
+
disableFormTag = _ref$disableFormTag === void 0 ? false : _ref$disableFormTag;
|
|
159
258
|
var _useState = (0, _react.useState)([]),
|
|
160
259
|
_useState2 = _slicedToArray(_useState, 2),
|
|
161
260
|
sortedFields = _useState2[0],
|
|
@@ -224,7 +323,7 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
224
323
|
var nextErrors = _objectSpread({}, prevErrors);
|
|
225
324
|
Object.keys(patch).forEach(function (name) {
|
|
226
325
|
var field = fields.find(function (f) {
|
|
227
|
-
return f.name === name;
|
|
326
|
+
return (f === null || f === void 0 ? void 0 : f.name) === name;
|
|
228
327
|
});
|
|
229
328
|
if (field) nextErrors[name] = validateField(field, patch[name], merged) || undefined;
|
|
230
329
|
});
|
|
@@ -243,7 +342,7 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
243
342
|
var errs = [];
|
|
244
343
|
if (field.required) {
|
|
245
344
|
var empty = value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
|
|
246
|
-
if (empty) errs.push(field.errorMessage || "".concat(typeof field.label === 'string' && field.label || field.
|
|
345
|
+
if (empty) errs.push(field.errorMessage || "".concat(typeof field.label === 'string' && field.label || field.name, " is required"));
|
|
247
346
|
}
|
|
248
347
|
if (field.type === 'email' && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) errs.push(field.errorMessage || 'Invalid email format');
|
|
249
348
|
if (field.minLength && value && value.length < field.minLength) errs.push(field.errorMessage || "Minimum ".concat(field.minLength, " characters required"));
|
|
@@ -454,9 +553,10 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
454
553
|
// Props shared by all interactive fields
|
|
455
554
|
var cp = {
|
|
456
555
|
name: field.name,
|
|
457
|
-
|
|
556
|
+
label: field.label,
|
|
458
557
|
disabled: field.disabled,
|
|
459
|
-
required: field.required
|
|
558
|
+
required: field.required,
|
|
559
|
+
placeholder: field.placeholder
|
|
460
560
|
};
|
|
461
561
|
var sp = {
|
|
462
562
|
mainDivStyle: field.style,
|
|
@@ -500,7 +600,6 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
500
600
|
case 'number':
|
|
501
601
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomNumberInput["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
|
|
502
602
|
value: value,
|
|
503
|
-
placeholder: field.placeholder,
|
|
504
603
|
min: field.min,
|
|
505
604
|
max: field.max,
|
|
506
605
|
step: field.step,
|
|
@@ -509,11 +608,15 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
509
608
|
case 'textArea':
|
|
510
609
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomTextArea["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
|
|
511
610
|
value: value,
|
|
512
|
-
placeholder: field.placeholder,
|
|
513
611
|
rows: field.rows,
|
|
514
612
|
height: field.height,
|
|
515
613
|
onChange: fieldHandler(field)
|
|
516
614
|
}), field.name);
|
|
615
|
+
case 'tel':
|
|
616
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomMobilePhone["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
|
|
617
|
+
value: value,
|
|
618
|
+
onChange: fieldHandler(field)
|
|
619
|
+
}), field.name);
|
|
517
620
|
|
|
518
621
|
// Date
|
|
519
622
|
case 'date':
|
|
@@ -522,7 +625,6 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
522
625
|
case 'year':
|
|
523
626
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomDatePicker["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
|
|
524
627
|
value: value,
|
|
525
|
-
placeholder: field.placeholder,
|
|
526
628
|
onChange: dateFieldHandler(field),
|
|
527
629
|
isValidDate: field.validate,
|
|
528
630
|
dateFormat: field.type === 'time' ? false : field.type === 'year' ? 'YYYY' : 'DD/MM/YYYY',
|
|
@@ -634,12 +736,17 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
634
736
|
return validateJsonField(name, raw, isMulti, false, field);
|
|
635
737
|
}
|
|
636
738
|
}), field.name);
|
|
739
|
+
case 'file':
|
|
740
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomFileInput["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
|
|
741
|
+
value: value,
|
|
742
|
+
accept: field.accept,
|
|
743
|
+
onChange: fieldHandler(field)
|
|
744
|
+
}), field.name);
|
|
637
745
|
default:
|
|
638
746
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomInput["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
639
747
|
type: field.type
|
|
640
748
|
}, cp), sp), fp), {}, {
|
|
641
749
|
value: value,
|
|
642
|
-
placeholder: field.placeholder,
|
|
643
750
|
onChange: fieldHandler(field),
|
|
644
751
|
className: field.className
|
|
645
752
|
}), field.name);
|
|
@@ -662,6 +769,7 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
662
769
|
return groupByInline(fieldList).map(function (group, idx) {
|
|
663
770
|
return group.type === 'inline' ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
664
771
|
className: "ufg-field-row",
|
|
772
|
+
style: inlineStyle,
|
|
665
773
|
children: group.fields.map(function (_ref9) {
|
|
666
774
|
var field = _ref9.field;
|
|
667
775
|
return renderField(field);
|
|
@@ -678,63 +786,91 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
678
786
|
}), renderFields(fieldList)]
|
|
679
787
|
}, g);
|
|
680
788
|
};
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
789
|
+
|
|
790
|
+
// ── Replace splitByField + buildContent entirely ─────────────────────────────
|
|
791
|
+
|
|
792
|
+
var splitFieldsSet = (0, _react.useMemo)(function () {
|
|
793
|
+
return new Set(splitFields);
|
|
794
|
+
}, [splitFields]);
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Returns the index of the last field (in `list`) whose name is in splitFields.
|
|
798
|
+
* Returns -1 when none match.
|
|
799
|
+
*/
|
|
800
|
+
var lastSplitIdx = (0, _react.useCallback)(function (list) {
|
|
801
|
+
var idx = -1;
|
|
802
|
+
list.forEach(function (f, i) {
|
|
803
|
+
if (splitFieldsSet.has(f.name)) idx = i;
|
|
684
804
|
});
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
};
|
|
689
|
-
return {
|
|
690
|
-
left: fieldList.slice(0, idx + 1),
|
|
691
|
-
right: fieldList.slice(idx + 1)
|
|
692
|
-
};
|
|
693
|
-
};
|
|
694
|
-
var buildContent = function buildContent() {
|
|
805
|
+
return idx;
|
|
806
|
+
}, [splitFieldsSet]);
|
|
807
|
+
var buildContent = (0, _react.useCallback)(function () {
|
|
695
808
|
var groups = Object.keys(groupedFields);
|
|
696
|
-
if (splitForm
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
809
|
+
if (!splitForm || splitFields.length === 0) return groups.map(function (g) {
|
|
810
|
+
return renderGroupSection(g, groupedFields[g]);
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
// ── Group-level split ────────────────────────────────────────────────────
|
|
814
|
+
if (splitGroup) {
|
|
815
|
+
// Find the rightmost group that contains any splitField
|
|
816
|
+
var pivotGroupIdx = -1;
|
|
817
|
+
groups.forEach(function (g, gi) {
|
|
818
|
+
if (groupedFields[g].some(function (f) {
|
|
819
|
+
return splitFieldsSet.has(f.name);
|
|
820
|
+
})) pivotGroupIdx = gi;
|
|
701
821
|
});
|
|
702
|
-
if (
|
|
822
|
+
if (pivotGroupIdx === -1) return groups.map(function (g) {
|
|
703
823
|
return renderGroupSection(g, groupedFields[g]);
|
|
704
824
|
});
|
|
705
825
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
706
826
|
className: "ufg-form-columns",
|
|
827
|
+
style: {
|
|
828
|
+
gridTemplateColumns: "repeat(".concat(splitColumns, ", 1fr)")
|
|
829
|
+
},
|
|
707
830
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
708
|
-
children: groups.slice(0,
|
|
831
|
+
children: groups.slice(0, pivotGroupIdx + 1).map(function (g) {
|
|
709
832
|
return renderGroupSection(g, groupedFields[g]);
|
|
710
833
|
})
|
|
711
834
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
712
|
-
children: groups.slice(
|
|
835
|
+
children: groups.slice(pivotGroupIdx + 1).map(function (g) {
|
|
713
836
|
return renderGroupSection(g, groupedFields[g]);
|
|
714
837
|
})
|
|
715
838
|
})]
|
|
716
839
|
});
|
|
717
840
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
children: groups.map(function (g) {
|
|
727
|
-
var _splitByField = splitByField(groupedFields[g]),
|
|
728
|
-
right = _splitByField.right;
|
|
729
|
-
return right.length ? renderGroupSection(g, right) : null;
|
|
730
|
-
})
|
|
731
|
-
})]
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
return groups.map(function (g) {
|
|
841
|
+
|
|
842
|
+
// ── Field-level split (cross-group aware) ────────────────────────────────
|
|
843
|
+
// Flatten preserving order, find pivot, then re-group each side.
|
|
844
|
+
var allFields = groups.flatMap(function (g) {
|
|
845
|
+
return groupedFields[g];
|
|
846
|
+
});
|
|
847
|
+
var pivot = lastSplitIdx(allFields);
|
|
848
|
+
if (pivot === -1) return groups.map(function (g) {
|
|
735
849
|
return renderGroupSection(g, groupedFields[g]);
|
|
736
850
|
});
|
|
737
|
-
|
|
851
|
+
var regroup = function regroup(slice) {
|
|
852
|
+
var map = {};
|
|
853
|
+
slice.forEach(function (f) {
|
|
854
|
+
var g = f.group || 'ungrouped';
|
|
855
|
+
if (!map[g]) map[g] = [];
|
|
856
|
+
map[g].push(f);
|
|
857
|
+
});
|
|
858
|
+
return Object.keys(map).map(function (g) {
|
|
859
|
+
return renderGroupSection(g, map[g]);
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
863
|
+
className: "ufg-form-columns",
|
|
864
|
+
style: {
|
|
865
|
+
gridTemplateColumns: "repeat(".concat(splitColumns, ", 1fr)")
|
|
866
|
+
},
|
|
867
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
868
|
+
children: regroup(allFields.slice(0, pivot + 1))
|
|
869
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
870
|
+
children: regroup(allFields.slice(pivot + 1))
|
|
871
|
+
})]
|
|
872
|
+
});
|
|
873
|
+
}, [groupedFields, splitForm, splitFields, splitGroup, splitFieldsSet, lastSplitIdx, renderGroupSection]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
738
874
|
|
|
739
875
|
// #endregion
|
|
740
876
|
// #region Actions bar
|
|
@@ -743,14 +879,11 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
743
879
|
className: "ufg-actions",
|
|
744
880
|
style: actionsDivStyle,
|
|
745
881
|
children: [customActions.map(function (action, idx) {
|
|
746
|
-
return
|
|
747
|
-
|
|
748
|
-
className:
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
style: _objectSpread(_objectSpread({}, actionsStyle), action.style),
|
|
752
|
-
children: [action.icon, action.label || action.name]
|
|
753
|
-
}, idx);
|
|
882
|
+
return (0, _CustomAction["default"])(_objectSpread(_objectSpread({}, action), {}, {
|
|
883
|
+
name: "".concat(action.name, " ").concat(idx),
|
|
884
|
+
className: action.className || "ufg-button-secondary",
|
|
885
|
+
style: _objectSpread(_objectSpread({}, actionsStyle), action.style)
|
|
886
|
+
}));
|
|
754
887
|
}), showSubmit && haveSaveButton && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
755
888
|
type: "submit",
|
|
756
889
|
className: "ufg-button ".concat(submitButton.className || 'ufg-button-primary'),
|
|
@@ -775,7 +908,14 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
775
908
|
|
|
776
909
|
// #endregion
|
|
777
910
|
// #region Form JSX
|
|
778
|
-
var formJSX = /*#__PURE__*/(0, _jsxRuntime.jsxs)("
|
|
911
|
+
var formJSX = disableFormTag ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
912
|
+
className: "ufg-form",
|
|
913
|
+
style: formStyle || {
|
|
914
|
+
margin: 'auto'
|
|
915
|
+
},
|
|
916
|
+
onSubmit: onFormSubmit,
|
|
917
|
+
children: [buildContent(), actionsBar]
|
|
918
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
|
|
779
919
|
className: "ufg-form",
|
|
780
920
|
style: formStyle || {
|
|
781
921
|
margin: 'auto'
|
package/package.json
CHANGED