@patternfly/react-core 5.1.1-prerelease.4 → 5.1.1-prerelease.5
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 +6 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/Chip/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/DragDrop/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/Text/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/Tile/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
- package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
- package/dist/dynamic/deprecated/components/Select/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/favorites/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.js +8 -6
- package/dist/esm/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarExpandableContent.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarExpandableContent.js +3 -5
- package/dist/esm/components/Toolbar/ToolbarExpandableContent.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarFilter.d.ts +4 -0
- package/dist/esm/components/Toolbar/ToolbarFilter.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarFilter.js +8 -4
- package/dist/esm/components/Toolbar/ToolbarFilter.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.d.ts +14 -0
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js +21 -20
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarUtils.d.ts +4 -0
- package/dist/esm/components/Toolbar/ToolbarUtils.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarUtils.js +2 -1
- package/dist/esm/components/Toolbar/ToolbarUtils.js.map +1 -1
- package/dist/esm/components/Toolbar/index.d.ts +1 -0
- package/dist/esm/components/Toolbar/index.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/index.js +1 -0
- package/dist/esm/components/Toolbar/index.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.js +8 -6
- package/dist/js/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarExpandableContent.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarExpandableContent.js +3 -5
- package/dist/js/components/Toolbar/ToolbarExpandableContent.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarFilter.d.ts +4 -0
- package/dist/js/components/Toolbar/ToolbarFilter.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarFilter.js +8 -4
- package/dist/js/components/Toolbar/ToolbarFilter.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.d.ts +14 -0
- package/dist/js/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js +21 -20
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarUtils.d.ts +4 -0
- package/dist/js/components/Toolbar/ToolbarUtils.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarUtils.js +2 -1
- package/dist/js/components/Toolbar/ToolbarUtils.js.map +1 -1
- package/dist/js/components/Toolbar/index.d.ts +1 -0
- package/dist/js/components/Toolbar/index.d.ts.map +1 -1
- package/dist/js/components/Toolbar/index.js +1 -0
- package/dist/js/components/Toolbar/index.js.map +1 -1
- package/dist/umd/react-core.min.js +3 -3
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +6 -6
- package/src/components/Alert/__tests__/AlertGroup.test.tsx +77 -73
- package/src/components/Toolbar/ToolbarContent.tsx +7 -11
- package/src/components/Toolbar/ToolbarExpandableContent.tsx +7 -3
- package/src/components/Toolbar/ToolbarFilter.tsx +12 -2
- package/src/components/Toolbar/ToolbarToggleGroup.tsx +92 -47
- package/src/components/Toolbar/ToolbarUtils.tsx +6 -1
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarContent.test.tsx.snap +0 -8
- package/src/components/Toolbar/__tests__/Toolbar.test.tsx +3 -4
- package/src/components/Toolbar/__tests__/ToolbarToggleGroup.test.tsx +13 -10
- package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +0 -59
- package/src/components/Toolbar/examples/Test.tsx +258 -0
- package/src/components/Toolbar/examples/Toolbar.md +12 -6
- package/src/components/Toolbar/index.ts +1 -0
- package/src/components/Alert/__tests__/__snapshots__/AlertGroup.test.tsx.snap +0 -10
|
@@ -34,14 +34,6 @@ exports[`Toolbar should render inset 1`] = `
|
|
|
34
34
|
Test 3
|
|
35
35
|
</div>
|
|
36
36
|
</div>
|
|
37
|
-
<div
|
|
38
|
-
class="pf-v5-c-toolbar__expandable-content"
|
|
39
|
-
id="toolbar-expandable-content-0"
|
|
40
|
-
>
|
|
41
|
-
<div
|
|
42
|
-
class="pf-v5-c-toolbar__group"
|
|
43
|
-
/>
|
|
44
|
-
</div>
|
|
45
37
|
</div>
|
|
46
38
|
<div
|
|
47
39
|
class="pf-v5-c-toolbar__content pf-m-hidden"
|
|
@@ -99,49 +91,6 @@ exports[`Toolbar should render with custom chip content 1`] = `
|
|
|
99
91
|
</div>
|
|
100
92
|
</div>
|
|
101
93
|
</div>
|
|
102
|
-
<div
|
|
103
|
-
class="pf-v5-c-toolbar__expandable-content"
|
|
104
|
-
id="toolbar-with-filter-expandable-content-3"
|
|
105
|
-
>
|
|
106
|
-
<div
|
|
107
|
-
class="pf-v5-c-toolbar__group"
|
|
108
|
-
/>
|
|
109
|
-
<div
|
|
110
|
-
class="pf-v5-c-toolbar__group pf-m-chip-container"
|
|
111
|
-
>
|
|
112
|
-
<div
|
|
113
|
-
class="pf-v5-c-toolbar__group"
|
|
114
|
-
/>
|
|
115
|
-
<div
|
|
116
|
-
class="pf-v5-c-toolbar__item"
|
|
117
|
-
>
|
|
118
|
-
<button
|
|
119
|
-
aria-disabled="false"
|
|
120
|
-
class="pf-v5-c-button pf-m-link pf-m-inline"
|
|
121
|
-
data-ouia-component-id="OUIA-Generated-Button-link-3"
|
|
122
|
-
data-ouia-component-type="PF5/Button"
|
|
123
|
-
data-ouia-safe="true"
|
|
124
|
-
type="button"
|
|
125
|
-
>
|
|
126
|
-
Save filters
|
|
127
|
-
</button>
|
|
128
|
-
</div>
|
|
129
|
-
<div
|
|
130
|
-
class="pf-v5-c-toolbar__item"
|
|
131
|
-
>
|
|
132
|
-
<button
|
|
133
|
-
aria-disabled="false"
|
|
134
|
-
class="pf-v5-c-button pf-m-link pf-m-inline"
|
|
135
|
-
data-ouia-component-id="OUIA-Generated-Button-link-4"
|
|
136
|
-
data-ouia-component-type="PF5/Button"
|
|
137
|
-
data-ouia-safe="true"
|
|
138
|
-
type="button"
|
|
139
|
-
>
|
|
140
|
-
Clear all filters
|
|
141
|
-
</button>
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
94
|
</div>
|
|
146
95
|
<div
|
|
147
96
|
class="pf-v5-c-toolbar__content"
|
|
@@ -385,14 +334,6 @@ exports[`Toolbar should render with page inset flag 1`] = `
|
|
|
385
334
|
Test 3
|
|
386
335
|
</div>
|
|
387
336
|
</div>
|
|
388
|
-
<div
|
|
389
|
-
class="pf-v5-c-toolbar__expandable-content"
|
|
390
|
-
id="toolbar-expandable-content-1"
|
|
391
|
-
>
|
|
392
|
-
<div
|
|
393
|
-
class="pf-v5-c-toolbar__group"
|
|
394
|
-
/>
|
|
395
|
-
</div>
|
|
396
337
|
</div>
|
|
397
338
|
<div
|
|
398
339
|
class="pf-v5-c-toolbar__content pf-m-hidden"
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
MenuToggle,
|
|
4
|
+
MenuToggleElement,
|
|
5
|
+
Toolbar,
|
|
6
|
+
ToolbarItem,
|
|
7
|
+
ToolbarContent,
|
|
8
|
+
ToolbarToggleGroup,
|
|
9
|
+
ToolbarGroup,
|
|
10
|
+
SearchInput,
|
|
11
|
+
Select,
|
|
12
|
+
SelectList,
|
|
13
|
+
SelectOption,
|
|
14
|
+
ToolbarFilter,
|
|
15
|
+
Badge
|
|
16
|
+
} from '@patternfly/react-core';
|
|
17
|
+
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
18
|
+
|
|
19
|
+
export const Test: React.FunctionComponent = () => {
|
|
20
|
+
const statusChipContainerRef = React.useRef<HTMLDivElement>();
|
|
21
|
+
const riskChipContainerRef = React.useRef<HTMLDivElement>();
|
|
22
|
+
|
|
23
|
+
const [isStatusGroupExpanded, setIsStatusGroupExpanded] = React.useState(false);
|
|
24
|
+
const [isRiskGroupExpanded, setIsRiskGroupExpanded] = React.useState(false);
|
|
25
|
+
|
|
26
|
+
const [isStatusMenuExpanded, setIsStatusExpanded] = React.useState(false);
|
|
27
|
+
const [isRiskMenuExpanded, setIsRiskExpanded] = React.useState(false);
|
|
28
|
+
const [inputValue, setInputValue] = React.useState('');
|
|
29
|
+
const [filters, setFilters] = React.useState({
|
|
30
|
+
risk: ['Low'],
|
|
31
|
+
status: ['New', 'Pending']
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const closeToggleGroups = () => {
|
|
35
|
+
setIsStatusGroupExpanded(false);
|
|
36
|
+
setIsRiskGroupExpanded(false);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
window.addEventListener('resize', closeToggleGroups); // Resize observer to toggle off expand groups is required to properly reformat toolbar when growing
|
|
41
|
+
return () => {
|
|
42
|
+
window.removeEventListener('resize', closeToggleGroups);
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
const onInputChange = (newValue: string) => {
|
|
47
|
+
setInputValue(newValue);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const onStatusToggle = () => {
|
|
51
|
+
setIsStatusExpanded(!isStatusMenuExpanded);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const onRiskToggle = () => {
|
|
55
|
+
setIsRiskExpanded(!isRiskMenuExpanded);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const onSelect = (type: string, event: React.MouseEvent | React.ChangeEvent | undefined, selection: string) => {
|
|
59
|
+
const checked = (event?.target as HTMLInputElement).checked;
|
|
60
|
+
setFilters((prev) => {
|
|
61
|
+
const prevSelections = prev[type];
|
|
62
|
+
return {
|
|
63
|
+
...prev,
|
|
64
|
+
[type]: checked ? [...prevSelections, selection] : prevSelections.filter((value) => value !== selection)
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const onStatusSelect = (event: React.MouseEvent | React.ChangeEvent | undefined, selection: string) => {
|
|
70
|
+
onSelect('status', event, selection);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const onRiskSelect = (event: React.MouseEvent | React.ChangeEvent | undefined, selection: string) => {
|
|
74
|
+
onSelect('risk', event, selection);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const onDelete = (type: string, id: string) => {
|
|
78
|
+
if (type === 'Risk') {
|
|
79
|
+
setFilters({ risk: filters.risk.filter((fil: string) => fil !== id), status: filters.status });
|
|
80
|
+
} else if (type === 'Status') {
|
|
81
|
+
setFilters({ risk: filters.risk, status: filters.status.filter((fil: string) => fil !== id) });
|
|
82
|
+
} else {
|
|
83
|
+
setFilters({ risk: [], status: [] });
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const onDeleteGroup = (type: string) => {
|
|
88
|
+
if (type === 'Risk') {
|
|
89
|
+
setFilters({ risk: [], status: filters.status });
|
|
90
|
+
} else if (type === 'Status') {
|
|
91
|
+
setFilters({ risk: filters.risk, status: [] });
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const statusToggleGroupItems = (
|
|
96
|
+
<React.Fragment>
|
|
97
|
+
<ToolbarItem variant="search-filter">
|
|
98
|
+
<SearchInput
|
|
99
|
+
aria-label="Consumer toggle groups example search input"
|
|
100
|
+
onChange={(_event, value) => onInputChange(value)}
|
|
101
|
+
value={inputValue}
|
|
102
|
+
onClear={() => {
|
|
103
|
+
onInputChange('');
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
</ToolbarItem>
|
|
107
|
+
<ToolbarGroup variant="filter-group">
|
|
108
|
+
<ToolbarFilter
|
|
109
|
+
chips={filters.status}
|
|
110
|
+
deleteChip={(category, chip) => onDelete(category as string, chip as string)}
|
|
111
|
+
deleteChipGroup={(category) => onDeleteGroup(category as string)}
|
|
112
|
+
categoryName="Status"
|
|
113
|
+
isExpanded={isStatusGroupExpanded}
|
|
114
|
+
expandableChipContainerRef={statusChipContainerRef} // Required to link the toolbar filter chip group to the custom expandable group
|
|
115
|
+
>
|
|
116
|
+
<Select
|
|
117
|
+
aria-label="Status"
|
|
118
|
+
role="menu"
|
|
119
|
+
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
|
120
|
+
<MenuToggle
|
|
121
|
+
ref={toggleRef}
|
|
122
|
+
onClick={onStatusToggle}
|
|
123
|
+
isExpanded={isStatusMenuExpanded}
|
|
124
|
+
style={
|
|
125
|
+
{
|
|
126
|
+
width: '140px'
|
|
127
|
+
} as React.CSSProperties
|
|
128
|
+
}
|
|
129
|
+
>
|
|
130
|
+
Status
|
|
131
|
+
{filters.status.length > 0 && <Badge isRead>{filters.status.length}</Badge>}
|
|
132
|
+
</MenuToggle>
|
|
133
|
+
)}
|
|
134
|
+
onSelect={(event, selection) => onStatusSelect(event, selection as string)}
|
|
135
|
+
selected={filters.status}
|
|
136
|
+
isOpen={isStatusMenuExpanded}
|
|
137
|
+
onOpenChange={(isOpen) => setIsStatusExpanded(isOpen)}
|
|
138
|
+
>
|
|
139
|
+
<SelectList>
|
|
140
|
+
<SelectOption hasCheckbox key="statusNew" value="New" isSelected={filters.status.includes('New')}>
|
|
141
|
+
New
|
|
142
|
+
</SelectOption>
|
|
143
|
+
<SelectOption
|
|
144
|
+
hasCheckbox
|
|
145
|
+
key="statusPending"
|
|
146
|
+
value="Pending"
|
|
147
|
+
isSelected={filters.status.includes('Pending')}
|
|
148
|
+
>
|
|
149
|
+
Pending
|
|
150
|
+
</SelectOption>
|
|
151
|
+
<SelectOption
|
|
152
|
+
hasCheckbox
|
|
153
|
+
key="statusRunning"
|
|
154
|
+
value="Running"
|
|
155
|
+
isSelected={filters.status.includes('Running')}
|
|
156
|
+
>
|
|
157
|
+
Running
|
|
158
|
+
</SelectOption>
|
|
159
|
+
<SelectOption
|
|
160
|
+
hasCheckbox
|
|
161
|
+
key="statusCancelled"
|
|
162
|
+
value="Cancelled"
|
|
163
|
+
isSelected={filters.status.includes('Cancelled')}
|
|
164
|
+
>
|
|
165
|
+
Cancelled
|
|
166
|
+
</SelectOption>
|
|
167
|
+
</SelectList>
|
|
168
|
+
</Select>
|
|
169
|
+
</ToolbarFilter>
|
|
170
|
+
</ToolbarGroup>
|
|
171
|
+
</React.Fragment>
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const riskToggleGroupItems = (
|
|
175
|
+
<ToolbarGroup variant="filter-group">
|
|
176
|
+
<ToolbarFilter
|
|
177
|
+
chips={filters.risk}
|
|
178
|
+
deleteChip={(category, chip) => onDelete(category as string, chip as string)}
|
|
179
|
+
categoryName="Risk"
|
|
180
|
+
isExpanded={isRiskGroupExpanded}
|
|
181
|
+
expandableChipContainerRef={riskChipContainerRef} // Required to link the toolbar filter chip group to the custom expandable group
|
|
182
|
+
>
|
|
183
|
+
<Select
|
|
184
|
+
aria-label="Risk"
|
|
185
|
+
role="menu"
|
|
186
|
+
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
|
187
|
+
<MenuToggle
|
|
188
|
+
ref={toggleRef}
|
|
189
|
+
onClick={onRiskToggle}
|
|
190
|
+
isExpanded={isRiskMenuExpanded}
|
|
191
|
+
style={
|
|
192
|
+
{
|
|
193
|
+
width: '140px'
|
|
194
|
+
} as React.CSSProperties
|
|
195
|
+
}
|
|
196
|
+
>
|
|
197
|
+
Risk
|
|
198
|
+
{filters.risk.length > 0 && <Badge isRead>{filters.risk.length}</Badge>}
|
|
199
|
+
</MenuToggle>
|
|
200
|
+
)}
|
|
201
|
+
onSelect={(event, selection) => onRiskSelect(event, selection as string)}
|
|
202
|
+
selected={filters.risk}
|
|
203
|
+
isOpen={isRiskMenuExpanded}
|
|
204
|
+
onOpenChange={(isOpen) => setIsRiskExpanded(isOpen)}
|
|
205
|
+
>
|
|
206
|
+
<SelectList>
|
|
207
|
+
<SelectOption hasCheckbox key="riskLow" value="Low" isSelected={filters.risk.includes('Low')}>
|
|
208
|
+
Low
|
|
209
|
+
</SelectOption>
|
|
210
|
+
<SelectOption hasCheckbox key="riskMedium" value="Medium" isSelected={filters.risk.includes('Medium')}>
|
|
211
|
+
Medium
|
|
212
|
+
</SelectOption>
|
|
213
|
+
<SelectOption hasCheckbox key="riskHigh" value="High" isSelected={filters.risk.includes('High')}>
|
|
214
|
+
High
|
|
215
|
+
</SelectOption>
|
|
216
|
+
</SelectList>
|
|
217
|
+
</Select>
|
|
218
|
+
</ToolbarFilter>
|
|
219
|
+
</ToolbarGroup>
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<Toolbar id="toolbar-multiple-toggle-groups" className="pf-m-toggle-group-container">
|
|
224
|
+
<ToolbarContent>
|
|
225
|
+
<ToolbarToggleGroup
|
|
226
|
+
isExpanded={isStatusGroupExpanded} // Required to control expanded state
|
|
227
|
+
onToggle={() => {
|
|
228
|
+
setIsStatusGroupExpanded(!isStatusGroupExpanded);
|
|
229
|
+
setIsRiskGroupExpanded(false);
|
|
230
|
+
}} // Required to control expanded state
|
|
231
|
+
toggleIcon={<FilterIcon />}
|
|
232
|
+
breakpoint="md"
|
|
233
|
+
chipContainerRef={statusChipContainerRef}
|
|
234
|
+
showClearFiltersButton
|
|
235
|
+
clearAllFilters={() => onDeleteGroup('Status')}
|
|
236
|
+
clearFiltersButtonText="Clear status filter"
|
|
237
|
+
>
|
|
238
|
+
{statusToggleGroupItems}
|
|
239
|
+
</ToolbarToggleGroup>
|
|
240
|
+
<ToolbarToggleGroup
|
|
241
|
+
isExpanded={isRiskGroupExpanded} // Required to control expanded state
|
|
242
|
+
onToggle={() => {
|
|
243
|
+
setIsRiskGroupExpanded(!isRiskGroupExpanded);
|
|
244
|
+
setIsStatusGroupExpanded(false);
|
|
245
|
+
}} // Required to control expanded state
|
|
246
|
+
toggleIcon={<FilterIcon />}
|
|
247
|
+
breakpoint="xl"
|
|
248
|
+
chipContainerRef={riskChipContainerRef}
|
|
249
|
+
showClearFiltersButton
|
|
250
|
+
clearAllFilters={() => onDeleteGroup('Risk')}
|
|
251
|
+
clearFiltersButtonText={'Clear risk filter'}
|
|
252
|
+
>
|
|
253
|
+
{riskToggleGroupItems}
|
|
254
|
+
</ToolbarToggleGroup>
|
|
255
|
+
</ToolbarContent>
|
|
256
|
+
</Toolbar>
|
|
257
|
+
);
|
|
258
|
+
};
|
|
@@ -14,6 +14,12 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico
|
|
|
14
14
|
|
|
15
15
|
## Examples
|
|
16
16
|
|
|
17
|
+
### TEST - remove before merging
|
|
18
|
+
|
|
19
|
+
```ts file="./Test.tsx"
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
17
23
|
### Toolbar items
|
|
18
24
|
|
|
19
25
|
A toolbar can contain multiple toolbar items, like filters and buttons.
|
|
@@ -28,7 +34,7 @@ Note: This example does not demonstrate responsive toolbar behavior. Responsive
|
|
|
28
34
|
|
|
29
35
|
You may adjust the space between toolbar items to arrange them into groups. Read our spacers documentation to learn more about using spacers.
|
|
30
36
|
|
|
31
|
-
Items are spaced “16px” apart by default. To adjust the size of the space between items, use the `spacer` property of each `<ToolbarItem>`. You can set the `spacer` value at multiple breakpoints, including "default", "md", "lg", "xl", and "2xl".
|
|
37
|
+
Items are spaced “16px” apart by default. To adjust the size of the space between items, use the `spacer` property of each `<ToolbarItem>`. You can set the `spacer` value at multiple breakpoints, including "default", "md", "lg", "xl", and "2xl". Available `spacer` values include "spacerNone", "spacerSm", "spacerMd", or "spacerLg" into each breakpoint.
|
|
32
38
|
|
|
33
39
|
```ts file="./ToolbarSpacers.tsx"
|
|
34
40
|
|
|
@@ -54,27 +60,28 @@ To adjust a toolbar’s inset, use the `inset` property. You can set the inset v
|
|
|
54
60
|
|
|
55
61
|
### Sticky toolbar
|
|
56
62
|
|
|
57
|
-
To lock a toolbar and prevent it
|
|
63
|
+
To lock a toolbar and prevent it from scrolling with other content, use a sticky toolbar.
|
|
58
64
|
|
|
59
65
|
In the following example, toggle the "is toolbar sticky" checkbox to see the difference between a sticky and non-sticky toolbar.
|
|
60
66
|
|
|
61
67
|
```ts file="./ToolbarSticky.tsx"
|
|
68
|
+
|
|
62
69
|
```
|
|
63
70
|
|
|
64
71
|
### With groups of items
|
|
65
72
|
|
|
66
|
-
You can group similar items together to create desired associations and to enable items to respond to changes in viewport width together.
|
|
73
|
+
You can group similar items together to create desired associations and to enable items to respond to changes in viewport width together.
|
|
67
74
|
|
|
68
75
|
Note: This example does not demonstrate responsive toolbar behavior. Responsive toolbars are shown in the [examples with toggle groups and filters](/components/toolbar#examples-with-toggle-groups-and-filters).
|
|
69
76
|
|
|
70
77
|
```ts file="./ToolbarGroups.tsx"
|
|
71
78
|
|
|
72
79
|
```
|
|
80
|
+
|
|
73
81
|
## Examples with toggle groups and filters
|
|
74
82
|
|
|
75
83
|
The following examples use toggle groups to allow for more responsive and complex toolbars with multiple items and groups of items. To visualize responsive toolbar behavior in the following examples, resize the browser to a smaller screen width.
|
|
76
84
|
|
|
77
|
-
|
|
78
85
|
### Component managed toggle groups
|
|
79
86
|
|
|
80
87
|
A toggle group allows you to collapse a set of items into an overlay panel at a certain breakpoint. For example, when a toggle group contains filter controls, its contents will collapse into an overlay panel when the toolbar adapts to a change in the viewport size. The contents can be toggled by selecting the filter icon in the overlay panel.
|
|
@@ -102,7 +109,6 @@ You can add filters to a toolbar to let users filter the content that a toolbar
|
|
|
102
109
|
|
|
103
110
|
The `<ToolbarFilter>` component expects applied filters and a delete chip handler to be passed in as properties. Pass in a `deleteChipGroup` property to close the entire chip group. Once close, the rendering of chips will be handled responsively by the toolbar.
|
|
104
111
|
|
|
105
|
-
|
|
106
112
|
```ts file="./ToolbarWithFilters.tsx"
|
|
107
113
|
|
|
108
114
|
```
|
|
@@ -120,5 +126,5 @@ To customize the chip groups generated by toolbar filters, use the `customChipGr
|
|
|
120
126
|
When all of a toolbar's required elements cannot fit in a single line, you can split toolbar items into multiple rows.
|
|
121
127
|
|
|
122
128
|
```ts file="./ToolbarStacked.tsx"
|
|
123
|
-
```
|
|
124
129
|
|
|
130
|
+
```
|