-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f955c9
commit 011aae7
Showing
77 changed files
with
5,741 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
examples/src/pages/tests/multisort/nestedMultisort.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { multisortNested } from '@src/utils/multisort'; | ||
|
||
const options = { | ||
nodesKey: 'children', | ||
isLeafNode: (item: any) => !item.children, | ||
getNodeChildren: (item: any) => item.children, | ||
toKey: (item: any) => item.id, | ||
}; | ||
export default test.describe.parallel('Nested multisort', () => { | ||
test('should sort empty array', () => { | ||
expect(multisortNested([], [], options)).toEqual([]); | ||
}); | ||
|
||
test('should not sort when no sort info provided', () => { | ||
expect(multisortNested([], [3, 1, 2], options)).toEqual([3, 1, 2]); | ||
}); | ||
|
||
test('should sort well', () => { | ||
const data = [ | ||
{ | ||
id: 1, | ||
size: 130, | ||
name: 'Documents', | ||
children: [ | ||
{ | ||
id: 2, | ||
size: 110, | ||
name: 'Work', | ||
}, | ||
{ | ||
id: 3, | ||
size: 20, | ||
name: 'Vacation', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 4, | ||
size: 100, | ||
name: 'Downloads', | ||
}, | ||
]; | ||
|
||
expect( | ||
multisortNested( | ||
[ | ||
{ | ||
dir: 1, | ||
type: 'number', | ||
field: 'size', | ||
}, | ||
], | ||
data, | ||
options, | ||
), | ||
).toEqual([ | ||
{ | ||
id: 4, | ||
size: 100, | ||
name: 'Downloads', | ||
}, | ||
{ | ||
id: 1, | ||
size: 130, | ||
name: 'Documents', | ||
children: [ | ||
{ | ||
id: 3, | ||
size: 20, | ||
name: 'Vacation', | ||
}, | ||
{ | ||
id: 2, | ||
size: 110, | ||
name: 'Work', | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
}); |
164 changes: 164 additions & 0 deletions
164
examples/src/pages/tests/table/props/data/basic-add-data.page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
InfiniteTable, | ||
DataSource, | ||
InfiniteTableColumn, | ||
DataSourceApi, | ||
} from '@infinite-table/infinite-react'; | ||
import { CarSale } from '@examples/datasets/CarSale'; | ||
import { useState } from 'react'; | ||
|
||
const carsales: CarSale[] = [ | ||
{ | ||
category: '1 - Category 1 Truck', | ||
make: 'Acura', | ||
model: 'RDX 2WD', | ||
year: 2010, | ||
sales: 15, | ||
color: 'red', | ||
id: 0, | ||
}, | ||
{ | ||
category: '1 - Category 1 Truck', | ||
make: 'Acura', | ||
model: 'RDX 4WD', | ||
year: 2007, | ||
sales: 1, | ||
color: 'red', | ||
id: 1, | ||
}, | ||
{ | ||
category: '1 - Category 1 Truck', | ||
make: 'Acura', | ||
model: 'RDX 4WD', | ||
year: 2008, | ||
sales: 2, | ||
color: 'magenta', | ||
id: 2, | ||
}, | ||
{ | ||
category: '1 - Category 1 Truck', | ||
make: 'Acura', | ||
model: 'RDX 4WD', | ||
year: 2009, | ||
sales: 136, | ||
color: 'blue', | ||
id: 3, | ||
}, | ||
{ | ||
category: '1 - Category 1 Truck', | ||
make: 'Acura', | ||
model: 'RDX 4WD', | ||
year: 2010, | ||
color: 'blue', | ||
sales: 30, | ||
id: 4, | ||
}, | ||
{ | ||
category: '1 - Category 1 Truck', | ||
make: 'Acura', | ||
model: 'TSX', | ||
year: 2009, | ||
sales: 14, | ||
color: 'yellow', | ||
id: 5, | ||
}, | ||
{ | ||
category: '1 - Category 1 Truck', | ||
make: 'Acura', | ||
model: 'TSX', | ||
year: 2010, | ||
sales: 14, | ||
color: 'red', | ||
id: 6, | ||
}, | ||
{ | ||
category: '1 - Category 1 Truck', | ||
make: 'Audi', | ||
model: 'A3', | ||
year: 2009, | ||
sales: 2, | ||
color: 'magenta', | ||
id: 7, | ||
}, | ||
]; | ||
|
||
(globalThis as any).carsales = carsales; | ||
|
||
const columns: Record<string, InfiniteTableColumn<CarSale>> = { | ||
id: { field: 'id', defaultWidth: 80 }, | ||
make: { field: 'make' }, | ||
model: { field: 'model' }, | ||
|
||
category: { | ||
field: 'category', | ||
}, | ||
count: { | ||
field: 'sales', | ||
}, | ||
year: { | ||
field: 'year', | ||
type: 'number', | ||
}, | ||
}; | ||
|
||
export default function DataTestPage() { | ||
const [dataSourceApi, setDataSourceApi] = | ||
useState<DataSourceApi<CarSale> | null>(null); | ||
return ( | ||
<React.StrictMode> | ||
<> | ||
<button | ||
onClick={() => { | ||
dataSourceApi?.insertDataArray( | ||
[ | ||
{ | ||
id: 9, | ||
make: 'test', | ||
model: 'test', | ||
category: 'test', | ||
year: 2024, | ||
sales: 1, | ||
color: 'test', | ||
}, | ||
{ | ||
id: 10, | ||
make: 'test', | ||
model: 'test', | ||
category: 'test', | ||
year: 2024, | ||
sales: 1, | ||
color: 'test', | ||
}, | ||
], | ||
{ | ||
position: 'after', | ||
primaryKey: 0, | ||
}, | ||
); | ||
}} | ||
> | ||
Insert row after ID=1 | ||
</button> | ||
<DataSource<CarSale> | ||
data={carsales} | ||
primaryKey="id" | ||
onReady={setDataSourceApi} | ||
> | ||
<InfiniteTable<CarSale> | ||
domProps={{ | ||
style: { | ||
margin: '5px', | ||
height: 900, | ||
border: '1px solid gray', | ||
position: 'relative', | ||
}, | ||
}} | ||
columns={columns} | ||
/> | ||
</DataSource> | ||
</> | ||
</React.StrictMode> | ||
); | ||
} |
Oops, something went wrong.