@patternfly/react-core 4.192.5 → 4.192.9
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/Menu/MenuContent.js +1 -1
- package/dist/esm/components/Menu/MenuContent.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/Menu/MenuContent.js +1 -1
- package/dist/js/components/Menu/MenuContent.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 +0 -104
- package/dist/umd/react-core.js +1586 -1319
- package/dist/umd/react-core.min.css +0 -104
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +5 -5
- 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/Menu/MenuContent.tsx +2 -2
- package/src/components/Menu/examples/Menu.md +7 -7
- 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/ComposableMenu/ComposableMenu.md +88 -0
- package/src/demos/ComposableMenu/examples/ComposableActionsMenu.tsx +122 -0
- package/src/demos/ComposableMenu/examples/ComposableApplicationLauncher.tsx +282 -0
- package/src/demos/ComposableMenu/examples/ComposableContextSelector.tsx +202 -0
- package/src/demos/ComposableMenu/examples/ComposableDrilldownMenu.tsx +246 -0
- package/src/demos/ComposableMenu/examples/ComposableDropdwnVariants.tsx +235 -0
- package/src/demos/ComposableMenu/examples/ComposableFlyout.tsx +103 -0
- package/src/demos/ComposableMenu/examples/ComposableOptionsMenuVariants.tsx +94 -0
- package/src/demos/ComposableMenu/examples/ComposableSimpleDropdown.tsx +70 -0
- package/src/demos/ComposableMenu/examples/ComposableSimpleSelect.tsx +74 -0
- package/src/demos/ComposableMenu/examples/ComposableTreeViewMenu.tsx +240 -0
- package/src/demos/ComposableMenu/examples/avatarImg.svg +18 -0
- package/src/demos/ComposableMenu/examples/pf-logo-small.svg +23 -0
- package/src/demos/Page/Page.md +92 -43
- package/src/helpers/util.ts +74 -12
- package/src/demos/ComposableMenu.md +0 -1443
- package/src/demos/composable-menu.css +0 -3
|
@@ -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
|
`;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Composable menu
|
|
3
|
+
section: demos
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { Link } from '@reach/router';
|
|
7
|
+
|
|
8
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
9
|
+
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
10
|
+
import TableIcon from '@patternfly/react-icons/dist/esm/icons/table-icon';
|
|
11
|
+
import StorageDomainIcon from '@patternfly/react-icons/dist/esm/icons/storage-domain-icon';
|
|
12
|
+
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
13
|
+
import LayerGroupIcon from '@patternfly/react-icons/dist/esm/icons/layer-group-icon';
|
|
14
|
+
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
15
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
16
|
+
import ClipboardIcon from '@patternfly/react-icons/dist/esm/icons/clipboard-icon';
|
|
17
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
18
|
+
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
|
|
19
|
+
import pfIcon from './examples/pf-logo-small.svg';
|
|
20
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
21
|
+
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
22
|
+
import avatarImg from './examples/avatarImg.svg';
|
|
23
|
+
|
|
24
|
+
## Demos
|
|
25
|
+
|
|
26
|
+
Composable menus currently require consumer keyboard handling and use of our undocumented [popper.js](https://popper.js.org/) wrapper component called Popper. We understand this is inconvientent boilerplate and these examples will be updated to use [Dropdown](/components/dropdown) in a future release.
|
|
27
|
+
|
|
28
|
+
### Composable simple dropdown
|
|
29
|
+
|
|
30
|
+
```ts file="./examples/ComposableSimpleDropdown.tsx"
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Composable actions menu
|
|
35
|
+
|
|
36
|
+
```ts file="./examples/ComposableActionsMenu.tsx"
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Composable simple select
|
|
41
|
+
|
|
42
|
+
```ts file="./examples/ComposableSimpleSelect.tsx"
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Composable drilldown menu
|
|
47
|
+
|
|
48
|
+
```ts isBeta file="./examples/ComposableDrilldownMenu.tsx"
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Composable tree view menu
|
|
53
|
+
|
|
54
|
+
```ts file="./examples/ComposableTreeViewMenu.tsx"
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Composable flyout
|
|
59
|
+
|
|
60
|
+
The flyout will automatically position to the left or top if it would otherwise go outside the window. The menu must be placed in a container outside the main content like Popper, [Popover](/components/popover) or [Tooltip](/components/tooltip) since it may go over the side nav.
|
|
61
|
+
|
|
62
|
+
```ts isBeta file="./examples/ComposableFlyout.tsx"
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Composable application launcher
|
|
67
|
+
|
|
68
|
+
```ts file="./examples/ComposableApplicationLauncher.tsx"
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Composable context selector
|
|
73
|
+
|
|
74
|
+
```ts file="./examples/ComposableContextSelector.tsx"
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Composable options menu variants
|
|
79
|
+
|
|
80
|
+
```ts file="./examples/ComposableOptionsMenuVariants.tsx"
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Composable dropdown variants
|
|
85
|
+
|
|
86
|
+
```ts file="./examples/ComposableDropdwnVariants.tsx"
|
|
87
|
+
|
|
88
|
+
```
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuToggle, Menu, MenuList, MenuItem, MenuGroup, MenuItemAction, Popper } from '@patternfly/react-core';
|
|
3
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
4
|
+
import ClipboardIcon from '@patternfly/react-icons/dist/esm/icons/clipboard-icon';
|
|
5
|
+
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
6
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
7
|
+
|
|
8
|
+
export const ComposableActionsMenu: React.FunctionComponent = () => {
|
|
9
|
+
const [isOpen, setIsOpen] = React.useState<boolean>(false);
|
|
10
|
+
const [selectedItems, setSelectedItems] = React.useState<number[]>([]);
|
|
11
|
+
const toggleRef = React.useRef<HTMLButtonElement>();
|
|
12
|
+
const menuRef = React.useRef<HTMLDivElement>();
|
|
13
|
+
|
|
14
|
+
const handleMenuKeys = (event: KeyboardEvent) => {
|
|
15
|
+
if (isOpen && menuRef.current.contains(event.target as Node)) {
|
|
16
|
+
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
17
|
+
setIsOpen(!isOpen);
|
|
18
|
+
toggleRef.current.focus();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
24
|
+
if (isOpen && !menuRef.current.contains(event.target as Node)) {
|
|
25
|
+
setIsOpen(false);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
window.addEventListener('keydown', handleMenuKeys);
|
|
31
|
+
window.addEventListener('click', handleClickOutside);
|
|
32
|
+
return () => {
|
|
33
|
+
window.removeEventListener('keydown', handleMenuKeys);
|
|
34
|
+
window.removeEventListener('click', handleClickOutside);
|
|
35
|
+
};
|
|
36
|
+
}, [isOpen, menuRef]);
|
|
37
|
+
|
|
38
|
+
const onSelect = (ev: React.MouseEvent<Element, MouseEvent>, itemId: number) => {
|
|
39
|
+
if (selectedItems.includes(itemId)) {
|
|
40
|
+
setSelectedItems(selectedItems.filter(id => id !== itemId));
|
|
41
|
+
} else {
|
|
42
|
+
setSelectedItems([...selectedItems, itemId]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const onToggleClick = (ev: React.MouseEvent) => {
|
|
47
|
+
ev.stopPropagation(); // Stop handleClickOutside from handling
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
if (menuRef.current) {
|
|
50
|
+
const firstElement = menuRef.current.querySelector('li > button:not(:disabled)');
|
|
51
|
+
firstElement && (firstElement as HTMLElement).focus();
|
|
52
|
+
}
|
|
53
|
+
}, 0);
|
|
54
|
+
setIsOpen(!isOpen);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const toggle = (
|
|
58
|
+
<MenuToggle ref={toggleRef} onClick={onToggleClick} isExpanded={isOpen}>
|
|
59
|
+
{isOpen ? 'Expanded' : 'Collapsed'}
|
|
60
|
+
</MenuToggle>
|
|
61
|
+
);
|
|
62
|
+
const menu = (
|
|
63
|
+
<Menu
|
|
64
|
+
ref={menuRef}
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
onActionClick={(event, itemId, actionId) => console.log(`clicked on ${itemId} - ${actionId}`)}
|
|
67
|
+
onSelect={onSelect}
|
|
68
|
+
style={
|
|
69
|
+
{
|
|
70
|
+
'--pf-c-menu--Width': '300px'
|
|
71
|
+
} as React.CSSProperties
|
|
72
|
+
}
|
|
73
|
+
>
|
|
74
|
+
<MenuGroup label="Actions">
|
|
75
|
+
<MenuList>
|
|
76
|
+
<MenuItem
|
|
77
|
+
isSelected={selectedItems.includes(0)}
|
|
78
|
+
actions={
|
|
79
|
+
<MenuItemAction
|
|
80
|
+
icon={<CodeBranchIcon aria-hidden />}
|
|
81
|
+
actionId="code"
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
onClick={() => console.log('clicked on code icon')}
|
|
84
|
+
aria-label="Code"
|
|
85
|
+
/>
|
|
86
|
+
}
|
|
87
|
+
description="This is a description"
|
|
88
|
+
itemId={0}
|
|
89
|
+
>
|
|
90
|
+
Item 1
|
|
91
|
+
</MenuItem>
|
|
92
|
+
<MenuItem
|
|
93
|
+
isDisabled
|
|
94
|
+
isSelected={selectedItems.includes(1)}
|
|
95
|
+
actions={<MenuItemAction icon={<BellIcon aria-hidden />} actionId="alert" aria-label="Alert" />}
|
|
96
|
+
description="This is a description"
|
|
97
|
+
itemId={1}
|
|
98
|
+
>
|
|
99
|
+
Item 2
|
|
100
|
+
</MenuItem>
|
|
101
|
+
<MenuItem
|
|
102
|
+
isSelected={selectedItems.includes(2)}
|
|
103
|
+
actions={<MenuItemAction icon={<ClipboardIcon aria-hidden />} actionId="copy" aria-label="Copy" />}
|
|
104
|
+
itemId={2}
|
|
105
|
+
>
|
|
106
|
+
Item 3
|
|
107
|
+
</MenuItem>
|
|
108
|
+
<MenuItem
|
|
109
|
+
isSelected={selectedItems.includes(3)}
|
|
110
|
+
actions={<MenuItemAction icon={<BarsIcon aria-hidden />} actionId="expand" aria-label="Expand" />}
|
|
111
|
+
description="This is a description"
|
|
112
|
+
itemId={3}
|
|
113
|
+
>
|
|
114
|
+
Item 4
|
|
115
|
+
</MenuItem>
|
|
116
|
+
</MenuList>
|
|
117
|
+
</MenuGroup>
|
|
118
|
+
</Menu>
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return <Popper trigger={toggle} popper={menu} isVisible={isOpen} popperMatchesTriggerWidth={false} />;
|
|
122
|
+
};
|