@megafon/ui-core 4.9.0 → 4.9.1

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,14 @@
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.9.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.9.0...@megafon/ui-core@4.9.1) (2022-12-06)
7
+
8
+ **Note:** Version bump only for package @megafon/ui-core
9
+
10
+
11
+
12
+
13
+
6
14
  # [4.9.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.8.2...@megafon/ui-core@4.9.0) (2022-11-29)
7
15
 
8
16
 
@@ -29,7 +29,7 @@ var Counter = function Counter(_ref) {
29
29
  _ref$isControlled = _ref.isControlled,
30
30
  isControlled = _ref$isControlled === void 0 ? false : _ref$isControlled,
31
31
  _ref$value = _ref.value,
32
- value = _ref$value === void 0 ? 0 : _ref$value,
32
+ outerValue = _ref$value === void 0 ? 0 : _ref$value,
33
33
  initialValue = _ref.initialValue,
34
34
  _ref$max = _ref.max,
35
35
  max = _ref$max === void 0 ? 999999 : _ref$max,
@@ -45,15 +45,16 @@ var Counter = function Counter(_ref) {
45
45
 
46
46
  var _React$useState = React.useState(currentInitialValue),
47
47
  _React$useState2 = _slicedToArray(_React$useState, 2),
48
- counter = _React$useState2[0],
49
- setCounter = _React$useState2[1];
48
+ innerValue = _React$useState2[0],
49
+ setInnerValue = _React$useState2[1];
50
50
 
51
+ var currentValue = isControlled ? outerValue : innerValue;
51
52
  React.useEffect(function () {
52
- setCounter(currentInitialValue);
53
+ setInnerValue(currentInitialValue);
53
54
  }, [currentInitialValue]);
54
55
  var handleValueChange = React.useCallback(function (inputValue) {
55
56
  if (!isControlled) {
56
- setCounter(inputValue);
57
+ setInnerValue(inputValue);
57
58
  }
58
59
 
59
60
  if (inputValue < min) {
@@ -69,11 +70,11 @@ var Counter = function Counter(_ref) {
69
70
  }
70
71
  }, [min, max, onChange, isControlled]);
71
72
  var handleMinusClick = React.useCallback(function () {
72
- handleValueChange(isControlled ? value - 1 : counter - 1);
73
- }, [handleValueChange, counter, isControlled, value]);
73
+ handleValueChange(currentValue - 1);
74
+ }, [handleValueChange, currentValue]);
74
75
  var handlePlusClick = React.useCallback(function () {
75
- handleValueChange(isControlled ? value + 1 : counter + 1);
76
- }, [handleValueChange, counter, isControlled, value]);
76
+ handleValueChange(currentValue + 1);
77
+ }, [handleValueChange, currentValue]);
77
78
  var handleInputChange = React.useCallback(function (e) {
78
79
  var pattern = /^[0-9\b]+$/;
79
80
  var inputValue = e.target.value;
@@ -106,7 +107,7 @@ var Counter = function Counter(_ref) {
106
107
  left: true
107
108
  }, classes.buttonMinus),
108
109
  type: "button",
109
- disabled: disabled || (isControlled ? value : counter) <= min,
110
+ disabled: disabled || currentValue <= min,
110
111
  onClick: handleMinusClick
111
112
  }), /*#__PURE__*/React.createElement(IconMinus, {
112
113
  className: cn('icon')
@@ -114,7 +115,7 @@ var Counter = function Counter(_ref) {
114
115
  className: cn('input-box')
115
116
  }, /*#__PURE__*/React.createElement("input", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input), {
116
117
  className: cn('input', classes.input),
117
- value: isControlled ? value : counter,
118
+ value: currentValue,
118
119
  onChange: handleInputChange,
119
120
  onBlur: handleInputBlur,
120
121
  disabled: disabled
@@ -123,7 +124,7 @@ var Counter = function Counter(_ref) {
123
124
  right: true
124
125
  }, classes.buttonPlus),
125
126
  type: "button",
126
- disabled: disabled || counter >= max || value >= max,
127
+ disabled: disabled || currentValue >= max,
127
128
  onClick: handlePlusClick
128
129
  }), /*#__PURE__*/React.createElement(IconPlus, {
129
130
  className: cn('icon')
@@ -4,13 +4,17 @@ export interface ILogoProps {
4
4
  /** Дополнительный класс корневого элемента */
5
5
  className?: string;
6
6
  /** Цвет */
7
- color?: string;
7
+ color?: 'green';
8
8
  /** Отображение */
9
9
  view?: 'horizontal' | 'vertical';
10
10
  /** Ссылка */
11
11
  href?: string;
12
12
  /** target - аргумент тега <a> */
13
13
  target?: '_self' | '_blank' | '_parent' | '_top';
14
+ /** Дополнительные data атрибуты к внутренним элементам */
15
+ dataAttrs?: {
16
+ root?: Record<string, string>;
17
+ };
14
18
  }
15
19
  declare const Logo: React.FC<ILogoProps>;
16
20
  export default Logo;
@@ -60,13 +60,15 @@ var Logo = function Logo(_ref) {
60
60
  _ref$target = _ref.target,
61
61
  target = _ref$target === void 0 ? '_blank' : _ref$target,
62
62
  _ref$href = _ref.href,
63
- href = _ref$href === void 0 ? '/' : _ref$href;
63
+ href = _ref$href === void 0 ? '/' : _ref$href,
64
+ dataAttrs = _ref.dataAttrs;
64
65
  var images = {
65
66
  'green-horizontal': greenHorizontalImg,
66
67
  'green-vertical': greenVerticalImg
67
68
  };
68
69
  var BackgroundImage = images["".concat(color, "-").concat(view)];
69
70
  return /*#__PURE__*/React.createElement(Link, {
71
+ dataAttrs: dataAttrs,
70
72
  href: href,
71
73
  target: target,
72
74
  className: cn('', {
@@ -80,10 +82,13 @@ var Logo = function Logo(_ref) {
80
82
  };
81
83
 
82
84
  Logo.propTypes = {
83
- color: PropTypes.string,
85
+ color: PropTypes.oneOf(['green']),
84
86
  view: PropTypes.oneOf(['horizontal', 'vertical']),
85
87
  target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
86
88
  href: PropTypes.string,
87
- className: PropTypes.string
89
+ className: PropTypes.string,
90
+ dataAttrs: PropTypes.shape({
91
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
92
+ })
88
93
  };
89
94
  export default Logo;
@@ -13,6 +13,8 @@ declare type ViewType = typeof View[keyof typeof View];
13
13
  export interface INavArrowProps {
14
14
  dataAttrs?: {
15
15
  root?: Record<string, string>;
16
+ prevArrow?: Record<string, string>;
17
+ nextArrow?: Record<string, string>;
16
18
  };
17
19
  className?: string;
18
20
  theme?: ThemeType;
@@ -44,16 +44,16 @@ var NavArrow = function NavArrow(_ref) {
44
44
  var renderIcon = React.useCallback(function () {
45
45
  switch (view) {
46
46
  case View.PREV:
47
- return /*#__PURE__*/React.createElement(ArrowLeft, {
47
+ return /*#__PURE__*/React.createElement(ArrowLeft, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prevArrow), {
48
48
  className: cn('icon')
49
- });
49
+ }));
50
50
 
51
51
  default:
52
- return /*#__PURE__*/React.createElement(ArrowRight, {
52
+ return /*#__PURE__*/React.createElement(ArrowRight, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.nextArrow), {
53
53
  className: cn('icon')
54
- });
54
+ }));
55
55
  }
56
- }, [view]);
56
+ }, [dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prevArrow, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.nextArrow, view]);
57
57
  return /*#__PURE__*/React.createElement("button", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
58
58
  type: "button",
59
59
  className: cn({
@@ -66,7 +66,9 @@ var NavArrow = function NavArrow(_ref) {
66
66
 
67
67
  NavArrow.propTypes = {
68
68
  dataAttrs: PropTypes.shape({
69
- root: PropTypes.objectOf(PropTypes.string.isRequired)
69
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
70
+ prevArrow: PropTypes.objectOf(PropTypes.string.isRequired),
71
+ nextArrow: PropTypes.objectOf(PropTypes.string.isRequired)
70
72
  }),
71
73
  className: PropTypes.string,
72
74
  theme: PropTypes.oneOf(Object.values(Theme)),
@@ -48,7 +48,7 @@ var Counter = function Counter(_ref) {
48
48
  _ref$isControlled = _ref.isControlled,
49
49
  isControlled = _ref$isControlled === void 0 ? false : _ref$isControlled,
50
50
  _ref$value = _ref.value,
51
- value = _ref$value === void 0 ? 0 : _ref$value,
51
+ outerValue = _ref$value === void 0 ? 0 : _ref$value,
52
52
  initialValue = _ref.initialValue,
53
53
  _ref$max = _ref.max,
54
54
  max = _ref$max === void 0 ? 999999 : _ref$max,
@@ -64,15 +64,16 @@ var Counter = function Counter(_ref) {
64
64
 
65
65
  var _React$useState = React.useState(currentInitialValue),
66
66
  _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
67
- counter = _React$useState2[0],
68
- setCounter = _React$useState2[1];
67
+ innerValue = _React$useState2[0],
68
+ setInnerValue = _React$useState2[1];
69
69
 
70
+ var currentValue = isControlled ? outerValue : innerValue;
70
71
  React.useEffect(function () {
71
- setCounter(currentInitialValue);
72
+ setInnerValue(currentInitialValue);
72
73
  }, [currentInitialValue]);
73
74
  var handleValueChange = React.useCallback(function (inputValue) {
74
75
  if (!isControlled) {
75
- setCounter(inputValue);
76
+ setInnerValue(inputValue);
76
77
  }
77
78
 
78
79
  if (inputValue < min) {
@@ -88,11 +89,11 @@ var Counter = function Counter(_ref) {
88
89
  }
89
90
  }, [min, max, onChange, isControlled]);
90
91
  var handleMinusClick = React.useCallback(function () {
91
- handleValueChange(isControlled ? value - 1 : counter - 1);
92
- }, [handleValueChange, counter, isControlled, value]);
92
+ handleValueChange(currentValue - 1);
93
+ }, [handleValueChange, currentValue]);
93
94
  var handlePlusClick = React.useCallback(function () {
94
- handleValueChange(isControlled ? value + 1 : counter + 1);
95
- }, [handleValueChange, counter, isControlled, value]);
95
+ handleValueChange(currentValue + 1);
96
+ }, [handleValueChange, currentValue]);
96
97
  var handleInputChange = React.useCallback(function (e) {
97
98
  var pattern = /^[0-9\b]+$/;
98
99
  var inputValue = e.target.value;
@@ -125,7 +126,7 @@ var Counter = function Counter(_ref) {
125
126
  left: true
126
127
  }, classes.buttonMinus),
127
128
  type: "button",
128
- disabled: disabled || (isControlled ? value : counter) <= min,
129
+ disabled: disabled || currentValue <= min,
129
130
  onClick: handleMinusClick
130
131
  }), /*#__PURE__*/React.createElement(IconMinus, {
131
132
  className: cn('icon')
@@ -133,7 +134,7 @@ var Counter = function Counter(_ref) {
133
134
  className: cn('input-box')
134
135
  }, /*#__PURE__*/React.createElement("input", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input), {
135
136
  className: cn('input', classes.input),
136
- value: isControlled ? value : counter,
137
+ value: currentValue,
137
138
  onChange: handleInputChange,
138
139
  onBlur: handleInputBlur,
139
140
  disabled: disabled
@@ -142,7 +143,7 @@ var Counter = function Counter(_ref) {
142
143
  right: true
143
144
  }, classes.buttonPlus),
144
145
  type: "button",
145
- disabled: disabled || counter >= max || value >= max,
146
+ disabled: disabled || currentValue >= max,
146
147
  onClick: handlePlusClick
147
148
  }), /*#__PURE__*/React.createElement(IconPlus, {
148
149
  className: cn('icon')
@@ -4,13 +4,17 @@ export interface ILogoProps {
4
4
  /** Дополнительный класс корневого элемента */
5
5
  className?: string;
6
6
  /** Цвет */
7
- color?: string;
7
+ color?: 'green';
8
8
  /** Отображение */
9
9
  view?: 'horizontal' | 'vertical';
10
10
  /** Ссылка */
11
11
  href?: string;
12
12
  /** target - аргумент тега <a> */
13
13
  target?: '_self' | '_blank' | '_parent' | '_top';
14
+ /** Дополнительные data атрибуты к внутренним элементам */
15
+ dataAttrs?: {
16
+ root?: Record<string, string>;
17
+ };
14
18
  }
15
19
  declare const Logo: React.FC<ILogoProps>;
16
20
  export default Logo;
@@ -79,13 +79,15 @@ var Logo = function Logo(_ref) {
79
79
  _ref$target = _ref.target,
80
80
  target = _ref$target === void 0 ? '_blank' : _ref$target,
81
81
  _ref$href = _ref.href,
82
- href = _ref$href === void 0 ? '/' : _ref$href;
82
+ href = _ref$href === void 0 ? '/' : _ref$href,
83
+ dataAttrs = _ref.dataAttrs;
83
84
  var images = {
84
85
  'green-horizontal': greenHorizontalImg,
85
86
  'green-vertical': greenVerticalImg
86
87
  };
87
88
  var BackgroundImage = images["".concat(color, "-").concat(view)];
88
89
  return /*#__PURE__*/React.createElement(_Link["default"], {
90
+ dataAttrs: dataAttrs,
89
91
  href: href,
90
92
  target: target,
91
93
  className: cn('', {
@@ -99,11 +101,14 @@ var Logo = function Logo(_ref) {
99
101
  };
100
102
 
101
103
  Logo.propTypes = {
102
- color: PropTypes.string,
104
+ color: PropTypes.oneOf(['green']),
103
105
  view: PropTypes.oneOf(['horizontal', 'vertical']),
104
106
  target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
105
107
  href: PropTypes.string,
106
- className: PropTypes.string
108
+ className: PropTypes.string,
109
+ dataAttrs: PropTypes.shape({
110
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
111
+ })
107
112
  };
108
113
  var _default = Logo;
109
114
  exports["default"] = _default;
@@ -13,6 +13,8 @@ declare type ViewType = typeof View[keyof typeof View];
13
13
  export interface INavArrowProps {
14
14
  dataAttrs?: {
15
15
  root?: Record<string, string>;
16
+ prevArrow?: Record<string, string>;
17
+ nextArrow?: Record<string, string>;
16
18
  };
17
19
  className?: string;
18
20
  theme?: ThemeType;
@@ -64,16 +64,16 @@ var NavArrow = function NavArrow(_ref) {
64
64
  var renderIcon = React.useCallback(function () {
65
65
  switch (view) {
66
66
  case View.PREV:
67
- return /*#__PURE__*/React.createElement(ArrowLeft, {
67
+ return /*#__PURE__*/React.createElement(ArrowLeft, (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prevArrow), {
68
68
  className: cn('icon')
69
- });
69
+ }));
70
70
 
71
71
  default:
72
- return /*#__PURE__*/React.createElement(ArrowRight, {
72
+ return /*#__PURE__*/React.createElement(ArrowRight, (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.nextArrow), {
73
73
  className: cn('icon')
74
- });
74
+ }));
75
75
  }
76
- }, [view]);
76
+ }, [dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prevArrow, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.nextArrow, view]);
77
77
  return /*#__PURE__*/React.createElement("button", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
78
78
  type: "button",
79
79
  className: cn({
@@ -86,7 +86,9 @@ var NavArrow = function NavArrow(_ref) {
86
86
 
87
87
  NavArrow.propTypes = {
88
88
  dataAttrs: PropTypes.shape({
89
- root: PropTypes.objectOf(PropTypes.string.isRequired)
89
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
90
+ prevArrow: PropTypes.objectOf(PropTypes.string.isRequired),
91
+ nextArrow: PropTypes.objectOf(PropTypes.string.isRequired)
90
92
  }),
91
93
  className: PropTypes.string,
92
94
  theme: PropTypes.oneOf(Object.values(Theme)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -100,5 +100,5 @@
100
100
  "react-popper": "^2.2.3",
101
101
  "swiper": "^6.5.6"
102
102
  },
103
- "gitHead": "ab9cb505dca6ae5f4e3db5d4a21add24d10a1be1"
103
+ "gitHead": "079e229d423944ab3643730e461d4d5b4342cff0"
104
104
  }