@patternfly/react-table 6.0.0-prerelease.9 → 6.1.0-prerelease.1
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 +84 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/Table/package.json +1 -1
- package/dist/dynamic/components/Table/utils/decorators/package.json +1 -1
- package/dist/dynamic/components/Table/utils/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/base/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.d.ts +2 -0
- package/dist/esm/components/Table/EditableSelectInputCell.d.ts.map +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.js +4 -6
- package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.d.ts.map +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js +2 -2
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js.map +1 -1
- package/dist/esm/components/Table/SortColumn.d.ts +2 -0
- package/dist/esm/components/Table/SortColumn.d.ts.map +1 -1
- package/dist/esm/components/Table/SortColumn.js +11 -1
- package/dist/esm/components/Table/SortColumn.js.map +1 -1
- package/dist/esm/components/Table/TableTypes.d.ts +1 -0
- package/dist/esm/components/Table/TableTypes.d.ts.map +1 -1
- package/dist/esm/components/Table/Th.d.ts.map +1 -1
- package/dist/esm/components/Table/Th.js +9 -4
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/esm/components/Table/base/types.d.ts +9 -3
- package/dist/esm/components/Table/base/types.d.ts.map +1 -1
- package/dist/esm/components/Table/base/types.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.d.ts.map +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.js +20 -20
- package/dist/esm/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/esm/components/Table/utils/headerUtils.d.ts +7 -0
- package/dist/esm/components/Table/utils/headerUtils.d.ts.map +1 -1
- package/dist/js/components/Table/EditableSelectInputCell.d.ts +2 -0
- package/dist/js/components/Table/EditableSelectInputCell.d.ts.map +1 -1
- package/dist/js/components/Table/EditableSelectInputCell.js +4 -6
- package/dist/js/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/js/components/Table/HeaderCellInfoWrapper.d.ts.map +1 -1
- package/dist/js/components/Table/HeaderCellInfoWrapper.js +2 -2
- package/dist/js/components/Table/HeaderCellInfoWrapper.js.map +1 -1
- package/dist/js/components/Table/SortColumn.d.ts +2 -0
- package/dist/js/components/Table/SortColumn.d.ts.map +1 -1
- package/dist/js/components/Table/SortColumn.js +11 -1
- package/dist/js/components/Table/SortColumn.js.map +1 -1
- package/dist/js/components/Table/TableTypes.d.ts +1 -0
- package/dist/js/components/Table/TableTypes.d.ts.map +1 -1
- package/dist/js/components/Table/Th.d.ts.map +1 -1
- package/dist/js/components/Table/Th.js +9 -4
- package/dist/js/components/Table/Th.js.map +1 -1
- package/dist/js/components/Table/base/types.d.ts +9 -3
- package/dist/js/components/Table/base/types.d.ts.map +1 -1
- package/dist/js/components/Table/base/types.js.map +1 -1
- package/dist/js/components/Table/utils/decorators/sortable.d.ts.map +1 -1
- package/dist/js/components/Table/utils/decorators/sortable.js +20 -20
- package/dist/js/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/js/components/Table/utils/headerUtils.d.ts +7 -0
- package/dist/js/components/Table/utils/headerUtils.d.ts.map +1 -1
- package/dist/umd/assets/{output-CFrsMmEW.css → output-D6lBZT5r.css} +18403 -18429
- package/dist/umd/react-table.min.js +3 -3
- package/package.json +6 -6
- package/src/components/Table/EditableSelectInputCell.tsx +7 -8
- package/src/components/Table/HeaderCellInfoWrapper.tsx +2 -0
- package/src/components/Table/SortColumn.tsx +28 -0
- package/src/components/Table/TableTypes.tsx +1 -0
- package/src/components/Table/Th.tsx +10 -3
- package/src/components/Table/base/types.tsx +10 -3
- package/src/components/Table/examples/Table.md +3 -2
- package/src/components/Table/examples/TableFavoritable.tsx +30 -5
- package/src/components/Table/examples/TableMisc.tsx +2 -2
- package/src/components/Table/utils/decorators/sortable.tsx +7 -5
- package/src/demos/examples/TableBulkSelect.tsx +13 -15
- package/src/deprecated/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +0 -16
- package/src/deprecated/components/Table/examples/LegacyTableMisc.tsx +2 -2
- package/src/deprecated/components/Table/examples/Table.md +37 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0-prerelease.1",
|
|
4
4
|
"description": "This library provides a set of React table components for use with the PatternFly 4",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"subpaths": "node ../../scripts/exportSubpaths.mjs --config subpaths.config.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@patternfly/react-core": "^6.
|
|
44
|
-
"@patternfly/react-icons": "^6.
|
|
45
|
-
"@patternfly/react-styles": "^6.
|
|
46
|
-
"@patternfly/react-tokens": "^6.
|
|
43
|
+
"@patternfly/react-core": "^6.1.0-prerelease.1",
|
|
44
|
+
"@patternfly/react-icons": "^6.1.0-prerelease.0",
|
|
45
|
+
"@patternfly/react-styles": "^6.1.0-prerelease.0",
|
|
46
|
+
"@patternfly/react-tokens": "^6.1.0-prerelease.0",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
48
|
"tslib": "^2.7.0"
|
|
49
49
|
},
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"react": "^17 || ^18",
|
|
52
52
|
"react-dom": "^17 || ^18"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "07cc495ab53d6d3a0c10ccdd36d20b92ce800cb7"
|
|
55
55
|
}
|
|
@@ -25,6 +25,8 @@ export interface IEditableSelectInputCell extends Omit<React.HTMLProps<HTMLEleme
|
|
|
25
25
|
options?: React.ReactElement[];
|
|
26
26
|
/** Flag indicating the select input is disabled */
|
|
27
27
|
isDisabled?: boolean;
|
|
28
|
+
/** Flag indicating the toggle gets placeholder styles **/
|
|
29
|
+
isPlaceholder?: boolean;
|
|
28
30
|
/** Current selected options to display as the read only value of the table cell */
|
|
29
31
|
selections?: any | any[];
|
|
30
32
|
/** Flag indicating the select menu is open */
|
|
@@ -42,17 +44,14 @@ export const EditableSelectInputCell: React.FunctionComponent<IEditableSelectInp
|
|
|
42
44
|
onSelect = () => {},
|
|
43
45
|
clearSelection,
|
|
44
46
|
isOpen = false,
|
|
47
|
+
isPlaceholder = false,
|
|
45
48
|
onToggle = () => {},
|
|
46
49
|
selections = [''],
|
|
47
50
|
options = [] as React.ReactElement[],
|
|
48
51
|
props
|
|
49
52
|
}: IEditableSelectInputCell) => {
|
|
50
|
-
const onSelectHandler = (
|
|
51
|
-
event
|
|
52
|
-
newValue: any | any[]
|
|
53
|
-
// isPlaceholder: boolean
|
|
54
|
-
) => {
|
|
55
|
-
onSelect(event, newValue, rowIndex, cellIndex);
|
|
53
|
+
const onSelectHandler = (event: React.MouseEvent | React.ChangeEvent, newValue: any | any[]) => {
|
|
54
|
+
onSelect(event, newValue, rowIndex, cellIndex, isPlaceholder);
|
|
56
55
|
};
|
|
57
56
|
|
|
58
57
|
const onClear = (event: React.MouseEvent) => {
|
|
@@ -61,16 +60,16 @@ export const EditableSelectInputCell: React.FunctionComponent<IEditableSelectInp
|
|
|
61
60
|
|
|
62
61
|
const select = (
|
|
63
62
|
<Select
|
|
64
|
-
{...props.editableSelectProps}
|
|
65
63
|
onSelect={onSelectHandler}
|
|
66
64
|
{...(clearSelection && { onClear })}
|
|
67
65
|
isOpen={isOpen}
|
|
68
66
|
selected={selections}
|
|
69
67
|
toggle={(toggleRef: any) => (
|
|
70
|
-
<MenuToggle ref={toggleRef} onClick={onToggle} isExpanded={isOpen}>
|
|
68
|
+
<MenuToggle ref={toggleRef} onClick={onToggle} isExpanded={isOpen} isPlaceholder={isPlaceholder}>
|
|
71
69
|
{isOpen ? 'Expanded' : 'Collapsed'}
|
|
72
70
|
</MenuToggle>
|
|
73
71
|
)}
|
|
72
|
+
{...props.editableSelectProps}
|
|
74
73
|
>
|
|
75
74
|
<SelectList>{options}</SelectList>
|
|
76
75
|
</Select>
|
|
@@ -54,6 +54,7 @@ export const HeaderCellInfoWrapper: React.FunctionComponent<ColumnHelpWrapperPro
|
|
|
54
54
|
<Tooltip content={info} {...tooltipProps}>
|
|
55
55
|
<Button
|
|
56
56
|
variant="plain"
|
|
57
|
+
hasNoPadding
|
|
57
58
|
aria-label={ariaLabel || (typeof info === 'string' && info) || 'More info'}
|
|
58
59
|
icon={<HelpIcon />}
|
|
59
60
|
/>
|
|
@@ -62,6 +63,7 @@ export const HeaderCellInfoWrapper: React.FunctionComponent<ColumnHelpWrapperPro
|
|
|
62
63
|
<Popover bodyContent={info} {...popoverProps}>
|
|
63
64
|
<Button
|
|
64
65
|
variant="plain"
|
|
66
|
+
hasNoPadding
|
|
65
67
|
aria-label={ariaLabel || (typeof info === 'string' && info) || 'More info'}
|
|
66
68
|
icon={<HelpIcon />}
|
|
67
69
|
/>
|
|
@@ -2,10 +2,13 @@ import * as React from 'react';
|
|
|
2
2
|
import LongArrowAltUpIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-up-icon';
|
|
3
3
|
import LongArrowAltDownIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon';
|
|
4
4
|
import ArrowsAltVIcon from '@patternfly/react-icons/dist/esm/icons/arrows-alt-v-icon';
|
|
5
|
+
import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
|
|
5
6
|
import { css } from '@patternfly/react-styles';
|
|
6
7
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
7
8
|
import { TableText } from './TableText';
|
|
8
9
|
import { TooltipProps } from '@patternfly/react-core/dist/esm/components/Tooltip';
|
|
10
|
+
import { ActionList, ActionListItem, Button } from '@patternfly/react-core';
|
|
11
|
+
import { FavoriteButtonProps } from './base/types';
|
|
9
12
|
|
|
10
13
|
export enum SortByDirection {
|
|
11
14
|
asc = 'asc',
|
|
@@ -21,6 +24,7 @@ export interface SortColumnProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
21
24
|
tooltip?: React.ReactNode;
|
|
22
25
|
tooltipProps?: Omit<TooltipProps, 'content'>;
|
|
23
26
|
tooltipHasDefaultBehavior?: boolean;
|
|
27
|
+
favoriteButtonProps?: FavoriteButtonProps;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
|
|
@@ -33,6 +37,7 @@ export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
|
|
|
33
37
|
tooltip,
|
|
34
38
|
tooltipProps,
|
|
35
39
|
tooltipHasDefaultBehavior,
|
|
40
|
+
favoriteButtonProps,
|
|
36
41
|
...props
|
|
37
42
|
}: SortColumnProps) => {
|
|
38
43
|
let SortedByIcon;
|
|
@@ -42,6 +47,29 @@ export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
|
|
|
42
47
|
} else {
|
|
43
48
|
SortedByIcon = ArrowsAltVIcon;
|
|
44
49
|
}
|
|
50
|
+
|
|
51
|
+
if (favoriteButtonProps) {
|
|
52
|
+
return (
|
|
53
|
+
<ActionList isIconList>
|
|
54
|
+
<ActionListItem>
|
|
55
|
+
<Button variant="plain" icon={<StarIcon />} {...favoriteButtonProps} />
|
|
56
|
+
</ActionListItem>
|
|
57
|
+
<ActionListItem>
|
|
58
|
+
<Button
|
|
59
|
+
variant="plain"
|
|
60
|
+
icon={
|
|
61
|
+
<span className={css(styles.tableSortIndicator)}>
|
|
62
|
+
<SortedByIcon />
|
|
63
|
+
</span>
|
|
64
|
+
}
|
|
65
|
+
onClick={(event) => onSort && onSort(event)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
</ActionListItem>
|
|
69
|
+
</ActionList>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
45
73
|
return (
|
|
46
74
|
<button
|
|
47
75
|
{...props}
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { css } from '@patternfly/react-styles';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
4
4
|
import scrollStyles from '@patternfly/react-styles/css/components/Table/table-scrollable';
|
|
5
|
+
import accessibilityStyles from '@patternfly/react-styles/css/utilities/Accessibility/accessibility';
|
|
5
6
|
import { info, sortable, sortableFavorites, selectable, collapsible, cellWidth, Visibility, classNames } from './utils';
|
|
6
7
|
import { ThInfoType, ThSelectType, ThExpandType, ThSortType, formatterValueType } from './base/types';
|
|
7
8
|
import { mergeProps } from './base/merge-props';
|
|
@@ -113,15 +114,18 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
113
114
|
}
|
|
114
115
|
onMouseEnterProp(event);
|
|
115
116
|
};
|
|
117
|
+
|
|
116
118
|
let sortParams = null;
|
|
117
119
|
if (sort) {
|
|
118
120
|
if (sort.isFavorites) {
|
|
119
121
|
sortParams = sortableFavorites({
|
|
120
|
-
onSort: sort
|
|
122
|
+
onSort: sort.onSort,
|
|
121
123
|
columnIndex: sort.columnIndex,
|
|
122
124
|
sortBy: sort.sortBy,
|
|
123
125
|
tooltip: tooltip as string,
|
|
124
|
-
tooltipProps
|
|
126
|
+
tooltipProps,
|
|
127
|
+
ariaLabel: sort['aria-label'],
|
|
128
|
+
favoriteButtonProps: sort.favoriteButtonProps
|
|
125
129
|
})();
|
|
126
130
|
} else {
|
|
127
131
|
sortParams = sortable(children as IFormatterValueType, {
|
|
@@ -137,6 +141,7 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
137
141
|
});
|
|
138
142
|
}
|
|
139
143
|
}
|
|
144
|
+
|
|
140
145
|
const selectParams = select
|
|
141
146
|
? selectable(children as IFormatterValueType, {
|
|
142
147
|
rowData: {
|
|
@@ -217,6 +222,7 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
217
222
|
hasRightBorder && scrollStyles.modifiers.borderRight,
|
|
218
223
|
hasLeftBorder && scrollStyles.modifiers.borderLeft,
|
|
219
224
|
modifier && styles.modifiers[modifier as 'breakWord' | 'fitContent' | 'nowrap' | 'truncate' | 'wrap'],
|
|
225
|
+
sort?.favoriteButtonProps?.favorited && styles.modifiers.favorited,
|
|
220
226
|
mergedClassName
|
|
221
227
|
)}
|
|
222
228
|
{...mergedProps}
|
|
@@ -230,7 +236,8 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
230
236
|
} as React.CSSProperties
|
|
231
237
|
})}
|
|
232
238
|
>
|
|
233
|
-
{transformedChildren ||
|
|
239
|
+
{transformedChildren ||
|
|
240
|
+
(screenReaderText && <span className={accessibilityStyles.screenReader}>{screenReaderText}</span>)}
|
|
234
241
|
</MergedComponent>
|
|
235
242
|
);
|
|
236
243
|
|
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as React from 'react';
|
|
9
|
-
import { TooltipProps } from '@patternfly/react-core
|
|
10
|
-
import { PopoverProps } from '@patternfly/react-core/dist/esm/components/Popover';
|
|
11
|
-
import { SelectProps } from '@patternfly/react-core/dist/esm/components/Select';
|
|
9
|
+
import { ButtonProps, PopoverProps, SelectProps, TooltipProps } from '@patternfly/react-core';
|
|
12
10
|
import { Table } from '../Table';
|
|
13
11
|
import { Thead } from '../Thead';
|
|
14
12
|
import { Tbody } from '../Tbody';
|
|
@@ -156,6 +154,11 @@ export interface ThInfoType {
|
|
|
156
154
|
className?: string;
|
|
157
155
|
}
|
|
158
156
|
|
|
157
|
+
export interface FavoriteButtonProps extends ButtonProps {
|
|
158
|
+
/** Flag if the button is favorited. */
|
|
159
|
+
favorited?: boolean;
|
|
160
|
+
}
|
|
161
|
+
|
|
159
162
|
export interface ThSortType {
|
|
160
163
|
/** Wraps the content in a button and adds a sort icon - Click callback on the sortable cell */
|
|
161
164
|
onSort?: OnSort;
|
|
@@ -163,8 +166,12 @@ export interface ThSortType {
|
|
|
163
166
|
sortBy: ISortBy;
|
|
164
167
|
/** The column index */
|
|
165
168
|
columnIndex: number;
|
|
169
|
+
/** Adds accessible text to the sort button. */
|
|
170
|
+
'aria-label'?: string;
|
|
166
171
|
/** True to make this a favoritable sorting cell */
|
|
167
172
|
isFavorites?: boolean;
|
|
173
|
+
/** Props for the favorite button (only for favoritable cell). */
|
|
174
|
+
favoriteButtonProps?: FavoriteButtonProps;
|
|
168
175
|
}
|
|
169
176
|
|
|
170
177
|
export interface ThSelectType {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: Table
|
|
3
|
-
cssPrefix: pf-c-table
|
|
3
|
+
cssPrefix: pf-v6-c-table
|
|
4
4
|
section: components
|
|
5
5
|
propComponents:
|
|
6
6
|
[
|
|
@@ -60,7 +60,7 @@ import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
|
60
60
|
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
|
|
61
61
|
import textStyles from '@patternfly/react-styles/css/utilities/Text/text';
|
|
62
62
|
import inlineEditStyles from '@patternfly/react-styles/css/components/InlineEdit/inline-edit';
|
|
63
|
-
import
|
|
63
|
+
import t_global_background_color_secondary_default from '@patternfly/react-tokens/dist/esm/t_global_background_color_secondary_default';
|
|
64
64
|
|
|
65
65
|
## Table examples
|
|
66
66
|
|
|
@@ -172,6 +172,7 @@ This selectable rows feature is intended for use when a table is used to present
|
|
|
172
172
|
This example shows a table with editable rows. Cells in a row can be edited after clicking on the edit icon.
|
|
173
173
|
|
|
174
174
|
```ts file="TableEditable.tsx"
|
|
175
|
+
|
|
175
176
|
```
|
|
176
177
|
|
|
177
178
|
### Actions
|
|
@@ -28,10 +28,10 @@ export const TableFavoritable: React.FunctionComponent = () => {
|
|
|
28
28
|
// Index of the currently sorted column
|
|
29
29
|
// Note: if you intend to make columns reorderable, you may instead want to use a non-numeric key
|
|
30
30
|
// as the identifier of the sorted column. See the "Compound expandable" example.
|
|
31
|
-
const [activeSortIndex, setActiveSortIndex] = React.useState<number
|
|
31
|
+
const [activeSortIndex, setActiveSortIndex] = React.useState<number>();
|
|
32
32
|
|
|
33
33
|
// Sort direction of the currently sorted column
|
|
34
|
-
const [activeSortDirection, setActiveSortDirection] = React.useState<'asc' | 'desc'
|
|
34
|
+
const [activeSortDirection, setActiveSortDirection] = React.useState<'asc' | 'desc'>();
|
|
35
35
|
|
|
36
36
|
// Favorite state is similar to selection state, see Selectable with checkbox.
|
|
37
37
|
const [favoriteRepoNames, setFavoriteRepoNames] = React.useState<string[]>([]);
|
|
@@ -42,6 +42,9 @@ export const TableFavoritable: React.FunctionComponent = () => {
|
|
|
42
42
|
});
|
|
43
43
|
const isRepoFavorited = (repo: Repository) => favoriteRepoNames.includes(repo.name);
|
|
44
44
|
|
|
45
|
+
// State of the header cell to favorite / unfavorite all rows
|
|
46
|
+
const [headerFavorited, setHeaderFavorited] = React.useState(false);
|
|
47
|
+
|
|
45
48
|
// Since OnSort specifies sorted columns by index, we need sortable values for our object by column index.
|
|
46
49
|
// In this example we only deal with booleans here because we only sort on the favorites column.
|
|
47
50
|
// For more complex sorting, see Sortable.
|
|
@@ -55,7 +58,7 @@ export const TableFavoritable: React.FunctionComponent = () => {
|
|
|
55
58
|
// Note that we perform the sort as part of the component's render logic and not in onSort.
|
|
56
59
|
// We shouldn't store the list of data in state because we don't want to have to sync that with props.
|
|
57
60
|
let sortedRepositories = repositories;
|
|
58
|
-
if (activeSortIndex !==
|
|
61
|
+
if (activeSortIndex !== undefined) {
|
|
59
62
|
sortedRepositories = repositories.sort((a, b) => {
|
|
60
63
|
const aValue = getSortableRowValues(a)[activeSortIndex];
|
|
61
64
|
const bValue = getSortableRowValues(b)[activeSortIndex];
|
|
@@ -80,7 +83,16 @@ export const TableFavoritable: React.FunctionComponent = () => {
|
|
|
80
83
|
setActiveSortIndex(index);
|
|
81
84
|
setActiveSortDirection(direction);
|
|
82
85
|
},
|
|
83
|
-
|
|
86
|
+
'aria-label': 'Sort favorites',
|
|
87
|
+
columnIndex,
|
|
88
|
+
favoriteButtonProps: {
|
|
89
|
+
favorited: headerFavorited,
|
|
90
|
+
onClick: (_event) => {
|
|
91
|
+
repositories.forEach((repo) => setRepoFavorited(repo, !headerFavorited));
|
|
92
|
+
setHeaderFavorited(!headerFavorited);
|
|
93
|
+
},
|
|
94
|
+
'aria-label': headerFavorited ? 'Unfavorite all' : 'Favorite all'
|
|
95
|
+
}
|
|
84
96
|
});
|
|
85
97
|
|
|
86
98
|
return (
|
|
@@ -101,7 +113,20 @@ export const TableFavoritable: React.FunctionComponent = () => {
|
|
|
101
113
|
<Td
|
|
102
114
|
favorites={{
|
|
103
115
|
isFavorited: isRepoFavorited(repo),
|
|
104
|
-
onFavorite: (_event, isFavoriting) =>
|
|
116
|
+
onFavorite: (_event, isFavoriting) => {
|
|
117
|
+
setRepoFavorited(repo, isFavoriting);
|
|
118
|
+
|
|
119
|
+
if (
|
|
120
|
+
isFavoriting &&
|
|
121
|
+
repositories.filter((r) => r !== repo).every((r) => favoriteRepoNames.includes(r.name))
|
|
122
|
+
) {
|
|
123
|
+
setHeaderFavorited(true);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!isFavoriting && favoriteRepoNames.length === 1 && favoriteRepoNames.includes(repo.name)) {
|
|
127
|
+
setHeaderFavorited(false);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
105
130
|
rowIndex
|
|
106
131
|
}}
|
|
107
132
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
3
3
|
/* eslint-disable camelcase */
|
|
4
|
-
import
|
|
4
|
+
import t_global_background_color_secondary_default from '@patternfly/react-tokens/dist/esm/t_global_background_color_secondary_default';
|
|
5
5
|
|
|
6
6
|
interface Repository {
|
|
7
7
|
name: string;
|
|
@@ -67,7 +67,7 @@ export const TableMisc: React.FunctionComponent = () => {
|
|
|
67
67
|
{repositories.map((repo, rowIndex) => {
|
|
68
68
|
const isOddRow = (rowIndex + 1) % 2;
|
|
69
69
|
const customStyle = {
|
|
70
|
-
backgroundColor:
|
|
70
|
+
backgroundColor: t_global_background_color_secondary_default.var
|
|
71
71
|
};
|
|
72
72
|
// Some arbitrary logic to demonstrate that cell styles can be based on anything
|
|
73
73
|
const nameColSpan = repo.branches === null && repo.prs === null ? 3 : 1;
|
|
@@ -8,12 +8,13 @@ import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
|
|
|
8
8
|
export const sortableFavorites = (sort: any) => () =>
|
|
9
9
|
sortable(<StarIcon aria-hidden />, {
|
|
10
10
|
columnIndex: sort.columnIndex,
|
|
11
|
-
className: styles.
|
|
12
|
-
ariaLabel: 'Sort favorites',
|
|
11
|
+
className: styles.tableFavorite,
|
|
12
|
+
ariaLabel: sort.ariaLabel ?? 'Sort favorites',
|
|
13
13
|
column: {
|
|
14
14
|
extraParams: {
|
|
15
15
|
sortBy: sort.sortBy,
|
|
16
|
-
onSort: sort
|
|
16
|
+
onSort: sort.onSort,
|
|
17
|
+
favoriteButtonProps: sort.favoriteButtonProps
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
20
|
tooltip: sort.tooltip,
|
|
@@ -26,7 +27,7 @@ export const sortable: ITransform = (
|
|
|
26
27
|
{ columnIndex, column, property, className, ariaLabel, tooltip, tooltipProps, tooltipHasDefaultBehavior }: IExtra
|
|
27
28
|
) => {
|
|
28
29
|
const {
|
|
29
|
-
extraParams: { sortBy, onSort }
|
|
30
|
+
extraParams: { sortBy, onSort, favoriteButtonProps }
|
|
30
31
|
} = column;
|
|
31
32
|
|
|
32
33
|
const extraData = {
|
|
@@ -52,7 +53,7 @@ export const sortable: ITransform = (
|
|
|
52
53
|
|
|
53
54
|
return {
|
|
54
55
|
className: css(styles.tableSort, isSortedBy && styles.modifiers.selected, className),
|
|
55
|
-
'aria-sort':
|
|
56
|
+
...(isSortedBy && { 'aria-sort': `${sortBy.direction}ending` }),
|
|
56
57
|
children: (
|
|
57
58
|
<SortColumn
|
|
58
59
|
isSortedBy={isSortedBy}
|
|
@@ -62,6 +63,7 @@ export const sortable: ITransform = (
|
|
|
62
63
|
tooltip={tooltip}
|
|
63
64
|
tooltipProps={tooltipProps}
|
|
64
65
|
tooltipHasDefaultBehavior={tooltipHasDefaultBehavior}
|
|
66
|
+
favoriteButtonProps={favoriteButtonProps}
|
|
65
67
|
>
|
|
66
68
|
{label as React.ReactNode}
|
|
67
69
|
</SortColumn>
|
|
@@ -113,21 +113,19 @@ export const TableBulkSelect: React.FunctionComponent = () => {
|
|
|
113
113
|
isExpanded={isBulkSelectDropdownOpen}
|
|
114
114
|
onClick={() => setIsBulkSelectDropdownOpen(!isBulkSelectDropdownOpen)}
|
|
115
115
|
aria-label="Select cards"
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
]
|
|
130
|
-
}}
|
|
116
|
+
splitButtonItems={[
|
|
117
|
+
<MenuToggleCheckbox
|
|
118
|
+
id="split-dropdown-checkbox"
|
|
119
|
+
key="split-dropdown-checkbox"
|
|
120
|
+
aria-label={anySelected ? 'Deselect all cards' : 'Select all cards'}
|
|
121
|
+
isChecked={isChecked}
|
|
122
|
+
onClick={() => {
|
|
123
|
+
anySelected ? setSelectedRows([]) : selectAllRows(bulkSelection !== 'all');
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
{numSelected !== 0 && `${numSelected} selected`}
|
|
127
|
+
</MenuToggleCheckbox>
|
|
128
|
+
]}
|
|
131
129
|
></MenuToggle>
|
|
132
130
|
)}
|
|
133
131
|
>
|
|
@@ -20,7 +20,6 @@ exports[`Table Actions table 1`] = `
|
|
|
20
20
|
data-ouia-safe="true"
|
|
21
21
|
>
|
|
22
22
|
<th
|
|
23
|
-
aria-sort="none"
|
|
24
23
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
25
24
|
data-key="0"
|
|
26
25
|
data-label="Header cell"
|
|
@@ -861,7 +860,6 @@ exports[`Table Cell header table 1`] = `
|
|
|
861
860
|
data-ouia-safe="true"
|
|
862
861
|
>
|
|
863
862
|
<th
|
|
864
|
-
aria-sort="none"
|
|
865
863
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
866
864
|
data-key="0"
|
|
867
865
|
data-label="Header cell"
|
|
@@ -1433,7 +1431,6 @@ exports[`Table Collapsible nested table 1`] = `
|
|
|
1433
1431
|
tabindex="-1"
|
|
1434
1432
|
/>
|
|
1435
1433
|
<th
|
|
1436
|
-
aria-sort="none"
|
|
1437
1434
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
1438
1435
|
data-key="1"
|
|
1439
1436
|
data-label="Header cell"
|
|
@@ -2198,7 +2195,6 @@ exports[`Table Collapsible table 1`] = `
|
|
|
2198
2195
|
tabindex="-1"
|
|
2199
2196
|
/>
|
|
2200
2197
|
<th
|
|
2201
|
-
aria-sort="none"
|
|
2202
2198
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
2203
2199
|
data-key="1"
|
|
2204
2200
|
data-label="Header cell"
|
|
@@ -4234,7 +4230,6 @@ exports[`Table Selectable table 1`] = `
|
|
|
4234
4230
|
</label>
|
|
4235
4231
|
</th>
|
|
4236
4232
|
<th
|
|
4237
|
-
aria-sort="none"
|
|
4238
4233
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
4239
4234
|
data-key="1"
|
|
4240
4235
|
data-label="Header cell"
|
|
@@ -4927,7 +4922,6 @@ exports[`Table Selectable table with Radio 1`] = `
|
|
|
4927
4922
|
tabindex="-1"
|
|
4928
4923
|
/>
|
|
4929
4924
|
<th
|
|
4930
|
-
aria-sort="none"
|
|
4931
4925
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
4932
4926
|
data-key="1"
|
|
4933
4927
|
data-label="Header cell"
|
|
@@ -5717,7 +5711,6 @@ exports[`Table Simple Actions table 1`] = `
|
|
|
5717
5711
|
data-ouia-safe="true"
|
|
5718
5712
|
>
|
|
5719
5713
|
<th
|
|
5720
|
-
aria-sort="none"
|
|
5721
5714
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
5722
5715
|
data-key="0"
|
|
5723
5716
|
data-label="Header cell"
|
|
@@ -6640,7 +6633,6 @@ exports[`Table Table variants Breakpoint - 1`] = `
|
|
|
6640
6633
|
data-ouia-safe="true"
|
|
6641
6634
|
>
|
|
6642
6635
|
<th
|
|
6643
|
-
aria-sort="none"
|
|
6644
6636
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
6645
6637
|
data-key="0"
|
|
6646
6638
|
data-label="Header cell"
|
|
@@ -7169,7 +7161,6 @@ exports[`Table Table variants Breakpoint - grid 1`] = `
|
|
|
7169
7161
|
data-ouia-safe="true"
|
|
7170
7162
|
>
|
|
7171
7163
|
<th
|
|
7172
|
-
aria-sort="none"
|
|
7173
7164
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
7174
7165
|
data-key="0"
|
|
7175
7166
|
data-label="Header cell"
|
|
@@ -7698,7 +7689,6 @@ exports[`Table Table variants Breakpoint - grid-2xl 1`] = `
|
|
|
7698
7689
|
data-ouia-safe="true"
|
|
7699
7690
|
>
|
|
7700
7691
|
<th
|
|
7701
|
-
aria-sort="none"
|
|
7702
7692
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
7703
7693
|
data-key="0"
|
|
7704
7694
|
data-label="Header cell"
|
|
@@ -8227,7 +8217,6 @@ exports[`Table Table variants Breakpoint - grid-lg 1`] = `
|
|
|
8227
8217
|
data-ouia-safe="true"
|
|
8228
8218
|
>
|
|
8229
8219
|
<th
|
|
8230
|
-
aria-sort="none"
|
|
8231
8220
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
8232
8221
|
data-key="0"
|
|
8233
8222
|
data-label="Header cell"
|
|
@@ -8756,7 +8745,6 @@ exports[`Table Table variants Breakpoint - grid-md 1`] = `
|
|
|
8756
8745
|
data-ouia-safe="true"
|
|
8757
8746
|
>
|
|
8758
8747
|
<th
|
|
8759
|
-
aria-sort="none"
|
|
8760
8748
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
8761
8749
|
data-key="0"
|
|
8762
8750
|
data-label="Header cell"
|
|
@@ -9285,7 +9273,6 @@ exports[`Table Table variants Breakpoint - grid-xl 1`] = `
|
|
|
9285
9273
|
data-ouia-safe="true"
|
|
9286
9274
|
>
|
|
9287
9275
|
<th
|
|
9288
|
-
aria-sort="none"
|
|
9289
9276
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
9290
9277
|
data-key="0"
|
|
9291
9278
|
data-label="Header cell"
|
|
@@ -9814,7 +9801,6 @@ exports[`Table Table variants Size - compact 1`] = `
|
|
|
9814
9801
|
data-ouia-safe="true"
|
|
9815
9802
|
>
|
|
9816
9803
|
<th
|
|
9817
|
-
aria-sort="none"
|
|
9818
9804
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
9819
9805
|
data-key="0"
|
|
9820
9806
|
data-label="Header cell"
|
|
@@ -10908,7 +10894,6 @@ exports[`Table simple Row click table 1`] = `
|
|
|
10908
10894
|
data-ouia-safe="true"
|
|
10909
10895
|
>
|
|
10910
10896
|
<th
|
|
10911
|
-
aria-sort="none"
|
|
10912
10897
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
10913
10898
|
data-key="0"
|
|
10914
10899
|
data-label="Header cell"
|
|
@@ -11437,7 +11422,6 @@ exports[`Table simple Sortable table 1`] = `
|
|
|
11437
11422
|
data-ouia-safe="true"
|
|
11438
11423
|
>
|
|
11439
11424
|
<th
|
|
11440
|
-
aria-sort="none"
|
|
11441
11425
|
class="pf-v6-c-table__th pf-v6-c-table__sort"
|
|
11442
11426
|
data-key="0"
|
|
11443
11427
|
data-label="Header cell"
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Table, TableHeader, TableBody, TableProps } from '@patternfly/react-table/deprecated';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
/* eslint-disable camelcase */
|
|
5
|
-
import
|
|
5
|
+
import t_global_color_brand_default from '@patternfly/react-tokens/dist/esm/t_global_color_brand_default';
|
|
6
6
|
|
|
7
7
|
interface Repository {
|
|
8
8
|
name: string;
|
|
@@ -32,7 +32,7 @@ export const LegacyTableMisc: React.FunctionComponent = () => {
|
|
|
32
32
|
const customRowWrapper: TableProps['rowWrapper'] = ({ trRef, className, rowProps, row: _row }) => {
|
|
33
33
|
const isOddRow = rowProps ? !!((rowProps.rowIndex + 1) % 2) : true;
|
|
34
34
|
const customStyle = {
|
|
35
|
-
borderLeft: `3px solid ${
|
|
35
|
+
borderLeft: `3px solid ${t_global_color_brand_default.var}`
|
|
36
36
|
};
|
|
37
37
|
return (
|
|
38
38
|
<tr
|