@ai-table/grid 0.1.34 → 0.1.35

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, input, EventEmitter, inject, ElementRef, effect, Output, ChangeDetectionStrategy, Component, signal, computed, output, Input, ChangeDetectorRef, ViewChild, untracked, model, Renderer2, Pipe, booleanAttribute, Injectable, DestroyRef, NgZone, ViewContainerRef, viewChild, afterNextRender } from '@angular/core';
2
+ import { InjectionToken, input, EventEmitter, inject, ElementRef, effect, Output, ChangeDetectionStrategy, Component, signal, computed, output, Input, ChangeDetectorRef, ViewChild, model, untracked, Renderer2, Pipe, booleanAttribute, Injectable, DestroyRef, NgZone, ViewContainerRef, viewChild, afterNextRender } from '@angular/core';
3
3
  import Konva from 'konva';
4
4
  import { Shape } from 'konva/lib/Shape';
5
5
  import { Sprite } from 'konva/lib/shapes/Sprite';
@@ -4778,24 +4778,10 @@ class CoverCellBase {
4778
4778
  constructor() {
4779
4779
  this.config = input();
4780
4780
  this.onlyDisplayBorder = input(false);
4781
- this.height = computed(() => {
4782
- const { render } = this.config();
4783
- return render.rowHeight;
4784
- });
4785
4781
  this.isExpand = computed(() => {
4786
4782
  const { isExpand } = this.config();
4787
4783
  return isExpand;
4788
4784
  });
4789
- effect(() => {
4790
- const height = this.height();
4791
- if (this.isExpand()) {
4792
- untracked(() => {
4793
- const { render, aiTable } = this.config();
4794
- const { columnWidth } = render;
4795
- setExpandCellInfo(aiTable, { width: columnWidth, height });
4796
- });
4797
- }
4798
- });
4799
4785
  }
4800
4786
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: CoverCellBase, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
4801
4787
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.10", type: CoverCellBase, isStandalone: true, selector: "ai-table-cover-cell-base", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, onlyDisplayBorder: { classPropertyName: "onlyDisplayBorder", publicName: "onlyDisplayBorder", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
@@ -4807,7 +4793,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
4807
4793
  template: '',
4808
4794
  changeDetection: ChangeDetectionStrategy.OnPush
4809
4795
  }]
4810
- }], ctorParameters: () => [] });
4796
+ }] });
4811
4797
 
4812
4798
  class AITableCellLink extends CoverCellBase {
4813
4799
  constructor() {
@@ -8365,9 +8351,6 @@ class AITableScrollableGroup {
8365
8351
  this.rootGroup.getNode().moveTo(this.parentContainer().getNode());
8366
8352
  }
8367
8353
  }
8368
- stopBubble(e) {
8369
- e.event.cancelBubble = true;
8370
- }
8371
8354
  verticalScrollbarClick(e) {
8372
8355
  e.event.cancelBubble = true;
8373
8356
  const { contentHeight, height } = this.config();
@@ -8456,13 +8439,7 @@ class AITableScrollableGroup {
8456
8439
  }
8457
8440
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AITableScrollableGroup, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8458
8441
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.10", type: AITableScrollableGroup, isStandalone: true, selector: "ai-table-scrollable-group", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, contentTemplate: { classPropertyName: "contentTemplate", publicName: "contentTemplate", isSignal: true, isRequired: true, transformFunction: null }, parentContainer: { classPropertyName: "parentContainer", publicName: "parentContainer", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { scrollPosition: "scrollPosition" }, viewQueries: [{ propertyName: "verticalTrack", first: true, predicate: ["verticalTrack"], descendants: true }, { propertyName: "verticalThumb", first: true, predicate: ["verticalThumb"], descendants: true }, { propertyName: "horizontalTrack", first: true, predicate: ["horizontalTrack"], descendants: true }, { propertyName: "contentGroup", first: true, predicate: ["contentGroup"], descendants: true }, { propertyName: "rootGroup", first: true, predicate: ["rootGroup"], descendants: true }], ngImport: i0, template: `
8459
- <ko-group
8460
- #rootGroup
8461
- [config]="containerConfig()"
8462
- (koWheel)="stageWheel($event)"
8463
- (koMousedown)="stopBubble($event)"
8464
- (koMouseup)="stopBubble($event)"
8465
- >
8442
+ <ko-group #rootGroup [config]="containerConfig()" (koWheel)="stageWheel($event)">
8466
8443
  <ko-group>
8467
8444
  <ko-rect [config]="bgConfig()"></ko-rect>
8468
8445
  </ko-group>
@@ -8514,13 +8491,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
8514
8491
  args: [{
8515
8492
  selector: 'ai-table-scrollable-group',
8516
8493
  template: `
8517
- <ko-group
8518
- #rootGroup
8519
- [config]="containerConfig()"
8520
- (koWheel)="stageWheel($event)"
8521
- (koMousedown)="stopBubble($event)"
8522
- (koMouseup)="stopBubble($event)"
8523
- >
8494
+ <ko-group #rootGroup [config]="containerConfig()" (koWheel)="stageWheel($event)">
8524
8495
  <ko-group>
8525
8496
  <ko-rect [config]="bgConfig()"></ko-rect>
8526
8497
  </ko-group>
@@ -8608,7 +8579,9 @@ class AITableFillHandle {
8608
8579
  const rowOffset = coordinate.getRowOffset(rowIndex);
8609
8580
  const width = 6;
8610
8581
  const height = 6;
8611
- const cellHeight = aiTable.selection().expandCellInfo?.height ?? AI_TABLE_ROW_HEIGHT;
8582
+ const cellHeight = aiTable.selection().expandCellInfo?.height
8583
+ ? aiTable.selection().expandCellInfo.height + AI_TABLE_CELL_LINE_BORDER
8584
+ : AI_TABLE_ROW_HEIGHT;
8612
8585
  return {
8613
8586
  x: columnOffset + columnWidth - width / 2 + AI_TABLE_OFFSET,
8614
8587
  y: rowOffset + cellHeight - height + AI_TABLE_CELL_BORDER + AI_TABLE_OFFSET,
@@ -9998,8 +9971,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
9998
9971
  }] });
9999
9972
 
10000
9973
  class AITableCellText extends CoverCellBase {
9974
+ static { this.fieldType = AITableFieldType.text; }
10001
9975
  constructor() {
10002
- super(...arguments);
9976
+ super();
10003
9977
  this.expandBorderConfig = computed(() => {
10004
9978
  const { render, field, recordId, readonly, isExpand } = this.config();
10005
9979
  const { columnWidth } = render;
@@ -10123,9 +10097,18 @@ class AITableCellText extends CoverCellBase {
10123
10097
  }
10124
10098
  return;
10125
10099
  });
10100
+ effect(() => {
10101
+ const height = this.height();
10102
+ if (this.isExpand()) {
10103
+ untracked(() => {
10104
+ const { render, aiTable } = this.config();
10105
+ const { columnWidth } = render;
10106
+ setExpandCellInfo(aiTable, { width: columnWidth, height });
10107
+ });
10108
+ }
10109
+ });
10126
10110
  }
10127
- static { this.fieldType = AITableFieldType.text; }
10128
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AITableCellText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
10111
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AITableCellText, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
10129
10112
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.10", type: AITableCellText, isStandalone: true, selector: "ai-table-single-text", usesInheritance: true, ngImport: i0, template: `
10130
10113
  <ko-group>
10131
10114
  @if (isExpand()) {
@@ -10178,7 +10161,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
10178
10161
  imports: [AITableTextComponent, KoShape, KoContainer, AITableScrollableGroup],
10179
10162
  changeDetection: ChangeDetectionStrategy.OnPush
10180
10163
  }]
10181
- }] });
10164
+ }], ctorParameters: () => [] });
10182
10165
 
10183
10166
  // TODO: components下的cells组件考虑移出 components ,这些组件都属于
10184
10167
 
@@ -10917,7 +10900,7 @@ class AITableGridSelectionService {
10917
10900
  initialize(aiTable) {
10918
10901
  this.aiTable = aiTable;
10919
10902
  }
10920
- clearSelection() {
10903
+ clearSelection(options) {
10921
10904
  this.aiTable.selection.set({
10922
10905
  selectedRecords: new Set(),
10923
10906
  selectedFields: new Set(),
@@ -10926,7 +10909,7 @@ class AITableGridSelectionService {
10926
10909
  expandCell: null,
10927
10910
  editingCell: null,
10928
10911
  selectAllState: AITableSelectAllState.none,
10929
- expandCellInfo: null
10912
+ expandCellInfo: options?.retainExpandCellInfo ? this.aiTable.selection().expandCellInfo : null
10930
10913
  });
10931
10914
  }
10932
10915
  setActiveCell(activeCell) {
@@ -11024,6 +11007,11 @@ class AITableGridSelectionService {
11024
11007
  selectedCells.add(`${startRecordId}:${startFieldId}`);
11025
11008
  }
11026
11009
  else {
11010
+ // 数据的存储设计结构,决定了最后一条就是endCell
11011
+ const lastItem = Array.from(this.aiTable.selection().selectedCells).pop();
11012
+ if (endCell.join(':') === lastItem) {
11013
+ return;
11014
+ }
11027
11015
  const [endRecordId, endFieldId] = endCell;
11028
11016
  const startRowIndex = this.aiTable.context.visibleRowsIndexMap().get(startRecordId);
11029
11017
  const endRowIndex = this.aiTable.context.visibleRowsIndexMap().get(endRecordId);
@@ -11040,8 +11028,11 @@ class AITableGridSelectionService {
11040
11028
  }
11041
11029
  }
11042
11030
  this.clearSelection();
11043
- this.setActiveCell(activeCell || startCell);
11044
- this.aiTable.selection().selectedCells = selectedCells;
11031
+ this.aiTable.selection.set({
11032
+ ...this.aiTable.selection(),
11033
+ activeCell: activeCell || startCell,
11034
+ selectedCells: selectedCells
11035
+ });
11045
11036
  }
11046
11037
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AITableGridSelectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
11047
11038
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AITableGridSelectionService }); }
@@ -12611,7 +12602,7 @@ class AITableGrid extends AITableGridBase {
12611
12602
  if (expandRecordId !== recordId || expandFieldId !== fieldId) {
12612
12603
  const field = this.aiTable.fieldsMap()[fieldId];
12613
12604
  if (field.type === AITableFieldType.text) {
12614
- this.aiTableGridSelectionService.clearSelection();
12605
+ this.aiTableGridSelectionService.clearSelection({ retainExpandCellInfo: true });
12615
12606
  expandCell(this.aiTable, [recordId, fieldId]);
12616
12607
  }
12617
12608
  else {