@steroidsjs/core 3.0.88 → 3.0.90
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/components/ClientStorageComponent.d.ts +7 -1
- package/components/ClientStorageComponent.js +13 -7
- package/docs-autogen-result.json +241 -33
- package/en.json +85 -89
- package/hooks/useAddressBar.d.ts +0 -6
- package/hooks/useAddressBar.js +33 -15
- package/hooks/useDataProvider.js +6 -4
- package/hooks/useDataSelect.d.ts +2 -2
- package/hooks/useSaveCursorPosition.d.ts +16 -3
- package/hooks/useSaveCursorPosition.js +50 -15
- package/package.json +2 -3
- package/ui/content/Alert/Alert.d.ts +1 -1
- package/ui/content/Icon/Icon.d.ts +1 -1
- package/ui/content/Menu/Menu.d.ts +1 -1
- package/ui/form/DateField/DateField.d.ts +1 -1
- package/ui/form/DateRangeField/DateRangeField.d.ts +1 -1
- package/ui/form/DateTimeField/DateTimeField.d.ts +1 -1
- package/ui/form/DateTimeRangeField/DateTimeRangeField.d.ts +1 -1
- package/ui/form/EmailField/EmailField.js +3 -1
- package/ui/form/InputField/InputField.d.ts +5 -0
- package/ui/form/InputField/InputField.js +8 -6
- package/ui/form/NumberField/NumberField.d.ts +5 -0
- package/ui/form/NumberField/NumberField.js +8 -6
- package/ui/form/PasswordField/PasswordField.js +1 -1
- package/ui/form/TextField/TextField.d.ts +7 -1
- package/ui/form/TextField/TextField.js +6 -3
- package/ui/form/TimeField/TimeField.d.ts +1 -1
- package/ui/form/TimeRangeField/TimeRangeField.d.ts +1 -1
- package/ui/list/Grid/Grid.d.ts +1 -1
- package/ui/list/List/List.js +4 -3
- package/ui/modal/Modal/Modal.d.ts +4 -0
- package/ui/modal/Modal/Modal.js +3 -3
|
@@ -44,7 +44,9 @@ var useInputTypeEmail_1 = __importDefault(require("./hooks/useInputTypeEmail"));
|
|
|
44
44
|
var enums_1 = require("../../../enums");
|
|
45
45
|
function EmailField(props) {
|
|
46
46
|
var components = (0, hooks_1.useComponents)();
|
|
47
|
-
var _a = (0, hooks_1.useSaveCursorPosition)(
|
|
47
|
+
var _a = (0, hooks_1.useSaveCursorPosition)({
|
|
48
|
+
inputParams: props.input
|
|
49
|
+
}), currentInputRef = _a.inputRef, onChange = _a.onChange;
|
|
48
50
|
var onInputChange = (0, useInputTypeEmail_1["default"])(currentInputRef, onChange, props.input.value, props.required).onInputChange;
|
|
49
51
|
var onClear = react_1["default"].useCallback(function () { return props.input.onChange(''); }, [props.input]);
|
|
50
52
|
var inputProps = react_1["default"].useMemo(function () {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InputHTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
import { MaskitoOptions } from '@maskito/core';
|
|
4
|
+
import { ISaveCursorPositionDebounceConfig } from '@steroidsjs/core/hooks/useSaveCursorPosition';
|
|
4
5
|
import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../Field/fieldWrapper';
|
|
5
6
|
export declare const MASK_PRESETS: {
|
|
6
7
|
date: Required<MaskitoOptions>;
|
|
@@ -87,6 +88,10 @@ export interface IInputFieldProps extends IBaseFieldProps {
|
|
|
87
88
|
* Пользовательская иконка svg или название иконки
|
|
88
89
|
*/
|
|
89
90
|
leadIcon?: React.ReactElement | string;
|
|
91
|
+
/**
|
|
92
|
+
* Задержка применения введённого значения
|
|
93
|
+
*/
|
|
94
|
+
debounce?: boolean | ISaveCursorPositionDebounceConfig;
|
|
90
95
|
}
|
|
91
96
|
export interface IInputFieldViewProps extends IInputFieldProps, IFieldWrapperOutputProps {
|
|
92
97
|
inputProps: {
|
|
@@ -87,11 +87,16 @@ exports.MASK_PRESETS = {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
function InputField(props) {
|
|
90
|
+
var _a;
|
|
90
91
|
var components = (0, hooks_1.useComponents)();
|
|
91
92
|
var maskedInputRef = (0, react_2.useMaskito)({
|
|
92
93
|
options: props.maskOptions
|
|
93
94
|
});
|
|
94
|
-
var
|
|
95
|
+
var _b = (0, hooks_1.useSaveCursorPosition)({
|
|
96
|
+
inputParams: props.input,
|
|
97
|
+
onChangeCallback: props.onChange,
|
|
98
|
+
debounce: __assign({ enabled: !!props.debounce }, (typeof props.debounce === 'boolean' ? { enabled: props.debounce } : ((_a = props.debounce) !== null && _a !== void 0 ? _a : {})))
|
|
99
|
+
}), inputRef = _b.inputRef, onChange = _b.onChange, value = _b.value;
|
|
95
100
|
React.useEffect(function () {
|
|
96
101
|
if (inputRef.current) {
|
|
97
102
|
maskedInputRef(inputRef.current);
|
|
@@ -103,11 +108,8 @@ function InputField(props) {
|
|
|
103
108
|
props.onClear('');
|
|
104
109
|
}
|
|
105
110
|
props.input.onChange('');
|
|
106
|
-
}, [props
|
|
107
|
-
var inputProps = (0, react_1.useMemo)(function () {
|
|
108
|
-
var _a;
|
|
109
|
-
return (__assign({ type: props.type, name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onInput: onChange, placeholder: props.placeholder }, props.inputProps));
|
|
110
|
-
}, [onChange, props.input.name, props.input.value, props.inputProps, props.placeholder, props.type]);
|
|
111
|
+
}, [props]);
|
|
112
|
+
var inputProps = (0, react_1.useMemo)(function () { return (__assign({ type: props.type, name: props.input.name, value: value, onInput: onChange, placeholder: props.placeholder }, props.inputProps)); }, [value, onChange, props.input.name, props.inputProps, props.placeholder, props.type]);
|
|
111
113
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
112
114
|
inputRef: useInputFieldWarningByType_1.INPUT_TYPES_SUPPORTED_SELECTION.includes(props.type) ? inputRef : null,
|
|
113
115
|
onClear: onClear,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { ChangeEvent } from 'react';
|
|
2
|
+
import { ISaveCursorPositionDebounceConfig } from '@steroidsjs/core/hooks/useSaveCursorPosition';
|
|
2
3
|
import { IBaseFieldProps } from '../InputField/InputField';
|
|
3
4
|
import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../Field/fieldWrapper';
|
|
4
5
|
/**
|
|
@@ -30,6 +31,10 @@ export interface INumberFieldProps extends IFieldWrapperInputProps, IBaseFieldPr
|
|
|
30
31
|
* Может ли число быть отрицательным
|
|
31
32
|
*/
|
|
32
33
|
isCanBeNegative?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Задержка применения введённого значения
|
|
36
|
+
*/
|
|
37
|
+
debounce?: boolean | ISaveCursorPositionDebounceConfig;
|
|
33
38
|
}
|
|
34
39
|
export interface INumberFieldViewProps extends INumberFieldProps, IFieldWrapperOutputProps {
|
|
35
40
|
inputProps: {
|
|
@@ -45,8 +45,13 @@ var useInputTypeNumber_1 = __importDefault(require("./hooks/useInputTypeNumber")
|
|
|
45
45
|
var enums_1 = require("../../../enums");
|
|
46
46
|
var DEFAULT_STEP = 1;
|
|
47
47
|
function NumberField(props) {
|
|
48
|
+
var _a;
|
|
48
49
|
var components = (0, hooks_1.useComponents)();
|
|
49
|
-
var
|
|
50
|
+
var _b = (0, hooks_1.useSaveCursorPosition)({
|
|
51
|
+
inputParams: props.input,
|
|
52
|
+
onChangeCallback: props.onChange,
|
|
53
|
+
debounce: __assign({ enabled: !!props.debounce }, (typeof props.debounce === 'boolean' ? { enabled: props.debounce } : ((_a = props.debounce) !== null && _a !== void 0 ? _a : {})))
|
|
54
|
+
}), currentInputRef = _b.inputRef, onChange = _b.onChange, value = _b.value;
|
|
50
55
|
var step = react_1["default"].useMemo(function () { var _a; return (_a = props.step) !== null && _a !== void 0 ? _a : DEFAULT_STEP; }, [props.step]);
|
|
51
56
|
var onInputChange = (0, useInputTypeNumber_1["default"])(currentInputRef, {
|
|
52
57
|
max: props.max,
|
|
@@ -58,7 +63,7 @@ function NumberField(props) {
|
|
|
58
63
|
var _a;
|
|
59
64
|
var currentValue = Number((_a = currentInputRef === null || currentInputRef === void 0 ? void 0 : currentInputRef.current) === null || _a === void 0 ? void 0 : _a.value);
|
|
60
65
|
var newValue;
|
|
61
|
-
var fixToDecimal = function (
|
|
66
|
+
var fixToDecimal = function (rawValue) { return props.decimal ? rawValue.toFixed(props.decimal) : rawValue; };
|
|
62
67
|
if (isIncrement) {
|
|
63
68
|
newValue = fixToDecimal(currentValue + step);
|
|
64
69
|
}
|
|
@@ -75,10 +80,7 @@ function NumberField(props) {
|
|
|
75
80
|
onStep(false);
|
|
76
81
|
}
|
|
77
82
|
}, [onStep]);
|
|
78
|
-
var inputProps = (0, react_1.useMemo)(function () {
|
|
79
|
-
var _a;
|
|
80
|
-
return (__assign(__assign({}, props.inputProps), { name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onChange: onInputChange, type: 'text', min: props.min, max: props.max, step: props.step, placeholder: props.placeholder, disabled: props.disabled, required: props.required, autoComplete: 'off', onKeyDown: onKeyDown }));
|
|
81
|
-
}, [props.inputProps, props.input.name, props.input.value, props.min, props.max, props.step, props.placeholder, props.disabled, props.required, onInputChange, onKeyDown]);
|
|
83
|
+
var inputProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.inputProps), { name: props.input.name, value: value, onChange: onInputChange, type: 'text', min: props.min, max: props.max, step: props.step, placeholder: props.placeholder, disabled: props.disabled, required: props.required, autoComplete: 'off', onKeyDown: onKeyDown })); }, [props.inputProps, props.input.name, props.min, props.max, props.step, props.placeholder, props.disabled, props.required, value, onInputChange, onKeyDown]);
|
|
82
84
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
83
85
|
viewProps: props.viewProps,
|
|
84
86
|
inputProps: inputProps,
|
|
@@ -56,7 +56,7 @@ exports.checkPassword = checkPassword;
|
|
|
56
56
|
function PasswordField(props) {
|
|
57
57
|
var _a = (0, react_1.useState)(InputType.PASSWORD), type = _a[0], setType = _a[1];
|
|
58
58
|
var components = (0, hooks_1.useComponents)();
|
|
59
|
-
var _b = (0, hooks_1.useSaveCursorPosition)(props.input), inputRef = _b.inputRef, onChange = _b.onChange;
|
|
59
|
+
var _b = (0, hooks_1.useSaveCursorPosition)({ inputParams: props.input }), inputRef = _b.inputRef, onChange = _b.onChange;
|
|
60
60
|
var onClear = (0, react_1.useCallback)(function () { return props.input.onChange(''); }, [props.input]);
|
|
61
61
|
var onShowButtonClick = (0, react_1.useCallback)(function () {
|
|
62
62
|
type === InputType.PASSWORD ? setType(InputType.TEXT) : setType(InputType.PASSWORD);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, KeyboardEventHandler } from 'react';
|
|
1
|
+
import React, { ChangeEvent, KeyboardEventHandler } from 'react';
|
|
2
2
|
import { IFieldWrapperOutputProps } from '../Field/fieldWrapper';
|
|
3
3
|
import { IBaseFieldProps } from '../InputField/InputField';
|
|
4
4
|
/**
|
|
@@ -11,6 +11,11 @@ export interface ITextFieldProps extends IBaseFieldProps {
|
|
|
11
11
|
* @example true
|
|
12
12
|
*/
|
|
13
13
|
submitOnEnter?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Флаг, который указывает, что высота поля должна быть равна высоте контента
|
|
16
|
+
* @example false
|
|
17
|
+
*/
|
|
18
|
+
autoHeight?: boolean;
|
|
14
19
|
}
|
|
15
20
|
export interface ITextFieldViewProps extends ITextFieldProps, IFieldWrapperOutputProps {
|
|
16
21
|
inputProps: {
|
|
@@ -21,6 +26,7 @@ export interface ITextFieldViewProps extends ITextFieldProps, IFieldWrapperOutpu
|
|
|
21
26
|
placeholder: string;
|
|
22
27
|
disabled: boolean;
|
|
23
28
|
required: boolean;
|
|
29
|
+
ref: React.MutableRefObject<any>;
|
|
24
30
|
};
|
|
25
31
|
onClear: VoidFunction;
|
|
26
32
|
}
|
|
@@ -21,7 +21,9 @@ var enums_1 = require("../../../enums");
|
|
|
21
21
|
function TextField(props) {
|
|
22
22
|
// const dispatch = useDispatch();
|
|
23
23
|
var components = (0, hooks_1.useComponents)();
|
|
24
|
-
var _a = (0, hooks_1.useSaveCursorPosition)(
|
|
24
|
+
var _a = (0, hooks_1.useSaveCursorPosition)({
|
|
25
|
+
inputParams: props.input
|
|
26
|
+
}), inputRef = _a.inputRef, onChange = _a.onChange;
|
|
25
27
|
var onKeyUp = (0, react_1.useCallback)(function (e) {
|
|
26
28
|
if (props.submitOnEnter
|
|
27
29
|
&& props.formId
|
|
@@ -38,12 +40,13 @@ function TextField(props) {
|
|
|
38
40
|
var _a;
|
|
39
41
|
return (__assign({ name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onChange: handleChange, onKeyUp: onKeyUp, placeholder: props.placeholder, disabled: props.disabled, required: props.required, ref: inputRef }, props.inputProps));
|
|
40
42
|
}, [props.input.name, props.input.value, props.placeholder, props.disabled, props.required, props.inputProps, handleChange, onKeyUp, inputRef]);
|
|
41
|
-
var viewProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.viewProps), { inputProps: inputProps, onClear: onClear, errors: props.errors, size: props.size, className: props.className, showClear: props.showClear })); }, [inputProps, onClear, props.className, props.errors, props.showClear, props.size, props.viewProps]);
|
|
43
|
+
var viewProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.viewProps), { inputProps: inputProps, onClear: onClear, errors: props.errors, size: props.size, className: props.className, showClear: props.showClear, autoHeight: props.autoHeight })); }, [inputProps, onClear, props.className, props.errors, props.showClear, props.size, props.viewProps, props.autoHeight]);
|
|
42
44
|
return components.ui.renderView(props.view || 'form.TextFieldView', viewProps);
|
|
43
45
|
}
|
|
44
46
|
TextField.defaultProps = {
|
|
45
47
|
disabled: false,
|
|
46
48
|
required: false,
|
|
47
|
-
submitOnEnter: false
|
|
49
|
+
submitOnEnter: false,
|
|
50
|
+
autoHeight: false
|
|
48
51
|
};
|
|
49
52
|
exports["default"] = (0, fieldWrapper_1["default"])(enums_1.FieldEnum.TEXT_FIELD, TextField);
|
package/ui/list/Grid/Grid.d.ts
CHANGED
package/ui/list/List/List.js
CHANGED
|
@@ -50,6 +50,7 @@ function List(props) {
|
|
|
50
50
|
actionMethod: props.actionMethod,
|
|
51
51
|
pagination: props.pagination,
|
|
52
52
|
paginationSize: props.paginationSize,
|
|
53
|
+
infiniteScroll: props.infiniteScroll,
|
|
53
54
|
sort: props.sort,
|
|
54
55
|
layout: props.layout,
|
|
55
56
|
empty: props.empty,
|
|
@@ -67,7 +68,7 @@ function List(props) {
|
|
|
67
68
|
initialItems: props.initialItems,
|
|
68
69
|
initialTotal: props.initialTotal,
|
|
69
70
|
autoFetchOnFormChanges: props.autoFetchOnFormChanges
|
|
70
|
-
}), list = _a.list, paginationPosition = _a.paginationPosition, paginationSizePosition = _a.paginationSizePosition, layoutNamesPosition = _a.layoutNamesPosition, renderList = _a.renderList, renderLoading = _a.renderLoading, renderEmpty = _a.renderEmpty, renderPagination = _a.renderPagination, renderPaginationSize = _a.renderPaginationSize, renderLayoutNames = _a.renderLayoutNames, renderSearchForm = _a.renderSearchForm;
|
|
71
|
+
}), list = _a.list, paginationPosition = _a.paginationPosition, paginationSizePosition = _a.paginationSizePosition, layoutNamesPosition = _a.layoutNamesPosition, renderList = _a.renderList, renderLoading = _a.renderLoading, renderEmpty = _a.renderEmpty, renderPagination = _a.renderPagination, renderPaginationSize = _a.renderPaginationSize, renderLayoutNames = _a.renderLayoutNames, renderSearchForm = _a.renderSearchForm, renderInfiniteScroll = _a.renderInfiniteScroll;
|
|
71
72
|
var ItemView = props.itemView || components.ui.getView('list.ListItemView');
|
|
72
73
|
var content = ((list === null || list === void 0 ? void 0 : list.items) || []).map(function (item, index) { return (React.createElement(ItemView, __assign({}, props.itemProps, { key: item[props.primaryKey] || index, primaryKey: props.primaryKey, item: item, index: index, layoutSelected: list.layoutName }))); });
|
|
73
74
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
@@ -82,12 +83,12 @@ function List(props) {
|
|
|
82
83
|
renderPaginationSize: renderPaginationSize,
|
|
83
84
|
renderLayoutNames: renderLayoutNames,
|
|
84
85
|
renderSearchForm: renderSearchForm,
|
|
86
|
+
renderInfiniteScroll: renderInfiniteScroll,
|
|
85
87
|
content: content,
|
|
86
88
|
isLoading: props.isLoading,
|
|
87
89
|
className: props.className,
|
|
88
90
|
contentClassName: props.contentClassName
|
|
89
|
-
}); }, [
|
|
90
|
-
props.isLoading, renderEmpty, renderLayoutNames, renderList, renderPagination, renderPaginationSize, renderSearchForm, renderLoading]);
|
|
91
|
+
}); }, [list, paginationPosition, paginationSizePosition, layoutNamesPosition, renderList, renderLoading, renderEmpty, renderPagination, renderPaginationSize, renderLayoutNames, renderSearchForm, renderInfiniteScroll, content, props.isLoading, props.className, props.contentClassName]);
|
|
91
92
|
return components.ui.renderView(props.view || 'list.ListView', viewProps);
|
|
92
93
|
}
|
|
93
94
|
exports["default"] = List;
|
package/ui/modal/Modal/Modal.js
CHANGED
|
@@ -56,9 +56,9 @@ function Modal(props) {
|
|
|
56
56
|
shouldCloseOnOverlayClick: props.shouldCloseOnOverlayClick,
|
|
57
57
|
title: props.title,
|
|
58
58
|
children: props.children,
|
|
59
|
-
buttons: props.buttons
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
buttons: props.buttons,
|
|
60
|
+
viewProps: props.viewProps
|
|
61
|
+
}); }, [props.buttons, props.children, props.className, props.closeTimeoutMs, props.isClosing, props.onClose, props.shouldCloseOnEsc, props.shouldCloseOnOverlayClick, props.size, props.title, props.viewProps]);
|
|
62
62
|
return (react_1["default"].createElement(ModalView, __assign({}, viewProps), (ContentComponent && (react_1["default"].createElement(ContentComponent, __assign({}, props, props.componentProps)))) || (props.children)));
|
|
63
63
|
}
|
|
64
64
|
Modal.defaultProps = {
|