import React from 'react'; import { useTranslation } from 'react-i18next'; import OptionGroup from './OptionGroup'; import { optionValue } from './constraints'; import { optionLabel, paramLabel } from './labels'; /** * 分段选择(schema type = 'segmented'),主要用于时长,按 unit 显示"5s"。 * props: { param, value, onChange(value), optionDisabledReasons?, disabledReason? } */ const DurationSegmented = ({ param, value, onChange, optionDisabledReasons, disabledReason, }) => { const { t } = useTranslation(); const unitWord = param?.unit === 's' ? t('秒') : param?.unit || ''; return ( `${optionValue(opt)} ${unitWord}`.trim()} renderOption={(opt) => ( {optionLabel(t, param, opt)} )} /> ); }; export default DurationSegmented;