@steroidsjs/core 3.0.0-beta.103 → 3.0.0-beta.105

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 (62) hide show
  1. package/components/HttpComponent.d.ts +4 -4
  2. package/components/JwtHttpComponent.d.ts +2 -2
  3. package/components/LocaleComponent.d.ts +5 -5
  4. package/components/ResourceComponent.d.ts +2 -2
  5. package/components/WebSocketComponent.d.ts +6 -6
  6. package/docs-autogen-result.json +10480 -4175
  7. package/en.json +119 -110
  8. package/hooks/useDataProvider.d.ts +17 -2
  9. package/hooks/useFile.d.ts +1 -0
  10. package/hooks/useFile.js +2 -0
  11. package/hooks/useList.d.ts +53 -8
  12. package/hooks/useList.js +1 -1
  13. package/package.json +2 -1
  14. package/ui/content/Accordion/Accordion.d.ts +5 -2
  15. package/ui/content/Alert/Alert.d.ts +5 -2
  16. package/ui/content/Badge/Badge.d.ts +5 -1
  17. package/ui/content/Calendar/Calendar.d.ts +6 -1
  18. package/ui/content/Card/Card.d.ts +31 -25
  19. package/ui/content/Chart/Chart.d.ts +10 -2
  20. package/ui/content/Chat/Chat.d.ts +24 -22
  21. package/ui/content/CopyToClipboard/CopyToClipboard.d.ts +3 -3
  22. package/ui/content/Detail/Detail.d.ts +15 -2
  23. package/ui/content/DropDown/DropDown.d.ts +1 -1
  24. package/ui/content/DropDown/DropDown.js +4 -4
  25. package/ui/content/Kanban/hooks/useKanban.d.ts +33 -26
  26. package/ui/form/CheckboxListField/CheckboxListField.d.ts +14 -2
  27. package/ui/form/DateField/useDateRange.d.ts +1 -0
  28. package/ui/form/DateField/useDateRange.js +8 -1
  29. package/ui/form/DateRangeField/DateRangeField.d.ts +11 -1
  30. package/ui/form/DateRangeField/DateRangeField.js +2 -0
  31. package/ui/form/DateTimeRangeField/DateTimeRangeField.d.ts +11 -1
  32. package/ui/form/DateTimeRangeField/DateTimeRangeField.js +2 -0
  33. package/ui/form/DropDownField/DropDownField.d.ts +19 -3
  34. package/ui/form/Field/Field.d.ts +9 -1
  35. package/ui/form/Field/Field.js +1 -1
  36. package/ui/form/Field/fieldWrapper.d.ts +9 -1
  37. package/ui/form/FieldList/FieldList.d.ts +5 -1
  38. package/ui/form/Form/Form.d.ts +21 -3
  39. package/ui/form/Form/Form.js +4 -1
  40. package/ui/form/ImageField/ImageField.d.ts +9 -1
  41. package/ui/form/InputField/InputField.d.ts +5 -2
  42. package/ui/form/NumberField/NumberField.js +34 -7
  43. package/ui/form/SliderField/SliderField.d.ts +10 -2
  44. package/ui/form/TimeRangeField/TimeRangeField.d.ts +10 -1
  45. package/ui/form/TimeRangeField/TimeRangeField.js +3 -1
  46. package/ui/layout/Tooltip/Tooltip.d.ts +4 -1
  47. package/ui/list/ControlsColumn/ControlsColumn.d.ts +16 -2
  48. package/ui/list/FlexGrid/FlexGrid.d.ts +11 -1
  49. package/ui/list/Grid/Grid.d.ts +42 -6
  50. package/ui/list/LayoutNames/LayoutNames.d.ts +11 -1
  51. package/ui/list/TreeTable/TreeTable.d.ts +39 -15
  52. package/ui/list/TreeTable/TreeTable.js +6 -3
  53. package/ui/modal/Modal/Modal.d.ts +7 -1
  54. package/ui/nav/Breadcrumbs/Breadcrumbs.d.ts +11 -1
  55. package/ui/nav/ButtonGroup/ButtonGroup.d.ts +13 -4
  56. package/ui/nav/Controls/Controls.d.ts +7 -1
  57. package/ui/nav/Nav/Nav.d.ts +15 -2
  58. package/ui/nav/Router/Router.js +3 -0
  59. package/ui/nav/Tree/Tree.d.ts +16 -2
  60. package/utils/calculateComponentAbsolutePosition.js +57 -21
  61. package/utils/form.d.ts +1 -0
  62. package/utils/form.js +16 -1
@@ -43,7 +43,12 @@ export interface ISliderFieldProps extends IFieldWrapperInputProps, IUiComponent
43
43
  * Метки на ползунке. В объекте '{'key: value'}' key определяет положение, а value определяет, что будет отображаться.
44
44
  * Если вы хотите задать стиль определенной точки метки, значением должен быть объект,
45
45
  * содержащий свойства style и label.
46
- * @example { min: 20, 40: 40, max: 100 }
46
+ * @example
47
+ * {
48
+ * min: 20,
49
+ * 40: 40,
50
+ * max: 100
51
+ * }
47
52
  */
48
53
  marks?: Record<string, {
49
54
  style: {
@@ -54,7 +59,10 @@ export interface ISliderFieldProps extends IFieldWrapperInputProps, IUiComponent
54
59
  /**
55
60
  * Функция, вызываемая после отпускания tip'а у слайдера (при событии onmouseup)
56
61
  * @see https://github.com/schrodinger/rc-slider
57
- * @example {() => console.log('Slider handler is released')}
62
+ * @example
63
+ * {
64
+ * () => console.log('Slider handler is released')
65
+ * }
58
66
  */
59
67
  onAfterChange?: (value: any) => void;
60
68
  [key: string]: any;
@@ -40,9 +40,18 @@ export interface ITimeRangeFieldProps extends IDateInputStateInput, Omit<IFieldW
40
40
  placeholder?: any;
41
41
  /**
42
42
  * Свойства для компонента DayPickerInput
43
- * @example {dayPickerProps: {showWeekNumbers: true}}
43
+ * @example
44
+ * {
45
+ * dayPickerProps: {
46
+ * showWeekNumbers: true
47
+ * }
44
48
  */
45
49
  pickerProps?: any;
50
+ /**
51
+ * Устанавливать ли фокус и показывать панель времени сразу после рендера страницы
52
+ * @example true
53
+ */
54
+ hasInitialFocus?: boolean;
46
55
  [key: string]: any;
47
56
  }
48
57
  export interface ITimeRangeFieldViewProps extends IDateInputStateOutput, Pick<ITimeRangeFieldProps, 'size' | 'errors' | 'showRemove' | 'className' | 'timePanelViewProps' | 'disabled' | 'style' | 'icon'>, Omit<IFieldWrapperOutputProps, 'input'> {
@@ -62,7 +62,8 @@ function TimeRangeField(props) {
62
62
  inputPropsTo: inputPropsTo,
63
63
  inputFrom: props.inputFrom,
64
64
  inputTo: props.inputTo,
65
- useSmartFocus: true
65
+ useSmartFocus: false,
66
+ hasInitialFocus: props.hasInitialFocus
66
67
  }), focus = _c.focus, onClose = _c.onClose, onClear = _c.onClear, extendedInputPropsFrom = _c.extendedInputPropsFrom, extendedInputPropsTo = _c.extendedInputPropsTo;
67
68
  var timePanelFromViewProps = (0, react_1.useMemo)(function () { return (__assign({ onNow: onNowFrom, onClose: onCloseFrom, value: inputPropsFrom.value, onSelect: inputPropsFrom.onChange }, props.timePanelViewProps)); }, [inputPropsFrom.onChange, inputPropsFrom.value, onCloseFrom, onNowFrom, props.timePanelViewProps]);
68
69
  var timePanelToViewProps = (0, react_1.useMemo)(function () { return (__assign({ onNow: onNowTo, onClose: onCloseTo, value: inputPropsTo.value, onSelect: inputPropsTo.onChange }, props.timePanelViewProps)); }, [inputPropsTo.onChange, inputPropsTo.value, onCloseTo, onNowTo, props.timePanelViewProps]);
@@ -73,6 +74,7 @@ TimeRangeField.defaultProps = {
73
74
  displayFormat: 'HH:mm',
74
75
  required: false,
75
76
  showRemove: true,
77
+ hasInitialFocus: false,
76
78
  type: 'text',
77
79
  valueFormat: 'HH:mm',
78
80
  useUTC: true,
@@ -72,7 +72,10 @@ export interface ITooltipProps {
72
72
  style?: ITooltipStylePosition;
73
73
  /**
74
74
  * Стили для позиционирования стрелки
75
- * @example {left: 10}
75
+ * @example
76
+ * {
77
+ * left: 10
78
+ * }
76
79
  */
77
80
  arrowPosition?: ITooltipArrowPosition;
78
81
  /**
@@ -17,13 +17,27 @@ export interface IControlsColumnProps {
17
17
  primaryKey?: string;
18
18
  /**
19
19
  * Коллекция с контролами
20
- * @example [{id: 'delete'}, {id: 'view', position: 'left'}]
20
+ * @example
21
+ * [
22
+ * {
23
+ * id: 'delete'
24
+ * },
25
+ * {
26
+ * id: 'view',
27
+ * position: 'left'
28
+ * }
29
+ * ]
21
30
  */
22
31
  controls?: IControlItem[] | ((item: any, primaryKey: string) => IControlItem[]);
23
32
  /**
24
33
  * Элемент, для которого будет отображаться список с контролами, в нём можно задать видимость контрола
25
34
  * с помощью свойства 'can' + _upperFirst(control.id)
26
- * @example {name: 'Ivan', work: 'development', canView: false}
35
+ * @example
36
+ * {
37
+ * name: 'Ivan',
38
+ * work: 'development',
39
+ * canView: false
40
+ * }
27
41
  */
28
42
  item?: any;
29
43
  /**
@@ -36,7 +36,17 @@ export interface IFlexGridItem {
36
36
  export interface IFlexGridProps extends IUiComponent {
37
37
  /**
38
38
  * Элементы FlexGrid
39
- * @example [{content: 'Block1', col: 4}, {content: 'Block2', col: 6}]
39
+ * @example
40
+ * [
41
+ * {
42
+ * content: 'Block1',
43
+ * col: 4
44
+ * },
45
+ * {
46
+ * content: 'Block2',
47
+ * col: 6
48
+ * }
49
+ * ]
40
50
  */
41
51
  items?: IFlexGridItem[];
42
52
  /**
@@ -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
  /**
@@ -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
  /**
@@ -1,11 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { IColumnViewProps, IGridColumn, IGridProps } from '../Grid/Grid';
3
3
  export interface ITreeColumnViewProps extends IColumnViewProps {
4
- item: {
5
- onTreeItemClick?: (uniqueId: string, item: {
6
- [key: string]: any;
7
- }) => void;
8
- [key: string]: any;
4
+ item: ITreeTableItem & {
5
+ uniqueId: string;
6
+ level: number;
7
+ isOpened: boolean;
8
+ hasItems: boolean;
9
+ onClick: () => void;
9
10
  };
10
11
  }
11
12
  export interface ITreeTableItem {
@@ -15,14 +16,15 @@ export interface ITreeTableItem {
15
16
  id?: string | number;
16
17
  /**
17
18
  * Вложенные элементы
18
- * @example items: [{id: 3, name: 'Ivan'}]
19
+ * @example
20
+ * items: [
21
+ * {
22
+ * id: 3,
23
+ * name: 'Ivan'
24
+ * }
25
+ * ]
19
26
  */
20
- items?: any[];
21
- /**
22
- * Уникальный идентификатор,
23
- * используется для сохранения состояния открыта или закрыта ячейка
24
- */
25
- uniqueId?: string;
27
+ items?: ITreeTableItem[];
26
28
  }
27
29
  /**
28
30
  * TreeTable
@@ -32,9 +34,31 @@ export interface ITreeTableItem {
32
34
  export interface ITreeTableProps extends Omit<IGridProps, 'items'> {
33
35
  /**
34
36
  * Элементы коллекции
35
- * @example [{id: 1, name: 'Jane'}, {id: 2, name: 'John', items: [...]}]
37
+ * @example
38
+ * [
39
+ * {
40
+ * id: 1,
41
+ * name: 'Jane'
42
+ * },
43
+ * {
44
+ * id: 2,
45
+ * name: 'John',
46
+ * items: [...]
47
+ * }
48
+ * ]
36
49
  */
37
50
  items?: ITreeTableItem[];
51
+ /**
52
+ * Расстояние вложенных элементов от родителя для каждого уровня
53
+ * @example 32
54
+ */
55
+ levelPadding?: number | string;
56
+ }
57
+ export declare const addTreeColumnFieldsToFirstColumn: (columns: IGridColumn[], levelPadding: string | number) => IGridColumn[];
58
+ declare function TreeTable(props: ITreeTableProps): JSX.Element;
59
+ declare namespace TreeTable {
60
+ var defaultProps: {
61
+ levelPadding: number;
62
+ };
38
63
  }
39
- export declare const addTreeColumnFieldsToFirstColumn: (columns: IGridColumn[]) => IGridColumn[];
40
- export default function TreeTable(props: ITreeTableProps): JSX.Element;
64
+ export default TreeTable;
@@ -55,15 +55,18 @@ var TREE_COLUMN_VIEW_FIELDS = {
55
55
  valueView: 'TreeColumnView',
56
56
  headerClassName: 'TreeColumnHeader'
57
57
  };
58
- var addTreeColumnFieldsToFirstColumn = function (columns) {
58
+ var addTreeColumnFieldsToFirstColumn = function (columns, levelPadding) {
59
59
  var newColumns = __spreadArray([], columns, true);
60
60
  // Add tree view to the first column
61
- (0, merge_1["default"])(newColumns[0], TREE_COLUMN_VIEW_FIELDS);
61
+ (0, merge_1["default"])(newColumns[0], __assign(__assign({}, TREE_COLUMN_VIEW_FIELDS), { levelPadding: levelPadding }));
62
62
  return newColumns;
63
63
  };
64
64
  exports.addTreeColumnFieldsToFirstColumn = addTreeColumnFieldsToFirstColumn;
65
65
  function TreeTable(props) {
66
- var columns = (0, react_1.useMemo)(function () { return (0, exports.addTreeColumnFieldsToFirstColumn)(props.columns); }, [props.columns]);
66
+ var columns = (0, react_1.useMemo)(function () { return (0, exports.addTreeColumnFieldsToFirstColumn)(props.columns, props.levelPadding); }, [props.columns, props.levelPadding]);
67
67
  return (React.createElement(Grid_1["default"], __assign({}, props, { columns: columns, items: props.items, itemsIndexing: false, hasTreeItems: true })));
68
68
  }
69
69
  exports["default"] = TreeTable;
70
+ TreeTable.defaultProps = {
71
+ levelPadding: 32
72
+ };
@@ -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
  /**
@@ -41,7 +41,10 @@ export interface INavItem extends IButtonProps {
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
  /**
@@ -69,7 +72,17 @@ export interface INavProps {
69
72
  /**
70
73
  * Коллекция с элементами навигации. Также можно передать идентификатор роута, тогда компонент найдет все
71
74
  * вложенные роуты и отобразит их в навигации.
72
- * @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'
73
86
  */
74
87
  items?: string | INavItem[];
75
88
  /**
@@ -175,6 +175,9 @@ function Router(props) {
175
175
  });
176
176
  var result = renderComponent(routeItem, activePath, __assign(__assign({}, routeProps), { children: children }));
177
177
  if (!result) {
178
+ if (children) {
179
+ return children;
180
+ }
178
181
  // eslint-disable-next-line no-console
179
182
  console.error('Not found component for route:', routeItem);
180
183
  }
@@ -7,7 +7,14 @@ export interface ITreeItem extends IButtonProps {
7
7
  id?: string | number;
8
8
  /**
9
9
  * Вложенные элементы
10
- * @example [{id: 2, label: 'Nested element', items: [...]}]
10
+ * @example
11
+ * [
12
+ * {
13
+ * id: 2,
14
+ * label: 'Nested element',
15
+ * items: [...]
16
+ * }
17
+ * ]
11
18
  */
12
19
  items?: any[];
13
20
  /**
@@ -29,7 +36,14 @@ export interface ITreeProps {
29
36
  /**
30
37
  * Коллекция с узлами. Также можно передать идентификатор роута, тогда компонент найдет все
31
38
  * вложенные роуты и отобразит их в виде дерева.
32
- * @example [{id: 1, label: 'Root', items: [...]}] | 'root'
39
+ * @example
40
+ * [
41
+ * {
42
+ * id: 1,
43
+ * label: 'Root',
44
+ * items: [...]
45
+ * }
46
+ * ] | 'root'
33
47
  */
34
48
  items?: ITreeItem[] | string;
35
49
  /**
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
+ /* eslint-disable implicit-arrow-linebreak */
3
4
  var useAbsolutePositioning_1 = require("../hooks/useAbsolutePositioning");
5
+ var isComponentBeyondTop = function (parentDimensions, componentSize, gap) {
6
+ return (parentDimensions.top - window.scrollY) <= Math.round(componentSize.height + gap);
7
+ };
8
+ var isComponentBeyondLeft = function (parentDimensions, componentSize, gap) {
9
+ return parentDimensions.left <= Math.round(componentSize.width + gap);
10
+ };
11
+ var isComponentBeyondRight = function (parentDimensions, componentSize, gap) {
12
+ return document.body.clientWidth - parentDimensions.right <= Math.round(componentSize.width + gap);
13
+ };
14
+ var isComponentBeyondBottom = function (parentDimensions, componentSize, gap) {
15
+ return (window.innerHeight - (parentDimensions.top + parentDimensions.height - window.scrollY)) <= Math.round(componentSize.height + gap);
16
+ };
4
17
  function calculateComponentAbsolutePosition(gap, position, parentRef, componentSize, arrowSize, hasAutoPositioning) {
5
18
  if (arrowSize === void 0) { arrowSize = null; }
6
19
  if (hasAutoPositioning === void 0) { hasAutoPositioning = true; }
@@ -17,10 +30,9 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
17
30
  case useAbsolutePositioning_1.Position.TOP:
18
31
  case useAbsolutePositioning_1.Position.TOP_LEFT:
19
32
  case useAbsolutePositioning_1.Position.TOP_RIGHT:
20
- // Проверка - выходит ли tooltip за верхний край страницы?
33
+ // Проверка - выходит ли component за верхний край страницы?
21
34
  // Если да - меняем позицию на bottom
22
- if (hasAutoPositioning
23
- && ((parentDimensions.top - window.scrollY) <= Math.round(componentSize.height + gap))) {
35
+ if (hasAutoPositioning && isComponentBeyondTop(parentDimensions, componentSize, gap)) {
24
36
  style.top = parentDimensions.top + parentDimensions.height;
25
37
  position = position.replace(useAbsolutePositioning_1.Position.TOP, useAbsolutePositioning_1.Position.BOTTOM);
26
38
  }
@@ -31,11 +43,9 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
31
43
  case useAbsolutePositioning_1.Position.BOTTOM:
32
44
  case useAbsolutePositioning_1.Position.BOTTOM_LEFT:
33
45
  case useAbsolutePositioning_1.Position.BOTTOM_RIGHT:
34
- /// Проверка - выходит ли tooltip за нижний край страницы?
46
+ /// Проверка - выходит ли component за нижний край страницы?
35
47
  // Если да - меняем позицию на top
36
- if (hasAutoPositioning
37
- && ((window.innerHeight - (parentDimensions.top + parentDimensions.height - window.scrollY))
38
- <= Math.round(componentSize.height + gap))) {
48
+ if (hasAutoPositioning && isComponentBeyondBottom(parentDimensions, componentSize, gap)) {
39
49
  style.top = parentDimensions.top - componentSize.height;
40
50
  position = position.replace(useAbsolutePositioning_1.Position.BOTTOM, useAbsolutePositioning_1.Position.TOP);
41
51
  }
@@ -46,9 +56,9 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
46
56
  case useAbsolutePositioning_1.Position.LEFT:
47
57
  case useAbsolutePositioning_1.Position.LEFT_TOP:
48
58
  case useAbsolutePositioning_1.Position.LEFT_BOTTOM:
49
- // Проверка - выходит ли tooltip за левый край страницы?
59
+ // Проверка - выходит ли component за левый край страницы?
50
60
  // Если да - меняем позицию на right
51
- if (hasAutoPositioning && (parentDimensions.left <= Math.round(componentSize.width + gap))) {
61
+ if (hasAutoPositioning && isComponentBeyondLeft(parentDimensions, componentSize, gap)) {
52
62
  style.left = parentDimensions.right;
53
63
  position = position.replace(useAbsolutePositioning_1.Position.LEFT, useAbsolutePositioning_1.Position.RIGHT);
54
64
  }
@@ -59,10 +69,9 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
59
69
  case useAbsolutePositioning_1.Position.RIGHT:
60
70
  case useAbsolutePositioning_1.Position.RIGHT_TOP:
61
71
  case useAbsolutePositioning_1.Position.RIGHT_BOTTOM:
62
- // Проверка - выходит ли tooltip за правый край страницы?
72
+ // Проверка - выходит ли component за правый край страницы?
63
73
  // Если да - меняем позицию на left
64
- if (hasAutoPositioning
65
- && (document.body.clientWidth - parentDimensions.right <= Math.round(componentSize.width + gap))) {
74
+ if (hasAutoPositioning && isComponentBeyondRight(parentDimensions, componentSize, gap)) {
66
75
  style.left = parentDimensions.left - componentSize.width;
67
76
  position = position.replace(useAbsolutePositioning_1.Position.RIGHT, useAbsolutePositioning_1.Position.LEFT);
68
77
  }
@@ -72,6 +81,31 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
72
81
  break;
73
82
  }
74
83
  // eslint-disable-next-line default-case
84
+ switch (position) {
85
+ case useAbsolutePositioning_1.Position.LEFT:
86
+ case useAbsolutePositioning_1.Position.LEFT_TOP:
87
+ case useAbsolutePositioning_1.Position.LEFT_BOTTOM:
88
+ // Проверка - выходит ли component после изменения позиции на left за левый край страницы?
89
+ // Если да - меняем позицию на bottom
90
+ if (hasAutoPositioning && isComponentBeyondLeft(parentDimensions, componentSize, gap)) {
91
+ style.left = null;
92
+ style.top = parentDimensions.top + parentDimensions.height;
93
+ position = useAbsolutePositioning_1.Position.BOTTOM;
94
+ }
95
+ break;
96
+ case useAbsolutePositioning_1.Position.RIGHT:
97
+ case useAbsolutePositioning_1.Position.RIGHT_TOP:
98
+ case useAbsolutePositioning_1.Position.RIGHT_BOTTOM:
99
+ // Проверка - выходит ли component после изменения позиции на right за правый край страницы?
100
+ // Если да - меняем позицию на bottom
101
+ if (hasAutoPositioning && isComponentBeyondRight(parentDimensions, componentSize, gap)) {
102
+ style.left = null;
103
+ style.top = parentDimensions.top + parentDimensions.height;
104
+ position = useAbsolutePositioning_1.Position.BOTTOM;
105
+ }
106
+ break;
107
+ }
108
+ // eslint-disable-next-line default-case
75
109
  switch (position) {
76
110
  case useAbsolutePositioning_1.Position.TOP:
77
111
  case useAbsolutePositioning_1.Position.BOTTOM:
@@ -80,7 +114,7 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
80
114
  break;
81
115
  case useAbsolutePositioning_1.Position.TOP_LEFT:
82
116
  case useAbsolutePositioning_1.Position.BOTTOM_LEFT:
83
- // Ширина tooltip больше родителя - стрелка на середину родителя
117
+ // Ширина component больше родителя - стрелка на середину родителя
84
118
  style.left = parentDimensions.left;
85
119
  if (arrowSize && (parentDimensions.width < componentSize.width)) {
86
120
  arrowPosition = { left: parentDimensions.width / 2 };
@@ -88,7 +122,7 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
88
122
  break;
89
123
  case useAbsolutePositioning_1.Position.TOP_RIGHT:
90
124
  case useAbsolutePositioning_1.Position.BOTTOM_RIGHT:
91
- // Ширина tooltip больше родителя - стрелка на середину родителя
125
+ // Ширина component больше родителя - стрелка на середину родителя
92
126
  style.left = parentDimensions.right - componentSize.width;
93
127
  if (arrowSize && (parentDimensions.width < componentSize.width)) {
94
128
  arrowPosition = {
@@ -118,13 +152,13 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
118
152
  }
119
153
  break;
120
154
  }
121
- // Проверка - при позиционировании top/bottom tooltip не выходит за пределы страницы по горизонтали
155
+ //Проверка - при позиционировании top/bottom component не выходит за пределы страницы по горизонтали
122
156
  if (position.includes('top') || position.includes('bottom')) {
123
157
  if (!position.includes('Left')
124
- && (style.left < 0 || parentDimensions.left <= Math.round((componentSize.width - parentDimensions.width) + gap))) {
158
+ && (parentDimensions.left <= Math.round((componentSize.width - parentDimensions.width) + gap))) {
125
159
  style.right = null;
126
160
  position = position.replace('Right', 'Left');
127
- // Если ширина tooltip больше ширины родителя - выставить стрелку на середину родителя
161
+ // Если ширина component больше ширины родителя - выставить стрелку на середину родителя
128
162
  if (parentDimensions.left < componentSize.width) {
129
163
  arrowPosition = { left: parentDimensions.width / 2 };
130
164
  }
@@ -144,15 +178,17 @@ function calculateComponentAbsolutePosition(gap, position, parentRef, componentS
144
178
  style.right = document.body.clientWidth - parentDimensions.right;
145
179
  }
146
180
  }
147
- // Проверка - при позиционировании left/right tooltip не выходит за пределы страницы по вертикали
181
+ // Проверка - при позиционировании left/right component не выходит за пределы страницы по вертикали
148
182
  if (position.includes('left') || position.includes('right')) {
149
183
  if (!position.includes('Top')
150
184
  && parentDimensions.top - window.scrollY <= Math.round((componentSize.height - parentDimensions.height) + gap)) {
151
185
  position = position.replace('Bottom', 'Top');
152
- if (parentDimensions.height < componentSize.height) {
153
- arrowPosition = { top: parentDimensions.height / 2 };
154
- }
155
186
  style.top = parentDimensions.top;
187
+ if (arrowSize && parentDimensions.height < componentSize.height) {
188
+ arrowPosition = {
189
+ top: parentDimensions.height / 2
190
+ };
191
+ }
156
192
  }
157
193
  else if (!position.includes('Bottom')
158
194
  && (window.innerHeight - (parentDimensions.top + parentDimensions.height - window.scrollY)