@zeedhi/teknisa-components-common 1.93.0 → 1.93.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.
@@ -2295,12 +2295,12 @@ class TekGrid extends GridEditable {
2295
2295
  if (!this.toolbarSlotProps)
2296
2296
  this.toolbarSlot = this.gridBase.createToolbarProps();
2297
2297
  this.navigationKeyMapping.left = {
2298
- event: this.navigateLeft.bind(this),
2298
+ event: this.directionalLeft.bind(this),
2299
2299
  stop: true,
2300
2300
  active: true,
2301
2301
  };
2302
2302
  this.navigationKeyMapping.right = {
2303
- event: this.navigateRight.bind(this),
2303
+ event: this.directionalRight.bind(this),
2304
2304
  stop: true,
2305
2305
  active: true,
2306
2306
  };
@@ -2700,73 +2700,82 @@ class TekGrid extends GridEditable {
2700
2700
  navigateDown(params) {
2701
2701
  if (!this.isGrouped()) {
2702
2702
  super.navigateDown();
2703
+ return;
2703
2704
  }
2704
- else {
2705
- const { index } = params;
2706
- if (!this.groupedData.length || index === this.groupedData.length)
2707
- return;
2708
- const { uniqueKey, currentRow } = this.datasource;
2709
- const rowIndex = index !== undefined
2710
- ? index
2711
- : this.groupedData.findIndex((row) => {
2712
- if (currentRow.group) {
2713
- return row.group && row.groupValue === currentRow.groupValue;
2714
- }
2715
- return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
2716
- });
2717
- const newRow = this.groupedData[rowIndex + 1];
2718
- if (newRow && this.isItemVisible(newRow) && !newRow.groupFooter) {
2719
- this.datasource.currentRow = newRow;
2720
- }
2721
- else {
2722
- this.navigateDown({ index: rowIndex + 1 });
2723
- }
2705
+ if (this.cellSelection && this.viewNavigate) {
2706
+ this.viewNavigate('down');
2707
+ return;
2724
2708
  }
2709
+ const { index } = params;
2710
+ if (!this.groupedData.length || index === this.groupedData.length)
2711
+ return;
2712
+ const { uniqueKey, currentRow } = this.datasource;
2713
+ const rowIndex = index !== undefined
2714
+ ? index
2715
+ : this.groupedData.findIndex((row) => {
2716
+ if (currentRow.group) {
2717
+ return row.group && row.groupValue === currentRow.groupValue;
2718
+ }
2719
+ return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
2720
+ });
2721
+ const newRow = this.groupedData[rowIndex + 1];
2722
+ if (!newRow || !this.isItemVisible(newRow) || newRow.groupFooter) {
2723
+ this.navigateDown({ index: rowIndex + 1 });
2724
+ return;
2725
+ }
2726
+ this.datasource.currentRow = newRow;
2725
2727
  }
2726
2728
  navigateUp(params) {
2727
2729
  if (!this.isGrouped()) {
2728
2730
  super.navigateUp();
2731
+ return;
2729
2732
  }
2730
- else {
2731
- const { index } = params;
2732
- if (!this.groupedData.length || index === -1)
2733
- return;
2734
- const { uniqueKey, currentRow } = this.datasource;
2735
- let rowIndex;
2736
- rowIndex = index !== undefined
2737
- ? index
2738
- : this.groupedData.findIndex((row) => {
2739
- if (currentRow.group) {
2740
- return row.group && row.groupValue === currentRow.groupValue;
2741
- }
2742
- return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
2743
- });
2744
- if (rowIndex === -1)
2745
- rowIndex = this.groupedData.length;
2746
- const newRow = this.groupedData[rowIndex - 1];
2747
- if (newRow && this.isItemVisible(newRow) && !newRow.groupFooter) {
2748
- this.datasource.currentRow = newRow;
2749
- }
2750
- else {
2751
- this.navigateUp({ index: rowIndex - 1 });
2752
- }
2733
+ if (this.cellSelection && this.viewNavigate) {
2734
+ this.viewNavigate('up');
2735
+ return;
2736
+ }
2737
+ const { index } = params;
2738
+ if (!this.groupedData.length || index === -1)
2739
+ return;
2740
+ const { uniqueKey, currentRow } = this.datasource;
2741
+ let rowIndex;
2742
+ rowIndex = index !== undefined
2743
+ ? index
2744
+ : this.groupedData.findIndex((row) => {
2745
+ if (currentRow.group) {
2746
+ return row.group && row.groupValue === currentRow.groupValue;
2747
+ }
2748
+ return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
2749
+ });
2750
+ if (rowIndex === -1)
2751
+ rowIndex = this.groupedData.length;
2752
+ const newRow = this.groupedData[rowIndex - 1];
2753
+ if (!newRow || !this.isItemVisible(newRow) || newRow.groupFooter) {
2754
+ this.navigateUp({ index: rowIndex - 1 });
2755
+ return;
2753
2756
  }
2757
+ this.datasource.currentRow = newRow;
2754
2758
  }
2755
- navigateLeft() {
2759
+ directionalLeft() {
2756
2760
  var _a;
2757
2761
  const { currentRow } = this.datasource;
2758
2762
  if (currentRow.group && currentRow.groupOpened) {
2759
2763
  currentRow.groupOpened = false;
2764
+ return;
2760
2765
  }
2761
- else if ((_a = currentRow.groupHeaders) === null || _a === void 0 ? void 0 : _a.length) {
2766
+ if (!this.cellSelection && ((_a = currentRow.groupHeaders) === null || _a === void 0 ? void 0 : _a.length)) {
2762
2767
  this.datasource.currentRow = currentRow.groupHeaders[currentRow.groupHeaders.length - 1];
2768
+ return;
2763
2769
  }
2770
+ this.navigateLeft();
2764
2771
  }
2765
- navigateRight() {
2772
+ directionalRight() {
2766
2773
  const { currentRow } = this.datasource;
2767
2774
  if (currentRow.group && !currentRow.groupOpened) {
2768
2775
  currentRow.groupOpened = true;
2776
+ return;
2769
2777
  }
2778
+ this.navigateRight();
2770
2779
  }
2771
2780
  /**
2772
2781
  * Dispatches row click event
@@ -2299,12 +2299,12 @@
2299
2299
  if (!this.toolbarSlotProps)
2300
2300
  this.toolbarSlot = this.gridBase.createToolbarProps();
2301
2301
  this.navigationKeyMapping.left = {
2302
- event: this.navigateLeft.bind(this),
2302
+ event: this.directionalLeft.bind(this),
2303
2303
  stop: true,
2304
2304
  active: true,
2305
2305
  };
2306
2306
  this.navigationKeyMapping.right = {
2307
- event: this.navigateRight.bind(this),
2307
+ event: this.directionalRight.bind(this),
2308
2308
  stop: true,
2309
2309
  active: true,
2310
2310
  };
@@ -2704,73 +2704,82 @@
2704
2704
  navigateDown(params) {
2705
2705
  if (!this.isGrouped()) {
2706
2706
  super.navigateDown();
2707
+ return;
2707
2708
  }
2708
- else {
2709
- const { index } = params;
2710
- if (!this.groupedData.length || index === this.groupedData.length)
2711
- return;
2712
- const { uniqueKey, currentRow } = this.datasource;
2713
- const rowIndex = index !== undefined
2714
- ? index
2715
- : this.groupedData.findIndex((row) => {
2716
- if (currentRow.group) {
2717
- return row.group && row.groupValue === currentRow.groupValue;
2718
- }
2719
- return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
2720
- });
2721
- const newRow = this.groupedData[rowIndex + 1];
2722
- if (newRow && this.isItemVisible(newRow) && !newRow.groupFooter) {
2723
- this.datasource.currentRow = newRow;
2724
- }
2725
- else {
2726
- this.navigateDown({ index: rowIndex + 1 });
2727
- }
2709
+ if (this.cellSelection && this.viewNavigate) {
2710
+ this.viewNavigate('down');
2711
+ return;
2728
2712
  }
2713
+ const { index } = params;
2714
+ if (!this.groupedData.length || index === this.groupedData.length)
2715
+ return;
2716
+ const { uniqueKey, currentRow } = this.datasource;
2717
+ const rowIndex = index !== undefined
2718
+ ? index
2719
+ : this.groupedData.findIndex((row) => {
2720
+ if (currentRow.group) {
2721
+ return row.group && row.groupValue === currentRow.groupValue;
2722
+ }
2723
+ return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
2724
+ });
2725
+ const newRow = this.groupedData[rowIndex + 1];
2726
+ if (!newRow || !this.isItemVisible(newRow) || newRow.groupFooter) {
2727
+ this.navigateDown({ index: rowIndex + 1 });
2728
+ return;
2729
+ }
2730
+ this.datasource.currentRow = newRow;
2729
2731
  }
2730
2732
  navigateUp(params) {
2731
2733
  if (!this.isGrouped()) {
2732
2734
  super.navigateUp();
2735
+ return;
2733
2736
  }
2734
- else {
2735
- const { index } = params;
2736
- if (!this.groupedData.length || index === -1)
2737
- return;
2738
- const { uniqueKey, currentRow } = this.datasource;
2739
- let rowIndex;
2740
- rowIndex = index !== undefined
2741
- ? index
2742
- : this.groupedData.findIndex((row) => {
2743
- if (currentRow.group) {
2744
- return row.group && row.groupValue === currentRow.groupValue;
2745
- }
2746
- return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
2747
- });
2748
- if (rowIndex === -1)
2749
- rowIndex = this.groupedData.length;
2750
- const newRow = this.groupedData[rowIndex - 1];
2751
- if (newRow && this.isItemVisible(newRow) && !newRow.groupFooter) {
2752
- this.datasource.currentRow = newRow;
2753
- }
2754
- else {
2755
- this.navigateUp({ index: rowIndex - 1 });
2756
- }
2737
+ if (this.cellSelection && this.viewNavigate) {
2738
+ this.viewNavigate('up');
2739
+ return;
2740
+ }
2741
+ const { index } = params;
2742
+ if (!this.groupedData.length || index === -1)
2743
+ return;
2744
+ const { uniqueKey, currentRow } = this.datasource;
2745
+ let rowIndex;
2746
+ rowIndex = index !== undefined
2747
+ ? index
2748
+ : this.groupedData.findIndex((row) => {
2749
+ if (currentRow.group) {
2750
+ return row.group && row.groupValue === currentRow.groupValue;
2751
+ }
2752
+ return row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey];
2753
+ });
2754
+ if (rowIndex === -1)
2755
+ rowIndex = this.groupedData.length;
2756
+ const newRow = this.groupedData[rowIndex - 1];
2757
+ if (!newRow || !this.isItemVisible(newRow) || newRow.groupFooter) {
2758
+ this.navigateUp({ index: rowIndex - 1 });
2759
+ return;
2757
2760
  }
2761
+ this.datasource.currentRow = newRow;
2758
2762
  }
2759
- navigateLeft() {
2763
+ directionalLeft() {
2760
2764
  var _a;
2761
2765
  const { currentRow } = this.datasource;
2762
2766
  if (currentRow.group && currentRow.groupOpened) {
2763
2767
  currentRow.groupOpened = false;
2768
+ return;
2764
2769
  }
2765
- else if ((_a = currentRow.groupHeaders) === null || _a === void 0 ? void 0 : _a.length) {
2770
+ if (!this.cellSelection && ((_a = currentRow.groupHeaders) === null || _a === void 0 ? void 0 : _a.length)) {
2766
2771
  this.datasource.currentRow = currentRow.groupHeaders[currentRow.groupHeaders.length - 1];
2772
+ return;
2767
2773
  }
2774
+ this.navigateLeft();
2768
2775
  }
2769
- navigateRight() {
2776
+ directionalRight() {
2770
2777
  const { currentRow } = this.datasource;
2771
2778
  if (currentRow.group && !currentRow.groupOpened) {
2772
2779
  currentRow.groupOpened = true;
2780
+ return;
2773
2781
  }
2782
+ this.navigateRight();
2774
2783
  }
2775
2784
  /**
2776
2785
  * Dispatches row click event
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/teknisa-components-common",
3
- "version": "1.93.0",
3
+ "version": "1.93.1",
4
4
  "description": "Teknisa Components Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -32,5 +32,5 @@
32
32
  "peerDependencies": {
33
33
  "@zeedhi/core": "*"
34
34
  },
35
- "gitHead": "f994901c45e87971a66097fa7c70542402eeb7b1"
35
+ "gitHead": "20420a9274a19f72fbea80d245bf6a517b02a96b"
36
36
  }
@@ -938,6 +938,37 @@ describe('TekGrid', () => {
938
938
  spySetFocus.mockReset();
939
939
  spyMetadata.mockReset();
940
940
  });
941
+
942
+ it('when using cellSelection, should use viewNavigate', async () => {
943
+ const instance = new TekGrid({
944
+ name: 'grid_navigation_1',
945
+ component: 'TekGrid',
946
+ cellSelection: true,
947
+ columns: [
948
+ {
949
+ name: 'name',
950
+ grouped: true,
951
+ },
952
+ ],
953
+ });
954
+
955
+ const elem = document.createElement('DIV');
956
+ (KeyMap as any).isElementActive = () => true;
957
+ instance.onCreated();
958
+ instance.onMounted(elem);
959
+
960
+ await flushPromises();
961
+ const spy = jest.fn();
962
+ instance.setViewNavigate(spy);
963
+
964
+ instance.navigateUp();
965
+
966
+ expect(spy).toHaveBeenLastCalledWith('up');
967
+
968
+ instance.navigateDown();
969
+
970
+ expect(spy).toHaveBeenLastCalledWith('down');
971
+ });
941
972
  });
942
973
 
943
974
  describe('reloadClick()', () => {
@@ -133,10 +133,10 @@ export declare class TekGrid extends GridEditable implements ITekGrid {
133
133
  }[];
134
134
  setSearch(search: string): Promise<any>;
135
135
  isGrouped(): number | false;
136
- protected navigateDown(params?: any): void;
137
- protected navigateUp(params?: any): void;
138
- protected navigateLeft(): void;
139
- protected navigateRight(): void;
136
+ navigateDown(params?: any): void;
137
+ navigateUp(params?: any): void;
138
+ directionalLeft(): void;
139
+ directionalRight(): void;
140
140
  /**
141
141
  * Dispatches row click event
142
142
  * @param row Grid row