@lunit/oui 2.0.1 → 2.2.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/dist/components/Dropdown/Dropdown.styled.js +1 -0
- package/dist/components/Tooltip/Tooltip.utils.js +1 -1
- package/dist/presentations/Accordion/index.d.ts +2 -0
- package/dist/presentations/AnalysisBar/AnalysisBar.js +2 -2
- package/dist/presentations/AnalysisBar/AnalysisBar.styled.d.ts +2 -1
- package/dist/presentations/AnalysisBar/AnalysisBar.styled.js +6 -4
- package/dist/presentations/FreeText/FreeText.js +2 -1
- package/dist/presentations/Histogram/Histogram.d.ts +1 -1
- package/dist/presentations/Histogram/Histogram.js +6 -3
- package/dist/presentations/Histogram/Histogram.styled.d.ts +3 -0
- package/dist/presentations/Histogram/Histogram.styled.js +5 -0
- package/dist/presentations/Histogram/Histogram.types.d.ts +2 -0
- package/dist/presentations/Preview/Preview.d.ts +3 -0
- package/dist/presentations/Preview/Preview.js +18 -0
- package/dist/presentations/Preview/Preview.styled.d.ts +4 -0
- package/dist/presentations/Preview/Preview.styled.js +9 -0
- package/dist/presentations/Preview/Preview.types.d.ts +14 -0
- package/dist/presentations/Preview/Preview.types.js +1 -0
- package/dist/presentations/Preview/index.d.ts +4 -0
- package/dist/presentations/Preview/index.js +2 -0
- package/dist/presentations/Statistic/Statistic.d.ts +1 -1
- package/dist/presentations/Statistic/Statistic.js +2 -2
- package/dist/presentations/Statistic/Statistic.types.d.ts +5 -1
- package/dist/presentations/Statistic/index.d.ts +2 -2
- package/dist/presentations/Threshold/Threshold.d.ts +3 -0
- package/dist/presentations/Threshold/Threshold.js +36 -0
- package/dist/presentations/Threshold/Threshold.styled.d.ts +8 -0
- package/dist/presentations/Threshold/Threshold.styled.js +81 -0
- package/dist/presentations/Threshold/Threshold.types.d.ts +31 -0
- package/dist/presentations/Threshold/Threshold.types.js +1 -0
- package/dist/presentations/Threshold/Threshold.utils.d.ts +16 -0
- package/dist/presentations/Threshold/Threshold.utils.js +34 -0
- package/dist/presentations/Threshold/index.d.ts +4 -0
- package/dist/presentations/Threshold/index.js +2 -0
- package/dist/presentations/ToggleControl/ToggleControl.d.ts +1 -1
- package/dist/presentations/ToggleControl/ToggleControl.js +5 -3
- package/dist/presentations/ToggleControl/ToggleControl.styled.js +2 -3
- package/dist/presentations/ToggleControl/ToggleControl.types.d.ts +2 -1
- package/dist/presentations/ToggleControlGroup/ToggleControlGroup.js +28 -2
- package/dist/presentations/ToggleControlGroup/ToggleControlGroup.types.d.ts +1 -1
- package/dist/presentations/ToggleControlGroup/index.d.ts +2 -0
- package/dist/presentations/index.d.ts +2 -0
- package/dist/presentations/index.js +2 -0
- package/dist/presentations/presentations.styled.js +7 -7
- package/dist/presentations/presentations.types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -23,6 +23,7 @@ const baseDropdownStyle = (theme) => {
|
|
|
23
23
|
'&.Mui-disabled': { border: 'none', background: theme.palette.neutralGrey[75] },
|
|
24
24
|
'.MuiSvgIcon-root ': {
|
|
25
25
|
cursor: 'pointer',
|
|
26
|
+
marginRight: '16px',
|
|
26
27
|
color: theme.palette.neutralGrey[5],
|
|
27
28
|
'&.Mui-disabled': {
|
|
28
29
|
color: theme.palette.neutralGrey[45],
|
|
@@ -8,7 +8,7 @@ const Segments = ({ segments, adjustForOnePercent }) => {
|
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
10
|
if (segments?.length === 1 && segments[0].color === 'jet') {
|
|
11
|
-
return (_jsx(Box, { sx: { width: '100%', height: '
|
|
11
|
+
return (_jsx(Box, { sx: { width: '100%', height: '14px', transform: 'scaleY(0.8)' }, children: _jsx(HeatmapGraphSVG, { width: 'auto', height: 'auto' }) }));
|
|
12
12
|
}
|
|
13
13
|
return (_jsx(_Fragment, { children: segments?.map((segment, i) => {
|
|
14
14
|
if (segment.color === 'jet') {
|
|
@@ -19,7 +19,7 @@ const Segments = ({ segments, adjustForOnePercent }) => {
|
|
|
19
19
|
};
|
|
20
20
|
const AnalysisBar = ({ componentType = 'analysisBar', expressionValue, caption, expressionLevels, segments, isDimmed = false, }) => {
|
|
21
21
|
const hasAdjustedOnePercentSegment = segments?.[0].width === 1;
|
|
22
|
-
return (_jsxs(AnalysisBarOuter, { className: "analysis-bar", isDimmed: isDimmed, children: [_jsxs(AnalysisBarSegmentContainer, { children: [expressionValue && (_jsx(GraphScoreIndicator, { adjustForOnePercent: hasAdjustedOnePercentSegment, value: expressionValue })), _jsx(Segments, { segments: segments, adjustForOnePercent: hasAdjustedOnePercentSegment })] }), _jsxs(AxisLabels, { children: [expressionLevels.map((val, i) => {
|
|
22
|
+
return (_jsxs(AnalysisBarOuter, { className: "analysis-bar", isDimmed: isDimmed, children: [_jsxs(AnalysisBarSegmentContainer, { children: [expressionValue && (_jsx(GraphScoreIndicator, { adjustForOnePercent: hasAdjustedOnePercentSegment, value: expressionValue, isJet: segments?.[0].color === 'jet' })), _jsx(Segments, { segments: segments, adjustForOnePercent: hasAdjustedOnePercentSegment })] }), _jsxs(AxisLabels, { children: [expressionLevels.map((val, i) => {
|
|
23
23
|
return (_jsx(GraphAxisLabel, { label: val, adjustForOnePercent: hasAdjustedOnePercentSegment, leftPos: parseStringValToNumber(val) }, i));
|
|
24
24
|
}), caption && (_jsx(GraphAxisLabel, { label: caption, adjustForOnePercent: hasAdjustedOnePercentSegment, leftPos: 50 }))] })] }));
|
|
25
25
|
};
|
|
@@ -7,9 +7,10 @@ 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, adjustForOnePercent, }: {
|
|
10
|
+
export declare const GraphScoreIndicator: ({ value, adjustForOnePercent, isJet, }: {
|
|
11
11
|
value: string;
|
|
12
12
|
adjustForOnePercent: boolean;
|
|
13
|
+
isJet?: boolean | undefined;
|
|
13
14
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export declare const GraphAxisLabel: ({ label, leftPos, adjustForOnePercent, }: {
|
|
15
16
|
label: string;
|
|
@@ -17,14 +17,16 @@ export const AnalysisBarSegmentContainer = styled(Box)(() => ({
|
|
|
17
17
|
position: 'relative',
|
|
18
18
|
width: '100%',
|
|
19
19
|
}));
|
|
20
|
-
const GraphScoreIndicatorContainer = styled('span'
|
|
20
|
+
const GraphScoreIndicatorContainer = styled('span', {
|
|
21
|
+
shouldForwardProp: (prop) => prop !== 'isJet',
|
|
22
|
+
})(({ isJet }) => {
|
|
21
23
|
return {
|
|
22
24
|
width: '20px',
|
|
23
25
|
position: 'absolute',
|
|
24
26
|
display: 'flex',
|
|
25
27
|
flexDirection: 'column',
|
|
26
28
|
alignItems: 'center',
|
|
27
|
-
top: '-20px',
|
|
29
|
+
top: isJet ? '-20px' : '-19px',
|
|
28
30
|
zIndex: 999,
|
|
29
31
|
};
|
|
30
32
|
});
|
|
@@ -38,14 +40,14 @@ const GraphScoreIndicatorPip = styled('span')(() => {
|
|
|
38
40
|
boxSizing: 'content-box',
|
|
39
41
|
};
|
|
40
42
|
});
|
|
41
|
-
export const GraphScoreIndicator = ({ value, adjustForOnePercent, }) => {
|
|
43
|
+
export const GraphScoreIndicator = ({ value, adjustForOnePercent, isJet, }) => {
|
|
42
44
|
let leftPos = parseStringValToNumber(value);
|
|
43
45
|
if (adjustForOnePercent) {
|
|
44
46
|
leftPos = adjustBarLabelPosition(leftPos);
|
|
45
47
|
}
|
|
46
48
|
return (_jsxs(GraphScoreIndicatorContainer, { className: "analysis-bar-score-indicator", sx: {
|
|
47
49
|
left: `${leftPos}%`,
|
|
48
|
-
transform: 'translateX(-50%)',
|
|
50
|
+
transform: isJet ? 'translateX(-50%) translateY(8px)' : 'translateX(-50%)',
|
|
49
51
|
}, children: [_jsx(Typography, { variant: "small_body_sb1", sx: { textAlign: 'center' }, children: value }), _jsx(GraphScoreIndicatorPip, {})] }));
|
|
50
52
|
};
|
|
51
53
|
const GraphAxisLabelContainer = styled('span')(() => {
|
|
@@ -8,8 +8,9 @@ const FreeText = ({ componentType = 'freeText', size = 'medium', content, height
|
|
|
8
8
|
borderRadius: background ? '8px' : 0,
|
|
9
9
|
backgroundColor: background ? theme.palette.neutralGrey[75] : 'transparent',
|
|
10
10
|
height: height ? height : 'auto',
|
|
11
|
+
display: 'flex',
|
|
11
12
|
}, children: _jsx(PresentationTypography, { size: size, sx: {
|
|
12
|
-
display: '
|
|
13
|
+
display: 'block',
|
|
13
14
|
whiteSpace: 'pre-wrap',
|
|
14
15
|
overflow: 'auto',
|
|
15
16
|
color: background ? '#FFFFFF' : 'inherit',
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HistogramProps } from './Histogram.types';
|
|
2
|
-
declare const Histogram: ({ componentType, title, xAxisLabels, yAxisLabels, tabs, }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const Histogram: ({ componentType, title, xAxisLabels, yAxisLabels, tabs, description, }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default Histogram;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
3
4
|
import { Box } from '@mui/material';
|
|
4
|
-
import { HistogramContainer, HistogramChartContainer, HistogramTitle, HistogramNoData, } from './Histogram.styled';
|
|
5
|
+
import { HistogramContainer, HistogramChartContainer, HistogramTitle, HistogramNoData, HistogramDescription, } from './Histogram.styled';
|
|
5
6
|
import HistogramTabs from './HistogramTabs';
|
|
6
7
|
import HistogramChart from './HistogramCharts';
|
|
7
|
-
|
|
8
|
+
import { FreeText } from '../FreeText';
|
|
9
|
+
const Histogram = ({ componentType = 'histogram', title, xAxisLabels, yAxisLabels, tabs, description = [], }) => {
|
|
8
10
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
9
11
|
const noData = tabs[activeIndex].data.length === 0;
|
|
10
12
|
return (_jsxs(HistogramContainer, { children: [noData && _jsx(HistogramNoData, { children: "No Data" }), title && _jsx(HistogramTitle, { children: title }), _jsx(HistogramTabs, { options: tabs.map((tab) => tab.label), active: activeIndex, onChange: setActiveIndex }), _jsx(HistogramChartContainer, { children: _jsx(Box, { sx: {
|
|
11
13
|
position: 'absolute',
|
|
12
14
|
left: '-25px',
|
|
13
|
-
}, children: _jsx(HistogramChart, { dataset: tabs[activeIndex], xAxisLabels: xAxisLabels, yAxisLabels: yAxisLabels }) }) })
|
|
15
|
+
}, children: _jsx(HistogramChart, { dataset: tabs[activeIndex], xAxisLabels: xAxisLabels, yAxisLabels: yAxisLabels }) }) }), _jsx(HistogramDescription, { children: description.length > 0 &&
|
|
16
|
+
description.map((item) => (_jsx(FreeText, { ...item }, uuidV4()))) })] }));
|
|
14
17
|
};
|
|
15
18
|
export default Histogram;
|
|
@@ -14,6 +14,9 @@ export declare const HistogramTabsContainer: import("@emotion/styled").StyledCom
|
|
|
14
14
|
export declare const HistogramChartContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
15
15
|
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
16
16
|
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
17
|
+
export declare const HistogramDescription: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
18
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
19
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
17
20
|
export declare const TabButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
18
21
|
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
19
22
|
}, "color" | "disabled" | "size" | "style" | "fullWidth" | "classes" | "className" | "children" | "sx" | "variant" | "tabIndex" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "href" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
@@ -29,6 +29,11 @@ export const HistogramChartContainer = styled(Box)({
|
|
|
29
29
|
width: '244px',
|
|
30
30
|
marginBottom: '32px',
|
|
31
31
|
});
|
|
32
|
+
export const HistogramDescription = styled(Box)({
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexDirection: 'column',
|
|
35
|
+
gap: '4px',
|
|
36
|
+
});
|
|
32
37
|
export const TabButton = styled(Button, {
|
|
33
38
|
shouldForwardProp: (prop) => prop !== 'active',
|
|
34
39
|
})(({ theme, active = false }) => ({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FreeTextProps } from '../FreeText';
|
|
1
2
|
export interface HistogramTab {
|
|
2
3
|
label: string;
|
|
3
4
|
data: number[];
|
|
@@ -5,6 +6,7 @@ export interface HistogramTab {
|
|
|
5
6
|
export interface HistogramProps {
|
|
6
7
|
componentType: 'histogram';
|
|
7
8
|
title?: string;
|
|
9
|
+
description?: FreeTextProps[];
|
|
8
10
|
xAxisLabels: number[];
|
|
9
11
|
yAxisLabels: number[];
|
|
10
12
|
tabs: HistogramTab[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
3
|
+
import { Container } from './Preview.styled';
|
|
4
|
+
import { Box } from '@mui/material';
|
|
5
|
+
import { ToggleControl } from '../ToggleControl';
|
|
6
|
+
import { ToggleControlGroup } from '../ToggleControlGroup';
|
|
7
|
+
import { AnalysisBar } from '../AnalysisBar';
|
|
8
|
+
import { HorizonDivider } from '../HorizonDivider';
|
|
9
|
+
import { Accordion } from '../Accordion';
|
|
10
|
+
import { Statistic } from '../Statistic';
|
|
11
|
+
import { Score } from '../Score';
|
|
12
|
+
import { FreeText } from '../FreeText';
|
|
13
|
+
import { Threshold } from '../Threshold';
|
|
14
|
+
import { Histogram } from '../Histogram';
|
|
15
|
+
const Preview = ({ visualizationControls = [], analysisSummary = [] }) => {
|
|
16
|
+
return (_jsxs(Container, { children: [_jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '16px', padding: '16px' }, children: visualizationControls.map((item) => (_jsxs(Box, { children: [item.componentType === 'toggle' && (_jsx(ToggleControl, { ...item, onChange: () => { } }, uuidV4())), item.componentType === 'toggleGroup' && (_jsx(ToggleControlGroup, { ...item, onChange: () => { } }, uuidV4())), item.componentType === 'analysisBar' && (_jsx(AnalysisBar, { ...item }, uuidV4()))] }, uuidV4()))) }), _jsx(HorizonDivider, { componentType: "divider" }), _jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '16px', padding: '16px' }, children: [_jsx(FreeText, { componentType: "freeText", size: "large-bold", content: "Analysis Summary" }), analysisSummary.map((item) => (_jsxs(Box, { children: [item.componentType === 'accordion' && (_jsx(Accordion, { ...item }, uuidV4())), item.componentType === 'statistic' && (_jsx(Statistic, { ...item }, uuidV4())), item.componentType === 'score' && (_jsx(Score, { ...item }, uuidV4())), item.componentType === 'freeText' && (_jsx(FreeText, { ...item }, uuidV4())), item.componentType === 'threshold' && (_jsx(Threshold, { ...item }, uuidV4())), item.componentType === 'histogram' && (_jsx(Histogram, { ...item }, uuidV4()))] }, uuidV4())))] })] }));
|
|
17
|
+
};
|
|
18
|
+
export default Preview;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Container: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
4
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AccordionProps } from '../Accordion';
|
|
2
|
+
import { StatisticProps } from '../Statistic';
|
|
3
|
+
import { ScoreProps } from '../Score';
|
|
4
|
+
import { ToggleControlProps } from '../ToggleControl';
|
|
5
|
+
import { ToggleControlGroupProps } from '../ToggleControlGroup';
|
|
6
|
+
import { AnalysisBarProps } from '../AnalysisBar';
|
|
7
|
+
import { FreeTextProps } from '../FreeText';
|
|
8
|
+
import { ThresholdProps } from '../Threshold';
|
|
9
|
+
import { HistogramProps } from '../Histogram';
|
|
10
|
+
interface PreviewProps {
|
|
11
|
+
visualizationControls: (ToggleControlProps | ToggleControlGroupProps | AnalysisBarProps)[];
|
|
12
|
+
analysisSummary: (AccordionProps | StatisticProps | ScoreProps | FreeTextProps | ThresholdProps | HistogramProps)[];
|
|
13
|
+
}
|
|
14
|
+
export type { PreviewProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StatisticProps } from './Statistic.types';
|
|
2
|
-
declare const Statistic: ({ componentType, title, layout, metrics, size, symbol, color, ...rest }: StatisticProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const Statistic: ({ componentType, title, layout, metrics, size, symbol, color, isDimmed, ...rest }: StatisticProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default Statistic;
|
|
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { Container, HorizontalStatisticContainer, VerticalStatisticContainer, } from './Statistic.styled';
|
|
4
4
|
import { PresentationSymbolIcon, PresentationTypography } from '../presentations.styled';
|
|
5
|
-
const Statistic = ({ componentType = 'statistic', title, layout = 'vertical', metrics = '', size = 'medium', symbol, color, ...rest }) => {
|
|
5
|
+
const Statistic = ({ componentType = 'statistic', title, layout = 'vertical', metrics = '', size = 'medium', symbol, color, isDimmed = false, ...rest }) => {
|
|
6
6
|
return (_jsx(Container, { ...rest, sx: { width: '100%' }, children: layout === 'horizontal' ? (_jsxs(HorizontalStatisticContainer, { children: [_jsxs(Box, { sx: {
|
|
7
7
|
display: 'flex',
|
|
8
8
|
alignItems: 'center',
|
|
9
9
|
gap: '6px',
|
|
10
|
-
}, children: [symbol && (_jsx(PresentationSymbolIcon, { symbol: symbol, color: color })), _jsx(PresentationTypography, { size: size, children: title })] }), _jsx(PresentationTypography, { size: size, children: metrics })] })) : (_jsx(VerticalStatisticContainer, { title: title, metrics: metrics })) }));
|
|
10
|
+
}, children: [symbol && (_jsx(PresentationSymbolIcon, { symbol: symbol, color: color, isDimmed: isDimmed })), _jsx(PresentationTypography, { isDimmed: isDimmed, size: size, children: title })] }), _jsx(PresentationTypography, { size: size, children: metrics })] })) : (_jsx(VerticalStatisticContainer, { title: title, metrics: metrics })) }));
|
|
11
11
|
};
|
|
12
12
|
export default Statistic;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BoxProps } from '@mui/material';
|
|
2
2
|
import { PresentationSymbolProps } from '../presentations.types';
|
|
3
|
-
export interface
|
|
3
|
+
export interface StatisticSpec extends BoxProps {
|
|
4
4
|
componentType: 'statistic';
|
|
5
5
|
title: string;
|
|
6
6
|
layout?: 'horizontal' | 'vertical';
|
|
@@ -8,4 +8,8 @@ export interface StatisticProps extends BoxProps {
|
|
|
8
8
|
size?: 'small-dimmed' | 'small' | 'small-bold' | 'medium' | 'medium-bold' | 'large-bold';
|
|
9
9
|
symbol?: PresentationSymbolProps['symbol'];
|
|
10
10
|
color?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface StatisticProps extends StatisticSpec {
|
|
14
|
+
isDimmed?: boolean;
|
|
11
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import Statistic from './Statistic';
|
|
2
|
-
import type { StatisticProps } from './Statistic.types';
|
|
2
|
+
import type { StatisticProps, StatisticSpec } from './Statistic.types';
|
|
3
3
|
export { Statistic };
|
|
4
|
-
export type { StatisticProps };
|
|
4
|
+
export type { StatisticProps, StatisticSpec };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ThresholdProps } from './Threshold.types';
|
|
2
|
+
declare const Threshold: ({ componentType, title, totalScore, totalCells, statisticItems, options, description, controlStep, onChangeDropdown, onSliderChangeCommitted, }: ThresholdProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default Threshold;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
4
|
+
import { Box } from '@mui/material';
|
|
5
|
+
import { BaseSlider, Container } from './Threshold.styled';
|
|
6
|
+
import { Score } from '../Score';
|
|
7
|
+
import { Statistic } from '../Statistic';
|
|
8
|
+
import { PresentationTypography } from '../presentations.styled';
|
|
9
|
+
import { Button, Dropdown, DropdownItem } from '../../components';
|
|
10
|
+
import { HorizonDivider } from '../HorizonDivider';
|
|
11
|
+
import { FreeText } from '../FreeText';
|
|
12
|
+
import { getPresetValue, getSliderMarks } from './Threshold.utils';
|
|
13
|
+
const Threshold = ({ componentType = 'threshold', title, totalScore, totalCells, statisticItems, options, description, controlStep = 1, onChangeDropdown, onSliderChangeCommitted, }) => {
|
|
14
|
+
const [selectedItem, setSelectedItem] = useState(options[0].title.toString());
|
|
15
|
+
const [selectedValue, setSelectedValue] = useState(options[0].value);
|
|
16
|
+
const [isPresetSelected, setIsPresetSelected] = useState(options[0].isPreset);
|
|
17
|
+
const presetValue = getPresetValue(options, selectedItem);
|
|
18
|
+
const marks = getSliderMarks(presetValue);
|
|
19
|
+
const handleChange = (event) => {
|
|
20
|
+
setSelectedItem(event.target.value);
|
|
21
|
+
setSelectedValue(options.find((option) => option.title === event.target.value)?.value);
|
|
22
|
+
setIsPresetSelected(options.find((option) => option.title === event.target.value)?.isPreset || false);
|
|
23
|
+
onChangeDropdown(event);
|
|
24
|
+
};
|
|
25
|
+
const handleSliderChange = (event, value) => {
|
|
26
|
+
setSelectedValue(value);
|
|
27
|
+
};
|
|
28
|
+
return (_jsxs(Container, { children: [_jsx(Score, { ...totalScore }), _jsx(Statistic, { ...totalCells }), statisticItems.map((item) => {
|
|
29
|
+
return (_jsx(Statistic, { ...item }, uuidV4()));
|
|
30
|
+
}), _jsx(HorizonDivider, { componentType: "divider" }), _jsx(PresentationTypography, { size: "medium", children: title }), _jsx(Dropdown, { value: selectedItem, onChange: handleChange, sx: { width: '258px' }, children: options.map((option) => {
|
|
31
|
+
return (_jsx(DropdownItem, { value: option.title, children: option.title }, option.title));
|
|
32
|
+
}) }), _jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', paddingTop: '36px', gap: '6px' }, children: [_jsx(BaseSlider, { disabled: isPresetSelected, step: controlStep, value: selectedValue, valueLabelDisplay: "on", defaultThreshold: presetValue, marks: marks, onChange: handleSliderChange, onChangeCommitted: onSliderChangeCommitted }), !isPresetSelected && (_jsx(Button, { label: "Update Configuration", sx: {
|
|
33
|
+
width: '100%',
|
|
34
|
+
} })), isPresetSelected && description?.preset && (_jsx(FreeText, { componentType: "freeText", size: "small-dimmed", content: description.preset })), !isPresetSelected && description?.user && (_jsx(FreeText, { componentType: "freeText", size: "small-dimmed", content: description.user }))] })] }));
|
|
35
|
+
};
|
|
36
|
+
export default Threshold;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseSliderProps } from './Threshold.types';
|
|
3
|
+
export declare const Container: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
4
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
5
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
6
|
+
export declare const BaseSlider: import("@emotion/styled").StyledComponent<import("@mui/material").SliderOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
7
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
8
|
+
}, "components" | "color" | "disabled" | "scale" | "size" | "style" | "classes" | "className" | "sx" | "track" | "defaultValue" | "tabIndex" | "aria-label" | "aria-labelledby" | "aria-valuetext" | "onChange" | "name" | "value" | "componentsProps" | "slotProps" | "slots" | "max" | "orientation" | "disableSwap" | "getAriaLabel" | "getAriaValueText" | "marks" | "min" | "onChangeCommitted" | "step" | "valueLabelDisplay" | "valueLabelFormat"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & BaseSliderProps, {}, {}>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Box, Slider, styled } from '@mui/material';
|
|
2
|
+
import theme from '../../theme';
|
|
3
|
+
export const Container = styled(Box)({
|
|
4
|
+
display: 'flex',
|
|
5
|
+
flexDirection: 'column',
|
|
6
|
+
gap: '12px',
|
|
7
|
+
});
|
|
8
|
+
export const BaseSlider = styled(Slider, {
|
|
9
|
+
shouldForwardProp: (prop) => prop !== 'defaultThreshold',
|
|
10
|
+
})(({ defaultThreshold, marks }) => {
|
|
11
|
+
let markIndex = 0;
|
|
12
|
+
if (Array.isArray(marks) && marks.length > 0) {
|
|
13
|
+
markIndex = marks.findIndex((mark) => mark.value === defaultThreshold);
|
|
14
|
+
}
|
|
15
|
+
const defaultThresClass = `&:nth-of-type(${markIndex + 4})`;
|
|
16
|
+
const defaultLabelClass = `&:nth-of-type(${markIndex + 5})`;
|
|
17
|
+
return {
|
|
18
|
+
'& .MuiSlider-rail': {
|
|
19
|
+
background: theme.palette.neutralGrey[75],
|
|
20
|
+
height: '8px',
|
|
21
|
+
},
|
|
22
|
+
'& .MuiSlider-track': {
|
|
23
|
+
display: 'none',
|
|
24
|
+
},
|
|
25
|
+
'& .MuiSlider-thumb': {
|
|
26
|
+
background: theme.palette.neutralGrey[0],
|
|
27
|
+
'&:hover': {
|
|
28
|
+
boxShadow: `0px 0px 0px 8px rgba(255, 0, 0, 0.2)`,
|
|
29
|
+
},
|
|
30
|
+
'&.Mui-focusVisible': {
|
|
31
|
+
boxShadow: `0px 0px 0px 8px rgba(255, 0, 0, 0.2)`,
|
|
32
|
+
},
|
|
33
|
+
'&.Mui-disabled': {
|
|
34
|
+
visibility: 'hidden',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
'& .MuiSlider-mark': {
|
|
38
|
+
background: theme.palette.neutralGrey[40],
|
|
39
|
+
height: '6px',
|
|
40
|
+
width: '6px',
|
|
41
|
+
borderRadius: '50%',
|
|
42
|
+
[defaultThresClass]: {
|
|
43
|
+
background: theme.palette.lunitTeal[40],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
'& .MuiSlider-markLabel': {
|
|
47
|
+
fontFamily: 'Pretendard,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
|
|
48
|
+
fontSize: '8px',
|
|
49
|
+
fontStyle: 'normal',
|
|
50
|
+
fontWeight: '500',
|
|
51
|
+
lineHeight: '12px',
|
|
52
|
+
[defaultLabelClass]: {
|
|
53
|
+
color: theme.palette.lunitTeal[40],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
'& .MuiSlider-valueLabel': {
|
|
57
|
+
fontFamily: 'Pretendard,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"',
|
|
58
|
+
fontSize: '12px',
|
|
59
|
+
fontWeight: '700',
|
|
60
|
+
lineHeight: '16px',
|
|
61
|
+
background: 'unset',
|
|
62
|
+
padding: 0,
|
|
63
|
+
width: 32,
|
|
64
|
+
height: 32,
|
|
65
|
+
borderRadius: '50% 50% 50% 0',
|
|
66
|
+
backgroundColor: theme.palette.lunitTeal[40],
|
|
67
|
+
transformOrigin: 'bottom left',
|
|
68
|
+
transform: 'translate(50%, -100%) rotate(-45deg) scale(0)',
|
|
69
|
+
'&:before': { display: 'none' },
|
|
70
|
+
'&.MuiSlider-valueLabelOpen': {
|
|
71
|
+
transform: 'translate(50%, -100%) rotate(-45deg) scale(1)',
|
|
72
|
+
},
|
|
73
|
+
'& > *': {
|
|
74
|
+
transform: 'rotate(45deg)',
|
|
75
|
+
},
|
|
76
|
+
'&.Mui-disabled': {
|
|
77
|
+
visibility: 'visible',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
|
2
|
+
import { SliderProps } from '@mui/material';
|
|
3
|
+
import { SelectChangeEvent } from '@mui/material/Select';
|
|
4
|
+
import { ScoreProps } from '../Score';
|
|
5
|
+
import { StatisticProps } from '../Statistic';
|
|
6
|
+
export interface ThresholdOption {
|
|
7
|
+
title: string;
|
|
8
|
+
category: string;
|
|
9
|
+
value: number;
|
|
10
|
+
isPreset?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ThresholdSpec {
|
|
13
|
+
componentType: 'threshold';
|
|
14
|
+
totalScore: ScoreProps;
|
|
15
|
+
totalCells: StatisticProps;
|
|
16
|
+
statisticItems: StatisticProps[];
|
|
17
|
+
title?: string;
|
|
18
|
+
description?: {
|
|
19
|
+
preset: string;
|
|
20
|
+
user: string;
|
|
21
|
+
};
|
|
22
|
+
options: ThresholdOption[];
|
|
23
|
+
controlStep?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ThresholdProps extends ThresholdSpec {
|
|
26
|
+
onChangeDropdown: (event: SelectChangeEvent) => void;
|
|
27
|
+
onSliderChangeCommitted: (event: Event | SyntheticEvent, value: number | number[]) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface BaseSliderProps extends SliderProps {
|
|
30
|
+
defaultThreshold: number;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ThresholdOption } from './Threshold.types';
|
|
2
|
+
export declare const baseSliderMarks: ({
|
|
3
|
+
value: number;
|
|
4
|
+
label: string;
|
|
5
|
+
} | {
|
|
6
|
+
value: number;
|
|
7
|
+
label?: undefined;
|
|
8
|
+
})[];
|
|
9
|
+
export declare const getPresetValue: (options: ThresholdOption[], selectedItem: string) => number;
|
|
10
|
+
export declare const getSliderMarks: (presetValue: number) => ({
|
|
11
|
+
value: number;
|
|
12
|
+
label: string;
|
|
13
|
+
} | {
|
|
14
|
+
value: number;
|
|
15
|
+
label?: undefined;
|
|
16
|
+
})[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const baseSliderMarks = [
|
|
2
|
+
{ value: 0, label: '0' },
|
|
3
|
+
{ value: 10 },
|
|
4
|
+
{ value: 20 },
|
|
5
|
+
{ value: 30 },
|
|
6
|
+
{ value: 40 },
|
|
7
|
+
{ value: 50 },
|
|
8
|
+
{ value: 60 },
|
|
9
|
+
{ value: 70 },
|
|
10
|
+
{ value: 80 },
|
|
11
|
+
{ value: 90 },
|
|
12
|
+
{ value: 100, label: '100' },
|
|
13
|
+
];
|
|
14
|
+
export const getPresetValue = (options, selectedItem) => {
|
|
15
|
+
const selectedCategory = options.find((option) => option.title === selectedItem)?.category;
|
|
16
|
+
const presetValue = options.find((option) => option.category === selectedCategory && option.isPreset)?.value;
|
|
17
|
+
return presetValue;
|
|
18
|
+
};
|
|
19
|
+
export const getSliderMarks = (presetValue) => {
|
|
20
|
+
const marks = baseSliderMarks.map((mark) => {
|
|
21
|
+
if (mark.value === presetValue) {
|
|
22
|
+
return {
|
|
23
|
+
...mark,
|
|
24
|
+
label: `Preset: ${presetValue}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return mark;
|
|
28
|
+
});
|
|
29
|
+
if (!baseSliderMarks.find((mark) => mark.value === presetValue)) {
|
|
30
|
+
const index = Math.floor(presetValue / 10);
|
|
31
|
+
marks.splice(index + 1, 0, { value: presetValue, label: `Preset: ${presetValue}` });
|
|
32
|
+
}
|
|
33
|
+
return marks;
|
|
34
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ToggleControlProps } from './ToggleControl.types';
|
|
2
|
-
declare const ToggleControl: ({ componentType, title, size, symbol, tooltip, color, isParent, disabled, bar, checked, isDimmed, onChange, }: ToggleControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const ToggleControl: ({ componentType, title, size, symbol, tooltip, content, color, isParent, disabled, bar, checked, isDimmed, onChange, }: ToggleControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default ToggleControl;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { v4 as uuidV4 } from 'uuid';
|
|
3
4
|
import { Box } from '@mui/material';
|
|
4
5
|
import { ToggleControlContainer, ToggleControlOuter } from './ToggleControl.styled';
|
|
@@ -9,14 +10,15 @@ import { FreeText } from '../FreeText';
|
|
|
9
10
|
import { Statistic } from '../Statistic';
|
|
10
11
|
import { Tooltip } from '../../components';
|
|
11
12
|
import { Information } from '../../icons';
|
|
12
|
-
|
|
13
|
-
const
|
|
13
|
+
const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbol, tooltip = [], content = [], color, isParent = false, disabled = false, bar, checked, isDimmed = false, onChange, }) => {
|
|
14
|
+
const [isChecked, setIsChecked] = useState(checked);
|
|
14
15
|
const handleChange = (event) => {
|
|
16
|
+
setIsChecked(event.target.checked);
|
|
15
17
|
onChange && onChange(event);
|
|
16
18
|
};
|
|
17
19
|
return (_jsxs(ToggleControlOuter, { "data-toggle-name": `toggle-control-${title?.replace(/\s/g, '-')}`, hasBar: !!bar, 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: {
|
|
18
20
|
display: 'flex',
|
|
19
21
|
alignItems: 'center',
|
|
20
|
-
}, children: _jsx(Information, {}) }) })), symbol && (_jsx(PresentationSymbolIcon, { symbol: symbol, color: color, isDimmed: isDimmed || !checked })), _jsx(PresentationTypography, { size: size,
|
|
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, checked: isChecked, onChange: handleChange })] }), content.length > 0 && (_jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: content.map((item) => (_jsx(Statistic, { ...item, isDimmed: isDimmed || !checked }))) }, 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 }) }))] }));
|
|
21
23
|
};
|
|
22
24
|
export default ToggleControl;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Box, styled } from '@mui/material';
|
|
2
2
|
const getPadding = (size) => {
|
|
3
3
|
if (size === 'large-bold') {
|
|
4
|
-
return '14px
|
|
4
|
+
return '14px 0';
|
|
5
5
|
}
|
|
6
|
-
return '
|
|
6
|
+
return '2px';
|
|
7
7
|
};
|
|
8
8
|
export const ToggleControlOuter = styled(Box, { shouldForwardProp: (prop) => prop !== 'hasBar' })(({ hasBar }) => ({
|
|
9
9
|
display: 'flex',
|
|
@@ -20,7 +20,6 @@ export const ToggleControlContainer = styled(Box, {
|
|
|
20
20
|
width: '100%',
|
|
21
21
|
display: 'flex',
|
|
22
22
|
justifyContent: 'space-between',
|
|
23
|
-
gap: '34px',
|
|
24
23
|
padding: getPadding(size),
|
|
25
24
|
alignItems: 'center',
|
|
26
25
|
};
|
|
@@ -9,8 +9,9 @@ export interface ToggleControlSpec {
|
|
|
9
9
|
size?: PresentationElementSize;
|
|
10
10
|
symbol?: PresentationSymbol;
|
|
11
11
|
color?: string;
|
|
12
|
-
checked
|
|
12
|
+
checked?: boolean;
|
|
13
13
|
tooltip?: (StatisticProps | FreeTextProps)[];
|
|
14
|
+
content?: StatisticProps[];
|
|
14
15
|
bar?: AnalysisBarProps;
|
|
15
16
|
}
|
|
16
17
|
export interface ToggleControlProps extends ToggleControlSpec {
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
3
|
import { v4 as uuidV4 } from 'uuid';
|
|
4
4
|
import { filter as _filter } from 'lodash';
|
|
5
5
|
import { ToggleControlGroupContainer } from './ToggleControlGroup.styled';
|
|
6
6
|
import ToggleControl from '../ToggleControl/ToggleControl';
|
|
7
|
-
const ToggleControlGroup = ({ componentType = 'toggleGroup', size = 'medium', title, tooltip = [], bar, childToggles, disabled, checked, behavior = 'multi', onChange, }) => {
|
|
7
|
+
const ToggleControlGroup = ({ componentType = 'toggleGroup', size = 'medium', title, tooltip = [], bar, childToggles, disabled, checked = true, behavior = 'multi', onChange, }) => {
|
|
8
8
|
const [toggleChecked, setToggleChecked] = useState(checked || _filter(childToggles, (child) => child.checked).length > 0);
|
|
9
9
|
const [childrenChecked, setChildrenChecked] = useState(childToggles?.map((child) => child.checked) || []);
|
|
10
10
|
const handleToggleChange = (event) => {
|
|
11
11
|
setToggleChecked(!toggleChecked);
|
|
12
|
+
if (!_filter(childrenChecked, (child) => child).length) {
|
|
13
|
+
if (behavior === 'multi' && event.target.checked) {
|
|
14
|
+
setChildrenChecked(Array(childToggles.length).fill(true));
|
|
15
|
+
}
|
|
16
|
+
else if (behavior === 'exclusive' && event.target.checked) {
|
|
17
|
+
const newState = Array(childrenChecked.length).fill(false);
|
|
18
|
+
newState[0] = true;
|
|
19
|
+
setChildrenChecked(newState);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
12
22
|
onChange(event);
|
|
13
23
|
};
|
|
14
24
|
const handleMultiChange = (index) => {
|
|
@@ -22,6 +32,22 @@ const ToggleControlGroup = ({ componentType = 'toggleGroup', size = 'medium', ti
|
|
|
22
32
|
newState[index] = event.target.checked;
|
|
23
33
|
setChildrenChecked(newState);
|
|
24
34
|
};
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (behavior === 'exclusive') {
|
|
37
|
+
const newState = Array(childrenChecked.length).fill(false);
|
|
38
|
+
newState[0] = true;
|
|
39
|
+
setChildrenChecked(newState);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const childChecked = Array(childToggles.length).fill(true);
|
|
43
|
+
childToggles.forEach((child, index) => {
|
|
44
|
+
if (child.checked === false) {
|
|
45
|
+
childChecked[index] = false;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
setChildrenChecked(childChecked);
|
|
49
|
+
}
|
|
50
|
+
}, [behavior, childToggles, childrenChecked.length]);
|
|
25
51
|
return (_jsxs(ToggleControlGroupContainer, { children: [_jsx(ToggleControl, { isParent: true, componentType: "toggle", bar: bar, disabled: disabled, size: size, title: title, tooltip: tooltip, checked: toggleChecked, onChange: handleToggleChange }), childToggles?.map((child, index) => {
|
|
26
52
|
return (_jsx(ToggleControl, { componentType: "toggle", title: child.title, size: size, tooltip: child.tooltip, symbol: child.symbol, color: child.color, isDimmed: !toggleChecked, checked: childrenChecked[index], disabled: !toggleChecked, onChange: (event) => {
|
|
27
53
|
behavior === 'multi' ? handleMultiChange(index) : handleExclusiveChange(index, event);
|
|
@@ -12,7 +12,7 @@ export interface ToggleGroupControlSpec {
|
|
|
12
12
|
size?: PresentationElementSize;
|
|
13
13
|
tooltip?: (StatisticProps | FreeTextProps)[];
|
|
14
14
|
bar?: AnalysisBarProps;
|
|
15
|
-
checked
|
|
15
|
+
checked?: boolean;
|
|
16
16
|
childToggles: ToggleControlProps[];
|
|
17
17
|
}
|
|
18
18
|
export interface ToggleControlGroupProps extends ToggleGroupControlSpec {
|
|
@@ -3,7 +3,9 @@ export * from './AnalysisBar';
|
|
|
3
3
|
export * from './FreeText';
|
|
4
4
|
export * from './Histogram';
|
|
5
5
|
export * from './HorizonDivider';
|
|
6
|
+
export * from './Preview';
|
|
6
7
|
export * from './Score';
|
|
7
8
|
export * from './Statistic';
|
|
9
|
+
export * from './Threshold';
|
|
8
10
|
export * from './ToggleControl';
|
|
9
11
|
export * from './ToggleControlGroup';
|
|
@@ -3,7 +3,9 @@ export * from './AnalysisBar';
|
|
|
3
3
|
export * from './FreeText';
|
|
4
4
|
export * from './Histogram';
|
|
5
5
|
export * from './HorizonDivider';
|
|
6
|
+
export * from './Preview';
|
|
6
7
|
export * from './Score';
|
|
7
8
|
export * from './Statistic';
|
|
9
|
+
export * from './Threshold';
|
|
8
10
|
export * from './ToggleControl';
|
|
9
11
|
export * from './ToggleControlGroup';
|
|
@@ -2,24 +2,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Typography } from '@mui/material';
|
|
3
3
|
import theme from '../theme';
|
|
4
4
|
export const PresentationTypography = (props) => {
|
|
5
|
-
const { size, ...rest } = props;
|
|
5
|
+
const { size, isDimmed, ...rest } = props;
|
|
6
6
|
if (size === 'small-dimmed') {
|
|
7
|
-
return (_jsx(Typography, { variant: "body_m2", sx: { color: theme.palette.neutralGrey[40] }
|
|
7
|
+
return (_jsx(Typography, { variant: "body_m2", ...rest, sx: { color: theme.palette.neutralGrey[40] } }));
|
|
8
8
|
}
|
|
9
9
|
if (size === 'small') {
|
|
10
|
-
return (_jsx(Typography, { variant: "body8", ...rest }));
|
|
10
|
+
return (_jsx(Typography, { variant: "body8", ...rest, sx: { color: isDimmed ? theme.palette.neutralGrey[40] : 'inherit' } }));
|
|
11
11
|
}
|
|
12
12
|
if (size === 'small-bold') {
|
|
13
|
-
return (_jsx(Typography, { variant: "body8", sx: { fontWeight: 'bold'
|
|
13
|
+
return (_jsx(Typography, { variant: "body8", ...rest, sx: { fontWeight: 'bold', color: isDimmed ? theme.palette.neutralGrey[40] : 'inherit' } }));
|
|
14
14
|
}
|
|
15
15
|
if (size === 'medium') {
|
|
16
|
-
return (_jsx(Typography, { variant: "body5", ...rest }));
|
|
16
|
+
return (_jsx(Typography, { variant: "body5", ...rest, sx: { color: isDimmed ? theme.palette.neutralGrey[40] : 'inherit' } }));
|
|
17
17
|
}
|
|
18
18
|
if (size === 'medium-bold') {
|
|
19
|
-
return (_jsx(Typography, { variant: "body_b1", ...rest }));
|
|
19
|
+
return (_jsx(Typography, { variant: "body_b1", ...rest, sx: { color: isDimmed ? theme.palette.neutralGrey[40] : 'inherit' } }));
|
|
20
20
|
}
|
|
21
21
|
if (size === 'large-bold') {
|
|
22
|
-
return (_jsx(Typography, { variant: "h9", ...rest }));
|
|
22
|
+
return (_jsx(Typography, { variant: "h9", ...rest, sx: { color: isDimmed ? theme.palette.neutralGrey[40] : 'inherit' } }));
|
|
23
23
|
}
|
|
24
24
|
return _jsx(Typography, { ...rest });
|
|
25
25
|
};
|
|
@@ -8,5 +8,7 @@ interface PresentationSymbolProps {
|
|
|
8
8
|
}
|
|
9
9
|
interface PresentationTypographyProps extends TypographyProps {
|
|
10
10
|
size?: PresentationElementSize;
|
|
11
|
+
isDimmed?: boolean;
|
|
12
|
+
display?: 'block' | 'inline-block' | 'flex' | 'inherit';
|
|
11
13
|
}
|
|
12
14
|
export type { PresentationSymbolProps, PresentationTypographyProps };
|
package/package.json
CHANGED