@megafon/ui-core 3.0.0-beta.1 → 3.0.0-beta.5

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 (28) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/es/colors/Colors.js +32 -3
  3. package/dist/es/components/Accordion/Accordion.d.ts +1 -1
  4. package/dist/es/components/Accordion/Accordion.js +10 -5
  5. package/dist/es/components/Calendar/components/Month/Month.js +21 -5
  6. package/dist/es/components/Checkbox/Checkbox.d.ts +3 -25
  7. package/dist/es/components/Checkbox/Checkbox.js +71 -89
  8. package/dist/es/components/Header/Header.d.ts +1 -18
  9. package/dist/es/components/Header/Header.js +28 -66
  10. package/dist/es/components/RadioButton/RadioButton.d.ts +1 -26
  11. package/dist/es/components/RadioButton/RadioButton.js +44 -83
  12. package/dist/es/components/Select/Select.d.ts +1 -1
  13. package/dist/es/components/Tooltip/Tooltip.d.ts +3 -2
  14. package/dist/es/components/Tooltip/Tooltip.js +2 -9
  15. package/dist/lib/colors/Colors.js +30 -3
  16. package/dist/lib/components/Accordion/Accordion.d.ts +1 -1
  17. package/dist/lib/components/Accordion/Accordion.js +9 -4
  18. package/dist/lib/components/Calendar/components/Month/Month.js +20 -4
  19. package/dist/lib/components/Checkbox/Checkbox.d.ts +3 -25
  20. package/dist/lib/components/Checkbox/Checkbox.js +76 -124
  21. package/dist/lib/components/Header/Header.d.ts +1 -18
  22. package/dist/lib/components/Header/Header.js +28 -97
  23. package/dist/lib/components/RadioButton/RadioButton.d.ts +1 -26
  24. package/dist/lib/components/RadioButton/RadioButton.js +45 -115
  25. package/dist/lib/components/Select/Select.d.ts +1 -1
  26. package/dist/lib/components/Tooltip/Tooltip.d.ts +3 -2
  27. package/dist/lib/components/Tooltip/Tooltip.js +1 -8
  28. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,57 @@
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.0.0-beta.5](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.0-beta.4...@megafon/ui-core@3.0.0-beta.5) (2022-01-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * **header:** made header as a functional component ([81701ad](https://github.com/MegafonWebLab/megafon-ui/commit/81701ad87b6e9df2fe630bf4e183383264c0bb01))
12
+ * **radiobutton:** made radiobutton as a functional component ([65406af](https://github.com/MegafonWebLab/megafon-ui/commit/65406afc90fd82f7eb0fdcbbe78569fc98164e78))
13
+
14
+
15
+
16
+
17
+
18
+ # [3.0.0-beta.4](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.0-beta.3...@megafon/ui-core@3.0.0-beta.4) (2022-01-27)
19
+
20
+ **Note:** Version bump only for package @megafon/ui-core
21
+
22
+
23
+
24
+
25
+
26
+ # [3.0.0-beta.3](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.0-beta.2...@megafon/ui-core@3.0.0-beta.3) (2022-01-24)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * **accordion:** add focus on arrow after tab press, add open/close accordion after enter press ([9bfa0ac](https://github.com/MegafonWebLab/megafon-ui/commit/9bfa0ac5348ac25c0e37a4df51e26e2dabde02ba))
32
+ * **accordion:** change type of onClickAccordion prop ([9a150c5](https://github.com/MegafonWebLab/megafon-ui/commit/9a150c5de309547763a714b0eb630dfb386a8107))
33
+ * **calendar/month:** add focus on month arrows, add enter press handlers ([63f1e47](https://github.com/MegafonWebLab/megafon-ui/commit/63f1e4761e57ed6d56464b632dce9fd5e77655e1))
34
+ * **checkbox:** add focus on custom checkbox, add enter press handler ([83d111d](https://github.com/MegafonWebLab/megafon-ui/commit/83d111d0e4b41d3915bdd079bed4a7f9715ce7a5))
35
+ * **checkbox:** add isChecked state, change type of onChange prop ([f535caf](https://github.com/MegafonWebLab/megafon-ui/commit/f535caf39a02ab6793d3c63b654a1f1f3e9b2b93))
36
+ * **tooltip:** add check event function from ui-helpers ([a784ab4](https://github.com/MegafonWebLab/megafon-ui/commit/a784ab4f288124eb941fe8f52e46b2efc9aa2f82))
37
+
38
+
39
+ ### BREAKING CHANGES
40
+
41
+ * **checkbox:** change type of onChange prop on (checked: boolean) => void
42
+ * **accordion:** remove parameter 'title' in onClickAccordion prop
43
+ * **tooltip:** change onOpen, onClose types; AccessibilityEventTypeNative from @megafon/ui-helpers
44
+
45
+
46
+
47
+
48
+
49
+ # [3.0.0-beta.2](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.0-beta.1...@megafon/ui-core@3.0.0-beta.2) (2022-01-21)
50
+
51
+ **Note:** Version bump only for package @megafon/ui-core
52
+
53
+
54
+
55
+
56
+
6
57
  # [3.0.0-beta.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.0-beta.0...@megafon/ui-core@3.0.0-beta.1) (2022-01-20)
7
58
 
8
59
 
@@ -1,5 +1,6 @@
1
1
  import "core-js/modules/es.symbol";
2
2
  import "core-js/modules/es.symbol.description";
3
+ import "core-js/modules/es.array.includes";
3
4
  import "core-js/modules/es.array.map";
4
5
  import "core-js/modules/es.function.name";
5
6
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
@@ -104,16 +105,44 @@ var basic = colorsData.basic,
104
105
  gradientColors = colorsData.gradientColors,
105
106
  staticColors = colorsData.staticColors,
106
107
  staticOpacity = colorsData.staticOpacity,
107
- soft = colorsData.soft;
108
+ soft = colorsData.soft; // TODO: refactor this
109
+
110
+ var getThemeFromLocalStorage = function getThemeFromLocalStorage() {
111
+ var theme = 'light';
112
+
113
+ if (typeof window !== 'undefined') {
114
+ var localStorageTheme = String(window.localStorage.getItem('theme'));
115
+
116
+ if (['light', 'dark'].includes(localStorageTheme)) {
117
+ theme = localStorageTheme;
118
+ }
119
+ }
120
+
121
+ return theme;
122
+ };
123
+
108
124
  var cn = cnCreate('colors');
109
125
 
110
126
  var Colors = function Colors() {
111
- var _React$useState = React.useState(window.localStorage.getItem('theme') === 'dark' ? 'dark' : 'light'),
127
+ var _React$useState = React.useState(getThemeFromLocalStorage()),
112
128
  _React$useState2 = _slicedToArray(_React$useState, 2),
113
129
  setCurrentTheme = _React$useState2[1];
114
130
 
131
+ var _React$useState3 = React.useState(false),
132
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
133
+ setLoad = _React$useState4[1];
134
+
135
+ React.useEffect(function () {
136
+ function load() {
137
+ setLoad(true);
138
+ document.removeEventListener('css-var-load', load);
139
+ }
140
+
141
+ document.addEventListener('css-var-load', load);
142
+ }, []);
143
+
115
144
  var getCurrentColorValue = function getCurrentColorValue(code) {
116
- return document.documentElement.style.getPropertyValue("--".concat(code));
145
+ return typeof document !== 'undefined' ? document.documentElement.style.getPropertyValue("--".concat(code)) : '';
117
146
  };
118
147
 
119
148
  React.useEffect(function () {
@@ -20,7 +20,7 @@ export interface IAccordionProps extends IFilterDataAttrs {
20
20
  titleWrap?: string;
21
21
  };
22
22
  /** Обработчик клика */
23
- onClickAccordion?: (isOpened: boolean, title: string | React.ReactNode | React.ReactNode[]) => void;
23
+ onClickAccordion?: (isOpened: boolean) => void;
24
24
  }
25
25
  declare const Accordion: React.FC<IAccordionProps>;
26
26
  export default Accordion;
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import * as React from 'react';
4
- import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
4
+ import { cnCreate, filterDataAttrs, checkEventIsClickOrEnterPress } from '@megafon/ui-helpers';
5
5
  import * as PropTypes from 'prop-types';
6
6
  import Collapse from "../Collapse/Collapse";
7
7
  import Header from "../Header/Header";
@@ -52,9 +52,11 @@ var Accordion = function Accordion(_ref) {
52
52
  setIsOpenedState(isOpened);
53
53
  }, [isOpened]);
54
54
 
55
- var handleClickTitle = function handleClickTitle() {
56
- onClickAccordion && onClickAccordion(!isOpenedState, title);
57
- setIsOpenedState(!isOpenedState);
55
+ var handleClickTitle = function handleClickTitle(e) {
56
+ if (checkEventIsClickOrEnterPress(e)) {
57
+ onClickAccordion && onClickAccordion(!isOpenedState);
58
+ setIsOpenedState(!isOpenedState);
59
+ }
58
60
  };
59
61
 
60
62
  var openedClassName = isOpenedState ? openedClass : undefined;
@@ -65,10 +67,13 @@ var Accordion = function Accordion(_ref) {
65
67
  }, [className, rootPropsClasses, openedClassName])
66
68
  }), /*#__PURE__*/React.createElement("div", {
67
69
  className: cn('title-wrap', [titleWrapPropsClasses]),
68
- onClick: handleClickTitle
70
+ onClick: handleClickTitle,
71
+ onKeyDown: handleClickTitle
69
72
  }, /*#__PURE__*/React.createElement(Header, {
70
73
  as: "h5"
71
74
  }, title), /*#__PURE__*/React.createElement("div", {
75
+ tabIndex: 0,
76
+ role: "button",
72
77
  className: cn('icon-box', {
73
78
  open: isOpenedState
74
79
  })
@@ -2,7 +2,7 @@ import "core-js/modules/es.array.concat";
2
2
  import "core-js/modules/es.array.map";
3
3
  import _extends from "@babel/runtime/helpers/extends";
4
4
  import React from 'react';
5
- import { cnCreate } from '@megafon/ui-helpers';
5
+ import { checkEventIsClickOrEnterPress, cnCreate } from '@megafon/ui-helpers';
6
6
  import "./Month.css";
7
7
  import PropTypes from 'prop-types';
8
8
 
@@ -38,12 +38,22 @@ var Month = function Month(_ref) {
38
38
  goToNextMonth = _ref.goToNextMonth,
39
39
  children = _ref.children;
40
40
 
41
- var handleArrowLeftClick = function handleArrowLeftClick() {
42
- !isPrevMonthDisabled && goToPreviousMonth();
41
+ var handleArrowLeftClick = function handleArrowLeftClick(e) {
42
+ if (checkEventIsClickOrEnterPress(e)) {
43
+ !isPrevMonthDisabled && goToPreviousMonth();
44
+ }
43
45
  };
44
46
 
45
- var handleArrowRightClick = function handleArrowRightClick() {
46
- !isNextMonthDisabled && goToNextMonth();
47
+ var handleArrowRightClick = function handleArrowRightClick(e) {
48
+ if (checkEventIsClickOrEnterPress(e)) {
49
+ !isNextMonthDisabled && goToNextMonth();
50
+ }
51
+ };
52
+
53
+ var getTabIndex = function getTabIndex(hasFocus) {
54
+ var tabIndexWithFocus = 0;
55
+ var tabIndexWithoutFocus = -1;
56
+ return hasFocus ? tabIndexWithFocus : tabIndexWithoutFocus;
47
57
  };
48
58
 
49
59
  return /*#__PURE__*/React.createElement("div", {
@@ -51,16 +61,22 @@ var Month = function Month(_ref) {
51
61
  }, /*#__PURE__*/React.createElement("div", {
52
62
  className: cn('header')
53
63
  }, /*#__PURE__*/React.createElement(ArrowLeft, {
64
+ role: "button",
65
+ tabIndex: getTabIndex(!isPrevMonthDisabled),
54
66
  className: cn('arrow', {
55
67
  disabled: isPrevMonthDisabled
56
68
  }),
69
+ onKeyDown: handleArrowLeftClick,
57
70
  onClick: handleArrowLeftClick
58
71
  }), /*#__PURE__*/React.createElement("span", {
59
72
  className: cn('title')
60
73
  }, "".concat(monthLabel, " ").concat(year)), /*#__PURE__*/React.createElement(ArrowRight, {
74
+ role: "button",
75
+ tabIndex: getTabIndex(!isNextMonthDisabled),
61
76
  className: cn('arrow', {
62
77
  disabled: isNextMonthDisabled
63
78
  }),
79
+ onKeyDown: handleArrowRightClick,
64
80
  onClick: handleArrowRightClick
65
81
  })), /*#__PURE__*/React.createElement("div", {
66
82
  className: cn('weekday-labels')
@@ -1,6 +1,5 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { IFilterDataAttrs } from '@megafon/ui-helpers';
3
- import * as PropTypes from 'prop-types';
4
3
  import './Checkbox.less';
5
4
  export interface ICheckboxProps extends IFilterDataAttrs {
6
5
  /** Цвет чекбокса */
@@ -28,28 +27,7 @@ export interface ICheckboxProps extends IFilterDataAttrs {
28
27
  extraContent?: JSX.Element[] | Element[] | JSX.Element | Element | string;
29
28
  children: JSX.Element[] | Element[] | JSX.Element | Element | string;
30
29
  /** Обработчик изменения значения */
31
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
32
- }
33
- declare class Checkbox extends React.Component<ICheckboxProps, {}> {
34
- static propTypes: {
35
- className: PropTypes.Requireable<string>;
36
- fontSize: PropTypes.Requireable<string>;
37
- color: PropTypes.Requireable<string>;
38
- name: PropTypes.Requireable<string>;
39
- value: PropTypes.Requireable<string>;
40
- checked: PropTypes.Requireable<boolean>;
41
- disabled: PropTypes.Requireable<boolean>;
42
- error: PropTypes.Requireable<boolean>;
43
- children: PropTypes.Requireable<string | PropTypes.ReactElementLike | (PropTypes.ReactElementLike | null | undefined)[]>;
44
- extraContent: PropTypes.Requireable<string | PropTypes.ReactElementLike | (PropTypes.ReactElementLike | null | undefined)[]>;
45
- dataAttrs: PropTypes.Requireable<{
46
- [x: string]: string;
47
- }>;
48
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
49
- };
50
- static defaultProps: Partial<ICheckboxProps>;
51
- isTouch: boolean;
52
- handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
53
- render(): JSX.Element;
30
+ onChange?: (checked: boolean) => void;
54
31
  }
32
+ declare const Checkbox: React.FC<ICheckboxProps>;
55
33
  export default Checkbox;
@@ -1,21 +1,8 @@
1
- import "core-js/modules/es.date.to-string";
2
1
  import "core-js/modules/es.function.name";
3
- import "core-js/modules/es.object.to-string";
4
- import "core-js/modules/es.reflect.construct";
5
- import "core-js/modules/es.regexp.to-string";
6
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
7
- import _createClass from "@babel/runtime/helpers/createClass";
8
- import _inherits from "@babel/runtime/helpers/inherits";
9
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
10
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
11
3
  import _extends from "@babel/runtime/helpers/extends";
12
-
13
- function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16
-
17
- import * as React from 'react';
18
- import { cnCreate, detectTouch, filterDataAttrs } from '@megafon/ui-helpers';
4
+ import React, { useState, useEffect } from 'react';
5
+ import { checkEventIsClickOrEnterPress, cnCreate, detectTouch, filterDataAttrs } from '@megafon/ui-helpers';
19
6
  import * as PropTypes from 'prop-types';
20
7
  import "./Checkbox.css";
21
8
 
@@ -27,79 +14,79 @@ var CheckedIcon = function CheckedIcon(props) {
27
14
  }));
28
15
  };
29
16
 
17
+ var CHANGE_KEY = 'change';
30
18
  var cn = cnCreate('mfui-checkbox');
31
19
 
32
- var Checkbox = /*#__PURE__*/function (_React$Component) {
33
- _inherits(Checkbox, _React$Component);
34
-
35
- var _super = _createSuper(Checkbox);
36
-
37
- function Checkbox() {
38
- var _this;
20
+ var Checkbox = function Checkbox(_ref) {
21
+ var className = _ref.className,
22
+ _ref$fontSize = _ref.fontSize,
23
+ fontSize = _ref$fontSize === void 0 ? 'regular' : _ref$fontSize,
24
+ name = _ref.name,
25
+ _ref$color = _ref.color,
26
+ color = _ref$color === void 0 ? 'dark' : _ref$color,
27
+ value = _ref.value,
28
+ _ref$checked = _ref.checked,
29
+ checked = _ref$checked === void 0 ? false : _ref$checked,
30
+ disabled = _ref.disabled,
31
+ error = _ref.error,
32
+ children = _ref.children,
33
+ extraContent = _ref.extraContent,
34
+ dataAttrs = _ref.dataAttrs,
35
+ classes = _ref.classes,
36
+ onChange = _ref.onChange;
37
+ var isTouch = detectTouch();
39
38
 
40
- _classCallCheck(this, Checkbox);
39
+ var _useState = useState(checked),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ isChecked = _useState2[0],
42
+ setIsChecked = _useState2[1];
41
43
 
42
- _this = _super.apply(this, arguments);
43
- _this.isTouch = detectTouch();
44
+ useEffect(function () {
45
+ setIsChecked(checked);
46
+ }, [checked]);
44
47
 
45
- _this.handleChange = function (e) {
46
- var onChange = _this.props.onChange;
47
- onChange && onChange(e);
48
- };
49
-
50
- return _this;
51
- }
52
-
53
- _createClass(Checkbox, [{
54
- key: "render",
55
- value: function render() {
56
- var _this$props = this.props,
57
- className = _this$props.className,
58
- fontSize = _this$props.fontSize,
59
- name = _this$props.name,
60
- color = _this$props.color,
61
- value = _this$props.value,
62
- checked = _this$props.checked,
63
- disabled = _this$props.disabled,
64
- error = _this$props.error,
65
- children = _this$props.children,
66
- extraContent = _this$props.extraContent,
67
- dataAttrs = _this$props.dataAttrs,
68
- classes = _this$props.classes;
69
- return /*#__PURE__*/React.createElement("div", _extends({
70
- className: cn('', {
71
- 'font-size': fontSize,
72
- color: color,
73
- checked: checked,
74
- disabled: disabled,
75
- error: error
76
- }, className)
77
- }, filterDataAttrs(dataAttrs)), /*#__PURE__*/React.createElement("div", {
78
- className: cn('inner', [classes === null || classes === void 0 ? void 0 : classes.inner])
79
- }, /*#__PURE__*/React.createElement("label", {
80
- className: cn('label', {
81
- 'no-touch': !this.isTouch
82
- })
83
- }, /*#__PURE__*/React.createElement("input", {
84
- className: cn('input'),
85
- type: "checkbox",
86
- name: name,
87
- value: value,
88
- checked: checked,
89
- onChange: this.handleChange,
90
- disabled: disabled
91
- }), /*#__PURE__*/React.createElement("div", {
92
- className: cn('custom-input', [classes === null || classes === void 0 ? void 0 : classes.icon])
93
- }, /*#__PURE__*/React.createElement(CheckedIcon, {
94
- className: cn('icon')
95
- })), children), extraContent && /*#__PURE__*/React.createElement("span", {
96
- className: cn('extra-content')
97
- }, extraContent)));
48
+ var handleChange = function handleChange(e) {
49
+ if (checkEventIsClickOrEnterPress(e) || e.type === CHANGE_KEY) {
50
+ setIsChecked(!isChecked);
51
+ onChange && onChange(!isChecked);
98
52
  }
99
- }]);
53
+ };
100
54
 
101
- return Checkbox;
102
- }(React.Component);
55
+ return /*#__PURE__*/React.createElement("div", _extends({
56
+ className: cn('', {
57
+ 'font-size': fontSize,
58
+ color: color,
59
+ checked: isChecked,
60
+ disabled: disabled,
61
+ error: error
62
+ }, className)
63
+ }, filterDataAttrs(dataAttrs)), /*#__PURE__*/React.createElement("div", {
64
+ className: cn('inner', [classes === null || classes === void 0 ? void 0 : classes.inner])
65
+ }, /*#__PURE__*/React.createElement("label", {
66
+ className: cn('label', {
67
+ 'no-touch': !isTouch
68
+ })
69
+ }, /*#__PURE__*/React.createElement("input", {
70
+ className: cn('input'),
71
+ type: "checkbox",
72
+ tabIndex: -1,
73
+ name: name,
74
+ value: value,
75
+ checked: isChecked,
76
+ onChange: handleChange,
77
+ disabled: disabled
78
+ }), /*#__PURE__*/React.createElement("div", {
79
+ tabIndex: 0,
80
+ role: "checkbox",
81
+ "aria-checked": isChecked,
82
+ className: cn('custom-input', [classes === null || classes === void 0 ? void 0 : classes.icon]),
83
+ onKeyDown: handleChange
84
+ }, /*#__PURE__*/React.createElement(CheckedIcon, {
85
+ className: cn('icon')
86
+ })), children), extraContent && /*#__PURE__*/React.createElement("span", {
87
+ className: cn('extra-content')
88
+ }, extraContent)));
89
+ };
103
90
 
104
91
  Checkbox.propTypes = {
105
92
  className: PropTypes.string,
@@ -110,14 +97,9 @@ Checkbox.propTypes = {
110
97
  checked: PropTypes.bool,
111
98
  disabled: PropTypes.bool,
112
99
  error: PropTypes.bool,
113
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.string]),
114
- extraContent: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.string]),
100
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]).isRequired,
101
+ extraContent: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element, PropTypes.string]),
115
102
  dataAttrs: PropTypes.objectOf(PropTypes.string.isRequired),
116
103
  onChange: PropTypes.func
117
104
  };
118
- Checkbox.defaultProps = {
119
- color: 'dark',
120
- fontSize: 'regular',
121
- checked: false
122
- };
123
105
  export default Checkbox;
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { IFilterDataAttrs } from '@megafon/ui-helpers';
3
- import * as PropTypes from 'prop-types';
4
3
  import './Header.less';
5
4
  interface IHeaderProps extends IFilterDataAttrs {
6
5
  /** Тег */
@@ -18,21 +17,5 @@ interface IHeaderProps extends IFilterDataAttrs {
18
17
  /** Обработчик клика */
19
18
  onClick?: (e: React.SyntheticEvent<EventTarget>) => void;
20
19
  }
21
- declare class Header extends React.Component<IHeaderProps, {}> {
22
- static propTypes: {
23
- as: PropTypes.Requireable<string>;
24
- color: PropTypes.Requireable<string>;
25
- margin: PropTypes.Requireable<boolean>;
26
- addition: PropTypes.Requireable<PropTypes.ReactElementLike>;
27
- hAlign: PropTypes.Requireable<string>;
28
- dataAttrs: PropTypes.Requireable<{
29
- [x: string]: string | null | undefined;
30
- }>;
31
- onClick: PropTypes.Requireable<(...args: any[]) => any>;
32
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
33
- };
34
- static defaultProps: Partial<IHeaderProps>;
35
- renderAddition(): JSX.Element;
36
- render(): JSX.Element;
37
- }
20
+ declare const Header: React.FC<IHeaderProps>;
38
21
  export default Header;
@@ -1,68 +1,36 @@
1
- import "core-js/modules/es.date.to-string";
2
- import "core-js/modules/es.object.to-string";
3
- import "core-js/modules/es.reflect.construct";
4
- import "core-js/modules/es.regexp.to-string";
5
1
  import _extends from "@babel/runtime/helpers/extends";
6
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
7
- import _createClass from "@babel/runtime/helpers/createClass";
8
- import _inherits from "@babel/runtime/helpers/inherits";
9
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
10
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
11
-
12
- function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
-
14
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
15
-
16
2
  import * as React from 'react';
17
3
  import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
18
4
  import * as PropTypes from 'prop-types';
19
5
  import "./Header.css";
20
6
  var cn = cnCreate('mfui-header');
21
7
 
22
- var Header = /*#__PURE__*/function (_React$Component) {
23
- _inherits(Header, _React$Component);
24
-
25
- var _super = _createSuper(Header);
26
-
27
- function Header() {
28
- _classCallCheck(this, Header);
29
-
30
- return _super.apply(this, arguments);
31
- }
32
-
33
- _createClass(Header, [{
34
- key: "renderAddition",
35
- value: function renderAddition() {
36
- return /*#__PURE__*/React.createElement("div", {
37
- className: cn('addition')
38
- }, this.props.addition);
39
- }
40
- }, {
41
- key: "render",
42
- value: function render() {
43
- var _this$props = this.props,
44
- color = _this$props.color,
45
- margin = _this$props.margin,
46
- level = _this$props.as,
47
- hAlign = _this$props.hAlign,
48
- onClick = _this$props.onClick,
49
- dataAttrs = _this$props.dataAttrs,
50
- className = _this$props.className;
51
- var ElementType = level;
52
- return /*#__PURE__*/React.createElement(ElementType, _extends({}, filterDataAttrs(dataAttrs), {
53
- className: cn({
54
- color: color,
55
- margin: margin,
56
- level: level,
57
- 'h-align': hAlign
58
- }, className),
59
- onClick: onClick
60
- }), this.props.children, this.props.addition && this.renderAddition());
61
- }
62
- }]);
63
-
64
- return Header;
65
- }(React.Component);
8
+ var Header = function Header(_ref) {
9
+ var addition = _ref.addition,
10
+ _ref$as = _ref.as,
11
+ level = _ref$as === void 0 ? 'h1' : _ref$as,
12
+ children = _ref.children,
13
+ className = _ref.className,
14
+ _ref$color = _ref.color,
15
+ color = _ref$color === void 0 ? 'default' : _ref$color,
16
+ dataAttrs = _ref.dataAttrs,
17
+ _ref$hAlign = _ref.hAlign,
18
+ hAlign = _ref$hAlign === void 0 ? 'inherit' : _ref$hAlign,
19
+ margin = _ref.margin,
20
+ onClick = _ref.onClick;
21
+ var ElementType = level;
22
+ return /*#__PURE__*/React.createElement(ElementType, _extends({}, filterDataAttrs(dataAttrs), {
23
+ className: cn({
24
+ color: color,
25
+ margin: margin,
26
+ level: level,
27
+ 'h-align': hAlign
28
+ }, className),
29
+ onClick: onClick
30
+ }), children, addition && /*#__PURE__*/React.createElement("div", {
31
+ className: cn('addition')
32
+ }, addition));
33
+ };
66
34
 
67
35
  Header.propTypes = {
68
36
  as: PropTypes.oneOf(['h1', 'h2', 'h3', 'h5']),
@@ -70,13 +38,7 @@ Header.propTypes = {
70
38
  margin: PropTypes.bool,
71
39
  addition: PropTypes.element,
72
40
  hAlign: PropTypes.oneOf(['inherit', 'left', 'center', 'right']),
73
- dataAttrs: PropTypes.objectOf(PropTypes.string),
74
- onClick: PropTypes.func,
75
- children: PropTypes.node
76
- };
77
- Header.defaultProps = {
78
- as: 'h1',
79
- color: 'default',
80
- hAlign: 'inherit'
41
+ dataAttrs: PropTypes.objectOf(PropTypes.string.isRequired),
42
+ onClick: PropTypes.func
81
43
  };
82
44
  export default Header;
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { IFilterDataAttrs } from '@megafon/ui-helpers';
3
- import * as PropTypes from 'prop-types';
4
3
  import './RadioButton.less';
5
4
  export interface IRadioButtonProps extends IFilterDataAttrs {
6
5
  /** Значение */
@@ -28,29 +27,5 @@ export interface IRadioButtonProps extends IFilterDataAttrs {
28
27
  /** Ссылка на input */
29
28
  inputRef?: React.Ref<HTMLInputElement>;
30
29
  }
31
- declare class RadioButton extends React.Component<IRadioButtonProps> {
32
- static propTypes: {
33
- value: PropTypes.Validator<string>;
34
- name: PropTypes.Requireable<string>;
35
- textSize: PropTypes.Requireable<string>;
36
- disabled: PropTypes.Requireable<boolean>;
37
- isChecked: PropTypes.Requireable<boolean>;
38
- className: PropTypes.Requireable<string>;
39
- classes: PropTypes.Requireable<PropTypes.InferProps<{
40
- root: PropTypes.Requireable<string>;
41
- label: PropTypes.Requireable<string>;
42
- customInput: PropTypes.Requireable<string>;
43
- labelText: PropTypes.Requireable<string>;
44
- }>>;
45
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
46
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
47
- inputRef: PropTypes.Requireable<any>;
48
- dataAttrs: PropTypes.Requireable<{
49
- [x: string]: string;
50
- }>;
51
- };
52
- static defaultProps: Partial<IRadioButtonProps>;
53
- handleChange: () => void;
54
- render(): JSX.Element;
55
- }
30
+ declare const RadioButton: React.FC<IRadioButtonProps>;
56
31
  export default RadioButton;