@infinite-table/infinite-react 1.2.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -23,7 +23,7 @@ declare type MultisortInfo<T> = {
23
23
  valueGetter?: (item: T) => any;
24
24
  };
25
25
  declare type MultisortInfoAllowMultipleFields<T> = Omit<MultisortInfo<T>, 'field'> & {
26
- field?: keyof T | (keyof T)[];
26
+ field?: keyof T | (keyof T | ((item: T) => any))[];
27
27
  };
28
28
  declare const multisort: {
29
29
  <T>(sortInfo: MultisortInfoAllowMultipleFields<T>[], array: T[], get?: ((item: any) => T) | undefined): T[];
@@ -230,6 +230,22 @@ declare type KeyOfNoSymbol<T> = Exclude<keyof T, Symbol>;
230
230
  * @see https://github.com/maninak/ts-xor/tree/master#description
231
231
  */
232
232
  declare type XOR<T, U> = T | U extends object ? Prettify<Without<T, U> & U> | Prettify<Without<U, T> & T> : T | U;
233
+ /**
234
+ * Useful if applying XOR on more than 2 types.
235
+ * It comes with the penalty of having the types wrapped in an array
236
+ *
237
+ * @example
238
+ * ```
239
+ * AllXOR<[
240
+ * { a: AModule },
241
+ * { b: BModule },
242
+ * { c: CModule },
243
+ * { d: DModule }
244
+ * ]>
245
+ * ```
246
+ * @see https://github.com/Microsoft/TypeScript/issues/14094#issuecomment-723571692
247
+ */
248
+ declare type AllXOR<T extends any[]> = T extends [infer Only] ? Only : T extends [infer A, infer B, ...infer Rest] ? AllXOR<[XOR<A, B>, ...Rest]> : never;
233
249
  /**
234
250
  * Get the keys of T without any keys of U.
235
251
  */
@@ -374,10 +390,7 @@ declare type InfiniteTableColumnVerticalAlignFn<T> = (params: InfiniteTableColum
374
390
  declare type InfiniteTableColumnHeaderStyle<T> = CSSProperties | InfiniteTableColumnHeaderStyleFn<T>;
375
391
  declare type InfiniteTableColumnClassName<T> = string | InfiniteTableColumnClassNameFn<T>;
376
392
  declare type InfiniteTableColumnHeaderClassName<T> = string | InfiniteTableColumnHeaderClassNameFn<T>;
377
- declare type InfiniteTableColumnValueGetterParams<T> = {
378
- data: T;
379
- field?: keyof T;
380
- };
393
+ declare type InfiniteTableColumnValueGetterParams<T> = ValueGetterParams<T>;
381
394
  declare type InfiniteTableColumnValueFormatterParams<T> = InfiniteTableRowInfoDataDiscriminator<T>;
382
395
  declare type InfiniteTableColumnValueGetter<T, VALUE_GETTER_TYPE = string | number | boolean | Date | null | undefined> = (params: InfiniteTableColumnValueGetterParams<T>) => VALUE_GETTER_TYPE;
383
396
  declare type InfiniteTableColumnValueFormatter<T, VALUE_FORMATTER_TYPE = string | number | boolean | Date | null | undefined> = (params: InfiniteTableColumnValueFormatterParams<T>) => VALUE_FORMATTER_TYPE;
@@ -449,7 +462,7 @@ declare type InfiniteTableColumn<DATA_TYPE> = {
449
462
  };
450
463
  };
451
464
  declare type InfiniteTableGeneratedGroupColumn<T> = Omit<InfiniteTableColumn<T>, 'sortable'> & {
452
- groupByField: string | string[];
465
+ groupByForColumn: GroupBy<T> | GroupBy<T>[];
453
466
  id?: string;
454
467
  };
455
468
  declare type InfiniteTablePivotColumn<T> = InfiniteTableColumn<T> & ColumnTypeWithInherit<Partial<InfiniteTablePivotFinalColumnVariant<T, any>>>;
@@ -1242,6 +1255,7 @@ interface InfiniteTableMappedState<T> {
1242
1255
  columnMinWidth: NonUndefined<InfiniteTableProps<T>['columnMinWidth']>;
1243
1256
  columnMaxWidth: NonUndefined<InfiniteTableProps<T>['columnMaxWidth']>;
1244
1257
  columnDefaultWidth: NonUndefined<InfiniteTableProps<T>['columnDefaultWidth']>;
1258
+ columnDefaultFlex: InfiniteTableProps<T>['columnDefaultFlex'];
1245
1259
  columnCssEllipsis: NonUndefined<InfiniteTableProps<T>['columnCssEllipsis']>;
1246
1260
  draggableColumns: NonUndefined<InfiniteTableProps<T>['draggableColumns']>;
1247
1261
  sortable: NonUndefined<InfiniteTableProps<T>['sortable']>;
@@ -1344,12 +1358,29 @@ interface InfiniteTableCellContext<T> {
1344
1358
  columnApi: InfiniteTableColumnApi<T>;
1345
1359
  }
1346
1360
 
1361
+ declare type ValueGetterParams<T> = {
1362
+ data: T;
1363
+ field?: keyof T;
1364
+ };
1347
1365
  declare type GroupKeyType$1<T extends any = any> = T;
1348
- declare type GroupBy<DataType, KeyType> = {
1349
- field: KeyOfNoSymbol<DataType>;
1366
+ declare type GroupByValueGetter<T> = (params: ValueGetterParams<T>) => any;
1367
+ declare type GroupBy<DataType, KeyType = any> = {
1350
1368
  toKey?: (value: any, data: DataType) => GroupKeyType$1<KeyType>;
1351
1369
  column?: Partial<InfiniteTableGroupColumnBase<DataType>>;
1352
- };
1370
+ } & AllXOR<[
1371
+ {
1372
+ field: KeyOfNoSymbol<DataType>;
1373
+ },
1374
+ {
1375
+ valueGetter: GroupByValueGetter<DataType>;
1376
+ field: KeyOfNoSymbol<DataType>;
1377
+ },
1378
+ {
1379
+ valueGetter: GroupByValueGetter<DataType>;
1380
+ field?: KeyOfNoSymbol<DataType>;
1381
+ groupField: string;
1382
+ }
1383
+ ]>;
1353
1384
 
1354
1385
  declare type RenderRange = {
1355
1386
  renderStartIndex: number;
@@ -1463,8 +1494,7 @@ interface DataSourceDataParams<T> {
1463
1494
  changes?: DataSourceDataParamsChanges<T>;
1464
1495
  }
1465
1496
  declare type DataSourceDataParamsChanges<T> = Partial<Record<keyof Omit<DataSourceDataParams<T>, 'originalDataArray' | 'changes'>, true>>;
1466
- declare type DataSourceSingleSortInfo<T> = Omit<MultisortInfo<T>, 'field'> & {
1467
- field?: keyof T | (keyof T)[];
1497
+ declare type DataSourceSingleSortInfo<T> = MultisortInfoAllowMultipleFields<T> & {
1468
1498
  id?: string;
1469
1499
  };
1470
1500
  declare type DataSourceGroupBy<T> = GroupBy<T, any>;
@@ -1982,17 +2012,17 @@ declare type InfiniteTable_HasGrouping_RowInfoBase<T> = {
1982
2012
  *
1983
2013
  * Example: People grouped by country and city
1984
2014
  *
1985
- * Italy - country - groupKeys: ['country']
1986
- * Rome - city - groupKeys: ['country', 'city']
1987
- * Marco - person - groupKeys: ['country', 'city']
1988
- * Luca - person - groupKeys: ['country', 'city']
1989
- * Giuseppe - person - groupKeys: ['country', 'city']
2015
+ * Italy - country - groupBy: [{field: 'country'}]
2016
+ * Rome - city - groupBy: [{field: 'country'}, {field: 'city'} ]
2017
+ * Marco - person - groupBy: [{field: 'country'}, {field: 'city'} ]
2018
+ * Luca - person - groupBy: [{field: 'country'}, {field: 'city'} ]
2019
+ * Giuseppe - person - groupBy: [{field: 'country'}, {field: 'city'} ]
1990
2020
  */
1991
- groupBy: (keyof T)[];
2021
+ groupBy: GroupBy<T, any>[];
1992
2022
  /**
1993
2023
  * The groupBy value of the DataSource component, mapped to the groupBy.field
1994
2024
  */
1995
- rootGroupBy: (keyof T)[];
2025
+ rootGroupBy: GroupBy<T, any>[];
1996
2026
  /**
1997
2027
  * Available on all rowInfo objects when the datasource is grouped.
1998
2028
  *
@@ -2625,6 +2655,7 @@ interface InfiniteTableProps<T> {
2625
2655
  columnCssEllipsis?: boolean;
2626
2656
  columnHeaderCssEllipsis?: boolean;
2627
2657
  columnDefaultWidth?: number;
2658
+ columnDefaultFlex?: number;
2628
2659
  columnMinWidth?: number;
2629
2660
  columnMaxWidth?: number;
2630
2661
  hideColumnWhenGrouped?: boolean;