{"code":"// Generated with util/create-component.js\r\nimport React, { useCallback, useRef, useState } from \"react\";\r\nimport NsImage from \"../shared/ns-image\";\r\nimport { Close } from \"../UI/Icon\";\r\nimport Text from \"../UI/Text\";\r\nvar CommentInput = function (props) {\r\n    var onSubmitContent = props.onSubmitContent, nickNameForReply = props.nickNameForReply, _a = props.isFixedBottom, isFixedBottom = _a === void 0 ? false : _a, profileImage = props.profileImage, profileImageWrapper = props.profileImageWrapper;\r\n    var _b = useState(\"\"), content = _b[0], setContent = _b[1];\r\n    var _c = useState(nickNameForReply ? true : false), isReplying = _c[0], setIsReplying = _c[1];\r\n    var _d = useState(0), formHeight = _d[0], setFormHeight = _d[1];\r\n    var textareaRef = useRef(null);\r\n    var formRef = useRef(null);\r\n    var handleResizeHeight = useCallback(function () {\r\n        if (textareaRef === null ||\r\n            textareaRef.current === null ||\r\n            formRef === null ||\r\n            formRef.current === null)\r\n            return;\r\n        textareaRef.current.style.height = \"4.5rem\";\r\n        textareaRef.current.style.height = textareaRef.current.scrollHeight + \"px\";\r\n        formRef.current.style.height = textareaRef.current.scrollHeight + 2 + \"px\";\r\n        setFormHeight(textareaRef.current.scrollHeight + 2);\r\n    }, [content]);\r\n    var submitContent = function () {\r\n        if (content === \"\")\r\n            return;\r\n        onSubmitContent(content);\r\n        setContent(\"\");\r\n        if (textareaRef === null ||\r\n            textareaRef.current === null ||\r\n            formRef === null ||\r\n            formRef.current === null)\r\n            return;\r\n        textareaRef.current.style.height = \"4.5rem\";\r\n        formRef.current.style.height = \"4.7rem\";\r\n        setIsReplying(false);\r\n    };\r\n    return (React.createElement(React.Fragment, null,\r\n        isReplying && nickNameForReply && (React.createElement(TargetBox, { formHeight: formHeight, isFixedBottom: isFixedBottom, nickNameForReply: nickNameForReply, onCloseTarget: setIsReplying })),\r\n        React.createElement(\"section\", { className: \"nrc--CommentInput flex items-center w-[37.5rem] pc:w-[80rem] px-[2rem] py-[1.2rem] border-t-[1px] border-gray-3 \".concat(isFixedBottom ? \"fixed bottom-0 left-0\" : \"relative\") },\r\n            React.createElement(\"div\", { className: \"w-[3rem] h-[3rem] rounded-full mr-[1rem] flex-shrink-0\" },\r\n                React.createElement(NsImage, { ImageWrapper: profileImageWrapper, imageUrl: profileImage, className: \"w-[3rem] h-[3rem]\" })),\r\n            React.createElement(\"form\", { \"data-testid\": \"CommentInput\", className: \"w-[33.5rem] pc:w-[74rem] bg-gray-1 flex justify-between border-[1px] border-gray-2 rounded-[5px] box-border max-h-[40rem] pc:max-h-[20rem] \", onSubmit: function (e) {\r\n                    e.preventDefault();\r\n                    submitContent();\r\n                }, ref: formRef },\r\n                React.createElement(\"textarea\", { className: \"box-border overflow-hidden outline-none resize-none nrc--CommentInput-textarea bg-gray-1 p-[1rem] max-h-[40rem] pc:max-h-[20rem] break-all placeholder-gray-7 text-body-4 text-gray-10 flex-grow\", placeholder: \"\\uAD81\\uAE08\\uD55C \\uC810\\uC744 \\uBB3C\\uC5B4\\uBCF4\\uC138\\uC694!\", value: content, onChange: function (e) {\r\n                        setContent(e.target.value);\r\n                    }, onInput: handleResizeHeight, ref: textareaRef, rows: 1, autoComplete: \"off\", autoFocus: false }),\r\n                React.createElement(\"button\", { onClick: function (e) {\r\n                        e.preventDefault();\r\n                        submitContent();\r\n                    }, className: \"mr-[1rem] \".concat(content === \"\" && \"cursor-not-allowed\") },\r\n                    React.createElement(Text, { type: \"B2\", className: \" whitespace-nowrap \".concat(content === \"\" ? \"text-blue-5\" : \"text-blue-7\") }, \"\\uB4F1\\uB85D\"))))));\r\n};\r\nexport default CommentInput;\r\nvar TargetBox = function (props) {\r\n    var formHeight = props.formHeight, isFixedBottom = props.isFixedBottom, nickNameForReply = props.nickNameForReply, onCloseTarget = props.onCloseTarget;\r\n    var basicFormHeight = formHeight >= 37 ? 22 : 68;\r\n    var targetBottom = (formHeight + basicFormHeight) / 10;\r\n    return (React.createElement(\"div\", { className: \"pc:hidden w-[37.5rem] h-[4.5rem] bg-blue-1 flex justify-between items-center px-[2rem] \".concat(isFixedBottom &&\r\n            \"absolute left-0\"), style: { bottom: \"\".concat(targetBottom > 40 ? 42.5 : targetBottom, \"rem\") } },\r\n        React.createElement(\"div\", { className: \"flex\" },\r\n            React.createElement(Text, { type: \"B8\", className: \"text-gray-10\" }, nickNameForReply),\r\n            React.createElement(Text, { type: \"B10\", className: \"text-gray-10 ml-[0.4rem]\" }, \"\\uB2D8\\uC5D0\\uAC8C \\uB2F5\\uAE00\\uC744 \\uB0A8\\uAE30\\uB294 \\uC911\")),\r\n        React.createElement(\"button\", { onClick: function () {\r\n                onCloseTarget(false);\r\n            } },\r\n            React.createElement(Close, { size: \"1.5rem\" }))));\r\n};\r\n","references":["/Users/dongyoonkim/Dev/nosearch-react-component/node_modules/@types/react/index.d.ts","/Users/dongyoonkim/Dev/nosearch-react-component/src/components/shared/ns-image.tsx","/Users/dongyoonkim/Dev/nosearch-react-component/src/components/UI/Icon/index.ts","/Users/dongyoonkim/Dev/nosearch-react-component/src/components/UI/Text/index.ts","/Users/dongyoonkim/Dev/nosearch-react-component/src/components/CommentInput/CommentInput.types.ts"],"dts":{"name":"/Users/dongyoonkim/Dev/nosearch-react-component/lib/components/CommentInput/CommentInput.d.ts","writeByteOrderMark":false,"text":"import React from \"react\";\r\nimport { CommentInputProps } from \"./CommentInput.types\";\r\ndeclare const CommentInput: React.FC<CommentInputProps>;\r\nexport default CommentInput;\r\n"}}
