@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
@@ -0,0 +1,110 @@
1
+ import "core-js/modules/es.date.now";
2
+ import "core-js/modules/es.date.to-string";
3
+ import "core-js/modules/web.timers";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+ import _extends from "@babel/runtime/helpers/extends";
6
+ import React, { useEffect, useState } from 'react';
7
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
8
+ import * as PropTypes from 'prop-types';
9
+ import Timer from "./Timer/Timer";
10
+ import "./TimerBadge.css";
11
+
12
+ var TimerIcon = function TimerIcon(props) {
13
+ return /*#__PURE__*/React.createElement("svg", _extends({
14
+ viewBox: "0 0 20 20"
15
+ }, props), /*#__PURE__*/React.createElement("path", {
16
+ fillRule: "evenodd",
17
+ clipRule: "evenodd",
18
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-8.414V5H9v5.414l3 3L13.414 12 11 9.586z"
19
+ }));
20
+ };
21
+
22
+ var SECONDS_IN_HOUR = 3600;
23
+ var MS_IN_SECOND = 1000;
24
+ var TIMEOUT = 1000;
25
+ var TimerBadgeTheme = {
26
+ RED: 'red',
27
+ GREY: 'grey'
28
+ };
29
+ var cn = cnCreate('mfui-timer-badge');
30
+
31
+ var TimerBadge = function TimerBadge(_ref) {
32
+ var expirationDate = _ref.expirationDate,
33
+ _ref$countdownStart = _ref.countdownStart,
34
+ countdownStart = _ref$countdownStart === void 0 ? 86400 : _ref$countdownStart,
35
+ _ref$hasPrefix = _ref.hasPrefix,
36
+ hasPrefix = _ref$hasPrefix === void 0 ? false : _ref$hasPrefix,
37
+ _ref$countdownText = _ref.countdownText,
38
+ countdownText = _ref$countdownText === void 0 ? 'Закончится через' : _ref$countdownText,
39
+ _ref$expirationDateTe = _ref.expirationDateText,
40
+ expirationDateText = _ref$expirationDateTe === void 0 ? 'Воспользуйтесь до' : _ref$expirationDateTe,
41
+ className = _ref.className,
42
+ dataAttrs = _ref.dataAttrs;
43
+ var remainingTime = (expirationDate.getTime() - Date.now()) / MS_IN_SECOND;
44
+
45
+ var _useState = useState(remainingTime),
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ actualRemainingTime = _useState2[0],
48
+ setActualRemainingTime = _useState2[1];
49
+
50
+ var _useState3 = useState(false),
51
+ _useState4 = _slicedToArray(_useState3, 2),
52
+ showCountdown = _useState4[0],
53
+ setShowCountdown = _useState4[1];
54
+
55
+ var isLastHour = actualRemainingTime < SECONDS_IN_HOUR;
56
+ var isTimeExpired = actualRemainingTime < 1;
57
+ var theme = showCountdown ? TimerBadgeTheme.RED : TimerBadgeTheme.GREY;
58
+ var additionalText = showCountdown ? countdownText : expirationDateText;
59
+ useEffect(function () {
60
+ setShowCountdown(actualRemainingTime < countdownStart);
61
+ }, [actualRemainingTime, countdownStart]);
62
+ useEffect(function () {
63
+ if (isTimeExpired) {
64
+ return undefined;
65
+ }
66
+
67
+ var timeoutId = window.setTimeout(function () {
68
+ return setActualRemainingTime(actualRemainingTime - 1);
69
+ }, TIMEOUT);
70
+ return function () {
71
+ return clearTimeout(timeoutId);
72
+ };
73
+ }, [isTimeExpired, showCountdown, actualRemainingTime]);
74
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
75
+ className: cn({
76
+ theme: theme
77
+ }, className)
78
+ }), /*#__PURE__*/React.createElement("div", {
79
+ className: cn('icon-container', {
80
+ shadow: isLastHour && showCountdown
81
+ })
82
+ }, /*#__PURE__*/React.createElement(TimerIcon, {
83
+ className: cn('icon')
84
+ })), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.text), {
85
+ className: cn('text')
86
+ }), isTimeExpired ? 'Время действия истекло' : /*#__PURE__*/React.createElement(Timer, {
87
+ additionalText: hasPrefix ? additionalText : undefined,
88
+ showCountdown: showCountdown,
89
+ expirationDate: expirationDate,
90
+ actualRemainingTime: actualRemainingTime,
91
+ dataAttrs: {
92
+ root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.timer
93
+ }
94
+ })));
95
+ };
96
+
97
+ TimerBadge.propTypes = {
98
+ expirationDate: PropTypes.instanceOf(Date).isRequired,
99
+ countdownStart: PropTypes.number,
100
+ hasPrefix: PropTypes.bool,
101
+ countdownText: PropTypes.string,
102
+ expirationDateText: PropTypes.string,
103
+ className: PropTypes.string,
104
+ dataAttrs: PropTypes.shape({
105
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
106
+ text: PropTypes.objectOf(PropTypes.string.isRequired),
107
+ timer: PropTypes.objectOf(PropTypes.string.isRequired)
108
+ })
109
+ };
110
+ export default TimerBadge;
@@ -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;
@@ -58,6 +58,7 @@ var Collapse = function Collapse(props) {
58
58
  } else {
59
59
  animationStart.current = null;
60
60
  animationId.current = null;
61
+ rootNode.current.style.height = isOpenAction ? 'auto' : '0px';
61
62
  }
62
63
  }, []);
63
64
  useEffect(function () {
@@ -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-notification_type_success .mfui-notification__text,
197
- .mfui-notification_colored.mfui-notification_type_success .mfui-notification__link {
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-notification_type_success .mfui-notification__right-arrow {
201
- fill: var(--stcBlack);
202
- }
203
- .mfui-notification_colored.mfui-notification_type_success .mfui-notification__icon-container {
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;
@@ -46,7 +46,8 @@ var Search = function Search(_ref) {
46
46
  classes = _ref.classes,
47
47
  onChange = _ref.onChange,
48
48
  onSubmit = _ref.onSubmit,
49
- onBlur = _ref.onBlur;
49
+ onBlur = _ref.onBlur,
50
+ onFocus = _ref.onFocus;
50
51
 
51
52
  var _React$useState = React.useState(value),
52
53
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -101,9 +102,10 @@ var Search = function Search(_ref) {
101
102
  handleItemSubmit(activeIndex);
102
103
  };
103
104
  }, [handleItemSubmit, activeIndex]);
104
- var handleFocus = React.useCallback(function () {
105
+ var handleFocus = React.useCallback(function (e) {
105
106
  setFocus(true);
106
- }, []);
107
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
108
+ }, [onFocus]);
107
109
  var handleBlur = React.useCallback(function (e) {
108
110
  setFocus(false);
109
111
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
@@ -242,6 +244,7 @@ Search.propTypes = {
242
244
  }),
243
245
  onChange: PropTypes.func,
244
246
  onSubmit: PropTypes.func,
245
- onBlur: PropTypes.func
247
+ onBlur: PropTypes.func,
248
+ onFocus: PropTypes.func
246
249
  };
247
250
  export default Search;
@@ -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;
@@ -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';
package/dist/es/index.js 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";
@@ -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,136 @@
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.PriceBadgeIcon = exports.PriceBadgeTheme = 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 AttentionIcon = function AttentionIcon(props) {
27
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
28
+ viewBox: "0 0 20 20"
29
+ }, props), /*#__PURE__*/React.createElement("path", {
30
+ 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"
31
+ }));
32
+ };
33
+
34
+ var CheckIcon = function CheckIcon(props) {
35
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
36
+ viewBox: "0 0 20 20"
37
+ }, props), /*#__PURE__*/React.createElement("path", {
38
+ fillRule: "evenodd",
39
+ clipRule: "evenodd",
40
+ 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"
41
+ }));
42
+ };
43
+
44
+ var PriceIcon = function PriceIcon(props) {
45
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
46
+ viewBox: "0 0 20 20"
47
+ }, props), /*#__PURE__*/React.createElement("path", {
48
+ fillRule: "evenodd",
49
+ clipRule: "evenodd",
50
+ 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"
51
+ }));
52
+ };
53
+
54
+ var TimerIcon = function TimerIcon(props) {
55
+ return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
56
+ viewBox: "0 0 20 20"
57
+ }, props), /*#__PURE__*/React.createElement("path", {
58
+ fillRule: "evenodd",
59
+ clipRule: "evenodd",
60
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-8.414V5H9v5.414l3 3L13.414 12 11 9.586z"
61
+ }));
62
+ };
63
+
64
+ var PriceBadgeTheme = {
65
+ RED: 'red',
66
+ GREY: 'grey',
67
+ GREEN: 'green',
68
+ ORANGE: 'orange'
69
+ };
70
+ exports.PriceBadgeTheme = PriceBadgeTheme;
71
+ var PriceBadgeIcon = {
72
+ TIMER: 'timer',
73
+ PRICE: 'price',
74
+ CHECK: 'check',
75
+ ATTENTION: 'attention'
76
+ };
77
+ exports.PriceBadgeIcon = PriceBadgeIcon;
78
+
79
+ var getPriceBadgeIcon = function getPriceBadgeIcon(iconType) {
80
+ switch (iconType) {
81
+ case PriceBadgeIcon.TIMER:
82
+ return TimerIcon;
83
+
84
+ case PriceBadgeIcon.PRICE:
85
+ return PriceIcon;
86
+
87
+ case PriceBadgeIcon.CHECK:
88
+ return CheckIcon;
89
+
90
+ case PriceBadgeIcon.ATTENTION:
91
+ return AttentionIcon;
92
+
93
+ default:
94
+ return TimerIcon;
95
+ }
96
+ };
97
+
98
+ var cn = (0, _uiHelpers.cnCreate)('mfui-price-badge');
99
+
100
+ var PriceBadge = function PriceBadge(_ref) {
101
+ var _ref$iconType = _ref.iconType,
102
+ iconType = _ref$iconType === void 0 ? 'timer' : _ref$iconType,
103
+ _ref$isAdaptive = _ref.isAdaptive,
104
+ isAdaptive = _ref$isAdaptive === void 0 ? false : _ref$isAdaptive,
105
+ _ref$theme = _ref.theme,
106
+ theme = _ref$theme === void 0 ? 'grey' : _ref$theme,
107
+ className = _ref.className,
108
+ dataAttrs = _ref.dataAttrs,
109
+ children = _ref.children;
110
+ var Icon = getPriceBadgeIcon(iconType);
111
+ return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
112
+ className: cn({
113
+ theme: theme,
114
+ adaptive: isAdaptive
115
+ }, className)
116
+ }), /*#__PURE__*/React.createElement("div", {
117
+ className: cn('icon-container')
118
+ }, /*#__PURE__*/React.createElement(Icon, {
119
+ className: cn('icon')
120
+ })), /*#__PURE__*/React.createElement("span", {
121
+ className: cn('text')
122
+ }, children));
123
+ };
124
+
125
+ PriceBadge.propTypes = {
126
+ isAdaptive: PropTypes.bool,
127
+ iconType: PropTypes.oneOf(Object.values(PriceBadgeIcon)),
128
+ theme: PropTypes.oneOf(Object.values(PriceBadgeTheme)),
129
+ className: PropTypes.string,
130
+ dataAttrs: PropTypes.shape({
131
+ root: PropTypes.objectOf(PropTypes.string.isRequired).isRequired
132
+ }),
133
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired
134
+ };
135
+ var _default = PriceBadge;
136
+ exports["default"] = _default;
@@ -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;