@steroidsjs/core 3.0.20 → 3.0.21
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 +17 -0
- package/en.json +1 -0
- package/package.json +1 -1
- package/ui/form/CheckboxListField/CheckboxListField.d.ts +0 -1
- package/ui/form/CheckboxListField/CheckboxListField.js +10 -4
- package/ui/form/FileField/FileField.js +4 -2
- package/ui/form/NumberField/NumberField.d.ts +4 -0
- package/ui/form/NumberField/NumberField.js +3 -2
- package/ui/form/NumberField/hooks/useInputTypeNumber.d.ts +1 -1
- package/ui/form/NumberField/hooks/useInputTypeNumber.js +25 -13
package/docs-autogen-result.json
CHANGED
|
@@ -25384,6 +25384,15 @@
|
|
|
25384
25384
|
"example": "{ onKeyDown: ... }",
|
|
25385
25385
|
"defaultValue": null
|
|
25386
25386
|
},
|
|
25387
|
+
{
|
|
25388
|
+
"name": "isCanBeNegative",
|
|
25389
|
+
"decorators": [],
|
|
25390
|
+
"description": "Может ли число быть отрицательным",
|
|
25391
|
+
"required": false,
|
|
25392
|
+
"type": "boolean",
|
|
25393
|
+
"example": null,
|
|
25394
|
+
"defaultValue": null
|
|
25395
|
+
},
|
|
25387
25396
|
{
|
|
25388
25397
|
"name": "isRenderWithoutFieldLayout",
|
|
25389
25398
|
"decorators": [],
|
|
@@ -25665,6 +25674,14 @@
|
|
|
25665
25674
|
"type": "MutableRefObject",
|
|
25666
25675
|
"example": null
|
|
25667
25676
|
},
|
|
25677
|
+
{
|
|
25678
|
+
"name": "isCanBeNegative",
|
|
25679
|
+
"decorators": [],
|
|
25680
|
+
"description": "Может ли число быть отрицательным",
|
|
25681
|
+
"required": false,
|
|
25682
|
+
"type": "boolean",
|
|
25683
|
+
"example": null
|
|
25684
|
+
},
|
|
25668
25685
|
{
|
|
25669
25686
|
"name": "isRenderWithoutFieldLayout",
|
|
25670
25687
|
"decorators": [],
|
package/en.json
CHANGED
|
@@ -1003,6 +1003,7 @@
|
|
|
1003
1003
|
"Конструктор редактора 'ckeditor5-react' из библиотеки @steroidsjs/ckeditor5/packages/ckeditor5-build-classic\nПримечание: для использования встроенного отображения 'HtmlField', данный компонент должен быть передан": "",
|
|
1004
1004
|
"Компонент редактора 'ckeditor5-react' из библиотеки @ckeditor\nПримечание: для использования встроенного отображения 'HtmlField', данный компонент должен быть передан": "",
|
|
1005
1005
|
"Допустимое количество символов после разделителя": "",
|
|
1006
|
+
"Может ли число быть отрицательным": "",
|
|
1006
1007
|
"CSS-класс для элемента навигации.": "",
|
|
1007
1008
|
"Тип данных для параметров маршрута.": "",
|
|
1008
1009
|
"Обертка над Redux Store со встроенными middleware (thunk, multi, promise..) и react-router.": ""
|
package/package.json
CHANGED
|
@@ -58,7 +58,6 @@ export interface ICheckboxListFieldProps extends IFieldWrapperInputProps, Omit<I
|
|
|
58
58
|
viewProps?: {
|
|
59
59
|
[key: string]: any;
|
|
60
60
|
};
|
|
61
|
-
[key: string]: any;
|
|
62
61
|
}
|
|
63
62
|
export interface ICheckboxListFieldViewProps extends IFieldWrapperOutputProps, IUiComponent {
|
|
64
63
|
inputProps: {
|
|
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
exports.__esModule = true;
|
|
40
40
|
var react_1 = __importStar(require("react"));
|
|
41
41
|
var react_use_1 = require("react-use");
|
|
42
|
+
var isEqual_1 = __importDefault(require("lodash-es/isEqual"));
|
|
42
43
|
var hooks_1 = require("../../../hooks");
|
|
43
44
|
var fieldWrapper_1 = __importDefault(require("../../../ui/form/Field/fieldWrapper"));
|
|
44
45
|
function CheckboxListField(props) {
|
|
@@ -53,6 +54,7 @@ function CheckboxListField(props) {
|
|
|
53
54
|
selectedIds: inputSelectedIds,
|
|
54
55
|
multiple: props.multiple,
|
|
55
56
|
primaryKey: props.primaryKey,
|
|
57
|
+
selectFirst: props.selectFirst,
|
|
56
58
|
items: items,
|
|
57
59
|
inputValue: props.input.value
|
|
58
60
|
}), selectedIds = _a.selectedIds, setSelectedIds = _a.setSelectedIds;
|
|
@@ -61,12 +63,16 @@ function CheckboxListField(props) {
|
|
|
61
63
|
}, [setSelectedIds]);
|
|
62
64
|
var inputProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.inputProps), { type: 'checkbox', name: props.input.name, disabled: props.disabled })); }, [props.disabled, props.input, props.inputProps]);
|
|
63
65
|
// Sync with form
|
|
66
|
+
var prevSelectedIds = (0, react_use_1.usePrevious)(selectedIds);
|
|
64
67
|
(0, react_1.useEffect)(function () {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
props.onChange
|
|
68
|
+
if (!(0, isEqual_1["default"])(prevSelectedIds || [], selectedIds)) {
|
|
69
|
+
props.input.onChange.call(null, selectedIds);
|
|
70
|
+
if (props.onChange) {
|
|
71
|
+
props.onChange.call(null, selectedIds);
|
|
72
|
+
}
|
|
68
73
|
}
|
|
69
|
-
|
|
74
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
|
+
}, [props.input.onChange, selectedIds]);
|
|
70
76
|
var onReset = (0, react_1.useCallback)(function () {
|
|
71
77
|
setSelectedIds([]);
|
|
72
78
|
}, [setSelectedIds]);
|
|
@@ -71,7 +71,10 @@ function FileFieldComponent(props) {
|
|
|
71
71
|
}
|
|
72
72
|
}, [files, props]);
|
|
73
73
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
74
|
+
input: props.input,
|
|
74
75
|
buttonView: props.buttonView,
|
|
76
|
+
multiple: props.multiple,
|
|
77
|
+
imagesOnly: props.imagesOnly,
|
|
75
78
|
buttonProps: __assign({ label: props.filesLayout === FilesLayout.wall
|
|
76
79
|
? __('Upload')
|
|
77
80
|
: __('Click to Upload'), size: props.size, disabled: props.disabled, onClick: onBrowse }, props.buttonProps),
|
|
@@ -122,8 +125,7 @@ function FileFieldComponent(props) {
|
|
|
122
125
|
}
|
|
123
126
|
return item;
|
|
124
127
|
})
|
|
125
|
-
}); }, [FileFieldItemView, files, onBrowse, onRemove, props.buttonProps, props.buttonView, props.className, props.disabled,
|
|
126
|
-
props.filesLayout, props.imagesOnly, props.imagesProcessor, props.itemProps, props.showRemove, props.size]);
|
|
128
|
+
}); }, [FileFieldItemView, files, onBrowse, onRemove, props.buttonProps, props.buttonView, props.className, props.disabled, props.filesLayout, props.imagesOnly, props.imagesProcessor, props.input, props.itemProps, props.showRemove, props.size]);
|
|
127
129
|
return (react_1["default"].createElement(FileFieldView, __assign({}, viewProps)));
|
|
128
130
|
}
|
|
129
131
|
function FileField(props) {
|
|
@@ -26,6 +26,10 @@ export interface INumberFieldProps extends IBaseFieldProps {
|
|
|
26
26
|
* Допустимое количество символов после разделителя
|
|
27
27
|
*/
|
|
28
28
|
decimal?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Может ли число быть отрицательным
|
|
31
|
+
*/
|
|
32
|
+
isCanBeNegative?: boolean;
|
|
29
33
|
}
|
|
30
34
|
export interface INumberFieldViewProps extends INumberFieldProps, IFieldWrapperOutputProps {
|
|
31
35
|
inputProps: {
|
|
@@ -52,7 +52,7 @@ function NumberField(props) {
|
|
|
52
52
|
min: props.min,
|
|
53
53
|
value: props.input.value,
|
|
54
54
|
required: props.required
|
|
55
|
-
}, onChange, props.decimal).onInputChange;
|
|
55
|
+
}, onChange, props.decimal, props.isCanBeNegative).onInputChange;
|
|
56
56
|
var onStep = (0, react_1.useCallback)(function (isIncrement) {
|
|
57
57
|
var _a;
|
|
58
58
|
var currentValue = Number((_a = currentInputRef === null || currentInputRef === void 0 ? void 0 : currentInputRef.current) === null || _a === void 0 ? void 0 : _a.value);
|
|
@@ -105,6 +105,7 @@ function NumberField(props) {
|
|
|
105
105
|
}
|
|
106
106
|
NumberField.defaultProps = {
|
|
107
107
|
disabled: false,
|
|
108
|
-
required: false
|
|
108
|
+
required: false,
|
|
109
|
+
isCanBeNegative: true
|
|
109
110
|
};
|
|
110
111
|
exports["default"] = (0, fieldWrapper_1["default"])('NumberField', NumberField);
|
|
@@ -5,7 +5,7 @@ interface IInputTypeNumberProps {
|
|
|
5
5
|
value: string | undefined | null;
|
|
6
6
|
required?: boolean;
|
|
7
7
|
}
|
|
8
|
-
declare const useInputTypeNumber: (currentInputRef: React.MutableRefObject<HTMLInputElement>, inputTypeNumberProps: IInputTypeNumberProps, onChange: (event: React.ChangeEvent<HTMLInputElement>, value?: any) => void, decimal: number) => {
|
|
8
|
+
declare const useInputTypeNumber: (currentInputRef: React.MutableRefObject<HTMLInputElement>, inputTypeNumberProps: IInputTypeNumberProps, onChange: (event: React.ChangeEvent<HTMLInputElement>, value?: any) => void, decimal: number, isCanBeNegative?: boolean) => {
|
|
9
9
|
onInputChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
10
|
};
|
|
11
11
|
export default useInputTypeNumber;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
var react_1 = __importDefault(require("react"));
|
|
7
|
-
var useInputTypeNumber = function (currentInputRef, inputTypeNumberProps, onChange, decimal) {
|
|
7
|
+
var useInputTypeNumber = function (currentInputRef, inputTypeNumberProps, onChange, decimal, isCanBeNegative) {
|
|
8
8
|
react_1["default"].useEffect(function () {
|
|
9
9
|
var _a;
|
|
10
10
|
var defaultValidity = __('The number is not valid.');
|
|
@@ -20,18 +20,30 @@ var useInputTypeNumber = function (currentInputRef, inputTypeNumberProps, onChan
|
|
|
20
20
|
if (!value) {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
var numericFloatRegExp = isCanBeNegative
|
|
24
|
+
/**
|
|
25
|
+
* Подходят отрицательные и положительные числа с плавающей точкой
|
|
26
|
+
* @example -1.0
|
|
27
|
+
* @example 1.1
|
|
28
|
+
*/
|
|
29
|
+
? new RegExp("^-?\\d*\\.?\\d{0,".concat(decimal, "}$"))
|
|
30
|
+
/**
|
|
31
|
+
* Подходят положительные числа с плавающей точкой
|
|
32
|
+
* @example 1.1
|
|
33
|
+
*/
|
|
34
|
+
: new RegExp("^\\d*\\.?\\d{0,".concat(decimal, "}$"));
|
|
35
|
+
var numericRegExp = isCanBeNegative
|
|
36
|
+
/**
|
|
37
|
+
* Подходят отрицательные и положительные целые числа
|
|
38
|
+
* @example 1
|
|
39
|
+
* @example -2
|
|
40
|
+
*/
|
|
41
|
+
? new RegExp('^-?\\d*$')
|
|
42
|
+
/**
|
|
43
|
+
* Подходят положительные целые числа
|
|
44
|
+
* @example 1
|
|
45
|
+
*/
|
|
46
|
+
: new RegExp('^\\d+$');
|
|
35
47
|
return decimal ? numericFloatRegExp.test(value) : numericRegExp.test(value);
|
|
36
48
|
};
|
|
37
49
|
var onInputChange = function (event) {
|