@insticc/genericform 2.0.8 → 2.1.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/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 +166 -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 +200 -58
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
|
12
12
|
/** onChange(name, value: bool) */var CustomToggle = function CustomToggle(_ref) {
|
|
13
13
|
var onChange = _ref.onChange,
|
|
14
14
|
name = _ref.name,
|
|
15
|
-
|
|
15
|
+
label = _ref.label,
|
|
16
16
|
_ref$value = _ref.value,
|
|
17
17
|
value = _ref$value === void 0 ? false : _ref$value,
|
|
18
18
|
_ref$disabled = _ref.disabled,
|
|
@@ -45,7 +45,15 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
|
45
45
|
style: mainDivStyle,
|
|
46
46
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
47
47
|
className: "ufg-toggle-wrapper",
|
|
48
|
-
children: [(0, _defaults.labelJsx)(
|
|
48
|
+
children: [(0, _defaults.labelJsx)({
|
|
49
|
+
name: name,
|
|
50
|
+
labelStyle: labelStyle,
|
|
51
|
+
label: label,
|
|
52
|
+
required: required,
|
|
53
|
+
spanStyle: spanStyle,
|
|
54
|
+
showHelp: showHelp,
|
|
55
|
+
helpText: helpText
|
|
56
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
49
57
|
className: "ufg-toggle-track".concat(value ? " active" : "").concat(disabled ? " disabled" : ""),
|
|
50
58
|
style: inputStyle,
|
|
51
59
|
onClick: handleClick,
|
|
@@ -59,7 +67,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
|
59
67
|
CustomToggle.propTypes = {
|
|
60
68
|
onChange: _propTypes["default"].func.isRequired,
|
|
61
69
|
name: _propTypes["default"].string.isRequired,
|
|
62
|
-
|
|
70
|
+
label: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object]),
|
|
63
71
|
value: _propTypes["default"].bool,
|
|
64
72
|
disabled: _propTypes["default"].bool,
|
|
65
73
|
required: _propTypes["default"].bool,
|
|
@@ -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,17 @@ 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,
|
|
619
|
+
countryCodes: field.countryCodes,
|
|
620
|
+
defaultCountryCode: field.defaultCountryCode
|
|
621
|
+
}), field.name);
|
|
517
622
|
|
|
518
623
|
// Date
|
|
519
624
|
case 'date':
|
|
@@ -522,7 +627,6 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
522
627
|
case 'year':
|
|
523
628
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomDatePicker["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
|
|
524
629
|
value: value,
|
|
525
|
-
placeholder: field.placeholder,
|
|
526
630
|
onChange: dateFieldHandler(field),
|
|
527
631
|
isValidDate: field.validate,
|
|
528
632
|
dateFormat: field.type === 'time' ? false : field.type === 'year' ? 'YYYY' : 'DD/MM/YYYY',
|
|
@@ -634,12 +738,17 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
634
738
|
return validateJsonField(name, raw, isMulti, false, field);
|
|
635
739
|
}
|
|
636
740
|
}), field.name);
|
|
741
|
+
case 'file':
|
|
742
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomFileInput["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, cp), sp), fp), {}, {
|
|
743
|
+
value: value,
|
|
744
|
+
accept: field.accept,
|
|
745
|
+
onChange: fieldHandler(field)
|
|
746
|
+
}), field.name);
|
|
637
747
|
default:
|
|
638
748
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomInput["default"], _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
639
749
|
type: field.type
|
|
640
750
|
}, cp), sp), fp), {}, {
|
|
641
751
|
value: value,
|
|
642
|
-
placeholder: field.placeholder,
|
|
643
752
|
onChange: fieldHandler(field),
|
|
644
753
|
className: field.className
|
|
645
754
|
}), field.name);
|
|
@@ -662,6 +771,7 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
662
771
|
return groupByInline(fieldList).map(function (group, idx) {
|
|
663
772
|
return group.type === 'inline' ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
664
773
|
className: "ufg-field-row",
|
|
774
|
+
style: inlineStyle,
|
|
665
775
|
children: group.fields.map(function (_ref9) {
|
|
666
776
|
var field = _ref9.field;
|
|
667
777
|
return renderField(field);
|
|
@@ -678,63 +788,91 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
678
788
|
}), renderFields(fieldList)]
|
|
679
789
|
}, g);
|
|
680
790
|
};
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
791
|
+
|
|
792
|
+
// ── Replace splitByField + buildContent entirely ─────────────────────────────
|
|
793
|
+
|
|
794
|
+
var splitFieldsSet = (0, _react.useMemo)(function () {
|
|
795
|
+
return new Set(splitFields);
|
|
796
|
+
}, [splitFields]);
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Returns the index of the last field (in `list`) whose name is in splitFields.
|
|
800
|
+
* Returns -1 when none match.
|
|
801
|
+
*/
|
|
802
|
+
var lastSplitIdx = (0, _react.useCallback)(function (list) {
|
|
803
|
+
var idx = -1;
|
|
804
|
+
list.forEach(function (f, i) {
|
|
805
|
+
if (splitFieldsSet.has(f.name)) idx = i;
|
|
684
806
|
});
|
|
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() {
|
|
807
|
+
return idx;
|
|
808
|
+
}, [splitFieldsSet]);
|
|
809
|
+
var buildContent = (0, _react.useCallback)(function () {
|
|
695
810
|
var groups = Object.keys(groupedFields);
|
|
696
|
-
if (splitForm
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
811
|
+
if (!splitForm || splitFields.length === 0) return groups.map(function (g) {
|
|
812
|
+
return renderGroupSection(g, groupedFields[g]);
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
// ── Group-level split ────────────────────────────────────────────────────
|
|
816
|
+
if (splitGroup) {
|
|
817
|
+
// Find the rightmost group that contains any splitField
|
|
818
|
+
var pivotGroupIdx = -1;
|
|
819
|
+
groups.forEach(function (g, gi) {
|
|
820
|
+
if (groupedFields[g].some(function (f) {
|
|
821
|
+
return splitFieldsSet.has(f.name);
|
|
822
|
+
})) pivotGroupIdx = gi;
|
|
701
823
|
});
|
|
702
|
-
if (
|
|
824
|
+
if (pivotGroupIdx === -1) return groups.map(function (g) {
|
|
703
825
|
return renderGroupSection(g, groupedFields[g]);
|
|
704
826
|
});
|
|
705
827
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
706
828
|
className: "ufg-form-columns",
|
|
829
|
+
style: {
|
|
830
|
+
gridTemplateColumns: "repeat(".concat(splitColumns, ", 1fr)")
|
|
831
|
+
},
|
|
707
832
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
708
|
-
children: groups.slice(0,
|
|
833
|
+
children: groups.slice(0, pivotGroupIdx + 1).map(function (g) {
|
|
709
834
|
return renderGroupSection(g, groupedFields[g]);
|
|
710
835
|
})
|
|
711
836
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
712
|
-
children: groups.slice(
|
|
837
|
+
children: groups.slice(pivotGroupIdx + 1).map(function (g) {
|
|
713
838
|
return renderGroupSection(g, groupedFields[g]);
|
|
714
839
|
})
|
|
715
840
|
})]
|
|
716
841
|
});
|
|
717
842
|
}
|
|
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) {
|
|
843
|
+
|
|
844
|
+
// ── Field-level split (cross-group aware) ────────────────────────────────
|
|
845
|
+
// Flatten preserving order, find pivot, then re-group each side.
|
|
846
|
+
var allFields = groups.flatMap(function (g) {
|
|
847
|
+
return groupedFields[g];
|
|
848
|
+
});
|
|
849
|
+
var pivot = lastSplitIdx(allFields);
|
|
850
|
+
if (pivot === -1) return groups.map(function (g) {
|
|
735
851
|
return renderGroupSection(g, groupedFields[g]);
|
|
736
852
|
});
|
|
737
|
-
|
|
853
|
+
var regroup = function regroup(slice) {
|
|
854
|
+
var map = {};
|
|
855
|
+
slice.forEach(function (f) {
|
|
856
|
+
var g = f.group || 'ungrouped';
|
|
857
|
+
if (!map[g]) map[g] = [];
|
|
858
|
+
map[g].push(f);
|
|
859
|
+
});
|
|
860
|
+
return Object.keys(map).map(function (g) {
|
|
861
|
+
return renderGroupSection(g, map[g]);
|
|
862
|
+
});
|
|
863
|
+
};
|
|
864
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
865
|
+
className: "ufg-form-columns",
|
|
866
|
+
style: {
|
|
867
|
+
gridTemplateColumns: "repeat(".concat(splitColumns, ", 1fr)")
|
|
868
|
+
},
|
|
869
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
870
|
+
children: regroup(allFields.slice(0, pivot + 1))
|
|
871
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
872
|
+
children: regroup(allFields.slice(pivot + 1))
|
|
873
|
+
})]
|
|
874
|
+
});
|
|
875
|
+
}, [groupedFields, splitForm, splitFields, splitGroup, splitFieldsSet, lastSplitIdx, renderGroupSection]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
738
876
|
|
|
739
877
|
// #endregion
|
|
740
878
|
// #region Actions bar
|
|
@@ -743,14 +881,11 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
743
881
|
className: "ufg-actions",
|
|
744
882
|
style: actionsDivStyle,
|
|
745
883
|
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);
|
|
884
|
+
return (0, _CustomAction["default"])(_objectSpread(_objectSpread({}, action), {}, {
|
|
885
|
+
name: "".concat(action.name, " ").concat(idx),
|
|
886
|
+
className: action.className || "ufg-button-secondary",
|
|
887
|
+
style: _objectSpread(_objectSpread({}, actionsStyle), action.style)
|
|
888
|
+
}));
|
|
754
889
|
}), showSubmit && haveSaveButton && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
755
890
|
type: "submit",
|
|
756
891
|
className: "ufg-button ".concat(submitButton.className || 'ufg-button-primary'),
|
|
@@ -775,7 +910,14 @@ var GenericForm = function GenericForm(_ref) {
|
|
|
775
910
|
|
|
776
911
|
// #endregion
|
|
777
912
|
// #region Form JSX
|
|
778
|
-
var formJSX = /*#__PURE__*/(0, _jsxRuntime.jsxs)("
|
|
913
|
+
var formJSX = disableFormTag ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
914
|
+
className: "ufg-form",
|
|
915
|
+
style: formStyle || {
|
|
916
|
+
margin: 'auto'
|
|
917
|
+
},
|
|
918
|
+
onSubmit: onFormSubmit,
|
|
919
|
+
children: [buildContent(), actionsBar]
|
|
920
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
|
|
779
921
|
className: "ufg-form",
|
|
780
922
|
style: formStyle || {
|
|
781
923
|
margin: 'auto'
|
package/package.json
CHANGED