@megafon/ui-core 4.5.0 → 4.6.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 (30) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/es/components/Accordion/Accordion.d.ts +7 -2
  3. package/dist/es/components/Accordion/Accordion.js +14 -7
  4. package/dist/es/components/Badges/components/TimerBadge/TimerBadge.d.ts +2 -0
  5. package/dist/es/components/Badges/components/TimerBadge/TimerBadge.js +5 -4
  6. package/dist/es/components/Caption/Caption.css +1 -1
  7. package/dist/es/components/Carousel/Carousel.js +10 -0
  8. package/dist/es/components/Carousel/usePrevious.d.ts +2 -0
  9. package/dist/es/components/Carousel/usePrevious.js +11 -0
  10. package/dist/es/components/Notification/Notification.js +3 -3
  11. package/dist/es/components/Search/Search.css +1 -0
  12. package/dist/es/components/Switcher/Switcher.css +1 -0
  13. package/dist/es/components/Tabs/Tabs.js +12 -6
  14. package/dist/es/index.d.ts +1 -0
  15. package/dist/es/index.js +2 -1
  16. package/dist/lib/components/Accordion/Accordion.d.ts +7 -2
  17. package/dist/lib/components/Accordion/Accordion.js +14 -7
  18. package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.d.ts +2 -0
  19. package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.js +6 -4
  20. package/dist/lib/components/Caption/Caption.css +1 -1
  21. package/dist/lib/components/Carousel/Carousel.js +12 -0
  22. package/dist/lib/components/Carousel/usePrevious.d.ts +2 -0
  23. package/dist/lib/components/Carousel/usePrevious.js +25 -0
  24. package/dist/lib/components/Notification/Notification.js +2 -2
  25. package/dist/lib/components/Search/Search.css +1 -0
  26. package/dist/lib/components/Switcher/Switcher.css +1 -0
  27. package/dist/lib/components/Tabs/Tabs.js +12 -6
  28. package/dist/lib/index.d.ts +1 -0
  29. package/dist/lib/index.js +8 -0
  30. package/package.json +7 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,36 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.6.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.5.1...@megafon/ui-core@4.6.0) (2022-10-31)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **accordion:** fix dataAttrs props ([bb6e71c](https://github.com/MegafonWebLab/megafon-ui/commit/bb6e71cf36687fdcfb41a9ee40a27e0fdb21940b))
12
+
13
+
14
+ ### Features
15
+
16
+ * **notification:** allow using html: br, &nbsp, font color, a href in title plus b in text ([1661b7b](https://github.com/MegafonWebLab/megafon-ui/commit/1661b7b602532594ed4d1398d9f70870b1e4d852))
17
+ * **timerbadge:** add iconContainer to dataAttrs prop ([fa9b094](https://github.com/MegafonWebLab/megafon-ui/commit/fa9b094b209705c448de63fe0cfbfe52764e6709))
18
+
19
+
20
+
21
+
22
+
23
+ ## [4.5.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.5.0...@megafon/ui-core@4.5.1) (2022-10-24)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **carousel:** change navigation view after change slides count ([7b300eb](https://github.com/MegafonWebLab/megafon-ui/commit/7b300eb9c6f805c3b425104a17f437b3b8a520c5))
29
+ * **search:** fix input field font-size for all browsers ([739f3b0](https://github.com/MegafonWebLab/megafon-ui/commit/739f3b02a2dbf8abc6ad430e43272a5bae4d9cf9))
30
+ * **tabs:** change tabs list structure for correct underline width ([ab87ab2](https://github.com/MegafonWebLab/megafon-ui/commit/ab87ab2e23b3db7620ea0fd83c58bdc8f51ab0ae))
31
+
32
+
33
+
34
+
35
+
6
36
  # [4.5.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.4.0...@megafon/ui-core@4.5.0) (2022-10-17)
7
37
 
8
38
 
@@ -158,6 +188,10 @@ new sizes
158
188
  either accept new rules or manually add line-height: 16px in your components
159
189
  * **paragraph:** prop 'size' is no longer exists.
160
190
  use component Caption instead of Paragraph size="small"
191
+ * **header:** rename prop 'hAlign' to 'align'
192
+ * **list:** rename prop 'hAlign' to 'align'
193
+ * **contentarea:** remove value 'DEFAULT' from 'innerBackgroundColor' and 'outerBackgroundColor' props
194
+ * **tabs:** rename prop 'hAlign' to 'align'
161
195
 
162
196
 
163
197
 
@@ -19,8 +19,13 @@ export interface IAccordionProps {
19
19
  /** Дополнительные data атрибуты к внутренним элементам */
20
20
  dataAttrs?: {
21
21
  root?: Record<string, string>;
22
- header?: Record<string, string>;
23
- collapse?: Record<string, string>;
22
+ header?: {
23
+ root: Record<string, string>;
24
+ };
25
+ collapse?: {
26
+ root?: Record<string, string>;
27
+ inner?: Record<string, string>;
28
+ };
24
29
  titleWrap?: Record<string, string>;
25
30
  arrowUp?: Record<string, string>;
26
31
  arrowDown?: Record<string, string>;
@@ -64,17 +64,19 @@ var Accordion = function Accordion(_ref) {
64
64
  onKeyDown: handleClickTitle,
65
65
  tabIndex: 0,
66
66
  role: "button"
67
- }), /*#__PURE__*/React.createElement(Header, _extends({
68
- as: "h5"
69
- }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.header)), title), /*#__PURE__*/React.createElement("div", {
67
+ }), /*#__PURE__*/React.createElement(Header, {
68
+ as: "h5",
69
+ dataAttrs: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.header
70
+ }, title), /*#__PURE__*/React.createElement("div", {
70
71
  className: cn('icon-box')
71
72
  }, /*#__PURE__*/React.createElement(ArrowDown, _extends({
72
73
  className: cn('icon')
73
- }, filterDataAttrs(arrowDataAttrs))))), /*#__PURE__*/React.createElement(Collapse, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.collapse), {
74
+ }, filterDataAttrs(arrowDataAttrs))))), /*#__PURE__*/React.createElement(Collapse, {
75
+ dataAttrs: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.collapse,
74
76
  className: cn('content', collapsePropsClasses),
75
77
  classNameContainer: cn('content-inner'),
76
78
  isOpened: isOpenedState
77
- }), children));
79
+ }, children));
78
80
  };
79
81
 
80
82
  Accordion.propTypes = {
@@ -92,8 +94,13 @@ Accordion.propTypes = {
92
94
  }),
93
95
  dataAttrs: PropTypes.shape({
94
96
  root: PropTypes.objectOf(PropTypes.string.isRequired),
95
- header: PropTypes.objectOf(PropTypes.string.isRequired),
96
- collapse: PropTypes.objectOf(PropTypes.string.isRequired),
97
+ header: PropTypes.shape({
98
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
99
+ }),
100
+ collapse: PropTypes.shape({
101
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
102
+ inner: PropTypes.objectOf(PropTypes.string.isRequired)
103
+ }),
97
104
  titleWrap: PropTypes.objectOf(PropTypes.string.isRequired),
98
105
  arrowUp: PropTypes.objectOf(PropTypes.string.isRequired),
99
106
  arrowDown: PropTypes.objectOf(PropTypes.string.isRequired)
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import './TimerBadge.less';
3
+ export declare const TIMEOUT = 1000;
3
4
  export interface ITimerBadgeProps {
4
5
  /** Дата окончания таймера */
5
6
  expirationDate: Date;
@@ -18,6 +19,7 @@ export interface ITimerBadgeProps {
18
19
  root?: Record<string, string>;
19
20
  text?: Record<string, string>;
20
21
  timer?: Record<string, string>;
22
+ iconContainer?: Record<string, string>;
21
23
  };
22
24
  }
23
25
  declare const TimerBadge: React.FC<ITimerBadgeProps>;
@@ -21,7 +21,7 @@ var TimerIcon = function TimerIcon(props) {
21
21
 
22
22
  var SECONDS_IN_HOUR = 3600;
23
23
  var MS_IN_SECOND = 1000;
24
- var TIMEOUT = 1000;
24
+ export var TIMEOUT = 1000;
25
25
  var TimerBadgeTheme = {
26
26
  RED: 'red',
27
27
  GREY: 'grey'
@@ -75,11 +75,11 @@ var TimerBadge = function TimerBadge(_ref) {
75
75
  className: cn({
76
76
  theme: theme
77
77
  }, className)
78
- }), /*#__PURE__*/React.createElement("div", {
78
+ }), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.iconContainer), {
79
79
  className: cn('icon-container', {
80
80
  shadow: isLastHour && showCountdown
81
81
  })
82
- }, /*#__PURE__*/React.createElement(TimerIcon, {
82
+ }), /*#__PURE__*/React.createElement(TimerIcon, {
83
83
  className: cn('icon')
84
84
  })), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.text), {
85
85
  className: cn('text')
@@ -104,7 +104,8 @@ TimerBadge.propTypes = {
104
104
  dataAttrs: PropTypes.shape({
105
105
  root: PropTypes.objectOf(PropTypes.string.isRequired),
106
106
  text: PropTypes.objectOf(PropTypes.string.isRequired),
107
- timer: PropTypes.objectOf(PropTypes.string.isRequired)
107
+ timer: PropTypes.objectOf(PropTypes.string.isRequired),
108
+ iconContainer: PropTypes.objectOf(PropTypes.string.isRequired)
108
109
  })
109
110
  };
110
111
  export default TimerBadge;
@@ -8,7 +8,7 @@
8
8
  font-weight: 400;
9
9
  }
10
10
  .mfui-caption_variant_medium {
11
- font-weight: 600;
11
+ font-weight: 500;
12
12
  }
13
13
  .mfui-caption_space_wide {
14
14
  line-height: 18px;
@@ -1,4 +1,5 @@
1
1
  import "core-js/modules/es.array.index-of";
2
+ import "core-js/modules/es.array.is-array";
2
3
  import "core-js/modules/es.array.map";
3
4
  import "core-js/modules/es.object.values";
4
5
  import _extends from "@babel/runtime/helpers/extends";
@@ -18,6 +19,7 @@ import NavArrow, { Theme as ArrowTheme } from "../NavArrow/NavArrow";
18
19
  import throttleTime from "../../constants/throttleTime";
19
20
  import checkBreakpointsPropTypes from "./checkBreakpointsPropTypes";
20
21
  import "./Carousel.css";
22
+ import usePrevious from "./usePrevious";
21
23
  SwiperCore.use([Autoplay, Pagination, EffectFade]);
22
24
  export var NavTheme = {
23
25
  LIGHT: 'light',
@@ -116,6 +118,9 @@ var Carousel = function Carousel(_ref) {
116
118
  isLocked = _React$useState8[0],
117
119
  setLocked = _React$useState8[1];
118
120
 
121
+ var childrenLen = Array.isArray(children) ? children.length : 0;
122
+ var prevChildrenLen = usePrevious(childrenLen) || 0;
123
+ var isChildrenLenDiff = childrenLen !== prevChildrenLen;
119
124
  var increaseAutoplayDelay = React.useCallback(function (_ref2) {
120
125
  var params = _ref2.params,
121
126
  autoplay = _ref2.autoplay;
@@ -241,6 +246,11 @@ var Carousel = function Carousel(_ref) {
241
246
  window.removeEventListener('resize', windowResizeHandlerThrottled);
242
247
  };
243
248
  }, [swiperInstance]);
249
+ React.useEffect(function () {
250
+ if (swiperInstance && isChildrenLenDiff) {
251
+ handleNavDisplay(swiperInstance);
252
+ }
253
+ }, [isChildrenLenDiff, swiperInstance]);
244
254
  return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
245
255
  ref: rootRef,
246
256
  className: cn({
@@ -0,0 +1,2 @@
1
+ declare function usePrevious<T>(value: T): T | undefined;
2
+ export default usePrevious;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+
3
+ function usePrevious(value) {
4
+ var ref = React.useRef();
5
+ React.useEffect(function () {
6
+ ref.current = value;
7
+ }, [value]);
8
+ return ref.current;
9
+ }
10
+
11
+ export default usePrevious;
@@ -4,7 +4,7 @@ import "core-js/modules/web.timers";
4
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
5
  import _extends from "@babel/runtime/helpers/extends";
6
6
  import React, { useEffect, useRef, useState } from 'react';
7
- import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
7
+ import { cnCreate, filterDataAttrs, convert, titleConvertConfig, textConvertConfig } from '@megafon/ui-helpers';
8
8
  import * as PropTypes from 'prop-types';
9
9
  import Button from "../Button/Button";
10
10
  import TextLink from "../TextLink/TextLink";
@@ -299,7 +299,7 @@ var Notification = function Notification(_ref) {
299
299
  className: cn('text-container')
300
300
  }, title && /*#__PURE__*/React.createElement("span", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.title), {
301
301
  className: cn('title')
302
- }), title), /*#__PURE__*/React.createElement("div", _extends({
302
+ }), convert(title, titleConvertConfig)), /*#__PURE__*/React.createElement("div", _extends({
303
303
  ref: wrapTextRef
304
304
  }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.text), {
305
305
  className: cn('text', {
@@ -308,7 +308,7 @@ var Notification = function Notification(_ref) {
308
308
  }), /*#__PURE__*/React.createElement("div", {
309
309
  ref: shortTextRef,
310
310
  className: cn('short-text', textClasses["short"])
311
- }, shortText || children), shortText && /*#__PURE__*/React.createElement("div", {
311
+ }, shortText && convert(shortText, textConvertConfig) || children), shortText && /*#__PURE__*/React.createElement("div", {
312
312
  ref: fullTextRef,
313
313
  className: cn('full-text', textClasses.full)
314
314
  }, children))), hasBottom && /*#__PURE__*/React.createElement("div", {
@@ -172,6 +172,7 @@
172
172
  border-radius: 0;
173
173
  overflow: auto;
174
174
  color: var(--content);
175
+ font-size: 100%;
175
176
  font-family: inherit;
176
177
  line-height: 25px;
177
178
  background-color: transparent;
@@ -2,6 +2,7 @@
2
2
  display: -webkit-box;
3
3
  display: -ms-flexbox;
4
4
  display: flex;
5
+ -webkit-tap-highlight-color: transparent;
5
6
  }
6
7
  .mfui-switcher__content {
7
8
  font-size: 15px;
@@ -59,7 +59,7 @@ var Tabs = function Tabs(_ref) {
59
59
  dataAttrs = _ref.dataAttrs,
60
60
  onTabClick = _ref.onTabClick,
61
61
  outerObserveContainer = _ref.outerObserveContainer;
62
- var tabsRef = React.useRef([]);
62
+ var tabsRef = React.useRef({});
63
63
  var rootRef = React.useRef(null);
64
64
  var tabListRef = React.useRef(null);
65
65
  var intersectionObserverRef = React.useRef();
@@ -124,15 +124,21 @@ var Tabs = function Tabs(_ref) {
124
124
  stickyOffset = _React$useState22[0],
125
125
  setStickyOffset = _React$useState22[1];
126
126
 
127
- var setTabRef = React.useCallback(function (tab) {
128
- tab && tabsRef.current.push(tab);
127
+ var setTabRef = React.useCallback(function (i) {
128
+ return function (tab) {
129
+ if (tab) {
130
+ tabsRef.current[i] = tab;
131
+ }
132
+ };
129
133
  }, []);
130
134
  var calculateUnderline = React.useCallback(function () {
131
- if (!tabsRef.current.length) {
135
+ var tabs = Object.values(tabsRef.current);
136
+
137
+ if (!tabs.length) {
132
138
  return;
133
139
  }
134
140
 
135
- var translate = _toConsumableArray(tabsRef.current).splice(0, currentIndex).reduce(function (accWidth, node) {
141
+ var translate = _toConsumableArray(tabs).splice(0, currentIndex).reduce(function (accWidth, node) {
136
142
  var _node$getBoundingClie = node.getBoundingClientRect(),
137
143
  width = _node$getBoundingClie.width;
138
144
 
@@ -288,7 +294,7 @@ var Tabs = function Tabs(_ref) {
288
294
  className: cn('slide')
289
295
  }, /*#__PURE__*/React.createElement("div", _extends({
290
296
  className: cn('tab', [classes === null || classes === void 0 ? void 0 : classes.tab, activeTabClassName]),
291
- ref: setTabRef
297
+ ref: setTabRef(i)
292
298
  }, filterDataAttrs(data === null || data === void 0 ? void 0 : data.root, i + 1)), renderTabWrapper ? renderTabWrapper(tab) : tab));
293
299
  });
294
300
  }, [renderTab, children, classes === null || classes === void 0 ? void 0 : classes.activeTab, currentIndex, setTabRef, classes === null || classes === void 0 ? void 0 : classes.tab]);
@@ -44,3 +44,4 @@ export { default as Timer } from './components/Badges/components/TimerBadge/Time
44
44
  export { default as TimerBadge } from './components/Badges/components/TimerBadge/TimerBadge';
45
45
  export { default as Tooltip } from './components/Tooltip/Tooltip';
46
46
  export { default as usePagination } from './components/Pagination/usePagination';
47
+ export { default as usePrevious } from './components/Carousel/usePrevious';
package/dist/es/index.js CHANGED
@@ -43,4 +43,5 @@ export { default as Tile } from "./components/Tile/Tile";
43
43
  export { default as Timer } from "./components/Badges/components/TimerBadge/Timer/Timer";
44
44
  export { default as TimerBadge } from "./components/Badges/components/TimerBadge/TimerBadge";
45
45
  export { default as Tooltip } from "./components/Tooltip/Tooltip";
46
- export { default as usePagination } from "./components/Pagination/usePagination";
46
+ export { default as usePagination } from "./components/Pagination/usePagination";
47
+ export { default as usePrevious } from "./components/Carousel/usePrevious";
@@ -19,8 +19,13 @@ export interface IAccordionProps {
19
19
  /** Дополнительные data атрибуты к внутренним элементам */
20
20
  dataAttrs?: {
21
21
  root?: Record<string, string>;
22
- header?: Record<string, string>;
23
- collapse?: Record<string, string>;
22
+ header?: {
23
+ root: Record<string, string>;
24
+ };
25
+ collapse?: {
26
+ root?: Record<string, string>;
27
+ inner?: Record<string, string>;
28
+ };
24
29
  titleWrap?: Record<string, string>;
25
30
  arrowUp?: Record<string, string>;
26
31
  arrowDown?: Record<string, string>;
@@ -84,17 +84,19 @@ var Accordion = function Accordion(_ref) {
84
84
  onKeyDown: handleClickTitle,
85
85
  tabIndex: 0,
86
86
  role: "button"
87
- }), /*#__PURE__*/React.createElement(_Header["default"], (0, _extends2["default"])({
88
- as: "h5"
89
- }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.header)), title), /*#__PURE__*/React.createElement("div", {
87
+ }), /*#__PURE__*/React.createElement(_Header["default"], {
88
+ as: "h5",
89
+ dataAttrs: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.header
90
+ }, title), /*#__PURE__*/React.createElement("div", {
90
91
  className: cn('icon-box')
91
92
  }, /*#__PURE__*/React.createElement(ArrowDown, (0, _extends2["default"])({
92
93
  className: cn('icon')
93
- }, (0, _uiHelpers.filterDataAttrs)(arrowDataAttrs))))), /*#__PURE__*/React.createElement(_Collapse["default"], (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.collapse), {
94
+ }, (0, _uiHelpers.filterDataAttrs)(arrowDataAttrs))))), /*#__PURE__*/React.createElement(_Collapse["default"], {
95
+ dataAttrs: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.collapse,
94
96
  className: cn('content', collapsePropsClasses),
95
97
  classNameContainer: cn('content-inner'),
96
98
  isOpened: isOpenedState
97
- }), children));
99
+ }, children));
98
100
  };
99
101
 
100
102
  Accordion.propTypes = {
@@ -112,8 +114,13 @@ Accordion.propTypes = {
112
114
  }),
113
115
  dataAttrs: PropTypes.shape({
114
116
  root: PropTypes.objectOf(PropTypes.string.isRequired),
115
- header: PropTypes.objectOf(PropTypes.string.isRequired),
116
- collapse: PropTypes.objectOf(PropTypes.string.isRequired),
117
+ header: PropTypes.shape({
118
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
119
+ }),
120
+ collapse: PropTypes.shape({
121
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
122
+ inner: PropTypes.objectOf(PropTypes.string.isRequired)
123
+ }),
117
124
  titleWrap: PropTypes.objectOf(PropTypes.string.isRequired),
118
125
  arrowUp: PropTypes.objectOf(PropTypes.string.isRequired),
119
126
  arrowDown: PropTypes.objectOf(PropTypes.string.isRequired)
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import './TimerBadge.less';
3
+ export declare const TIMEOUT = 1000;
3
4
  export interface ITimerBadgeProps {
4
5
  /** Дата окончания таймера */
5
6
  expirationDate: Date;
@@ -18,6 +19,7 @@ export interface ITimerBadgeProps {
18
19
  root?: Record<string, string>;
19
20
  text?: Record<string, string>;
20
21
  timer?: Record<string, string>;
22
+ iconContainer?: Record<string, string>;
21
23
  };
22
24
  }
23
25
  declare const TimerBadge: React.FC<ITimerBadgeProps>;
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = void 0;
8
+ exports["default"] = exports.TIMEOUT = void 0;
9
9
 
10
10
  require("core-js/modules/es.date.now");
11
11
 
@@ -44,6 +44,7 @@ var TimerIcon = function TimerIcon(props) {
44
44
  var SECONDS_IN_HOUR = 3600;
45
45
  var MS_IN_SECOND = 1000;
46
46
  var TIMEOUT = 1000;
47
+ exports.TIMEOUT = TIMEOUT;
47
48
  var TimerBadgeTheme = {
48
49
  RED: 'red',
49
50
  GREY: 'grey'
@@ -97,11 +98,11 @@ var TimerBadge = function TimerBadge(_ref) {
97
98
  className: cn({
98
99
  theme: theme
99
100
  }, className)
100
- }), /*#__PURE__*/_react["default"].createElement("div", {
101
+ }), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.iconContainer), {
101
102
  className: cn('icon-container', {
102
103
  shadow: isLastHour && showCountdown
103
104
  })
104
- }, /*#__PURE__*/_react["default"].createElement(TimerIcon, {
105
+ }), /*#__PURE__*/_react["default"].createElement(TimerIcon, {
105
106
  className: cn('icon')
106
107
  })), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.text), {
107
108
  className: cn('text')
@@ -126,7 +127,8 @@ TimerBadge.propTypes = {
126
127
  dataAttrs: PropTypes.shape({
127
128
  root: PropTypes.objectOf(PropTypes.string.isRequired),
128
129
  text: PropTypes.objectOf(PropTypes.string.isRequired),
129
- timer: PropTypes.objectOf(PropTypes.string.isRequired)
130
+ timer: PropTypes.objectOf(PropTypes.string.isRequired),
131
+ iconContainer: PropTypes.objectOf(PropTypes.string.isRequired)
130
132
  })
131
133
  };
132
134
  var _default = TimerBadge;
@@ -8,7 +8,7 @@
8
8
  font-weight: 400;
9
9
  }
10
10
  .mfui-caption_variant_medium {
11
- font-weight: 600;
11
+ font-weight: 500;
12
12
  }
13
13
  .mfui-caption_space_wide {
14
14
  line-height: 18px;
@@ -9,6 +9,8 @@ exports["default"] = exports.EffectTheme = exports.NavTheme = void 0;
9
9
 
10
10
  require("core-js/modules/es.array.index-of");
11
11
 
12
+ require("core-js/modules/es.array.is-array");
13
+
12
14
  require("core-js/modules/es.array.map");
13
15
 
14
16
  require("core-js/modules/es.object.values");
@@ -39,6 +41,8 @@ var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime
39
41
 
40
42
  var _checkBreakpointsPropTypes = _interopRequireDefault(require("./checkBreakpointsPropTypes"));
41
43
 
44
+ var _usePrevious = _interopRequireDefault(require("./usePrevious"));
45
+
42
46
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
43
47
 
44
48
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -148,6 +152,9 @@ var Carousel = function Carousel(_ref) {
148
152
  isLocked = _React$useState8[0],
149
153
  setLocked = _React$useState8[1];
150
154
 
155
+ var childrenLen = Array.isArray(children) ? children.length : 0;
156
+ var prevChildrenLen = (0, _usePrevious["default"])(childrenLen) || 0;
157
+ var isChildrenLenDiff = childrenLen !== prevChildrenLen;
151
158
  var increaseAutoplayDelay = React.useCallback(function (_ref2) {
152
159
  var params = _ref2.params,
153
160
  autoplay = _ref2.autoplay;
@@ -271,6 +278,11 @@ var Carousel = function Carousel(_ref) {
271
278
  window.removeEventListener('resize', windowResizeHandlerThrottled);
272
279
  };
273
280
  }, [swiperInstance]);
281
+ React.useEffect(function () {
282
+ if (swiperInstance && isChildrenLenDiff) {
283
+ handleNavDisplay(swiperInstance);
284
+ }
285
+ }, [isChildrenLenDiff, swiperInstance]);
274
286
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
275
287
  ref: rootRef,
276
288
  className: cn({
@@ -0,0 +1,2 @@
1
+ declare function usePrevious<T>(value: T): T | undefined;
2
+ export default usePrevious;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var React = _interopRequireWildcard(require("react"));
11
+
12
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
13
+
14
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ function usePrevious(value) {
17
+ var ref = React.useRef();
18
+ React.useEffect(function () {
19
+ ref.current = value;
20
+ }, [value]);
21
+ return ref.current;
22
+ }
23
+
24
+ var _default = usePrevious;
25
+ exports["default"] = _default;
@@ -325,7 +325,7 @@ var Notification = function Notification(_ref) {
325
325
  className: cn('text-container')
326
326
  }, title && /*#__PURE__*/_react["default"].createElement("span", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.title), {
327
327
  className: cn('title')
328
- }), title), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
328
+ }), (0, _uiHelpers.convert)(title, _uiHelpers.titleConvertConfig)), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
329
329
  ref: wrapTextRef
330
330
  }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.text), {
331
331
  className: cn('text', {
@@ -334,7 +334,7 @@ var Notification = function Notification(_ref) {
334
334
  }), /*#__PURE__*/_react["default"].createElement("div", {
335
335
  ref: shortTextRef,
336
336
  className: cn('short-text', textClasses["short"])
337
- }, shortText || children), shortText && /*#__PURE__*/_react["default"].createElement("div", {
337
+ }, shortText && (0, _uiHelpers.convert)(shortText, _uiHelpers.textConvertConfig) || children), shortText && /*#__PURE__*/_react["default"].createElement("div", {
338
338
  ref: fullTextRef,
339
339
  className: cn('full-text', textClasses.full)
340
340
  }, children))), hasBottom && /*#__PURE__*/_react["default"].createElement("div", {
@@ -172,6 +172,7 @@
172
172
  border-radius: 0;
173
173
  overflow: auto;
174
174
  color: var(--content);
175
+ font-size: 100%;
175
176
  font-family: inherit;
176
177
  line-height: 25px;
177
178
  background-color: transparent;
@@ -2,6 +2,7 @@
2
2
  display: -webkit-box;
3
3
  display: -ms-flexbox;
4
4
  display: flex;
5
+ -webkit-tap-highlight-color: transparent;
5
6
  }
6
7
  .mfui-switcher__content {
7
8
  font-size: 15px;
@@ -89,7 +89,7 @@ var Tabs = function Tabs(_ref) {
89
89
  dataAttrs = _ref.dataAttrs,
90
90
  onTabClick = _ref.onTabClick,
91
91
  outerObserveContainer = _ref.outerObserveContainer;
92
- var tabsRef = React.useRef([]);
92
+ var tabsRef = React.useRef({});
93
93
  var rootRef = React.useRef(null);
94
94
  var tabListRef = React.useRef(null);
95
95
  var intersectionObserverRef = React.useRef();
@@ -154,15 +154,21 @@ var Tabs = function Tabs(_ref) {
154
154
  stickyOffset = _React$useState22[0],
155
155
  setStickyOffset = _React$useState22[1];
156
156
 
157
- var setTabRef = React.useCallback(function (tab) {
158
- tab && tabsRef.current.push(tab);
157
+ var setTabRef = React.useCallback(function (i) {
158
+ return function (tab) {
159
+ if (tab) {
160
+ tabsRef.current[i] = tab;
161
+ }
162
+ };
159
163
  }, []);
160
164
  var calculateUnderline = React.useCallback(function () {
161
- if (!tabsRef.current.length) {
165
+ var tabs = Object.values(tabsRef.current);
166
+
167
+ if (!tabs.length) {
162
168
  return;
163
169
  }
164
170
 
165
- var translate = (0, _toConsumableArray2["default"])(tabsRef.current).splice(0, currentIndex).reduce(function (accWidth, node) {
171
+ var translate = (0, _toConsumableArray2["default"])(tabs).splice(0, currentIndex).reduce(function (accWidth, node) {
166
172
  var _node$getBoundingClie = node.getBoundingClientRect(),
167
173
  width = _node$getBoundingClie.width;
168
174
 
@@ -317,7 +323,7 @@ var Tabs = function Tabs(_ref) {
317
323
  className: cn('slide')
318
324
  }, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
319
325
  className: cn('tab', [classes === null || classes === void 0 ? void 0 : classes.tab, activeTabClassName]),
320
- ref: setTabRef
326
+ ref: setTabRef(i)
321
327
  }, (0, _uiHelpers.filterDataAttrs)(data === null || data === void 0 ? void 0 : data.root, i + 1)), renderTabWrapper ? renderTabWrapper(tab) : tab));
322
328
  });
323
329
  }, [renderTab, children, classes === null || classes === void 0 ? void 0 : classes.activeTab, currentIndex, setTabRef, classes === null || classes === void 0 ? void 0 : classes.tab]);
@@ -44,3 +44,4 @@ export { default as Timer } from './components/Badges/components/TimerBadge/Time
44
44
  export { default as TimerBadge } from './components/Badges/components/TimerBadge/TimerBadge';
45
45
  export { default as Tooltip } from './components/Tooltip/Tooltip';
46
46
  export { default as usePagination } from './components/Pagination/usePagination';
47
+ export { default as usePrevious } from './components/Carousel/usePrevious';
package/dist/lib/index.js CHANGED
@@ -279,6 +279,12 @@ Object.defineProperty(exports, "usePagination", {
279
279
  return _usePagination["default"];
280
280
  }
281
281
  });
282
+ Object.defineProperty(exports, "usePrevious", {
283
+ enumerable: true,
284
+ get: function get() {
285
+ return _usePrevious["default"];
286
+ }
287
+ });
282
288
 
283
289
  var _Accordion = _interopRequireDefault(require("./components/Accordion/Accordion"));
284
290
 
@@ -372,4 +378,6 @@ var _Tooltip = _interopRequireDefault(require("./components/Tooltip/Tooltip"));
372
378
 
373
379
  var _usePagination = _interopRequireDefault(require("./components/Pagination/usePagination"));
374
380
 
381
+ var _usePrevious = _interopRequireDefault(require("./components/Carousel/usePrevious"));
382
+
375
383
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -54,9 +54,12 @@
54
54
  "@babel/preset-env": "^7.8.6",
55
55
  "@babel/preset-react": "^7.8.3",
56
56
  "@babel/preset-typescript": "^7.8.3",
57
- "@megafon/ui-icons": "^2.1.0",
57
+ "@megafon/ui-icons": "^2.3.0",
58
58
  "@svgr/core": "^2.4.1",
59
+ "@testing-library/jest-dom": "5.16.2",
60
+ "@testing-library/react": "12.1.2",
59
61
  "@testing-library/react-hooks": "^7.0.1",
62
+ "@testing-library/user-event": "13.5.0",
60
63
  "@types/enzyme": "^3.10.5",
61
64
  "@types/enzyme-adapter-react-16": "^1.0.6",
62
65
  "@types/jest": "^25.1.3",
@@ -86,7 +89,7 @@
86
89
  "dependencies": {
87
90
  "@babel/runtime": "^7.8.4",
88
91
  "@datepicker-react/hooks": "^2.7.0",
89
- "@megafon/ui-helpers": "^2.2.0",
92
+ "@megafon/ui-helpers": "^2.3.0",
90
93
  "@popperjs/core": "^2.5.3",
91
94
  "core-js": "^3.6.4",
92
95
  "date-fns": "^2.16.1",
@@ -97,5 +100,5 @@
97
100
  "react-popper": "^2.2.3",
98
101
  "swiper": "^6.5.6"
99
102
  },
100
- "gitHead": "1767b434f1650a100aa2aca6f5c795f8b549a184"
103
+ "gitHead": "fd77e756d2591ad3489e94c585d40bfa05e40710"
101
104
  }