React-data-grid: adding Data and DraggableHeader (#15941)

* added Data + DraggableHeader in react-data-grid-addons types

* React-data-grid: adding Data and DraggableHeader

* edit test + more specific Selectors

* change Object to object
This commit is contained in:
Martin Novák
2017-04-26 15:02:03 -07:00
committed by Sheetal Nandi
parent 86d6ae08ba
commit ea0a353f21
2 changed files with 26 additions and 4 deletions
+18 -3
View File
@@ -1,6 +1,6 @@
// Type definitions for react-data-grid 2.0
// Project: https://github.com/adazzle/react-data-grid.git
// Definitions by: Simon Gellis <https://github.com/SupernaviX>, Kieran Peat <https://github.com/KieranPeat>
// Definitions by: Simon Gellis <https://github.com/SupernaviX>, Kieran Peat <https://github.com/KieranPeat>, Martin Novak <https://github.com/martinnov92/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -464,6 +464,15 @@ declare namespace AdazzleReactDataGridPlugins {
export class DropDownFormatter extends React.Component<any, {}> { }
}
export class Toolbar extends React.Component<any, any> {}
export namespace DraggableHeader {
export class DraggableContainer extends React.Component<any, any>{ }
}
export namespace Data {
export const Selectors: {
getRows: (state: object) => object[];
getSelectedRowsByKey: (state: object) => object[];
}
}
// TODO: re-export the react-contextmenu typings once those exist
// https://github.com/vkbansal/react-contextmenu/issues/10
export namespace Menu {
@@ -497,13 +506,17 @@ declare module "react-data-grid-addons" {
import Formatters = Plugins.Formatters;
import Toolbar = Plugins.Toolbar;
import Menu = Plugins.Menu;
import Data = Plugins.Data;
import DraggableHeader = Plugins.DraggableHeader;
// ES6 named exports
export {
Editors,
Formatters,
Toolbar,
Menu
Menu,
Data,
DraggableHeader
}
// attach to window
@@ -513,7 +526,9 @@ declare module "react-data-grid-addons" {
Editors: typeof Editors
Formatters: typeof Formatters
Toolbar: typeof Toolbar
Menu: typeof Menu
Menu: typeof Menu,
Data: typeof Data,
DraggableHeader: typeof DraggableHeader
}
}
}
@@ -7,7 +7,7 @@ var Editors = ReactDataGridPlugins.Editors;
var Toolbar = ReactDataGridPlugins.Toolbar;
var AutoCompleteEditor = Editors.AutoComplete;
var DropDownEditor = Editors.DropDownEditor;
var { Selectors } = ReactDataGridPlugins.Data;
class CustomFilterHeaderCell extends React.Component<any, any> {
constructor(props: any, context: any) {
@@ -253,6 +253,12 @@ class Example extends React.Component<any, any> {
// Do nothing, just test that it accepts an event
}
getRows() {
const rows = Selectors.getRows(this.state);
console.log(rows);
return rows;
}
handleAddRow(e:any) {
var newRow = {
value: e.newRowIndex,
@@ -266,6 +272,7 @@ class Example extends React.Component<any, any> {
}
getRowAt(index:number) {
this.getRows();
if (index < 0 || index > this.getSize()) {
return undefined;
}