@lunit/oui 2.0.1 → 2.1.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 (26) hide show
  1. package/dist/components/Dropdown/Dropdown.styled.js +1 -0
  2. package/dist/presentations/FreeText/FreeText.js +2 -1
  3. package/dist/presentations/Statistic/Statistic.d.ts +1 -1
  4. package/dist/presentations/Statistic/Statistic.js +2 -2
  5. package/dist/presentations/Statistic/Statistic.types.d.ts +5 -1
  6. package/dist/presentations/Statistic/index.d.ts +2 -2
  7. package/dist/presentations/Threshold/Threshold.d.ts +3 -0
  8. package/dist/presentations/Threshold/Threshold.js +36 -0
  9. package/dist/presentations/Threshold/Threshold.styled.d.ts +8 -0
  10. package/dist/presentations/Threshold/Threshold.styled.js +81 -0
  11. package/dist/presentations/Threshold/Threshold.types.d.ts +30 -0
  12. package/dist/presentations/Threshold/Threshold.types.js +1 -0
  13. package/dist/presentations/Threshold/Threshold.utils.d.ts +16 -0
  14. package/dist/presentations/Threshold/Threshold.utils.js +34 -0
  15. package/dist/presentations/Threshold/index.d.ts +4 -0
  16. package/dist/presentations/Threshold/index.js +2 -0
  17. package/dist/presentations/ToggleControl/ToggleControl.d.ts +1 -1
  18. package/dist/presentations/ToggleControl/ToggleControl.js +2 -3
  19. package/dist/presentations/ToggleControl/ToggleControl.types.d.ts +2 -1
  20. package/dist/presentations/ToggleControlGroup/ToggleControlGroup.js +22 -2
  21. package/dist/presentations/ToggleControlGroup/ToggleControlGroup.types.d.ts +1 -1
  22. package/dist/presentations/index.d.ts +1 -0
  23. package/dist/presentations/index.js +1 -0
  24. package/dist/presentations/presentations.styled.js +7 -7
  25. package/dist/presentations/presentations.types.d.ts +2 -0
  26. 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,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: 'flex',
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 { 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 StatisticProps extends BoxProps {
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, 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, 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 }), 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,30 @@
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
+ statisticItems: StatisticProps[];
16
+ title?: string;
17
+ description?: {
18
+ preset: string;
19
+ user: string;
20
+ };
21
+ options: ThresholdOption[];
22
+ controlStep?: number;
23
+ }
24
+ export interface ThresholdProps extends ThresholdSpec {
25
+ onChangeDropdown: (event: SelectChangeEvent) => void;
26
+ onSliderChangeCommitted: (event: Event | SyntheticEvent, value: number | number[]) => void;
27
+ }
28
+ export interface BaseSliderProps extends SliderProps {
29
+ defaultThreshold: number;
30
+ }
@@ -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
+ };
@@ -0,0 +1,4 @@
1
+ import Threshold from './Threshold';
2
+ import type { ThresholdProps } from './Threshold.types';
3
+ export { Threshold };
4
+ export type { ThresholdProps };
@@ -0,0 +1,2 @@
1
+ import Threshold from './Threshold';
2
+ export { Threshold };
@@ -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;
@@ -9,14 +9,13 @@ import { FreeText } from '../FreeText';
9
9
  import { Statistic } from '../Statistic';
10
10
  import { Tooltip } from '../../components';
11
11
  import { Information } from '../../icons';
12
- import theme from '../../theme';
13
- const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbol, tooltip = [], color, isParent = false, disabled = false, bar, checked, isDimmed = false, onChange, }) => {
12
+ const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbol, tooltip = [], content = [], color, isParent = false, disabled = false, bar, checked, isDimmed = false, onChange, }) => {
14
13
  const handleChange = (event) => {
15
14
  onChange && onChange(event);
16
15
  };
17
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: {
18
17
  display: 'flex',
19
18
  alignItems: 'center',
20
- }, children: _jsx(Information, {}) }) })), symbol && (_jsx(PresentationSymbolIcon, { symbol: symbol, color: color, isDimmed: isDimmed || !checked })), _jsx(PresentationTypography, { size: size, sx: { color: checked && !isDimmed ? 'inherit' : theme.palette.neutralGrey[65] }, children: title })] }), _jsx(StyledToggle, { disabled: disabled, checked: checked, onChange: handleChange })] }), 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 }) }))] }));
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 }) }))] }));
21
20
  };
22
21
  export default ToggleControl;
@@ -9,8 +9,9 @@ export interface ToggleControlSpec {
9
9
  size?: PresentationElementSize;
10
10
  symbol?: PresentationSymbol;
11
11
  color?: string;
12
- checked: boolean;
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,16 @@ 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
+ setChildrenChecked(Array(childToggles.length).fill(true));
43
+ }
44
+ }, [behavior, childToggles, childrenChecked.length]);
25
45
  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
46
  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
47
  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: boolean;
15
+ checked?: boolean;
16
16
  childToggles: ToggleControlProps[];
17
17
  }
18
18
  export interface ToggleControlGroupProps extends ToggleGroupControlSpec {
@@ -5,5 +5,6 @@ export * from './Histogram';
5
5
  export * from './HorizonDivider';
6
6
  export * from './Score';
7
7
  export * from './Statistic';
8
+ export * from './Threshold';
8
9
  export * from './ToggleControl';
9
10
  export * from './ToggleControlGroup';
@@ -5,5 +5,6 @@ export * from './Histogram';
5
5
  export * from './HorizonDivider';
6
6
  export * from './Score';
7
7
  export * from './Statistic';
8
+ export * from './Threshold';
8
9
  export * from './ToggleControl';
9
10
  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] }, ...rest }));
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' }, ...rest }));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunit/oui",
3
- "version": "2.0.1",
3
+ "version": "2.1.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)"