@antv/s2
Version:
effective spreadsheet render core lib
38 lines • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateAllHeaderCellState = exports.getActiveHoverHeaderCells = void 0;
const lodash_1 = require("lodash");
const constant_1 = require("../../common/constant");
const generate_id_1 = require("../layout/generate-id");
/**
* @description Return all the row cells or column cells which are needed to be highlighted.
* @param id rowId or colId
* @param headerCells all the rowHeader cells or all the colHeader cells
* @param isHierarchyTree The tree mode will only highlight the leaf nodes at the head of the row
*/
const getActiveHoverHeaderCells = (id, headerCells, isHierarchyTree) => {
let allHeaderIds;
const ids = id.split(constant_1.NODE_ID_SEPARATOR);
if (isHierarchyTree) {
allHeaderIds = [id];
}
else {
allHeaderIds = [(0, generate_id_1.generateId)(ids[0], ids[1])];
for (let i = 2; i < ids.length; i += 1) {
allHeaderIds.push((0, generate_id_1.generateId)(allHeaderIds[i - 2], ids[i]));
}
}
const allHeaderCells = (0, lodash_1.filter)(headerCells, (cell) => { var _a; return allHeaderIds.includes((_a = cell.getMeta()) === null || _a === void 0 ? void 0 : _a.id); });
return allHeaderCells;
};
exports.getActiveHoverHeaderCells = getActiveHoverHeaderCells;
const updateAllHeaderCellState = (id, headerCells, stateName) => {
if (id) {
const allColHeaderCells = (0, exports.getActiveHoverHeaderCells)(id, headerCells);
(0, lodash_1.forEach)(allColHeaderCells, (cell) => {
cell.updateByState(stateName);
});
}
};
exports.updateAllHeaderCellState = updateAllHeaderCellState;
//# sourceMappingURL=hover-event.js.map