@lunit/oui
Version:
Lunit Oncology UI components
25 lines (24 loc) • 1.33 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useState } from 'react';
import { Threshold } from '../Threshold';
const ThresholdControl = (threshold) => {
const [selectedItem, setSelectedItem] = useState(threshold?.options[0].title.toString());
const [sliderValue, setSliderValue] = useState(threshold?.options[0].value);
const [isPresetSelected, setIsPresetSelected] = useState(threshold?.options[0].isPreset || false);
const onChangeDropdown = (event) => {
setSelectedItem(event.target.value);
setSliderValue(threshold.options.find((option) => option.title === event.target.value)?.value);
setIsPresetSelected(threshold.options.find((option) => option.title === event.target.value)?.isPreset || false);
};
const onChangeSlider = (event, value) => {
setSliderValue(value);
};
const onSliderChangeCommitted = (event, value) => { };
const onClickUpdateConfiguration = () => { };
return (_jsx(Threshold, { ...threshold, thresholdState: {
selectedItem,
sliderValue,
isPresetSelected,
}, onChangeDropdown: onChangeDropdown, onChangeSlider: onChangeSlider, onSliderChangeCommitted: onSliderChangeCommitted, onClickUpdateConfiguration: onClickUpdateConfiguration }));
};
export default ThresholdControl;