@patternfly/react-data-view 5.1.2 → 5.1.3
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/dist/cjs/DataViewToolbar/DataViewToolbar.d.ts +2 -0
- package/dist/cjs/DataViewToolbar/DataViewToolbar.js +2 -1
- package/dist/esm/DataViewToolbar/DataViewToolbar.d.ts +2 -0
- package/dist/esm/DataViewToolbar/DataViewToolbar.js +2 -1
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableExample.tsx +22 -2
- package/src/DataViewToolbar/DataViewToolbar.tsx +4 -1
|
@@ -8,6 +8,8 @@ export interface DataViewToolbarProps extends PropsWithChildren {
|
|
|
8
8
|
bulkSelect?: React.ReactNode;
|
|
9
9
|
/** React component to display pagination */
|
|
10
10
|
pagination?: React.ReactNode;
|
|
11
|
+
/** React component to display actions */
|
|
12
|
+
actions?: React.ReactNode;
|
|
11
13
|
}
|
|
12
14
|
export declare const DataViewToolbar: React.FC<DataViewToolbarProps>;
|
|
13
15
|
export default DataViewToolbar;
|
|
@@ -18,10 +18,11 @@ exports.DataViewToolbar = void 0;
|
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
19
|
const react_core_1 = require("@patternfly/react-core");
|
|
20
20
|
const DataViewToolbar = (_a) => {
|
|
21
|
-
var { className, ouiaId = 'DataViewToolbar', bulkSelect, pagination, children } = _a, props = __rest(_a, ["className", "ouiaId", "bulkSelect", "pagination", "children"]);
|
|
21
|
+
var { className, ouiaId = 'DataViewToolbar', bulkSelect, actions = null, pagination, children } = _a, props = __rest(_a, ["className", "ouiaId", "bulkSelect", "actions", "pagination", "children"]);
|
|
22
22
|
return (react_1.default.createElement(react_core_1.Toolbar, Object.assign({ ouiaId: ouiaId, className: className }, props),
|
|
23
23
|
react_1.default.createElement(react_core_1.ToolbarContent, null,
|
|
24
24
|
bulkSelect && (react_1.default.createElement(react_core_1.ToolbarItem, { "data-ouia-component-id": `${ouiaId}-bulk-select` }, bulkSelect)),
|
|
25
|
+
actions,
|
|
25
26
|
pagination && (react_1.default.createElement(react_core_1.ToolbarItem, { variant: react_core_1.ToolbarItemVariant.pagination, "data-ouia-component-id": `${ouiaId}-pagination` }, pagination)),
|
|
26
27
|
children)));
|
|
27
28
|
};
|
|
@@ -8,6 +8,8 @@ export interface DataViewToolbarProps extends PropsWithChildren {
|
|
|
8
8
|
bulkSelect?: React.ReactNode;
|
|
9
9
|
/** React component to display pagination */
|
|
10
10
|
pagination?: React.ReactNode;
|
|
11
|
+
/** React component to display actions */
|
|
12
|
+
actions?: React.ReactNode;
|
|
11
13
|
}
|
|
12
14
|
export declare const DataViewToolbar: React.FC<DataViewToolbarProps>;
|
|
13
15
|
export default DataViewToolbar;
|
|
@@ -12,10 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import { Toolbar, ToolbarContent, ToolbarItem, ToolbarItemVariant } from '@patternfly/react-core';
|
|
14
14
|
export const DataViewToolbar = (_a) => {
|
|
15
|
-
var { className, ouiaId = 'DataViewToolbar', bulkSelect, pagination, children } = _a, props = __rest(_a, ["className", "ouiaId", "bulkSelect", "pagination", "children"]);
|
|
15
|
+
var { className, ouiaId = 'DataViewToolbar', bulkSelect, actions = null, pagination, children } = _a, props = __rest(_a, ["className", "ouiaId", "bulkSelect", "actions", "pagination", "children"]);
|
|
16
16
|
return (React.createElement(Toolbar, Object.assign({ ouiaId: ouiaId, className: className }, props),
|
|
17
17
|
React.createElement(ToolbarContent, null,
|
|
18
18
|
bulkSelect && (React.createElement(ToolbarItem, { "data-ouia-component-id": `${ouiaId}-bulk-select` }, bulkSelect)),
|
|
19
|
+
actions,
|
|
19
20
|
pagination && (React.createElement(ToolbarItem, { variant: ToolbarItemVariant.pagination, "data-ouia-component-id": `${ouiaId}-pagination` }, pagination)),
|
|
20
21
|
children)));
|
|
21
22
|
};
|
package/package.json
CHANGED
package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableExample.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
3
3
|
import { ExclamationCircleIcon } from '@patternfly/react-icons';
|
|
4
4
|
import { Button } from '@patternfly/react-core';
|
|
5
|
+
import { ActionsColumn } from '@patternfly/react-table';
|
|
5
6
|
|
|
6
7
|
interface Repository {
|
|
7
8
|
id: number;
|
|
@@ -21,6 +22,24 @@ const repositories: Repository[] = [
|
|
|
21
22
|
{ id: 6, name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six' }
|
|
22
23
|
];
|
|
23
24
|
|
|
25
|
+
const rowActions = [
|
|
26
|
+
{
|
|
27
|
+
title: 'Some action',
|
|
28
|
+
onClick: () => console.log('clicked on Some action') // eslint-disable-line no-console
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: <div>Another action</div>,
|
|
32
|
+
onClick: () => console.log('clicked on Another action') // eslint-disable-line no-console
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
isSeparator: true
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: 'Third action',
|
|
39
|
+
onClick: () => console.log('clicked on Third action') // eslint-disable-line no-console
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
|
|
24
43
|
// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
|
|
25
44
|
const rows: DataViewTr[] = repositories.map(({ id, name, branches, prs, workspaces, lastCommit }) => [
|
|
26
45
|
{ id, cell: workspaces, props: { favorites: { isFavorited: true } } },
|
|
@@ -28,7 +47,8 @@ const rows: DataViewTr[] = repositories.map(({ id, name, branches, prs, workspac
|
|
|
28
47
|
branches,
|
|
29
48
|
prs,
|
|
30
49
|
workspaces,
|
|
31
|
-
lastCommit
|
|
50
|
+
lastCommit,
|
|
51
|
+
{ cell: <ActionsColumn items={rowActions}/>, props: { isActionCell: true } },
|
|
32
52
|
]);
|
|
33
53
|
|
|
34
54
|
const columns: DataViewTh[] = [
|
|
@@ -37,7 +57,7 @@ const columns: DataViewTh[] = [
|
|
|
37
57
|
{ cell: <>Branches<ExclamationCircleIcon className='pf-v5-u-ml-sm' color='var(--pf-v5-global--danger-color--100)'/></> },
|
|
38
58
|
'Pull requests',
|
|
39
59
|
{ cell: 'Workspaces', props: { info: { tooltip: 'More information' } } },
|
|
40
|
-
{ cell: 'Last commit', props: { sort: { sortBy: {}, columnIndex: 4 } } }
|
|
60
|
+
{ cell: 'Last commit', props: { sort: { sortBy: {}, columnIndex: 4 } } },
|
|
41
61
|
];
|
|
42
62
|
|
|
43
63
|
const ouiaId = 'TableExample';
|
|
@@ -10,9 +10,11 @@ export interface DataViewToolbarProps extends PropsWithChildren {
|
|
|
10
10
|
bulkSelect?: React.ReactNode;
|
|
11
11
|
/** React component to display pagination */
|
|
12
12
|
pagination?: React.ReactNode;
|
|
13
|
+
/** React component to display actions */
|
|
14
|
+
actions?: React.ReactNode;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
export const DataViewToolbar: React.FC<DataViewToolbarProps> = ({ className, ouiaId = 'DataViewToolbar', bulkSelect, pagination, children, ...props }: DataViewToolbarProps) => (
|
|
17
|
+
export const DataViewToolbar: React.FC<DataViewToolbarProps> = ({ className, ouiaId = 'DataViewToolbar', bulkSelect, actions = null, pagination, children, ...props }: DataViewToolbarProps) => (
|
|
16
18
|
<Toolbar ouiaId={ouiaId} className={className} {...props}>
|
|
17
19
|
<ToolbarContent>
|
|
18
20
|
{bulkSelect && (
|
|
@@ -20,6 +22,7 @@ export const DataViewToolbar: React.FC<DataViewToolbarProps> = ({ className, oui
|
|
|
20
22
|
{bulkSelect}
|
|
21
23
|
</ToolbarItem>
|
|
22
24
|
)}
|
|
25
|
+
{actions}
|
|
23
26
|
{pagination && (
|
|
24
27
|
<ToolbarItem variant={ToolbarItemVariant.pagination} data-ouia-component-id={`${ouiaId}-pagination`}>
|
|
25
28
|
{pagination}
|