import * as React from 'react';
import { TreeDataSource, TreeGrid, } from '../../InfiniteTable';
import { Flex } from '../../Flex';
import clsx from 'clsx';
const columns = {
    label: {
        field: 'label',
        header: 'Label',
        defaultFlex: 1,
        renderTreeIcon: true,
        renderSelectionCheckBox: true,
        defaultSortable: false,
    },
};
const domProps = {
    className: 'ab-TreeList twa:flex-1 twa:h-full',
};
const DEFAULT_TREE_EXPAND_STATE = {
    expandedPaths: [],
    defaultExpanded: false,
};
export function TreeList(props) {
    return (React.createElement(Flex, { flexDirection: 'column', className: "ab-TreeList twa:flex-1", style: props.style },
        React.createElement(TreeDataSource, { data: props.options, primaryKey: props.primaryKey ?? 'id', defaultTreeSelection: props.defaultTreeSelection, treeSelection: props.treeSelection, onTreeSelectionChange: props.onTreeSelectionChange, treeFilterFunction: props.treeFilterFunction, onTreeExpandStateChange: props.onTreeExpandStateChange, defaultTreeExpandState: props.defaultTreeExpandState ?? DEFAULT_TREE_EXPAND_STATE },
            React.createElement(TreeGrid, { defaultActiveRowIndex: 0, onReady: props.onReady, debugId: props.debugId, keyboardSelection: true, rowHeight: props.rowHeight ?? '--ab-grid-row-height', keyboardNavigation: "row", columnHeaderHeight: props.columnHeaderHeight, domProps: {
                    ...domProps,
                    ...props.domProps,
                    className: clsx(domProps.className, props.domProps?.className),
                    style: { ...domProps.style, ...props.domProps?.style },
                }, columns: props.columns ?? columns, showZebraRows: false }))));
}
