{
	"$schema": "https://ui.shadcn.com/schema/registry-item.json",
	"name": "use-textarea-resize",
	"type": "registry:hook",
	"files": [
		{
			"path": "./src/registry/hooks/use-textarea-resize.ts",
			"content": "\"use client\";\n\nimport type { ComponentProps } from \"react\";\nimport { useLayoutEffect, useRef } from \"react\";\n\nexport function useTextareaResize(\n\tvalue: ComponentProps<\"textarea\">[\"value\"],\n\trows = 1,\n) {\n\tconst textareaRef = useRef<HTMLTextAreaElement>(null);\n\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: Needed\n\tuseLayoutEffect(() => {\n\t\tconst textArea = textareaRef.current;\n\n\t\tif (textArea) {\n\t\t\t// Get the line height to calculate minimum height based on rows\n\t\t\tconst computedStyle = window.getComputedStyle(textArea);\n\t\t\tconst lineHeight =\n\t\t\t\tNumber.parseInt(computedStyle.lineHeight, 10) || 20;\n\t\t\tconst padding =\n\t\t\t\tNumber.parseInt(computedStyle.paddingTop, 10) +\n\t\t\t\tNumber.parseInt(computedStyle.paddingBottom, 10);\n\n\t\t\t// Calculate minimum height based on rows\n\t\t\tconst minHeight = lineHeight * rows + padding;\n\n\t\t\t// Reset height to auto first to get the correct scrollHeight\n\t\t\ttextArea.style.height = \"0px\";\n\t\t\tconst scrollHeight = Math.max(textArea.scrollHeight, minHeight);\n\n\t\t\t// Set the final height\n\t\t\ttextArea.style.height = `${scrollHeight + 2}px`;\n\t\t}\n\t}, [textareaRef, value, rows]);\n\n\treturn textareaRef;\n}\n",
			"type": "registry:hook"
		}
	]
}
