Skip to content

Commit a9274f2

Browse files
lethemanhrezk2ll
authored andcommitted
feat: Implement range selection in list view and grid view ✨
1 parent 5678489 commit a9274f2

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

react/Table/Readme.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ const initialVariants = [{ grouped: false }]
103103

104104
const makeGroups = () => ({ groupLabels: ['C', 'D', 'Others'], groupCounts: [1,1,12] })
105105

106-
;
106+
/**
107+
* @param order
108+
* @param orderBy
109+
*/
110+
const onSortChange = ({ order, orderBy }) => {
111+
setState({ order, orderBy })
112+
}
107113

108114
<Variants initialVariants={initialVariants} screenshotAllVariants>
109115
{variant => (
@@ -117,6 +123,7 @@ const makeGroups = () => ({ groupLabels: ['C', 'D', 'Others'], groupCounts: [1,1
117123
isSelectedItem={row => isSelectedItem(row)}
118124
onSelect={onSelect}
119125
onSelectAll={onSelectAll}
126+
onSortChange={onSortChange}
120127
componentsProps={{
121128
rowContent: {
122129
onClick: (row, column) => { console.info(`click on cell. Row ${row['id']}, Column ${column['id']}`) },

react/Table/Virtualized/RowContent.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const RowContent = ({
3030
'aria-labelledby': `enhanced-table-checkbox-${index}`
3131
}}
3232
size="small"
33-
onChange={() => onSelectClick(row)}
33+
onClick={event => onSelectClick(event, row, index)}
3434
/>
3535
</TableCell>
3636
{columns.map(column => (

react/Table/Virtualized/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const VirtualizedTable = forwardRef(
2323
componentsProps,
2424
context,
2525
components,
26+
onSortChange,
2627
...props
2728
},
2829
ref
@@ -43,8 +44,10 @@ const VirtualizedTable = forwardRef(
4344

4445
const handleSort = property => {
4546
const isAsc = orderBy === property && order === 'asc'
46-
setOrder(isAsc ? 'desc' : 'asc')
47+
const newOrder = isAsc ? 'desc' : 'asc'
48+
setOrder(newOrder)
4749
setOrderBy(property)
50+
onSortChange({ order: newOrder, orderBy: property })
4851
}
4952

5053
const handleSelectAll = event => {

0 commit comments

Comments
 (0)