@carbon/ibm-products
Version:
Carbon for IBM Products
24 lines (22 loc) • 1.01 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const require_settings = require("../../../settings.js");
//#region src/components/DataSpreadsheet/utils/removeCellSelections.js
/**
* Copyright IBM Corp. 2022, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const removeCellSelections = ({ matcher, spreadsheetRef, blockClass = `${require_settings.pkg.prefix}--data-spreadsheet` }) => {
if (matcher && typeof matcher === "string") {
const selectionToRemove = spreadsheetRef.current.querySelector(`[data-matcher-id="${matcher}"]`);
if (selectionToRemove) selectionToRemove.remove();
} else [...spreadsheetRef.current.querySelectorAll(`.${blockClass}__selection-area--element`)].forEach((element) => element.remove());
};
//#endregion
exports.removeCellSelections = removeCellSelections;