@megafon/ui-core 4.11.4 → 4.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
+ # [4.12.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.11.4...@megafon/ui-core@4.12.0) (2023-02-13)
7
+
8
+
9
+ ### Features
10
+
11
+ * **tabs:** add rel prop ([7a4a2de](https://github.com/MegafonWebLab/megafon-ui/commit/7a4a2ded26083cc466de10c362700a6c98a38dfd))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [4.11.4](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.11.3...@megafon/ui-core@4.11.4) (2023-02-06)
7
18
 
8
19
  **Note:** Version bump only for package @megafon/ui-core
@@ -75,9 +75,13 @@ export interface ISelectProps<T extends SelectItemValueType> {
75
75
  dataAttrs?: {
76
76
  root?: Record<string, string>;
77
77
  label?: Record<string, string>;
78
+ control?: Record<string, string>;
78
79
  title?: Record<string, string>;
80
+ titleInner?: Record<string, string>;
79
81
  input?: Record<string, string>;
80
82
  noticeText?: Record<string, string>;
83
+ list?: Record<string, string>;
84
+ listInner?: Record<string, string>;
81
85
  listItem?: Record<string, string>;
82
86
  listItemTitle?: Record<string, string>;
83
87
  notFound?: Record<string, string>;
@@ -120,15 +124,27 @@ declare const Select: {
120
124
  label: PropTypes.Requireable<{
121
125
  [x: string]: string;
122
126
  }>;
127
+ control: PropTypes.Requireable<{
128
+ [x: string]: string;
129
+ }>;
123
130
  title: PropTypes.Requireable<{
124
131
  [x: string]: string;
125
132
  }>;
133
+ titleInner: PropTypes.Requireable<{
134
+ [x: string]: string;
135
+ }>;
126
136
  input: PropTypes.Requireable<{
127
137
  [x: string]: string;
128
138
  }>;
129
139
  noticeText: PropTypes.Requireable<{
130
140
  [x: string]: string;
131
141
  }>;
142
+ list: PropTypes.Requireable<{
143
+ [x: string]: string;
144
+ }>;
145
+ listInner: PropTypes.Requireable<{
146
+ [x: string]: string;
147
+ }>;
132
148
  listItem: PropTypes.Requireable<{
133
149
  [x: string]: string;
134
150
  }>;
@@ -200,6 +200,7 @@ var Select = function Select(_ref) {
200
200
  comparableInputValue: title,
201
201
  items: items
202
202
  });
203
+ e.persist();
203
204
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(e, item);
204
205
  onClosed === null || onClosed === void 0 ? void 0 : onClosed();
205
206
  };
@@ -355,11 +356,11 @@ var Select = function Select(_ref) {
355
356
  role: "button",
356
357
  tabIndex: 0,
357
358
  onClick: handleSelectClick
358
- }), /*#__PURE__*/React.createElement("div", {
359
+ }), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.titleInner), {
359
360
  className: cn('title-inner', {
360
361
  'hide-value': !item
361
362
  }, [classes === null || classes === void 0 ? void 0 : classes.titleInner])
362
- }, /*#__PURE__*/React.createElement("div", {
363
+ }), /*#__PURE__*/React.createElement("div", {
363
364
  className: cn('title-value')
364
365
  }, inputTitle), label && renderLabel()));
365
366
  };
@@ -379,14 +380,14 @@ var Select = function Select(_ref) {
379
380
 
380
381
  var renderChildren = function renderChildren() {
381
382
  var currentItems = type === SelectTypes.COMBOBOX ? itemsList : items;
382
- return /*#__PURE__*/React.createElement("div", {
383
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.list), {
383
384
  className: cn('list', [classes.list])
384
- }, /*#__PURE__*/React.createElement("div", {
385
+ }), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.listInner), {
385
386
  className: cn('list-inner', {
386
387
  "short": shortList
387
388
  }, [classes.listInner]),
388
389
  ref: itemWrapperNode
389
- }, currentItems.map(function (_ref3, i) {
390
+ }), currentItems.map(function (_ref3, i) {
390
391
  var title = _ref3.title,
391
392
  value = _ref3.value,
392
393
  view = _ref3.view,
@@ -423,12 +424,12 @@ var Select = function Select(_ref) {
423
424
  ref: selectNode
424
425
  }), /*#__PURE__*/React.createElement("div", {
425
426
  className: cn('inner')
426
- }, /*#__PURE__*/React.createElement("div", {
427
+ }, /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control), {
427
428
  className: cn('control', {
428
429
  labeled: !!label
429
430
  }, classes.control),
430
431
  onKeyDown: handleKeyDown
431
- }, type === SelectTypes.COMBOBOX && renderCombobox(), type === SelectTypes.CLASSIC && renderTitle()), renderChildren()), noticeText && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.noticeText), {
432
+ }), type === SelectTypes.COMBOBOX && renderCombobox(), type === SelectTypes.CLASSIC && renderTitle()), renderChildren()), noticeText && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.noticeText), {
432
433
  className: cn('text', {
433
434
  error: verification === Verification.ERROR,
434
435
  success: verification === Verification.VALID
@@ -461,9 +462,13 @@ Select.propTypes = {
461
462
  dataAttrs: PropTypes.shape({
462
463
  root: PropTypes.objectOf(PropTypes.string.isRequired),
463
464
  label: PropTypes.objectOf(PropTypes.string.isRequired),
465
+ control: PropTypes.objectOf(PropTypes.string.isRequired),
464
466
  title: PropTypes.objectOf(PropTypes.string.isRequired),
467
+ titleInner: PropTypes.objectOf(PropTypes.string.isRequired),
465
468
  input: PropTypes.objectOf(PropTypes.string.isRequired),
466
469
  noticeText: PropTypes.objectOf(PropTypes.string.isRequired),
470
+ list: PropTypes.objectOf(PropTypes.string.isRequired),
471
+ listInner: PropTypes.objectOf(PropTypes.string.isRequired),
467
472
  listItem: PropTypes.objectOf(PropTypes.string.isRequired),
468
473
  listItemTitle: PropTypes.objectOf(PropTypes.string.isRequired),
469
474
  notFound: PropTypes.objectOf(PropTypes.string.isRequired)
@@ -6,6 +6,8 @@ export interface ITabProps {
6
6
  icon?: React.ReactNode;
7
7
  /** Ссылка */
8
8
  href?: string;
9
+ /** Rel - атрибут тега <a> */
10
+ rel?: string;
9
11
  /** Дополнительные data атрибуты к внутренним элементам */
10
12
  dataAttrs?: {
11
13
  root?: Record<string, string>;
@@ -15,6 +15,7 @@ Tab.propTypes = {
15
15
  title: PropTypes.string,
16
16
  icon: PropTypes.node,
17
17
  href: PropTypes.string,
18
+ rel: PropTypes.string,
18
19
  renderTabWrapper: PropTypes.func
19
20
  };
20
21
  export default Tab;
@@ -271,10 +271,16 @@ var Tabs = function Tabs(_ref) {
271
271
  var rootRefNode = rootRef.current;
272
272
  rootRefNode && ((_a = intersectionObserverRef.current) === null || _a === void 0 ? void 0 : _a.unobserve(outerObserveContainer || rootRefNode));
273
273
  }, [outerObserveContainer]);
274
- var renderTab = React.useCallback(function (index, title, icon, href, attr) {
274
+ var renderTab = React.useCallback(function (_ref3, index) {
275
+ var title = _ref3.title,
276
+ icon = _ref3.icon,
277
+ href = _ref3.href,
278
+ rel = _ref3.rel,
279
+ attr = _ref3.attr;
275
280
  var ElementType = href ? 'a' : 'div';
276
281
  return /*#__PURE__*/React.createElement(ElementType, _extends({
277
282
  href: href,
283
+ rel: rel,
278
284
  className: cn('tab-inner', {
279
285
  current: currentIndex === index,
280
286
  'with-icon': !!icon
@@ -292,9 +298,16 @@ var Tabs = function Tabs(_ref) {
292
298
  title = _child$props.title,
293
299
  icon = _child$props.icon,
294
300
  href = _child$props.href,
301
+ rel = _child$props.rel,
295
302
  renderTabWrapper = _child$props.renderTabWrapper,
296
303
  data = _child$props.dataAttrs;
297
- var tab = renderTab(i, title, icon, href, data === null || data === void 0 ? void 0 : data.inner);
304
+ var tab = renderTab({
305
+ title: title,
306
+ icon: icon,
307
+ href: href,
308
+ rel: rel,
309
+ attr: data === null || data === void 0 ? void 0 : data.inner
310
+ }, i);
298
311
  var activeTabClassName = currentIndex === i ? classes === null || classes === void 0 ? void 0 : classes.activeTab : undefined;
299
312
  return /*#__PURE__*/React.createElement(SwiperSlide, {
300
313
  className: cn('slide')
@@ -75,9 +75,13 @@ export interface ISelectProps<T extends SelectItemValueType> {
75
75
  dataAttrs?: {
76
76
  root?: Record<string, string>;
77
77
  label?: Record<string, string>;
78
+ control?: Record<string, string>;
78
79
  title?: Record<string, string>;
80
+ titleInner?: Record<string, string>;
79
81
  input?: Record<string, string>;
80
82
  noticeText?: Record<string, string>;
83
+ list?: Record<string, string>;
84
+ listInner?: Record<string, string>;
81
85
  listItem?: Record<string, string>;
82
86
  listItemTitle?: Record<string, string>;
83
87
  notFound?: Record<string, string>;
@@ -120,15 +124,27 @@ declare const Select: {
120
124
  label: PropTypes.Requireable<{
121
125
  [x: string]: string;
122
126
  }>;
127
+ control: PropTypes.Requireable<{
128
+ [x: string]: string;
129
+ }>;
123
130
  title: PropTypes.Requireable<{
124
131
  [x: string]: string;
125
132
  }>;
133
+ titleInner: PropTypes.Requireable<{
134
+ [x: string]: string;
135
+ }>;
126
136
  input: PropTypes.Requireable<{
127
137
  [x: string]: string;
128
138
  }>;
129
139
  noticeText: PropTypes.Requireable<{
130
140
  [x: string]: string;
131
141
  }>;
142
+ list: PropTypes.Requireable<{
143
+ [x: string]: string;
144
+ }>;
145
+ listInner: PropTypes.Requireable<{
146
+ [x: string]: string;
147
+ }>;
132
148
  listItem: PropTypes.Requireable<{
133
149
  [x: string]: string;
134
150
  }>;
@@ -235,6 +235,7 @@ var Select = function Select(_ref) {
235
235
  comparableInputValue: title,
236
236
  items: items
237
237
  });
238
+ e.persist();
238
239
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(e, item);
239
240
  onClosed === null || onClosed === void 0 ? void 0 : onClosed();
240
241
  };
@@ -390,11 +391,11 @@ var Select = function Select(_ref) {
390
391
  role: "button",
391
392
  tabIndex: 0,
392
393
  onClick: handleSelectClick
393
- }), /*#__PURE__*/React.createElement("div", {
394
+ }), /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.titleInner), {
394
395
  className: cn('title-inner', {
395
396
  'hide-value': !item
396
397
  }, [classes === null || classes === void 0 ? void 0 : classes.titleInner])
397
- }, /*#__PURE__*/React.createElement("div", {
398
+ }), /*#__PURE__*/React.createElement("div", {
398
399
  className: cn('title-value')
399
400
  }, inputTitle), label && renderLabel()));
400
401
  };
@@ -414,14 +415,14 @@ var Select = function Select(_ref) {
414
415
 
415
416
  var renderChildren = function renderChildren() {
416
417
  var currentItems = type === SelectTypes.COMBOBOX ? itemsList : items;
417
- return /*#__PURE__*/React.createElement("div", {
418
+ return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.list), {
418
419
  className: cn('list', [classes.list])
419
- }, /*#__PURE__*/React.createElement("div", {
420
+ }), /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.listInner), {
420
421
  className: cn('list-inner', {
421
422
  "short": shortList
422
423
  }, [classes.listInner]),
423
424
  ref: itemWrapperNode
424
- }, currentItems.map(function (_ref3, i) {
425
+ }), currentItems.map(function (_ref3, i) {
425
426
  var title = _ref3.title,
426
427
  value = _ref3.value,
427
428
  view = _ref3.view,
@@ -458,12 +459,12 @@ var Select = function Select(_ref) {
458
459
  ref: selectNode
459
460
  }), /*#__PURE__*/React.createElement("div", {
460
461
  className: cn('inner')
461
- }, /*#__PURE__*/React.createElement("div", {
462
+ }, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control), {
462
463
  className: cn('control', {
463
464
  labeled: !!label
464
465
  }, classes.control),
465
466
  onKeyDown: handleKeyDown
466
- }, type === SelectTypes.COMBOBOX && renderCombobox(), type === SelectTypes.CLASSIC && renderTitle()), renderChildren()), noticeText && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.noticeText), {
467
+ }), type === SelectTypes.COMBOBOX && renderCombobox(), type === SelectTypes.CLASSIC && renderTitle()), renderChildren()), noticeText && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.noticeText), {
467
468
  className: cn('text', {
468
469
  error: verification === Verification.ERROR,
469
470
  success: verification === Verification.VALID
@@ -496,9 +497,13 @@ Select.propTypes = {
496
497
  dataAttrs: PropTypes.shape({
497
498
  root: PropTypes.objectOf(PropTypes.string.isRequired),
498
499
  label: PropTypes.objectOf(PropTypes.string.isRequired),
500
+ control: PropTypes.objectOf(PropTypes.string.isRequired),
499
501
  title: PropTypes.objectOf(PropTypes.string.isRequired),
502
+ titleInner: PropTypes.objectOf(PropTypes.string.isRequired),
500
503
  input: PropTypes.objectOf(PropTypes.string.isRequired),
501
504
  noticeText: PropTypes.objectOf(PropTypes.string.isRequired),
505
+ list: PropTypes.objectOf(PropTypes.string.isRequired),
506
+ listInner: PropTypes.objectOf(PropTypes.string.isRequired),
502
507
  listItem: PropTypes.objectOf(PropTypes.string.isRequired),
503
508
  listItemTitle: PropTypes.objectOf(PropTypes.string.isRequired),
504
509
  notFound: PropTypes.objectOf(PropTypes.string.isRequired)
@@ -6,6 +6,8 @@ export interface ITabProps {
6
6
  icon?: React.ReactNode;
7
7
  /** Ссылка */
8
8
  href?: string;
9
+ /** Rel - атрибут тега <a> */
10
+ rel?: string;
9
11
  /** Дополнительные data атрибуты к внутренним элементам */
10
12
  dataAttrs?: {
11
13
  root?: Record<string, string>;
@@ -31,6 +31,7 @@ Tab.propTypes = {
31
31
  title: _propTypes["default"].string,
32
32
  icon: _propTypes["default"].node,
33
33
  href: _propTypes["default"].string,
34
+ rel: _propTypes["default"].string,
34
35
  renderTabWrapper: _propTypes["default"].func
35
36
  };
36
37
  var _default = Tab;
@@ -302,10 +302,16 @@ var Tabs = function Tabs(_ref) {
302
302
  var rootRefNode = rootRef.current;
303
303
  rootRefNode && ((_a = intersectionObserverRef.current) === null || _a === void 0 ? void 0 : _a.unobserve(outerObserveContainer || rootRefNode));
304
304
  }, [outerObserveContainer]);
305
- var renderTab = React.useCallback(function (index, title, icon, href, attr) {
305
+ var renderTab = React.useCallback(function (_ref3, index) {
306
+ var title = _ref3.title,
307
+ icon = _ref3.icon,
308
+ href = _ref3.href,
309
+ rel = _ref3.rel,
310
+ attr = _ref3.attr;
306
311
  var ElementType = href ? 'a' : 'div';
307
312
  return /*#__PURE__*/React.createElement(ElementType, (0, _extends2["default"])({
308
313
  href: href,
314
+ rel: rel,
309
315
  className: cn('tab-inner', {
310
316
  current: currentIndex === index,
311
317
  'with-icon': !!icon
@@ -323,9 +329,16 @@ var Tabs = function Tabs(_ref) {
323
329
  title = _child$props.title,
324
330
  icon = _child$props.icon,
325
331
  href = _child$props.href,
332
+ rel = _child$props.rel,
326
333
  renderTabWrapper = _child$props.renderTabWrapper,
327
334
  data = _child$props.dataAttrs;
328
- var tab = renderTab(i, title, icon, href, data === null || data === void 0 ? void 0 : data.inner);
335
+ var tab = renderTab({
336
+ title: title,
337
+ icon: icon,
338
+ href: href,
339
+ rel: rel,
340
+ attr: data === null || data === void 0 ? void 0 : data.inner
341
+ }, i);
329
342
  var activeTabClassName = currentIndex === i ? classes === null || classes === void 0 ? void 0 : classes.activeTab : undefined;
330
343
  return /*#__PURE__*/React.createElement(_react2.SwiperSlide, {
331
344
  className: cn('slide')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "4.11.4",
3
+ "version": "4.12.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -54,7 +54,7 @@
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.6.0",
57
+ "@megafon/ui-icons": "^2.7.0",
58
58
  "@svgr/core": "^2.4.1",
59
59
  "@testing-library/jest-dom": "5.16.2",
60
60
  "@testing-library/react": "12.1.2",
@@ -100,5 +100,5 @@
100
100
  "react-popper": "^2.2.3",
101
101
  "swiper": "^6.5.6"
102
102
  },
103
- "gitHead": "e7bdd83cccb39b833ced5eb1a5714f22166a0672"
103
+ "gitHead": "8aa400bad61aac6015ab7eff10b6aa24dcdbd8f6"
104
104
  }