@megafon/ui-core 3.0.0-beta.3 → 3.0.0-beta.7

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 (124) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/dist/es/colors/Colors.js +13 -0
  3. package/dist/es/components/Accordion/Accordion.d.ts +11 -3
  4. package/dist/es/components/Accordion/Accordion.js +14 -7
  5. package/dist/es/components/Banner/Banner.d.ts +10 -0
  6. package/dist/es/components/Banner/Banner.js +25 -11
  7. package/dist/es/components/Banner/BannerDot.d.ts +3 -0
  8. package/dist/es/components/Banner/BannerDot.js +8 -3
  9. package/dist/es/components/Button/Button.d.ts +8 -2
  10. package/dist/es/components/Button/Button.js +14 -6
  11. package/dist/es/components/Carousel/Carousel.d.ts +9 -2
  12. package/dist/es/components/Carousel/Carousel.js +14 -8
  13. package/dist/es/components/Checkbox/Checkbox.d.ts +8 -2
  14. package/dist/es/components/Checkbox/Checkbox.js +12 -7
  15. package/dist/es/components/Collapse/Collapse.d.ts +15 -3
  16. package/dist/es/components/Collapse/Collapse.js +11 -4
  17. package/dist/es/components/ContentArea/ContentArea.css +8 -59
  18. package/dist/es/components/ContentArea/ContentArea.d.ts +2 -6
  19. package/dist/es/components/ContentArea/ContentArea.js +5 -38
  20. package/dist/es/components/Counter/Counter.css +0 -47
  21. package/dist/es/components/Grid/Grid.css +0 -47
  22. package/dist/es/components/Header/Header.d.ts +6 -20
  23. package/dist/es/components/Header/Header.js +30 -66
  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 +6 -2
  27. package/dist/es/components/Link/Link.js +28 -4
  28. package/dist/es/components/Notification/Notification.css +0 -47
  29. package/dist/es/components/Notification/Notification.d.ts +8 -0
  30. package/dist/es/components/Notification/Notification.js +21 -4
  31. package/dist/es/components/Pagination/Pagination.d.ts +9 -2
  32. package/dist/es/components/Pagination/Pagination.js +20 -3
  33. package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.css +0 -47
  34. package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.d.ts +6 -3
  35. package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.js +11 -6
  36. package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +5 -2
  37. package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.js +10 -2
  38. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.css +0 -47
  39. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +5 -2
  40. package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +6 -1
  41. package/dist/es/components/Paragraph/Paragraph.css +9 -11
  42. package/dist/es/components/Paragraph/Paragraph.d.ts +12 -12
  43. package/dist/es/components/Paragraph/Paragraph.js +14 -36
  44. package/dist/es/components/Preloader/Preloader.d.ts +4 -0
  45. package/dist/es/components/Preloader/Preloader.js +10 -5
  46. package/dist/es/components/RadioButton/RadioButton.d.ts +8 -28
  47. package/dist/es/components/RadioButton/RadioButton.js +50 -85
  48. package/dist/es/components/Select/Select.d.ts +38 -5
  49. package/dist/es/components/Select/Select.js +50 -34
  50. package/dist/es/components/Tabs/Tab.d.ts +5 -2
  51. package/dist/es/components/Tabs/Tab.js +4 -2
  52. package/dist/es/components/Tabs/Tabs.d.ts +8 -0
  53. package/dist/es/components/Tabs/Tabs.js +29 -21
  54. package/dist/es/components/TextField/TextField.d.ts +8 -0
  55. package/dist/es/components/TextField/TextField.js +22 -10
  56. package/dist/es/components/TextLink/TextLink.js +7 -2
  57. package/dist/es/components/Tile/Tile.d.ts +5 -2
  58. package/dist/es/components/Tile/Tile.js +1 -1
  59. package/dist/es/components/Tooltip/Tooltip.d.ts +5 -0
  60. package/dist/es/components/Tooltip/Tooltip.js +10 -2
  61. package/dist/lib/colors/Colors.js +10 -0
  62. package/dist/lib/components/Accordion/Accordion.d.ts +11 -3
  63. package/dist/lib/components/Accordion/Accordion.js +14 -7
  64. package/dist/lib/components/Banner/Banner.d.ts +10 -0
  65. package/dist/lib/components/Banner/Banner.js +25 -10
  66. package/dist/lib/components/Banner/BannerDot.d.ts +3 -0
  67. package/dist/lib/components/Banner/BannerDot.js +10 -2
  68. package/dist/lib/components/Button/Button.d.ts +8 -2
  69. package/dist/lib/components/Button/Button.js +14 -6
  70. package/dist/lib/components/Carousel/Carousel.d.ts +9 -2
  71. package/dist/lib/components/Carousel/Carousel.js +14 -8
  72. package/dist/lib/components/Checkbox/Checkbox.d.ts +8 -2
  73. package/dist/lib/components/Checkbox/Checkbox.js +12 -7
  74. package/dist/lib/components/Collapse/Collapse.d.ts +15 -3
  75. package/dist/lib/components/Collapse/Collapse.js +13 -4
  76. package/dist/lib/components/ContentArea/ContentArea.css +8 -59
  77. package/dist/lib/components/ContentArea/ContentArea.d.ts +2 -6
  78. package/dist/lib/components/ContentArea/ContentArea.js +5 -41
  79. package/dist/lib/components/Counter/Counter.css +0 -47
  80. package/dist/lib/components/Grid/Grid.css +0 -47
  81. package/dist/lib/components/Header/Header.d.ts +6 -20
  82. package/dist/lib/components/Header/Header.js +30 -97
  83. package/dist/lib/components/InputLabel/InputLabel.d.ts +3 -0
  84. package/dist/lib/components/InputLabel/InputLabel.js +11 -3
  85. package/dist/lib/components/Link/Link.d.ts +6 -2
  86. package/dist/lib/components/Link/Link.js +33 -4
  87. package/dist/lib/components/Notification/Notification.css +0 -47
  88. package/dist/lib/components/Notification/Notification.d.ts +8 -0
  89. package/dist/lib/components/Notification/Notification.js +20 -3
  90. package/dist/lib/components/Pagination/Pagination.d.ts +9 -2
  91. package/dist/lib/components/Pagination/Pagination.js +20 -2
  92. package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.css +0 -47
  93. package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.d.ts +6 -3
  94. package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.js +11 -5
  95. package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +5 -2
  96. package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.js +9 -1
  97. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.css +0 -47
  98. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +5 -2
  99. package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +6 -1
  100. package/dist/lib/components/Paragraph/Paragraph.css +9 -11
  101. package/dist/lib/components/Paragraph/Paragraph.d.ts +12 -12
  102. package/dist/lib/components/Paragraph/Paragraph.js +15 -37
  103. package/dist/lib/components/Preloader/Preloader.d.ts +4 -0
  104. package/dist/lib/components/Preloader/Preloader.js +10 -4
  105. package/dist/lib/components/RadioButton/RadioButton.d.ts +8 -28
  106. package/dist/lib/components/RadioButton/RadioButton.js +51 -117
  107. package/dist/lib/components/Select/Select.d.ts +38 -5
  108. package/dist/lib/components/Select/Select.js +50 -34
  109. package/dist/lib/components/Tabs/Tab.d.ts +5 -2
  110. package/dist/lib/components/Tabs/Tab.js +4 -2
  111. package/dist/lib/components/Tabs/Tabs.d.ts +8 -0
  112. package/dist/lib/components/Tabs/Tabs.js +29 -21
  113. package/dist/lib/components/TextField/TextField.d.ts +8 -0
  114. package/dist/lib/components/TextField/TextField.js +20 -9
  115. package/dist/lib/components/TextLink/TextLink.js +7 -2
  116. package/dist/lib/components/Tile/Tile.d.ts +5 -2
  117. package/dist/lib/components/Tile/Tile.js +1 -1
  118. package/dist/lib/components/Tooltip/Tooltip.d.ts +5 -0
  119. package/dist/lib/components/Tooltip/Tooltip.js +9 -1
  120. package/package.json +5 -4
  121. package/styles/base.less +1 -60
  122. package/styles/colors.css +60 -0
  123. package/styles/colorsDark.css +62 -0
  124. package/styles/base.css +0 -54
@@ -1,8 +1,6 @@
1
1
  import * as React from 'react';
2
- import { IFilterDataAttrs } from '@megafon/ui-helpers';
3
- import * as PropTypes from 'prop-types';
4
2
  import './RadioButton.less';
5
- export interface IRadioButtonProps extends IFilterDataAttrs {
3
+ export interface IRadioButtonProps {
6
4
  /** Значение */
7
5
  value: string;
8
6
  /** Имя для тега form */
@@ -22,35 +20,17 @@ export interface IRadioButtonProps extends IFilterDataAttrs {
22
20
  customInput?: string;
23
21
  labelText?: string;
24
22
  };
23
+ /** Дополнительные data атрибуты к внутренним элементам */
24
+ dataAttrs?: {
25
+ root?: Record<string, string>;
26
+ input?: Record<string, string>;
27
+ text?: Record<string, string>;
28
+ };
25
29
  children?: React.ReactNode;
26
30
  /** Обработчик изменения значения 'value' */
27
31
  onChange?: (value: string) => void;
28
32
  /** Ссылка на input */
29
33
  inputRef?: React.Ref<HTMLInputElement>;
30
34
  }
31
- declare class RadioButton extends React.Component<IRadioButtonProps> {
32
- static propTypes: {
33
- value: PropTypes.Validator<string>;
34
- name: PropTypes.Requireable<string>;
35
- textSize: PropTypes.Requireable<string>;
36
- disabled: PropTypes.Requireable<boolean>;
37
- isChecked: PropTypes.Requireable<boolean>;
38
- className: PropTypes.Requireable<string>;
39
- classes: PropTypes.Requireable<PropTypes.InferProps<{
40
- root: PropTypes.Requireable<string>;
41
- label: PropTypes.Requireable<string>;
42
- customInput: PropTypes.Requireable<string>;
43
- labelText: PropTypes.Requireable<string>;
44
- }>>;
45
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
46
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
47
- inputRef: PropTypes.Requireable<any>;
48
- dataAttrs: PropTypes.Requireable<{
49
- [x: string]: string;
50
- }>;
51
- };
52
- static defaultProps: Partial<IRadioButtonProps>;
53
- handleChange: () => void;
54
- render(): JSX.Element;
55
- }
35
+ declare const RadioButton: React.FC<IRadioButtonProps>;
56
36
  export default RadioButton;
@@ -1,95 +1,60 @@
1
1
  import "core-js/modules/es.array.concat";
2
2
  import "core-js/modules/es.array.is-array";
3
- import "core-js/modules/es.date.to-string";
4
3
  import "core-js/modules/es.function.name";
5
- import "core-js/modules/es.object.to-string";
6
- import "core-js/modules/es.reflect.construct";
7
- import "core-js/modules/es.regexp.to-string";
8
4
  import _extends from "@babel/runtime/helpers/extends";
9
5
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
10
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
11
- import _createClass from "@babel/runtime/helpers/createClass";
12
- import _inherits from "@babel/runtime/helpers/inherits";
13
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
14
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
15
-
16
- function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
-
18
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19
-
20
6
  import * as React from 'react';
21
7
  import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
22
8
  import * as PropTypes from 'prop-types';
23
9
  import "./RadioButton.css";
24
10
  var cn = cnCreate('mfui-radio-button');
25
11
 
26
- var RadioButton = /*#__PURE__*/function (_React$Component) {
27
- _inherits(RadioButton, _React$Component);
28
-
29
- var _super = _createSuper(RadioButton);
30
-
31
- function RadioButton() {
32
- var _this;
33
-
34
- _classCallCheck(this, RadioButton);
12
+ var RadioButton = function RadioButton(_ref) {
13
+ var isChecked = _ref.isChecked,
14
+ _ref$disabled = _ref.disabled,
15
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
16
+ name = _ref.name,
17
+ value = _ref.value,
18
+ _ref$textSize = _ref.textSize,
19
+ textSize = _ref$textSize === void 0 ? 'medium' : _ref$textSize,
20
+ children = _ref.children,
21
+ inputRef = _ref.inputRef,
22
+ className = _ref.className,
23
+ _ref$classes = _ref.classes,
24
+ classes = _ref$classes === void 0 ? {} : _ref$classes,
25
+ dataAttrs = _ref.dataAttrs,
26
+ onChange = _ref.onChange;
27
+ var checkedProp = isChecked !== undefined ? {
28
+ checked: isChecked
29
+ } : {};
30
+ var rootClassNames = Array.isArray(className) ? [].concat(_toConsumableArray(className), [classes.root]) : [className, classes.root];
35
31
 
36
- _this = _super.apply(this, arguments);
32
+ var handleChange = function handleChange() {
33
+ return onChange && onChange(value);
34
+ };
37
35
 
38
- _this.handleChange = function () {
39
- var _this$props = _this.props,
40
- onChange = _this$props.onChange,
41
- value = _this$props.value;
42
- onChange && onChange(value);
43
- };
44
-
45
- return _this;
46
- }
47
-
48
- _createClass(RadioButton, [{
49
- key: "render",
50
- value: function render() {
51
- var _this$props2 = this.props,
52
- isChecked = _this$props2.isChecked,
53
- disabled = _this$props2.disabled,
54
- name = _this$props2.name,
55
- value = _this$props2.value,
56
- textSize = _this$props2.textSize,
57
- children = _this$props2.children,
58
- inputRef = _this$props2.inputRef,
59
- className = _this$props2.className,
60
- _this$props2$classes = _this$props2.classes,
61
- classes = _this$props2$classes === void 0 ? {} : _this$props2$classes,
62
- dataAttrs = _this$props2.dataAttrs;
63
- var checkedProp = isChecked !== undefined ? {
64
- checked: isChecked
65
- } : {};
66
- var rootClassNames = Array.isArray(className) ? [].concat(_toConsumableArray(className), [classes.root]) : [className, classes.root];
67
- return /*#__PURE__*/React.createElement("div", _extends({
68
- className: cn(rootClassNames)
69
- }, filterDataAttrs(dataAttrs)), /*#__PURE__*/React.createElement("label", {
70
- className: cn('label', {
71
- disabled: disabled
72
- }, classes.label)
73
- }, /*#__PURE__*/React.createElement("input", _extends({}, checkedProp, {
74
- className: cn('input'),
75
- type: "radio",
76
- name: name,
77
- value: value,
78
- onChange: this.handleChange,
79
- disabled: disabled,
80
- ref: inputRef
81
- })), /*#__PURE__*/React.createElement("div", {
82
- className: cn('custom-input', classes.customInput)
83
- }), children && /*#__PURE__*/React.createElement("div", {
84
- className: cn('text', {
85
- size: textSize
86
- }, classes.labelText)
87
- }, children)));
88
- }
89
- }]);
90
-
91
- return RadioButton;
92
- }(React.Component);
36
+ return /*#__PURE__*/React.createElement("div", _extends({
37
+ className: cn(rootClassNames)
38
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("label", {
39
+ className: cn('label', {
40
+ disabled: disabled
41
+ }, classes.label)
42
+ }, /*#__PURE__*/React.createElement("input", _extends({}, checkedProp, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input), {
43
+ className: cn('input'),
44
+ type: "radio",
45
+ name: name,
46
+ value: value,
47
+ onChange: handleChange,
48
+ disabled: disabled,
49
+ ref: inputRef
50
+ })), /*#__PURE__*/React.createElement("div", {
51
+ className: cn('custom-input', classes.customInput)
52
+ }), children && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.text), {
53
+ className: cn('text', {
54
+ size: textSize
55
+ }, classes.labelText)
56
+ }), children)));
57
+ };
93
58
 
94
59
  RadioButton.propTypes = {
95
60
  value: PropTypes.string.isRequired,
@@ -104,15 +69,15 @@ RadioButton.propTypes = {
104
69
  customInput: PropTypes.string,
105
70
  labelText: PropTypes.string
106
71
  }),
72
+ dataAttrs: PropTypes.shape({
73
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
74
+ input: PropTypes.objectOf(PropTypes.string.isRequired),
75
+ text: PropTypes.objectOf(PropTypes.string.isRequired)
76
+ }),
107
77
  children: PropTypes.node,
108
78
  onChange: PropTypes.func,
109
79
  inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
110
80
  current: PropTypes.elementType
111
- }), PropTypes.any])]),
112
- dataAttrs: PropTypes.objectOf(PropTypes.string.isRequired)
113
- };
114
- RadioButton.defaultProps = {
115
- textSize: 'medium',
116
- disabled: false
81
+ }), PropTypes.any])])
117
82
  };
118
83
  export default RadioButton;
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import { IFilterDataAttrs } from '@megafon/ui-helpers';
3
2
  import * as PropTypes from 'prop-types';
4
3
  import './Select.less';
5
4
  export declare const Verification: {
@@ -27,7 +26,7 @@ export interface ISelectItem<T extends SelectItemValueType> {
27
26
  /** Настраиваемое отображение выбранного элемента в поле селекта */
28
27
  selectedView?: JSX.Element | Element | React.ReactElement;
29
28
  }
30
- export interface ISelectProps<T extends SelectItemValueType> extends IFilterDataAttrs {
29
+ export interface ISelectProps<T extends SelectItemValueType> {
31
30
  /** Тип компонента */
32
31
  type?: SelectTypesType;
33
32
  /** Заголовок поля */
@@ -62,6 +61,17 @@ export interface ISelectProps<T extends SelectItemValueType> extends IFilterData
62
61
  listItem?: string;
63
62
  listItemTitle?: string;
64
63
  };
64
+ /** Дополнительные data атрибуты к внутренним элементам */
65
+ dataAttrs?: {
66
+ root?: Record<string, string>;
67
+ label?: Record<string, string>;
68
+ title?: Record<string, string>;
69
+ input?: Record<string, string>;
70
+ noticeText?: Record<string, string>;
71
+ listItem?: Record<string, string>;
72
+ listItemTitle?: Record<string, string>;
73
+ notFound?: Record<string, string>;
74
+ };
65
75
  /** Обработчик выбора элемента селекта */
66
76
  onSelect?: (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement> | null, dataItem?: ISelectItem<T>) => void;
67
77
  /** Обработчик при открытом селекте */
@@ -99,6 +109,32 @@ declare class Select<T extends SelectItemValueType> extends React.Component<ISel
99
109
  listItem: PropTypes.Requireable<string>;
100
110
  listItemTitle: PropTypes.Requireable<string>;
101
111
  }>>;
112
+ dataAttrs: PropTypes.Requireable<PropTypes.InferProps<{
113
+ root: PropTypes.Requireable<{
114
+ [x: string]: string;
115
+ }>;
116
+ label: PropTypes.Requireable<{
117
+ [x: string]: string;
118
+ }>;
119
+ title: PropTypes.Requireable<{
120
+ [x: string]: string;
121
+ }>;
122
+ input: PropTypes.Requireable<{
123
+ [x: string]: string;
124
+ }>;
125
+ noticeText: PropTypes.Requireable<{
126
+ [x: string]: string;
127
+ }>;
128
+ listItem: PropTypes.Requireable<{
129
+ [x: string]: string;
130
+ }>;
131
+ listItemTitle: PropTypes.Requireable<{
132
+ [x: string]: string;
133
+ }>;
134
+ notFound: PropTypes.Requireable<{
135
+ [x: string]: string;
136
+ }>;
137
+ }>>;
102
138
  items: PropTypes.Validator<(Required<PropTypes.InferProps<{
103
139
  view: PropTypes.Requireable<string | PropTypes.ReactElementLike | ((...args: any[]) => any)>;
104
140
  selectedView: PropTypes.Requireable<string | PropTypes.ReactElementLike | ((...args: any[]) => any)>;
@@ -106,9 +142,6 @@ declare class Select<T extends SelectItemValueType> extends React.Component<ISel
106
142
  value: PropTypes.Validator<string | number>;
107
143
  }>> | null | undefined)[]>;
108
144
  onSelect: PropTypes.Requireable<(...args: any[]) => any>;
109
- dataAttrs: PropTypes.Requireable<{
110
- [x: string]: string;
111
- }>;
112
145
  onOpened: PropTypes.Requireable<(...args: any[]) => any>;
113
146
  onClosed: PropTypes.Requireable<(...args: any[]) => any>;
114
147
  };
@@ -403,7 +403,8 @@ var Select = /*#__PURE__*/function (_React$Component) {
403
403
  placeholder = _this$props2.placeholder,
404
404
  items = _this$props2.items,
405
405
  currentValue = _this$props2.currentValue,
406
- classes = _this$props2.classes;
406
+ classes = _this$props2.classes,
407
+ dataAttrs = _this$props2.dataAttrs;
407
408
  var item = items.find(function (elem) {
408
409
  return elem.value === currentValue;
409
410
  });
@@ -413,42 +414,45 @@ var Select = /*#__PURE__*/function (_React$Component) {
413
414
  inputTitle = item.selectedView ? item.selectedView : item.title;
414
415
  }
415
416
 
416
- return /*#__PURE__*/React.createElement("div", {
417
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.title), {
417
418
  className: cn('title', {
418
419
  placeholder: !!placeholder && !currentValue
419
420
  }, [classes === null || classes === void 0 ? void 0 : classes.title]),
420
421
  role: "button",
421
422
  tabIndex: 0,
422
423
  onClick: this.handleOpenDropdown
423
- }, /*#__PURE__*/React.createElement("div", {
424
+ }), /*#__PURE__*/React.createElement("div", {
424
425
  className: cn('title-inner', [classes === null || classes === void 0 ? void 0 : classes.titleInner])
425
426
  }, inputTitle));
426
427
  }
427
428
  }, {
428
429
  key: "renderCombobox",
429
430
  value: function renderCombobox() {
430
- var placeholder = this.props.placeholder;
431
+ var _this$props3 = this.props,
432
+ placeholder = _this$props3.placeholder,
433
+ dataAttrs = _this$props3.dataAttrs;
431
434
  var inputValue = this.state.inputValue;
432
- return /*#__PURE__*/React.createElement("input", {
435
+ return /*#__PURE__*/React.createElement("input", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input), {
433
436
  className: cn('combobox'),
434
437
  onFocus: this.handleComboboxFocus,
435
438
  onChange: this.handleChangeCombobox,
436
439
  type: "text",
437
440
  value: inputValue,
438
441
  placeholder: placeholder
439
- });
442
+ }));
440
443
  }
441
444
  }, {
442
445
  key: "renderChildren",
443
446
  value: function renderChildren() {
444
447
  var _this2 = this;
445
448
 
446
- var _this$props3 = this.props,
447
- type = _this$props3.type,
448
- items = _this$props3.items,
449
- notFoundText = _this$props3.notFoundText,
450
- _this$props3$classes = _this$props3.classes,
451
- classes = _this$props3$classes === void 0 ? {} : _this$props3$classes;
449
+ var _this$props4 = this.props,
450
+ type = _this$props4.type,
451
+ items = _this$props4.items,
452
+ notFoundText = _this$props4.notFoundText,
453
+ _this$props4$classes = _this$props4.classes,
454
+ classes = _this$props4$classes === void 0 ? {} : _this$props4$classes,
455
+ dataAttrs = _this$props4.dataAttrs;
452
456
  var _this$state5 = this.state,
453
457
  filteredItems = _this$state5.filteredItems,
454
458
  activeIndex = _this$state5.activeIndex;
@@ -462,7 +466,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
462
466
  var title = _ref3.title,
463
467
  value = _ref3.value,
464
468
  view = _ref3.view;
465
- return /*#__PURE__*/React.createElement("div", {
469
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.listItem, i + 1), {
466
470
  className: cn('list-item', {
467
471
  active: activeIndex === i
468
472
  }, [classes.listItem]),
@@ -470,31 +474,31 @@ var Select = /*#__PURE__*/function (_React$Component) {
470
474
  onClick: _this2.handleSelectItem,
471
475
  onMouseEnter: _this2.handleHoverItem(i),
472
476
  ref: _this2.getNodeList
473
- }, /*#__PURE__*/React.createElement("div", {
477
+ }), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.listItemTitle, i + 1), {
474
478
  className: cn('item-title', [classes.listItemTitle])
475
- }, _this2.highlightString(title, view)));
476
- }), type === SelectTypes.COMBOBOX && !currentItems.length && /*#__PURE__*/React.createElement("div", {
479
+ }), _this2.highlightString(title, view)));
480
+ }), type === SelectTypes.COMBOBOX && !currentItems.length && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notFound), {
477
481
  className: cn('not-found')
478
- }, notFoundText)));
482
+ }), notFoundText)));
479
483
  }
480
484
  }, {
481
485
  key: "render",
482
486
  value: function render() {
483
- var _this$props4 = this.props,
484
- type = _this$props4.type,
485
- disabled = _this$props4.disabled,
486
- verification = _this$props4.verification,
487
- noticeText = _this$props4.noticeText,
488
- label = _this$props4.label,
489
- labelId = _this$props4.labelId,
490
- required = _this$props4.required,
491
- _this$props4$classNam = _this$props4.className,
492
- className = _this$props4$classNam === void 0 ? '' : _this$props4$classNam,
493
- _this$props4$classes = _this$props4.classes,
494
- classes = _this$props4$classes === void 0 ? {} : _this$props4$classes,
495
- dataAttrs = _this$props4.dataAttrs;
487
+ var _this$props5 = this.props,
488
+ type = _this$props5.type,
489
+ disabled = _this$props5.disabled,
490
+ verification = _this$props5.verification,
491
+ noticeText = _this$props5.noticeText,
492
+ label = _this$props5.label,
493
+ labelId = _this$props5.labelId,
494
+ required = _this$props5.required,
495
+ _this$props5$classNam = _this$props5.className,
496
+ className = _this$props5$classNam === void 0 ? '' : _this$props5$classNam,
497
+ _this$props5$classes = _this$props5.classes,
498
+ classes = _this$props5$classes === void 0 ? {} : _this$props5$classes,
499
+ dataAttrs = _this$props5.dataAttrs;
496
500
  var isOpened = this.state.isOpened;
497
- return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs), {
501
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
498
502
  className: cn({
499
503
  open: isOpened,
500
504
  disabled: disabled,
@@ -506,18 +510,21 @@ var Select = /*#__PURE__*/function (_React$Component) {
506
510
  }), /*#__PURE__*/React.createElement("div", {
507
511
  className: cn('inner')
508
512
  }, label && /*#__PURE__*/React.createElement(InputLabel, {
513
+ dataAttrs: {
514
+ root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.label
515
+ },
509
516
  htmlFor: labelId
510
517
  }, label, required && /*#__PURE__*/React.createElement("span", {
511
518
  className: cn('require-mark')
512
519
  }, "*")), /*#__PURE__*/React.createElement("div", {
513
520
  className: cn('control', classes.control),
514
521
  onKeyDown: this.handleKeyDown
515
- }, type === SelectTypes.COMBOBOX && this.renderCombobox(), type === SelectTypes.CLASSIC && this.renderTitle()), this.renderChildren()), noticeText && /*#__PURE__*/React.createElement("div", {
522
+ }, type === SelectTypes.COMBOBOX && this.renderCombobox(), type === SelectTypes.CLASSIC && this.renderTitle()), this.renderChildren()), noticeText && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.noticeText), {
516
523
  className: cn('text', {
517
524
  error: verification === Verification.ERROR,
518
525
  success: verification === Verification.VALID
519
526
  })
520
- }, noticeText));
527
+ }), noticeText));
521
528
  }
522
529
  }]);
523
530
 
@@ -545,6 +552,16 @@ Select.propTypes = {
545
552
  listItem: PropTypes.string,
546
553
  listItemTitle: PropTypes.string
547
554
  }),
555
+ dataAttrs: PropTypes.shape({
556
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
557
+ label: PropTypes.objectOf(PropTypes.string.isRequired),
558
+ title: PropTypes.objectOf(PropTypes.string.isRequired),
559
+ input: PropTypes.objectOf(PropTypes.string.isRequired),
560
+ noticeText: PropTypes.objectOf(PropTypes.string.isRequired),
561
+ listItem: PropTypes.objectOf(PropTypes.string.isRequired),
562
+ listItemTitle: PropTypes.objectOf(PropTypes.string.isRequired),
563
+ notFound: PropTypes.objectOf(PropTypes.string.isRequired)
564
+ }),
548
565
  items: PropTypes.arrayOf(PropTypes.exact({
549
566
  view: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]),
550
567
  selectedView: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]),
@@ -552,7 +569,6 @@ Select.propTypes = {
552
569
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
553
570
  })).isRequired,
554
571
  onSelect: PropTypes.func,
555
- dataAttrs: PropTypes.objectOf(PropTypes.string.isRequired),
556
572
  onOpened: PropTypes.func,
557
573
  onClosed: PropTypes.func
558
574
  };
@@ -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
  /** Горизонтальное выравнивание */
@@ -67,6 +67,7 @@ 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
+ dataAttrs = _ref.dataAttrs,
70
71
  onTabClick = _ref.onTabClick;
71
72
  var tabsRef = React.useRef([]);
72
73
  var rootRef = React.useRef(null);
@@ -186,6 +187,16 @@ var Tabs = function Tabs(_ref) {
186
187
  var handleNextArrowClick = React.useCallback(function () {
187
188
  swiperInstance === null || swiperInstance === void 0 ? void 0 : swiperInstance.slideNext();
188
189
  }, [swiperInstance]);
190
+ var handleReachBeginning = React.useCallback(function (swiper) {
191
+ setBeginning(swiper.isBeginning);
192
+ }, []);
193
+ var handleReachEnd = React.useCallback(function (swiper) {
194
+ setEnd(swiper.isEnd);
195
+ }, []);
196
+ var handleFromEdge = React.useCallback(function (swiper) {
197
+ setBeginning(swiper.isBeginning);
198
+ setEnd(swiper.isEnd);
199
+ }, []);
189
200
  var renderTab = React.useCallback(function (index, title, icon, href) {
190
201
  var ElementType = href ? 'a' : 'div';
191
202
  return /*#__PURE__*/React.createElement(ElementType, {
@@ -207,7 +218,7 @@ var Tabs = function Tabs(_ref) {
207
218
  icon = _child$props.icon,
208
219
  href = _child$props.href,
209
220
  renderTabWrapper = _child$props.renderTabWrapper,
210
- dataAttrs = _child$props.dataAttrs;
221
+ data = _child$props.dataAttrs;
211
222
  var tab = renderTab(i, title, icon, href);
212
223
  var activeTabClassName = currentIndex === i ? activeTabClass : undefined;
213
224
  return /*#__PURE__*/React.createElement(SwiperSlide, {
@@ -215,7 +226,7 @@ var Tabs = function Tabs(_ref) {
215
226
  }, /*#__PURE__*/React.createElement("div", _extends({
216
227
  className: cn('tab', [tabClass, activeTabClassName]),
217
228
  ref: setTabRef
218
- }, filterDataAttrs(dataAttrs)), renderTabWrapper ? renderTabWrapper(tab) : tab));
229
+ }, filterDataAttrs(data === null || data === void 0 ? void 0 : data.root, i + 1)), renderTabWrapper ? renderTabWrapper(tab) : tab));
219
230
  });
220
231
  }, [renderTab, children]);
221
232
  var renderPanels = React.useCallback(function () {
@@ -227,23 +238,13 @@ var Tabs = function Tabs(_ref) {
227
238
  return null;
228
239
  }
229
240
 
230
- return /*#__PURE__*/React.createElement("div", {
241
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.panel, i + 1), {
231
242
  className: cn('panel', {
232
243
  current: isCurrentPanel
233
244
  })
234
- }, panel);
245
+ }), panel);
235
246
  });
236
247
  }, [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
- }, []);
247
248
  React.useEffect(function () {
248
249
  var observer = new IntersectionObserver(function (entries) {
249
250
  entries.forEach(function (_ref2) {
@@ -320,7 +321,7 @@ var Tabs = function Tabs(_ref) {
320
321
  setBeginning(swiperInstance.isBeginning);
321
322
  setEnd(swiperInstance.isEnd);
322
323
  }, [swiperInstance]);
323
- return /*#__PURE__*/React.createElement("div", {
324
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
324
325
  className: cn({
325
326
  size: size,
326
327
  'h-align': hAlign,
@@ -329,7 +330,7 @@ var Tabs = function Tabs(_ref) {
329
330
  sticky: isSticky
330
331
  }, [className, rootClass]),
331
332
  ref: rootRef
332
- }, /*#__PURE__*/React.createElement("div", {
333
+ }), /*#__PURE__*/React.createElement("div", {
333
334
  ref: tabListRef,
334
335
  style: {
335
336
  height: tabListHeight
@@ -340,7 +341,7 @@ var Tabs = function Tabs(_ref) {
340
341
  paddingLeft: stickyOffset.left,
341
342
  paddingRight: stickyOffset.right
342
343
  }
343
- }, /*#__PURE__*/React.createElement(Swiper, {
344
+ }, /*#__PURE__*/React.createElement(Swiper, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.slider), {
344
345
  simulateTouch: false,
345
346
  className: cn('swiper', {
346
347
  beginning: isBeginning,
@@ -352,7 +353,7 @@ var Tabs = function Tabs(_ref) {
352
353
  onReachBeginning: handleReachBeginning,
353
354
  onReachEnd: handleReachEnd,
354
355
  onFromEdge: handleFromEdge
355
- }, renderTabs(), /*#__PURE__*/React.createElement("div", {
356
+ }), renderTabs(), /*#__PURE__*/React.createElement("div", {
356
357
  className: cn('underline'),
357
358
  slot: "wrapper-start",
358
359
  style: {
@@ -360,19 +361,19 @@ var Tabs = function Tabs(_ref) {
360
361
  transform: "translateX(".concat(underlineTranslate, "px)"),
361
362
  transitionProperty: underlineTransition
362
363
  }
363
- }), /*#__PURE__*/React.createElement(ArrowLeft, {
364
+ }), /*#__PURE__*/React.createElement(ArrowLeft, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prev), {
364
365
  className: cn('arrow', {
365
366
  prev: true,
366
367
  hide: isBeginning
367
368
  }),
368
369
  onClick: handlePrevArrowClick
369
- }), /*#__PURE__*/React.createElement(ArrowRight, {
370
+ })), /*#__PURE__*/React.createElement(ArrowRight, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.next), {
370
371
  className: cn('arrow', {
371
372
  next: true,
372
373
  hide: isEnd
373
374
  }),
374
375
  onClick: handleNextArrowClick
375
- })))), renderPanels());
376
+ }))))), renderPanels());
376
377
  };
377
378
 
378
379
  Tabs.propTypes = {
@@ -383,6 +384,13 @@ Tabs.propTypes = {
383
384
  tab: PropTypes.string,
384
385
  activeTab: PropTypes.string
385
386
  }),
387
+ dataAttrs: PropTypes.shape({
388
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
389
+ slider: PropTypes.objectOf(PropTypes.string.isRequired),
390
+ panel: PropTypes.objectOf(PropTypes.string.isRequired),
391
+ prev: PropTypes.objectOf(PropTypes.string.isRequired),
392
+ next: PropTypes.objectOf(PropTypes.string.isRequired)
393
+ }),
386
394
  size: PropTypes.oneOf(Object.values(TabSize)),
387
395
  hAlign: PropTypes.oneOf(Object.values(TabHAlign)),
388
396
  tabColorTheme: PropTypes.oneOf(Object.values(TabColorTheme)),