@patternfly/react-core 4.192.6 → 4.192.10
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 +38 -0
- package/dist/esm/components/Label/Label.d.ts.map +1 -1
- package/dist/esm/components/Label/Label.js +38 -25
- package/dist/esm/components/Label/Label.js.map +1 -1
- 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/Select/Select.d.ts +5 -1
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +171 -28
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/SelectMenu.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectMenu.js +2 -1
- package/dist/esm/components/Select/SelectMenu.js.map +1 -1
- package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectOption.js +6 -1
- package/dist/esm/components/Select/SelectOption.js.map +1 -1
- package/dist/esm/components/Select/SelectToggle.d.ts +3 -2
- package/dist/esm/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectToggle.js +26 -16
- package/dist/esm/components/Select/SelectToggle.js.map +1 -1
- package/dist/esm/components/Select/selectConstants.d.ts +1 -0
- package/dist/esm/components/Select/selectConstants.d.ts.map +1 -1
- package/dist/esm/components/Select/selectConstants.js +1 -0
- package/dist/esm/components/Select/selectConstants.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.d.ts +4 -6
- package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.js +74 -42
- package/dist/esm/components/TimePicker/TimePicker.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 +22 -8
- package/dist/esm/helpers/util.d.ts.map +1 -1
- package/dist/esm/helpers/util.js +65 -7
- package/dist/esm/helpers/util.js.map +1 -1
- package/dist/js/components/Label/Label.d.ts.map +1 -1
- package/dist/js/components/Label/Label.js +38 -25
- package/dist/js/components/Label/Label.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/Select/Select.d.ts +5 -1
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +170 -27
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Select/SelectMenu.d.ts.map +1 -1
- package/dist/js/components/Select/SelectMenu.js +2 -1
- package/dist/js/components/Select/SelectMenu.js.map +1 -1
- package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/js/components/Select/SelectOption.js +6 -1
- package/dist/js/components/Select/SelectOption.js.map +1 -1
- package/dist/js/components/Select/SelectToggle.d.ts +3 -2
- package/dist/js/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/js/components/Select/SelectToggle.js +25 -15
- package/dist/js/components/Select/SelectToggle.js.map +1 -1
- package/dist/js/components/Select/selectConstants.d.ts +1 -0
- package/dist/js/components/Select/selectConstants.d.ts.map +1 -1
- package/dist/js/components/Select/selectConstants.js +2 -1
- package/dist/js/components/Select/selectConstants.js.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.d.ts +4 -6
- package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.js +73 -41
- package/dist/js/components/TimePicker/TimePicker.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 +22 -8
- package/dist/js/helpers/util.d.ts.map +1 -1
- package/dist/js/helpers/util.js +68 -8
- package/dist/js/helpers/util.js.map +1 -1
- package/dist/umd/react-core.css +1093 -1139
- package/dist/umd/react-core.js +1585 -1318
- package/dist/umd/react-core.min.css +136 -182
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +6 -6
- package/src/components/Alert/examples/AlertAsyncLiveRegion.tsx +1 -1
- package/src/components/ApplicationLauncher/examples/ApplicationLauncher.md +11 -577
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignRight.tsx +32 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignTop.tsx +31 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherBasic.tsx +23 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherCustomIcon.tsx +32 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherDisabled.tsx +25 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherDocumentBody.tsx +31 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherFavoritesAndSearch.tsx +105 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherRouterLink.tsx +50 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherSectionsAndIcons.tsx +47 -0
- package/src/components/ApplicationLauncher/examples/ApplicationLauncherTooltip.tsx +35 -0
- package/src/components/Label/Label.tsx +58 -39
- package/src/components/Label/__tests__/Label.test.tsx +19 -1
- package/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +109 -0
- package/src/components/Label/examples/Label.md +1 -41
- package/src/components/Label/examples/LabelEditable.tsx +57 -0
- 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/Select/Select.tsx +166 -26
- package/src/components/Select/SelectMenu.tsx +2 -1
- package/src/components/Select/SelectOption.tsx +5 -1
- package/src/components/Select/SelectToggle.tsx +38 -17
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +74 -24
- package/src/components/Select/examples/Select.md +5 -1
- package/src/components/Select/selectConstants.tsx +2 -0
- package/src/components/TimePicker/TimePicker.tsx +112 -124
- package/src/components/TimePicker/examples/TimePicker.md +16 -10
- 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 +74 -12
|
@@ -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
|
`;
|
package/src/demos/Page/Page.md
CHANGED
|
@@ -11,6 +11,7 @@ import imgBrand from '@patternfly/react-core/src/demos/examples/pfColorLogo.svg'
|
|
|
11
11
|
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
12
12
|
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
13
13
|
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
14
|
+
import LightbulbIcon from '@patternfly/react-icons/dist/esm/icons/lightbulb-icon';
|
|
14
15
|
|
|
15
16
|
- All but the last example set the `isManagedSidebar` prop on the Page component to have the sidebar automatically close for smaller screen widths. You can also manually control this behavior by not adding the `isManagedSidebar` prop and instead:
|
|
16
17
|
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
ButtonVariant,
|
|
39
40
|
Card,
|
|
40
41
|
CardBody,
|
|
42
|
+
Checkbox,
|
|
41
43
|
Divider,
|
|
42
44
|
Dropdown,
|
|
43
45
|
DropdownGroup,
|
|
@@ -66,13 +68,21 @@ import {
|
|
|
66
68
|
Toolbar,
|
|
67
69
|
ToolbarContent,
|
|
68
70
|
ToolbarGroup,
|
|
69
|
-
ToolbarItem
|
|
71
|
+
ToolbarItem,
|
|
72
|
+
Drawer,
|
|
73
|
+
DrawerPanelContent,
|
|
74
|
+
DrawerContent,
|
|
75
|
+
DrawerContentBody,
|
|
76
|
+
DrawerHead,
|
|
77
|
+
DrawerActions,
|
|
78
|
+
DrawerCloseButton,
|
|
70
79
|
} from '@patternfly/react-core';
|
|
71
80
|
import { css } from '@patternfly/react-styles';
|
|
72
81
|
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
73
82
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
74
83
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
75
84
|
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
85
|
+
import LightbulbIcon from '@patternfly/react-icons/dist/esm/icons/lightbulb-icon';
|
|
76
86
|
import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
|
|
77
87
|
import imgBrand from './imgBrand.svg';
|
|
78
88
|
import imgAvatar from './imgAvatar.svg';
|
|
@@ -84,7 +94,8 @@ class PageLayoutGrouped extends React.Component {
|
|
|
84
94
|
isDropdownOpen: false,
|
|
85
95
|
isKebabDropdownOpen: false,
|
|
86
96
|
isFullKebabDropdownOpen: false,
|
|
87
|
-
activeItem: 0
|
|
97
|
+
activeItem: 0,
|
|
98
|
+
isDrawerExpanded: false
|
|
88
99
|
};
|
|
89
100
|
this.onDropdownToggle = isDropdownOpen => {
|
|
90
101
|
this.setState({
|
|
@@ -127,10 +138,23 @@ class PageLayoutGrouped extends React.Component {
|
|
|
127
138
|
isFullKebabDropdownOpen: !this.state.isFullKebabDropdownOpen
|
|
128
139
|
});
|
|
129
140
|
};
|
|
141
|
+
|
|
142
|
+
this.onDrawerToggle = () => {
|
|
143
|
+
const isDrawerExpanded = !this.state.isDrawerExpanded;
|
|
144
|
+
this.setState({
|
|
145
|
+
isDrawerExpanded
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
this.onDrawerClose = () => {
|
|
150
|
+
this.setState({
|
|
151
|
+
isDrawerExpanded: false
|
|
152
|
+
});
|
|
153
|
+
};
|
|
130
154
|
}
|
|
131
155
|
|
|
132
156
|
render() {
|
|
133
|
-
const { isDropdownOpen, isKebabDropdownOpen, activeItem, isFullKebabDropdownOpen } = this.state;
|
|
157
|
+
const { isDropdownOpen, isKebabDropdownOpen, activeItem, isFullKebabDropdownOpen, isDrawerExpanded } = this.state;
|
|
134
158
|
|
|
135
159
|
const PageNav = (
|
|
136
160
|
<Nav variant="tertiary" onSelect={this.onNavSelect} aria-label="Nav">
|
|
@@ -198,6 +222,11 @@ class PageLayoutGrouped extends React.Component {
|
|
|
198
222
|
alignment={{ default: 'alignRight' }}
|
|
199
223
|
spacer={{ default: 'spacerNone', md: 'spacerMd' }}
|
|
200
224
|
>
|
|
225
|
+
<ToolbarItem>
|
|
226
|
+
<Button aria-label="Toggle drawer" variant={ButtonVariant.plain} onClick={this.onDrawerToggle}>
|
|
227
|
+
<LightbulbIcon color={isDrawerExpanded ? 'yellow' : 'currentColor'} />
|
|
228
|
+
</Button>
|
|
229
|
+
</ToolbarItem>
|
|
201
230
|
<ToolbarItem>
|
|
202
231
|
<Button aria-label="Notifications" variant={ButtonVariant.plain}>
|
|
203
232
|
<AttentionBellIcon />
|
|
@@ -283,47 +312,67 @@ class PageLayoutGrouped extends React.Component {
|
|
|
283
312
|
</Breadcrumb>
|
|
284
313
|
);
|
|
285
314
|
|
|
315
|
+
const panelContent = (
|
|
316
|
+
<DrawerPanelContent isResizable>
|
|
317
|
+
<DrawerHead>
|
|
318
|
+
<span tabIndex={isDrawerExpanded ? 0 : -1}>
|
|
319
|
+
drawer-panel
|
|
320
|
+
</span>
|
|
321
|
+
<DrawerActions>
|
|
322
|
+
<DrawerCloseButton onClick={this.onDrawerClose} />
|
|
323
|
+
</DrawerActions>
|
|
324
|
+
</DrawerHead>
|
|
325
|
+
</DrawerPanelContent>
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
const Sidebar = <PageSidebar nav="Navigation" />;
|
|
329
|
+
|
|
286
330
|
return (
|
|
287
|
-
<
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
<
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
331
|
+
<Drawer isExpanded={isDrawerExpanded} isInline onExpand={this.onExpand}>
|
|
332
|
+
<DrawerContent panelContent={panelContent}>
|
|
333
|
+
<DrawerContentBody>
|
|
334
|
+
<Page
|
|
335
|
+
header={Header}
|
|
336
|
+
breadcrumb={PageBreadcrumb}
|
|
337
|
+
sidebar={Sidebar}
|
|
338
|
+
tertiaryNav={PageNav}
|
|
339
|
+
isManagedSidebar
|
|
340
|
+
isTertiaryNavWidthLimited
|
|
341
|
+
isBreadcrumbWidthLimited
|
|
342
|
+
skipToContent={PageSkipToContent}
|
|
343
|
+
mainContainerId={pageId}
|
|
344
|
+
isTertiaryNavGrouped
|
|
345
|
+
isBreadcrumbGrouped
|
|
346
|
+
additionalGroupedContent={
|
|
347
|
+
<PageSection variant={PageSectionVariants.light}>
|
|
348
|
+
<TextContent>
|
|
349
|
+
<Text component="h1">Main title</Text>
|
|
350
|
+
<Text component="p">
|
|
351
|
+
Body text should be Overpass Regular at 16px. It should have leading of 24px because <br />
|
|
352
|
+
of its relative line height of 1.5.
|
|
353
|
+
</Text>
|
|
354
|
+
</TextContent>
|
|
355
|
+
</PageSection>
|
|
356
|
+
}
|
|
357
|
+
groupProps={{
|
|
358
|
+
sticky: 'top'
|
|
359
|
+
}}
|
|
360
|
+
>
|
|
361
|
+
<PageSection>
|
|
362
|
+
<Gallery hasGutter>
|
|
363
|
+
{Array.apply(0, Array(20)).map((x, i) => (
|
|
364
|
+
<GalleryItem key={i}>
|
|
365
|
+
<Card>
|
|
366
|
+
<CardBody>This is a card</CardBody>
|
|
367
|
+
</Card>
|
|
368
|
+
</GalleryItem>
|
|
369
|
+
))}
|
|
370
|
+
</Gallery>
|
|
371
|
+
</PageSection>
|
|
372
|
+
</Page>
|
|
373
|
+
</DrawerContentBody>
|
|
374
|
+
</DrawerContent>
|
|
375
|
+
</Drawer>
|
|
327
376
|
);
|
|
328
377
|
}
|
|
329
378
|
}
|
package/src/helpers/util.ts
CHANGED
|
@@ -196,6 +196,19 @@ export function keyHandler(
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
/** This function returns a list of tabbable items in a container
|
|
200
|
+
*
|
|
201
|
+
* @param {any} containerRef to the container
|
|
202
|
+
* @param {string} tababbleSelectors CSS selector string of tabbable items
|
|
203
|
+
*/
|
|
204
|
+
export function findTabbableElements(containerRef: any, tababbleSelectors: string): any[] {
|
|
205
|
+
const tabbable = containerRef.current.querySelectorAll(tababbleSelectors);
|
|
206
|
+
const list = Array.prototype.filter.call(tabbable, function(item) {
|
|
207
|
+
return item.tabIndex >= '0';
|
|
208
|
+
});
|
|
209
|
+
return list;
|
|
210
|
+
}
|
|
211
|
+
|
|
199
212
|
/** This function is a helper for keyboard navigation through dropdowns.
|
|
200
213
|
*
|
|
201
214
|
* @param {number} index The index of the element you're on
|
|
@@ -262,6 +275,16 @@ export const setBreakpointCssVars = (
|
|
|
262
275
|
{}
|
|
263
276
|
);
|
|
264
277
|
|
|
278
|
+
export interface Mods {
|
|
279
|
+
default?: string;
|
|
280
|
+
sm?: string;
|
|
281
|
+
md?: string;
|
|
282
|
+
lg?: string;
|
|
283
|
+
xl?: string;
|
|
284
|
+
'2xl'?: string;
|
|
285
|
+
'3xl'?: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
265
288
|
/**
|
|
266
289
|
* This function is a helper for turning arrays of breakpointMod objects for data toolbar and flex into classes
|
|
267
290
|
*
|
|
@@ -269,25 +292,64 @@ export const setBreakpointCssVars = (
|
|
|
269
292
|
* @param {any} styles The appropriate styles object for the component
|
|
270
293
|
*/
|
|
271
294
|
export const formatBreakpointMods = (
|
|
272
|
-
mods:
|
|
273
|
-
default?: string;
|
|
274
|
-
sm?: string;
|
|
275
|
-
md?: string;
|
|
276
|
-
lg?: string;
|
|
277
|
-
xl?: string;
|
|
278
|
-
'2xl'?: string;
|
|
279
|
-
'3xl'?: string;
|
|
280
|
-
},
|
|
295
|
+
mods: Mods,
|
|
281
296
|
styles: any,
|
|
282
|
-
stylePrefix: string = ''
|
|
283
|
-
|
|
284
|
-
|
|
297
|
+
stylePrefix: string = '',
|
|
298
|
+
breakpoint?: 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
|
|
299
|
+
) => {
|
|
300
|
+
if (!mods) {
|
|
301
|
+
return '';
|
|
302
|
+
}
|
|
303
|
+
if (breakpoint) {
|
|
304
|
+
if (breakpoint in mods) {
|
|
305
|
+
return styles.modifiers[toCamel(`${stylePrefix}${mods[breakpoint as keyof Mods]}`)];
|
|
306
|
+
}
|
|
307
|
+
// the current breakpoint is not specified in mods, so we try to find the next nearest
|
|
308
|
+
const breakpointsOrder = ['2xl', 'xl', 'lg', 'md', 'sm', 'default'];
|
|
309
|
+
const breakpointsIndex = breakpointsOrder.indexOf(breakpoint);
|
|
310
|
+
for (let i = breakpointsIndex; i < breakpointsOrder.length; i++) {
|
|
311
|
+
if (breakpointsOrder[i] in mods) {
|
|
312
|
+
return styles.modifiers[toCamel(`${stylePrefix}${mods[breakpointsOrder[i] as keyof Mods]}`)];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return '';
|
|
316
|
+
}
|
|
317
|
+
return Object.entries(mods || {})
|
|
285
318
|
.map(([breakpoint, mod]) => `${stylePrefix}${mod}${breakpoint !== 'default' ? `-on-${breakpoint}` : ''}`)
|
|
286
319
|
.map(toCamel)
|
|
287
320
|
.map(mod => mod.replace(/-?(\dxl)/gi, (_res, group) => `_${group}`))
|
|
288
321
|
.map(modifierKey => styles.modifiers[modifierKey])
|
|
289
322
|
.filter(Boolean)
|
|
290
323
|
.join(' ');
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Return the breakpoint for the given width
|
|
328
|
+
*
|
|
329
|
+
* @param {number | null} width The width to check
|
|
330
|
+
* @returns {'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'} The breakpoint
|
|
331
|
+
*/
|
|
332
|
+
export const getBreakpoint = (width: number): 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' => {
|
|
333
|
+
if (width === null) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
if (width >= 1450) {
|
|
337
|
+
return '2xl';
|
|
338
|
+
}
|
|
339
|
+
if (width >= 1200) {
|
|
340
|
+
return 'xl';
|
|
341
|
+
}
|
|
342
|
+
if (width >= 992) {
|
|
343
|
+
return 'lg';
|
|
344
|
+
}
|
|
345
|
+
if (width >= 768) {
|
|
346
|
+
return 'md';
|
|
347
|
+
}
|
|
348
|
+
if (width >= 576) {
|
|
349
|
+
return 'sm';
|
|
350
|
+
}
|
|
351
|
+
return 'default';
|
|
352
|
+
};
|
|
291
353
|
|
|
292
354
|
const camelize = (s: string) =>
|
|
293
355
|
s
|