| 1 |
import { useDeviceType } from '@Controls/getPreviewType'; |
| 2 |
export const limitMax = ( unitVal, props, isResponsiveMinMax ) => { |
| 3 |
let max = 0; |
| 4 |
if( isResponsiveMinMax ){ |
| 5 |
const deviceType = useDeviceType(); // eslint-disable-line react-hooks/rules-of-hooks |
| 6 |
const responsiveUnit = ( unitVal ) ? unitVal : props.data[deviceType.toLowerCase()].value; |
| 7 |
max = ( responsiveUnit && props.data[deviceType.toLowerCase()]?.max ) ? props.data[deviceType.toLowerCase()].max : props.max; |
| 8 |
} else { |
| 9 |
max = ( unitVal && props.limitMax ) ? props.limitMax[unitVal] : props.max; |
| 10 |
} |
| 11 |
|
| 12 |
return max; |
| 13 |
}; |
| 14 |
|
| 15 |
export const limitMin = ( unitVal, props, isResponsiveMinMax ) => { |
| 16 |
let min = 0; |
| 17 |
if( isResponsiveMinMax ){ |
| 18 |
const deviceType = useDeviceType(); // eslint-disable-line react-hooks/rules-of-hooks |
| 19 |
const responsiveUnit = ( unitVal ) ? unitVal : props.data[deviceType.toLowerCase()].value; |
| 20 |
min = ( responsiveUnit && props.data[deviceType.toLowerCase()]?.min ) ? props.data[deviceType.toLowerCase()].min : props.min; |
| 21 |
} else { |
| 22 |
min = ( unitVal && props.limitMin ) ? props.limitMin[unitVal] : props.min; |
| 23 |
} |
| 24 |
return min; |
| 25 |
}; |
| 26 |
|