@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.
Files changed (52) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/es/components/Accordion/Accordion.css +1 -0
  3. package/dist/es/components/Badges/components/PriceBadge/PriceBadge.css +78 -0
  4. package/dist/es/components/Badges/components/PriceBadge/PriceBadge.d.ts +33 -0
  5. package/dist/es/components/Badges/components/PriceBadge/PriceBadge.js +115 -0
  6. package/dist/es/components/Badges/components/PromoBadge/PromoBadge.css +35 -0
  7. package/dist/es/components/Badges/components/PromoBadge/PromoBadge.d.ts +23 -0
  8. package/dist/es/components/Badges/components/PromoBadge/PromoBadge.js +39 -0
  9. package/dist/es/components/Badges/components/TimerBadge/Timer/Timer.d.ts +13 -0
  10. package/dist/es/components/Badges/components/TimerBadge/Timer/Timer.js +96 -0
  11. package/dist/es/components/Badges/components/TimerBadge/TimerBadge.css +60 -0
  12. package/dist/es/components/Badges/components/TimerBadge/TimerBadge.d.ts +24 -0
  13. package/dist/es/components/Badges/components/TimerBadge/TimerBadge.js +110 -0
  14. package/dist/es/components/Button/Button.d.ts +1 -1
  15. package/dist/es/components/Checkbox/Checkbox.d.ts +1 -1
  16. package/dist/es/components/Collapse/Collapse.js +1 -0
  17. package/dist/es/components/Counter/Counter.d.ts +1 -1
  18. package/dist/es/components/Notification/Notification.css +15 -21
  19. package/dist/es/components/RadioButton/RadioButton.d.ts +1 -1
  20. package/dist/es/components/Search/Search.d.ts +3 -1
  21. package/dist/es/components/Search/Search.js +7 -4
  22. package/dist/es/components/Select/Select.d.ts +1 -1
  23. package/dist/es/components/Switcher/Switcher.d.ts +1 -1
  24. package/dist/es/components/TextField/TextField.d.ts +1 -1
  25. package/dist/es/index.d.ts +4 -0
  26. package/dist/es/index.js +4 -0
  27. package/dist/lib/components/Accordion/Accordion.css +1 -0
  28. package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.css +78 -0
  29. package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.d.ts +33 -0
  30. package/dist/lib/components/Badges/components/PriceBadge/PriceBadge.js +136 -0
  31. package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.css +35 -0
  32. package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.d.ts +23 -0
  33. package/dist/lib/components/Badges/components/PromoBadge/PromoBadge.js +60 -0
  34. package/dist/lib/components/Badges/components/TimerBadge/Timer/Timer.d.ts +13 -0
  35. package/dist/lib/components/Badges/components/TimerBadge/Timer/Timer.js +123 -0
  36. package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.css +60 -0
  37. package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.d.ts +24 -0
  38. package/dist/lib/components/Badges/components/TimerBadge/TimerBadge.js +133 -0
  39. package/dist/lib/components/Button/Button.d.ts +1 -1
  40. package/dist/lib/components/Checkbox/Checkbox.d.ts +1 -1
  41. package/dist/lib/components/Collapse/Collapse.js +1 -0
  42. package/dist/lib/components/Counter/Counter.d.ts +1 -1
  43. package/dist/lib/components/Notification/Notification.css +15 -21
  44. package/dist/lib/components/RadioButton/RadioButton.d.ts +1 -1
  45. package/dist/lib/components/Search/Search.d.ts +3 -1
  46. package/dist/lib/components/Search/Search.js +7 -4
  47. package/dist/lib/components/Select/Select.d.ts +1 -1
  48. package/dist/lib/components/Switcher/Switcher.d.ts +1 -1
  49. package/dist/lib/components/TextField/TextField.d.ts +1 -1
  50. package/dist/lib/index.d.ts +4 -0
  51. package/dist/lib/index.js +32 -0
  52. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,54 @@
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
+ # [3.4.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.3.1...@megafon/ui-core@3.4.0) (2022-03-21)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **notification:** fix link styles ([9d7e67e](https://github.com/MegafonWebLab/megafon-ui/commit/9d7e67e1f21c9ddb1dc911502a114924c8896a6a))
12
+ * **pricebadge:** fix icon styles ([f5502a0](https://github.com/MegafonWebLab/megafon-ui/commit/f5502a0e28d067694cee4165fe224a38ecf3a15f))
13
+ * **storebutton:** fixed test for Select and update type for StoreButton ([8996754](https://github.com/MegafonWebLab/megafon-ui/commit/8996754482e9cf899fdcb0f488c8a9fa1afddd11))
14
+
15
+
16
+ ### Features
17
+
18
+ * **badges:** add new component TimerBadge ([82a900b](https://github.com/MegafonWebLab/megafon-ui/commit/82a900b362ca15db30dfdbffbfe299b637cae5b3))
19
+ * **promobadge:** add vip type (purple background color) ([51ea858](https://github.com/MegafonWebLab/megafon-ui/commit/51ea8582ff750199166c64681fecae636d30ca18))
20
+ * **search:** add onFocus callback ([b6dfdad](https://github.com/MegafonWebLab/megafon-ui/commit/b6dfdadd8dc695d7622bb95443ef6556b4e5d1c6))
21
+
22
+
23
+
24
+
25
+
26
+ ## [3.3.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.3.0...@megafon/ui-core@3.3.1) (2022-03-15)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * **collapse:** made collapse height 0 or auto on animation end ([c898d1e](https://github.com/MegafonWebLab/megafon-ui/commit/c898d1e84d3c92defa204c24125508655466d5cd))
32
+
33
+
34
+
35
+
36
+
37
+ # [3.3.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.2.0...@megafon/ui-core@3.3.0) (2022-03-14)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * **accordion:** remove outline for safari ([787b572](https://github.com/MegafonWebLab/megafon-ui/commit/787b5725ef962637401a0a3a1a8ae7ba0cece031))
43
+
44
+
45
+ ### Features
46
+
47
+ * **badges:** add new component PriceBadge ([9214baa](https://github.com/MegafonWebLab/megafon-ui/commit/9214baab003f958b916b728cf07e6f9db15173dd))
48
+ * **badges:** add new component PromoBadge ([6e550a0](https://github.com/MegafonWebLab/megafon-ui/commit/6e550a06fd2d0fb7b3dba488702f4a34f4f6d101))
49
+
50
+
51
+
52
+
53
+
6
54
  # [3.2.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.1.0...@megafon/ui-core@3.2.0) (2022-02-28)
7
55
 
8
56
 
@@ -32,6 +32,7 @@
32
32
  right: 20px;
33
33
  width: 32px;
34
34
  height: 32px;
35
+ outline: none;
35
36
  -webkit-transform: translateY(-50%);
36
37
  transform: translateY(-50%);
37
38
  opacity: 1;
@@ -0,0 +1,78 @@
1
+ .mfui-price-badge {
2
+ font-size: 12px;
3
+ line-height: 16px;
4
+ display: -webkit-box;
5
+ display: -ms-flexbox;
6
+ display: flex;
7
+ -webkit-box-align: center;
8
+ -ms-flex-align: center;
9
+ align-items: center;
10
+ padding: 2px;
11
+ padding-right: 8px;
12
+ width: -webkit-fit-content;
13
+ width: -moz-fit-content;
14
+ width: fit-content;
15
+ height: -webkit-fit-content;
16
+ height: -moz-fit-content;
17
+ height: fit-content;
18
+ border-radius: 8px;
19
+ }
20
+ @media screen and (min-width: 1024px) {
21
+ .mfui-price-badge_adaptive {
22
+ font-size: 15px;
23
+ line-height: 24px;
24
+ padding: 4px;
25
+ padding-right: 8px;
26
+ min-height: 32px;
27
+ border-radius: 12px;
28
+ }
29
+ }
30
+ .mfui-price-badge_theme_grey {
31
+ background-color: var(--spbSky0);
32
+ }
33
+ .mfui-price-badge_theme_grey .mfui-price-badge__text {
34
+ color: var(--spbSky3);
35
+ }
36
+ .mfui-price-badge_theme_grey .mfui-price-badge__icon {
37
+ fill: var(--spbSky3);
38
+ }
39
+ .mfui-price-badge_theme_orange {
40
+ background-color: var(--137C20);
41
+ }
42
+ .mfui-price-badge_theme_orange .mfui-price-badge__text {
43
+ color: var(--137C);
44
+ }
45
+ .mfui-price-badge_theme_orange .mfui-price-badge__icon {
46
+ fill: var(--137C);
47
+ }
48
+ .mfui-price-badge_theme_green {
49
+ background-color: var(--brandGreen20);
50
+ }
51
+ .mfui-price-badge_theme_green .mfui-price-badge__text {
52
+ color: var(--brandGreen);
53
+ }
54
+ .mfui-price-badge_theme_green .mfui-price-badge__icon {
55
+ fill: var(--brandGreen);
56
+ }
57
+ .mfui-price-badge_theme_red {
58
+ background-color: var(--fury20);
59
+ }
60
+ .mfui-price-badge_theme_red .mfui-price-badge__text {
61
+ color: var(--fury);
62
+ }
63
+ .mfui-price-badge_theme_red .mfui-price-badge__icon {
64
+ fill: var(--fury);
65
+ }
66
+ .mfui-price-badge__text {
67
+ font-family: inherit;
68
+ margin-left: 2px;
69
+ }
70
+ .mfui-price-badge__icon-container {
71
+ display: -webkit-box;
72
+ display: -ms-flexbox;
73
+ display: flex;
74
+ }
75
+ .mfui-price-badge__icon {
76
+ height: 20px;
77
+ width: 20px;
78
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import './PriceBadge.less';
3
+ export declare const PriceBadgeTheme: {
4
+ readonly RED: "red";
5
+ readonly GREY: "grey";
6
+ readonly GREEN: "green";
7
+ readonly ORANGE: "orange";
8
+ };
9
+ export declare const PriceBadgeIcon: {
10
+ readonly TIMER: "timer";
11
+ readonly PRICE: "price";
12
+ readonly CHECK: "check";
13
+ readonly ATTENTION: "attention";
14
+ };
15
+ declare type PriceBadgeThemeType = typeof PriceBadgeTheme[keyof typeof PriceBadgeTheme];
16
+ declare type PriceBadgeIconType = typeof PriceBadgeIcon[keyof typeof PriceBadgeIcon];
17
+ export interface IPriceBadgeProps {
18
+ /** Адаптивный режим */
19
+ isAdaptive?: boolean;
20
+ /** Тип иконки */
21
+ iconType?: PriceBadgeIconType;
22
+ /** Цветовая тема */
23
+ theme?: PriceBadgeThemeType;
24
+ /** Дополнительный класс корневого элемента */
25
+ className?: string;
26
+ /** Дополнительные data-атрибуты к внутренним элементам */
27
+ dataAttrs?: {
28
+ root?: Record<string, string>;
29
+ };
30
+ children: JSX.Element[] | Element[] | JSX.Element | Element | string;
31
+ }
32
+ declare const PriceBadge: React.FC<IPriceBadgeProps>;
33
+ export default PriceBadge;
@@ -0,0 +1,115 @@
1
+ import "core-js/modules/es.object.values";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import * as React from 'react';
4
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
5
+ import * as PropTypes from 'prop-types';
6
+ import "./PriceBadge.css";
7
+
8
+ var AttentionIcon = function AttentionIcon(props) {
9
+ return /*#__PURE__*/React.createElement("svg", _extends({
10
+ viewBox: "0 0 20 20"
11
+ }, props), /*#__PURE__*/React.createElement("path", {
12
+ d: "M10 2c4.4 0 8 3.6 8 8s-3.6 8-8 8-8-3.6-8-8 3.6-8 8-8zm0 13c.3 0 .5-.1.7-.3.2-.2.3-.4.3-.7s-.1-.5-.3-.7c-.2-.2-.5-.3-.7-.3s-.5.1-.7.3c-.2.2-.3.4-.3.7s.1.5.3.7.5.3.7.3zM9 5v6h2V5H9z"
13
+ }));
14
+ };
15
+
16
+ var CheckIcon = function CheckIcon(props) {
17
+ return /*#__PURE__*/React.createElement("svg", _extends({
18
+ viewBox: "0 0 20 20"
19
+ }, props), /*#__PURE__*/React.createElement("path", {
20
+ fillRule: "evenodd",
21
+ clipRule: "evenodd",
22
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zM7.295 9.467l1.77 1.77 3.66-5.22 1.31.918-4.745 6.79-3.126-3.127 1.131-1.13z"
23
+ }));
24
+ };
25
+
26
+ var PriceIcon = function PriceIcon(props) {
27
+ return /*#__PURE__*/React.createElement("svg", _extends({
28
+ viewBox: "0 0 20 20"
29
+ }, props), /*#__PURE__*/React.createElement("path", {
30
+ fillRule: "evenodd",
31
+ clipRule: "evenodd",
32
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zM7.75 5.75H11a2.75 2.75 0 010 5.5H9.25V12h3v1.5h-3v1.75h-1.5V13.5h-1V12h1v-.75h-1v-1.5h1v-4zM11 7.25H9.25v2.5H11a1.25 1.25 0 000-2.5z"
33
+ }));
34
+ };
35
+
36
+ var TimerIcon = function TimerIcon(props) {
37
+ return /*#__PURE__*/React.createElement("svg", _extends({
38
+ viewBox: "0 0 20 20"
39
+ }, props), /*#__PURE__*/React.createElement("path", {
40
+ fillRule: "evenodd",
41
+ clipRule: "evenodd",
42
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-8.414V5H9v5.414l3 3L13.414 12 11 9.586z"
43
+ }));
44
+ };
45
+
46
+ export var PriceBadgeTheme = {
47
+ RED: 'red',
48
+ GREY: 'grey',
49
+ GREEN: 'green',
50
+ ORANGE: 'orange'
51
+ };
52
+ export var PriceBadgeIcon = {
53
+ TIMER: 'timer',
54
+ PRICE: 'price',
55
+ CHECK: 'check',
56
+ ATTENTION: 'attention'
57
+ };
58
+
59
+ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType) {
60
+ switch (iconType) {
61
+ case PriceBadgeIcon.TIMER:
62
+ return TimerIcon;
63
+
64
+ case PriceBadgeIcon.PRICE:
65
+ return PriceIcon;
66
+
67
+ case PriceBadgeIcon.CHECK:
68
+ return CheckIcon;
69
+
70
+ case PriceBadgeIcon.ATTENTION:
71
+ return AttentionIcon;
72
+
73
+ default:
74
+ return TimerIcon;
75
+ }
76
+ };
77
+
78
+ var cn = cnCreate('mfui-price-badge');
79
+
80
+ var PriceBadge = function PriceBadge(_ref) {
81
+ var _ref$iconType = _ref.iconType,
82
+ iconType = _ref$iconType === void 0 ? 'timer' : _ref$iconType,
83
+ _ref$isAdaptive = _ref.isAdaptive,
84
+ isAdaptive = _ref$isAdaptive === void 0 ? false : _ref$isAdaptive,
85
+ _ref$theme = _ref.theme,
86
+ theme = _ref$theme === void 0 ? 'grey' : _ref$theme,
87
+ className = _ref.className,
88
+ dataAttrs = _ref.dataAttrs,
89
+ children = _ref.children;
90
+ var Icon = getPriceBadgeIcon(iconType);
91
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
92
+ className: cn({
93
+ theme: theme,
94
+ adaptive: isAdaptive
95
+ }, className)
96
+ }), /*#__PURE__*/React.createElement("div", {
97
+ className: cn('icon-container')
98
+ }, /*#__PURE__*/React.createElement(Icon, {
99
+ className: cn('icon')
100
+ })), /*#__PURE__*/React.createElement("span", {
101
+ className: cn('text')
102
+ }, children));
103
+ };
104
+
105
+ PriceBadge.propTypes = {
106
+ isAdaptive: PropTypes.bool,
107
+ iconType: PropTypes.oneOf(Object.values(PriceBadgeIcon)),
108
+ theme: PropTypes.oneOf(Object.values(PriceBadgeTheme)),
109
+ className: PropTypes.string,
110
+ dataAttrs: PropTypes.shape({
111
+ root: PropTypes.objectOf(PropTypes.string.isRequired).isRequired
112
+ }),
113
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired
114
+ };
115
+ export default PriceBadge;
@@ -0,0 +1,35 @@
1
+ .mfui-promo-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: 4px 12px;
9
+ width: -webkit-fit-content;
10
+ width: -moz-fit-content;
11
+ width: fit-content;
12
+ border-radius: 8px;
13
+ color: var(--base);
14
+ }
15
+ .mfui-promo-badge_type_hit {
16
+ background-color: var(--warmRedC);
17
+ }
18
+ .mfui-promo-badge_type_new {
19
+ background-color: var(--systemBlue);
20
+ }
21
+ .mfui-promo-badge_type_vip {
22
+ background-color: var(--brandPurple);
23
+ }
24
+ .mfui-promo-badge_type_popular {
25
+ background-color: var(--137C);
26
+ }
27
+ .mfui-promo-badge_type_user-choice {
28
+ background-color: var(--reflexBlue);
29
+ }
30
+ .mfui-promo-badge__text {
31
+ font-family: inherit;
32
+ font-size: 12px;
33
+ line-height: 16px;
34
+ font-weight: 500;
35
+ }
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import './PromoBadge.less';
3
+ export declare const PromoBadgeTypes: {
4
+ readonly HIT: "hit";
5
+ readonly NEW: "new";
6
+ readonly VIP: "vip";
7
+ readonly POPULAR: "popular";
8
+ readonly USER_CHOICE: "user-choice";
9
+ };
10
+ declare type PromoBadgeTypesType = typeof PromoBadgeTypes[keyof typeof PromoBadgeTypes];
11
+ export interface IPromoBadgeProps {
12
+ /** Тип промо-бэйджа */
13
+ type?: PromoBadgeTypesType;
14
+ /** Дополнительный класс корневого элемента */
15
+ className?: string;
16
+ /** Дополнительные data-атрибуты к внутренним элементам */
17
+ dataAttrs?: {
18
+ root?: Record<string, string>;
19
+ };
20
+ children: JSX.Element[] | Element[] | JSX.Element | Element | string;
21
+ }
22
+ declare const PromoBadge: React.FC<IPromoBadgeProps>;
23
+ export default PromoBadge;
@@ -0,0 +1,39 @@
1
+ import "core-js/modules/es.object.values";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import * as React from 'react';
4
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
5
+ import * as PropTypes from 'prop-types';
6
+ import "./PromoBadge.css";
7
+ export var PromoBadgeTypes = {
8
+ HIT: 'hit',
9
+ NEW: 'new',
10
+ VIP: 'vip',
11
+ POPULAR: 'popular',
12
+ USER_CHOICE: 'user-choice'
13
+ };
14
+ var cn = cnCreate('mfui-promo-badge');
15
+
16
+ var PromoBadge = function PromoBadge(_ref) {
17
+ var _ref$type = _ref.type,
18
+ type = _ref$type === void 0 ? 'hit' : _ref$type,
19
+ className = _ref.className,
20
+ children = _ref.children,
21
+ dataAttrs = _ref.dataAttrs;
22
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
23
+ className: cn({
24
+ type: type
25
+ }, className)
26
+ }), /*#__PURE__*/React.createElement("span", {
27
+ className: cn('text')
28
+ }, children));
29
+ };
30
+
31
+ PromoBadge.propTypes = {
32
+ type: PropTypes.oneOf(Object.values(PromoBadgeTypes)),
33
+ className: PropTypes.string,
34
+ dataAttrs: PropTypes.shape({
35
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
36
+ }),
37
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired
38
+ };
39
+ export default PromoBadge;
@@ -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,96 @@
1
+ import "core-js/modules/es.array.concat";
2
+ import "core-js/modules/es.date.to-string";
3
+ import "core-js/modules/es.math.trunc";
4
+ import _extends from "@babel/runtime/helpers/extends";
5
+ import * as React from 'react';
6
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
7
+ import format from 'date-fns/format';
8
+ import ruLocale from 'date-fns/locale/ru';
9
+ import * as PropTypes from 'prop-types';
10
+ var SECONDS_IN_DAY = 86400;
11
+ var SECONDS_IN_HOUR = 3600;
12
+ var SECONDS_IN_MINUTE = 60;
13
+
14
+ var formatDate = function formatDate(date, pattern) {
15
+ return format(date, pattern, {
16
+ locale: ruLocale
17
+ });
18
+ };
19
+
20
+ export var getCountdownText = function getCountdownText() {
21
+ var remainingTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
22
+ var isMoreHourAndLessDay = remainingTime >= SECONDS_IN_HOUR && remainingTime < SECONDS_IN_DAY;
23
+
24
+ var truncTime = function truncTime() {
25
+ var divider = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
26
+ return Math.trunc(remainingTime / divider);
27
+ };
28
+
29
+ switch (true) {
30
+ case remainingTime <= 0:
31
+ {
32
+ return '';
33
+ }
34
+
35
+ case remainingTime < SECONDS_IN_MINUTE:
36
+ {
37
+ var seconds = truncTime();
38
+ return "".concat(seconds, " \u0441\u0435\u043A");
39
+ }
40
+
41
+ case remainingTime < SECONDS_IN_HOUR:
42
+ {
43
+ var minutes = truncTime(SECONDS_IN_MINUTE);
44
+ return "".concat(minutes, " \u043C\u0438\u043D");
45
+ }
46
+
47
+ case isMoreHourAndLessDay:
48
+ {
49
+ var hours = truncTime(SECONDS_IN_HOUR);
50
+ var secondsLeft = remainingTime - hours * SECONDS_IN_HOUR;
51
+
52
+ var _minutes = Math.trunc(secondsLeft / SECONDS_IN_MINUTE);
53
+
54
+ return _minutes ? "".concat(hours, " \u0447 ").concat(_minutes, " \u043C\u0438\u043D") : "".concat(hours, " \u0447");
55
+ }
56
+
57
+ case remainingTime >= SECONDS_IN_DAY:
58
+ {
59
+ var days = truncTime(SECONDS_IN_DAY);
60
+
61
+ var _secondsLeft = remainingTime - days * SECONDS_IN_DAY;
62
+
63
+ var _hours = Math.trunc(_secondsLeft / SECONDS_IN_HOUR);
64
+
65
+ return _hours ? "".concat(days, " \u0434\u043D ").concat(_hours, " \u0447") : "".concat(days, " \u0434\u043D");
66
+ }
67
+
68
+ default:
69
+ {
70
+ return '';
71
+ }
72
+ }
73
+ };
74
+ var cn = cnCreate('mfui-timer');
75
+
76
+ var Timer = function Timer(_ref) {
77
+ var actualRemainingTime = _ref.actualRemainingTime,
78
+ expirationDate = _ref.expirationDate,
79
+ showCountdown = _ref.showCountdown,
80
+ additionalText = _ref.additionalText,
81
+ dataAttrs = _ref.dataAttrs;
82
+ return /*#__PURE__*/React.createElement("div", _extends({
83
+ className: cn()
84
+ }, 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')));
85
+ };
86
+
87
+ Timer.propTypes = {
88
+ expirationDate: PropTypes.instanceOf(Date).isRequired,
89
+ actualRemainingTime: PropTypes.number.isRequired,
90
+ showCountdown: PropTypes.bool.isRequired,
91
+ additionalText: PropTypes.string,
92
+ dataAttrs: PropTypes.shape({
93
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
94
+ })
95
+ };
96
+ export default Timer;
@@ -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;