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