import React, { useEffect, useRef, useState } from "react"; import { CloseIcon, KebabIcon } from "../../icons/ExportCommonIcons"; import Messages from "./Messages"; import { ExpandIcon } from "../../icons/SimulationIcons"; import { adjustHeight } from "./function/textAreaHeightAdjust"; const ThreadChat: React.FC = () => { const [openThreadOptions, setOpenThreadOptions] = useState(false); const [inputActive, setInputActive] = useState(false); const [value, setValue] = useState(""); const textareaRef = useRef(null); const wrapperRef = useRef(null); const [dragging, setDragging] = useState(false); const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 }); const [position, setPosition] = useState({ x: 100, y: 100 }); const messages = [ { replyId: "user 1", creatorId: "1", createdAt: "2 hrs ago", lastUpdatedAt: "2 hrs ago", reply: "reply testing reply content 1, reply testing reply content 1reply testing reply content 1", }, { replyId: "user 2", creatorId: "2", createdAt: "2 hrs ago", lastUpdatedAt: "2 hrs ago", reply: "reply 2", }, ]; useEffect(() => { if (textareaRef.current) adjustHeight(textareaRef.current); }, [value]); const clamp = (val: number, min: number, max: number) => { return Math.min(Math.max(val, min), max); }; const handlePointerDown = (event: React.PointerEvent) => { if (event.button !== 0) return; const wrapper = wrapperRef.current; if (!wrapper) return; const rect = wrapper.getBoundingClientRect(); const offsetX = event.clientX - rect.left; const offsetY = event.clientY - rect.top; setDragging(true); setDragOffset({ x: offsetX, y: offsetY }); wrapper.setPointerCapture(event.pointerId); }; const handlePointerMove = (event: React.PointerEvent) => { if (!dragging) return; const container = document.getElementById("work-space-three-d-canvas"); const wrapper = wrapperRef.current; if (!container || !wrapper) return; const containerRect = container.getBoundingClientRect(); const wrapperRect = wrapper.getBoundingClientRect(); let newX = event.clientX - containerRect.left - dragOffset.x; let newY = event.clientY - containerRect.top - dragOffset.y; const maxX = containerRect.width - wrapper.offsetWidth; const maxY = containerRect.height - wrapper.offsetHeight; newX = clamp(newX, 0, maxX); newY = clamp(newY, 0, maxY); setPosition({ x: newX, y: newY }); }; const handlePointerUp = (event: React.PointerEvent) => { if (!dragging) return; setDragging(false); const wrapper = wrapperRef.current; if (wrapper) wrapper.releasePointerCapture(event.pointerId); }; return (
Comment
{openThreadOptions && (
Mark as Unread
Mark as Resolved
Delete Thread
)}
{messages.map((val, i) => ( ))}