@bytebrand/fe-ui-core 4.2.11 → 4.2.13
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/package.json
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { styled } from '@mui/system';
|
|
2
2
|
import IconSVG from '../IconSVG/IconSVG';
|
|
3
|
+
import { createTheme } from '@mui/material/styles';
|
|
3
4
|
|
|
4
5
|
export const IconSvgWrapper = styled(IconSVG)(props => ({
|
|
5
6
|
fill: props.disabled ? '#4C4E6442' : '#4C4E648A',
|
|
6
7
|
width: '10px',
|
|
7
8
|
height: '10px'
|
|
8
9
|
}));
|
|
10
|
+
|
|
11
|
+
export const TooltipWrapper = styled('div')(props => ({
|
|
12
|
+
// zIndex: props.zindex ? props.zindex : 9996,
|
|
13
|
+
display: 'inline-block'
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
export const Theme = createTheme({
|
|
17
|
+
components: {
|
|
18
|
+
MuiTooltip: {
|
|
19
|
+
styleOverrides: {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
@@ -2,8 +2,10 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
|
3
3
|
import Tooltip, { TooltipProps, tooltipClasses } from '@mui/material/Tooltip';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
-
import { IconSvgWrapper } from './MaterialTooltip.styled';
|
|
6
|
-
import {
|
|
5
|
+
import { IconSvgWrapper, Theme, TooltipWrapper } from './MaterialTooltip.styled';
|
|
6
|
+
import { ThemeProvider } from '@mui/material/styles';
|
|
7
|
+
import ClickAwayListener from '@mui/material/ClickAwayListener';
|
|
8
|
+
import { debounce } from 'lodash'
|
|
7
9
|
|
|
8
10
|
interface IMaterialTooltip {
|
|
9
11
|
text: string;
|
|
@@ -34,27 +36,49 @@ const LightTooltip = styled(({ className, ...props }: TooltipProps) => (
|
|
|
34
36
|
const MaterialTooltip = ({ text, placement, className, disabled, zindex }: IMaterialTooltip) => {
|
|
35
37
|
const [isOpen, setIsOpen] = useState(false);
|
|
36
38
|
|
|
37
|
-
const
|
|
39
|
+
const onHandleMenuOpen = (event: any) => {
|
|
38
40
|
event.persist();
|
|
39
|
-
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
setIsOpen(true);
|
|
40
43
|
};
|
|
41
44
|
|
|
45
|
+
const onHandleMenuClose = () => {
|
|
46
|
+
setIsOpen(false);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const onHandleMenuToggle = debounce((event: any) => {
|
|
50
|
+
setIsOpen(() => !isOpen);
|
|
51
|
+
}, 50)
|
|
52
|
+
|
|
42
53
|
return (
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
<ThemeProvider theme={Theme}>
|
|
55
|
+
<ClickAwayListener touchEvent={'onTouchStart'} onClickAway={onHandleMenuClose}>
|
|
56
|
+
<TooltipWrapper>
|
|
57
|
+
<LightTooltip
|
|
58
|
+
open={isOpen}
|
|
59
|
+
onMouseOver={onHandleMenuOpen}
|
|
60
|
+
onMouseLeave={onHandleMenuClose}
|
|
61
|
+
onClose={onHandleMenuClose}
|
|
62
|
+
onTouchEnd={onHandleMenuToggle}
|
|
63
|
+
placement={placement}
|
|
64
|
+
title={text}
|
|
65
|
+
enterTouchDelay={0}
|
|
66
|
+
leaveTouchDelay={10000}
|
|
67
|
+
disableFocusListener
|
|
68
|
+
disableTouchListener
|
|
69
|
+
className={className}
|
|
70
|
+
zindex={zindex}
|
|
71
|
+
PopperProps={{
|
|
72
|
+
disablePortal: true,
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
<IconButton>
|
|
76
|
+
<IconSvgWrapper name={'infoIcon'} customDimensions disabled={disabled} />
|
|
77
|
+
</IconButton>
|
|
78
|
+
</LightTooltip>
|
|
79
|
+
</TooltipWrapper>
|
|
80
|
+
</ClickAwayListener>
|
|
81
|
+
</ThemeProvider>
|
|
58
82
|
);
|
|
59
83
|
};
|
|
60
84
|
|