@megafon/ui-core 3.3.0 → 3.5.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 +48 -0
- package/dist/es/components/Badges/components/PriceBadge/PriceBadge.css +13 -5
- package/dist/es/components/Badges/components/PriceBadge/PriceBadge.js +4 -2
- package/dist/es/components/Badges/components/PromoBadge/PromoBadge.css +4 -1
- package/dist/es/components/Badges/components/PromoBadge/PromoBadge.d.ts +1 -0
- package/dist/es/components/Badges/components/PromoBadge/PromoBadge.js +1 -0
- package/dist/es/components/Badges/components/TimerBadge/Timer/Timer.d.ts +13 -0
- package/dist/es/components/Badges/components/TimerBadge/Timer/Timer.js +96 -0
- package/dist/es/components/Badges/components/TimerBadge/TimerBadge.css +60 -0
- package/dist/es/components/Badges/components/TimerBadge/TimerBadge.d.ts +24 -0
- package/dist/es/components/Badges/components/TimerBadge/TimerBadge.js +110 -0
- package/dist/es/components/Button/Button.d.ts +1 -1
- package/dist/es/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/es/components/Collapse/Collapse.js +1 -0
- package/dist/es/components/Counter/Counter.d.ts +1 -1
- package/dist/es/components/Logo/Logo.css +5 -0
- package/dist/es/components/Notification/Notification.css +15 -21
- package/dist/es/components/RadioButton/RadioButton.d.ts +1 -1
- package/dist/es/components/Search/Search.d.ts +3 -1
- package/dist/es/components/Search/Search.js +7 -4
- package/dist/es/components/Select/Select.d.ts +1 -1
- package/dist/es/components/Switcher/Switcher.css +101 -28
- package/dist/es/components/Switcher/Switcher.d.ts +9 -2
- package/dist/es/components/Switcher/Switcher.js +39 -10
- package/dist/es/components/TextField/TextField.d.ts +1 -1
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.js +2 -0
- package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.css +13 -5
- package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.js +4 -2
- package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.css +4 -1
- package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.d.ts +1 -0
- package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.js +1 -0
- package/dist/lib/components/Badges/components/TimerBadge/Timer/Timer.d.ts +13 -0
- package/dist/lib/components/Badges/components/TimerBadge/Timer/Timer.js +123 -0
- package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.css +60 -0
- package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.d.ts +24 -0
- package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.js +133 -0
- package/dist/lib/components/Button/Button.d.ts +1 -1
- package/dist/lib/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/lib/components/Collapse/Collapse.js +1 -0
- package/dist/lib/components/Counter/Counter.d.ts +1 -1
- package/dist/lib/components/Logo/Logo.css +5 -0
- package/dist/lib/components/Notification/Notification.css +15 -21
- package/dist/lib/components/RadioButton/RadioButton.d.ts +1 -1
- package/dist/lib/components/Search/Search.d.ts +3 -1
- package/dist/lib/components/Search/Search.js +7 -4
- package/dist/lib/components/Select/Select.d.ts +1 -1
- package/dist/lib/components/Switcher/Switcher.css +101 -28
- package/dist/lib/components/Switcher/Switcher.d.ts +9 -2
- package/dist/lib/components/Switcher/Switcher.js +38 -9
- package/dist/lib/components/TextField/TextField.d.ts +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +16 -0
- package/package.json +4 -4
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
require("core-js/modules/es.date.now");
|
|
11
|
+
|
|
12
|
+
require("core-js/modules/es.date.to-string");
|
|
13
|
+
|
|
14
|
+
require("core-js/modules/web.timers");
|
|
15
|
+
|
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
|
|
18
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
19
|
+
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
+
|
|
22
|
+
var _uiHelpers = require("@megafon/ui-helpers");
|
|
23
|
+
|
|
24
|
+
var PropTypes = _interopRequireWildcard(require("prop-types"));
|
|
25
|
+
|
|
26
|
+
var _Timer = _interopRequireDefault(require("./Timer/Timer"));
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
31
|
+
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
|
+
|
|
34
|
+
var TimerIcon = function TimerIcon(props) {
|
|
35
|
+
return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
|
|
36
|
+
viewBox: "0 0 20 20"
|
|
37
|
+
}, props), /*#__PURE__*/_react["default"].createElement("path", {
|
|
38
|
+
fillRule: "evenodd",
|
|
39
|
+
clipRule: "evenodd",
|
|
40
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-8.414V5H9v5.414l3 3L13.414 12 11 9.586z"
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var SECONDS_IN_HOUR = 3600;
|
|
45
|
+
var MS_IN_SECOND = 1000;
|
|
46
|
+
var TIMEOUT = 1000;
|
|
47
|
+
var TimerBadgeTheme = {
|
|
48
|
+
RED: 'red',
|
|
49
|
+
GREY: 'grey'
|
|
50
|
+
};
|
|
51
|
+
var cn = (0, _uiHelpers.cnCreate)('mfui-timer-badge');
|
|
52
|
+
|
|
53
|
+
var TimerBadge = function TimerBadge(_ref) {
|
|
54
|
+
var expirationDate = _ref.expirationDate,
|
|
55
|
+
_ref$countdownStart = _ref.countdownStart,
|
|
56
|
+
countdownStart = _ref$countdownStart === void 0 ? 86400 : _ref$countdownStart,
|
|
57
|
+
_ref$hasPrefix = _ref.hasPrefix,
|
|
58
|
+
hasPrefix = _ref$hasPrefix === void 0 ? false : _ref$hasPrefix,
|
|
59
|
+
_ref$countdownText = _ref.countdownText,
|
|
60
|
+
countdownText = _ref$countdownText === void 0 ? 'Закончится через' : _ref$countdownText,
|
|
61
|
+
_ref$expirationDateTe = _ref.expirationDateText,
|
|
62
|
+
expirationDateText = _ref$expirationDateTe === void 0 ? 'Воспользуйтесь до' : _ref$expirationDateTe,
|
|
63
|
+
className = _ref.className,
|
|
64
|
+
dataAttrs = _ref.dataAttrs;
|
|
65
|
+
var remainingTime = (expirationDate.getTime() - Date.now()) / MS_IN_SECOND;
|
|
66
|
+
|
|
67
|
+
var _useState = (0, _react.useState)(remainingTime),
|
|
68
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
69
|
+
actualRemainingTime = _useState2[0],
|
|
70
|
+
setActualRemainingTime = _useState2[1];
|
|
71
|
+
|
|
72
|
+
var _useState3 = (0, _react.useState)(false),
|
|
73
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
74
|
+
showCountdown = _useState4[0],
|
|
75
|
+
setShowCountdown = _useState4[1];
|
|
76
|
+
|
|
77
|
+
var isLastHour = actualRemainingTime < SECONDS_IN_HOUR;
|
|
78
|
+
var isTimeExpired = actualRemainingTime < 1;
|
|
79
|
+
var theme = showCountdown ? TimerBadgeTheme.RED : TimerBadgeTheme.GREY;
|
|
80
|
+
var additionalText = showCountdown ? countdownText : expirationDateText;
|
|
81
|
+
(0, _react.useEffect)(function () {
|
|
82
|
+
setShowCountdown(actualRemainingTime < countdownStart);
|
|
83
|
+
}, [actualRemainingTime, countdownStart]);
|
|
84
|
+
(0, _react.useEffect)(function () {
|
|
85
|
+
if (isTimeExpired) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var timeoutId = window.setTimeout(function () {
|
|
90
|
+
return setActualRemainingTime(actualRemainingTime - 1);
|
|
91
|
+
}, TIMEOUT);
|
|
92
|
+
return function () {
|
|
93
|
+
return clearTimeout(timeoutId);
|
|
94
|
+
};
|
|
95
|
+
}, [isTimeExpired, showCountdown, actualRemainingTime]);
|
|
96
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
97
|
+
className: cn({
|
|
98
|
+
theme: theme
|
|
99
|
+
}, className)
|
|
100
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
101
|
+
className: cn('icon-container', {
|
|
102
|
+
shadow: isLastHour && showCountdown
|
|
103
|
+
})
|
|
104
|
+
}, /*#__PURE__*/_react["default"].createElement(TimerIcon, {
|
|
105
|
+
className: cn('icon')
|
|
106
|
+
})), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.text), {
|
|
107
|
+
className: cn('text')
|
|
108
|
+
}), isTimeExpired ? 'Время действия истекло' : /*#__PURE__*/_react["default"].createElement(_Timer["default"], {
|
|
109
|
+
additionalText: hasPrefix ? additionalText : undefined,
|
|
110
|
+
showCountdown: showCountdown,
|
|
111
|
+
expirationDate: expirationDate,
|
|
112
|
+
actualRemainingTime: actualRemainingTime,
|
|
113
|
+
dataAttrs: {
|
|
114
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.timer
|
|
115
|
+
}
|
|
116
|
+
})));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
TimerBadge.propTypes = {
|
|
120
|
+
expirationDate: PropTypes.instanceOf(Date).isRequired,
|
|
121
|
+
countdownStart: PropTypes.number,
|
|
122
|
+
hasPrefix: PropTypes.bool,
|
|
123
|
+
countdownText: PropTypes.string,
|
|
124
|
+
expirationDateText: PropTypes.string,
|
|
125
|
+
className: PropTypes.string,
|
|
126
|
+
dataAttrs: PropTypes.shape({
|
|
127
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
128
|
+
text: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
129
|
+
timer: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
130
|
+
})
|
|
131
|
+
};
|
|
132
|
+
var _default = TimerBadge;
|
|
133
|
+
exports["default"] = _default;
|
|
@@ -69,7 +69,7 @@ export interface IButtonProps {
|
|
|
69
69
|
showArrow?: boolean;
|
|
70
70
|
/** Иконка */
|
|
71
71
|
icon?: JSX.Element;
|
|
72
|
-
/**
|
|
72
|
+
/** Отключение кнопки */
|
|
73
73
|
disabled?: boolean;
|
|
74
74
|
/** Ссылка на элемент */
|
|
75
75
|
buttonRef?: Ref<HTMLButtonElement | HTMLAnchorElement>;
|
|
@@ -25,7 +25,7 @@ export interface ICheckboxProps {
|
|
|
25
25
|
value?: string;
|
|
26
26
|
/** Управление состоянием вкл/выкл компонента */
|
|
27
27
|
checked?: boolean;
|
|
28
|
-
/**
|
|
28
|
+
/** Отключение чекбокса */
|
|
29
29
|
disabled?: boolean;
|
|
30
30
|
/** Отобразить компонент в состоянии ошибки */
|
|
31
31
|
error?: boolean;
|
|
@@ -18,7 +18,7 @@ export interface ICounterProps {
|
|
|
18
18
|
min?: number;
|
|
19
19
|
/** Максимальное доступное значение */
|
|
20
20
|
max?: number;
|
|
21
|
-
/**
|
|
21
|
+
/** Отключение счетчика */
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
/** Обработчик изменения значения 'value' */
|
|
24
24
|
onChange?: (value: number) => void;
|
|
@@ -189,19 +189,27 @@ h5 {
|
|
|
189
189
|
.mfui-notification_colored .mfui-notification__icon-container {
|
|
190
190
|
background-color: var(--stcWhite);
|
|
191
191
|
}
|
|
192
|
+
.mfui-notification_colored.mfui-notification_type_info {
|
|
193
|
+
background-color: var(--311C20);
|
|
194
|
+
}
|
|
195
|
+
.mfui-notification_colored.mfui-notification_type_warning {
|
|
196
|
+
background-color: var(--137C20);
|
|
197
|
+
}
|
|
192
198
|
.mfui-notification_colored.mfui-notification_type_success {
|
|
193
199
|
background-color: var(--brandGreen20);
|
|
194
200
|
}
|
|
201
|
+
.mfui-notification_colored.mfui-notification_type_info .mfui-notification__title,
|
|
202
|
+
.mfui-notification_colored.mfui-notification_type_warning .mfui-notification__title,
|
|
195
203
|
.mfui-notification_colored.mfui-notification_type_success .mfui-notification__title,
|
|
196
|
-
.mfui-notification_colored.mfui-
|
|
197
|
-
.mfui-notification_colored.mfui-
|
|
204
|
+
.mfui-notification_colored.mfui-notification_type_info .mfui-notification__text,
|
|
205
|
+
.mfui-notification_colored.mfui-notification_type_warning .mfui-notification__text,
|
|
206
|
+
.mfui-notification_colored.mfui-notification_type_success .mfui-notification__text {
|
|
198
207
|
color: var(--stcBlack);
|
|
199
208
|
}
|
|
200
|
-
.mfui-notification_colored.mfui-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
background-color: var(--stcWhite);
|
|
209
|
+
.mfui-notification_colored.mfui-notification_type_info .mfui-notification__link,
|
|
210
|
+
.mfui-notification_colored.mfui-notification_type_warning .mfui-notification__link,
|
|
211
|
+
.mfui-notification_colored.mfui-notification_type_success .mfui-notification__link {
|
|
212
|
+
color: var(--systemBlue);
|
|
205
213
|
}
|
|
206
214
|
.mfui-notification_colored.mfui-notification_type_error {
|
|
207
215
|
background-color: var(--fury80);
|
|
@@ -221,17 +229,3 @@ h5 {
|
|
|
221
229
|
/* stylelint-disable-line max-nesting-depth */
|
|
222
230
|
fill: var(--stcWhite);
|
|
223
231
|
}
|
|
224
|
-
.mfui-notification_colored.mfui-notification_type_info .mfui-notification__title,
|
|
225
|
-
.mfui-notification_colored.mfui-notification_type_warning .mfui-notification__title,
|
|
226
|
-
.mfui-notification_colored.mfui-notification_type_info .mfui-notification__text,
|
|
227
|
-
.mfui-notification_colored.mfui-notification_type_warning .mfui-notification__text,
|
|
228
|
-
.mfui-notification_colored.mfui-notification_type_info .mfui-notification__link,
|
|
229
|
-
.mfui-notification_colored.mfui-notification_type_warning .mfui-notification__link {
|
|
230
|
-
color: var(--stcBlack);
|
|
231
|
-
}
|
|
232
|
-
.mfui-notification_colored.mfui-notification_type_info {
|
|
233
|
-
background-color: var(--311C20);
|
|
234
|
-
}
|
|
235
|
-
.mfui-notification_colored.mfui-notification_type_warning {
|
|
236
|
-
background-color: var(--137C20);
|
|
237
|
-
}
|
|
@@ -7,7 +7,7 @@ export interface IRadioButtonProps {
|
|
|
7
7
|
name?: string;
|
|
8
8
|
/** Размер текста лейбла */
|
|
9
9
|
textSize?: 'small' | 'medium';
|
|
10
|
-
/**
|
|
10
|
+
/** Отключение радио-кнопки */
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
/** Управление состоянием вкл/выкл компонента */
|
|
13
13
|
isChecked?: boolean;
|
|
@@ -36,7 +36,7 @@ export interface ISearchProps {
|
|
|
36
36
|
verification?: VerificationType;
|
|
37
37
|
/** Дополнительный текст под полем. Свойство verification влияет на цвет текста. */
|
|
38
38
|
noticeText?: string;
|
|
39
|
-
/**
|
|
39
|
+
/** Отключение поля ввода */
|
|
40
40
|
disabled?: boolean;
|
|
41
41
|
/** Делает поле обязательным */
|
|
42
42
|
required?: boolean;
|
|
@@ -54,6 +54,8 @@ export interface ISearchProps {
|
|
|
54
54
|
onSubmit?: (value: string) => void;
|
|
55
55
|
/** Обработчик выхода из фокуса */
|
|
56
56
|
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
57
|
+
/** Обработчик входа в фокус */
|
|
58
|
+
onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
57
59
|
}
|
|
58
60
|
declare const Search: React.FC<ISearchProps>;
|
|
59
61
|
export default Search;
|
|
@@ -73,7 +73,8 @@ var Search = function Search(_ref) {
|
|
|
73
73
|
classes = _ref.classes,
|
|
74
74
|
onChange = _ref.onChange,
|
|
75
75
|
onSubmit = _ref.onSubmit,
|
|
76
|
-
onBlur = _ref.onBlur
|
|
76
|
+
onBlur = _ref.onBlur,
|
|
77
|
+
onFocus = _ref.onFocus;
|
|
77
78
|
|
|
78
79
|
var _React$useState = _react["default"].useState(value),
|
|
79
80
|
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
@@ -134,9 +135,10 @@ var Search = function Search(_ref) {
|
|
|
134
135
|
};
|
|
135
136
|
}, [handleItemSubmit, activeIndex]);
|
|
136
137
|
|
|
137
|
-
var handleFocus = _react["default"].useCallback(function () {
|
|
138
|
+
var handleFocus = _react["default"].useCallback(function (e) {
|
|
138
139
|
setFocus(true);
|
|
139
|
-
|
|
140
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
141
|
+
}, [onFocus]);
|
|
140
142
|
|
|
141
143
|
var handleBlur = _react["default"].useCallback(function (e) {
|
|
142
144
|
setFocus(false);
|
|
@@ -281,7 +283,8 @@ Search.propTypes = {
|
|
|
281
283
|
}),
|
|
282
284
|
onChange: PropTypes.func,
|
|
283
285
|
onSubmit: PropTypes.func,
|
|
284
|
-
onBlur: PropTypes.func
|
|
286
|
+
onBlur: PropTypes.func,
|
|
287
|
+
onFocus: PropTypes.func
|
|
285
288
|
};
|
|
286
289
|
var _default = Search;
|
|
287
290
|
exports["default"] = _default;
|
|
@@ -40,7 +40,7 @@ export interface ISelectProps<T extends SelectItemValueType> {
|
|
|
40
40
|
verification?: VerificationType;
|
|
41
41
|
/** Дополнительный текст под полем. Свойство verification влияет на цвет текста. */
|
|
42
42
|
noticeText?: string;
|
|
43
|
-
/**
|
|
43
|
+
/** Отключение селекта */
|
|
44
44
|
disabled?: boolean;
|
|
45
45
|
/** Делает поле обязательным */
|
|
46
46
|
required?: boolean;
|
|
@@ -1,48 +1,121 @@
|
|
|
1
1
|
.mfui-switcher {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
2
|
+
display: -webkit-box;
|
|
3
|
+
display: -ms-flexbox;
|
|
4
|
+
display: flex;
|
|
5
|
+
}
|
|
6
|
+
.mfui-switcher__content {
|
|
7
|
+
font-size: 15px;
|
|
8
|
+
line-height: 24px;
|
|
9
|
+
font-weight: 400;
|
|
10
|
+
-ms-flex-item-align: center;
|
|
11
|
+
align-self: center;
|
|
12
|
+
margin-left: 12px;
|
|
13
|
+
}
|
|
14
|
+
.mfui-switcher__content_size_small {
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
line-height: 16px;
|
|
17
|
+
}
|
|
18
|
+
.mfui-switcher__content_left {
|
|
19
|
+
margin-right: 12px;
|
|
20
|
+
margin-left: 0;
|
|
21
|
+
}
|
|
22
|
+
.mfui-switcher__content_left + .mfui-switcher__input {
|
|
23
|
+
margin-left: auto;
|
|
12
24
|
}
|
|
13
25
|
.mfui-switcher__pointer {
|
|
14
26
|
position: relative;
|
|
15
|
-
top:
|
|
16
|
-
left:
|
|
27
|
+
top: 2px;
|
|
28
|
+
left: 2px;
|
|
17
29
|
width: 24px;
|
|
18
30
|
height: 24px;
|
|
19
|
-
border: 1px solid var(--stcBlack20);
|
|
20
31
|
border-radius: 50%;
|
|
21
|
-
background-color: var(--
|
|
22
|
-
-webkit-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.05), 0 3px 1px rgba(0, 0, 0, 0.05);
|
|
23
|
-
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.05), 0 3px 1px rgba(0, 0, 0, 0.05);
|
|
32
|
+
background-color: var(--stcWhite);
|
|
24
33
|
-webkit-transition: all 0.3s;
|
|
25
34
|
transition: all 0.3s;
|
|
26
35
|
}
|
|
27
|
-
.mfui-
|
|
36
|
+
.mfui-switcher__loader {
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 0;
|
|
39
|
+
right: 0;
|
|
40
|
+
bottom: 0;
|
|
41
|
+
left: 0;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
}
|
|
44
|
+
.mfui-switcher__loader:before {
|
|
45
|
+
content: '';
|
|
46
|
+
position: absolute;
|
|
47
|
+
top: 0;
|
|
48
|
+
bottom: 0;
|
|
49
|
+
left: 0;
|
|
50
|
+
width: 300%;
|
|
51
|
+
height: 100%;
|
|
52
|
+
background: -webkit-gradient(linear, left top, right top, from(var(--spbSky1)), color-stop(16%, var(--spbSky2)), color-stop(33%, var(--spbSky1)), color-stop(50%, var(--spbSky2)), color-stop(66%, var(--spbSky1)), color-stop(82%, var(--spbSky2)), to(var(--spbSky1)));
|
|
53
|
+
background: linear-gradient(90deg, var(--spbSky1) 0%, var(--spbSky2) 16%, var(--spbSky1) 33%, var(--spbSky2) 50%, var(--spbSky1) 66%, var(--spbSky2) 82%, var(--spbSky1) 100%);
|
|
54
|
+
-webkit-animation: shining 0.8s linear infinite;
|
|
55
|
+
animation: shining 0.8s linear infinite;
|
|
56
|
+
}
|
|
57
|
+
@-webkit-keyframes shining {
|
|
58
|
+
0% {
|
|
59
|
+
-webkit-transform: translateX(-33%);
|
|
60
|
+
transform: translateX(-33%);
|
|
61
|
+
}
|
|
62
|
+
100% {
|
|
63
|
+
-webkit-transform: translateX(0);
|
|
64
|
+
transform: translateX(0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
@keyframes shining {
|
|
68
|
+
0% {
|
|
69
|
+
-webkit-transform: translateX(-33%);
|
|
70
|
+
transform: translateX(-33%);
|
|
71
|
+
}
|
|
72
|
+
100% {
|
|
73
|
+
-webkit-transform: translateX(0);
|
|
74
|
+
transform: translateX(0);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
.mfui-switcher__input {
|
|
78
|
+
position: relative;
|
|
79
|
+
-ms-flex-item-align: start;
|
|
80
|
+
align-self: flex-start;
|
|
81
|
+
width: 48px;
|
|
82
|
+
min-width: 48px;
|
|
83
|
+
height: 28px;
|
|
84
|
+
border-radius: 15.5px;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
background-color: var(--spbSky1);
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
-webkit-transition: background-color 0.3s;
|
|
89
|
+
transition: background-color 0.3s;
|
|
90
|
+
}
|
|
91
|
+
.mfui-switcher__input_disabled {
|
|
28
92
|
background-color: var(--spbSky1);
|
|
29
93
|
}
|
|
30
|
-
.mfui-
|
|
94
|
+
.mfui-switcher__input_disabled,
|
|
95
|
+
.mfui-switcher__input_loaded {
|
|
96
|
+
cursor: default;
|
|
97
|
+
}
|
|
98
|
+
.mfui-switcher__input:hover:not(.mfui-switcher__input_disabled) {
|
|
99
|
+
background-color: var(--spbSky2);
|
|
100
|
+
}
|
|
101
|
+
.mfui-switcher__input_checked:not(.mfui-switcher__input_disabled) {
|
|
31
102
|
border-color: var(--brandGreen);
|
|
32
103
|
background-color: var(--brandGreen);
|
|
33
104
|
}
|
|
34
|
-
.mfui-
|
|
35
|
-
left: 21px;
|
|
36
|
-
}
|
|
37
|
-
.mfui-switcher_checked.mfui-switcher_no-touch:hover {
|
|
105
|
+
.mfui-switcher__input_checked:hover:not(.mfui-switcher__input_disabled) {
|
|
38
106
|
border-color: var(--buttonHoverGreen);
|
|
39
107
|
background-color: var(--buttonHoverGreen);
|
|
40
108
|
}
|
|
41
|
-
.mfui-
|
|
42
|
-
background-color: var(--spbSky1);
|
|
43
|
-
cursor: default;
|
|
44
|
-
}
|
|
45
|
-
.mfui-switcher_disabled.mfui-switcher_checked.mfui-switcher_no-touch {
|
|
46
|
-
border-color: var(--spbSky2);
|
|
109
|
+
.mfui-switcher__input_disabled .mfui-switcher__pointer {
|
|
47
110
|
background-color: var(--spbSky2);
|
|
48
111
|
}
|
|
112
|
+
.mfui-switcher__input_checked .mfui-switcher__pointer {
|
|
113
|
+
left: 22px;
|
|
114
|
+
}
|
|
115
|
+
.mfui-switcher__input_checked .mfui-switcher__loader:before {
|
|
116
|
+
background: -webkit-gradient(linear, left top, right top, from(var(--brandGreen)), color-stop(16%, var(--buttonHoverGreen)), color-stop(33%, var(--brandGreen)), color-stop(50%, var(--buttonHoverGreen)), color-stop(66%, var(--brandGreen)), color-stop(82%, var(--buttonHoverGreen)), to(var(--brandGreen)));
|
|
117
|
+
background: linear-gradient(90deg, var(--brandGreen) 0%, var(--buttonHoverGreen) 16%, var(--brandGreen) 33%, var(--buttonHoverGreen) 50%, var(--brandGreen) 66%, var(--buttonHoverGreen) 82%, var(--brandGreen) 100%);
|
|
118
|
+
}
|
|
119
|
+
.mfui-switcher_disabled .mfui-switcher__content {
|
|
120
|
+
color: var(--spbSky3);
|
|
121
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { AccessibilityEventType } from '@megafon/ui-helpers';
|
|
2
3
|
import './Switcher.less';
|
|
3
4
|
export interface ISwitcherProps {
|
|
4
5
|
/** Дополнительные data атрибуты к внутренним элементам */
|
|
@@ -9,10 +10,16 @@ export interface ISwitcherProps {
|
|
|
9
10
|
className?: string;
|
|
10
11
|
/** Управление состоянием вкл/выкл компонента */
|
|
11
12
|
checked?: boolean;
|
|
12
|
-
/**
|
|
13
|
+
/** Отключение переключателя */
|
|
13
14
|
disabled?: boolean;
|
|
15
|
+
/** Cостояние загрузки */
|
|
16
|
+
showLoader?: boolean;
|
|
17
|
+
/** Размер текста лейбла */
|
|
18
|
+
textSize?: 'small' | 'medium';
|
|
19
|
+
/** Позиция лейбла относительно свитчера */
|
|
20
|
+
textPosition?: 'left' | 'right';
|
|
14
21
|
/** Обработчик изменения элемента */
|
|
15
|
-
onChange?: (e:
|
|
22
|
+
onChange?: (e: AccessibilityEventType) => void;
|
|
16
23
|
}
|
|
17
24
|
declare const Switcher: React.FC<ISwitcherProps>;
|
|
18
25
|
export default Switcher;
|
|
@@ -30,27 +30,53 @@ var Switcher = function Switcher(_ref) {
|
|
|
30
30
|
checked = _ref$checked === void 0 ? false : _ref$checked,
|
|
31
31
|
_ref$disabled = _ref.disabled,
|
|
32
32
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
33
|
+
_ref$showLoader = _ref.showLoader,
|
|
34
|
+
showLoader = _ref$showLoader === void 0 ? false : _ref$showLoader,
|
|
35
|
+
children = _ref.children,
|
|
36
|
+
_ref$textSize = _ref.textSize,
|
|
37
|
+
textSize = _ref$textSize === void 0 ? 'medium' : _ref$textSize,
|
|
38
|
+
_ref$textPosition = _ref.textPosition,
|
|
39
|
+
textPosition = _ref$textPosition === void 0 ? 'right' : _ref$textPosition,
|
|
33
40
|
onChange = _ref.onChange;
|
|
34
41
|
var isTouch = (0, _uiHelpers.detectTouch)();
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
42
|
+
var isLeftContent = !!children && textPosition === 'left';
|
|
43
|
+
var isRightContent = !!children && textPosition === 'right';
|
|
44
|
+
var isInteractiveDisabled = showLoader || disabled;
|
|
45
|
+
var handleChange = React.useCallback(function (e) {
|
|
46
|
+
if (isInteractiveDisabled || !(0, _uiHelpers.checkEventIsClickOrEnterPress)(e)) {
|
|
38
47
|
return;
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
51
|
+
}, [isInteractiveDisabled, onChange]);
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
|
|
45
53
|
className: cn({
|
|
54
|
+
disabled: disabled
|
|
55
|
+
}, className)
|
|
56
|
+
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), isLeftContent && /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: cn('content', {
|
|
58
|
+
size: textSize,
|
|
59
|
+
left: true
|
|
60
|
+
})
|
|
61
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: cn('input', {
|
|
46
63
|
checked: checked,
|
|
47
64
|
disabled: disabled,
|
|
65
|
+
loaded: showLoader,
|
|
48
66
|
'no-touch': !isTouch
|
|
49
|
-
}
|
|
50
|
-
onClick: handleChange
|
|
67
|
+
}),
|
|
68
|
+
onClick: handleChange,
|
|
69
|
+
onKeyDown: handleChange,
|
|
70
|
+
tabIndex: isInteractiveDisabled ? undefined : 0
|
|
71
|
+
}, showLoader && !disabled && /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: cn('loader')
|
|
51
73
|
}), /*#__PURE__*/React.createElement("div", {
|
|
52
74
|
className: cn('pointer')
|
|
53
|
-
}))
|
|
75
|
+
})), isRightContent && /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: cn('content', {
|
|
77
|
+
size: textSize
|
|
78
|
+
})
|
|
79
|
+
}, children));
|
|
54
80
|
};
|
|
55
81
|
|
|
56
82
|
Switcher.propTypes = {
|
|
@@ -58,8 +84,11 @@ Switcher.propTypes = {
|
|
|
58
84
|
root: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
59
85
|
}),
|
|
60
86
|
className: PropTypes.string,
|
|
87
|
+
textSize: PropTypes.oneOf(['small', 'medium']),
|
|
88
|
+
textPosition: PropTypes.oneOf(['left', 'right']),
|
|
61
89
|
checked: PropTypes.bool,
|
|
62
90
|
disabled: PropTypes.bool,
|
|
91
|
+
showLoader: PropTypes.bool,
|
|
63
92
|
onChange: PropTypes.func
|
|
64
93
|
};
|
|
65
94
|
var _default = Switcher;
|
|
@@ -31,7 +31,7 @@ export declare type TextFieldProps = {
|
|
|
31
31
|
verification?: 'valid' | 'error';
|
|
32
32
|
/** Подпись снизу, меняет цвет в зависимости от аргумента verification */
|
|
33
33
|
noticeText?: string;
|
|
34
|
-
/**
|
|
34
|
+
/** Отключение поля ввода */
|
|
35
35
|
disabled?: boolean;
|
|
36
36
|
/** Показывает обязательность поля */
|
|
37
37
|
required?: boolean;
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -40,5 +40,7 @@ export { default as Tabs } from './components/Tabs/Tabs';
|
|
|
40
40
|
export { default as TextField } from './components/TextField/TextField';
|
|
41
41
|
export { default as TextLink } from './components/TextLink/TextLink';
|
|
42
42
|
export { default as Tile } from './components/Tile/Tile';
|
|
43
|
+
export { default as Timer } from './components/Badges/components/TimerBadge/Timer/Timer';
|
|
44
|
+
export { default as TimerBadge } from './components/Badges/components/TimerBadge/TimerBadge';
|
|
43
45
|
export { default as Tooltip } from './components/Tooltip/Tooltip';
|
|
44
46
|
export { default as usePagination } from './components/Pagination/usePagination';
|
package/dist/lib/index.js
CHANGED
|
@@ -255,6 +255,18 @@ Object.defineProperty(exports, "Tile", {
|
|
|
255
255
|
return _Tile["default"];
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
|
+
Object.defineProperty(exports, "Timer", {
|
|
259
|
+
enumerable: true,
|
|
260
|
+
get: function get() {
|
|
261
|
+
return _Timer["default"];
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
Object.defineProperty(exports, "TimerBadge", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
get: function get() {
|
|
267
|
+
return _TimerBadge["default"];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
258
270
|
Object.defineProperty(exports, "Tooltip", {
|
|
259
271
|
enumerable: true,
|
|
260
272
|
get: function get() {
|
|
@@ -352,6 +364,10 @@ var _TextLink = _interopRequireDefault(require("./components/TextLink/TextLink")
|
|
|
352
364
|
|
|
353
365
|
var _Tile = _interopRequireDefault(require("./components/Tile/Tile"));
|
|
354
366
|
|
|
367
|
+
var _Timer = _interopRequireDefault(require("./components/Badges/components/TimerBadge/Timer/Timer"));
|
|
368
|
+
|
|
369
|
+
var _TimerBadge = _interopRequireDefault(require("./components/Badges/components/TimerBadge/TimerBadge"));
|
|
370
|
+
|
|
355
371
|
var _Tooltip = _interopRequireDefault(require("./components/Tooltip/Tooltip"));
|
|
356
372
|
|
|
357
373
|
var _usePagination = _interopRequireDefault(require("./components/Pagination/usePagination"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@megafon/ui-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"styles"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@babel/preset-env": "^7.8.6",
|
|
55
55
|
"@babel/preset-react": "^7.8.3",
|
|
56
56
|
"@babel/preset-typescript": "^7.8.3",
|
|
57
|
-
"@megafon/ui-icons": "^1.1.
|
|
57
|
+
"@megafon/ui-icons": "^1.1.1",
|
|
58
58
|
"@svgr/core": "^2.4.1",
|
|
59
59
|
"@testing-library/react-hooks": "^7.0.1",
|
|
60
60
|
"@types/enzyme": "^3.10.5",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@babel/runtime": "^7.8.4",
|
|
88
88
|
"@datepicker-react/hooks": "^2.7.0",
|
|
89
|
-
"@megafon/ui-helpers": "^2.1.
|
|
89
|
+
"@megafon/ui-helpers": "^2.1.1",
|
|
90
90
|
"@popperjs/core": "^2.5.3",
|
|
91
91
|
"core-js": "^3.6.4",
|
|
92
92
|
"date-fns": "^2.16.1",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"react-popper": "^2.2.3",
|
|
98
98
|
"swiper": "^6.5.6"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "48ac683c2daf04dfdc42d1359024800699f2e7dc"
|
|
101
101
|
}
|