"use client";
import { useMemo, useState } from "react";
import { ChevronRight } from "lucide-react";
import { RichText } from "@/components/ui/RichText";
import { ValueView } from "@/components/ui/ValueView";
interface Props {
value: unknown;
label?: string;
threshold?: number;
previewLength?: number;
className?: string;
}
export function LongValueDisclosure({ value, label = "完整内容", threshold = 800, previewLength = 240, className = "" }: Props) {
const text = useMemo(() => printable(value), [value]);
const characters = useMemo(() => Array.from(text), [text]);
const isLong = characters.length > threshold || (Array.isArray(value) && value.length > 5);
const [open, setOpen] = useState(false);
if (!isLong) return
{label}
{characters.length.toLocaleString()} 字符
{!open ? {preview(value, text, previewLength)} : null}
{open ?
(空)
; return