@mui/x-date-pickers-pro
Version:
The Pro plan edition of the MUI X Date and Time Picker components.
18 lines • 628 B
JavaScript
import useControlled from '@mui/utils/useControlled';
import useEventCallback from '@mui/utils/useEventCallback';
export const useRangePosition = props => {
const [rangePosition, setRangePosition] = useControlled({
name: 'useRangePosition',
state: 'rangePosition',
controlled: props.rangePosition,
default: props.defaultRangePosition ?? 'start'
});
const handleRangePositionChange = useEventCallback(newRangePosition => {
setRangePosition(newRangePosition);
props.onRangePositionChange?.(newRangePosition);
});
return {
rangePosition,
setRangePosition: handleRangePositionChange
};
};