@megafon/ui-core 3.0.0-beta.6 → 3.0.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 +51 -67
- package/dist/es/colors/Colors.d.ts +2 -2
- package/dist/es/components/Accordion/Accordion.css +1 -15
- package/dist/es/components/Accordion/Accordion.d.ts +11 -5
- package/dist/es/components/Accordion/Accordion.js +16 -14
- package/dist/es/components/Banner/Banner.css +28 -0
- package/dist/es/components/Banner/Banner.d.ts +12 -0
- package/dist/es/components/Banner/Banner.js +40 -21
- package/dist/es/components/Banner/BannerDot.d.ts +3 -0
- package/dist/es/components/Banner/BannerDot.js +8 -3
- package/dist/es/components/Button/Button.d.ts +8 -2
- package/dist/es/components/Button/Button.js +17 -9
- 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.d.ts +9 -2
- package/dist/es/components/Carousel/Carousel.js +31 -22
- package/dist/es/components/Checkbox/Checkbox.d.ts +8 -2
- package/dist/es/components/Checkbox/Checkbox.js +13 -8
- package/dist/es/components/Collapse/Collapse.d.ts +15 -3
- package/dist/es/components/Collapse/Collapse.js +11 -4
- package/dist/es/components/Counter/Counter.js +3 -3
- package/dist/es/components/Header/Header.d.ts +5 -2
- package/dist/es/components/Header/Header.js +4 -2
- package/dist/es/components/InputLabel/InputLabel.d.ts +3 -0
- package/dist/es/components/InputLabel/InputLabel.js +9 -4
- package/dist/es/components/Link/Link.d.ts +7 -3
- package/dist/es/components/Link/Link.js +26 -10
- package/dist/es/components/Notification/Notification.d.ts +8 -0
- package/dist/es/components/Notification/Notification.js +21 -4
- package/dist/es/components/Pagination/Pagination.d.ts +9 -2
- package/dist/es/components/Pagination/Pagination.js +20 -3
- package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.d.ts +6 -3
- package/dist/es/components/Pagination/components/PaginationButton/PaginationButton.js +12 -7
- package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +5 -2
- package/dist/es/components/Pagination/components/PaginationButtons/PaginationButtons.js +10 -2
- package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +5 -2
- package/dist/es/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +6 -1
- package/dist/es/components/Pagination/helpers.d.ts +1 -1
- package/dist/es/components/Paragraph/Paragraph.css +0 -9
- package/dist/es/components/Paragraph/Paragraph.d.ts +4 -3
- package/dist/es/components/Paragraph/Paragraph.js +9 -7
- package/dist/es/components/Preloader/Preloader.d.ts +4 -0
- package/dist/es/components/Preloader/Preloader.js +10 -5
- package/dist/es/components/RadioButton/RadioButton.d.ts +7 -2
- package/dist/es/components/RadioButton/RadioButton.js +11 -7
- package/dist/es/components/Search/Search.js +4 -3
- package/dist/es/components/Select/Select.css +5 -2
- package/dist/es/components/Select/Select.d.ts +43 -50
- package/dist/es/components/Select/Select.js +374 -461
- package/dist/es/components/Select/reducer/selectReducer.d.ts +34 -0
- package/dist/es/components/Select/reducer/selectReducer.js +123 -0
- package/dist/es/components/Switcher/Switcher.css +19 -15
- package/dist/es/components/Switcher/Switcher.js +1 -1
- package/dist/es/components/Tabs/Tab.d.ts +5 -2
- package/dist/es/components/Tabs/Tab.js +4 -2
- package/dist/es/components/Tabs/Tabs.d.ts +10 -0
- package/dist/es/components/Tabs/Tabs.js +123 -70
- package/dist/es/components/TextField/TextField.d.ts +11 -1
- package/dist/es/components/TextField/TextField.js +36 -20
- package/dist/es/components/TextLink/TextLink.js +6 -1
- package/dist/es/components/Tile/Tile.d.ts +5 -2
- package/dist/es/components/Tile/Tile.js +2 -2
- package/dist/es/components/Tooltip/Tooltip.d.ts +5 -0
- package/dist/es/components/Tooltip/Tooltip.js +27 -19
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +1 -0
- package/dist/lib/colors/Colors.d.ts +2 -2
- package/dist/lib/components/Accordion/Accordion.css +1 -15
- package/dist/lib/components/Accordion/Accordion.d.ts +11 -5
- package/dist/lib/components/Accordion/Accordion.js +16 -14
- package/dist/lib/components/Banner/Banner.css +28 -0
- package/dist/lib/components/Banner/Banner.d.ts +12 -0
- package/dist/lib/components/Banner/Banner.js +40 -20
- package/dist/lib/components/Banner/BannerDot.d.ts +3 -0
- package/dist/lib/components/Banner/BannerDot.js +10 -2
- package/dist/lib/components/Button/Button.d.ts +8 -2
- package/dist/lib/components/Button/Button.js +17 -9
- 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.d.ts +9 -2
- package/dist/lib/components/Carousel/Carousel.js +29 -20
- package/dist/lib/components/Checkbox/Checkbox.d.ts +8 -2
- package/dist/lib/components/Checkbox/Checkbox.js +13 -8
- package/dist/lib/components/Collapse/Collapse.d.ts +15 -3
- package/dist/lib/components/Collapse/Collapse.js +13 -4
- package/dist/lib/components/Counter/Counter.js +3 -3
- package/dist/lib/components/Header/Header.d.ts +5 -2
- package/dist/lib/components/Header/Header.js +4 -2
- package/dist/lib/components/InputLabel/InputLabel.d.ts +3 -0
- package/dist/lib/components/InputLabel/InputLabel.js +11 -3
- package/dist/lib/components/Link/Link.d.ts +7 -3
- package/dist/lib/components/Link/Link.js +37 -23
- package/dist/lib/components/Notification/Notification.d.ts +8 -0
- package/dist/lib/components/Notification/Notification.js +20 -3
- package/dist/lib/components/Pagination/Pagination.d.ts +9 -2
- package/dist/lib/components/Pagination/Pagination.js +20 -2
- package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.d.ts +6 -3
- package/dist/lib/components/Pagination/components/PaginationButton/PaginationButton.js +12 -6
- package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.d.ts +5 -2
- package/dist/lib/components/Pagination/components/PaginationButtons/PaginationButtons.js +9 -1
- package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.d.ts +5 -2
- package/dist/lib/components/Pagination/components/PaginationNavigation/PaginationNavigation.js +6 -1
- package/dist/lib/components/Pagination/helpers.d.ts +1 -1
- package/dist/lib/components/Paragraph/Paragraph.css +0 -9
- package/dist/lib/components/Paragraph/Paragraph.d.ts +4 -3
- package/dist/lib/components/Paragraph/Paragraph.js +11 -6
- package/dist/lib/components/Preloader/Preloader.d.ts +4 -0
- package/dist/lib/components/Preloader/Preloader.js +10 -4
- package/dist/lib/components/RadioButton/RadioButton.d.ts +7 -2
- package/dist/lib/components/RadioButton/RadioButton.js +11 -7
- package/dist/lib/components/Search/Search.js +4 -3
- package/dist/lib/components/Select/Select.css +5 -2
- package/dist/lib/components/Select/Select.d.ts +43 -50
- package/dist/lib/components/Select/Select.js +368 -484
- package/dist/lib/components/Select/reducer/selectReducer.d.ts +34 -0
- package/dist/lib/components/Select/reducer/selectReducer.js +136 -0
- package/dist/lib/components/Switcher/Switcher.css +19 -15
- package/dist/lib/components/Switcher/Switcher.js +1 -1
- package/dist/lib/components/Tabs/Tab.d.ts +5 -2
- package/dist/lib/components/Tabs/Tab.js +4 -2
- package/dist/lib/components/Tabs/Tabs.d.ts +10 -0
- package/dist/lib/components/Tabs/Tabs.js +123 -70
- package/dist/lib/components/TextField/TextField.d.ts +11 -1
- package/dist/lib/components/TextField/TextField.js +34 -19
- package/dist/lib/components/TextLink/TextLink.js +6 -1
- package/dist/lib/components/Tile/Tile.d.ts +5 -2
- package/dist/lib/components/Tile/Tile.js +2 -2
- package/dist/lib/components/Tooltip/Tooltip.d.ts +5 -0
- package/dist/lib/components/Tooltip/Tooltip.js +26 -18
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +8 -0
- package/package.json +4 -4
|
@@ -121,9 +121,11 @@ var TextField = function TextField(_ref) {
|
|
|
121
121
|
noticeText = _ref.noticeText,
|
|
122
122
|
inputRef = _ref.inputRef,
|
|
123
123
|
inputMode = _ref.inputMode,
|
|
124
|
+
autoComplete = _ref.autoComplete,
|
|
124
125
|
_ref$classes = _ref.classes;
|
|
125
126
|
_ref$classes = _ref$classes === void 0 ? {} : _ref$classes;
|
|
126
|
-
var input = _ref$classes.input
|
|
127
|
+
var input = _ref$classes.input,
|
|
128
|
+
dataAttrs = _ref.dataAttrs;
|
|
127
129
|
|
|
128
130
|
var _useState = (0, React.useState)(true),
|
|
129
131
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -174,7 +176,7 @@ var TextField = function TextField(_ref) {
|
|
|
174
176
|
(0, React.useEffect)(function () {
|
|
175
177
|
!isControlled && setInputValue(value);
|
|
176
178
|
checkSymbolMaxLimit(value);
|
|
177
|
-
}, [value, checkSymbolMaxLimit]);
|
|
179
|
+
}, [value, checkSymbolMaxLimit, isControlled]);
|
|
178
180
|
(0, React.useEffect)(function () {
|
|
179
181
|
setTouch((0, _uiHelpers.detectTouch)());
|
|
180
182
|
}, []);
|
|
@@ -182,7 +184,7 @@ var TextField = function TextField(_ref) {
|
|
|
182
184
|
return setPasswordHidden(function (prevPassState) {
|
|
183
185
|
return !prevPassState;
|
|
184
186
|
});
|
|
185
|
-
}, [
|
|
187
|
+
}, []);
|
|
186
188
|
|
|
187
189
|
var setTextareaHeight = function setTextareaHeight() {
|
|
188
190
|
if (!(fieldNode === null || fieldNode === void 0 ? void 0 : fieldNode.current)) {
|
|
@@ -205,7 +207,7 @@ var TextField = function TextField(_ref) {
|
|
|
205
207
|
|
|
206
208
|
!isControlled && setInputValue(e.target.value);
|
|
207
209
|
checkSymbolMaxLimit(e.target.value);
|
|
208
|
-
onChange
|
|
210
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
209
211
|
};
|
|
210
212
|
|
|
211
213
|
var handleTextareaClick = function handleTextareaClick() {
|
|
@@ -222,25 +224,25 @@ var TextField = function TextField(_ref) {
|
|
|
222
224
|
var isClearFuncAvailable = !customIcon && !onCustomIconClick && verification === ERROR;
|
|
223
225
|
var field = fieldNode.current;
|
|
224
226
|
isPasswordType && togglePasswordHiding();
|
|
225
|
-
onCustomIconClick
|
|
227
|
+
onCustomIconClick === null || onCustomIconClick === void 0 ? void 0 : onCustomIconClick(e);
|
|
226
228
|
|
|
227
229
|
if (!isControlled && isClearFuncAvailable) {
|
|
228
230
|
setInputValue('');
|
|
229
|
-
field
|
|
231
|
+
field === null || field === void 0 ? void 0 : field.focus();
|
|
230
232
|
}
|
|
231
|
-
}, [isPasswordType, togglePasswordHiding, onCustomIconClick, verification,
|
|
233
|
+
}, [isPasswordType, togglePasswordHiding, onCustomIconClick, verification, customIcon, isControlled]);
|
|
232
234
|
var handleFocus = (0, React.useCallback)(function (e) {
|
|
233
|
-
onFocus
|
|
235
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
234
236
|
}, [onFocus]);
|
|
235
237
|
var handleBlur = (0, React.useCallback)(function (e) {
|
|
236
|
-
onBlur
|
|
238
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
237
239
|
}, [onBlur]);
|
|
238
240
|
var handleBeforeMaskChange = (0, React.useCallback)(function (newState, oldState, inputedValue) {
|
|
239
241
|
return onBeforeMaskChange && onBeforeMaskChange(inputedValue, newState, oldState);
|
|
240
242
|
}, [onBeforeMaskChange]);
|
|
241
243
|
var textareaType = textarea === TextareaTypes.FLEXIBLE ? TextareaTypes.FLEXIBLE : TextareaTypes.FIXED;
|
|
242
244
|
var hasScrolling = initialTextareaHeight >= TEXTAREA_MAX_HEIGHT || isTextareaResized;
|
|
243
|
-
var commonParams = {
|
|
245
|
+
var commonParams = (0, _extends2["default"])((0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input)), {
|
|
244
246
|
disabled: disabled,
|
|
245
247
|
id: id,
|
|
246
248
|
name: name,
|
|
@@ -253,10 +255,11 @@ var TextField = function TextField(_ref) {
|
|
|
253
255
|
placeholder: placeholder,
|
|
254
256
|
required: required,
|
|
255
257
|
inputMode: inputMode
|
|
256
|
-
};
|
|
258
|
+
});
|
|
257
259
|
var inputParams = (0, _extends2["default"])((0, _extends2["default"])({}, commonParams), {
|
|
258
260
|
className: cn('field', input),
|
|
259
|
-
type: isVisiblePassword ? 'text' : type
|
|
261
|
+
type: isVisiblePassword ? 'text' : type,
|
|
262
|
+
autoComplete: autoComplete
|
|
260
263
|
});
|
|
261
264
|
var inputMaskParams = {
|
|
262
265
|
mask: mask,
|
|
@@ -276,7 +279,7 @@ var TextField = function TextField(_ref) {
|
|
|
276
279
|
}
|
|
277
280
|
|
|
278
281
|
fieldNode.current = node;
|
|
279
|
-
inputRef
|
|
282
|
+
inputRef === null || inputRef === void 0 ? void 0 : inputRef(node);
|
|
280
283
|
};
|
|
281
284
|
|
|
282
285
|
var getIcon = function getIcon() {
|
|
@@ -321,14 +324,14 @@ var TextField = function TextField(_ref) {
|
|
|
321
324
|
|
|
322
325
|
var renderIconBlock = function renderIconBlock() {
|
|
323
326
|
var icon = getIcon();
|
|
324
|
-
return icon && /*#__PURE__*/React.createElement("div", {
|
|
327
|
+
return icon && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.iconBox), {
|
|
325
328
|
className: cn('icon-box', {
|
|
326
329
|
error: verification === Verification.ERROR && !customIcon,
|
|
327
330
|
password: isPasswordType,
|
|
328
331
|
'custom-handler': !!onCustomIconClick
|
|
329
332
|
}),
|
|
330
333
|
onClick: handleIconClick
|
|
331
|
-
}, icon);
|
|
334
|
+
}), icon);
|
|
332
335
|
};
|
|
333
336
|
|
|
334
337
|
var renderInput = function renderInput() {
|
|
@@ -350,7 +353,7 @@ var TextField = function TextField(_ref) {
|
|
|
350
353
|
var isPlaceholderShowed = isPasswordType && isPasswordHidden && !!inputValue;
|
|
351
354
|
var valueHasSymbols = inputValue !== null && inputValue !== undefined;
|
|
352
355
|
var currentSymbolCount = valueHasSymbols && String(inputValue).length || 0;
|
|
353
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
356
|
+
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
354
357
|
className: cn({
|
|
355
358
|
disabled: disabled,
|
|
356
359
|
theme: theme,
|
|
@@ -359,7 +362,10 @@ var TextField = function TextField(_ref) {
|
|
|
359
362
|
icon: !hideIcon && (!!verification || !!customIcon || type === 'password') && !textarea,
|
|
360
363
|
password: isPlaceholderShowed
|
|
361
364
|
}, className)
|
|
362
|
-
}, label && /*#__PURE__*/React.createElement(_InputLabel["default"], {
|
|
365
|
+
}), label && /*#__PURE__*/React.createElement(_InputLabel["default"], {
|
|
366
|
+
dataAttrs: {
|
|
367
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.label
|
|
368
|
+
},
|
|
363
369
|
htmlFor: id
|
|
364
370
|
}, label, required && /*#__PURE__*/React.createElement("span", {
|
|
365
371
|
className: cn('require-mark')
|
|
@@ -369,12 +375,12 @@ var TextField = function TextField(_ref) {
|
|
|
369
375
|
})
|
|
370
376
|
}, renderField()), /*#__PURE__*/React.createElement("div", {
|
|
371
377
|
className: cn('wrap')
|
|
372
|
-
}, noticeText && /*#__PURE__*/React.createElement("div", {
|
|
378
|
+
}, noticeText && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice), {
|
|
373
379
|
className: cn('text', {
|
|
374
380
|
error: verification === Verification.ERROR,
|
|
375
381
|
success: verification === Verification.VALID
|
|
376
382
|
})
|
|
377
|
-
}, noticeText), symbolCounter && /*#__PURE__*/React.createElement(_Paragraph["default"], {
|
|
383
|
+
}), noticeText), symbolCounter && /*#__PURE__*/React.createElement(_Paragraph["default"], {
|
|
378
384
|
size: "small",
|
|
379
385
|
hasMargin: false,
|
|
380
386
|
className: cn('counter', {
|
|
@@ -392,6 +398,8 @@ TextField.propTypes = {
|
|
|
392
398
|
disabled: PropTypes.bool,
|
|
393
399
|
required: PropTypes.bool,
|
|
394
400
|
type: PropTypes.oneOf(['text', 'password', 'tel', 'email']),
|
|
401
|
+
inputMode: PropTypes.oneOf(['numeric', 'tel', 'decimal', 'email', 'url', 'search', 'none']),
|
|
402
|
+
autoComplete: PropTypes.string,
|
|
395
403
|
name: PropTypes.string,
|
|
396
404
|
placeholder: PropTypes.string,
|
|
397
405
|
id: PropTypes.string,
|
|
@@ -413,6 +421,13 @@ TextField.propTypes = {
|
|
|
413
421
|
inputRef: PropTypes.func,
|
|
414
422
|
classes: PropTypes.shape({
|
|
415
423
|
input: PropTypes.string
|
|
424
|
+
}),
|
|
425
|
+
dataAttrs: PropTypes.shape({
|
|
426
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
427
|
+
label: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
428
|
+
notice: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
429
|
+
input: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
430
|
+
iconBox: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
416
431
|
})
|
|
417
432
|
};
|
|
418
433
|
var _default = TextField;
|
|
@@ -33,8 +33,10 @@ var TextLink = function TextLink(_ref) {
|
|
|
33
33
|
rel = _ref.rel,
|
|
34
34
|
onClick = _ref.onClick,
|
|
35
35
|
children = _ref.children,
|
|
36
|
-
download = _ref.download
|
|
36
|
+
download = _ref.download,
|
|
37
|
+
dataAttrs = _ref.dataAttrs;
|
|
37
38
|
return /*#__PURE__*/React.createElement(_Link["default"], {
|
|
39
|
+
dataAttrs: dataAttrs,
|
|
38
40
|
target: target,
|
|
39
41
|
href: href,
|
|
40
42
|
rel: rel,
|
|
@@ -52,6 +54,9 @@ TextLink.propTypes = {
|
|
|
52
54
|
color: PropTypes.oneOf(['default', 'white', 'black', 'gray', 'green', 'blue', 'inherit']),
|
|
53
55
|
underlineVisibility: PropTypes.oneOf(['hover', 'always']),
|
|
54
56
|
underlineStyle: PropTypes.oneOf(['solid', 'dashed', 'border', 'none']),
|
|
57
|
+
dataAttrs: PropTypes.shape({
|
|
58
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
59
|
+
}),
|
|
55
60
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.string, PropTypes.node])
|
|
56
61
|
};
|
|
57
62
|
TextLink.defaultProps = {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { IFilterDataAttrs } from '@megafon/ui-helpers';
|
|
3
2
|
import './Tile.less';
|
|
4
3
|
export declare const Theme: {
|
|
5
4
|
readonly LIGHT: "light";
|
|
@@ -18,7 +17,7 @@ export declare const Shadow: {
|
|
|
18
17
|
readonly HOVER: "hover";
|
|
19
18
|
};
|
|
20
19
|
declare type ShadowType = typeof Shadow[keyof typeof Shadow];
|
|
21
|
-
export interface ITileProps
|
|
20
|
+
export interface ITileProps {
|
|
22
21
|
/** Ссылка */
|
|
23
22
|
href?: string;
|
|
24
23
|
/** Тема */
|
|
@@ -31,6 +30,10 @@ export interface ITileProps extends IFilterDataAttrs {
|
|
|
31
30
|
isInteractive?: boolean;
|
|
32
31
|
/** Дополнительный класс корневого элемента */
|
|
33
32
|
className?: string;
|
|
33
|
+
/** Дополнительные data атрибуты к внутренним элементам */
|
|
34
|
+
dataAttrs?: {
|
|
35
|
+
root?: Record<string, string>;
|
|
36
|
+
};
|
|
34
37
|
/** Обработчик клика */
|
|
35
38
|
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
36
39
|
}
|
|
@@ -52,7 +52,7 @@ var Tile = function Tile(_ref) {
|
|
|
52
52
|
dataAttrs = _ref.dataAttrs;
|
|
53
53
|
|
|
54
54
|
var handleClick = function handleClick(e) {
|
|
55
|
-
onClick
|
|
55
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
var isPointer = !!href || isInteractive;
|
|
@@ -65,7 +65,7 @@ var Tile = function Tile(_ref) {
|
|
|
65
65
|
interactive: isInteractive
|
|
66
66
|
}, className),
|
|
67
67
|
onClick: handleClick
|
|
68
|
-
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs)), href && /*#__PURE__*/_react["default"].createElement("a", {
|
|
68
|
+
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), href && /*#__PURE__*/_react["default"].createElement("a", {
|
|
69
69
|
href: href,
|
|
70
70
|
className: cn('link')
|
|
71
71
|
}, children), !href && children);
|
|
@@ -46,6 +46,11 @@ export interface ITooltipProps {
|
|
|
46
46
|
content?: string;
|
|
47
47
|
contentShadow?: string;
|
|
48
48
|
};
|
|
49
|
+
/** Дополнительные data атрибуты к внутренним элементам */
|
|
50
|
+
dataAttrs?: {
|
|
51
|
+
root?: Record<string, string>;
|
|
52
|
+
content?: Record<string, string>;
|
|
53
|
+
};
|
|
49
54
|
/** Обработчик на открытие */
|
|
50
55
|
onOpen?: (e: AccessibilityEventTypeNative) => void;
|
|
51
56
|
/** Обработчик на закрытие */
|
|
@@ -79,6 +79,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
79
79
|
arrowClassName = _ref$classes.arrow,
|
|
80
80
|
contentClassName = _ref$classes.content,
|
|
81
81
|
contentShadowClassName = _ref$classes.contentShadow,
|
|
82
|
+
dataAttrs = _ref.dataAttrs,
|
|
82
83
|
onOpen = _ref.onOpen,
|
|
83
84
|
onClose = _ref.onClose;
|
|
84
85
|
var currentTrigger = triggerElement.current;
|
|
@@ -102,7 +103,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
102
103
|
|
|
103
104
|
(0, _react.useEffect)(function () {
|
|
104
105
|
return setIsOpen(isOpened);
|
|
105
|
-
}, [isOpened
|
|
106
|
+
}, [isOpened]);
|
|
106
107
|
var options = (0, _react.useMemo)(function () {
|
|
107
108
|
return {
|
|
108
109
|
placement: placement,
|
|
@@ -130,7 +131,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
130
131
|
}
|
|
131
132
|
}]
|
|
132
133
|
};
|
|
133
|
-
}, [placement, arrowElement, currentBoundary, isOpen]);
|
|
134
|
+
}, [placement, arrowElement, currentBoundary, isOpen, fallbackPlacements]);
|
|
134
135
|
|
|
135
136
|
var _usePopper = (0, _reactPopper.usePopper)(currentTarget, popperElement, options),
|
|
136
137
|
styles = _usePopper.styles,
|
|
@@ -138,7 +139,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
138
139
|
update = _usePopper.update;
|
|
139
140
|
|
|
140
141
|
(0, _react.useEffect)(function () {
|
|
141
|
-
update
|
|
142
|
+
update === null || update === void 0 ? void 0 : update();
|
|
142
143
|
}, [children, update]);
|
|
143
144
|
|
|
144
145
|
var _useState7 = (0, _react.useState)(false),
|
|
@@ -148,7 +149,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
148
149
|
|
|
149
150
|
(0, _react.useEffect)(function () {
|
|
150
151
|
return setIsTouchDevice((0, _uiHelpers.detectTouch)());
|
|
151
|
-
}, [
|
|
152
|
+
}, []);
|
|
152
153
|
var clickEvent = (0, _react.useMemo)(function () {
|
|
153
154
|
return isTouchDevice ? TOUCH_KEY : MOUSE_KEY;
|
|
154
155
|
}, [isTouchDevice]);
|
|
@@ -158,9 +159,9 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
158
159
|
var handleMouseEnter = (0, _react.useCallback)(function (e) {
|
|
159
160
|
if (!isOpen) {
|
|
160
161
|
setIsOpen(true);
|
|
161
|
-
onOpen
|
|
162
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen(e);
|
|
162
163
|
}
|
|
163
|
-
}, [isOpen, onOpen
|
|
164
|
+
}, [isOpen, onOpen]);
|
|
164
165
|
var handleClick = (0, _react.useCallback)(function (e) {
|
|
165
166
|
if (!(0, _uiHelpers.checkNativeEventIsClickOrEnterPress)(e)) {
|
|
166
167
|
return;
|
|
@@ -171,24 +172,24 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
171
172
|
});
|
|
172
173
|
|
|
173
174
|
if (!isOpen) {
|
|
174
|
-
onOpen
|
|
175
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen(e);
|
|
175
176
|
} else {
|
|
176
|
-
onClose
|
|
177
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(e);
|
|
177
178
|
}
|
|
178
|
-
}, [isOpen, onOpen, onClose
|
|
179
|
+
}, [isOpen, onOpen, onClose]);
|
|
179
180
|
var handleOutsideEvent = (0, _react.useCallback)(function (e) {
|
|
180
181
|
var isTargetInPopper = e.target instanceof Element && popperElement && popperElement.contains(e.target);
|
|
181
182
|
var isTargetInTrigger = e.target instanceof Element && currentTrigger && currentTrigger.contains(e.target);
|
|
182
183
|
|
|
183
184
|
if (!isTargetInPopper && !isTargetInTrigger) {
|
|
184
185
|
setIsOpen(false);
|
|
185
|
-
onClose
|
|
186
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(e);
|
|
186
187
|
}
|
|
187
|
-
}, [onClose, currentTrigger, popperElement
|
|
188
|
+
}, [onClose, currentTrigger, popperElement]);
|
|
188
189
|
var handleBlurEvent = (0, _react.useCallback)(function (e) {
|
|
189
190
|
setIsOpen(false);
|
|
190
|
-
onClose
|
|
191
|
-
}, [onClose
|
|
191
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(e);
|
|
192
|
+
}, [onClose]);
|
|
192
193
|
(0, _react.useEffect)(function () {
|
|
193
194
|
if (triggerEventName === TriggerEvent.HOVER) {
|
|
194
195
|
if (currentTrigger) {
|
|
@@ -198,10 +199,10 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
198
199
|
|
|
199
200
|
if (isOpen) {
|
|
200
201
|
document.addEventListener('mouseover', handleOutsideEvent);
|
|
201
|
-
currentTrigger
|
|
202
|
+
currentTrigger === null || currentTrigger === void 0 ? void 0 : currentTrigger.addEventListener('blur', handleBlurEvent);
|
|
202
203
|
} else {
|
|
203
204
|
document.removeEventListener('mouseover', handleOutsideEvent);
|
|
204
|
-
currentTrigger
|
|
205
|
+
currentTrigger === null || currentTrigger === void 0 ? void 0 : currentTrigger.removeEventListener('blur', handleBlurEvent);
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
return function () {
|
|
@@ -215,7 +216,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
return undefined;
|
|
218
|
-
}, [triggerEventName, isOpen, currentTrigger, handleOutsideEvent, handleMouseEnter]);
|
|
219
|
+
}, [triggerEventName, isOpen, currentTrigger, handleOutsideEvent, handleMouseEnter, handleBlurEvent]);
|
|
219
220
|
(0, _react.useEffect)(function () {
|
|
220
221
|
if (triggerEventName === TriggerEvent.CLICK) {
|
|
221
222
|
if (currentTrigger) {
|
|
@@ -240,8 +241,8 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
240
241
|
}
|
|
241
242
|
|
|
242
243
|
return undefined;
|
|
243
|
-
}, [triggerEventName, isOpen, currentTrigger, handleOutsideEvent, handleClick]);
|
|
244
|
-
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
244
|
+
}, [triggerEventName, isOpen, currentTrigger, handleOutsideEvent, handleClick, clickEvent]);
|
|
245
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
245
246
|
className: cn({
|
|
246
247
|
paddings: paddings,
|
|
247
248
|
open: isOpen
|
|
@@ -256,6 +257,9 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
256
257
|
className: cn('arrow-shadow'),
|
|
257
258
|
style: styles.arrow
|
|
258
259
|
}), /*#__PURE__*/_react["default"].createElement(_Tile["default"], {
|
|
260
|
+
dataAttrs: {
|
|
261
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.content
|
|
262
|
+
},
|
|
259
263
|
className: cn('content', [contentClassName])
|
|
260
264
|
}, children), /*#__PURE__*/_react["default"].createElement(_Tile["default"], {
|
|
261
265
|
shadowLevel: "high",
|
|
@@ -298,6 +302,10 @@ Tooltip.propTypes = {
|
|
|
298
302
|
content: _propTypes["default"].string,
|
|
299
303
|
contentShadow: _propTypes["default"].string
|
|
300
304
|
}),
|
|
305
|
+
dataAttrs: _propTypes["default"].shape({
|
|
306
|
+
root: _propTypes["default"].objectOf(_propTypes["default"].string.isRequired),
|
|
307
|
+
content: _propTypes["default"].objectOf(_propTypes["default"].string.isRequired)
|
|
308
|
+
}),
|
|
301
309
|
onOpen: _propTypes["default"].func,
|
|
302
310
|
onClose: _propTypes["default"].func
|
|
303
311
|
};
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export { default as Preloader } from './components/Preloader/Preloader';
|
|
|
31
31
|
export { default as RadioButton } from './components/RadioButton/RadioButton';
|
|
32
32
|
export { default as Search } from './components/Search/Search';
|
|
33
33
|
export { default as Select } from './components/Select/Select';
|
|
34
|
+
export { default as selectReducer } from './components/Select/reducer/selectReducer';
|
|
34
35
|
export { default as Switcher } from './components/Switcher/Switcher';
|
|
35
36
|
export { default as Tab } from './components/Tabs/Tab';
|
|
36
37
|
export { default as Tabs } from './components/Tabs/Tabs';
|
package/dist/lib/index.js
CHANGED
|
@@ -201,6 +201,12 @@ Object.defineProperty(exports, "Select", {
|
|
|
201
201
|
return _Select["default"];
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
|
+
Object.defineProperty(exports, "selectReducer", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function get() {
|
|
207
|
+
return _selectReducer["default"];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
204
210
|
Object.defineProperty(exports, "Switcher", {
|
|
205
211
|
enumerable: true,
|
|
206
212
|
get: function get() {
|
|
@@ -316,6 +322,8 @@ var _Search = _interopRequireDefault(require("./components/Search/Search"));
|
|
|
316
322
|
|
|
317
323
|
var _Select = _interopRequireDefault(require("./components/Select/Select"));
|
|
318
324
|
|
|
325
|
+
var _selectReducer = _interopRequireDefault(require("./components/Select/reducer/selectReducer"));
|
|
326
|
+
|
|
319
327
|
var _Switcher = _interopRequireDefault(require("./components/Switcher/Switcher"));
|
|
320
328
|
|
|
321
329
|
var _Tab = _interopRequireDefault(require("./components/Tabs/Tab"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@megafon/ui-core",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"styles"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@babel/preset-env": "^7.8.6",
|
|
55
55
|
"@babel/preset-react": "^7.8.3",
|
|
56
56
|
"@babel/preset-typescript": "^7.8.3",
|
|
57
|
-
"@megafon/ui-icons": "^1.0.0
|
|
57
|
+
"@megafon/ui-icons": "^1.0.0",
|
|
58
58
|
"@svgr/core": "^2.4.1",
|
|
59
59
|
"@testing-library/react-hooks": "^7.0.1",
|
|
60
60
|
"@types/enzyme": "^3.10.5",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@babel/runtime": "^7.8.4",
|
|
88
88
|
"@datepicker-react/hooks": "^2.7.0",
|
|
89
|
-
"@megafon/ui-helpers": "^2.0.0
|
|
89
|
+
"@megafon/ui-helpers": "^2.0.0",
|
|
90
90
|
"@popperjs/core": "^2.5.3",
|
|
91
91
|
"core-js": "^3.6.4",
|
|
92
92
|
"date-fns": "^2.16.1",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"react-popper": "^2.2.3",
|
|
98
98
|
"swiper": "^6.5.6"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "6c0ceaf24ab250ae0d733395974991f0b58572b6"
|
|
101
101
|
}
|