@steroidsjs/core 2.2.11 → 2.2.12
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/package.json
CHANGED
package/reducers/form.js
CHANGED
|
@@ -50,7 +50,7 @@ function reducerItem(state, action) {
|
|
|
50
50
|
case form_1.FORM_SUBMIT:
|
|
51
51
|
return dot_prop_immutable_1.set(state, 'submitCounter', (state.submitCounter || 0) + 1);
|
|
52
52
|
case form_1.FORM_RESET:
|
|
53
|
-
return
|
|
53
|
+
return __assign(__assign({}, state), { values: cloneDeep_1["default"](state.initialValues || {}) });
|
|
54
54
|
case form_1.FORM_ARRAY_ADD:
|
|
55
55
|
// eslint-disable-next-line no-case-declarations
|
|
56
56
|
var newValue = [].concat(get_1["default"](state, 'values.' + action.name) || []);
|
|
@@ -90,7 +90,7 @@ export interface IButtonProps {
|
|
|
90
90
|
* автоматически будет переключаться в режим загрузки (`loading`) на время выполнения `Promise`.
|
|
91
91
|
* @param e => fetch(...)
|
|
92
92
|
*/
|
|
93
|
-
onClick?: (e: Event | React.MouseEvent) => Promise<any> |
|
|
93
|
+
onClick?: (e: Event | React.MouseEvent) => Promise<any> | any;
|
|
94
94
|
/**
|
|
95
95
|
* Переводит кнопку в состояние "не активна"
|
|
96
96
|
* @example true
|
|
@@ -15,6 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
exports.__esModule = true;
|
|
17
17
|
var react_1 = require("react");
|
|
18
|
+
var react_use_1 = require("react-use");
|
|
18
19
|
var hooks_1 = require("../../../hooks");
|
|
19
20
|
var fieldWrapper_1 = __importDefault(require("../../../ui/form/Field/fieldWrapper"));
|
|
20
21
|
function CheckboxListField(props) {
|
|
@@ -42,6 +43,17 @@ function CheckboxListField(props) {
|
|
|
42
43
|
react_1.useEffect(function () {
|
|
43
44
|
props.input.onChange.call(null, selectedIds);
|
|
44
45
|
}, [props.input.onChange, selectedIds]);
|
|
46
|
+
var onReset = react_1.useCallback(function () {
|
|
47
|
+
setSelectedIds([]);
|
|
48
|
+
}, [setSelectedIds]);
|
|
49
|
+
// Reset selected ids on form reset
|
|
50
|
+
var prevInputValue = react_use_1.usePrevious(props.input.value);
|
|
51
|
+
react_use_1.useUpdateEffect(function () {
|
|
52
|
+
// if form reset
|
|
53
|
+
if (prevInputValue && props.input.value === undefined && selectedIds.length > 0) {
|
|
54
|
+
onReset();
|
|
55
|
+
}
|
|
56
|
+
}, [onReset, prevInputValue, props.input.value, selectedIds.length]);
|
|
45
57
|
return components.ui.renderView(props.view || 'form.CheckboxListFieldView', __assign(__assign({}, props), { items: items,
|
|
46
58
|
inputProps: inputProps,
|
|
47
59
|
onItemSelect: onItemSelect,
|
|
@@ -21,9 +21,9 @@ function NumberField(props) {
|
|
|
21
21
|
var components = hooks_1.useComponents();
|
|
22
22
|
props.inputProps = react_1.useMemo(function () {
|
|
23
23
|
var _a;
|
|
24
|
-
return (__assign({ name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a :
|
|
24
|
+
return (__assign({ name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onChange: function (e) { var _a, _b; return props.input.onChange(((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) || ((_b = e.nativeEvent) === null || _b === void 0 ? void 0 : _b.text)); }, type: 'number', min: props.min, max: props.max, step: props.step, placeholder: props.placeholder, disabled: props.disabled }, props.inputProps));
|
|
25
25
|
}, [props.disabled, props.input, props.inputProps, props.placeholder, props.min, props.max, props.step]);
|
|
26
|
-
return components.ui.renderView(props.view || 'form.NumberFieldView'
|
|
26
|
+
return components.ui.renderView(props.view || 'form.NumberFieldView', props);
|
|
27
27
|
}
|
|
28
28
|
NumberField.defaultProps = {
|
|
29
29
|
disabled: false,
|