@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
|
@@ -7,18 +7,24 @@ export interface IKanbanConfig {
|
|
|
7
7
|
kanbanId?: string;
|
|
8
8
|
/**
|
|
9
9
|
* Коллекция с наименованиями и свойствами колонок в таблице
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
10
|
+
* @example
|
|
11
|
+
* [
|
|
12
|
+
* {
|
|
13
|
+
* id: 1,
|
|
14
|
+
* title: 'column 1',
|
|
15
|
+
* tasks: [
|
|
16
|
+
* {
|
|
17
|
+
* content: 'item 1',
|
|
18
|
+
* id: 1
|
|
19
|
+
* }
|
|
20
|
+
* ],
|
|
21
|
+
* },
|
|
22
|
+
* {
|
|
23
|
+
* id: 2,
|
|
24
|
+
* title: 'column 2',
|
|
25
|
+
* tasks: [],
|
|
26
|
+
* }
|
|
27
|
+
* ]
|
|
22
28
|
*/
|
|
23
29
|
columns: IKanbanColumn[];
|
|
24
30
|
/**
|
|
@@ -32,20 +38,21 @@ export interface IKanbanConfig {
|
|
|
32
38
|
/**
|
|
33
39
|
* Обработчик события окончания перетаскивания карточки или колонки
|
|
34
40
|
* В result передается объект с информацией о событии
|
|
35
|
-
* @example
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
41
|
+
* @example
|
|
42
|
+
* {
|
|
43
|
+
* draggableId: 1,
|
|
44
|
+
* type: 'task',
|
|
45
|
+
* source: {
|
|
46
|
+
* index: 0,
|
|
47
|
+
* droppableId: 2
|
|
48
|
+
* },
|
|
49
|
+
* reason: 'DROP',
|
|
50
|
+
* mode: 'FLUID',
|
|
51
|
+
* destination: {
|
|
52
|
+
* droppableId: 2,
|
|
53
|
+
* index: 1
|
|
54
|
+
* },
|
|
55
|
+
* combine: null
|
|
49
56
|
* }
|
|
50
57
|
*/
|
|
51
58
|
onDragEnd?: (result: IDragEndResult) => void;
|
package/ui/content/Menu/Menu.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
exports.__esModule = true;
|
|
6
|
+
var react_1 = require("react");
|
|
17
7
|
var useComponents_1 = __importDefault(require("../../../hooks/useComponents"));
|
|
18
8
|
function Menu(props) {
|
|
19
9
|
var components = (0, useComponents_1["default"])();
|
|
20
10
|
var MenuItemView = components.ui.getView(props.itemView || 'content.MenuItemView');
|
|
21
|
-
|
|
11
|
+
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
12
|
+
items: props.items,
|
|
13
|
+
dropDownProps: props.dropDownProps,
|
|
14
|
+
icon: props.icon,
|
|
15
|
+
className: props.className,
|
|
16
|
+
style: props.style,
|
|
17
|
+
itemView: MenuItemView
|
|
18
|
+
}); }, [MenuItemView, props.className, props.dropDownProps, props.icon, props.items, props.style]);
|
|
19
|
+
return components.ui.renderView(props.view || 'content.MenuView', viewProps);
|
|
22
20
|
}
|
|
23
21
|
exports["default"] = Menu;
|
|
@@ -1,19 +1,8 @@
|
|
|
1
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
2
|
exports.__esModule = true;
|
|
14
3
|
var hooks_1 = require("../../../hooks");
|
|
15
4
|
function Slider(props) {
|
|
16
5
|
var components = (0, hooks_1.useComponents)();
|
|
17
|
-
return components.ui.renderView(props.view || 'content.SliderView',
|
|
6
|
+
return components.ui.renderView(props.view || 'content.SliderView', props);
|
|
18
7
|
}
|
|
19
8
|
exports["default"] = Slider;
|
package/ui/content/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ import CopyToClipboard from './CopyToClipboard';
|
|
|
12
12
|
import Chart from './Chart';
|
|
13
13
|
import Slider from './Slider';
|
|
14
14
|
import CalendarSystem from './CalendarSystem';
|
|
15
|
-
|
|
15
|
+
import Chat from './Chat';
|
|
16
|
+
export { Avatar, AvatarGroup, Accordion, AccordionItem, Alert, Card, DropDown, Badge, Detail, DetailItem, Icon, Kanban, Menu, CopyToClipboard, Chart, Slider, CalendarSystem, Chat, };
|
package/ui/content/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.CalendarSystem = exports.Slider = exports.Chart = exports.CopyToClipboard = exports.Menu = exports.Kanban = exports.Icon = exports.DetailItem = exports.Detail = exports.Badge = exports.DropDown = exports.Card = exports.Alert = exports.AccordionItem = exports.Accordion = exports.AvatarGroup = exports.Avatar = void 0;
|
|
6
|
+
exports.Chat = exports.CalendarSystem = exports.Slider = exports.Chart = exports.CopyToClipboard = exports.Menu = exports.Kanban = exports.Icon = exports.DetailItem = exports.Detail = exports.Badge = exports.DropDown = exports.Card = exports.Alert = exports.AccordionItem = exports.Accordion = exports.AvatarGroup = exports.Avatar = void 0;
|
|
7
7
|
var Avatar_1 = require("./Avatar");
|
|
8
8
|
exports.Avatar = Avatar_1.Avatar;
|
|
9
9
|
exports.AvatarGroup = Avatar_1.AvatarGroup;
|
|
@@ -35,3 +35,5 @@ var Slider_1 = __importDefault(require("./Slider"));
|
|
|
35
35
|
exports.Slider = Slider_1["default"];
|
|
36
36
|
var CalendarSystem_1 = __importDefault(require("./CalendarSystem"));
|
|
37
37
|
exports.CalendarSystem = CalendarSystem_1["default"];
|
|
38
|
+
var Chat_1 = __importDefault(require("./Chat"));
|
|
39
|
+
exports.Chat = Chat_1["default"];
|
package/ui/crud/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import Crud from './Crud';
|
|
2
3
|
import { IRouteItem } from '../nav/Router/Router';
|
|
3
4
|
import { ICrudProps } from './Crud/Crud';
|
|
@@ -19,6 +20,7 @@ export declare const generateCrud: (routeId: string, props: ICrudGeneratorProps)
|
|
|
19
20
|
title?: string;
|
|
20
21
|
path: string;
|
|
21
22
|
exact?: boolean;
|
|
23
|
+
strict?: boolean;
|
|
22
24
|
redirectTo?: string | boolean;
|
|
23
25
|
component: any;
|
|
24
26
|
layout?: string;
|
|
@@ -32,4 +34,5 @@ export declare const generateCrud: (routeId: string, props: ICrudGeneratorProps)
|
|
|
32
34
|
[key: string]: IRouteItem;
|
|
33
35
|
};
|
|
34
36
|
preloadData?: (match: Record<string, any>) => (import("../../hooks/useFetch").IFetchConfig | import("../list/List/List").IListProps)[];
|
|
37
|
+
icon?: string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
35
38
|
};
|
|
@@ -94,7 +94,7 @@ function AutoCompleteField(props) {
|
|
|
94
94
|
}, [onClose, props.inputProps, props.isOpened]);
|
|
95
95
|
var inputProps = (0, react_1.useMemo)(function () {
|
|
96
96
|
var _a;
|
|
97
|
-
return (__assign(__assign({}, props.inputProps), { type: 'text', name: props.input.name,
|
|
97
|
+
return (__assign(__assign({}, props.inputProps), { type: 'text', name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', placeholder: props.placeholder, disabled: props.disabled, onChange: onChange, onBlur: onBlur }));
|
|
98
98
|
}, [onBlur, onChange, props.disabled, props.input.name, props.input.value, props.inputProps, props.placeholder]);
|
|
99
99
|
//Sync with form
|
|
100
100
|
(0, react_1.useEffect)(function () {
|
package/ui/form/Button/Button.js
CHANGED
|
@@ -52,9 +52,15 @@ function Button(props) {
|
|
|
52
52
|
? props.url
|
|
53
53
|
: (routePath ? (0, router_2.buildUrl)(routePath, props.toRouteParams) : null);
|
|
54
54
|
// Flags: isLoading, isFailed
|
|
55
|
-
var _a = (0, react_1.useState)({
|
|
55
|
+
var _a = (0, react_1.useState)({
|
|
56
|
+
isLoading: false,
|
|
57
|
+
isFailed: false
|
|
58
|
+
}), _b = _a[0], isLoading = _b.isLoading, isFailed = _b.isFailed, setStateFlags = _a[1];
|
|
56
59
|
React.useEffect(function () {
|
|
57
|
-
setStateFlags({
|
|
60
|
+
setStateFlags({
|
|
61
|
+
isLoading: props.isLoading,
|
|
62
|
+
isFailed: props.isFailed
|
|
63
|
+
});
|
|
58
64
|
}, [props.isLoading, props.isFailed]);
|
|
59
65
|
// Form submitting
|
|
60
66
|
var context = (0, react_1.useContext)(Form_1.FormContext);
|
|
@@ -29,6 +29,7 @@ export interface ICheckboxFieldViewProps extends ICheckboxFieldProps, IFieldWrap
|
|
|
29
29
|
checked: boolean;
|
|
30
30
|
onChange: (value: string | React.ChangeEvent) => void;
|
|
31
31
|
disabled: boolean;
|
|
32
|
+
required?: boolean;
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
declare const _default: import("../Field/fieldWrapper").FieldWrapperComponent<ICheckboxFieldProps>;
|
|
@@ -53,8 +53,8 @@ function CheckboxField(props) {
|
|
|
53
53
|
}, [props]);
|
|
54
54
|
var inputProps = (0, react_1.useMemo)(function () {
|
|
55
55
|
var _a, _b;
|
|
56
|
-
return (__assign({ name: (_a = props.input) === null || _a === void 0 ? void 0 : _a.name, type: 'checkbox', checked: !!((_b = props.input) === null || _b === void 0 ? void 0 : _b.value), onChange: onChangeHandler, disabled: props.disabled }, props.inputProps));
|
|
57
|
-
}, [onChangeHandler, props.disabled, (_a = props.input) === null || _a === void 0 ? void 0 : _a.name, (_b = props.input) === null || _b === void 0 ? void 0 : _b.value, props.inputProps]);
|
|
56
|
+
return (__assign({ name: (_a = props.input) === null || _a === void 0 ? void 0 : _a.name, type: 'checkbox', checked: !!((_b = props.input) === null || _b === void 0 ? void 0 : _b.value), onChange: onChangeHandler, disabled: props.disabled, required: props.required }, props.inputProps));
|
|
57
|
+
}, [onChangeHandler, props.disabled, (_a = props.input) === null || _a === void 0 ? void 0 : _a.name, (_b = props.input) === null || _b === void 0 ? void 0 : _b.value, props.inputProps, props.required]);
|
|
58
58
|
return components.ui.renderView(props.view || 'form.CheckboxFieldView', __assign(__assign({}, props), { inputProps: inputProps }));
|
|
59
59
|
}
|
|
60
60
|
CheckboxField.defaultProps = {
|
|
@@ -20,7 +20,7 @@ type CheckboxFieldListItems = string | ({
|
|
|
20
20
|
export interface ICheckboxListFieldProps extends IFieldWrapperInputProps, Omit<IDataProviderConfig, 'items'>, Omit<IDataSelectConfig, 'items'>, IUiComponent {
|
|
21
21
|
/**
|
|
22
22
|
* Свойства для элемента input
|
|
23
|
-
* @example {onKeyDown: ...}
|
|
23
|
+
* @example { onKeyDown: ... }
|
|
24
24
|
*/
|
|
25
25
|
inputProps?: any;
|
|
26
26
|
/**
|
|
@@ -29,9 +29,25 @@ export interface ICheckboxListFieldProps extends IFieldWrapperInputProps, Omit<I
|
|
|
29
29
|
orientation?: Orientation;
|
|
30
30
|
/**
|
|
31
31
|
* Коллекция элементов
|
|
32
|
-
* @example
|
|
32
|
+
* @example
|
|
33
|
+
* [
|
|
34
|
+
* {
|
|
35
|
+
* id: 1,
|
|
36
|
+
* label: 'Krasnoyarsk',
|
|
37
|
+
* color: 'red'
|
|
38
|
+
* },
|
|
39
|
+
* {
|
|
40
|
+
* id: 2,
|
|
41
|
+
* label: 'Moscow',
|
|
42
|
+
* color: 'purple'
|
|
43
|
+
* }
|
|
44
|
+
* ]
|
|
33
45
|
*/
|
|
34
46
|
items: CheckboxFieldListItems;
|
|
47
|
+
/**
|
|
48
|
+
* Кастомная вьюшка для элемента
|
|
49
|
+
*/
|
|
50
|
+
itemView?: CustomView;
|
|
35
51
|
[key: string]: any;
|
|
36
52
|
}
|
|
37
53
|
export interface ICheckboxListFieldViewProps extends IFieldWrapperOutputProps {
|
|
@@ -79,7 +79,7 @@ function CheckboxListField(props) {
|
|
|
79
79
|
onReset();
|
|
80
80
|
}
|
|
81
81
|
}, [onReset, prevInputValue, props.input.value, selectedIds.length]);
|
|
82
|
-
var CheckboxFieldView = components.ui.getView('form.CheckboxFieldView');
|
|
82
|
+
var CheckboxFieldView = props.itemView || components.ui.getView('form.CheckboxFieldView');
|
|
83
83
|
var renderCheckbox = function (checkboxProps) { return (React.createElement(CheckboxFieldView, __assign({}, checkboxProps))); };
|
|
84
84
|
return components.ui.renderView(props.view || 'form.CheckboxListFieldView', __assign(__assign({}, props), { items: items, inputProps: inputProps, onItemSelect: onItemSelect, selectedIds: selectedIds, renderCheckbox: renderCheckbox }));
|
|
85
85
|
}
|
|
@@ -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;
|