UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

48 lines 1.96 kB
import { InterceptType, S2Event } from '../../../common/constant'; import { CellData } from '../../../data-set/cell-data'; import { BaseEvent } from '../../base-event'; export class HeaderCellLinkClick extends BaseEvent { constructor() { super(...arguments); this.getCellData = (node) => { var _a, _b; const leafNode = node.getHeadLeafChild(); const data = this.spreadsheet.dataSet.getCellMultiData({ query: leafNode === null || leafNode === void 0 ? void 0 : leafNode.query, })[0]; const originalData = CellData.getFieldValue(data); return Object.assign(Object.assign({}, originalData), { rowIndex: (_a = node.rowIndex) !== null && _a !== void 0 ? _a : leafNode === null || leafNode === void 0 ? void 0 : leafNode.rowIndex, colIndex: (_b = node.colIndex) !== null && _b !== void 0 ? _b : leafNode === null || leafNode === void 0 ? void 0 : leafNode.colIndex }); }; } bindEvents() { this.bindRowCellClick(); this.bindColCellClick(); } onHeaderCellClick(event) { if (this.spreadsheet.interaction.hasIntercepts([InterceptType.CLICK])) { return; } if (!this.isLinkFieldText(event.target)) { return; } const { meta } = this.getCellAppendInfo(event.target); const field = meta.field; const rowData = this.getCellData(meta); this.spreadsheet.emit(S2Event.GLOBAL_LINK_FIELD_JUMP, { field, meta: meta, record: rowData, }); } bindRowCellClick() { this.spreadsheet.on(S2Event.ROW_CELL_CLICK, (event) => { this.onHeaderCellClick(event); }); } bindColCellClick() { this.spreadsheet.on(S2Event.COL_CELL_CLICK, (event) => { this.onHeaderCellClick(event); }); } } //# sourceMappingURL=header-cell-link-click.js.map