UNPKG

e-virt-table

Version:

A powerful data table based on canvas. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.

50 lines • 1.63 kB
export default class Tooltip { constructor(ctx) { Object.defineProperty(this, "ctx", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "emptyEl", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.ctx = ctx; const { EMPTY_CUSTOM_STYLE } = this.ctx.config; if (this.ctx.emptyElement) { this.emptyEl = this.ctx.emptyElement; } else { this.emptyEl = document.createElement('div'); this.emptyEl.innerText = this.getText(); } this.emptyEl.className = 'e-virt-table-empty'; this.emptyEl.style.display = 'none'; this.ctx.containerElement.appendChild(this.emptyEl); this.ctx.on('emptyChange', ({ type, headerHeight, bodyHeight, footerHeight }) => { const top = headerHeight + (bodyHeight + footerHeight) / 2; const contentStyle = { display: type === 'empty' ? 'block' : 'none', top: `${top}px`, ...EMPTY_CUSTOM_STYLE, }; Object.assign(this.emptyEl.style, contentStyle); }); } getText() { return this.ctx.config.EMPTY_TEXT || this.ctx.locale.getText('emptyText'); } draw() { if (this.ctx.emptyElement) { return; } this.emptyEl.innerText = this.getText(); } destroy() { this.emptyEl.remove(); } } //# sourceMappingURL=Empty.js.map