@patternfly/react-table 4.61.9 → 4.61.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-table",
3
- "version": "4.61.9",
3
+ "version": "4.61.13",
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",
@@ -31,10 +31,10 @@
31
31
  "clean": "rimraf dist"
32
32
  },
33
33
  "dependencies": {
34
- "@patternfly/react-core": "^4.192.9",
35
- "@patternfly/react-icons": "^4.43.9",
36
- "@patternfly/react-styles": "^4.42.9",
37
- "@patternfly/react-tokens": "^4.44.9",
34
+ "@patternfly/react-core": "^4.192.13",
35
+ "@patternfly/react-icons": "^4.43.13",
36
+ "@patternfly/react-styles": "^4.42.13",
37
+ "@patternfly/react-tokens": "^4.44.13",
38
38
  "lodash": "^4.17.19",
39
39
  "tslib": "^2.0.0"
40
40
  },
@@ -46,5 +46,5 @@
46
46
  "react": "^16.8.0 || ^17.0.0",
47
47
  "react-dom": "^16.8.0 || ^17.0.0"
48
48
  },
49
- "gitHead": "ef03957eef7673a3fbecd704a5a0c88040bd5313"
49
+ "gitHead": "1c02d77a07a642f8ef67eaf94ba3330fa8015a63"
50
50
  }
@@ -10,14 +10,7 @@ import {
10
10
  DropdownPosition
11
11
  } from '@patternfly/react-core/dist/esm/components/Dropdown/dropdownConstants';
12
12
 
13
- import {
14
- IAction,
15
- IActionDropdownItem,
16
- IActionOutsideItemButton,
17
- IActionOutsideItemCustom,
18
- IExtraData,
19
- IRowData
20
- } from './TableTypes';
13
+ import { IAction, IExtraData, IRowData } from './TableTypes';
21
14
 
22
15
  export interface CustomActionsToggleProps {
23
16
  onToggle: (isOpen: boolean) => void;
@@ -89,16 +82,10 @@ export class ActionsColumn extends React.Component<ActionsColumnProps, ActionsCo
89
82
  <KebabToggle isDisabled={isDisabled} onToggle={this.onToggle} />
90
83
  );
91
84
 
92
- const outsideDropdownItems = items.filter(a => a.isOutsideDropdown) as (
93
- | IActionOutsideItemButton
94
- | IActionOutsideItemCustom
95
- )[];
96
-
97
- const dropdownItems = items.filter(a => !a.isOutsideDropdown) as IActionDropdownItem[];
98
-
99
85
  return (
100
86
  <React.Fragment>
101
- {outsideDropdownItems
87
+ {items
88
+ .filter(item => item.isOutsideDropdown)
102
89
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
103
90
  .map(({ title, itemKey, onClick, isOutsideDropdown, ...props }, key) =>
104
91
  typeof title === 'string' ? (
@@ -120,24 +107,26 @@ export class ActionsColumn extends React.Component<ActionsColumnProps, ActionsCo
120
107
  position={dropdownPosition}
121
108
  direction={dropdownDirection}
122
109
  isOpen={isOpen}
123
- dropdownItems={dropdownItems.map(({ title, itemKey, onClick, isSeparator, ...props }, key) =>
124
- isSeparator ? (
125
- <DropdownSeparator {...props} key={itemKey || key} data-key={itemKey || key} />
126
- ) : (
127
- <DropdownItem
128
- component="button"
129
- onClick={event => {
130
- this.onClick(event, onClick);
131
- this.onToggle(!isOpen);
132
- }}
133
- {...props}
134
- key={itemKey || key}
135
- data-key={itemKey || key}
136
- >
137
- {title}
138
- </DropdownItem>
139
- )
140
- )}
110
+ dropdownItems={items
111
+ .filter(item => !item.isOutsideDropdown)
112
+ .map(({ title, itemKey, onClick, isSeparator, ...props }, key) =>
113
+ isSeparator ? (
114
+ <DropdownSeparator {...props} key={itemKey || key} data-key={itemKey || key} />
115
+ ) : (
116
+ <DropdownItem
117
+ component="button"
118
+ onClick={event => {
119
+ this.onClick(event, onClick);
120
+ this.onToggle(!isOpen);
121
+ }}
122
+ {...props}
123
+ key={itemKey || key}
124
+ data-key={itemKey || key}
125
+ >
126
+ {title}
127
+ </DropdownItem>
128
+ )
129
+ )}
141
130
  isPlain
142
131
  {...(rowData && rowData.actionProps)}
143
132
  />
@@ -146,54 +146,22 @@ export interface ISortBy {
146
146
  defaultDirection?: 'asc' | 'desc';
147
147
  }
148
148
 
149
- export interface ISeparator {
149
+ export interface IAction extends Omit<DropdownItemProps, 'title' | 'onClick'>, Pick<ButtonProps, 'variant'> {
150
150
  /** Flag indicating an item on actions menu is a separator, rather than an action */
151
- isSeparator: true;
152
- }
153
-
154
- export interface IActionSeparator extends ISeparator {
155
- isOutsideDropdown?: false;
156
- }
157
-
158
- interface IActionClickable {
151
+ isSeparator?: boolean;
152
+ /** Key of actions menu item */
153
+ itemKey?: string;
154
+ /** Content to display in the actions menu item */
155
+ title?: string | React.ReactNode;
159
156
  /** Click handler for the actions menu item */
160
157
  onClick?: (event: React.MouseEvent, rowIndex: number, rowData: IRowData, extraData: IExtraData) => void;
161
- }
162
-
163
- export type IActionOutsideItemBase = IActionClickable & {
164
158
  /** Flag indicating this action should be placed outside the actions menu, beside the toggle */
165
- isOutsideDropdown: true;
166
- /** Flag indicating an item on actions menu is not a separator, added to make it easy to distinguish */
167
- isSeparator?: false;
168
- /** Key of actions menu item */
169
- itemKey?: undefined;
170
- };
171
-
172
- export type IActionOutsideItemButton = IActionOutsideItemBase &
173
- Omit<ButtonProps, 'onClick'> & {
174
- title: string;
175
- /** Key of actions menu item */
176
- itemKey?: string;
177
- };
178
-
179
- export type IActionOutsideItemCustom = IActionOutsideItemBase & {
180
- title: Exclude<React.ReactNode, string>;
181
- [key: string]: any;
182
- };
183
-
184
- export type IActionDropdownItem = Omit<DropdownItemProps, 'title' | 'onClick'> &
185
- IActionClickable & {
186
- /** Flag indicating an item on actions menu is not a separator, added to make it easy to distinguish */
187
- isSeparator?: false;
188
- /** Flag indicating this action should be placed outside the actions menu, beside the toggle */
189
- isOutsideDropdown?: false;
190
- /** Key of actions menu item */
191
- itemKey?: string;
192
- /** Content to display in the actions menu item */
193
- title: React.ReactNode;
194
- };
159
+ isOutsideDropdown?: boolean;
160
+ }
195
161
 
196
- export type IAction = IActionSeparator | IActionDropdownItem | IActionOutsideItemButton | IActionOutsideItemCustom;
162
+ export interface ISeparator extends IAction {
163
+ isSeparator: boolean;
164
+ }
197
165
 
198
166
  export type IActions = (IAction | ISeparator)[];
199
167
  export type IActionsResolver = (rowData: IRowData, extraData: IExtraData) => (IAction | ISeparator)[];
@@ -163,9 +163,6 @@ This example demonstrates adding actions as the last column. The header's last c
163
163
 
164
164
  To make a cell an action cell, render an `ActionsColumn` component inside a row's last `Td` and pass an array of `IAction` objects via the `items` prop of `ActionsColumn`.
165
165
 
166
- Look [here](https://github.com/patternfly/patternfly-react/blob/main/packages/react-table/src/components/Table/TableTypes.tsx)
167
- for the `IAction` type to see what it looks like.
168
-
169
166
  ```ts file="ComposableTableActions.tsx"
170
167
  ```
171
168