@infinite-table/infinite-react 4.1.1 → 4.2.1-canary.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
@@ -2046,6 +2046,10 @@ interface DataSourceApi<T> {
2046
2046
  }
2047
2047
  declare type DataSourcePropRowInfoReducers<T> = Record<string, DataSourceRowInfoReducer<T>>;
2048
2048
  declare type DataSourceRowInfoReducer<T> = DataSourceRawReducer<InfiniteTableRowInfo<T>, any>;
2049
+ declare type DataSourcePropShouldReloadDataObject<T> = {
2050
+ [key in keyof Pick<DataSourceDataParams<T>, 'sortInfo' | 'pivotBy' | 'groupBy' | 'filterValue'>]: boolean;
2051
+ };
2052
+ declare type DataSourcePropShouldReloadData<T> = DataSourcePropShouldReloadDataObject<T>;
2049
2053
  declare type DataSourceProps<T> = {
2050
2054
  debugId?: string;
2051
2055
  children: React$1.ReactNode | ((contextData: DataSourceState<T>) => React$1.ReactNode);
@@ -2100,9 +2104,19 @@ declare type DataSourceProps<T> = {
2100
2104
  livePaginationCursor?: DataSourcePropLivePaginationCursor<T>;
2101
2105
  onLivePaginationCursorChange?: (livePaginationCursor: DataSourceLivePaginationCursorValue) => void;
2102
2106
  filterFunction?: DataSourcePropFilterFunction<T>;
2107
+ /**
2108
+ * @deprecated Use shouldReloadData.sortInfo instead
2109
+ */
2103
2110
  sortMode?: 'local' | 'remote';
2111
+ /**
2112
+ * @deprecated Use shouldReloadData.filterValue instead
2113
+ */
2104
2114
  filterMode?: 'local' | 'remote';
2115
+ /**
2116
+ * @deprecated Use shouldReloadData.groupBy instead
2117
+ */
2105
2118
  groupMode?: 'local' | 'remote';
2119
+ shouldReloadData?: DataSourcePropShouldReloadData<T>;
2106
2120
  filterValue?: DataSourcePropFilterValue<T>;
2107
2121
  defaultFilterValue?: DataSourcePropFilterValue<T>;
2108
2122
  onFilterValueChange?: (filterValue: DataSourcePropFilterValue<T>) => void;
@@ -2199,9 +2213,11 @@ interface DataSourceState<T> extends DataSourceSetupState<T>, DataSourceDerivedS
2199
2213
  declare type DataSourceDerivedState<T> = {
2200
2214
  toPrimaryKey: (data: T) => any;
2201
2215
  operatorsByFilterType: Record<string, Record<string, DataSourceFilterOperator<T>>>;
2202
- sortMode: NonUndefined<DataSourceProps<T>['sortMode']>;
2203
- filterMode: NonUndefined<DataSourceProps<T>['filterMode']>;
2204
- groupMode: NonUndefined<DataSourceProps<T>['groupMode']>;
2216
+ sortMode: 'local' | 'remote';
2217
+ filterMode: 'local' | 'remote';
2218
+ groupMode: 'local' | 'remote';
2219
+ pivotMode: 'local' | 'remote';
2220
+ shouldReloadData: NonUndefined<Required<DataSourcePropShouldReloadData<T>>>;
2205
2221
  groupRowsState: GroupRowsState<T>;
2206
2222
  multiSort: boolean;
2207
2223
  controlledSort: boolean;
@@ -3334,4 +3350,4 @@ declare const components: {
3334
3350
  NumberFilterEditor: typeof NumberFilterEditor;
3335
3351
  };
3336
3352
 
3337
- export { AdvancedAlignable, CellSelectionState, CellSelectionStateObject, ColumnTypeWithInherit, DataSource, DataSourceAction, DataSourceActionType, DataSourceAggregationReducer, DataSourceApi, DataSourceCRUDParam, DataSourceComponentActions, DataSourceContextValue, DataSourceData, DataSourceDataParams, DataSourceDataParamsChanges, DataSourceDerivedState, DataSourceFilterFunctionParam, DataSourceFilterOperator, DataSourceFilterOperatorFunction, DataSourceFilterOperatorFunctionParam, DataSourceFilterType, DataSourceFilterValueItem, DataSourceFilterValueItemValueGetter, DataSourceGroupBy, DataSourceGroupRowsList, DataSourceInsertParam, DataSourceLivePaginationCursorFn, DataSourceLivePaginationCursorParams, DataSourceLivePaginationCursorValue, DataSourceMappedState, DataSourceMappings, DataSourceMasterDetailContextValue, DataSourcePivotBy, DataSourcePropAggregationReducers, DataSourcePropCellSelection, DataSourcePropCellSelection_MultiCell, DataSourcePropCellSelection_SingleCell, DataSourcePropFilterFunction, DataSourcePropFilterTypes, DataSourcePropFilterValue, DataSourcePropGroupBy, DataSourcePropGroupRowsStateObject, DataSourcePropIsRowSelected, DataSourcePropLivePaginationCursor, DataSourcePropMultiRowSelectionChangeParamType, DataSourcePropOnCellSelectionChange, DataSourcePropOnCellSelectionChange_MultiCell, DataSourcePropOnCellSelectionChange_SingleCell, DataSourcePropOnRowSelectionChange, DataSourcePropOnRowSelectionChange_MultiRow, DataSourcePropOnRowSelectionChange_SingleRow, DataSourcePropPivotBy, DataSourcePropRowInfoReducers, DataSourcePropRowSelection, DataSourcePropRowSelection_MultiRow, DataSourcePropRowSelection_SingleRow, DataSourcePropSelectionMode, DataSourcePropSortFn, DataSourcePropSortInfo, DataSourcePropSortTypes, DataSourceProps, DataSourceRawReducer, DataSourceRemoteData, DataSourceRowInfoReducer, DataSourceSetupState, DataSourceSingleSortInfo, DataSourceSortInfo, DataSourceState, DebugLogger, DeepMap, ElementContainerGetter, FixedSizeSet, GroupRowsState, InfiniteColumnEditorContextType, InfiniteTable, InfiniteTableAction, InfiniteTableActionType, InfiniteTableApi, InfiniteTableClassName, InfiniteTableColumn, InfiniteTableColumnAggregator, InfiniteTableColumnApi, InfiniteTableColumnCellContextType, InfiniteTableColumnComparer, InfiniteTableColumnGroup, InfiniteTableColumnRenderFunctionForGroupRows, InfiniteTableColumnRenderFunctionForNormalRows, InfiniteTableColumnRenderValueParam, InfiniteTableColumnRowspanParam, InfiniteTableColumnSizingOptions, InfiniteTableColumnValueFormatterParams, InfiniteTableColumnValueGetterParams, InfiniteTableComponent, InfiniteTableComputedColumn, InfiniteTableComputedValues, InfiniteTableContextValue, InfiniteTableGroupColumnBase, InfiniteTableGroupColumnFunction, InfiniteTableGroupColumnGetterOptions, InfiniteTablePivotColumn, InfiniteTablePropAutoSizeColumnsKey, InfiniteTablePropColumnGroups, InfiniteTablePropColumnOrder, InfiniteTablePropColumnPinning, InfiniteTablePropColumnSizing, InfiniteTablePropColumnTypes, InfiniteTablePropColumnVisibility, InfiniteTablePropColumns, InfiniteTablePropComponents, InfiniteTablePropGetCellContextMenuItems, InfiniteTablePropGetColumnMenuItems, InfiniteTablePropGroupColumn, InfiniteTablePropGroupRenderStrategy, InfiniteTablePropHeaderOptions, InfiniteTablePropKeyboardNavigation, InfiniteTablePropKeyboardShorcut, InfiniteTablePropMultiSortBehavior, InfiniteTablePropRowClassName, InfiniteTablePropRowStyle, InfiniteTableProps, InfiniteTableRowClassNameFn, InfiniteTableRowInfo, InfiniteTableRowStyleFn, InfiniteTableState, InfiniteTable_HasGrouping_RowInfoGroup, InfiniteTable_HasGrouping_RowInfoNormal, LazyGroupDataDeepMap, LazyGroupDataItem, LazyRowInfoGroup, Menu, MenuChildrenFnParam, MenuColumn, MenuColumnRenderParam, MenuDecoration, MenuIconProps, MenuItemActionContext, MenuItemDefinition, MenuItemObject, MenuProps, MenuRenderable, MenuRuntimeItem, MenuRuntimeItemSelectable, MenuSeparator, OverlayShowParams, RowDetailCache, RowDetailState, RowDetailStateObject, RowSelectionState, Scrollbars, ShowOverlayFn, WeakFixedSizeSet, components, debounce, debug, defaultFilterTypes, eventMatchesKeyboardShortcut, defaultFilterTypes as filterTypes, flatten, getComponentStateRoot, group, interceptMap, keyboardShortcuts, multisort, useComponentState, useDataSource, useEffectWithChanges, useEffectWithObject, useGridScroll, useInfiniteColumnCell, useInfiniteColumnEditor, useInfiniteColumnFilterEditor, useInfiniteHeaderCell, useMasterRowInfo, useOverlay, useOverlayPortal, useRowInfoReducers, useVisibleColumnSizes };
3353
+ export { AdvancedAlignable, CellSelectionState, CellSelectionStateObject, ColumnTypeWithInherit, DataSource, DataSourceAction, DataSourceActionType, DataSourceAggregationReducer, DataSourceApi, DataSourceCRUDParam, DataSourceComponentActions, DataSourceContextValue, DataSourceData, DataSourceDataParams, DataSourceDataParamsChanges, DataSourceDerivedState, DataSourceFilterFunctionParam, DataSourceFilterOperator, DataSourceFilterOperatorFunction, DataSourceFilterOperatorFunctionParam, DataSourceFilterType, DataSourceFilterValueItem, DataSourceFilterValueItemValueGetter, DataSourceGroupBy, DataSourceGroupRowsList, DataSourceInsertParam, DataSourceLivePaginationCursorFn, DataSourceLivePaginationCursorParams, DataSourceLivePaginationCursorValue, DataSourceMappedState, DataSourceMappings, DataSourceMasterDetailContextValue, DataSourcePivotBy, DataSourcePropAggregationReducers, DataSourcePropCellSelection, DataSourcePropCellSelection_MultiCell, DataSourcePropCellSelection_SingleCell, DataSourcePropFilterFunction, DataSourcePropFilterTypes, DataSourcePropFilterValue, DataSourcePropGroupBy, DataSourcePropGroupRowsStateObject, DataSourcePropIsRowSelected, DataSourcePropLivePaginationCursor, DataSourcePropMultiRowSelectionChangeParamType, DataSourcePropOnCellSelectionChange, DataSourcePropOnCellSelectionChange_MultiCell, DataSourcePropOnCellSelectionChange_SingleCell, DataSourcePropOnRowSelectionChange, DataSourcePropOnRowSelectionChange_MultiRow, DataSourcePropOnRowSelectionChange_SingleRow, DataSourcePropPivotBy, DataSourcePropRowInfoReducers, DataSourcePropRowSelection, DataSourcePropRowSelection_MultiRow, DataSourcePropRowSelection_SingleRow, DataSourcePropSelectionMode, DataSourcePropShouldReloadData, DataSourcePropShouldReloadDataObject, DataSourcePropSortFn, DataSourcePropSortInfo, DataSourcePropSortTypes, DataSourceProps, DataSourceRawReducer, DataSourceRemoteData, DataSourceRowInfoReducer, DataSourceSetupState, DataSourceSingleSortInfo, DataSourceSortInfo, DataSourceState, DebugLogger, DeepMap, ElementContainerGetter, FixedSizeSet, GroupRowsState, InfiniteColumnEditorContextType, InfiniteTable, InfiniteTableAction, InfiniteTableActionType, InfiniteTableApi, InfiniteTableClassName, InfiniteTableColumn, InfiniteTableColumnAggregator, InfiniteTableColumnApi, InfiniteTableColumnCellContextType, InfiniteTableColumnComparer, InfiniteTableColumnGroup, InfiniteTableColumnRenderFunctionForGroupRows, InfiniteTableColumnRenderFunctionForNormalRows, InfiniteTableColumnRenderValueParam, InfiniteTableColumnRowspanParam, InfiniteTableColumnSizingOptions, InfiniteTableColumnValueFormatterParams, InfiniteTableColumnValueGetterParams, InfiniteTableComponent, InfiniteTableComputedColumn, InfiniteTableComputedValues, InfiniteTableContextValue, InfiniteTableGroupColumnBase, InfiniteTableGroupColumnFunction, InfiniteTableGroupColumnGetterOptions, InfiniteTablePivotColumn, InfiniteTablePropAutoSizeColumnsKey, InfiniteTablePropColumnGroups, InfiniteTablePropColumnOrder, InfiniteTablePropColumnPinning, InfiniteTablePropColumnSizing, InfiniteTablePropColumnTypes, InfiniteTablePropColumnVisibility, InfiniteTablePropColumns, InfiniteTablePropComponents, InfiniteTablePropGetCellContextMenuItems, InfiniteTablePropGetColumnMenuItems, InfiniteTablePropGroupColumn, InfiniteTablePropGroupRenderStrategy, InfiniteTablePropHeaderOptions, InfiniteTablePropKeyboardNavigation, InfiniteTablePropKeyboardShorcut, InfiniteTablePropMultiSortBehavior, InfiniteTablePropRowClassName, InfiniteTablePropRowStyle, InfiniteTableProps, InfiniteTableRowClassNameFn, InfiniteTableRowInfo, InfiniteTableRowStyleFn, InfiniteTableState, InfiniteTable_HasGrouping_RowInfoGroup, InfiniteTable_HasGrouping_RowInfoNormal, LazyGroupDataDeepMap, LazyGroupDataItem, LazyRowInfoGroup, Menu, MenuChildrenFnParam, MenuColumn, MenuColumnRenderParam, MenuDecoration, MenuIconProps, MenuItemActionContext, MenuItemDefinition, MenuItemObject, MenuProps, MenuRenderable, MenuRuntimeItem, MenuRuntimeItemSelectable, MenuSeparator, OverlayShowParams, RowDetailCache, RowDetailState, RowDetailStateObject, RowSelectionState, Scrollbars, ShowOverlayFn, WeakFixedSizeSet, components, debounce, debug, defaultFilterTypes, eventMatchesKeyboardShortcut, defaultFilterTypes as filterTypes, flatten, getComponentStateRoot, group, interceptMap, keyboardShortcuts, multisort, useComponentState, useDataSource, useEffectWithChanges, useEffectWithObject, useGridScroll, useInfiniteColumnCell, useInfiniteColumnEditor, useInfiniteColumnFilterEditor, useInfiniteHeaderCell, useMasterRowInfo, useOverlay, useOverlayPortal, useRowInfoReducers, useVisibleColumnSizes };
package/index.dev.js CHANGED
@@ -851,7 +851,7 @@ function debugPackage(channelName) {
851
851
  let lastMessageTimestamp = 0;
852
852
  const isEnabled = () => enabled != null ? enabled : isLoggingEnabled(channel, storageKeyValue);
853
853
  const color = getNextColor(debug.colors);
854
- const logger = Object.defineProperties(
854
+ const logger2 = Object.defineProperties(
855
855
  (...args) => {
856
856
  if (isLoggingEnabled(channel, storageKeyValue)) {
857
857
  const now = Date.now();
@@ -928,8 +928,8 @@ function debugPackage(channelName) {
928
928
  }
929
929
  }
930
930
  );
931
- loggers.set(channelParts, logger);
932
- return logger;
931
+ loggers.set(channelParts, logger2);
932
+ return logger2;
933
933
  }
934
934
  return debugFactory(channelName);
935
935
  }
@@ -4504,7 +4504,6 @@ var notifyChange = (props, callbackPropName, values) => {
4504
4504
  callbackProp(...values);
4505
4505
  }
4506
4506
  };
4507
- var debug3 = dbg("rerender");
4508
4507
  var ComponentContext;
4509
4508
  function getComponentStateContext() {
4510
4509
  if (ComponentContext) {
@@ -4753,7 +4752,8 @@ function getComponentStateRoot(config) {
4753
4752
  }
4754
4753
  });
4755
4754
  if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
4756
- debug3(
4755
+ const logger2 = config.debugName ? dbg(`${config.debugName}:rerender`) : dbg("rerender");
4756
+ logger2(
4757
4757
  "Triggered by new values for the following props",
4758
4758
  ...[
4759
4759
  ...Object.keys(newMappedState != null ? newMappedState : {}),
@@ -12188,7 +12188,7 @@ function getRowSelectionApi(param) {
12188
12188
  }
12189
12189
 
12190
12190
  // src/components/DataSource/CellSelectionState.ts
12191
- var debug4 = dbg("CellSelectionState");
12191
+ var debug3 = dbg("CellSelectionState");
12192
12192
  var WILDCARD = "*";
12193
12193
  var CellSelectionState = class {
12194
12194
  constructor(clone) {
@@ -12449,7 +12449,7 @@ var CellSelectionState = class {
12449
12449
  console.error(
12450
12450
  `CellSelectionState.isCellSelected should not be called with wildcard`
12451
12451
  );
12452
- debug4(
12452
+ debug3(
12453
12453
  `CellSelectionState.isCellSelected should not be called with wildcard`
12454
12454
  );
12455
12455
  return false;
@@ -13779,8 +13779,7 @@ function useLoadData() {
13779
13779
  notifyScrollbarsChange,
13780
13780
  refetchKey,
13781
13781
  sortInfo,
13782
- sortMode,
13783
- groupMode,
13782
+ shouldReloadData,
13784
13783
  groupBy,
13785
13784
  pivotBy,
13786
13785
  filterValue,
@@ -13851,11 +13850,12 @@ function useLoadData() {
13851
13850
  });
13852
13851
  }, [filterValue, filterMode, filterTypes]);
13853
13852
  const depsObject = {
13854
- sortInfo: sortMode === "remote" ? sortInfo : null,
13855
- groupBy: groupMode === "remote" ? groupBy : null,
13856
- pivotBy,
13853
+ // #sortMode_vs_shouldReloadData.sortInfo
13854
+ sortInfo: shouldReloadData.sortInfo ? sortInfo : null,
13855
+ groupBy: shouldReloadData.groupBy ? groupBy : null,
13856
+ pivotBy: shouldReloadData.pivotBy ? pivotBy : null,
13857
13857
  refetchKey,
13858
- filterValue: computedFilterValue,
13858
+ filterValue: shouldReloadData.filterValue ? computedFilterValue : null,
13859
13859
  cursorId: livePagination ? stateCursorId : null
13860
13860
  };
13861
13861
  const initialRef = (0, import_react35.useRef)(true);
@@ -14095,6 +14095,36 @@ function lazyLoadRange(options, cache) {
14095
14095
  }, initialPromise);
14096
14096
  }
14097
14097
 
14098
+ // src/utils/logger.ts
14099
+ var log = debug("InfiniteTable");
14100
+ var COLOR_WARN_VALUE = `#eb9316`;
14101
+ var warnChannel = "Warn";
14102
+ var errorChannel = "Error";
14103
+ var infoChannel = "Info";
14104
+ var successChannel = "Success";
14105
+ var logChannel = "Logs";
14106
+ var logger = log.extend(logChannel);
14107
+ var infoLogger = logger.extend(infoChannel);
14108
+ var warnLogger = logger.extend(warnChannel);
14109
+ var errorLogger = logger.extend(errorChannel);
14110
+ var successLogger = logger.extend(successChannel);
14111
+ var logColorWarn = COLOR_WARN_VALUE;
14112
+ var warn = (message, logger2) => {
14113
+ logger2 = logger2 ? logger2.extend(warnChannel) : warnLogger;
14114
+ logger2(log.color(logColorWarn, message));
14115
+ };
14116
+ var doOnceFlags = new DeepMap();
14117
+ var doOnce = (func, ...keys) => {
14118
+ if (doOnceFlags.has(keys)) {
14119
+ return;
14120
+ }
14121
+ doOnceFlags.set(keys, true);
14122
+ func();
14123
+ };
14124
+ var warnOnce = (message, key = message, logger2) => {
14125
+ doOnce(() => warn(message, logger2), key, "warn");
14126
+ };
14127
+
14098
14128
  // src/components/utils/discardCallsWithEqualArg.ts
14099
14129
  var map = /* @__PURE__ */ new WeakMap();
14100
14130
  var getCompareDefault = (a) => a;
@@ -14205,6 +14235,7 @@ var normalizeSortInfo = (initialSortInfo, weakMap3) => {
14205
14235
  };
14206
14236
 
14207
14237
  // src/components/DataSource/state/getInitialState.ts
14238
+ var DataSourceLogger = dbg("DataSource");
14208
14239
  var defaultCursorId = Symbol("cursorId");
14209
14240
  function initSetupState() {
14210
14241
  const now = Date.now();
@@ -14335,7 +14366,7 @@ function getLivePaginationCursorValue(livePaginationCursorProp, state) {
14335
14366
  }
14336
14367
  var weakMap = /* @__PURE__ */ new WeakMap();
14337
14368
  function deriveStateFromProps(params) {
14338
- var _a, _b, _c, _d;
14369
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
14339
14370
  const { props, state, oldState } = params;
14340
14371
  const controlledSort = isControlledValue(props.sortInfo);
14341
14372
  const controlledFilter = isControlledValue(props.filterValue);
@@ -14424,18 +14455,61 @@ function deriveStateFromProps(params) {
14424
14455
  collapsedRows: []
14425
14456
  }
14426
14457
  );
14458
+ const { shouldReloadData = {} } = props;
14459
+ const propsGroupMode = (_b = props.groupMode) != null ? _b : shouldReloadData.groupBy != null ? shouldReloadData.groupBy ? "remote" : "local" : void 0;
14460
+ const propsSortMode = ((_c = props.sortMode) != null ? _c : shouldReloadData.sortInfo != null) ? shouldReloadData.sortInfo ? "remote" : "local" : void 0;
14461
+ const propsFilterMode = ((_d = props.filterMode) != null ? _d : shouldReloadData.filterValue != null) ? shouldReloadData.filterValue ? "remote" : "local" : void 0;
14462
+ if (props.groupMode) {
14463
+ warnOnce(
14464
+ `"groupMode" prop is deprecated for the <DataSource />, use "shouldReloadData.groupBy: true|false" instead`,
14465
+ "groupMode deprecated",
14466
+ DataSourceLogger
14467
+ );
14468
+ }
14469
+ if (props.sortMode) {
14470
+ warnOnce(
14471
+ `"sortMode" prop is deprecated for the <DataSource />, use "shouldReloadData.sortInfo: true|false" instead`,
14472
+ "sortMode deprecated",
14473
+ DataSourceLogger
14474
+ );
14475
+ }
14476
+ if (props.filterMode) {
14477
+ warnOnce(
14478
+ `"filterMode" prop is deprecated for the <DataSource />, use "shouldReloadData.filterValue: true|false" instead`,
14479
+ "filterMode deprecated",
14480
+ DataSourceLogger
14481
+ );
14482
+ }
14483
+ const groupMode = typeof props.data === "function" ? propsGroupMode != null ? propsGroupMode : "local" : "local";
14484
+ const sortMode = props.sortFunction ? "local" : propsSortMode != null ? propsSortMode : controlledSort ? "remote" : "local";
14485
+ const filterMode = typeof props.filterFunction === "function" ? "local" : propsFilterMode != null ? propsFilterMode : typeof props.data === "function" ? "remote" : "local";
14486
+ const pivotMode = shouldReloadData.pivotBy ? "remote" : "local";
14427
14487
  const result = {
14428
14488
  selectionMode,
14429
14489
  groupRowsState,
14490
+ shouldReloadData: {
14491
+ // #sortMode_vs_shouldReloadData.sortInfo
14492
+ // we reconstruct this object
14493
+ // and don't default to the computed filterMode, sortMode, groupMode and pivotMode
14494
+ // as computed above
14495
+ // since we want a subtle difference between the computed sortMode and shouldReloadData.sortInfo (for example)
14496
+ // difference: sortMode will be local when sortFunction is provided, however, the user may want to reload data when sortInfo changes
14497
+ // and thus the data will be refetched, but will be sorted locally
14498
+ filterValue: (_f = (_e = props.shouldReloadData) == null ? void 0 : _e.filterValue) != null ? _f : filterMode === "remote",
14499
+ sortInfo: (_h = (_g = props.shouldReloadData) == null ? void 0 : _g.sortInfo) != null ? _h : sortMode === "remote",
14500
+ groupBy: (_j = (_i = props.shouldReloadData) == null ? void 0 : _i.groupBy) != null ? _j : groupMode === "remote",
14501
+ pivotBy: (_l = (_k = props.shouldReloadData) == null ? void 0 : _k.pivotBy) != null ? _l : pivotMode === "remote"
14502
+ },
14430
14503
  rowSelection: rowSelectionState,
14431
14504
  cellSelection: cellSelectionState,
14505
+ groupMode,
14506
+ sortMode,
14507
+ filterMode,
14508
+ pivotMode,
14432
14509
  toPrimaryKey,
14433
14510
  operatorsByFilterType,
14434
14511
  controlledSort,
14435
14512
  controlledFilter,
14436
- groupMode: typeof props.data === "function" ? (_b = props.groupMode) != null ? _b : "local" : "local",
14437
- sortMode: props.sortFunction ? "local" : (_c = props.sortMode) != null ? _c : controlledSort ? "remote" : "local",
14438
- filterMode: typeof props.filterFunction === "function" ? "local" : (_d = props.filterMode) != null ? _d : typeof props.data === "function" ? "remote" : "local",
14439
14513
  multiSort: Array.isArray(
14440
14514
  controlledSort ? props.sortInfo : props.defaultSortInfo
14441
14515
  ),
@@ -14971,6 +15045,7 @@ function DataSourceWithContext(props) {
14971
15045
  return /* @__PURE__ */ React50.createElement(React50.Fragment, null, children);
14972
15046
  }
14973
15047
  var DataSourceRoot = getComponentStateRoot({
15048
+ debugName: "DataSource",
14974
15049
  //@ts-ignore
14975
15050
  initSetupState,
14976
15051
  //@ts-ignore
@@ -17070,13 +17145,13 @@ function useColumnRowspan(computedVisibleColumns) {
17070
17145
 
17071
17146
  // src/components/InfiniteTable/hooks/useColumnSizeFn.ts
17072
17147
  var import_react42 = require("react");
17073
- var debug5 = dbg("useColumnSizeFn");
17148
+ var debug4 = dbg("useColumnSizeFn");
17074
17149
  function useColumnSizeFn(columns) {
17075
17150
  const columnSize = (0, import_react42.useCallback)(
17076
17151
  (index) => {
17077
17152
  const column = columns[index];
17078
17153
  if (false) {
17079
- debug5("cannot find column at index", index, columns);
17154
+ debug4("cannot find column at index", index, columns);
17080
17155
  }
17081
17156
  return column ? column.computedWidth : 0;
17082
17157
  },
@@ -18636,7 +18711,7 @@ var useLicense = (licenseKey = "") => {
18636
18711
  }
18637
18712
  let valid2 = isValidLicense(licenseKey, {
18638
18713
  publishedAt: 1624970570587,
18639
- version: "4.1.1"
18714
+ version: "4.2.1-canary.0"
18640
18715
  });
18641
18716
  if (!licenseKey && !valid2 && isInsidePlayground) {
18642
18717
  return true;
package/index.dev.mjs CHANGED
@@ -799,7 +799,7 @@ function debugPackage(channelName) {
799
799
  let lastMessageTimestamp = 0;
800
800
  const isEnabled = () => enabled != null ? enabled : isLoggingEnabled(channel, storageKeyValue);
801
801
  const color = getNextColor(debug.colors);
802
- const logger = Object.defineProperties(
802
+ const logger2 = Object.defineProperties(
803
803
  (...args) => {
804
804
  if (isLoggingEnabled(channel, storageKeyValue)) {
805
805
  const now = Date.now();
@@ -876,8 +876,8 @@ function debugPackage(channelName) {
876
876
  }
877
877
  }
878
878
  );
879
- loggers.set(channelParts, logger);
880
- return logger;
879
+ loggers.set(channelParts, logger2);
880
+ return logger2;
881
881
  }
882
882
  return debugFactory(channelName);
883
883
  }
@@ -4471,7 +4471,6 @@ var notifyChange = (props, callbackPropName, values) => {
4471
4471
  callbackProp(...values);
4472
4472
  }
4473
4473
  };
4474
- var debug3 = dbg("rerender");
4475
4474
  var ComponentContext;
4476
4475
  function getComponentStateContext() {
4477
4476
  if (ComponentContext) {
@@ -4720,7 +4719,8 @@ function getComponentStateRoot(config) {
4720
4719
  }
4721
4720
  });
4722
4721
  if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
4723
- debug3(
4722
+ const logger2 = config.debugName ? dbg(`${config.debugName}:rerender`) : dbg("rerender");
4723
+ logger2(
4724
4724
  "Triggered by new values for the following props",
4725
4725
  ...[
4726
4726
  ...Object.keys(newMappedState != null ? newMappedState : {}),
@@ -12155,7 +12155,7 @@ function getRowSelectionApi(param) {
12155
12155
  }
12156
12156
 
12157
12157
  // src/components/DataSource/CellSelectionState.ts
12158
- var debug4 = dbg("CellSelectionState");
12158
+ var debug3 = dbg("CellSelectionState");
12159
12159
  var WILDCARD = "*";
12160
12160
  var CellSelectionState = class {
12161
12161
  constructor(clone) {
@@ -12416,7 +12416,7 @@ var CellSelectionState = class {
12416
12416
  console.error(
12417
12417
  `CellSelectionState.isCellSelected should not be called with wildcard`
12418
12418
  );
12419
- debug4(
12419
+ debug3(
12420
12420
  `CellSelectionState.isCellSelected should not be called with wildcard`
12421
12421
  );
12422
12422
  return false;
@@ -13746,8 +13746,7 @@ function useLoadData() {
13746
13746
  notifyScrollbarsChange,
13747
13747
  refetchKey,
13748
13748
  sortInfo,
13749
- sortMode,
13750
- groupMode,
13749
+ shouldReloadData,
13751
13750
  groupBy,
13752
13751
  pivotBy,
13753
13752
  filterValue,
@@ -13818,11 +13817,12 @@ function useLoadData() {
13818
13817
  });
13819
13818
  }, [filterValue, filterMode, filterTypes]);
13820
13819
  const depsObject = {
13821
- sortInfo: sortMode === "remote" ? sortInfo : null,
13822
- groupBy: groupMode === "remote" ? groupBy : null,
13823
- pivotBy,
13820
+ // #sortMode_vs_shouldReloadData.sortInfo
13821
+ sortInfo: shouldReloadData.sortInfo ? sortInfo : null,
13822
+ groupBy: shouldReloadData.groupBy ? groupBy : null,
13823
+ pivotBy: shouldReloadData.pivotBy ? pivotBy : null,
13824
13824
  refetchKey,
13825
- filterValue: computedFilterValue,
13825
+ filterValue: shouldReloadData.filterValue ? computedFilterValue : null,
13826
13826
  cursorId: livePagination ? stateCursorId : null
13827
13827
  };
13828
13828
  const initialRef = useRef21(true);
@@ -14062,6 +14062,36 @@ function lazyLoadRange(options, cache) {
14062
14062
  }, initialPromise);
14063
14063
  }
14064
14064
 
14065
+ // src/utils/logger.ts
14066
+ var log = debug("InfiniteTable");
14067
+ var COLOR_WARN_VALUE = `#eb9316`;
14068
+ var warnChannel = "Warn";
14069
+ var errorChannel = "Error";
14070
+ var infoChannel = "Info";
14071
+ var successChannel = "Success";
14072
+ var logChannel = "Logs";
14073
+ var logger = log.extend(logChannel);
14074
+ var infoLogger = logger.extend(infoChannel);
14075
+ var warnLogger = logger.extend(warnChannel);
14076
+ var errorLogger = logger.extend(errorChannel);
14077
+ var successLogger = logger.extend(successChannel);
14078
+ var logColorWarn = COLOR_WARN_VALUE;
14079
+ var warn = (message, logger2) => {
14080
+ logger2 = logger2 ? logger2.extend(warnChannel) : warnLogger;
14081
+ logger2(log.color(logColorWarn, message));
14082
+ };
14083
+ var doOnceFlags = new DeepMap();
14084
+ var doOnce = (func, ...keys) => {
14085
+ if (doOnceFlags.has(keys)) {
14086
+ return;
14087
+ }
14088
+ doOnceFlags.set(keys, true);
14089
+ func();
14090
+ };
14091
+ var warnOnce = (message, key = message, logger2) => {
14092
+ doOnce(() => warn(message, logger2), key, "warn");
14093
+ };
14094
+
14065
14095
  // src/components/utils/discardCallsWithEqualArg.ts
14066
14096
  var map = /* @__PURE__ */ new WeakMap();
14067
14097
  var getCompareDefault = (a) => a;
@@ -14172,6 +14202,7 @@ var normalizeSortInfo = (initialSortInfo, weakMap3) => {
14172
14202
  };
14173
14203
 
14174
14204
  // src/components/DataSource/state/getInitialState.ts
14205
+ var DataSourceLogger = dbg("DataSource");
14175
14206
  var defaultCursorId = Symbol("cursorId");
14176
14207
  function initSetupState() {
14177
14208
  const now = Date.now();
@@ -14302,7 +14333,7 @@ function getLivePaginationCursorValue(livePaginationCursorProp, state) {
14302
14333
  }
14303
14334
  var weakMap = /* @__PURE__ */ new WeakMap();
14304
14335
  function deriveStateFromProps(params) {
14305
- var _a, _b, _c, _d;
14336
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
14306
14337
  const { props, state, oldState } = params;
14307
14338
  const controlledSort = isControlledValue(props.sortInfo);
14308
14339
  const controlledFilter = isControlledValue(props.filterValue);
@@ -14391,18 +14422,61 @@ function deriveStateFromProps(params) {
14391
14422
  collapsedRows: []
14392
14423
  }
14393
14424
  );
14425
+ const { shouldReloadData = {} } = props;
14426
+ const propsGroupMode = (_b = props.groupMode) != null ? _b : shouldReloadData.groupBy != null ? shouldReloadData.groupBy ? "remote" : "local" : void 0;
14427
+ const propsSortMode = ((_c = props.sortMode) != null ? _c : shouldReloadData.sortInfo != null) ? shouldReloadData.sortInfo ? "remote" : "local" : void 0;
14428
+ const propsFilterMode = ((_d = props.filterMode) != null ? _d : shouldReloadData.filterValue != null) ? shouldReloadData.filterValue ? "remote" : "local" : void 0;
14429
+ if (props.groupMode) {
14430
+ warnOnce(
14431
+ `"groupMode" prop is deprecated for the <DataSource />, use "shouldReloadData.groupBy: true|false" instead`,
14432
+ "groupMode deprecated",
14433
+ DataSourceLogger
14434
+ );
14435
+ }
14436
+ if (props.sortMode) {
14437
+ warnOnce(
14438
+ `"sortMode" prop is deprecated for the <DataSource />, use "shouldReloadData.sortInfo: true|false" instead`,
14439
+ "sortMode deprecated",
14440
+ DataSourceLogger
14441
+ );
14442
+ }
14443
+ if (props.filterMode) {
14444
+ warnOnce(
14445
+ `"filterMode" prop is deprecated for the <DataSource />, use "shouldReloadData.filterValue: true|false" instead`,
14446
+ "filterMode deprecated",
14447
+ DataSourceLogger
14448
+ );
14449
+ }
14450
+ const groupMode = typeof props.data === "function" ? propsGroupMode != null ? propsGroupMode : "local" : "local";
14451
+ const sortMode = props.sortFunction ? "local" : propsSortMode != null ? propsSortMode : controlledSort ? "remote" : "local";
14452
+ const filterMode = typeof props.filterFunction === "function" ? "local" : propsFilterMode != null ? propsFilterMode : typeof props.data === "function" ? "remote" : "local";
14453
+ const pivotMode = shouldReloadData.pivotBy ? "remote" : "local";
14394
14454
  const result = {
14395
14455
  selectionMode,
14396
14456
  groupRowsState,
14457
+ shouldReloadData: {
14458
+ // #sortMode_vs_shouldReloadData.sortInfo
14459
+ // we reconstruct this object
14460
+ // and don't default to the computed filterMode, sortMode, groupMode and pivotMode
14461
+ // as computed above
14462
+ // since we want a subtle difference between the computed sortMode and shouldReloadData.sortInfo (for example)
14463
+ // difference: sortMode will be local when sortFunction is provided, however, the user may want to reload data when sortInfo changes
14464
+ // and thus the data will be refetched, but will be sorted locally
14465
+ filterValue: (_f = (_e = props.shouldReloadData) == null ? void 0 : _e.filterValue) != null ? _f : filterMode === "remote",
14466
+ sortInfo: (_h = (_g = props.shouldReloadData) == null ? void 0 : _g.sortInfo) != null ? _h : sortMode === "remote",
14467
+ groupBy: (_j = (_i = props.shouldReloadData) == null ? void 0 : _i.groupBy) != null ? _j : groupMode === "remote",
14468
+ pivotBy: (_l = (_k = props.shouldReloadData) == null ? void 0 : _k.pivotBy) != null ? _l : pivotMode === "remote"
14469
+ },
14397
14470
  rowSelection: rowSelectionState,
14398
14471
  cellSelection: cellSelectionState,
14472
+ groupMode,
14473
+ sortMode,
14474
+ filterMode,
14475
+ pivotMode,
14399
14476
  toPrimaryKey,
14400
14477
  operatorsByFilterType,
14401
14478
  controlledSort,
14402
14479
  controlledFilter,
14403
- groupMode: typeof props.data === "function" ? (_b = props.groupMode) != null ? _b : "local" : "local",
14404
- sortMode: props.sortFunction ? "local" : (_c = props.sortMode) != null ? _c : controlledSort ? "remote" : "local",
14405
- filterMode: typeof props.filterFunction === "function" ? "local" : (_d = props.filterMode) != null ? _d : typeof props.data === "function" ? "remote" : "local",
14406
14480
  multiSort: Array.isArray(
14407
14481
  controlledSort ? props.sortInfo : props.defaultSortInfo
14408
14482
  ),
@@ -14938,6 +15012,7 @@ function DataSourceWithContext(props) {
14938
15012
  return /* @__PURE__ */ React50.createElement(React50.Fragment, null, children);
14939
15013
  }
14940
15014
  var DataSourceRoot = getComponentStateRoot({
15015
+ debugName: "DataSource",
14941
15016
  //@ts-ignore
14942
15017
  initSetupState,
14943
15018
  //@ts-ignore
@@ -17041,13 +17116,13 @@ function useColumnRowspan(computedVisibleColumns) {
17041
17116
 
17042
17117
  // src/components/InfiniteTable/hooks/useColumnSizeFn.ts
17043
17118
  import { useCallback as useCallback20 } from "react";
17044
- var debug5 = dbg("useColumnSizeFn");
17119
+ var debug4 = dbg("useColumnSizeFn");
17045
17120
  function useColumnSizeFn(columns) {
17046
17121
  const columnSize = useCallback20(
17047
17122
  (index) => {
17048
17123
  const column = columns[index];
17049
17124
  if (false) {
17050
- debug5("cannot find column at index", index, columns);
17125
+ debug4("cannot find column at index", index, columns);
17051
17126
  }
17052
17127
  return column ? column.computedWidth : 0;
17053
17128
  },
@@ -18607,7 +18682,7 @@ var useLicense = (licenseKey = "") => {
18607
18682
  }
18608
18683
  let valid2 = isValidLicense(licenseKey, {
18609
18684
  publishedAt: 1624970570587,
18610
- version: "4.1.1"
18685
+ version: "4.2.1-canary.0"
18611
18686
  });
18612
18687
  if (!licenseKey && !valid2 && isInsidePlayground) {
18613
18688
  return true;