@steroidsjs/core 3.0.0-beta.98 → 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 +15226 -6277
- package/en.json +151 -84
- 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 +94 -17
- package/ui/content/CalendarSystem/CalendarSystem.js +66 -77
- 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.d.ts +2 -1
- package/ui/content/CalendarSystem/hooks/useCalendarSystemEventGroupModals.js +13 -5
- 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 +109 -0
- package/ui/content/Chat/Chat.js +52 -0
- package/ui/content/Chat/constants/timeTemplatesAndUnits.d.ts +8 -0
- package/ui/content/Chat/constants/timeTemplatesAndUnits.js +11 -0
- package/ui/content/Chat/hooks/useChat.d.ts +12 -0
- package/ui/content/Chat/hooks/useChat.js +58 -0
- package/ui/content/Chat/index.d.ts +2 -0
- package/ui/content/Chat/index.js +7 -0
- package/ui/content/Chat/utils/addNewMessageIntoGroupedMessages.d.ts +5 -0
- package/ui/content/Chat/utils/addNewMessageIntoGroupedMessages.js +61 -0
- package/ui/content/Chat/utils/calculateMessageTimeAgo.d.ts +1 -0
- package/ui/content/Chat/utils/calculateMessageTimeAgo.js +26 -0
- package/ui/content/Chat/utils/getMessagesGroupedByDate.d.ts +4 -0
- package/ui/content/Chat/utils/getMessagesGroupedByDate.js +56 -0
- package/ui/content/Chat/utils/index.d.ts +5 -0
- package/ui/content/Chat/utils/index.js +12 -0
- 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/content/index.d.ts +2 -1
- package/ui/content/index.js +3 -1
- 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,17 +10,45 @@ 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 hooks_1 = require("../../../hooks");
|
|
20
45
|
var useDateInputState_1 = __importDefault(require("../DateField/useDateInputState"));
|
|
21
46
|
var fieldWrapper_1 = __importDefault(require("../../form/Field/fieldWrapper"));
|
|
22
47
|
function DateRangeField(props) {
|
|
48
|
+
var _a, _b;
|
|
23
49
|
var components = (0, hooks_1.useComponents)();
|
|
50
|
+
var maskInputFromRef = (0, react_2.useMaskito)({ options: (_a = props.maskOptions) === null || _a === void 0 ? void 0 : _a.from });
|
|
51
|
+
var maskInputToRef = (0, react_2.useMaskito)({ options: (_b = props.maskOptions) === null || _b === void 0 ? void 0 : _b.to });
|
|
24
52
|
// Global onChange (from props)
|
|
25
53
|
var onChange = (0, react_1.useCallback)(function () {
|
|
26
54
|
var _a;
|
|
@@ -32,7 +60,7 @@ function DateRangeField(props) {
|
|
|
32
60
|
}
|
|
33
61
|
}, [props.attributeFrom, props.attributeTo, props.inputFrom.value, props.inputTo.value, props.onChange]);
|
|
34
62
|
// Input 'from'
|
|
35
|
-
var
|
|
63
|
+
var _c = (0, useDateInputState_1["default"])({
|
|
36
64
|
displayFormat: props.displayFormat,
|
|
37
65
|
valueFormat: props.valueFormat,
|
|
38
66
|
input: props.inputFrom,
|
|
@@ -41,9 +69,9 @@ function DateRangeField(props) {
|
|
|
41
69
|
required: props.required,
|
|
42
70
|
inputProps: props.inputPropsFrom,
|
|
43
71
|
onChange: onChange
|
|
44
|
-
}), isOpenedFrom =
|
|
72
|
+
}), isOpenedFrom = _c.isOpened, onCloseFrom = _c.onClose, inputPropsFrom = _c.inputProps, onClearFrom = _c.onClear;
|
|
45
73
|
// Input 'to'
|
|
46
|
-
var
|
|
74
|
+
var _d = (0, useDateInputState_1["default"])({
|
|
47
75
|
displayFormat: props.displayFormat,
|
|
48
76
|
valueFormat: props.valueFormat,
|
|
49
77
|
input: props.inputTo,
|
|
@@ -52,8 +80,8 @@ function DateRangeField(props) {
|
|
|
52
80
|
required: props.required,
|
|
53
81
|
inputProps: props.inputPropsTo,
|
|
54
82
|
onChange: onChange
|
|
55
|
-
}), isOpenedTo =
|
|
56
|
-
var
|
|
83
|
+
}), isOpenedTo = _d.isOpened, onCloseTo = _d.onClose, inputPropsTo = _d.inputProps, onClearTo = _d.onClear;
|
|
84
|
+
var _e = (0, useDateRange_1["default"])({
|
|
57
85
|
onClearFrom: onClearFrom,
|
|
58
86
|
onCloseTo: onCloseTo,
|
|
59
87
|
onCloseFrom: onCloseFrom,
|
|
@@ -63,9 +91,21 @@ function DateRangeField(props) {
|
|
|
63
91
|
inputFrom: props.inputFrom,
|
|
64
92
|
inputTo: props.inputTo,
|
|
65
93
|
useSmartFocus: true,
|
|
94
|
+
hasInitialFocus: props.hasInitialFocus,
|
|
66
95
|
displayFormat: props.displayFormat,
|
|
67
96
|
valueFormat: props.valueFormat
|
|
68
|
-
}), focus =
|
|
97
|
+
}), focus = _e.focus, onClose = _e.onClose, onClear = _e.onClear, extendedInputPropsFrom = _e.extendedInputPropsFrom, extendedInputPropsTo = _e.extendedInputPropsTo;
|
|
98
|
+
react_1["default"].useEffect(function () {
|
|
99
|
+
if (extendedInputPropsFrom.ref && extendedInputPropsTo.ref) {
|
|
100
|
+
maskInputFromRef(extendedInputPropsFrom.ref.current);
|
|
101
|
+
maskInputToRef(extendedInputPropsTo.ref.current);
|
|
102
|
+
}
|
|
103
|
+
}, [
|
|
104
|
+
extendedInputPropsFrom.ref,
|
|
105
|
+
extendedInputPropsTo.ref,
|
|
106
|
+
maskInputFromRef,
|
|
107
|
+
maskInputToRef,
|
|
108
|
+
]);
|
|
69
109
|
// Calendar props
|
|
70
110
|
var calendarProps = (0, react_1.useMemo)(function () { return ({
|
|
71
111
|
value: [props.inputFrom.value, props.inputTo.value],
|
|
@@ -84,8 +124,19 @@ DateRangeField.defaultProps = {
|
|
|
84
124
|
displayFormat: 'DD.MM.YYYY',
|
|
85
125
|
valueFormat: 'YYYY-MM-DD',
|
|
86
126
|
showRemove: true,
|
|
127
|
+
hasInitialFocus: false,
|
|
87
128
|
icon: true,
|
|
88
129
|
noBorder: false,
|
|
89
|
-
size: 'md'
|
|
130
|
+
size: 'md',
|
|
131
|
+
maskOptions: {
|
|
132
|
+
from: (0, kit_1.maskitoDateOptionsGenerator)({
|
|
133
|
+
mode: 'dd/mm/yyyy',
|
|
134
|
+
separator: '.'
|
|
135
|
+
}),
|
|
136
|
+
to: (0, kit_1.maskitoDateOptionsGenerator)({
|
|
137
|
+
mode: 'dd/mm/yyyy',
|
|
138
|
+
separator: '.'
|
|
139
|
+
})
|
|
140
|
+
}
|
|
90
141
|
};
|
|
91
142
|
exports["default"] = (0, fieldWrapper_1["default"])('DateRangeField', DateRangeField, { attributeSuffixes: ['from', 'to'] });
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MaskitoOptions } from '@maskito/core';
|
|
1
3
|
import { ICalendarProps } from '../../content/Calendar/Calendar';
|
|
2
4
|
import { IDateInputStateInput, IDateInputStateOutput } from '../../form/DateField/useDateInputState';
|
|
3
5
|
/**
|
|
@@ -17,9 +19,17 @@ export interface IDateTimeFieldProps extends IDateInputStateInput, IUiComponent
|
|
|
17
19
|
* Свойства для компонента панели времени
|
|
18
20
|
*/
|
|
19
21
|
timePanelViewProps?: any;
|
|
22
|
+
/**
|
|
23
|
+
* Опции маски для поля ввода
|
|
24
|
+
*/
|
|
25
|
+
maskOptions?: MaskitoOptions;
|
|
20
26
|
[key: string]: any;
|
|
21
27
|
}
|
|
22
28
|
export interface IDateTimeFieldViewProps extends IDateInputStateOutput, Pick<IDateTimeFieldProps, 'size' | 'errors' | 'showRemove' | 'calendarProps' | 'className' | 'timePanelViewProps'> {
|
|
29
|
+
/**
|
|
30
|
+
* Ref для input элемента, который накладывает маску
|
|
31
|
+
*/
|
|
32
|
+
maskInputRef?: React.RefCallback<HTMLElement>;
|
|
23
33
|
[key: string]: any;
|
|
24
34
|
}
|
|
25
35
|
declare const _default: import("../../form/Field/fieldWrapper").FieldWrapperComponent<IDateTimeFieldProps>;
|
|
@@ -15,17 +15,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
exports.__esModule = true;
|
|
17
17
|
var react_1 = require("react");
|
|
18
|
+
var kit_1 = require("@maskito/kit");
|
|
19
|
+
var react_2 = require("@maskito/react");
|
|
18
20
|
var useDateTime_1 = __importDefault(require("../DateField/useDateTime"));
|
|
19
21
|
var useDateInputState_1 = __importDefault(require("../../form/DateField/useDateInputState"));
|
|
20
22
|
var fieldWrapper_1 = __importDefault(require("../../form/Field/fieldWrapper"));
|
|
21
23
|
var hooks_1 = require("../../../hooks");
|
|
22
|
-
var DATE_TIME_SEPARATOR = ' ';
|
|
24
|
+
var DATE_TIME_SEPARATOR = ', ';
|
|
23
25
|
/**
|
|
24
26
|
* DateTimeField
|
|
25
27
|
* Поля ввода с выпадающими списками для выбора даты и времени
|
|
26
28
|
*/
|
|
27
29
|
function DateTimeField(props) {
|
|
28
30
|
var components = (0, hooks_1.useComponents)();
|
|
31
|
+
var maskInputRef = (0, react_2.useMaskito)({ options: props.maskOptions });
|
|
29
32
|
var _a = (0, useDateInputState_1["default"])({
|
|
30
33
|
input: props.input,
|
|
31
34
|
disabled: props.disabled,
|
|
@@ -56,7 +59,7 @@ function DateTimeField(props) {
|
|
|
56
59
|
value: timeValue,
|
|
57
60
|
onSelect: onTimeSelect
|
|
58
61
|
}); }, [onClose, onTimeSelect, timeValue]);
|
|
59
|
-
return components.ui.renderView(props.view || 'form.DateTimeFieldView', __assign(__assign({}, props.viewProps), { isOpened: isOpened, onClear: onClear, onClose: onClose, inputProps: inputProps, calendarProps: calendarProps, timePanelViewProps: timePanelViewProps, size: props.size, icon: props.icon, label: props.label, errors: props.errors, className: props.className, showRemove: props.showRemove, isInvalid: props.isInvalid, disabled: props.disabled, style: props.style }));
|
|
62
|
+
return components.ui.renderView(props.view || 'form.DateTimeFieldView', __assign(__assign({}, props.viewProps), { isOpened: isOpened, onClear: onClear, onClose: onClose, inputProps: inputProps, calendarProps: calendarProps, timePanelViewProps: timePanelViewProps, size: props.size, icon: props.icon, label: props.label, errors: props.errors, className: props.className, showRemove: props.showRemove, isInvalid: props.isInvalid, disabled: props.disabled, style: props.style, maskInputRef: maskInputRef }));
|
|
60
63
|
}
|
|
61
64
|
DateTimeField.defaultProps = {
|
|
62
65
|
disabled: false,
|
|
@@ -67,6 +70,11 @@ DateTimeField.defaultProps = {
|
|
|
67
70
|
useUTC: false,
|
|
68
71
|
dateInUTC: false,
|
|
69
72
|
size: 'md',
|
|
70
|
-
icon: true
|
|
73
|
+
icon: true,
|
|
74
|
+
maskOptions: (0, kit_1.maskitoDateTimeOptionsGenerator)({
|
|
75
|
+
dateMode: 'dd/mm/yyyy',
|
|
76
|
+
timeMode: 'HH:MM',
|
|
77
|
+
dateSeparator: '.'
|
|
78
|
+
})
|
|
71
79
|
};
|
|
72
80
|
exports["default"] = (0, fieldWrapper_1["default"])('DateTimeField', DateTimeField);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MaskitoOptions } from '@maskito/core';
|
|
1
2
|
import { ICalendarProps } from '../../content/Calendar/Calendar';
|
|
2
3
|
import { IDateRangeFieldProps } from '../../form/DateRangeField/DateRangeField';
|
|
3
4
|
import { IDateInputStateInput, IDateInputStateOutput } from '../../form/DateField/useDateInputState';
|
|
@@ -24,7 +25,12 @@ export interface IDateTimeRangeFieldProps extends Omit<IDateInputStateInput, 'in
|
|
|
24
25
|
attributeTo?: string;
|
|
25
26
|
/**
|
|
26
27
|
* Свойства для компонента DayPickerInput
|
|
27
|
-
* @example
|
|
28
|
+
* @example
|
|
29
|
+
* {
|
|
30
|
+
* dayPickerProps: {
|
|
31
|
+
* showWeekNumbers: true
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
28
34
|
*/
|
|
29
35
|
pickerProps?: any;
|
|
30
36
|
/**
|
|
@@ -43,6 +49,24 @@ export interface IDateTimeRangeFieldProps extends Omit<IDateInputStateInput, 'in
|
|
|
43
49
|
* Свойства для компонента Calendar
|
|
44
50
|
*/
|
|
45
51
|
calendarProps?: ICalendarProps;
|
|
52
|
+
/**
|
|
53
|
+
* Устанавливать ли фокус и показывать календарь сразу после рендера страницы
|
|
54
|
+
* @example true
|
|
55
|
+
*/
|
|
56
|
+
hasInitialFocus?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Опции маски для полей
|
|
59
|
+
*/
|
|
60
|
+
maskOptions?: {
|
|
61
|
+
/**
|
|
62
|
+
* Опции маски для поля from
|
|
63
|
+
*/
|
|
64
|
+
from: MaskitoOptions;
|
|
65
|
+
/**
|
|
66
|
+
* Опции маски для поля to
|
|
67
|
+
*/
|
|
68
|
+
to: MaskitoOptions;
|
|
69
|
+
};
|
|
46
70
|
[key: string]: any;
|
|
47
71
|
}
|
|
48
72
|
export interface IDateTimeRangeFieldViewProps extends IDateInputStateOutput, Omit<IFieldWrapperOutputProps, 'input'>, Pick<IDateRangeFieldProps, 'size' | 'icon' | 'errors' | 'showRemove' | 'calendarProps' | 'className' | 'disabled' | 'noBorder' | 'style'> {
|
|
@@ -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) {
|