import { css } from 'ecij'; import type { RenderEditCellContentProps } from '../types'; const textEditorInternalClassname = css` @layer rdg.TextEditor { appearance: none; box-sizing: border-box; inline-size: 100%; block-size: 100%; padding-block: 0; padding-inline: 6px; border: 2px solid light-dark(#8f8f8f, #ccc); vertical-align: top; color: var(--rdg-color); background-color: var(--rdg-background-color); font-family: inherit; font-size: var(--rdg-font-size); &:focus { border-color: var(--rdg-selection-color); outline: none; } &::placeholder { color: light-dark(#767676, #999); opacity: 1; } } `; export const textEditorClassname = `rdg-text-editor ${textEditorInternalClassname}`; function autoFocusAndSelect(input: HTMLInputElement | null) { input?.focus(); input?.select(); } export function renderTextEditor({ row, column, onRowChange, onClose }: RenderEditCellContentProps) { return ( onRowChange({ ...row, [column.key]: event.target.value })} onBlur={() => onClose(true, false)} /> ); }