@megafon/ui-core 5.2.3 → 5.4.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,37 @@
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.4.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.3.0...@megafon/ui-core@5.4.0) (2023-11-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **snackbar:** fix swipe ([ce8b5eb](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/ce8b5ebd8bae725befab8adc08dbaa879f430bd4))
12
+ * **snackbar:** fix transform ([286e976](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/286e976a6bf395de41392efcd3cbf66ecc949a1a))
13
+ * **snackbar:** refactoring ([6f49ad1](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/6f49ad130d8ce2e810660ae0bbb7a270269d29e0))
14
+ * **snackbar:** refactoring ([b58f943](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/b58f943f364995da610374140287b64a229b7aed))
15
+ * **tabs:** fix text color in not active tab ([d0bd99b](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/d0bd99b710ce97813df671eeeb4edf6f8ae5be44))
16
+
17
+
18
+ ### Features
19
+
20
+ * **pricebadge:** add new iconType profile ([0259dd8](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/0259dd8c3989e4041bb0a4d9100e0a76352c1377))
21
+
22
+
23
+
24
+
25
+
26
+ # [5.3.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-core@5.2.3...@megafon/ui-core@5.3.0) (2023-11-08)
27
+
28
+
29
+ ### Features
30
+
31
+ * **selector:** create component Selector ([73d6aec](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/73d6aec573fe500471f0b557f0cbe0a9485b1fa3))
32
+
33
+
34
+
35
+
36
+
6
37
  ## [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
38
 
8
39
 
@@ -12,6 +12,7 @@ export declare const PriceBadgeIcon: {
12
12
  readonly CHECK: "check";
13
13
  readonly ATTENTION: "attention";
14
14
  readonly INFO: "info";
15
+ readonly PROFILE: "profile";
15
16
  };
16
17
  export declare const PriseBadgeSize: {
17
18
  readonly SMALL: "small";
@@ -5,6 +5,22 @@ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
5
5
  import * as PropTypes from 'prop-types';
6
6
  import "./PriceBadge.css";
7
7
 
8
+ var ProfileIcon = function ProfileIcon(props) {
9
+ return /*#__PURE__*/React.createElement("svg", _extends({
10
+ viewBox: "0 0 20 20"
11
+ }, props), /*#__PURE__*/React.createElement("path", {
12
+ d: "M5.22 18h9.55L16 13.47A8.28 8.28 0 0010 11a8.302 8.302 0 00-6 2.5L5.22 18zM14 6a4 4 0 10-8 0 4 4 0 008 0z"
13
+ }));
14
+ };
15
+
16
+ var ProfileIconBig = function ProfileIconBig(props) {
17
+ return /*#__PURE__*/React.createElement("svg", _extends({
18
+ viewBox: "0 0 32 32"
19
+ }, props), /*#__PURE__*/React.createElement("path", {
20
+ d: "M23 28l2-7.43-.32-.31A12.67 12.67 0 0016 17a12.68 12.68 0 00-8.68 3.27l-.32.3L9 28h14zM10 9a6 6 0 1012 0 6 6 0 00-12 0z"
21
+ }));
22
+ };
23
+
8
24
  var AttentionIcon = function AttentionIcon(props) {
9
25
  return /*#__PURE__*/React.createElement("svg", _extends({
10
26
  viewBox: "0 0 20 20"
@@ -108,7 +124,8 @@ export var PriceBadgeIcon = {
108
124
  PRICE: 'price',
109
125
  CHECK: 'check',
110
126
  ATTENTION: 'attention',
111
- INFO: 'info'
127
+ INFO: 'info',
128
+ PROFILE: 'profile'
112
129
  };
113
130
  export var PriseBadgeSize = {
114
131
  SMALL: 'small',
@@ -134,6 +151,9 @@ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType, size) {
134
151
  case iconType === PriceBadgeIcon.INFO && isBigIcon:
135
152
  return InfoIconBig;
136
153
 
154
+ case iconType === PriceBadgeIcon.PROFILE && isBigIcon:
155
+ return ProfileIconBig;
156
+
137
157
  case iconType === PriceBadgeIcon.PRICE:
138
158
  return PriceIcon;
139
159
 
@@ -146,6 +166,9 @@ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType, size) {
146
166
  case iconType === PriceBadgeIcon.INFO:
147
167
  return InfoIcon;
148
168
 
169
+ case iconType === PriceBadgeIcon.PROFILE:
170
+ return ProfileIcon;
171
+
149
172
  default:
150
173
  return TimerIcon;
151
174
  }
@@ -0,0 +1,98 @@
1
+ .mfui-selector__input {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ z-index: -1;
6
+ width: 0;
7
+ height: 0;
8
+ opacity: 0;
9
+ }
10
+ .mfui-selector__label {
11
+ position: relative;
12
+ display: -webkit-inline-box;
13
+ display: -ms-inline-flexbox;
14
+ display: inline-flex;
15
+ -webkit-box-align: center;
16
+ -ms-flex-align: center;
17
+ align-items: center;
18
+ outline: none;
19
+ cursor: pointer;
20
+ }
21
+ .mfui-selector__custom-input {
22
+ position: absolute;
23
+ display: -webkit-box;
24
+ display: -ms-flexbox;
25
+ display: flex;
26
+ -webkit-box-align: center;
27
+ -ms-flex-align: center;
28
+ align-items: center;
29
+ -webkit-box-pack: center;
30
+ -ms-flex-pack: center;
31
+ justify-content: center;
32
+ -webkit-box-sizing: border-box;
33
+ box-sizing: border-box;
34
+ width: 20px;
35
+ height: 20px;
36
+ border: 2px solid;
37
+ border-color: var(--spbSky2);
38
+ border-radius: 50%;
39
+ background-color: var(--base);
40
+ -webkit-transition: background-color, border-color;
41
+ transition: background-color, border-color;
42
+ -webkit-transition-duration: 0.3s;
43
+ transition-duration: 0.3s;
44
+ }
45
+ .mfui-selector__icon {
46
+ display: block;
47
+ width: 20px;
48
+ height: 20px;
49
+ opacity: 0;
50
+ -webkit-transition: fill, opacity;
51
+ transition: fill, opacity;
52
+ -webkit-transition-duration: 0.3s;
53
+ transition-duration: 0.3s;
54
+ fill: var(--stcWhite);
55
+ }
56
+ .mfui-selector__label:not(.mfui-selector__label_disabled):hover .mfui-selector__custom-input {
57
+ border-color: var(--buttonHoverGreen);
58
+ }
59
+ .mfui-selector__label:not(.mfui-selector__label_disabled):active .mfui-selector__custom-input {
60
+ border-color: var(--buttonDown);
61
+ }
62
+ .mfui-selector__label_disabled {
63
+ cursor: default;
64
+ }
65
+ .mfui-selector__label_disabled .mfui-selector__custom-input {
66
+ border-color: var(--spbSky2);
67
+ background-color: var(--spbSky1);
68
+ }
69
+ .mfui-selector__label_disabled .mfui-selector__input:checked + .mfui-selector__custom-input {
70
+ background-color: var(--spbSky2);
71
+ }
72
+ .mfui-selector__label_disabled .mfui-selector__input:checked + .mfui-selector__custom-input .mfui-selector__icon {
73
+ opacity: 1;
74
+ }
75
+ .mfui-selector__label:not(.mfui-selector__label_disabled):hover .mfui-selector__input:checked + .mfui-selector__custom-input {
76
+ border-color: var(--buttonHoverGreen);
77
+ background-color: var(--buttonHoverGreen);
78
+ }
79
+ .mfui-selector__label:not(.mfui-selector__label_disabled):hover .mfui-selector__input:checked + .mfui-selector__custom-input .mfui-selector__icon {
80
+ opacity: 1;
81
+ }
82
+ .mfui-selector__label:not(.mfui-selector__label_disabled):active .mfui-selector__input:checked + .mfui-selector__custom-input {
83
+ border-color: var(--buttonDown);
84
+ background-color: var(--buttonDown);
85
+ }
86
+ .mfui-selector__label:not(.mfui-selector__label_disabled):active .mfui-selector__input:checked + .mfui-selector__custom-input .mfui-selector__icon {
87
+ opacity: 1;
88
+ }
89
+ .mfui-selector__label:not(.mfui-selector__label_disabled) .mfui-selector__input:checked + .mfui-selector__custom-input {
90
+ border-color: var(--brandGreen);
91
+ background-color: var(--brandGreen);
92
+ }
93
+ .mfui-selector__label:not(.mfui-selector__label_disabled) .mfui-selector__input:checked + .mfui-selector__custom-input .mfui-selector__icon {
94
+ opacity: 1;
95
+ }
96
+ .mfui-selector__label_error .mfui-selector__custom-input {
97
+ border-color: var(--fury);
98
+ }
@@ -0,0 +1,39 @@
1
+ import * as React from 'react';
2
+ import './Selector.less';
3
+ export interface ISelectorProps {
4
+ /** Базовый тип компонента */
5
+ type?: 'radio' | 'checkbox';
6
+ /** Значение */
7
+ value: string;
8
+ /** Имя для тега form */
9
+ name?: string;
10
+ /** Управление состоянием вкл/выкл компонента */
11
+ checked?: boolean;
12
+ /** Управление состоянием компонента при типе checkbox */
13
+ checkedOptions?: string[];
14
+ /** Отключение компонента */
15
+ disabled?: boolean;
16
+ /** Отобразить компонент в состоянии ошибки */
17
+ error?: boolean;
18
+ /** Дополнительный класс корневого элемента */
19
+ className?: string;
20
+ /** Дополнительные классы для внутренних элементов */
21
+ classes?: {
22
+ label?: string;
23
+ customInput?: string;
24
+ };
25
+ /** Дополнительные data атрибуты к внутренним элементам */
26
+ dataAttrs?: {
27
+ root?: Record<string, string>;
28
+ label?: Record<string, string>;
29
+ input?: Record<string, string>;
30
+ customInput?: Record<string, string>;
31
+ };
32
+ children?: React.ReactNode;
33
+ /** Обработчик изменения значения 'value' */
34
+ onChange?: (value: string | string[]) => void;
35
+ /** Ссылка на input */
36
+ inputRef?: React.Ref<HTMLInputElement>;
37
+ }
38
+ declare const Selector: React.FC<ISelectorProps>;
39
+ export default Selector;
@@ -0,0 +1,94 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import "core-js/modules/es.function.name.js";
4
+ import "core-js/modules/es.array.includes.js";
5
+ import "core-js/modules/es.string.includes.js";
6
+ import "core-js/modules/es.array.filter.js";
7
+ import "core-js/modules/es.array.concat.js";
8
+ import * as React from 'react';
9
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
10
+ import * as PropTypes from 'prop-types';
11
+ import "./Selector.css";
12
+
13
+ var CheckedIcon = function CheckedIcon(props) {
14
+ return /*#__PURE__*/React.createElement("svg", _extends({
15
+ viewBox: "0 0 20 20"
16
+ }, props), /*#__PURE__*/React.createElement("path", {
17
+ d: "M8.832 11.547L6.619 9.335l-1.414 1.413 2.462 2.462 1.445 1.446 5.932-8.486-1.638-1.148-4.574 6.525z"
18
+ }));
19
+ };
20
+
21
+ var cn = cnCreate('mfui-selector');
22
+
23
+ var Selector = function Selector(_ref) {
24
+ var _ref$type = _ref.type,
25
+ type = _ref$type === void 0 ? 'radio' : _ref$type,
26
+ value = _ref.value,
27
+ name = _ref.name,
28
+ checked = _ref.checked,
29
+ _ref$checkedOptions = _ref.checkedOptions,
30
+ checkedOptions = _ref$checkedOptions === void 0 ? [] : _ref$checkedOptions,
31
+ _ref$disabled = _ref.disabled,
32
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
33
+ error = _ref.error,
34
+ className = _ref.className,
35
+ _ref$classes = _ref.classes,
36
+ classes = _ref$classes === void 0 ? {} : _ref$classes,
37
+ dataAttrs = _ref.dataAttrs,
38
+ children = _ref.children,
39
+ onChange = _ref.onChange,
40
+ inputRef = _ref.inputRef;
41
+
42
+ var handleChange = function handleChange() {
43
+ if (type === 'radio') {
44
+ return onChange === null || onChange === void 0 ? void 0 : onChange(value);
45
+ }
46
+
47
+ var isChecked = checkedOptions.includes(value);
48
+ var newCheckedOptions = isChecked ? checkedOptions.filter(function (option) {
49
+ return option !== value;
50
+ }) : [].concat(_toConsumableArray(checkedOptions), [value]);
51
+ return onChange === null || onChange === void 0 ? void 0 : onChange(newCheckedOptions);
52
+ };
53
+
54
+ return /*#__PURE__*/React.createElement("div", _extends({
55
+ className: cn('', className)
56
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("label", _extends({
57
+ className: cn('label', {
58
+ disabled: disabled,
59
+ error: error
60
+ }, classes.label)
61
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.label)), /*#__PURE__*/React.createElement("input", _extends({
62
+ className: cn('input'),
63
+ type: type,
64
+ name: name,
65
+ value: value,
66
+ checked: type === 'radio' ? checked : checkedOptions.includes(value),
67
+ disabled: disabled,
68
+ onChange: handleChange,
69
+ ref: inputRef
70
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input))), /*#__PURE__*/React.createElement("div", _extends({
71
+ className: cn('custom-input', classes.customInput)
72
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.customInput)), /*#__PURE__*/React.createElement(CheckedIcon, {
73
+ className: cn('icon')
74
+ })), children));
75
+ };
76
+
77
+ Selector.propTypes = {
78
+ type: PropTypes.oneOf(['radio', 'checkbox']),
79
+ value: PropTypes.string.isRequired,
80
+ name: PropTypes.string,
81
+ disabled: PropTypes.bool,
82
+ checked: PropTypes.bool,
83
+ checkedOptions: PropTypes.arrayOf(PropTypes.string.isRequired),
84
+ error: PropTypes.bool,
85
+ className: PropTypes.string,
86
+ classes: PropTypes.objectOf(PropTypes.string),
87
+ dataAttrs: PropTypes.objectOf(PropTypes.object),
88
+ children: PropTypes.node,
89
+ onChange: PropTypes.func,
90
+ inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
91
+ current: PropTypes.elementType
92
+ }), PropTypes.any])])
93
+ };
94
+ export default Selector;
@@ -0,0 +1,14 @@
1
+ .top-right {
2
+ top: 10px;
3
+ right: 10px;
4
+ }
5
+ .center {
6
+ top: 50%;
7
+ left: 50%;
8
+ -webkit-transform: translateX(-50%) translateY(-50%);
9
+ transform: translateX(-50%) translateY(-50%);
10
+ }
11
+ .bottom-left {
12
+ bottom: 10px;
13
+ left: 10px;
14
+ }
@@ -146,24 +146,30 @@
146
146
  box-sizing: border-box;
147
147
  height: 36px;
148
148
  padding: 2px 12px;
149
- color: var(--spbSky3);
149
+ color: var(--content);
150
150
  white-space: nowrap;
151
151
  text-align: center;
152
152
  text-decoration: none;
153
153
  cursor: pointer;
154
154
  -webkit-transition: color 0.3s, fill 0.3s;
155
155
  transition: color 0.3s, fill 0.3s;
156
- fill: var(--spbSky3);
156
+ fill: var(--content);
157
157
  }
158
158
  .mfui-tabs__tab-inner:hover {
159
159
  text-decoration: none;
160
160
  }
161
+ .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current) {
162
+ opacity: 0.8;
163
+ }
161
164
  @media screen and (min-width: 1024px) {
162
165
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
163
166
  color: var(--content);
164
167
  fill: var(--content);
165
168
  }
166
169
  }
170
+ .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
171
+ opacity: 1;
172
+ }
167
173
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):active {
168
174
  color: var(--buttonDown);
169
175
  fill: var(--buttonDown);
@@ -255,11 +261,13 @@
255
261
  background-color: var(--stcBlack20);
256
262
  }
257
263
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:not(.mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current) {
258
- color: #ffffffb2;
259
- fill: #ffffffb2;
264
+ color: var(--stcWhite);
265
+ opacity: 0.8;
266
+ fill: var(--stcWhite);
260
267
  }
261
268
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:not(.mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current):hover {
262
269
  color: var(--stcWhite);
270
+ opacity: 1;
263
271
  fill: var(--stcWhite);
264
272
  }
265
273
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current {
@@ -35,6 +35,7 @@ export { default as PromoBadge } from './components/Badges/components/PromoBadge
35
35
  export { default as RadioButton } from './components/RadioButton/RadioButton';
36
36
  export { default as Search } from './components/Search/Search';
37
37
  export { default as Select } from './components/Select/Select';
38
+ export { default as Selector } from './components/Selector/Selector';
38
39
  export { default as selectReducer } from './components/Select/reducer/selectReducer';
39
40
  export { default as Snackbar } from './components/Snackbar/Snackbar';
40
41
  export { default as SnackbarTimer } from './components/Snackbar/SnackbarTimer/SnackbarTimer';
package/dist/es/index.js CHANGED
@@ -35,6 +35,7 @@ export { default as PromoBadge } from "./components/Badges/components/PromoBadge
35
35
  export { default as RadioButton } from "./components/RadioButton/RadioButton";
36
36
  export { default as Search } from "./components/Search/Search";
37
37
  export { default as Select } from "./components/Select/Select";
38
+ export { default as Selector } from "./components/Selector/Selector";
38
39
  export { default as selectReducer } from "./components/Select/reducer/selectReducer";
39
40
  export { default as Snackbar } from "./components/Snackbar/Snackbar";
40
41
  export { default as SnackbarTimer } from "./components/Snackbar/SnackbarTimer/SnackbarTimer";
@@ -12,6 +12,7 @@ export declare const PriceBadgeIcon: {
12
12
  readonly CHECK: "check";
13
13
  readonly ATTENTION: "attention";
14
14
  readonly INFO: "info";
15
+ readonly PROFILE: "profile";
15
16
  };
16
17
  export declare const PriseBadgeSize: {
17
18
  readonly SMALL: "small";
@@ -23,6 +23,22 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
25
 
26
+ var ProfileIcon = function ProfileIcon(props) {
27
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
28
+ viewBox: "0 0 20 20"
29
+ }, props), /*#__PURE__*/React.createElement("path", {
30
+ d: "M5.22 18h9.55L16 13.47A8.28 8.28 0 0010 11a8.302 8.302 0 00-6 2.5L5.22 18zM14 6a4 4 0 10-8 0 4 4 0 008 0z"
31
+ }));
32
+ };
33
+
34
+ var ProfileIconBig = function ProfileIconBig(props) {
35
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
36
+ viewBox: "0 0 32 32"
37
+ }, props), /*#__PURE__*/React.createElement("path", {
38
+ d: "M23 28l2-7.43-.32-.31A12.67 12.67 0 0016 17a12.68 12.68 0 00-8.68 3.27l-.32.3L9 28h14zM10 9a6 6 0 1012 0 6 6 0 00-12 0z"
39
+ }));
40
+ };
41
+
26
42
  var AttentionIcon = function AttentionIcon(props) {
27
43
  return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
28
44
  viewBox: "0 0 20 20"
@@ -127,7 +143,8 @@ var PriceBadgeIcon = {
127
143
  PRICE: 'price',
128
144
  CHECK: 'check',
129
145
  ATTENTION: 'attention',
130
- INFO: 'info'
146
+ INFO: 'info',
147
+ PROFILE: 'profile'
131
148
  };
132
149
  exports.PriceBadgeIcon = PriceBadgeIcon;
133
150
  var PriseBadgeSize = {
@@ -155,6 +172,9 @@ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType, size) {
155
172
  case iconType === PriceBadgeIcon.INFO && isBigIcon:
156
173
  return InfoIconBig;
157
174
 
175
+ case iconType === PriceBadgeIcon.PROFILE && isBigIcon:
176
+ return ProfileIconBig;
177
+
158
178
  case iconType === PriceBadgeIcon.PRICE:
159
179
  return PriceIcon;
160
180
 
@@ -167,6 +187,9 @@ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType, size) {
167
187
  case iconType === PriceBadgeIcon.INFO:
168
188
  return InfoIcon;
169
189
 
190
+ case iconType === PriceBadgeIcon.PROFILE:
191
+ return ProfileIcon;
192
+
170
193
  default:
171
194
  return TimerIcon;
172
195
  }
@@ -0,0 +1,98 @@
1
+ .mfui-selector__input {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ z-index: -1;
6
+ width: 0;
7
+ height: 0;
8
+ opacity: 0;
9
+ }
10
+ .mfui-selector__label {
11
+ position: relative;
12
+ display: -webkit-inline-box;
13
+ display: -ms-inline-flexbox;
14
+ display: inline-flex;
15
+ -webkit-box-align: center;
16
+ -ms-flex-align: center;
17
+ align-items: center;
18
+ outline: none;
19
+ cursor: pointer;
20
+ }
21
+ .mfui-selector__custom-input {
22
+ position: absolute;
23
+ display: -webkit-box;
24
+ display: -ms-flexbox;
25
+ display: flex;
26
+ -webkit-box-align: center;
27
+ -ms-flex-align: center;
28
+ align-items: center;
29
+ -webkit-box-pack: center;
30
+ -ms-flex-pack: center;
31
+ justify-content: center;
32
+ -webkit-box-sizing: border-box;
33
+ box-sizing: border-box;
34
+ width: 20px;
35
+ height: 20px;
36
+ border: 2px solid;
37
+ border-color: var(--spbSky2);
38
+ border-radius: 50%;
39
+ background-color: var(--base);
40
+ -webkit-transition: background-color, border-color;
41
+ transition: background-color, border-color;
42
+ -webkit-transition-duration: 0.3s;
43
+ transition-duration: 0.3s;
44
+ }
45
+ .mfui-selector__icon {
46
+ display: block;
47
+ width: 20px;
48
+ height: 20px;
49
+ opacity: 0;
50
+ -webkit-transition: fill, opacity;
51
+ transition: fill, opacity;
52
+ -webkit-transition-duration: 0.3s;
53
+ transition-duration: 0.3s;
54
+ fill: var(--stcWhite);
55
+ }
56
+ .mfui-selector__label:not(.mfui-selector__label_disabled):hover .mfui-selector__custom-input {
57
+ border-color: var(--buttonHoverGreen);
58
+ }
59
+ .mfui-selector__label:not(.mfui-selector__label_disabled):active .mfui-selector__custom-input {
60
+ border-color: var(--buttonDown);
61
+ }
62
+ .mfui-selector__label_disabled {
63
+ cursor: default;
64
+ }
65
+ .mfui-selector__label_disabled .mfui-selector__custom-input {
66
+ border-color: var(--spbSky2);
67
+ background-color: var(--spbSky1);
68
+ }
69
+ .mfui-selector__label_disabled .mfui-selector__input:checked + .mfui-selector__custom-input {
70
+ background-color: var(--spbSky2);
71
+ }
72
+ .mfui-selector__label_disabled .mfui-selector__input:checked + .mfui-selector__custom-input .mfui-selector__icon {
73
+ opacity: 1;
74
+ }
75
+ .mfui-selector__label:not(.mfui-selector__label_disabled):hover .mfui-selector__input:checked + .mfui-selector__custom-input {
76
+ border-color: var(--buttonHoverGreen);
77
+ background-color: var(--buttonHoverGreen);
78
+ }
79
+ .mfui-selector__label:not(.mfui-selector__label_disabled):hover .mfui-selector__input:checked + .mfui-selector__custom-input .mfui-selector__icon {
80
+ opacity: 1;
81
+ }
82
+ .mfui-selector__label:not(.mfui-selector__label_disabled):active .mfui-selector__input:checked + .mfui-selector__custom-input {
83
+ border-color: var(--buttonDown);
84
+ background-color: var(--buttonDown);
85
+ }
86
+ .mfui-selector__label:not(.mfui-selector__label_disabled):active .mfui-selector__input:checked + .mfui-selector__custom-input .mfui-selector__icon {
87
+ opacity: 1;
88
+ }
89
+ .mfui-selector__label:not(.mfui-selector__label_disabled) .mfui-selector__input:checked + .mfui-selector__custom-input {
90
+ border-color: var(--brandGreen);
91
+ background-color: var(--brandGreen);
92
+ }
93
+ .mfui-selector__label:not(.mfui-selector__label_disabled) .mfui-selector__input:checked + .mfui-selector__custom-input .mfui-selector__icon {
94
+ opacity: 1;
95
+ }
96
+ .mfui-selector__label_error .mfui-selector__custom-input {
97
+ border-color: var(--fury);
98
+ }
@@ -0,0 +1,39 @@
1
+ import * as React from 'react';
2
+ import './Selector.less';
3
+ export interface ISelectorProps {
4
+ /** Базовый тип компонента */
5
+ type?: 'radio' | 'checkbox';
6
+ /** Значение */
7
+ value: string;
8
+ /** Имя для тега form */
9
+ name?: string;
10
+ /** Управление состоянием вкл/выкл компонента */
11
+ checked?: boolean;
12
+ /** Управление состоянием компонента при типе checkbox */
13
+ checkedOptions?: string[];
14
+ /** Отключение компонента */
15
+ disabled?: boolean;
16
+ /** Отобразить компонент в состоянии ошибки */
17
+ error?: boolean;
18
+ /** Дополнительный класс корневого элемента */
19
+ className?: string;
20
+ /** Дополнительные классы для внутренних элементов */
21
+ classes?: {
22
+ label?: string;
23
+ customInput?: string;
24
+ };
25
+ /** Дополнительные data атрибуты к внутренним элементам */
26
+ dataAttrs?: {
27
+ root?: Record<string, string>;
28
+ label?: Record<string, string>;
29
+ input?: Record<string, string>;
30
+ customInput?: Record<string, string>;
31
+ };
32
+ children?: React.ReactNode;
33
+ /** Обработчик изменения значения 'value' */
34
+ onChange?: (value: string | string[]) => void;
35
+ /** Ссылка на input */
36
+ inputRef?: React.Ref<HTMLInputElement>;
37
+ }
38
+ declare const Selector: React.FC<ISelectorProps>;
39
+ export default Selector;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ require("core-js/modules/es.function.name.js");
15
+
16
+ require("core-js/modules/es.array.includes.js");
17
+
18
+ require("core-js/modules/es.string.includes.js");
19
+
20
+ require("core-js/modules/es.array.filter.js");
21
+
22
+ require("core-js/modules/es.array.concat.js");
23
+
24
+ var React = _interopRequireWildcard(require("react"));
25
+
26
+ var _uiHelpers = require("@megafon/ui-helpers");
27
+
28
+ var PropTypes = _interopRequireWildcard(require("prop-types"));
29
+
30
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
+
32
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
+
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
35
+
36
+ var CheckedIcon = function CheckedIcon(props) {
37
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
38
+ viewBox: "0 0 20 20"
39
+ }, props), /*#__PURE__*/React.createElement("path", {
40
+ d: "M8.832 11.547L6.619 9.335l-1.414 1.413 2.462 2.462 1.445 1.446 5.932-8.486-1.638-1.148-4.574 6.525z"
41
+ }));
42
+ };
43
+
44
+ var cn = (0, _uiHelpers.cnCreate)('mfui-selector');
45
+
46
+ var Selector = function Selector(_ref) {
47
+ var _ref$type = _ref.type,
48
+ type = _ref$type === void 0 ? 'radio' : _ref$type,
49
+ value = _ref.value,
50
+ name = _ref.name,
51
+ checked = _ref.checked,
52
+ _ref$checkedOptions = _ref.checkedOptions,
53
+ checkedOptions = _ref$checkedOptions === void 0 ? [] : _ref$checkedOptions,
54
+ _ref$disabled = _ref.disabled,
55
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
56
+ error = _ref.error,
57
+ className = _ref.className,
58
+ _ref$classes = _ref.classes,
59
+ classes = _ref$classes === void 0 ? {} : _ref$classes,
60
+ dataAttrs = _ref.dataAttrs,
61
+ children = _ref.children,
62
+ onChange = _ref.onChange,
63
+ inputRef = _ref.inputRef;
64
+
65
+ var handleChange = function handleChange() {
66
+ if (type === 'radio') {
67
+ return onChange === null || onChange === void 0 ? void 0 : onChange(value);
68
+ }
69
+
70
+ var isChecked = checkedOptions.includes(value);
71
+ var newCheckedOptions = isChecked ? checkedOptions.filter(function (option) {
72
+ return option !== value;
73
+ }) : [].concat((0, _toConsumableArray2["default"])(checkedOptions), [value]);
74
+ return onChange === null || onChange === void 0 ? void 0 : onChange(newCheckedOptions);
75
+ };
76
+
77
+ return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
78
+ className: cn('', className)
79
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("label", (0, _extends2["default"])({
80
+ className: cn('label', {
81
+ disabled: disabled,
82
+ error: error
83
+ }, classes.label)
84
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.label)), /*#__PURE__*/React.createElement("input", (0, _extends2["default"])({
85
+ className: cn('input'),
86
+ type: type,
87
+ name: name,
88
+ value: value,
89
+ checked: type === 'radio' ? checked : checkedOptions.includes(value),
90
+ disabled: disabled,
91
+ onChange: handleChange,
92
+ ref: inputRef
93
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input))), /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
94
+ className: cn('custom-input', classes.customInput)
95
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.customInput)), /*#__PURE__*/React.createElement(CheckedIcon, {
96
+ className: cn('icon')
97
+ })), children));
98
+ };
99
+
100
+ Selector.propTypes = {
101
+ type: PropTypes.oneOf(['radio', 'checkbox']),
102
+ value: PropTypes.string.isRequired,
103
+ name: PropTypes.string,
104
+ disabled: PropTypes.bool,
105
+ checked: PropTypes.bool,
106
+ checkedOptions: PropTypes.arrayOf(PropTypes.string.isRequired),
107
+ error: PropTypes.bool,
108
+ className: PropTypes.string,
109
+ classes: PropTypes.objectOf(PropTypes.string),
110
+ dataAttrs: PropTypes.objectOf(PropTypes.object),
111
+ children: PropTypes.node,
112
+ onChange: PropTypes.func,
113
+ inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
114
+ current: PropTypes.elementType
115
+ }), PropTypes.any])])
116
+ };
117
+ var _default = Selector;
118
+ exports["default"] = _default;
@@ -0,0 +1,14 @@
1
+ .top-right {
2
+ top: 10px;
3
+ right: 10px;
4
+ }
5
+ .center {
6
+ top: 50%;
7
+ left: 50%;
8
+ -webkit-transform: translateX(-50%) translateY(-50%);
9
+ transform: translateX(-50%) translateY(-50%);
10
+ }
11
+ .bottom-left {
12
+ bottom: 10px;
13
+ left: 10px;
14
+ }
@@ -146,24 +146,30 @@
146
146
  box-sizing: border-box;
147
147
  height: 36px;
148
148
  padding: 2px 12px;
149
- color: var(--spbSky3);
149
+ color: var(--content);
150
150
  white-space: nowrap;
151
151
  text-align: center;
152
152
  text-decoration: none;
153
153
  cursor: pointer;
154
154
  -webkit-transition: color 0.3s, fill 0.3s;
155
155
  transition: color 0.3s, fill 0.3s;
156
- fill: var(--spbSky3);
156
+ fill: var(--content);
157
157
  }
158
158
  .mfui-tabs__tab-inner:hover {
159
159
  text-decoration: none;
160
160
  }
161
+ .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current) {
162
+ opacity: 0.8;
163
+ }
161
164
  @media screen and (min-width: 1024px) {
162
165
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
163
166
  color: var(--content);
164
167
  fill: var(--content);
165
168
  }
166
169
  }
170
+ .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
171
+ opacity: 1;
172
+ }
167
173
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):active {
168
174
  color: var(--buttonDown);
169
175
  fill: var(--buttonDown);
@@ -255,11 +261,13 @@
255
261
  background-color: var(--stcBlack20);
256
262
  }
257
263
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:not(.mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current) {
258
- color: #ffffffb2;
259
- fill: #ffffffb2;
264
+ color: var(--stcWhite);
265
+ opacity: 0.8;
266
+ fill: var(--stcWhite);
260
267
  }
261
268
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:not(.mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current):hover {
262
269
  color: var(--stcWhite);
270
+ opacity: 1;
263
271
  fill: var(--stcWhite);
264
272
  }
265
273
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner_current {
@@ -35,6 +35,7 @@ export { default as PromoBadge } from './components/Badges/components/PromoBadge
35
35
  export { default as RadioButton } from './components/RadioButton/RadioButton';
36
36
  export { default as Search } from './components/Search/Search';
37
37
  export { default as Select } from './components/Select/Select';
38
+ export { default as Selector } from './components/Selector/Selector';
38
39
  export { default as selectReducer } from './components/Select/reducer/selectReducer';
39
40
  export { default as Snackbar } from './components/Snackbar/Snackbar';
40
41
  export { default as SnackbarTimer } from './components/Snackbar/SnackbarTimer/SnackbarTimer';
package/dist/lib/index.js CHANGED
@@ -225,6 +225,12 @@ Object.defineProperty(exports, "Select", {
225
225
  return _Select["default"];
226
226
  }
227
227
  });
228
+ Object.defineProperty(exports, "Selector", {
229
+ enumerable: true,
230
+ get: function get() {
231
+ return _Selector["default"];
232
+ }
233
+ });
228
234
  Object.defineProperty(exports, "selectReducer", {
229
235
  enumerable: true,
230
236
  get: function get() {
@@ -384,6 +390,8 @@ var _Search = _interopRequireDefault(require("./components/Search/Search"));
384
390
 
385
391
  var _Select = _interopRequireDefault(require("./components/Select/Select"));
386
392
 
393
+ var _Selector = _interopRequireDefault(require("./components/Selector/Selector"));
394
+
387
395
  var _selectReducer = _interopRequireDefault(require("./components/Select/reducer/selectReducer"));
388
396
 
389
397
  var _Snackbar = _interopRequireDefault(require("./components/Snackbar/Snackbar"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "5.2.3",
3
+ "version": "5.4.0",
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.1",
53
+ "@megafon/ui-icons": "^2.15.0",
54
54
  "@svgr/core": "^2.4.1",
55
55
  "@testing-library/jest-dom": "5.16.2",
56
56
  "@testing-library/react": "12.1.2",
@@ -96,5 +96,5 @@
96
96
  "react-popper": "^2.2.3",
97
97
  "swiper": "^6.5.6"
98
98
  },
99
- "gitHead": "1bb6769da99d917f5dd4420892c57a7af5be3ab4"
99
+ "gitHead": "e78c7c397c514016ee74020939dc3807e09bf49a"
100
100
  }