@infinite-table/infinite-react 0.2.12 → 0.2.15

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 +263 -228
  2. package/index.esm.js +367 -239
  3. package/index.js +438 -315
  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;
@@ -47,6 +47,7 @@ declare class DeepMap<KeyType, ValueType> {
47
47
  private map;
48
48
  private length;
49
49
  private revision;
50
+ private emptyKey;
50
51
  static clone<KeyType, ValueType>(map: DeepMap<KeyType, ValueType>): DeepMap<KeyType, ValueType>;
51
52
  constructor(initial?: [KeyType[], ValueType][]);
52
53
  set(keys: KeyType[] & {
@@ -77,7 +78,7 @@ declare type ComponentStateContext<T_STATE, T_ACTIONS> = {
77
78
  componentActions: T_ACTIONS;
78
79
  };
79
80
  declare type ComponentStateGeneratedActions<T_STATE> = {
80
- [k in keyof T_STATE]: T_STATE[k] | React$1.SetStateAction<T_STATE[k]>;
81
+ [k in keyof T_STATE]: T_STATE[k] | React.SetStateAction<T_STATE[k]>;
81
82
  };
82
83
  declare type ComponentInterceptedActions<T_STATE> = {
83
84
  [k in keyof T_STATE]?: (value: T_STATE[k], { actions, state, }: {
@@ -86,40 +87,28 @@ declare type ComponentInterceptedActions<T_STATE> = {
86
87
  }) => void | boolean;
87
88
  };
88
89
  declare type ComponentStateActions<T_STATE> = ComponentStateGeneratedActions<T_STATE>;
89
- declare type ForwardPropsToStateFnResult<TYPE_PROPS, TYPE_RESULT> = Partial<{
90
- [propName in keyof TYPE_PROPS & keyof TYPE_RESULT]: 1 | ((value: TYPE_PROPS[propName]) => TYPE_RESULT[propName]);
91
- }>;
92
- declare type ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE = {}, COMPONENT_DERIVED_STATE = {}, T_ACTIONS = {}, T_PARENT_STATE = {}> = {
93
- debugName?: string;
94
- initSetupState?: () => COMPONENT_SETUP_STATE;
95
- forwardProps?: (setupState: COMPONENT_SETUP_STATE) => ForwardPropsToStateFnResult<T_PROPS, COMPONENT_MAPPED_STATE>;
96
- allowedControlledPropOverrides?: Record<keyof T_PROPS, true>;
97
- interceptActions?: ComponentInterceptedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
98
- onPropChange?: (params: {
99
- name: keyof T_PROPS;
100
- oldValue: any;
101
- newValue: any;
102
- }, props: T_PROPS, actions: ComponentStateActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>) => void;
103
- mapPropsToState?: (params: {
104
- props: T_PROPS;
105
- state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>;
106
- oldState: null | (COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>);
107
- parentState: T_PARENT_STATE | null;
108
- }) => COMPONENT_DERIVED_STATE;
109
- concludeReducer?: (params: {
110
- previousState: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
111
- state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
112
- updatedProps: Partial<T_PROPS> | null;
113
- parentState: T_PARENT_STATE | null;
114
- }) => COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
115
- getReducerActions?: (dispatch: React$1.Dispatch<any>) => T_ACTIONS;
116
- getParentState?: () => T_PARENT_STATE;
117
- onControlledPropertyChange?: (name: string, newValue: any, oldValue: any) => void | ((value: any, oldValue: any) => any);
118
- };
119
- declare function getComponentStateRoot<T_PROPS, COMPONENT_MAPPED_STATE extends object, COMPONENT_SETUP_STATE extends object = {}, COMPONENT_DERIVED_STATE extends object = {}, T_ACTIONS = {}, T_PARENT_STATE = {}>(config: ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE, COMPONENT_DERIVED_STATE, T_ACTIONS, T_PARENT_STATE>): React$1.NamedExoticComponent<T_PROPS & {
120
- children: React$1.ReactNode;
121
- }>;
122
- declare function useComponentState<COMPONENT_STATE>(): ComponentStateContext<COMPONENT_STATE, ComponentStateGeneratedActions<COMPONENT_STATE>>;
90
+
91
+ declare class GroupRowsState<KeyType extends any = any> {
92
+ private expandedMap?;
93
+ private collapsedMap?;
94
+ private collapsedAll;
95
+ private expandedAll;
96
+ private initialState;
97
+ constructor(state: DataSourceExpandedAndCollapsedGroupRows<KeyType> | GroupRowsState<KeyType>);
98
+ getState(): DataSourceExpandedAndCollapsedGroupRows<KeyType>;
99
+ destroy(): void;
100
+ private update;
101
+ areAllCollapsed(): boolean;
102
+ areAllExpanded(): boolean;
103
+ collapseAll(): void;
104
+ expandAll(): void;
105
+ isGroupRowExpanded(keys: KeyType[]): boolean | undefined;
106
+ isGroupRowCollapsed(keys: KeyType[]): boolean;
107
+ setGroupRowExpanded(keys: KeyType[], shouldExpand: boolean): void;
108
+ collapseGroupRow(keys: KeyType[]): void;
109
+ expandGroupRow(keys: KeyType[]): void;
110
+ toggleGroupRow(keys: KeyType[]): void;
111
+ }
123
112
 
124
113
  declare type NonUndefined<T> = T extends undefined ? never : T;
125
114
 
@@ -230,6 +219,191 @@ declare class VirtualBrain extends Logger {
230
219
  destroy: () => void;
231
220
  }
232
221
 
222
+ declare type Renderable = React$1.ReactNode | JSX.Element;
223
+
224
+ declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
225
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
226
+ }[Keys];
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
+
243
+ declare type InfiniteTableToggleGroupRowFn = (groupKeys: any[]) => void;
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'];
252
+ value: string | number | Renderable;
253
+ groupRowInfo: InfiniteTableRowInfo<DATA_TYPE> | null;
254
+ rowIndex: number;
255
+ column: COL_TYPE;
256
+ toggleCurrentGroupRow: () => void;
257
+ toggleGroupRow: InfiniteTableToggleGroupRowFn;
258
+ groupBy: DataSourceState<DATA_TYPE>['groupBy'];
259
+ pivotBy?: DataSourceState<DATA_TYPE>['pivotBy'];
260
+ } & ({
261
+ rowInfo: InfiniteTableRowInfoNormal<DATA_TYPE>;
262
+ data: DATA_TYPE;
263
+ } | {
264
+ rowInfo: InfiniteTableRowInfoGroup<DATA_TYPE>;
265
+ data: Partial<DATA_TYPE> | null;
266
+ });
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> & {
269
+ collapsed: boolean;
270
+ groupIcon: Renderable;
271
+ };
272
+ declare type InfiniteTableColumnRenderValueParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParams<DATA_TYPE, COL_TYPE>;
273
+ declare type InfiniteTableColumnRowspanParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
274
+ rowInfo: InfiniteTableRowInfo<DATA_TYPE>;
275
+ data: DATA_TYPE | Partial<DATA_TYPE> | null;
276
+ dataArray: InfiniteTableRowInfo<DATA_TYPE>[];
277
+ rowIndex: number;
278
+ column: COL_TYPE;
279
+ };
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;
281
+ declare type InfiniteTableGroupColumnRenderIconFunction<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = (param: InfiniteTableGroupColumnRenderIconParam<DATA_TYPE, COL_TYPE>) => Renderable | null;
282
+ declare type InfiniteTableColumnHeaderRenderFunction<T> = ({ columnSortInfo, column, }: InfiniteTableColumnHeaderParams<T>) => Renderable;
283
+ declare type InfiniteTableColumnAlign = 'start' | 'center' | 'end';
284
+ declare type InfiniteTableColumnVerticalAlign = 'start' | 'center' | 'end';
285
+ declare type InfiniteTableColumnHeader<T> = Renderable | InfiniteTableColumnHeaderRenderFunction<T>;
286
+ declare type InfiniteTableColumnTypeNames = 'string' | 'number' | 'date' | string;
287
+ declare type InfiniteTableColumnWithRenderOrRenderValueOrFieldOrValueGetter<T> = RequireAtLeastOne<{
288
+ /**
289
+ * Determines the field property of the column.
290
+ */
291
+ field?: keyof T;
292
+ render?: InfiniteTableColumnRenderFunction<T>;
293
+ renderValue?: InfiniteTableColumnRenderFunction<T>;
294
+ valueGetter?: InfiniteTableColumnValueGetter<T>;
295
+ }, 'render' | 'renderValue' | 'field' | 'valueGetter'>;
296
+ declare type InfiniteTableColumnStyleFnParams<T> = {
297
+ value: Renderable;
298
+ column: InfiniteTableColumn<T>;
299
+ } & ({
300
+ data: T;
301
+ rowInfo: InfiniteTableRowInfoNormal<T>;
302
+ } | {
303
+ data: Partial<T> | null;
304
+ rowInfo: InfiniteTableRowInfoGroup<T>;
305
+ });
306
+ declare type InfiniteTableColumnStyleFn<T> = (params: InfiniteTableColumnStyleFnParams<T>) => undefined | React.CSSProperties;
307
+ declare type InfiniteTableColumnClassNameFn<T> = (params: InfiniteTableColumnStyleFnParams<T>) => undefined | string;
308
+ declare type InfiniteTableColumnStyle<T> = CSSProperties | InfiniteTableColumnStyleFn<T>;
309
+ declare type InfiniteTableColumnClassName<T> = string | InfiniteTableColumnClassNameFn<T>;
310
+ declare type InfiniteTableColumnValueGetterParams<T> = {
311
+ data: T;
312
+ rowInfo: InfiniteTableRowInfoNormal<T>;
313
+ } | {
314
+ data: Partial<T> | null;
315
+ rowInfo: InfiniteTableRowInfoGroup<T>;
316
+ };
317
+ declare type InfiniteTableColumnValueGetter<T, VALUE_GETTER_TYPE = string | number | boolean | null | undefined> = (params: InfiniteTableColumnValueGetterParams<T>) => VALUE_GETTER_TYPE;
318
+ declare type InfiniteTableColumnRowspanFn<T> = (params: InfiniteTableColumnRowspanParam<T>) => number;
319
+ declare type InfiniteTableColumnComparer<T> = (a: T, b: T) => number;
320
+ declare type InfiniteTableBaseColumn<T> = {
321
+ sortable?: boolean;
322
+ draggable?: boolean;
323
+ resizable?: boolean;
324
+ comparer?: InfiniteTableColumnComparer<T>;
325
+ defaultHiddenWhenGroupedBy?: '*' | keyof T | {
326
+ [k in keyof Partial<T>]: true;
327
+ };
328
+ align?: InfiniteTableColumnAlign;
329
+ verticalAlign?: InfiniteTableColumnVerticalAlign;
330
+ columnGroup?: string;
331
+ header?: InfiniteTableColumnHeader<T>;
332
+ name?: Renderable;
333
+ cssEllipsis?: boolean;
334
+ headerCssEllipsis?: boolean;
335
+ type?: InfiniteTableColumnTypeNames | InfiniteTableColumnTypeNames[] | null;
336
+ style?: InfiniteTableColumnStyle<T>;
337
+ className?: InfiniteTableColumnClassName<T>;
338
+ rowspan?: InfiniteTableColumnRowspanFn<T>;
339
+ valueGetter?: InfiniteTableColumnValueGetter<T>;
340
+ defaultWidth?: number;
341
+ defaultFlex?: number;
342
+ minWidth?: number;
343
+ maxWidth?: number;
344
+ components?: {
345
+ ColumnCell?: React.ComponentType<HTMLProps<HTMLDivElement>>;
346
+ HeaderCell?: React.ComponentType<HTMLProps<HTMLDivElement>>;
347
+ };
348
+ };
349
+ /**
350
+ * Defines a column in the table.
351
+ *
352
+ * @typeParam DATA_TYPE The type of the data in the table.
353
+ *
354
+ * Can be bound to a field which is a `keyof DATA_TYPE`.
355
+ */
356
+ declare type InfiniteTableColumn<DATA_TYPE> = {} & InfiniteTableBaseColumn<DATA_TYPE> & InfiniteTableColumnWithRenderOrRenderValueOrFieldOrValueGetter<DATA_TYPE>;
357
+ declare type InfiniteTableGeneratedGroupColumn<T> = InfiniteTableColumn<T> & {
358
+ groupByField: string | string[];
359
+ id?: string;
360
+ };
361
+ declare type InfiniteTablePivotColumn<T> = InfiniteTableColumn<T> & ColumnTypeWithInherit<Partial<InfiniteTablePivotFinalColumnVariant<T, any>>>;
362
+ declare type InfiniteTablePivotFinalColumnGroup<DataType, KeyType extends any = any> = InfiniteTableColumnGroup & {
363
+ pivotBy: DataSourcePivotBy<DataType>[];
364
+ pivotTotalColumnGroup?: true;
365
+ pivotGroupKeys: KeyType[];
366
+ pivotByAtIndex: PivotBy<DataType, KeyType>;
367
+ pivotGroupKey: KeyType;
368
+ pivotIndex: number;
369
+ };
370
+ declare type InfiniteTablePivotFinalColumn<DataType, KeyType extends any = any> = InfiniteTableColumn<DataType> & {
371
+ pivotBy: DataSourcePivotBy<DataType>[];
372
+ pivotColumn: true;
373
+ pivotTotalColumn: boolean;
374
+ pivotAggregator: AggregationReducer<DataType, any>;
375
+ pivotAggregatorIndex: number;
376
+ pivotGroupKeys: KeyType[];
377
+ pivotByAtIndex?: PivotBy<DataType, KeyType>;
378
+ pivotIndex: number;
379
+ pivotGroupKey: KeyType;
380
+ };
381
+ declare type InfiniteTablePivotFinalColumnVariant<DataType, KeyType extends any = any> = InfiniteTablePivotFinalColumn<DataType, KeyType>;
382
+ declare type InfiniteTableComputedColumnBase<T> = {
383
+ computedWidth: number;
384
+ computedOffset: number;
385
+ computedPinningOffset: number;
386
+ computedAbsoluteOffset: number;
387
+ computedSortable: boolean;
388
+ computedSortInfo: DataSourceSingleSortInfo<T> | null;
389
+ computedSorted: boolean;
390
+ computedSortedAsc: boolean;
391
+ computedSortedDesc: boolean;
392
+ computedSortIndex: number;
393
+ computedVisibleIndex: number;
394
+ computedMultiSort: boolean;
395
+ computedPinned: InfiniteTableColumnPinnedValues;
396
+ computedDraggable: boolean;
397
+ computedFirstInCategory: boolean;
398
+ computedLastInCategory: boolean;
399
+ computedFirst: boolean;
400
+ computedLast: boolean;
401
+ toggleSort: () => void;
402
+ id: string;
403
+ };
404
+ declare type InfiniteTableComputedColumn<T> = InfiniteTableColumn<T> & InfiniteTableComputedColumnBase<T> & Partial<InfiniteTablePivotFinalColumn<T>> & Partial<InfiniteTableGeneratedGroupColumn<T>>;
405
+ declare type InfiniteTableComputedPivotFinalColumn<T> = InfiniteTableComputedColumn<T> & InfiniteTablePivotFinalColumn<T>;
406
+
233
407
  interface DataSourceDataParams<T> {
234
408
  originalDataArray: T[];
235
409
  sortInfo?: DataSourceSortInfo<T>;
@@ -240,7 +414,7 @@ interface DataSourceDataParams<T> {
240
414
  groupKeys?: any[];
241
415
  aggregationReducers?: DataSourcePropAggregationReducers<T>;
242
416
  livePaginationCursor?: DataSourceLivePaginationCursorValue;
243
- cursorId?: DataSourceSetupState<T>['cursorId'];
417
+ __cursorId?: DataSourceSetupState<T>['cursorId'];
244
418
  changes?: DataSourceDataParamsChanges<T>;
245
419
  }
246
420
  declare type DataSourceDataParamsChanges<T> = Partial<Record<keyof Omit<DataSourceDataParams<T>, 'originalDataArray' | 'changes'>, true>>;
@@ -287,6 +461,12 @@ declare type DataSourceAggregationReducer<T, AggregationResultType> = {
287
461
  getter?: (data: T) => any;
288
462
  reducer: string | ((accumulator: any, value: any, data: T) => AggregationResultType | any);
289
463
  done?: (accumulatedValue: AggregationResultType | any, array: T[]) => AggregationResultType;
464
+ pivotColumn?: ColumnTypeWithInherit<Partial<InfiniteTableColumn<T>>> | (({ column, }: {
465
+ column: InfiniteTablePivotFinalColumnVariant<T>;
466
+ }) => ColumnTypeWithInherit<Partial<InfiniteTablePivotColumn<T>>>);
467
+ };
468
+ declare type ColumnTypeWithInherit<COL_TYPE> = COL_TYPE & {
469
+ inheritFromColumn?: string | boolean;
290
470
  };
291
471
  declare type DataSourceMappings = Record<'totals' | 'values', string>;
292
472
  declare type LazyGroupDataItem<DataType> = {
@@ -397,194 +577,6 @@ interface DataSourceReducer<T> {
397
577
  (state: DataSourceState<T>, action: DataSourceAction<any>): DataSourceState<T>;
398
578
  }
399
579
 
400
- declare function useDataSource<T>(): DataSourceState<T>;
401
-
402
- declare function DataSource<T>(props: DataSourceProps<T>): JSX.Element;
403
-
404
- declare class GroupRowsState<KeyType extends any = any> {
405
- private expandedMap?;
406
- private collapsedMap?;
407
- private collapsedAll;
408
- private expandedAll;
409
- private initialState;
410
- constructor(state: DataSourceExpandedAndCollapsedGroupRows<KeyType> | GroupRowsState<KeyType>);
411
- getState(): DataSourceExpandedAndCollapsedGroupRows<KeyType>;
412
- destroy(): void;
413
- private update;
414
- areAllCollapsed(): boolean;
415
- areAllExpanded(): boolean;
416
- collapseAll(): void;
417
- expandAll(): void;
418
- isGroupRowExpanded(keys: KeyType[]): boolean | undefined;
419
- isGroupRowCollapsed(keys: KeyType[]): boolean;
420
- setGroupRowExpanded(keys: KeyType[], shouldExpand: boolean): void;
421
- collapseGroupRow(keys: KeyType[]): void;
422
- expandGroupRow(keys: KeyType[]): void;
423
- toggleGroupRow(keys: KeyType[]): void;
424
- }
425
-
426
- declare type Renderable = React$1.ReactNode;
427
-
428
- declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
429
- [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
430
- }[Keys];
431
-
432
- declare type InfiniteTableToggleGroupRowFn = (groupKeys: any[]) => void;
433
- declare type InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
434
- value: string | number | Renderable;
435
- groupRowInfo: InfiniteTableRowInfo<DATA_TYPE> | null;
436
- rowIndex: number;
437
- column: COL_TYPE;
438
- toggleCurrentGroupRow: () => void;
439
- toggleGroupRow: InfiniteTableToggleGroupRowFn;
440
- groupBy: DataSourceState<DATA_TYPE>['groupBy'];
441
- pivotBy?: DataSourceState<DATA_TYPE>['pivotBy'];
442
- } & ({
443
- rowInfo: InfiniteTableRowInfoNormal<DATA_TYPE>;
444
- data: DATA_TYPE;
445
- } | {
446
- rowInfo: InfiniteTableRowInfoGroup<DATA_TYPE>;
447
- data: Partial<DATA_TYPE> | null;
448
- });
449
- declare type InfiniteTableGroupColumnRenderIconParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE> & {
450
- collapsed: boolean;
451
- groupIcon: Renderable;
452
- };
453
- declare type InfiniteTableColumnRenderValueParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE>;
454
- declare type InfiniteTableColumnRowspanParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
455
- rowInfo: InfiniteTableRowInfo<DATA_TYPE>;
456
- data: DATA_TYPE | Partial<DATA_TYPE> | null;
457
- dataArray: InfiniteTableRowInfo<DATA_TYPE>[];
458
- rowIndex: number;
459
- column: COL_TYPE;
460
- };
461
- interface InfiniteTableColumnHeaderRenderParams<T> {
462
- column: InfiniteTableComputedColumn<T>;
463
- columnSortInfo: DataSourceSingleSortInfo<T> | null | undefined;
464
- }
465
- 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;
466
- declare type InfiniteTableGroupColumnRenderIconFunction<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = (param: InfiniteTableGroupColumnRenderIconParam<DATA_TYPE, COL_TYPE>) => Renderable | null;
467
- declare type InfiniteTableColumnHeaderRenderFunction<T> = ({ columnSortInfo, column, }: InfiniteTableColumnHeaderRenderParams<T>) => Renderable;
468
- declare type InfiniteTableColumnAlign = 'start' | 'center' | 'end';
469
- declare type InfiniteTableColumnVerticalAlign = 'start' | 'center' | 'end';
470
- declare type InfiniteTableColumnHeader<T> = Renderable | InfiniteTableColumnHeaderRenderFunction<T>;
471
- declare type InfiniteTableColumnTypeNames = 'string' | 'number' | 'date' | string;
472
- declare type InfiniteTableColumnWithRenderOrRenderValueOrFieldOrValueGetter<T> = RequireAtLeastOne<{
473
- /**
474
- * Determines the field property of the column.
475
- */
476
- field?: keyof T;
477
- render?: InfiniteTableColumnRenderFunction<T>;
478
- renderValue?: InfiniteTableColumnRenderFunction<T>;
479
- valueGetter?: InfiniteTableColumnValueGetter<T>;
480
- }, 'render' | 'renderValue' | 'field' | 'valueGetter'>;
481
- declare type InfiniteTableColumnStyleFnParams<T> = {
482
- value: Renderable;
483
- column: InfiniteTableColumn<T>;
484
- } & ({
485
- data: T;
486
- rowInfo: InfiniteTableRowInfoNormal<T>;
487
- } | {
488
- data: Partial<T> | null;
489
- rowInfo: InfiniteTableRowInfoGroup<T>;
490
- });
491
- declare type InfiniteTableColumnStyleFn<T> = (params: InfiniteTableColumnStyleFnParams<T>) => undefined | React.CSSProperties;
492
- declare type InfiniteTableColumnClassNameFn<T> = (params: InfiniteTableColumnStyleFnParams<T>) => undefined | string;
493
- declare type InfiniteTableColumnStyle<T> = CSSProperties | InfiniteTableColumnStyleFn<T>;
494
- declare type InfiniteTableColumnClassName<T> = string | InfiniteTableColumnClassNameFn<T>;
495
- declare type InfiniteTableColumnValueGetterParams<T> = {
496
- data: T;
497
- rowInfo: InfiniteTableRowInfoNormal<T>;
498
- } | {
499
- data: Partial<T> | null;
500
- rowInfo: InfiniteTableRowInfoGroup<T>;
501
- };
502
- declare type InfiniteTableColumnValueGetter<T, VALUE_GETTER_TYPE = Renderable> = (params: InfiniteTableColumnValueGetterParams<T>) => VALUE_GETTER_TYPE;
503
- declare type InfiniteTableColumnRowspanFn<T> = (params: InfiniteTableColumnRowspanParam<T>) => number;
504
- declare type InfiniteTableColumnComparer<T> = (a: T, b: T) => number;
505
- declare type InfiniteTableBaseColumn<T> = {
506
- sortable?: boolean;
507
- draggable?: boolean;
508
- resizable?: boolean;
509
- comparer?: InfiniteTableColumnComparer<T>;
510
- defaultHiddenWhenGroupedBy?: '*' | keyof T | {
511
- [k in keyof Partial<T>]: true;
512
- };
513
- align?: InfiniteTableColumnAlign;
514
- verticalAlign?: InfiniteTableColumnVerticalAlign;
515
- columnGroup?: string;
516
- header?: InfiniteTableColumnHeader<T>;
517
- name?: Renderable;
518
- cssEllipsis?: boolean;
519
- headerCssEllipsis?: boolean;
520
- type?: InfiniteTableColumnTypeNames | InfiniteTableColumnTypeNames[] | null;
521
- style?: InfiniteTableColumnStyle<T>;
522
- className?: InfiniteTableColumnClassName<T>;
523
- rowspan?: InfiniteTableColumnRowspanFn<T>;
524
- valueGetter?: InfiniteTableColumnValueGetter<T>;
525
- defaultWidth?: number;
526
- defaultFlex?: number;
527
- minWidth?: number;
528
- maxWidth?: number;
529
- };
530
- /**
531
- * Defines a column in the table.
532
- *
533
- * @typeParam DATA_TYPE The type of the data in the table.
534
- *
535
- * Can be bound to a field which is a `keyof DATA_TYPE`.
536
- */
537
- declare type InfiniteTableColumn<DATA_TYPE> = {} & InfiniteTableBaseColumn<DATA_TYPE> & InfiniteTableColumnWithRenderOrRenderValueOrFieldOrValueGetter<DATA_TYPE>;
538
- declare type InfiniteTableGeneratedGroupColumn<T> = InfiniteTableColumn<T> & {
539
- groupByField: string | string[];
540
- id?: string;
541
- };
542
- declare type InfiniteTablePivotColumn<T> = InfiniteTableColumn<T> & Partial<InfiniteTablePivotFinalColumnVariant<T, any>>;
543
- declare type InfiniteTablePivotFinalColumnGroup<DataType, KeyType extends any = any> = InfiniteTableColumnGroup & {
544
- pivotBy: DataSourcePivotBy<DataType>[];
545
- pivotTotalColumnGroup?: true;
546
- pivotGroupKeys: KeyType[];
547
- pivotByAtIndex: PivotBy<DataType, KeyType>;
548
- pivotGroupKey: KeyType;
549
- pivotIndex: number;
550
- };
551
- declare type InfiniteTablePivotFinalColumn<DataType, KeyType extends any = any> = InfiniteTableColumn<DataType> & {
552
- pivotBy: DataSourcePivotBy<DataType>[];
553
- pivotColumn: true;
554
- pivotTotalColumn: boolean;
555
- pivotAggregator: AggregationReducer<DataType, any>;
556
- pivotAggregatorIndex: number;
557
- pivotGroupKeys: KeyType[];
558
- pivotByAtIndex?: PivotBy<DataType, KeyType>;
559
- pivotIndex: number;
560
- pivotGroupKey: KeyType;
561
- };
562
- declare type InfiniteTablePivotFinalColumnVariant<DataType, KeyType extends any = any> = InfiniteTablePivotFinalColumn<DataType, KeyType>;
563
- declare type InfiniteTableComputedColumnBase<T> = {
564
- computedWidth: number;
565
- computedOffset: number;
566
- computedPinningOffset: number;
567
- computedAbsoluteOffset: number;
568
- computedSortable: boolean;
569
- computedSortInfo: DataSourceSingleSortInfo<T> | null;
570
- computedSorted: boolean;
571
- computedSortedAsc: boolean;
572
- computedSortedDesc: boolean;
573
- computedSortIndex: number;
574
- computedVisibleIndex: number;
575
- computedMultiSort: boolean;
576
- computedPinned: InfiniteTableColumnPinnedValues;
577
- computedDraggable: boolean;
578
- computedFirstInCategory: boolean;
579
- computedLastInCategory: boolean;
580
- computedFirst: boolean;
581
- computedLast: boolean;
582
- toggleSort: () => void;
583
- id: string;
584
- };
585
- declare type InfiniteTableComputedColumn<T> = InfiniteTableColumn<T> & InfiniteTableComputedColumnBase<T> & Partial<InfiniteTablePivotFinalColumn<T>> & Partial<InfiniteTableGeneratedGroupColumn<T>>;
586
- declare type InfiniteTableComputedPivotFinalColumn<T> = InfiniteTableComputedColumn<T> & InfiniteTablePivotFinalColumn<T>;
587
-
588
580
  declare type AggregationReducer<T, AggregationResultType = any> = DataSourceAggregationReducer<T, AggregationResultType> & {
589
581
  id: string;
590
582
  };
@@ -657,12 +649,12 @@ declare type GroupBy<DataType, KeyType> = {
657
649
  column?: Partial<InfiniteTableGroupColumnBase<DataType>>;
658
650
  };
659
651
  declare type PivotBy<DataType, KeyType> = Omit<GroupBy<DataType, KeyType>, 'column'> & {
660
- column?: InfiniteTableColumn<DataType> | (({ column, }: {
652
+ column?: ColumnTypeWithInherit<Partial<InfiniteTableColumn<DataType>>> | (({ column, }: {
661
653
  column: InfiniteTablePivotFinalColumnVariant<DataType, KeyType>;
662
654
  }) => Partial<InfiniteTablePivotColumn<DataType>>);
663
655
  columnGroup?: InfiniteTableColumnGroup | (({ columnGroup, }: {
664
656
  columnGroup: InfiniteTablePivotFinalColumnGroup<DataType, KeyType>;
665
- }) => Partial<InfiniteTablePivotFinalColumnGroup<DataType>>);
657
+ }) => ColumnTypeWithInherit<Partial<InfiniteTablePivotFinalColumnGroup<DataType>>>);
666
658
  };
667
659
  declare type GroupParams<DataType, KeyType> = {
668
660
  groupBy: GroupBy<DataType, KeyType>[];
@@ -1042,6 +1034,10 @@ interface InfiniteTableContextValue<T> {
1042
1034
  getState: () => InfiniteTableState<T>;
1043
1035
  }
1044
1036
 
1037
+ declare function useInfiniteColumnCell<T>(): InfiniteTableColumnCellContextType<T>;
1038
+
1039
+ declare function useInfiniteHeaderCell<T>(): InfiniteTableColumnHeaderParams<T, InfiniteTableComputedColumn<T>>;
1040
+
1045
1041
  declare const InfiniteTableClassName: string;
1046
1042
  declare const InfiniteTableComponent: React$1.MemoExoticComponent<(<T>() => JSX.Element)>;
1047
1043
  declare function InfiniteTable<T>(props: InfiniteTableProps<T>): JSX.Element;
@@ -1052,6 +1048,45 @@ declare namespace InfiniteTable {
1052
1048
  };
1053
1049
  }
1054
1050
 
1051
+ declare function useDataSource<T>(): DataSourceState<T>;
1052
+
1053
+ declare function DataSource<T>(props: DataSourceProps<T>): JSX.Element;
1054
+
1055
+ declare type ForwardPropsToStateFnResult<TYPE_PROPS, TYPE_RESULT> = Partial<{
1056
+ [propName in keyof TYPE_PROPS & keyof TYPE_RESULT]: 1 | ((value: TYPE_PROPS[propName]) => TYPE_RESULT[propName]);
1057
+ }>;
1058
+ declare type ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE = {}, COMPONENT_DERIVED_STATE = {}, T_ACTIONS = {}, T_PARENT_STATE = {}> = {
1059
+ debugName?: string;
1060
+ initSetupState?: () => COMPONENT_SETUP_STATE;
1061
+ forwardProps?: (setupState: COMPONENT_SETUP_STATE) => ForwardPropsToStateFnResult<T_PROPS, COMPONENT_MAPPED_STATE>;
1062
+ allowedControlledPropOverrides?: Record<keyof T_PROPS, true>;
1063
+ interceptActions?: ComponentInterceptedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
1064
+ onPropChange?: (params: {
1065
+ name: keyof T_PROPS;
1066
+ oldValue: any;
1067
+ newValue: any;
1068
+ }, props: T_PROPS, actions: ComponentStateActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>) => void;
1069
+ mapPropsToState?: (params: {
1070
+ props: T_PROPS;
1071
+ state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>;
1072
+ oldState: null | (COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>);
1073
+ parentState: T_PARENT_STATE | null;
1074
+ }) => COMPONENT_DERIVED_STATE;
1075
+ concludeReducer?: (params: {
1076
+ previousState: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
1077
+ state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
1078
+ updatedProps: Partial<T_PROPS> | null;
1079
+ parentState: T_PARENT_STATE | null;
1080
+ }) => COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
1081
+ getReducerActions?: (dispatch: React$1.Dispatch<any>) => T_ACTIONS;
1082
+ getParentState?: () => T_PARENT_STATE;
1083
+ onControlledPropertyChange?: (name: string, newValue: any, oldValue: any) => void | ((value: any, oldValue: any) => any);
1084
+ };
1085
+ declare function getComponentStateRoot<T_PROPS, COMPONENT_MAPPED_STATE extends object, COMPONENT_SETUP_STATE extends object = {}, COMPONENT_DERIVED_STATE extends object = {}, T_ACTIONS = {}, T_PARENT_STATE = {}>(config: ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE, COMPONENT_DERIVED_STATE, T_ACTIONS, T_PARENT_STATE>): React$1.NamedExoticComponent<T_PROPS & {
1086
+ children: React$1.ReactNode;
1087
+ }>;
1088
+ declare function useComponentState<COMPONENT_STATE>(): ComponentStateContext<COMPONENT_STATE, ComponentStateGeneratedActions<COMPONENT_STATE>>;
1089
+
1055
1090
  declare type InterceptedMapFns<K, V> = {
1056
1091
  set?: (k: K, v: V) => void;
1057
1092
  beforeClear?: (map: Map<K, V>) => void;
@@ -1068,4 +1103,4 @@ declare function interceptMap<K, V>(map: Map<K, V>, fns: InterceptedMapFns<K, V>
1068
1103
 
1069
1104
  declare function useEffectWithChanges(fn: (changes: Record<string, any>, prevValues: Record<string, any>) => void | (() => void), deps: Record<string, any>): void;
1070
1105
 
1071
- export { 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 };
1106
+ 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 };