@megafon/ui-core 3.11.0 → 3.13.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,39 @@
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
+ # [3.13.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.12.1...@megafon/ui-core@3.13.0) (2022-08-11)
7
+
8
+
9
+ ### Features
10
+
11
+ * **banner:** add auto height ([c7658fa](https://github.com/MegafonWebLab/megafon-ui/commit/c7658faf335bc26f0a1b816e29b9cca114944691))
12
+
13
+
14
+
15
+
16
+
17
+ ## [3.12.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.12.0...@megafon/ui-core@3.12.1) (2022-08-02)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **carousel:** popup input focus ([b1c117a](https://github.com/MegafonWebLab/megafon-ui/commit/b1c117ac1ed560182e61133393ec65f14527958f))
23
+
24
+
25
+
26
+
27
+
28
+ # [3.12.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.11.0...@megafon/ui-core@3.12.0) (2022-06-28)
29
+
30
+
31
+ ### Features
32
+
33
+ * **tab:** add data-attribute for inner element ([43e58e1](https://github.com/MegafonWebLab/megafon-ui/commit/43e58e12b8da661020f4b48f55245492c21ad376))
34
+
35
+
36
+
37
+
38
+
6
39
  # [3.11.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.10.1...@megafon/ui-core@3.11.0) (2022-06-21)
7
40
 
8
41
 
@@ -36,6 +36,9 @@
36
36
  height: 400px;
37
37
  }
38
38
  }
39
+ .mfui-banner_auto-height .mfui-banner__slide {
40
+ height: auto;
41
+ }
39
42
  @media screen and (min-width: 1024px) {
40
43
  .mfui-banner .swiper-slide-visible {
41
44
  opacity: 1;
@@ -36,6 +36,8 @@ export interface IBannerProps {
36
36
  pauseOnHover?: boolean;
37
37
  /** Цветовая тема навигации */
38
38
  navTheme?: NavThemeType;
39
+ /** Автоматическая высота слайдов */
40
+ autoHeight?: boolean;
39
41
  /** Обработчик клика по стрелке "вперед" (должен быть обернут в useCallback) */
40
42
  onNextClick?: (index: number) => void;
41
43
  /** Обработчик клика по стрелке "назад" (должен быть обернут в useCallback) */
@@ -43,6 +43,8 @@ var Banner = function Banner(_ref) {
43
43
  loop = _ref$loop === void 0 ? false : _ref$loop,
44
44
  _ref$navTheme = _ref.navTheme,
45
45
  navTheme = _ref$navTheme === void 0 ? 'light' : _ref$navTheme,
46
+ _ref$autoHeight = _ref.autoHeight,
47
+ autoHeight = _ref$autoHeight === void 0 ? false : _ref$autoHeight,
46
48
  _ref$children = _ref.children,
47
49
  children = _ref$children === void 0 ? [] : _ref$children,
48
50
  onNextClick = _ref.onNextClick,
@@ -178,7 +180,8 @@ var Banner = function Banner(_ref) {
178
180
  }, [autoPlay, pauseOnHover, swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay]);
179
181
  return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
180
182
  className: cn({
181
- 'nav-theme': navTheme
183
+ 'nav-theme': navTheme,
184
+ 'auto-height': autoHeight
182
185
  }, className),
183
186
  ref: rootRef
184
187
  }), /*#__PURE__*/React.createElement(Swiper, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.swiper), {
@@ -259,6 +262,7 @@ Banner.propTypes = {
259
262
  autoPlayDelay: PropTypes.number,
260
263
  pauseOnHover: PropTypes.bool,
261
264
  navTheme: PropTypes.oneOf(Object.values(NavTheme)),
265
+ autoHeight: PropTypes.bool,
262
266
  onNextClick: PropTypes.func,
263
267
  onPrevClick: PropTypes.func,
264
268
  onDotClick: PropTypes.func,
@@ -219,7 +219,9 @@ var Carousel = function Carousel(_ref) {
219
219
  };
220
220
 
221
221
  var disableFocusOnSlideClick = function disableFocusOnSlideClick(e) {
222
- e.nativeEvent.preventDefault();
222
+ if (e.nativeEvent.target.closest(".".concat(cn()))) {
223
+ e.nativeEvent.preventDefault();
224
+ }
223
225
  };
224
226
 
225
227
  React.useEffect(function () {
@@ -9,6 +9,7 @@ export interface ITabProps {
9
9
  /** Дополнительные data атрибуты к внутренним элементам */
10
10
  dataAttrs?: {
11
11
  root?: Record<string, string>;
12
+ inner?: Record<string, string>;
12
13
  };
13
14
  /** Дочерние элементы */
14
15
  children?: React.ReactNode;
@@ -9,7 +9,8 @@ var Tab = function Tab(_ref) {
9
9
 
10
10
  Tab.propTypes = {
11
11
  dataAttrs: PropTypes.shape({
12
- root: PropTypes.objectOf(PropTypes.string.isRequired)
12
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
13
+ inner: PropTypes.objectOf(PropTypes.string.isRequired)
13
14
  }),
14
15
  title: PropTypes.string,
15
16
  icon: PropTypes.node,
@@ -270,15 +270,15 @@ var Tabs = function Tabs(_ref) {
270
270
  var rootRefNode = rootRef.current;
271
271
  rootRefNode && ((_a = intersectionObserverRef.current) === null || _a === void 0 ? void 0 : _a.unobserve(outerObserveContainer || rootRefNode));
272
272
  }, [outerObserveContainer]);
273
- var renderTab = React.useCallback(function (index, title, icon, href) {
273
+ var renderTab = React.useCallback(function (index, title, icon, href, attr) {
274
274
  var ElementType = href ? 'a' : 'div';
275
- return /*#__PURE__*/React.createElement(ElementType, {
275
+ return /*#__PURE__*/React.createElement(ElementType, _extends({
276
276
  href: href,
277
277
  className: cn('tab-inner', {
278
278
  current: currentIndex === index
279
279
  }),
280
280
  onClick: handleTabInnerClick(index)
281
- }, !!icon && /*#__PURE__*/React.createElement("div", {
281
+ }, filterDataAttrs(attr, index + 1)), !!icon && /*#__PURE__*/React.createElement("div", {
282
282
  className: cn('tab-icon')
283
283
  }, icon), !!title && /*#__PURE__*/React.createElement("div", {
284
284
  className: cn('tab-title')
@@ -292,7 +292,7 @@ var Tabs = function Tabs(_ref) {
292
292
  href = _child$props.href,
293
293
  renderTabWrapper = _child$props.renderTabWrapper,
294
294
  data = _child$props.dataAttrs;
295
- var tab = renderTab(i, title, icon, href);
295
+ var tab = renderTab(i, title, icon, href, data === null || data === void 0 ? void 0 : data.inner);
296
296
  var activeTabClassName = currentIndex === i ? activeTabClass : undefined;
297
297
  return /*#__PURE__*/React.createElement(SwiperSlide, {
298
298
  className: cn('slide')
@@ -36,6 +36,9 @@
36
36
  height: 400px;
37
37
  }
38
38
  }
39
+ .mfui-banner_auto-height .mfui-banner__slide {
40
+ height: auto;
41
+ }
39
42
  @media screen and (min-width: 1024px) {
40
43
  .mfui-banner .swiper-slide-visible {
41
44
  opacity: 1;
@@ -36,6 +36,8 @@ export interface IBannerProps {
36
36
  pauseOnHover?: boolean;
37
37
  /** Цветовая тема навигации */
38
38
  navTheme?: NavThemeType;
39
+ /** Автоматическая высота слайдов */
40
+ autoHeight?: boolean;
39
41
  /** Обработчик клика по стрелке "вперед" (должен быть обернут в useCallback) */
40
42
  onNextClick?: (index: number) => void;
41
43
  /** Обработчик клика по стрелке "назад" (должен быть обернут в useCallback) */
@@ -71,6 +71,8 @@ var Banner = function Banner(_ref) {
71
71
  loop = _ref$loop === void 0 ? false : _ref$loop,
72
72
  _ref$navTheme = _ref.navTheme,
73
73
  navTheme = _ref$navTheme === void 0 ? 'light' : _ref$navTheme,
74
+ _ref$autoHeight = _ref.autoHeight,
75
+ autoHeight = _ref$autoHeight === void 0 ? false : _ref$autoHeight,
74
76
  _ref$children = _ref.children,
75
77
  children = _ref$children === void 0 ? [] : _ref$children,
76
78
  onNextClick = _ref.onNextClick,
@@ -206,7 +208,8 @@ var Banner = function Banner(_ref) {
206
208
  }, [autoPlay, pauseOnHover, swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.autoplay]);
207
209
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
208
210
  className: cn({
209
- 'nav-theme': navTheme
211
+ 'nav-theme': navTheme,
212
+ 'auto-height': autoHeight
210
213
  }, className),
211
214
  ref: rootRef
212
215
  }), /*#__PURE__*/React.createElement(_react2.Swiper, (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.swiper), {
@@ -287,6 +290,7 @@ Banner.propTypes = {
287
290
  autoPlayDelay: PropTypes.number,
288
291
  pauseOnHover: PropTypes.bool,
289
292
  navTheme: PropTypes.oneOf(Object.values(NavTheme)),
293
+ autoHeight: PropTypes.bool,
290
294
  onNextClick: PropTypes.func,
291
295
  onPrevClick: PropTypes.func,
292
296
  onDotClick: PropTypes.func,
@@ -249,7 +249,9 @@ var Carousel = function Carousel(_ref) {
249
249
  };
250
250
 
251
251
  var disableFocusOnSlideClick = function disableFocusOnSlideClick(e) {
252
- e.nativeEvent.preventDefault();
252
+ if (e.nativeEvent.target.closest(".".concat(cn()))) {
253
+ e.nativeEvent.preventDefault();
254
+ }
253
255
  };
254
256
 
255
257
  React.useEffect(function () {
@@ -9,6 +9,7 @@ export interface ITabProps {
9
9
  /** Дополнительные data атрибуты к внутренним элементам */
10
10
  dataAttrs?: {
11
11
  root?: Record<string, string>;
12
+ inner?: Record<string, string>;
12
13
  };
13
14
  /** Дочерние элементы */
14
15
  children?: React.ReactNode;
@@ -25,7 +25,8 @@ var Tab = function Tab(_ref) {
25
25
 
26
26
  Tab.propTypes = {
27
27
  dataAttrs: _propTypes["default"].shape({
28
- root: _propTypes["default"].objectOf(_propTypes["default"].string.isRequired)
28
+ root: _propTypes["default"].objectOf(_propTypes["default"].string.isRequired),
29
+ inner: _propTypes["default"].objectOf(_propTypes["default"].string.isRequired)
29
30
  }),
30
31
  title: _propTypes["default"].string,
31
32
  icon: _propTypes["default"].node,
@@ -299,15 +299,15 @@ var Tabs = function Tabs(_ref) {
299
299
  var rootRefNode = rootRef.current;
300
300
  rootRefNode && ((_a = intersectionObserverRef.current) === null || _a === void 0 ? void 0 : _a.unobserve(outerObserveContainer || rootRefNode));
301
301
  }, [outerObserveContainer]);
302
- var renderTab = React.useCallback(function (index, title, icon, href) {
302
+ var renderTab = React.useCallback(function (index, title, icon, href, attr) {
303
303
  var ElementType = href ? 'a' : 'div';
304
- return /*#__PURE__*/React.createElement(ElementType, {
304
+ return /*#__PURE__*/React.createElement(ElementType, (0, _extends2["default"])({
305
305
  href: href,
306
306
  className: cn('tab-inner', {
307
307
  current: currentIndex === index
308
308
  }),
309
309
  onClick: handleTabInnerClick(index)
310
- }, !!icon && /*#__PURE__*/React.createElement("div", {
310
+ }, (0, _uiHelpers.filterDataAttrs)(attr, index + 1)), !!icon && /*#__PURE__*/React.createElement("div", {
311
311
  className: cn('tab-icon')
312
312
  }, icon), !!title && /*#__PURE__*/React.createElement("div", {
313
313
  className: cn('tab-title')
@@ -321,7 +321,7 @@ var Tabs = function Tabs(_ref) {
321
321
  href = _child$props.href,
322
322
  renderTabWrapper = _child$props.renderTabWrapper,
323
323
  data = _child$props.dataAttrs;
324
- var tab = renderTab(i, title, icon, href);
324
+ var tab = renderTab(i, title, icon, href, data === null || data === void 0 ? void 0 : data.inner);
325
325
  var activeTabClassName = currentIndex === i ? activeTabClass : undefined;
326
326
  return /*#__PURE__*/React.createElement(_react2.SwiperSlide, {
327
327
  className: cn('slide')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "3.11.0",
3
+ "version": "3.13.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  },
45
45
  "peerDependencies": {
46
- "@megafon/ui-icons": "^0.0.2-beta.2",
46
+ "@megafon/ui-icons": "^1.0.0",
47
47
  "react": ">=16.13.0",
48
48
  "react-dom": ">=16.13.0"
49
49
  },
@@ -97,5 +97,5 @@
97
97
  "react-popper": "^2.2.3",
98
98
  "swiper": "^6.5.6"
99
99
  },
100
- "gitHead": "c0c35d6f50202e8af91b58ca10cf2b9cbb58a71d"
100
+ "gitHead": "805c619438eb41f92e1dbb930d750393e8fea5fe"
101
101
  }