import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__Table_Void_mjs__ from "./Table.Void.mjs";
const toArr = (value)=>(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.isArr)(value) ? value : (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.isValid)(value) ? [
        value
    ] : [];
const TableRowSelection = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)((props)=>{
    const { rowKey = 'id', objectValue } = props;
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const rowSelection = {
        type: 'checkbox',
        ...props.rowSelection,
        selectedRowKeys: toArr(field.value).map((val)=>'object' == typeof val ? val[rowKey] : val),
        onChange (selectedRowKeys, selectedRows) {
            if ('checkbox' === rowSelection.type) props.onChange(objectValue ? selectedRows : selectedRowKeys);
            else props.onChange([
                ...objectValue ? selectedRows : selectedRowKeys
            ].shift());
        }
    };
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__Table_Void_mjs__.TableVoid, {
        ...props,
        rowSelection: rowSelection
    });
}, {
    displayName: 'TableRowSelection'
});
export { TableRowSelection };
