@lunit/oui 2.2.20 → 2.2.22
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/dist/components/EllipsisTypography/EllipsisTypography.js +18 -46
- package/dist/components/Toggle/Toggle.styled.js +1 -1
- package/dist/presentations/AnalysisBar/AnalysisBar.styled.js +3 -1
- package/dist/presentations/Histogram/HistogramTabs.js +2 -6
- package/dist/presentations/ToggleControl/ToggleControl.js +2 -1
- package/package.json +1 -1
|
@@ -10,52 +10,24 @@ function EllipsisTypography({ children, heightThreshold: heightThresholdProp, to
|
|
|
10
10
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
11
11
|
const { addResizeHandler, removeResizeHandler } = useContext(ResizeObserverContext);
|
|
12
12
|
useEffect(() => {
|
|
13
|
-
if (typographyRef.current)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
showTooltip) {
|
|
23
|
-
setShowTooltip(false);
|
|
24
|
-
}
|
|
25
|
-
break;
|
|
26
|
-
case 'column':
|
|
27
|
-
default:
|
|
28
|
-
if (target.scrollHeight - target.clientHeight > heightThreshold && !showTooltip) {
|
|
29
|
-
setShowTooltip(true);
|
|
30
|
-
}
|
|
31
|
-
else if (target.scrollHeight - target.clientHeight <= heightThreshold &&
|
|
32
|
-
showTooltip) {
|
|
33
|
-
setShowTooltip(false);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
if (addResizeHandler) {
|
|
38
|
-
console.log(addResizeHandler);
|
|
39
|
-
addResizeHandler(target, resizeHandler);
|
|
40
|
-
}
|
|
41
|
-
return () => {
|
|
42
|
-
if (removeResizeHandler)
|
|
43
|
-
removeResizeHandler(target);
|
|
44
|
-
};
|
|
13
|
+
if (!typographyRef.current)
|
|
14
|
+
return;
|
|
15
|
+
const target = typographyRef.current;
|
|
16
|
+
const checkOverflow = () => {
|
|
17
|
+
const isOverflowing = target.scrollHeight - target.clientHeight > heightThreshold;
|
|
18
|
+
setShowTooltip(isOverflowing);
|
|
19
|
+
};
|
|
20
|
+
if (addResizeHandler) {
|
|
21
|
+
addResizeHandler(target, checkOverflow);
|
|
45
22
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.log(showTooltip);
|
|
56
|
-
if (showTooltip) {
|
|
57
|
-
return (_jsx(Tooltip, { title: children, placement: tooltipPlacement, size: "small", children: _jsx(StyledTypography, { ...otherProps, ref: typographyRef, direction: direction, maxLines: maxLines, children: children }) }));
|
|
58
|
-
}
|
|
59
|
-
return (_jsx(StyledTypography, { ...otherProps, ref: typographyRef, direction: direction, maxLines: maxLines, children: children }));
|
|
23
|
+
checkOverflow();
|
|
24
|
+
return () => {
|
|
25
|
+
if (removeResizeHandler) {
|
|
26
|
+
removeResizeHandler(target);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}, [heightThreshold, addResizeHandler, removeResizeHandler]);
|
|
30
|
+
const TypographyComponent = (_jsx(StyledTypography, { ...otherProps, ref: typographyRef, direction: direction, maxLines: maxLines, children: children }));
|
|
31
|
+
return showTooltip ? (_jsx(Tooltip, { title: children, placement: tooltipPlacement, size: "small", children: TypographyComponent })) : (TypographyComponent);
|
|
60
32
|
}
|
|
61
33
|
export default EllipsisTypography;
|
|
@@ -47,7 +47,7 @@ export const StyledToggle = styled(Switch, {
|
|
|
47
47
|
},
|
|
48
48
|
'& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track': {
|
|
49
49
|
opacity: 1,
|
|
50
|
-
backgroundColor: toggleColor || theme.palette.lunitTeal[
|
|
50
|
+
backgroundColor: toggleColor || theme.palette.lunitTeal[40],
|
|
51
51
|
},
|
|
52
52
|
'& .MuiSwitch-switchBase.Mui-disabled + .MuiSwitch-track': {
|
|
53
53
|
opacity: 1,
|
|
@@ -99,7 +99,9 @@ const segmentStyle = (color, width, square) => {
|
|
|
99
99
|
export const GraphSegment = styled('span', {
|
|
100
100
|
shouldForwardProp: (prop) => !['color', 'width', 'square'].includes(prop.toString()),
|
|
101
101
|
})(({ color, width, square }) => {
|
|
102
|
+
// cover undefined and empty string
|
|
103
|
+
const barColor = color && color.length ? color : 'red';
|
|
102
104
|
return {
|
|
103
|
-
...segmentStyle(
|
|
105
|
+
...segmentStyle(barColor, width, square ?? false), // fallback color
|
|
104
106
|
};
|
|
105
107
|
});
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Typography } from '@mui/material';
|
|
3
2
|
import { calculateFontSize, doBorderRadius } from './Histogram.utils';
|
|
4
3
|
import { HistogramTabsContainer, TabButton } from './Histogram.styled';
|
|
4
|
+
import { EllipsisTypography } from '../../components';
|
|
5
5
|
const HistogramTabs = ({ options, active, onChange }) => {
|
|
6
6
|
return (_jsx(HistogramTabsContainer, { children: options.map((tabLabel, idx) => {
|
|
7
7
|
const fontSize = calculateFontSize(tabLabel);
|
|
8
8
|
return (_jsx(TabButton, { disableRipple: true, active: idx === active, onClick: () => onChange(idx), sx: {
|
|
9
9
|
padding: '4px 6px',
|
|
10
10
|
borderRadius: doBorderRadius(idx, options.length),
|
|
11
|
-
}, children: _jsx(
|
|
11
|
+
}, children: _jsx(EllipsisTypography, { variant: "body_sb1", sx: {
|
|
12
12
|
fontSize: `${fontSize}px`,
|
|
13
|
-
whiteSpace: 'nowrap',
|
|
14
|
-
overflow: 'hidden',
|
|
15
|
-
textOverflow: 'ellipsis',
|
|
16
|
-
width: '100%',
|
|
17
13
|
}, children: tabLabel }) }, tabLabel));
|
|
18
14
|
}) }));
|
|
19
15
|
};
|
|
@@ -9,6 +9,7 @@ import { FreeText } from '../FreeText';
|
|
|
9
9
|
import { Statistic } from '../Statistic';
|
|
10
10
|
import { Tooltip } from '../../components';
|
|
11
11
|
import { Information } from '../../icons';
|
|
12
|
+
import theme from '../../theme';
|
|
12
13
|
const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbol, tooltip = [], content = [], color, isParent = false, disabled = false, bar, checked, isDimmed = false, onChange, }) => {
|
|
13
14
|
if (!componentType)
|
|
14
15
|
throw new Error("The 'componentType' prop is required.");
|
|
@@ -19,6 +20,6 @@ const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbo
|
|
|
19
20
|
return (_jsxs(ToggleControlOuter, { "data-toggle-name": `toggle-control-${title?.replace(/\s/g, '-')}`, hasBar: !!bar || !!content.length, style: { marginBottom: isParent ? '4px' : '0' }, children: [_jsxs(ToggleControlContainer, { className: "toggle-inner-container", size: size, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: '6px' }, className: "toggle-label", children: [!!tooltip.length && (_jsx(Tooltip, { arrow: true, size: "large", title: _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: tooltip.map((item) => (_jsxs(Box, { children: [item.componentType === 'freeText' && (_jsx(FreeText, { componentType: item.componentType, size: item.size, content: item.content })), item.componentType === 'statistic' && (_jsx(Statistic, { componentType: item.componentType, title: item.title, size: item.size, layout: item.layout, symbol: item.symbol, color: item.color }))] }, uuidV4()))) }), children: _jsx(Box, { sx: {
|
|
20
21
|
display: 'flex',
|
|
21
22
|
alignItems: 'center',
|
|
22
|
-
}, children: _jsx(Information, {}) }) })), symbol && (_jsx(PresentationSymbolIcon, { symbol: symbol, color: color, isDimmed: isDimmed || !checked })), _jsx(PresentationTypography, { size: size, isDimmed: isDimmed || !checked, children: title })] }), _jsx(StyledToggle, { disabled: disabled || isDimmed, checked: checked, onChange: onChange })] }), content.length > 0 && (_jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: content.map((item) => (_jsx(Statistic, { ...item, isDimmed: isDimmed || !checked }, uuidV4()))) }, uuidV4())), bar && (_jsx(Box, { sx: { padding: '0 8px', fontSize: '14px', lineHeight: '8px' }, children: _jsx(AnalysisBar, { isDimmed: isDimmed || !checked, componentType: bar.componentType, expressionValue: bar.expressionValue, expressionLevels: bar.expressionLevels, caption: bar.caption, segments: bar.segments }) }))] }));
|
|
23
|
+
}, children: _jsx(Information, {}) }) })), symbol && (_jsx(PresentationSymbolIcon, { symbol: symbol, color: color, isDimmed: isDimmed || !checked })), _jsx(PresentationTypography, { size: size, isDimmed: isDimmed || !checked, children: title })] }), _jsx(StyledToggle, { disabled: disabled || isDimmed, checked: checked, toggleColor: theme.palette.lunitTeal[70], onChange: onChange })] }), content.length > 0 && (_jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: content.map((item) => (_jsx(Statistic, { ...item, isDimmed: isDimmed || !checked }, uuidV4()))) }, uuidV4())), bar && (_jsx(Box, { sx: { padding: '0 8px', fontSize: '14px', lineHeight: '8px' }, children: _jsx(AnalysisBar, { isDimmed: isDimmed || !checked, componentType: bar.componentType, expressionValue: bar.expressionValue, expressionLevels: bar.expressionLevels, caption: bar.caption, segments: bar.segments }) }))] }));
|
|
23
24
|
};
|
|
24
25
|
export default ToggleControl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunit/oui",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.22",
|
|
4
4
|
"validate-branch-name": {
|
|
5
5
|
"pattern": "^(main|develop)|(feature|fix|release|hotfix|qe)/.+$",
|
|
6
6
|
"errorMsg": "The branch name is not correct. Please check the pattern. (ex. feature/add-something)"
|