@infinite-table/infinite-react 0.2.14 → 0.2.17

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.
Files changed (4) hide show
  1. package/index.d.ts +45 -13
  2. package/index.esm.js +295 -183
  3. package/index.js +328 -218
  4. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _vanilla_extract_private from '@vanilla-extract/private';
2
2
  import * as React$1 from 'react';
3
- import { CSSProperties, MutableRefObject } from 'react';
3
+ import { CSSProperties, HTMLProps, MutableRefObject } from 'react';
4
4
 
5
5
  declare function debounce(fn: Function, { wait }: {
6
6
  wait: number;
@@ -219,14 +219,36 @@ declare class VirtualBrain extends Logger {
219
219
  destroy: () => void;
220
220
  }
221
221
 
222
- declare type Renderable = React$1.ReactNode;
222
+ declare type Renderable = React$1.ReactNode | JSX.Element;
223
223
 
224
224
  declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
225
225
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
226
226
  }[Keys];
227
227
 
228
+ declare type InfiniteTableCellProps<T> = {
229
+ column: InfiniteTableComputedColumn<T>;
230
+ renderChildren: () => Renderable;
231
+ cssEllipsis?: boolean;
232
+ virtualized?: boolean;
233
+ skipColumnShifting?: boolean;
234
+ beforeChildren?: Renderable;
235
+ afterChildren?: Renderable;
236
+ offset?: number;
237
+ offsetProperty?: 'left' | 'right';
238
+ cssPosition?: CSSProperties['position'];
239
+ domRef?: React.RefCallback<HTMLElement>;
240
+ cellType: 'body' | 'header';
241
+ };
242
+
228
243
  declare type InfiniteTableToggleGroupRowFn = (groupKeys: any[]) => void;
229
- declare type InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
244
+ declare type InfiniteTableColumnHeaderParams<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
245
+ domRef: InfiniteTableCellProps<DATA_TYPE>['domRef'];
246
+ sortTool: JSX.Element;
247
+ column: COL_TYPE;
248
+ columnSortInfo: DataSourceSingleSortInfo<DATA_TYPE> | null;
249
+ };
250
+ declare type InfiniteTableColumnRenderParams<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
251
+ domRef: InfiniteTableCellProps<DATA_TYPE>['domRef'];
230
252
  value: string | number | Renderable;
231
253
  groupRowInfo: InfiniteTableRowInfo<DATA_TYPE> | null;
232
254
  rowIndex: number;
@@ -242,11 +264,12 @@ declare type InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE = InfiniteTableC
242
264
  rowInfo: InfiniteTableRowInfoGroup<DATA_TYPE>;
243
265
  data: Partial<DATA_TYPE> | null;
244
266
  });
245
- declare type InfiniteTableGroupColumnRenderIconParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE> & {
267
+ declare type InfiniteTableColumnCellContextType<DATA_TYPE> = InfiniteTableColumnRenderParams<DATA_TYPE> & {};
268
+ declare type InfiniteTableGroupColumnRenderIconParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParams<DATA_TYPE, COL_TYPE> & {
246
269
  collapsed: boolean;
247
270
  groupIcon: Renderable;
248
271
  };
249
- declare type InfiniteTableColumnRenderValueParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE>;
272
+ declare type InfiniteTableColumnRenderValueParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParams<DATA_TYPE, COL_TYPE>;
250
273
  declare type InfiniteTableColumnRowspanParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
251
274
  rowInfo: InfiniteTableRowInfo<DATA_TYPE>;
252
275
  data: DATA_TYPE | Partial<DATA_TYPE> | null;
@@ -254,13 +277,9 @@ declare type InfiniteTableColumnRowspanParam<DATA_TYPE, COL_TYPE = InfiniteTable
254
277
  rowIndex: number;
255
278
  column: COL_TYPE;
256
279
  };
257
- interface InfiniteTableColumnHeaderRenderParams<T> {
258
- column: InfiniteTableComputedColumn<T>;
259
- columnSortInfo: DataSourceSingleSortInfo<T> | null | undefined;
260
- }
261
- declare type InfiniteTableColumnRenderFunction<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = ({ value, rowIndex, column, data, toggleGroupRow, toggleCurrentGroupRow, rowInfo, groupBy, pivotBy, }: InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE>) => Renderable | null;
280
+ declare type InfiniteTableColumnRenderFunction<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = ({ value, rowIndex, column, data, toggleGroupRow, toggleCurrentGroupRow, rowInfo, groupBy, pivotBy, }: InfiniteTableColumnRenderParams<DATA_TYPE, COL_TYPE>) => Renderable | null;
262
281
  declare type InfiniteTableGroupColumnRenderIconFunction<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = (param: InfiniteTableGroupColumnRenderIconParam<DATA_TYPE, COL_TYPE>) => Renderable | null;
263
- declare type InfiniteTableColumnHeaderRenderFunction<T> = ({ columnSortInfo, column, }: InfiniteTableColumnHeaderRenderParams<T>) => Renderable;
282
+ declare type InfiniteTableColumnHeaderRenderFunction<T> = ({ columnSortInfo, column, }: InfiniteTableColumnHeaderParams<T>) => Renderable;
264
283
  declare type InfiniteTableColumnAlign = 'start' | 'center' | 'end';
265
284
  declare type InfiniteTableColumnVerticalAlign = 'start' | 'center' | 'end';
266
285
  declare type InfiniteTableColumnHeader<T> = Renderable | InfiniteTableColumnHeaderRenderFunction<T>;
@@ -295,7 +314,7 @@ declare type InfiniteTableColumnValueGetterParams<T> = {
295
314
  data: Partial<T> | null;
296
315
  rowInfo: InfiniteTableRowInfoGroup<T>;
297
316
  };
298
- declare type InfiniteTableColumnValueGetter<T, VALUE_GETTER_TYPE = Renderable> = (params: InfiniteTableColumnValueGetterParams<T>) => VALUE_GETTER_TYPE;
317
+ declare type InfiniteTableColumnValueGetter<T, VALUE_GETTER_TYPE = string | number | boolean | null | undefined> = (params: InfiniteTableColumnValueGetterParams<T>) => VALUE_GETTER_TYPE;
299
318
  declare type InfiniteTableColumnRowspanFn<T> = (params: InfiniteTableColumnRowspanParam<T>) => number;
300
319
  declare type InfiniteTableColumnComparer<T> = (a: T, b: T) => number;
301
320
  declare type InfiniteTableBaseColumn<T> = {
@@ -322,6 +341,10 @@ declare type InfiniteTableBaseColumn<T> = {
322
341
  defaultFlex?: number;
323
342
  minWidth?: number;
324
343
  maxWidth?: number;
344
+ components?: {
345
+ ColumnCell?: React.FunctionComponent<HTMLProps<HTMLDivElement>>;
346
+ HeaderCell?: React.FunctionComponent<HTMLProps<HTMLDivElement>>;
347
+ };
325
348
  };
326
349
  /**
327
350
  * Defines a column in the table.
@@ -478,6 +501,7 @@ interface DataSourceSetupState<T> {
478
501
  dataArray: InfiniteTableRowInfo<T>[];
479
502
  groupDeepMap?: DeepMap<GroupKeyType, DeepMapGroupValueType<T, any>>;
480
503
  pivotTotalColumnPosition: InfiniteTablePropPivotTotalColumnPosition;
504
+ pivotGrandTotalColumnPosition: InfiniteTablePropPivotGrandTotalColumnPosition;
481
505
  cursorId: number | Symbol | DataSourceLivePaginationCursorValue;
482
506
  updatedAt: number;
483
507
  reducedAt: number;
@@ -696,6 +720,7 @@ declare type InfiniteTableColumnType<T> = {
696
720
  verticalAlign?: InfiniteTableColumn<T>['verticalAlign'];
697
721
  cssEllipsis?: boolean;
698
722
  headerCssEllipsis?: boolean;
723
+ components?: InfiniteTableColumn<T>['components'];
699
724
  renderValue?: InfiniteTableColumn<T>['renderValue'];
700
725
  render?: InfiniteTableColumn<T>['render'];
701
726
  valueGetter?: InfiniteTableColumn<T>['valueGetter'];
@@ -780,6 +805,7 @@ interface InfiniteTableProps<T> {
780
805
  viewportReservedWidth?: number;
781
806
  pivotColumn?: InfiniteTablePropPivotColumn<T, InfiniteTableColumn<T> & InfiniteTablePivotFinalColumn<T>>;
782
807
  pivotTotalColumnPosition?: InfiniteTablePropPivotTotalColumnPosition;
808
+ pivotGrandTotalColumnPosition?: InfiniteTablePropPivotGrandTotalColumnPosition;
783
809
  groupColumn?: Partial<InfiniteTablePropGroupColumn<T>>;
784
810
  groupRenderStrategy?: InfiniteTablePropGroupRenderStrategy;
785
811
  hideEmptyGroupColumns?: boolean;
@@ -888,6 +914,7 @@ interface InfiniteTableSetupState<T> {
888
914
  }
889
915
  declare type InfiniteTableColumnGroupsDepthsMap = Map<string, number>;
890
916
  declare type InfiniteTablePropPivotTotalColumnPosition = false | 'start' | 'end';
917
+ declare type InfiniteTablePropPivotGrandTotalColumnPosition = InfiniteTablePropPivotTotalColumnPosition;
891
918
  interface InfiniteTableMappedState<T> {
892
919
  scrollTopKey: InfiniteTableProps<T>['scrollTopKey'];
893
920
  viewportReservedWidth: InfiniteTableProps<T>['viewportReservedWidth'];
@@ -944,6 +971,7 @@ interface InfiniteTableMappedState<T> {
944
971
  columnGroups: InfiniteTablePropColumnGroupsMap;
945
972
  collapsedColumnGroups: NonUndefined<InfiniteTableProps<T>['collapsedColumnGroups']>;
946
973
  pivotTotalColumnPosition: NonUndefined<InfiniteTableProps<T>['pivotTotalColumnPosition']>;
974
+ pivotGrandTotalColumnPosition: InfiniteTableProps<T>['pivotGrandTotalColumnPosition'];
947
975
  }
948
976
  interface InfiniteTableDerivedState<T> {
949
977
  groupBy: DataSourceProps<T>['groupBy'];
@@ -1011,6 +1039,10 @@ interface InfiniteTableContextValue<T> {
1011
1039
  getState: () => InfiniteTableState<T>;
1012
1040
  }
1013
1041
 
1042
+ declare function useInfiniteColumnCell<T>(): InfiniteTableColumnCellContextType<T>;
1043
+
1044
+ declare function useInfiniteHeaderCell<T>(): InfiniteTableColumnHeaderParams<T, InfiniteTableComputedColumn<T>>;
1045
+
1014
1046
  declare const InfiniteTableClassName: string;
1015
1047
  declare const InfiniteTableComponent: React$1.MemoExoticComponent<(<T>() => JSX.Element)>;
1016
1048
  declare function InfiniteTable<T>(props: InfiniteTableProps<T>): JSX.Element;
@@ -1076,4 +1108,4 @@ declare function interceptMap<K, V>(map: Map<K, V>, fns: InterceptedMapFns<K, V>
1076
1108
 
1077
1109
  declare function useEffectWithChanges(fn: (changes: Record<string, any>, prevValues: Record<string, any>) => void | (() => void), deps: Record<string, any>): void;
1078
1110
 
1079
- export { ColumnTypeWithInherit, DataSource, DataSourceAction, DataSourceActionType, DataSourceAggregationReducer, DataSourceComponentActions, DataSourceContextValue, DataSourceData, DataSourceDataParams, DataSourceDataParamsChanges, DataSourceDerivedState, DataSourceExpandedAndCollapsedGroupRows, DataSourceGroupBy, DataSourceGroupRowsList, DataSourceLivePaginationCursorFn, DataSourceLivePaginationCursorParams, DataSourceLivePaginationCursorValue, DataSourceMappedState, DataSourceMappings, DataSourcePivotBy, DataSourcePropAggregationReducers, DataSourcePropGroupBy, DataSourcePropLivePaginationCursor, DataSourcePropPivotBy, DataSourceProps, DataSourceReducer, DataSourceRemoteData, DataSourceSetupState, DataSourceSingleSortInfo, DataSourceSortInfo, DataSourceState, GroupRowsState, InfiniteTable, InfiniteTableAction, InfiniteTableActionType, InfiniteTableClassName, InfiniteTableColumn, InfiniteTableColumnAggregator, InfiniteTableColumnComparer, InfiniteTableColumnGroup, InfiniteTableColumnRenderParam, InfiniteTableColumnRenderValueParam, InfiniteTableColumnRowspanParam, InfiniteTableColumnSizingOptions, InfiniteTableComponent, InfiniteTableComputedColumn, InfiniteTableComputedValues, InfiniteTableContextValue, InfiniteTableGroupColumnBase, InfiniteTableGroupColumnFunction, InfiniteTableGroupColumnGetterOptions, InfiniteTableImperativeApi, InfiniteTablePivotColumn, InfiniteTablePropAutoSizeColumnsKey, InfiniteTablePropColumnGroups, InfiniteTablePropColumnOrder, InfiniteTablePropColumnPinning, InfiniteTablePropColumnSizing, InfiniteTablePropColumnTypes, InfiniteTablePropColumnVisibility, InfiniteTablePropColumns, InfiniteTablePropColumnsMap, InfiniteTablePropComponents, InfiniteTablePropGroupColumn, InfiniteTablePropGroupRenderStrategy, InfiniteTablePropRowClassName, InfiniteTablePropRowStyle, InfiniteTableProps, InfiniteTableRowClassNameFn, InfiniteTableRowInfo, InfiniteTableRowStyleFn, InfiniteTableState, LazyGroupDataDeepMap, LazyGroupDataItem, LazyGroupRowInfo, Scrollbars, debounce, flatten, getComponentStateRoot, group, interceptMap, multisort, useComponentState, useDataSource, useEffectWithChanges };
1111
+ export { ColumnTypeWithInherit, DataSource, DataSourceAction, DataSourceActionType, DataSourceAggregationReducer, DataSourceComponentActions, DataSourceContextValue, DataSourceData, DataSourceDataParams, DataSourceDataParamsChanges, DataSourceDerivedState, DataSourceExpandedAndCollapsedGroupRows, DataSourceGroupBy, DataSourceGroupRowsList, DataSourceLivePaginationCursorFn, DataSourceLivePaginationCursorParams, DataSourceLivePaginationCursorValue, DataSourceMappedState, DataSourceMappings, DataSourcePivotBy, DataSourcePropAggregationReducers, DataSourcePropGroupBy, DataSourcePropLivePaginationCursor, DataSourcePropPivotBy, DataSourceProps, DataSourceReducer, DataSourceRemoteData, DataSourceSetupState, DataSourceSingleSortInfo, DataSourceSortInfo, DataSourceState, GroupRowsState, InfiniteTable, InfiniteTableAction, InfiniteTableActionType, InfiniteTableClassName, InfiniteTableColumn, InfiniteTableColumnAggregator, InfiniteTableColumnComparer, InfiniteTableColumnGroup, InfiniteTableColumnRenderParams as InfiniteTableColumnRenderParam, InfiniteTableColumnRenderValueParam, InfiniteTableColumnRowspanParam, InfiniteTableColumnSizingOptions, InfiniteTableComponent, InfiniteTableComputedColumn, InfiniteTableComputedValues, InfiniteTableContextValue, InfiniteTableGroupColumnBase, InfiniteTableGroupColumnFunction, InfiniteTableGroupColumnGetterOptions, InfiniteTableGroupColumnRenderIconFunction, InfiniteTableImperativeApi, InfiniteTablePivotColumn, InfiniteTablePropAutoSizeColumnsKey, InfiniteTablePropColumnGroups, InfiniteTablePropColumnOrder, InfiniteTablePropColumnPinning, InfiniteTablePropColumnSizing, InfiniteTablePropColumnTypes, InfiniteTablePropColumnVisibility, InfiniteTablePropColumns, InfiniteTablePropColumnsMap, InfiniteTablePropComponents, InfiniteTablePropGroupColumn, InfiniteTablePropGroupRenderStrategy, InfiniteTablePropRowClassName, InfiniteTablePropRowStyle, InfiniteTableProps, InfiniteTableRowClassNameFn, InfiniteTableRowInfo, InfiniteTableRowStyleFn, InfiniteTableState, LazyGroupDataDeepMap, LazyGroupDataItem, LazyGroupRowInfo, Scrollbars, debounce, flatten, getComponentStateRoot, group, interceptMap, multisort, useComponentState, useDataSource, useEffectWithChanges, useInfiniteColumnCell, useInfiniteHeaderCell };