@atom-learning/components 2.16.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,14 +1,14 @@
1
- # [2.16.0](https://github.com/Atom-Learning/components/compare/v2.15.0...v2.16.0) (2022-11-16)
1
+ # [2.17.0](https://github.com/Atom-Learning/components/compare/v2.16.0...v2.17.0) (2022-11-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * workaround to only render first page of rows ([559b469](https://github.com/Atom-Learning/components/commit/559b469fb986fcdc3f50567e182253a15731ecbf))
2
7
 
3
8
 
4
9
  ### Features
5
10
 
6
- * navigation-menu - custom trigger improvements to match api pattern ([de81014](https://github.com/Atom-Learning/components/commit/de8101470683406ee76496f48e97eef8397ba140))
7
- * navigation-menu - trigger simplified ([ef0e18e](https://github.com/Atom-Learning/components/commit/ef0e18e4a3a4936e8d9c8b9acfb27de2ed7aea29))
8
- * navigation-menu cleanup ([d4956cc](https://github.com/Atom-Learning/components/commit/d4956cc10b888bb2bbe030663e1d1274e747c03d))
9
- * navigation-menu custom trigger component ([cbacdcd](https://github.com/Atom-Learning/components/commit/cbacdcd7b32b5e002f6a3a08a1206bc172c9e584))
10
- * navigation-menu mdx update ([46fb78e](https://github.com/Atom-Learning/components/commit/46fb78ebffae3d21e788b26ba99902b9a24b3cfc))
11
- * navigation-menu types improvements ([009101c](https://github.com/Atom-Learning/components/commit/009101cb74f4a6be0c4b47ad30d7c75df3bd1090))
11
+ * accept initialState for DataTable ([f230794](https://github.com/Atom-Learning/components/commit/f230794aaf57174145efd2609bdb6f0a6dcdecf0))
12
12
 
13
13
  # [1.4.0](https://github.com/Atom-Learning/components/compare/v1.3.0...v1.4.0) (2022-04-11)
14
14
 
@@ -1,11 +1,12 @@
1
1
  import * as React from 'react';
2
- import type { Table } from '@tanstack/react-table';
2
+ import type { VisibilityTableState, ColumnOrderTableState, ColumnPinningTableState, FiltersTableState, SortingTableState, ExpandedTableState, GroupingTableState, ColumnSizingTableState, PaginationTableState, RowSelectionTableState, Table } from '@tanstack/react-table';
3
3
  declare type DataTableContextType<T = unknown> = Table<T> & {
4
4
  setIsSortable: React.Dispatch<React.SetStateAction<boolean>>;
5
5
  applyPagination: () => void;
6
6
  getTotalRows: () => number;
7
7
  isSortable: boolean;
8
8
  };
9
+ declare type InitialState = Partial<VisibilityTableState & ColumnOrderTableState & ColumnPinningTableState & FiltersTableState & SortingTableState & ExpandedTableState & GroupingTableState & ColumnSizingTableState & PaginationTableState & RowSelectionTableState>;
9
10
  declare type TableProviderProps = {
10
11
  columns: any;
11
12
  data: Array<Record<string, unknown>>;
@@ -14,7 +15,8 @@ declare type TableProviderProps = {
14
15
  direction: 'asc' | 'desc';
15
16
  };
16
17
  children: React.ReactNode;
18
+ initialState?: InitialState;
17
19
  };
18
- export declare const DataTableProvider: ({ columns, data, defaultSort, children }: TableProviderProps) => JSX.Element;
20
+ export declare const DataTableProvider: ({ columns, data, defaultSort, initialState, children }: TableProviderProps) => JSX.Element;
19
21
  export declare const useDataTable: <T extends Record<string, unknown>>() => DataTableContextType<T>;
20
22
  export {};
@@ -1 +1 @@
1
- import*as e from"react";import{useReactTable as R,getCoreRowModel as M,getPaginationRowModel as S,getSortedRowModel as T,getFilteredRowModel as p}from"@tanstack/react-table";const s=e.createContext(null),v=({columns:t,data:l,defaultSort:o,children:g})=>{const[u,c]=e.useState(!1),[a,w]=e.useState(!1),[r,b]=e.useState(o?[{id:o.column,desc:o.direction==="desc"}]:[]),n=e.useCallback(()=>{c(!0)},[]),d=()=>l.length,i=R({columns:t,data:l,getCoreRowModel:M(),getPaginationRowModel:u?S():void 0,getSortedRowModel:a||r.length?T():void 0,state:{sorting:r},onSortingChange:b,getFilteredRowModel:p()}),m=e.useMemo(()=>({...i,setIsSortable:w,applyPagination:n,getTotalRows:d,isSortable:a}),[i,n,d,a]);return e.createElement(s.Provider,{value:m},g)},C=()=>{const t=e.useContext(s);if(!t)throw new Error("useDataTable can only be called from inside a DataTableProvider");return t};export{v as DataTableProvider,C as useDataTable};
1
+ import*as e from"react";import{useReactTable as R,getCoreRowModel as M,getPaginationRowModel as p,getSortedRowModel as v,getFilteredRowModel as C}from"@tanstack/react-table";const g=e.createContext(null),P=({columns:t,data:n,defaultSort:o,initialState:a=void 0,children:u})=>{const[c,S]=e.useState(!!(a!=null&&a.pagination)),[l,w]=e.useState(!1),[r,b]=e.useState(o?[{id:o.column,desc:o.direction==="desc"}]:[]),i=e.useCallback(()=>{S(!0)},[]),d=()=>n.length,s=R({columns:t,data:n,getCoreRowModel:M(),getPaginationRowModel:c?p():void 0,getSortedRowModel:l||r.length?v():void 0,initialState:a,state:{sorting:r},onSortingChange:b,getFilteredRowModel:C()}),m=e.useMemo(()=>({...s,setIsSortable:w,applyPagination:i,getTotalRows:d,isSortable:l}),[s,i,d,l]);return e.createElement(g.Provider,{value:m},u)},T=()=>{const t=e.useContext(g);if(!t)throw new Error("useDataTable can only be called from inside a DataTableProvider");return t};export{P as DataTableProvider,T as useDataTable};