import "./components/ui/tidal.css"; import { useState, useRef, useLayoutEffect } from "react"; import { TidalResponseFeedback, type TidalFeedbackChoice } from "./components/ui/response-feedback"; import "./components/ui/response-feedback.css"; export function ResponseFeedbackDemo() { const form = useRef(null), editSource = useRef(null); const [choice, setChoice] = useState(null), [reasons, setReasons] = useState([]), [comment, setComment] = useState(""), [success, setSuccess] = useState(""); useLayoutEffect(() => { const source = editSource.current; if (success || !source) return; editSource.current = null; const active = source.ownerDocument.activeElement; if (active === source || active === source.ownerDocument.body) form.current?.focus({ preventScroll: true }); }, [success]); return (
{ e.preventDefault(); const data = new FormData(e.currentTarget); setSuccess(`Feedback kept in this preview: ${data.get("feedback")}.`); }} textareaProps={{ placeholder: "What would make this response more useful?", maxLength: 1000, }} /> {success && ( )}
); } export default function AgentExample() { return (
); }