import { Flex, Typography, Tag, Space } from 'antd' import PropTypes from 'prop-types' const { Text } = Typography const getPrecision = (step) => { if (step == null) return null const stepStr = String(step) const dotIndex = stepStr.indexOf('.') return dotIndex === -1 ? 0 : stepStr.length - dotIndex - 1 } const formatValue = (value, step) => { if (value == null || value === '') return null const parsed = parseFloat(value) if (Number.isNaN(parsed)) return null const precision = getPrecision(step) return precision == null ? parsed.toString() : parsed.toFixed(precision) } const MinMaxDisplay = ({ value, prefix = '', suffix = '', step }) => { const min = formatValue(value?.min, step) const max = formatValue(value?.max, step) return ( {min != null ? ( prefix + min + suffix ) : ( n/a )} Min {max != null ? ( prefix + max + suffix ) : ( n/a )} Max ) } MinMaxDisplay.propTypes = { value: PropTypes.shape({ min: PropTypes.number, max: PropTypes.number }), prefix: PropTypes.string, suffix: PropTypes.string, step: PropTypes.number } export default MinMaxDisplay