import * as React from 'react'; import styles from '@patternfly/react-styles/css/components/Toolbar/toolbar'; import { css } from '@patternfly/react-styles'; import { RefObject } from 'react'; import { ToolbarGroup } from './ToolbarGroup'; import { ToolbarItem } from './ToolbarItem'; import { Button } from '../Button'; import { ToolbarContext } from './ToolbarUtils'; import { PickOptional } from '../../helpers/typeUtils'; export interface ToolbarExpandableContentProps extends React.HTMLProps { /** Classes added to the root element of the data toolbar expandable content */ className?: string; /** Flag indicating the expandable content is expanded */ isExpanded?: boolean; /** Expandable content reference for passing to data toolbar children */ expandableContentRef?: RefObject; /** Chip container reference for passing to data toolbar children */ chipContainerRef?: RefObject; /** optional callback for clearing all filters in the toolbar */ clearAllFilters?: () => void; /** Text to display in the clear all filters button */ clearFiltersButtonText?: string; /** Flag indicating that the clear all filters button should be visible */ showClearFiltersButton: boolean; } class ToolbarExpandableContent extends React.Component { static displayName = 'ToolbarExpandableContent'; static contextType = ToolbarContext; declare context: React.ContextType; static defaultProps: PickOptional = { isExpanded: false, clearFiltersButtonText: 'Clear all filters' }; render() { const { className, expandableContentRef, chipContainerRef, // eslint-disable-next-line @typescript-eslint/no-unused-vars isExpanded, clearAllFilters, clearFiltersButtonText, showClearFiltersButton, ...props } = this.props; const { numberOfFilters, customChipGroupContent } = this.context; const clearChipGroups = () => { clearAllFilters(); }; return (
{numberOfFilters > 0 && ( {showClearFiltersButton && !customChipGroupContent && ( )} {customChipGroupContent && customChipGroupContent} )}
); } } export { ToolbarExpandableContent };