@lunit/oui 2.2.1 → 2.2.3

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.
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { v4 as uuidV4 } from 'uuid';
3
3
  import { Box } from '@mui/material';
4
4
  import theme from '../../theme';
@@ -15,7 +15,7 @@ const Accordion = ({ componentType = 'accordion', MuiAccordionProps, AccordionDe
15
15
  display: 'flex',
16
16
  alignItems: 'center',
17
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
- return (_jsxs(_Fragment, { children: [item.componentType === 'statistic' && _jsx(Statistic, { ...item }), item.componentType === 'freeText' && _jsx(FreeText, { ...item }), item.componentType === 'score' && _jsx(Score, { ...item })] }));
18
+ return (_jsxs("div", { children: [item.componentType === 'statistic' && _jsx(Statistic, { ...item }), item.componentType === 'freeText' && _jsx(FreeText, { ...item }), item.componentType === 'score' && _jsx(Score, { ...item })] }, uuidV4()));
19
19
  }) })] }));
20
20
  };
21
21
  export default Accordion;
@@ -8,11 +8,11 @@ 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: '14px', transform: 'scaleY(0.8)' }, children: _jsx(HeatmapGraphSVG, { width: 'auto', height: 'auto' }) }));
11
+ return (_jsx(Box, { sx: { width: '100%', height: '14px', transform: 'scaleY(0.8)' }, children: _jsx(HeatmapGraphSVG, {}) }));
12
12
  }
13
13
  return (_jsx(_Fragment, { children: segments?.map((segment, i) => {
14
14
  if (segment.color === 'jet') {
15
- return (_jsx(HeatmapGraphSVG, { width: `${segment.width}%`, height: 'auto' }));
15
+ return _jsx(HeatmapGraphSVG, { width: `${segment.width}%` });
16
16
  }
17
17
  return (_jsx(GraphSegment, { color: segment.color, width: adjustForOnePercent ? adjustBarSegmentWidth(segment.width) : segment.width }, i));
18
18
  }) }));
@@ -1,3 +1,3 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- const HeatmapGraphSVG = (props) => (_jsxs("svg", { width: "234", height: "8", viewBox: "0 0 234 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [_jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M1.30733e-07 4C5.85312e-08 1.79086 1.79086 5.86502e-08 4 1.30999e-07L230 7.53243e-06C232.209 7.60478e-06 234 1.79087 234 4.00001C234 6.20915 232.209 8.00001 230 8.00001L4 8C1.79086 8 2.02935e-07 6.20914 1.30733e-07 4Z", fill: "url(#paint0_linear_4060_316245)" }), _jsx("defs", { children: _jsxs("linearGradient", { id: "paint0_linear_4060_316245", x1: "-0.585003", y1: "5.99984", x2: "228.159", y2: "4.97311", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { stopColor: "#3000FF" }), _jsx("stop", { offset: "0.239583", stopColor: "#5CFFE2" }), _jsx("stop", { offset: "0.447917", stopColor: "#E2FFA4" }), _jsx("stop", { offset: "0.546875", stopColor: "#FCFF75" }), _jsx("stop", { offset: "0.78125", stopColor: "#FDBA73" }), _jsx("stop", { offset: "1", stopColor: "#FF0F00" })] }) })] }));
2
+ const HeatmapGraphSVG = (props) => (_jsxs("svg", { width: "100%", height: "100%", viewBox: "0 0 234 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [_jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M1.30733e-07 4C5.85312e-08 1.79086 1.79086 5.86502e-08 4 1.30999e-07L230 7.53243e-06C232.209 7.60478e-06 234 1.79087 234 4.00001C234 6.20915 232.209 8.00001 230 8.00001L4 8C1.79086 8 2.02935e-07 6.20914 1.30733e-07 4Z", fill: "url(#paint0_linear_4060_316245)" }), _jsx("defs", { children: _jsxs("linearGradient", { id: "paint0_linear_4060_316245", x1: "-0.585003", y1: "5.99984", x2: "228.159", y2: "4.97311", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { stopColor: "#3000FF" }), _jsx("stop", { offset: "0.239583", stopColor: "#5CFFE2" }), _jsx("stop", { offset: "0.447917", stopColor: "#E2FFA4" }), _jsx("stop", { offset: "0.546875", stopColor: "#FCFF75" }), _jsx("stop", { offset: "0.78125", stopColor: "#FDBA73" }), _jsx("stop", { offset: "1", stopColor: "#FF0F00" })] }) })] }));
3
3
  export default HeatmapGraphSVG;
@@ -5,23 +5,16 @@ import { HistogramTabsContainer, TabButton } from './Histogram.styled';
5
5
  const HistogramTabs = ({ options, active, onChange }) => {
6
6
  return (_jsx(HistogramTabsContainer, { children: options.map((tabLabel, idx) => {
7
7
  const fontSize = calculateFontSize(tabLabel);
8
- const commonButtonProps = {
9
- key: tabLabel,
10
- disableRipple: true,
11
- active: idx === active,
12
- onClick: () => onChange(idx),
13
- sx: {
8
+ return (_jsx(TabButton, { disableRipple: true, active: idx === active, onClick: () => onChange(idx), sx: {
14
9
  padding: '4px 6px',
15
10
  borderRadius: doBorderRadius(idx, options.length),
16
- },
17
- };
18
- return (_jsx(TabButton, { ...commonButtonProps, children: _jsx(Typography, { variant: "body_sb1", sx: {
11
+ }, children: _jsx(Typography, { variant: "body_sb1", sx: {
19
12
  fontSize: `${fontSize}px`,
20
13
  whiteSpace: 'nowrap',
21
14
  overflow: 'hidden',
22
15
  textOverflow: 'ellipsis',
23
16
  width: '100%',
24
- }, children: tabLabel }) }));
17
+ }, children: tabLabel }) }, tabLabel));
25
18
  }) }));
26
19
  };
27
20
  export default HistogramTabs;
@@ -1,3 +1,3 @@
1
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;
2
+ declare const Threshold: ({ componentType, title, totalScore, totalCells, statisticItems, options, description, controlStep, isLoading, onChangeDropdown, onSliderChangeCommitted, onClickUpdateConfiguration, }: ThresholdProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default Threshold;
@@ -10,20 +10,24 @@ 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, totalCells, statisticItems, options, description, controlStep = 1, onChangeDropdown, onSliderChangeCommitted, }) => {
13
+ const Threshold = ({ componentType = 'threshold', title, totalScore, totalCells, statisticItems, options, description, controlStep = 1, isLoading = false, onChangeDropdown, onSliderChangeCommitted, onClickUpdateConfiguration, }) => {
14
14
  const [selectedItem, setSelectedItem] = useState(options[0].title.toString());
15
15
  const [selectedValue, setSelectedValue] = useState(options[0].value);
16
+ const [selectedOptionValue, setSelectedOptionValue] = useState(options[0].value);
16
17
  const [isPresetSelected, setIsPresetSelected] = useState(options[0].isPreset);
18
+ const [isThresholdChanged, setIsThresholdChanged] = useState(false);
17
19
  const presetValue = getPresetValue(options, selectedItem);
18
20
  const marks = getSliderMarks(presetValue);
19
21
  const handleChange = (event) => {
20
22
  setSelectedItem(event.target.value);
21
23
  setSelectedValue(options.find((option) => option.title === event.target.value)?.value);
24
+ setSelectedOptionValue(options.find((option) => option.title === event.target.value)?.value);
22
25
  setIsPresetSelected(options.find((option) => option.title === event.target.value)?.isPreset || false);
23
26
  onChangeDropdown(event);
24
27
  };
25
28
  const handleSliderChange = (event, value) => {
26
29
  setSelectedValue(value);
30
+ setIsThresholdChanged(value !== selectedOptionValue);
27
31
  };
28
32
  return (_jsxs(Container, { children: [_jsx(Score, { ...totalScore }), _jsx(Statistic, { ...totalCells }), statisticItems.map((item) => {
29
33
  return (_jsx(Statistic, { ...item }, uuidV4()));
@@ -31,6 +35,6 @@ const Threshold = ({ componentType = 'threshold', title, totalScore, totalCells,
31
35
  return (_jsx(DropdownItem, { value: option.title, children: option.title }, option.title));
32
36
  }) }), _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
37
  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 }))] })] }));
38
+ }, disabled: !isThresholdChanged || isLoading, onClick: onClickUpdateConfiguration, loading: isLoading })), 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
39
  };
36
40
  export default Threshold;
@@ -25,6 +25,8 @@ export interface ThresholdSpec {
25
25
  export interface ThresholdProps extends ThresholdSpec {
26
26
  onChangeDropdown: (event: SelectChangeEvent) => void;
27
27
  onSliderChangeCommitted: (event: Event | SyntheticEvent, value: number | number[]) => void;
28
+ onClickUpdateConfiguration: () => void;
29
+ isLoading?: boolean;
28
30
  }
29
31
  export interface BaseSliderProps extends SliderProps {
30
32
  defaultThreshold: number;
@@ -1,4 +1,4 @@
1
1
  import Threshold from './Threshold';
2
- import type { ThresholdProps } from './Threshold.types';
2
+ import type { ThresholdProps, ThresholdSpec } from './Threshold.types';
3
3
  export { Threshold };
4
- export type { ThresholdProps };
4
+ export type { ThresholdProps, ThresholdSpec };
@@ -14,11 +14,11 @@ const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbo
14
14
  const [isChecked, setIsChecked] = useState(checked);
15
15
  const handleChange = (event) => {
16
16
  setIsChecked(event.target.checked);
17
- onChange && onChange(event);
17
+ onChange && onChange(event, event.target.checked);
18
18
  };
19
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: {
20
20
  display: 'flex',
21
21
  alignItems: 'center',
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 }) }))] }));
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()))) }, 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 }) }))] }));
23
23
  };
24
24
  export default ToggleControl;
@@ -48,6 +48,6 @@ export interface ToggleControlProps extends ToggleControlSpec {
48
48
  disabled?: boolean;
49
49
  target?: TargetSpec;
50
50
  isMaster?: boolean;
51
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
51
+ onChange: (event: React.ChangeEvent<HTMLInputElement>, toggle: boolean) => void;
52
52
  }
53
53
  export {};
@@ -19,18 +19,20 @@ const ToggleControlGroup = ({ componentType = 'toggleGroup', size = 'medium', ti
19
19
  setChildrenChecked(newState);
20
20
  }
21
21
  }
22
- onChange(event);
22
+ onChange(event, event.target.checked, childrenChecked);
23
23
  };
24
- const handleMultiChange = (index) => {
24
+ const handleMultiChange = (index, event) => {
25
25
  const newState = [...childrenChecked];
26
26
  newState[index] = !newState[index];
27
27
  setChildrenChecked(newState);
28
+ onChange(event, toggleChecked, newState);
28
29
  };
29
30
  const handleExclusiveChange = (index, event) => {
30
31
  const newState = Array(childrenChecked.length).fill(false);
31
32
  setChildrenChecked(newState);
32
33
  newState[index] = event.target.checked;
33
34
  setChildrenChecked(newState);
35
+ onChange(event, toggleChecked, newState);
34
36
  };
35
37
  useEffect(() => {
36
38
  if (behavior === 'exclusive') {
@@ -49,9 +51,11 @@ const ToggleControlGroup = ({ componentType = 'toggleGroup', size = 'medium', ti
49
51
  }
50
52
  }, [behavior, childToggles, childrenChecked.length]);
51
53
  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) => {
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) => {
53
- behavior === 'multi' ? handleMultiChange(index) : handleExclusiveChange(index, event);
54
- child.onChange(event);
54
+ 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, toggle) => {
55
+ behavior === 'multi'
56
+ ? handleMultiChange(index, event)
57
+ : handleExclusiveChange(index, event);
58
+ child.onChange(event, toggle);
55
59
  }, bar: child.bar }, uuidV4()));
56
60
  })] }));
57
61
  };
@@ -16,6 +16,6 @@ export interface ToggleGroupControlSpec {
16
16
  childToggles: ToggleControlProps[];
17
17
  }
18
18
  export interface ToggleControlGroupProps extends ToggleGroupControlSpec {
19
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
19
+ onChange: (event: React.ChangeEvent<HTMLInputElement>, parent: boolean, children: Array<boolean | undefined>) => void;
20
20
  disabled?: boolean;
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunit/oui",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
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)"