@infinite-table/infinite-react 0.2.12 → 0.2.13

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 +233 -226
  2. package/index.esm.js +38 -15
  3. package/index.js +38 -15
  4. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -77,7 +77,7 @@ declare type ComponentStateContext<T_STATE, T_ACTIONS> = {
77
77
  componentActions: T_ACTIONS;
78
78
  };
79
79
  declare type ComponentStateGeneratedActions<T_STATE> = {
80
- [k in keyof T_STATE]: T_STATE[k] | React$1.SetStateAction<T_STATE[k]>;
80
+ [k in keyof T_STATE]: T_STATE[k] | React.SetStateAction<T_STATE[k]>;
81
81
  };
82
82
  declare type ComponentInterceptedActions<T_STATE> = {
83
83
  [k in keyof T_STATE]?: (value: T_STATE[k], { actions, state, }: {
@@ -86,40 +86,28 @@ declare type ComponentInterceptedActions<T_STATE> = {
86
86
  }) => void | boolean;
87
87
  };
88
88
  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>>;
89
+
90
+ declare class GroupRowsState<KeyType extends any = any> {
91
+ private expandedMap?;
92
+ private collapsedMap?;
93
+ private collapsedAll;
94
+ private expandedAll;
95
+ private initialState;
96
+ constructor(state: DataSourceExpandedAndCollapsedGroupRows<KeyType> | GroupRowsState<KeyType>);
97
+ getState(): DataSourceExpandedAndCollapsedGroupRows<KeyType>;
98
+ destroy(): void;
99
+ private update;
100
+ areAllCollapsed(): boolean;
101
+ areAllExpanded(): boolean;
102
+ collapseAll(): void;
103
+ expandAll(): void;
104
+ isGroupRowExpanded(keys: KeyType[]): boolean | undefined;
105
+ isGroupRowCollapsed(keys: KeyType[]): boolean;
106
+ setGroupRowExpanded(keys: KeyType[], shouldExpand: boolean): void;
107
+ collapseGroupRow(keys: KeyType[]): void;
108
+ expandGroupRow(keys: KeyType[]): void;
109
+ toggleGroupRow(keys: KeyType[]): void;
110
+ }
123
111
 
124
112
  declare type NonUndefined<T> = T extends undefined ? never : T;
125
113
 
@@ -230,6 +218,168 @@ declare class VirtualBrain extends Logger {
230
218
  destroy: () => void;
231
219
  }
232
220
 
221
+ declare type Renderable = React$1.ReactNode;
222
+
223
+ declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
224
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
225
+ }[Keys];
226
+
227
+ declare type InfiniteTableToggleGroupRowFn = (groupKeys: any[]) => void;
228
+ declare type InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
229
+ value: string | number | Renderable;
230
+ groupRowInfo: InfiniteTableRowInfo<DATA_TYPE> | null;
231
+ rowIndex: number;
232
+ column: COL_TYPE;
233
+ toggleCurrentGroupRow: () => void;
234
+ toggleGroupRow: InfiniteTableToggleGroupRowFn;
235
+ groupBy: DataSourceState<DATA_TYPE>['groupBy'];
236
+ pivotBy?: DataSourceState<DATA_TYPE>['pivotBy'];
237
+ } & ({
238
+ rowInfo: InfiniteTableRowInfoNormal<DATA_TYPE>;
239
+ data: DATA_TYPE;
240
+ } | {
241
+ rowInfo: InfiniteTableRowInfoGroup<DATA_TYPE>;
242
+ data: Partial<DATA_TYPE> | null;
243
+ });
244
+ declare type InfiniteTableGroupColumnRenderIconParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE> & {
245
+ collapsed: boolean;
246
+ groupIcon: Renderable;
247
+ };
248
+ declare type InfiniteTableColumnRenderValueParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = InfiniteTableColumnRenderParam<DATA_TYPE, COL_TYPE>;
249
+ declare type InfiniteTableColumnRowspanParam<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = {
250
+ rowInfo: InfiniteTableRowInfo<DATA_TYPE>;
251
+ data: DATA_TYPE | Partial<DATA_TYPE> | null;
252
+ dataArray: InfiniteTableRowInfo<DATA_TYPE>[];
253
+ rowIndex: number;
254
+ column: COL_TYPE;
255
+ };
256
+ interface InfiniteTableColumnHeaderRenderParams<T> {
257
+ column: InfiniteTableComputedColumn<T>;
258
+ columnSortInfo: DataSourceSingleSortInfo<T> | null | undefined;
259
+ }
260
+ 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;
261
+ declare type InfiniteTableGroupColumnRenderIconFunction<DATA_TYPE, COL_TYPE = InfiniteTableComputedColumn<DATA_TYPE>> = (param: InfiniteTableGroupColumnRenderIconParam<DATA_TYPE, COL_TYPE>) => Renderable | null;
262
+ declare type InfiniteTableColumnHeaderRenderFunction<T> = ({ columnSortInfo, column, }: InfiniteTableColumnHeaderRenderParams<T>) => Renderable;
263
+ declare type InfiniteTableColumnAlign = 'start' | 'center' | 'end';
264
+ declare type InfiniteTableColumnVerticalAlign = 'start' | 'center' | 'end';
265
+ declare type InfiniteTableColumnHeader<T> = Renderable | InfiniteTableColumnHeaderRenderFunction<T>;
266
+ declare type InfiniteTableColumnTypeNames = 'string' | 'number' | 'date' | string;
267
+ declare type InfiniteTableColumnWithRenderOrRenderValueOrFieldOrValueGetter<T> = RequireAtLeastOne<{
268
+ /**
269
+ * Determines the field property of the column.
270
+ */
271
+ field?: keyof T;
272
+ render?: InfiniteTableColumnRenderFunction<T>;
273
+ renderValue?: InfiniteTableColumnRenderFunction<T>;
274
+ valueGetter?: InfiniteTableColumnValueGetter<T>;
275
+ }, 'render' | 'renderValue' | 'field' | 'valueGetter'>;
276
+ declare type InfiniteTableColumnStyleFnParams<T> = {
277
+ value: Renderable;
278
+ column: InfiniteTableColumn<T>;
279
+ } & ({
280
+ data: T;
281
+ rowInfo: InfiniteTableRowInfoNormal<T>;
282
+ } | {
283
+ data: Partial<T> | null;
284
+ rowInfo: InfiniteTableRowInfoGroup<T>;
285
+ });
286
+ declare type InfiniteTableColumnStyleFn<T> = (params: InfiniteTableColumnStyleFnParams<T>) => undefined | React.CSSProperties;
287
+ declare type InfiniteTableColumnClassNameFn<T> = (params: InfiniteTableColumnStyleFnParams<T>) => undefined | string;
288
+ declare type InfiniteTableColumnStyle<T> = CSSProperties | InfiniteTableColumnStyleFn<T>;
289
+ declare type InfiniteTableColumnClassName<T> = string | InfiniteTableColumnClassNameFn<T>;
290
+ declare type InfiniteTableColumnValueGetterParams<T> = {
291
+ data: T;
292
+ rowInfo: InfiniteTableRowInfoNormal<T>;
293
+ } | {
294
+ data: Partial<T> | null;
295
+ rowInfo: InfiniteTableRowInfoGroup<T>;
296
+ };
297
+ declare type InfiniteTableColumnValueGetter<T, VALUE_GETTER_TYPE = Renderable> = (params: InfiniteTableColumnValueGetterParams<T>) => VALUE_GETTER_TYPE;
298
+ declare type InfiniteTableColumnRowspanFn<T> = (params: InfiniteTableColumnRowspanParam<T>) => number;
299
+ declare type InfiniteTableColumnComparer<T> = (a: T, b: T) => number;
300
+ declare type InfiniteTableBaseColumn<T> = {
301
+ sortable?: boolean;
302
+ draggable?: boolean;
303
+ resizable?: boolean;
304
+ comparer?: InfiniteTableColumnComparer<T>;
305
+ defaultHiddenWhenGroupedBy?: '*' | keyof T | {
306
+ [k in keyof Partial<T>]: true;
307
+ };
308
+ align?: InfiniteTableColumnAlign;
309
+ verticalAlign?: InfiniteTableColumnVerticalAlign;
310
+ columnGroup?: string;
311
+ header?: InfiniteTableColumnHeader<T>;
312
+ name?: Renderable;
313
+ cssEllipsis?: boolean;
314
+ headerCssEllipsis?: boolean;
315
+ type?: InfiniteTableColumnTypeNames | InfiniteTableColumnTypeNames[] | null;
316
+ style?: InfiniteTableColumnStyle<T>;
317
+ className?: InfiniteTableColumnClassName<T>;
318
+ rowspan?: InfiniteTableColumnRowspanFn<T>;
319
+ valueGetter?: InfiniteTableColumnValueGetter<T>;
320
+ defaultWidth?: number;
321
+ defaultFlex?: number;
322
+ minWidth?: number;
323
+ maxWidth?: number;
324
+ };
325
+ /**
326
+ * Defines a column in the table.
327
+ *
328
+ * @typeParam DATA_TYPE The type of the data in the table.
329
+ *
330
+ * Can be bound to a field which is a `keyof DATA_TYPE`.
331
+ */
332
+ declare type InfiniteTableColumn<DATA_TYPE> = {} & InfiniteTableBaseColumn<DATA_TYPE> & InfiniteTableColumnWithRenderOrRenderValueOrFieldOrValueGetter<DATA_TYPE>;
333
+ declare type InfiniteTableGeneratedGroupColumn<T> = InfiniteTableColumn<T> & {
334
+ groupByField: string | string[];
335
+ id?: string;
336
+ };
337
+ declare type InfiniteTablePivotColumn<T> = InfiniteTableColumn<T> & ColumnTypeWithInherit<Partial<InfiniteTablePivotFinalColumnVariant<T, any>>>;
338
+ declare type InfiniteTablePivotFinalColumnGroup<DataType, KeyType extends any = any> = InfiniteTableColumnGroup & {
339
+ pivotBy: DataSourcePivotBy<DataType>[];
340
+ pivotTotalColumnGroup?: true;
341
+ pivotGroupKeys: KeyType[];
342
+ pivotByAtIndex: PivotBy<DataType, KeyType>;
343
+ pivotGroupKey: KeyType;
344
+ pivotIndex: number;
345
+ };
346
+ declare type InfiniteTablePivotFinalColumn<DataType, KeyType extends any = any> = InfiniteTableColumn<DataType> & {
347
+ pivotBy: DataSourcePivotBy<DataType>[];
348
+ pivotColumn: true;
349
+ pivotTotalColumn: boolean;
350
+ pivotAggregator: AggregationReducer<DataType, any>;
351
+ pivotAggregatorIndex: number;
352
+ pivotGroupKeys: KeyType[];
353
+ pivotByAtIndex?: PivotBy<DataType, KeyType>;
354
+ pivotIndex: number;
355
+ pivotGroupKey: KeyType;
356
+ };
357
+ declare type InfiniteTablePivotFinalColumnVariant<DataType, KeyType extends any = any> = InfiniteTablePivotFinalColumn<DataType, KeyType>;
358
+ declare type InfiniteTableComputedColumnBase<T> = {
359
+ computedWidth: number;
360
+ computedOffset: number;
361
+ computedPinningOffset: number;
362
+ computedAbsoluteOffset: number;
363
+ computedSortable: boolean;
364
+ computedSortInfo: DataSourceSingleSortInfo<T> | null;
365
+ computedSorted: boolean;
366
+ computedSortedAsc: boolean;
367
+ computedSortedDesc: boolean;
368
+ computedSortIndex: number;
369
+ computedVisibleIndex: number;
370
+ computedMultiSort: boolean;
371
+ computedPinned: InfiniteTableColumnPinnedValues;
372
+ computedDraggable: boolean;
373
+ computedFirstInCategory: boolean;
374
+ computedLastInCategory: boolean;
375
+ computedFirst: boolean;
376
+ computedLast: boolean;
377
+ toggleSort: () => void;
378
+ id: string;
379
+ };
380
+ declare type InfiniteTableComputedColumn<T> = InfiniteTableColumn<T> & InfiniteTableComputedColumnBase<T> & Partial<InfiniteTablePivotFinalColumn<T>> & Partial<InfiniteTableGeneratedGroupColumn<T>>;
381
+ declare type InfiniteTableComputedPivotFinalColumn<T> = InfiniteTableComputedColumn<T> & InfiniteTablePivotFinalColumn<T>;
382
+
233
383
  interface DataSourceDataParams<T> {
234
384
  originalDataArray: T[];
235
385
  sortInfo?: DataSourceSortInfo<T>;
@@ -287,6 +437,12 @@ declare type DataSourceAggregationReducer<T, AggregationResultType> = {
287
437
  getter?: (data: T) => any;
288
438
  reducer: string | ((accumulator: any, value: any, data: T) => AggregationResultType | any);
289
439
  done?: (accumulatedValue: AggregationResultType | any, array: T[]) => AggregationResultType;
440
+ pivotColumn?: ColumnTypeWithInherit<Partial<InfiniteTableColumn<T>>> | (({ column, }: {
441
+ column: InfiniteTablePivotFinalColumnVariant<T>;
442
+ }) => ColumnTypeWithInherit<Partial<InfiniteTablePivotColumn<T>>>);
443
+ };
444
+ declare type ColumnTypeWithInherit<COL_TYPE> = COL_TYPE & {
445
+ inheritFromColumn?: string | boolean;
290
446
  };
291
447
  declare type DataSourceMappings = Record<'totals' | 'values', string>;
292
448
  declare type LazyGroupDataItem<DataType> = {
@@ -397,194 +553,6 @@ interface DataSourceReducer<T> {
397
553
  (state: DataSourceState<T>, action: DataSourceAction<any>): DataSourceState<T>;
398
554
  }
399
555
 
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
556
  declare type AggregationReducer<T, AggregationResultType = any> = DataSourceAggregationReducer<T, AggregationResultType> & {
589
557
  id: string;
590
558
  };
@@ -657,12 +625,12 @@ declare type GroupBy<DataType, KeyType> = {
657
625
  column?: Partial<InfiniteTableGroupColumnBase<DataType>>;
658
626
  };
659
627
  declare type PivotBy<DataType, KeyType> = Omit<GroupBy<DataType, KeyType>, 'column'> & {
660
- column?: InfiniteTableColumn<DataType> | (({ column, }: {
628
+ column?: ColumnTypeWithInherit<Partial<InfiniteTableColumn<DataType>>> | (({ column, }: {
661
629
  column: InfiniteTablePivotFinalColumnVariant<DataType, KeyType>;
662
630
  }) => Partial<InfiniteTablePivotColumn<DataType>>);
663
631
  columnGroup?: InfiniteTableColumnGroup | (({ columnGroup, }: {
664
632
  columnGroup: InfiniteTablePivotFinalColumnGroup<DataType, KeyType>;
665
- }) => Partial<InfiniteTablePivotFinalColumnGroup<DataType>>);
633
+ }) => ColumnTypeWithInherit<Partial<InfiniteTablePivotFinalColumnGroup<DataType>>>);
666
634
  };
667
635
  declare type GroupParams<DataType, KeyType> = {
668
636
  groupBy: GroupBy<DataType, KeyType>[];
@@ -1052,6 +1020,45 @@ declare namespace InfiniteTable {
1052
1020
  };
1053
1021
  }
1054
1022
 
1023
+ declare function useDataSource<T>(): DataSourceState<T>;
1024
+
1025
+ declare function DataSource<T>(props: DataSourceProps<T>): JSX.Element;
1026
+
1027
+ declare type ForwardPropsToStateFnResult<TYPE_PROPS, TYPE_RESULT> = Partial<{
1028
+ [propName in keyof TYPE_PROPS & keyof TYPE_RESULT]: 1 | ((value: TYPE_PROPS[propName]) => TYPE_RESULT[propName]);
1029
+ }>;
1030
+ declare type ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE = {}, COMPONENT_DERIVED_STATE = {}, T_ACTIONS = {}, T_PARENT_STATE = {}> = {
1031
+ debugName?: string;
1032
+ initSetupState?: () => COMPONENT_SETUP_STATE;
1033
+ forwardProps?: (setupState: COMPONENT_SETUP_STATE) => ForwardPropsToStateFnResult<T_PROPS, COMPONENT_MAPPED_STATE>;
1034
+ allowedControlledPropOverrides?: Record<keyof T_PROPS, true>;
1035
+ interceptActions?: ComponentInterceptedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
1036
+ onPropChange?: (params: {
1037
+ name: keyof T_PROPS;
1038
+ oldValue: any;
1039
+ newValue: any;
1040
+ }, props: T_PROPS, actions: ComponentStateActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>) => void;
1041
+ mapPropsToState?: (params: {
1042
+ props: T_PROPS;
1043
+ state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>;
1044
+ oldState: null | (COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>);
1045
+ parentState: T_PARENT_STATE | null;
1046
+ }) => COMPONENT_DERIVED_STATE;
1047
+ concludeReducer?: (params: {
1048
+ previousState: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
1049
+ state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
1050
+ updatedProps: Partial<T_PROPS> | null;
1051
+ parentState: T_PARENT_STATE | null;
1052
+ }) => COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
1053
+ getReducerActions?: (dispatch: React$1.Dispatch<any>) => T_ACTIONS;
1054
+ getParentState?: () => T_PARENT_STATE;
1055
+ onControlledPropertyChange?: (name: string, newValue: any, oldValue: any) => void | ((value: any, oldValue: any) => any);
1056
+ };
1057
+ 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 & {
1058
+ children: React$1.ReactNode;
1059
+ }>;
1060
+ declare function useComponentState<COMPONENT_STATE>(): ComponentStateContext<COMPONENT_STATE, ComponentStateGeneratedActions<COMPONENT_STATE>>;
1061
+
1055
1062
  declare type InterceptedMapFns<K, V> = {
1056
1063
  set?: (k: K, v: V) => void;
1057
1064
  beforeClear?: (map: Map<K, V>) => void;
@@ -1068,4 +1075,4 @@ declare function interceptMap<K, V>(map: Map<K, V>, fns: InterceptedMapFns<K, V>
1068
1075
 
1069
1076
  declare function useEffectWithChanges(fn: (changes: Record<string, any>, prevValues: Record<string, any>) => void | (() => void), deps: Record<string, any>): void;
1070
1077
 
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 };
1078
+ 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 };
package/index.esm.js CHANGED
@@ -2144,7 +2144,7 @@ var sortAscending = (a, b) => a - b;
2144
2144
  // src/components/InfiniteTable/hooks/useComputed.ts
2145
2145
  import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo6, useState as useState5 } from "react";
2146
2146
 
2147
- // src/components/hooks/useComponentState.tsx
2147
+ // src/components/hooks/useComponentState/index.tsx
2148
2148
  import {
2149
2149
  createElement as createElement2,
2150
2150
  memo,
@@ -2217,7 +2217,7 @@ var usePrevious = (value, initialValue) => {
2217
2217
  return ref.current;
2218
2218
  };
2219
2219
 
2220
- // src/components/hooks/useComponentState.tsx
2220
+ // src/components/hooks/useComponentState/index.tsx
2221
2221
  var notifyChange = (props, propName, newValue) => {
2222
2222
  const upperPropName = toUpperFirst(propName);
2223
2223
  const callbackPropName = `on${upperPropName}Change`;
@@ -3612,10 +3612,14 @@ function loadData(data, componentState, actions, overrides) {
3612
3612
  lazyGroupData.set(key, newGroupRowInfo);
3613
3613
  }
3614
3614
  skipAssign = true;
3615
- actions.originalLazyGroupDataChangeDetect = getChangeDetect();
3615
+ let skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = false;
3616
3616
  if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
3617
3617
  const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
3618
3618
  actions.originalDataArray = [...topLevelItems.items];
3619
+ skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = true;
3620
+ }
3621
+ if (!skipTriggerChangeAsAlreadyOriginalArrayWasUpdated) {
3622
+ actions.originalLazyGroupDataChangeDetect = getChangeDetect();
3619
3623
  }
3620
3624
  }
3621
3625
  } else {
@@ -3722,13 +3726,13 @@ function useLazyLoadRange() {
3722
3726
  scrollStopDelayUpdatedByTable
3723
3727
  } = componentState;
3724
3728
  const latestRenderRangeRef = useRef6(null);
3725
- const loadRange = (param, cache = loadingCache) => {
3729
+ const loadRange = (renderRange, cache = loadingCache) => {
3726
3730
  const componentState2 = getComponentState();
3727
- param = param || latestRenderRangeRef.current;
3728
- if (!param) {
3731
+ renderRange = renderRange || latestRenderRangeRef.current;
3732
+ if (!renderRange) {
3729
3733
  return;
3730
3734
  }
3731
- const { renderStartIndex: startIndex, renderEndIndex: endIndex } = param;
3735
+ const { renderStartIndex: startIndex, renderEndIndex: endIndex } = renderRange;
3732
3736
  if (!lazyLoadBatchSize || lazyLoadBatchSize <= 0) {
3733
3737
  return;
3734
3738
  }
@@ -3743,9 +3747,9 @@ function useLazyLoadRange() {
3743
3747
  const debouncedLoadRange = useMemo4(() => debounce(loadRange, { wait: scrollStopDelayUpdatedByTable }), [scrollStopDelayUpdatedByTable]);
3744
3748
  useEffect8(() => {
3745
3749
  if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
3746
- return notifyRenderRangeChange.onChange((param) => {
3747
- latestRenderRangeRef.current = param;
3748
- loadRange(param, loadingCache);
3750
+ return notifyRenderRangeChange.onChange((renderRange) => {
3751
+ latestRenderRangeRef.current = renderRange;
3752
+ loadRange(renderRange, loadingCache);
3749
3753
  });
3750
3754
  }
3751
3755
  return;
@@ -4181,7 +4185,7 @@ function getInterceptActions() {
4181
4185
 
4182
4186
  // src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
4183
4187
  function prepareColumn(column) {
4184
- const { pivotByAtIndex: pivotByForColumn } = column;
4188
+ const { pivotByAtIndex: pivotByForColumn, pivotAggregator } = column;
4185
4189
  if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
4186
4190
  if (typeof pivotByForColumn.column === "function") {
4187
4191
  Object.assign(column, pivotByForColumn.column({ column }));
@@ -4189,6 +4193,13 @@ function prepareColumn(column) {
4189
4193
  Object.assign(column, pivotByForColumn.column);
4190
4194
  }
4191
4195
  }
4196
+ if (pivotAggregator == null ? void 0 : pivotAggregator.pivotColumn) {
4197
+ if (typeof pivotAggregator.pivotColumn === "function") {
4198
+ Object.assign(column, pivotAggregator.pivotColumn({ column }));
4199
+ } else {
4200
+ Object.assign(column, pivotAggregator.pivotColumn);
4201
+ }
4202
+ }
4192
4203
  return column;
4193
4204
  }
4194
4205
  function prepareColumnGroup(columnGroup) {
@@ -4861,7 +4872,14 @@ function getColumnsWhenGrouping(params) {
4861
4872
  computedColumns.set(singleGroupColumn.id || "group-by", singleGroupColumn);
4862
4873
  }
4863
4874
  if (pivotColumns) {
4875
+ const columnsByField = {};
4876
+ columns.forEach((col) => {
4877
+ if (col.field) {
4878
+ columnsByField[col.field] = col;
4879
+ }
4880
+ });
4864
4881
  pivotColumns.forEach((col, key) => {
4882
+ var _a, _b;
4865
4883
  if (col.pivotTotalColumn && pivotTotalColumnPosition === false) {
4866
4884
  return;
4867
4885
  }
@@ -4877,6 +4895,10 @@ function getColumnsWhenGrouping(params) {
4877
4895
  column = __spreadValues(__spreadValues({}, column), pivotColumn);
4878
4896
  }
4879
4897
  }
4898
+ if (column.inheritFromColumn !== false) {
4899
+ const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns.get(column.inheritFromColumn) : ((_a = column.pivotAggregator) == null ? void 0 : _a.field) ? columnsByField[(_b = column.pivotAggregator) == null ? void 0 : _b.field] : void 0;
4900
+ column = __spreadValues(__spreadValues({}, colToInheritFrom), column);
4901
+ }
4880
4902
  if (!column.render && column.renderValue) {
4881
4903
  column.render = (renderOptions) => {
4882
4904
  return column.renderValue(renderOptions);
@@ -7315,8 +7337,8 @@ function PinnedRowsContainer(props) {
7315
7337
  }
7316
7338
  function useRenderPinnedRow(params) {
7317
7339
  const { getData, getState, columnsWidth, columns, rowSpan, verticalBrain } = params;
7340
+ const dataArray = getData();
7318
7341
  const renderPinnedRow = useCallback15((rowParams) => {
7319
- const dataArray = getData();
7320
7342
  const rowInfo = dataArray[rowParams.rowIndex];
7321
7343
  const { showZebraRows, showHoverRows } = getState();
7322
7344
  const rowProps = __spreadValues({
@@ -7333,7 +7355,7 @@ function useRenderPinnedRow(params) {
7333
7355
  columns
7334
7356
  }, rowParams);
7335
7357
  return /* @__PURE__ */ createElement28(TableRowUnvirtualized, __spreadValues({}, rowProps));
7336
- }, [columnsWidth, columns, verticalBrain]);
7358
+ }, [columnsWidth, columns, verticalBrain, dataArray]);
7337
7359
  return renderPinnedRow;
7338
7360
  }
7339
7361
  function usePinnedRenderingForSide(side, params) {
@@ -7371,6 +7393,7 @@ function usePinnedRenderingForSide(side, params) {
7371
7393
  const renderRowPinned = useRenderPinnedRow({
7372
7394
  getData,
7373
7395
  getState,
7396
+ repaintId,
7374
7397
  toggleGroupRow,
7375
7398
  rowSpan,
7376
7399
  verticalBrain: verticalVirtualBrain,
@@ -7516,7 +7539,7 @@ function useListRendering(param) {
7516
7539
  } = componentState;
7517
7540
  const prevDataSourceTimestamp = usePrevious(dataSourceState.updatedAt);
7518
7541
  const repaintIdRef = useRef17(0);
7519
- if (!shallowEqualObjects(prevComputed, computed) || prevDataSourceTimestamp !== dataSourceState.updatedAt) {
7542
+ if (prevDataSourceTimestamp !== dataSourceState.updatedAt || !shallowEqualObjects(prevComputed, computed)) {
7520
7543
  repaintIdRef.current++;
7521
7544
  }
7522
7545
  const repaintId = repaintIdRef.current;
@@ -7861,7 +7884,7 @@ var useLicense = (licenseKey = "") => {
7861
7884
  const valid = useMemo12(() => {
7862
7885
  let valid2 = isValidLicense(licenseKey, {
7863
7886
  publishedAt: 1624970570587,
7864
- version: "0.2.12"
7887
+ version: "0.2.13"
7865
7888
  });
7866
7889
  if (!licenseKey && !valid2 && isInsidePlayground) {
7867
7890
  return true;
package/index.js CHANGED
@@ -2154,7 +2154,7 @@ var sortAscending = (a, b) => a - b;
2154
2154
  // src/components/InfiniteTable/hooks/useComputed.ts
2155
2155
  var import_react18 = __toModule(require("react"));
2156
2156
 
2157
- // src/components/hooks/useComponentState.tsx
2157
+ // src/components/hooks/useComponentState/index.tsx
2158
2158
  var React2 = __toModule(require("react"));
2159
2159
  var import_react11 = __toModule(require("react"));
2160
2160
 
@@ -2216,7 +2216,7 @@ var usePrevious = (value, initialValue) => {
2216
2216
  return ref.current;
2217
2217
  };
2218
2218
 
2219
- // src/components/hooks/useComponentState.tsx
2219
+ // src/components/hooks/useComponentState/index.tsx
2220
2220
  var notifyChange = (props, propName, newValue) => {
2221
2221
  const upperPropName = toUpperFirst(propName);
2222
2222
  const callbackPropName = `on${upperPropName}Change`;
@@ -3599,10 +3599,14 @@ function loadData(data, componentState, actions, overrides) {
3599
3599
  lazyGroupData.set(key, newGroupRowInfo);
3600
3600
  }
3601
3601
  skipAssign = true;
3602
- actions.originalLazyGroupDataChangeDetect = getChangeDetect();
3602
+ let skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = false;
3603
3603
  if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
3604
3604
  const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
3605
3605
  actions.originalDataArray = [...topLevelItems.items];
3606
+ skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = true;
3607
+ }
3608
+ if (!skipTriggerChangeAsAlreadyOriginalArrayWasUpdated) {
3609
+ actions.originalLazyGroupDataChangeDetect = getChangeDetect();
3606
3610
  }
3607
3611
  }
3608
3612
  } else {
@@ -3709,13 +3713,13 @@ function useLazyLoadRange() {
3709
3713
  scrollStopDelayUpdatedByTable
3710
3714
  } = componentState;
3711
3715
  const latestRenderRangeRef = (0, import_react15.useRef)(null);
3712
- const loadRange = (param, cache = loadingCache) => {
3716
+ const loadRange = (renderRange, cache = loadingCache) => {
3713
3717
  const componentState2 = getComponentState();
3714
- param = param || latestRenderRangeRef.current;
3715
- if (!param) {
3718
+ renderRange = renderRange || latestRenderRangeRef.current;
3719
+ if (!renderRange) {
3716
3720
  return;
3717
3721
  }
3718
- const { renderStartIndex: startIndex, renderEndIndex: endIndex } = param;
3722
+ const { renderStartIndex: startIndex, renderEndIndex: endIndex } = renderRange;
3719
3723
  if (!lazyLoadBatchSize || lazyLoadBatchSize <= 0) {
3720
3724
  return;
3721
3725
  }
@@ -3730,9 +3734,9 @@ function useLazyLoadRange() {
3730
3734
  const debouncedLoadRange = (0, import_react15.useMemo)(() => debounce(loadRange, { wait: scrollStopDelayUpdatedByTable }), [scrollStopDelayUpdatedByTable]);
3731
3735
  (0, import_react15.useEffect)(() => {
3732
3736
  if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
3733
- return notifyRenderRangeChange.onChange((param) => {
3734
- latestRenderRangeRef.current = param;
3735
- loadRange(param, loadingCache);
3737
+ return notifyRenderRangeChange.onChange((renderRange) => {
3738
+ latestRenderRangeRef.current = renderRange;
3739
+ loadRange(renderRange, loadingCache);
3736
3740
  });
3737
3741
  }
3738
3742
  return;
@@ -4168,7 +4172,7 @@ function getInterceptActions() {
4168
4172
 
4169
4173
  // src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts
4170
4174
  function prepareColumn(column) {
4171
- const { pivotByAtIndex: pivotByForColumn } = column;
4175
+ const { pivotByAtIndex: pivotByForColumn, pivotAggregator } = column;
4172
4176
  if (pivotByForColumn == null ? void 0 : pivotByForColumn.column) {
4173
4177
  if (typeof pivotByForColumn.column === "function") {
4174
4178
  Object.assign(column, pivotByForColumn.column({ column }));
@@ -4176,6 +4180,13 @@ function prepareColumn(column) {
4176
4180
  Object.assign(column, pivotByForColumn.column);
4177
4181
  }
4178
4182
  }
4183
+ if (pivotAggregator == null ? void 0 : pivotAggregator.pivotColumn) {
4184
+ if (typeof pivotAggregator.pivotColumn === "function") {
4185
+ Object.assign(column, pivotAggregator.pivotColumn({ column }));
4186
+ } else {
4187
+ Object.assign(column, pivotAggregator.pivotColumn);
4188
+ }
4189
+ }
4179
4190
  return column;
4180
4191
  }
4181
4192
  function prepareColumnGroup(columnGroup) {
@@ -4848,7 +4859,14 @@ function getColumnsWhenGrouping(params) {
4848
4859
  computedColumns.set(singleGroupColumn.id || "group-by", singleGroupColumn);
4849
4860
  }
4850
4861
  if (pivotColumns) {
4862
+ const columnsByField = {};
4863
+ columns.forEach((col) => {
4864
+ if (col.field) {
4865
+ columnsByField[col.field] = col;
4866
+ }
4867
+ });
4851
4868
  pivotColumns.forEach((col, key) => {
4869
+ var _a, _b;
4852
4870
  if (col.pivotTotalColumn && pivotTotalColumnPosition === false) {
4853
4871
  return;
4854
4872
  }
@@ -4864,6 +4882,10 @@ function getColumnsWhenGrouping(params) {
4864
4882
  column = __spreadValues(__spreadValues({}, column), pivotColumn);
4865
4883
  }
4866
4884
  }
4885
+ if (column.inheritFromColumn !== false) {
4886
+ const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns.get(column.inheritFromColumn) : ((_a = column.pivotAggregator) == null ? void 0 : _a.field) ? columnsByField[(_b = column.pivotAggregator) == null ? void 0 : _b.field] : void 0;
4887
+ column = __spreadValues(__spreadValues({}, colToInheritFrom), column);
4888
+ }
4867
4889
  if (!column.render && column.renderValue) {
4868
4890
  column.render = (renderOptions) => {
4869
4891
  return column.renderValue(renderOptions);
@@ -7228,8 +7250,8 @@ function PinnedRowsContainer(props) {
7228
7250
  }
7229
7251
  function useRenderPinnedRow(params) {
7230
7252
  const { getData, getState, columnsWidth, columns, rowSpan, verticalBrain } = params;
7253
+ const dataArray = getData();
7231
7254
  const renderPinnedRow = (0, import_react37.useCallback)((rowParams) => {
7232
- const dataArray = getData();
7233
7255
  const rowInfo = dataArray[rowParams.rowIndex];
7234
7256
  const { showZebraRows, showHoverRows } = getState();
7235
7257
  const rowProps = __spreadValues({
@@ -7246,7 +7268,7 @@ function useRenderPinnedRow(params) {
7246
7268
  columns
7247
7269
  }, rowParams);
7248
7270
  return /* @__PURE__ */ React30.createElement(TableRowUnvirtualized, __spreadValues({}, rowProps));
7249
- }, [columnsWidth, columns, verticalBrain]);
7271
+ }, [columnsWidth, columns, verticalBrain, dataArray]);
7250
7272
  return renderPinnedRow;
7251
7273
  }
7252
7274
  function usePinnedRenderingForSide(side, params) {
@@ -7284,6 +7306,7 @@ function usePinnedRenderingForSide(side, params) {
7284
7306
  const renderRowPinned = useRenderPinnedRow({
7285
7307
  getData,
7286
7308
  getState,
7309
+ repaintId,
7287
7310
  toggleGroupRow,
7288
7311
  rowSpan,
7289
7312
  verticalBrain: verticalVirtualBrain,
@@ -7429,7 +7452,7 @@ function useListRendering(param) {
7429
7452
  } = componentState;
7430
7453
  const prevDataSourceTimestamp = usePrevious(dataSourceState.updatedAt);
7431
7454
  const repaintIdRef = (0, import_react40.useRef)(0);
7432
- if (!shallowEqualObjects(prevComputed, computed) || prevDataSourceTimestamp !== dataSourceState.updatedAt) {
7455
+ if (prevDataSourceTimestamp !== dataSourceState.updatedAt || !shallowEqualObjects(prevComputed, computed)) {
7433
7456
  repaintIdRef.current++;
7434
7457
  }
7435
7458
  const repaintId = repaintIdRef.current;
@@ -7769,7 +7792,7 @@ var useLicense = (licenseKey = "") => {
7769
7792
  const valid = (0, import_react42.useMemo)(() => {
7770
7793
  let valid2 = isValidLicense(licenseKey, {
7771
7794
  publishedAt: 1624970570587,
7772
- version: "0.2.12"
7795
+ version: "0.2.13"
7773
7796
  });
7774
7797
  if (!licenseKey && !valid2 && isInsidePlayground) {
7775
7798
  return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infinite-table/infinite-react",
3
3
  "description": "Infinite Table for React",
4
- "version": "0.2.12",
4
+ "version": "0.2.13",
5
5
  "main": "index.js",
6
6
  "module": "index.esm.js",
7
7
  "typings": "index.d.ts",
@@ -14,5 +14,5 @@
14
14
  },
15
15
  "license": "Commercial & Open Source",
16
16
  "//": "will be updated at build time",
17
- "publishedAt": 1646828095950
17
+ "publishedAt": 1647043236196
18
18
  }