@megafon/ui-core 3.11.0 → 3.12.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,17 @@
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.12.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.11.0...@megafon/ui-core@3.12.0) (2022-06-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * **tab:** add data-attribute for inner element ([43e58e1](https://github.com/MegafonWebLab/megafon-ui/commit/43e58e12b8da661020f4b48f55245492c21ad376))
12
+
13
+
14
+
15
+
16
+
6
17
  # [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
18
 
8
19
 
@@ -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')
@@ -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.12.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -97,5 +97,5 @@
97
97
  "react-popper": "^2.2.3",
98
98
  "swiper": "^6.5.6"
99
99
  },
100
- "gitHead": "c0c35d6f50202e8af91b58ca10cf2b9cbb58a71d"
100
+ "gitHead": "937a89d31be941889706301984fdbf6c1e1852b2"
101
101
  }