@infinite-table/infinite-react 1.3.23 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. package/index.d.ts +35 -10
  2. package/index.dev.js +10348 -10256
  3. package/index.dev.mjs +10350 -10258
  4. package/index.js +5 -5
  5. package/index.mjs +5 -5
  6. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare type MultisortInfo<T> = {
11
11
  * for now 'string' and 'number' are known types, meaning they have
12
12
  * sort functions already implemented
13
13
  */
14
- type?: string;
14
+ type?: string | string[];
15
15
  fn?: (a: any, b: any) => number;
16
16
  /**
17
17
  * a property whose value to use for sorting on the array items
@@ -370,6 +370,13 @@ declare type InfiniteTableColumnValueGetter<T, VALUE_GETTER_TYPE = string | numb
370
370
  declare type InfiniteTableColumnValueFormatter<T, VALUE_FORMATTER_TYPE = string | number | boolean | Date | null | undefined> = (params: InfiniteTableColumnValueFormatterParams<T>) => VALUE_FORMATTER_TYPE;
371
371
  declare type InfiniteTableColumnRowspanFn<T> = (params: InfiniteTableColumnRowspanParam<T>) => number;
372
372
  declare type InfiniteTableColumnComparer<T> = (a: T, b: T) => number;
373
+ declare type InfiniteTableColumnSortableFn<T> = (context: {
374
+ api: InfiniteTableApi<T>;
375
+ columnApi: InfiniteTableColumnApi<T>;
376
+ column: InfiniteTableComputedColumn<T>;
377
+ columns: Map<string, InfiniteTableComputedColumn<T>>;
378
+ }) => boolean;
379
+ declare type InfiniteTableColumnSortable<T> = boolean | InfiniteTableColumnSortableFn<T>;
373
380
  /**
374
381
  * Defines a column in the table.
375
382
  *
@@ -380,7 +387,7 @@ declare type InfiniteTableColumnComparer<T> = (a: T, b: T) => number;
380
387
  declare type InfiniteTableColumn<DATA_TYPE> = {
381
388
  field?: KeyOfNoSymbol<DATA_TYPE>;
382
389
  valueGetter?: InfiniteTableColumnValueGetter<DATA_TYPE>;
383
- sortable?: boolean;
390
+ defaultSortable?: InfiniteTableColumnSortable<DATA_TYPE>;
384
391
  draggable?: boolean;
385
392
  resizable?: boolean;
386
393
  shouldAcceptEdit?: (params: InfiniteTablePropOnEditAcceptedParams<DATA_TYPE>) => boolean | Error | Promise<boolean | Error>;
@@ -403,7 +410,7 @@ declare type InfiniteTableColumn<DATA_TYPE> = {
403
410
  headerCssEllipsis?: boolean;
404
411
  type?: InfiniteTableColumnTypeNames | InfiniteTableColumnTypeNames[] | null;
405
412
  dataType?: InfiniteTableDataTypeNames;
406
- sortType?: string;
413
+ sortType?: string | string[];
407
414
  filterType?: string;
408
415
  style?: InfiniteTableColumnStyle<DATA_TYPE>;
409
416
  headerStyle?: InfiniteTableColumnHeaderStyle<DATA_TYPE>;
@@ -435,7 +442,7 @@ declare type InfiniteTableColumn<DATA_TYPE> = {
435
442
  MenuIcon?: (props: MenuIconProps) => JSX.Element | null;
436
443
  };
437
444
  };
438
- declare type InfiniteTableGeneratedGroupColumn<T> = Omit<InfiniteTableColumn<T>, 'sortable'> & {
445
+ declare type InfiniteTableGeneratedGroupColumn<T> = Omit<InfiniteTableColumn<T>, 'defaultSortable'> & {
439
446
  groupByForColumn: GroupBy<T> | GroupBy<T>[];
440
447
  id?: string;
441
448
  };
@@ -462,7 +469,7 @@ declare type InfiniteTablePivotFinalColumn<DataType, KeyType extends any = any>
462
469
  declare type InfiniteTablePivotFinalColumnVariant<DataType, KeyType extends any = any> = InfiniteTablePivotFinalColumn<DataType, KeyType>;
463
470
  declare type InfiniteTableComputedColumnBase<T> = {
464
471
  computedFilterType: string;
465
- computedSortType: string;
472
+ computedSortType: string | string[];
466
473
  computedDataType: string;
467
474
  computedWidth: number;
468
475
  computedFlex: number | null;
@@ -471,7 +478,6 @@ declare type InfiniteTableComputedColumnBase<T> = {
471
478
  computedOffset: number;
472
479
  computedPinningOffset: number;
473
480
  computedAbsoluteOffset: number;
474
- computedSortable: boolean;
475
481
  computedSortInfo: DataSourceSingleSortInfo<T> | null;
476
482
  computedSorted: boolean;
477
483
  computedSortedAsc: boolean;
@@ -492,6 +498,7 @@ declare type InfiniteTableComputedColumnBase<T> = {
492
498
  computedFirst: boolean;
493
499
  computedLast: boolean;
494
500
  computedEditable: NonUndefined<InfiniteTableColumn<T>['defaultEditable']>;
501
+ computedSortable: NonUndefined<InfiniteTableColumn<T>['defaultSortable']>;
495
502
  colType: InfiniteTableColumnType<T>;
496
503
  id: string;
497
504
  };
@@ -1222,6 +1229,7 @@ interface InfiniteTableMappedState<T> {
1222
1229
  columnMenuRealignDelay: NonUndefined<InfiniteTableProps<T>['columnMenuRealignDelay']>;
1223
1230
  columnDefaultEditable: InfiniteTableProps<T>['columnDefaultEditable'];
1224
1231
  columnDefaultFilterable: InfiniteTableProps<T>['columnDefaultFilterable'];
1232
+ columnDefaultSortable: InfiniteTableProps<T>['columnDefaultSortable'];
1225
1233
  rowStyle: InfiniteTableProps<T>['rowStyle'];
1226
1234
  rowProps: InfiniteTableProps<T>['rowProps'];
1227
1235
  rowClassName: InfiniteTableProps<T>['rowClassName'];
@@ -1235,7 +1243,7 @@ interface InfiniteTableMappedState<T> {
1235
1243
  columnDefaultFlex: InfiniteTableProps<T>['columnDefaultFlex'];
1236
1244
  columnCssEllipsis: NonUndefined<InfiniteTableProps<T>['columnCssEllipsis']>;
1237
1245
  draggableColumns: NonUndefined<InfiniteTableProps<T>['draggableColumns']>;
1238
- sortable: NonUndefined<InfiniteTableProps<T>['sortable']>;
1246
+ sortable: InfiniteTableProps<T>['sortable'];
1239
1247
  hideEmptyGroupColumns: NonUndefined<InfiniteTableProps<T>['hideEmptyGroupColumns']>;
1240
1248
  hideColumnWhenGrouped: NonUndefined<InfiniteTableProps<T>['hideColumnWhenGrouped']>;
1241
1249
  keyboardSelection: NonUndefined<InfiniteTableProps<T>['keyboardSelection']>;
@@ -2320,12 +2328,12 @@ declare type InfiniteTableColumnType<T> = {
2320
2328
  header?: InfiniteTableColumn<T>['header'];
2321
2329
  comparer?: InfiniteTableColumn<T>['comparer'];
2322
2330
  draggable?: InfiniteTableColumn<T>['draggable'];
2323
- sortable?: InfiniteTableColumn<T>['sortable'];
2324
2331
  resizable?: InfiniteTableColumn<T>['resizable'];
2325
2332
  align?: InfiniteTableColumn<T>['align'];
2326
2333
  headerAlign?: InfiniteTableColumn<T>['headerAlign'];
2327
2334
  verticalAlign?: InfiniteTableColumn<T>['verticalAlign'];
2328
2335
  contentFocusable?: InfiniteTableColumn<T>['contentFocusable'];
2336
+ defaultSortable?: InfiniteTableColumn<T>['defaultSortable'];
2329
2337
  defaultEditable?: InfiniteTableColumn<T>['defaultEditable'];
2330
2338
  defaultFilterable?: InfiniteTableColumn<T>['defaultFilterable'];
2331
2339
  columnGroup?: string;
@@ -2369,6 +2377,7 @@ declare type InfiniteTableColumnApi<_T> = {
2369
2377
  toggleFilterOperatorMenu: (target: EventTarget | HTMLElement) => void;
2370
2378
  hideFilterOperatorMenu: () => void;
2371
2379
  isVisible: () => boolean;
2380
+ isSortable: () => boolean;
2372
2381
  getSortInfo: () => DataSourceSingleSortInfo<_T> | null;
2373
2382
  getSortDir(): SortDir | null;
2374
2383
  toggleSort: (options?: MultiSortBehaviorOptions) => void;
@@ -2442,16 +2451,18 @@ interface InfiniteTableApi<T> {
2442
2451
  renderStartIndex: number;
2443
2452
  renderEndIndex: number;
2444
2453
  };
2454
+ collapseAllGroupRows: () => void;
2445
2455
  toggleGroupRow: (groupKeys: any[]) => void;
2446
2456
  collapseGroupRow: (groupKeys: any[]) => boolean;
2447
2457
  expandGroupRow: (groupKeys: any[]) => boolean;
2448
2458
  setSortInfoForColumn: (columnId: string, sortInfo: DataSourceSingleSortInfo<T> | null) => void;
2449
2459
  getSortInfoForColumn: (columnId: string) => DataSourceSingleSortInfo<T> | null;
2450
- getSortTypeForColumn: (columnId: string) => string | null;
2460
+ getSortTypeForColumn: (columnId: string) => string | string[] | null;
2451
2461
  toggleSortingForColumn: (columnId: string, options?: MultiSortBehaviorOptions) => void;
2452
2462
  setColumnFilter: (columnId: string, filterValue: any) => void;
2453
2463
  setColumnFilterOperator: (columnId: string, operator: string) => void;
2454
2464
  clearColumnFilter: (columnId: string) => void;
2465
+ isColumnSortable: (columnId: string) => boolean;
2455
2466
  setFilterValueForColumn: (columnId: string, filterValue: DataSourceFilterValueItem<T>) => void;
2456
2467
  setPinningForColumn: (columnId: string, pinning: InfiniteTableColumnPinnedValues) => void;
2457
2468
  setSortingForColumn: (columnId: string, dir: SortDir | null) => void;
@@ -2550,6 +2561,7 @@ declare type InfiniteTableRowInfoDataDiscriminatorWithColumnAndApis<T> = {
2550
2561
  dataSourceApi: DataSourceApi<T>;
2551
2562
  } & InfiniteTableRowInfoDataDiscriminatorWithColumn<T>;
2552
2563
  declare type InfiniteTablePropsEditable<T> = InfiniteTableColumnEditableFn<T> | undefined;
2564
+ declare type InfiniteTablePropsSortable<T> = InfiniteTableColumnSortable<T> | undefined;
2553
2565
  declare type InfiniteTablePropOnEditAcceptedParams<T> = InfiniteTableRowInfoDataDiscriminatorWithColumnAndApis<T> & {
2554
2566
  initialValue: any;
2555
2567
  };
@@ -2571,6 +2583,20 @@ interface InfiniteTableProps<T> {
2571
2583
  pivotColumn?: InfiniteTablePropPivotColumn<T, InfiniteTableColumn<T> & InfiniteTablePivotFinalColumn<T>>;
2572
2584
  columnDefaultFilterable?: boolean;
2573
2585
  columnDefaultEditable?: boolean;
2586
+ /**
2587
+ * Default behavior for column sorting. Defaults to true.
2588
+ *
2589
+ * This is overriden by all other props that can control sorting behavior (`column.defaultSortable`, `columnType.defaultSortable`, `sortable`).
2590
+ */
2591
+ columnDefaultSortable?: boolean;
2592
+ /**
2593
+ * This overrides both the global `columnDefaultSortable` prop and the column's own `defaultSortable` prop.
2594
+ * When used, it's the ultimate source of truth for whether (and which) columns are sortable.
2595
+ */
2596
+ sortable?: InfiniteTablePropsSortable<T>;
2597
+ /**
2598
+ * This overrides both the global `columnDefaultEditable` prop and the column's own `defaultEditable` prop.
2599
+ */
2574
2600
  editable?: InfiniteTablePropsEditable<T>;
2575
2601
  pivotTotalColumnPosition?: InfiniteTablePropPivotTotalColumnPosition;
2576
2602
  pivotGrandTotalColumnPosition?: InfiniteTablePropPivotGrandTotalColumnPosition;
@@ -2633,7 +2659,6 @@ interface InfiniteTableProps<T> {
2633
2659
  id?: string;
2634
2660
  showZebraRows?: boolean;
2635
2661
  showHoverRows?: boolean;
2636
- sortable?: boolean;
2637
2662
  multiSortBehavior?: InfiniteTablePropMultiSortBehavior;
2638
2663
  keyboardNavigation?: InfiniteTablePropKeyboardNavigation;
2639
2664
  keyboardSelection?: InfiniteTablePropKeyboardSelection;