UNPKG

3.45 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ToolbarContent = void 0;
4const tslib_1 = require("tslib");
5const React = tslib_1.__importStar(require("react"));
6const toolbar_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Toolbar/toolbar"));
7const react_styles_1 = require("@patternfly/react-styles");
8const ToolbarUtils_1 = require("./ToolbarUtils");
9const util_1 = require("../../helpers/util");
10const ToolbarExpandableContent_1 = require("./ToolbarExpandableContent");
11const Page_1 = require("../Page/Page");
12class ToolbarContent extends React.Component {
13 constructor() {
14 super(...arguments);
15 this.expandableContentRef = React.createRef();
16 this.chipContainerRef = React.createRef();
17 }
18 render() {
19 const _a = this.props, { className, children, isExpanded, toolbarId, visibility, visiblity, alignment, clearAllFilters, showClearFiltersButton, clearFiltersButtonText } = _a, props = tslib_1.__rest(_a, ["className", "children", "isExpanded", "toolbarId", "visibility", "visiblity", "alignment", "clearAllFilters", "showClearFiltersButton", "clearFiltersButtonText"]);
20 if (visiblity !== undefined) {
21 // eslint-disable-next-line no-console
22 console.warn('The ToolbarContent visiblity prop has been deprecated. ' +
23 'Please use the correctly spelled visibility prop instead.');
24 }
25 return (React.createElement(Page_1.PageContext.Consumer, null, ({ width, getBreakpoint }) => (React.createElement("div", Object.assign({ className: react_styles_1.css(toolbar_1.default.toolbarContent, util_1.formatBreakpointMods(visibility || visiblity, toolbar_1.default, '', getBreakpoint(width)), util_1.formatBreakpointMods(alignment, toolbar_1.default, '', getBreakpoint(width)), className) }, props),
26 React.createElement(ToolbarUtils_1.ToolbarContext.Consumer, null, ({ clearAllFilters: clearAllFiltersContext, clearFiltersButtonText: clearFiltersButtonContext, showClearFiltersButton: showClearFiltersButtonContext, toolbarId: toolbarIdContext }) => {
27 const expandableContentId = `${toolbarId ||
28 toolbarIdContext}-expandable-content-${ToolbarContent.currentId++}`;
29 return (React.createElement(ToolbarUtils_1.ToolbarContentContext.Provider, { value: {
30 expandableContentRef: this.expandableContentRef,
31 expandableContentId,
32 chipContainerRef: this.chipContainerRef
33 } },
34 React.createElement("div", { className: react_styles_1.css(toolbar_1.default.toolbarContentSection) }, children),
35 React.createElement(ToolbarExpandableContent_1.ToolbarExpandableContent, { id: expandableContentId, isExpanded: isExpanded, expandableContentRef: this.expandableContentRef, chipContainerRef: this.chipContainerRef, clearAllFilters: clearAllFilters || clearAllFiltersContext, showClearFiltersButton: showClearFiltersButton || showClearFiltersButtonContext, clearFiltersButtonText: clearFiltersButtonText || clearFiltersButtonContext })));
36 })))));
37 }
38}
39exports.ToolbarContent = ToolbarContent;
40ToolbarContent.displayName = 'ToolbarContent';
41ToolbarContent.currentId = 0;
42ToolbarContent.defaultProps = {
43 isExpanded: false,
44 showClearFiltersButton: false
45};
46//# sourceMappingURL=ToolbarContent.js.map
\No newline at end of file