@megafon/ui-core 5.2.1 → 5.2.3

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,29 @@
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
+ ## [5.2.3](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.2.2...@megafon/ui-core@5.2.3) (2023-10-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **preloader:** add new prop disableAnimate ([5b1fc46](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/5b1fc469ccab408679e07e64ce3e04474a410c09))
12
+ * **switcher:** add new prop waiting ([78b8bb9](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/78b8bb9d115ed0a45d529a1204f5a3d5d132a330))
13
+
14
+
15
+
16
+
17
+
18
+ ## [5.2.2](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.2.1...@megafon/ui-core@5.2.2) (2023-09-14)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **colors:** replace dark buttonHoverPurpleSoft color ([0b68d15](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/0b68d15cb053f4e9020e28e0a997c81e070f060c))
24
+
25
+
26
+
27
+
28
+
6
29
  ## [5.2.1](https://hq-gitlab.megafon.ru/site-portal/libraries/javascript/megafon-ui/compare/@megafon/ui-core@5.2.0...@megafon/ui-core@5.2.1) (2023-08-28)
7
30
 
8
31
 
@@ -138,6 +138,10 @@
138
138
  -webkit-animation-delay: 0.33s;
139
139
  animation-delay: 0.33s;
140
140
  }
141
+ .mfui-preloader_disable-animate .mfui-preloader__item:before {
142
+ -webkit-animation: none;
143
+ animation: none;
144
+ }
141
145
  @-webkit-keyframes scaling {
142
146
  0% {
143
147
  -webkit-transform: scale(1);
@@ -26,6 +26,8 @@ export interface IPreloaderProps {
26
26
  sizeTablet?: PreloaderSizesType;
27
27
  /** Размер на разрешении экрана 0-767 */
28
28
  sizeMobile?: PreloaderSizesType;
29
+ /** Отмена анимации */
30
+ disableAnimate?: boolean;
29
31
  /** Дополнительный класс корневого элемента */
30
32
  className?: string;
31
33
  /** Дополнительные data атрибуты к внутренним элементам */
@@ -24,6 +24,8 @@ var Preloader = function Preloader(_ref) {
24
24
  sizeAll = _ref$sizeAll === void 0 ? 'medium' : _ref$sizeAll,
25
25
  _ref$delay = _ref.delay,
26
26
  delay = _ref$delay === void 0 ? true : _ref$delay,
27
+ _ref$disableAnimate = _ref.disableAnimate,
28
+ disableAnimate = _ref$disableAnimate === void 0 ? false : _ref$disableAnimate,
27
29
  sizeWide = _ref.sizeWide,
28
30
  sizeDesktop = _ref.sizeDesktop,
29
31
  sizeTablet = _ref.sizeTablet,
@@ -55,7 +57,8 @@ var Preloader = function Preloader(_ref) {
55
57
  'size-wide': sizeWide,
56
58
  'size-desktop': sizeDesktop,
57
59
  'size-tablet': sizeTablet,
58
- 'size-mobile': sizeMobile
60
+ 'size-mobile': sizeMobile,
61
+ 'disable-animate': disableAnimate
59
62
  }, className)
60
63
  }), /*#__PURE__*/React.createElement("div", {
61
64
  className: cn('item', {
@@ -79,6 +82,7 @@ Preloader.propTypes = {
79
82
  sizeDesktop: PropTypes.oneOf(Object.values(PreloaderSizes)),
80
83
  sizeTablet: PropTypes.oneOf(Object.values(PreloaderSizes)),
81
84
  sizeMobile: PropTypes.oneOf(Object.values(PreloaderSizes)),
85
+ disableAnimate: PropTypes.bool,
82
86
  className: PropTypes.string,
83
87
  dataAttrs: PropTypes.shape({
84
88
  root: PropTypes.objectOf(PropTypes.string.isRequired)
@@ -75,6 +75,27 @@
75
75
  transform: translateX(0);
76
76
  }
77
77
  }
78
+ .mfui-switcher__timer {
79
+ position: absolute;
80
+ top: 50%;
81
+ left: 50%;
82
+ width: 20px;
83
+ height: 20px;
84
+ border-radius: 50%;
85
+ background: var(--base);
86
+ -webkit-transform: translate(-50%, -50%);
87
+ transform: translate(-50%, -50%);
88
+ }
89
+ .mfui-switcher__timer-icon {
90
+ position: absolute;
91
+ top: 50%;
92
+ left: 50%;
93
+ width: 20px;
94
+ height: 20px;
95
+ -webkit-transform: translate(-50%, -50%);
96
+ transform: translate(-50%, -50%);
97
+ fill: var(--spbSky2);
98
+ }
78
99
  .mfui-switcher__input {
79
100
  position: relative;
80
101
  -ms-flex-item-align: start;
@@ -96,7 +117,8 @@
96
117
  background-color: var(--spbSky1);
97
118
  }
98
119
  .mfui-switcher__input_disabled,
99
- .mfui-switcher__input_loaded {
120
+ .mfui-switcher__input_loaded,
121
+ .mfui-switcher__input_waiting {
100
122
  cursor: default;
101
123
  }
102
124
  .mfui-switcher__input:hover:not(.mfui-switcher__input_disabled) {
@@ -7,12 +7,16 @@ export interface ISwitcherProps {
7
7
  root?: Record<string, string>;
8
8
  input?: Record<string, string>;
9
9
  loader?: Record<string, string>;
10
+ pointer?: Record<string, string>;
11
+ timer?: Record<string, string>;
10
12
  };
11
13
  /** Дополнительный класс корневого элемента */
12
14
  className?: string;
13
15
  /** Управление состоянием вкл/выкл компонента */
14
16
  checked?: boolean;
15
- /** Отключение переключателя */
17
+ /** Состояние ожидание */
18
+ waiting?: boolean;
19
+ /** сот */
16
20
  disabled?: boolean;
17
21
  /** Состояние загрузки */
18
22
  showLoader?: boolean;
@@ -3,6 +3,17 @@ import * as React from 'react';
3
3
  import { checkEventIsClickOrEnterPress, cnCreate, detectTouch, filterDataAttrs } from '@megafon/ui-helpers';
4
4
  import * as PropTypes from 'prop-types';
5
5
  import "./Switcher.css";
6
+
7
+ var WaitingIcon = function WaitingIcon(props) {
8
+ return /*#__PURE__*/React.createElement("svg", _extends({
9
+ viewBox: "0 0 20 20"
10
+ }, props), /*#__PURE__*/React.createElement("path", {
11
+ fillRule: "evenodd",
12
+ clipRule: "evenodd",
13
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-8.414V5H9v5.414l3 3L13.414 12 11 9.586z"
14
+ }));
15
+ };
16
+
6
17
  var cn = cnCreate('mfui-switcher');
7
18
 
8
19
  var Switcher = function Switcher(_ref) {
@@ -14,6 +25,8 @@ var Switcher = function Switcher(_ref) {
14
25
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
15
26
  _ref$showLoader = _ref.showLoader,
16
27
  showLoader = _ref$showLoader === void 0 ? false : _ref$showLoader,
28
+ _ref$waiting = _ref.waiting,
29
+ waiting = _ref$waiting === void 0 ? false : _ref$waiting,
17
30
  children = _ref.children,
18
31
  _ref$textSize = _ref.textSize,
19
32
  textSize = _ref$textSize === void 0 ? 'medium' : _ref$textSize,
@@ -23,7 +36,9 @@ var Switcher = function Switcher(_ref) {
23
36
  var isTouch = detectTouch();
24
37
  var isLeftContent = !!children && textPosition === 'left';
25
38
  var isRightContent = !!children && textPosition === 'right';
26
- var isInteractiveDisabled = showLoader || disabled;
39
+ var isNoProcesses = disabled || waiting;
40
+ var isInteractiveDisabled = showLoader || isNoProcesses;
41
+ var isLoaderDisplayed = showLoader && !isNoProcesses;
27
42
  var handleChange = React.useCallback(function (e) {
28
43
  if (isInteractiveDisabled || !checkEventIsClickOrEnterPress(e)) {
29
44
  return;
@@ -42,19 +57,23 @@ var Switcher = function Switcher(_ref) {
42
57
  })
43
58
  }, children), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input), {
44
59
  className: cn('input', {
45
- checked: checked,
46
- disabled: disabled,
47
- loaded: showLoader,
60
+ checked: checked && !waiting,
61
+ disabled: isNoProcesses,
62
+ loaded: showLoader && !waiting,
48
63
  'no-touch': !isTouch
49
64
  }),
50
65
  onClick: handleChange,
51
66
  onKeyDown: handleChange,
52
67
  tabIndex: isInteractiveDisabled ? undefined : 0
53
- }), showLoader && !disabled && /*#__PURE__*/React.createElement("div", _extends({
68
+ }), isLoaderDisplayed && /*#__PURE__*/React.createElement("div", _extends({
54
69
  className: cn('loader')
55
- }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.loader))), /*#__PURE__*/React.createElement("div", {
70
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.loader))), waiting ? /*#__PURE__*/React.createElement("div", _extends({
71
+ className: cn('timer')
72
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.timer)), /*#__PURE__*/React.createElement(WaitingIcon, {
73
+ className: cn('timer-icon')
74
+ })) : /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.pointer), {
56
75
  className: cn('pointer')
57
- })), isRightContent && /*#__PURE__*/React.createElement("div", {
76
+ }))), isRightContent && /*#__PURE__*/React.createElement("div", {
58
77
  className: cn('content', {
59
78
  size: textSize
60
79
  })
@@ -72,6 +91,7 @@ Switcher.propTypes = {
72
91
  textPosition: PropTypes.oneOf(['left', 'right']),
73
92
  checked: PropTypes.bool,
74
93
  disabled: PropTypes.bool,
94
+ waiting: PropTypes.bool,
75
95
  showLoader: PropTypes.bool,
76
96
  onChange: PropTypes.func
77
97
  };
@@ -138,6 +138,10 @@
138
138
  -webkit-animation-delay: 0.33s;
139
139
  animation-delay: 0.33s;
140
140
  }
141
+ .mfui-preloader_disable-animate .mfui-preloader__item:before {
142
+ -webkit-animation: none;
143
+ animation: none;
144
+ }
141
145
  @-webkit-keyframes scaling {
142
146
  0% {
143
147
  -webkit-transform: scale(1);
@@ -26,6 +26,8 @@ export interface IPreloaderProps {
26
26
  sizeTablet?: PreloaderSizesType;
27
27
  /** Размер на разрешении экрана 0-767 */
28
28
  sizeMobile?: PreloaderSizesType;
29
+ /** Отмена анимации */
30
+ disableAnimate?: boolean;
29
31
  /** Дополнительный класс корневого элемента */
30
32
  className?: string;
31
33
  /** Дополнительные data атрибуты к внутренним элементам */
@@ -47,6 +47,8 @@ var Preloader = function Preloader(_ref) {
47
47
  sizeAll = _ref$sizeAll === void 0 ? 'medium' : _ref$sizeAll,
48
48
  _ref$delay = _ref.delay,
49
49
  delay = _ref$delay === void 0 ? true : _ref$delay,
50
+ _ref$disableAnimate = _ref.disableAnimate,
51
+ disableAnimate = _ref$disableAnimate === void 0 ? false : _ref$disableAnimate,
50
52
  sizeWide = _ref.sizeWide,
51
53
  sizeDesktop = _ref.sizeDesktop,
52
54
  sizeTablet = _ref.sizeTablet,
@@ -78,7 +80,8 @@ var Preloader = function Preloader(_ref) {
78
80
  'size-wide': sizeWide,
79
81
  'size-desktop': sizeDesktop,
80
82
  'size-tablet': sizeTablet,
81
- 'size-mobile': sizeMobile
83
+ 'size-mobile': sizeMobile,
84
+ 'disable-animate': disableAnimate
82
85
  }, className)
83
86
  }), /*#__PURE__*/React.createElement("div", {
84
87
  className: cn('item', {
@@ -102,6 +105,7 @@ Preloader.propTypes = {
102
105
  sizeDesktop: PropTypes.oneOf(Object.values(PreloaderSizes)),
103
106
  sizeTablet: PropTypes.oneOf(Object.values(PreloaderSizes)),
104
107
  sizeMobile: PropTypes.oneOf(Object.values(PreloaderSizes)),
108
+ disableAnimate: PropTypes.bool,
105
109
  className: PropTypes.string,
106
110
  dataAttrs: PropTypes.shape({
107
111
  root: PropTypes.objectOf(PropTypes.string.isRequired)
@@ -75,6 +75,27 @@
75
75
  transform: translateX(0);
76
76
  }
77
77
  }
78
+ .mfui-switcher__timer {
79
+ position: absolute;
80
+ top: 50%;
81
+ left: 50%;
82
+ width: 20px;
83
+ height: 20px;
84
+ border-radius: 50%;
85
+ background: var(--base);
86
+ -webkit-transform: translate(-50%, -50%);
87
+ transform: translate(-50%, -50%);
88
+ }
89
+ .mfui-switcher__timer-icon {
90
+ position: absolute;
91
+ top: 50%;
92
+ left: 50%;
93
+ width: 20px;
94
+ height: 20px;
95
+ -webkit-transform: translate(-50%, -50%);
96
+ transform: translate(-50%, -50%);
97
+ fill: var(--spbSky2);
98
+ }
78
99
  .mfui-switcher__input {
79
100
  position: relative;
80
101
  -ms-flex-item-align: start;
@@ -96,7 +117,8 @@
96
117
  background-color: var(--spbSky1);
97
118
  }
98
119
  .mfui-switcher__input_disabled,
99
- .mfui-switcher__input_loaded {
120
+ .mfui-switcher__input_loaded,
121
+ .mfui-switcher__input_waiting {
100
122
  cursor: default;
101
123
  }
102
124
  .mfui-switcher__input:hover:not(.mfui-switcher__input_disabled) {
@@ -7,12 +7,16 @@ export interface ISwitcherProps {
7
7
  root?: Record<string, string>;
8
8
  input?: Record<string, string>;
9
9
  loader?: Record<string, string>;
10
+ pointer?: Record<string, string>;
11
+ timer?: Record<string, string>;
10
12
  };
11
13
  /** Дополнительный класс корневого элемента */
12
14
  className?: string;
13
15
  /** Управление состоянием вкл/выкл компонента */
14
16
  checked?: boolean;
15
- /** Отключение переключателя */
17
+ /** Состояние ожидание */
18
+ waiting?: boolean;
19
+ /** сот */
16
20
  disabled?: boolean;
17
21
  /** Состояние загрузки */
18
22
  showLoader?: boolean;
@@ -21,6 +21,16 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
21
21
 
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
23
 
24
+ var WaitingIcon = function WaitingIcon(props) {
25
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
26
+ viewBox: "0 0 20 20"
27
+ }, props), /*#__PURE__*/React.createElement("path", {
28
+ fillRule: "evenodd",
29
+ clipRule: "evenodd",
30
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-8.414V5H9v5.414l3 3L13.414 12 11 9.586z"
31
+ }));
32
+ };
33
+
24
34
  var cn = (0, _uiHelpers.cnCreate)('mfui-switcher');
25
35
 
26
36
  var Switcher = function Switcher(_ref) {
@@ -32,6 +42,8 @@ var Switcher = function Switcher(_ref) {
32
42
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
33
43
  _ref$showLoader = _ref.showLoader,
34
44
  showLoader = _ref$showLoader === void 0 ? false : _ref$showLoader,
45
+ _ref$waiting = _ref.waiting,
46
+ waiting = _ref$waiting === void 0 ? false : _ref$waiting,
35
47
  children = _ref.children,
36
48
  _ref$textSize = _ref.textSize,
37
49
  textSize = _ref$textSize === void 0 ? 'medium' : _ref$textSize,
@@ -41,7 +53,9 @@ var Switcher = function Switcher(_ref) {
41
53
  var isTouch = (0, _uiHelpers.detectTouch)();
42
54
  var isLeftContent = !!children && textPosition === 'left';
43
55
  var isRightContent = !!children && textPosition === 'right';
44
- var isInteractiveDisabled = showLoader || disabled;
56
+ var isNoProcesses = disabled || waiting;
57
+ var isInteractiveDisabled = showLoader || isNoProcesses;
58
+ var isLoaderDisplayed = showLoader && !isNoProcesses;
45
59
  var handleChange = React.useCallback(function (e) {
46
60
  if (isInteractiveDisabled || !(0, _uiHelpers.checkEventIsClickOrEnterPress)(e)) {
47
61
  return;
@@ -60,19 +74,23 @@ var Switcher = function Switcher(_ref) {
60
74
  })
61
75
  }, children), /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input), {
62
76
  className: cn('input', {
63
- checked: checked,
64
- disabled: disabled,
65
- loaded: showLoader,
77
+ checked: checked && !waiting,
78
+ disabled: isNoProcesses,
79
+ loaded: showLoader && !waiting,
66
80
  'no-touch': !isTouch
67
81
  }),
68
82
  onClick: handleChange,
69
83
  onKeyDown: handleChange,
70
84
  tabIndex: isInteractiveDisabled ? undefined : 0
71
- }), showLoader && !disabled && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
85
+ }), isLoaderDisplayed && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
72
86
  className: cn('loader')
73
- }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.loader))), /*#__PURE__*/React.createElement("div", {
87
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.loader))), waiting ? /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
88
+ className: cn('timer')
89
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.timer)), /*#__PURE__*/React.createElement(WaitingIcon, {
90
+ className: cn('timer-icon')
91
+ })) : /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.pointer), {
74
92
  className: cn('pointer')
75
- })), isRightContent && /*#__PURE__*/React.createElement("div", {
93
+ }))), isRightContent && /*#__PURE__*/React.createElement("div", {
76
94
  className: cn('content', {
77
95
  size: textSize
78
96
  })
@@ -90,6 +108,7 @@ Switcher.propTypes = {
90
108
  textPosition: PropTypes.oneOf(['left', 'right']),
91
109
  checked: PropTypes.bool,
92
110
  disabled: PropTypes.bool,
111
+ waiting: PropTypes.bool,
93
112
  showLoader: PropTypes.bool,
94
113
  onChange: PropTypes.func
95
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "5.2.1",
3
+ "version": "5.2.3",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -50,7 +50,7 @@
50
50
  "@babel/preset-env": "^7.8.6",
51
51
  "@babel/preset-react": "^7.8.3",
52
52
  "@babel/preset-typescript": "^7.8.3",
53
- "@megafon/ui-icons": "^2.14.0",
53
+ "@megafon/ui-icons": "^2.14.1",
54
54
  "@svgr/core": "^2.4.1",
55
55
  "@testing-library/jest-dom": "5.16.2",
56
56
  "@testing-library/react": "12.1.2",
@@ -85,7 +85,7 @@
85
85
  "dependencies": {
86
86
  "@babel/runtime": "^7.8.4",
87
87
  "@datepicker-react/hooks": "^2.7.0",
88
- "@megafon/ui-helpers": "^2.5.2",
88
+ "@megafon/ui-helpers": "^2.5.3",
89
89
  "@popperjs/core": "^2.5.3",
90
90
  "core-js": "^3.6.4",
91
91
  "date-fns": "^2.16.1",
@@ -96,5 +96,5 @@
96
96
  "react-popper": "^2.2.3",
97
97
  "swiper": "^6.5.6"
98
98
  },
99
- "gitHead": "61659ea89aca6bac2ebcd3befa866f430ad0ee30"
99
+ "gitHead": "1bb6769da99d917f5dd4420892c57a7af5be3ab4"
100
100
  }
@@ -23,7 +23,7 @@
23
23
  --buttonHoverGreen: #10E272;
24
24
  --buttonHoverGreenSoft: #355A46;
25
25
  --buttonHoverPurple: #A500BF;
26
- --buttonHoverPurpleSoft: #FFE1FF;
26
+ --buttonHoverPurpleSoft: #492B50;
27
27
  --buttonHoverGrey: #D6D6D6;
28
28
  --buttonDown: #404D46;
29
29
  --overlay: #000000CC;