// // Copyright 2026 DXOS.org // import { PasswordInput as PasswordInputPrimitive, usePasswordInputContext } from '@ark-ui/react/password-input'; import React, { type FocusEventHandler, forwardRef } from 'react'; import { useTranslation } from 'react-i18next'; import { mx } from '@dxos/ui-theme'; import { type ThemedClassName } from '@dxos/ui-types'; import { translationKey } from '#translations'; import { recipes } from '../../recipes.ts'; import { Button } from '../Button/Button.tsx'; export type PasswordInputProps = ThemedClassName< Pick< PasswordInputPrimitive.RootProps, | 'visible' | 'defaultVisible' | 'autoComplete' | 'ignorePasswordManagers' | 'disabled' | 'readOnly' | 'required' | 'invalid' | 'name' > > & { 'value'?: string; 'defaultValue'?: string; 'onValueChange'?: (value: string) => void; 'onVisibleChange'?: (visible: boolean) => void; /** Focus leaving the input, e.g. to commit a draft. */ 'onBlur'?: FocusEventHandler; 'placeholder'?: string; 'autoFocus'?: boolean; /** Overrides the translated `password-input.show.label`. */ 'showLabel'?: string; /** Overrides the translated `password-input.hide.label`. */ 'hideLabel'?: string; 'aria-label'?: string; 'data-testid'?: string; }; type VisibilityTriggerProps = Pick; /** The eye toggle names the action it performs, which follows the machine's visibility. */ const VisibilityTrigger = ({ showLabel, hideLabel }: VisibilityTriggerProps) => { const { t } = useTranslation(translationKey); const { visible } = usePasswordInputContext(); return (