@patternfly/react-table 4.111.55 → 4.112.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 (29) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/esm/components/Table/base/provider.d.ts +1 -1
  3. package/dist/esm/components/Table/base/types.d.ts +5 -1
  4. package/dist/esm/components/Table/base/types.d.ts.map +1 -1
  5. package/dist/esm/components/Table/base/types.js.map +1 -1
  6. package/dist/esm/components/TableComposable/Td.d.ts +9 -1
  7. package/dist/esm/components/TableComposable/Td.d.ts.map +1 -1
  8. package/dist/esm/components/TableComposable/Td.js +5 -2
  9. package/dist/esm/components/TableComposable/Td.js.map +1 -1
  10. package/dist/esm/components/TableComposable/Th.d.ts.map +1 -1
  11. package/dist/esm/components/TableComposable/Th.js +5 -0
  12. package/dist/esm/components/TableComposable/Th.js.map +1 -1
  13. package/dist/js/components/Table/base/provider.d.ts +1 -1
  14. package/dist/js/components/Table/base/types.d.ts +5 -1
  15. package/dist/js/components/Table/base/types.d.ts.map +1 -1
  16. package/dist/js/components/Table/base/types.js.map +1 -1
  17. package/dist/js/components/TableComposable/Td.d.ts +9 -1
  18. package/dist/js/components/TableComposable/Td.d.ts.map +1 -1
  19. package/dist/js/components/TableComposable/Td.js +5 -2
  20. package/dist/js/components/TableComposable/Td.js.map +1 -1
  21. package/dist/js/components/TableComposable/Th.d.ts.map +1 -1
  22. package/dist/js/components/TableComposable/Th.js +5 -0
  23. package/dist/js/components/TableComposable/Th.js.map +1 -1
  24. package/dist/umd/react-table.min.js +3 -3
  25. package/package.json +2 -2
  26. package/src/components/Table/base/types.tsx +4 -0
  27. package/src/components/TableComposable/Td.tsx +22 -0
  28. package/src/components/TableComposable/Th.tsx +5 -0
  29. package/src/components/TableComposable/examples/ComposableTable.md +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-table",
3
- "version": "4.111.55",
3
+ "version": "4.112.0",
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",
@@ -58,5 +58,5 @@
58
58
  "react": "^16.8 || ^17 || ^18",
59
59
  "react-dom": "^16.8 || ^17 || ^18"
60
60
  },
61
- "gitHead": "b224b7b6d5b36770ee02671dc33db62da2a79e0a"
61
+ "gitHead": "bf5681a6297998e57a4e0f8486cc891ef64af76e"
62
62
  }
@@ -171,6 +171,10 @@ export interface ThSelectType {
171
171
  isSelected: boolean;
172
172
  /** Flag indicating the select checkbox in the th is disabled */
173
173
  isHeaderSelectDisabled?: boolean;
174
+ /** Whether to disable the selection */
175
+ isDisabled?: boolean;
176
+ /** Additional props forwarded to select rowData */
177
+ props?: any;
174
178
  }
175
179
 
176
180
  export interface ThExpandType {
@@ -1,6 +1,7 @@
1
1
  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
+ import scrollStyles from '@patternfly/react-styles/css/components/Table/table-scrollable';
4
5
  import { BaseCellProps } from './TableComposable';
5
6
  import { cellActions } from '../Table/utils/decorators/cellActions';
6
7
  import { selectable } from '../Table/utils/decorators/selectable';
@@ -57,6 +58,14 @@ export interface TdProps extends BaseCellProps, Omit<React.HTMLProps<HTMLTableDa
57
58
  tooltip?: React.ReactNode;
58
59
  /** Callback on mouse enter */
59
60
  onMouseEnter?: (event: any) => void;
61
+ /** Indicates the column should be sticky */
62
+ isStickyColumn?: boolean;
63
+ /** Adds a border to the right side of the cell */
64
+ hasRightBorder?: boolean;
65
+ /** Minimum width for a sticky column */
66
+ stickyMinWidth?: string;
67
+ /** Left offset of a sticky column. This will typically be equal to the combined value set by stickyMinWidth of any sticky columns that precede the current sticky column. */
68
+ stickyLeftOffset?: string;
60
69
  }
61
70
 
62
71
  const TdBase: React.FunctionComponent<TdProps> = ({
@@ -80,6 +89,10 @@ const TdBase: React.FunctionComponent<TdProps> = ({
80
89
  draggableRow: draggableRowProp = null,
81
90
  tooltip = '',
82
91
  onMouseEnter: onMouseEnterProp = () => {},
92
+ isStickyColumn = false,
93
+ hasRightBorder = false,
94
+ stickyMinWidth = '120px',
95
+ stickyLeftOffset,
83
96
  ...props
84
97
  }: TdProps) => {
85
98
  const [showTooltip, setShowTooltip] = React.useState(false);
@@ -239,6 +252,8 @@ const TdBase: React.FunctionComponent<TdProps> = ({
239
252
  isActionCell && styles.tableAction,
240
253
  textCenter && styles.modifiers.center,
241
254
  noPadding && styles.modifiers.noPadding,
255
+ isStickyColumn && scrollStyles.tableStickyColumn,
256
+ hasRightBorder && scrollStyles.modifiers.borderRight,
242
257
  styles.modifiers[modifier as 'breakWord' | 'fitContent' | 'nowrap' | 'truncate' | 'wrap' | undefined],
243
258
  draggableParams && styles.tableDraggable,
244
259
  mergedClassName
@@ -246,6 +261,13 @@ const TdBase: React.FunctionComponent<TdProps> = ({
246
261
  ref={innerRef}
247
262
  {...mergedProps}
248
263
  {...props}
264
+ {...(isStickyColumn && {
265
+ style: {
266
+ '--pf-c-table__sticky-column--MinWidth': stickyMinWidth ? stickyMinWidth : undefined,
267
+ '--pf-c-table__sticky-column--Left': stickyLeftOffset ? stickyLeftOffset : undefined,
268
+ ...props.style
269
+ } as React.CSSProperties
270
+ })}
249
271
  >
250
272
  {mergedChildren || children}
251
273
  </MergedComponent>
@@ -109,6 +109,11 @@ const ThBase: React.FunctionComponent<ThProps> = ({
109
109
  }
110
110
  const selectParams = select
111
111
  ? selectable(children as IFormatterValueType, {
112
+ rowData: {
113
+ selected: select.isSelected,
114
+ disableSelection: select?.isDisabled,
115
+ props: select?.props
116
+ },
112
117
  column: {
113
118
  extraParams: {
114
119
  onSelect: select?.onSelect,
@@ -327,14 +327,14 @@ There are a few ways this can be handled:
327
327
 
328
328
  ### Composable: Sticky column
329
329
 
330
- To make a column sticky, wrap `TableComposable` with `InnerScrollContainer` and add the following properties to the `Th` that should be sticky: `isStickyColumn` and `hasRightBorder`. To prevent the default text wrapping behavior and allow horizontal scrolling, all `Th` should also have the `modifier="nowrap"` property. To set the minimum width of the sticky column, use the `stickyMinWidth` property.
330
+ To make a column sticky, wrap `TableComposable` with `InnerScrollContainer` and add the following properties to the `Th` or `Td` that should be sticky: `isStickyColumn` and `hasRightBorder`. To prevent the default text wrapping behavior and allow horizontal scrolling, all `Th` or `Td` cells should also have the `modifier="nowrap"` property. To set the minimum width of the sticky column, use the `stickyMinWidth` property.
331
331
 
332
332
  ```ts file="ComposableTableStickyColumn.tsx"
333
333
  ```
334
334
 
335
335
  ### Composable: Multiple sticky columns
336
336
 
337
- To make multiple columns sticky, wrap `TableComposable` with `InnerScrollContainer` and add `isStickyColumn` to all columns that should be sticky. The rightmost column should also have the `hasRightBorder` property, and each sticky column after the first must define a `stickyLeftOffset` property that equals the combined width of the previous sticky columns - set by `stickyMinWidth`. To prevent the default text wrapping behavior and allow horizontal scrolling, all `Th` should also have the `modifier="nowrap"` property.
337
+ To make multiple columns sticky, wrap `TableComposable` with `InnerScrollContainer` and add `isStickyColumn` to all columns that should be sticky. The rightmost column should also have the `hasRightBorder` property, and each sticky column after the first must define a `stickyLeftOffset` property that equals the combined width of the previous sticky columns - set by `stickyMinWidth`. To prevent the default text wrapping behavior and allow horizontal scrolling, all `Th` or `Td` cells should also have the `modifier="nowrap"` property.
338
338
 
339
339
  ```ts file="ComposableTableMultipleStickyColumns.tsx"
340
340
  ```