@carbon/ibm-products
Version:
Carbon for IBM Products
29 lines (25 loc) • 850 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.
*/
import { pkg } from '../../../settings.js';
// Removes the cell selection elements
const removeCellSelections = _ref => {
let {
matcher,
spreadsheetRef,
blockClass = `${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());
}
};
export { removeCellSelections };