@patternfly/react-core 5.1.1-prerelease.4 → 5.1.1-prerelease.6
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 +10 -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
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.1.1-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.1.1-prerelease.5","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.1.1-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.1.1-prerelease.5","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.1.1-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.1.1-prerelease.5","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.1.1-prerelease.
|
|
3
|
+
"version": "5.1.1-prerelease.6",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@patternfly/react-icons": "^5.1.1-prerelease.
|
|
49
|
-
"@patternfly/react-styles": "^5.1.1-prerelease.
|
|
50
|
-
"@patternfly/react-tokens": "^5.1.1-prerelease.
|
|
48
|
+
"@patternfly/react-icons": "^5.1.1-prerelease.4",
|
|
49
|
+
"@patternfly/react-styles": "^5.1.1-prerelease.4",
|
|
50
|
+
"@patternfly/react-tokens": "^5.1.1-prerelease.4",
|
|
51
51
|
"focus-trap": "7.5.2",
|
|
52
52
|
"react-dropzone": "^14.2.3",
|
|
53
53
|
"tslib": "^2.5.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@patternfly/patternfly": "5.1.0-prerelease.
|
|
56
|
+
"@patternfly/patternfly": "5.1.0-prerelease.21",
|
|
57
57
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
58
58
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
59
59
|
"@rollup/plugin-replace": "^5.0.2",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^17 || ^18",
|
|
71
71
|
"react-dom": "^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b61a033e45c6c3d4ff582754e505e9211c052c95"
|
|
74
74
|
}
|
|
@@ -7,77 +7,81 @@ import { Alert } from '../../Alert';
|
|
|
7
7
|
import { AlertGroup } from '../../Alert';
|
|
8
8
|
import { AlertActionCloseButton } from '../../../components/Alert/AlertActionCloseButton';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
10
|
+
test('Alert Group renders without children', () => {
|
|
11
|
+
render(
|
|
12
|
+
<div data-testid="container">
|
|
13
|
+
<AlertGroup data-testid="alertgroup" />
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
expect(screen.getByTestId('container').firstChild).toBeVisible();
|
|
18
|
+
expect(screen.getByTestId('alertgroup').children.length).toBe(0);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('Alert Group works with n children', () => {
|
|
22
|
+
const { asFragment } = render(
|
|
23
|
+
<AlertGroup data-testid="container">
|
|
24
|
+
<Alert variant="success" title="alert title" />
|
|
25
|
+
<Alert variant="warning" title="another alert title" />
|
|
26
|
+
</AlertGroup>
|
|
27
|
+
);
|
|
28
|
+
expect(screen.getByTestId('container').children.length).toBe(2);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('Alert group overflow shows up', async () => {
|
|
32
|
+
const overflowMessage = 'View 2 more alerts';
|
|
33
|
+
const onOverflowClick = jest.fn();
|
|
34
|
+
const user = userEvent.setup();
|
|
35
|
+
|
|
36
|
+
render(
|
|
37
|
+
<AlertGroup overflowMessage={overflowMessage} onOverflowClick={onOverflowClick}>
|
|
38
|
+
<Alert variant="danger" title="alert title" />
|
|
39
|
+
</AlertGroup>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(screen.getAllByRole('listitem')).toHaveLength(2);
|
|
43
|
+
|
|
44
|
+
const overflowButton = screen.getByRole('button', { name: 'View 2 more alerts' });
|
|
45
|
+
expect(overflowButton).toBeInTheDocument();
|
|
46
|
+
|
|
47
|
+
await user.click(overflowButton);
|
|
48
|
+
expect(onOverflowClick).toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('Standard Alert Group is not a toast alert group', () => {
|
|
52
|
+
render(
|
|
53
|
+
<AlertGroup>
|
|
54
|
+
<Alert variant="danger" title="alert title" />
|
|
55
|
+
</AlertGroup>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(screen.getByText('alert title').parentElement).not.toHaveClass('pf-m-toast');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('Toast Alert Group contains expected modifier class', () => {
|
|
62
|
+
render(
|
|
63
|
+
<AlertGroup isToast aria-label="group label">
|
|
64
|
+
<Alert variant="warning" title="alert title" />
|
|
65
|
+
</AlertGroup>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
expect(screen.getByLabelText('group label')).toHaveClass('pf-m-toast');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('alertgroup closes when alerts are closed', async () => {
|
|
72
|
+
const onClose = jest.fn();
|
|
73
|
+
const user = userEvent.setup();
|
|
74
|
+
|
|
75
|
+
render(
|
|
76
|
+
<AlertGroup isToast appendTo={document.body}>
|
|
77
|
+
<Alert
|
|
78
|
+
isLiveRegion
|
|
79
|
+
title={'Test Alert'}
|
|
80
|
+
actionClose={<AlertActionCloseButton aria-label="Close" onClose={onClose} />}
|
|
81
|
+
/>
|
|
82
|
+
</AlertGroup>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
await user.click(screen.getByLabelText('Close'));
|
|
86
|
+
expect(onClose).toHaveBeenCalled();
|
|
83
87
|
});
|
|
@@ -3,7 +3,6 @@ import styles from '@patternfly/react-styles/css/components/Toolbar/toolbar';
|
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { ToolbarContentContext, ToolbarContext } from './ToolbarUtils';
|
|
5
5
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
6
|
-
import { ToolbarExpandableContent } from './ToolbarExpandableContent';
|
|
7
6
|
import { PageContext } from '../Page/PageContext';
|
|
8
7
|
|
|
9
8
|
export interface ToolbarContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
@@ -70,6 +69,7 @@ class ToolbarContent extends React.Component<ToolbarContentProps> {
|
|
|
70
69
|
formatBreakpointMods(visibility, styles, '', getBreakpoint(width)),
|
|
71
70
|
className
|
|
72
71
|
)}
|
|
72
|
+
ref={this.expandableContentRef}
|
|
73
73
|
{...props}
|
|
74
74
|
>
|
|
75
75
|
<ToolbarContext.Consumer>
|
|
@@ -77,6 +77,7 @@ class ToolbarContent extends React.Component<ToolbarContentProps> {
|
|
|
77
77
|
clearAllFilters: clearAllFiltersContext,
|
|
78
78
|
clearFiltersButtonText: clearFiltersButtonContext,
|
|
79
79
|
showClearFiltersButton: showClearFiltersButtonContext,
|
|
80
|
+
isExpanded: isExpandedContext,
|
|
80
81
|
toolbarId: toolbarIdContext
|
|
81
82
|
}) => {
|
|
82
83
|
const expandableContentId = `${
|
|
@@ -87,7 +88,11 @@ class ToolbarContent extends React.Component<ToolbarContentProps> {
|
|
|
87
88
|
value={{
|
|
88
89
|
expandableContentRef: this.expandableContentRef,
|
|
89
90
|
expandableContentId,
|
|
90
|
-
chipContainerRef: this.chipContainerRef
|
|
91
|
+
chipContainerRef: this.chipContainerRef,
|
|
92
|
+
isExpanded: isExpanded || isExpandedContext,
|
|
93
|
+
clearAllFilters: clearAllFilters || clearAllFiltersContext,
|
|
94
|
+
clearFiltersButtonText: clearFiltersButtonText || clearFiltersButtonContext,
|
|
95
|
+
showClearFiltersButton: showClearFiltersButton || showClearFiltersButtonContext
|
|
91
96
|
}}
|
|
92
97
|
>
|
|
93
98
|
<div
|
|
@@ -103,15 +108,6 @@ class ToolbarContent extends React.Component<ToolbarContentProps> {
|
|
|
103
108
|
>
|
|
104
109
|
{children}
|
|
105
110
|
</div>
|
|
106
|
-
<ToolbarExpandableContent
|
|
107
|
-
id={expandableContentId}
|
|
108
|
-
isExpanded={isExpanded}
|
|
109
|
-
expandableContentRef={this.expandableContentRef}
|
|
110
|
-
chipContainerRef={this.chipContainerRef}
|
|
111
|
-
clearAllFilters={clearAllFilters || clearAllFiltersContext}
|
|
112
|
-
showClearFiltersButton={showClearFiltersButton || showClearFiltersButtonContext}
|
|
113
|
-
clearFiltersButtonText={clearFiltersButtonText || clearFiltersButtonContext}
|
|
114
|
-
/>
|
|
115
111
|
</ToolbarContentContext.Provider>
|
|
116
112
|
);
|
|
117
113
|
}}
|
|
@@ -37,10 +37,10 @@ class ToolbarExpandableContent extends React.Component<ToolbarExpandableContentP
|
|
|
37
37
|
|
|
38
38
|
render() {
|
|
39
39
|
const {
|
|
40
|
+
children,
|
|
40
41
|
className,
|
|
41
42
|
expandableContentRef,
|
|
42
43
|
chipContainerRef,
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
44
|
isExpanded,
|
|
45
45
|
clearAllFilters,
|
|
46
46
|
clearFiltersButtonText,
|
|
@@ -54,8 +54,12 @@ class ToolbarExpandableContent extends React.Component<ToolbarExpandableContentP
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
|
-
<div
|
|
58
|
-
|
|
57
|
+
<div
|
|
58
|
+
className={css(styles.toolbarExpandableContent, isExpanded && styles.modifiers.expanded, className)}
|
|
59
|
+
ref={expandableContentRef}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
<ToolbarGroup>{children}</ToolbarGroup>
|
|
59
63
|
{numberOfFilters > 0 && (
|
|
60
64
|
<ToolbarGroup className={styles.modifiers.chipContainer}>
|
|
61
65
|
<ToolbarGroup ref={chipContainerRef} />
|
|
@@ -21,6 +21,8 @@ export interface ToolbarChip {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface ToolbarFilterProps extends ToolbarItemProps {
|
|
24
|
+
/** Flag indicating when toolbar toggle group is expanded for non-managed toolbar toggle groups. */
|
|
25
|
+
isExpanded?: boolean;
|
|
24
26
|
/** An array of strings to be displayed as chips in the expandable content */
|
|
25
27
|
chips?: (string | ToolbarChip)[];
|
|
26
28
|
/** Callback passed by consumer used to close the entire chip group */
|
|
@@ -37,6 +39,8 @@ export interface ToolbarFilterProps extends ToolbarItemProps {
|
|
|
37
39
|
categoryName: string | ToolbarChipGroup;
|
|
38
40
|
/** Flag to show the toolbar item */
|
|
39
41
|
showToolbarItem?: boolean;
|
|
42
|
+
/** Reference to a chip container created with a custom expandable content group, for non-managed multiple toolbar toggle groups. */
|
|
43
|
+
expandableChipContainerRef?: React.RefObject<HTMLDivElement>;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
interface ToolbarFilterState {
|
|
@@ -90,9 +94,12 @@ class ToolbarFilter extends React.Component<ToolbarFilterProps, ToolbarFilterSta
|
|
|
90
94
|
chipGroupCollapsedText,
|
|
91
95
|
categoryName,
|
|
92
96
|
showToolbarItem,
|
|
97
|
+
isExpanded,
|
|
98
|
+
expandableChipContainerRef,
|
|
93
99
|
...props
|
|
94
100
|
} = this.props;
|
|
95
|
-
const { isExpanded, chipGroupContentRef } = this.context;
|
|
101
|
+
const { isExpanded: managedIsExpanded, chipGroupContentRef } = this.context;
|
|
102
|
+
const _isExpanded = isExpanded !== undefined ? isExpanded : managedIsExpanded;
|
|
96
103
|
const categoryKey =
|
|
97
104
|
typeof categoryName !== 'string' && categoryName.hasOwnProperty('key')
|
|
98
105
|
? categoryName.key
|
|
@@ -123,7 +130,7 @@ class ToolbarFilter extends React.Component<ToolbarFilterProps, ToolbarFilterSta
|
|
|
123
130
|
</ToolbarItem>
|
|
124
131
|
) : null;
|
|
125
132
|
|
|
126
|
-
if (!
|
|
133
|
+
if (!_isExpanded && this.state.isMounted) {
|
|
127
134
|
return (
|
|
128
135
|
<React.Fragment>
|
|
129
136
|
{showToolbarItem && <ToolbarItem {...props}>{children}</ToolbarItem>}
|
|
@@ -138,6 +145,9 @@ class ToolbarFilter extends React.Component<ToolbarFilterProps, ToolbarFilterSta
|
|
|
138
145
|
<React.Fragment>
|
|
139
146
|
{showToolbarItem && <ToolbarItem {...props}>{children}</ToolbarItem>}
|
|
140
147
|
{chipContainerRef.current && ReactDOM.createPortal(chipGroup, chipContainerRef.current)}
|
|
148
|
+
{expandableChipContainerRef &&
|
|
149
|
+
expandableChipContainerRef.current &&
|
|
150
|
+
ReactDOM.createPortal(chipGroup, expandableChipContainerRef.current)}
|
|
141
151
|
</React.Fragment>
|
|
142
152
|
)}
|
|
143
153
|
</ToolbarContentContext.Consumer>
|
|
@@ -8,8 +8,13 @@ import { Button } from '../Button';
|
|
|
8
8
|
import globalBreakpointLg from '@patternfly/react-tokens/dist/esm/global_breakpoint_lg';
|
|
9
9
|
import { formatBreakpointMods, toCamel, canUseDOM } from '../../helpers/util';
|
|
10
10
|
import { PageContext } from '../Page/PageContext';
|
|
11
|
+
import { ToolbarExpandableContent } from './ToolbarExpandableContent';
|
|
11
12
|
|
|
12
13
|
export interface ToolbarToggleGroupProps extends ToolbarGroupProps {
|
|
14
|
+
/** Flag indicating when toggle group is expanded for non-managed toolbar toggle groups. */
|
|
15
|
+
isExpanded?: boolean;
|
|
16
|
+
/** Callback for toggle group click event for non-managed toolbar toggle groups. */
|
|
17
|
+
onToggle?: (event: React.MouseEvent) => void;
|
|
13
18
|
/** An icon to be rendered when the toggle group has collapsed down */
|
|
14
19
|
toggleIcon: React.ReactNode;
|
|
15
20
|
/** Controls when filters are shown and when the toggle button is hidden. */
|
|
@@ -46,10 +51,21 @@ export interface ToolbarToggleGroupProps extends ToolbarGroupProps {
|
|
|
46
51
|
xl?: 'spaceItemsNone' | 'spaceItemsSm' | 'spaceItemsMd' | 'spaceItemsLg';
|
|
47
52
|
'2xl'?: 'spaceItemsNone' | 'spaceItemsSm' | 'spaceItemsMd' | 'spaceItemsLg';
|
|
48
53
|
};
|
|
54
|
+
/** Reference to a chip container group for filters inside the toolbar toggle group */
|
|
55
|
+
chipContainerRef?: React.RefObject<any>;
|
|
56
|
+
/** Optional callback for clearing all filters in the toolbar toggle group */
|
|
57
|
+
clearAllFilters?: () => void;
|
|
58
|
+
/** Flag indicating that the clear all filters button should be visible in the toolbar toggle group */
|
|
59
|
+
showClearFiltersButton?: boolean;
|
|
60
|
+
/** Text to display in the clear all filters button of the toolbar toggle group */
|
|
61
|
+
clearFiltersButtonText?: string;
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
class ToolbarToggleGroup extends React.Component<ToolbarToggleGroupProps> {
|
|
52
65
|
static displayName = 'ToolbarToggleGroup';
|
|
66
|
+
toggleRef = React.createRef<HTMLButtonElement>();
|
|
67
|
+
expandableContentRef = React.createRef<HTMLDivElement>();
|
|
68
|
+
|
|
53
69
|
isContentPopup = () => {
|
|
54
70
|
const viewportSize = canUseDOM ? window.innerWidth : 1200;
|
|
55
71
|
const lgBreakpointValue = parseInt(globalBreakpointLg.value);
|
|
@@ -67,6 +83,12 @@ class ToolbarToggleGroup extends React.Component<ToolbarToggleGroupProps> {
|
|
|
67
83
|
spaceItems,
|
|
68
84
|
className,
|
|
69
85
|
children,
|
|
86
|
+
isExpanded,
|
|
87
|
+
onToggle,
|
|
88
|
+
chipContainerRef,
|
|
89
|
+
clearAllFilters,
|
|
90
|
+
showClearFiltersButton,
|
|
91
|
+
clearFiltersButtonText,
|
|
70
92
|
...props
|
|
71
93
|
} = this.props;
|
|
72
94
|
|
|
@@ -79,64 +101,87 @@ class ToolbarToggleGroup extends React.Component<ToolbarToggleGroupProps> {
|
|
|
79
101
|
<PageContext.Consumer>
|
|
80
102
|
{({ width, getBreakpoint }) => (
|
|
81
103
|
<ToolbarContext.Consumer>
|
|
82
|
-
{({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
{({ toggleIsExpanded: managedOnToggle }) => {
|
|
105
|
+
const _onToggle = onToggle !== undefined ? onToggle : managedOnToggle;
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<ToolbarContentContext.Consumer>
|
|
109
|
+
{({
|
|
110
|
+
expandableContentRef,
|
|
111
|
+
expandableContentId,
|
|
112
|
+
chipContainerRef: managedChipContainerRef,
|
|
113
|
+
isExpanded: managedIsExpanded,
|
|
114
|
+
clearAllFilters: clearAllFiltersContext,
|
|
115
|
+
clearFiltersButtonText: clearFiltersButtonContext,
|
|
116
|
+
showClearFiltersButton: showClearFiltersButtonContext
|
|
117
|
+
}) => {
|
|
118
|
+
const _isExpanded = isExpanded !== undefined ? isExpanded : managedIsExpanded;
|
|
119
|
+
const _chipContainerRef =
|
|
120
|
+
chipContainerRef !== undefined ? chipContainerRef : managedChipContainerRef;
|
|
121
|
+
|
|
122
|
+
const breakpointMod: {
|
|
123
|
+
md?: 'show';
|
|
124
|
+
lg?: 'show';
|
|
125
|
+
xl?: 'show';
|
|
126
|
+
'2xl'?: 'show';
|
|
127
|
+
} = {};
|
|
128
|
+
breakpointMod[breakpoint] = 'show';
|
|
92
129
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
130
|
+
const expandableContent = (
|
|
131
|
+
<ToolbarExpandableContent
|
|
132
|
+
id={expandableContentId}
|
|
133
|
+
expandableContentRef={this.expandableContentRef}
|
|
134
|
+
isExpanded={_isExpanded}
|
|
135
|
+
clearAllFilters={clearAllFilters || clearAllFiltersContext}
|
|
136
|
+
showClearFiltersButton={showClearFiltersButton || showClearFiltersButtonContext}
|
|
137
|
+
clearFiltersButtonText={clearFiltersButtonText || clearFiltersButtonContext}
|
|
138
|
+
chipContainerRef={_chipContainerRef}
|
|
139
|
+
>
|
|
140
|
+
{children}
|
|
141
|
+
</ToolbarExpandableContent>
|
|
142
|
+
);
|
|
100
143
|
|
|
101
|
-
|
|
102
|
-
<div
|
|
103
|
-
className={css(
|
|
104
|
-
styles.toolbarGroup,
|
|
105
|
-
styles.modifiers.toggleGroup,
|
|
106
|
-
variant &&
|
|
107
|
-
styles.modifiers[toCamel(variant) as 'filterGroup' | 'iconButtonGroup' | 'buttonGroup'],
|
|
108
|
-
formatBreakpointMods(breakpointMod, styles, '', getBreakpoint(width)),
|
|
109
|
-
formatBreakpointMods(visibility, styles, '', getBreakpoint(width)),
|
|
110
|
-
formatBreakpointMods(alignment, styles, '', getBreakpoint(width)),
|
|
111
|
-
formatBreakpointMods(spacer, styles, '', getBreakpoint(width)),
|
|
112
|
-
formatBreakpointMods(spaceItems, styles, '', getBreakpoint(width)),
|
|
113
|
-
className
|
|
114
|
-
)}
|
|
115
|
-
{...props}
|
|
116
|
-
>
|
|
144
|
+
const toggleButton = (
|
|
117
145
|
<div className={css(styles.toolbarToggle)}>
|
|
118
146
|
<Button
|
|
119
147
|
variant="plain"
|
|
120
|
-
onClick={
|
|
148
|
+
onClick={_onToggle}
|
|
121
149
|
aria-label="Show Filters"
|
|
122
|
-
{...(
|
|
123
|
-
aria-haspopup={
|
|
150
|
+
{...(_isExpanded && { 'aria-expanded': true })}
|
|
151
|
+
aria-haspopup={_isExpanded && this.isContentPopup()}
|
|
124
152
|
aria-controls={expandableContentId}
|
|
153
|
+
ref={this.toggleRef}
|
|
125
154
|
>
|
|
126
155
|
{toggleIcon}
|
|
127
156
|
</Button>
|
|
128
157
|
</div>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div
|
|
162
|
+
className={css(
|
|
163
|
+
styles.toolbarGroup,
|
|
164
|
+
styles.modifiers.toggleGroup,
|
|
165
|
+
variant &&
|
|
166
|
+
styles.modifiers[toCamel(variant) as 'filterGroup' | 'iconButtonGroup' | 'buttonGroup'],
|
|
167
|
+
formatBreakpointMods(breakpointMod, styles, '', getBreakpoint(width)),
|
|
168
|
+
formatBreakpointMods(visibility, styles, '', getBreakpoint(width)),
|
|
169
|
+
formatBreakpointMods(alignment, styles, '', getBreakpoint(width)),
|
|
170
|
+
formatBreakpointMods(spacer, styles, '', getBreakpoint(width)),
|
|
171
|
+
formatBreakpointMods(spaceItems, styles, '', getBreakpoint(width)),
|
|
172
|
+
className
|
|
173
|
+
)}
|
|
174
|
+
{...props}
|
|
175
|
+
>
|
|
176
|
+
{toggleButton}
|
|
177
|
+
{_isExpanded && ReactDOM.createPortal(expandableContent, expandableContentRef.current)}
|
|
178
|
+
{!_isExpanded && children}
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
181
|
+
}}
|
|
182
|
+
</ToolbarContentContext.Consumer>
|
|
183
|
+
);
|
|
184
|
+
}}
|
|
140
185
|
</ToolbarContext.Consumer>
|
|
141
186
|
)}
|
|
142
187
|
</PageContext.Consumer>
|
|
@@ -31,12 +31,17 @@ interface ToolbarContentContextProps {
|
|
|
31
31
|
expandableContentRef: RefObject<HTMLDivElement>;
|
|
32
32
|
expandableContentId: string;
|
|
33
33
|
chipContainerRef: RefObject<any>;
|
|
34
|
+
isExpanded?: boolean;
|
|
35
|
+
clearAllFilters?: () => void;
|
|
36
|
+
clearFiltersButtonText?: string;
|
|
37
|
+
showClearFiltersButton?: boolean;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
export const ToolbarContentContext = React.createContext<ToolbarContentContextProps>({
|
|
37
41
|
expandableContentRef: null,
|
|
38
42
|
expandableContentId: '',
|
|
39
|
-
chipContainerRef: null
|
|
43
|
+
chipContainerRef: null,
|
|
44
|
+
clearAllFilters: () => {}
|
|
40
45
|
});
|
|
41
46
|
|
|
42
47
|
export const globalBreakpoints = {
|
package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarContent.test.tsx.snap
CHANGED
|
@@ -12,14 +12,6 @@ exports[`ToolbarContent should match snapshot (auto-generated) 1`] = `
|
|
|
12
12
|
ReactNode
|
|
13
13
|
</div>
|
|
14
14
|
</div>
|
|
15
|
-
<div
|
|
16
|
-
class="pf-v5-c-toolbar__expandable-content"
|
|
17
|
-
id="string-expandable-content-0"
|
|
18
|
-
>
|
|
19
|
-
<div
|
|
20
|
-
class="pf-v5-c-toolbar__group"
|
|
21
|
-
/>
|
|
22
|
-
</div>
|
|
23
15
|
</div>
|
|
24
16
|
</DocumentFragment>
|
|
25
17
|
`;
|
|
@@ -65,7 +65,7 @@ describe('Toolbar', () => {
|
|
|
65
65
|
<ToolbarFilter
|
|
66
66
|
chips={['New', 'Pending']}
|
|
67
67
|
deleteChip={(category, chip) => {}}
|
|
68
|
-
deleteChipGroup={category => {}}
|
|
68
|
+
deleteChipGroup={(category) => {}}
|
|
69
69
|
categoryName="Status"
|
|
70
70
|
>
|
|
71
71
|
test content
|
|
@@ -102,8 +102,7 @@ describe('Toolbar', () => {
|
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
expect(asFragment()).toMatchSnapshot();
|
|
105
|
-
|
|
106
|
-
expect(screen.getAllByRole('button', { name: '
|
|
107
|
-
expect(screen.getAllByRole('button', { name: 'Clear all filters' }).length).toBe(2);
|
|
105
|
+
expect(screen.getAllByRole('button', { name: 'Save filters' }).length).toBe(1);
|
|
106
|
+
expect(screen.getAllByRole('button', { name: 'Clear all filters' }).length).toBe(1);
|
|
108
107
|
});
|
|
109
108
|
});
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { ToolbarToggleGroup } from '../ToolbarToggleGroup';
|
|
4
|
-
import {
|
|
4
|
+
import { Toolbar } from '../Toolbar';
|
|
5
|
+
import { ToolbarContent } from '../ToolbarContent';
|
|
5
6
|
|
|
6
7
|
describe('ToolbarToggleGroup', () => {
|
|
7
8
|
it('should warn on bad props', () => {
|
|
8
9
|
const myMock = jest.fn() as any;
|
|
9
10
|
global.console = { error: myMock } as any;
|
|
10
11
|
|
|
12
|
+
const items = (
|
|
13
|
+
<React.Fragment>
|
|
14
|
+
<ToolbarToggleGroup breakpoint={undefined as 'xl'} toggleIcon={null}>
|
|
15
|
+
test
|
|
16
|
+
</ToolbarToggleGroup>
|
|
17
|
+
</React.Fragment>
|
|
18
|
+
);
|
|
19
|
+
|
|
11
20
|
render(
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
expandableContentRef: { current: undefined },
|
|
16
|
-
chipContainerRef: { current: undefined }
|
|
17
|
-
}}
|
|
18
|
-
>
|
|
19
|
-
<ToolbarToggleGroup breakpoint={undefined as 'xl'} toggleIcon={null} />
|
|
20
|
-
</ToolbarContentContext.Provider>
|
|
21
|
+
<Toolbar id="toolbar-with-filter" className="pf-m-toggle-group-container" collapseListedFiltersBreakpoint="xl">
|
|
22
|
+
<ToolbarContent>{items}</ToolbarContent>
|
|
23
|
+
</Toolbar>
|
|
21
24
|
);
|
|
22
25
|
|
|
23
26
|
expect(myMock).toHaveBeenCalled();
|