@megafon/ui-core 3.0.0-beta.6 → 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 (132) hide show
  1. package/CHANGELOG.md +51 -67
  2. package/dist/es/colors/Colors.d.ts +2 -2
  3. package/dist/es/components/Accordion/Accordion.css +1 -15
  4. package/dist/es/components/Accordion/Accordion.d.ts +11 -5
  5. package/dist/es/components/Accordion/Accordion.js +16 -14
  6. package/dist/es/components/Banner/Banner.css +28 -0
  7. package/dist/es/components/Banner/Banner.d.ts +12 -0
  8. package/dist/es/components/Banner/Banner.js +40 -21
  9. package/dist/es/components/Banner/BannerDot.d.ts +3 -0
  10. package/dist/es/components/Banner/BannerDot.js +8 -3
  11. package/dist/es/components/Button/Button.d.ts +8 -2
  12. package/dist/es/components/Button/Button.js +17 -9
  13. package/dist/es/components/Calendar/Calendar.js +3 -2
  14. package/dist/es/components/Calendar/components/Day/Day.js +1 -1
  15. package/dist/es/components/Carousel/Carousel.d.ts +9 -2
  16. package/dist/es/components/Carousel/Carousel.js +31 -22
  17. package/dist/es/components/Checkbox/Checkbox.d.ts +8 -2
  18. package/dist/es/components/Checkbox/Checkbox.js +13 -8
  19. package/dist/es/components/Collapse/Collapse.d.ts +15 -3
  20. package/dist/es/components/Collapse/Collapse.js +11 -4
  21. package/dist/es/components/Counter/Counter.js +3 -3
  22. package/dist/es/components/Header/Header.d.ts +5 -2
  23. package/dist/es/components/Header/Header.js +4 -2
  24. package/dist/es/components/InputLabel/InputLabel.d.ts +3 -0
  25. package/dist/es/components/InputLabel/InputLabel.js +9 -4
  26. package/dist/es/components/Link/Link.d.ts +7 -3
  27. package/dist/es/components/Link/Link.js +26 -10
  28. package/dist/es/components/Notification/Notification.d.ts +8 -0
  29. package/dist/es/components/Notification/Notification.js +21 -4
  30. package/dist/es/components/Pagination/Pagination.d.ts +9 -2
  31. package/dist/es/components/Pagination/Pagination.js +20 -3
  32. package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.d.ts +6 -3
  33. package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.js +12 -7
  34. package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +5 -2
  35. package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.js +10 -2
  36. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +5 -2
  37. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +6 -1
  38. package/dist/es/components/Pagination/helpers.d.ts +1 -1
  39. package/dist/es/components/Paragraph/Paragraph.css +0 -9
  40. package/dist/es/components/Paragraph/Paragraph.d.ts +4 -3
  41. package/dist/es/components/Paragraph/Paragraph.js +9 -7
  42. package/dist/es/components/Preloader/Preloader.d.ts +4 -0
  43. package/dist/es/components/Preloader/Preloader.js +10 -5
  44. package/dist/es/components/RadioButton/RadioButton.d.ts +7 -2
  45. package/dist/es/components/RadioButton/RadioButton.js +11 -7
  46. package/dist/es/components/Search/Search.js +4 -3
  47. package/dist/es/components/Select/Select.css +5 -2
  48. package/dist/es/components/Select/Select.d.ts +43 -50
  49. package/dist/es/components/Select/Select.js +374 -461
  50. package/dist/es/components/Select/reducer/selectReducer.d.ts +34 -0
  51. package/dist/es/components/Select/reducer/selectReducer.js +123 -0
  52. package/dist/es/components/Switcher/Switcher.css +19 -15
  53. package/dist/es/components/Switcher/Switcher.js +1 -1
  54. package/dist/es/components/Tabs/Tab.d.ts +5 -2
  55. package/dist/es/components/Tabs/Tab.js +4 -2
  56. package/dist/es/components/Tabs/Tabs.d.ts +10 -0
  57. package/dist/es/components/Tabs/Tabs.js +123 -70
  58. package/dist/es/components/TextField/TextField.d.ts +11 -1
  59. package/dist/es/components/TextField/TextField.js +36 -20
  60. package/dist/es/components/TextLink/TextLink.js +6 -1
  61. package/dist/es/components/Tile/Tile.d.ts +5 -2
  62. package/dist/es/components/Tile/Tile.js +2 -2
  63. package/dist/es/components/Tooltip/Tooltip.d.ts +5 -0
  64. package/dist/es/components/Tooltip/Tooltip.js +27 -19
  65. package/dist/es/index.d.ts +1 -0
  66. package/dist/es/index.js +1 -0
  67. package/dist/lib/colors/Colors.d.ts +2 -2
  68. package/dist/lib/components/Accordion/Accordion.css +1 -15
  69. package/dist/lib/components/Accordion/Accordion.d.ts +11 -5
  70. package/dist/lib/components/Accordion/Accordion.js +16 -14
  71. package/dist/lib/components/Banner/Banner.css +28 -0
  72. package/dist/lib/components/Banner/Banner.d.ts +12 -0
  73. package/dist/lib/components/Banner/Banner.js +40 -20
  74. package/dist/lib/components/Banner/BannerDot.d.ts +3 -0
  75. package/dist/lib/components/Banner/BannerDot.js +10 -2
  76. package/dist/lib/components/Button/Button.d.ts +8 -2
  77. package/dist/lib/components/Button/Button.js +17 -9
  78. package/dist/lib/components/Calendar/Calendar.js +3 -3
  79. package/dist/lib/components/Calendar/components/Day/Day.js +1 -1
  80. package/dist/lib/components/Carousel/Carousel.d.ts +9 -2
  81. package/dist/lib/components/Carousel/Carousel.js +29 -20
  82. package/dist/lib/components/Checkbox/Checkbox.d.ts +8 -2
  83. package/dist/lib/components/Checkbox/Checkbox.js +13 -8
  84. package/dist/lib/components/Collapse/Collapse.d.ts +15 -3
  85. package/dist/lib/components/Collapse/Collapse.js +13 -4
  86. package/dist/lib/components/Counter/Counter.js +3 -3
  87. package/dist/lib/components/Header/Header.d.ts +5 -2
  88. package/dist/lib/components/Header/Header.js +4 -2
  89. package/dist/lib/components/InputLabel/InputLabel.d.ts +3 -0
  90. package/dist/lib/components/InputLabel/InputLabel.js +11 -3
  91. package/dist/lib/components/Link/Link.d.ts +7 -3
  92. package/dist/lib/components/Link/Link.js +37 -23
  93. package/dist/lib/components/Notification/Notification.d.ts +8 -0
  94. package/dist/lib/components/Notification/Notification.js +20 -3
  95. package/dist/lib/components/Pagination/Pagination.d.ts +9 -2
  96. package/dist/lib/components/Pagination/Pagination.js +20 -2
  97. package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.d.ts +6 -3
  98. package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.js +12 -6
  99. package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +5 -2
  100. package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.js +9 -1
  101. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +5 -2
  102. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +6 -1
  103. package/dist/lib/components/Pagination/helpers.d.ts +1 -1
  104. package/dist/lib/components/Paragraph/Paragraph.css +0 -9
  105. package/dist/lib/components/Paragraph/Paragraph.d.ts +4 -3
  106. package/dist/lib/components/Paragraph/Paragraph.js +11 -6
  107. package/dist/lib/components/Preloader/Preloader.d.ts +4 -0
  108. package/dist/lib/components/Preloader/Preloader.js +10 -4
  109. package/dist/lib/components/RadioButton/RadioButton.d.ts +7 -2
  110. package/dist/lib/components/RadioButton/RadioButton.js +11 -7
  111. package/dist/lib/components/Search/Search.js +4 -3
  112. package/dist/lib/components/Select/Select.css +5 -2
  113. package/dist/lib/components/Select/Select.d.ts +43 -50
  114. package/dist/lib/components/Select/Select.js +368 -484
  115. package/dist/lib/components/Select/reducer/selectReducer.d.ts +34 -0
  116. package/dist/lib/components/Select/reducer/selectReducer.js +136 -0
  117. package/dist/lib/components/Switcher/Switcher.css +19 -15
  118. package/dist/lib/components/Switcher/Switcher.js +1 -1
  119. package/dist/lib/components/Tabs/Tab.d.ts +5 -2
  120. package/dist/lib/components/Tabs/Tab.js +4 -2
  121. package/dist/lib/components/Tabs/Tabs.d.ts +10 -0
  122. package/dist/lib/components/Tabs/Tabs.js +123 -70
  123. package/dist/lib/components/TextField/TextField.d.ts +11 -1
  124. package/dist/lib/components/TextField/TextField.js +34 -19
  125. package/dist/lib/components/TextLink/TextLink.js +6 -1
  126. package/dist/lib/components/Tile/Tile.d.ts +5 -2
  127. package/dist/lib/components/Tile/Tile.js +2 -2
  128. package/dist/lib/components/Tooltip/Tooltip.d.ts +5 -0
  129. package/dist/lib/components/Tooltip/Tooltip.js +26 -18
  130. package/dist/lib/index.d.ts +1 -0
  131. package/dist/lib/index.js +8 -0
  132. package/package.json +4 -4
@@ -0,0 +1,34 @@
1
+ import { ISelectItem, SelectItemValueType } from '../Select';
2
+ export declare const initialState: {
3
+ isOpened: boolean;
4
+ hoveredItemIndex: number;
5
+ itemsList: never[];
6
+ comparableInputValue: string;
7
+ inputValue: string;
8
+ };
9
+ export declare enum SelectActions {
10
+ TOGGLE_DROPDOWN = "TOGGLE_DROPDOWN",
11
+ UPDATE_ITEMS_LIST = "UPDATE_ITEMS_LIST",
12
+ UPDATE_VALUE_FROM_PROPS = "UPDATE_VALUE_FROM_PROPS",
13
+ UPDATE_SELECT_VALUE = "UPDATE_SELECT_VALUE",
14
+ SET_HOVERED_ITEM_INDEX = "SET_HOVERED_ITEM_INDEX",
15
+ COMBOBOX_VALUE_DEBOUNCE = "COMBOBOX_VALUE_DEBOUNCE",
16
+ COMBOBOX_INPUT_CHANGE = "COMBOBOX_INPUT_CHANGE"
17
+ }
18
+ export interface ISelectState<T extends SelectItemValueType> {
19
+ isOpened: boolean;
20
+ hoveredItemIndex: number;
21
+ itemsList: Array<ISelectItem<T>>;
22
+ comparableInputValue: string;
23
+ inputValue: string;
24
+ }
25
+ export interface ISelectAction<T extends SelectItemValueType> {
26
+ type: SelectActions;
27
+ items?: Array<ISelectItem<T>>;
28
+ hoveredItemIndex?: number;
29
+ inputValue?: string;
30
+ comparableInputValue?: string;
31
+ isOpened?: boolean;
32
+ }
33
+ declare const selectReducer: <T extends string | number | undefined>(state: ISelectState<T>, action: ISelectAction<T>) => ISelectState<T>;
34
+ export default selectReducer;
@@ -0,0 +1,123 @@
1
+ import "core-js/modules/es.array.every";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+
4
+ var isEqualItems = function isEqualItems(newItems, setItems) {
5
+ if (newItems.length !== setItems.length) {
6
+ return false;
7
+ }
8
+
9
+ return newItems.every(function (item, i) {
10
+ var isEqualValue = item.value === setItems[i].value;
11
+ var isEqualTitle = item.title === setItems[i].title;
12
+ return isEqualValue && isEqualTitle;
13
+ });
14
+ };
15
+
16
+ export var initialState = {
17
+ isOpened: false,
18
+ hoveredItemIndex: 0,
19
+ itemsList: [],
20
+ comparableInputValue: '',
21
+ inputValue: ''
22
+ };
23
+ export var SelectActions;
24
+
25
+ (function (SelectActions) {
26
+ SelectActions["TOGGLE_DROPDOWN"] = "TOGGLE_DROPDOWN";
27
+ SelectActions["UPDATE_ITEMS_LIST"] = "UPDATE_ITEMS_LIST";
28
+ SelectActions["UPDATE_VALUE_FROM_PROPS"] = "UPDATE_VALUE_FROM_PROPS";
29
+ SelectActions["UPDATE_SELECT_VALUE"] = "UPDATE_SELECT_VALUE";
30
+ SelectActions["SET_HOVERED_ITEM_INDEX"] = "SET_HOVERED_ITEM_INDEX";
31
+ SelectActions["COMBOBOX_VALUE_DEBOUNCE"] = "COMBOBOX_VALUE_DEBOUNCE";
32
+ SelectActions["COMBOBOX_INPUT_CHANGE"] = "COMBOBOX_INPUT_CHANGE";
33
+ })(SelectActions || (SelectActions = {}));
34
+
35
+ var _SelectActions = SelectActions,
36
+ TOGGLE_DROPDOWN = _SelectActions.TOGGLE_DROPDOWN,
37
+ UPDATE_ITEMS_LIST = _SelectActions.UPDATE_ITEMS_LIST,
38
+ UPDATE_VALUE_FROM_PROPS = _SelectActions.UPDATE_VALUE_FROM_PROPS,
39
+ UPDATE_SELECT_VALUE = _SelectActions.UPDATE_SELECT_VALUE,
40
+ SET_HOVERED_ITEM_INDEX = _SelectActions.SET_HOVERED_ITEM_INDEX,
41
+ COMBOBOX_VALUE_DEBOUNCE = _SelectActions.COMBOBOX_VALUE_DEBOUNCE,
42
+ COMBOBOX_INPUT_CHANGE = _SelectActions.COMBOBOX_INPUT_CHANGE;
43
+
44
+ var selectReducer = function selectReducer(state, action) {
45
+ var type = action.type,
46
+ _action$items = action.items,
47
+ items = _action$items === void 0 ? [] : _action$items,
48
+ _action$hoveredItemIn = action.hoveredItemIndex,
49
+ hoveredItemIndex = _action$hoveredItemIn === void 0 ? 0 : _action$hoveredItemIn,
50
+ _action$inputValue = action.inputValue,
51
+ inputValue = _action$inputValue === void 0 ? '' : _action$inputValue,
52
+ _action$comparableInp = action.comparableInputValue,
53
+ comparableInputValue = _action$comparableInp === void 0 ? '' : _action$comparableInp,
54
+ _action$isOpened = action.isOpened,
55
+ isOpened = _action$isOpened === void 0 ? false : _action$isOpened;
56
+ var prevItems = state.itemsList;
57
+
58
+ switch (type) {
59
+ case TOGGLE_DROPDOWN:
60
+ {
61
+ return _extends(_extends({}, state), {
62
+ isOpened: isOpened
63
+ });
64
+ }
65
+
66
+ case UPDATE_ITEMS_LIST:
67
+ {
68
+ var isItemsEqual = isEqualItems(items, prevItems);
69
+ return isItemsEqual ? state : _extends(_extends({}, state), {
70
+ itemsList: items
71
+ });
72
+ }
73
+
74
+ case UPDATE_VALUE_FROM_PROPS:
75
+ {
76
+ return _extends(_extends({}, state), {
77
+ hoveredItemIndex: hoveredItemIndex,
78
+ inputValue: inputValue,
79
+ comparableInputValue: ''
80
+ });
81
+ }
82
+
83
+ case COMBOBOX_VALUE_DEBOUNCE:
84
+ {
85
+ return _extends(_extends({}, state), {
86
+ comparableInputValue: comparableInputValue,
87
+ itemsList: items,
88
+ isOpened: true,
89
+ hoveredItemIndex: 0
90
+ });
91
+ }
92
+
93
+ case UPDATE_SELECT_VALUE:
94
+ {
95
+ return _extends(_extends({}, state), {
96
+ isOpened: false,
97
+ itemsList: items,
98
+ hoveredItemIndex: hoveredItemIndex
99
+ });
100
+ }
101
+
102
+ case SET_HOVERED_ITEM_INDEX:
103
+ {
104
+ return _extends(_extends({}, state), {
105
+ hoveredItemIndex: hoveredItemIndex
106
+ });
107
+ }
108
+
109
+ case COMBOBOX_INPUT_CHANGE:
110
+ {
111
+ return _extends(_extends({}, state), {
112
+ inputValue: inputValue
113
+ });
114
+ }
115
+
116
+ default:
117
+ {
118
+ return state;
119
+ }
120
+ }
121
+ };
122
+
123
+ export default selectReducer;
@@ -1,44 +1,48 @@
1
1
  .mfui-switcher {
2
2
  top: 22px;
3
3
  right: 28px;
4
- width: 40px;
5
- height: 24px;
4
+ width: 48px;
5
+ height: 28px;
6
+ border: 1px solid var(--stcBlack20);
6
7
  border-radius: 15.5px;
7
- background-color: var(--spbSky1);
8
+ background-color: var(--base);
8
9
  cursor: pointer;
9
10
  -webkit-transition: all 0.3s;
10
11
  transition: all 0.3s;
11
12
  }
12
- .mfui-switcher_no-touch:hover {
13
- background-color: var(--spbSky1);
14
- }
15
13
  .mfui-switcher__pointer {
16
14
  position: relative;
17
- top: 2px;
18
- left: 2px;
19
- width: 20px;
20
- height: 20px;
15
+ top: 1px;
16
+ left: 1px;
17
+ width: 24px;
18
+ height: 24px;
19
+ border: 1px solid var(--stcBlack20);
21
20
  border-radius: 50%;
22
21
  background-color: var(--base);
22
+ -webkit-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.05), 0 3px 1px rgba(0, 0, 0, 0.05);
23
+ box-shadow: 0 3px 3px rgba(0, 0, 0, 0.05), 0 3px 1px rgba(0, 0, 0, 0.05);
23
24
  -webkit-transition: all 0.3s;
24
25
  transition: all 0.3s;
25
26
  }
27
+ .mfui-switcher_no-touch:hover:not(.mfui-switcher_disabled) {
28
+ background-color: var(--spbSky1);
29
+ }
26
30
  .mfui-switcher_checked {
31
+ border-color: var(--brandGreen);
27
32
  background-color: var(--brandGreen);
28
33
  }
29
34
  .mfui-switcher_checked .mfui-switcher__pointer {
30
- left: 18px;
35
+ left: 21px;
31
36
  }
32
37
  .mfui-switcher_checked.mfui-switcher_no-touch:hover {
38
+ border-color: var(--buttonHoverGreen);
33
39
  background-color: var(--buttonHoverGreen);
34
40
  }
35
41
  .mfui-switcher_disabled {
36
42
  background-color: var(--spbSky1);
37
43
  cursor: default;
38
44
  }
39
- .mfui-switcher_disabled.mfui-switcher_checked.mfui-switcher_no-touch.mfui-switcher:hover {
40
- background-color: var(--spbSky1);
41
- }
42
- .mfui-switcher_disabled .mfui-switcher__pointer {
45
+ .mfui-switcher_disabled.mfui-switcher_checked.mfui-switcher_no-touch {
46
+ border-color: var(--spbSky2);
43
47
  background-color: var(--spbSky2);
44
48
  }
@@ -17,7 +17,7 @@ var Switcher = function Switcher(props) {
17
17
  return;
18
18
  }
19
19
 
20
- onChange && onChange(e);
20
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
21
21
  };
22
22
 
23
23
  return /*#__PURE__*/React.createElement("div", {
@@ -1,12 +1,15 @@
1
1
  import * as React from 'react';
2
- import { IFilterDataAttrs } from '@megafon/ui-helpers';
3
- export interface ITabProps extends IFilterDataAttrs {
2
+ export interface ITabProps {
4
3
  /** Заголовок таба */
5
4
  title?: string;
6
5
  /** Иконка таба */
7
6
  icon?: React.ReactNode;
8
7
  /** Ссылка */
9
8
  href?: string;
9
+ /** Дополнительные data атрибуты к внутренним элементам */
10
+ dataAttrs?: {
11
+ root?: Record<string, string>;
12
+ };
10
13
  /** Дочерние элементы */
11
14
  children?: React.ReactNode;
12
15
  /** Функция рендера компонента-обертки для заголовка и иконки */
@@ -8,10 +8,12 @@ var Tab = function Tab(_ref) {
8
8
  };
9
9
 
10
10
  Tab.propTypes = {
11
+ dataAttrs: PropTypes.shape({
12
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
13
+ }),
11
14
  title: PropTypes.string,
12
15
  icon: PropTypes.node,
13
16
  href: PropTypes.string,
14
- renderTabWrapper: PropTypes.func,
15
- dataAttrs: PropTypes.objectOf(PropTypes.string.isRequired)
17
+ renderTabWrapper: PropTypes.func
16
18
  };
17
19
  export default Tab;
@@ -27,6 +27,14 @@ export interface ITabsProps {
27
27
  tab?: string;
28
28
  activeTab?: string;
29
29
  };
30
+ /** Дополнительные data атрибуты к внутренним элементам */
31
+ dataAttrs?: {
32
+ root?: Record<string, string>;
33
+ slider?: Record<string, string>;
34
+ panel?: Record<string, string>;
35
+ prev?: Record<string, string>;
36
+ next?: Record<string, string>;
37
+ };
30
38
  /** Размер табов */
31
39
  size?: TabSizeType;
32
40
  /** Горизонтальное выравнивание */
@@ -41,6 +49,8 @@ export interface ITabsProps {
41
49
  defaultIndex?: number;
42
50
  /** Рендер содержимого только для текущего таба */
43
51
  renderOnlyCurrentPanel?: boolean;
52
+ /** Внешний контейнер для режима фиксация табов */
53
+ outerObserveContainer?: HTMLDivElement | null;
44
54
  /** Обработчика клика по табам */
45
55
  onTabClick?: (index: number) => void;
46
56
  children: Array<React.ReactElement<ITabProps>>;
@@ -67,10 +67,13 @@ var Tabs = function Tabs(_ref) {
67
67
  _ref$renderOnlyCurren = _ref.renderOnlyCurrentPanel,
68
68
  renderOnlyCurrentPanel = _ref$renderOnlyCurren === void 0 ? false : _ref$renderOnlyCurren,
69
69
  children = _ref.children,
70
- onTabClick = _ref.onTabClick;
70
+ dataAttrs = _ref.dataAttrs,
71
+ onTabClick = _ref.onTabClick,
72
+ outerObserveContainer = _ref.outerObserveContainer;
71
73
  var tabsRef = React.useRef([]);
72
74
  var rootRef = React.useRef(null);
73
75
  var tabListRef = React.useRef(null);
76
+ var intersectionObserverRef = React.useRef();
74
77
 
75
78
  var _React$useState = React.useState(),
76
79
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -164,11 +167,70 @@ var Tabs = function Tabs(_ref) {
164
167
  left: left,
165
168
  right: documentWidth - right
166
169
  });
167
- }, [stickyOffset, isSticky]);
170
+ }, [sticky]);
171
+ var stickyON = React.useCallback(function (leftOffset, rightOffset) {
172
+ var documentWidth = document.documentElement.clientWidth;
173
+ setStickyOffset({
174
+ left: leftOffset,
175
+ right: documentWidth - rightOffset
176
+ });
177
+ setSticky(true);
178
+ }, []);
179
+ var stickyOFF = React.useCallback(function () {
180
+ setStickyOffset({
181
+ left: 0,
182
+ right: 0
183
+ });
184
+ setSticky(false);
185
+ }, []);
186
+ var isContainerNotFitViewport = React.useCallback(function () {
187
+ var _a;
188
+
189
+ var containerHeight = (_a = outerObserveContainer || rootRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight;
190
+ return containerHeight && containerHeight > window.innerHeight;
191
+ }, [outerObserveContainer]);
192
+ var addIntersectionObserver = React.useCallback(function () {
193
+ var observerOptions = {
194
+ threshold: [0, 1]
195
+ };
196
+
197
+ if (isContainerNotFitViewport()) {
198
+ observerOptions.rootMargin = '0px 0px -100%';
199
+ }
200
+
201
+ intersectionObserverRef.current = new IntersectionObserver(function (entries) {
202
+ entries.forEach(function (_ref2) {
203
+ var isIntersecting = _ref2.isIntersecting,
204
+ _ref2$boundingClientR = _ref2.boundingClientRect,
205
+ top = _ref2$boundingClientR.top,
206
+ left = _ref2$boundingClientR.left,
207
+ right = _ref2$boundingClientR.right;
208
+
209
+ if (!tabListRef.current) {
210
+ return;
211
+ }
212
+
213
+ var _tabListRef$current$g = tabListRef.current.getBoundingClientRect(),
214
+ height = _tabListRef$current$g.height,
215
+ tabListNodeLeft = _tabListRef$current$g.left,
216
+ tabListNodeRight = _tabListRef$current$g.right;
217
+
218
+ var leftOffset = outerObserveContainer ? tabListNodeLeft : left;
219
+ var rightOffset = outerObserveContainer ? tabListNodeRight : right;
220
+ setTabListHeight(height);
221
+
222
+ if (isIntersecting) {
223
+ top < 0 ? stickyON(leftOffset, rightOffset) : stickyOFF();
224
+ } else {
225
+ stickyOFF();
226
+ }
227
+ });
228
+ }, observerOptions);
229
+ }, [isContainerNotFitViewport, outerObserveContainer, stickyOFF, stickyON]);
168
230
  var handleTabInnerClick = React.useCallback(function (index) {
169
231
  return function () {
170
232
  setUnderlineTransition('all');
171
- onTabClick && onTabClick(index);
233
+ onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(index);
172
234
 
173
235
  if (outerIndex === undefined) {
174
236
  setInnerIndex(index);
@@ -186,6 +248,28 @@ var Tabs = function Tabs(_ref) {
186
248
  var handleNextArrowClick = React.useCallback(function () {
187
249
  swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.slideNext();
188
250
  }, [swiperInstance]);
251
+ var handleReachBeginning = React.useCallback(function (swiper) {
252
+ setBeginning(swiper.isBeginning);
253
+ }, []);
254
+ var handleReachEnd = React.useCallback(function (swiper) {
255
+ setEnd(swiper.isEnd);
256
+ }, []);
257
+ var handleFromEdge = React.useCallback(function (swiper) {
258
+ setBeginning(swiper.isBeginning);
259
+ setEnd(swiper.isEnd);
260
+ }, []);
261
+ var addObserveEvent = React.useCallback(function () {
262
+ var _a;
263
+
264
+ var rootRefNode = rootRef.current;
265
+ rootRefNode && ((_a = intersectionObserverRef.current) === null || _a === void 0 ? void 0 : _a.observe(outerObserveContainer || rootRefNode));
266
+ }, [outerObserveContainer]);
267
+ var removeObserveEvent = React.useCallback(function () {
268
+ var _a;
269
+
270
+ var rootRefNode = rootRef.current;
271
+ rootRefNode && ((_a = intersectionObserverRef.current) === null || _a === void 0 ? void 0 : _a.unobserve(outerObserveContainer || rootRefNode));
272
+ }, [outerObserveContainer]);
189
273
  var renderTab = React.useCallback(function (index, title, icon, href) {
190
274
  var ElementType = href ? 'a' : 'div';
191
275
  return /*#__PURE__*/React.createElement(ElementType, {
@@ -207,7 +291,7 @@ var Tabs = function Tabs(_ref) {
207
291
  icon = _child$props.icon,
208
292
  href = _child$props.href,
209
293
  renderTabWrapper = _child$props.renderTabWrapper,
210
- dataAttrs = _child$props.dataAttrs;
294
+ data = _child$props.dataAttrs;
211
295
  var tab = renderTab(i, title, icon, href);
212
296
  var activeTabClassName = currentIndex === i ? activeTabClass : undefined;
213
297
  return /*#__PURE__*/React.createElement(SwiperSlide, {
@@ -215,9 +299,9 @@ var Tabs = function Tabs(_ref) {
215
299
  }, /*#__PURE__*/React.createElement("div", _extends({
216
300
  className: cn('tab', [tabClass, activeTabClassName]),
217
301
  ref: setTabRef
218
- }, filterDataAttrs(dataAttrs)), renderTabWrapper ? renderTabWrapper(tab) : tab));
302
+ }, filterDataAttrs(data === null || data === void 0 ? void 0 : data.root, i + 1)), renderTabWrapper ? renderTabWrapper(tab) : tab));
219
303
  });
220
- }, [renderTab, children]);
304
+ }, [renderTab, children, activeTabClass, currentIndex, setTabRef, tabClass]);
221
305
  var renderPanels = React.useCallback(function () {
222
306
  return React.Children.map(children, function (child, i) {
223
307
  var panel = child.props.children;
@@ -227,73 +311,33 @@ var Tabs = function Tabs(_ref) {
227
311
  return null;
228
312
  }
229
313
 
230
- return /*#__PURE__*/React.createElement("div", {
314
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.panel, i + 1), {
231
315
  className: cn('panel', {
232
316
  current: isCurrentPanel
233
317
  })
234
- }, panel);
318
+ }), panel);
235
319
  });
236
- }, [children, currentIndex]);
237
- var handleReachBeginning = React.useCallback(function (swiper) {
238
- setBeginning(swiper.isBeginning);
239
- }, []);
240
- var handleReachEnd = React.useCallback(function (swiper) {
241
- setEnd(swiper.isEnd);
242
- }, []);
243
- var handleFromEdge = React.useCallback(function (swiper) {
244
- setBeginning(swiper.isBeginning);
245
- setEnd(swiper.isEnd);
246
- }, []);
320
+ }, [children, currentIndex, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.panel, renderOnlyCurrentPanel]);
247
321
  React.useEffect(function () {
248
- var observer = new IntersectionObserver(function (entries) {
249
- entries.forEach(function (_ref2) {
250
- var isIntersecting = _ref2.isIntersecting,
251
- _ref2$boundingClientR = _ref2.boundingClientRect,
252
- top = _ref2$boundingClientR.top,
253
- left = _ref2$boundingClientR.left,
254
- right = _ref2$boundingClientR.right;
255
-
256
- if (!sticky || !rootRef.current || !tabListRef.current) {
257
- return;
258
- }
259
-
260
- var listHeight = tabListRef.current.clientHeight;
261
- setTabListHeight(listHeight);
262
-
263
- var stickyON = function stickyON(leftOffset, rightOffset) {
264
- var documentWidth = document.documentElement.clientWidth;
265
- setStickyOffset({
266
- left: leftOffset,
267
- right: documentWidth - rightOffset
268
- });
269
- setSticky(true);
270
- };
271
-
272
- var stickyOFF = function stickyOFF() {
273
- setStickyOffset({
274
- left: 0,
275
- right: 0
276
- });
277
- setSticky(false);
278
- };
322
+ if (!sticky) {
323
+ return undefined;
324
+ }
279
325
 
280
- if (isIntersecting) {
281
- top < 0 ? stickyON(left, right) : stickyOFF();
282
- } else {
283
- top < 0 && stickyOFF();
284
- }
285
- });
286
- }, {
287
- threshold: [0, 1]
288
- });
289
- rootRef.current && observer.observe(rootRef.current);
326
+ addIntersectionObserver();
327
+ addObserveEvent();
290
328
  return function () {
291
- rootRef.current && observer.unobserve(rootRef.current);
329
+ removeObserveEvent();
292
330
  };
293
- }, [calculateSticky]);
331
+ }, [addIntersectionObserver, sticky, addObserveEvent, removeObserveEvent]);
294
332
  React.useEffect(function () {
295
333
  var handleResize = throttle(function () {
296
334
  calculateSticky();
335
+
336
+ if (sticky && isContainerNotFitViewport()) {
337
+ removeObserveEvent();
338
+ addIntersectionObserver();
339
+ addObserveEvent();
340
+ }
297
341
  }, 300);
298
342
  var activeTabNode = tabsRef.current[currentIndex];
299
343
  var resizeObserver = new ResizeObserver(function (entries) {
@@ -310,8 +354,9 @@ var Tabs = function Tabs(_ref) {
310
354
  window.addEventListener('resize', handleResize);
311
355
  return function () {
312
356
  window.removeEventListener('resize', handleResize);
357
+ resizeObserver.unobserve(activeTabNode);
313
358
  };
314
- }, [calculateUnderline, calculateSticky]);
359
+ }, [sticky, currentIndex, addObserveEvent, calculateSticky, removeObserveEvent, calculateUnderline, addIntersectionObserver, isContainerNotFitViewport]);
315
360
  React.useEffect(function () {
316
361
  if (!swiperInstance) {
317
362
  return;
@@ -320,7 +365,7 @@ var Tabs = function Tabs(_ref) {
320
365
  setBeginning(swiperInstance.isBeginning);
321
366
  setEnd(swiperInstance.isEnd);
322
367
  }, [swiperInstance]);
323
- return /*#__PURE__*/React.createElement("div", {
368
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
324
369
  className: cn({
325
370
  size: size,
326
371
  'h-align': hAlign,
@@ -329,7 +374,7 @@ var Tabs = function Tabs(_ref) {
329
374
  sticky: isSticky
330
375
  }, [className, rootClass]),
331
376
  ref: rootRef
332
- }, /*#__PURE__*/React.createElement("div", {
377
+ }), /*#__PURE__*/React.createElement("div", {
333
378
  ref: tabListRef,
334
379
  style: {
335
380
  height: tabListHeight
@@ -340,7 +385,7 @@ var Tabs = function Tabs(_ref) {
340
385
  paddingLeft: stickyOffset.left,
341
386
  paddingRight: stickyOffset.right
342
387
  }
343
- }, /*#__PURE__*/React.createElement(Swiper, {
388
+ }, /*#__PURE__*/React.createElement(Swiper, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.slider), {
344
389
  simulateTouch: false,
345
390
  className: cn('swiper', {
346
391
  beginning: isBeginning,
@@ -352,7 +397,7 @@ var Tabs = function Tabs(_ref) {
352
397
  onReachBeginning: handleReachBeginning,
353
398
  onReachEnd: handleReachEnd,
354
399
  onFromEdge: handleFromEdge
355
- }, renderTabs(), /*#__PURE__*/React.createElement("div", {
400
+ }), renderTabs(), /*#__PURE__*/React.createElement("div", {
356
401
  className: cn('underline'),
357
402
  slot: "wrapper-start",
358
403
  style: {
@@ -360,19 +405,19 @@ var Tabs = function Tabs(_ref) {
360
405
  transform: "translateX(".concat(underlineTranslate, "px)"),
361
406
  transitionProperty: underlineTransition
362
407
  }
363
- }), /*#__PURE__*/React.createElement(ArrowLeft, {
408
+ }), /*#__PURE__*/React.createElement(ArrowLeft, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prev), {
364
409
  className: cn('arrow', {
365
410
  prev: true,
366
411
  hide: isBeginning
367
412
  }),
368
413
  onClick: handlePrevArrowClick
369
- }), /*#__PURE__*/React.createElement(ArrowRight, {
414
+ })), /*#__PURE__*/React.createElement(ArrowRight, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.next), {
370
415
  className: cn('arrow', {
371
416
  next: true,
372
417
  hide: isEnd
373
418
  }),
374
419
  onClick: handleNextArrowClick
375
- })))), renderPanels());
420
+ }))))), renderPanels());
376
421
  };
377
422
 
378
423
  Tabs.propTypes = {
@@ -383,6 +428,13 @@ Tabs.propTypes = {
383
428
  tab: PropTypes.string,
384
429
  activeTab: PropTypes.string
385
430
  }),
431
+ dataAttrs: PropTypes.shape({
432
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
433
+ slider: PropTypes.objectOf(PropTypes.string.isRequired),
434
+ panel: PropTypes.objectOf(PropTypes.string.isRequired),
435
+ prev: PropTypes.objectOf(PropTypes.string.isRequired),
436
+ next: PropTypes.objectOf(PropTypes.string.isRequired)
437
+ }),
386
438
  size: PropTypes.oneOf(Object.values(TabSize)),
387
439
  hAlign: PropTypes.oneOf(Object.values(TabHAlign)),
388
440
  tabColorTheme: PropTypes.oneOf(Object.values(TabColorTheme)),
@@ -390,6 +442,7 @@ Tabs.propTypes = {
390
442
  currentIndex: PropTypes.number,
391
443
  defaultIndex: PropTypes.number,
392
444
  renderOnlyCurrentPanel: PropTypes.bool,
445
+ outerObserveContainer: PropTypes.oneOfType([PropTypes.elementType, PropTypes.any]),
393
446
  onTabClick: PropTypes.func
394
447
  };
395
448
  export default Tabs;
@@ -62,8 +62,18 @@ export declare type TextFieldProps = {
62
62
  classes?: {
63
63
  input?: string;
64
64
  };
65
- /** Аргумент элемента input */
65
+ /** Дополнительные data атрибуты к внутренним элементам */
66
+ dataAttrs?: {
67
+ root?: Record<string, string>;
68
+ label?: Record<string, string>;
69
+ notice?: Record<string, string>;
70
+ input?: Record<string, string>;
71
+ iconBox?: Record<string, string>;
72
+ };
73
+ /** Атрибут элемента input */
66
74
  inputMode?: 'numeric' | 'tel' | 'decimal' | 'email' | 'url' | 'search' | 'none';
75
+ /** Атрибут элемента input. Не работает с textarea=true */
76
+ autoComplete?: string;
67
77
  /** Переводит компонент в контролируемое состояние */
68
78
  isControlled?: boolean;
69
79
  /** Обработчик изменения значения */