@patternfly/react-table 4.38.2 → 4.39.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-table",
3
- "version": "4.38.2",
3
+ "version": "4.39.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",
@@ -31,10 +31,10 @@
31
31
  "clean": "rimraf dist"
32
32
  },
33
33
  "dependencies": {
34
- "@patternfly/react-core": "^4.169.2",
35
- "@patternfly/react-icons": "^4.20.2",
36
- "@patternfly/react-styles": "^4.19.2",
37
- "@patternfly/react-tokens": "^4.21.2",
34
+ "@patternfly/react-core": "^4.170.1",
35
+ "@patternfly/react-icons": "^4.21.1",
36
+ "@patternfly/react-styles": "^4.20.1",
37
+ "@patternfly/react-tokens": "^4.22.1",
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": "fef8a9f3a2a4a522fba27c683d298fd817b95f57"
49
+ "gitHead": "da37ad257c8bbc6dd946e36089dfbf054841d527"
50
50
  }
@@ -137,8 +137,12 @@ export type IFormatterValueType = formatterValueType & {
137
137
  };
138
138
 
139
139
  export interface ISortBy {
140
+ /** Index of the current sorted column */
140
141
  index?: number;
142
+ /** Current sort direction */
141
143
  direction?: 'asc' | 'desc';
144
+ /** Defaulting sorting direction. Defaults to "asc". */
145
+ defaultDirection?: 'asc' | 'desc';
142
146
  }
143
147
 
144
148
  export interface IAction extends Omit<DropdownItemProps, 'title' | 'onClick'> {
@@ -2,7 +2,7 @@
2
2
  id: Table
3
3
  cssPrefix: pf-c-table
4
4
  section: components
5
- propComponents: ['Table', 'TableHeader', 'TableBody']
5
+ propComponents: ['Table', 'TableHeader', 'TableBody', 'ISortBy']
6
6
  ouia: true
7
7
  ---
8
8
 
@@ -330,7 +330,9 @@ class SortableTable extends React.Component {
330
330
  ['a', 'two', 'k', 'four', 'five'],
331
331
  ['p', 'two', 'b', 'four', 'five']
332
332
  ],
333
- sortBy: {}
333
+ sortBy: {
334
+ defaultDirection: 'asc' // starting sort direction when first sorting a column. Defaults to 'asc'
335
+ }
334
336
  };
335
337
  this.onSort = this.onSort.bind(this);
336
338
  }
@@ -39,7 +39,7 @@ export const sortable: ITransform = (
39
39
  function sortClicked(event: React.MouseEvent) {
40
40
  let reversedDirection: SortByDirection;
41
41
  if (!isSortedBy) {
42
- reversedDirection = SortByDirection.asc;
42
+ reversedDirection = sortBy.defaultDirection ? (sortBy.defaultDirection as SortByDirection) : SortByDirection.asc;
43
43
  } else {
44
44
  reversedDirection = sortBy.direction === SortByDirection.asc ? SortByDirection.desc : SortByDirection.asc;
45
45
  }
@@ -27,6 +27,7 @@ propComponents:
27
27
  'EditableSelectInputProps',
28
28
  'EditableTextCellProps',
29
29
  'ThSortType',
30
+ 'ISortBy',
30
31
  ]
31
32
  ouia: true
32
33
  ---
@@ -313,7 +314,8 @@ ComposableTableSortable = () => {
313
314
  sort: {
314
315
  sortBy: {
315
316
  index: activeSortIndex,
316
- direction: activeSortDirection
317
+ direction: activeSortDirection,
318
+ defaultDirection: 'asc' // starting sort direction when first sorting a column. Defaults to 'asc'
317
319
  },
318
320
  onSort,
319
321
  columnIndex