@infinite-table/infinite-react 6.1.1-canary.0 → 6.1.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.
Files changed (6) hide show
  1. package/index.d.ts +1288 -1274
  2. package/index.dev.js +483 -405
  3. package/index.dev.mjs +483 -405
  4. package/index.js +483 -405
  5. package/index.mjs +483 -405
  6. package/package.json +2 -2
package/index.dev.mjs CHANGED
@@ -19517,6 +19517,377 @@ function getRowDetailApi(param) {
19517
19517
  return rowDetailApi;
19518
19518
  }
19519
19519
 
19520
+ // src/components/utils/clamp.ts
19521
+ function clamp(value, min, max) {
19522
+ return Math.min(Math.max(value, min), max);
19523
+ }
19524
+
19525
+ // src/components/InfiniteTable/eventHandlers/keyboardNavigation.ts
19526
+ function getNextEnabledRowIndex(getDataSourceState, activeRowIndex, direction) {
19527
+ const dataArray = getDataSourceState().dataArray;
19528
+ const min = 0;
19529
+ const max = dataArray.length - 1;
19530
+ let i = activeRowIndex;
19531
+ do {
19532
+ i += direction;
19533
+ const rowInfo = dataArray[i];
19534
+ if (!rowInfo) {
19535
+ return i < min ? min : max;
19536
+ }
19537
+ if (!rowInfo.rowDisabled) {
19538
+ return i;
19539
+ }
19540
+ } while (i >= min && i <= max);
19541
+ return clamp(i, min, max);
19542
+ }
19543
+ function handleRowNavigation(options, event) {
19544
+ const { getState, getDataSourceState, actions, api, dataSourceApi } = options;
19545
+ const { key } = event;
19546
+ const dataArray = getDataSourceState().dataArray;
19547
+ const arrLength = dataArray.length;
19548
+ const state = getState();
19549
+ const { brain } = state;
19550
+ let { activeRowIndex } = state;
19551
+ if (activeRowIndex == null) {
19552
+ return false;
19553
+ }
19554
+ const {
19555
+ start: [startRow],
19556
+ end: [endRow]
19557
+ } = brain.getRenderRange();
19558
+ const initialActiveRowIndex = activeRowIndex;
19559
+ const renderRowCount = endRow - startRow - 1;
19560
+ const min = 0;
19561
+ const max = arrLength - 1;
19562
+ const KeyToFunction = {
19563
+ ArrowDown: () => {
19564
+ activeRowIndex = getNextEnabledRowIndex(
19565
+ getDataSourceState,
19566
+ activeRowIndex,
19567
+ 1
19568
+ );
19569
+ },
19570
+ ArrowUp: () => {
19571
+ activeRowIndex = getNextEnabledRowIndex(
19572
+ getDataSourceState,
19573
+ activeRowIndex,
19574
+ -1
19575
+ );
19576
+ },
19577
+ ArrowLeft: () => {
19578
+ const rowInfo = dataArray[activeRowIndex];
19579
+ if (brain.isHorizontalLayoutBrain) {
19580
+ const rowsPerPage = brain.rowsPerPage;
19581
+ if (activeRowIndex - rowsPerPage >= min) {
19582
+ activeRowIndex = activeRowIndex - rowsPerPage;
19583
+ } else {
19584
+ KeyToFunction.ArrowUp();
19585
+ }
19586
+ return;
19587
+ }
19588
+ if (rowInfo && rowInfo.isGroupRow) {
19589
+ return api.collapseGroupRow(rowInfo.groupKeys);
19590
+ }
19591
+ if (rowInfo && api.rowDetailApi.isRowDetailEnabledForRow(rowInfo.id)) {
19592
+ return api.rowDetailApi.collapseRowDetail(rowInfo.id);
19593
+ }
19594
+ return false;
19595
+ },
19596
+ ArrowRight: () => {
19597
+ const rowInfo = dataArray[activeRowIndex];
19598
+ if (brain.isHorizontalLayoutBrain) {
19599
+ const rowsPerPage = brain.rowsPerPage;
19600
+ if (activeRowIndex + rowsPerPage <= max) {
19601
+ activeRowIndex = activeRowIndex + rowsPerPage;
19602
+ } else {
19603
+ KeyToFunction.ArrowDown();
19604
+ }
19605
+ return;
19606
+ }
19607
+ if (rowInfo && rowInfo.isGroupRow) {
19608
+ return api.expandGroupRow(rowInfo.groupKeys);
19609
+ }
19610
+ if (rowInfo && api.rowDetailApi.isRowDetailEnabledForRow(rowInfo.id)) {
19611
+ return api.rowDetailApi.expandRowDetail(rowInfo.id);
19612
+ }
19613
+ return false;
19614
+ },
19615
+ Enter: () => {
19616
+ const rowInfo = dataArray[activeRowIndex];
19617
+ if (rowInfo && rowInfo.isGroupRow) {
19618
+ return api.toggleGroupRow(rowInfo.groupKeys);
19619
+ }
19620
+ if (rowInfo && rowInfo.isTreeNode && rowInfo.isParentNode) {
19621
+ return dataSourceApi.treeApi.toggleNode(rowInfo.nodePath);
19622
+ }
19623
+ const hasRowDetail = api.rowDetailApi.isRowDetailEnabledForRow(
19624
+ rowInfo.id
19625
+ );
19626
+ if (hasRowDetail) {
19627
+ return api.rowDetailApi.toggleRowDetail(rowInfo.id);
19628
+ }
19629
+ return false;
19630
+ },
19631
+ PageDown: () => {
19632
+ activeRowIndex = Math.min(
19633
+ activeRowIndex + renderRowCount,
19634
+ arrLength - 1
19635
+ );
19636
+ },
19637
+ PageUp: () => {
19638
+ activeRowIndex = Math.max(activeRowIndex - renderRowCount, min);
19639
+ },
19640
+ End: () => {
19641
+ activeRowIndex = max;
19642
+ },
19643
+ Home: () => {
19644
+ activeRowIndex = min;
19645
+ }
19646
+ };
19647
+ const Fn = KeyToFunction[key];
19648
+ if (!Fn) {
19649
+ return false;
19650
+ }
19651
+ Fn();
19652
+ if (initialActiveRowIndex !== activeRowIndex) {
19653
+ actions.activeRowIndex = activeRowIndex;
19654
+ return true;
19655
+ }
19656
+ return false;
19657
+ }
19658
+ function computeNextActiveCellIndex(options, event) {
19659
+ const {
19660
+ api,
19661
+ getState,
19662
+ getComputed,
19663
+ getDataSourceState,
19664
+ dataSourceApi
19665
+ } = options;
19666
+ const { key, shiftKey } = event;
19667
+ const dataArray = getDataSourceState().dataArray;
19668
+ const state = getState();
19669
+ const { activeCellIndex, brain } = state;
19670
+ if (!activeCellIndex) {
19671
+ return false;
19672
+ }
19673
+ let [rowIndex, colIndex] = activeCellIndex;
19674
+ const {
19675
+ start: [startRow, startCol],
19676
+ end: [endRow, endCol]
19677
+ } = brain.getRenderRange();
19678
+ const renderRowCount = endRow - startRow - 1;
19679
+ const renderColCount = endCol - startCol - 1;
19680
+ const maxRow = getDataSourceState().dataArray.length - 1;
19681
+ const maxCol = getComputed().computedVisibleColumns.length - 1;
19682
+ const minRow = 0;
19683
+ const minCol = 0;
19684
+ rowIndex = clamp(rowIndex, 0, maxRow);
19685
+ colIndex = clamp(colIndex, 0, maxCol);
19686
+ const KeyToFunction = {
19687
+ ArrowDown: () => {
19688
+ rowIndex = clamp(rowIndex + 1, minRow, maxRow);
19689
+ },
19690
+ ArrowUp: () => {
19691
+ rowIndex = clamp(rowIndex - 1, minRow, maxRow);
19692
+ },
19693
+ ArrowLeft: () => {
19694
+ if (colIndex === minCol) {
19695
+ if (rowIndex !== minRow) {
19696
+ colIndex = maxCol;
19697
+ }
19698
+ if (brain.isHorizontalLayoutBrain) {
19699
+ const rowsPerPage = brain.rowsPerPage;
19700
+ if (rowIndex - rowsPerPage >= minRow) {
19701
+ rowIndex = rowIndex - rowsPerPage;
19702
+ } else {
19703
+ KeyToFunction.ArrowUp();
19704
+ }
19705
+ } else {
19706
+ KeyToFunction.ArrowUp();
19707
+ }
19708
+ } else {
19709
+ colIndex = clamp(colIndex - 1, minCol, maxCol);
19710
+ }
19711
+ },
19712
+ ArrowRight: () => {
19713
+ if (colIndex === maxCol) {
19714
+ if (rowIndex !== maxRow) {
19715
+ colIndex = minCol;
19716
+ }
19717
+ if (brain.isHorizontalLayoutBrain) {
19718
+ const rowsPerPage = brain.rowsPerPage;
19719
+ if (rowIndex + rowsPerPage <= maxRow) {
19720
+ rowIndex = rowIndex + rowsPerPage;
19721
+ } else {
19722
+ KeyToFunction.ArrowDown();
19723
+ }
19724
+ } else {
19725
+ KeyToFunction.ArrowDown();
19726
+ }
19727
+ } else {
19728
+ colIndex = clamp(colIndex + 1, minCol, maxCol);
19729
+ }
19730
+ },
19731
+ Enter: () => {
19732
+ const rowInfo = dataArray[rowIndex];
19733
+ if (rowInfo && rowInfo.isGroupRow) {
19734
+ return api.toggleGroupRow(rowInfo.groupKeys);
19735
+ }
19736
+ if (rowInfo && rowInfo.isTreeNode && rowInfo.isParentNode) {
19737
+ return dataSourceApi.treeApi.toggleNode(rowInfo.nodePath);
19738
+ }
19739
+ if (rowInfo && api.rowDetailApi.isRowDetailEnabledForRow(rowInfo.id)) {
19740
+ return api.rowDetailApi.toggleRowDetail(rowInfo.id);
19741
+ }
19742
+ return false;
19743
+ },
19744
+ PageDown: () => {
19745
+ if (!shiftKey) {
19746
+ rowIndex = Math.min(rowIndex + renderRowCount, maxRow);
19747
+ } else {
19748
+ colIndex = Math.min(colIndex + renderColCount, maxCol);
19749
+ }
19750
+ },
19751
+ PageUp: () => {
19752
+ if (!shiftKey) {
19753
+ rowIndex = Math.max(rowIndex - renderRowCount, minRow);
19754
+ } else {
19755
+ colIndex = Math.max(colIndex - renderColCount, minCol);
19756
+ }
19757
+ },
19758
+ End: () => {
19759
+ if (!shiftKey) {
19760
+ rowIndex = maxRow;
19761
+ } else {
19762
+ colIndex = maxCol;
19763
+ }
19764
+ },
19765
+ Home: () => {
19766
+ if (!shiftKey) {
19767
+ rowIndex = minRow;
19768
+ } else {
19769
+ colIndex = minCol;
19770
+ }
19771
+ }
19772
+ };
19773
+ const Fn = KeyToFunction[key];
19774
+ if (!Fn) {
19775
+ return false;
19776
+ }
19777
+ Fn();
19778
+ return [rowIndex, colIndex];
19779
+ }
19780
+ function handleCellNavigation(options, event) {
19781
+ const result = computeNextActiveCellIndex(
19782
+ options,
19783
+ event
19784
+ );
19785
+ if (result) {
19786
+ options.actions.activeCellIndex = result;
19787
+ return true;
19788
+ }
19789
+ return false;
19790
+ }
19791
+ var validKeys = {
19792
+ ArrowUp: true,
19793
+ ArrowDown: true,
19794
+ ArrowLeft: true,
19795
+ ArrowRight: true,
19796
+ PageUp: true,
19797
+ PageDown: true,
19798
+ Home: true,
19799
+ End: true,
19800
+ Enter: true,
19801
+ " ": true
19802
+ };
19803
+ function handleKeyboardNavigation(options, event) {
19804
+ const { key } = event;
19805
+ const { getState } = options;
19806
+ const state = getState();
19807
+ const {
19808
+ activeRowIndex,
19809
+ activeCellIndex,
19810
+ keyboardNavigation,
19811
+ cellContextMenuVisibleFor,
19812
+ contextMenuVisibleFor
19813
+ } = state;
19814
+ if (cellContextMenuVisibleFor || contextMenuVisibleFor) {
19815
+ return false;
19816
+ }
19817
+ if (!validKeys[key]) {
19818
+ return false;
19819
+ }
19820
+ if (activeRowIndex != null && keyboardNavigation === "row") {
19821
+ return handleRowNavigation(options, event);
19822
+ }
19823
+ if (activeCellIndex != null && keyboardNavigation === "cell") {
19824
+ return handleCellNavigation(options, event);
19825
+ }
19826
+ return false;
19827
+ }
19828
+
19829
+ // src/components/InfiniteTable/api/getKeyboardNavigationApi.ts
19830
+ var KeyboardNavigationApi = class {
19831
+ constructor(param) {
19832
+ this.param = param;
19833
+ }
19834
+ setKeyboardNavigation(keyboardNavigation) {
19835
+ this.param.actions.keyboardNavigation = keyboardNavigation;
19836
+ }
19837
+ setActiveCellIndex(activeCellIndex) {
19838
+ this.param.actions.activeCellIndex = activeCellIndex;
19839
+ }
19840
+ setActiveRowIndex(activeRowIndex) {
19841
+ this.param.actions.activeRowIndex = activeRowIndex;
19842
+ }
19843
+ gotoRowWithDirection(direction) {
19844
+ const { getDataSourceState, getState } = this.param;
19845
+ const { activeRowIndex, keyboardNavigation } = getState();
19846
+ if (keyboardNavigation !== "row") {
19847
+ console.error("Keyboard navigation is not enabled for rows");
19848
+ return false;
19849
+ }
19850
+ if (activeRowIndex == null) {
19851
+ return false;
19852
+ }
19853
+ const newActiveRowIndex = getNextEnabledRowIndex(
19854
+ getDataSourceState,
19855
+ activeRowIndex,
19856
+ direction
19857
+ );
19858
+ if (newActiveRowIndex !== activeRowIndex) {
19859
+ this.param.actions.activeRowIndex = newActiveRowIndex;
19860
+ return newActiveRowIndex;
19861
+ }
19862
+ return false;
19863
+ }
19864
+ gotoRow(direction) {
19865
+ return this.gotoRowWithDirection(direction);
19866
+ }
19867
+ gotoNextRow() {
19868
+ return this.gotoRow(1);
19869
+ }
19870
+ gotoPreviousRow() {
19871
+ return this.gotoRow(-1);
19872
+ }
19873
+ gotoCell(config) {
19874
+ const { direction } = config;
19875
+ const key = direction == "top" ? "ArrowUp" : direction == "bottom" ? "ArrowDown" : direction == "left" ? "ArrowLeft" : "ArrowRight";
19876
+ const activeCellIndex = computeNextActiveCellIndex(this.param, {
19877
+ key,
19878
+ shiftKey: false
19879
+ });
19880
+ if (activeCellIndex === false) {
19881
+ return false;
19882
+ }
19883
+ this.param.actions.activeCellIndex = activeCellIndex;
19884
+ return activeCellIndex;
19885
+ }
19886
+ };
19887
+ function getKeyboardNavigationApi(param) {
19888
+ return new KeyboardNavigationApi(param);
19889
+ }
19890
+
19520
19891
  // src/components/InfiniteTable/api/getImperativeApi.ts
19521
19892
  function isSortInfoForColumn(sortInfo, col) {
19522
19893
  if (sortInfo.id) {
@@ -19951,6 +20322,14 @@ var InfiniteTableApiImpl = class {
19951
20322
  dataSourceActions: context.dataSourceActions,
19952
20323
  getDataSourceState: context.getDataSourceState
19953
20324
  });
20325
+ this.keyboardNavigationApi = getKeyboardNavigationApi({
20326
+ getState: context.getState,
20327
+ getDataSourceState: context.getDataSourceState,
20328
+ actions: context.actions,
20329
+ getComputed: context.getComputed,
20330
+ api: this,
20331
+ dataSourceApi: context.dataSourceApi
20332
+ });
19954
20333
  this.rowDetailApi = getRowDetailApi({
19955
20334
  getState: context.getState,
19956
20335
  actions: context.actions,
@@ -23172,7 +23551,7 @@ var useLicense = (licenseKey = "") => {
23172
23551
  }
23173
23552
  let valid2 = isValidLicense(licenseKey, {
23174
23553
  publishedAt: 1624970570587,
23175
- version: "6.1.1-canary.0"
23554
+ version: "6.1.1"
23176
23555
  });
23177
23556
  if (!licenseKey && !valid2 && isInsidePlayground) {
23178
23557
  return true;
@@ -23280,431 +23659,130 @@ function onCellDoubleClick(context, event) {
23280
23659
  };
23281
23660
  if (onCellDoubleClick2) {
23282
23661
  const result = onCellDoubleClick2(context, event);
23283
- if (result && typeof result === "object") {
23284
- dblClickResult = { ...dblClickResult, ...result };
23285
- }
23286
- }
23287
- if (dblClickResult.preventEdit) {
23288
- return;
23289
- }
23290
- const computed = context.getComputed();
23291
- const column = computed.computedVisibleColumns[context.colIndex];
23292
- context.api.startEdit({
23293
- rowIndex: context.rowIndex,
23294
- columnId: column.id
23295
- });
23296
- }
23297
- function updateCellSelectionOnCellClick(context, event) {
23298
- const {
23299
- getDataSourceState,
23300
- getState,
23301
- getComputed,
23302
- rowIndex,
23303
- colIndex,
23304
- dataSourceActions
23305
- } = context;
23306
- const dataSourceState = getDataSourceState();
23307
- const { selectionMode, cellSelection: existingCellSelection } = dataSourceState;
23308
- if (!existingCellSelection) {
23309
- return;
23310
- }
23311
- if (selectionMode !== "multi-cell") {
23312
- return;
23313
- }
23314
- const { multiCellSelector, computedVisibleColumns } = getComputed();
23315
- const { brain } = getState();
23316
- const { rowsPerPage } = brain;
23317
- const columnsPerSet = computedVisibleColumns.length;
23318
- const cellSelection = new CellSelectionState(existingCellSelection);
23319
- multiCellSelector.cellSelectionState = cellSelection;
23320
- const position2 = {
23321
- rowIndex,
23322
- colIndex
23323
- };
23324
- if (event.metaKey || event.ctrlKey) {
23325
- multiCellSelector.singleAddClick(position2);
23326
- } else if (event.shiftKey) {
23327
- const horizontalLayout = !!getState().wrapRowsHorizontally;
23328
- multiCellSelector.multiSelectClick(
23329
- position2,
23330
- horizontalLayout ? {
23331
- horizontalLayout,
23332
- rowsPerPage,
23333
- columnsPerSet
23334
- } : {
23335
- horizontalLayout
23336
- }
23337
- );
23338
- } else {
23339
- multiCellSelector.resetClick(position2);
23340
- }
23341
- dataSourceActions.cellSelection = cellSelection;
23342
- }
23343
- function updateRowSelectionOnCellClick(context, event) {
23344
- const {
23345
- rowIndex,
23346
- getDataSourceState,
23347
- getComputed,
23348
- dataSourceActions,
23349
- api,
23350
- cloneRowSelection: cloneRowSelection2
23351
- } = context;
23352
- const { multiRowSelector, renderSelectionCheckBox } = getComputed();
23353
- const dataSourceState = getDataSourceState();
23354
- const { selectionMode, groupBy, dataArray, isTree } = dataSourceState;
23355
- if (groupBy.length) {
23356
- return false;
23357
- }
23358
- if (isTree) {
23359
- return false;
23360
- }
23361
- const rowInfo = dataArray[rowIndex];
23362
- if (rowInfo?.rowDisabled) {
23363
- return false;
23364
- }
23365
- if (selectionMode === "multi-row") {
23366
- if (renderSelectionCheckBox && !event.key) {
23367
- return false;
23368
- }
23369
- let { rowSelection: rowSelectionState } = dataSourceState;
23370
- rowSelectionState = cloneRowSelection2(
23371
- rowSelectionState
23372
- );
23373
- multiRowSelector.rowSelectionState = rowSelectionState;
23374
- if (rowSelectionState && typeof rowSelectionState === "object") {
23375
- if (event.shiftKey) {
23376
- multiRowSelector.multiSelectClick(rowIndex);
23377
- } else if (event.metaKey || event.ctrlKey) {
23378
- multiRowSelector.singleAddClick(rowIndex);
23379
- } else {
23380
- multiRowSelector.resetClick(rowIndex);
23381
- }
23382
- dataSourceActions.rowSelection = rowSelectionState;
23383
- return true;
23384
- }
23385
- } else if (selectionMode === "single-row") {
23386
- const rowInfo2 = dataArray[rowIndex];
23387
- const id = rowInfo2.id;
23388
- if (event.metaKey || event.ctrlKey) {
23389
- api.rowSelectionApi.toggleRowSelection(id);
23390
- } else {
23391
- api.rowSelectionApi.selectRow(id);
23392
- }
23393
- }
23394
- return false;
23395
- }
23396
-
23397
- // src/components/InfiniteTable/eventHandlers/onCellMouseDown.ts
23398
- function onCellMouseDown(context, event) {
23399
- if (event.detail === 2) {
23400
- return;
23401
- }
23402
- updateCellSelectionOnCellMouseDown(context);
23403
- }
23404
- function updateCellSelectionOnCellMouseDown(_context) {
23405
- }
23406
-
23407
- // src/components/utils/clamp.ts
23408
- function clamp(value, min, max) {
23409
- return Math.min(Math.max(value, min), max);
23410
- }
23411
-
23412
- // src/components/InfiniteTable/eventHandlers/keyboardNavigation.ts
23413
- function getNextEnabledRowIndex(getDataSourceState, activeRowIndex, direction) {
23414
- const dataArray = getDataSourceState().dataArray;
23415
- const min = 0;
23416
- const max = dataArray.length - 1;
23417
- let i = activeRowIndex;
23418
- do {
23419
- i += direction;
23420
- const rowInfo = dataArray[i];
23421
- if (!rowInfo) {
23422
- return i < min ? min : max;
23423
- }
23424
- if (!rowInfo.rowDisabled) {
23425
- return i;
23426
- }
23427
- } while (i >= min && i <= max);
23428
- return clamp(i, min, max);
23429
- }
23430
- function handleRowNavigation(options, event) {
23431
- const { getState, getDataSourceState, actions, api, dataSourceApi } = options;
23432
- const { key } = event;
23433
- const dataArray = getDataSourceState().dataArray;
23434
- const arrLength = dataArray.length;
23435
- const state = getState();
23436
- const { brain } = state;
23437
- let { activeRowIndex } = state;
23438
- if (activeRowIndex == null) {
23439
- return false;
23440
- }
23441
- const {
23442
- start: [startRow],
23443
- end: [endRow]
23444
- } = brain.getRenderRange();
23445
- const initialActiveRowIndex = activeRowIndex;
23446
- const renderRowCount = endRow - startRow - 1;
23447
- const min = 0;
23448
- const max = arrLength - 1;
23449
- const KeyToFunction = {
23450
- ArrowDown: () => {
23451
- activeRowIndex = getNextEnabledRowIndex(
23452
- getDataSourceState,
23453
- activeRowIndex,
23454
- 1
23455
- );
23456
- },
23457
- ArrowUp: () => {
23458
- activeRowIndex = getNextEnabledRowIndex(
23459
- getDataSourceState,
23460
- activeRowIndex,
23461
- -1
23462
- );
23463
- },
23464
- ArrowLeft: () => {
23465
- const rowInfo = dataArray[activeRowIndex];
23466
- if (brain.isHorizontalLayoutBrain) {
23467
- const rowsPerPage = brain.rowsPerPage;
23468
- if (activeRowIndex - rowsPerPage >= min) {
23469
- activeRowIndex = activeRowIndex - rowsPerPage;
23470
- } else {
23471
- KeyToFunction.ArrowUp();
23472
- }
23473
- return;
23474
- }
23475
- if (rowInfo && rowInfo.isGroupRow) {
23476
- return api.collapseGroupRow(rowInfo.groupKeys);
23477
- }
23478
- if (rowInfo && api.rowDetailApi.isRowDetailEnabledForRow(rowInfo.id)) {
23479
- return api.rowDetailApi.collapseRowDetail(rowInfo.id);
23480
- }
23481
- return false;
23482
- },
23483
- ArrowRight: () => {
23484
- const rowInfo = dataArray[activeRowIndex];
23485
- if (brain.isHorizontalLayoutBrain) {
23486
- const rowsPerPage = brain.rowsPerPage;
23487
- if (activeRowIndex + rowsPerPage <= max) {
23488
- activeRowIndex = activeRowIndex + rowsPerPage;
23489
- } else {
23490
- KeyToFunction.ArrowDown();
23491
- }
23492
- return;
23493
- }
23494
- if (rowInfo && rowInfo.isGroupRow) {
23495
- return api.expandGroupRow(rowInfo.groupKeys);
23496
- }
23497
- if (rowInfo && api.rowDetailApi.isRowDetailEnabledForRow(rowInfo.id)) {
23498
- return api.rowDetailApi.expandRowDetail(rowInfo.id);
23499
- }
23500
- return false;
23501
- },
23502
- Enter: () => {
23503
- const rowInfo = dataArray[activeRowIndex];
23504
- if (rowInfo && rowInfo.isGroupRow) {
23505
- return api.toggleGroupRow(rowInfo.groupKeys);
23506
- }
23507
- if (rowInfo && rowInfo.isTreeNode && rowInfo.isParentNode) {
23508
- return dataSourceApi.treeApi.toggleNode(rowInfo.nodePath);
23509
- }
23510
- const hasRowDetail = api.rowDetailApi.isRowDetailEnabledForRow(
23511
- rowInfo.id
23512
- );
23513
- if (hasRowDetail) {
23514
- return api.rowDetailApi.toggleRowDetail(rowInfo.id);
23515
- }
23516
- return false;
23517
- },
23518
- PageDown: () => {
23519
- activeRowIndex = Math.min(
23520
- activeRowIndex + renderRowCount,
23521
- arrLength - 1
23522
- );
23523
- },
23524
- PageUp: () => {
23525
- activeRowIndex = Math.max(activeRowIndex - renderRowCount, min);
23526
- },
23527
- End: () => {
23528
- activeRowIndex = max;
23529
- },
23530
- Home: () => {
23531
- activeRowIndex = min;
23662
+ if (result && typeof result === "object") {
23663
+ dblClickResult = { ...dblClickResult, ...result };
23532
23664
  }
23533
- };
23534
- const Fn = KeyToFunction[key];
23535
- if (!Fn) {
23536
- return false;
23537
23665
  }
23538
- Fn();
23539
- if (initialActiveRowIndex !== activeRowIndex) {
23540
- actions.activeRowIndex = activeRowIndex;
23541
- return true;
23666
+ if (dblClickResult.preventEdit) {
23667
+ return;
23542
23668
  }
23543
- return false;
23669
+ const computed = context.getComputed();
23670
+ const column = computed.computedVisibleColumns[context.colIndex];
23671
+ context.api.startEdit({
23672
+ rowIndex: context.rowIndex,
23673
+ columnId: column.id
23674
+ });
23544
23675
  }
23545
- function handleCellNavigation(options, event) {
23676
+ function updateCellSelectionOnCellClick(context, event) {
23546
23677
  const {
23547
- api,
23678
+ getDataSourceState,
23548
23679
  getState,
23549
23680
  getComputed,
23550
- getDataSourceState,
23551
- dataSourceApi,
23552
- actions
23553
- } = options;
23554
- const { key, shiftKey } = event;
23555
- const dataArray = getDataSourceState().dataArray;
23556
- const state = getState();
23557
- const { activeCellIndex, brain } = state;
23558
- if (!activeCellIndex) {
23559
- return false;
23681
+ rowIndex,
23682
+ colIndex,
23683
+ dataSourceActions
23684
+ } = context;
23685
+ const dataSourceState = getDataSourceState();
23686
+ const { selectionMode, cellSelection: existingCellSelection } = dataSourceState;
23687
+ if (!existingCellSelection) {
23688
+ return;
23560
23689
  }
23561
- let [rowIndex, colIndex] = activeCellIndex;
23562
- const {
23563
- start: [startRow, startCol],
23564
- end: [endRow, endCol]
23565
- } = brain.getRenderRange();
23566
- const renderRowCount = endRow - startRow - 1;
23567
- const renderColCount = endCol - startCol - 1;
23568
- const maxRow = getDataSourceState().dataArray.length - 1;
23569
- const maxCol = getComputed().computedVisibleColumns.length - 1;
23570
- const minRow = 0;
23571
- const minCol = 0;
23572
- rowIndex = clamp(rowIndex, 0, maxRow);
23573
- colIndex = clamp(colIndex, 0, maxCol);
23574
- actions.activeCellIndex = [rowIndex, colIndex];
23575
- const KeyToFunction = {
23576
- ArrowDown: () => {
23577
- rowIndex = clamp(rowIndex + 1, minRow, maxRow);
23578
- },
23579
- ArrowUp: () => {
23580
- rowIndex = clamp(rowIndex - 1, minRow, maxRow);
23581
- },
23582
- ArrowLeft: () => {
23583
- if (colIndex === minCol) {
23584
- if (rowIndex !== minRow) {
23585
- colIndex = maxCol;
23586
- }
23587
- if (brain.isHorizontalLayoutBrain) {
23588
- const rowsPerPage = brain.rowsPerPage;
23589
- if (rowIndex - rowsPerPage >= minRow) {
23590
- rowIndex = rowIndex - rowsPerPage;
23591
- } else {
23592
- KeyToFunction.ArrowUp();
23593
- }
23594
- } else {
23595
- KeyToFunction.ArrowUp();
23596
- }
23597
- } else {
23598
- colIndex = clamp(colIndex - 1, minCol, maxCol);
23599
- }
23600
- },
23601
- ArrowRight: () => {
23602
- if (colIndex === maxCol) {
23603
- if (rowIndex !== maxRow) {
23604
- colIndex = minCol;
23605
- }
23606
- if (brain.isHorizontalLayoutBrain) {
23607
- const rowsPerPage = brain.rowsPerPage;
23608
- if (rowIndex + rowsPerPage <= maxRow) {
23609
- rowIndex = rowIndex + rowsPerPage;
23610
- } else {
23611
- KeyToFunction.ArrowDown();
23612
- }
23613
- } else {
23614
- KeyToFunction.ArrowDown();
23615
- }
23616
- } else {
23617
- colIndex = clamp(colIndex + 1, minCol, maxCol);
23618
- }
23619
- },
23620
- Enter: () => {
23621
- const rowInfo = dataArray[rowIndex];
23622
- if (rowInfo && rowInfo.isGroupRow) {
23623
- return api.toggleGroupRow(rowInfo.groupKeys);
23624
- }
23625
- if (rowInfo && rowInfo.isTreeNode && rowInfo.isParentNode) {
23626
- return dataSourceApi.treeApi.toggleNode(rowInfo.nodePath);
23627
- }
23628
- if (rowInfo && api.rowDetailApi.isRowDetailEnabledForRow(rowInfo.id)) {
23629
- return api.rowDetailApi.toggleRowDetail(rowInfo.id);
23630
- }
23631
- return false;
23632
- },
23633
- PageDown: () => {
23634
- if (!shiftKey) {
23635
- rowIndex = Math.min(rowIndex + renderRowCount, maxRow);
23636
- } else {
23637
- colIndex = Math.min(colIndex + renderColCount, maxCol);
23638
- }
23639
- },
23640
- PageUp: () => {
23641
- if (!shiftKey) {
23642
- rowIndex = Math.max(rowIndex - renderRowCount, minRow);
23643
- } else {
23644
- colIndex = Math.max(colIndex - renderColCount, minCol);
23645
- }
23646
- },
23647
- End: () => {
23648
- if (!shiftKey) {
23649
- rowIndex = maxRow;
23650
- } else {
23651
- colIndex = maxCol;
23652
- }
23653
- },
23654
- Home: () => {
23655
- if (!shiftKey) {
23656
- rowIndex = minRow;
23657
- } else {
23658
- colIndex = minCol;
23659
- }
23660
- }
23690
+ if (selectionMode !== "multi-cell") {
23691
+ return;
23692
+ }
23693
+ const { multiCellSelector, computedVisibleColumns } = getComputed();
23694
+ const { brain } = getState();
23695
+ const { rowsPerPage } = brain;
23696
+ const columnsPerSet = computedVisibleColumns.length;
23697
+ const cellSelection = new CellSelectionState(existingCellSelection);
23698
+ multiCellSelector.cellSelectionState = cellSelection;
23699
+ const position2 = {
23700
+ rowIndex,
23701
+ colIndex
23661
23702
  };
23662
- const Fn = KeyToFunction[key];
23663
- if (!Fn) {
23664
- return false;
23703
+ if (event.metaKey || event.ctrlKey) {
23704
+ multiCellSelector.singleAddClick(position2);
23705
+ } else if (event.shiftKey) {
23706
+ const horizontalLayout = !!getState().wrapRowsHorizontally;
23707
+ multiCellSelector.multiSelectClick(
23708
+ position2,
23709
+ horizontalLayout ? {
23710
+ horizontalLayout,
23711
+ rowsPerPage,
23712
+ columnsPerSet
23713
+ } : {
23714
+ horizontalLayout
23715
+ }
23716
+ );
23717
+ } else {
23718
+ multiCellSelector.resetClick(position2);
23665
23719
  }
23666
- Fn();
23667
- actions.activeCellIndex = [rowIndex, colIndex];
23668
- return true;
23720
+ dataSourceActions.cellSelection = cellSelection;
23669
23721
  }
23670
- var validKeys = {
23671
- ArrowUp: true,
23672
- ArrowDown: true,
23673
- ArrowLeft: true,
23674
- ArrowRight: true,
23675
- PageUp: true,
23676
- PageDown: true,
23677
- Home: true,
23678
- End: true,
23679
- Enter: true,
23680
- " ": true
23681
- };
23682
- function handleKeyboardNavigation(options, event) {
23683
- const { key } = event;
23684
- const { getState } = options;
23685
- const state = getState();
23722
+ function updateRowSelectionOnCellClick(context, event) {
23686
23723
  const {
23687
- activeRowIndex,
23688
- activeCellIndex,
23689
- keyboardNavigation,
23690
- cellContextMenuVisibleFor,
23691
- contextMenuVisibleFor
23692
- } = state;
23693
- if (cellContextMenuVisibleFor || contextMenuVisibleFor) {
23724
+ rowIndex,
23725
+ getDataSourceState,
23726
+ getComputed,
23727
+ dataSourceActions,
23728
+ api,
23729
+ cloneRowSelection: cloneRowSelection2
23730
+ } = context;
23731
+ const { multiRowSelector, renderSelectionCheckBox } = getComputed();
23732
+ const dataSourceState = getDataSourceState();
23733
+ const { selectionMode, groupBy, dataArray, isTree } = dataSourceState;
23734
+ if (groupBy.length) {
23694
23735
  return false;
23695
23736
  }
23696
- if (!validKeys[key]) {
23737
+ if (isTree) {
23697
23738
  return false;
23698
23739
  }
23699
- if (activeRowIndex != null && keyboardNavigation === "row") {
23700
- return handleRowNavigation(options, event);
23740
+ const rowInfo = dataArray[rowIndex];
23741
+ if (rowInfo?.rowDisabled) {
23742
+ return false;
23701
23743
  }
23702
- if (activeCellIndex != null && keyboardNavigation === "cell") {
23703
- return handleCellNavigation(options, event);
23744
+ if (selectionMode === "multi-row") {
23745
+ if (renderSelectionCheckBox && !event.key) {
23746
+ return false;
23747
+ }
23748
+ let { rowSelection: rowSelectionState } = dataSourceState;
23749
+ rowSelectionState = cloneRowSelection2(
23750
+ rowSelectionState
23751
+ );
23752
+ multiRowSelector.rowSelectionState = rowSelectionState;
23753
+ if (rowSelectionState && typeof rowSelectionState === "object") {
23754
+ if (event.shiftKey) {
23755
+ multiRowSelector.multiSelectClick(rowIndex);
23756
+ } else if (event.metaKey || event.ctrlKey) {
23757
+ multiRowSelector.singleAddClick(rowIndex);
23758
+ } else {
23759
+ multiRowSelector.resetClick(rowIndex);
23760
+ }
23761
+ dataSourceActions.rowSelection = rowSelectionState;
23762
+ return true;
23763
+ }
23764
+ } else if (selectionMode === "single-row") {
23765
+ const rowInfo2 = dataArray[rowIndex];
23766
+ const id = rowInfo2.id;
23767
+ if (event.metaKey || event.ctrlKey) {
23768
+ api.rowSelectionApi.toggleRowSelection(id);
23769
+ } else {
23770
+ api.rowSelectionApi.selectRow(id);
23771
+ }
23704
23772
  }
23705
23773
  return false;
23706
23774
  }
23707
23775
 
23776
+ // src/components/InfiniteTable/eventHandlers/onCellMouseDown.ts
23777
+ function onCellMouseDown(context, event) {
23778
+ if (event.detail === 2) {
23779
+ return;
23780
+ }
23781
+ updateCellSelectionOnCellMouseDown(context);
23782
+ }
23783
+ function updateCellSelectionOnCellMouseDown(_context) {
23784
+ }
23785
+
23708
23786
  // src/components/InfiniteTable/eventHandlers/keyboardSelection.ts
23709
23787
  var validKeys2 = {
23710
23788
  Enter: true,