@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.
Files changed (168) hide show
  1. package/actions/notifications.js +7 -1
  2. package/actions/router.js +16 -2
  3. package/components/HttpComponent.d.ts +7 -7
  4. package/components/JwtHttpComponent.d.ts +2 -2
  5. package/components/LocaleComponent.d.ts +6 -6
  6. package/components/MetaComponent.d.ts +90 -1
  7. package/components/MetricsComponent.js +2 -1
  8. package/components/ResourceComponent.d.ts +4 -4
  9. package/components/UiComponent.d.ts +7 -7
  10. package/components/WebSocketComponent.d.ts +11 -11
  11. package/docs-autogen-result.json +15147 -6371
  12. package/en.json +151 -92
  13. package/hooks/index.d.ts +4 -3
  14. package/hooks/index.js +7 -5
  15. package/hooks/useAbsolutePositioning.js +0 -1
  16. package/hooks/useAddressBar.js +0 -1
  17. package/hooks/useApplication.js +8 -1
  18. package/hooks/useDataProvider.d.ts +17 -2
  19. package/hooks/useDataSelect.js +21 -4
  20. package/hooks/useFetch.js +6 -1
  21. package/hooks/useFile.d.ts +1 -0
  22. package/hooks/useFile.js +2 -0
  23. package/hooks/useList.d.ts +53 -14
  24. package/hooks/useList.js +31 -70
  25. package/hooks/useTree.d.ts +104 -0
  26. package/hooks/useTree.js +169 -0
  27. package/index.d.ts +3 -3
  28. package/package.json +94 -93
  29. package/reducers/router.d.ts +2 -1
  30. package/ui/content/Accordion/Accordion.d.ts +8 -5
  31. package/ui/content/Accordion/Accordion.js +6 -1
  32. package/ui/content/Accordion/AccordionItem.d.ts +2 -2
  33. package/ui/content/Accordion/AccordionItem.js +1 -12
  34. package/ui/content/Alert/Alert.d.ts +5 -2
  35. package/ui/content/Alert/Alert.js +13 -12
  36. package/ui/content/Avatar/Avatar.js +18 -12
  37. package/ui/content/Badge/Badge.d.ts +5 -1
  38. package/ui/content/Badge/Badge.js +14 -12
  39. package/ui/content/Calendar/Calendar.d.ts +6 -1
  40. package/ui/content/Calendar/Calendar.js +19 -12
  41. package/ui/content/CalendarSystem/CalendarSystem.d.ts +40 -18
  42. package/ui/content/CalendarSystem/CalendarSystem.js +65 -76
  43. package/ui/content/CalendarSystem/hooks/useCalendarControls.d.ts +1 -2
  44. package/ui/content/CalendarSystem/hooks/useCalendarControls.js +14 -17
  45. package/ui/content/CalendarSystem/hooks/useCalendarSystemEventGroupModals.js +11 -3
  46. package/ui/content/CalendarSystem/hooks/useCalendarSystemModals.js +2 -2
  47. package/ui/content/CalendarSystem/hooks/useCalendarType.d.ts +5 -0
  48. package/ui/content/CalendarSystem/hooks/useCalendarType.js +22 -0
  49. package/ui/content/CalendarSystem/hooks/useEventsFromDate.d.ts +5 -0
  50. package/ui/content/CalendarSystem/hooks/useEventsFromDate.js +49 -0
  51. package/ui/content/CalendarSystem/hooks/{useMonthCalendar.d.ts → useMonthGrid.d.ts} +4 -5
  52. package/ui/content/CalendarSystem/hooks/{useMonthCalendar.js → useMonthGrid.js} +24 -15
  53. package/ui/content/CalendarSystem/hooks/{useWeekCalendar.d.ts → useWeekGrid.d.ts} +6 -5
  54. package/ui/content/CalendarSystem/hooks/useWeekGrid.js +72 -0
  55. package/ui/content/CalendarSystem/utils/utils.d.ts +8 -0
  56. package/ui/content/CalendarSystem/utils/utils.js +27 -1
  57. package/ui/content/Card/Card.d.ts +33 -27
  58. package/ui/content/Card/Card.js +1 -12
  59. package/ui/content/Chart/Chart.d.ts +38 -8
  60. package/ui/content/Chart/Chart.js +16 -12
  61. package/ui/content/Chat/Chat.d.ts +90 -5
  62. package/ui/content/Chat/Chat.js +40 -14
  63. package/ui/content/Chat/constants/timeTemplatesAndUnits.d.ts +1 -0
  64. package/ui/content/Chat/constants/timeTemplatesAndUnits.js +2 -1
  65. package/ui/content/Chat/hooks/useChat.d.ts +5 -6
  66. package/ui/content/Chat/hooks/useChat.js +49 -3
  67. package/ui/content/Chat/utils/addNewMessageIntoGroupedMessages.d.ts +5 -0
  68. package/ui/content/Chat/utils/addNewMessageIntoGroupedMessages.js +61 -0
  69. package/ui/content/Chat/utils/getMessagesGroupedByDate.d.ts +1 -0
  70. package/ui/content/Chat/utils/getMessagesGroupedByDate.js +3 -2
  71. package/ui/content/Chat/utils/index.d.ts +4 -2
  72. package/ui/content/Chat/utils/index.js +6 -1
  73. package/ui/content/Chat/utils/isTodayMessage.d.ts +1 -0
  74. package/ui/content/Chat/utils/isTodayMessage.js +13 -0
  75. package/ui/content/CopyToClipboard/CopyToClipboard.d.ts +3 -3
  76. package/ui/content/CopyToClipboard/CopyToClipboard.js +10 -12
  77. package/ui/content/Dashboard/Dashboard.d.ts +5 -2
  78. package/ui/content/Dashboard/Dashboard.js +27 -3
  79. package/ui/content/Detail/Detail.d.ts +15 -2
  80. package/ui/content/Detail/Detail.js +12 -1
  81. package/ui/content/DropDown/DropDown.d.ts +1 -1
  82. package/ui/content/DropDown/DropDown.js +16 -4
  83. package/ui/content/Icon/Icon.js +13 -15
  84. package/ui/content/Kanban/Kanban.d.ts +15 -4
  85. package/ui/content/Kanban/Kanban.js +8 -12
  86. package/ui/content/Kanban/hooks/useKanban.d.ts +33 -26
  87. package/ui/content/Menu/Menu.js +10 -12
  88. package/ui/content/Slider/Slider.js +1 -12
  89. package/ui/crud/index.d.ts +3 -0
  90. package/ui/form/AutoCompleteField/AutoCompleteField.js +1 -1
  91. package/ui/form/Button/Button.js +8 -2
  92. package/ui/form/CheckboxField/CheckboxField.d.ts +1 -0
  93. package/ui/form/CheckboxField/CheckboxField.js +2 -2
  94. package/ui/form/CheckboxListField/CheckboxListField.d.ts +18 -2
  95. package/ui/form/CheckboxListField/CheckboxListField.js +1 -1
  96. package/ui/form/CheckboxTreeField/CheckboxTreeField.d.ts +67 -0
  97. package/ui/form/CheckboxTreeField/CheckboxTreeField.js +126 -0
  98. package/ui/form/CheckboxTreeField/index.d.ts +2 -0
  99. package/ui/form/CheckboxTreeField/index.js +7 -0
  100. package/ui/form/DateField/DateField.js +4 -1
  101. package/ui/form/DateField/useDateRange.d.ts +1 -0
  102. package/ui/form/DateField/useDateRange.js +13 -2
  103. package/ui/form/DateRangeField/DateRangeField.d.ts +34 -1
  104. package/ui/form/DateRangeField/DateRangeField.js +59 -8
  105. package/ui/form/DateTimeField/DateTimeField.d.ts +10 -0
  106. package/ui/form/DateTimeField/DateTimeField.js +11 -3
  107. package/ui/form/DateTimeRangeField/DateTimeRangeField.d.ts +25 -1
  108. package/ui/form/DateTimeRangeField/DateTimeRangeField.js +66 -13
  109. package/ui/form/DropDownField/DropDownField.d.ts +23 -3
  110. package/ui/form/DropDownField/DropDownField.js +1 -1
  111. package/ui/form/EmailField/EmailField.d.ts +6 -0
  112. package/ui/form/EmailField/EmailField.js +0 -4
  113. package/ui/form/Field/Field.d.ts +9 -1
  114. package/ui/form/Field/Field.js +1 -1
  115. package/ui/form/Field/fieldWrapper.d.ts +9 -1
  116. package/ui/form/FieldList/FieldList.d.ts +13 -7
  117. package/ui/form/FieldList/FieldList.js +30 -4
  118. package/ui/form/FileField/FileField.js +5 -0
  119. package/ui/form/Form/Form.d.ts +26 -3
  120. package/ui/form/Form/Form.js +5 -3
  121. package/ui/form/ImageField/ImageField.d.ts +9 -1
  122. package/ui/form/InputField/InputField.d.ts +5 -2
  123. package/ui/form/InputField/hooks/useInputFieldWarningByType.js +1 -0
  124. package/ui/form/NumberField/NumberField.js +34 -7
  125. package/ui/form/SliderField/SliderField.d.ts +10 -2
  126. package/ui/form/TimeRangeField/TimeRangeField.d.ts +10 -1
  127. package/ui/form/TimeRangeField/TimeRangeField.js +3 -1
  128. package/ui/form/WizardForm/WizardForm.d.ts +119 -0
  129. package/ui/form/WizardForm/WizardForm.js +167 -0
  130. package/ui/form/WizardForm/index.d.ts +2 -0
  131. package/ui/form/WizardForm/index.js +7 -0
  132. package/ui/form/WizardForm/utils.d.ts +12 -0
  133. package/ui/form/WizardForm/utils.js +111 -0
  134. package/ui/form/index.d.ts +3 -1
  135. package/ui/form/index.js +4 -1
  136. package/ui/layout/ProgressBar/ProgressBar.js +8 -2
  137. package/ui/layout/Skeleton/Skeleton.d.ts +3 -1
  138. package/ui/layout/Tooltip/Tooltip.d.ts +4 -1
  139. package/ui/list/ControlsColumn/ControlsColumn.d.ts +17 -3
  140. package/ui/list/FlexGrid/FlexGrid.d.ts +11 -1
  141. package/ui/list/Grid/Grid.d.ts +42 -6
  142. package/ui/list/Grid/Grid.js +1 -2
  143. package/ui/list/LayoutNames/LayoutNames.d.ts +11 -1
  144. package/ui/list/Steps/Steps.d.ts +19 -7
  145. package/ui/list/Steps/Steps.js +46 -26
  146. package/ui/list/TreeTable/TreeTable.d.ts +34 -33
  147. package/ui/list/TreeTable/TreeTable.js +19 -8
  148. package/ui/modal/Modal/Modal.d.ts +7 -1
  149. package/ui/nav/Breadcrumbs/Breadcrumbs.d.ts +11 -1
  150. package/ui/nav/ButtonGroup/ButtonGroup.d.ts +13 -4
  151. package/ui/nav/Controls/Controls.d.ts +7 -1
  152. package/ui/nav/Link/Link.d.ts +1 -1
  153. package/ui/nav/Nav/Nav.d.ts +19 -4
  154. package/ui/nav/Router/Router.d.ts +19 -3
  155. package/ui/nav/Router/Router.js +11 -6
  156. package/ui/nav/Router/helpers.d.ts +2 -2
  157. package/ui/nav/Router/helpers.js +39 -7
  158. package/ui/nav/Tree/Tree.d.ts +32 -62
  159. package/ui/nav/Tree/Tree.js +18 -165
  160. package/utils/calculateComponentAbsolutePosition.js +74 -24
  161. package/utils/calendar.d.ts +8 -0
  162. package/utils/calendar.js +76 -1
  163. package/utils/data.js +1 -0
  164. package/utils/form.d.ts +1 -0
  165. package/utils/form.js +16 -1
  166. package/ui/content/CalendarSystem/hooks/useWeekCalendar.js +0 -86
  167. package/utils/list.d.ts +0 -1
  168. package/utils/list.js +0 -5
@@ -18,7 +18,11 @@ export interface IGridColumn {
18
18
  attribute?: string;
19
19
  /**
20
20
  * Свойства для компонента форматирования
21
- * @example {component: DateFormatter, format: 'DD MMMM'}
21
+ * @example
22
+ * {
23
+ * component: DateFormatter,
24
+ * format: 'DD MMMM'
25
+ * }
22
26
  */
23
27
  formatter?: Record<string, any>;
24
28
  /**
@@ -74,7 +78,12 @@ export interface IGridColumn {
74
78
  subtitleAttribute?: string;
75
79
  /**
76
80
  * Параметры для ссылки в колонке
77
- * @example {attribute: 'name', linkProps: {target: 'blank'}, url: 'https://kozhindev.com'}
81
+ * @example
82
+ * {
83
+ * attribute: 'name',
84
+ * linkProps: {target: 'blank'},
85
+ * url: 'https://kozhindev.com'
86
+ * }
78
87
  */
79
88
  link?: {
80
89
  attribute: string;
@@ -83,7 +92,11 @@ export interface IGridColumn {
83
92
  };
84
93
  /**
85
94
  * Параметры для иконки в колонке
86
- * @example {attribute: 'icon', isLeft: true}
95
+ * @example
96
+ * {
97
+ * attribute: 'icon',
98
+ * isLeft: true
99
+ * }
87
100
  */
88
101
  icon?: {
89
102
  attribute: string;
@@ -91,7 +104,11 @@ export interface IGridColumn {
91
104
  };
92
105
  /**
93
106
  * Параметры для картинки в колонке
94
- * @example {attribute: 'icon', isLeft: true}
107
+ * @example
108
+ * {
109
+ * attribute: 'icon',
110
+ * isLeft: true
111
+ * }
95
112
  */
96
113
  picture?: {
97
114
  attribute: string;
@@ -122,13 +139,32 @@ export interface IGridProps extends IListConfig {
122
139
  view?: CustomView;
123
140
  /**
124
141
  * Коллекция с наименованиями и свойствами колонок в таблице
125
- * @example [{label: 'Name', attribute: 'name'}, {label: 'Work', attribute: 'work'}]
142
+ * @example
143
+ * [
144
+ * {
145
+ * label: 'Name',
146
+ * attribute: 'name'
147
+ * },
148
+ * {
149
+ * label: 'Work',
150
+ * attribute: 'work'
151
+ * }
152
+ * ]
126
153
  */
127
154
  columns: (string | IGridColumn)[];
128
155
  /**
129
156
  * Коллекция с элементами управления. Данная коллекция отобразится в колонке рядом с каждой записью в таблице.
130
157
  * Например, кнопки для удаления и детального просмотра записи.
131
- * @example [{id: 'delete'}, {id: 'view', position: 'left'}]
158
+ * @example
159
+ * [
160
+ * {
161
+ * id: 'delete'
162
+ * },
163
+ * {
164
+ * id: 'view',
165
+ * position: 'left'
166
+ * }
167
+ * ]
132
168
  */
133
169
  controls?: IControlItem[] | ((item: any, primaryKey: string) => IControlItem[]);
134
170
  /**
@@ -69,8 +69,7 @@ function Grid(props) {
69
69
  items: props.items,
70
70
  initialItems: props.initialItems,
71
71
  initialTotal: props.initialTotal,
72
- autoFetchOnFormChanges: props.autoFetchOnFormChanges,
73
- hasTreeItems: props.hasTreeItems
72
+ autoFetchOnFormChanges: props.autoFetchOnFormChanges
74
73
  }), list = _a.list, model = _a.model, searchModel = _a.searchModel, paginationPosition = _a.paginationPosition, paginationSizePosition = _a.paginationSizePosition, layoutNamesPosition = _a.layoutNamesPosition, renderList = _a.renderList, renderEmpty = _a.renderEmpty, renderPagination = _a.renderPagination, renderPaginationSize = _a.renderPaginationSize, renderLayoutNames = _a.renderLayoutNames, renderSearchForm = _a.renderSearchForm, onFetch = _a.onFetch, onSort = _a.onSort;
75
74
  var renderLabel = (0, react_1.useCallback)(function (column) {
76
75
  if (column.headerView) {
@@ -34,7 +34,17 @@ export interface ILayoutNamesProps {
34
34
  position?: ListControlPosition;
35
35
  /**
36
36
  * Коллекция с шаблонами
37
- * @example [{id: 'list', label: 'List'}, {id: 'grid', label: 'Grid'}]
37
+ * @example
38
+ * [
39
+ * {
40
+ * id: 'list',
41
+ * label: 'List'
42
+ * },
43
+ * {
44
+ * id: 'grid',
45
+ * label: 'Grid'
46
+ * }
47
+ * ]
38
48
  */
39
49
  items?: INavItem[];
40
50
  /**
@@ -2,34 +2,46 @@ import React from 'react';
2
2
  /**
3
3
  * Компонент Steps предоставляет шаги для выполнения определенного процесса.
4
4
  **/
5
- interface IStepsProps {
6
- stepItems: IStepItem[];
5
+ export interface IStepsProps extends IUiComponent {
6
+ stepItems: number | IStepItem[];
7
7
  currentStep: number;
8
8
  isChangeable?: boolean;
9
- className?: CssClassName;
10
9
  onChange?: (index: number) => void;
10
+ showDivider?: boolean;
11
+ stepTitleOrientation?: Orientation;
12
+ stepItemView?: React.ReactNode;
11
13
  }
12
14
  export interface IStepsViewProps {
13
15
  className?: CssClassName;
14
16
  children?: React.ReactNode;
15
17
  }
16
- export interface IStepItemViewProps {
18
+ export interface IStepItemViewProps extends Pick<IStepsProps, 'showDivider' | 'stepTitleOrientation' | 'onChange'>, IUiComponent {
17
19
  stepItem: IStepItem;
18
- className?: CssClassName;
19
20
  index: number;
20
21
  status: string;
21
22
  disabled: boolean;
22
- onChange: () => void;
23
+ showDivider?: boolean;
23
24
  }
24
25
  export interface IStepItem {
26
+ id: number;
25
27
  title?: string;
26
28
  subtitle?: string;
27
29
  description?: string;
30
+ status?: string;
28
31
  icon?: string | React.ReactNode;
29
32
  isError?: boolean;
30
33
  }
34
+ export declare const ERROR_STATUS = "error";
35
+ export declare const WAIT_STATUS = "wait";
36
+ export declare const ACTIVE_STATUS = "active";
37
+ export declare const FINISH_STATUS = "finish";
38
+ export declare const HORIZONTAL_STEP_LAYOUT = "horizontal";
39
+ export declare const VERTICAL_STEP_LAYOUT = "vertical";
31
40
  declare function Steps(props: IStepsProps): JSX.Element;
32
41
  declare namespace Steps {
33
- var defaultProps: {};
42
+ var defaultProps: {
43
+ showDivider: boolean;
44
+ stepTitleOrientation: string;
45
+ };
34
46
  }
35
47
  export default Steps;
@@ -1,38 +1,58 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  exports.__esModule = true;
6
+ exports.VERTICAL_STEP_LAYOUT = exports.HORIZONTAL_STEP_LAYOUT = exports.FINISH_STATUS = exports.ACTIVE_STATUS = exports.WAIT_STATUS = exports.ERROR_STATUS = void 0;
3
7
  var react_1 = require("react");
8
+ var range_1 = __importDefault(require("lodash-es/range"));
4
9
  var hooks_1 = require("../../../hooks");
10
+ exports.ERROR_STATUS = 'error';
11
+ exports.WAIT_STATUS = 'wait';
12
+ exports.ACTIVE_STATUS = 'active';
13
+ exports.FINISH_STATUS = 'finish';
14
+ exports.HORIZONTAL_STEP_LAYOUT = 'horizontal';
15
+ exports.VERTICAL_STEP_LAYOUT = 'vertical';
16
+ var getStepStatus = function (index, stepItem, currentStep) {
17
+ if (stepItem.isError) {
18
+ return exports.ERROR_STATUS;
19
+ }
20
+ if (currentStep < index) {
21
+ return exports.WAIT_STATUS;
22
+ }
23
+ if (currentStep === index) {
24
+ return exports.ACTIVE_STATUS;
25
+ }
26
+ return exports.FINISH_STATUS;
27
+ };
5
28
  function Steps(props) {
29
+ var components = (0, hooks_1.useComponents)();
6
30
  var _a = (0, react_1.useState)(false), isChangeable = _a[0], setIsChangeable = _a[1];
7
31
  (0, react_1.useEffect)(function () { return setIsChangeable(props.isChangeable); }, [props.isChangeable]);
8
- function getStepStatus(index, stepItem) {
9
- if (stepItem.isError) {
10
- return 'error';
11
- }
12
- if (props.currentStep < index) {
13
- return 'wait';
14
- }
15
- if (props.currentStep === index) {
16
- return 'active';
32
+ var toStep = (0, react_1.useCallback)(function (stepItem, index) { return components.ui.renderView(props.stepItemView || 'list.StepItemView', {
33
+ key: stepItem.id,
34
+ stepItem: stepItem,
35
+ index: index + 1,
36
+ status: (stepItem === null || stepItem === void 0 ? void 0 : stepItem.status) || getStepStatus(index, stepItem, props.currentStep),
37
+ disabled: !isChangeable,
38
+ showDivider: props.showDivider,
39
+ stepTitleOrientation: props.stepTitleOrientation,
40
+ onChange: function () {
41
+ if (isChangeable) {
42
+ props.onChange(index);
43
+ }
17
44
  }
18
- return 'finish';
19
- }
20
- return (0, hooks_1.useComponents)().ui.renderView('list.StepsView', {
45
+ }); }, [components.ui, isChangeable, props]);
46
+ return components.ui.renderView(props.view || 'list.StepsView', {
21
47
  className: props.className,
22
- children: props.stepItems.map(
23
- // eslint-disable-next-line react-hooks/rules-of-hooks
24
- function (stepItem, index) { return (0, hooks_1.useComponents)().ui.renderView('list.StepItemView', {
25
- stepItem: stepItem,
26
- index: index + 1,
27
- status: getStepStatus(index, stepItem),
28
- disabled: !isChangeable,
29
- onChange: function () {
30
- if (isChangeable) {
31
- props.onChange(index);
32
- }
33
- }
34
- }); })
48
+ children: (Array.isArray(props.stepItems)
49
+ ? props.stepItems
50
+ : (0, range_1["default"])(props.stepItems || 0))
51
+ .map(toStep)
35
52
  });
36
53
  }
37
- Steps.defaultProps = {};
38
54
  exports["default"] = Steps;
55
+ Steps.defaultProps = {
56
+ showDivider: true,
57
+ stepTitleOrientation: 'vertical'
58
+ };
@@ -1,39 +1,40 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
+ import { ITreeProps } from '@steroidsjs/core/ui/nav/Tree/Tree';
3
+ import { IPreparedTreeItem, ITreeItem } from '../../../hooks/useTree';
2
4
  import { IColumnViewProps, IGridColumn, IGridProps } from '../Grid/Grid';
3
- export interface ITreeColumnViewProps extends IColumnViewProps {
4
- item: {
5
- onTreeItemClick?: (uniqueId: string, item: {
6
- [key: string]: any;
7
- }) => void;
8
- [key: string]: any;
9
- };
10
- }
11
- export interface ITreeTableItem {
12
- /**
13
- * Идентификатор узла
14
- */
15
- id?: string | number;
16
- /**
17
- * Вложенные элементы
18
- * @example items: [{id: 3, name: 'Ivan'}]
19
- */
20
- items?: any[];
21
- /**
22
- * Уникальный идентификатор,
23
- * используется для сохранения состояния открыта или закрыта ячейка
24
- */
25
- uniqueId?: string;
26
- }
27
- export interface ITreeTableProps extends Omit<IGridProps, 'items'> {
28
- /**
29
- * Элементы коллекции
30
- * @example [{id: 1, name: 'Jane'}, {id: 2, name: 'John', items: [...]}]
31
- */
32
- items?: ITreeTableItem[];
5
+ export interface ITreeColumnViewProps extends IColumnViewProps, Pick<ITreeTableProps, 'levelPadding' | 'customIcon'> {
6
+ item: IPreparedTreeItem;
33
7
  }
34
- export declare const addTreeColumnFieldsToFirstColumn: (columns: IGridColumn[]) => IGridColumn[];
35
8
  /**
36
9
  * TreeTable
10
+ *
37
11
  * Компонент для представления данных коллекции в виде иерархической структуры.
38
12
  */
39
- export default function TreeTable(props: ITreeTableProps): JSX.Element;
13
+ export interface ITreeTableProps extends Omit<IGridProps, 'items'>, Pick<ITreeProps, 'alwaysOpened' | 'levelPadding' | 'customIcon'> {
14
+ /**
15
+ * Элементы коллекции
16
+ * @example
17
+ * [
18
+ * {
19
+ * id: 1,
20
+ * name: 'Jane'
21
+ * },
22
+ * {
23
+ * id: 2,
24
+ * name: 'John',
25
+ * items: [...]
26
+ * }
27
+ * ]
28
+ */
29
+ items?: ITreeItem[];
30
+ customIcon?: string | React.ReactElement;
31
+ }
32
+ export declare const addTreeColumnFieldsToFirstColumn: (columns: IGridColumn[], levelPadding: string | number, customIcon?: string | React.ReactElement) => IGridColumn[];
33
+ declare function TreeTable(props: ITreeTableProps): JSX.Element;
34
+ declare namespace TreeTable {
35
+ var defaultProps: {
36
+ levelPadding: number;
37
+ alwaysOpened: boolean;
38
+ };
39
+ }
40
+ export default TreeTable;
@@ -50,24 +50,35 @@ exports.addTreeColumnFieldsToFirstColumn = void 0;
50
50
  var React = __importStar(require("react"));
51
51
  var react_1 = require("react");
52
52
  var merge_1 = __importDefault(require("lodash-es/merge"));
53
+ var list_1 = require("@steroidsjs/core/reducers/list");
54
+ var useTree_1 = __importDefault(require("../../../hooks/useTree"));
53
55
  var Grid_1 = __importDefault(require("../Grid"));
56
+ var useSelector_1 = __importDefault(require("../../../hooks/useSelector"));
54
57
  var TREE_COLUMN_VIEW_FIELDS = {
55
58
  valueView: 'TreeColumnView',
56
59
  headerClassName: 'TreeColumnHeader'
57
60
  };
58
- var addTreeColumnFieldsToFirstColumn = function (columns) {
61
+ var addTreeColumnFieldsToFirstColumn = function (columns, levelPadding, customIcon) {
59
62
  var newColumns = __spreadArray([], columns, true);
60
63
  // Add tree view to the first column
61
- (0, merge_1["default"])(newColumns[0], TREE_COLUMN_VIEW_FIELDS);
64
+ (0, merge_1["default"])(newColumns[0], __assign(__assign({}, TREE_COLUMN_VIEW_FIELDS), { levelPadding: levelPadding, customIcon: customIcon }));
62
65
  return newColumns;
63
66
  };
64
67
  exports.addTreeColumnFieldsToFirstColumn = addTreeColumnFieldsToFirstColumn;
65
- /**
66
- * TreeTable
67
- * Компонент для представления данных коллекции в виде иерархической структуры.
68
- */
69
68
  function TreeTable(props) {
70
- var columns = (0, react_1.useMemo)(function () { return (0, exports.addTreeColumnFieldsToFirstColumn)(props.columns); }, [props.columns]);
71
- return (React.createElement(Grid_1["default"], __assign({}, props, { columns: columns, items: props.items, itemsIndexing: false, hasTreeItems: true })));
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
+ var list = (0, useSelector_1["default"])(function (state) { return (0, list_1.getList)(state, props.listId); });
71
+ var treeItems = (0, useTree_1["default"])({
72
+ items: props.items,
73
+ autoOpenLevels: 0,
74
+ alwaysOpened: props.alwaysOpened,
75
+ currentPage: list === null || list === void 0 ? void 0 : list.page,
76
+ itemsOnPage: list === null || list === void 0 ? void 0 : list.pageSize
77
+ }).treeItems;
78
+ return (React.createElement(Grid_1["default"], __assign({}, props, { columns: columns, items: treeItems, itemsIndexing: false })));
72
79
  }
73
80
  exports["default"] = TreeTable;
81
+ TreeTable.defaultProps = {
82
+ levelPadding: 32,
83
+ alwaysOpened: false
84
+ };
@@ -21,7 +21,13 @@ export interface IModalProps {
21
21
  componentProps?: any;
22
22
  /**
23
23
  * Коллекция кнопок, которая отобразится в нижней секции Modal
24
- * @example [{label: __(('Закрыть')), onClick: () => props.onClose()}]
24
+ * @example
25
+ * [
26
+ * {
27
+ * label: __(('Закрыть')),
28
+ * onClick: () => props.onClose()
29
+ * }
30
+ * ]
25
31
  */
26
32
  buttons?: IButtonProps[];
27
33
  /**
@@ -13,7 +13,17 @@ export interface IBreadcrumbsProps {
13
13
  className?: CssClassName;
14
14
  /**
15
15
  * Коллекция элементов навигационной цепочки
16
- * @example [{id: 'root', title: 'Home'}, {id: 'catalog', title: 'Catalog'}]
16
+ * @example
17
+ * [
18
+ * {
19
+ * id: 'root',
20
+ * title: 'Home'
21
+ * },
22
+ * {
23
+ * id: 'catalog',
24
+ * title: 'Catalog'
25
+ * }
26
+ * ]
17
27
  */
18
28
  items?: IRouteItem[];
19
29
  /**
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { Dispatch, SetStateAction } from 'react';
2
2
  import { IButtonProps } from '../../form/Button/Button';
3
3
  import { DataProviderItems } from '../../../hooks/useDataProvider';
4
4
  /**
@@ -9,14 +9,19 @@ import { DataProviderItems } from '../../../hooks/useDataProvider';
9
9
  export interface IButtonGroupProps extends IUiComponent {
10
10
  /**
11
11
  * Элементы для группы кнопок
12
- * @example ['button1', 'button2', 'button3']
12
+ * @example
13
+ * [
14
+ * 'button1',
15
+ * 'button2',
16
+ * 'button3'
17
+ * ]
13
18
  */
14
19
  items: DataProviderItems;
15
20
  /**
16
21
  * Функция, которая будет вызываться при клике по кнопке
17
22
  * @example setActiveTab
18
23
  */
19
- onClick: (value: number | string | boolean) => void;
24
+ onClick: ((value: number | string | boolean) => void) | Dispatch<SetStateAction<string | number | boolean>>;
20
25
  /**
21
26
  * При указании в связке с onClick предоставляет возможность реализовать two-way binding
22
27
  * @example 'button1'
@@ -28,7 +33,11 @@ export interface IButtonGroupProps extends IUiComponent {
28
33
  defaultActiveButton?: number | string;
29
34
  /**
30
35
  * Общие свойства для всех кнопок группы
31
- * @example {outline: true, color: 'secondary'}
36
+ * @example
37
+ * {
38
+ * outline: true,
39
+ * color: 'secondary'
40
+ * }
32
41
  */
33
42
  buttonProps?: IButtonProps;
34
43
  }
@@ -27,7 +27,13 @@ export interface IControlItem extends IButtonProps {
27
27
  export interface IControlsProps {
28
28
  /**
29
29
  * Коллекция контролов
30
- * @example [{id: 'delete', onClick: () => alert("It's deleted")}]
30
+ * @example
31
+ * [
32
+ * {
33
+ * id: 'delete',
34
+ * onClick: () => alert("It's deleted")
35
+ * }
36
+ * ]
31
37
  */
32
38
  items?: IControlItem[];
33
39
  /**
@@ -3,7 +3,7 @@ import { IButtonProps, IButtonViewProps } from '../../form/Button/Button';
3
3
  /**
4
4
  * Link
5
5
  *
6
- * Ссылка
6
+ * С помощью компонента `Link` вы можете легко настраивать цветовую схему элементов ссылок.
7
7
  */
8
8
  export interface ILinkProps extends IButtonProps {
9
9
  [key: string]: any;
@@ -35,13 +35,16 @@ export interface INavItem extends IButtonProps {
35
35
  */
36
36
  visible?: boolean;
37
37
  /**
38
- * Контент, который отобразиться, если элемент навигации будет активен
38
+ * Контент, который отобразится, если элемент навигации будет активен
39
39
  * @example ContentComponent
40
40
  */
41
41
  content?: any;
42
42
  /**
43
43
  * Свойства для компонента с контентом
44
- * @example {content: 'Some text'}
44
+ * @example
45
+ * {
46
+ * content: 'Some text'
47
+ * }
45
48
  */
46
49
  contentProps?: any;
47
50
  /**
@@ -56,7 +59,9 @@ export interface INavItem extends IButtonProps {
56
59
  }
57
60
  /**
58
61
  * Nav
59
- * Компонент навигации
62
+ *
63
+ * Компонент навигации позволяет переключаться между группами связанного контента.
64
+ *
60
65
  */
61
66
  export interface INavProps {
62
67
  /**
@@ -67,7 +72,17 @@ export interface INavProps {
67
72
  /**
68
73
  * Коллекция с элементами навигации. Также можно передать идентификатор роута, тогда компонент найдет все
69
74
  * вложенные роуты и отобразит их в навигации.
70
- * @example [{id: 1, label: 'One'}, {id: 2, label: 'Two'}] | 'root'
75
+ * @example
76
+ * [
77
+ * {
78
+ * id: 1,
79
+ * label: 'One'
80
+ * },
81
+ * {
82
+ * id: 2,
83
+ * label: 'Two'
84
+ * }
85
+ * ] | 'root'
71
86
  */
72
87
  items?: string | INavItem[];
73
88
  /**
@@ -31,12 +31,18 @@ export interface IRouteItem {
31
31
  * Путь до роута
32
32
  * @example '/catalog'
33
33
  */
34
- path?: string;
34
+ path: string;
35
35
  /**
36
36
  * Если true, то путь должен точно соответствовать location.pathname
37
37
  * @example '/catalog'
38
38
  */
39
39
  exact?: boolean;
40
+ /**
41
+ * Если true, то location.pathname будет совпадать с теми путями, которые содержат слеш в конце.
42
+ * Например, если указать путь '/catalog/', тогда совпадение будет с '/catalog/' и '/catalog/chapter', но не '/catalog'.
43
+ * @example '/catalog'
44
+ */
45
+ strict?: boolean;
40
46
  /**
41
47
  * В свойстве можно передать как путь, на который осуществится редирект, так и булево значение.
42
48
  * Если свойство равно true - то редирект произойдет на первый из вложенных роутов.
@@ -102,7 +108,11 @@ export interface IRouteItem {
102
108
  * @return {Array} Например, [{url: '/api/v1/some-data'}, {listId: 'someList', action: '/api/v1/some-list'}]
103
109
  */
104
110
  preloadData?: (match: Record<string, any>) => (IFetchConfig | IListProps)[];
105
- [key: string]: any;
111
+ /**
112
+ * Пользовательская иконка svg или название иконки
113
+ * @example 'circle'
114
+ */
115
+ icon?: React.ReactElement | string;
106
116
  }
107
117
  export interface IRouterProps {
108
118
  /**
@@ -118,7 +128,7 @@ export interface IRouterProps {
118
128
  * Дерево роутов
119
129
  * @example {id: 'root', path: '/', component: IndexPage, items: [...]}
120
130
  */
121
- routes?: IRouteItem[] | {
131
+ routes: IRouteItem[] | {
122
132
  [key: string]: IRouteItem;
123
133
  };
124
134
  /**
@@ -137,11 +147,17 @@ export interface IRouterProps {
137
147
  * @example SomeComponent
138
148
  */
139
149
  children?: React.ReactNode;
150
+ /**
151
+ * Флаг, который позволяет использовать вложенные роуты c указанием вложенного пути
152
+ * @example true
153
+ */
154
+ alwaysAppendParentRoutePath?: boolean;
140
155
  }
141
156
  declare function Router(props: IRouterProps): JSX.Element;
142
157
  declare namespace Router {
143
158
  var defaultProps: {
144
159
  autoScrollTop: boolean;
160
+ alwaysAppendParentRoutePath: boolean;
145
161
  };
146
162
  }
147
163
  export default Router;
@@ -80,9 +80,10 @@ var renderComponent = function (route, activePath, routeProps) {
80
80
  return (React.createElement(Component, __assign({}, routeProps, route.componentProps)));
81
81
  };
82
82
  function Router(props) {
83
+ var _a;
83
84
  var components = (0, hooks_1.useComponents)();
84
85
  var routeParams = (0, hooks_1.useSelector)(router_2.getRouteParams);
85
- var _a = (0, hooks_1.useSelector)(function (state) {
86
+ var _b = (0, hooks_1.useSelector)(function (state) {
86
87
  var _a, _b;
87
88
  return ({
88
89
  isInitialized: (0, router_2.isRouterInitialized)(state),
@@ -91,24 +92,24 @@ function Router(props) {
91
92
  activePath: (_b = (_a = state.router) === null || _a === void 0 ? void 0 : _a.location) === null || _b === void 0 ? void 0 : _b.pathname,
92
93
  activeRouteIds: (0, router_2.getActiveRouteIds)(state)
93
94
  });
94
- }), isInitialized = _a.isInitialized, pathname = _a.pathname, route = _a.route, activePath = _a.activePath, activeRouteIds = _a.activeRouteIds;
95
+ }), isInitialized = _b.isInitialized, pathname = _b.pathname, route = _b.route, activePath = _b.activePath, activeRouteIds = _b.activeRouteIds;
95
96
  var routeId = (route === null || route === void 0 ? void 0 : route.id) || null;
96
97
  // Init routes in redux
97
98
  var dispatch = (0, useDispatch_1["default"])();
98
99
  (0, react_use_1.useEffectOnce)(function () {
99
100
  if (props.routes) {
100
- dispatch((0, router_1.initRoutes)((0, helpers_1.walkRoutesRecursive)(__assign({ id: 'root' }, props.routes), props.defaultRoles ? { roles: props.defaultRoles } : undefined)));
101
+ dispatch((0, router_1.initRoutes)((0, helpers_1.walkRoutesRecursive)(__assign({ id: 'root' }, props.routes), props.defaultRoles ? { roles: props.defaultRoles } : undefined, {}, props.alwaysAppendParentRoutePath)));
101
102
  }
102
103
  });
103
104
  // Sync route params with redux
104
- var prevRouteParams = (0, react_use_1.usePreviousDistinct)(routeParams);
105
+ var prevRouteParams = (_a = (0, react_use_1.usePreviousDistinct)(routeParams)) !== null && _a !== void 0 ? _a : routeParams;
105
106
  (0, react_1.useEffect)(function () {
106
107
  if (!(0, isEqual_1["default"])(prevRouteParams, routeParams)) {
107
108
  dispatch((0, router_1.initParams)(routeParams));
108
109
  }
109
110
  }, [dispatch, prevRouteParams, routeParams]);
110
111
  // Routes state
111
- var _b = (0, react_1.useState)((0, helpers_1.treeToList)(props.routes)), routes = _b[0], setRoutes = _b[1];
112
+ var _c = (0, react_1.useState)((0, helpers_1.treeToList)(props.routes, true, null, props.alwaysAppendParentRoutePath)), routes = _c[0], setRoutes = _c[1];
112
113
  (0, react_use_1.useUpdateEffect)(function () {
113
114
  setRoutes(props.routes);
114
115
  }, [props.routes]);
@@ -175,6 +176,9 @@ function Router(props) {
175
176
  });
176
177
  var result = renderComponent(routeItem, activePath, __assign(__assign({}, routeProps), { children: children }));
177
178
  if (!result) {
179
+ if (children) {
180
+ return children;
181
+ }
178
182
  // eslint-disable-next-line no-console
179
183
  console.error('Not found component for route:', routeItem);
180
184
  }
@@ -202,6 +206,7 @@ function Router(props) {
202
206
  return (React.createElement(connected_react_router_1.ConnectedRouter, { history: components.store.history }, renderContent()));
203
207
  }
204
208
  Router.defaultProps = {
205
- autoScrollTop: true
209
+ autoScrollTop: true,
210
+ alwaysAppendParentRoutePath: true
206
211
  };
207
212
  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>;