@steroidsjs/core 3.0.0-beta.99 → 3.0.0
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/actions/notifications.js +7 -1
- package/actions/router.js +16 -2
- package/components/HttpComponent.d.ts +7 -7
- package/components/JwtHttpComponent.d.ts +2 -2
- package/components/LocaleComponent.d.ts +6 -6
- package/components/MetaComponent.d.ts +90 -1
- package/components/MetricsComponent.js +2 -1
- package/components/ResourceComponent.d.ts +4 -4
- package/components/UiComponent.d.ts +7 -7
- package/components/WebSocketComponent.d.ts +11 -11
- package/docs-autogen-result.json +15147 -6371
- package/en.json +151 -92
- package/hooks/index.d.ts +4 -3
- package/hooks/index.js +7 -5
- package/hooks/useAbsolutePositioning.js +0 -1
- package/hooks/useAddressBar.js +0 -1
- package/hooks/useApplication.js +8 -1
- package/hooks/useDataProvider.d.ts +17 -2
- package/hooks/useDataSelect.js +21 -4
- package/hooks/useFetch.js +6 -1
- package/hooks/useFile.d.ts +1 -0
- package/hooks/useFile.js +2 -0
- package/hooks/useList.d.ts +53 -14
- package/hooks/useList.js +31 -70
- package/hooks/useTree.d.ts +104 -0
- package/hooks/useTree.js +169 -0
- package/index.d.ts +3 -3
- package/package.json +94 -93
- package/reducers/router.d.ts +2 -1
- package/ui/content/Accordion/Accordion.d.ts +8 -5
- package/ui/content/Accordion/Accordion.js +6 -1
- package/ui/content/Accordion/AccordionItem.d.ts +2 -2
- package/ui/content/Accordion/AccordionItem.js +1 -12
- package/ui/content/Alert/Alert.d.ts +5 -2
- package/ui/content/Alert/Alert.js +13 -12
- package/ui/content/Avatar/Avatar.js +18 -12
- package/ui/content/Badge/Badge.d.ts +5 -1
- package/ui/content/Badge/Badge.js +14 -12
- package/ui/content/Calendar/Calendar.d.ts +6 -1
- package/ui/content/Calendar/Calendar.js +19 -12
- package/ui/content/CalendarSystem/CalendarSystem.d.ts +40 -18
- package/ui/content/CalendarSystem/CalendarSystem.js +65 -76
- package/ui/content/CalendarSystem/hooks/useCalendarControls.d.ts +1 -2
- package/ui/content/CalendarSystem/hooks/useCalendarControls.js +14 -17
- package/ui/content/CalendarSystem/hooks/useCalendarSystemEventGroupModals.js +11 -3
- package/ui/content/CalendarSystem/hooks/useCalendarSystemModals.js +2 -2
- package/ui/content/CalendarSystem/hooks/useCalendarType.d.ts +5 -0
- package/ui/content/CalendarSystem/hooks/useCalendarType.js +22 -0
- package/ui/content/CalendarSystem/hooks/useEventsFromDate.d.ts +5 -0
- package/ui/content/CalendarSystem/hooks/useEventsFromDate.js +49 -0
- package/ui/content/CalendarSystem/hooks/{useMonthCalendar.d.ts → useMonthGrid.d.ts} +4 -5
- package/ui/content/CalendarSystem/hooks/{useMonthCalendar.js → useMonthGrid.js} +24 -15
- package/ui/content/CalendarSystem/hooks/{useWeekCalendar.d.ts → useWeekGrid.d.ts} +6 -5
- package/ui/content/CalendarSystem/hooks/useWeekGrid.js +72 -0
- package/ui/content/CalendarSystem/utils/utils.d.ts +8 -0
- package/ui/content/CalendarSystem/utils/utils.js +27 -1
- package/ui/content/Card/Card.d.ts +33 -27
- package/ui/content/Card/Card.js +1 -12
- package/ui/content/Chart/Chart.d.ts +38 -8
- package/ui/content/Chart/Chart.js +16 -12
- package/ui/content/Chat/Chat.d.ts +90 -5
- package/ui/content/Chat/Chat.js +40 -14
- package/ui/content/Chat/constants/timeTemplatesAndUnits.d.ts +1 -0
- package/ui/content/Chat/constants/timeTemplatesAndUnits.js +2 -1
- package/ui/content/Chat/hooks/useChat.d.ts +5 -6
- package/ui/content/Chat/hooks/useChat.js +49 -3
- package/ui/content/Chat/utils/addNewMessageIntoGroupedMessages.d.ts +5 -0
- package/ui/content/Chat/utils/addNewMessageIntoGroupedMessages.js +61 -0
- package/ui/content/Chat/utils/getMessagesGroupedByDate.d.ts +1 -0
- package/ui/content/Chat/utils/getMessagesGroupedByDate.js +3 -2
- package/ui/content/Chat/utils/index.d.ts +4 -2
- package/ui/content/Chat/utils/index.js +6 -1
- package/ui/content/Chat/utils/isTodayMessage.d.ts +1 -0
- package/ui/content/Chat/utils/isTodayMessage.js +13 -0
- package/ui/content/CopyToClipboard/CopyToClipboard.d.ts +3 -3
- package/ui/content/CopyToClipboard/CopyToClipboard.js +10 -12
- package/ui/content/Dashboard/Dashboard.d.ts +5 -2
- package/ui/content/Dashboard/Dashboard.js +27 -3
- package/ui/content/Detail/Detail.d.ts +15 -2
- package/ui/content/Detail/Detail.js +12 -1
- package/ui/content/DropDown/DropDown.d.ts +1 -1
- package/ui/content/DropDown/DropDown.js +16 -4
- package/ui/content/Icon/Icon.js +13 -15
- package/ui/content/Kanban/Kanban.d.ts +15 -4
- package/ui/content/Kanban/Kanban.js +8 -12
- package/ui/content/Kanban/hooks/useKanban.d.ts +33 -26
- package/ui/content/Menu/Menu.js +10 -12
- package/ui/content/Slider/Slider.js +1 -12
- package/ui/crud/index.d.ts +3 -0
- package/ui/form/AutoCompleteField/AutoCompleteField.js +1 -1
- package/ui/form/Button/Button.js +8 -2
- package/ui/form/CheckboxField/CheckboxField.d.ts +1 -0
- package/ui/form/CheckboxField/CheckboxField.js +2 -2
- package/ui/form/CheckboxListField/CheckboxListField.d.ts +18 -2
- package/ui/form/CheckboxListField/CheckboxListField.js +1 -1
- package/ui/form/CheckboxTreeField/CheckboxTreeField.d.ts +67 -0
- package/ui/form/CheckboxTreeField/CheckboxTreeField.js +126 -0
- package/ui/form/CheckboxTreeField/index.d.ts +2 -0
- package/ui/form/CheckboxTreeField/index.js +7 -0
- package/ui/form/DateField/DateField.js +4 -1
- package/ui/form/DateField/useDateRange.d.ts +1 -0
- package/ui/form/DateField/useDateRange.js +13 -2
- package/ui/form/DateRangeField/DateRangeField.d.ts +34 -1
- package/ui/form/DateRangeField/DateRangeField.js +59 -8
- package/ui/form/DateTimeField/DateTimeField.d.ts +10 -0
- package/ui/form/DateTimeField/DateTimeField.js +11 -3
- package/ui/form/DateTimeRangeField/DateTimeRangeField.d.ts +25 -1
- package/ui/form/DateTimeRangeField/DateTimeRangeField.js +66 -13
- package/ui/form/DropDownField/DropDownField.d.ts +23 -3
- package/ui/form/DropDownField/DropDownField.js +1 -1
- package/ui/form/EmailField/EmailField.d.ts +6 -0
- package/ui/form/EmailField/EmailField.js +0 -4
- package/ui/form/Field/Field.d.ts +9 -1
- package/ui/form/Field/Field.js +1 -1
- package/ui/form/Field/fieldWrapper.d.ts +9 -1
- package/ui/form/FieldList/FieldList.d.ts +13 -7
- package/ui/form/FieldList/FieldList.js +30 -4
- package/ui/form/FileField/FileField.js +5 -0
- package/ui/form/Form/Form.d.ts +26 -3
- package/ui/form/Form/Form.js +5 -3
- package/ui/form/ImageField/ImageField.d.ts +9 -1
- package/ui/form/InputField/InputField.d.ts +5 -2
- package/ui/form/InputField/hooks/useInputFieldWarningByType.js +1 -0
- package/ui/form/NumberField/NumberField.js +34 -7
- package/ui/form/SliderField/SliderField.d.ts +10 -2
- package/ui/form/TimeRangeField/TimeRangeField.d.ts +10 -1
- package/ui/form/TimeRangeField/TimeRangeField.js +3 -1
- package/ui/form/WizardForm/WizardForm.d.ts +119 -0
- package/ui/form/WizardForm/WizardForm.js +167 -0
- package/ui/form/WizardForm/index.d.ts +2 -0
- package/ui/form/WizardForm/index.js +7 -0
- package/ui/form/WizardForm/utils.d.ts +12 -0
- package/ui/form/WizardForm/utils.js +111 -0
- package/ui/form/index.d.ts +3 -1
- package/ui/form/index.js +4 -1
- package/ui/layout/ProgressBar/ProgressBar.js +8 -2
- package/ui/layout/Skeleton/Skeleton.d.ts +3 -1
- package/ui/layout/Tooltip/Tooltip.d.ts +4 -1
- package/ui/list/ControlsColumn/ControlsColumn.d.ts +17 -3
- package/ui/list/FlexGrid/FlexGrid.d.ts +11 -1
- package/ui/list/Grid/Grid.d.ts +42 -6
- package/ui/list/Grid/Grid.js +1 -2
- package/ui/list/LayoutNames/LayoutNames.d.ts +11 -1
- package/ui/list/Steps/Steps.d.ts +19 -7
- package/ui/list/Steps/Steps.js +46 -26
- package/ui/list/TreeTable/TreeTable.d.ts +34 -33
- package/ui/list/TreeTable/TreeTable.js +19 -8
- package/ui/modal/Modal/Modal.d.ts +7 -1
- package/ui/nav/Breadcrumbs/Breadcrumbs.d.ts +11 -1
- package/ui/nav/ButtonGroup/ButtonGroup.d.ts +13 -4
- package/ui/nav/Controls/Controls.d.ts +7 -1
- package/ui/nav/Link/Link.d.ts +1 -1
- package/ui/nav/Nav/Nav.d.ts +19 -4
- package/ui/nav/Router/Router.d.ts +19 -3
- package/ui/nav/Router/Router.js +11 -6
- package/ui/nav/Router/helpers.d.ts +2 -2
- package/ui/nav/Router/helpers.js +39 -7
- package/ui/nav/Tree/Tree.d.ts +32 -62
- package/ui/nav/Tree/Tree.js +18 -165
- package/utils/calculateComponentAbsolutePosition.js +74 -24
- package/utils/calendar.d.ts +8 -0
- package/utils/calendar.js +76 -1
- package/utils/data.js +1 -0
- package/utils/form.d.ts +1 -0
- package/utils/form.js +16 -1
- package/ui/content/CalendarSystem/hooks/useWeekCalendar.js +0 -86
- package/utils/list.d.ts +0 -1
- package/utils/list.js +0 -5
|
@@ -10,19 +10,47 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
13
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
38
|
};
|
|
16
39
|
exports.__esModule = true;
|
|
17
|
-
var react_1 = require("react");
|
|
40
|
+
var react_1 = __importStar(require("react"));
|
|
41
|
+
var kit_1 = require("@maskito/kit");
|
|
42
|
+
var react_2 = require("@maskito/react");
|
|
18
43
|
var useDateRange_1 = __importDefault(require("../../form/DateField/useDateRange"));
|
|
19
44
|
var useDateTime_1 = __importDefault(require("../../form/DateField/useDateTime"));
|
|
20
45
|
var useDateInputState_1 = __importDefault(require("../../form/DateField/useDateInputState"));
|
|
21
46
|
var fieldWrapper_1 = __importDefault(require("../../form/Field/fieldWrapper"));
|
|
22
47
|
var hooks_1 = require("../../../hooks");
|
|
23
|
-
var DATE_TIME_SEPARATOR = ' ';
|
|
48
|
+
var DATE_TIME_SEPARATOR = ', ';
|
|
24
49
|
function DateTimeRangeField(props) {
|
|
50
|
+
var _a, _b;
|
|
25
51
|
var components = (0, hooks_1.useComponents)();
|
|
52
|
+
var maskInputFromRef = (0, react_2.useMaskito)({ options: (_a = props.maskOptions) === null || _a === void 0 ? void 0 : _a.from });
|
|
53
|
+
var maskInputToRef = (0, react_2.useMaskito)({ options: (_b = props.maskOptions) === null || _b === void 0 ? void 0 : _b.to });
|
|
26
54
|
// Global onChange (from props)
|
|
27
55
|
var onChange = (0, react_1.useCallback)(function () {
|
|
28
56
|
var _a;
|
|
@@ -34,7 +62,7 @@ function DateTimeRangeField(props) {
|
|
|
34
62
|
}
|
|
35
63
|
}, [props.attributeFrom, props.attributeTo, props.inputFrom.value, props.inputTo.value, props.onChange]);
|
|
36
64
|
// Input 'from'
|
|
37
|
-
var
|
|
65
|
+
var _c = (0, useDateInputState_1["default"])({
|
|
38
66
|
displayFormat: props.displayFormat,
|
|
39
67
|
valueFormat: props.valueFormat,
|
|
40
68
|
input: props.inputFrom,
|
|
@@ -45,9 +73,9 @@ function DateTimeRangeField(props) {
|
|
|
45
73
|
useUTC: props.useUTC,
|
|
46
74
|
dateInUTC: props.dateInUTC,
|
|
47
75
|
onChange: onChange
|
|
48
|
-
}), isOpenedFrom =
|
|
76
|
+
}), isOpenedFrom = _c.isOpened, onCloseFrom = _c.onClose, inputPropsFrom = _c.inputProps, onClearFrom = _c.onClear, onNow = _c.onNow;
|
|
49
77
|
// Input 'to'
|
|
50
|
-
var
|
|
78
|
+
var _d = (0, useDateInputState_1["default"])({
|
|
51
79
|
displayFormat: props.displayFormat,
|
|
52
80
|
valueFormat: props.valueFormat,
|
|
53
81
|
input: props.inputTo,
|
|
@@ -58,24 +86,24 @@ function DateTimeRangeField(props) {
|
|
|
58
86
|
useUTC: props.useUTC,
|
|
59
87
|
dateInUTC: props.dateInUTC,
|
|
60
88
|
onChange: onChange
|
|
61
|
-
}), isOpenedTo =
|
|
62
|
-
var
|
|
89
|
+
}), isOpenedTo = _d.isOpened, onCloseTo = _d.onClose, inputPropsTo = _d.inputProps, onClearTo = _d.onClear;
|
|
90
|
+
var _e = (0, useDateTime_1["default"])({
|
|
63
91
|
displayFormat: props.displayFormat,
|
|
64
92
|
valueFormat: props.valueFormat,
|
|
65
93
|
dateTimeSeparator: DATE_TIME_SEPARATOR,
|
|
66
94
|
useUTC: props.useUTC,
|
|
67
95
|
dateInUTC: props.dateInUTC,
|
|
68
96
|
input: props.inputFrom
|
|
69
|
-
}), dateValueFormat =
|
|
70
|
-
var
|
|
97
|
+
}), dateValueFormat = _e.dateValueFormat, dateValueFrom = _e.dateValue, timeValueFrom = _e.timeValue, onDateFromSelect = _e.onDateSelect, onTimeFromSelect = _e.onTimeSelect;
|
|
98
|
+
var _f = (0, useDateTime_1["default"])({
|
|
71
99
|
displayFormat: props.displayFormat,
|
|
72
100
|
valueFormat: props.valueFormat,
|
|
73
101
|
dateTimeSeparator: DATE_TIME_SEPARATOR,
|
|
74
102
|
useUTC: props.useUTC,
|
|
75
103
|
dateInUTC: props.dateInUTC,
|
|
76
104
|
input: props.inputTo
|
|
77
|
-
}), dateValueTo =
|
|
78
|
-
var
|
|
105
|
+
}), dateValueTo = _f.dateValue, timeValueTo = _f.timeValue, onDateToSelect = _f.onDateSelect, onTimeToSelect = _f.onTimeSelect;
|
|
106
|
+
var _g = (0, useDateRange_1["default"])({
|
|
79
107
|
onClearFrom: onClearFrom,
|
|
80
108
|
onCloseTo: onCloseTo,
|
|
81
109
|
onCloseFrom: onCloseFrom,
|
|
@@ -85,9 +113,21 @@ function DateTimeRangeField(props) {
|
|
|
85
113
|
inputFrom: props.inputFrom,
|
|
86
114
|
inputTo: props.inputTo,
|
|
87
115
|
useSmartFocus: false,
|
|
116
|
+
hasInitialFocus: props.hasInitialFocus,
|
|
88
117
|
displayFormat: props.displayFormat,
|
|
89
118
|
valueFormat: props.valueFormat
|
|
90
|
-
}), focus =
|
|
119
|
+
}), focus = _g.focus, onClose = _g.onClose, onClear = _g.onClear, extendedInputPropsFrom = _g.extendedInputPropsFrom, extendedInputPropsTo = _g.extendedInputPropsTo;
|
|
120
|
+
react_1["default"].useEffect(function () {
|
|
121
|
+
if (extendedInputPropsFrom.ref && extendedInputPropsTo.ref) {
|
|
122
|
+
maskInputFromRef(extendedInputPropsFrom.ref.current);
|
|
123
|
+
maskInputToRef(extendedInputPropsTo.ref.current);
|
|
124
|
+
}
|
|
125
|
+
}, [
|
|
126
|
+
extendedInputPropsFrom.ref,
|
|
127
|
+
extendedInputPropsTo.ref,
|
|
128
|
+
maskInputFromRef,
|
|
129
|
+
maskInputToRef,
|
|
130
|
+
]);
|
|
91
131
|
// Calendar props
|
|
92
132
|
var calendarProps = (0, react_1.useMemo)(function () { return (__assign({ value: [dateValueFrom, dateValueTo], onChange: focus === 'from' ? onDateFromSelect : onDateToSelect, valueFormat: dateValueFormat }, props.calendarProps)); }, [dateValueFormat, dateValueFrom, dateValueTo, focus, onDateFromSelect, onDateToSelect, props.calendarProps]);
|
|
93
133
|
// TimePanel props
|
|
@@ -110,9 +150,22 @@ DateTimeRangeField.defaultProps = {
|
|
|
110
150
|
displayFormat: 'DD.MM.YYYY' + DATE_TIME_SEPARATOR + 'HH:mm',
|
|
111
151
|
valueFormat: 'YYYY-MM-DD' + DATE_TIME_SEPARATOR + 'HH:mm',
|
|
112
152
|
showRemove: true,
|
|
153
|
+
hasInitialFocus: false,
|
|
113
154
|
useUTC: false,
|
|
114
155
|
dateInUTC: false,
|
|
115
156
|
icon: true,
|
|
116
|
-
size: 'md'
|
|
157
|
+
size: 'md',
|
|
158
|
+
maskOptions: {
|
|
159
|
+
from: (0, kit_1.maskitoDateTimeOptionsGenerator)({
|
|
160
|
+
dateMode: 'dd/mm/yyyy',
|
|
161
|
+
timeMode: 'HH:MM',
|
|
162
|
+
dateSeparator: '.'
|
|
163
|
+
}),
|
|
164
|
+
to: (0, kit_1.maskitoDateTimeOptionsGenerator)({
|
|
165
|
+
dateMode: 'dd/mm/yyyy',
|
|
166
|
+
timeMode: 'HH:MM',
|
|
167
|
+
dateSeparator: '.'
|
|
168
|
+
})
|
|
169
|
+
}
|
|
117
170
|
};
|
|
118
171
|
exports["default"] = (0, fieldWrapper_1["default"])('DateTimeRangeField', DateTimeRangeField, { attributeSuffixes: ['from', 'to'] });
|
|
@@ -86,7 +86,11 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, Omit<IData
|
|
|
86
86
|
groupAttribute?: string;
|
|
87
87
|
/**
|
|
88
88
|
* Свойство, которое устанавливает один type и src контента для всех пунктов
|
|
89
|
-
* @example
|
|
89
|
+
* @example
|
|
90
|
+
* {
|
|
91
|
+
* type: 'icon',
|
|
92
|
+
* src: 'user'
|
|
93
|
+
* }
|
|
90
94
|
*/
|
|
91
95
|
itemsContent?: {
|
|
92
96
|
type: ContentType | string;
|
|
@@ -94,7 +98,15 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, Omit<IData
|
|
|
94
98
|
};
|
|
95
99
|
/**
|
|
96
100
|
* Элементы вложенные внутрь DropDownField
|
|
97
|
-
* @example
|
|
101
|
+
* @example
|
|
102
|
+
* [
|
|
103
|
+
* {
|
|
104
|
+
* id: 1,
|
|
105
|
+
* label: 'Ivan Ivanov',
|
|
106
|
+
* type: 'icon',
|
|
107
|
+
* typeSrc: 'user'
|
|
108
|
+
* }
|
|
109
|
+
* ]
|
|
98
110
|
*/
|
|
99
111
|
items?: IDropDownFieldItem[] | DataProviderItems;
|
|
100
112
|
/**
|
|
@@ -104,12 +116,20 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, Omit<IData
|
|
|
104
116
|
showEllipses?: boolean;
|
|
105
117
|
/**
|
|
106
118
|
* Добавляет кнопку при нажатии на которую выбираются все элементы, работает только при multiple: true
|
|
107
|
-
* @example
|
|
119
|
+
* @example
|
|
120
|
+
* {
|
|
121
|
+
* label: 'All',
|
|
122
|
+
* id: 'all'
|
|
123
|
+
* }
|
|
108
124
|
*/
|
|
109
125
|
itemToSelectAll?: boolean | {
|
|
110
126
|
label: string;
|
|
111
127
|
id: string;
|
|
112
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Кастомная вьюшка для элемента
|
|
131
|
+
*/
|
|
132
|
+
itemView?: CustomView;
|
|
113
133
|
[key: string]: any;
|
|
114
134
|
}
|
|
115
135
|
export interface IDropDownFieldViewProps extends IDropDownFieldProps {
|
|
@@ -170,7 +170,7 @@ function DropDownField(props) {
|
|
|
170
170
|
onReset();
|
|
171
171
|
}
|
|
172
172
|
}, [onReset, prevInputValue, props.input.value, selectedIds.length]);
|
|
173
|
-
var renderItemView = function (item, type, src) { return components.ui.renderView('form.DropDownFieldItemView', {
|
|
173
|
+
var renderItemView = function (item, type, src) { return components.ui.renderView(props.itemView || 'form.DropDownFieldItemView', {
|
|
174
174
|
item: __assign(__assign({}, item), { contentSrc: src, contentType: type }),
|
|
175
175
|
selectedIds: selectedIds,
|
|
176
176
|
size: props.size,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { IBaseFieldProps } from '../InputField/InputField';
|
|
2
2
|
import { IFieldWrapperInputProps } from '../Field/fieldWrapper';
|
|
3
|
+
/**
|
|
4
|
+
* EmailField
|
|
5
|
+
*
|
|
6
|
+
* Поле ввода почты. Этот компонент представляет собой поле ввода почты.
|
|
7
|
+
*
|
|
8
|
+
**/
|
|
3
9
|
export interface IEmailFieldProps extends IBaseFieldProps, IFieldWrapperInputProps {
|
|
4
10
|
}
|
|
5
11
|
declare const _default: import("../Field/fieldWrapper").FieldWrapperComponent<IEmailFieldProps>;
|
|
@@ -19,10 +19,6 @@ var react_1 = __importDefault(require("react"));
|
|
|
19
19
|
var hooks_1 = require("../../../hooks");
|
|
20
20
|
var fieldWrapper_1 = __importDefault(require("../Field/fieldWrapper"));
|
|
21
21
|
var useInputTypeEmail_1 = __importDefault(require("./hooks/useInputTypeEmail"));
|
|
22
|
-
/**
|
|
23
|
-
* EmailField
|
|
24
|
-
* Поле для ввода почты
|
|
25
|
-
*/
|
|
26
22
|
function EmailField(props) {
|
|
27
23
|
var components = (0, hooks_1.useComponents)();
|
|
28
24
|
var _a = (0, hooks_1.useSaveCursorPosition)(props.input), currentInputRef = _a.inputRef, onChange = _a.onChange;
|
package/ui/form/Field/Field.d.ts
CHANGED
|
@@ -16,7 +16,15 @@ export interface IFieldProps extends IFieldWrapperInputProps {
|
|
|
16
16
|
attribute?: any;
|
|
17
17
|
/**
|
|
18
18
|
* Модель с полями формы
|
|
19
|
-
* @example
|
|
19
|
+
* @example
|
|
20
|
+
* {
|
|
21
|
+
* attributes: [
|
|
22
|
+
* {
|
|
23
|
+
* attribute: 'category',
|
|
24
|
+
* field: 'DropDownField'
|
|
25
|
+
* }
|
|
26
|
+
* ]
|
|
27
|
+
* }
|
|
20
28
|
*/
|
|
21
29
|
model?: Model;
|
|
22
30
|
/**
|
package/ui/form/Field/Field.js
CHANGED
|
@@ -50,7 +50,7 @@ function Field(props) {
|
|
|
50
50
|
var fieldModel = (0, react_1.useMemo)(function () {
|
|
51
51
|
var _a;
|
|
52
52
|
var model = props.model || context.model;
|
|
53
|
-
var modelAttributes = (((_a = components.meta.getModel(model)) === null || _a === void 0 ? void 0 : _a.attributes) || []);
|
|
53
|
+
var modelAttributes = (((_a = components.meta.getModel(model)) === null || _a === void 0 ? void 0 : _a.attributes) || (model === null || model === void 0 ? void 0 : model.attributes) || []);
|
|
54
54
|
var result = modelAttributes
|
|
55
55
|
.find(function (field) { return field.attribute === props.attribute; });
|
|
56
56
|
return result || {};
|
|
@@ -16,7 +16,15 @@ export interface IFieldWrapperInputProps {
|
|
|
16
16
|
attribute?: string;
|
|
17
17
|
/**
|
|
18
18
|
* Модель с полями формы
|
|
19
|
-
* @example
|
|
19
|
+
* @example
|
|
20
|
+
* {
|
|
21
|
+
* attributes: [
|
|
22
|
+
* {
|
|
23
|
+
* attribute: 'category',
|
|
24
|
+
* field: 'DropDownField'
|
|
25
|
+
* }
|
|
26
|
+
* ]
|
|
27
|
+
* }
|
|
20
28
|
*/
|
|
21
29
|
model?: string | ((...args: any[]) => any) | any;
|
|
22
30
|
/**
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../../form/Field/fieldWrapper';
|
|
3
|
-
/**
|
|
4
|
-
* FieldList
|
|
5
|
-
* Создает список из сгруппированных полей формы
|
|
6
|
-
*/
|
|
7
3
|
export interface IFieldListItem extends IFieldWrapperInputProps, IUiComponent {
|
|
8
4
|
/**
|
|
9
|
-
* Будет ли отображён item
|
|
5
|
+
* Будет ли отображён item?
|
|
10
6
|
* @example true
|
|
11
7
|
*/
|
|
12
8
|
visible?: boolean;
|
|
@@ -25,15 +21,25 @@ export interface IFieldListItem extends IFieldWrapperInputProps, IUiComponent {
|
|
|
25
21
|
*/
|
|
26
22
|
headerClassName?: CssClassName;
|
|
27
23
|
/**
|
|
28
|
-
* Заголовок для колонки
|
|
24
|
+
* Заголовок для колонки таблицы
|
|
29
25
|
*/
|
|
30
26
|
title?: string;
|
|
31
27
|
[key: string]: any;
|
|
32
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* FieldList
|
|
31
|
+
*
|
|
32
|
+
* Создает список из сгруппированных полей формы.
|
|
33
|
+
* Для загрузки файлов с помощью `FileField` внутри строк `FieldList`, нужно использовать форму с флагом `useRedux`.
|
|
34
|
+
*/
|
|
33
35
|
export interface IFieldListProps extends IFieldWrapperInputProps, IUiComponent {
|
|
34
36
|
/**
|
|
35
37
|
* Начальные значения в полях
|
|
36
|
-
* @example
|
|
38
|
+
* @example
|
|
39
|
+
* {
|
|
40
|
+
* name: 'Ivan',
|
|
41
|
+
* amount: 5
|
|
42
|
+
* }
|
|
37
43
|
*/
|
|
38
44
|
initialValues?: {
|
|
39
45
|
[key: string]: any;
|
|
@@ -33,6 +33,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
33
|
__setModuleDefault(result, mod);
|
|
34
34
|
return result;
|
|
35
35
|
};
|
|
36
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
+
if (ar || !(i in from)) {
|
|
39
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
+
ar[i] = from[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
+
};
|
|
36
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
47
|
};
|
|
@@ -40,6 +49,10 @@ exports.__esModule = true;
|
|
|
40
49
|
var React = __importStar(require("react"));
|
|
41
50
|
var isBoolean_1 = __importDefault(require("lodash-es/isBoolean"));
|
|
42
51
|
var range_1 = __importDefault(require("lodash-es/range"));
|
|
52
|
+
var concat_1 = __importDefault(require("lodash-es/concat"));
|
|
53
|
+
var last_1 = __importDefault(require("lodash-es/last"));
|
|
54
|
+
var isEmpty_1 = __importDefault(require("lodash-es/isEmpty"));
|
|
55
|
+
var get_1 = __importDefault(require("lodash-es/get"));
|
|
43
56
|
var react_use_1 = require("react-use");
|
|
44
57
|
var react_1 = require("react");
|
|
45
58
|
var hooks_1 = require("../../../hooks");
|
|
@@ -53,15 +66,29 @@ function FieldList(props) {
|
|
|
53
66
|
var context = (0, react_1.useContext)(Form_1.FormContext);
|
|
54
67
|
// Resolve model
|
|
55
68
|
var modelAttributes = (_a = components.meta.getModel(props.model)) === null || _a === void 0 ? void 0 : _a.attributes;
|
|
69
|
+
var isWithReduxForm = (0, hooks_1.useSelector)(function (state) { return (0, get_1["default"])(state, ['form', context.formId]) || null; });
|
|
56
70
|
var dispatch = context.provider.useDispatch();
|
|
71
|
+
// Mapper for preserving the correct sequence of rows on the UI
|
|
72
|
+
var _b = (0, react_1.useState)((0, range_1["default"])(props.input.value) || []), storeToRowIndexMap = _b[0], setStoreToRowIndexMap = _b[1];
|
|
73
|
+
var addRowIndexes = (0, react_1.useCallback)(function (rowsCount) {
|
|
74
|
+
setStoreToRowIndexMap(function (prevMap) {
|
|
75
|
+
var lastIndex = !(0, isEmpty_1["default"])(prevMap) ? (0, last_1["default"])(prevMap) + 1 : 0;
|
|
76
|
+
return (0, concat_1["default"])(prevMap, (0, range_1["default"])(lastIndex, lastIndex + rowsCount));
|
|
77
|
+
});
|
|
78
|
+
}, []);
|
|
79
|
+
var removeRowIndex = (0, react_1.useCallback)(function (rowIndex) {
|
|
80
|
+
setStoreToRowIndexMap(function (prevMap) { return __spreadArray(__spreadArray([], prevMap.slice(0, rowIndex), true), prevMap.slice(rowIndex + 1), true); });
|
|
81
|
+
}, []);
|
|
57
82
|
// Add and Remove handlers
|
|
58
83
|
var onAdd = (0, react_1.useCallback)(function (rowsCount) {
|
|
59
84
|
if (rowsCount === void 0) { rowsCount = 1; }
|
|
85
|
+
addRowIndexes(rowsCount);
|
|
60
86
|
dispatch((0, form_1.formArrayAdd)(context.formId, props.input.name, rowsCount, props.initialValues));
|
|
61
|
-
}, [context.formId, dispatch, props.initialValues, props.input.name]);
|
|
87
|
+
}, [context.formId, dispatch, props.initialValues, props.input.name, addRowIndexes]);
|
|
62
88
|
var onRemove = (0, react_1.useCallback)(function (rowIndex) {
|
|
89
|
+
removeRowIndex(rowIndex);
|
|
63
90
|
dispatch((0, form_1.formArrayRemove)(context.formId, props.input.name, rowIndex));
|
|
64
|
-
}, [context.formId, dispatch, props.input.name]);
|
|
91
|
+
}, [context.formId, dispatch, props.input.name, removeRowIndex]);
|
|
65
92
|
// Add initial rows
|
|
66
93
|
(0, react_use_1.useMount)(function () {
|
|
67
94
|
if (!props.input.value) {
|
|
@@ -106,8 +133,7 @@ function FieldList(props) {
|
|
|
106
133
|
var FieldListView = props.view || components.ui.getView('form.FieldListView');
|
|
107
134
|
var FieldListItemView = props.itemView || components.ui.getView('form.FieldListItemView');
|
|
108
135
|
return (React.createElement(Form_1.FormContext.Provider, { value: contextValue },
|
|
109
|
-
React.createElement(FieldListView, __assign({}, props.viewProps, commonProps, { forwardedRef: nodeRef, onAdd: onAdd, hasAlternatingColors: props.hasAlternatingColors }), (0, range_1["default"])(props.input.value || 0)
|
|
110
|
-
.map(function (index) { return (React.createElement(FieldListItemView, __assign({}, props.itemViewProps, commonProps, { key: index, onRemove: onRemove, prefix: props.input.name + '.' + index, rowIndex: index }))); }))));
|
|
136
|
+
React.createElement(FieldListView, __assign({}, props.viewProps, commonProps, { forwardedRef: nodeRef, onAdd: onAdd, hasAlternatingColors: props.hasAlternatingColors }), !(0, isEmpty_1["default"])(storeToRowIndexMap) && (0, range_1["default"])(props.input.value || 0).map(function (index) { return (React.createElement(FieldListItemView, __assign({}, props.itemViewProps, commonProps, { key: isWithReduxForm ? storeToRowIndexMap[index] : index, onRemove: onRemove, prefix: props.input.name + '.' + index, rowIndex: index }))); }))));
|
|
111
137
|
}
|
|
112
138
|
FieldList.defaultProps = {
|
|
113
139
|
initialValues: null,
|
|
@@ -66,6 +66,11 @@ function FileFieldComponent(props) {
|
|
|
66
66
|
props.onLoad();
|
|
67
67
|
}
|
|
68
68
|
}, [isFilesLoaded, props]);
|
|
69
|
+
(0, react_1.useEffect)(function () {
|
|
70
|
+
if (props.onChange) {
|
|
71
|
+
props.onChange(files);
|
|
72
|
+
}
|
|
73
|
+
}, [files, props]);
|
|
69
74
|
return (React.createElement(FileFieldView, __assign({}, props, { buttonView: props.buttonView, buttonProps: __assign({ label: props.filesLayout === FilesLayout.wall
|
|
70
75
|
? __('Upload')
|
|
71
76
|
: __('Click to Upload'), size: props.size, disabled: props.disabled, onClick: onBrowse }, props.buttonProps), itemView: FileFieldItemView, items: files.map(function (file) {
|
package/ui/form/Form/Form.d.ts
CHANGED
|
@@ -19,7 +19,15 @@ export interface IFormProps extends IUiComponent {
|
|
|
19
19
|
prefix?: string;
|
|
20
20
|
/**
|
|
21
21
|
* Модель с полями формы
|
|
22
|
-
* @example
|
|
22
|
+
* @example
|
|
23
|
+
* {
|
|
24
|
+
* attributes: [
|
|
25
|
+
* {
|
|
26
|
+
* attribute: 'category',
|
|
27
|
+
* field: 'DropDownField'
|
|
28
|
+
* }
|
|
29
|
+
* ]
|
|
30
|
+
* }
|
|
23
31
|
*/
|
|
24
32
|
model?: string | ((...args: any[]) => any) | any;
|
|
25
33
|
/**
|
|
@@ -45,7 +53,11 @@ export interface IFormProps extends IUiComponent {
|
|
|
45
53
|
/**
|
|
46
54
|
* Набор с правилами для проверки соответствия значений полей формы определенному формату.
|
|
47
55
|
* Проверка запускается в момент отправки формы (в обработчике onSubmit).
|
|
48
|
-
* @example
|
|
56
|
+
* @example
|
|
57
|
+
* [
|
|
58
|
+
* ['name', 'required'],
|
|
59
|
+
* ['age', 'integer']
|
|
60
|
+
* ]
|
|
49
61
|
*/
|
|
50
62
|
validators?: any[];
|
|
51
63
|
/**
|
|
@@ -97,7 +109,13 @@ export interface IFormProps extends IUiComponent {
|
|
|
97
109
|
viewProps?: any;
|
|
98
110
|
/**
|
|
99
111
|
* Поля, которые необходимо поместить в форму
|
|
100
|
-
* @example
|
|
112
|
+
* @example
|
|
113
|
+
* [
|
|
114
|
+
* {
|
|
115
|
+
* attribute: 'category',
|
|
116
|
+
* component: 'DropDownField'
|
|
117
|
+
* }
|
|
118
|
+
* ]
|
|
101
119
|
*/
|
|
102
120
|
fields?: (string | IFieldProps)[];
|
|
103
121
|
/**
|
|
@@ -131,6 +149,10 @@ export interface IFormProps extends IUiComponent {
|
|
|
131
149
|
* @example false
|
|
132
150
|
*/
|
|
133
151
|
autoDestroy?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Дополнительные кнопки
|
|
154
|
+
*/
|
|
155
|
+
buttons?: React.ReactNode;
|
|
134
156
|
[key: string]: any;
|
|
135
157
|
}
|
|
136
158
|
export interface IFormViewProps {
|
|
@@ -141,6 +163,7 @@ export interface IFormViewProps {
|
|
|
141
163
|
autoFocus?: boolean;
|
|
142
164
|
style?: CustomStyle;
|
|
143
165
|
children?: React.ReactNode;
|
|
166
|
+
buttons?: React.ReactNode;
|
|
144
167
|
}
|
|
145
168
|
export interface IFormReducerState {
|
|
146
169
|
values: any;
|
package/ui/form/Form/Form.js
CHANGED
|
@@ -129,7 +129,7 @@ function Form(props) {
|
|
|
129
129
|
}
|
|
130
130
|
// Init data provider
|
|
131
131
|
var provider = props.useRedux ? form_1.providers.redux : form_1.providers.reducer;
|
|
132
|
-
var _b = provider.useForm(props.formId, initialValues), values = _b.values, submitCounter = _b.submitCounter, isInvalid = _b.isInvalid, isSubmitting = _b.isSubmitting, setErrors = _b.setErrors, reducer = _b.reducer, dispatch = _b.dispatch;
|
|
132
|
+
var _b = provider.useForm(props.formId, initialValues), values = _b.values, submitCounter = _b.submitCounter, isInvalid = _b.isInvalid, isSubmitting = _b.isSubmitting, errors = _b.errors, setErrors = _b.setErrors, reducer = _b.reducer, dispatch = _b.dispatch;
|
|
133
133
|
// Sync with address bar
|
|
134
134
|
(0, react_use_1.useUpdateEffect)(function () {
|
|
135
135
|
updateQuery(values);
|
|
@@ -147,6 +147,9 @@ function Form(props) {
|
|
|
147
147
|
dispatch((0, form_2.formDestroy)(props.formId));
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
|
+
// Clear Errors
|
|
151
|
+
var prevValues = (0, react_use_1.usePrevious)(values);
|
|
152
|
+
(0, react_use_1.useUpdateEffect)(function () { return (0, form_1.clearErrors)(values, prevValues, errors, setErrors); }, [errors, prevValues, setErrors, values]);
|
|
150
153
|
// OnChange handler
|
|
151
154
|
(0, react_use_1.useUpdateEffect)(function () {
|
|
152
155
|
if (props.onChange) {
|
|
@@ -164,7 +167,6 @@ function Form(props) {
|
|
|
164
167
|
switch (_b.label) {
|
|
165
168
|
case 0:
|
|
166
169
|
dispatch((0, form_2.formSetSubmitting)(props.formId, true));
|
|
167
|
-
// TODO
|
|
168
170
|
if (e) {
|
|
169
171
|
e.preventDefault();
|
|
170
172
|
}
|
|
@@ -329,7 +331,7 @@ function Form(props) {
|
|
|
329
331
|
}
|
|
330
332
|
// Render context and form
|
|
331
333
|
return (React.createElement(exports.FormContext.Provider, { value: formContextValue }, props.view !== false
|
|
332
|
-
? components.ui.renderView(props.view || 'form.FormView', __assign(__assign({}, props.viewProps), { isSubmitting: isSubmitting, onSubmit: onSubmit, submitLabel: props.submitLabel, fields: props.fields, children: props.children, className: props.className, style: props.style, autoFocus: props.autoFocus }))
|
|
334
|
+
? components.ui.renderView(props.view || 'form.FormView', __assign(__assign({}, props.viewProps), { isSubmitting: isSubmitting, onSubmit: onSubmit, submitLabel: props.submitLabel, fields: props.fields, children: props.children, buttons: props.buttons, className: props.className, style: props.style, autoFocus: props.autoFocus }))
|
|
333
335
|
: props.children));
|
|
334
336
|
}
|
|
335
337
|
Form.defaultProps = {
|
|
@@ -6,7 +6,15 @@ import { IButtonProps } from '../Button/Button';
|
|
|
6
6
|
export interface ICropConfig {
|
|
7
7
|
/**
|
|
8
8
|
* Изначальные параметры обрезки изображения
|
|
9
|
-
* @example
|
|
9
|
+
* @example
|
|
10
|
+
* {
|
|
11
|
+
* unit: 'px',
|
|
12
|
+
* aspect: 1,
|
|
13
|
+
* x: 0,
|
|
14
|
+
* y: 0,
|
|
15
|
+
* width: 200,
|
|
16
|
+
* height: 200
|
|
17
|
+
* }
|
|
10
18
|
*/
|
|
11
19
|
initialValues?: Crop;
|
|
12
20
|
/**
|
|
@@ -15,7 +15,7 @@ export type IElementInputType = 'button' | 'checkbox' | 'color' | 'date' | 'date
|
|
|
15
15
|
export interface IBaseFieldProps extends IFieldWrapperInputProps, IUiComponent {
|
|
16
16
|
/**
|
|
17
17
|
* Свойства для элемента input
|
|
18
|
-
* @example {onKeyDown: ...}
|
|
18
|
+
* @example { onKeyDown: ... }
|
|
19
19
|
*/
|
|
20
20
|
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
21
21
|
/**
|
|
@@ -25,7 +25,10 @@ export interface IBaseFieldProps extends IFieldWrapperInputProps, IUiComponent {
|
|
|
25
25
|
showClear?: boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Свойства для компонента отображения
|
|
28
|
-
* @example
|
|
28
|
+
* @example
|
|
29
|
+
* {
|
|
30
|
+
* customHandler: () => {...}
|
|
31
|
+
* }
|
|
29
32
|
*/
|
|
30
33
|
viewProps?: {
|
|
31
34
|
[key: string]: any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.useInputFieldWarningByType = exports.INPUT_TYPES_SUPPORTED_SELECTION = void 0;
|
|
4
|
+
/* eslint-disable no-console */
|
|
4
5
|
/* eslint-disable max-len */
|
|
5
6
|
/* eslint-disable no-unused-expressions */
|
|
6
7
|
var react_use_1 = require("react-use");
|
|
@@ -10,12 +10,35 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
13
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
38
|
};
|
|
16
39
|
exports.__esModule = true;
|
|
17
40
|
/* eslint-disable max-len */
|
|
18
|
-
var react_1 = require("react");
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
19
42
|
var hooks_1 = require("../../../hooks");
|
|
20
43
|
var fieldWrapper_1 = __importDefault(require("../Field/fieldWrapper"));
|
|
21
44
|
var useInputTypeNumber_1 = __importDefault(require("./hooks/useInputTypeNumber"));
|
|
@@ -23,6 +46,7 @@ var DEFAULT_STEP = 1;
|
|
|
23
46
|
function NumberField(props) {
|
|
24
47
|
var components = (0, hooks_1.useComponents)();
|
|
25
48
|
var _a = (0, hooks_1.useSaveCursorPosition)(props.input), currentInputRef = _a.inputRef, onChange = _a.onChange;
|
|
49
|
+
var step = react_1["default"].useMemo(function () { var _a; return (_a = props.step) !== null && _a !== void 0 ? _a : DEFAULT_STEP; }, [props.step]);
|
|
26
50
|
var onInputChange = (0, useInputTypeNumber_1["default"])(currentInputRef, {
|
|
27
51
|
max: props.max,
|
|
28
52
|
min: props.min,
|
|
@@ -30,15 +54,18 @@ function NumberField(props) {
|
|
|
30
54
|
}, onChange).onInputChange;
|
|
31
55
|
var onStep = (0, react_1.useCallback)(function (isIncrement) {
|
|
32
56
|
var _a;
|
|
33
|
-
var step = props.step || DEFAULT_STEP;
|
|
34
57
|
onChange(null, String(Number((_a = currentInputRef === null || currentInputRef === void 0 ? void 0 : currentInputRef.current) === null || _a === void 0 ? void 0 : _a.value) + (isIncrement ? step : -step)));
|
|
35
|
-
}, [currentInputRef, onChange,
|
|
58
|
+
}, [currentInputRef, onChange, step]);
|
|
36
59
|
var onStepUp = (0, react_1.useCallback)(function () {
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
if (!(Number(currentInputRef.current.value) + step > props.max)) {
|
|
61
|
+
onStep(true);
|
|
62
|
+
}
|
|
63
|
+
}, [currentInputRef, onStep, props.max, step]);
|
|
39
64
|
var onStepDown = (0, react_1.useCallback)(function () {
|
|
40
|
-
|
|
41
|
-
|
|
65
|
+
if (!(Number(currentInputRef.current.value) - step < props.min)) {
|
|
66
|
+
onStep(false);
|
|
67
|
+
}
|
|
68
|
+
}, [currentInputRef, onStep, props.min, step]);
|
|
42
69
|
var onKeyDown = (0, react_1.useCallback)(function (event) {
|
|
43
70
|
if (event.key === 'ArrowUp') {
|
|
44
71
|
onStepUp();
|
|
@@ -43,7 +43,12 @@ export interface ISliderFieldProps extends IFieldWrapperInputProps, IUiComponent
|
|
|
43
43
|
* Метки на ползунке. В объекте '{'key: value'}' key определяет положение, а value определяет, что будет отображаться.
|
|
44
44
|
* Если вы хотите задать стиль определенной точки метки, значением должен быть объект,
|
|
45
45
|
* содержащий свойства style и label.
|
|
46
|
-
* @example
|
|
46
|
+
* @example
|
|
47
|
+
* {
|
|
48
|
+
* min: 20,
|
|
49
|
+
* 40: 40,
|
|
50
|
+
* max: 100
|
|
51
|
+
* }
|
|
47
52
|
*/
|
|
48
53
|
marks?: Record<string, {
|
|
49
54
|
style: {
|
|
@@ -54,7 +59,10 @@ export interface ISliderFieldProps extends IFieldWrapperInputProps, IUiComponent
|
|
|
54
59
|
/**
|
|
55
60
|
* Функция, вызываемая после отпускания tip'а у слайдера (при событии onmouseup)
|
|
56
61
|
* @see https://github.com/schrodinger/rc-slider
|
|
57
|
-
* @example
|
|
62
|
+
* @example
|
|
63
|
+
* {
|
|
64
|
+
* () => console.log('Slider handler is released')
|
|
65
|
+
* }
|
|
58
66
|
*/
|
|
59
67
|
onAfterChange?: (value: any) => void;
|
|
60
68
|
[key: string]: any;
|