@megafon/ui-core 2.1.3 → 2.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 +56 -0
- package/dist/es/colors/Colors.css +3 -3
- package/dist/es/colors/Colors.d.ts +2 -2
- package/dist/es/colors/Colors.js +2 -2
- package/dist/es/colors/colorsData.js +9 -0
- package/dist/es/components/Accordion/Accordion.d.ts +1 -0
- package/dist/es/components/Accordion/Accordion.js +4 -2
- package/dist/es/components/Banner/Banner.css +28 -0
- package/dist/es/components/Banner/Banner.d.ts +2 -0
- package/dist/es/components/Banner/Banner.js +15 -10
- package/dist/es/components/Button/Button.js +2 -2
- package/dist/es/components/Calendar/Calendar.js +3 -2
- package/dist/es/components/Calendar/components/Day/Day.js +1 -1
- package/dist/es/components/Carousel/Carousel.js +17 -14
- package/dist/es/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/es/components/Checkbox/Checkbox.js +1 -1
- package/dist/es/components/Counter/Counter.js +3 -3
- package/dist/es/components/Header/Header.d.ts +1 -1
- package/dist/es/components/Link/Link.d.ts +7 -3
- package/dist/es/components/Link/Link.js +21 -8
- package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.js +1 -1
- package/dist/es/components/Pagination/helpers.d.ts +1 -1
- package/dist/es/components/RadioButton/RadioButton.d.ts +5 -1
- package/dist/es/components/RadioButton/RadioButton.js +8 -6
- package/dist/es/components/Search/Search.js +4 -3
- package/dist/es/components/Select/Select.d.ts +3 -3
- package/dist/es/components/Select/Select.js +5 -5
- package/dist/es/components/Switcher/Switcher.js +1 -1
- package/dist/es/components/Tabs/Tabs.js +52 -42
- package/dist/es/components/TextField/TextField.d.ts +3 -1
- package/dist/es/components/TextField/TextField.js +14 -10
- package/dist/es/components/Tile/Tile.js +1 -1
- package/dist/es/components/Tooltip/Tooltip.js +17 -17
- package/dist/lib/colors/Colors.css +3 -3
- package/dist/lib/colors/Colors.d.ts +2 -2
- package/dist/lib/colors/Colors.js +2 -2
- package/dist/lib/colors/colorsData.js +9 -0
- package/dist/lib/components/Accordion/Accordion.d.ts +1 -0
- package/dist/lib/components/Accordion/Accordion.js +4 -2
- package/dist/lib/components/Banner/Banner.css +28 -0
- package/dist/lib/components/Banner/Banner.d.ts +2 -0
- package/dist/lib/components/Banner/Banner.js +15 -10
- package/dist/lib/components/Button/Button.js +2 -2
- package/dist/lib/components/Calendar/Calendar.js +3 -3
- package/dist/lib/components/Calendar/components/Day/Day.js +1 -1
- package/dist/lib/components/Carousel/Carousel.js +15 -12
- package/dist/lib/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/lib/components/Checkbox/Checkbox.js +1 -1
- package/dist/lib/components/Counter/Counter.js +3 -3
- package/dist/lib/components/Header/Header.d.ts +1 -1
- package/dist/lib/components/Link/Link.d.ts +7 -3
- package/dist/lib/components/Link/Link.js +34 -23
- package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.js +1 -1
- package/dist/lib/components/Pagination/helpers.d.ts +1 -1
- package/dist/lib/components/RadioButton/RadioButton.d.ts +5 -1
- package/dist/lib/components/RadioButton/RadioButton.js +7 -5
- package/dist/lib/components/Search/Search.js +4 -3
- package/dist/lib/components/Select/Select.d.ts +3 -3
- package/dist/lib/components/Select/Select.js +5 -5
- package/dist/lib/components/Switcher/Switcher.js +1 -1
- package/dist/lib/components/Tabs/Tabs.js +52 -42
- package/dist/lib/components/TextField/TextField.d.ts +3 -1
- package/dist/lib/components/TextField/TextField.js +14 -10
- package/dist/lib/components/Tile/Tile.js +1 -1
- package/dist/lib/components/Tooltip/Tooltip.js +17 -17
- package/package.json +2 -2
- package/styles/base.less +3 -5
|
@@ -123,7 +123,7 @@ var Button = function Button(_ref) {
|
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
onClick
|
|
126
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
127
127
|
}, [disabled, onClick]);
|
|
128
128
|
|
|
129
129
|
var currentTheme = _react["default"].useMemo(function () {
|
|
@@ -185,7 +185,7 @@ var Button = function Button(_ref) {
|
|
|
185
185
|
sizeTablet: sizeTablet && getLoaderSize(sizeTablet),
|
|
186
186
|
sizeMobile: sizeMobile && getLoaderSize(sizeMobile)
|
|
187
187
|
});
|
|
188
|
-
}, [sizeAll, sizeWide, sizeDesktop, sizeTablet, sizeMobile]);
|
|
188
|
+
}, [sizeAll, sizeWide, sizeDesktop, sizeTablet, sizeMobile, loaderColor]);
|
|
189
189
|
|
|
190
190
|
var setRelAttribute = function setRelAttribute() {
|
|
191
191
|
if (ElementType !== 'a') {
|
|
@@ -146,7 +146,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
146
146
|
(0, _react.useEffect)(function () {
|
|
147
147
|
var propsStartDate = calendarStateFromProps.startDate;
|
|
148
148
|
setCalendarState(calendarStateFromProps);
|
|
149
|
-
propsStartDate && goToDate(propsStartDate);
|
|
149
|
+
propsStartDate && goToDate(propsStartDate); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
150
150
|
}, [calendarStateFromProps]);
|
|
151
151
|
|
|
152
152
|
var getCalendarState = function getCalendarState(date) {
|
|
@@ -211,7 +211,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
211
211
|
var nextStartDate = nextState.startDate,
|
|
212
212
|
nextEndDate = nextState.endDate;
|
|
213
213
|
setCalendarState(nextState);
|
|
214
|
-
onChange
|
|
214
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(nextStartDate, nextEndDate);
|
|
215
215
|
};
|
|
216
216
|
|
|
217
217
|
var handleDateHover = function handleDateHover(date) {
|
|
@@ -255,7 +255,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
255
255
|
var renderMonths = function renderMonths() {
|
|
256
256
|
return activeMonths.map(function (_ref2) {
|
|
257
257
|
var month = _ref2.month,
|
|
258
|
-
year = _ref2.year;
|
|
258
|
+
year = _ref2.year; // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
259
259
|
|
|
260
260
|
var _useMonth = (0, _hooks.useMonth)({
|
|
261
261
|
year: year,
|
|
@@ -79,7 +79,7 @@ var Day = function Day(_a) {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
var handleMouseLeave = function handleMouseLeave() {
|
|
82
|
-
onMouseLeave
|
|
82
|
+
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave();
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
return /*#__PURE__*/_react["default"].createElement("button", {
|
|
@@ -154,7 +154,8 @@ var Carousel = function Carousel(_ref) {
|
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
autoplay.stop();
|
|
157
|
+
autoplay.stop(); // eslint-disable-next-line no-param-reassign
|
|
158
|
+
|
|
158
159
|
params.autoplay.delay = autoPlayDelay * 3;
|
|
159
160
|
autoplay.start();
|
|
160
161
|
}, [autoPlayDelay]);
|
|
@@ -164,7 +165,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
swiperInstance.slidePrev();
|
|
167
|
-
onPrevClick
|
|
168
|
+
onPrevClick === null || onPrevClick === void 0 ? void 0 : onPrevClick(swiperInstance.realIndex);
|
|
168
169
|
increaseAutoplayDelay(swiperInstance);
|
|
169
170
|
}, [swiperInstance, onPrevClick, increaseAutoplayDelay]);
|
|
170
171
|
var handleNextClick = React.useCallback(function () {
|
|
@@ -173,14 +174,14 @@ var Carousel = function Carousel(_ref) {
|
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
swiperInstance.slideNext();
|
|
176
|
-
onNextClick
|
|
177
|
+
onNextClick === null || onNextClick === void 0 ? void 0 : onNextClick(swiperInstance.realIndex);
|
|
177
178
|
increaseAutoplayDelay(swiperInstance);
|
|
178
179
|
}, [swiperInstance, onNextClick, increaseAutoplayDelay]);
|
|
179
180
|
var handleSwiper = React.useCallback(function (swiper) {
|
|
180
181
|
setSwiperInstance(swiper);
|
|
181
182
|
setLocked(swiper.isBeginning && swiper.isEnd);
|
|
182
|
-
getSwiper
|
|
183
|
-
}, []);
|
|
183
|
+
getSwiper === null || getSwiper === void 0 ? void 0 : getSwiper(swiper);
|
|
184
|
+
}, [getSwiper]);
|
|
184
185
|
var handleReachBeginnig = React.useCallback(function () {
|
|
185
186
|
setBeginning(true);
|
|
186
187
|
}, []);
|
|
@@ -201,7 +202,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
201
202
|
var realIndex = _ref4.realIndex,
|
|
202
203
|
previousIndex = _ref4.previousIndex,
|
|
203
204
|
params = _ref4.params;
|
|
204
|
-
onChange
|
|
205
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(realIndex, previousIndex, params.slidesPerView);
|
|
205
206
|
}, [onChange]);
|
|
206
207
|
|
|
207
208
|
var handleRootClick = function handleRootClick(e) {
|
|
@@ -214,13 +215,15 @@ var Carousel = function Carousel(_ref) {
|
|
|
214
215
|
}; // https://github.com/nolimits4web/Swiper/issues/2346
|
|
215
216
|
|
|
216
217
|
|
|
217
|
-
var handleSwiperResize = React.useCallback(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
var handleSwiperResize = React.useCallback(function () {
|
|
219
|
+
(0, _lodash["default"])(function (swiper) {
|
|
220
|
+
setBeginning(swiper.isBeginning);
|
|
221
|
+
setEnd(swiper.isEnd);
|
|
222
|
+
setLocked(swiper.isBeginning && swiper.isEnd);
|
|
221
223
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
+
if (swiper.params.slidesPerView === SlidesPerView.AUTO) {}
|
|
225
|
+
}, _throttleTime["default"].resize);
|
|
226
|
+
}, []);
|
|
224
227
|
|
|
225
228
|
var handleSlideFocus = function handleSlideFocus(index) {
|
|
226
229
|
return function (e) {
|
|
@@ -30,7 +30,7 @@ export interface ICheckboxProps extends IFilterDataAttrs {
|
|
|
30
30
|
/** Обработчик изменения значения */
|
|
31
31
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
32
32
|
}
|
|
33
|
-
declare class Checkbox extends React.Component<ICheckboxProps
|
|
33
|
+
declare class Checkbox extends React.Component<ICheckboxProps> {
|
|
34
34
|
static propTypes: {
|
|
35
35
|
className: PropTypes.Requireable<string>;
|
|
36
36
|
fontSize: PropTypes.Requireable<string>;
|
|
@@ -94,7 +94,7 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
|
|
|
94
94
|
|
|
95
95
|
_this.handleChange = function (e) {
|
|
96
96
|
var onChange = _this.props.onChange;
|
|
97
|
-
onChange
|
|
97
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
return _this;
|
|
@@ -75,15 +75,15 @@ var Counter = function Counter(_ref) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
if (inputValue < min) {
|
|
78
|
-
onChange
|
|
78
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(min);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
if (inputValue > max) {
|
|
82
|
-
onChange
|
|
82
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(max);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
if (inputValue >= min && inputValue <= max) {
|
|
86
|
-
onChange
|
|
86
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(inputValue);
|
|
87
87
|
}
|
|
88
88
|
}, [min, max, onChange, isControlled]);
|
|
89
89
|
var handleMinusClick = React.useCallback(function () {
|
|
@@ -18,7 +18,7 @@ interface IHeaderProps extends IFilterDataAttrs {
|
|
|
18
18
|
/** Обработчик клика */
|
|
19
19
|
onClick?: (e: React.SyntheticEvent<EventTarget>) => void;
|
|
20
20
|
}
|
|
21
|
-
declare class Header extends React.Component<IHeaderProps
|
|
21
|
+
declare class Header extends React.Component<IHeaderProps> {
|
|
22
22
|
static propTypes: {
|
|
23
23
|
as: PropTypes.Requireable<string>;
|
|
24
24
|
color: PropTypes.Requireable<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export interface ILinkProps {
|
|
3
3
|
/** Дополнительный класс корневого элемента */
|
|
4
4
|
className?: string;
|
|
@@ -8,10 +8,14 @@ export interface ILinkProps {
|
|
|
8
8
|
target?: '_self' | '_blank' | '_parent' | '_top';
|
|
9
9
|
/** rel - аргумент тега <a> */
|
|
10
10
|
rel?: string;
|
|
11
|
-
/** Обработчик клика */
|
|
12
|
-
onClick?: (e: React.MouseEvent<EventTarget>) => void;
|
|
13
11
|
/** Добавление атрибута download */
|
|
14
12
|
download?: boolean;
|
|
13
|
+
/** Дата атрибуты для элемента */
|
|
14
|
+
dataAttrs?: {
|
|
15
|
+
root?: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
/** Обработчик клика */
|
|
18
|
+
onClick?: (e: React.MouseEvent<EventTarget>) => void;
|
|
15
19
|
children?: JSX.Element[] | Element[] | JSX.Element | string | Element | React.ReactNode;
|
|
16
20
|
}
|
|
17
21
|
declare const Link: React.FC<ILinkProps>;
|
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports["default"] = void 0;
|
|
9
7
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _uiHelpers = require("@megafon/ui-helpers");
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
var Link = function Link(_ref) {
|
|
19
|
+
var target = _ref.target,
|
|
20
|
+
href = _ref.href,
|
|
21
|
+
rel = _ref.rel,
|
|
22
|
+
onClick = _ref.onClick,
|
|
23
|
+
className = _ref.className,
|
|
24
|
+
download = _ref.download,
|
|
25
|
+
children = _ref.children,
|
|
26
|
+
dataAttrs = _ref.dataAttrs;
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement("a", (0, _extends2["default"])({
|
|
28
|
+
className: className,
|
|
29
|
+
href: href,
|
|
30
|
+
target: target,
|
|
31
|
+
rel: rel,
|
|
32
|
+
download: download,
|
|
33
|
+
onClick: onClick
|
|
34
|
+
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), children);
|
|
24
35
|
};
|
|
25
36
|
|
|
26
37
|
Link.propTypes = {
|
|
27
|
-
href:
|
|
28
|
-
children:
|
|
29
|
-
target:
|
|
30
|
-
className:
|
|
31
|
-
rel:
|
|
32
|
-
onClick:
|
|
33
|
-
download:
|
|
38
|
+
href: _propTypes["default"].string,
|
|
39
|
+
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].element), _propTypes["default"].element, _propTypes["default"].string, _propTypes["default"].node]),
|
|
40
|
+
target: _propTypes["default"].oneOf(['_self', '_blank', '_parent', '_top']),
|
|
41
|
+
className: _propTypes["default"].string,
|
|
42
|
+
rel: _propTypes["default"].string,
|
|
43
|
+
onClick: _propTypes["default"].func,
|
|
44
|
+
download: _propTypes["default"].bool
|
|
34
45
|
};
|
|
35
46
|
var _default = Link;
|
|
36
47
|
exports["default"] = _default;
|
|
@@ -28,7 +28,7 @@ var PaginationButton = function PaginationButton(_ref) {
|
|
|
28
28
|
value = _ref.value;
|
|
29
29
|
|
|
30
30
|
var handleClick = function handleClick() {
|
|
31
|
-
onClick
|
|
31
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(value);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
return /*#__PURE__*/_react["default"].createElement("button", {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const getRange: (from:
|
|
1
|
+
declare const getRange: (from: number, to: number, step?: number) => number[];
|
|
2
2
|
export default getRange;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { IFilterDataAttrs } from '@megafon/ui-helpers';
|
|
2
3
|
import * as PropTypes from 'prop-types';
|
|
3
4
|
import './RadioButton.less';
|
|
4
|
-
export interface IRadioButtonProps {
|
|
5
|
+
export interface IRadioButtonProps extends IFilterDataAttrs {
|
|
5
6
|
/** Значение */
|
|
6
7
|
value: string;
|
|
7
8
|
/** Имя для тега form */
|
|
@@ -44,6 +45,9 @@ declare class RadioButton extends React.Component<IRadioButtonProps> {
|
|
|
44
45
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
45
46
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
46
47
|
inputRef: PropTypes.Requireable<any>;
|
|
48
|
+
dataAttrs: PropTypes.Requireable<{
|
|
49
|
+
[x: string]: string;
|
|
50
|
+
}>;
|
|
47
51
|
};
|
|
48
52
|
static defaultProps: Partial<IRadioButtonProps>;
|
|
49
53
|
handleChange: () => void;
|
|
@@ -93,7 +93,7 @@ var RadioButton = /*#__PURE__*/function (_React$Component) {
|
|
|
93
93
|
var _this$props = _this.props,
|
|
94
94
|
onChange = _this$props.onChange,
|
|
95
95
|
value = _this$props.value;
|
|
96
|
-
onChange
|
|
96
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
return _this;
|
|
@@ -112,14 +112,15 @@ var RadioButton = /*#__PURE__*/function (_React$Component) {
|
|
|
112
112
|
inputRef = _this$props2.inputRef,
|
|
113
113
|
className = _this$props2.className,
|
|
114
114
|
_this$props2$classes = _this$props2.classes,
|
|
115
|
-
classes = _this$props2$classes === void 0 ? {} : _this$props2$classes
|
|
115
|
+
classes = _this$props2$classes === void 0 ? {} : _this$props2$classes,
|
|
116
|
+
dataAttrs = _this$props2.dataAttrs;
|
|
116
117
|
var checkedProp = isChecked !== undefined ? {
|
|
117
118
|
checked: isChecked
|
|
118
119
|
} : {};
|
|
119
120
|
var rootClassNames = Array.isArray(className) ? [].concat((0, _toConsumableArray2["default"])(className), [classes.root]) : [className, classes.root];
|
|
120
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
121
|
+
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
|
|
121
122
|
className: cn(rootClassNames)
|
|
122
|
-
}, /*#__PURE__*/React.createElement("label", {
|
|
123
|
+
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs)), /*#__PURE__*/React.createElement("label", {
|
|
123
124
|
className: cn('label', {
|
|
124
125
|
disabled: disabled
|
|
125
126
|
}, classes.label)
|
|
@@ -160,7 +161,8 @@ RadioButton.propTypes = {
|
|
|
160
161
|
onChange: PropTypes.func,
|
|
161
162
|
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
|
|
162
163
|
current: PropTypes.elementType
|
|
163
|
-
}), PropTypes.any])])
|
|
164
|
+
}), PropTypes.any])]),
|
|
165
|
+
dataAttrs: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
164
166
|
};
|
|
165
167
|
RadioButton.defaultProps = {
|
|
166
168
|
textSize: 'medium',
|
|
@@ -100,7 +100,7 @@ var Search = function Search(_ref) {
|
|
|
100
100
|
setActiveIndex(-1);
|
|
101
101
|
|
|
102
102
|
if (changeDelay === 0) {
|
|
103
|
-
onChange
|
|
103
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(inputValue);
|
|
104
104
|
} else {
|
|
105
105
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
106
106
|
// @ts-ignore
|
|
@@ -124,7 +124,7 @@ var Search = function Search(_ref) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
var chosenValue = items[index].value;
|
|
127
|
-
onSubmit
|
|
127
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(chosenValue);
|
|
128
128
|
}, [disabled, items, onSubmit]);
|
|
129
129
|
|
|
130
130
|
var handleSelectSubmit = _react["default"].useCallback(function () {
|
|
@@ -139,7 +139,7 @@ var Search = function Search(_ref) {
|
|
|
139
139
|
|
|
140
140
|
var handleBlur = _react["default"].useCallback(function (e) {
|
|
141
141
|
setFocus(false);
|
|
142
|
-
onBlur
|
|
142
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
143
143
|
}, [onBlur]);
|
|
144
144
|
|
|
145
145
|
var handleClick = _react["default"].useCallback(function () {
|
|
@@ -161,6 +161,7 @@ var Search = function Search(_ref) {
|
|
|
161
161
|
e.preventDefault();
|
|
162
162
|
} else if (e.key === 'Enter' && activeIndex > -1) {
|
|
163
163
|
handleItemSubmit(activeIndex);
|
|
164
|
+
e.preventDefault();
|
|
164
165
|
} else if (e.key === 'Enter' && activeIndex === -1) {
|
|
165
166
|
handleSearchSubmit();
|
|
166
167
|
}
|
|
@@ -138,9 +138,9 @@ declare class Select<T extends SelectItemValueType> extends React.Component<ISel
|
|
|
138
138
|
handleChangeCombobox: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
139
139
|
handleKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => boolean;
|
|
140
140
|
highlightString: (title: string, view?: string | Element | JSX.Element | JSX.Element[] | Element[] | ((data: ViewCallbackArguments) => ElementOrString) | undefined) => ElementOrString;
|
|
141
|
-
getItemWrapper: (node:
|
|
142
|
-
getSelectNode: (node:
|
|
143
|
-
getNodeList: (node:
|
|
141
|
+
getItemWrapper: (node: HTMLDivElement) => void;
|
|
142
|
+
getSelectNode: (node: HTMLDivElement) => void;
|
|
143
|
+
getNodeList: (node: HTMLDivElement) => void;
|
|
144
144
|
scrollList(activeIndex: number): void;
|
|
145
145
|
renderTitle(): JSX.Element;
|
|
146
146
|
renderCombobox(): JSX.Element;
|
|
@@ -154,12 +154,12 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
154
154
|
|
|
155
155
|
_this.handleOpened = function () {
|
|
156
156
|
var onOpened = _this.props.onOpened;
|
|
157
|
-
onOpened
|
|
157
|
+
onOpened === null || onOpened === void 0 ? void 0 : onOpened();
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
_this.handleClosed = function () {
|
|
161
161
|
var onClosed = _this.props.onClosed;
|
|
162
|
-
onClosed
|
|
162
|
+
onClosed === null || onClosed === void 0 ? void 0 : onClosed();
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
_this.handleClickOutside = function (e) {
|
|
@@ -218,7 +218,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
218
218
|
isChoosenItem: true
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
-
onSelect
|
|
221
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(e, item);
|
|
222
222
|
|
|
223
223
|
_this.handleClosed();
|
|
224
224
|
};
|
|
@@ -258,7 +258,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
258
258
|
var filterValue = e.target.value;
|
|
259
259
|
|
|
260
260
|
if (isChoosenItem) {
|
|
261
|
-
onSelect
|
|
261
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(null);
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
_this.setState({
|
|
@@ -376,7 +376,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
376
376
|
};
|
|
377
377
|
|
|
378
378
|
_this.getNodeList = function (node) {
|
|
379
|
-
|
|
379
|
+
_this.itemsNodeList.push(node);
|
|
380
380
|
};
|
|
381
381
|
|
|
382
382
|
_this.state = {
|
|
@@ -126,36 +126,41 @@ var Tabs = function Tabs(_ref) {
|
|
|
126
126
|
|
|
127
127
|
var _React$useState9 = React.useState(0),
|
|
128
128
|
_React$useState10 = (0, _slicedToArray2["default"])(_React$useState9, 2),
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
activeTabWidth = _React$useState10[0],
|
|
130
|
+
setActiveTabWidth = _React$useState10[1];
|
|
131
131
|
|
|
132
132
|
var _React$useState11 = React.useState(0),
|
|
133
133
|
_React$useState12 = (0, _slicedToArray2["default"])(_React$useState11, 2),
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
underlineWidth = _React$useState12[0],
|
|
135
|
+
setUnderlineWidth = _React$useState12[1];
|
|
136
136
|
|
|
137
|
-
var _React$useState13 = React.useState(
|
|
137
|
+
var _React$useState13 = React.useState(0),
|
|
138
138
|
_React$useState14 = (0, _slicedToArray2["default"])(_React$useState13, 2),
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
underlineTranslate = _React$useState14[0],
|
|
140
|
+
setUnderlineTranslate = _React$useState14[1];
|
|
141
141
|
|
|
142
|
-
var _React$useState15 = React.useState('
|
|
142
|
+
var _React$useState15 = React.useState('none'),
|
|
143
143
|
_React$useState16 = (0, _slicedToArray2["default"])(_React$useState15, 2),
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
underlineTransition = _React$useState16[0],
|
|
145
|
+
setUnderlineTransition = _React$useState16[1];
|
|
146
146
|
|
|
147
|
-
var _React$useState17 = React.useState(
|
|
147
|
+
var _React$useState17 = React.useState('auto'),
|
|
148
148
|
_React$useState18 = (0, _slicedToArray2["default"])(_React$useState17, 2),
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
tabListHeight = _React$useState18[0],
|
|
150
|
+
setTabListHeight = _React$useState18[1];
|
|
151
151
|
|
|
152
|
-
var _React$useState19 = React.useState(
|
|
152
|
+
var _React$useState19 = React.useState(false),
|
|
153
|
+
_React$useState20 = (0, _slicedToArray2["default"])(_React$useState19, 2),
|
|
154
|
+
isSticky = _React$useState20[0],
|
|
155
|
+
setSticky = _React$useState20[1];
|
|
156
|
+
|
|
157
|
+
var _React$useState21 = React.useState({
|
|
153
158
|
left: 0,
|
|
154
159
|
right: 0
|
|
155
160
|
}),
|
|
156
|
-
_React$
|
|
157
|
-
stickyOffset = _React$
|
|
158
|
-
setStickyOffset = _React$
|
|
161
|
+
_React$useState22 = (0, _slicedToArray2["default"])(_React$useState21, 2),
|
|
162
|
+
stickyOffset = _React$useState22[0],
|
|
163
|
+
setStickyOffset = _React$useState22[1];
|
|
159
164
|
|
|
160
165
|
var setTabRef = React.useCallback(function (tab) {
|
|
161
166
|
tab && tabsRef.current.push(tab);
|
|
@@ -165,21 +170,15 @@ var Tabs = function Tabs(_ref) {
|
|
|
165
170
|
return;
|
|
166
171
|
}
|
|
167
172
|
|
|
168
|
-
var tabNodeChild = tabsRef.current[currentIndex].firstElementChild;
|
|
169
|
-
|
|
170
|
-
var _ref2 = tabNodeChild || {},
|
|
171
|
-
_ref2$clientWidth = _ref2.clientWidth,
|
|
172
|
-
clientWidth = _ref2$clientWidth === void 0 ? 0 : _ref2$clientWidth;
|
|
173
|
-
|
|
174
173
|
var translate = (0, _toConsumableArray2["default"])(tabsRef.current).splice(0, currentIndex).reduce(function (accWidth, node) {
|
|
175
174
|
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
176
175
|
width = _node$getBoundingClie.width;
|
|
177
176
|
|
|
178
177
|
return accWidth + width;
|
|
179
178
|
}, 0);
|
|
180
|
-
setUnderlineWidth(
|
|
179
|
+
setUnderlineWidth(activeTabWidth);
|
|
181
180
|
setUnderlineTranslate(translate);
|
|
182
|
-
}, [currentIndex]);
|
|
181
|
+
}, [currentIndex, activeTabWidth]);
|
|
183
182
|
var calculateSticky = React.useCallback(function () {
|
|
184
183
|
if (!sticky || !rootRef.current || !tabListRef.current) {
|
|
185
184
|
return;
|
|
@@ -194,11 +193,11 @@ var Tabs = function Tabs(_ref) {
|
|
|
194
193
|
left: left,
|
|
195
194
|
right: documentWidth - right
|
|
196
195
|
});
|
|
197
|
-
}, [
|
|
196
|
+
}, [sticky]);
|
|
198
197
|
var handleTabInnerClick = React.useCallback(function (index) {
|
|
199
198
|
return function () {
|
|
200
199
|
setUnderlineTransition('all');
|
|
201
|
-
onTabClick
|
|
200
|
+
onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(index);
|
|
202
201
|
|
|
203
202
|
if (outerIndex === undefined) {
|
|
204
203
|
setInnerIndex(index);
|
|
@@ -247,7 +246,7 @@ var Tabs = function Tabs(_ref) {
|
|
|
247
246
|
ref: setTabRef
|
|
248
247
|
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs)), renderTabWrapper ? renderTabWrapper(tab) : tab));
|
|
249
248
|
});
|
|
250
|
-
}, [renderTab, children]);
|
|
249
|
+
}, [renderTab, children, activeTabClass, currentIndex, setTabRef, tabClass]);
|
|
251
250
|
var renderPanels = React.useCallback(function () {
|
|
252
251
|
return React.Children.map(children, function (child, i) {
|
|
253
252
|
var panel = child.props.children;
|
|
@@ -263,7 +262,7 @@ var Tabs = function Tabs(_ref) {
|
|
|
263
262
|
})
|
|
264
263
|
}, panel);
|
|
265
264
|
});
|
|
266
|
-
}, [children, currentIndex]);
|
|
265
|
+
}, [children, currentIndex, renderOnlyCurrentPanel]);
|
|
267
266
|
var handleReachBeginning = React.useCallback(function (swiper) {
|
|
268
267
|
setBeginning(swiper.isBeginning);
|
|
269
268
|
}, []);
|
|
@@ -275,15 +274,16 @@ var Tabs = function Tabs(_ref) {
|
|
|
275
274
|
setEnd(swiper.isEnd);
|
|
276
275
|
}, []);
|
|
277
276
|
React.useEffect(function () {
|
|
277
|
+
var rootRefNode = rootRef.current;
|
|
278
278
|
var observer = new IntersectionObserver(function (entries) {
|
|
279
|
-
entries.forEach(function (
|
|
280
|
-
var isIntersecting =
|
|
281
|
-
|
|
282
|
-
top =
|
|
283
|
-
left =
|
|
284
|
-
right =
|
|
285
|
-
|
|
286
|
-
if (!sticky || !
|
|
279
|
+
entries.forEach(function (_ref2) {
|
|
280
|
+
var isIntersecting = _ref2.isIntersecting,
|
|
281
|
+
_ref2$boundingClientR = _ref2.boundingClientRect,
|
|
282
|
+
top = _ref2$boundingClientR.top,
|
|
283
|
+
left = _ref2$boundingClientR.left,
|
|
284
|
+
right = _ref2$boundingClientR.right;
|
|
285
|
+
|
|
286
|
+
if (!sticky || !rootRefNode || !tabListRef.current) {
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
289
|
|
|
@@ -316,22 +316,32 @@ var Tabs = function Tabs(_ref) {
|
|
|
316
316
|
}, {
|
|
317
317
|
threshold: [0, 1]
|
|
318
318
|
});
|
|
319
|
-
|
|
319
|
+
rootRefNode && observer.observe(rootRefNode);
|
|
320
320
|
return function () {
|
|
321
|
-
|
|
321
|
+
rootRefNode && observer.unobserve(rootRefNode);
|
|
322
322
|
};
|
|
323
|
-
}, [calculateSticky]);
|
|
323
|
+
}, [calculateSticky, sticky]);
|
|
324
324
|
React.useEffect(function () {
|
|
325
325
|
var handleResize = (0, _lodash["default"])(function () {
|
|
326
|
-
calculateUnderline();
|
|
327
326
|
calculateSticky();
|
|
328
327
|
}, 300);
|
|
328
|
+
var activeTabNode = tabsRef.current[currentIndex];
|
|
329
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
330
|
+
if (!entries.length || !entries[0]) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
var width = entries[0].contentRect.width;
|
|
335
|
+
setActiveTabWidth(width);
|
|
336
|
+
calculateUnderline();
|
|
337
|
+
});
|
|
329
338
|
calculateUnderline();
|
|
339
|
+
resizeObserver.observe(activeTabNode);
|
|
330
340
|
window.addEventListener('resize', handleResize);
|
|
331
341
|
return function () {
|
|
332
342
|
window.removeEventListener('resize', handleResize);
|
|
333
343
|
};
|
|
334
|
-
}, [calculateUnderline, calculateSticky]);
|
|
344
|
+
}, [calculateUnderline, calculateSticky, currentIndex]);
|
|
335
345
|
React.useEffect(function () {
|
|
336
346
|
if (!swiperInstance) {
|
|
337
347
|
return;
|
|
@@ -62,8 +62,10 @@ export declare type TextFieldProps = {
|
|
|
62
62
|
classes?: {
|
|
63
63
|
input?: string;
|
|
64
64
|
};
|
|
65
|
-
/**
|
|
65
|
+
/** Атрибут элемента input */
|
|
66
66
|
inputMode?: 'numeric' | 'tel' | 'decimal' | 'email' | 'url' | 'search' | 'none';
|
|
67
|
+
/** Атрибут элемента input. Не работает с textarea=true */
|
|
68
|
+
autoComplete?: string;
|
|
67
69
|
/** Переводит компонент в контролируемое состояние */
|
|
68
70
|
isControlled?: boolean;
|
|
69
71
|
/** Обработчик изменения значения */
|