@lunit/oui 2.4.3 → 2.4.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.
- package/dist/components/LoadingIndicator/LoadingIndicator.d.ts +1 -1
- package/dist/components/LoadingIndicator/LoadingIndicator.js +2 -2
- package/dist/components/LoadingIndicator/LoadingIndicator.types.d.ts +1 -0
- package/dist/presentations/AnalysisBar/AnalysisBar.d.ts +1 -1
- package/dist/presentations/AnalysisBar/AnalysisBar.js +9 -6
- package/dist/presentations/AnalysisBar/AnalysisBar.styled.d.ts +8 -2
- package/dist/presentations/AnalysisBar/AnalysisBar.styled.js +40 -8
- package/dist/presentations/AnalysisBar/AnalysisBar.types.d.ts +1 -0
- package/dist/presentations/ToggleControl/ToggleControl.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LoadingIndicatorProps } from './LoadingIndicator.types';
|
|
2
|
-
declare const LoadingIndicator: ({ message, details, loadingAnimation, }: LoadingIndicatorProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const LoadingIndicator: ({ message, details, loadingAnimation, dataTestId, }: LoadingIndicatorProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default LoadingIndicator;
|
|
@@ -4,7 +4,7 @@ import { Player } from '@lottiefiles/react-lottie-player';
|
|
|
4
4
|
import { LoadingOverlay, LoadingIndicatorBox, LoadingMessage, LoadingDetails, } from './LoadingIndicator.styled';
|
|
5
5
|
const DotLoadingAnimation = require('./assets/DotLoadingAnimation.json');
|
|
6
6
|
const DnaLoadingAnimation = require('./assets/DnaLoadingAnimation.json');
|
|
7
|
-
const LoadingIndicator = ({ message, details, loadingAnimation = 'dot', }) => {
|
|
8
|
-
return (_jsx(LoadingOverlay, { children: _jsxs(LoadingIndicatorBox, { children: [_jsx(Player, { autoplay: true, loop: true, src: loadingAnimation === 'dot' ? DotLoadingAnimation : DnaLoadingAnimation, style: { height: '112px', width: '140px' } }), _jsx(LoadingMessage, { children: message }), _jsx(LoadingDetails, { children: details || (_jsxs(_Fragment, { children: ["Please wait.", _jsx("br", {}), "It may take a few minutes."] })) })] }) }));
|
|
7
|
+
const LoadingIndicator = ({ message, details, loadingAnimation = 'dot', dataTestId = 'loading-indicator', }) => {
|
|
8
|
+
return (_jsx(LoadingOverlay, { children: _jsxs(LoadingIndicatorBox, { "data-testid": dataTestId, children: [_jsx(Player, { autoplay: true, loop: true, src: loadingAnimation === 'dot' ? DotLoadingAnimation : DnaLoadingAnimation, style: { height: '112px', width: '140px' } }), _jsx(LoadingMessage, { children: message }), _jsx(LoadingDetails, { children: details || (_jsxs(_Fragment, { children: ["Please wait.", _jsx("br", {}), "It may take a few minutes."] })) })] }) }));
|
|
9
9
|
};
|
|
10
10
|
export default LoadingIndicator;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AnalysisBarProps } from './AnalysisBar.types';
|
|
2
|
-
declare const AnalysisBar: ({ componentType, expressionValue, caption, expressionLevels, expressionLabels, segments, isDimmed, }: AnalysisBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const AnalysisBar: ({ componentType, isCutoff, expressionValue, caption, expressionLevels, expressionLabels, segments, isDimmed, }: AnalysisBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default AnalysisBar;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { findIndex as _findIndex } from 'lodash';
|
|
2
3
|
import { Box } from '@mui/material';
|
|
3
4
|
import { AnalysisBarSegmentContainer, AnalysisBarOuter, AxisLabels, GraphAxisLabel, GraphScoreIndicator, GraphSegment, } from './AnalysisBar.styled';
|
|
4
5
|
import { parseStringValToNumber } from './AnalysisBar.utils';
|
|
5
6
|
import HeatmapGraphSVG from './HeatmapGraphIcon/HeatmapGraphSVG';
|
|
6
|
-
const Segments = ({ segments }) => {
|
|
7
|
+
const Segments = ({ segments, isCutoff }) => {
|
|
7
8
|
if (!segments) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
11
|
const validSegments = segments.filter((segment) => segment.width > 0);
|
|
12
|
+
const combinedWidth = segments.length > 1 ? segments[0].width + segments[1].width : 0;
|
|
13
|
+
const onePercentSegmentIndex = _findIndex(segments, (segment) => segment.width > 0 && segment.width <= 1);
|
|
11
14
|
if (segments?.length === 1 && segments[0].color === 'jet') {
|
|
12
15
|
return (_jsx(Box, { sx: { width: '100%', height: '14px', transform: 'scaleY(0.8)' }, children: _jsx(HeatmapGraphSVG, {}) }));
|
|
13
16
|
}
|
|
@@ -15,18 +18,18 @@ const Segments = ({ segments }) => {
|
|
|
15
18
|
if (segment.color === 'jet') {
|
|
16
19
|
return _jsx(HeatmapGraphSVG, { width: `${segment.width}%` });
|
|
17
20
|
}
|
|
18
|
-
return (_jsx(GraphSegment, { color: segment.color, width: segment.width, isFirstSegment: i === 0, isLastSegment: i === segments.length - 1 }, i));
|
|
21
|
+
return (_jsx(GraphSegment, { color: segment.color, width: segment.width, isFirstSegment: i === 0, isLastSegment: i === segments.length - 1, isCutoff: isCutoff, combinedWidth: combinedWidth, isNextSegment: i === onePercentSegmentIndex + 1, isOnePercentSegment: segment.width <= 1 }, i));
|
|
19
22
|
}) }));
|
|
20
23
|
};
|
|
21
|
-
const AnalysisBar = ({ componentType = 'analysisBar', expressionValue, caption, expressionLevels = [], expressionLabels = [], segments, isDimmed = false, }) => {
|
|
24
|
+
const AnalysisBar = ({ componentType = 'analysisBar', isCutoff = false, expressionValue, caption, expressionLevels = [], expressionLabels = [], segments, isDimmed = false, }) => {
|
|
22
25
|
if (!componentType)
|
|
23
26
|
throw new Error("The 'componentType' prop is required.");
|
|
24
27
|
if (!expressionLevels.length)
|
|
25
28
|
throw new Error("The 'expressionLevels' prop must contain at least one item.");
|
|
26
29
|
const validSegments = segments.filter((segment) => segment.width > 0);
|
|
27
|
-
return (_jsxs(AnalysisBarOuter, { className: "analysis-bar", isDimmed: isDimmed, children: [_jsxs(AnalysisBarSegmentContainer, { children: [expressionValue && (_jsx(GraphScoreIndicator, { value: expressionValue, isJet: segments?.[0].color === 'jet' })), _jsx(Segments, { segments: validSegments })] }), (expressionLevels.length > 0 || caption) && (_jsxs(AxisLabels, { children: [expressionLevels.length > 0 &&
|
|
30
|
+
return (_jsxs(AnalysisBarOuter, { className: "analysis-bar", isDimmed: isDimmed, children: [_jsxs(AnalysisBarSegmentContainer, { children: [expressionValue && (_jsx(GraphScoreIndicator, { value: expressionValue, isCutoff: isCutoff, isJet: segments?.[0].color === 'jet' })), _jsx(Segments, { segments: validSegments, isCutoff: isCutoff })] }), (expressionLevels.length > 0 || caption) && (_jsxs(AxisLabels, { children: [expressionLevels.length > 0 &&
|
|
28
31
|
expressionLevels.map((val, i) => {
|
|
29
|
-
return (_jsx(GraphAxisLabel, { label: expressionLabels[i] || val, leftPos: parseStringValToNumber(val) }, i));
|
|
30
|
-
}), caption && (_jsx(GraphAxisLabel, { label: caption, leftPos: 50 }))] }))] }));
|
|
32
|
+
return (_jsx(GraphAxisLabel, { label: expressionLabels[i] || val, isCutoff: isCutoff, leftPos: parseStringValToNumber(val) }, i));
|
|
33
|
+
}), caption && (_jsx(GraphAxisLabel, { label: caption, isCutoff: isCutoff, leftPos: 50 }))] }))] }));
|
|
31
34
|
};
|
|
32
35
|
export default AnalysisBar;
|
|
@@ -7,13 +7,15 @@ export declare const AnalysisBarOuter: import("@emotion/styled").StyledComponent
|
|
|
7
7
|
export declare const AnalysisBarSegmentContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
8
8
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
9
9
|
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
10
|
-
export declare const GraphScoreIndicator: ({ value, isJet }: {
|
|
10
|
+
export declare const GraphScoreIndicator: ({ value, isCutoff, isJet, }: {
|
|
11
11
|
value: string;
|
|
12
|
+
isCutoff?: boolean | undefined;
|
|
12
13
|
isJet?: boolean | undefined;
|
|
13
14
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare const GraphAxisLabel: ({ label, leftPos }: {
|
|
15
|
+
export declare const GraphAxisLabel: ({ label, leftPos, isCutoff, }: {
|
|
15
16
|
label: string;
|
|
16
17
|
leftPos: number;
|
|
18
|
+
isCutoff?: boolean | undefined;
|
|
17
19
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
20
|
export declare const AxisLabels: ({ children }: {
|
|
19
21
|
percent?: boolean;
|
|
@@ -24,6 +26,10 @@ export declare const AnalysisBarCaption: ({ label }: {
|
|
|
24
26
|
interface GraphSegmentProps {
|
|
25
27
|
color: string | undefined;
|
|
26
28
|
width: number;
|
|
29
|
+
isCutoff?: boolean;
|
|
30
|
+
combinedWidth?: number;
|
|
31
|
+
isNextSegment?: boolean;
|
|
32
|
+
isOnePercentSegment?: boolean;
|
|
27
33
|
isFirstSegment: boolean;
|
|
28
34
|
isLastSegment: boolean;
|
|
29
35
|
}
|
|
@@ -42,8 +42,16 @@ const GraphScoreIndicatorPip = styled('span')(() => {
|
|
|
42
42
|
boxSizing: 'content-box',
|
|
43
43
|
};
|
|
44
44
|
});
|
|
45
|
-
export const GraphScoreIndicator = ({ value, isJet }) => {
|
|
46
|
-
|
|
45
|
+
export const GraphScoreIndicator = ({ value, isCutoff, isJet, }) => {
|
|
46
|
+
let leftPos = `${parseStringValToNumber(value)}%`;
|
|
47
|
+
if (isCutoff) {
|
|
48
|
+
if (+value <= 1) {
|
|
49
|
+
leftPos = '12px';
|
|
50
|
+
}
|
|
51
|
+
if (+value > 1 && +value <= 7) {
|
|
52
|
+
leftPos = '20px';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
47
55
|
return (_jsxs(GraphScoreIndicatorContainer, { className: "analysis-bar-score-indicator", sx: {
|
|
48
56
|
left: leftPos,
|
|
49
57
|
transform: isJet ? 'translateX(-50%) translateY(8px)' : 'translateX(-50%)',
|
|
@@ -59,8 +67,11 @@ const GraphAxisLabelContainer = styled('span')(() => {
|
|
|
59
67
|
alignItems: 'center',
|
|
60
68
|
};
|
|
61
69
|
});
|
|
62
|
-
export const GraphAxisLabel = ({ label, leftPos }) => {
|
|
70
|
+
export const GraphAxisLabel = ({ label, leftPos, isCutoff, }) => {
|
|
63
71
|
const getLeft = (value) => {
|
|
72
|
+
if (isCutoff && +value > 0 && +value <= 1) {
|
|
73
|
+
return '12px';
|
|
74
|
+
}
|
|
64
75
|
return `${clampBarLabelPosition(value)}%`;
|
|
65
76
|
};
|
|
66
77
|
return (_jsx(GraphAxisLabelContainer, { sx: {
|
|
@@ -84,8 +95,8 @@ export const AnalysisBarCaption = ({ label }) => {
|
|
|
84
95
|
width: 'auto',
|
|
85
96
|
}, className: "analysis-bar-caption", children: _jsx(Typography, { variant: "small_body_m5", sx: { textAlign: 'center' }, children: label }) }));
|
|
86
97
|
};
|
|
87
|
-
const segmentStyle = (color, width, isFirstSegment, isLastSegment) => {
|
|
88
|
-
|
|
98
|
+
const segmentStyle = (color, width, isFirstSegment, isLastSegment, isCutoff, combinedWidth, isNextSegment, isOnePercentSegment) => {
|
|
99
|
+
const baseStyle = {
|
|
89
100
|
backgroundColor: color,
|
|
90
101
|
height: '8px',
|
|
91
102
|
borderTopLeftRadius: isFirstSegment ? '2px' : '0px',
|
|
@@ -94,13 +105,34 @@ const segmentStyle = (color, width, isFirstSegment, isLastSegment) => {
|
|
|
94
105
|
borderBottomRightRadius: isLastSegment ? '2px' : '0px',
|
|
95
106
|
width: `${width}%`,
|
|
96
107
|
};
|
|
108
|
+
if (isOnePercentSegment) {
|
|
109
|
+
return {
|
|
110
|
+
...baseStyle,
|
|
111
|
+
width: '12px',
|
|
112
|
+
minWidth: '12px',
|
|
113
|
+
maxWidth: '12px',
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
...baseStyle,
|
|
118
|
+
width: isCutoff && isNextSegment ? `calc(${combinedWidth}% - 12px)` : `${width}%`,
|
|
119
|
+
};
|
|
97
120
|
};
|
|
98
121
|
export const GraphSegment = styled('span', {
|
|
99
|
-
shouldForwardProp: (prop) => ![
|
|
100
|
-
|
|
122
|
+
shouldForwardProp: (prop) => ![
|
|
123
|
+
'color',
|
|
124
|
+
'width',
|
|
125
|
+
'isFirstSegment',
|
|
126
|
+
'isLastSegment',
|
|
127
|
+
'isCutoff',
|
|
128
|
+
'combinedWidth',
|
|
129
|
+
'isNextSegment',
|
|
130
|
+
'isOnePercentSegment',
|
|
131
|
+
].includes(prop.toString()),
|
|
132
|
+
})(({ color, width, isFirstSegment, isLastSegment, isCutoff, combinedWidth, isNextSegment, isOnePercentSegment, }) => {
|
|
101
133
|
// cover undefined and empty string
|
|
102
134
|
const barColor = color && color.length ? color : 'red';
|
|
103
135
|
return {
|
|
104
|
-
...segmentStyle(barColor, width, isFirstSegment, isLastSegment), // fallback color
|
|
136
|
+
...segmentStyle(barColor, width, isFirstSegment, isLastSegment, isCutoff, combinedWidth, isNextSegment, isOnePercentSegment), // fallback color
|
|
105
137
|
};
|
|
106
138
|
});
|
|
@@ -19,7 +19,7 @@ const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbo
|
|
|
19
19
|
throw new Error("The 'checked' prop is required.");
|
|
20
20
|
if (typeof checked !== 'boolean')
|
|
21
21
|
throw new Error("The 'checked' prop must be a boolean.");
|
|
22
|
-
return (_jsxs(ToggleControlOuter, { "data-
|
|
22
|
+
return (_jsxs(ToggleControlOuter, { "data-testid": `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: {
|
|
23
23
|
display: 'flex',
|
|
24
24
|
alignItems: 'center',
|
|
25
25
|
}, 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, expressionLabels: bar.expressionLabels, caption: bar.caption, segments: bar.segments }) }))] }));
|
package/package.json
CHANGED