{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "opentui/password-input",
  "title": "Password Input",
  "description": "Password input with masked characters and reveal toggle",
  "dependencies": [
    "@opentui/react"
  ],
  "registryDependencies": [
    "https://termcn.dev/r/opentui/use-theme.json"
  ],
  "files": [
    {
      "path": "registry/opentui/ui/password-input.tsx",
      "content": "/* @jsxImportSource @opentui/react */\nimport { useKeyboard } from \"@opentui/react\";\nimport { useState } from \"react\";\n\nimport { useTheme } from \"@/hooks/use-theme\";\nimport type { BorderStyle } from \"@/components/ui/types\";\n\nexport interface PasswordInputProps {\n  value?: string;\n  onChange?: (value: string) => void;\n  onSubmit?: (value: string) => void;\n  placeholder?: string;\n  mask?: string;\n  showToggle?: boolean;\n  label?: string;\n  id?: string;\n  borderStyle?: BorderStyle;\n  paddingX?: number;\n  width?: number;\n  cursor?: string;\n}\n\nexport const PasswordInput = ({\n  value: controlledValue,\n  onChange,\n  onSubmit,\n  placeholder = \"\",\n  mask = \"●\",\n  showToggle = false,\n  label,\n  id: _id,\n  borderStyle = \"rounded\",\n  paddingX = 1,\n  width,\n  cursor = \"█\",\n}: PasswordInputProps) => {\n  const [internalValue, setInternalValue] = useState(\"\");\n  const [isVisible, setIsVisible] = useState(false);\n  const theme = useTheme();\n  const [isFocused] = useState(true);\n\n  const value = controlledValue ?? internalValue;\n\n  const setValue = (newVal: string) => {\n    if (onChange) {\n      onChange(newVal);\n    } else {\n      setInternalValue(newVal);\n    }\n  };\n\n  useKeyboard((key) => {\n    if (!isFocused) {\n      return;\n    }\n    if (showToggle && key.ctrl && key.name === \"h\") {\n      setIsVisible((v) => !v);\n      return;\n    }\n    if (key.name === \"return\") {\n      onSubmit?.(value);\n      return;\n    }\n    if (key.name === \"backspace\" || key.name === \"delete\") {\n      setValue(value.slice(0, -1));\n      return;\n    }\n    if (\n      key.name === \"escape\" ||\n      key.name === \"up\" ||\n      key.name === \"down\" ||\n      key.name === \"tab\"\n    ) {\n      return;\n    }\n    if (key.name && key.name.length === 1) {\n      setValue(value + key.name);\n    }\n  });\n\n  const displayValue = isVisible ? value : mask.repeat(value.length);\n  const borderColor = isFocused ? theme.colors.focusRing : theme.colors.border;\n\n  return (\n    <box flexDirection=\"column\">\n      {label && (\n        <text>\n          <b>{label}</b>\n        </text>\n      )}\n      <box flexDirection=\"row\" alignItems=\"center\" gap={1}>\n        <box\n          borderStyle={borderStyle}\n          borderColor={borderColor}\n          paddingLeft={paddingX}\n          paddingRight={paddingX}\n          width={width}\n        >\n          <text\n            fg={value ? theme.colors.foreground : theme.colors.mutedForeground}\n          >\n            {displayValue || placeholder}\n          </text>\n          {isFocused && <text fg={theme.colors.focusRing}>{cursor}</text>}\n        </box>\n        {showToggle && isFocused && (\n          <text fg={theme.colors.mutedForeground}>\n            {isVisible ? \"Ctrl+H hide\" : \"Ctrl+H show\"}\n          </text>\n        )}\n      </box>\n    </box>\n  );\n};\n",
      "type": "registry:ui",
      "target": "components/ui/password-input.tsx"
    }
  ],
  "categories": [
    "input"
  ],
  "type": "registry:ui"
}