@lunit/oui 2.1.1 → 2.2.1

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.
Files changed (31) hide show
  1. package/dist/components/Tooltip/Tooltip.utils.js +1 -1
  2. package/dist/presentations/Accordion/Accordion.js +2 -2
  3. package/dist/presentations/Accordion/index.d.ts +2 -0
  4. package/dist/presentations/AnalysisBar/AnalysisBar.js +6 -5
  5. package/dist/presentations/AnalysisBar/AnalysisBar.styled.d.ts +2 -1
  6. package/dist/presentations/AnalysisBar/AnalysisBar.styled.js +7 -5
  7. package/dist/presentations/AnalysisBar/AnalysisBar.types.d.ts +1 -1
  8. package/dist/presentations/Histogram/Histogram.d.ts +1 -1
  9. package/dist/presentations/Histogram/Histogram.js +6 -3
  10. package/dist/presentations/Histogram/Histogram.styled.d.ts +3 -0
  11. package/dist/presentations/Histogram/Histogram.styled.js +5 -0
  12. package/dist/presentations/Histogram/Histogram.types.d.ts +2 -0
  13. package/dist/presentations/Preview/Preview.d.ts +3 -0
  14. package/dist/presentations/Preview/Preview.js +18 -0
  15. package/dist/presentations/Preview/Preview.styled.d.ts +4 -0
  16. package/dist/presentations/Preview/Preview.styled.js +9 -0
  17. package/dist/presentations/Preview/Preview.types.d.ts +14 -0
  18. package/dist/presentations/Preview/Preview.types.js +1 -0
  19. package/dist/presentations/Preview/index.d.ts +4 -0
  20. package/dist/presentations/Preview/index.js +2 -0
  21. package/dist/presentations/Threshold/Threshold.d.ts +1 -1
  22. package/dist/presentations/Threshold/Threshold.js +2 -2
  23. package/dist/presentations/Threshold/Threshold.types.d.ts +1 -0
  24. package/dist/presentations/ToggleControl/ToggleControl.js +6 -3
  25. package/dist/presentations/ToggleControl/ToggleControl.styled.js +2 -3
  26. package/dist/presentations/ToggleControl/ToggleControl.types.d.ts +31 -0
  27. package/dist/presentations/ToggleControlGroup/ToggleControlGroup.js +8 -2
  28. package/dist/presentations/ToggleControlGroup/index.d.ts +2 -0
  29. package/dist/presentations/index.d.ts +1 -0
  30. package/dist/presentations/index.js +1 -0
  31. package/package.json +1 -1
@@ -25,5 +25,5 @@ export const setMarginByPlacement = (tooltipPlacement, margin) => ({
25
25
  })[tooltipPlacement];
26
26
  export const setPaddingBySize = (tooltipSize) => ({
27
27
  small: '6px 8px',
28
- large: '12px 16px',
28
+ large: '16px',
29
29
  })[tooltipSize];
@@ -10,11 +10,11 @@ import { FreeText } from '../FreeText';
10
10
  import { Statistic } from '../Statistic';
11
11
  import { Score } from '../Score';
12
12
  const Accordion = ({ componentType = 'accordion', MuiAccordionProps, AccordionDetailsProps, AccordionSummaryProps, size = 'medium', tooltip = [], title, items, metrics, isOpen, onChange, }) => {
13
- return (_jsxs(BaseAccordion, { ...MuiAccordionProps, expanded: isOpen, onChange: onChange, sx: { alignItems: 'center' }, children: [_jsxs(BaseAccordionSummary, { expandIcon: _jsx(ArrowDown, { sx: { fill: theme.palette.neutralGrey[40] } }), ...AccordionSummaryProps, 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: {
13
+ return (_jsxs(BaseAccordion, { ...MuiAccordionProps, expanded: isOpen, onChange: onChange, sx: { alignItems: 'center' }, children: [_jsxs(BaseAccordionSummary, { expandIcon: _jsx(ArrowDown, { sx: { fill: theme.palette.neutralGrey[40] } }), ...AccordionSummaryProps, children: [!!tooltip.length && (_jsx(Tooltip, { arrow: true, size: "large", onClick: (event) => event.stopPropagation(), title: _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '8px' }, onClick: (event) => event.stopPropagation(), 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: {
14
14
  marginRight: size.includes('small') ? '4px' : '6px',
15
15
  display: 'flex',
16
16
  alignItems: 'center',
17
- }, children: _jsx(Information, {}) }) })), _jsx(PresentationTypography, { size: size, children: title }), metrics && (_jsx(PresentationTypography, { size: size, children: _jsxs(Box, { sx: { marginLeft: '4px' }, children: [": ", metrics] }) }))] }), _jsx(BaseAccordionDetails, { ...AccordionDetailsProps, sx: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: items.map((item) => {
17
+ }, children: _jsx(Information, {}) }) })), _jsx(PresentationTypography, { size: size, children: title }), metrics && (_jsx(PresentationTypography, { size: size, children: _jsxs(Box, { sx: { marginLeft: '4px' }, children: [": ", metrics] }) }))] }), _jsx(BaseAccordionDetails, { ...AccordionDetailsProps, sx: { display: 'flex', flexDirection: 'column', gap: '14px' }, children: items.map((item) => {
18
18
  return (_jsxs(_Fragment, { children: [item.componentType === 'statistic' && _jsx(Statistic, { ...item }), item.componentType === 'freeText' && _jsx(FreeText, { ...item }), item.componentType === 'score' && _jsx(Score, { ...item })] }));
19
19
  }) })] }));
20
20
  };
@@ -1,2 +1,4 @@
1
1
  import Accordion from './Accordion';
2
+ import { AccordionProps } from './Accordion.types';
2
3
  export { Accordion };
4
+ export type { AccordionProps };
@@ -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: '12px', transform: 'scaleY(0.8) translateY(-10px)' }, children: _jsx(HeatmapGraphSVG, { width: 'auto', height: 'auto' }) }));
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') {
@@ -17,10 +17,11 @@ const Segments = ({ segments, adjustForOnePercent }) => {
17
17
  return (_jsx(GraphSegment, { color: segment.color, width: adjustForOnePercent ? adjustBarSegmentWidth(segment.width) : segment.width }, i));
18
18
  }) }));
19
19
  };
20
- const AnalysisBar = ({ componentType = 'analysisBar', expressionValue, caption, expressionLevels, segments, isDimmed = false, }) => {
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) => {
23
- return (_jsx(GraphAxisLabel, { label: val, adjustForOnePercent: hasAdjustedOnePercentSegment, leftPos: parseStringValToNumber(val) }, i));
24
- }), caption && (_jsx(GraphAxisLabel, { label: caption, adjustForOnePercent: hasAdjustedOnePercentSegment, leftPos: 50 }))] })] }));
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 })] }), (expressionLevels.length > 0 || caption) && (_jsxs(AxisLabels, { children: [expressionLevels.length > 0 &&
23
+ expressionLevels.map((val, i) => {
24
+ return (_jsx(GraphAxisLabel, { label: val, adjustForOnePercent: hasAdjustedOnePercentSegment, leftPos: parseStringValToNumber(val) }, i));
25
+ }), caption && (_jsx(GraphAxisLabel, { label: caption, adjustForOnePercent: hasAdjustedOnePercentSegment, leftPos: 50 }))] }))] }));
25
26
  };
26
27
  export default AnalysisBar;
@@ -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,15 +40,15 @@ 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%)',
49
- }, children: [_jsx(Typography, { variant: "small_body_sb1", sx: { textAlign: 'center' }, children: value }), _jsx(GraphScoreIndicatorPip, {})] }));
50
+ transform: isJet ? 'translateX(-50%) translateY(8px)' : 'translateX(-50%)',
51
+ }, isJet: isJet, children: [_jsx(Typography, { variant: "small_body_sb1", sx: { textAlign: 'center' }, children: value }), _jsx(GraphScoreIndicatorPip, {})] }));
50
52
  };
51
53
  const GraphAxisLabelContainer = styled('span')(() => {
52
54
  return {
@@ -1,6 +1,6 @@
1
1
  export interface AnalysisBarProps {
2
2
  componentType: 'analysisBar';
3
- expressionLevels: string[];
3
+ expressionLevels?: string[];
4
4
  caption?: string;
5
5
  segments?: {
6
6
  color: 'jet' | string;
@@ -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
- const Histogram = ({ componentType = 'histogram', title, xAxisLabels, yAxisLabels, tabs, }) => {
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,3 @@
1
+ import { PreviewProps } from './Preview.types';
2
+ declare const Preview: ({ visualizationControls, analysisSummary }: PreviewProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default Preview;
@@ -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: "medium-bold", content: "Analysis Summary" }), analysisSummary.map((item) => (_jsxs(Box, { children: [item.componentType === 'accordion' && (_jsx(Accordion, { ...item }, uuidV4())), item.componentType === 'analysisBar' && (_jsx(AnalysisBar, { ...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,9 @@
1
+ import { Box, 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
+ width: '290px',
8
+ backgroundColor: theme.palette.neutralGrey[95],
9
+ });
@@ -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 | AnalysisBarProps | StatisticProps | ScoreProps | FreeTextProps | ThresholdProps | HistogramProps)[];
13
+ }
14
+ export type { PreviewProps };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import Preview from './Preview';
2
+ import { PreviewProps } from './Preview.types';
3
+ export { Preview };
4
+ export type { PreviewProps };
@@ -0,0 +1,2 @@
1
+ import Preview from './Preview';
2
+ export { Preview };
@@ -1,3 +1,3 @@
1
1
  import { ThresholdProps } from './Threshold.types';
2
- declare const Threshold: ({ componentType, title, totalScore, statisticItems, options, description, controlStep, onChangeDropdown, onSliderChangeCommitted, }: ThresholdProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const Threshold: ({ componentType, title, totalScore, totalCells, statisticItems, options, description, controlStep, onChangeDropdown, onSliderChangeCommitted, }: ThresholdProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default Threshold;
@@ -10,7 +10,7 @@ import { Button, Dropdown, DropdownItem } from '../../components';
10
10
  import { HorizonDivider } from '../HorizonDivider';
11
11
  import { FreeText } from '../FreeText';
12
12
  import { getPresetValue, getSliderMarks } from './Threshold.utils';
13
- const Threshold = ({ componentType = 'threshold', title, totalScore, statisticItems, options, description, controlStep = 1, onChangeDropdown, onSliderChangeCommitted, }) => {
13
+ const Threshold = ({ componentType = 'threshold', title, totalScore, totalCells, statisticItems, options, description, controlStep = 1, onChangeDropdown, onSliderChangeCommitted, }) => {
14
14
  const [selectedItem, setSelectedItem] = useState(options[0].title.toString());
15
15
  const [selectedValue, setSelectedValue] = useState(options[0].value);
16
16
  const [isPresetSelected, setIsPresetSelected] = useState(options[0].isPreset);
@@ -25,7 +25,7 @@ const Threshold = ({ componentType = 'threshold', title, totalScore, statisticIt
25
25
  const handleSliderChange = (event, value) => {
26
26
  setSelectedValue(value);
27
27
  };
28
- return (_jsxs(Container, { children: [_jsx(Score, { ...totalScore }), statisticItems.map((item) => {
28
+ return (_jsxs(Container, { children: [_jsx(Score, { ...totalScore }), _jsx(Statistic, { ...totalCells }), statisticItems.map((item) => {
29
29
  return (_jsx(Statistic, { ...item }, uuidV4()));
30
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
31
  return (_jsx(DropdownItem, { value: option.title, children: option.title }, option.title));
@@ -12,6 +12,7 @@ export interface ThresholdOption {
12
12
  export interface ThresholdSpec {
13
13
  componentType: 'threshold';
14
14
  totalScore: ScoreProps;
15
+ totalCells: StatisticProps;
15
16
  statisticItems: StatisticProps[];
16
17
  title?: string;
17
18
  description?: {
@@ -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,13 +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
- const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbol, tooltip = [], content = [], color, isParent = false, disabled = false, bar, checked, isDimmed = false, onChange, }) => {
13
+ const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbol, tooltip = [], content = [], color, isParent = false, disabled = false, bar, checked = true, isDimmed = false, onChange, }) => {
14
+ const [isChecked, setIsChecked] = useState(checked);
13
15
  const handleChange = (event) => {
16
+ setIsChecked(event.target.checked);
14
17
  onChange && onChange(event);
15
18
  };
16
- 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: {
19
+ 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: {
17
20
  display: 'flex',
18
21
  alignItems: 'center',
19
- }, 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: checked, 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: { paddingRight: '16px' }, children: _jsx(AnalysisBar, { isDimmed: isDimmed || !checked, componentType: bar.componentType, expressionValue: bar.expressionValue, expressionLevels: bar.expressionLevels, caption: bar.caption, segments: bar.segments }) }))] }));
22
+ }, children: _jsx(Information, {}) }) })), symbol && (_jsx(PresentationSymbolIcon, { symbol: symbol, color: color, isDimmed: isDimmed || !isChecked })), _jsx(PresentationTypography, { size: size, isDimmed: isDimmed || !isChecked, 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 || !isChecked }))) }, uuidV4())), bar && (_jsx(Box, { sx: { padding: '0 8px', fontSize: '14px', lineHeight: '8px' }, children: _jsx(AnalysisBar, { isDimmed: isDimmed || !isChecked, componentType: bar.componentType, expressionValue: bar.expressionValue, expressionLevels: bar.expressionLevels, caption: bar.caption, segments: bar.segments }) }))] }));
20
23
  };
21
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 16px 14px 0';
4
+ return '14px 0';
5
5
  }
6
- return '0 16px 0 0';
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
  };
@@ -14,9 +14,40 @@ export interface ToggleControlSpec {
14
14
  content?: StatisticProps[];
15
15
  bar?: AnalysisBarProps;
16
16
  }
17
+ interface PixelAnnotationSpec {
18
+ url: string;
19
+ bbox: number[];
20
+ mpp: {
21
+ x: number;
22
+ y: number;
23
+ };
24
+ }
25
+ interface CellAnnotationSpec {
26
+ name: string;
27
+ }
28
+ interface GridAnnotationSpec {
29
+ name: string;
30
+ }
31
+ interface CutOffLabelProps {
32
+ color: string;
33
+ labelIndex: number;
34
+ }
35
+ interface TargetSpec {
36
+ visualizationType: string;
37
+ annotationId?: string;
38
+ annotation: PixelAnnotationSpec | CellAnnotationSpec | GridAnnotationSpec | string;
39
+ label?: string;
40
+ labelId?: string;
41
+ labels?: (string | CutOffLabelProps)[];
42
+ color?: string;
43
+ colors?: string[];
44
+ }
17
45
  export interface ToggleControlProps extends ToggleControlSpec {
18
46
  isParent?: boolean;
19
47
  isDimmed?: boolean;
20
48
  disabled?: boolean;
49
+ target?: TargetSpec;
50
+ isMaster?: boolean;
21
51
  onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
22
52
  }
53
+ export {};
@@ -39,14 +39,20 @@ const ToggleControlGroup = ({ componentType = 'toggleGroup', size = 'medium', ti
39
39
  setChildrenChecked(newState);
40
40
  }
41
41
  else {
42
- setChildrenChecked(Array(childToggles.length).fill(true));
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);
43
49
  }
44
50
  }, [behavior, childToggles, childrenChecked.length]);
45
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) => {
46
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) => {
47
53
  behavior === 'multi' ? handleMultiChange(index) : handleExclusiveChange(index, event);
48
54
  child.onChange(event);
49
- } }, uuidV4()));
55
+ }, bar: child.bar }, uuidV4()));
50
56
  })] }));
51
57
  };
52
58
  export default ToggleControlGroup;
@@ -1,2 +1,4 @@
1
1
  import ToggleControlGroup from './ToggleControlGroup';
2
+ import type { ToggleControlGroupProps } from './ToggleControlGroup.types';
2
3
  export { ToggleControlGroup };
4
+ export type { ToggleControlGroupProps };
@@ -3,6 +3,7 @@ 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';
8
9
  export * from './Threshold';
@@ -3,6 +3,7 @@ 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';
8
9
  export * from './Threshold';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunit/oui",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
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)"