@atom-learning/components 2.25.0 → 2.25.2-beta.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 +0 -7
- package/dist/components/data-table/DataTableContext.d.ts +1 -3
- package/dist/components/data-table/DataTableContext.js +1 -1
- package/dist/docgen.json +1 -1
- package/dist/docs/Avatar.mdx +1 -1
- package/dist/docs/ChipDismissibleGroup.mdx +1 -1
- package/dist/docs/ChipToggleGroup.mdx +1 -1
- package/dist/docs/DataTable.mdx +2 -0
- package/dist/docs/Dismissible.mdx +1 -1
- package/dist/docs/DismissibleGroup.mdx +1 -1
- package/dist/docs/Tabs.mdx +1 -1
- package/dist/docs/Toast.mdx +1 -0
- package/dist/docs/ToggleGroup.mdx +1 -1
- package/dist/index.cjs.js +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
# [2.25.0](https://github.com/Atom-Learning/components/compare/v2.24.0...v2.25.0) (2022-12-15)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* support markdown emphasis wrapping link without line break ([c656c97](https://github.com/Atom-Learning/components/commit/c656c970917e0959530ba741b27861166ba0c163))
|
|
7
|
-
|
|
8
1
|
# [1.4.0](https://github.com/Atom-Learning/components/compare/v1.3.0...v1.4.0) (2022-04-11)
|
|
9
2
|
|
|
10
3
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { VisibilityTableState, ColumnOrderTableState, ColumnPinningTableState, FiltersTableState, SortingTableState, ExpandedTableState, GroupingTableState, ColumnSizingTableState, PaginationTableState, RowSelectionTableState, SortDirection } from '@tanstack/react-table';
|
|
3
|
-
import { CSS } from '../../stitches';
|
|
4
3
|
import { DataTableContextType, TGetAsyncData } from './DataTable.types';
|
|
5
4
|
declare type InitialState = Partial<VisibilityTableState & ColumnOrderTableState & ColumnPinningTableState & FiltersTableState & SortingTableState & ExpandedTableState & GroupingTableState & ColumnSizingTableState & PaginationTableState & RowSelectionTableState>;
|
|
6
5
|
declare type TableProviderProps = {
|
|
@@ -11,7 +10,6 @@ declare type TableProviderProps = {
|
|
|
11
10
|
};
|
|
12
11
|
children: React.ReactNode;
|
|
13
12
|
initialState?: InitialState;
|
|
14
|
-
css?: CSS;
|
|
15
13
|
} & ({
|
|
16
14
|
data: Array<Record<string, unknown>>;
|
|
17
15
|
getAsyncData?: never;
|
|
@@ -19,6 +17,6 @@ declare type TableProviderProps = {
|
|
|
19
17
|
data?: never;
|
|
20
18
|
getAsyncData: TGetAsyncData;
|
|
21
19
|
});
|
|
22
|
-
export declare const DataTableProvider: ({ columns, data: dataProp, getAsyncData, defaultSort, initialState, children
|
|
20
|
+
export declare const DataTableProvider: ({ columns, data: dataProp, getAsyncData, defaultSort, initialState, children }: TableProviderProps) => JSX.Element;
|
|
23
21
|
export declare const useDataTable: <T extends Record<string, unknown>>() => DataTableContextType<T>;
|
|
24
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{useReactTable as
|
|
1
|
+
import*as e from"react";import x from"use-deep-compare-effect";import{useReactTable as I,getCoreRowModel as A,getPaginationRowModel as G,getSortedRowModel as L,getFilteredRowModel as z}from"@tanstack/react-table";import{AsyncDataState as n}from"./DataTable.types.js";import{getNewAsyncData as k}from"./getNewAsyncData.js";const J={pageIndex:0,pageSize:10},C=e.createContext(null),O=({columns:i,data:t=[],getAsyncData:o,defaultSort:u,initialState:l=void 0,children:R})=>{var p;const[b,v]=e.useState({results:t!=null?t:[],total:(p=t==null?void 0:t.length)!=null?p:0}),[r,h]=e.useState(!!(l!=null&&l.pagination)),[w,g]=e.useState(n.NONE),[d,E]=e.useState(""),[a,M]=e.useState({...J,...l==null?void 0:l.pagination}),[c,P]=e.useState(!1),[s,y]=e.useState(u?[{id:u.column,desc:u.direction==="desc"}]:[]),D=e.useCallback(()=>{h(!0)},[]),S=e.useCallback(async F=>{if(o)try{g(n.PENDING);const N=await k(o,F,a,s,d);v(N),g(n.FULFILLED)}catch{g(n.REJECTED)}},[o,a==null?void 0:a.pageIndex,a==null?void 0:a.pageSize,s,d]);e.useEffect(()=>{S({})},[S]),x(()=>{!t||v({results:t,total:t.length})},[t]);const m=()=>b.total,f=I({columns:i,data:b.results,pageCount:a?Math.ceil(m()/a.pageSize):-1,initialState:l,state:{sorting:s,globalFilter:d,pagination:a},manualPagination:o&&r,manualSorting:o&&r,enableSorting:w!==n.PENDING,enableGlobalFilter:!o,getCoreRowModel:A(),getPaginationRowModel:r?G():void 0,getSortedRowModel:c||s.length?L():void 0,getFilteredRowModel:z(),onPaginationChange:r?M:void 0,onSortingChange:y,onGlobalFilterChange:E}),T=e.useMemo(()=>({...f,setIsSortable:P,applyPagination:D,getTotalRows:m,isSortable:c,asyncDataState:w,runAsyncData:S}),[f,D,m,c]);return e.createElement(C.Provider,{value:T},R)},U=()=>{const i=e.useContext(C);if(!i)throw new Error("useDataTable can only be called from inside a DataTableProvider");return i};export{O as DataTableProvider,U as useDataTable};
|