@patternfly/react-docs 5.22.11 → 5.23.3

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.
@@ -586,7 +586,7 @@ pageData.examples = {
586
586
 
587
587
  </Example>,
588
588
  'Footer': props =>
589
- <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';\nimport { Select, SelectOption, SelectVariant, SelectDirection, Checkbox, Divider, Button } from '@patternfly/react-core';\n\nclass SelectWithFooter extends React.Component {\n constructor(props) {\n super(props);\n this.options = [\n <SelectOption key={0} value=\"Select a title\" isPlaceholder />,\n <SelectOption key={1} value=\"Mr\" />,\n <SelectOption key={2} value=\"Miss\" />,\n <SelectOption key={3} value=\"Mrs\" />,\n <SelectOption key={4} value=\"Ms\" />,\n <Divider component=\"li\" key={5} />,\n <SelectOption key={6} value=\"Dr\" />,\n <SelectOption key={7} value=\"Other\" />\n ];\n\n this.state = {\n isToggleIcon: false,\n isOpen: false,\n selected: null,\n isDisabled: false,\n direction: SelectDirection.down\n };\n\n this.onToggle = isOpen => {\n this.setState({\n isOpen\n });\n };\n\n this.onSelect = (event, selection, isPlaceholder) => {\n if (isPlaceholder) this.clearSelection();\n else {\n this.setState({\n selected: selection,\n isOpen: false\n });\n console.log('selected:', selection);\n }\n };\n\n this.clearSelection = () => {\n this.setState({\n selected: null,\n isOpen: false\n });\n };\n }\n\n\n\n render() {\n const { isOpen, selected, isDisabled, direction, isToggleIcon } = this.state;\n const titleId = 'title-id-footer';\n return (\n <div>\n <span id={titleId} hidden>\n Title\n </span>\n <Select\n toggleIcon={isToggleIcon && <CubeIcon />}\n variant={SelectVariant.single}\n aria-label=\"Select Input\"\n onToggle={this.onToggle}\n onSelect={this.onSelect}\n selections={selected}\n isOpen={isOpen}\n aria-labelledby={titleId}\n isDisabled={isDisabled}\n direction={direction}\n footer={<Button variant=\"link\" isInline>Action</Button>}\n >\n {this.options}\n </Select>\n </div>\n );\n }\n}","title":"Footer","lang":"js"}}>
589
+ <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';\nimport { Select, SelectOption, SelectVariant, SelectDirection, Divider, Button } from '@patternfly/react-core';\n\nclass SelectWithFooter extends React.Component {\n constructor(props) {\n super(props);\n this.options = [\n <SelectOption key={0} value=\"Select a title\" isPlaceholder />,\n <SelectOption key={1} value=\"Mr\" />,\n <SelectOption key={2} value=\"Miss\" />,\n <SelectOption key={3} value=\"Mrs\" />,\n <SelectOption key={4} value=\"Ms\" />,\n <Divider component=\"li\" key={5} />,\n <SelectOption key={6} value=\"Dr\" />,\n <SelectOption key={7} value=\"Other\" />\n ];\n\n this.state = {\n isToggleIcon: false,\n isOpen: false,\n selected: null,\n isDisabled: false,\n direction: SelectDirection.down\n };\n\n this.onToggle = isOpen => {\n this.setState({\n isOpen\n });\n };\n\n this.onSelect = (event, selection, isPlaceholder) => {\n if (isPlaceholder) this.clearSelection();\n else {\n this.setState({\n selected: selection,\n isOpen: false\n });\n console.log('selected:', selection);\n }\n };\n\n this.clearSelection = () => {\n this.setState({\n selected: null,\n isOpen: false\n });\n };\n }\n\n\n\n render() {\n const { isOpen, selected, isDisabled, direction, isToggleIcon } = this.state;\n const titleId = 'title-id-footer';\n return (\n <div>\n <span id={titleId} hidden>\n Title\n </span>\n <Select\n toggleIcon={isToggleIcon && <CubeIcon />}\n variant={SelectVariant.single}\n aria-label=\"Select Input\"\n onToggle={this.onToggle}\n onSelect={this.onSelect}\n selections={selected}\n isOpen={isOpen}\n aria-labelledby={titleId}\n isDisabled={isDisabled}\n direction={direction}\n footer={<Button variant=\"link\" isInline>Action</Button>}\n >\n {this.options}\n </Select>\n </div>\n );\n }\n}","title":"Footer","lang":"js"}}>
590
590
 
591
591
  </Example>,
592
592
  'Footer with checkboxes': props =>
@@ -7,7 +7,7 @@ import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
7
7
  import LeafIcon from '@patternfly/react-icons/dist/esm/icons/leaf-icon';
8
8
  import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon';
9
9
  import FolderOpenIcon from '@patternfly/react-icons/dist/esm/icons/folder-open-icon';
10
- import { Checkbox, ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
10
+ import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
11
11
  import { css } from '@patternfly/react-styles';
12
12
  import styles from '@patternfly/react-styles/css/components/Table/table';
13
13
  import DemoSortableTable from '../../../../../react-table/src/components/TableComposable/examples/./DemoSortableTable';
@@ -801,6 +801,7 @@ const pageData = {
801
801
  "Composable: Basic",
802
802
  "Composable: Custom row wrapper, header tooltips & popovers",
803
803
  "Composable: Sortable & wrapping headers",
804
+ "Composable: Sortable - custom control",
804
805
  "Composable: Selectable with checkbox",
805
806
  "Composable: Selectable radio input",
806
807
  "Composable: Row click handler, hoverable & selected rows",
@@ -823,9 +824,7 @@ pageData.liveContext = {
823
824
  LeafIcon,
824
825
  FolderIcon,
825
826
  FolderOpenIcon,
826
- Checkbox,
827
- ToggleGroup,
828
- ToggleGroupItem,
827
+ SortAmountDownIcon,
829
828
  css,
830
829
  styles,
831
830
  DemoSortableTable
@@ -836,7 +835,7 @@ pageData.examples = {
836
835
 
837
836
  </Example>,
838
837
  'Composable: Custom row wrapper, header tooltips & popovers': props =>
839
- <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { TableComposable, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';\n\nComposableTableMisc = () => {\n const columns = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit'];\n const rows = [\n ['one', 'two', 'three', 'four', 'five'],\n [{ title: 'one - 2', colSpan: 3 }, null, null, 'four - 2', 'five - 2'],\n ['one - 3', 'two - 3', 'three - 3', 'four - 3', { title: 'five - 3 (not centered)', textCenter: false }]\n ];\n \n return (\n <TableComposable aria-label=\"Misc table\">\n <Thead noWrap>\n <Tr>\n <Th\n info={{\n tooltip: 'More information about repositories',\n className: 'repositories-info-tip',\n tooltipProps: {\n isContentLeftAligned: true\n }\n }}\n >\n {columns[0]}\n </Th>\n <Th>{columns[1]}</Th>\n <Th\n info={{\n popover: (\n <div>\n More <strong>information</strong> on pull requests\n </div>\n ),\n ariaLabel: 'More information on pull requests',\n popoverProps: {\n headerContent: 'Pull requests',\n footerContent: <a href=\"\">Click here for even more info</a>\n }\n }}\n >\n {columns[2]}\n </Th>\n <Th>{columns[3]}</Th>\n <Th textCenter>{columns[4]}</Th>\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => {\n const isOddRow = (rowIndex + 1) % 2;\n const customStyle = {\n borderLeft: '3px solid var(--pf-global--primary-color--100)'\n };\n return (\n <Tr\n key={rowIndex}\n className={isOddRow ? 'odd-row-class' : 'even-row-class'}\n style={isOddRow ? customStyle : {}}\n >\n {row.map((cell, cellIndex) => {\n if (!cell) {\n return null;\n }\n let cellObject;\n if (typeof cell !== 'object') {\n cellObject = {\n title: cell\n };\n } else {\n cellObject = cell;\n }\n const { title, ...rest } = cellObject;\n return (\n <Td\n key={`${rowIndex}_${cellIndex}`}\n dataLabel={columns[cellIndex]}\n textCenter={cellIndex === row.length - 1}\n {...rest}\n >\n {title}\n </Td>\n );\n })}\n </Tr>\n );\n })}\n </Tbody>\n </TableComposable>\n );\n};","title":"Composable: Custom row wrapper, header tooltips & popovers","lang":"js"}}>
838
+ <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { TableComposable, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';\n\nComposableTableMisc = () => {\n const columns = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit'];\n const rows = [\n ['one', 'two', 'three', 'four', 'five'],\n [{ title: 'one - 2', colSpan: 3 }, null, null, 'four - 2', 'five - 2'],\n ['one - 3', 'two - 3', 'three - 3', 'four - 3', { title: 'five - 3 (not centered)', textCenter: false }]\n ];\n\n return (\n <TableComposable aria-label=\"Misc table\">\n <Thead noWrap>\n <Tr>\n <Th\n info={{\n tooltip: 'More information about repositories',\n className: 'repositories-info-tip',\n tooltipProps: {\n isContentLeftAligned: true\n }\n }}\n >\n {columns[0]}\n </Th>\n <Th>{columns[1]}</Th>\n <Th\n info={{\n popover: (\n <div>\n More <strong>information</strong> on pull requests\n </div>\n ),\n ariaLabel: 'More information on pull requests',\n popoverProps: {\n headerContent: 'Pull requests',\n footerContent: <a href=\"\">Click here for even more info</a>\n }\n }}\n >\n {columns[2]}\n </Th>\n <Th>{columns[3]}</Th>\n <Th textCenter>{columns[4]}</Th>\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => {\n const isOddRow = (rowIndex + 1) % 2;\n const customStyle = {\n borderLeft: '3px solid var(--pf-global--primary-color--100)'\n };\n return (\n <Tr\n key={rowIndex}\n className={isOddRow ? 'odd-row-class' : 'even-row-class'}\n style={isOddRow ? customStyle : {}}\n >\n {row.map((cell, cellIndex) => {\n if (!cell) {\n return null;\n }\n let cellObject;\n if (typeof cell !== 'object') {\n cellObject = {\n title: cell\n };\n } else {\n cellObject = cell;\n }\n const { title, ...rest } = cellObject;\n return (\n <Td\n key={`${rowIndex}_${cellIndex}`}\n dataLabel={columns[cellIndex]}\n textCenter={cellIndex === row.length - 1}\n {...rest}\n >\n {title}\n </Td>\n );\n })}\n </Tr>\n );\n })}\n </Tbody>\n </TableComposable>\n );\n};","title":"Composable: Custom row wrapper, header tooltips & popovers","lang":"js"}}>
840
839
 
841
840
  <ul {...{"className":"ws-ul"}}>
842
841
 
@@ -957,9 +956,40 @@ pageData.examples = {
957
956
  <Example {...{"code":"type OnSort = (\n event: React.MouseEvent,\n columnIndex: number,\n sortByDirection: SortByDirection,\n extraData: IExtraColumnData\n) => void;"}}>
958
957
 
959
958
  </Example>
959
+
960
+ <p {...{"className":"ws-p"}}>
961
+ {`The built in display for sorting is not fully responsive, as the column headers will be displayed per row when the screen size is small. To see a full page demo of a responsive sortable table, utilizing a toolbar item to control sorting for small screens, view the `}
962
+
963
+ <code {...{"className":"ws-code"}}>
964
+ {`Sortable - responsive`}
965
+ </code>
966
+ {` demo in the `}
967
+
968
+ <code {...{"className":"ws-code"}}>
969
+ {`React demos`}
970
+ </code>
971
+ {` tab.`}
972
+ </p>
973
+ </Example>,
974
+ 'Composable: Sortable - custom control': props =>
975
+ <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { TableComposable, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';\nimport {\n Toolbar,\n ToolbarItem,\n ToolbarContent,\n OptionsMenu,\n OptionsMenuItemGroup,\n OptionsMenuItem,\n OptionsMenuSeparator,\n OptionsMenuToggle\n} from '@patternfly/react-core';\nimport SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';\n\nComposableTableSortable = () => {\n const columns = ['Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'];\n const [rows, setRows] = React.useState([\n ['one', 'two', 'a', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['p', 'two', 'b', 'four', 'five']\n ]);\n // index of the currently active column\n const [activeSortIndex, setActiveSortIndex] = React.useState(-1);\n // sort direction of the currently active column\n const [activeSortDirection, setActiveSortDirection] = React.useState('none');\n // sort dropdown expansion\n const [isSortDropdownOpen, setIsSortDropdownOpen] = React.useState(false);\n const onSort = (event, index, direction) => {\n setActiveSortIndex(index);\n setActiveSortDirection(direction);\n console.log('i; ', index, direction);\n // sorts the rows\n const updatedRows = rows.sort((a, b) => {\n if (typeof a[index] === 'number') {\n // numeric sort\n if (direction === 'asc') {\n return a[index] - b[index];\n }\n return b[index] - a[index];\n } else {\n // string sort\n if (direction === 'asc') {\n return a[index].localeCompare(b[index]);\n }\n return b[index].localeCompare(a[index]);\n }\n });\n setRows(updatedRows);\n };\n return (\n <React.Fragment>\n <Toolbar id=\"toolbar\">\n <ToolbarContent>\n <ToolbarItem>\n <OptionsMenu\n id=\"options-menu-multiple-options-example\"\n menuItems={[\n <OptionsMenuItemGroup key=\"first group\" aria-label=\"Sort column\">\n {columns.map((column, columnIndex) => (\n <OptionsMenuItem\n key={column}\n isSelected={activeSortIndex === columnIndex}\n onSelect={evt =>\n onSort(evt, columnIndex, activeSortDirection !== 'none' ? activeSortDirection : 'asc')\n }\n >\n {column}\n </OptionsMenuItem>\n ))}\n </OptionsMenuItemGroup>,\n <OptionsMenuSeparator key=\"separator\" />,\n <OptionsMenuItemGroup key=\"second group\" aria-label=\"Sort direction\">\n <OptionsMenuItem\n onSelect={evt => onSort(evt, activeSortIndex, 'asc')}\n isSelected={activeSortDirection === 'asc'}\n id=\"ascending\"\n key=\"ascending\"\n >\n Ascending\n </OptionsMenuItem>\n <OptionsMenuItem\n onSelect={evt => onSort(evt, activeSortIndex, 'desc')}\n isSelected={activeSortDirection === 'desc'}\n id=\"descending\"\n key=\"descending\"\n >\n Descending\n </OptionsMenuItem>\n </OptionsMenuItemGroup>\n ]}\n isOpen={isSortDropdownOpen}\n toggle={\n <OptionsMenuToggle\n hideCaret\n onToggle={() => setIsSortDropdownOpen(!isSortDropdownOpen)}\n toggleTemplate={<SortAmountDownIcon />}\n />\n }\n isPlain\n isGrouped\n />\n </ToolbarItem>\n </ToolbarContent>\n </Toolbar>\n <TableComposable aria-label=\"Sortable Table\">\n <Thead>\n <Tr>\n {columns.map((column, columnIndex) => {\n const sortParams = {\n sort: {\n sortBy: {\n index: activeSortIndex,\n direction: activeSortDirection\n },\n onSort,\n columnIndex\n }\n };\n const infoParams =\n columnIndex === 2\n ? {\n info: {\n tooltip: 'More information'\n }\n }\n : {};\n return (\n <Th key={columnIndex} {...sortParams} {...infoParams}>\n {column}\n </Th>\n );\n })}\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => (\n <Tr key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <Td key={`${rowIndex}_${cellIndex}`} dataLabel={columns[cellIndex]}>\n {cell}\n </Td>\n ))}\n </Tr>\n ))}\n </Tbody>\n </TableComposable>\n </React.Fragment>\n );\n};","title":"Composable: Sortable - custom control","lang":"js"}}>
976
+
977
+ <p {...{"className":"ws-p"}}>
978
+ {`Sorting a table may also be controlled manually with a toolbar control. To see a full page demo of a responsive table, view the `}
979
+
980
+ <code {...{"className":"ws-code"}}>
981
+ {`Sortable - responsive`}
982
+ </code>
983
+ {` demo in the `}
984
+
985
+ <code {...{"className":"ws-code"}}>
986
+ {`React demos`}
987
+ </code>
988
+ {` tab.`}
989
+ </p>
960
990
  </Example>,
961
991
  'Composable: Selectable with checkbox': props =>
962
- <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { TableComposable, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';\n\nComposableTableSelectable = () => {\n const columns = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit'];\n const rows = [\n ['one', 'two', 'a', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['p', 'two', 'b', 'four', 'five']\n ];\n const [allRowsSelected, setAllRowsSelected] = React.useState(false);\n const [selected, setSelected] = React.useState(rows.map(row => false));\n const [recentSelection, setRecentSelection] = React.useState(null);\n const [shifting, setShifting] = React.useState(false);\n const onSelect = (event, isSelected, rowId) => {\n let newSelected = selected.map((sel, index) => (index === rowId ? isSelected : sel))\n \n // if the user is shift + selecting the checkboxes, then all intermediate checkboxes should be selected\n if (shifting && recentSelection !== null && isSelected) {\n const numberSelected = rowId - recentSelection;\n newSelected = newSelected.map((sel, index) => {\n // select all between recentSelection and current rowId;\n const intermediateIndexes = numberSelected > 0 ? \n Array.from(new Array(numberSelected + 1), (x, i) => i + (recentSelection)) : \n Array.from(new Array(Math.abs(numberSelected) + 1), (x, i) => i + rowId);\n return intermediateIndexes.includes(index) ? true : sel;\n })\n }\n setSelected(newSelected);\n setRecentSelection(rowId);\n \n if (!isSelected && allRowsSelected) {\n setAllRowsSelected(false);\n } else if (isSelected && !allRowsSelected) {\n let allSelected = true;\n for (let i = 0; i < selected.length; i++) {\n if (i !== rowId) {\n if (!selected[i]) {\n allSelected = false;\n }\n }\n }\n if (allSelected) {\n setAllRowsSelected(true);\n }\n }\n };\n \n onKeyDown = (e) => {\n if (e.key === 'Shift') {\n setShifting(true);\n }\n };\n onKeyUp = (e) => {\n if (e.key === 'Shift') {\n setShifting(false);\n }\n };\n \n React.useEffect(() => {\n document.addEventListener(\"keydown\", onKeyDown);\n document.addEventListener(\"keyup\", onKeyUp);\n \n return () => {\n document.removeEventListener(\"keydown\", onKeyDown);\n document.removeEventListener(\"keyup\", onKeyUp);\n }\n }, []);\n \n const onSelectAll = (event, isSelected) => {\n setAllRowsSelected(isSelected);\n setSelected(selected.map(sel => isSelected));\n };\n \n return (\n <TableComposable aria-label=\"Selectable Table\">\n <Thead>\n <Tr>\n <Th\n select={{\n onSelect: onSelectAll,\n isSelected: allRowsSelected\n }}\n />\n <Th>{columns[0]}</Th>\n <Th>{columns[1]}</Th>\n <Th>{columns[2]}</Th>\n <Th>{columns[3]}</Th>\n <Th>{columns[4]}</Th>\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => (\n <Tr key={rowIndex}>\n <Td\n key={`${rowIndex}_0`}\n select={{\n rowIndex,\n onSelect,\n isSelected: selected[rowIndex] && rowIndex !== 1,\n disable: rowIndex === 1\n }}\n />\n {row.map((cell, cellIndex) => {\n const shiftedIndex = cellIndex + 1;\n return (\n <Td key={`${rowIndex}_${shiftedIndex}`} dataLabel={columns[cellIndex]}>\n {cell}\n </Td>\n );\n })}\n </Tr>\n ))}\n </Tbody>\n </TableComposable>\n );\n};","title":"Composable: Selectable with checkbox","lang":"js"}}>
992
+ <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { TableComposable, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';\n\nComposableTableSelectable = () => {\n const columns = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit'];\n const rows = [\n ['one', 'two', 'a', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['a', 'two', 'k', 'four', 'five'],\n ['p', 'two', 'b', 'four', 'five']\n ];\n const [allRowsSelected, setAllRowsSelected] = React.useState(false);\n const [selected, setSelected] = React.useState(rows.map(row => false));\n const [recentSelection, setRecentSelection] = React.useState(null);\n const [shifting, setShifting] = React.useState(false);\n const onSelect = (event, isSelected, rowId) => {\n let newSelected = selected.map((sel, index) => (index === rowId ? isSelected : sel));\n\n // if the user is shift + selecting the checkboxes, then all intermediate checkboxes should be selected\n if (shifting && recentSelection !== null && isSelected) {\n const numberSelected = rowId - recentSelection;\n newSelected = newSelected.map((sel, index) => {\n // select all between recentSelection and current rowId;\n const intermediateIndexes =\n numberSelected > 0\n ? Array.from(new Array(numberSelected + 1), (x, i) => i + recentSelection)\n : Array.from(new Array(Math.abs(numberSelected) + 1), (x, i) => i + rowId);\n return intermediateIndexes.includes(index) ? true : sel;\n });\n }\n setSelected(newSelected);\n setRecentSelection(rowId);\n\n if (!isSelected && allRowsSelected) {\n setAllRowsSelected(false);\n } else if (isSelected && !allRowsSelected) {\n let allSelected = true;\n for (let i = 0; i < selected.length; i++) {\n if (i !== rowId) {\n if (!selected[i]) {\n allSelected = false;\n }\n }\n }\n if (allSelected) {\n setAllRowsSelected(true);\n }\n }\n };\n\n onKeyDown = e => {\n if (e.key === 'Shift') {\n setShifting(true);\n }\n };\n onKeyUp = e => {\n if (e.key === 'Shift') {\n setShifting(false);\n }\n };\n\n React.useEffect(() => {\n document.addEventListener('keydown', onKeyDown);\n document.addEventListener('keyup', onKeyUp);\n\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('keyup', onKeyUp);\n };\n }, []);\n\n const onSelectAll = (event, isSelected) => {\n setAllRowsSelected(isSelected);\n setSelected(selected.map(sel => isSelected));\n };\n\n return (\n <TableComposable aria-label=\"Selectable Table\">\n <Thead>\n <Tr>\n <Th\n select={{\n onSelect: onSelectAll,\n isSelected: allRowsSelected\n }}\n />\n <Th>{columns[0]}</Th>\n <Th>{columns[1]}</Th>\n <Th>{columns[2]}</Th>\n <Th>{columns[3]}</Th>\n <Th>{columns[4]}</Th>\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => (\n <Tr key={rowIndex}>\n <Td\n key={`${rowIndex}_0`}\n select={{\n rowIndex,\n onSelect,\n isSelected: selected[rowIndex] && rowIndex !== 1,\n disable: rowIndex === 1\n }}\n />\n {row.map((cell, cellIndex) => {\n const shiftedIndex = cellIndex + 1;\n return (\n <Td key={`${rowIndex}_${shiftedIndex}`} dataLabel={columns[cellIndex]}>\n {cell}\n </Td>\n );\n })}\n </Tr>\n ))}\n </Tbody>\n </TableComposable>\n );\n};","title":"Composable: Selectable with checkbox","lang":"js"}}>
963
993
 
964
994
  <p {...{"className":"ws-p"}}>
965
995
  {`To make a row selectable, the table needs a selection column.
@@ -1057,7 +1087,7 @@ checking checkboxes will check intermediate rows' checkboxes.`}
1057
1087
  </p>
1058
1088
  </Example>,
1059
1089
  'Composable: Row click handler, hoverable & selected rows': props =>
1060
- <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { TableComposable, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';\n\nComposableTableHoverable = () => {\n const columns = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit'];\n const [rows, setRows] = React.useState([\n { cells: ['one', 'two', 'a', 'four', 'five'], isRowSelected: false},\n { cells: ['a', 'two', 'k', 'four', 'five'], isRowSelected: false},\n { cells: ['p', 'two', 'b', 'four', 'five'], isRowSelected: false}\n ]);\n const onRowClick = (event, rowIndex, row) => {\n const updatedRows = [...rows];\n updatedRows[rowIndex].isRowSelected = !rows[rowIndex].isRowSelected;\n setRows(updatedRows); \n };\n \n return (\n <TableComposable aria-label=\"Misc table\">\n <Thead noWrap>\n <Tr>\n <Th>\n {columns[0]}\n </Th>\n <Th>{columns[1]}</Th>\n <Th>\n {columns[2]}\n </Th>\n <Th>{columns[3]}</Th>\n <Th>{columns[4]}</Th>\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => {\n return (\n <Tr\n key={rowIndex}\n onRowClick={event => onRowClick(event, rowIndex, row.cells)}\n isHoverable\n isRowSelected={row.isRowSelected}\n >\n {row.cells.map((cell, cellIndex) => {\n return (\n <Td\n key={`${rowIndex}_${cellIndex}`}\n dataLabel={columns[cellIndex]}\n >\n {cell}\n </Td>\n );\n })}\n </Tr>\n );\n })}\n </Tbody>\n </TableComposable>\n );\n};","title":"Composable: Row click handler, hoverable & selected rows","lang":"js"}}>
1090
+ <Example {...pageData} {...props} {...{"code":"import React from 'react';\nimport { TableComposable, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';\n\nComposableTableHoverable = () => {\n const columns = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit'];\n const [rows, setRows] = React.useState([\n { cells: ['one', 'two', 'a', 'four', 'five'], isRowSelected: false },\n { cells: ['a', 'two', 'k', 'four', 'five'], isRowSelected: false },\n { cells: ['p', 'two', 'b', 'four', 'five'], isRowSelected: false }\n ]);\n const onRowClick = (event, rowIndex, row) => {\n const updatedRows = [...rows];\n updatedRows[rowIndex].isRowSelected = !rows[rowIndex].isRowSelected;\n setRows(updatedRows);\n };\n\n return (\n <TableComposable aria-label=\"Misc table\">\n <Thead noWrap>\n <Tr>\n <Th>{columns[0]}</Th>\n <Th>{columns[1]}</Th>\n <Th>{columns[2]}</Th>\n <Th>{columns[3]}</Th>\n <Th>{columns[4]}</Th>\n </Tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => {\n return (\n <Tr\n key={rowIndex}\n onRowClick={event => onRowClick(event, rowIndex, row.cells)}\n isHoverable\n isRowSelected={row.isRowSelected}\n >\n {row.cells.map((cell, cellIndex) => {\n return (\n <Td key={`${rowIndex}_${cellIndex}`} dataLabel={columns[cellIndex]}>\n {cell}\n </Td>\n );\n })}\n </Tr>\n );\n })}\n </Tbody>\n </TableComposable>\n );\n};","title":"Composable: Row click handler, hoverable & selected rows","lang":"js"}}>
1061
1091
 
1062
1092
  <p {...{"className":"ws-p"}}>
1063
1093
  {`This selectable rows feature is intended for use when a table is used to present a list of objects in a Primary-detail view.`}
@@ -1835,6 +1865,7 @@ const Component = () => (
1835
1865
  {React.createElement(pageData.examples["Composable: Basic"])}
1836
1866
  {React.createElement(pageData.examples["Composable: Custom row wrapper, header tooltips & popovers"])}
1837
1867
  {React.createElement(pageData.examples["Composable: Sortable & wrapping headers"])}
1868
+ {React.createElement(pageData.examples["Composable: Sortable - custom control"])}
1838
1869
  {React.createElement(pageData.examples["Composable: Selectable with checkbox"])}
1839
1870
  {React.createElement(pageData.examples["Composable: Selectable radio input"])}
1840
1871
  {React.createElement(pageData.examples["Composable: Row click handler, hoverable & selected rows"])}