@infinite-table/infinite-react 5.0.0 → 5.0.1

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
@@ -936,6 +936,13 @@ declare type CellPositionByIndex = {
936
936
  rowIndex: number;
937
937
  colIndex: number;
938
938
  };
939
+ declare type MultiSelectRangeOptions = {
940
+ horizontalLayout: false;
941
+ } | {
942
+ horizontalLayout: true;
943
+ rowsPerPage: number;
944
+ columnsPerSet: number;
945
+ };
939
946
 
940
947
  declare type MultiCellSelectorOptions = {
941
948
  getPrimaryKeyByIndex: (rowIndex: number) => string | number;
@@ -960,10 +967,10 @@ declare class MultiCellSelector {
960
967
  * @param position CellPosition
961
968
  */
962
969
  singleAddClick(position: CellPositionByIndex): void;
963
- multiSelectClick(position: CellPositionByIndex): void;
964
- setRangeSelected(startPosition: CellPositionByIndex, endPosition: CellPositionByIndex, selected: boolean): void;
965
- deselectRange(startPosition: CellPositionByIndex, endPosition: CellPositionByIndex): void;
966
- selectRange(startPosition: CellPositionByIndex, endPosition: CellPositionByIndex): void;
970
+ multiSelectClick(position: CellPositionByIndex, options: MultiSelectRangeOptions): void;
971
+ setRangeSelected(startPosition: CellPositionByIndex, endPosition: CellPositionByIndex, selected: boolean, options: MultiSelectRangeOptions): void;
972
+ deselectRange(startPosition: CellPositionByIndex, endPosition: CellPositionByIndex, options: MultiSelectRangeOptions): void;
973
+ selectRange(startPosition: CellPositionByIndex, endPosition: CellPositionByIndex, options: MultiSelectRangeOptions): void;
967
974
  }
968
975
 
969
976
  declare type RowSelectionStateItem = (any | any[])[];
package/index.dev.js CHANGED
@@ -16215,16 +16215,7 @@ function notNullable(value) {
16215
16215
  return true;
16216
16216
  }
16217
16217
 
16218
- // src/components/InfiniteTable/api/getCellSelectionApi.ts
16219
- function ensureSortedPerOrder(arr, sortPattern) {
16220
- const arrSet = new Set(arr);
16221
- return sortPattern.map((item) => {
16222
- if (arrSet.has(item)) {
16223
- return item;
16224
- }
16225
- return null;
16226
- }).filter((x) => x != null);
16227
- }
16218
+ // src/components/types/CellPositionByIndex.ts
16228
16219
  function ensureMinMaxCellPositionByIndex(start, end) {
16229
16220
  let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
16230
16221
  let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
@@ -16235,6 +16226,64 @@ function ensureMinMaxCellPositionByIndex(start, end) {
16235
16226
  { rowIndex: rowEnd, colIndex: colEnd }
16236
16227
  ];
16237
16228
  }
16229
+ function isSamePage(startPosition, endPosition, options) {
16230
+ const { rowsPerPage } = options;
16231
+ return !rowsPerPage ? true : Math.floor(startPosition.rowIndex / rowsPerPage) === Math.floor(endPosition.rowIndex / rowsPerPage);
16232
+ }
16233
+ function getPositionsArrayForRangeInHorizontaLLayout(startPosition, endPosition, options) {
16234
+ if (isSamePage(startPosition, endPosition, options)) {
16235
+ throw "You should not call this when the positions are in the same page";
16236
+ }
16237
+ const { rowsPerPage, columnsPerSet } = options;
16238
+ if (rowsPerPage === 0) {
16239
+ throw "rowsPerPage cannot be 0";
16240
+ }
16241
+ let start = startPosition;
16242
+ let end = endPosition;
16243
+ if (Math.floor(startPosition.rowIndex / rowsPerPage) > Math.floor(endPosition.rowIndex / rowsPerPage)) {
16244
+ start = endPosition;
16245
+ end = startPosition;
16246
+ }
16247
+ let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
16248
+ let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
16249
+ const pageForStartRowIndex = Math.floor(startRowIndex / rowsPerPage);
16250
+ const pageForEndRowIndex = Math.floor(endRowIndex / rowsPerPage);
16251
+ const offsetForStartRowIndex = startRowIndex % rowsPerPage;
16252
+ const offsetForEndRowIndex = endRowIndex % rowsPerPage;
16253
+ const minOffset = Math.min(offsetForStartRowIndex, offsetForEndRowIndex);
16254
+ const maxOffset = Math.max(offsetForStartRowIndex, offsetForEndRowIndex);
16255
+ const positions = [];
16256
+ for (let page = pageForStartRowIndex; page <= pageForEndRowIndex; page++) {
16257
+ for (let offset = minOffset; offset <= maxOffset; offset++) {
16258
+ const rowIndex = page * rowsPerPage + offset;
16259
+ if (page === pageForStartRowIndex) {
16260
+ for (let colIndex = startColIndex; colIndex < columnsPerSet; colIndex++) {
16261
+ positions.push({ rowIndex, colIndex });
16262
+ }
16263
+ } else if (page === pageForEndRowIndex) {
16264
+ for (let colIndex = 0; colIndex <= endColIndex; colIndex++) {
16265
+ positions.push({ rowIndex, colIndex });
16266
+ }
16267
+ } else {
16268
+ for (let colIndex = 0; colIndex < columnsPerSet; colIndex++) {
16269
+ positions.push({ rowIndex, colIndex });
16270
+ }
16271
+ }
16272
+ }
16273
+ }
16274
+ return positions;
16275
+ }
16276
+
16277
+ // src/components/InfiniteTable/api/getCellSelectionApi.ts
16278
+ function ensureSortedPerOrder(arr, sortPattern) {
16279
+ const arrSet = new Set(arr);
16280
+ return sortPattern.map((item) => {
16281
+ if (arrSet.has(item)) {
16282
+ return item;
16283
+ }
16284
+ return null;
16285
+ }).filter((x) => x != null);
16286
+ }
16238
16287
  var InfiniteTableCellSelectionApiImpl = class {
16239
16288
  constructor(param) {
16240
16289
  this.getCellSelectionPosition = (options) => {
@@ -18071,7 +18120,7 @@ var MultiCellSelector = class {
18071
18120
  this.multiSelectEndPosition = void 0;
18072
18121
  }
18073
18122
  }
18074
- multiSelectClick(position2) {
18123
+ multiSelectClick(position2, options) {
18075
18124
  if (!this.multiSelectStartPosition) {
18076
18125
  return;
18077
18126
  }
@@ -18082,13 +18131,39 @@ var MultiCellSelector = class {
18082
18131
  if (this.multiSelectEndPosition) {
18083
18132
  this.deselectRange(
18084
18133
  this.multiSelectStartPosition,
18085
- this.multiSelectEndPosition
18134
+ this.multiSelectEndPosition,
18135
+ options
18086
18136
  );
18087
18137
  }
18088
- this.selectRange(this.multiSelectStartPosition, position2);
18138
+ this.selectRange(this.multiSelectStartPosition, position2, options);
18089
18139
  this.multiSelectEndPosition = position2;
18090
18140
  }
18091
- setRangeSelected(startPosition, endPosition, selected) {
18141
+ setRangeSelected(startPosition, endPosition, selected, options) {
18142
+ if (options.horizontalLayout && !isSamePage(startPosition, endPosition, options)) {
18143
+ const positions = getPositionsArrayForRangeInHorizontaLLayout(
18144
+ startPosition,
18145
+ endPosition,
18146
+ {
18147
+ rowsPerPage: options.rowsPerPage,
18148
+ columnsPerSet: options.columnsPerSet
18149
+ }
18150
+ );
18151
+ positions.forEach((position2) => {
18152
+ const selectionPosition = this.getCellSelectionPosition({
18153
+ rowIndex: position2.rowIndex,
18154
+ colIndex: position2.colIndex
18155
+ });
18156
+ if (!selectionPosition) {
18157
+ return;
18158
+ }
18159
+ if (selected) {
18160
+ this.cellSelectionState.selectCell(...selectionPosition);
18161
+ } else {
18162
+ this.cellSelectionState.deselectCell(...selectionPosition);
18163
+ }
18164
+ });
18165
+ return;
18166
+ }
18092
18167
  const [start, end] = ensureMinMaxCellPositionByIndex(
18093
18168
  startPosition,
18094
18169
  endPosition
@@ -18115,11 +18190,11 @@ var MultiCellSelector = class {
18115
18190
  }
18116
18191
  }
18117
18192
  }
18118
- deselectRange(startPosition, endPosition) {
18119
- this.setRangeSelected(startPosition, endPosition, false);
18193
+ deselectRange(startPosition, endPosition, options) {
18194
+ this.setRangeSelected(startPosition, endPosition, false, options);
18120
18195
  }
18121
- selectRange(startPosition, endPosition) {
18122
- this.setRangeSelected(startPosition, endPosition, true);
18196
+ selectRange(startPosition, endPosition, options) {
18197
+ this.setRangeSelected(startPosition, endPosition, true, options);
18123
18198
  }
18124
18199
  };
18125
18200
 
@@ -20117,7 +20192,7 @@ var useLicense = (licenseKey = "") => {
20117
20192
  }
20118
20193
  let valid2 = isValidLicense(licenseKey, {
20119
20194
  publishedAt: 1624970570587,
20120
- version: "5.0.0"
20195
+ version: "5.0.1"
20121
20196
  });
20122
20197
  if (!licenseKey && !valid2 && isInsidePlayground) {
20123
20198
  return true;
@@ -20229,6 +20304,7 @@ function onCellDoubleClick(context, _event) {
20229
20304
  function updateCellSelectionOnCellClick(context, event) {
20230
20305
  const {
20231
20306
  getDataSourceState,
20307
+ getState,
20232
20308
  getComputed,
20233
20309
  rowIndex,
20234
20310
  colIndex,
@@ -20242,7 +20318,10 @@ function updateCellSelectionOnCellClick(context, event) {
20242
20318
  if (selectionMode !== "multi-cell") {
20243
20319
  return;
20244
20320
  }
20245
- const { multiCellSelector } = getComputed();
20321
+ const { multiCellSelector, computedVisibleColumns } = getComputed();
20322
+ const { brain } = getState();
20323
+ const { rowsPerPage } = brain;
20324
+ const columnsPerSet = computedVisibleColumns.length;
20246
20325
  const cellSelection = new CellSelectionState(existingCellSelection);
20247
20326
  multiCellSelector.cellSelectionState = cellSelection;
20248
20327
  const position2 = {
@@ -20252,7 +20331,17 @@ function updateCellSelectionOnCellClick(context, event) {
20252
20331
  if (event.metaKey || event.ctrlKey) {
20253
20332
  multiCellSelector.singleAddClick(position2);
20254
20333
  } else if (event.shiftKey) {
20255
- multiCellSelector.multiSelectClick(position2);
20334
+ const horizontalLayout = !!getState().wrapRowsHorizontally;
20335
+ multiCellSelector.multiSelectClick(
20336
+ position2,
20337
+ horizontalLayout ? {
20338
+ horizontalLayout,
20339
+ rowsPerPage,
20340
+ columnsPerSet
20341
+ } : {
20342
+ horizontalLayout
20343
+ }
20344
+ );
20256
20345
  } else {
20257
20346
  multiCellSelector.resetClick(position2);
20258
20347
  }
@@ -23827,7 +23916,7 @@ function useHorizontalLayout() {
23827
23916
  } = getDataSourceState();
23828
23917
  let changes = false;
23829
23918
  const rowsPerPage = brain.rowsPerPage;
23830
- const newRowsPerPage = groupBy && groupBy.length > 0 ? rowsPerPage : null;
23919
+ const newRowsPerPage = groupBy && groupBy.length > 0 && rowsPerPage > 0 ? rowsPerPage : null;
23831
23920
  if (currentRowsPerPage != newRowsPerPage) {
23832
23921
  dataSourceActions.rowsPerPage = newRowsPerPage;
23833
23922
  changes = true;
package/index.dev.mjs CHANGED
@@ -16177,16 +16177,7 @@ function notNullable(value) {
16177
16177
  return true;
16178
16178
  }
16179
16179
 
16180
- // src/components/InfiniteTable/api/getCellSelectionApi.ts
16181
- function ensureSortedPerOrder(arr, sortPattern) {
16182
- const arrSet = new Set(arr);
16183
- return sortPattern.map((item) => {
16184
- if (arrSet.has(item)) {
16185
- return item;
16186
- }
16187
- return null;
16188
- }).filter((x) => x != null);
16189
- }
16180
+ // src/components/types/CellPositionByIndex.ts
16190
16181
  function ensureMinMaxCellPositionByIndex(start, end) {
16191
16182
  let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
16192
16183
  let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
@@ -16197,6 +16188,64 @@ function ensureMinMaxCellPositionByIndex(start, end) {
16197
16188
  { rowIndex: rowEnd, colIndex: colEnd }
16198
16189
  ];
16199
16190
  }
16191
+ function isSamePage(startPosition, endPosition, options) {
16192
+ const { rowsPerPage } = options;
16193
+ return !rowsPerPage ? true : Math.floor(startPosition.rowIndex / rowsPerPage) === Math.floor(endPosition.rowIndex / rowsPerPage);
16194
+ }
16195
+ function getPositionsArrayForRangeInHorizontaLLayout(startPosition, endPosition, options) {
16196
+ if (isSamePage(startPosition, endPosition, options)) {
16197
+ throw "You should not call this when the positions are in the same page";
16198
+ }
16199
+ const { rowsPerPage, columnsPerSet } = options;
16200
+ if (rowsPerPage === 0) {
16201
+ throw "rowsPerPage cannot be 0";
16202
+ }
16203
+ let start = startPosition;
16204
+ let end = endPosition;
16205
+ if (Math.floor(startPosition.rowIndex / rowsPerPage) > Math.floor(endPosition.rowIndex / rowsPerPage)) {
16206
+ start = endPosition;
16207
+ end = startPosition;
16208
+ }
16209
+ let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
16210
+ let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
16211
+ const pageForStartRowIndex = Math.floor(startRowIndex / rowsPerPage);
16212
+ const pageForEndRowIndex = Math.floor(endRowIndex / rowsPerPage);
16213
+ const offsetForStartRowIndex = startRowIndex % rowsPerPage;
16214
+ const offsetForEndRowIndex = endRowIndex % rowsPerPage;
16215
+ const minOffset = Math.min(offsetForStartRowIndex, offsetForEndRowIndex);
16216
+ const maxOffset = Math.max(offsetForStartRowIndex, offsetForEndRowIndex);
16217
+ const positions = [];
16218
+ for (let page = pageForStartRowIndex; page <= pageForEndRowIndex; page++) {
16219
+ for (let offset = minOffset; offset <= maxOffset; offset++) {
16220
+ const rowIndex = page * rowsPerPage + offset;
16221
+ if (page === pageForStartRowIndex) {
16222
+ for (let colIndex = startColIndex; colIndex < columnsPerSet; colIndex++) {
16223
+ positions.push({ rowIndex, colIndex });
16224
+ }
16225
+ } else if (page === pageForEndRowIndex) {
16226
+ for (let colIndex = 0; colIndex <= endColIndex; colIndex++) {
16227
+ positions.push({ rowIndex, colIndex });
16228
+ }
16229
+ } else {
16230
+ for (let colIndex = 0; colIndex < columnsPerSet; colIndex++) {
16231
+ positions.push({ rowIndex, colIndex });
16232
+ }
16233
+ }
16234
+ }
16235
+ }
16236
+ return positions;
16237
+ }
16238
+
16239
+ // src/components/InfiniteTable/api/getCellSelectionApi.ts
16240
+ function ensureSortedPerOrder(arr, sortPattern) {
16241
+ const arrSet = new Set(arr);
16242
+ return sortPattern.map((item) => {
16243
+ if (arrSet.has(item)) {
16244
+ return item;
16245
+ }
16246
+ return null;
16247
+ }).filter((x) => x != null);
16248
+ }
16200
16249
  var InfiniteTableCellSelectionApiImpl = class {
16201
16250
  constructor(param) {
16202
16251
  this.getCellSelectionPosition = (options) => {
@@ -18037,7 +18086,7 @@ var MultiCellSelector = class {
18037
18086
  this.multiSelectEndPosition = void 0;
18038
18087
  }
18039
18088
  }
18040
- multiSelectClick(position2) {
18089
+ multiSelectClick(position2, options) {
18041
18090
  if (!this.multiSelectStartPosition) {
18042
18091
  return;
18043
18092
  }
@@ -18048,13 +18097,39 @@ var MultiCellSelector = class {
18048
18097
  if (this.multiSelectEndPosition) {
18049
18098
  this.deselectRange(
18050
18099
  this.multiSelectStartPosition,
18051
- this.multiSelectEndPosition
18100
+ this.multiSelectEndPosition,
18101
+ options
18052
18102
  );
18053
18103
  }
18054
- this.selectRange(this.multiSelectStartPosition, position2);
18104
+ this.selectRange(this.multiSelectStartPosition, position2, options);
18055
18105
  this.multiSelectEndPosition = position2;
18056
18106
  }
18057
- setRangeSelected(startPosition, endPosition, selected) {
18107
+ setRangeSelected(startPosition, endPosition, selected, options) {
18108
+ if (options.horizontalLayout && !isSamePage(startPosition, endPosition, options)) {
18109
+ const positions = getPositionsArrayForRangeInHorizontaLLayout(
18110
+ startPosition,
18111
+ endPosition,
18112
+ {
18113
+ rowsPerPage: options.rowsPerPage,
18114
+ columnsPerSet: options.columnsPerSet
18115
+ }
18116
+ );
18117
+ positions.forEach((position2) => {
18118
+ const selectionPosition = this.getCellSelectionPosition({
18119
+ rowIndex: position2.rowIndex,
18120
+ colIndex: position2.colIndex
18121
+ });
18122
+ if (!selectionPosition) {
18123
+ return;
18124
+ }
18125
+ if (selected) {
18126
+ this.cellSelectionState.selectCell(...selectionPosition);
18127
+ } else {
18128
+ this.cellSelectionState.deselectCell(...selectionPosition);
18129
+ }
18130
+ });
18131
+ return;
18132
+ }
18058
18133
  const [start, end] = ensureMinMaxCellPositionByIndex(
18059
18134
  startPosition,
18060
18135
  endPosition
@@ -18081,11 +18156,11 @@ var MultiCellSelector = class {
18081
18156
  }
18082
18157
  }
18083
18158
  }
18084
- deselectRange(startPosition, endPosition) {
18085
- this.setRangeSelected(startPosition, endPosition, false);
18159
+ deselectRange(startPosition, endPosition, options) {
18160
+ this.setRangeSelected(startPosition, endPosition, false, options);
18086
18161
  }
18087
- selectRange(startPosition, endPosition) {
18088
- this.setRangeSelected(startPosition, endPosition, true);
18162
+ selectRange(startPosition, endPosition, options) {
18163
+ this.setRangeSelected(startPosition, endPosition, true, options);
18089
18164
  }
18090
18165
  };
18091
18166
 
@@ -20083,7 +20158,7 @@ var useLicense = (licenseKey = "") => {
20083
20158
  }
20084
20159
  let valid2 = isValidLicense(licenseKey, {
20085
20160
  publishedAt: 1624970570587,
20086
- version: "5.0.0"
20161
+ version: "5.0.1"
20087
20162
  });
20088
20163
  if (!licenseKey && !valid2 && isInsidePlayground) {
20089
20164
  return true;
@@ -20195,6 +20270,7 @@ function onCellDoubleClick(context, _event) {
20195
20270
  function updateCellSelectionOnCellClick(context, event) {
20196
20271
  const {
20197
20272
  getDataSourceState,
20273
+ getState,
20198
20274
  getComputed,
20199
20275
  rowIndex,
20200
20276
  colIndex,
@@ -20208,7 +20284,10 @@ function updateCellSelectionOnCellClick(context, event) {
20208
20284
  if (selectionMode !== "multi-cell") {
20209
20285
  return;
20210
20286
  }
20211
- const { multiCellSelector } = getComputed();
20287
+ const { multiCellSelector, computedVisibleColumns } = getComputed();
20288
+ const { brain } = getState();
20289
+ const { rowsPerPage } = brain;
20290
+ const columnsPerSet = computedVisibleColumns.length;
20212
20291
  const cellSelection = new CellSelectionState(existingCellSelection);
20213
20292
  multiCellSelector.cellSelectionState = cellSelection;
20214
20293
  const position2 = {
@@ -20218,7 +20297,17 @@ function updateCellSelectionOnCellClick(context, event) {
20218
20297
  if (event.metaKey || event.ctrlKey) {
20219
20298
  multiCellSelector.singleAddClick(position2);
20220
20299
  } else if (event.shiftKey) {
20221
- multiCellSelector.multiSelectClick(position2);
20300
+ const horizontalLayout = !!getState().wrapRowsHorizontally;
20301
+ multiCellSelector.multiSelectClick(
20302
+ position2,
20303
+ horizontalLayout ? {
20304
+ horizontalLayout,
20305
+ rowsPerPage,
20306
+ columnsPerSet
20307
+ } : {
20308
+ horizontalLayout
20309
+ }
20310
+ );
20222
20311
  } else {
20223
20312
  multiCellSelector.resetClick(position2);
20224
20313
  }
@@ -23803,7 +23892,7 @@ function useHorizontalLayout() {
23803
23892
  } = getDataSourceState();
23804
23893
  let changes = false;
23805
23894
  const rowsPerPage = brain.rowsPerPage;
23806
- const newRowsPerPage = groupBy && groupBy.length > 0 ? rowsPerPage : null;
23895
+ const newRowsPerPage = groupBy && groupBy.length > 0 && rowsPerPage > 0 ? rowsPerPage : null;
23807
23896
  if (currentRowsPerPage != newRowsPerPage) {
23808
23897
  dataSourceActions.rowsPerPage = newRowsPerPage;
23809
23898
  changes = true;
package/index.js CHANGED
@@ -16215,16 +16215,7 @@ function notNullable(value) {
16215
16215
  return true;
16216
16216
  }
16217
16217
 
16218
- // src/components/InfiniteTable/api/getCellSelectionApi.ts
16219
- function ensureSortedPerOrder(arr, sortPattern) {
16220
- const arrSet = new Set(arr);
16221
- return sortPattern.map((item) => {
16222
- if (arrSet.has(item)) {
16223
- return item;
16224
- }
16225
- return null;
16226
- }).filter((x) => x != null);
16227
- }
16218
+ // src/components/types/CellPositionByIndex.ts
16228
16219
  function ensureMinMaxCellPositionByIndex(start, end) {
16229
16220
  let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
16230
16221
  let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
@@ -16235,6 +16226,64 @@ function ensureMinMaxCellPositionByIndex(start, end) {
16235
16226
  { rowIndex: rowEnd, colIndex: colEnd }
16236
16227
  ];
16237
16228
  }
16229
+ function isSamePage(startPosition, endPosition, options) {
16230
+ const { rowsPerPage } = options;
16231
+ return !rowsPerPage ? true : Math.floor(startPosition.rowIndex / rowsPerPage) === Math.floor(endPosition.rowIndex / rowsPerPage);
16232
+ }
16233
+ function getPositionsArrayForRangeInHorizontaLLayout(startPosition, endPosition, options) {
16234
+ if (isSamePage(startPosition, endPosition, options)) {
16235
+ throw "You should not call this when the positions are in the same page";
16236
+ }
16237
+ const { rowsPerPage, columnsPerSet } = options;
16238
+ if (rowsPerPage === 0) {
16239
+ throw "rowsPerPage cannot be 0";
16240
+ }
16241
+ let start = startPosition;
16242
+ let end = endPosition;
16243
+ if (Math.floor(startPosition.rowIndex / rowsPerPage) > Math.floor(endPosition.rowIndex / rowsPerPage)) {
16244
+ start = endPosition;
16245
+ end = startPosition;
16246
+ }
16247
+ let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
16248
+ let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
16249
+ const pageForStartRowIndex = Math.floor(startRowIndex / rowsPerPage);
16250
+ const pageForEndRowIndex = Math.floor(endRowIndex / rowsPerPage);
16251
+ const offsetForStartRowIndex = startRowIndex % rowsPerPage;
16252
+ const offsetForEndRowIndex = endRowIndex % rowsPerPage;
16253
+ const minOffset = Math.min(offsetForStartRowIndex, offsetForEndRowIndex);
16254
+ const maxOffset = Math.max(offsetForStartRowIndex, offsetForEndRowIndex);
16255
+ const positions = [];
16256
+ for (let page = pageForStartRowIndex; page <= pageForEndRowIndex; page++) {
16257
+ for (let offset = minOffset; offset <= maxOffset; offset++) {
16258
+ const rowIndex = page * rowsPerPage + offset;
16259
+ if (page === pageForStartRowIndex) {
16260
+ for (let colIndex = startColIndex; colIndex < columnsPerSet; colIndex++) {
16261
+ positions.push({ rowIndex, colIndex });
16262
+ }
16263
+ } else if (page === pageForEndRowIndex) {
16264
+ for (let colIndex = 0; colIndex <= endColIndex; colIndex++) {
16265
+ positions.push({ rowIndex, colIndex });
16266
+ }
16267
+ } else {
16268
+ for (let colIndex = 0; colIndex < columnsPerSet; colIndex++) {
16269
+ positions.push({ rowIndex, colIndex });
16270
+ }
16271
+ }
16272
+ }
16273
+ }
16274
+ return positions;
16275
+ }
16276
+
16277
+ // src/components/InfiniteTable/api/getCellSelectionApi.ts
16278
+ function ensureSortedPerOrder(arr, sortPattern) {
16279
+ const arrSet = new Set(arr);
16280
+ return sortPattern.map((item) => {
16281
+ if (arrSet.has(item)) {
16282
+ return item;
16283
+ }
16284
+ return null;
16285
+ }).filter((x) => x != null);
16286
+ }
16238
16287
  var InfiniteTableCellSelectionApiImpl = class {
16239
16288
  constructor(param) {
16240
16289
  this.getCellSelectionPosition = (options) => {
@@ -18071,7 +18120,7 @@ var MultiCellSelector = class {
18071
18120
  this.multiSelectEndPosition = void 0;
18072
18121
  }
18073
18122
  }
18074
- multiSelectClick(position2) {
18123
+ multiSelectClick(position2, options) {
18075
18124
  if (!this.multiSelectStartPosition) {
18076
18125
  return;
18077
18126
  }
@@ -18082,13 +18131,39 @@ var MultiCellSelector = class {
18082
18131
  if (this.multiSelectEndPosition) {
18083
18132
  this.deselectRange(
18084
18133
  this.multiSelectStartPosition,
18085
- this.multiSelectEndPosition
18134
+ this.multiSelectEndPosition,
18135
+ options
18086
18136
  );
18087
18137
  }
18088
- this.selectRange(this.multiSelectStartPosition, position2);
18138
+ this.selectRange(this.multiSelectStartPosition, position2, options);
18089
18139
  this.multiSelectEndPosition = position2;
18090
18140
  }
18091
- setRangeSelected(startPosition, endPosition, selected) {
18141
+ setRangeSelected(startPosition, endPosition, selected, options) {
18142
+ if (options.horizontalLayout && !isSamePage(startPosition, endPosition, options)) {
18143
+ const positions = getPositionsArrayForRangeInHorizontaLLayout(
18144
+ startPosition,
18145
+ endPosition,
18146
+ {
18147
+ rowsPerPage: options.rowsPerPage,
18148
+ columnsPerSet: options.columnsPerSet
18149
+ }
18150
+ );
18151
+ positions.forEach((position2) => {
18152
+ const selectionPosition = this.getCellSelectionPosition({
18153
+ rowIndex: position2.rowIndex,
18154
+ colIndex: position2.colIndex
18155
+ });
18156
+ if (!selectionPosition) {
18157
+ return;
18158
+ }
18159
+ if (selected) {
18160
+ this.cellSelectionState.selectCell(...selectionPosition);
18161
+ } else {
18162
+ this.cellSelectionState.deselectCell(...selectionPosition);
18163
+ }
18164
+ });
18165
+ return;
18166
+ }
18092
18167
  const [start, end] = ensureMinMaxCellPositionByIndex(
18093
18168
  startPosition,
18094
18169
  endPosition
@@ -18115,11 +18190,11 @@ var MultiCellSelector = class {
18115
18190
  }
18116
18191
  }
18117
18192
  }
18118
- deselectRange(startPosition, endPosition) {
18119
- this.setRangeSelected(startPosition, endPosition, false);
18193
+ deselectRange(startPosition, endPosition, options) {
18194
+ this.setRangeSelected(startPosition, endPosition, false, options);
18120
18195
  }
18121
- selectRange(startPosition, endPosition) {
18122
- this.setRangeSelected(startPosition, endPosition, true);
18196
+ selectRange(startPosition, endPosition, options) {
18197
+ this.setRangeSelected(startPosition, endPosition, true, options);
18123
18198
  }
18124
18199
  };
18125
18200
 
@@ -20117,7 +20192,7 @@ var useLicense = (licenseKey = "") => {
20117
20192
  }
20118
20193
  let valid2 = isValidLicense(licenseKey, {
20119
20194
  publishedAt: 1624970570587,
20120
- version: "5.0.0"
20195
+ version: "5.0.1"
20121
20196
  });
20122
20197
  if (!licenseKey && !valid2 && isInsidePlayground) {
20123
20198
  return true;
@@ -20229,6 +20304,7 @@ function onCellDoubleClick(context, _event) {
20229
20304
  function updateCellSelectionOnCellClick(context, event) {
20230
20305
  const {
20231
20306
  getDataSourceState,
20307
+ getState,
20232
20308
  getComputed,
20233
20309
  rowIndex,
20234
20310
  colIndex,
@@ -20242,7 +20318,10 @@ function updateCellSelectionOnCellClick(context, event) {
20242
20318
  if (selectionMode !== "multi-cell") {
20243
20319
  return;
20244
20320
  }
20245
- const { multiCellSelector } = getComputed();
20321
+ const { multiCellSelector, computedVisibleColumns } = getComputed();
20322
+ const { brain } = getState();
20323
+ const { rowsPerPage } = brain;
20324
+ const columnsPerSet = computedVisibleColumns.length;
20246
20325
  const cellSelection = new CellSelectionState(existingCellSelection);
20247
20326
  multiCellSelector.cellSelectionState = cellSelection;
20248
20327
  const position2 = {
@@ -20252,7 +20331,17 @@ function updateCellSelectionOnCellClick(context, event) {
20252
20331
  if (event.metaKey || event.ctrlKey) {
20253
20332
  multiCellSelector.singleAddClick(position2);
20254
20333
  } else if (event.shiftKey) {
20255
- multiCellSelector.multiSelectClick(position2);
20334
+ const horizontalLayout = !!getState().wrapRowsHorizontally;
20335
+ multiCellSelector.multiSelectClick(
20336
+ position2,
20337
+ horizontalLayout ? {
20338
+ horizontalLayout,
20339
+ rowsPerPage,
20340
+ columnsPerSet
20341
+ } : {
20342
+ horizontalLayout
20343
+ }
20344
+ );
20256
20345
  } else {
20257
20346
  multiCellSelector.resetClick(position2);
20258
20347
  }
@@ -23827,7 +23916,7 @@ function useHorizontalLayout() {
23827
23916
  } = getDataSourceState();
23828
23917
  let changes = false;
23829
23918
  const rowsPerPage = brain.rowsPerPage;
23830
- const newRowsPerPage = groupBy && groupBy.length > 0 ? rowsPerPage : null;
23919
+ const newRowsPerPage = groupBy && groupBy.length > 0 && rowsPerPage > 0 ? rowsPerPage : null;
23831
23920
  if (currentRowsPerPage != newRowsPerPage) {
23832
23921
  dataSourceActions.rowsPerPage = newRowsPerPage;
23833
23922
  changes = true;
package/index.mjs CHANGED
@@ -16177,16 +16177,7 @@ function notNullable(value) {
16177
16177
  return true;
16178
16178
  }
16179
16179
 
16180
- // src/components/InfiniteTable/api/getCellSelectionApi.ts
16181
- function ensureSortedPerOrder(arr, sortPattern) {
16182
- const arrSet = new Set(arr);
16183
- return sortPattern.map((item) => {
16184
- if (arrSet.has(item)) {
16185
- return item;
16186
- }
16187
- return null;
16188
- }).filter((x) => x != null);
16189
- }
16180
+ // src/components/types/CellPositionByIndex.ts
16190
16181
  function ensureMinMaxCellPositionByIndex(start, end) {
16191
16182
  let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
16192
16183
  let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
@@ -16197,6 +16188,64 @@ function ensureMinMaxCellPositionByIndex(start, end) {
16197
16188
  { rowIndex: rowEnd, colIndex: colEnd }
16198
16189
  ];
16199
16190
  }
16191
+ function isSamePage(startPosition, endPosition, options) {
16192
+ const { rowsPerPage } = options;
16193
+ return !rowsPerPage ? true : Math.floor(startPosition.rowIndex / rowsPerPage) === Math.floor(endPosition.rowIndex / rowsPerPage);
16194
+ }
16195
+ function getPositionsArrayForRangeInHorizontaLLayout(startPosition, endPosition, options) {
16196
+ if (isSamePage(startPosition, endPosition, options)) {
16197
+ throw "You should not call this when the positions are in the same page";
16198
+ }
16199
+ const { rowsPerPage, columnsPerSet } = options;
16200
+ if (rowsPerPage === 0) {
16201
+ throw "rowsPerPage cannot be 0";
16202
+ }
16203
+ let start = startPosition;
16204
+ let end = endPosition;
16205
+ if (Math.floor(startPosition.rowIndex / rowsPerPage) > Math.floor(endPosition.rowIndex / rowsPerPage)) {
16206
+ start = endPosition;
16207
+ end = startPosition;
16208
+ }
16209
+ let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
16210
+ let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
16211
+ const pageForStartRowIndex = Math.floor(startRowIndex / rowsPerPage);
16212
+ const pageForEndRowIndex = Math.floor(endRowIndex / rowsPerPage);
16213
+ const offsetForStartRowIndex = startRowIndex % rowsPerPage;
16214
+ const offsetForEndRowIndex = endRowIndex % rowsPerPage;
16215
+ const minOffset = Math.min(offsetForStartRowIndex, offsetForEndRowIndex);
16216
+ const maxOffset = Math.max(offsetForStartRowIndex, offsetForEndRowIndex);
16217
+ const positions = [];
16218
+ for (let page = pageForStartRowIndex; page <= pageForEndRowIndex; page++) {
16219
+ for (let offset = minOffset; offset <= maxOffset; offset++) {
16220
+ const rowIndex = page * rowsPerPage + offset;
16221
+ if (page === pageForStartRowIndex) {
16222
+ for (let colIndex = startColIndex; colIndex < columnsPerSet; colIndex++) {
16223
+ positions.push({ rowIndex, colIndex });
16224
+ }
16225
+ } else if (page === pageForEndRowIndex) {
16226
+ for (let colIndex = 0; colIndex <= endColIndex; colIndex++) {
16227
+ positions.push({ rowIndex, colIndex });
16228
+ }
16229
+ } else {
16230
+ for (let colIndex = 0; colIndex < columnsPerSet; colIndex++) {
16231
+ positions.push({ rowIndex, colIndex });
16232
+ }
16233
+ }
16234
+ }
16235
+ }
16236
+ return positions;
16237
+ }
16238
+
16239
+ // src/components/InfiniteTable/api/getCellSelectionApi.ts
16240
+ function ensureSortedPerOrder(arr, sortPattern) {
16241
+ const arrSet = new Set(arr);
16242
+ return sortPattern.map((item) => {
16243
+ if (arrSet.has(item)) {
16244
+ return item;
16245
+ }
16246
+ return null;
16247
+ }).filter((x) => x != null);
16248
+ }
16200
16249
  var InfiniteTableCellSelectionApiImpl = class {
16201
16250
  constructor(param) {
16202
16251
  this.getCellSelectionPosition = (options) => {
@@ -18037,7 +18086,7 @@ var MultiCellSelector = class {
18037
18086
  this.multiSelectEndPosition = void 0;
18038
18087
  }
18039
18088
  }
18040
- multiSelectClick(position2) {
18089
+ multiSelectClick(position2, options) {
18041
18090
  if (!this.multiSelectStartPosition) {
18042
18091
  return;
18043
18092
  }
@@ -18048,13 +18097,39 @@ var MultiCellSelector = class {
18048
18097
  if (this.multiSelectEndPosition) {
18049
18098
  this.deselectRange(
18050
18099
  this.multiSelectStartPosition,
18051
- this.multiSelectEndPosition
18100
+ this.multiSelectEndPosition,
18101
+ options
18052
18102
  );
18053
18103
  }
18054
- this.selectRange(this.multiSelectStartPosition, position2);
18104
+ this.selectRange(this.multiSelectStartPosition, position2, options);
18055
18105
  this.multiSelectEndPosition = position2;
18056
18106
  }
18057
- setRangeSelected(startPosition, endPosition, selected) {
18107
+ setRangeSelected(startPosition, endPosition, selected, options) {
18108
+ if (options.horizontalLayout && !isSamePage(startPosition, endPosition, options)) {
18109
+ const positions = getPositionsArrayForRangeInHorizontaLLayout(
18110
+ startPosition,
18111
+ endPosition,
18112
+ {
18113
+ rowsPerPage: options.rowsPerPage,
18114
+ columnsPerSet: options.columnsPerSet
18115
+ }
18116
+ );
18117
+ positions.forEach((position2) => {
18118
+ const selectionPosition = this.getCellSelectionPosition({
18119
+ rowIndex: position2.rowIndex,
18120
+ colIndex: position2.colIndex
18121
+ });
18122
+ if (!selectionPosition) {
18123
+ return;
18124
+ }
18125
+ if (selected) {
18126
+ this.cellSelectionState.selectCell(...selectionPosition);
18127
+ } else {
18128
+ this.cellSelectionState.deselectCell(...selectionPosition);
18129
+ }
18130
+ });
18131
+ return;
18132
+ }
18058
18133
  const [start, end] = ensureMinMaxCellPositionByIndex(
18059
18134
  startPosition,
18060
18135
  endPosition
@@ -18081,11 +18156,11 @@ var MultiCellSelector = class {
18081
18156
  }
18082
18157
  }
18083
18158
  }
18084
- deselectRange(startPosition, endPosition) {
18085
- this.setRangeSelected(startPosition, endPosition, false);
18159
+ deselectRange(startPosition, endPosition, options) {
18160
+ this.setRangeSelected(startPosition, endPosition, false, options);
18086
18161
  }
18087
- selectRange(startPosition, endPosition) {
18088
- this.setRangeSelected(startPosition, endPosition, true);
18162
+ selectRange(startPosition, endPosition, options) {
18163
+ this.setRangeSelected(startPosition, endPosition, true, options);
18089
18164
  }
18090
18165
  };
18091
18166
 
@@ -20083,7 +20158,7 @@ var useLicense = (licenseKey = "") => {
20083
20158
  }
20084
20159
  let valid2 = isValidLicense(licenseKey, {
20085
20160
  publishedAt: 1624970570587,
20086
- version: "5.0.0"
20161
+ version: "5.0.1"
20087
20162
  });
20088
20163
  if (!licenseKey && !valid2 && isInsidePlayground) {
20089
20164
  return true;
@@ -20195,6 +20270,7 @@ function onCellDoubleClick(context, _event) {
20195
20270
  function updateCellSelectionOnCellClick(context, event) {
20196
20271
  const {
20197
20272
  getDataSourceState,
20273
+ getState,
20198
20274
  getComputed,
20199
20275
  rowIndex,
20200
20276
  colIndex,
@@ -20208,7 +20284,10 @@ function updateCellSelectionOnCellClick(context, event) {
20208
20284
  if (selectionMode !== "multi-cell") {
20209
20285
  return;
20210
20286
  }
20211
- const { multiCellSelector } = getComputed();
20287
+ const { multiCellSelector, computedVisibleColumns } = getComputed();
20288
+ const { brain } = getState();
20289
+ const { rowsPerPage } = brain;
20290
+ const columnsPerSet = computedVisibleColumns.length;
20212
20291
  const cellSelection = new CellSelectionState(existingCellSelection);
20213
20292
  multiCellSelector.cellSelectionState = cellSelection;
20214
20293
  const position2 = {
@@ -20218,7 +20297,17 @@ function updateCellSelectionOnCellClick(context, event) {
20218
20297
  if (event.metaKey || event.ctrlKey) {
20219
20298
  multiCellSelector.singleAddClick(position2);
20220
20299
  } else if (event.shiftKey) {
20221
- multiCellSelector.multiSelectClick(position2);
20300
+ const horizontalLayout = !!getState().wrapRowsHorizontally;
20301
+ multiCellSelector.multiSelectClick(
20302
+ position2,
20303
+ horizontalLayout ? {
20304
+ horizontalLayout,
20305
+ rowsPerPage,
20306
+ columnsPerSet
20307
+ } : {
20308
+ horizontalLayout
20309
+ }
20310
+ );
20222
20311
  } else {
20223
20312
  multiCellSelector.resetClick(position2);
20224
20313
  }
@@ -23803,7 +23892,7 @@ function useHorizontalLayout() {
23803
23892
  } = getDataSourceState();
23804
23893
  let changes = false;
23805
23894
  const rowsPerPage = brain.rowsPerPage;
23806
- const newRowsPerPage = groupBy && groupBy.length > 0 ? rowsPerPage : null;
23895
+ const newRowsPerPage = groupBy && groupBy.length > 0 && rowsPerPage > 0 ? rowsPerPage : null;
23807
23896
  if (currentRowsPerPage != newRowsPerPage) {
23808
23897
  dataSourceActions.rowsPerPage = newRowsPerPage;
23809
23898
  changes = true;
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "bugs": {
26
26
  "url": "https://github.com/infinite-table/infinite-react/issues"
27
27
  },
28
- "version": "5.0.0",
28
+ "version": "5.0.1",
29
29
  "main": "index.js",
30
30
  "module": "index.mjs",
31
31
  "typings": "index.d.ts",
@@ -34,5 +34,5 @@
34
34
  },
35
35
  "license": "Commercial & Open Source",
36
36
  "//": "will be updated at build time",
37
- "publishedAt": 1728398746086
37
+ "publishedAt": 1728477164758
38
38
  }