{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "password-field",
  "type": "registry:ui",
  "title": "Password Field",
  "description": "A password input with a button that shows or hides what was typed.",
  "categories": [
    "ui"
  ],
  "dependencies": [
    "class-variance-authority",
    "lucide-react",
    "radix-ui"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn",
    "@rivier-ui/input"
  ],
  "files": [
    {
      "path": "registry/ui/password-field.tsx",
      "type": "registry:ui",
      "target": "components/ui/password-field.tsx",
      "content": "\"use client\";\n/**\n * @name password-field\n * @category ui\n * @description A password input with a button that shows or hides what was typed.\n * @when Every place a password is typed. The value is hidden again when the form is sent, and the button keeps the caret where it was. Set `autoComplete` to \"current-password\" (signing in) or \"new-password\" (choosing one) so a password manager knows which to offer. For a code sent by message use otp-field.\n * @example\n * <Field>\n *   <FieldLabel>Password</FieldLabel>\n *   <PasswordField>\n *     <FieldControl><PasswordFieldInput name=\"password\" autoComplete=\"current-password\" /></FieldControl>\n *     <PasswordFieldToggle />\n *   </PasswordField>\n * </Field>\n */\nimport { unstable_PasswordToggleField as PasswordPrimitive } from \"radix-ui\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport { Eye, EyeOff } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { inputVariants } from \"@/components/ui/input\";\nimport { cn } from \"@/lib/cn\";\n\nexport type PasswordFieldProps = ComponentProps<\"div\"> & Pick<ComponentProps<typeof PasswordPrimitive.Root>, \"visible\" | \"defaultVisible\" | \"onVisibilityChange\">;\n\n/** Holds whether the password is shown: `visible`, `defaultVisible`, `onVisibilityChange`. */\nexport function PasswordField({ className, visible, defaultVisible, onVisibilityChange, children, ...props }: PasswordFieldProps) {\n  return (\n    <PasswordPrimitive.Root visible={visible} defaultVisible={defaultVisible} onVisibilityChange={onVisibilityChange}>\n      <div data-slot=\"password-field\" className={cn(\"relative w-full\", className)} {...props}>\n        {children}\n      </div>\n    </PasswordPrimitive.Root>\n  );\n}\n\n/** `size` is the control's height (sm, md, lg), as on input. */\nexport type PasswordFieldInputProps = Omit<ComponentProps<typeof PasswordPrimitive.Input>, \"size\"> & VariantProps<typeof inputVariants>;\n\n/** The input, with room at the end for the button. */\nexport function PasswordFieldInput({ className, size, ...props }: PasswordFieldInputProps) {\n  return <PasswordPrimitive.Input data-slot=\"password-field-input\" className={cn(inputVariants({ size }), \"pe-11\", className)} {...props} />;\n}\n\nexport type PasswordFieldToggleProps = ComponentProps<typeof PasswordPrimitive.Toggle> & {\n  /** The button's accessible name in each state. Translate it with the rest of the interface. */\n  labels?: { show: string; hide: string };\n};\n\n/** The button at the end of the input. Its children replace the eye. */\nexport function PasswordFieldToggle({ className, labels = { show: \"Show password\", hide: \"Hide password\" }, children, ...props }: PasswordFieldToggleProps) {\n  return (\n    <PasswordPrimitive.Slot\n      render={({ visible }) => (\n        <PasswordPrimitive.Toggle\n          data-slot=\"password-field-toggle\"\n          aria-label={visible ? labels.hide : labels.show}\n          className={cn(\n            \"absolute inset-y-0 end-0 inline-flex aspect-square items-center justify-center rounded-control text-muted-foreground -outline-offset-2 transition-[color] duration-instant ease-out hover:text-foreground disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none\",\n            className,\n          )}\n          {...props}\n        >\n          {children ?? (\n            <PasswordPrimitive.Icon\n              aria-hidden=\"true\"\n              className=\"size-4\"\n              visible={<EyeOff strokeWidth={1.5} />}\n              hidden={<Eye strokeWidth={1.5} />}\n            />\n          )}\n        </PasswordPrimitive.Toggle>\n      )}\n    />\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "ui",
    "when": "Every place a password is typed. The value is hidden again when the form is sent, and the button keeps the caret where it was. Set `autoComplete` to \"current-password\" (signing in) or \"new-password\" (choosing one) so a password manager knows which to offer. For a code sent by message use otp-field.",
    "example": "<Field>\n  <FieldLabel>Password</FieldLabel>\n  <PasswordField>\n    <FieldControl><PasswordFieldInput name=\"password\" autoComplete=\"current-password\" /></FieldControl>\n    <PasswordFieldToggle />\n  </PasswordField>\n</Field>",
    "client": true
  }
}
