@megafon/ui-core 3.2.0 → 3.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 +48 -0
- package/dist/es/components/Accordion/Accordion.css +1 -0
- package/dist/es/components/Badges/components/PriceBadge/PriceBadge.css +78 -0
- package/dist/es/components/Badges/components/PriceBadge/PriceBadge.d.ts +33 -0
- package/dist/es/components/Badges/components/PriceBadge/PriceBadge.js +115 -0
- package/dist/es/components/Badges/components/PromoBadge/PromoBadge.css +35 -0
- package/dist/es/components/Badges/components/PromoBadge/PromoBadge.d.ts +23 -0
- package/dist/es/components/Badges/components/PromoBadge/PromoBadge.js +39 -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/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.d.ts +1 -1
- package/dist/es/components/TextField/TextField.d.ts +1 -1
- package/dist/es/index.d.ts +4 -0
- package/dist/es/index.js +4 -0
- package/dist/lib/components/Accordion/Accordion.css +1 -0
- package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.css +78 -0
- package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.d.ts +33 -0
- package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.js +136 -0
- package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.css +35 -0
- package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.d.ts +23 -0
- package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.js +60 -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/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.d.ts +1 -1
- package/dist/lib/components/TextField/TextField.d.ts +1 -1
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.js +32 -0
- package/package.json +4 -4
|
@@ -0,0 +1,60 @@
|
|
|
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"] = exports.PromoBadgeTypes = void 0;
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.object.values");
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var React = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _uiHelpers = require("@megafon/ui-helpers");
|
|
17
|
+
|
|
18
|
+
var PropTypes = _interopRequireWildcard(require("prop-types"));
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
+
|
|
26
|
+
var PromoBadgeTypes = {
|
|
27
|
+
HIT: 'hit',
|
|
28
|
+
NEW: 'new',
|
|
29
|
+
VIP: 'vip',
|
|
30
|
+
POPULAR: 'popular',
|
|
31
|
+
USER_CHOICE: 'user-choice'
|
|
32
|
+
};
|
|
33
|
+
exports.PromoBadgeTypes = PromoBadgeTypes;
|
|
34
|
+
var cn = (0, _uiHelpers.cnCreate)('mfui-promo-badge');
|
|
35
|
+
|
|
36
|
+
var PromoBadge = function PromoBadge(_ref) {
|
|
37
|
+
var _ref$type = _ref.type,
|
|
38
|
+
type = _ref$type === void 0 ? 'hit' : _ref$type,
|
|
39
|
+
className = _ref.className,
|
|
40
|
+
children = _ref.children,
|
|
41
|
+
dataAttrs = _ref.dataAttrs;
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
43
|
+
className: cn({
|
|
44
|
+
type: type
|
|
45
|
+
}, className)
|
|
46
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
className: cn('text')
|
|
48
|
+
}, children));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
PromoBadge.propTypes = {
|
|
52
|
+
type: PropTypes.oneOf(Object.values(PromoBadgeTypes)),
|
|
53
|
+
className: PropTypes.string,
|
|
54
|
+
dataAttrs: PropTypes.shape({
|
|
55
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
56
|
+
}),
|
|
57
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired
|
|
58
|
+
};
|
|
59
|
+
var _default = PromoBadge;
|
|
60
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const getCountdownText: (remainingTime?: number) => string;
|
|
3
|
+
interface ITimerProps {
|
|
4
|
+
actualRemainingTime: number;
|
|
5
|
+
expirationDate: Date;
|
|
6
|
+
showCountdown: boolean;
|
|
7
|
+
additionalText?: string;
|
|
8
|
+
dataAttrs?: {
|
|
9
|
+
root?: Record<string, string>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
declare const Timer: React.FC<ITimerProps>;
|
|
13
|
+
export default Timer;
|
|
@@ -0,0 +1,123 @@
|
|
|
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"] = exports.getCountdownText = void 0;
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.array.concat");
|
|
11
|
+
|
|
12
|
+
require("core-js/modules/es.date.to-string");
|
|
13
|
+
|
|
14
|
+
require("core-js/modules/es.math.trunc");
|
|
15
|
+
|
|
16
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
17
|
+
|
|
18
|
+
var React = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var _uiHelpers = require("@megafon/ui-helpers");
|
|
21
|
+
|
|
22
|
+
var _format = _interopRequireDefault(require("date-fns/format"));
|
|
23
|
+
|
|
24
|
+
var _ru = _interopRequireDefault(require("date-fns/locale/ru"));
|
|
25
|
+
|
|
26
|
+
var PropTypes = _interopRequireWildcard(require("prop-types"));
|
|
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 SECONDS_IN_DAY = 86400;
|
|
35
|
+
var SECONDS_IN_HOUR = 3600;
|
|
36
|
+
var SECONDS_IN_MINUTE = 60;
|
|
37
|
+
|
|
38
|
+
var formatDate = function formatDate(date, pattern) {
|
|
39
|
+
return (0, _format["default"])(date, pattern, {
|
|
40
|
+
locale: _ru["default"]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var getCountdownText = function getCountdownText() {
|
|
45
|
+
var remainingTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
46
|
+
var isMoreHourAndLessDay = remainingTime >= SECONDS_IN_HOUR && remainingTime < SECONDS_IN_DAY;
|
|
47
|
+
|
|
48
|
+
var truncTime = function truncTime() {
|
|
49
|
+
var divider = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
50
|
+
return Math.trunc(remainingTime / divider);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
switch (true) {
|
|
54
|
+
case remainingTime <= 0:
|
|
55
|
+
{
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case remainingTime < SECONDS_IN_MINUTE:
|
|
60
|
+
{
|
|
61
|
+
var seconds = truncTime();
|
|
62
|
+
return "".concat(seconds, " \u0441\u0435\u043A");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
case remainingTime < SECONDS_IN_HOUR:
|
|
66
|
+
{
|
|
67
|
+
var minutes = truncTime(SECONDS_IN_MINUTE);
|
|
68
|
+
return "".concat(minutes, " \u043C\u0438\u043D");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
case isMoreHourAndLessDay:
|
|
72
|
+
{
|
|
73
|
+
var hours = truncTime(SECONDS_IN_HOUR);
|
|
74
|
+
var secondsLeft = remainingTime - hours * SECONDS_IN_HOUR;
|
|
75
|
+
|
|
76
|
+
var _minutes = Math.trunc(secondsLeft / SECONDS_IN_MINUTE);
|
|
77
|
+
|
|
78
|
+
return _minutes ? "".concat(hours, " \u0447 ").concat(_minutes, " \u043C\u0438\u043D") : "".concat(hours, " \u0447");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
case remainingTime >= SECONDS_IN_DAY:
|
|
82
|
+
{
|
|
83
|
+
var days = truncTime(SECONDS_IN_DAY);
|
|
84
|
+
|
|
85
|
+
var _secondsLeft = remainingTime - days * SECONDS_IN_DAY;
|
|
86
|
+
|
|
87
|
+
var _hours = Math.trunc(_secondsLeft / SECONDS_IN_HOUR);
|
|
88
|
+
|
|
89
|
+
return _hours ? "".concat(days, " \u0434\u043D ").concat(_hours, " \u0447") : "".concat(days, " \u0434\u043D");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
default:
|
|
93
|
+
{
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.getCountdownText = getCountdownText;
|
|
100
|
+
var cn = (0, _uiHelpers.cnCreate)('mfui-timer');
|
|
101
|
+
|
|
102
|
+
var Timer = function Timer(_ref) {
|
|
103
|
+
var actualRemainingTime = _ref.actualRemainingTime,
|
|
104
|
+
expirationDate = _ref.expirationDate,
|
|
105
|
+
showCountdown = _ref.showCountdown,
|
|
106
|
+
additionalText = _ref.additionalText,
|
|
107
|
+
dataAttrs = _ref.dataAttrs;
|
|
108
|
+
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
|
|
109
|
+
className: cn()
|
|
110
|
+
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), additionalText && /*#__PURE__*/React.createElement("span", null, additionalText, " "), /*#__PURE__*/React.createElement("span", null, showCountdown ? getCountdownText(actualRemainingTime) : formatDate(expirationDate, 'dd MMMM yyyy')));
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
Timer.propTypes = {
|
|
114
|
+
expirationDate: PropTypes.instanceOf(Date).isRequired,
|
|
115
|
+
actualRemainingTime: PropTypes.number.isRequired,
|
|
116
|
+
showCountdown: PropTypes.bool.isRequired,
|
|
117
|
+
additionalText: PropTypes.string,
|
|
118
|
+
dataAttrs: PropTypes.shape({
|
|
119
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
120
|
+
})
|
|
121
|
+
};
|
|
122
|
+
var _default = Timer;
|
|
123
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
.mfui-timer-badge {
|
|
2
|
+
display: -webkit-box;
|
|
3
|
+
display: -ms-flexbox;
|
|
4
|
+
display: flex;
|
|
5
|
+
-webkit-box-align: center;
|
|
6
|
+
-ms-flex-align: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
padding: 1px 2px;
|
|
9
|
+
padding-right: 8px;
|
|
10
|
+
width: -webkit-fit-content;
|
|
11
|
+
width: -moz-fit-content;
|
|
12
|
+
width: fit-content;
|
|
13
|
+
height: -webkit-fit-content;
|
|
14
|
+
height: -moz-fit-content;
|
|
15
|
+
height: fit-content;
|
|
16
|
+
border: 1px solid var(--spbSky1);
|
|
17
|
+
border-radius: 12px;
|
|
18
|
+
background: var(--base);
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
.mfui-timer-badge_theme_grey .mfui-timer-badge__text {
|
|
22
|
+
color: var(--spbSky3);
|
|
23
|
+
}
|
|
24
|
+
.mfui-timer-badge_theme_grey .mfui-timer-badge__icon {
|
|
25
|
+
fill: var(--spbSky3);
|
|
26
|
+
}
|
|
27
|
+
.mfui-timer-badge_theme_red .mfui-timer-badge__text {
|
|
28
|
+
color: var(--fury);
|
|
29
|
+
}
|
|
30
|
+
.mfui-timer-badge_theme_red .mfui-timer-badge__icon {
|
|
31
|
+
fill: var(--fury);
|
|
32
|
+
}
|
|
33
|
+
.mfui-timer-badge__text {
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
line-height: 16px;
|
|
36
|
+
font-family: inherit;
|
|
37
|
+
margin-left: 2px;
|
|
38
|
+
font-weight: 500;
|
|
39
|
+
}
|
|
40
|
+
.mfui-timer-badge__icon {
|
|
41
|
+
height: 20px;
|
|
42
|
+
width: 20px;
|
|
43
|
+
}
|
|
44
|
+
.mfui-timer-badge__icon-container {
|
|
45
|
+
position: relative;
|
|
46
|
+
display: -webkit-box;
|
|
47
|
+
display: -ms-flexbox;
|
|
48
|
+
display: flex;
|
|
49
|
+
}
|
|
50
|
+
.mfui-timer-badge__icon-container_shadow:before {
|
|
51
|
+
content: '';
|
|
52
|
+
position: absolute;
|
|
53
|
+
top: 2px;
|
|
54
|
+
left: 2px;
|
|
55
|
+
height: 16px;
|
|
56
|
+
width: 16px;
|
|
57
|
+
border-radius: 50%;
|
|
58
|
+
-webkit-box-shadow: 0px 0px 6px var(--fury);
|
|
59
|
+
box-shadow: 0px 0px 6px var(--fury);
|
|
60
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './TimerBadge.less';
|
|
3
|
+
export interface ITimerBadgeProps {
|
|
4
|
+
/** Дата окончания таймера */
|
|
5
|
+
expirationDate: Date;
|
|
6
|
+
/** Граница переключения в режим обратного отсчёта, в секундах */
|
|
7
|
+
countdownStart?: number;
|
|
8
|
+
/** Отображение дополнительного текста */
|
|
9
|
+
hasPrefix?: boolean;
|
|
10
|
+
/** Текст перед таймером в режиме обратного отсчета. Появляется при hasPrefix=true. */
|
|
11
|
+
countdownText?: string;
|
|
12
|
+
/** Текст перед таймером в режиме даты. Появляется при hasPrefix=true. */
|
|
13
|
+
expirationDateText?: string;
|
|
14
|
+
/** Дополнительный класс корневого элемента */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Дополнительные data-атрибуты к внутренним элементам */
|
|
17
|
+
dataAttrs?: {
|
|
18
|
+
root?: Record<string, string>;
|
|
19
|
+
text?: Record<string, string>;
|
|
20
|
+
timer?: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare const TimerBadge: React.FC<ITimerBadgeProps>;
|
|
24
|
+
export default TimerBadge;
|
|
@@ -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;
|
|
@@ -9,7 +9,7 @@ export interface ISwitcherProps {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
/** Управление состоянием вкл/выкл компонента */
|
|
11
11
|
checked?: boolean;
|
|
12
|
-
/**
|
|
12
|
+
/** Отключение переключателя */
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
/** Обработчик изменения элемента */
|
|
15
15
|
onChange?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
@@ -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
|
@@ -28,6 +28,8 @@ export { default as PaginationButtons } from './components/Pagination/components
|
|
|
28
28
|
export { default as PaginationNavigation } from './components/Pagination/components/PaginationNavigation/PaginationNavigation';
|
|
29
29
|
export { default as Paragraph } from './components/Paragraph/Paragraph';
|
|
30
30
|
export { default as Preloader } from './components/Preloader/Preloader';
|
|
31
|
+
export { default as PriceBadge } from './components/Badges/components/PriceBadge/PriceBadge';
|
|
32
|
+
export { default as PromoBadge } from './components/Badges/components/PromoBadge/PromoBadge';
|
|
31
33
|
export { default as RadioButton } from './components/RadioButton/RadioButton';
|
|
32
34
|
export { default as Search } from './components/Search/Search';
|
|
33
35
|
export { default as Select } from './components/Select/Select';
|
|
@@ -38,5 +40,7 @@ export { default as Tabs } from './components/Tabs/Tabs';
|
|
|
38
40
|
export { default as TextField } from './components/TextField/TextField';
|
|
39
41
|
export { default as TextLink } from './components/TextLink/TextLink';
|
|
40
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';
|
|
41
45
|
export { default as Tooltip } from './components/Tooltip/Tooltip';
|
|
42
46
|
export { default as usePagination } from './components/Pagination/usePagination';
|