"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSingleSelectProps = getSingleSelectProps;
const consoleWarning_1 = require("../../../../utils/helpers/consoleWarning");
const selection_utils_1 = require("./selection.utils");
function getSingleSelectProps({ selectedKeysSet, setSelectedKeys, name, enableRowSelection, }) {
    const handleSelectionChange = (key, row) => {
        if (!row) {
            (0, consoleWarning_1.consoleWarning)(`DataGrid.Table: Row data is undefined for key ${key}. This may cause issues with selection if enableRowSelection is used.`);
        }
        if (!(0, selection_utils_1.canSelectTableRow)(enableRowSelection, { row, id: key })) {
            return;
        }
        setSelectedKeys([key]);
    };
    return {
        getRowRadioProps: (key, row) => {
            const isSelectionDisabled = !(0, selection_utils_1.canSelectTableRow)(enableRowSelection, {
                row,
                id: key,
            });
            return {
                checked: selectedKeysSet.has(key),
                onChange: isSelectionDisabled
                    ? () => null
                    : () => handleSelectionChange(key, row),
                disabled: isSelectionDisabled,
                value: key,
                name,
            };
        },
        toggleSelection: handleSelectionChange,
    };
}
//# sourceMappingURL=getSingleSelectProps.js.map