/** @jsxImportSource react */ import { ContainerBase, StyledContainerConfig } from "../../ui/Container"; import { VDOM } from "../../ui/VDOM"; import { findFirstChild, isFocusable, isFocusedDeep } from "../../util/DOM"; import { Instance } from "../../ui/Instance"; import { RenderingContext } from "../../ui/RenderingContext"; export interface GridCellEditorConfig extends StyledContainerConfig {} export class GridCellEditor extends ContainerBase { constructor(config?: GridCellEditorConfig) { super(config); } render(context: RenderingContext, instance: Instance, key: string) { let { data } = instance; return ( {this.renderChildren(context, instance)} ); } } GridCellEditor.prototype.styled = true; interface GridCellEditorCmpProps { className?: string; style?: React.CSSProperties; children?: React.ReactNode; } class GridCellEditorCmp extends VDOM.Component { el: HTMLDivElement | null = null; render() { let { className, style, children } = this.props; return (
{ this.el = el; }} className={className} style={style} > {children}
); } componentDidMount() { if (!isFocusedDeep(this.el!)) { let focusableChild = findFirstChild(this.el!, isFocusable); if (focusableChild) focusableChild.focus(); } } }