import type { NumberFieldInputProps, NumberFieldRootProps, NumberFieldSize } from '@langgenius/dify-ui/number-field' import type { FC, PropsWithChildren, ReactNode } from 'react' import type { InputProps } from '@/app/components/base/input' import { NumberField, NumberFieldControls, NumberFieldDecrement, NumberFieldGroup, NumberFieldIncrement, NumberFieldInput, NumberFieldUnit, } from '@langgenius/dify-ui/number-field' import { useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { Infotip } from '@/app/components/base/infotip' import Input from '@/app/components/base/input' import { env } from '@/env' const TextLabel: FC = (props) => { return } const FormField: FC> = (props) => { return (
{props.label} {props.children}
) } export const DelimiterInput: FC = ({ tooltip, onChange, value, ...rest }) => { const { t } = useTranslation() const isComposing = useRef(false) const [compositionValue, setCompositionValue] = useState('') return ( {t('stepTwo.separator', { ns: 'datasetCreation' })} {tooltip || t('stepTwo.separatorTip', { ns: 'datasetCreation' })} )} > { if (isComposing.current) setCompositionValue(e.target.value) else onChange?.(e) }} onCompositionStart={() => { isComposing.current = true setCompositionValue(String(value ?? '')) }} onCompositionEnd={(e) => { const committed = e.currentTarget.value isComposing.current = false setCompositionValue('') onChange?.({ ...e, target: { ...e.target, value: committed } } as unknown as React.ChangeEvent) }} {...rest} /> ) } type CompoundNumberInputProps = Omit & Omit & { label: string unit?: ReactNode size?: NumberFieldSize onChange: (value: number) => void } function CompoundNumberInput({ label, onChange, unit, size = 'large', className, ...props }: CompoundNumberInputProps) { const { value, defaultValue, min, max, step, disabled, readOnly, required, id, name, onBlur, ...inputProps } = props const emptyValue = defaultValue ?? min ?? 0 return ( onChange(value ?? emptyValue)} > {Boolean(unit) && ( {unit} )} ) } type LabeledCompoundNumberInputProps = Omit export const MaxLengthInput: FC = (props) => { const maxValue = env.NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH const { t } = useTranslation() const label = t('stepTwo.maxLength', { ns: 'datasetCreation' }) return ( {label} )} > ) } export const OverlapInput: FC = (props) => { const { t } = useTranslation() const label = t('stepTwo.overlap', { ns: 'datasetCreation' }) return ( {label} {t('stepTwo.overlapTip', { ns: 'datasetCreation' })} )} > ) }