UNPKG

@visactor/vtable

Version:

canvas table width high performance

33 lines (32 loc) 1.4 kB
import { Env } from "../tools/env"; export class FocusInput extends EventTarget { constructor(table, parentElement) { if (super(), this._table = table, "node" === Env.mode) return; const div = document.createElement("div"); div.style.opacity = "0", div.dataset.vtable = "vtable", div.style.pointerEvents = "none", div.classList.add("input-container"); const input = this._input = document.createElement("input"); div.appendChild(input), input.classList.add("table-focus-control"), input.dataset.vtable = "vtable", input.readOnly = !0, parentElement.appendChild(div), this._container = div; } focus() { this._input.focus({ preventScroll: !0 }); } setFocusRect(rect, value) { const input = this._input; input.value = value, input.select(); const top = rect.top - this._table.scrollTop, left = rect.left - this._table.scrollLeft; input.style.top = `${top.toFixed()}px`, input.style.left = `${left.toFixed()}px`, input.style.width = `${rect.width.toFixed()}px`, input.style.height = `${rect.height.toFixed()}px`; } get input() { return this._input; } release() { var _a; null === (_a = this._container.parentElement) || void 0 === _a || _a.removeChild(this._container); } } //# sourceMappingURL=FouseInput.js.map