import { Clipboard as ArkClipboard } from "@ark-ui/react/clipboard"; import { injectComponentStyle } from "@bysages/core/styling"; import type { CSSProperties } from "react"; import type { ComponentProps, HTMLAttributes } from "react"; import { iconNode } from "../../internal/icon"; import { useElementId } from "../../internal/id"; /** Ark's Clipboard, dressed in the paper-and-ink system: a hairline value * field beside an icon-sized copy trigger whose ink turns bamboo while the * copy is confirmed. The API is Ark's own — Root, Label, Control, Input, * Trigger, Indicator, Context, HiddenInput. */ type ClipboardRootProps = ComponentProps & Pick, "className" | "style"> & { /** One rung of the control-height ladder for the value field and * its copy seal. */ size?: "sm" | "md" | "lg"; }; function ClipboardRoot(props: ClipboardRootProps) { injectComponentStyle("clipboard"); const id = useElementId("clipboard", props); const { size = "md", ...rest } = props; return ; } type ClipboardFacadeProps = { value?: string; defaultValue?: string; label?: string; placeholder?: string; size?: "sm" | "md" | "lg"; className?: string; style?: CSSProperties; onValueChange?: (value: string) => void; }; /** The complete copy field behind one value: a labelled read-only input and * its confirmed copy trigger. */ function ClipboardFacade(props: ClipboardFacadeProps) { const { value, defaultValue, label, placeholder, size = "md", className, style, onValueChange, } = props; return ( onValueChange?.(event.value)} > {label ? {label} : null} {iconNode("copy", { width: 14, height: 14 })} ); } export const Clipboard: typeof ClipboardFacade & Omit & { Root: typeof ClipboardRoot } = Object.assign( ClipboardFacade, { ...ArkClipboard, Root: ClipboardRoot, }, ) as typeof ClipboardFacade & Omit & { Root: typeof ClipboardRoot };