intelicoreact 1.5.11 → 1.5.13
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.
|
@@ -27,11 +27,12 @@ const Label = _ref => {
|
|
|
27
27
|
"aria-label": label,
|
|
28
28
|
className: (0, _classnames.default)("label", {
|
|
29
29
|
label_bold: isLabelBolt,
|
|
30
|
-
error: error
|
|
30
|
+
error: error,
|
|
31
|
+
isRequired: isRequired
|
|
31
32
|
}, className)
|
|
32
|
-
},
|
|
33
|
-
className: "
|
|
34
|
-
},
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
34
|
+
className: "label_text"
|
|
35
|
+
}, label), note && /*#__PURE__*/_react.default.createElement("span", {
|
|
35
36
|
className: "label_note"
|
|
36
37
|
}, note), hint && /*#__PURE__*/_react.default.createElement(_Hint.default, {
|
|
37
38
|
isAccessability: isAccessabilityHint,
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
.label {
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
|
-
|
|
5
4
|
margin-bottom: 5px;
|
|
6
5
|
|
|
7
6
|
font-size: 13px;
|
|
8
7
|
|
|
9
8
|
color: #1e1e2d;
|
|
10
9
|
|
|
10
|
+
.label_text {
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.isRequired .label_text {
|
|
15
|
+
margin-right: 8px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.isRequired .label_text::after {
|
|
19
|
+
content: '*';
|
|
20
|
+
position: absolute;
|
|
21
|
+
right: -8px;
|
|
22
|
+
color: red;
|
|
23
|
+
}
|
|
24
|
+
|
|
11
25
|
&_bold {
|
|
12
26
|
font-weight: 500;
|
|
13
27
|
}
|
|
@@ -16,12 +30,6 @@
|
|
|
16
30
|
margin-left: 5px;
|
|
17
31
|
}
|
|
18
32
|
|
|
19
|
-
&_isRequired {
|
|
20
|
-
margin-left: 3px;
|
|
21
|
-
|
|
22
|
-
color: red;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
33
|
&_note {
|
|
26
34
|
margin-left: 4px;
|
|
27
35
|
}
|
|
@@ -23,6 +23,10 @@ const FormWithDependOn = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
23
23
|
form,
|
|
24
24
|
formId,
|
|
25
25
|
setForm,
|
|
26
|
+
//! Рекомендую НЕ использовать, пока что работает плохо
|
|
27
|
+
//? По задумке вводилась для коррекции формы при асинхронных последовательных зависимостях
|
|
28
|
+
// todo(VL) - как-нибудь попробовать допилить
|
|
29
|
+
getActualForm: getActualFormOuter,
|
|
26
30
|
onChange,
|
|
27
31
|
renderField,
|
|
28
32
|
getAnotherActions,
|
|
@@ -35,7 +39,7 @@ const FormWithDependOn = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
35
39
|
const [initialForm] = (0, _react.useState)((0, _utils.clone)(form));
|
|
36
40
|
const safelySetForm = typeof setForm === "function" ? setForm : () => {};
|
|
37
41
|
const safelyOnChange = typeof onChange === "function" ? onChange : () => {};
|
|
38
|
-
const getActualForm = () => form;
|
|
42
|
+
const getActualForm = typeof getActualFormOuter === "function" ? getActualFormOuter : () => form;
|
|
39
43
|
const {
|
|
40
44
|
assignChangesToField
|
|
41
45
|
} = (0, _useFormFieldsChangesManager.default)({
|
|
@@ -72,9 +76,13 @@ const FormWithDependOn = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
72
76
|
const handleChange = (newValue, fieldKey, propKey, additionalOfOnChange) => {
|
|
73
77
|
const {
|
|
74
78
|
updatedForm = null,
|
|
75
|
-
isMakeChangesAnyway = false
|
|
79
|
+
isMakeChangesAnyway = false,
|
|
80
|
+
isUseActualForm = false
|
|
76
81
|
} = (0, _utils.getIsOnlyAnObject)(additionalOfOnChange) ? additionalOfOnChange : {};
|
|
77
|
-
const currentForm = (0, _utils.clone)(
|
|
82
|
+
const currentForm = (0, _utils.clone)((() => {
|
|
83
|
+
if (isUseActualForm) return getActualForm();
|
|
84
|
+
return Array.isArray(updatedForm) ? updatedForm : form;
|
|
85
|
+
})());
|
|
78
86
|
const currField = (0, _utils.clone)(currentForm.find(field => field.key === fieldKey));
|
|
79
87
|
|
|
80
88
|
// ? Защита от дублирующих вызовов onChange снизу
|
|
@@ -86,7 +94,10 @@ const FormWithDependOn = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
86
94
|
if (currField[propKey || "value"] === newValue && !isMakeChangesAnyway) return;
|
|
87
95
|
|
|
88
96
|
// ? Сразу же мутируем
|
|
89
|
-
safelyOnChange(newValue, fieldKey, propKey,
|
|
97
|
+
safelyOnChange(newValue, fieldKey, propKey, {
|
|
98
|
+
...additionalOfOnChange,
|
|
99
|
+
updatedForm: currentForm
|
|
100
|
+
});
|
|
90
101
|
|
|
91
102
|
// ? Механика dependOn (обработка зависимостей)
|
|
92
103
|
// ? В текущей реализации отделил от экшена all.
|
|
@@ -143,9 +154,7 @@ const FormWithDependOn = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
143
154
|
}, [isInitializeByDependOn]);
|
|
144
155
|
|
|
145
156
|
// ***** output *****
|
|
146
|
-
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
147
|
-
ref: ref
|
|
148
|
-
}, formId ? {
|
|
157
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, formId ? {
|
|
149
158
|
id: formId
|
|
150
159
|
} : {}, {
|
|
151
160
|
className: (0, _classnames.default)(RC, className)
|