Commit Graph

4 Commits

Author SHA1 Message Date
Michael Stramel
36ba233e27 Updating types (#1535)
* Attempt to bring into alignment

fix plugin hook definitions

Remove old prop

Format

fix Header and Cell props

Rename prop

Abstract props to definitions

fix bad generic

fix typo

Revert "fix typo"

This reverts commit 1ca58c5d8fb017bb0af79dd4aa4f0cd296e7a7e8.

fix

* Remove documented prop

* Tweaks

* Re-add comment

* Some updates

* more changes

* Convert to interfaces

* more fixes

* rename sortByFn params

* Fixes

* Fix setFilter

* Hopefully the last changes

* Bump TypeScript Version for declaration file

Co-Authored-By: Christian Murphy <christian.murphy.42@gmail.com>

* format

* Linting

* fix typo

* expose defaultState

* swap aggregatedValue

* Allow cellvalue for accessor function return

* modifications

* manually added changes from ggascoigne

* remove changes from examples folder
2019-10-09 15:15:00 -06:00
tannerlinsley
bbfc6428b7 refactor(usetable/usetablestate): integrate useTableState into useTable
useTableState was an early and hasty abstraction that hasn't proved useful in many ways. Anything
you could do with useTableState, you could easily do using the same options (assuming they exist) in
the useTable hook. For this reason, state is now a first class citizen of the useTable hook, along
with more sane properties and option locations for anything pertaining to state.
2019-10-05 20:48:28 -06:00
ggascoigne
7ab6385839 TypeScript updates (#1521)
* TypeScript updates

I've found that trying to get solid TypeScript typings for this library
are a bit of a challenge.  The composable nature of the library means
that the types for the builtin functions are by their nature somewhat
minimal, and that the user needs to be able to extend those interfaces
to reflect the specific plugins that are in use.

With that in mind I propose something like this.

To get the best out of them, you then need to extend those interfaces
using declaration merging, see
https://www.typescriptlang.org/docs/handbook/declaration-merging.html

e.g.

```ts
declare module 'react-table-hooks' {
  export interface TableInstance<D = any>
    extends UseFiltersValues<D>,
      UsePaginationValues<D>,
      UseExpandedValues,
      UseGroupByValues {}

  export interface TableState<D = any>
    extends UsePaginationState,
      UseGroupByState,
      UseSortbyState<D>,
      UseFiltersState<D> {}
}
```

This also puts the ability to extend those types with any user defined
hooks completely in the users hands.

This gives the greatest flexibility, but I'll admit that it isn't
particularly obvious.  Perhaps a typescript readme and example is needed.

* fix useExpanded type

* fix module name

* fix typo

* address review feedback

* add IdType, update Filters definition
2019-09-20 09:37:45 -06:00
Michael Stramel
670a92734e Add typings (#1511) 2019-09-12 09:39:53 -06:00