@steroidsjs/core 3.0.0-beta.112 → 3.0.0-beta.114
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/router.js +19 -2
- package/docs-autogen-result.json +405 -130
- package/en.json +9 -1
- package/hooks/index.d.ts +3 -3
- package/hooks/index.js +5 -5
- package/hooks/useTree.d.ts +5 -0
- package/hooks/useTree.js +3 -2
- package/package.json +1 -1
- package/ui/content/CalendarSystem/CalendarSystem.d.ts +27 -16
- 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 +3 -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} +20 -14
- 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/Chat/Chat.d.ts +39 -1
- package/ui/content/Chat/Chat.js +32 -12
- package/ui/content/Chat/hooks/useChat.d.ts +2 -2
- package/ui/content/Chat/hooks/useChat.js +23 -6
- package/ui/form/CheckboxTreeField/CheckboxTreeField.d.ts +2 -3
- package/ui/form/CheckboxTreeField/CheckboxTreeField.js +3 -4
- package/ui/form/FileField/FileField.js +5 -0
- package/ui/list/TreeTable/TreeTable.d.ts +5 -4
- package/ui/list/TreeTable/TreeTable.js +3 -3
- package/ui/nav/Router/Router.d.ts +6 -0
- package/ui/nav/Router/Router.js +4 -3
- package/ui/nav/Router/helpers.d.ts +2 -2
- package/ui/nav/Router/helpers.js +41 -7
- package/ui/nav/Tree/Tree.d.ts +14 -3
- package/ui/nav/Tree/Tree.js +5 -2
- package/ui/content/CalendarSystem/hooks/useWeekCalendar.js +0 -86
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import DateControlEnum from '../enums/DateControlType';
|
|
2
|
-
declare const
|
|
3
|
-
|
|
2
|
+
declare const useWeekGrid: (currentMonthFirstDayDate: Date) => {
|
|
3
|
+
weekGridTwentyFourHoursArray: any[];
|
|
4
|
+
weekGridCurrentWeekDays: {
|
|
4
5
|
dayNumber: number;
|
|
5
6
|
date: Date;
|
|
6
7
|
outOfRange?: boolean;
|
|
7
8
|
isToday?: boolean;
|
|
8
9
|
formattedDisplay?: string;
|
|
9
10
|
}[];
|
|
10
|
-
|
|
11
|
+
weekGridControls: {
|
|
11
12
|
[key: string]: () => void | DateControlEnum;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
+
updateWeekOnMonthChange: (newMonthDate: Date) => void;
|
|
14
15
|
};
|
|
15
|
-
export default
|
|
16
|
+
export default useWeekGrid;
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
/* eslint-disable no-plusplus */
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var dayjs_1 = __importDefault(require("dayjs"));
|
|
9
|
+
var DateControlType_1 = __importDefault(require("../enums/DateControlType"));
|
|
10
|
+
var utils_1 = require("../utils/utils");
|
|
11
|
+
var ONE_DAY = 1;
|
|
12
|
+
var getTwentyFourHoursArray = function () {
|
|
13
|
+
var hoursArray = [];
|
|
14
|
+
for (var i = 0; i < 24; i++) {
|
|
15
|
+
var formattedHour = (0, dayjs_1["default"])().startOf('day').add(i, 'hour').format('HH:00');
|
|
16
|
+
hoursArray.push(formattedHour);
|
|
17
|
+
}
|
|
18
|
+
return hoursArray;
|
|
19
|
+
};
|
|
20
|
+
var useWeekGrid = function (currentMonthFirstDayDate) {
|
|
21
|
+
var _a;
|
|
22
|
+
var _b = react_1["default"].useState((0, utils_1.getFormattedWeekFromDate)()), currentWeek = _b[0], setCurrentWeek = _b[1];
|
|
23
|
+
var updateWeekOnMonthChange = react_1["default"].useCallback(function (newMonthDate) {
|
|
24
|
+
setCurrentWeek((0, utils_1.getFormattedWeekFromDate)(newMonthDate));
|
|
25
|
+
}, []);
|
|
26
|
+
var changeMonthAfterWeekChanged = react_1["default"].useCallback(function (formattedWeek) {
|
|
27
|
+
var firstDayOfWeek = formattedWeek[0].date;
|
|
28
|
+
var currentMonthNumber = currentMonthFirstDayDate.getMonth();
|
|
29
|
+
var isWeekOutOfMonth = formattedWeek.every(function (dayOfWeek) { return dayOfWeek.date.getMonth() !== currentMonthNumber; });
|
|
30
|
+
if (!isWeekOutOfMonth) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (currentMonthNumber - firstDayOfWeek.getMonth() === 1) {
|
|
34
|
+
var lastDayOfWeekInNewMonth = formattedWeek[formattedWeek.length - 1].date;
|
|
35
|
+
var prevMonthControl = (0, utils_1.getSourceCalendarControl)(DateControlType_1["default"].PREV_ONE);
|
|
36
|
+
prevMonthControl.click();
|
|
37
|
+
updateWeekOnMonthChange(lastDayOfWeekInNewMonth);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
var firstDayOfWeekInNewMonth = formattedWeek[0].date;
|
|
41
|
+
var nextMonthControl = (0, utils_1.getSourceCalendarControl)(DateControlType_1["default"].NEXT_ONE);
|
|
42
|
+
nextMonthControl.click();
|
|
43
|
+
updateWeekOnMonthChange(firstDayOfWeekInNewMonth);
|
|
44
|
+
}
|
|
45
|
+
}, [currentMonthFirstDayDate, updateWeekOnMonthChange]);
|
|
46
|
+
var setNextWeek = react_1["default"].useCallback(function () {
|
|
47
|
+
var lastDayOfWeek = currentWeek[currentWeek.length - 1].date;
|
|
48
|
+
lastDayOfWeek.setDate(lastDayOfWeek.getDate() + ONE_DAY);
|
|
49
|
+
var formattedNextWeek = (0, utils_1.getFormattedWeekFromDate)(lastDayOfWeek);
|
|
50
|
+
setCurrentWeek(formattedNextWeek);
|
|
51
|
+
changeMonthAfterWeekChanged(formattedNextWeek);
|
|
52
|
+
}, [currentWeek, changeMonthAfterWeekChanged]);
|
|
53
|
+
var setPrevWeek = react_1["default"].useCallback(function () {
|
|
54
|
+
var firstDayOfWeek = currentWeek[0].date;
|
|
55
|
+
firstDayOfWeek.setDate(firstDayOfWeek.getDate() - ONE_DAY);
|
|
56
|
+
var formattedPrevWeek = (0, utils_1.getFormattedWeekFromDate)(firstDayOfWeek);
|
|
57
|
+
setCurrentWeek(formattedPrevWeek);
|
|
58
|
+
changeMonthAfterWeekChanged(formattedPrevWeek);
|
|
59
|
+
}, [currentWeek, changeMonthAfterWeekChanged]);
|
|
60
|
+
return {
|
|
61
|
+
weekGridTwentyFourHoursArray: getTwentyFourHoursArray(),
|
|
62
|
+
weekGridCurrentWeekDays: currentWeek,
|
|
63
|
+
weekGridControls: (_a = {},
|
|
64
|
+
_a[DateControlType_1["default"].NEXT_DOUBLE] = DateControlType_1["default"].NEXT_ONE,
|
|
65
|
+
_a[DateControlType_1["default"].NEXT_ONE] = setNextWeek,
|
|
66
|
+
_a[DateControlType_1["default"].PREV_ONE] = setPrevWeek,
|
|
67
|
+
_a[DateControlType_1["default"].PREV_DOUBLE] = DateControlType_1["default"].PREV_ONE,
|
|
68
|
+
_a),
|
|
69
|
+
updateWeekOnMonthChange: updateWeekOnMonthChange
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
exports["default"] = useWeekGrid;
|
|
@@ -3,3 +3,11 @@ export declare const getWeekDaysFromDate: (date: Date) => IDay[];
|
|
|
3
3
|
export declare const isDateIsToday: (date: Date) => boolean;
|
|
4
4
|
export declare const getOmittedEvent: (event: IEvent | Omit<IEvent, 'color'>) => any;
|
|
5
5
|
export declare const sortEventsInGroup: (group: IEventGroup) => Omit<IEvent, "color">[];
|
|
6
|
+
export declare const getSourceCalendarControl: (control: string) => HTMLElement;
|
|
7
|
+
export declare const getFormattedWeekFromDate: (fromDate?: Date) => {
|
|
8
|
+
dayNumber: number;
|
|
9
|
+
date: Date;
|
|
10
|
+
outOfRange?: boolean;
|
|
11
|
+
isToday?: boolean;
|
|
12
|
+
formattedDisplay?: string;
|
|
13
|
+
}[];
|
|
@@ -1,14 +1,27 @@
|
|
|
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
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
5
16
|
exports.__esModule = true;
|
|
6
|
-
exports.sortEventsInGroup = exports.getOmittedEvent = exports.isDateIsToday = exports.getWeekDaysFromDate = void 0;
|
|
17
|
+
exports.getFormattedWeekFromDate = exports.getSourceCalendarControl = exports.sortEventsInGroup = exports.getOmittedEvent = exports.isDateIsToday = exports.getWeekDaysFromDate = void 0;
|
|
7
18
|
/* eslint-disable no-plusplus */
|
|
8
19
|
var dayjs_1 = __importDefault(require("dayjs"));
|
|
9
20
|
var omit_1 = __importDefault(require("lodash-es/omit"));
|
|
21
|
+
var calendar_1 = require("../../../../utils/calendar");
|
|
10
22
|
var SIX_DAYS_DIFF = 6;
|
|
11
23
|
var MAX_DAYS_DIFF_IN_WEEK = 7;
|
|
24
|
+
var WEEK_DAY_FORMAT = 'dd, D MMM';
|
|
12
25
|
var getWeekDaysFromDate = function (date) {
|
|
13
26
|
var weekDays = [];
|
|
14
27
|
var firstDayOfWeek = new Date(date);
|
|
@@ -32,3 +45,16 @@ var getOmittedEvent = function (event) { return (0, omit_1["default"])(event, ['
|
|
|
32
45
|
exports.getOmittedEvent = getOmittedEvent;
|
|
33
46
|
var sortEventsInGroup = function (group) { return group.events.sort(function (eventA, eventB) { return eventA.date.getTime() - eventB.date.getTime(); }); };
|
|
34
47
|
exports.sortEventsInGroup = sortEventsInGroup;
|
|
48
|
+
var getSourceCalendarControl = function (control) { return document.querySelector("[data-sourcecontrol=\"".concat(control, "\"]")); };
|
|
49
|
+
exports.getSourceCalendarControl = getSourceCalendarControl;
|
|
50
|
+
var getFormattedWeekFromDate = function (fromDate) {
|
|
51
|
+
if (fromDate === void 0) { fromDate = null; }
|
|
52
|
+
var currentWeek = (0, exports.getWeekDaysFromDate)(fromDate || new Date());
|
|
53
|
+
return currentWeek.map(function (dayOfWeek) {
|
|
54
|
+
var copyOfDayWeek = __assign({}, dayOfWeek);
|
|
55
|
+
copyOfDayWeek.formattedDisplay = (0, calendar_1.convertDate)(dayOfWeek.date, null, WEEK_DAY_FORMAT);
|
|
56
|
+
copyOfDayWeek.isToday = (0, exports.isDateIsToday)(copyOfDayWeek.date);
|
|
57
|
+
return copyOfDayWeek;
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.getFormattedWeekFromDate = getFormattedWeekFromDate;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IFileFieldProps } from '../../form/FileField/FileField';
|
|
2
3
|
import { IAvatarProps } from '../Avatar/Avatar';
|
|
3
4
|
import { IGroupedMessagesByDates } from './hooks/useChat';
|
|
4
5
|
export interface IChatUser {
|
|
@@ -7,11 +8,21 @@ export interface IChatUser {
|
|
|
7
8
|
lastName?: string;
|
|
8
9
|
avatar?: IAvatarProps;
|
|
9
10
|
}
|
|
11
|
+
export interface IMessageFile {
|
|
12
|
+
uid?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
size?: number;
|
|
15
|
+
url?: string;
|
|
16
|
+
downloadUrl?: string;
|
|
17
|
+
fullHeight?: number;
|
|
18
|
+
fullWidth?: number;
|
|
19
|
+
}
|
|
10
20
|
export interface IChatMessage {
|
|
11
21
|
id: number;
|
|
12
22
|
user: IChatUser;
|
|
13
23
|
text: string;
|
|
14
24
|
timestamp: Date | string;
|
|
25
|
+
files?: IMessageFile[];
|
|
15
26
|
}
|
|
16
27
|
/**
|
|
17
28
|
* Chat
|
|
@@ -31,6 +42,15 @@ export interface IChatProps extends IUiComponent {
|
|
|
31
42
|
* {
|
|
32
43
|
* id: 1,
|
|
33
44
|
* text: 'Всем привет!',
|
|
45
|
+
* files: [
|
|
46
|
+
* {
|
|
47
|
+
* id: 929,
|
|
48
|
+
* uid: 'c46f3d14-5891-4601-9e98-06f2c1e70a07',
|
|
49
|
+
* title: 'image.jpg',
|
|
50
|
+
* url: 'https://kozhin.dev/files/uploaded/c46f3d14-5891-4601-9e98-06f2c1e70a07.jpg',
|
|
51
|
+
* size: 47305,
|
|
52
|
+
* }
|
|
53
|
+
* ],
|
|
34
54
|
* user: {
|
|
35
55
|
* id: 1,
|
|
36
56
|
* firstName: 'Olga',
|
|
@@ -63,9 +83,27 @@ export interface IChatProps extends IUiComponent {
|
|
|
63
83
|
* Обработчик события отправки сообщения
|
|
64
84
|
*/
|
|
65
85
|
onSendMessage?: (chatId: string, message: IChatMessage) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Переопределение view React компонента для кастомизации отображения элемента инпута
|
|
88
|
+
* @example MyCustomView
|
|
89
|
+
*/
|
|
90
|
+
customChatInputView?: React.ReactNode;
|
|
91
|
+
/**
|
|
92
|
+
* Кастомный placeholder для инпута
|
|
93
|
+
*/
|
|
94
|
+
customInputPlaceholder?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Пропсы для инпута загрузки файлов
|
|
97
|
+
*/
|
|
98
|
+
fileFieldProps?: IFileFieldProps;
|
|
66
99
|
}
|
|
67
|
-
export interface IChatViewProps extends
|
|
100
|
+
export interface IChatViewProps extends Pick<IChatProps, 'currentUser'> {
|
|
68
101
|
groupedMessagesByDates: IGroupedMessagesByDates;
|
|
102
|
+
renderChatInput: () => JSX.Element;
|
|
103
|
+
}
|
|
104
|
+
export interface IChatInputViewProps extends Pick<IChatProps, 'chatId' | 'fileFieldProps'> {
|
|
69
105
|
onSendMessage: (data: any) => void;
|
|
106
|
+
onUploadFiles: (files: any) => void;
|
|
107
|
+
inputPlaceholder: string;
|
|
70
108
|
}
|
|
71
109
|
export default function Chat(props: IChatProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
package/ui/content/Chat/Chat.js
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
12
24
|
};
|
|
13
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
27
|
};
|
|
16
28
|
exports.__esModule = true;
|
|
29
|
+
var react_1 = __importStar(require("react"));
|
|
17
30
|
var hooks_1 = require("../../../hooks");
|
|
18
31
|
var useChat_1 = __importDefault(require("./hooks/useChat"));
|
|
19
32
|
function Chat(props) {
|
|
@@ -23,7 +36,14 @@ function Chat(props) {
|
|
|
23
36
|
messages: props.messages,
|
|
24
37
|
currentUser: props.currentUser,
|
|
25
38
|
onSendMessage: props.onSendMessage
|
|
26
|
-
}), onSendMessage = _a.onSendMessage, groupedMessagesByDates = _a.groupedMessagesByDates;
|
|
27
|
-
|
|
39
|
+
}), onSendMessage = _a.onSendMessage, onUploadFiles = _a.onUploadFiles, groupedMessagesByDates = _a.groupedMessagesByDates;
|
|
40
|
+
var ChatInputView = props.customChatInputView || components.ui.getView('content.ChatInputView');
|
|
41
|
+
var renderChatInput = (0, react_1.useCallback)(function () { return (react_1["default"].createElement(ChatInputView, { chatId: props.chatId, onSendMessage: onSendMessage, onUploadFiles: onUploadFiles, fileFieldProps: props.fileFieldProps, inputPlaceholder: props.customInputPlaceholder || __('Введите сообщение') })); }, [ChatInputView, onSendMessage, onUploadFiles, props.chatId, props.customInputPlaceholder, props.fileFieldProps]);
|
|
42
|
+
return components.ui.renderView(props.view || 'content.ChatView', {
|
|
43
|
+
currentUser: props.currentUser,
|
|
44
|
+
groupedMessagesByDates: groupedMessagesByDates,
|
|
45
|
+
onSendMessage: onSendMessage,
|
|
46
|
+
renderChatInput: renderChatInput
|
|
47
|
+
});
|
|
28
48
|
}
|
|
29
49
|
exports["default"] = Chat;
|
|
@@ -5,8 +5,8 @@ export interface IGroupedMessage extends IChatMessage {
|
|
|
5
5
|
isLastMessage?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export type IGroupedMessagesByDates = Record<string, IGroupedMessage[][]>;
|
|
8
|
-
|
|
8
|
+
export default function useChat(config: IChatConfig): {
|
|
9
9
|
groupedMessagesByDates: {};
|
|
10
10
|
onSendMessage: (rawMessage: any) => void;
|
|
11
|
+
onUploadFiles: (files: any) => void;
|
|
11
12
|
};
|
|
12
|
-
export default useChat;
|
|
@@ -17,25 +17,42 @@ exports.__esModule = true;
|
|
|
17
17
|
var react_1 = require("react");
|
|
18
18
|
var dayjs_1 = __importDefault(require("dayjs"));
|
|
19
19
|
var uniqueId_1 = __importDefault(require("lodash-es/uniqueId"));
|
|
20
|
+
var isEqual_1 = __importDefault(require("lodash-es/isEqual"));
|
|
21
|
+
var File_1 = __importDefault(require("fileup-core/lib/models/File"));
|
|
20
22
|
var hooks_1 = require("../../../../hooks");
|
|
21
23
|
var form_1 = require("../../../../actions/form");
|
|
22
24
|
var utils_1 = require("../utils");
|
|
23
25
|
var timeTemplatesAndUnits_1 = require("../constants/timeTemplatesAndUnits");
|
|
24
|
-
|
|
26
|
+
function useChat(config) {
|
|
27
|
+
var dispatch = (0, hooks_1.useDispatch)();
|
|
25
28
|
var _a = (0, react_1.useState)({}), groupedMessagesByDates = _a[0], setGroupedMessagesByDates = _a[1];
|
|
29
|
+
var _b = (0, react_1.useState)([]), uploadedFiles = _b[0], setUploadedFiles = _b[1];
|
|
26
30
|
(0, react_1.useEffect)(function () { return setGroupedMessagesByDates((0, utils_1.getMessagesGroupedByDate)(config.messages)); }, [config.messages]);
|
|
27
|
-
var
|
|
31
|
+
var onUploadFiles = (0, react_1.useCallback)(function (files) {
|
|
32
|
+
if (!(0, isEqual_1["default"])(uploadedFiles, files)) {
|
|
33
|
+
setUploadedFiles(files);
|
|
34
|
+
}
|
|
35
|
+
}, [uploadedFiles]);
|
|
28
36
|
var onSendMessage = (0, react_1.useCallback)(function (rawMessage) {
|
|
29
|
-
|
|
37
|
+
if (!rawMessage) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var newMessage = __assign(__assign({}, rawMessage), { id: (0, uniqueId_1["default"])(), user: config.currentUser, timestamp: (0, dayjs_1["default"])().format(timeTemplatesAndUnits_1.ISO_TIMESTAMP_TEMPLATE), files: (uploadedFiles === null || uploadedFiles === void 0 ? void 0 : uploadedFiles.reduce(function (acc, file) {
|
|
41
|
+
if (file.getResult() !== File_1["default"].RESULT_ERROR) {
|
|
42
|
+
acc.push(__assign({}, file._resultHttpMessage));
|
|
43
|
+
}
|
|
44
|
+
return acc;
|
|
45
|
+
}, [])) || null });
|
|
30
46
|
if (config.onSendMessage) {
|
|
31
47
|
config.onSendMessage(config.chatId, newMessage);
|
|
32
48
|
}
|
|
33
49
|
setGroupedMessagesByDates(function (prevGroupedMessagesByDates) { return (0, utils_1.addNewMessageIntoGroupedMessages)(newMessage, prevGroupedMessagesByDates); });
|
|
34
50
|
dispatch((0, form_1.formReset)(config.chatId));
|
|
35
|
-
}, [config, dispatch]);
|
|
51
|
+
}, [config, dispatch, uploadedFiles]);
|
|
36
52
|
return {
|
|
37
53
|
groupedMessagesByDates: groupedMessagesByDates,
|
|
38
|
-
onSendMessage: onSendMessage
|
|
54
|
+
onSendMessage: onSendMessage,
|
|
55
|
+
onUploadFiles: onUploadFiles
|
|
39
56
|
};
|
|
40
|
-
}
|
|
57
|
+
}
|
|
41
58
|
exports["default"] = useChat;
|
|
@@ -19,7 +19,7 @@ type CheckboxTreeItems = string | ({
|
|
|
19
19
|
*
|
|
20
20
|
* Список с вложенными чекбоксами. Используется в формах для создания иерархической структуры и выбора нескольких значений.
|
|
21
21
|
*/
|
|
22
|
-
export interface ICheckboxTreeFieldProps extends IFieldWrapperInputProps, Omit<IDataProviderConfig, 'items'>, Omit<IDataSelectConfig, 'items'>, IUiComponent, Pick<ITreeProps, 'levelPadding' | 'alwaysOpened'> {
|
|
22
|
+
export interface ICheckboxTreeFieldProps extends IFieldWrapperInputProps, Omit<IDataProviderConfig, 'items'>, Omit<IDataSelectConfig, 'items'>, IUiComponent, Pick<ITreeProps, 'levelPadding' | 'alwaysOpened' | 'showIcon' | 'customIcon'> {
|
|
23
23
|
/**
|
|
24
24
|
* Свойства для элемента input
|
|
25
25
|
* @example { onKeyDown: ... }
|
|
@@ -48,7 +48,7 @@ export interface ICheckboxTreeFieldProps extends IFieldWrapperInputProps, Omit<I
|
|
|
48
48
|
primaryKey?: string;
|
|
49
49
|
[key: string]: any;
|
|
50
50
|
}
|
|
51
|
-
export interface ICheckboxTreeFieldViewProps extends IFieldWrapperOutputProps {
|
|
51
|
+
export interface ICheckboxTreeFieldViewProps extends IFieldWrapperOutputProps, Pick<ITreeProps, 'levelPadding' | 'customIcon'> {
|
|
52
52
|
items: {
|
|
53
53
|
id: number | string | boolean;
|
|
54
54
|
label?: string;
|
|
@@ -61,7 +61,6 @@ export interface ICheckboxTreeFieldViewProps extends IFieldWrapperOutputProps {
|
|
|
61
61
|
onItemSelect: (checkbox: IPreparedTreeItem) => void;
|
|
62
62
|
renderCheckbox: (checkboxProps: ICheckboxFieldViewProps) => JSX.Element;
|
|
63
63
|
size?: Size;
|
|
64
|
-
levelPadding: number;
|
|
65
64
|
}
|
|
66
65
|
export declare const getNestedItemsIds: (item: any, groupAttribute: any) => any[];
|
|
67
66
|
declare const _default: import("../../../ui/form/Field/fieldWrapper").FieldWrapperComponent<ICheckboxTreeFieldProps>;
|
|
@@ -38,8 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
exports.__esModule = true;
|
|
40
40
|
exports.getNestedItemsIds = void 0;
|
|
41
|
-
var
|
|
42
|
-
var react_1 = require("react");
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
43
42
|
var react_use_1 = require("react-use");
|
|
44
43
|
var isArray_1 = __importDefault(require("lodash-es/isArray"));
|
|
45
44
|
var hooks_1 = require("../../../hooks");
|
|
@@ -113,8 +112,8 @@ function CheckboxTreeField(props) {
|
|
|
113
112
|
}
|
|
114
113
|
}, [onReset, prevInputValue, props.input.value, selectedIds.length]);
|
|
115
114
|
var CheckboxFieldView = components.ui.getView('form.CheckboxFieldView');
|
|
116
|
-
var renderCheckbox = function (checkboxProps) { return (
|
|
117
|
-
return components.ui.renderView(props.view || 'form.CheckboxTreeFieldView', __assign(__assign({}, props), { items: treeItems, onItemSelect: onItemSelect, selectedIds: selectedIds,
|
|
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 }));
|
|
118
117
|
}
|
|
119
118
|
CheckboxTreeField.defaultProps = {
|
|
120
119
|
disabled: false,
|
|
@@ -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) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { ITreeProps } from '@steroidsjs/core/ui/nav/Tree/Tree';
|
|
3
3
|
import { IPreparedTreeItem, ITreeItem } from '../../../hooks/useTree';
|
|
4
4
|
import { IColumnViewProps, IGridColumn, IGridProps } from '../Grid/Grid';
|
|
5
|
-
export interface ITreeColumnViewProps extends IColumnViewProps, Pick<ITreeTableProps, 'levelPadding'> {
|
|
5
|
+
export interface ITreeColumnViewProps extends IColumnViewProps, Pick<ITreeTableProps, 'levelPadding' | 'customIcon'> {
|
|
6
6
|
item: IPreparedTreeItem;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
@@ -10,7 +10,7 @@ export interface ITreeColumnViewProps extends IColumnViewProps, Pick<ITreeTableP
|
|
|
10
10
|
*
|
|
11
11
|
* Компонент для представления данных коллекции в виде иерархической структуры.
|
|
12
12
|
*/
|
|
13
|
-
export interface ITreeTableProps extends Omit<IGridProps, 'items'>, Pick<ITreeProps, 'alwaysOpened' | 'levelPadding'> {
|
|
13
|
+
export interface ITreeTableProps extends Omit<IGridProps, 'items'>, Pick<ITreeProps, 'alwaysOpened' | 'levelPadding' | 'customIcon'> {
|
|
14
14
|
/**
|
|
15
15
|
* Элементы коллекции
|
|
16
16
|
* @example
|
|
@@ -27,8 +27,9 @@ export interface ITreeTableProps extends Omit<IGridProps, 'items'>, Pick<ITreePr
|
|
|
27
27
|
* ]
|
|
28
28
|
*/
|
|
29
29
|
items?: ITreeItem[];
|
|
30
|
+
customIcon?: string | React.ReactElement;
|
|
30
31
|
}
|
|
31
|
-
export declare const addTreeColumnFieldsToFirstColumn: (columns: IGridColumn[], levelPadding: string | number) => IGridColumn[];
|
|
32
|
+
export declare const addTreeColumnFieldsToFirstColumn: (columns: IGridColumn[], levelPadding: string | number, customIcon?: string | React.ReactElement) => IGridColumn[];
|
|
32
33
|
declare function TreeTable(props: ITreeTableProps): JSX.Element;
|
|
33
34
|
declare namespace TreeTable {
|
|
34
35
|
var defaultProps: {
|
|
@@ -58,15 +58,15 @@ var TREE_COLUMN_VIEW_FIELDS = {
|
|
|
58
58
|
valueView: 'TreeColumnView',
|
|
59
59
|
headerClassName: 'TreeColumnHeader'
|
|
60
60
|
};
|
|
61
|
-
var addTreeColumnFieldsToFirstColumn = function (columns, levelPadding) {
|
|
61
|
+
var addTreeColumnFieldsToFirstColumn = function (columns, levelPadding, customIcon) {
|
|
62
62
|
var newColumns = __spreadArray([], columns, true);
|
|
63
63
|
// Add tree view to the first column
|
|
64
|
-
(0, merge_1["default"])(newColumns[0], __assign(__assign({}, TREE_COLUMN_VIEW_FIELDS), { levelPadding: levelPadding }));
|
|
64
|
+
(0, merge_1["default"])(newColumns[0], __assign(__assign({}, TREE_COLUMN_VIEW_FIELDS), { levelPadding: levelPadding, customIcon: customIcon }));
|
|
65
65
|
return newColumns;
|
|
66
66
|
};
|
|
67
67
|
exports.addTreeColumnFieldsToFirstColumn = addTreeColumnFieldsToFirstColumn;
|
|
68
68
|
function TreeTable(props) {
|
|
69
|
-
var columns = (0, react_1.useMemo)(function () { return (0, exports.addTreeColumnFieldsToFirstColumn)(props.columns, props.levelPadding); }, [props.columns, props.levelPadding]);
|
|
69
|
+
var columns = (0, react_1.useMemo)(function () { return (0, exports.addTreeColumnFieldsToFirstColumn)(props.columns, props.levelPadding, props.customIcon); }, [props.columns, props.customIcon, props.levelPadding]);
|
|
70
70
|
var list = (0, useSelector_1["default"])(function (state) { return (0, list_1.getList)(state, props.listId); });
|
|
71
71
|
var treeItems = (0, useTree_1["default"])({
|
|
72
72
|
items: props.items,
|
|
@@ -137,11 +137,17 @@ export interface IRouterProps {
|
|
|
137
137
|
* @example SomeComponent
|
|
138
138
|
*/
|
|
139
139
|
children?: React.ReactNode;
|
|
140
|
+
/**
|
|
141
|
+
* Флаг, который позволяет использовать вложенные роуты c указанием вложенного пути
|
|
142
|
+
* @example true
|
|
143
|
+
*/
|
|
144
|
+
alwaysAppendParentRoutePath?: boolean;
|
|
140
145
|
}
|
|
141
146
|
declare function Router(props: IRouterProps): JSX.Element;
|
|
142
147
|
declare namespace Router {
|
|
143
148
|
var defaultProps: {
|
|
144
149
|
autoScrollTop: boolean;
|
|
150
|
+
alwaysAppendParentRoutePath: boolean;
|
|
145
151
|
};
|
|
146
152
|
}
|
|
147
153
|
export default Router;
|
package/ui/nav/Router/Router.js
CHANGED
|
@@ -97,7 +97,7 @@ function Router(props) {
|
|
|
97
97
|
var dispatch = (0, useDispatch_1["default"])();
|
|
98
98
|
(0, react_use_1.useEffectOnce)(function () {
|
|
99
99
|
if (props.routes) {
|
|
100
|
-
dispatch((0, router_1.initRoutes)((0, helpers_1.walkRoutesRecursive)(__assign({ id: 'root' }, props.routes), props.defaultRoles ? { roles: props.defaultRoles } : undefined)));
|
|
100
|
+
dispatch((0, router_1.initRoutes)((0, helpers_1.walkRoutesRecursive)(__assign({ id: 'root' }, props.routes), props.defaultRoles ? { roles: props.defaultRoles } : undefined, {}, props.alwaysAppendParentRoutePath)));
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
// Sync route params with redux
|
|
@@ -108,7 +108,7 @@ function Router(props) {
|
|
|
108
108
|
}
|
|
109
109
|
}, [dispatch, prevRouteParams, routeParams]);
|
|
110
110
|
// Routes state
|
|
111
|
-
var _b = (0, react_1.useState)((0, helpers_1.treeToList)(props.routes)), routes = _b[0], setRoutes = _b[1];
|
|
111
|
+
var _b = (0, react_1.useState)((0, helpers_1.treeToList)(props.routes, true, null, props.alwaysAppendParentRoutePath)), routes = _b[0], setRoutes = _b[1];
|
|
112
112
|
(0, react_use_1.useUpdateEffect)(function () {
|
|
113
113
|
setRoutes(props.routes);
|
|
114
114
|
}, [props.routes]);
|
|
@@ -205,6 +205,7 @@ function Router(props) {
|
|
|
205
205
|
return (React.createElement(connected_react_router_1.ConnectedRouter, { history: components.store.history }, renderContent()));
|
|
206
206
|
}
|
|
207
207
|
Router.defaultProps = {
|
|
208
|
-
autoScrollTop: true
|
|
208
|
+
autoScrollTop: true,
|
|
209
|
+
alwaysAppendParentRoutePath: true
|
|
209
210
|
};
|
|
210
211
|
exports["default"] = Router;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IRouteItem } from './Router';
|
|
2
2
|
export declare const findRedirectPathRecursive: (route: IRouteItem) => any;
|
|
3
|
-
export declare const walkRoutesRecursive: (item: IRouteItem | Record<string, any>, defaultItem?: any, parentItem?: any) => any;
|
|
4
|
-
export declare const treeToList: (item: IRouteItem | Record<string, any>, isRoot?: boolean) => Record<string, any>;
|
|
3
|
+
export declare const walkRoutesRecursive: (item: IRouteItem | Record<string, any>, defaultItem?: any, parentItem?: any, alwaysAppendParentRoutePath?: boolean) => any;
|
|
4
|
+
export declare const treeToList: (item: IRouteItem | Record<string, any>, isRoot?: boolean, parentItem?: any, alwaysAppendParentRoutePath?: boolean) => Record<string, any>;
|
package/ui/nav/Router/helpers.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.treeToList = exports.walkRoutesRecursive = exports.findRedirectPathRecur
|
|
|
18
18
|
var get_1 = __importDefault(require("lodash-es/get"));
|
|
19
19
|
var isArray_1 = __importDefault(require("lodash-es/isArray"));
|
|
20
20
|
var isObject_1 = __importDefault(require("lodash-es/isObject"));
|
|
21
|
+
var SLASH = '/';
|
|
21
22
|
var findRedirectPathRecursive = function (route) {
|
|
22
23
|
if (!route) {
|
|
23
24
|
return null;
|
|
@@ -34,10 +35,36 @@ var findRedirectPathRecursive = function (route) {
|
|
|
34
35
|
: null;
|
|
35
36
|
};
|
|
36
37
|
exports.findRedirectPathRecursive = findRedirectPathRecursive;
|
|
37
|
-
var
|
|
38
|
+
var addSlashIfNotPresent = function (path) {
|
|
39
|
+
if (path === void 0) { path = ''; }
|
|
40
|
+
return path.startsWith(SLASH) ? path : (SLASH + path);
|
|
41
|
+
};
|
|
42
|
+
var joinChildAndParentPaths = function (path, parentPath) {
|
|
43
|
+
if (path === void 0) { path = ''; }
|
|
44
|
+
if (parentPath === void 0) { parentPath = null; }
|
|
45
|
+
if (!parentPath || parentPath === SLASH) {
|
|
46
|
+
return addSlashIfNotPresent(path);
|
|
47
|
+
}
|
|
48
|
+
return addSlashIfNotPresent(parentPath) + addSlashIfNotPresent(path);
|
|
49
|
+
};
|
|
50
|
+
var appendChildIfNoSlash = function (path, parentPath) {
|
|
51
|
+
if (path === void 0) { path = ''; }
|
|
52
|
+
if (parentPath === void 0) { parentPath = null; }
|
|
53
|
+
if (parentPath === SLASH) {
|
|
54
|
+
return addSlashIfNotPresent(path);
|
|
55
|
+
}
|
|
56
|
+
if (!path.startsWith(SLASH)) {
|
|
57
|
+
return addSlashIfNotPresent(parentPath) + addSlashIfNotPresent(path);
|
|
58
|
+
}
|
|
59
|
+
return path;
|
|
60
|
+
};
|
|
61
|
+
var walkRoutesRecursive = function (item, defaultItem, parentItem, alwaysAppendParentRoutePath) {
|
|
38
62
|
if (defaultItem === void 0) { defaultItem = {}; }
|
|
39
63
|
if (parentItem === void 0) { parentItem = {}; }
|
|
40
|
-
|
|
64
|
+
if (alwaysAppendParentRoutePath === void 0) { alwaysAppendParentRoutePath = true; }
|
|
65
|
+
var normalizedItem = __assign(__assign(__assign({}, defaultItem), item), { id: item.id, exact: item.exact, path: item.path && (alwaysAppendParentRoutePath
|
|
66
|
+
? joinChildAndParentPaths(item.path, parentItem.path)
|
|
67
|
+
: appendChildIfNoSlash(item.path, parentItem.path)), label: item.label, title: item.title, isVisible: typeof item.isVisible !== 'undefined'
|
|
41
68
|
? item.isVisible
|
|
42
69
|
: (typeof parentItem.isVisible !== 'undefined'
|
|
43
70
|
? parentItem.isVisible
|
|
@@ -48,32 +75,39 @@ var walkRoutesRecursive = function (item, defaultItem, parentItem) {
|
|
|
48
75
|
: defaultItem.isNavVisible), layout: item.layout || parentItem.layout || defaultItem.layout || null, roles: item.roles || parentItem.roles || defaultItem.roles || null, component: null, componentProps: null });
|
|
49
76
|
var items = null;
|
|
50
77
|
if ((0, isArray_1["default"])(item.items)) {
|
|
51
|
-
items = item.items.map(function (subItem) { return (0, exports.walkRoutesRecursive)(subItem, defaultItem, normalizedItem); });
|
|
78
|
+
items = item.items.map(function (subItem) { return (0, exports.walkRoutesRecursive)(subItem, defaultItem, normalizedItem, alwaysAppendParentRoutePath); });
|
|
52
79
|
}
|
|
53
80
|
else if ((0, isObject_1["default"])(item.items)) {
|
|
54
81
|
items = Object.keys(item.items)
|
|
55
|
-
.map(function (id) { return (0, exports.walkRoutesRecursive)(__assign(__assign({}, item.items[id]), { id: id }), defaultItem, normalizedItem); });
|
|
82
|
+
.map(function (id) { return (0, exports.walkRoutesRecursive)(__assign(__assign({}, item.items[id]), { id: id }), defaultItem, normalizedItem, alwaysAppendParentRoutePath); });
|
|
56
83
|
}
|
|
57
84
|
return __assign(__assign({}, normalizedItem), { items: items });
|
|
58
85
|
};
|
|
59
86
|
exports.walkRoutesRecursive = walkRoutesRecursive;
|
|
60
|
-
var treeToList = function (item, isRoot) {
|
|
87
|
+
var treeToList = function (item, isRoot, parentItem, alwaysAppendParentRoutePath) {
|
|
61
88
|
if (isRoot === void 0) { isRoot = true; }
|
|
89
|
+
if (parentItem === void 0) { parentItem = {}; }
|
|
90
|
+
if (alwaysAppendParentRoutePath === void 0) { alwaysAppendParentRoutePath = true; }
|
|
62
91
|
if ((0, isArray_1["default"])(item)) {
|
|
63
92
|
return item;
|
|
64
93
|
}
|
|
94
|
+
if (item.path) {
|
|
95
|
+
item.path = alwaysAppendParentRoutePath
|
|
96
|
+
? joinChildAndParentPaths(item.path, parentItem === null || parentItem === void 0 ? void 0 : parentItem.path)
|
|
97
|
+
: appendChildIfNoSlash(item.path, parentItem === null || parentItem === void 0 ? void 0 : parentItem.path);
|
|
98
|
+
}
|
|
65
99
|
if (isRoot && !item.id) {
|
|
66
100
|
item.id = 'root';
|
|
67
101
|
}
|
|
68
102
|
var items = item.path ? [item] : [];
|
|
69
103
|
if ((0, isArray_1["default"])(item.items)) {
|
|
70
104
|
item.items.forEach(function (subItem) {
|
|
71
|
-
items = items.concat((0, exports.treeToList)(subItem, false));
|
|
105
|
+
items = items.concat((0, exports.treeToList)(subItem, false, item, alwaysAppendParentRoutePath));
|
|
72
106
|
});
|
|
73
107
|
}
|
|
74
108
|
else if ((0, isObject_1["default"])(item.items)) {
|
|
75
109
|
Object.keys(item.items).forEach(function (id) {
|
|
76
|
-
items = items.concat((0, exports.treeToList)(__assign(__assign({}, item.items[id]), { id: id }), false));
|
|
110
|
+
items = items.concat((0, exports.treeToList)(__assign(__assign({}, item.items[id]), { id: id }), false, item, alwaysAppendParentRoutePath));
|
|
77
111
|
});
|
|
78
112
|
}
|
|
79
113
|
return items;
|