/**
 * 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.
 */

import { pkg } from "../../../settings.js";
import { useEffect } from "react";
//#region src/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.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 useResetSpreadsheetFocus = ({ blockClass = `${pkg.prefix}--data-spreadsheet`, focusedElement, removeActiveCell, setContainerHasFocus }) => {
	useEffect(() => {
		if (!focusedElement.classList.contains(`${blockClass}--interactive-cell-element`)) {
			setContainerHasFocus(false);
			removeActiveCell();
		}
		if (focusedElement.classList.contains(blockClass) || focusedElement.classList.contains(`${blockClass}--interactive-cell-element`)) setContainerHasFocus(true);
	}, [
		focusedElement,
		removeActiveCell,
		blockClass,
		setContainerHasFocus
	]);
};
//#endregion
export { useResetSpreadsheetFocus };
