/* Copyright 2026 Marimo. All rights reserved. */ import type { JSX } from "react"; import { z } from "zod"; import { cn } from "@/utils/cn"; import { DebouncedTextarea, OnBlurredTextarea, Textarea, } from "../../components/ui/textarea"; import type { IPlugin, IPluginProps, Setter } from "../types"; import { Labeled } from "./common/labeled"; type T = string; interface Data { placeholder: string; label: string | null; maxLength?: number; minLength?: number; disabled?: boolean; debounce?: boolean | number; rows: number; fullWidth: boolean; } export class TextAreaPlugin implements IPlugin { tagName = "marimo-text-area"; validator = z.object({ initialValue: z.string(), placeholder: z.string(), label: z.string().nullable(), maxLength: z.number().optional(), minLength: z.number().optional(), disabled: z.boolean().optional(), debounce: z.optional(z.union([z.boolean(), z.number()])), rows: z.number().default(4), fullWidth: z.boolean().default(false), }); render(props: IPluginProps): JSX.Element { return ( ); } } interface TextAreaComponentProps extends Data { value: T; setValue: Setter; } const TextAreaComponent = (props: TextAreaComponentProps) => { const bottomAdornment = props.maxLength ? ( {props.value.length}/{props.maxLength} ) : null; if (props.debounce === true) { return ( 0} disabled={props.disabled} bottomAdornment={bottomAdornment} value={props.value} onValueChange={props.setValue} placeholder={props.placeholder} /> ); } if (typeof props.debounce === "number") { return ( 0} disabled={props.disabled} bottomAdornment={bottomAdornment} value={props.value} onValueChange={props.setValue} placeholder={props.placeholder} delay={props.debounce} /> ); } return (