@carbon/ibm-products
Version:
Carbon for IBM Products
31 lines (26 loc) • 898 B
JavaScript
/**
* Copyright IBM Corp. 2020, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
;
var settings = require('../../../settings.js');
// Removes the cell selection elements
const removeCellSelections = _ref => {
let {
matcher,
spreadsheetRef,
blockClass = `${settings.pkg.prefix}--data-spreadsheet`
} = _ref;
if (matcher && typeof matcher === 'string') {
const selectionToRemove = spreadsheetRef.current.querySelector(`[data-matcher-id="${matcher}"]`);
if (selectionToRemove) {
selectionToRemove.remove();
}
} else {
const cellSelections = spreadsheetRef.current.querySelectorAll(`.${blockClass}__selection-area--element`);
[...cellSelections].forEach(element => element.remove());
}
};
exports.removeCellSelections = removeCellSelections;