1 import type { ChangeEvent, Ref } from 'react';
2 import { forwardRef } from 'react';
4 import type { InputProps } from '@proton/atoms';
5 import { Input } from '@proton/atoms';
6 import { getAllFieldLabels } from '@proton/shared/lib/helpers/contacts';
7 import type { VCardProperty } from '@proton/shared/lib/interfaces/contacts/VCard';
9 interface Props extends Omit<InputProps, 'onChange'> {
10 vCardProperty: VCardProperty<string>;
11 onChange: (vCardProperty: VCardProperty<string>) => void;
14 const ContactFieldString = ({ vCardProperty, onChange, ...rest }: Props, ref: Ref<HTMLInputElement>) => {
15 const label = (getAllFieldLabels() as any)[vCardProperty.field] || '';
17 const handleChange = ({ target }: ChangeEvent<HTMLInputElement>) => {
18 const newValue = target.value;
19 onChange({ ...vCardProperty, value: newValue });
25 value={vCardProperty.value}
27 onChange={handleChange}
34 export default forwardRef(ContactFieldString);