"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RowContextProvider = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const RowContext_1 = require("../RowContext");
const RowContextProvider = ({ children }) => {
    const [isDisabled, setDisabled] = (0, react_1.useState)(false);
    const [disabledReason, setDisabledReason] = (0, react_1.useState)();
    const addDisabledRow = (0, react_1.useCallback)((reason) => {
        setDisabled(true);
        setDisabledReason(reason);
    }, []);
    const removeDisabledRow = (0, react_1.useCallback)(() => {
        setDisabled(false);
        setDisabledReason(undefined);
    }, []);
    const contextValue = (0, react_1.useMemo)(() => ({
        isDisabled,
        disabledReason,
        addDisabledRow,
        removeDisabledRow,
    }), [isDisabled, disabledReason, addDisabledRow, removeDisabledRow]);
    return ((0, jsx_runtime_1.jsx)(RowContext_1.RowContext.Provider, { value: contextValue, children: children }));
};
exports.RowContextProvider = RowContextProvider;
