import React, { useId } from 'react'; import type { Exact } from '../../../types'; import { destruct } from '../../../utils/destruct'; import { omit } from '../../../utils/omit'; import { pick } from '../../../utils/pick'; import type { FormRowProps } from '../../FormRow/FormRow'; import { FormRow } from '../../FormRow/FormRow'; import type { FormRowHelperTextOwnProps } from '../../FormRow/FormRowHelperText'; import { CounterInput, type CounterInputProps } from '../../Inputs/CounterInput/CounterInput'; import type { LabelAfterProps } from '../../LabelAfter/LabelAfter'; import { LabelAfter } from '../../LabelAfter/LabelAfter'; interface CounterFieldContainerProps extends Omit {} interface CounterFieldHelperTextProps extends Partial {} interface CounterFieldInputProps extends Omit {} /** @inheritdoc */ export interface CounterFieldProps extends CounterFieldContainerProps, CounterFieldHelperTextProps, CounterFieldInputProps { /** * Label displayed after the input element. */ labelAfter?: LabelAfterProps['label']; } export function CounterField(props: CounterFieldProps) { const generatedId = useId(); const [formRowProps, helperTextProps, rest] = destruct( props, ['as', 'htmlFor', 'justify', 'labelHidden', 'required', 'tooltip'], ['error', 'hint', 'warning'] ); formRowProps satisfies Exact; helperTextProps satisfies Exact; rest satisfies Exact< Omit & Pick, typeof rest >; const inputId = formRowProps.htmlFor ?? generatedId; return (
{rest.labelAfter && }
); }