@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
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IPreparedTreeItem } from '../../../hooks/useTree';
|
|
3
|
+
import Enum from '../../../base/Enum';
|
|
4
|
+
import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../../../ui/form/Field/fieldWrapper';
|
|
5
|
+
import { IDataProviderConfig } from '../../../hooks/useDataProvider';
|
|
6
|
+
import { IDataSelectConfig } from '../../../hooks/useDataSelect';
|
|
7
|
+
import { ICheckboxFieldViewProps } from '../CheckboxField/CheckboxField';
|
|
8
|
+
import { ITreeProps } from '../../nav/Tree/Tree';
|
|
9
|
+
type CheckboxTreeItems = string | ({
|
|
10
|
+
new (): Enum;
|
|
11
|
+
}) | (string | number | {
|
|
12
|
+
id: string | number | boolean;
|
|
13
|
+
label: string;
|
|
14
|
+
color?: string;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
})[];
|
|
17
|
+
/**
|
|
18
|
+
* CheckboxTreeField
|
|
19
|
+
*
|
|
20
|
+
* Список с вложенными чекбоксами. Используется в формах для создания иерархической структуры и выбора нескольких значений.
|
|
21
|
+
*/
|
|
22
|
+
export interface ICheckboxTreeFieldProps extends IFieldWrapperInputProps, Omit<IDataProviderConfig, 'items'>, Omit<IDataSelectConfig, 'items'>, IUiComponent, Pick<ITreeProps, 'levelPadding' | 'alwaysOpened' | 'showIcon' | 'customIcon'> {
|
|
23
|
+
/**
|
|
24
|
+
* Свойства для элемента input
|
|
25
|
+
* @example { onKeyDown: ... }
|
|
26
|
+
*/
|
|
27
|
+
inputProps?: any;
|
|
28
|
+
/**
|
|
29
|
+
* Коллекция элементов
|
|
30
|
+
* @example
|
|
31
|
+
* [
|
|
32
|
+
* {
|
|
33
|
+
* id: 1,
|
|
34
|
+
* label: 'Krasnoyarsk',
|
|
35
|
+
* color: 'red'
|
|
36
|
+
* },
|
|
37
|
+
* {
|
|
38
|
+
* id: 2,
|
|
39
|
+
* label: 'Moscow',
|
|
40
|
+
* color: 'purple'
|
|
41
|
+
* }
|
|
42
|
+
* ]
|
|
43
|
+
*/
|
|
44
|
+
items: CheckboxTreeItems;
|
|
45
|
+
/**
|
|
46
|
+
* Первичный ключ для доступа к вложенным элементам
|
|
47
|
+
*/
|
|
48
|
+
primaryKey?: string;
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
}
|
|
51
|
+
export interface ICheckboxTreeFieldViewProps extends IFieldWrapperOutputProps, Pick<ITreeProps, 'levelPadding' | 'customIcon'> {
|
|
52
|
+
items: {
|
|
53
|
+
id: number | string | boolean;
|
|
54
|
+
label?: string;
|
|
55
|
+
isHovered: boolean;
|
|
56
|
+
color?: string;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
required?: boolean;
|
|
59
|
+
} & IPreparedTreeItem[];
|
|
60
|
+
selectedIds: (PrimaryKey | any)[];
|
|
61
|
+
onItemSelect: (checkbox: IPreparedTreeItem) => void;
|
|
62
|
+
renderCheckbox: (checkboxProps: ICheckboxFieldViewProps) => JSX.Element;
|
|
63
|
+
size?: Size;
|
|
64
|
+
}
|
|
65
|
+
export declare const getNestedItemsIds: (item: any, groupAttribute: any) => any[];
|
|
66
|
+
declare const _default: import("../../../ui/form/Field/fieldWrapper").FieldWrapperComponent<ICheckboxTreeFieldProps>;
|
|
67
|
+
export default _default;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
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
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
exports.__esModule = true;
|
|
40
|
+
exports.getNestedItemsIds = void 0;
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
42
|
+
var react_use_1 = require("react-use");
|
|
43
|
+
var isArray_1 = __importDefault(require("lodash-es/isArray"));
|
|
44
|
+
var hooks_1 = require("../../../hooks");
|
|
45
|
+
var fieldWrapper_1 = __importDefault(require("../../../ui/form/Field/fieldWrapper"));
|
|
46
|
+
var getNestedItemsIds = function (item, groupAttribute) {
|
|
47
|
+
if (item.disabled) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
var _a = item, _b = groupAttribute, _c = _a[_b], nestedItems = _c === void 0 ? [] : _c;
|
|
51
|
+
var result = [item.id];
|
|
52
|
+
if (groupAttribute && (0, isArray_1["default"])(nestedItems)) {
|
|
53
|
+
nestedItems.reduce(function (acc, nestedItem) {
|
|
54
|
+
if ((0, isArray_1["default"])(nestedItem[groupAttribute])) {
|
|
55
|
+
acc.push.apply(acc, (0, exports.getNestedItemsIds)(nestedItem, groupAttribute));
|
|
56
|
+
}
|
|
57
|
+
else if (!nestedItem.disabled) {
|
|
58
|
+
acc.push(nestedItem.id);
|
|
59
|
+
}
|
|
60
|
+
return acc;
|
|
61
|
+
}, result);
|
|
62
|
+
}
|
|
63
|
+
return result.sort();
|
|
64
|
+
};
|
|
65
|
+
exports.getNestedItemsIds = getNestedItemsIds;
|
|
66
|
+
function CheckboxTreeField(props) {
|
|
67
|
+
var components = (0, hooks_1.useComponents)();
|
|
68
|
+
var inputSelectedIds = (0, react_1.useMemo)(function () { return props.selectedIds || [].concat(props.input.value || []); }, [props.input.value, props.selectedIds]);
|
|
69
|
+
// Data Provider
|
|
70
|
+
var items = (0, hooks_1.useDataProvider)({
|
|
71
|
+
items: props.items
|
|
72
|
+
}).items;
|
|
73
|
+
// Tree items
|
|
74
|
+
var treeItems = (0, hooks_1.useTree)({
|
|
75
|
+
items: items,
|
|
76
|
+
autoOpenLevels: 0,
|
|
77
|
+
alwaysOpened: props.alwaysOpened
|
|
78
|
+
}).treeItems;
|
|
79
|
+
// Data select
|
|
80
|
+
var _a = (0, hooks_1.useDataSelect)({
|
|
81
|
+
selectedIds: inputSelectedIds,
|
|
82
|
+
multiple: true,
|
|
83
|
+
primaryKey: props.primaryKey,
|
|
84
|
+
items: treeItems,
|
|
85
|
+
inputValue: props.input.value
|
|
86
|
+
}), selectedIds = _a.selectedIds, setSelectedIds = _a.setSelectedIds;
|
|
87
|
+
var onItemSelect = (0, react_1.useCallback)(function (checkbox) {
|
|
88
|
+
if (checkbox.hasItems) {
|
|
89
|
+
var selectedItemIds = (0, exports.getNestedItemsIds)(checkbox, props.primaryKey);
|
|
90
|
+
setSelectedIds(selectedItemIds);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
setSelectedIds(checkbox.id);
|
|
94
|
+
}
|
|
95
|
+
}, [props.primaryKey, setSelectedIds]);
|
|
96
|
+
// Sync with form
|
|
97
|
+
(0, react_1.useEffect)(function () {
|
|
98
|
+
props.input.onChange.call(null, selectedIds);
|
|
99
|
+
if (props.onChange) {
|
|
100
|
+
props.onChange(selectedIds);
|
|
101
|
+
}
|
|
102
|
+
}, [props, props.input.onChange, selectedIds]);
|
|
103
|
+
var onReset = (0, react_1.useCallback)(function () {
|
|
104
|
+
setSelectedIds([]);
|
|
105
|
+
}, [setSelectedIds]);
|
|
106
|
+
// Reset selected ids on form reset
|
|
107
|
+
var prevInputValue = (0, react_use_1.usePrevious)(props.input.value);
|
|
108
|
+
(0, react_use_1.useUpdateEffect)(function () {
|
|
109
|
+
// if form reset
|
|
110
|
+
if (prevInputValue && props.input.value === undefined && selectedIds.length > 0) {
|
|
111
|
+
onReset();
|
|
112
|
+
}
|
|
113
|
+
}, [onReset, prevInputValue, props.input.value, selectedIds.length]);
|
|
114
|
+
var CheckboxFieldView = components.ui.getView('form.CheckboxFieldView');
|
|
115
|
+
var renderCheckbox = function (checkboxProps) { return (react_1["default"].createElement(CheckboxFieldView, __assign({}, checkboxProps))); };
|
|
116
|
+
return components.ui.renderView(props.view || 'form.CheckboxTreeFieldView', __assign(__assign({}, props), { items: treeItems, onItemSelect: onItemSelect, selectedIds: selectedIds, renderCheckbox: renderCheckbox }));
|
|
117
|
+
}
|
|
118
|
+
CheckboxTreeField.defaultProps = {
|
|
119
|
+
disabled: false,
|
|
120
|
+
required: false,
|
|
121
|
+
className: '',
|
|
122
|
+
levelPadding: 32,
|
|
123
|
+
alwaysOpened: false,
|
|
124
|
+
primaryKey: 'items'
|
|
125
|
+
};
|
|
126
|
+
exports["default"] = (0, fieldWrapper_1["default"])('CheckboxTreeField', CheckboxTreeField);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
var CheckboxTreeField_1 = __importDefault(require("./CheckboxTreeField"));
|
|
7
|
+
exports["default"] = CheckboxTreeField_1["default"];
|
|
@@ -48,7 +48,10 @@ DateField.defaultProps = {
|
|
|
48
48
|
required: false,
|
|
49
49
|
showRemove: true,
|
|
50
50
|
valueFormat: 'YYYY-MM-DD',
|
|
51
|
-
maskOptions: (0, kit_1.maskitoDateOptionsGenerator)({
|
|
51
|
+
maskOptions: (0, kit_1.maskitoDateOptionsGenerator)({
|
|
52
|
+
mode: 'dd/mm/yyyy',
|
|
53
|
+
separator: '.'
|
|
54
|
+
}),
|
|
52
55
|
size: 'md'
|
|
53
56
|
};
|
|
54
57
|
exports["default"] = (0, fieldWrapper_1["default"])('DateField', DateField);
|
|
@@ -9,6 +9,7 @@ interface IUseDateRangeProps extends Pick<IDateInputStateInput, 'displayFormat'
|
|
|
9
9
|
inputTo: any;
|
|
10
10
|
inputFrom: any;
|
|
11
11
|
useSmartFocus: boolean;
|
|
12
|
+
hasInitialFocus: boolean;
|
|
12
13
|
}
|
|
13
14
|
export default function useDateRange(props: IUseDateRangeProps): {
|
|
14
15
|
focus: "to" | "from";
|
|
@@ -16,12 +16,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
exports.__esModule = true;
|
|
17
17
|
var react_1 = require("react");
|
|
18
18
|
var react_use_1 = require("react-use");
|
|
19
|
+
var isNil_1 = __importDefault(require("lodash-es/isNil"));
|
|
19
20
|
var dayjs_1 = __importDefault(require("dayjs"));
|
|
20
21
|
var calendar_1 = require("@steroidsjs/core/utils/calendar");
|
|
21
22
|
function useDateRange(props) {
|
|
22
23
|
// Tracking focus for input being edited
|
|
23
24
|
var _a = (0, react_1.useState)('from'), focus = _a[0], setFocus = _a[1];
|
|
24
|
-
|
|
25
|
+
var isFirstMount = (0, react_use_1.useFirstMountState)();
|
|
26
|
+
// Refs to handle auto-focus
|
|
25
27
|
var valueFromRef = (0, react_1.useRef)('');
|
|
26
28
|
var valueToRef = (0, react_1.useRef)('');
|
|
27
29
|
// Close handler
|
|
@@ -57,6 +59,12 @@ function useDateRange(props) {
|
|
|
57
59
|
var prevValueFrom = (0, react_use_1.usePrevious)(props.inputFrom.value);
|
|
58
60
|
var prevValueTo = (0, react_use_1.usePrevious)(props.inputTo.value);
|
|
59
61
|
(0, react_1.useEffect)(function () {
|
|
62
|
+
if (!props.hasInitialFocus && isFirstMount) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if ((0, isNil_1["default"])(props.inputFrom.value) && (0, isNil_1["default"])(props.inputTo.value)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
60
68
|
if (props.useSmartFocus) {
|
|
61
69
|
if (focus === 'from' && !valueToRef.current && prevValueFrom !== props.inputFrom.value) {
|
|
62
70
|
valueFromRef.current = props.inputFrom.value;
|
|
@@ -67,8 +75,11 @@ function useDateRange(props) {
|
|
|
67
75
|
inputFromRef.current.focus();
|
|
68
76
|
}
|
|
69
77
|
}
|
|
78
|
+
else if (props.hasInitialFocus && isFirstMount) {
|
|
79
|
+
inputFromRef.current.focus();
|
|
80
|
+
}
|
|
70
81
|
// eslint-disable-next-line max-len
|
|
71
|
-
}, [focus, onClose, prevValueFrom, prevValueTo, props, props.inputFrom.onChange, props.inputFrom.value, props.inputTo.onChange, props.inputTo.value]);
|
|
82
|
+
}, [focus, isFirstMount, onClose, prevValueFrom, prevValueTo, props, props.inputFrom.onChange, props.inputFrom.value, props.inputTo.onChange, props.inputTo.value]);
|
|
72
83
|
// Swap start and end dates if start date is later than end date
|
|
73
84
|
(0, react_1.useEffect)(function () {
|
|
74
85
|
if (props.inputFrom.value
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MaskitoOptions } from '@maskito/core';
|
|
1
3
|
import { ICalendarProps } from '../../content/Calendar/Calendar';
|
|
2
4
|
import { IDateInputStateInput, IDateInputStateOutput } from '../DateField/useDateInputState';
|
|
3
5
|
import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../../form/Field/fieldWrapper';
|
|
@@ -22,7 +24,12 @@ export interface IDateRangeFieldProps extends IDateInputStateInput, Omit<IFieldW
|
|
|
22
24
|
attributeTo?: string;
|
|
23
25
|
/**
|
|
24
26
|
* Свойства для компонента DayPickerInput
|
|
25
|
-
* @example
|
|
27
|
+
* @example
|
|
28
|
+
* {
|
|
29
|
+
* dayPickerProps: {
|
|
30
|
+
* showWeekNumbers: true
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
26
33
|
*/
|
|
27
34
|
pickerProps?: any;
|
|
28
35
|
/**
|
|
@@ -62,6 +69,24 @@ export interface IDateRangeFieldProps extends IDateInputStateInput, Omit<IFieldW
|
|
|
62
69
|
* Свойства для компонента Calendar
|
|
63
70
|
*/
|
|
64
71
|
calendarProps?: ICalendarProps;
|
|
72
|
+
/**
|
|
73
|
+
* Устанавливать ли фокус и показывать календарь сразу после рендера страницы
|
|
74
|
+
* @example true
|
|
75
|
+
*/
|
|
76
|
+
hasInitialFocus?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Опции маски для полей
|
|
79
|
+
*/
|
|
80
|
+
maskOptions?: {
|
|
81
|
+
/**
|
|
82
|
+
* Опции маски для поля from
|
|
83
|
+
*/
|
|
84
|
+
from: MaskitoOptions;
|
|
85
|
+
/**
|
|
86
|
+
* Опции маски для поля to
|
|
87
|
+
*/
|
|
88
|
+
to: MaskitoOptions;
|
|
89
|
+
};
|
|
65
90
|
[key: string]: any;
|
|
66
91
|
}
|
|
67
92
|
export interface IDateRangeFieldViewProps extends IDateInputStateOutput, Omit<IFieldWrapperOutputProps, 'input'>, Pick<IDateRangeFieldProps, 'size' | 'icon' | 'errors' | 'showRemove' | 'calendarProps' | 'className' | 'disabled' | 'noBorder' | 'style'> {
|
|
@@ -69,6 +94,14 @@ export interface IDateRangeFieldViewProps extends IDateInputStateOutput, Omit<IF
|
|
|
69
94
|
inputPropsTo?: any;
|
|
70
95
|
errorsFrom?: string[];
|
|
71
96
|
errorsTo?: string[];
|
|
97
|
+
/**
|
|
98
|
+
* Ref для input элемента, который накладывает маску на поле from
|
|
99
|
+
*/
|
|
100
|
+
maskInputFromRef?: React.RefCallback<HTMLElement>;
|
|
101
|
+
/**
|
|
102
|
+
* Ref для input элемента, который накладывает маску на поле to
|
|
103
|
+
*/
|
|
104
|
+
maskInputFromTo?: React.RefCallback<HTMLElement>;
|
|
72
105
|
}
|
|
73
106
|
declare const _default: import("../../form/Field/fieldWrapper").FieldWrapperComponent<IDateRangeFieldProps>;
|
|
74
107
|
export default _default;
|
|
@@ -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'> {
|