import { Box, usePageScrollContext } from '@wix/design-system';
import React, { useEffect, useState, } from 'react';
import { assertComponentType, } from '../assertComponentType';
import { CollectionToolbars } from '../CollectionToolbars';
import { checkConflictingToolbarProps } from './checkConflictingToolbarProps';
export function ToolbarCollection(props) {
    const { state, filters, title, tabs, views, extraToolbar, selectionToolbar, dragAndDropReorderModeToolbar, sticky: stickyProp, search, children, tableGridSwitchButton, exportButton, importButton, primaryActionButton, secondaryActions, moreActions, summaryBar, topNotification, } = props;
    assertComponentType(views, 'CollectionViewsDropdown', 'views');
    checkConflictingToolbarProps(props);
    const { scrollableContentRef: scrollablePageRef } = usePageScrollContext();
    const [sticky, setSticky] = useState(stickyProp ?? scrollablePageRef?.current != null);
    useEffect(() => {
        setSticky(stickyProp ?? scrollablePageRef?.current != null);
    }, [stickyProp]);
    return (React.createElement(React.Fragment, null,
        React.createElement(CollectionToolbars, { sticky: sticky, state: state, search: search, views: views, title: title, tabs: tabs, filters: filters, selectionToolbar: selectionToolbar, dragAndDropReorderModeToolbar: dragAndDropReorderModeToolbar, extraToolbar: extraToolbar, tableGridSwitchButton: tableGridSwitchButton, exportButton: exportButton, importButton: importButton, primaryActionButton: primaryActionButton, secondaryActions: secondaryActions, moreActions: moreActions, summaryBar: summaryBar, topNotification: typeof topNotification === 'function'
                ? () => topNotification({ query: state.collection.result.originQuery })
                : topNotification, titleBar: React.createElement(Box, { width: "100%", borderTopColor: "D60", borderTopWidth: "1px", borderTopStyle: "solid", boxSizing: "border-box" }) }),
        React.createElement(Box, { dataHook: "toolbar-collection-content", width: "100%", direction: "vertical", minHeight: 0, flex: 1, verticalAlign: "middle" }, children)));
}
//# sourceMappingURL=ToolbarCollection.js.map