@patternfly/react-core 4.192.6 → 4.192.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/esm/components/Masthead/Masthead.d.ts.map +1 -1
- package/dist/esm/components/Masthead/Masthead.js +6 -2
- package/dist/esm/components/Masthead/Masthead.js.map +1 -1
- package/dist/esm/components/Nav/Nav.d.ts +4 -2
- package/dist/esm/components/Nav/Nav.d.ts.map +1 -1
- package/dist/esm/components/Nav/Nav.js +2 -1
- package/dist/esm/components/Nav/Nav.js.map +1 -1
- package/dist/esm/components/Nav/NavList.d.ts +2 -8
- package/dist/esm/components/Nav/NavList.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavList.js +4 -7
- package/dist/esm/components/Nav/NavList.js.map +1 -1
- package/dist/esm/components/Page/Page.d.ts +14 -0
- package/dist/esm/components/Page/Page.d.ts.map +1 -1
- package/dist/esm/components/Page/Page.js +31 -16
- package/dist/esm/components/Page/Page.js.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.d.ts.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.js +3 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.js.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.d.ts.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.js +7 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.js.map +1 -1
- package/dist/esm/components/Page/PageSidebar.d.ts +1 -0
- package/dist/esm/components/Page/PageSidebar.d.ts.map +1 -1
- package/dist/esm/components/Page/PageSidebar.js +3 -2
- package/dist/esm/components/Page/PageSidebar.js.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.js +3 -2
- package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.js +3 -2
- package/dist/esm/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.js +2 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.js +3 -2
- package/dist/esm/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js +8 -5
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/esm/helpers/util.d.ts +16 -8
- package/dist/esm/helpers/util.d.ts.map +1 -1
- package/dist/esm/helpers/util.js +53 -7
- package/dist/esm/helpers/util.js.map +1 -1
- package/dist/js/components/Masthead/Masthead.d.ts.map +1 -1
- package/dist/js/components/Masthead/Masthead.js +6 -2
- package/dist/js/components/Masthead/Masthead.js.map +1 -1
- package/dist/js/components/Nav/Nav.d.ts +4 -2
- package/dist/js/components/Nav/Nav.d.ts.map +1 -1
- package/dist/js/components/Nav/Nav.js +3 -2
- package/dist/js/components/Nav/Nav.js.map +1 -1
- package/dist/js/components/Nav/NavList.d.ts +2 -8
- package/dist/js/components/Nav/NavList.d.ts.map +1 -1
- package/dist/js/components/Nav/NavList.js +4 -7
- package/dist/js/components/Nav/NavList.js.map +1 -1
- package/dist/js/components/Page/Page.d.ts +14 -0
- package/dist/js/components/Page/Page.d.ts.map +1 -1
- package/dist/js/components/Page/Page.js +34 -19
- package/dist/js/components/Page/Page.js.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.d.ts.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.js +3 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.js.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsItem.d.ts.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsItem.js +6 -1
- package/dist/js/components/Page/PageHeaderToolsItem.js.map +1 -1
- package/dist/js/components/Page/PageSidebar.d.ts +1 -0
- package/dist/js/components/Page/PageSidebar.d.ts.map +1 -1
- package/dist/js/components/Page/PageSidebar.js +4 -3
- package/dist/js/components/Page/PageSidebar.js.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.js +3 -2
- package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.js +3 -2
- package/dist/js/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.js +2 -1
- package/dist/js/components/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.js +3 -2
- package/dist/js/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js +7 -4
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/js/helpers/util.d.ts +16 -8
- package/dist/js/helpers/util.d.ts.map +1 -1
- package/dist/js/helpers/util.js +55 -8
- package/dist/js/helpers/util.js.map +1 -1
- package/dist/umd/react-core.css +913 -913
- package/dist/umd/react-core.js +420 -347
- package/dist/umd/react-core.min.css +72 -72
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +5 -5
- package/src/components/Masthead/Masthead.tsx +23 -16
- package/src/components/Masthead/__tests__/__snapshots__/Masthead.test.tsx.snap +11 -11
- package/src/components/Nav/Nav.tsx +4 -2
- package/src/components/Nav/NavList.tsx +4 -7
- package/src/components/Page/Page.tsx +49 -16
- package/src/components/Page/PageHeaderToolsGroup.tsx +16 -5
- package/src/components/Page/PageHeaderToolsItem.tsx +20 -14
- package/src/components/Page/PageSidebar.tsx +3 -3
- package/src/components/Page/__tests__/Generated/__snapshots__/Page.test.tsx.snap +2 -0
- package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +18 -9
- package/src/components/Toolbar/Toolbar.tsx +44 -39
- package/src/components/Toolbar/ToolbarContent.tsx +45 -40
- package/src/components/Toolbar/ToolbarGroup.tsx +19 -14
- package/src/components/Toolbar/ToolbarItem.tsx +30 -19
- package/src/components/Toolbar/ToolbarToggleGroup.tsx +60 -53
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/Toolbar.test.tsx.snap +3 -43
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarContent.test.tsx.snap +3 -7
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarItem.test.tsx.snap +3 -8
- package/src/demos/Page/Page.md +92 -43
- package/src/helpers/util.ts +61 -12
|
@@ -6,6 +6,7 @@ import { ToolbarContext } from './ToolbarUtils';
|
|
|
6
6
|
import { ToolbarChipGroupContent } from './ToolbarChipGroupContent';
|
|
7
7
|
import { formatBreakpointMods, canUseDOM } from '../../helpers/util';
|
|
8
8
|
import { getDefaultOUIAId, getOUIAProps, OUIAProps } from '../../helpers';
|
|
9
|
+
import { PageContext } from '../Page/Page';
|
|
9
10
|
|
|
10
11
|
export interface ToolbarProps extends React.HTMLProps<HTMLDivElement>, OUIAProps {
|
|
11
12
|
/** Optional callback for clearing all filters in the toolbar */
|
|
@@ -139,46 +140,50 @@ export class Toolbar extends React.Component<ToolbarProps, ToolbarState> {
|
|
|
139
140
|
const showClearFiltersButton = numberOfFilters > 0;
|
|
140
141
|
|
|
141
142
|
return (
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
<PageContext.Consumer>
|
|
144
|
+
{({ width, getBreakpoint }) => (
|
|
145
|
+
<div
|
|
146
|
+
className={css(
|
|
147
|
+
styles.toolbar,
|
|
148
|
+
isFullHeight && styles.modifiers.fullHeight,
|
|
149
|
+
isStatic && styles.modifiers.static,
|
|
150
|
+
usePageInsets && styles.modifiers.pageInsets,
|
|
151
|
+
isSticky && styles.modifiers.sticky,
|
|
152
|
+
formatBreakpointMods(inset, styles, '', getBreakpoint(width)),
|
|
153
|
+
className
|
|
154
|
+
)}
|
|
155
|
+
id={randomId}
|
|
156
|
+
{...getOUIAProps(Toolbar.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId)}
|
|
157
|
+
{...props}
|
|
158
|
+
>
|
|
159
|
+
<ToolbarContext.Provider
|
|
160
|
+
value={{
|
|
161
|
+
isExpanded,
|
|
162
|
+
toggleIsExpanded: isToggleManaged ? this.toggleIsExpanded : toggleIsExpanded,
|
|
163
|
+
chipGroupContentRef: this.chipGroupContentRef,
|
|
164
|
+
updateNumberFilters: this.updateNumberFilters,
|
|
165
|
+
numberOfFilters,
|
|
166
|
+
clearAllFilters,
|
|
167
|
+
clearFiltersButtonText,
|
|
168
|
+
showClearFiltersButton,
|
|
169
|
+
toolbarId: randomId
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
{children}
|
|
173
|
+
<ToolbarChipGroupContent
|
|
174
|
+
isExpanded={isExpanded}
|
|
175
|
+
chipGroupContentRef={this.chipGroupContentRef}
|
|
176
|
+
clearAllFilters={clearAllFilters}
|
|
177
|
+
showClearFiltersButton={showClearFiltersButton}
|
|
178
|
+
clearFiltersButtonText={clearFiltersButtonText}
|
|
179
|
+
numberOfFilters={numberOfFilters}
|
|
180
|
+
numberOfFiltersText={numberOfFiltersText}
|
|
181
|
+
collapseListedFiltersBreakpoint={collapseListedFiltersBreakpoint}
|
|
182
|
+
/>
|
|
183
|
+
</ToolbarContext.Provider>
|
|
184
|
+
</div>
|
|
151
185
|
)}
|
|
152
|
-
|
|
153
|
-
{...getOUIAProps(Toolbar.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId)}
|
|
154
|
-
{...props}
|
|
155
|
-
>
|
|
156
|
-
<ToolbarContext.Provider
|
|
157
|
-
value={{
|
|
158
|
-
isExpanded,
|
|
159
|
-
toggleIsExpanded: isToggleManaged ? this.toggleIsExpanded : toggleIsExpanded,
|
|
160
|
-
chipGroupContentRef: this.chipGroupContentRef,
|
|
161
|
-
updateNumberFilters: this.updateNumberFilters,
|
|
162
|
-
numberOfFilters,
|
|
163
|
-
clearAllFilters,
|
|
164
|
-
clearFiltersButtonText,
|
|
165
|
-
showClearFiltersButton,
|
|
166
|
-
toolbarId: randomId
|
|
167
|
-
}}
|
|
168
|
-
>
|
|
169
|
-
{children}
|
|
170
|
-
<ToolbarChipGroupContent
|
|
171
|
-
isExpanded={isExpanded}
|
|
172
|
-
chipGroupContentRef={this.chipGroupContentRef}
|
|
173
|
-
clearAllFilters={clearAllFilters}
|
|
174
|
-
showClearFiltersButton={showClearFiltersButton}
|
|
175
|
-
clearFiltersButtonText={clearFiltersButtonText}
|
|
176
|
-
numberOfFilters={numberOfFilters}
|
|
177
|
-
numberOfFiltersText={numberOfFiltersText}
|
|
178
|
-
collapseListedFiltersBreakpoint={collapseListedFiltersBreakpoint}
|
|
179
|
-
/>
|
|
180
|
-
</ToolbarContext.Provider>
|
|
181
|
-
</div>
|
|
186
|
+
</PageContext.Consumer>
|
|
182
187
|
);
|
|
183
188
|
};
|
|
184
189
|
|
|
@@ -4,6 +4,7 @@ import { css } from '@patternfly/react-styles';
|
|
|
4
4
|
import { ToolbarContentContext, ToolbarContext } from './ToolbarUtils';
|
|
5
5
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
6
6
|
import { ToolbarExpandableContent } from './ToolbarExpandableContent';
|
|
7
|
+
import { PageContext } from '../Page/Page';
|
|
7
8
|
|
|
8
9
|
export interface ToolbarContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
9
10
|
/** Classes applied to root element of the data toolbar content row */
|
|
@@ -81,47 +82,51 @@ export class ToolbarContent extends React.Component<ToolbarContentProps> {
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
return (
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
<PageContext.Consumer>
|
|
86
|
+
{({ width, getBreakpoint }) => (
|
|
87
|
+
<div
|
|
88
|
+
className={css(
|
|
89
|
+
styles.toolbarContent,
|
|
90
|
+
formatBreakpointMods(visibility || visiblity, styles, '', getBreakpoint(width)),
|
|
91
|
+
formatBreakpointMods(alignment, styles, '', getBreakpoint(width)),
|
|
92
|
+
className
|
|
93
|
+
)}
|
|
94
|
+
{...props}
|
|
95
|
+
>
|
|
96
|
+
<ToolbarContext.Consumer>
|
|
97
|
+
{({
|
|
98
|
+
clearAllFilters: clearAllFiltersContext,
|
|
99
|
+
clearFiltersButtonText: clearFiltersButtonContext,
|
|
100
|
+
showClearFiltersButton: showClearFiltersButtonContext,
|
|
101
|
+
toolbarId: toolbarIdContext
|
|
102
|
+
}) => {
|
|
103
|
+
const expandableContentId = `${toolbarId ||
|
|
104
|
+
toolbarIdContext}-expandable-content-${ToolbarContent.currentId++}`;
|
|
105
|
+
return (
|
|
106
|
+
<ToolbarContentContext.Provider
|
|
107
|
+
value={{
|
|
108
|
+
expandableContentRef: this.expandableContentRef,
|
|
109
|
+
expandableContentId,
|
|
110
|
+
chipContainerRef: this.chipContainerRef
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
<div className={css(styles.toolbarContentSection)}>{children}</div>
|
|
114
|
+
<ToolbarExpandableContent
|
|
115
|
+
id={expandableContentId}
|
|
116
|
+
isExpanded={isExpanded}
|
|
117
|
+
expandableContentRef={this.expandableContentRef}
|
|
118
|
+
chipContainerRef={this.chipContainerRef}
|
|
119
|
+
clearAllFilters={clearAllFilters || clearAllFiltersContext}
|
|
120
|
+
showClearFiltersButton={showClearFiltersButton || showClearFiltersButtonContext}
|
|
121
|
+
clearFiltersButtonText={clearFiltersButtonText || clearFiltersButtonContext}
|
|
122
|
+
/>
|
|
123
|
+
</ToolbarContentContext.Provider>
|
|
124
|
+
);
|
|
125
|
+
}}
|
|
126
|
+
</ToolbarContext.Consumer>
|
|
127
|
+
</div>
|
|
90
128
|
)}
|
|
91
|
-
|
|
92
|
-
>
|
|
93
|
-
<ToolbarContext.Consumer>
|
|
94
|
-
{({
|
|
95
|
-
clearAllFilters: clearAllFiltersContext,
|
|
96
|
-
clearFiltersButtonText: clearFiltersButtonContext,
|
|
97
|
-
showClearFiltersButton: showClearFiltersButtonContext,
|
|
98
|
-
toolbarId: toolbarIdContext
|
|
99
|
-
}) => {
|
|
100
|
-
const expandableContentId = `${toolbarId ||
|
|
101
|
-
toolbarIdContext}-expandable-content-${ToolbarContent.currentId++}`;
|
|
102
|
-
return (
|
|
103
|
-
<ToolbarContentContext.Provider
|
|
104
|
-
value={{
|
|
105
|
-
expandableContentRef: this.expandableContentRef,
|
|
106
|
-
expandableContentId,
|
|
107
|
-
chipContainerRef: this.chipContainerRef
|
|
108
|
-
}}
|
|
109
|
-
>
|
|
110
|
-
<div className={css(styles.toolbarContentSection)}>{children}</div>
|
|
111
|
-
<ToolbarExpandableContent
|
|
112
|
-
id={expandableContentId}
|
|
113
|
-
isExpanded={isExpanded}
|
|
114
|
-
expandableContentRef={this.expandableContentRef}
|
|
115
|
-
chipContainerRef={this.chipContainerRef}
|
|
116
|
-
clearAllFilters={clearAllFilters || clearAllFiltersContext}
|
|
117
|
-
showClearFiltersButton={showClearFiltersButton || showClearFiltersButtonContext}
|
|
118
|
-
clearFiltersButtonText={clearFiltersButtonText || clearFiltersButtonContext}
|
|
119
|
-
/>
|
|
120
|
-
</ToolbarContentContext.Provider>
|
|
121
|
-
);
|
|
122
|
-
}}
|
|
123
|
-
</ToolbarContext.Consumer>
|
|
124
|
-
</div>
|
|
129
|
+
</PageContext.Consumer>
|
|
125
130
|
);
|
|
126
131
|
}
|
|
127
132
|
}
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Toolbar/toolbar';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods, toCamel } from '../../helpers/util';
|
|
5
|
+
import { PageContext } from '../Page/Page';
|
|
5
6
|
|
|
6
7
|
export enum ToolbarGroupVariant {
|
|
7
8
|
'filter-group' = 'filter-group',
|
|
@@ -84,21 +85,25 @@ class ToolbarGroupWithRef extends React.Component<ToolbarGroupProps> {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
return (
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
<PageContext.Consumer>
|
|
89
|
+
{({ width, getBreakpoint }) => (
|
|
90
|
+
<div
|
|
91
|
+
className={css(
|
|
92
|
+
styles.toolbarGroup,
|
|
93
|
+
variant && styles.modifiers[toCamel(variant) as 'filterGroup' | 'iconButtonGroup' | 'buttonGroup'],
|
|
94
|
+
formatBreakpointMods(visibility || visiblity, styles, '', getBreakpoint(width)),
|
|
95
|
+
formatBreakpointMods(alignment, styles, '', getBreakpoint(width)),
|
|
96
|
+
formatBreakpointMods(spacer, styles, '', getBreakpoint(width)),
|
|
97
|
+
formatBreakpointMods(spaceItems, styles, '', getBreakpoint(width)),
|
|
98
|
+
className
|
|
99
|
+
)}
|
|
100
|
+
{...props}
|
|
101
|
+
ref={innerRef}
|
|
102
|
+
>
|
|
103
|
+
{children}
|
|
104
|
+
</div>
|
|
96
105
|
)}
|
|
97
|
-
|
|
98
|
-
ref={innerRef}
|
|
99
|
-
>
|
|
100
|
-
{children}
|
|
101
|
-
</div>
|
|
106
|
+
</PageContext.Consumer>
|
|
102
107
|
);
|
|
103
108
|
}
|
|
104
109
|
}
|
|
@@ -4,6 +4,7 @@ import { css } from '@patternfly/react-styles';
|
|
|
4
4
|
|
|
5
5
|
import { formatBreakpointMods, toCamel } from '../../helpers/util';
|
|
6
6
|
import { Divider } from '../Divider';
|
|
7
|
+
import { PageContext } from '../Page/Page';
|
|
7
8
|
|
|
8
9
|
export enum ToolbarItemVariant {
|
|
9
10
|
separator = 'separator',
|
|
@@ -113,26 +114,36 @@ export const ToolbarItem: React.FunctionComponent<ToolbarItemProps> = ({
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
return (
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
117
|
+
<PageContext.Consumer>
|
|
118
|
+
{({ width, getBreakpoint }) => (
|
|
119
|
+
<div
|
|
120
|
+
className={css(
|
|
121
|
+
styles.toolbarItem,
|
|
122
|
+
variant &&
|
|
123
|
+
styles.modifiers[
|
|
124
|
+
toCamel(variant) as
|
|
125
|
+
| 'bulkSelect'
|
|
126
|
+
| 'overflowMenu'
|
|
127
|
+
| 'pagination'
|
|
128
|
+
| 'searchFilter'
|
|
129
|
+
| 'label'
|
|
130
|
+
| 'chipGroup'
|
|
131
|
+
],
|
|
132
|
+
isAllExpanded && styles.modifiers.expanded,
|
|
133
|
+
formatBreakpointMods(visibility || visiblity, styles, '', getBreakpoint(width)),
|
|
134
|
+
formatBreakpointMods(alignment, styles, '', getBreakpoint(width)),
|
|
135
|
+
formatBreakpointMods(spacer, styles, '', getBreakpoint(width)),
|
|
136
|
+
className
|
|
137
|
+
)}
|
|
138
|
+
{...(variant === 'label' && { 'aria-hidden': true })}
|
|
139
|
+
id={id}
|
|
140
|
+
{...props}
|
|
141
|
+
{...(widths && { style: { ...widthStyles, ...props.style } as React.CSSProperties })}
|
|
142
|
+
>
|
|
143
|
+
{children}
|
|
144
|
+
</div>
|
|
128
145
|
)}
|
|
129
|
-
|
|
130
|
-
id={id}
|
|
131
|
-
{...props}
|
|
132
|
-
{...(widths && { style: { ...widthStyles, ...props.style } as React.CSSProperties })}
|
|
133
|
-
>
|
|
134
|
-
{children}
|
|
135
|
-
</div>
|
|
146
|
+
</PageContext.Consumer>
|
|
136
147
|
);
|
|
137
148
|
};
|
|
138
149
|
ToolbarItem.displayName = 'ToolbarItem';
|
|
@@ -6,7 +6,8 @@ import { ToolbarGroupProps } from './ToolbarGroup';
|
|
|
6
6
|
import { ToolbarContext, ToolbarContentContext } from './ToolbarUtils';
|
|
7
7
|
import { Button } from '../Button';
|
|
8
8
|
import globalBreakpointLg from '@patternfly/react-tokens/dist/esm/global_breakpoint_lg';
|
|
9
|
-
import { formatBreakpointMods, toCamel,
|
|
9
|
+
import { formatBreakpointMods, toCamel, canUseDOM } from '../../helpers/util';
|
|
10
|
+
import { PageContext } from '../Page/Page';
|
|
10
11
|
|
|
11
12
|
export interface ToolbarToggleGroupProps extends ToolbarGroupProps {
|
|
12
13
|
/** An icon to be rendered when the toggle group has collapsed down */
|
|
@@ -92,61 +93,67 @@ export class ToolbarToggleGroup extends React.Component<ToolbarToggleGroupProps>
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
return (
|
|
95
|
-
<
|
|
96
|
-
{({
|
|
97
|
-
<
|
|
98
|
-
{({
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
expandableContentRef.current.classList
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
<PageContext.Consumer>
|
|
97
|
+
{({ width, getBreakpoint }) => (
|
|
98
|
+
<ToolbarContext.Consumer>
|
|
99
|
+
{({ isExpanded, toggleIsExpanded }) => (
|
|
100
|
+
<ToolbarContentContext.Consumer>
|
|
101
|
+
{({ expandableContentRef, expandableContentId }) => {
|
|
102
|
+
if (expandableContentRef.current && expandableContentRef.current.classList) {
|
|
103
|
+
if (isExpanded) {
|
|
104
|
+
expandableContentRef.current.classList.add(styles.modifiers.expanded);
|
|
105
|
+
} else {
|
|
106
|
+
expandableContentRef.current.classList.remove(styles.modifiers.expanded);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<Button
|
|
131
|
-
variant="plain"
|
|
132
|
-
onClick={toggleIsExpanded}
|
|
133
|
-
aria-label="Show Filters"
|
|
134
|
-
{...(isExpanded && { 'aria-expanded': true })}
|
|
135
|
-
aria-haspopup={isExpanded && this.isContentPopup()}
|
|
136
|
-
aria-controls={expandableContentId}
|
|
110
|
+
const breakpointMod: {
|
|
111
|
+
md?: 'show';
|
|
112
|
+
lg?: 'show';
|
|
113
|
+
xl?: 'show';
|
|
114
|
+
'2xl'?: 'show';
|
|
115
|
+
} = {};
|
|
116
|
+
breakpointMod[breakpoint] = 'show';
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div
|
|
120
|
+
className={css(
|
|
121
|
+
styles.toolbarGroup,
|
|
122
|
+
styles.modifiers.toggleGroup,
|
|
123
|
+
variant &&
|
|
124
|
+
styles.modifiers[toCamel(variant) as 'filterGroup' | 'iconButtonGroup' | 'buttonGroup'],
|
|
125
|
+
formatBreakpointMods(breakpointMod, styles, '', getBreakpoint(width)),
|
|
126
|
+
formatBreakpointMods(visibility || visiblity, styles, '', getBreakpoint(width)),
|
|
127
|
+
formatBreakpointMods(alignment, styles, '', getBreakpoint(width)),
|
|
128
|
+
formatBreakpointMods(spacer, styles, '', getBreakpoint(width)),
|
|
129
|
+
formatBreakpointMods(spaceItems, styles, '', getBreakpoint(width)),
|
|
130
|
+
className
|
|
131
|
+
)}
|
|
132
|
+
{...props}
|
|
137
133
|
>
|
|
138
|
-
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
134
|
+
<div className={css(styles.toolbarToggle)}>
|
|
135
|
+
<Button
|
|
136
|
+
variant="plain"
|
|
137
|
+
onClick={toggleIsExpanded}
|
|
138
|
+
aria-label="Show Filters"
|
|
139
|
+
{...(isExpanded && { 'aria-expanded': true })}
|
|
140
|
+
aria-haspopup={isExpanded && this.isContentPopup()}
|
|
141
|
+
aria-controls={expandableContentId}
|
|
142
|
+
>
|
|
143
|
+
{toggleIcon}
|
|
144
|
+
</Button>
|
|
145
|
+
</div>
|
|
146
|
+
{isExpanded
|
|
147
|
+
? ReactDOM.createPortal(children, expandableContentRef.current.firstElementChild)
|
|
148
|
+
: children}
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
}}
|
|
152
|
+
</ToolbarContentContext.Consumer>
|
|
153
|
+
)}
|
|
154
|
+
</ToolbarContext.Consumer>
|
|
148
155
|
)}
|
|
149
|
-
</
|
|
156
|
+
</PageContext.Consumer>
|
|
150
157
|
);
|
|
151
158
|
}
|
|
152
159
|
}
|
|
@@ -1,47 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`Toolbar should match snapshot (auto-generated) 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
data-ouia-component-type="PF4/Toolbar"
|
|
8
|
-
data-ouia-safe={true}
|
|
9
|
-
id="string"
|
|
10
|
-
>
|
|
11
|
-
<ContextProvider
|
|
12
|
-
value={
|
|
13
|
-
Object {
|
|
14
|
-
"chipGroupContentRef": Object {
|
|
15
|
-
"current": null,
|
|
16
|
-
},
|
|
17
|
-
"clearAllFilters": [Function],
|
|
18
|
-
"clearFiltersButtonText": "string",
|
|
19
|
-
"isExpanded": true,
|
|
20
|
-
"numberOfFilters": 0,
|
|
21
|
-
"showClearFiltersButton": false,
|
|
22
|
-
"toggleIsExpanded": [Function],
|
|
23
|
-
"toolbarId": "string",
|
|
24
|
-
"updateNumberFilters": [Function],
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
>
|
|
28
|
-
<div>
|
|
29
|
-
ReactNode
|
|
30
|
-
</div>
|
|
31
|
-
<ToolbarChipGroupContent
|
|
32
|
-
chipGroupContentRef={
|
|
33
|
-
Object {
|
|
34
|
-
"current": null,
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
clearAllFilters={[Function]}
|
|
38
|
-
clearFiltersButtonText="string"
|
|
39
|
-
collapseListedFiltersBreakpoint="md"
|
|
40
|
-
isExpanded={true}
|
|
41
|
-
numberOfFilters={0}
|
|
42
|
-
numberOfFiltersText={[Function]}
|
|
43
|
-
showClearFiltersButton={false}
|
|
44
|
-
/>
|
|
45
|
-
</ContextProvider>
|
|
46
|
-
</div>
|
|
4
|
+
<ContextConsumer>
|
|
5
|
+
<Component />
|
|
6
|
+
</ContextConsumer>
|
|
47
7
|
`;
|
package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarContent.test.tsx.snap
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`ToolbarContent should match snapshot (auto-generated) 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
>
|
|
7
|
-
<ContextConsumer>
|
|
8
|
-
<Component />
|
|
9
|
-
</ContextConsumer>
|
|
10
|
-
</div>
|
|
4
|
+
<ContextConsumer>
|
|
5
|
+
<Component />
|
|
6
|
+
</ContextConsumer>
|
|
11
7
|
`;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`ToolbarItem should match snapshot (auto-generated) 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
<div>
|
|
9
|
-
ReactNode
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
4
|
+
<ContextConsumer>
|
|
5
|
+
<Component />
|
|
6
|
+
</ContextConsumer>
|
|
12
7
|
`;
|