@patternfly/react-table 4.106.4 → 4.106.7

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.106.4",
3
+ "version": "4.106.7",
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.237.4",
35
- "@patternfly/react-icons": "^4.88.4",
36
- "@patternfly/react-styles": "^4.87.4",
37
- "@patternfly/react-tokens": "^4.89.4",
34
+ "@patternfly/react-core": "^4.237.7",
35
+ "@patternfly/react-icons": "^4.88.7",
36
+ "@patternfly/react-styles": "^4.87.7",
37
+ "@patternfly/react-tokens": "^4.89.7",
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": "c45164ec148b97dd7fe65152852de24813fba68e"
49
+ "gitHead": "6a8c488ab5de48d31ab8070271ebf17f9e6a625a"
50
50
  }
@@ -2612,174 +2612,9 @@ class ComplexPaginationTableDemo extends React.Component {
2612
2612
  }
2613
2613
  ```
2614
2614
 
2615
- ### Pagination
2615
+ ### Static bottom pagination on mobile
2616
2616
 
2617
- ```js
2618
- import React from 'react';
2619
- import {
2620
- Checkbox,
2621
- Pagination,
2622
- Title,
2623
- Toolbar,
2624
- ToolbarContent,
2625
- ToolbarItem,
2626
- EmptyState,
2627
- EmptyStateIcon,
2628
- EmptyStateBody,
2629
- EmptyStateVariant,
2630
- Bullseye
2631
- } from '@patternfly/react-core';
2632
- import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
2633
- import globalDangerColor200 from '@patternfly/react-tokens/dist/esm/global_danger_color_200';
2634
- import { Table, TableHeader, TableBody } from '@patternfly/react-table';
2635
- import { Spinner } from '@patternfly/react-core';
2636
-
2637
- class ComplexPaginationTableDemo extends React.Component {
2638
- constructor(props) {
2639
- super(props);
2640
- this.state = {
2641
- res: [],
2642
- perPage: 0,
2643
- total: 0,
2644
- page: 0,
2645
- error: null,
2646
- loading: true,
2647
- forceLoadingState: false
2648
- };
2649
-
2650
- this.handleCheckboxChange = checked => {
2651
- console.log(checked);
2652
- this.setState({ forceLoadingState: checked });
2653
- };
2654
- }
2655
-
2656
- fetch(page, perPage) {
2657
- this.setState({ loading: true });
2658
- fetch(`https://jsonplaceholder.typicode.com/posts?_page=${page}&_limit=${perPage}`)
2659
- .then(resp => resp.json())
2660
- .then(resp => this.setState({ res: resp, perPage, page, loading: false, total: 100 }))
2661
- .catch(err => this.setState({ error: err, loading: false, perPage: 0, page: 0, total: 0 }));
2662
- }
2663
-
2664
- componentDidMount() {
2665
- this.fetch(this.state.page || 1, this.state.perPage || 20);
2666
- }
2667
-
2668
- renderPagination(variant = 'top') {
2669
- const { page, perPage, total } = this.state;
2670
- return (
2671
- <Pagination
2672
- isCompact
2673
- itemCount={total}
2674
- page={page}
2675
- perPage={perPage}
2676
- onSetPage={(_evt, value) => this.fetch(value, perPage)}
2677
- onPerPageSelect={(_evt, value) => this.fetch(1, value)}
2678
- variant={variant}
2679
- titles={{
2680
- paginationTitle: `Pagination demo ${variant} pagination`
2681
- }}
2682
- />
2683
- );
2684
- }
2685
-
2686
- render() {
2687
- const { loading, res, error, forceLoadingState } = this.state;
2688
-
2689
- const toolbarItems = (
2690
- <React.Fragment>
2691
- <ToolbarContent>
2692
- <ToolbarItem>
2693
- <Checkbox
2694
- label="View loading state"
2695
- isChecked={this.state.forceLoadingState}
2696
- onChange={this.handleCheckboxChange}
2697
- aria-label="view loading state checkbox"
2698
- id="check"
2699
- name="check"
2700
- />
2701
- </ToolbarItem>
2702
- <ToolbarItem variant="pagination">{this.renderPagination()}</ToolbarItem>
2703
- </ToolbarContent>
2704
- </React.Fragment>
2705
- );
2706
-
2707
- if (error) {
2708
- const noResultsRows = [
2709
- {
2710
- heightAuto: true,
2711
- cells: [
2712
- {
2713
- props: { colSpan: 8 },
2714
- title: (
2715
- <Bullseye>
2716
- <EmptyState variant={EmptyStateVariant.small}>
2717
- <EmptyStateIcon icon={ExclamationCircleIcon} color={globalDangerColor200.value} />
2718
- <Title headingLevel="h2" size="lg">
2719
- Check your connection and reload the page.
2720
- </Title>
2721
- <EmptyStateBody>
2722
- There was an error retrieving data. Check your connection and try again.
2723
- </EmptyStateBody>
2724
- </EmptyState>
2725
- </Bullseye>
2726
- )
2727
- }
2728
- ]
2729
- }
2730
- ];
2731
-
2732
- return (
2733
- <React.Fragment>
2734
- <Table cells={['Title', 'Body']} rows={noResultsRows} aria-label="Pagination Table Demo">
2735
- <TableHeader />
2736
- <TableBody />
2737
- </Table>
2738
- </React.Fragment>
2739
- );
2740
- }
2741
-
2742
- const loadingRows = [
2743
- {
2744
- heightAuto: true,
2745
- cells: [
2746
- {
2747
- props: { colSpan: 8 },
2748
- title: (
2749
- <Bullseye>
2750
- <center>
2751
- <Spinner size="xl" />
2752
- </center>
2753
- </Bullseye>
2754
- )
2755
- }
2756
- ]
2757
- }
2758
- ];
2759
-
2760
- return (
2761
- <React.Fragment>
2762
- <Toolbar>{toolbarItems}</Toolbar>
2763
- {!(loading || forceLoadingState) && (
2764
- <Table
2765
- cells={['Title', 'Body']}
2766
- rows={res.map(post => [post.title, post.body])}
2767
- aria-label="Pagination Table Demo"
2768
- >
2769
- <TableHeader />
2770
- <TableBody />
2771
- </Table>
2772
- )}
2773
- {(loading || forceLoadingState) && (
2774
- <Table cells={['Title', 'Body']} rows={loadingRows} aria-label="Pagination Table Demo">
2775
- <TableHeader />
2776
- <TableBody />
2777
- </Table>
2778
- )}
2779
- </React.Fragment>
2780
- );
2781
- }
2782
- }
2617
+ ```js isFullscreen file="table-demos/StaticBottomPagination.jsx"
2783
2618
  ```
2784
2619
 
2785
2620
  ### Sticky header
@@ -0,0 +1,141 @@
1
+ import React from 'react';
2
+ import {
3
+ Button,
4
+ Card,
5
+ Toolbar,
6
+ ToolbarContent,
7
+ ToolbarGroup,
8
+ ToolbarItem,
9
+ Pagination,
10
+ Select,
11
+ SelectVariant,
12
+ SelectOption,
13
+ PageSection,
14
+ Label
15
+ } from '@patternfly/react-core';
16
+ import { TableComposable, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
17
+ import { rows, columns } from '../../examples/Data.jsx';
18
+
19
+ import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
20
+ import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
21
+
22
+ export const StaticBottomPagination = () => {
23
+ const [isSelectOpen, setIsSelectOpen] = React.useState(false);
24
+ const [page, setPage] = React.useState(1);
25
+ const [perPage, setPerPage] = React.useState(10);
26
+ const [paginatedRows, setPaginatedRows] = React.useState(rows.slice(0, 10));
27
+ const handleSetPage = (_evt, newPage, perPage, startIdx, endIdx) => {
28
+ setPaginatedRows(rows.slice(startIdx, endIdx));
29
+ setPage(newPage);
30
+ };
31
+ handlePerPageSelect = (_evt, newPerPage, newPage, startIdx, endIdx) => {
32
+ setPaginatedRows(rows.slice(startIdx, endIdx));
33
+ setPage(newPage);
34
+ setPerPage(newPerPage);
35
+ };
36
+
37
+
38
+ const renderPagination = (variant, isCompact) => (
39
+ <Pagination
40
+ isCompact={isCompact}
41
+ itemCount={rows.length}
42
+ page={page}
43
+ perPage={perPage}
44
+ onSetPage={handleSetPage}
45
+ onPerPageSelect={handlePerPageSelect}
46
+ variant={variant}
47
+ titles={{
48
+ paginationTitle: `${variant} pagination`
49
+ }}
50
+ isStatic
51
+ />
52
+ );
53
+
54
+ const renderLabel = labelText => {
55
+ switch (labelText) {
56
+ case 'Running':
57
+ return <span><Label color="green">{labelText}</Label></span>;
58
+ case 'Stopped':
59
+ return <span><Label color="orange">{labelText}</Label></span>;
60
+ case 'Needs Maintenance':
61
+ return <span><Label color="blue">{labelText}</Label></span>;
62
+ case 'Down':
63
+ return <span><Label color="red">{labelText}</Label></span>;
64
+ }
65
+ };
66
+
67
+ const tableToolbar = (
68
+ <Toolbar usePageInsets id="pagination-toolbar">
69
+ <ToolbarContent>
70
+ <ToolbarItem>
71
+ <Select
72
+ id="select-example"
73
+ variant={SelectVariant.single}
74
+ aria-label="Select Input"
75
+ placeholderText={
76
+ <>
77
+ <FilterIcon /> Status
78
+ </>
79
+ }
80
+ isOpen={isSelectOpen}
81
+ onToggle={() => setIsSelectOpen(!isSelectOpen)}
82
+ onSelect={() => setIsSelectOpen(!isSelectOpen)}
83
+ >
84
+ {[
85
+ <SelectOption key={0} value="Debug" />,
86
+ <SelectOption key={1} value="Info" />,
87
+ <SelectOption key={2} value="Warn" />,
88
+ <SelectOption key={3} value="Error" />
89
+ ]}
90
+ </Select>
91
+ </ToolbarItem>
92
+ <ToolbarGroup>
93
+ <ToolbarItem>
94
+ <Button variant="primary">Action</Button>
95
+ </ToolbarItem>
96
+ </ToolbarGroup>
97
+ <ToolbarItem variant="pagination">{renderPagination('top', true)}</ToolbarItem>
98
+ </ToolbarContent>
99
+ </Toolbar>
100
+ );
101
+
102
+ return (
103
+ <React.Fragment>
104
+ <DashboardWrapper hasPageTemplateTitle>
105
+ <PageSection isFilled>
106
+ <Card>
107
+ {tableToolbar}
108
+ <TableComposable variant="compact" aria-label="Paginated Table">
109
+ <Thead>
110
+ <Tr>
111
+ {columns.map((column, columnIndex) => (
112
+ <Th key={columnIndex}>{column}</Th>
113
+ ))}
114
+ </Tr>
115
+ </Thead>
116
+ <Tbody>
117
+ {paginatedRows.map((row, rowIndex) => (
118
+ <Tr key={rowIndex}>
119
+ <Td dataLabel={columns[0]}>{row.name}</Td>
120
+ <Td dataLabel={columns[1]}>{row.threads}</Td>
121
+ <Td dataLabel={columns[2]}>{row.applications}</Td>
122
+ <Td dataLabel={columns[3]}>{row.workspaces}</Td>
123
+ <Td dataLabel={columns[4]}>{renderLabel(row.status)}</Td>
124
+ <Td dataLabel={columns[5]}>{row.location}</Td>
125
+ <Td dataLabel={columns[6]}>{row.lastModified}</Td>
126
+ <Td dataLabel={columns[7]} modifier="truncate">
127
+ <TableText>
128
+ <a href="#">{row.url}</a>
129
+ </TableText>
130
+ </Td>
131
+ </Tr>
132
+ ))}
133
+ </Tbody>
134
+ </TableComposable>
135
+ {renderPagination('bottom', false)}
136
+ </Card>
137
+ </PageSection>
138
+ </DashboardWrapper>
139
+ </React.Fragment>
140
+ );
141
+ };