1 import { type FC, type KeyboardEventHandler } from 'react';
3 import { c } from 'ttag';
5 import Toggle from '@proton/components/components/toggle/Toggle';
6 import { InlineFieldBox } from '@proton/pass/components/Form/Field/Layout/InlineFieldBox';
7 import type { MaybeNull } from '@proton/pass/types';
9 import { IncrementableInput } from './IncrementableInput';
13 value: MaybeNull<number>;
14 onChange: (value: MaybeNull<number>) => void;
15 onPressEnter?: KeyboardEventHandler<HTMLInputElement>;
18 export const [MIN_READS, MAX_READS] = [1, 1000];
20 export const MaxReadsToggleInput: FC<Props> = ({ disabled, value, onPressEnter, onChange }) => (
22 <InlineFieldBox label={c('Action').t`Restrict number of views`}>
23 <Toggle checked={Boolean(value)} onChange={() => onChange(value ? null : MIN_READS)} disabled={disabled} />
27 <InlineFieldBox label={c('Action').t`Maximum views`}>
34 onPressEnter={onPressEnter}