@lunit/oui 2.2.7 → 2.2.9
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,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { v4 as uuidV4 } from 'uuid';
|
|
4
|
-
import { find as _find } from 'lodash';
|
|
5
4
|
import { Container } from './Preview.styled';
|
|
6
5
|
import { Box } from '@mui/material';
|
|
7
6
|
import { ToggleControl } from '../ToggleControl';
|
|
@@ -16,11 +15,6 @@ import { Threshold } from '../Threshold';
|
|
|
16
15
|
import { Histogram } from '../Histogram';
|
|
17
16
|
const Preview = ({ visualizationControls = [], analysisSummary = [] }) => {
|
|
18
17
|
const [controls, setControls] = useState(visualizationControls);
|
|
19
|
-
const thresholdItem = _find(analysisSummary, { componentType: 'threshold' });
|
|
20
|
-
const [selectedThresholdItem, setSelectedThresholdItem] = useState(thresholdItem?.options?.[0]?.title?.toString());
|
|
21
|
-
const [selectedThresholdValue, setSelectedThresholdValue] = useState(thresholdItem?.options?.[0]?.value);
|
|
22
|
-
const [selectedThresholdOptionValue, setSelectedThresholdOptionValue] = useState(thresholdItem?.options?.[0]?.value);
|
|
23
|
-
const [isThresholdPresetSelected, setIsThresholdPresetSelected] = useState(thresholdItem?.options?.[0]?.isPreset);
|
|
24
18
|
return (_jsxs(Container, { children: [_jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '16px', padding: '16px' }, children: visualizationControls.map((item, index) => {
|
|
25
19
|
if (item.componentType === 'toggleGroup') {
|
|
26
20
|
item.onChange = (event) => {
|
|
@@ -61,13 +55,6 @@ const Preview = ({ visualizationControls = [], analysisSummary = [] }) => {
|
|
|
61
55
|
});
|
|
62
56
|
}
|
|
63
57
|
return (_jsxs(Box, { children: [item.componentType === 'toggle' && (_jsx(ToggleControl, { ...item }, uuidV4())), item.componentType === 'toggleGroup' && (_jsx(ToggleControlGroup, { ...item }, uuidV4())), item.componentType === 'analysisBar' && (_jsx(AnalysisBar, { ...item }, uuidV4()))] }, uuidV4()));
|
|
64
|
-
}) }), _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) => {
|
|
65
|
-
return (_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, selectedItem: selectedThresholdItem, selectedValue: selectedThresholdValue, selectedOptionValue: selectedThresholdOptionValue, isPresetSelected: !!isThresholdPresetSelected, onChangeDropdown: (event) => {
|
|
66
|
-
setSelectedThresholdItem(event.target.value);
|
|
67
|
-
setSelectedThresholdValue(_find(thresholdItem?.options, { title: event.target.value })?.value);
|
|
68
|
-
setSelectedThresholdOptionValue(_find(thresholdItem?.options, { title: event.target.value })?.value);
|
|
69
|
-
setIsThresholdPresetSelected(_find(thresholdItem?.options, { title: event.target.value })?.isPreset);
|
|
70
|
-
}, onClickUpdateConfiguration: () => { }, onSliderChangeCommitted: () => { } }, uuidV4())), item.componentType === 'histogram' && (_jsx(Histogram, { ...item }, uuidV4()))] }, uuidV4()));
|
|
71
|
-
})] })] }));
|
|
58
|
+
}) }), _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, onChangeDropdown: () => { }, onSliderChangeCommitted: () => { }, onClickUpdateConfiguration: () => { } }, uuidV4())), item.componentType === 'histogram' && (_jsx(Histogram, { ...item }, uuidV4()))] }, uuidV4())))] })] }));
|
|
72
59
|
};
|
|
73
60
|
export default Preview;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ThresholdProps } from './Threshold.types';
|
|
2
|
-
declare const Threshold: ({ componentType, title, totalScore, totalCells, statisticItems, options, description, controlStep, isLoading,
|
|
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,28 +10,34 @@ 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, isLoading = false,
|
|
14
|
-
const [
|
|
13
|
+
const Threshold = ({ componentType = 'threshold', title, totalScore, totalCells, statisticItems, options, description, controlStep = 1, isLoading = false, onChangeDropdown, onSliderChangeCommitted, onClickUpdateConfiguration, }) => {
|
|
14
|
+
const [selectedItem, setSelectedItem] = useState(options[0].title.toString());
|
|
15
|
+
const [selectedValue, setSelectedValue] = useState(options[0].value);
|
|
16
|
+
const [selectedOptionValue, setSelectedOptionValue] = useState(options[0].value);
|
|
17
|
+
const [isPresetSelected, setIsPresetSelected] = useState(options[0].isPreset);
|
|
15
18
|
const [isThresholdChanged, setIsThresholdChanged] = useState(false);
|
|
16
19
|
const presetValue = getPresetValue(options, selectedItem);
|
|
17
20
|
const marks = getSliderMarks(presetValue);
|
|
21
|
+
const handleChange = (event) => {
|
|
22
|
+
setSelectedItem(event.target.value);
|
|
23
|
+
setSelectedValue(options.find((option) => option.title === event.target.value)?.value);
|
|
24
|
+
setSelectedOptionValue(options.find((option) => option.title === event.target.value)?.value);
|
|
25
|
+
setIsPresetSelected(options.find((option) => option.title === event.target.value)?.isPreset || false);
|
|
26
|
+
onChangeDropdown(event);
|
|
27
|
+
};
|
|
18
28
|
const handleSliderChange = (event, value) => {
|
|
19
|
-
|
|
29
|
+
setSelectedValue(value);
|
|
20
30
|
setIsThresholdChanged(value !== selectedOptionValue);
|
|
21
31
|
};
|
|
22
32
|
const handleUpdateConfiguration = () => {
|
|
23
33
|
onClickUpdateConfiguration();
|
|
24
34
|
setIsThresholdChanged(false);
|
|
25
35
|
};
|
|
26
|
-
const handleSliderChangeCommitted = (event, value) => {
|
|
27
|
-
setIsThresholdChanged(value !== selectedOptionValue);
|
|
28
|
-
onSliderChangeCommitted(event, value);
|
|
29
|
-
};
|
|
30
36
|
return (_jsxs(Container, { children: [_jsx(Score, { ...totalScore }), _jsx(Statistic, { ...totalCells }), statisticItems.map((item) => {
|
|
31
37
|
return (_jsx(Statistic, { ...item }, uuidV4()));
|
|
32
|
-
}), _jsx(HorizonDivider, { componentType: "divider" }), _jsx(PresentationTypography, { size: "medium", children: title }), _jsx(Dropdown, { value: selectedItem, onChange:
|
|
38
|
+
}), _jsx(HorizonDivider, { componentType: "divider" }), _jsx(PresentationTypography, { size: "medium", children: title }), _jsx(Dropdown, { value: selectedItem, onChange: handleChange, sx: { width: '258px' }, children: options.map((option) => {
|
|
33
39
|
return (_jsx(DropdownItem, { value: option.title, children: option.title }, option.title));
|
|
34
|
-
}) }), _jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', paddingTop: '36px', gap: '6px' }, children: [_jsx(BaseSlider, { disabled: isPresetSelected, step: controlStep, value:
|
|
40
|
+
}) }), _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, { id: "update-threshold-config-btn", label: "Update Configuration", sx: {
|
|
35
41
|
width: '100%',
|
|
36
42
|
}, disabled: !isThresholdChanged || isLoading, onClick: handleUpdateConfiguration, 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 }))] })] }));
|
|
37
43
|
};
|
|
@@ -26,10 +26,6 @@ export interface ThresholdProps extends ThresholdSpec {
|
|
|
26
26
|
onChangeDropdown: (event: SelectChangeEvent) => void;
|
|
27
27
|
onSliderChangeCommitted: (event: Event | SyntheticEvent, value: number | number[]) => void;
|
|
28
28
|
onClickUpdateConfiguration: () => void;
|
|
29
|
-
selectedItem: string;
|
|
30
|
-
selectedValue: number;
|
|
31
|
-
selectedOptionValue: number;
|
|
32
|
-
isPresetSelected: boolean;
|
|
33
29
|
isLoading?: boolean;
|
|
34
30
|
}
|
|
35
31
|
export interface BaseSliderProps extends SliderProps {
|
package/package.json
CHANGED