@antv/s2
Version:
effective spreadsheet render core lib
52 lines • 2.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HeaderCellLinkClick = void 0;
const constant_1 = require("../../../common/constant");
const cell_data_1 = require("../../../data-set/cell-data");
const base_event_1 = require("../../base-event");
class HeaderCellLinkClick extends base_event_1.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 = cell_data_1.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([constant_1.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(constant_1.S2Event.GLOBAL_LINK_FIELD_JUMP, {
field,
meta: meta,
record: rowData,
});
}
bindRowCellClick() {
this.spreadsheet.on(constant_1.S2Event.ROW_CELL_CLICK, (event) => {
this.onHeaderCellClick(event);
});
}
bindColCellClick() {
this.spreadsheet.on(constant_1.S2Event.COL_CELL_CLICK, (event) => {
this.onHeaderCellClick(event);
});
}
}
exports.HeaderCellLinkClick = HeaderCellLinkClick;
//# sourceMappingURL=header-cell-link-click.js.map