Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update TS definition for Filters plugin and Core methods (#10494)
- Loading branch information
Showing
11 changed files
with
123 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"issuesOrigin": "private", | ||
"title": "Updated TS definition for Filters plugin and Core methods", | ||
"type": "changed", | ||
"issueOrPR": 10494, | ||
"breaking": false, | ||
"framework": "none" | ||
} |
55 changes: 39 additions & 16 deletions
55
handsontable/src/plugins/columnSorting/__tests__/columnSorting.types.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 |
---|---|---|
@@ -1,32 +1,55 @@ | ||
import Handsontable from 'handsontable'; | ||
|
||
const hot = new Handsontable(document.createElement('div'), {}); | ||
const columnSorting = hot.getPlugin('columnSorting'); | ||
|
||
columnSorting.clearSort(); | ||
|
||
columnSorting.getSortConfig(); | ||
columnSorting.getSortConfig(0); | ||
|
||
const sortConfig0 = columnSorting.getSortConfig(0); | ||
const hot = new Handsontable(document.createElement('div'), { | ||
columnSorting: true, | ||
}); | ||
new Handsontable(document.createElement('div'), { | ||
columnSorting: { | ||
sortEmptyCells: true, | ||
indicator: true, | ||
headerAction: true, | ||
compareFunctionFactory(sortOrder, columnMeta) { | ||
return (a: any, b: any) => columnMeta.type === 'text' && sortOrder === 'asc' ? -1 : 1; | ||
}, | ||
initialConfig: { | ||
column: 1, | ||
sortOrder: 'asc' | ||
} | ||
} | ||
}); | ||
new Handsontable(document.createElement('div'), { | ||
columnSorting: { | ||
initialConfig: { | ||
column: 1, | ||
sortOrder: 'desc' | ||
} | ||
} | ||
}); | ||
const plugin = hot.getPlugin('columnSorting'); | ||
|
||
plugin.clearSort(); | ||
plugin.getSortConfig(); | ||
plugin.getSortConfig(0); | ||
|
||
const sortConfig0 = plugin.getSortConfig(0); | ||
|
||
if (typeof sortConfig0 !== 'undefined' && !Array.isArray(sortConfig0)) { | ||
sortConfig0.column; | ||
sortConfig0.sortOrder; | ||
} | ||
|
||
const sortConfigs = columnSorting.getSortConfig(); | ||
const sortConfigs = plugin.getSortConfig(); | ||
|
||
if (Array.isArray(sortConfigs)) { | ||
sortConfigs[0].column; | ||
sortConfigs[0].sortOrder; | ||
} | ||
|
||
columnSorting.setSortConfig({ column: 0, sortOrder: 'asc' }); | ||
columnSorting.setSortConfig([{ column: 0, sortOrder: 'asc' }]); | ||
columnSorting.setSortConfig([]); | ||
plugin.setSortConfig({ column: 0, sortOrder: 'asc' }); | ||
plugin.setSortConfig([{ column: 0, sortOrder: 'asc' }]); | ||
plugin.setSortConfig([]); | ||
|
||
columnSorting.isSorted(); | ||
const isSorted: boolean = plugin.isSorted(); | ||
|
||
columnSorting.sort({ column: 0, sortOrder: 'asc' }); | ||
columnSorting.sort([{ column: 0, sortOrder: 'asc' }]); | ||
plugin.sort({ column: 0, sortOrder: 'asc' }); | ||
plugin.sort([{ column: 0, sortOrder: 'asc' }]); |
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
62 changes: 46 additions & 16 deletions
62
handsontable/src/plugins/multiColumnSorting/__tests__/multiColumnSorting.types.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 |
---|---|---|
@@ -1,32 +1,62 @@ | ||
import Handsontable from 'handsontable'; | ||
|
||
const hot = new Handsontable(document.createElement('div'), {}); | ||
const columnSorting = hot.getPlugin('multiColumnSorting'); | ||
|
||
columnSorting.clearSort(); | ||
|
||
columnSorting.getSortConfig(); | ||
columnSorting.getSortConfig(0); | ||
|
||
const sortConfig0 = columnSorting.getSortConfig(0); | ||
const hot = new Handsontable(document.createElement('div'), { | ||
multiColumnSorting: true, | ||
}); | ||
new Handsontable(document.createElement('div'), { | ||
multiColumnSorting: { | ||
sortEmptyCells: true, | ||
indicator: true, | ||
headerAction: true, | ||
compareFunctionFactory(sortOrder, columnMeta) { | ||
return (a: any, b: any) => columnMeta.type === 'text' && sortOrder === 'asc' ? -1 : 1; | ||
}, | ||
initialConfig: { | ||
column: 1, | ||
sortOrder: 'asc' | ||
} | ||
} | ||
}); | ||
new Handsontable(document.createElement('div'), { | ||
multiColumnSorting: { | ||
initialConfig: [ | ||
{ | ||
column: 1, | ||
sortOrder: 'desc' | ||
}, | ||
{ | ||
column: 3, | ||
sortOrder: 'asc' | ||
} | ||
] | ||
} | ||
}); | ||
|
||
const plugin = hot.getPlugin('multiColumnSorting'); | ||
|
||
plugin.clearSort(); | ||
plugin.getSortConfig(); | ||
plugin.getSortConfig(0); | ||
|
||
const sortConfig0 = plugin.getSortConfig(0); | ||
|
||
if (typeof sortConfig0 !== 'undefined' && !Array.isArray(sortConfig0)) { | ||
sortConfig0.column; | ||
sortConfig0.sortOrder; | ||
} | ||
|
||
const sortConfigs = columnSorting.getSortConfig(); | ||
const sortConfigs = plugin.getSortConfig(); | ||
|
||
if (Array.isArray(sortConfigs)) { | ||
sortConfigs[0].column; | ||
sortConfigs[0].sortOrder; | ||
} | ||
|
||
columnSorting.setSortConfig({ column: 0, sortOrder: 'asc' }); | ||
columnSorting.setSortConfig([{ column: 0, sortOrder: 'asc' }]); | ||
columnSorting.setSortConfig([]); | ||
plugin.setSortConfig({ column: 0, sortOrder: 'asc' }); | ||
plugin.setSortConfig([{ column: 0, sortOrder: 'asc' }]); | ||
plugin.setSortConfig([]); | ||
|
||
columnSorting.isSorted(); | ||
const isSorted: boolean = plugin.isSorted(); | ||
|
||
columnSorting.sort({ column: 0, sortOrder: 'asc' }); | ||
columnSorting.sort([{ column: 1, sortOrder: 'desc' }, { column: 2, sortOrder: 'asc' }]); | ||
plugin.sort({ column: 0, sortOrder: 'asc' }); | ||
plugin.sort([{ column: 1, sortOrder: 'desc' }, { column: 2, sortOrder: 'asc' }]); |
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 @@ | ||
type Maybe<T> = NonNullable<T> | void; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
} | ||
}, | ||
"include": [ | ||
"./common.d.ts", | ||
"**/*.types.ts", | ||
"../../src/**/__tests__/*.types.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
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