@steroidsjs/core 3.0.26 → 3.0.28
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/docs-autogen-result.json
CHANGED
|
@@ -19027,6 +19027,24 @@
|
|
|
19027
19027
|
"example": null
|
|
19028
19028
|
}
|
|
19029
19029
|
]
|
|
19030
|
+
},
|
|
19031
|
+
{
|
|
19032
|
+
"name": "onClose",
|
|
19033
|
+
"decorators": [],
|
|
19034
|
+
"description": "Callback-функция, которая вызывается при закрытии DropDown",
|
|
19035
|
+
"required": false,
|
|
19036
|
+
"type": "void",
|
|
19037
|
+
"example": null,
|
|
19038
|
+
"parameters": [
|
|
19039
|
+
{
|
|
19040
|
+
"name": "selectedIds",
|
|
19041
|
+
"decorators": [],
|
|
19042
|
+
"description": "",
|
|
19043
|
+
"required": true,
|
|
19044
|
+
"type": "PrimaryKey[]",
|
|
19045
|
+
"example": null
|
|
19046
|
+
}
|
|
19047
|
+
]
|
|
19030
19048
|
}
|
|
19031
19049
|
]
|
|
19032
19050
|
},
|
|
@@ -19445,6 +19463,24 @@
|
|
|
19445
19463
|
}
|
|
19446
19464
|
]
|
|
19447
19465
|
},
|
|
19466
|
+
{
|
|
19467
|
+
"name": "onClose",
|
|
19468
|
+
"decorators": [],
|
|
19469
|
+
"description": "Callback-функция, которая вызывается при закрытии DropDown",
|
|
19470
|
+
"required": false,
|
|
19471
|
+
"type": "void",
|
|
19472
|
+
"example": null,
|
|
19473
|
+
"parameters": [
|
|
19474
|
+
{
|
|
19475
|
+
"name": "selectedIds",
|
|
19476
|
+
"decorators": [],
|
|
19477
|
+
"description": "",
|
|
19478
|
+
"required": true,
|
|
19479
|
+
"type": "PrimaryKey[]",
|
|
19480
|
+
"example": null
|
|
19481
|
+
}
|
|
19482
|
+
]
|
|
19483
|
+
},
|
|
19448
19484
|
{
|
|
19449
19485
|
"name": "onItemRemove",
|
|
19450
19486
|
"decorators": [],
|
|
@@ -20663,6 +20699,15 @@
|
|
|
20663
20699
|
}
|
|
20664
20700
|
],
|
|
20665
20701
|
"methods": [
|
|
20702
|
+
{
|
|
20703
|
+
"name": "onAdd",
|
|
20704
|
+
"decorators": [],
|
|
20705
|
+
"description": "",
|
|
20706
|
+
"required": false,
|
|
20707
|
+
"type": "void",
|
|
20708
|
+
"example": null,
|
|
20709
|
+
"parameters": []
|
|
20710
|
+
},
|
|
20666
20711
|
{
|
|
20667
20712
|
"name": "onRemove",
|
|
20668
20713
|
"decorators": [],
|
package/package.json
CHANGED
|
@@ -130,6 +130,10 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, Omit<IData
|
|
|
130
130
|
* Кастомная вьюшка для элемента
|
|
131
131
|
*/
|
|
132
132
|
itemView?: CustomView;
|
|
133
|
+
/**
|
|
134
|
+
* Callback-функция, которая вызывается при закрытии DropDown
|
|
135
|
+
*/
|
|
136
|
+
onClose?: (selectedIds: PrimaryKey[]) => void;
|
|
133
137
|
[key: string]: any;
|
|
134
138
|
}
|
|
135
139
|
export interface IDropDownFieldViewProps extends IDropDownFieldProps {
|
|
@@ -135,9 +135,14 @@ function DropDownField(props) {
|
|
|
135
135
|
setSelectedIds([]);
|
|
136
136
|
}, [setSelectedIds]);
|
|
137
137
|
var onClose = (0, react_1.useCallback)(function () {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
if (isOpened) {
|
|
139
|
+
setIsFocused(false);
|
|
140
|
+
setIsOpened(false);
|
|
141
|
+
if (props.onClose) {
|
|
142
|
+
props.onClose(selectedIds);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}, [isOpened, props, selectedIds, setIsFocused, setIsOpened]);
|
|
141
146
|
// Outside click -> close
|
|
142
147
|
var forwardedRef = (0, react_1.useRef)(null);
|
|
143
148
|
if (process.env.PLATFORM !== 'mobile') {
|
|
@@ -136,6 +136,7 @@ export interface IFieldListItemViewProps extends IFieldWrapperOutputProps {
|
|
|
136
136
|
required?: boolean;
|
|
137
137
|
rowIndex: number;
|
|
138
138
|
showRemove: boolean;
|
|
139
|
+
onAdd?: () => void;
|
|
139
140
|
}
|
|
140
141
|
declare const _default: import("../../form/Field/fieldWrapper").FieldWrapperComponent<IFieldListProps>;
|
|
141
142
|
export default _default;
|
|
@@ -131,9 +131,10 @@ function FieldList(props) {
|
|
|
131
131
|
required: props.required,
|
|
132
132
|
className: props.className,
|
|
133
133
|
tableClassName: props.tableClassName,
|
|
134
|
-
items: items
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
items: items,
|
|
135
|
+
onAdd: onAdd
|
|
136
|
+
}); }, [items, onAdd, props.className, props.disabled, props.required, props.showAdd, props.showRemove, props.size, props.tableClassName]);
|
|
137
|
+
var viewProps = (0, react_1.useMemo)(function () { return (__assign(__assign(__assign({}, commonProps), props.viewProps), { forwardedRef: nodeRef, hasAlternatingColors: props.hasAlternatingColors, style: props.style, children: props.children })); }, [commonProps, props.children, props.hasAlternatingColors, props.style, props.viewProps]);
|
|
137
138
|
var itemViewProps = (0, react_1.useMemo)(function () { return (__assign(__assign(__assign({}, commonProps), props.itemViewProps), { onRemove: onRemove })); }, [commonProps, onRemove, props.itemViewProps]);
|
|
138
139
|
var FieldListView = props.view || components.ui.getView('form.FieldListView');
|
|
139
140
|
var FieldListItemView = props.itemView || components.ui.getView('form.FieldListItemView');
|
package/utils/form.js
CHANGED
|
@@ -18,11 +18,11 @@ exports.providers = exports.clearErrors = exports.cleanEmptyObject = exports.set
|
|
|
18
18
|
var isPlainObject_1 = __importDefault(require("lodash-es/isPlainObject"));
|
|
19
19
|
var isArray_1 = __importDefault(require("lodash-es/isArray"));
|
|
20
20
|
var isEqual_1 = __importDefault(require("lodash-es/isEqual"));
|
|
21
|
+
var cloneDeep_1 = __importDefault(require("lodash-es/cloneDeep"));
|
|
21
22
|
var get_1 = __importDefault(require("lodash-es/get"));
|
|
22
|
-
var
|
|
23
|
-
var toPairs_1 = __importDefault(require("lodash-es/toPairs"));
|
|
24
|
-
var omit_1 = __importDefault(require("lodash-es/omit"));
|
|
23
|
+
var isObject_1 = __importDefault(require("lodash-es/isObject"));
|
|
25
24
|
var isEmpty_1 = __importDefault(require("lodash-es/isEmpty"));
|
|
25
|
+
var unset_1 = __importDefault(require("lodash-es/unset"));
|
|
26
26
|
var react_1 = require("react");
|
|
27
27
|
var react_use_1 = require("react-use");
|
|
28
28
|
var useDispatch_1 = __importDefault(require("../hooks/useDispatch"));
|
|
@@ -81,12 +81,34 @@ var cleanEmptyObject = function (object) {
|
|
|
81
81
|
exports.cleanEmptyObject = cleanEmptyObject;
|
|
82
82
|
var clearErrors = function (values, prevValues, errors, setErrors) {
|
|
83
83
|
if (!(0, isEmpty_1["default"])(errors) && !(0, isEqual_1["default"])(prevValues || {}, values)) {
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
84
|
+
var cleanedErrors_1 = (0, cloneDeep_1["default"])(errors);
|
|
85
|
+
var clearFieldErrors_1 = function (errorsPath, currentValue, currentPrevValue) {
|
|
86
|
+
if (!(0, isEqual_1["default"])(currentValue, currentPrevValue)) {
|
|
87
|
+
(0, unset_1["default"])(cleanedErrors_1, errorsPath);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var iterateErrors_1 = function (currentErrors, currentValues, currentPrevValues, path) {
|
|
91
|
+
if (path === void 0) { path = ''; }
|
|
92
|
+
Object.keys(currentErrors).forEach(function (key) {
|
|
93
|
+
var errorValue = currentErrors[key];
|
|
94
|
+
var newPath = path
|
|
95
|
+
? [path, key].join('.')
|
|
96
|
+
: key;
|
|
97
|
+
if ((0, isObject_1["default"])(errorValue)
|
|
98
|
+
&& !(0, isArray_1["default"])(errorValue)) {
|
|
99
|
+
// Если текущее значение ошибки - объект (но не массив), рекурсивно обрабатываем его
|
|
100
|
+
iterateErrors_1(errorValue, (0, get_1["default"])(currentValues, key, {}), (0, get_1["default"])(currentPrevValues, key, {}), newPath);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// Если текущее значение ошибки не объект, проверяем изменение значения
|
|
104
|
+
clearFieldErrors_1(newPath, (0, get_1["default"])(currentValues, key), (0, get_1["default"])(currentPrevValues, key));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
iterateErrors_1(errors, values, prevValues);
|
|
109
|
+
setErrors((0, isEmpty_1["default"])(cleanedErrors_1)
|
|
110
|
+
? null
|
|
111
|
+
: cleanedErrors_1);
|
|
90
112
|
}
|
|
91
113
|
};
|
|
92
114
|
exports.clearErrors = clearErrors;
|