| 1 |
"use strict"; |
| 2 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 |
exports.ToolbarExpandableContent = void 0; |
| 4 |
const tslib_1 = require("tslib"); |
| 5 |
const jsx_runtime_1 = require("react/jsx-runtime"); |
| 6 |
const react_1 = require("react"); |
| 7 |
const toolbar_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Toolbar/toolbar")); |
| 8 |
const react_styles_1 = require("@patternfly/react-styles"); |
| 9 |
const ToolbarGroup_1 = require("./ToolbarGroup"); |
| 10 |
const ToolbarItem_1 = require("./ToolbarItem"); |
| 11 |
const Button_1 = require("../Button"); |
| 12 |
const ToolbarUtils_1 = require("./ToolbarUtils"); |
| 13 |
class ToolbarExpandableContent extends react_1.Component { |
| 14 |
render() { |
| 15 |
const _a = this.props, { children, className, expandableContentRef, labelContainerRef, isExpanded, clearAllFilters, clearFiltersButtonText, showClearFiltersButton } = _a, props = tslib_1.__rest(_a, ["children", "className", "expandableContentRef", "labelContainerRef", "isExpanded", "clearAllFilters", "clearFiltersButtonText", "showClearFiltersButton"]); |
| 16 |
const { numberOfFilters, customLabelGroupContent } = this.context; |
| 17 |
const clearLabelGroups = () => { |
| 18 |
clearAllFilters(); |
| 19 |
}; |
| 20 |
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, react_styles_1.css)(toolbar_1.default.toolbarExpandableContent, isExpanded && toolbar_1.default.modifiers.expanded, className), ref: expandableContentRef }, props, { children: [(0, jsx_runtime_1.jsx)(ToolbarGroup_1.ToolbarGroup, { children: children }), numberOfFilters > 0 && ((0, jsx_runtime_1.jsxs)(ToolbarGroup_1.ToolbarGroup, { children: [(0, jsx_runtime_1.jsx)(ToolbarGroup_1.ToolbarGroup, { ref: labelContainerRef }), showClearFiltersButton && !customLabelGroupContent && ((0, jsx_runtime_1.jsx)(ToolbarItem_1.ToolbarItem, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "link", onClick: clearLabelGroups, isInline: true, children: clearFiltersButtonText }) })), customLabelGroupContent && customLabelGroupContent] }))] }))); |
| 21 |
} |
| 22 |
} |
| 23 |
exports.ToolbarExpandableContent = ToolbarExpandableContent; |
| 24 |
ToolbarExpandableContent.displayName = 'ToolbarExpandableContent'; |
| 25 |
ToolbarExpandableContent.contextType = ToolbarUtils_1.ToolbarContext; |
| 26 |
ToolbarExpandableContent.defaultProps = { |
| 27 |
isExpanded: false, |
| 28 |
clearFiltersButtonText: 'Clear all filters' |
| 29 |
}; |
| 30 |
//# sourceMappingURL=ToolbarExpandableContent.js.map |