import { Box, Page, Table } from '@wix/design-system'; import React, { FunctionComponent, ReactNode } from 'react'; import { ToolbarCollectionState } from '../../state'; import { observer } from 'mobx-react-lite'; import { CollectionToolbar } from '../CollectionToolbar'; import { FiltersMap } from '@wix/bex-core'; import { PartialFunctionComponent } from '../PartialFunctionComponent'; import { CollectionToolbarsProvider } from './CollectionToolbarsProvider'; import { ToolbarAndTitlebarContainer } from './ToolbarAndTitlebarContainer'; import { ToolbarCollectionBaseProps } from '../ToolbarCollection'; import { TopNotificationBasicRenderProp } from '../TableTopNotification'; import { useIsMobile } from '../../hooks/useIsMobile'; import { useBmHarmonyTheme } from '../../hooks/useBmHarmonyTheme'; import { CollectionToolbarsVisualization, CollectionToolbarsVisualizationProps, } from './CollectionToolbarsVisualization'; import { useIsCollectionToolbarExists } from '../CollectionToolbar/useIsCollectionToolbarExists'; export interface CollectionToolbarsProps extends Pick< ToolbarCollectionBaseProps, | 'showTitleBar' | 'tags' | 'sticky' | 'title' | 'tabs' | 'search' | 'customColumns' | 'multiLevelSorting' | 'views' | 'filters' | 'selectionToolbar' | 'dragAndDropReorderModeToolbar' | 'extraToolbar' | 'summaryBar' | 'tableGridSwitchButton' | 'exportButton' | 'importButton' | 'primaryActionButton' | 'secondaryActions' | 'moreActions' > { state: ToolbarCollectionState; topNotification?: TopNotificationBasicRenderProp; titleBar?: ReactNode; visualization?: CollectionToolbarsVisualizationProps['visualization']; } function BorderRadiusTopCard({ children }: { children?: ReactNode }) { const isMobile = useIsMobile(); return ( {children} ); } function BorderRadiusTopBottomCard({ children }: { children?: ReactNode }) { const isMobile = useIsMobile(); return ( {children} ); } function _CollectionToolbars( props: CollectionToolbarsProps, ) { const { sticky, state, selectionToolbar, extraToolbar, summaryBar, topNotification: topNotificationProp, titleBar, visualization: customSlot, } = props; const { collection, featuredComponents, hasSubToolbarComponents, shouldDisplayFiltersTags, bulk: { selectedIds }, internalScroll, container: { isPanelLayout }, } = state; const isMobile = useIsMobile(); const isBmHarmonyTheme = useBmHarmonyTheme(); const topNotification = isPanelLayout ? undefined : typeof topNotificationProp === 'function' ? topNotificationProp() : topNotificationProp; const AppliedFiltersTagList = featuredComponents.appliedFiltersTagList.value ?.component as PartialFunctionComponent as FunctionComponent | null; const { showRefreshLoader } = collection; const shouldDisplaySubToolbar = shouldDisplayFiltersTags && hasSubToolbarComponents; const shouldRenderCollectionToolbar = useIsCollectionToolbarExists(props); const toolbars = ( <> {selectionToolbar && !showRefreshLoader && selectedIds.length > 0 ? ( selectionToolbar ) : ( <> {extraToolbar} {(!isMobile || shouldRenderCollectionToolbar) && ( )} )} {shouldDisplaySubToolbar && (isBmHarmonyTheme ? ( {AppliedFiltersTagList && shouldDisplayFiltersTags && ( )} ) : ( {AppliedFiltersTagList && shouldDisplayFiltersTags && ( )} ))} {summaryBar} {topNotification} ); /* wrapping with Card is WSR way to make the sticky table header not to add extra border between the header and the content https://www.docs.wixdesignsystem.com/?path=/story/components-lists-table--table#Sticky_Toolbar_&_Sub-toolbar*/ const child = ( {customSlot ? ( <> {toolbars} {titleBar} ) : ( {toolbars} {titleBar} )} ); return ( {sticky && !internalScroll ? ( {child} ) : ( child )} ); } export const CollectionToolbars = observer(_CollectionToolbars);