@ai-table/grid 0.2.4 → 0.2.5

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.
@@ -37,6 +37,7 @@ export declare class AITableDragComponent implements OnInit, OnDestroy {
37
37
  private movingColumnWidth;
38
38
  private movingRecord;
39
39
  private setMovingRecordDragData;
40
+ private setMovingFieldDragData;
40
41
  private handleDragEnd;
41
42
  private clearDragState;
42
43
  private calculateDragWidth;
@@ -1 +1 @@
1
- {"version":3,"file":"drag.component.d.ts","sourceRoot":"","sources":["../../../../packages/grid/src/components/drag/drag.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,UAAU,EAIV,SAAS,EACT,MAAM,EAIT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAiB,WAAW,EAAY,MAAM,iBAAiB,CAAC;;AAiBvE,qBAQa,oBAAqB,YAAW,MAAM,EAAE,SAAS;IAC1D,aAAa,2EAAgD;IAE7D,WAAW,2EAAgD;IAE3D,OAAO,wDAAyB;IAEhC,OAAO,CAAC,uBAAuB,CAAmC;IAElE,OAAO,CAAC,OAAO,CAAqB;IAEpC,OAAO,CAAC,uBAAuB,CAA0C;IAEzE,UAAU,EAAE,UAAU,CAAC,WAAW,CAAC,CAAmC;IAEtE,OAAO,CAAC,IAAI,CAAe;IAE3B,OAAO,CAAC,aAAa,CAAe;IAEpC,OAAO,CAAC,WAAW,CAA4B;IAE/C,OAAO,CAAC,sBAAsB,CAA4C;IAE1E,OAAO,CAAC,kBAAkB,CAAyC;IAEnE,OAAO,CAAC,WAAW,CAAiC;IAEpD,OAAO,CAAC,KAAK,CAAiB;IAE9B,OAAO,CAAC,gBAAgB,CAAa;IAErC,OAAO,CAAC,iBAAiB,CAAkB;IAE3C,OAAO,CAAC,cAAc,CAAa;IAEnC,OAAO,CAAC,eAAe,CAAa;IAEpC,OAAO,CAAC,oBAAoB,CAAC,CAAc;IAE3C,OAAO,CAAC,sBAAsB,CAAa;IAE3C,OAAO,CA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AW,CAA4B;IAE/C,OAAO,CAAC,sBAAsB,CAA4C;IAE1E,OAAO,CAAC,kBAAkB,CAAyC;IAEnE,OAAO,CAAC,WAAW,CAAiC;IAEpD,OAAO,CAAC,KAAK,CAAiB;IAE9B,OAAO,CAAC,gBAAgB,CAAa;IAErC,OAAO,CAAC,iBAAiB,CAAkB;IAE3C,OAAO,CAAC,cAAc,CAAa;IAEnC,OAAO,CAAC,eAAe,CAAa;IAEpC,OAAO,CAAC,oBAAoB,CAAC,CAAc;IAE3C,OAAO,CAAC,sBAAsB,CAAa;IAE3C,OAAO,CAAC,kBAAkB,CAAC,CAAc;IAEzC,OAAO,CAAC,oBAAoB,CAAa;IAEzC,OAAO,CAAC,iBAAiB,CAAC,CAAa;IACvC,OAAO,CAAC,iBAAiB,CAAC,CAAa;IACvC,OAAO,CAAC,eAAe,CAAC,CAAa;;IAMrC,QAAQ;IAKR,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,mBAAmB;IA8C3B,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,UAAU;IA8BlB,OAAO,CAAC,YAAY;IAqIpB,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,YAAY;IAwFpB,OAAO,CAAC,uBAAuB;IAoB/B,OAAO,CAAC,sBAAsB;IAiB9B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,kBAAkB;IAI1B,WAAW;yCAtfF,oBAAoB;2CAApB,oBAAoB;CAigBhC"}
@@ -1589,7 +1589,7 @@ const AITableQueries = {
1589
1589
  if (!path) {
1590
1590
  throw new Error(`path does not exist as path [${path}]`);
1591
1591
  }
1592
- return aiTable.gridData().fields.find((item) => item._id === path[0]);
1592
+ return aiTable.fieldsMap()[path[0]];
1593
1593
  },
1594
1594
  getRecord(aiTable, path) {
1595
1595
  if (!aiTable) {
@@ -2105,7 +2105,7 @@ function expandCell(aiTable, cellPath) {
2105
2105
  setExpandCellInfo(aiTable, { path: cellPath });
2106
2106
  }
2107
2107
  function closeExpendCell(aiTable) {
2108
- setExpandCellInfo(aiTable, { path: null, width: undefined, height: undefined });
2108
+ setExpandCellInfo(aiTable, { path: null });
2109
2109
  }
2110
2110
  function setSelection(aiTable, selection) {
2111
2111
  aiTable.selection.set({
@@ -2277,7 +2277,7 @@ function getPlaceHolderCellsConfigs(options) {
2277
2277
  if (isGroupAndFirstColumn) {
2278
2278
  offset += AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE;
2279
2279
  }
2280
- const height = rowHeight - AI_TABLE_OFFSET * 4;
2280
+ const height = rowHeight;
2281
2281
  configs.unshift({
2282
2282
  key: `placeholder-cell-${fieldId}-${recordId}`,
2283
2283
  name: generateTargetName({
@@ -2287,7 +2287,7 @@ function getPlaceHolderCellsConfigs(options) {
2287
2287
  }),
2288
2288
  x: x + offset,
2289
2289
  y,
2290
- width: width - AI_TABLE_OFFSET * 4,
2290
+ width,
2291
2291
  height,
2292
2292
  fill: Colors.transparent,
2293
2293
  strokeEnabled: false,
@@ -9266,15 +9266,6 @@ class AITableFieldStat {
9266
9266
  config.strokeWidth = AI_TABLE_CELL_LINE_BORDER;
9267
9267
  }
9268
9268
  }
9269
- if (isGroupStat && this.isFirstColumn()) {
9270
- const groupStatContainerWidthMap = this.groupStatContainerWidthMap();
9271
- const groupStatCellKey = `${groupRow.groupId}:${field._id}`;
9272
- const originGroupStatContainerWidth = groupStatContainerWidthMap.get(groupStatCellKey);
9273
- const width = this.renderTexts() ? config.width : 0;
9274
- if (!originGroupStatContainerWidth || originGroupStatContainerWidth !== width) {
9275
- groupStatContainerWidthMap.set(groupStatCellKey, width);
9276
- }
9277
- }
9278
9269
  return config;
9279
9270
  });
9280
9271
  this.field = computed(() => {
@@ -9505,6 +9496,32 @@ class AITableFieldStat {
9505
9496
  listening: false
9506
9497
  };
9507
9498
  });
9499
+ effect(() => {
9500
+ const isGroupStat = this.isGroupStat();
9501
+ const bgConfigWidth = this.bgConfig().width;
9502
+ const renderTexts = this.renderTexts();
9503
+ untracked(() => {
9504
+ if (isGroupStat && this.isFirstColumn()) {
9505
+ const config = this.config();
9506
+ const { aiTable, groupRow, field } = config;
9507
+ const groupStatContainerWidthMap = this.groupStatContainerWidthMap();
9508
+ const groupStatCellKey = `${groupRow.groupId}:${groupRow.fieldId}`;
9509
+ const originGroupStatContainerWidth = groupStatContainerWidthMap.get(groupStatCellKey);
9510
+ // 计算新的宽度
9511
+ const groupStatContainerWidth = renderTexts ? bgConfigWidth : 0;
9512
+ // 只有当值发生变化时才更新
9513
+ if (originGroupStatContainerWidth !== groupStatContainerWidth) {
9514
+ if (groupStatContainerWidth > 0) {
9515
+ groupStatContainerWidthMap.set(groupStatCellKey, groupStatContainerWidth);
9516
+ }
9517
+ else {
9518
+ groupStatContainerWidthMap.delete(groupStatCellKey);
9519
+ }
9520
+ aiTable.context?.groupStatContainerWidthMap.set(groupStatContainerWidthMap);
9521
+ }
9522
+ }
9523
+ });
9524
+ });
9508
9525
  }
9509
9526
  onHoverChange(isHover) {
9510
9527
  this.isHover.set(isHover);
@@ -9608,7 +9625,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
9608
9625
  imports: [KoContainer, AITableTextComponent, AITableIcon, AITableBackground],
9609
9626
  changeDetection: ChangeDetectionStrategy.OnPush
9610
9627
  }]
9611
- }] });
9628
+ }], ctorParameters: () => [] });
9612
9629
 
9613
9630
  class AITableGroups {
9614
9631
  constructor() {
@@ -12752,12 +12769,7 @@ class AITableDragComponent {
12752
12769
  this.setAuxiliaryLineStyles({
12753
12770
  left: `${nextColumnStartX - scrollPosition.x}px`
12754
12771
  });
12755
- this.draggedData = {
12756
- type: DragType.field,
12757
- targetIndex: targetColumnIndex + 1,
12758
- fieldIds: drag.sourceIds,
12759
- fieldsIndex: Array.from(drag.sourceIds).map((id) => visibleColumnIndexMap.get(id) || 0)
12760
- };
12772
+ this.setMovingFieldDragData(DragType.field, drag.sourceIds, targetColumnIndex + 1);
12761
12773
  return;
12762
12774
  }
12763
12775
  }
@@ -12767,16 +12779,7 @@ class AITableDragComponent {
12767
12779
  top: 0,
12768
12780
  left: `${lineLeft}px`
12769
12781
  });
12770
- // 向右移动目标在目标列的前一列
12771
- if (targetColumnIndex > sourceColumnIndex) {
12772
- targetColumnIndex -= 1;
12773
- }
12774
- this.draggedData = {
12775
- type: DragType.field,
12776
- targetIndex: targetColumnIndex,
12777
- fieldIds: drag.sourceIds,
12778
- fieldsIndex: Array.from(drag.sourceIds).map((id) => visibleColumnIndexMap.get(id) || 0)
12779
- };
12782
+ this.setMovingFieldDragData(DragType.field, drag.sourceIds, targetColumnIndex);
12780
12783
  }
12781
12784
  else {
12782
12785
  this.resetAuxiliaryLine();
@@ -12956,6 +12959,24 @@ class AITableDragComponent {
12956
12959
  }
12957
12960
  }
12958
12961
  }
12962
+ setMovingFieldDragData(type, sourceIds, targetIndex) {
12963
+ const aiTable = this.aiTableGridEventService.aiTable;
12964
+ const fields = aiTable.gridData().fields;
12965
+ this.draggedData = {
12966
+ type,
12967
+ fieldIds: sourceIds,
12968
+ targetIndex
12969
+ };
12970
+ if (targetIndex === 0) {
12971
+ this.draggedData.beforeFieldId = fields[0]._id;
12972
+ }
12973
+ else if (targetIndex >= fields.length) {
12974
+ this.draggedData.afterFieldId = fields[fields.length - 1]._id;
12975
+ }
12976
+ else {
12977
+ this.draggedData.afterFieldId = fields[targetIndex - 1]._id;
12978
+ }
12979
+ }
12959
12980
  handleDragEnd() {
12960
12981
  if (this.draggedData) {
12961
12982
  this.dragEnd.emit({ ...this.draggedData });
@@ -13978,13 +13999,12 @@ class AITableGrid extends AITableGridBase {
13978
13999
  dragEnd(data) {
13979
14000
  switch (data.type) {
13980
14001
  case DragType.field:
13981
- if (data.fieldsIndex && isNumber(data.targetIndex)) {
13982
- for (let i = 0; i < data.fieldsIndex.length; i++) {
13983
- this.aiMoveField.emit({
13984
- path: [data.fieldsIndex[i]],
13985
- newPath: [data.targetIndex + i]
13986
- });
13987
- }
14002
+ if (data.fieldIds && (data.beforeFieldId || data.afterFieldId)) {
14003
+ this.aiMoveField.emit({
14004
+ fieldIds: Array.from(data.fieldIds),
14005
+ beforeFieldId: data.beforeFieldId,
14006
+ afterFieldId: data.afterFieldId
14007
+ });
13988
14008
  }
13989
14009
  break;
13990
14010
  case DragType.columnWidth: