@patternfly/react-data-view 1.0.0-prerelease.4 → 5.0.0

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.
Files changed (50) hide show
  1. package/dist/cjs/DataView/DataView.test.d.ts +1 -0
  2. package/dist/cjs/DataView/DataView.test.js +23 -0
  3. package/dist/cjs/DataViewToolbar/DataViewToolbar.d.ts +5 -3
  4. package/dist/cjs/DataViewToolbar/DataViewToolbar.js +3 -2
  5. package/dist/cjs/DataViewToolbar/DataViewToolbar.test.d.ts +1 -0
  6. package/dist/cjs/DataViewToolbar/DataViewToolbar.test.js +14 -0
  7. package/dist/cjs/Hooks/index.d.ts +1 -0
  8. package/dist/cjs/Hooks/index.js +1 -0
  9. package/dist/cjs/Hooks/pagination.d.ts +3 -0
  10. package/dist/cjs/Hooks/selection.d.ts +11 -0
  11. package/dist/cjs/Hooks/selection.js +26 -0
  12. package/dist/cjs/Hooks/selection.test.d.ts +1 -0
  13. package/dist/cjs/Hooks/selection.test.js +55 -0
  14. package/dist/esm/DataView/DataView.test.d.ts +1 -0
  15. package/dist/esm/DataView/DataView.test.js +18 -0
  16. package/dist/esm/DataViewToolbar/DataViewToolbar.d.ts +5 -3
  17. package/dist/esm/DataViewToolbar/DataViewToolbar.js +3 -2
  18. package/dist/esm/DataViewToolbar/DataViewToolbar.test.d.ts +1 -0
  19. package/dist/esm/DataViewToolbar/DataViewToolbar.test.js +9 -0
  20. package/dist/esm/Hooks/index.d.ts +1 -0
  21. package/dist/esm/Hooks/index.js +1 -0
  22. package/dist/esm/Hooks/pagination.d.ts +3 -0
  23. package/dist/esm/Hooks/selection.d.ts +11 -0
  24. package/dist/esm/Hooks/selection.js +22 -0
  25. package/dist/esm/Hooks/selection.test.d.ts +1 -0
  26. package/dist/esm/Hooks/selection.test.js +53 -0
  27. package/generate-fed-package-json.js +7 -8
  28. package/generate-index.js +2 -2
  29. package/package.json +8 -8
  30. package/patternfly-docs/content/extensions/data-view/examples/{DataViewToolbar/DataViewToolbar.md → Components/Components.md} +9 -5
  31. package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewToolbarExample.tsx +20 -0
  32. package/patternfly-docs/content/extensions/data-view/examples/Functionality/Functionality.md +77 -0
  33. package/patternfly-docs/content/extensions/data-view/examples/{DataView/DataViewPredefinedLayoutExample.tsx → Functionality/PaginationExample.tsx} +2 -2
  34. package/patternfly-docs/content/extensions/data-view/examples/Functionality/SelectionExample.tsx +88 -0
  35. package/patternfly-docs/content/extensions/data-view/examples/{DataView/DataViewLayoutExample.tsx → Layout/AbstractLayoutExample.tsx} +4 -3
  36. package/patternfly-docs/content/extensions/data-view/examples/{DataView/DataView.md → Layout/Layout.md} +8 -6
  37. package/patternfly-docs/content/extensions/data-view/examples/Layout/PredefinedLayoutExample.tsx +120 -0
  38. package/patternfly-docs/pages/index.js +1 -1
  39. package/release.config.js +6 -2
  40. package/src/DataView/DataView.test.tsx +22 -0
  41. package/src/DataView/__snapshots__/DataView.test.tsx.snap +134 -0
  42. package/src/DataViewToolbar/DataViewToolbar.test.tsx +11 -0
  43. package/src/DataViewToolbar/DataViewToolbar.tsx +12 -5
  44. package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +542 -0
  45. package/src/Hooks/index.ts +1 -0
  46. package/src/Hooks/pagination.ts +3 -0
  47. package/src/Hooks/selection.test.tsx +52 -0
  48. package/src/Hooks/selection.ts +32 -0
  49. package/patternfly-docs/content/extensions/data-view/examples/DataViewToolbar/DataViewToolbarExample.tsx +0 -7
  50. package/patternfly-docs/content/extensions/data-view/examples/Hooks/Hooks.md +0 -20
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import { Table, Tbody, Th, Thead, Tr, Td } from '@patternfly/react-table';
3
+ import { useDataViewSelection } from '@patternfly/react-data-view/dist/dynamic/Hooks';
4
+ import { BulkSelect, BulkSelectValue } from '@patternfly/react-component-groups/dist/dynamic/BulkSelect';
5
+ import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
6
+ import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
7
+
8
+ interface Repository {
9
+ name: string;
10
+ branches: string | null;
11
+ prs: string | null;
12
+ workspaces: string;
13
+ lastCommit: string;
14
+ }
15
+
16
+ const repositories: Repository[] = [
17
+ { name: 'one', branches: 'two', prs: 'three', workspaces: 'four', lastCommit: 'five' },
18
+ { name: 'one - 2', branches: null, prs: null, workspaces: 'four - 2', lastCommit: 'five - 2' },
19
+ { name: 'one - 3', branches: 'two - 3', prs: 'three - 3', workspaces: 'four - 3', lastCommit: 'five - 3' },
20
+ { name: 'one - 4', branches: 'two - 4', prs: 'null', workspaces: 'four - 4', lastCommit: 'five - 4' },
21
+ { name: 'one - 5', branches: 'two - 5', prs: 'three - 5', workspaces: 'four - 5', lastCommit: 'five - 5' },
22
+ { name: 'one - 6', branches: 'two - 6', prs: 'three - 6', workspaces: 'four - 6', lastCommit: 'five - 6' }
23
+ ];
24
+
25
+ const cols = {
26
+ name: 'Repositories',
27
+ branches: 'Branches',
28
+ prs: 'Pull requests',
29
+ workspaces: 'Workspaces',
30
+ lastCommit: 'Last commit'
31
+ };
32
+
33
+ const ouiaId = 'LayoutExample';
34
+
35
+ export const BasicExample: React.FunctionComponent = () => {
36
+ const selection = useDataViewSelection({});
37
+ const { selected, onSelect, isSelected } = selection;
38
+
39
+ const handleBulkSelect = (value: BulkSelectValue) => {
40
+ value === BulkSelectValue.none && onSelect(false);
41
+ value === BulkSelectValue.all && onSelect(true, repositories);
42
+ };
43
+
44
+ return (
45
+ <DataView>
46
+ <DataViewToolbar
47
+ ouiaId='DataViewHeader'
48
+ bulkSelect={
49
+ <BulkSelect
50
+ canSelectAll
51
+ isDataPaginated={false}
52
+ totalCount={repositories.length}
53
+ selectedCount={selected.length}
54
+ onSelect={handleBulkSelect}
55
+ />
56
+ }
57
+ />
58
+ <Table aria-label="Repositories table" ouiaId={ouiaId}>
59
+ <Thead data-ouia-component-id={`${ouiaId}-thead`}>
60
+ <Tr ouiaId={`${ouiaId}-tr-head`}>
61
+ <Th key="row-select"/>
62
+ {Object.values(cols).map((column, index) => (
63
+ <Th key={index} data-ouia-component-id={`${ouiaId}-th-${index}`}>{column}</Th>
64
+ ))}
65
+ </Tr>
66
+ </Thead>
67
+ <Tbody>
68
+ {repositories.map((repo, rowIndex) => (
69
+ <Tr key={repo.name} ouiaId={`${ouiaId}-tr-${rowIndex}`}>
70
+ <Td
71
+ key={`select-${rowIndex}`}
72
+ select={{
73
+ rowIndex,
74
+ onSelect: (_event, isSelecting) => onSelect(isSelecting, repo),
75
+ isSelected: isSelected(repo),
76
+ isDisabled: false
77
+ }}
78
+ />
79
+ {Object.keys(cols).map((column, colIndex) => (
80
+ <Td key={colIndex} data-ouia-component-id={`${ouiaId}-td-${rowIndex}-${colIndex}`}>{repo[column]}</Td>
81
+ ))}
82
+ </Tr>
83
+ ))}
84
+ </Tbody>
85
+ </Table>
86
+ </DataView>
87
+ );
88
+ }
@@ -4,14 +4,15 @@ import DataView from '@patternfly/react-data-view/dist/dynamic/DataView';
4
4
  const layoutItemStyling = {
5
5
  width: '100%',
6
6
  height: '5rem',
7
- padding: 'var(--pf-t--global--spacer--md)',
8
- border: 'var(--pf-t--global--border--width--box--default) dashed var(--pf-t--global--border--color--default)'
7
+ padding: 'var(--pf-v5-global--spacer--md)',
8
+ borderStyle: 'dashed',
9
+ borderWidth: '2px',
9
10
  };
10
11
 
11
12
  export const BasicExample: React.FunctionComponent = () => (
12
13
  <DataView>
13
14
  <div style={layoutItemStyling}>Header</div>
14
- <div style={layoutItemStyling}>Data representation</div>
15
+ <div style={{ ...layoutItemStyling, borderTopWidth: 0, borderBottomWidth: 0 }}>Data representation</div>
15
16
  <div style={layoutItemStyling}>Footer</div>
16
17
  </DataView>
17
18
  )
@@ -5,16 +5,18 @@ section: extensions
5
5
  subsection: Data view
6
6
  # Sidenav secondary level section
7
7
  # should be the same for all markdown files
8
- id: Data view layout
8
+ id: Layout
9
9
  # Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
10
10
  source: react
11
11
  # If you use typescript, the name of the interface to display props for
12
12
  # These are found through the sourceProps function provided in patternfly-docs.source.js
13
+ sortValue: 2
13
14
  propComponents: ['DataView']
14
- sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md
15
+ sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/Layout/Layout.md
15
16
  ---
16
17
  import { useMemo } from 'react';
17
- import { useDataViewPagination } from '@patternfly/react-data-view/dist/dynamic/Hooks';
18
+ import { useDataViewPagination, useDataViewSelection } from '@patternfly/react-data-view/dist/dynamic/Hooks';
19
+ import { BulkSelect, BulkSelectValue } from '@patternfly/react-component-groups/dist/dynamic/BulkSelect';
18
20
  import DataView from '@patternfly/react-data-view/dist/dynamic/DataView';
19
21
  import DataViewToolbar from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
20
22
 
@@ -24,14 +26,14 @@ The **data view** component renders record data in a configured layout.
24
26
 
25
27
  Data view is expected to consist of header, data part and footer stacked below each other and passed as `children`.
26
28
 
27
- ```js file="./DataViewLayoutExample.tsx"
29
+ ```js file="./AbstractLayoutExample.tsx"
28
30
 
29
31
  ```
30
32
 
31
33
  ### Predefined layout components
32
34
 
33
- You can make use of the predefined layout components to display a default header and footer. See [data view toolbar](/data-view/data-view-toolbar) for more information
35
+ You can make use of the predefined layout components to display a default header and footer. See [data view toolbar](/extensions/data-view/components#dataviewtoolbar) for more information
34
36
 
35
- ```js file="./DataViewPredefinedLayoutExample.tsx"
37
+ ```js file="./PredefinedLayoutExample.tsx"
36
38
 
37
39
  ```
@@ -0,0 +1,120 @@
1
+ import React, { useMemo } from 'react';
2
+ import { Pagination } from '@patternfly/react-core';
3
+ import { Table, Tbody, Th, Thead, Tr, Td } from '@patternfly/react-table';
4
+ import { useDataViewPagination, useDataViewSelection } from '@patternfly/react-data-view/dist/dynamic/Hooks';
5
+ import { BulkSelect, BulkSelectValue } from '@patternfly/react-component-groups/dist/dynamic/BulkSelect';
6
+ import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
7
+ import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
8
+
9
+ const perPageOptions = [
10
+ { title: '5', value: 5 },
11
+ { title: '10', value: 10 }
12
+ ];
13
+
14
+ interface Repository {
15
+ name: string;
16
+ branches: string | null;
17
+ prs: string | null;
18
+ workspaces: string;
19
+ lastCommit: string;
20
+ }
21
+
22
+ const repositories: Repository[] = [
23
+ { name: 'one', branches: 'two', prs: 'three', workspaces: 'four', lastCommit: 'five' },
24
+ { name: 'one - 2', branches: null, prs: null, workspaces: 'four - 2', lastCommit: 'five - 2' },
25
+ { name: 'one - 3', branches: 'two - 3', prs: 'three - 3', workspaces: 'four - 3', lastCommit: 'five - 3' },
26
+ { name: 'one - 4', branches: 'two - 4', prs: 'null', workspaces: 'four - 4', lastCommit: 'five - 4' },
27
+ { name: 'one - 5', branches: 'two - 5', prs: 'three - 5', workspaces: 'four - 5', lastCommit: 'five - 5' },
28
+ { name: 'one - 6', branches: 'two - 6', prs: 'three - 6', workspaces: 'four - 6', lastCommit: 'five - 6' }
29
+ ];
30
+
31
+ const cols = {
32
+ name: 'Repositories',
33
+ branches: 'Branches',
34
+ prs: 'Pull requests',
35
+ workspaces: 'Workspaces',
36
+ lastCommit: 'Last commit'
37
+ };
38
+
39
+ const ouiaId = 'LayoutExample';
40
+
41
+ export const BasicExample: React.FunctionComponent = () => {
42
+ const pagination = useDataViewPagination({ perPage: 5 });
43
+ const { page, perPage } = pagination;
44
+ const selection = useDataViewSelection({});
45
+ const { selected, onSelect, isSelected } = selection;
46
+
47
+ const pageData = useMemo(() => repositories.slice((page - 1) * perPage, ((page - 1) * perPage) + perPage), [ page, perPage ]);
48
+
49
+ const handleBulkSelect = (value: BulkSelectValue) => {
50
+ value === BulkSelectValue.none && onSelect(false);
51
+ value === BulkSelectValue.all && onSelect(true, repositories);
52
+ value === BulkSelectValue.nonePage && onSelect(false, pageData);
53
+ value === BulkSelectValue.page && onSelect(true, pageData);
54
+ };
55
+
56
+ return (
57
+ <DataView>
58
+ <DataViewToolbar
59
+ ouiaId='LayoutExampleHeader'
60
+ bulkSelect={
61
+ <BulkSelect
62
+ canSelectAll
63
+ pageCount={pageData.length}
64
+ totalCount={repositories.length}
65
+ selectedCount={selected.length}
66
+ pageSelected={pageData.every(item => isSelected(item))}
67
+ pagePartiallySelected={pageData.some(item => isSelected(item)) && !pageData.every(item => isSelected(item))}
68
+ onSelect={handleBulkSelect}
69
+ />
70
+ }
71
+ pagination={
72
+ <Pagination
73
+ perPageOptions={perPageOptions}
74
+ itemCount={repositories.length}
75
+ {...pagination}
76
+ />
77
+ }
78
+ />
79
+ <Table aria-label="Repositories table" ouiaId={ouiaId}>
80
+ <Thead data-ouia-component-id={`${ouiaId}-thead`}>
81
+ <Tr ouiaId={`${ouiaId}-tr-head`}>
82
+ <Th key="row-select"/>
83
+ {Object.values(cols).map((column, index) => (
84
+ <Th key={index} data-ouia-component-id={`${ouiaId}-th-${index}`}>{column}</Th>
85
+ ))}
86
+ </Tr>
87
+ </Thead>
88
+ <Tbody>
89
+ {pageData.map((repo, rowIndex) => (
90
+ <Tr key={repo.name} ouiaId={`${ouiaId}-tr-${rowIndex}`}>
91
+ <Td
92
+ key={`select-${rowIndex}`}
93
+ select={{
94
+ rowIndex,
95
+ onSelect: (_event, isSelecting) => onSelect(isSelecting, repo),
96
+ isSelected: isSelected(repo),
97
+ isDisabled: false
98
+ }}
99
+ />
100
+ {Object.keys(cols).map((column, colIndex) => (
101
+ <Td key={colIndex} data-ouia-component-id={`${ouiaId}-td-${rowIndex}-${colIndex}`}>{repo[column]}</Td>
102
+ ))}
103
+ </Tr>
104
+ ))}
105
+ </Tbody>
106
+ </Table>
107
+ <DataViewToolbar
108
+ ouiaId='LayoutExampleFooter'
109
+ pagination={
110
+ <Pagination
111
+ isCompact
112
+ perPageOptions={perPageOptions}
113
+ itemCount={repositories.length}
114
+ {...pagination}
115
+ />
116
+ }
117
+ />
118
+ </DataView>
119
+ );
120
+ }
@@ -10,7 +10,7 @@ const centerStyle = {
10
10
 
11
11
  const IndexPage = () => {
12
12
  return (
13
- <PageSection style={centerStyle}>
13
+ <PageSection variant="light" style={centerStyle}>
14
14
  <div style={{ flex: 'none', textAlign: 'center' }}>
15
15
  <Title size="4xl" headingLevel="h1">
16
16
  My extension docs
package/release.config.js CHANGED
@@ -1,5 +1,9 @@
1
1
  module.exports = {
2
- branches: [ 'do-not-delete', { name: 'main', channel: 'prerelease', prerelease: 'prerelease' } ],
2
+ branches: [
3
+ 'do-not-delete',
4
+ { name: 'main', channel: 'prerelease', prerelease: 'prerelease' },
5
+ { name: 'v5', channel: 'prerelease-v5' },
6
+ ],
3
7
  analyzeCommits: {
4
8
  preset: 'angular'
5
9
  },
@@ -11,4 +15,4 @@ module.exports = {
11
15
  ],
12
16
  tagFormat: 'prerelease-v${version}',
13
17
  dryRun: false
14
- };
18
+ };
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import DataView from './DataView';
4
+
5
+ const layoutItemStyling = {
6
+ width: '100%',
7
+ height: '5rem',
8
+ padding: 'var(--pf-v5-global--spacer--md)',
9
+ borderStyle: 'dashed',
10
+ borderWidth: '2px',
11
+ };
12
+
13
+ describe('DataView component', () => {
14
+ test('should render correctly', () => {
15
+ expect(render(
16
+ <DataView>
17
+ <div style={layoutItemStyling}>Header</div>
18
+ <div style={{ ...layoutItemStyling, borderTopWidth: 0, borderBottomWidth: 0 }}>Data representation</div>
19
+ <div style={layoutItemStyling}>Footer</div>
20
+ </DataView>)).toMatchSnapshot();
21
+ });
22
+ });
@@ -0,0 +1,134 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`DataView component should render correctly 1`] = `
4
+ {
5
+ "asFragment": [Function],
6
+ "baseElement": <body>
7
+ <div>
8
+ <div
9
+ class="pf-v5-l-stack"
10
+ data-ouia-component-id="DataView-stack}"
11
+ >
12
+ <div
13
+ class="pf-v5-l-stack__item"
14
+ data-ouia-component-id="DataView-stack-item-0"
15
+ >
16
+ <div
17
+ style="width: 100%; height: 5rem; border-style: dashed; border-width: 2px;"
18
+ >
19
+ Header
20
+ </div>
21
+ </div>
22
+ <div
23
+ class="pf-v5-l-stack__item"
24
+ data-ouia-component-id="DataView-stack-item-1"
25
+ >
26
+ <div
27
+ style="width: 100%; height: 5rem; border-style: dashed; border-width: 2px; border-top-width: 0; border-bottom-width: 0;"
28
+ >
29
+ Data representation
30
+ </div>
31
+ </div>
32
+ <div
33
+ class="pf-v5-l-stack__item"
34
+ data-ouia-component-id="DataView-stack-item-2"
35
+ >
36
+ <div
37
+ style="width: 100%; height: 5rem; border-style: dashed; border-width: 2px;"
38
+ >
39
+ Footer
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ </body>,
45
+ "container": <div>
46
+ <div
47
+ class="pf-v5-l-stack"
48
+ data-ouia-component-id="DataView-stack}"
49
+ >
50
+ <div
51
+ class="pf-v5-l-stack__item"
52
+ data-ouia-component-id="DataView-stack-item-0"
53
+ >
54
+ <div
55
+ style="width: 100%; height: 5rem; border-style: dashed; border-width: 2px;"
56
+ >
57
+ Header
58
+ </div>
59
+ </div>
60
+ <div
61
+ class="pf-v5-l-stack__item"
62
+ data-ouia-component-id="DataView-stack-item-1"
63
+ >
64
+ <div
65
+ style="width: 100%; height: 5rem; border-style: dashed; border-width: 2px; border-top-width: 0; border-bottom-width: 0;"
66
+ >
67
+ Data representation
68
+ </div>
69
+ </div>
70
+ <div
71
+ class="pf-v5-l-stack__item"
72
+ data-ouia-component-id="DataView-stack-item-2"
73
+ >
74
+ <div
75
+ style="width: 100%; height: 5rem; border-style: dashed; border-width: 2px;"
76
+ >
77
+ Footer
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>,
82
+ "debug": [Function],
83
+ "findAllByAltText": [Function],
84
+ "findAllByDisplayValue": [Function],
85
+ "findAllByLabelText": [Function],
86
+ "findAllByPlaceholderText": [Function],
87
+ "findAllByRole": [Function],
88
+ "findAllByTestId": [Function],
89
+ "findAllByText": [Function],
90
+ "findAllByTitle": [Function],
91
+ "findByAltText": [Function],
92
+ "findByDisplayValue": [Function],
93
+ "findByLabelText": [Function],
94
+ "findByPlaceholderText": [Function],
95
+ "findByRole": [Function],
96
+ "findByTestId": [Function],
97
+ "findByText": [Function],
98
+ "findByTitle": [Function],
99
+ "getAllByAltText": [Function],
100
+ "getAllByDisplayValue": [Function],
101
+ "getAllByLabelText": [Function],
102
+ "getAllByPlaceholderText": [Function],
103
+ "getAllByRole": [Function],
104
+ "getAllByTestId": [Function],
105
+ "getAllByText": [Function],
106
+ "getAllByTitle": [Function],
107
+ "getByAltText": [Function],
108
+ "getByDisplayValue": [Function],
109
+ "getByLabelText": [Function],
110
+ "getByPlaceholderText": [Function],
111
+ "getByRole": [Function],
112
+ "getByTestId": [Function],
113
+ "getByText": [Function],
114
+ "getByTitle": [Function],
115
+ "queryAllByAltText": [Function],
116
+ "queryAllByDisplayValue": [Function],
117
+ "queryAllByLabelText": [Function],
118
+ "queryAllByPlaceholderText": [Function],
119
+ "queryAllByRole": [Function],
120
+ "queryAllByTestId": [Function],
121
+ "queryAllByText": [Function],
122
+ "queryAllByTitle": [Function],
123
+ "queryByAltText": [Function],
124
+ "queryByDisplayValue": [Function],
125
+ "queryByLabelText": [Function],
126
+ "queryByPlaceholderText": [Function],
127
+ "queryByRole": [Function],
128
+ "queryByTestId": [Function],
129
+ "queryByText": [Function],
130
+ "queryByTitle": [Function],
131
+ "rerender": [Function],
132
+ "unmount": [Function],
133
+ }
134
+ `;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import DataViewToolbar from './DataViewToolbar';
4
+ import { Pagination } from '@patternfly/react-core';
5
+
6
+ describe('DataViewToolbar component', () => {
7
+ test('should render correctly', () => {
8
+ expect(render(
9
+ <DataViewToolbar pagination={<Pagination page={1} perPage={10} />} />)).toMatchSnapshot();
10
+ });
11
+ });
@@ -1,21 +1,27 @@
1
- import React from 'react';
1
+ import React, { PropsWithChildren } from 'react';
2
2
  import { Toolbar, ToolbarContent, ToolbarItem, ToolbarItemVariant } from '@patternfly/react-core';
3
3
 
4
- export interface DataViewToolbarProps {
4
+ export interface DataViewToolbarProps extends PropsWithChildren {
5
5
  /** Toolbar className */
6
6
  className?: string;
7
7
  /** Custom OUIA ID */
8
8
  ouiaId?: string;
9
+ /** React component to display bulk select */
10
+ bulkSelect?: React.ReactNode;
9
11
  /** React component to display pagination */
10
12
  pagination?: React.ReactNode;
11
13
  }
12
14
 
13
- export const DataViewToolbar: React.FC<React.PropsWithChildren<DataViewToolbarProps>> = ({ className, ouiaId = 'DataViewToolbar', pagination, children, ...props }: React.PropsWithChildren<DataViewToolbarProps>) => (
15
+ export const DataViewToolbar: React.FC<DataViewToolbarProps> = ({ className, ouiaId = 'DataViewToolbar', bulkSelect, pagination, children, ...props }: DataViewToolbarProps) => (
14
16
  <Toolbar ouiaId={ouiaId} className={className} {...props}>
15
17
  <ToolbarContent>
18
+ {bulkSelect && (
19
+ <ToolbarItem data-ouia-component-id={`${ouiaId}-bulk-select`}>
20
+ {bulkSelect}
21
+ </ToolbarItem>
22
+ )}
16
23
  {pagination && (
17
- <ToolbarItem variant={ToolbarItemVariant.pagination}>
18
- { /* TO DO: Make the pagination work later */ }
24
+ <ToolbarItem variant={ToolbarItemVariant.pagination} data-ouia-component-id={`${ouiaId}-pagination`}>
19
25
  {pagination}
20
26
  </ToolbarItem>
21
27
  )}
@@ -25,3 +31,4 @@ export const DataViewToolbar: React.FC<React.PropsWithChildren<DataViewToolbarPr
25
31
  );
26
32
 
27
33
  export default DataViewToolbar;
34
+