@patternfly/react-table 4.30.18 → 4.31.2
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 +35 -0
- package/dist/umd/react-table.css +8926 -8855
- package/dist/umd/react-table.min.css +9028 -8957
- package/package.json +6 -6
- package/src/components/Table/examples/Table.md +181 -71
- package/src/components/TableComposable/examples/ComposableTable.md +209 -52
- package/src/demos/Table.md +552 -159
package/src/demos/Table.md
CHANGED
|
@@ -18,6 +18,8 @@ import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLog
|
|
|
18
18
|
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
19
19
|
import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
|
|
20
20
|
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
|
|
21
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
22
|
+
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
21
23
|
|
|
22
24
|
### Bulk select
|
|
23
25
|
|
|
@@ -126,7 +128,6 @@ class BulkSelectTableDemo extends React.Component {
|
|
|
126
128
|
return { isDropDownOpen: !prevState.isDropDownOpen };
|
|
127
129
|
});
|
|
128
130
|
};
|
|
129
|
-
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
fetch(page, perPage) {
|
|
@@ -914,9 +915,7 @@ class ColumnManagementAction extends React.Component {
|
|
|
914
915
|
<DataListItemCells
|
|
915
916
|
dataListCells={[
|
|
916
917
|
<DataListCell id="table-column-management-item1" key="table-column-management-item1">
|
|
917
|
-
<label htmlFor="check1">
|
|
918
|
-
Repositories
|
|
919
|
-
</label>
|
|
918
|
+
<label htmlFor="check1">Repositories</label>
|
|
920
919
|
</DataListCell>
|
|
921
920
|
]}
|
|
922
921
|
/>
|
|
@@ -934,13 +933,11 @@ class ColumnManagementAction extends React.Component {
|
|
|
934
933
|
<DataListItemCells
|
|
935
934
|
dataListCells={[
|
|
936
935
|
<DataListCell id="table-column-management-item2" key="table-column-management-item2">
|
|
937
|
-
<label htmlFor="check2">
|
|
938
|
-
Branches
|
|
939
|
-
</label>
|
|
936
|
+
<label htmlFor="check2">Branches</label>
|
|
940
937
|
</DataListCell>
|
|
941
938
|
]}
|
|
942
939
|
/>
|
|
943
|
-
|
|
940
|
+
</DataListItemRow>
|
|
944
941
|
</DataListItem>
|
|
945
942
|
<DataListItem aria-labelledby="table-column-management-item3">
|
|
946
943
|
<DataListItemRow>
|
|
@@ -954,9 +951,7 @@ class ColumnManagementAction extends React.Component {
|
|
|
954
951
|
<DataListItemCells
|
|
955
952
|
dataListCells={[
|
|
956
953
|
<DataListCell id="table-column-management-item3" key="table-column-management-item3">
|
|
957
|
-
<label htmlFor="check3">
|
|
958
|
-
Pull requests
|
|
959
|
-
</label>
|
|
954
|
+
<label htmlFor="check3">Pull requests</label>
|
|
960
955
|
</DataListCell>
|
|
961
956
|
]}
|
|
962
957
|
/>
|
|
@@ -974,9 +969,7 @@ class ColumnManagementAction extends React.Component {
|
|
|
974
969
|
<DataListItemCells
|
|
975
970
|
dataListCells={[
|
|
976
971
|
<DataListCell id="table-column-management-item4" key="table-column-management-item4">
|
|
977
|
-
<label htmlFor="check4">
|
|
978
|
-
Workspaces
|
|
979
|
-
</label>
|
|
972
|
+
<label htmlFor="check4">Workspaces</label>
|
|
980
973
|
</DataListCell>
|
|
981
974
|
]}
|
|
982
975
|
/>
|
|
@@ -993,11 +986,9 @@ class ColumnManagementAction extends React.Component {
|
|
|
993
986
|
/>
|
|
994
987
|
<DataListItemCells
|
|
995
988
|
dataListCells={[
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
</label>
|
|
1000
|
-
</DataListCell>
|
|
989
|
+
<DataListCell id="table-column-management-item5" key="table-column-management-item5">
|
|
990
|
+
<label htmlFor="check5">Last commit</label>
|
|
991
|
+
</DataListCell>
|
|
1001
992
|
]}
|
|
1002
993
|
/>
|
|
1003
994
|
</DataListItemRow>
|
|
@@ -1424,7 +1415,7 @@ class ColumnManagementAction extends React.Component {
|
|
|
1424
1415
|
check4: true,
|
|
1425
1416
|
check5: true,
|
|
1426
1417
|
liveText: '',
|
|
1427
|
-
id: '',
|
|
1418
|
+
id: '',
|
|
1428
1419
|
itemOrder: ['data1', 'data2', 'data3', 'data4', 'data5']
|
|
1429
1420
|
};
|
|
1430
1421
|
this.onSelect = this.onSelect.bind(this);
|
|
@@ -1501,7 +1492,6 @@ class ColumnManagementAction extends React.Component {
|
|
|
1501
1492
|
this.setState({
|
|
1502
1493
|
[target.name]: value
|
|
1503
1494
|
});
|
|
1504
|
-
|
|
1505
1495
|
};
|
|
1506
1496
|
this.handleModalToggle = () => {
|
|
1507
1497
|
this.setState(({ isModalOpen }) => ({
|
|
@@ -1511,7 +1501,9 @@ class ColumnManagementAction extends React.Component {
|
|
|
1511
1501
|
this.onSave = () => {
|
|
1512
1502
|
const orderedColumns = this.state.itemOrder.map(item => this.matchDataListNameToColumn(item));
|
|
1513
1503
|
// concat empty string at the end for actions column
|
|
1514
|
-
const filteredOrderedColumns = orderedColumns
|
|
1504
|
+
const filteredOrderedColumns = orderedColumns
|
|
1505
|
+
.filter(col => this.state.filteredColumns.indexOf(col) > -1)
|
|
1506
|
+
.concat(['']);
|
|
1515
1507
|
const orderedRows = [];
|
|
1516
1508
|
this.state.filteredRows.forEach(row => {
|
|
1517
1509
|
const updatedCells = row.cells.sort((cellA, cellB) => {
|
|
@@ -1596,7 +1588,7 @@ class ColumnManagementAction extends React.Component {
|
|
|
1596
1588
|
canSelectAll: checked
|
|
1597
1589
|
});
|
|
1598
1590
|
}
|
|
1599
|
-
|
|
1591
|
+
|
|
1600
1592
|
renderModal() {
|
|
1601
1593
|
const { isModalOpen } = this.state;
|
|
1602
1594
|
return (
|
|
@@ -1622,7 +1614,7 @@ class ColumnManagementAction extends React.Component {
|
|
|
1622
1614
|
</Button>
|
|
1623
1615
|
]}
|
|
1624
1616
|
>
|
|
1625
|
-
<DataList
|
|
1617
|
+
<DataList
|
|
1626
1618
|
aria-label="Table column management"
|
|
1627
1619
|
id="table-column-management"
|
|
1628
1620
|
isCompact
|
|
@@ -1635,27 +1627,25 @@ class ColumnManagementAction extends React.Component {
|
|
|
1635
1627
|
<DataListItem aria-labelledby="table-column-management-item1" id="data1">
|
|
1636
1628
|
<DataListItemRow>
|
|
1637
1629
|
<DataListControl>
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1630
|
+
<DataListDragButton
|
|
1631
|
+
aria-label="Reorder"
|
|
1632
|
+
aria-labelledby="table-column-management-item1"
|
|
1633
|
+
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
1634
|
+
aria-pressed="false"
|
|
1635
|
+
/>
|
|
1636
|
+
<DataListCheck
|
|
1637
|
+
aria-labelledby="table-column-management-item1"
|
|
1638
|
+
checked={this.state.check1}
|
|
1639
|
+
name="check1"
|
|
1640
|
+
id="check1"
|
|
1641
|
+
onChange={this.handleChange}
|
|
1642
|
+
otherControls
|
|
1643
|
+
/>
|
|
1644
|
+
</DataListControl>
|
|
1653
1645
|
<DataListItemCells
|
|
1654
1646
|
dataListCells={[
|
|
1655
1647
|
<DataListCell id="table-column-management-item1" key="table-column-management-item1">
|
|
1656
|
-
<label htmlFor="check1">
|
|
1657
|
-
Repositories
|
|
1658
|
-
</label>
|
|
1648
|
+
<label htmlFor="check1">Repositories</label>
|
|
1659
1649
|
</DataListCell>
|
|
1660
1650
|
]}
|
|
1661
1651
|
/>
|
|
@@ -1663,58 +1653,54 @@ class ColumnManagementAction extends React.Component {
|
|
|
1663
1653
|
</DataListItem>
|
|
1664
1654
|
<DataListItem aria-labelledby="table-column-management-item2" id="data2">
|
|
1665
1655
|
<DataListItemRow>
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1656
|
+
<DataListControl>
|
|
1657
|
+
<DataListDragButton
|
|
1658
|
+
aria-label="Reorder"
|
|
1659
|
+
aria-labelledby="table-column-management-item2"
|
|
1660
|
+
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
1661
|
+
aria-pressed="false"
|
|
1662
|
+
/>
|
|
1663
|
+
<DataListCheck
|
|
1664
|
+
aria-labelledby="table-column-management-item2"
|
|
1665
|
+
checked={this.state.check2}
|
|
1666
|
+
name="check2"
|
|
1667
|
+
id="check2"
|
|
1668
|
+
onChange={this.handleChange}
|
|
1669
|
+
otherControls
|
|
1670
|
+
/>
|
|
1681
1671
|
</DataListControl>
|
|
1682
1672
|
<DataListItemCells
|
|
1683
1673
|
dataListCells={[
|
|
1684
1674
|
<DataListCell id="table-column-management-item2" key="table-column-management-item2">
|
|
1685
|
-
<label htmlFor="check2">
|
|
1686
|
-
Branches
|
|
1687
|
-
</label>
|
|
1675
|
+
<label htmlFor="check2">Branches</label>
|
|
1688
1676
|
</DataListCell>
|
|
1689
1677
|
]}
|
|
1690
1678
|
/>
|
|
1691
|
-
|
|
1679
|
+
</DataListItemRow>
|
|
1692
1680
|
</DataListItem>
|
|
1693
1681
|
<DataListItem aria-labelledby="table-column-management-item3" id="data3">
|
|
1694
1682
|
<DataListItemRow>
|
|
1695
1683
|
<DataListControl>
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1684
|
+
<DataListDragButton
|
|
1685
|
+
aria-label="Reorder"
|
|
1686
|
+
aria-labelledby="table-column-management-item3"
|
|
1687
|
+
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
1688
|
+
aria-pressed="false"
|
|
1689
|
+
/>
|
|
1690
|
+
<DataListCheck
|
|
1691
|
+
aria-labelledby="table-column-management-item3"
|
|
1692
|
+
checked={this.state.check3}
|
|
1693
|
+
name="check3"
|
|
1694
|
+
id="check3"
|
|
1695
|
+
onChange={this.handleChange}
|
|
1696
|
+
otherControls
|
|
1697
|
+
/>
|
|
1710
1698
|
</DataListControl>
|
|
1711
1699
|
<DataListItemCells
|
|
1712
1700
|
dataListCells={[
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
</label>
|
|
1717
|
-
</DataListCell>
|
|
1701
|
+
<DataListCell id="table-column-management-item3" key="table-column-management-item3">
|
|
1702
|
+
<label htmlFor="check3">Pull requests</label>
|
|
1703
|
+
</DataListCell>
|
|
1718
1704
|
]}
|
|
1719
1705
|
/>
|
|
1720
1706
|
</DataListItemRow>
|
|
@@ -1728,21 +1714,19 @@ class ColumnManagementAction extends React.Component {
|
|
|
1728
1714
|
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
1729
1715
|
aria-pressed="false"
|
|
1730
1716
|
/>
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1717
|
+
<DataListCheck
|
|
1718
|
+
aria-labelledby="table-column-management-item4"
|
|
1719
|
+
checked={this.state.check4}
|
|
1720
|
+
name="check4"
|
|
1721
|
+
id="check4"
|
|
1722
|
+
onChange={this.handleChange}
|
|
1723
|
+
otherControls
|
|
1724
|
+
/>
|
|
1739
1725
|
</DataListControl>
|
|
1740
1726
|
<DataListItemCells
|
|
1741
1727
|
dataListCells={[
|
|
1742
1728
|
<DataListCell id="table-column-management-item4" key="table-column-management-item4">
|
|
1743
|
-
<label htmlFor="check4">
|
|
1744
|
-
Workspaces
|
|
1745
|
-
</label>
|
|
1729
|
+
<label htmlFor="check4">Workspaces</label>
|
|
1746
1730
|
</DataListCell>
|
|
1747
1731
|
]}
|
|
1748
1732
|
/>
|
|
@@ -1757,21 +1741,19 @@ class ColumnManagementAction extends React.Component {
|
|
|
1757
1741
|
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
1758
1742
|
aria-pressed="false"
|
|
1759
1743
|
/>
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1744
|
+
<DataListCheck
|
|
1745
|
+
aria-labelledby="table-column-management-item5"
|
|
1746
|
+
checked={this.state.check5}
|
|
1747
|
+
name="check5"
|
|
1748
|
+
id="check5"
|
|
1749
|
+
onChange={this.handleChange}
|
|
1750
|
+
otherControls
|
|
1751
|
+
/>
|
|
1768
1752
|
</DataListControl>
|
|
1769
1753
|
<DataListItemCells
|
|
1770
1754
|
dataListCells={[
|
|
1771
1755
|
<DataListCell id="table-column-management-item5" key="table-column-management-item5">
|
|
1772
|
-
<label htmlFor="check5">
|
|
1773
|
-
Last commit
|
|
1774
|
-
</label>
|
|
1756
|
+
<label htmlFor="check5">Last commit</label>
|
|
1775
1757
|
</DataListCell>
|
|
1776
1758
|
]}
|
|
1777
1759
|
/>
|
|
@@ -2201,42 +2183,55 @@ class FilterTableDemo extends React.Component {
|
|
|
2201
2183
|
|
|
2202
2184
|
let tableRows = filteredRows;
|
|
2203
2185
|
if (!loading && filteredRows.length === 0) {
|
|
2204
|
-
tableRows = [
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
<
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2186
|
+
tableRows = [
|
|
2187
|
+
{
|
|
2188
|
+
heightAuto: true,
|
|
2189
|
+
cells: [
|
|
2190
|
+
{
|
|
2191
|
+
props: { colSpan: 8 },
|
|
2192
|
+
title: (
|
|
2193
|
+
<Bullseye>
|
|
2194
|
+
<EmptyState>
|
|
2195
|
+
<EmptyStateIcon icon={SearchIcon} />
|
|
2196
|
+
<Title headingLevel="h5" size="lg">
|
|
2197
|
+
Clear all filters and try again.
|
|
2198
|
+
</Title>
|
|
2199
|
+
<EmptyStateBody>
|
|
2200
|
+
No results match this filter criteria. Remove all filters or clear all filters to show results.
|
|
2201
|
+
</EmptyStateBody>
|
|
2202
|
+
<EmptyStateSecondaryActions>
|
|
2203
|
+
<Button
|
|
2204
|
+
variant="link"
|
|
2205
|
+
onClick={() => {
|
|
2206
|
+
this.onDelete(null);
|
|
2207
|
+
}}
|
|
2208
|
+
>
|
|
2209
|
+
Clear all filters
|
|
2210
|
+
</Button>
|
|
2211
|
+
</EmptyStateSecondaryActions>
|
|
2212
|
+
</EmptyState>
|
|
2213
|
+
</Bullseye>
|
|
2214
|
+
)
|
|
2215
|
+
}
|
|
2216
|
+
]
|
|
2217
|
+
}
|
|
2218
|
+
];
|
|
2228
2219
|
} else if (loading) {
|
|
2229
|
-
tableRows = [
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2220
|
+
tableRows = [
|
|
2221
|
+
{
|
|
2222
|
+
heightAuto: true,
|
|
2223
|
+
cells: [
|
|
2224
|
+
{
|
|
2225
|
+
props: { colSpan: 8 },
|
|
2226
|
+
title: (
|
|
2227
|
+
<Title headingLevel="h2" size="3xl">
|
|
2228
|
+
Please wait while loading data
|
|
2229
|
+
</Title>
|
|
2230
|
+
)
|
|
2231
|
+
}
|
|
2232
|
+
]
|
|
2233
|
+
}
|
|
2234
|
+
];
|
|
2240
2235
|
}
|
|
2241
2236
|
|
|
2242
2237
|
return (
|
|
@@ -2252,6 +2247,402 @@ class FilterTableDemo extends React.Component {
|
|
|
2252
2247
|
}
|
|
2253
2248
|
```
|
|
2254
2249
|
|
|
2250
|
+
### Sortable - responsive
|
|
2251
|
+
|
|
2252
|
+
This is an example of a responive sortable table. When the screen size is small, the table will change to a compact format and a new toolbar item will be displayed to control sorting.
|
|
2253
|
+
|
|
2254
|
+
```js isFullscreen
|
|
2255
|
+
import React from 'react';
|
|
2256
|
+
import {
|
|
2257
|
+
Button,
|
|
2258
|
+
Toolbar,
|
|
2259
|
+
ToolbarContent,
|
|
2260
|
+
ToolbarGroup,
|
|
2261
|
+
ToolbarItem,
|
|
2262
|
+
OptionsMenu,
|
|
2263
|
+
OptionsMenuToggle,
|
|
2264
|
+
Pagination,
|
|
2265
|
+
PaginationVariant,
|
|
2266
|
+
Text,
|
|
2267
|
+
TextContent,
|
|
2268
|
+
Select,
|
|
2269
|
+
SelectVariant,
|
|
2270
|
+
SelectOption,
|
|
2271
|
+
Nav,
|
|
2272
|
+
NavList,
|
|
2273
|
+
NavItem,
|
|
2274
|
+
Dropdown,
|
|
2275
|
+
DropdownItem,
|
|
2276
|
+
DropdownGroup,
|
|
2277
|
+
DropdownToggle,
|
|
2278
|
+
Divider,
|
|
2279
|
+
KebabToggle,
|
|
2280
|
+
Avatar,
|
|
2281
|
+
OptionsMenuItem,
|
|
2282
|
+
OptionsMenuSeparator,
|
|
2283
|
+
OptionsMenuItemGroup,
|
|
2284
|
+
Page,
|
|
2285
|
+
PageSidebar,
|
|
2286
|
+
Masthead,
|
|
2287
|
+
MastheadToggle,
|
|
2288
|
+
PageToggleButton,
|
|
2289
|
+
MastheadMain,
|
|
2290
|
+
MastheadContent,
|
|
2291
|
+
SkipToContent,
|
|
2292
|
+
PageSection
|
|
2293
|
+
} from '@patternfly/react-core';
|
|
2294
|
+
import { TableComposable, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
2295
|
+
|
|
2296
|
+
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
|
|
2297
|
+
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
2298
|
+
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
2299
|
+
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
2300
|
+
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
|
|
2301
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
2302
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
2303
|
+
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
2304
|
+
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
2305
|
+
|
|
2306
|
+
ComposableTableSortable = () => {
|
|
2307
|
+
const [navActiveItem, setNavActiveItem] = React.useState(0);
|
|
2308
|
+
const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
|
|
2309
|
+
const [isKebabDropdownOpen, setIsKebabDropdownOpen] = React.useState(false);
|
|
2310
|
+
const [isSelectOpen, setIsSelectOpen] = React.useState(false);
|
|
2311
|
+
const [isFullKebabDropdownOpen, setIsFullKebabDropdownOpen] = React.useState(false);
|
|
2312
|
+
|
|
2313
|
+
const columns = ['Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'];
|
|
2314
|
+
const [rows, setRows] = React.useState([
|
|
2315
|
+
['one', 'two', 'a', 'four', 'five'],
|
|
2316
|
+
['a', 'two', 'k', 'four', 'five'],
|
|
2317
|
+
['p', 'two', 'b', 'four', 'five']
|
|
2318
|
+
]);
|
|
2319
|
+
// index of the currently active column
|
|
2320
|
+
const [activeSortIndex, setActiveSortIndex] = React.useState(-1);
|
|
2321
|
+
// sort direction of the currently active column
|
|
2322
|
+
const [activeSortDirection, setActiveSortDirection] = React.useState('none');
|
|
2323
|
+
// sort dropdown expansion
|
|
2324
|
+
const [isSortDropdownOpen, setIsSortDropdownOpen] = React.useState(false);
|
|
2325
|
+
|
|
2326
|
+
const onSort = (event, index, direction) => {
|
|
2327
|
+
setActiveSortIndex(index);
|
|
2328
|
+
setActiveSortDirection(direction);
|
|
2329
|
+
console.log('i; ', index, direction);
|
|
2330
|
+
// sorts the rows
|
|
2331
|
+
const updatedRows = rows.sort((a, b) => {
|
|
2332
|
+
if (typeof a[index] === 'number') {
|
|
2333
|
+
// numeric sort
|
|
2334
|
+
if (direction === 'asc') {
|
|
2335
|
+
return a[index] - b[index];
|
|
2336
|
+
}
|
|
2337
|
+
return b[index] - a[index];
|
|
2338
|
+
} else {
|
|
2339
|
+
// string sort
|
|
2340
|
+
if (direction === 'asc') {
|
|
2341
|
+
return a[index].localeCompare(b[index]);
|
|
2342
|
+
}
|
|
2343
|
+
return b[index].localeCompare(a[index]);
|
|
2344
|
+
}
|
|
2345
|
+
});
|
|
2346
|
+
setRows(updatedRows);
|
|
2347
|
+
};
|
|
2348
|
+
|
|
2349
|
+
const PageNav = (
|
|
2350
|
+
<Nav onSelect={result => setNavActiveItem(result.itemId)} aria-label="Nav">
|
|
2351
|
+
<NavList>
|
|
2352
|
+
<NavItem itemId={0} isActive={navActiveItem === 0} to="#system-panel">
|
|
2353
|
+
System Panel
|
|
2354
|
+
</NavItem>
|
|
2355
|
+
<NavItem itemId={1} isActive={navActiveItem === 1} to="#policy">
|
|
2356
|
+
Policy
|
|
2357
|
+
</NavItem>
|
|
2358
|
+
<NavItem itemId={2} isActive={navActiveItem === 2} to="#auth">
|
|
2359
|
+
Authentication
|
|
2360
|
+
</NavItem>
|
|
2361
|
+
<NavItem itemId={3} isActive={navActiveItem === 3} to="#network">
|
|
2362
|
+
Network Services
|
|
2363
|
+
</NavItem>
|
|
2364
|
+
<NavItem itemId={4} isActive={navActiveItem === 4} to="#server">
|
|
2365
|
+
Server
|
|
2366
|
+
</NavItem>
|
|
2367
|
+
</NavList>
|
|
2368
|
+
</Nav>
|
|
2369
|
+
);
|
|
2370
|
+
|
|
2371
|
+
const kebabDropdownItems = [
|
|
2372
|
+
<DropdownItem key="kebab-1">
|
|
2373
|
+
<CogIcon /> Settings
|
|
2374
|
+
</DropdownItem>,
|
|
2375
|
+
<DropdownItem key="kebab-2">
|
|
2376
|
+
<HelpIcon /> Help
|
|
2377
|
+
</DropdownItem>
|
|
2378
|
+
];
|
|
2379
|
+
const userDropdownItems = [
|
|
2380
|
+
<DropdownGroup key="group 2">
|
|
2381
|
+
<DropdownItem key="group 2 profile">My profile</DropdownItem>
|
|
2382
|
+
<DropdownItem key="group 2 user" component="button">
|
|
2383
|
+
User management
|
|
2384
|
+
</DropdownItem>
|
|
2385
|
+
<DropdownItem key="group 2 logout">Logout</DropdownItem>
|
|
2386
|
+
</DropdownGroup>
|
|
2387
|
+
];
|
|
2388
|
+
|
|
2389
|
+
const fullKebabItems = [
|
|
2390
|
+
<DropdownGroup key="group 2">
|
|
2391
|
+
<DropdownItem key="group 2 profile">My profile</DropdownItem>
|
|
2392
|
+
<DropdownItem key="group 2 user" component="button">
|
|
2393
|
+
User management
|
|
2394
|
+
</DropdownItem>
|
|
2395
|
+
<DropdownItem key="group 2 logout">Logout</DropdownItem>
|
|
2396
|
+
</DropdownGroup>,
|
|
2397
|
+
<Divider key="divider" />,
|
|
2398
|
+
<DropdownItem key="kebab-1">
|
|
2399
|
+
<CogIcon /> Settings
|
|
2400
|
+
</DropdownItem>,
|
|
2401
|
+
<DropdownItem key="kebab-2">
|
|
2402
|
+
<HelpIcon /> Help
|
|
2403
|
+
</DropdownItem>
|
|
2404
|
+
];
|
|
2405
|
+
|
|
2406
|
+
const headerToolbar = (
|
|
2407
|
+
<Toolbar id="toolbar" isFullHeight isStatic>
|
|
2408
|
+
<ToolbarContent>
|
|
2409
|
+
<ToolbarGroup
|
|
2410
|
+
variant="icon-button-group"
|
|
2411
|
+
alignment={{ default: 'alignRight' }}
|
|
2412
|
+
spacer={{ default: 'spacerNone', md: 'spacerMd' }}
|
|
2413
|
+
>
|
|
2414
|
+
<ToolbarItem>
|
|
2415
|
+
<Button aria-label="Notifications" variant={ButtonVariant.plain}>
|
|
2416
|
+
<AttentionBellIcon />
|
|
2417
|
+
</Button>
|
|
2418
|
+
</ToolbarItem>
|
|
2419
|
+
<ToolbarGroup variant="icon-button-group" visibility={{ default: 'hidden', lg: 'visible' }}>
|
|
2420
|
+
<ToolbarItem>
|
|
2421
|
+
<Button aria-label="Settings actions" variant={ButtonVariant.plain}>
|
|
2422
|
+
<CogIcon />
|
|
2423
|
+
</Button>
|
|
2424
|
+
</ToolbarItem>
|
|
2425
|
+
<ToolbarItem>
|
|
2426
|
+
<Button aria-label="Help actions" variant={ButtonVariant.plain}>
|
|
2427
|
+
<HelpIcon />
|
|
2428
|
+
</Button>
|
|
2429
|
+
</ToolbarItem>
|
|
2430
|
+
</ToolbarGroup>
|
|
2431
|
+
</ToolbarGroup>
|
|
2432
|
+
<ToolbarItem visibility={{ default: 'hidden', md: 'visible', lg: 'hidden' }}>
|
|
2433
|
+
<Dropdown
|
|
2434
|
+
isPlain
|
|
2435
|
+
position="right"
|
|
2436
|
+
onSelect={() => setIsKebabDropdownOpen(!isKebabDropdownOpen)}
|
|
2437
|
+
toggle={<KebabToggle onToggle={() => setIsKebabDropdownOpen(!isKebabDropdownOpen)} />}
|
|
2438
|
+
isOpen={isKebabDropdownOpen}
|
|
2439
|
+
dropdownItems={kebabDropdownItems}
|
|
2440
|
+
/>
|
|
2441
|
+
</ToolbarItem>
|
|
2442
|
+
<ToolbarItem visibility={{ default: 'visible', md: 'hidden', lg: 'hidden', xl: 'hidden', '2xl': 'hidden' }}>
|
|
2443
|
+
<Dropdown
|
|
2444
|
+
isPlain
|
|
2445
|
+
position="right"
|
|
2446
|
+
onSelect={() => setIsFullKebabDropdownOpen(!isFullKebabDropdownOpen)}
|
|
2447
|
+
toggle={<KebabToggle onToggle={() => setIsFullKebabDropdownOpen(!isFullKebabDropdownOpen)} />}
|
|
2448
|
+
isOpen={isFullKebabDropdownOpen}
|
|
2449
|
+
dropdownItems={fullKebabItems}
|
|
2450
|
+
/>
|
|
2451
|
+
</ToolbarItem>
|
|
2452
|
+
<ToolbarItem visibility={{ default: 'hidden', md: 'visible' }}>
|
|
2453
|
+
<Dropdown
|
|
2454
|
+
position="right"
|
|
2455
|
+
onSelect={() => setIsDropdownOpen(!isDropdownOpen)}
|
|
2456
|
+
isOpen={isDropdownOpen}
|
|
2457
|
+
toggle={
|
|
2458
|
+
<DropdownToggle
|
|
2459
|
+
icon={<Avatar src={imgAvatar} alt="Avatar" />}
|
|
2460
|
+
onToggle={() => setIsDropdownOpen(!isDropdownOpen)}
|
|
2461
|
+
>
|
|
2462
|
+
John Smith
|
|
2463
|
+
</DropdownToggle>
|
|
2464
|
+
}
|
|
2465
|
+
dropdownItems={userDropdownItems}
|
|
2466
|
+
/>
|
|
2467
|
+
</ToolbarItem>
|
|
2468
|
+
</ToolbarContent>
|
|
2469
|
+
</Toolbar>
|
|
2470
|
+
);
|
|
2471
|
+
|
|
2472
|
+
const tableToolbar = (
|
|
2473
|
+
<Toolbar id="sortable-toolbar">
|
|
2474
|
+
<ToolbarContent>
|
|
2475
|
+
<ToolbarItem>
|
|
2476
|
+
<Select
|
|
2477
|
+
id="select-example"
|
|
2478
|
+
variant={SelectVariant.single}
|
|
2479
|
+
aria-label="Select Input"
|
|
2480
|
+
placeholderText={
|
|
2481
|
+
<>
|
|
2482
|
+
<FilterIcon /> Status
|
|
2483
|
+
</>
|
|
2484
|
+
}
|
|
2485
|
+
isOpen={isSelectOpen}
|
|
2486
|
+
onToggle={() => setIsSelectOpen(!isSelectOpen)}
|
|
2487
|
+
onSelect={() => setIsSelectOpen(!isSelectOpen)}
|
|
2488
|
+
>
|
|
2489
|
+
{[
|
|
2490
|
+
<SelectOption key={0} value="Debug" />,
|
|
2491
|
+
<SelectOption key={1} value="Info" />,
|
|
2492
|
+
<SelectOption key={2} value="Warn" />,
|
|
2493
|
+
<SelectOption key={3} value="Error" />
|
|
2494
|
+
]}
|
|
2495
|
+
</Select>
|
|
2496
|
+
</ToolbarItem>
|
|
2497
|
+
<ToolbarItem visibility={{ default: 'hidden', sm: 'visible', md: 'hidden' }}>
|
|
2498
|
+
<OptionsMenu
|
|
2499
|
+
id="options-menu-multiple-options-example"
|
|
2500
|
+
menuItems={[
|
|
2501
|
+
<OptionsMenuItemGroup key="first group" aria-label="Sort column">
|
|
2502
|
+
{columns.map((column, columnIndex) => (
|
|
2503
|
+
<OptionsMenuItem
|
|
2504
|
+
key={column}
|
|
2505
|
+
isSelected={activeSortIndex === columnIndex}
|
|
2506
|
+
onSelect={evt =>
|
|
2507
|
+
onSort(evt, columnIndex, activeSortDirection !== 'none' ? activeSortDirection : 'asc')
|
|
2508
|
+
}
|
|
2509
|
+
>
|
|
2510
|
+
{column}
|
|
2511
|
+
</OptionsMenuItem>
|
|
2512
|
+
))}
|
|
2513
|
+
</OptionsMenuItemGroup>,
|
|
2514
|
+
<OptionsMenuSeparator key="separator" />,
|
|
2515
|
+
<OptionsMenuItemGroup key="second group" aria-label="Sort direction">
|
|
2516
|
+
<OptionsMenuItem
|
|
2517
|
+
onSelect={evt => onSort(evt, activeSortIndex, 'asc')}
|
|
2518
|
+
isSelected={activeSortDirection === 'asc'}
|
|
2519
|
+
id="ascending"
|
|
2520
|
+
key="ascending"
|
|
2521
|
+
>
|
|
2522
|
+
Ascending
|
|
2523
|
+
</OptionsMenuItem>
|
|
2524
|
+
<OptionsMenuItem
|
|
2525
|
+
onSelect={evt => onSort(evt, activeSortIndex, 'desc')}
|
|
2526
|
+
isSelected={activeSortDirection === 'desc'}
|
|
2527
|
+
id="descending"
|
|
2528
|
+
key="descending"
|
|
2529
|
+
>
|
|
2530
|
+
Descending
|
|
2531
|
+
</OptionsMenuItem>
|
|
2532
|
+
</OptionsMenuItemGroup>
|
|
2533
|
+
]}
|
|
2534
|
+
isOpen={isSortDropdownOpen}
|
|
2535
|
+
toggle={
|
|
2536
|
+
<OptionsMenuToggle
|
|
2537
|
+
hideCaret
|
|
2538
|
+
onToggle={() => setIsSortDropdownOpen(!isSortDropdownOpen)}
|
|
2539
|
+
toggleTemplate={<SortAmountDownIcon />}
|
|
2540
|
+
/>
|
|
2541
|
+
}
|
|
2542
|
+
isPlain
|
|
2543
|
+
isGrouped
|
|
2544
|
+
/>
|
|
2545
|
+
</ToolbarItem>
|
|
2546
|
+
<ToolbarGroup>
|
|
2547
|
+
<ToolbarItem>
|
|
2548
|
+
<Button variant="primary">Action</Button>
|
|
2549
|
+
</ToolbarItem>
|
|
2550
|
+
<ToolbarItem visibility={{ default: 'visible', sm: 'hidden', md: 'visible' }}>
|
|
2551
|
+
<Button variant="primary">Responsive hidden action on small</Button>
|
|
2552
|
+
</ToolbarItem>
|
|
2553
|
+
</ToolbarGroup>
|
|
2554
|
+
<ToolbarItem variant="pagination">
|
|
2555
|
+
<Pagination
|
|
2556
|
+
itemCount={37}
|
|
2557
|
+
widgetId="pagination-options-menu-bottom"
|
|
2558
|
+
page={1}
|
|
2559
|
+
variant={PaginationVariant.top}
|
|
2560
|
+
isCompact
|
|
2561
|
+
/>
|
|
2562
|
+
</ToolbarItem>
|
|
2563
|
+
</ToolbarContent>
|
|
2564
|
+
</Toolbar>
|
|
2565
|
+
);
|
|
2566
|
+
|
|
2567
|
+
return (
|
|
2568
|
+
<React.Fragment>
|
|
2569
|
+
<Page
|
|
2570
|
+
header={
|
|
2571
|
+
<Masthead>
|
|
2572
|
+
<MastheadToggle>
|
|
2573
|
+
<PageToggleButton variant="plain" aria-label="Global navigation">
|
|
2574
|
+
<BarsIcon />
|
|
2575
|
+
</PageToggleButton>
|
|
2576
|
+
</MastheadToggle>
|
|
2577
|
+
<MastheadMain></MastheadMain>
|
|
2578
|
+
<MastheadContent>{headerToolbar}</MastheadContent>
|
|
2579
|
+
</Masthead>
|
|
2580
|
+
}
|
|
2581
|
+
sidebar={<PageSidebar nav={PageNav} />}
|
|
2582
|
+
isManagedSidebar
|
|
2583
|
+
skipToContent={<SkipToContent href={'#main-content-page-layout-default-nav'}>Skip to content</SkipToContent>}
|
|
2584
|
+
mainContainerId={'main-content-page-layout-default-nav'}
|
|
2585
|
+
>
|
|
2586
|
+
<PageSection variant={PageSectionVariants.light}>
|
|
2587
|
+
<TextContent>
|
|
2588
|
+
<Text component="h1">Table demos</Text>
|
|
2589
|
+
<Text component="p">
|
|
2590
|
+
Below is an example of a responsive sortable table. When the screen size shrinks the table into a compact
|
|
2591
|
+
form, the toolbar will display a dropdown menu containing sorting options.
|
|
2592
|
+
</Text>
|
|
2593
|
+
</TextContent>
|
|
2594
|
+
</PageSection>
|
|
2595
|
+
<PageSection isFilled>
|
|
2596
|
+
{tableToolbar}
|
|
2597
|
+
<TableComposable aria-label="Sortable Table">
|
|
2598
|
+
<Thead>
|
|
2599
|
+
<Tr>
|
|
2600
|
+
{columns.map((column, columnIndex) => {
|
|
2601
|
+
const sortParams = {
|
|
2602
|
+
sort: {
|
|
2603
|
+
sortBy: {
|
|
2604
|
+
index: activeSortIndex,
|
|
2605
|
+
direction: activeSortDirection
|
|
2606
|
+
},
|
|
2607
|
+
onSort,
|
|
2608
|
+
columnIndex
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
const infoParams =
|
|
2612
|
+
columnIndex === 2
|
|
2613
|
+
? {
|
|
2614
|
+
info: {
|
|
2615
|
+
tooltip: 'More information'
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
: {};
|
|
2619
|
+
return (
|
|
2620
|
+
<Th key={columnIndex} {...sortParams} {...infoParams}>
|
|
2621
|
+
{column}
|
|
2622
|
+
</Th>
|
|
2623
|
+
);
|
|
2624
|
+
})}
|
|
2625
|
+
</Tr>
|
|
2626
|
+
</Thead>
|
|
2627
|
+
<Tbody>
|
|
2628
|
+
{rows.map((row, rowIndex) => (
|
|
2629
|
+
<Tr key={rowIndex}>
|
|
2630
|
+
{row.map((cell, cellIndex) => (
|
|
2631
|
+
<Td key={`${rowIndex}_${cellIndex}`} dataLabel={columns[cellIndex]}>
|
|
2632
|
+
{cell}
|
|
2633
|
+
</Td>
|
|
2634
|
+
))}
|
|
2635
|
+
</Tr>
|
|
2636
|
+
))}
|
|
2637
|
+
</Tbody>
|
|
2638
|
+
</TableComposable>
|
|
2639
|
+
</PageSection>
|
|
2640
|
+
</Page>
|
|
2641
|
+
</React.Fragment>
|
|
2642
|
+
);
|
|
2643
|
+
};
|
|
2644
|
+
```
|
|
2645
|
+
|
|
2255
2646
|
### Automatic pagination
|
|
2256
2647
|
|
|
2257
2648
|
The below example illustrates the `defaultToFullPage` prop, which makes the following changes when the user sets the number of items to display per page to an amount that exceeds the remaining amount of data:
|
|
@@ -2794,28 +3185,30 @@ class EmptyStateDemo extends React.Component {
|
|
|
2794
3185
|
{ title: 'Location' }
|
|
2795
3186
|
];
|
|
2796
3187
|
|
|
2797
|
-
const rows = [
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
3188
|
+
const rows = [
|
|
3189
|
+
{
|
|
3190
|
+
heightAuto: true,
|
|
3191
|
+
cells: [
|
|
3192
|
+
{
|
|
3193
|
+
props: { colSpan: 8 },
|
|
3194
|
+
title: (
|
|
3195
|
+
<EmptyState>
|
|
3196
|
+
<EmptyStateIcon icon={SearchIcon} />
|
|
3197
|
+
<Title headingLevel="h5" size="lg">
|
|
3198
|
+
No results found
|
|
3199
|
+
</Title>
|
|
3200
|
+
<EmptyStateBody>No results match this filter criteria. Clear all filters and try again.</EmptyStateBody>
|
|
3201
|
+
<EmptyStateSecondaryActions>
|
|
3202
|
+
<Button variant="link" onClick={() => {}}>
|
|
3203
|
+
Clear all filters
|
|
3204
|
+
</Button>
|
|
3205
|
+
</EmptyStateSecondaryActions>
|
|
3206
|
+
</EmptyState>
|
|
3207
|
+
)
|
|
3208
|
+
}
|
|
3209
|
+
]
|
|
3210
|
+
}
|
|
3211
|
+
];
|
|
2819
3212
|
|
|
2820
3213
|
return (
|
|
2821
3214
|
<Table cells={columns} rows={rows} aria-label="Empty state demo">
|