@ai-table/grid 0.1.45 → 0.1.46

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.
@@ -113,7 +113,7 @@ export declare class Coordinate {
113
113
  * 如果可以完整渲染,则返回 { isCanFullRender: true, offsetY: 0 }
114
114
  * 如果不能完整渲染,则返回 { isCanFullRender: false, offsetY: 需要偏移的 y 值 }
115
115
  */
116
- getAddRowButtonIsFullRenderInfo(aiTable: AITable): {
116
+ getAddRowButtonIsFullRenderInfo(aiTable: AITable, addRowIndex: number): {
117
117
  isCanFullRender: boolean;
118
118
  offsetY: number;
119
119
  };
@@ -1 +1 @@
1
- {"version":3,"file":"coordinate.d.ts","sourceRoot":"","sources":["../../../packages/grid/src/core/coordinate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAO/C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;GAEG;AACH,qBAAa,UAAU;IACnB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,cAAc,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IAExB,iBAAiB,EAAE,cAAc,CAAM;IAEvC,oBAAoB,EAAE,cAAc,CAAM;IAE1C,WAAW,EAAE,MAAM,CAAC;IAEpB,cAAc,EAAE,MAAM,CAAC;IAEvB,YAAY,SAAM;IAElB,eAAe,SAAM;IACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAM;IACzD,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAM;IAC5D,iBAAiB,EAA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,则返回 { isCanFullRender: true, offsetY: 0 }
1351
1351
  * 如果不能完整渲染,则返回 { isCanFullRender: false, offsetY: 需要偏移的 y 值 }
1352
1352
  */
1353
- getAddRowButtonIsFullRenderInfo(aiTable) {
1353
+ getAddRowButtonIsFullRenderInfo(aiTable, addRowIndex) {
1354
1354
  let offsetY = 0;
1355
- const gridData = aiTable.gridData();
1356
- const lastRowIndex = gridData.records.length - 1;
1357
- const { size: height, offset: y } = this.getCellMetaData(lastRowIndex, AITableRowColumnType.row);
1355
+ const { size: height, offset: y } = this.getCellMetaData(addRowIndex, AITableRowColumnType.row);
1358
1356
  const { scrollTop } = aiTable.context.scrollState();
1359
- const addButtonMaxY = y + height + AI_TABLE_ROW_HEIGHT;
1357
+ const addButtonMaxY = y + height;
1360
1358
  const containerMaxY = aiTable.context.containerRect().height + scrollTop - AI_TABLE_FIELD_STAT_CONTAINER_HEIGHT - AI_TABLE_CELL_LINE_BORDER * 4;
1361
1359
  if (addButtonMaxY > containerMaxY) {
1362
1360
  offsetY = addButtonMaxY - containerMaxY;
@@ -2819,11 +2817,15 @@ function toDateFieldValue(plainText, targetField, originData) {
2819
2817
  const value = texts && texts.length ? texts[0].trim() : plainText.trim();
2820
2818
  return transformDateValue(value);
2821
2819
  }
2820
+ function getTimeDay(value) {
2821
+ return new TinyDate(fromUnixTime(value)).startOfDay().getUnixTime();
2822
+ }
2822
2823
  function cellValueToSortValue$4(cellValue) {
2823
2824
  if (isUndefinedOrNull(cellValue) || !isDateValid(cellValue)) {
2824
2825
  return 0;
2825
2826
  }
2826
- return cellValue?.timestamp ?? 0;
2827
+ const value = cellValue?.timestamp ?? 0;
2828
+ return value > 0 ? getTimeDay(value) : 0;
2827
2829
  }
2828
2830
  function transformDateValue(text) {
2829
2831
  const date = isDateAndReturnDate(text);
@@ -3755,6 +3757,7 @@ const writeToAITable = async (aiTable, actions) => {
3755
3757
  const { value, newField } = getPasteValue(plainText, aiTableContent, recordIndex, fieldIndex, targetField, references);
3756
3758
  if (newField) {
3757
3759
  actions.setField(newField);
3760
+ visibleFields[targetColIndex] = newField;
3758
3761
  }
3759
3762
  if (value !== null) {
3760
3763
  try {
@@ -6175,8 +6178,8 @@ class CellDrawer extends Drawer {
6175
6178
  }
6176
6179
  }
6177
6180
  // 单元格渲染
6178
- renderCell(render, ctx, columnWidth) {
6179
- const { field, cellValue, aiTable } = render;
6181
+ renderCell(render, ctx) {
6182
+ const { field, cellValue, aiTable, columnWidth } = render;
6180
6183
  const fieldType = field.type;
6181
6184
  const fieldMethod = FieldModelMap[fieldType];
6182
6185
  if (!fieldMethod.isValid(cellValue)) {
@@ -7025,7 +7028,7 @@ class GroupLayout extends Layout {
7025
7028
  x: render.x + iconContainerWidth,
7026
7029
  columnWidth: render.columnWidth - iconContainerWidth,
7027
7030
  isGroupFirstRender: true
7028
- }, this.ctx, columnWidth);
7031
+ }, this.ctx);
7029
7032
  }
7030
7033
  else {
7031
7034
  const emptyGroupString = getI18nTextByKey(aiTable, AITableGridI18nKey.emptyGroup);
@@ -7209,11 +7212,11 @@ const createCells = (config) => {
7209
7212
  ctx.save();
7210
7213
  ctx.rect(realX, realY, width, rowHeight);
7211
7214
  ctx.clip();
7212
- cellDrawer.renderCell(render, ctx, columnWidth);
7215
+ cellDrawer.renderCell(render, ctx);
7213
7216
  ctx.restore();
7214
7217
  }
7215
7218
  else {
7216
- cellDrawer.renderCell(render, ctx, columnWidth);
7219
+ cellDrawer.renderCell(render, ctx);
7217
7220
  }
7218
7221
  break;
7219
7222
  }
@@ -9809,6 +9812,7 @@ class AITableCoverCellEntry {
9809
9812
  isActive: isSelectedField(field._id, aiTable),
9810
9813
  x: renderX,
9811
9814
  y: renderY,
9815
+ groupOffset: columnWidth - width,
9812
9816
  columnWidth: width,
9813
9817
  rowHeight,
9814
9818
  cellValue,
@@ -10269,14 +10273,14 @@ class AITableCellRate extends CoverCellBase {
10269
10273
  this.whiteBgConfig = computed(() => {
10270
10274
  const { aiTable, render, field, recordId, coordinate } = this.config();
10271
10275
  const pointPosition = aiTable.context.pointPosition();
10272
- const { x, y } = render;
10276
+ const { x, y, groupOffset = 0 } = render;
10273
10277
  const { columnIndex } = pointPosition;
10274
10278
  const hasSelectedArea = aiTable.selection().selectedCells.size > 0 ||
10275
10279
  aiTable.selection().selectedRecords.size > 0 ||
10276
10280
  aiTable.selection().selectedFields.size > 0;
10277
10281
  const bgColor = hasSelectedArea ? null : Colors.white;
10278
10282
  return {
10279
- x: x - AI_TABLE_CELL_PADDING + AI_TABLE_CELL_BORDER,
10283
+ x: x - groupOffset - AI_TABLE_CELL_PADDING + AI_TABLE_CELL_BORDER,
10280
10284
  y: y + AI_TABLE_CELL_BORDER + AI_TABLE_OFFSET,
10281
10285
  width: coordinate.getColumnWidth(columnIndex) - (AI_TABLE_CELL_BORDER + AI_TABLE_OFFSET) * 2,
10282
10286
  height: AI_TABLE_ROW_BLANK_HEIGHT - (AI_TABLE_CELL_BORDER + AI_TABLE_OFFSET),
@@ -10292,7 +10296,7 @@ class AITableCellRate extends CoverCellBase {
10292
10296
  });
10293
10297
  this.starConfigs = computed(() => {
10294
10298
  const { render, field, recordId, readonly, aiTable, coordinate } = this.config();
10295
- const { x, transformValue } = render;
10299
+ const { x, columnWidth, transformValue } = render;
10296
10300
  const max = AI_TABLE_RATE_MAX;
10297
10301
  const starY = (AI_TABLE_ROW_BLANK_HEIGHT - AI_TABLE_CELL_EMOJI_SIZE) / 2 + AI_TABLE_OFFSET;
10298
10302
  const pointPosition = aiTable.context.pointPosition();
@@ -10308,7 +10312,7 @@ class AITableCellRate extends CoverCellBase {
10308
10312
  this.pointerX() <= lastStarRightX &&
10309
10313
  this.pointerY() >= startTopY &&
10310
10314
  this.pointerY() <= startBottomY;
10311
- const renderWidth = coordinate.getColumnWidth(columnIndex) - AI_TABLE_CELL_PADDING;
10315
+ const renderWidth = columnWidth - AI_TABLE_CELL_PADDING;
10312
10316
  const starWidth = AI_TABLE_CELL_EMOJI_SIZE + AI_TABLE_CELL_EMOJI_PADDING;
10313
10317
  const maxStar = Math.min(max, Math.floor(renderWidth / starWidth));
10314
10318
  return [...Array(maxStar).keys()].map((item, index) => {
@@ -10355,7 +10359,9 @@ class AITableCellRate extends CoverCellBase {
10355
10359
  if (!pos)
10356
10360
  return;
10357
10361
  const { x, y } = pos;
10358
- this.pointerX.set(x);
10362
+ const { render } = this.config();
10363
+ const { groupOffset = 0 } = render;
10364
+ this.pointerX.set(x - groupOffset);
10359
10365
  this.pointerY.set(y);
10360
10366
  }
10361
10367
  koClick(e, index) {
@@ -10438,14 +10444,14 @@ class AITableCellProgress extends CoverCellBase {
10438
10444
  this.whiteBgConfig = computed(() => {
10439
10445
  const { aiTable, render, field, recordId, coordinate } = this.config();
10440
10446
  const pointPosition = aiTable.context.pointPosition();
10441
- const { x, y } = render;
10447
+ const { x, y, groupOffset = 0 } = render;
10442
10448
  const { columnIndex } = pointPosition;
10443
10449
  const hasSelectedArea = aiTable.selection().selectedCells.size > 0 ||
10444
10450
  aiTable.selection().selectedRecords.size > 0 ||
10445
10451
  aiTable.selection().selectedFields.size > 0;
10446
10452
  const bgColor = hasSelectedArea ? null : Colors.white;
10447
10453
  return {
10448
- x: x - AI_TABLE_CELL_PADDING + AI_TABLE_CELL_BORDER / 2,
10454
+ x: x - groupOffset - AI_TABLE_CELL_PADDING + AI_TABLE_CELL_BORDER / 2,
10449
10455
  y: y + AI_TABLE_CELL_BORDER + AI_TABLE_OFFSET,
10450
10456
  width: coordinate.getColumnWidth(columnIndex) - (AI_TABLE_CELL_BORDER + AI_TABLE_OFFSET) * 2 + AI_TABLE_CELL_BORDER / 2,
10451
10457
  height: AI_TABLE_ROW_BLANK_HEIGHT - (AI_TABLE_CELL_BORDER + AI_TABLE_OFFSET),
@@ -10573,7 +10579,7 @@ class AITableCellProgress extends CoverCellBase {
10573
10579
  return;
10574
10580
  }
10575
10581
  const { render, aiTable, coordinate } = this.config();
10576
- const { x } = render;
10582
+ const { x, groupOffset = 0 } = render;
10577
10583
  const { scrollLeft } = aiTable.context.scrollState();
10578
10584
  const pointPosition = aiTable.context.pointPosition();
10579
10585
  const { columnIndex } = pointPosition;
@@ -10584,10 +10590,10 @@ class AITableCellProgress extends CoverCellBase {
10584
10590
  const point = stage.getPointerPosition();
10585
10591
  if (!point)
10586
10592
  return;
10587
- const dragX = point.x - columnLeftX - x;
10593
+ const dragX = point.x - columnLeftX - x - groupOffset;
10588
10594
  const minX = x;
10589
10595
  const maxX = x + this.railWidth();
10590
- let dragPointerX = point.x - columnLeftX;
10596
+ let dragPointerX = point.x - columnLeftX - groupOffset;
10591
10597
  if (dragPointerX < minX) {
10592
10598
  dragPointerX = minX;
10593
10599
  }
@@ -10608,7 +10614,7 @@ class AITableCellProgress extends CoverCellBase {
10608
10614
  }
10609
10615
  updateProgressValue(e) {
10610
10616
  const { render, aiTable, coordinate, actions, field, recordId } = this.config();
10611
- const { x } = render;
10617
+ const { x, groupOffset = 0 } = render;
10612
10618
  const { scrollLeft } = aiTable.context.scrollState();
10613
10619
  const pointPosition = aiTable.context.pointPosition();
10614
10620
  const { columnIndex } = pointPosition;
@@ -10619,7 +10625,7 @@ class AITableCellProgress extends CoverCellBase {
10619
10625
  const point = stage.getPointerPosition();
10620
10626
  if (!point)
10621
10627
  return;
10622
- const dragX = point.x - columnLeftX - x;
10628
+ const dragX = point.x - columnLeftX - x - groupOffset;
10623
10629
  const percentage = this.calculatePercentage(dragX);
10624
10630
  if (!this.readonly() && actions && actions.updateFieldValues) {
10625
10631
  actions.updateFieldValues([
@@ -13530,10 +13536,13 @@ class AITableGrid extends AITableGridBase {
13530
13536
  switch (targetName) {
13531
13537
  case AI_TABLE_ROW_ADD_BUTTON: {
13532
13538
  clearCoverCell(this.aiTable);
13539
+ const addRowIndex = (targetNameDetail.source
13540
+ ? this.aiTable.context.visibleRowsIndexMap().get(targetNameDetail.source)
13541
+ : this.aiTable.context.linearRows().length - 1) ?? -1;
13533
13542
  this.addRecord({
13534
13543
  forGroupId: targetNameDetail.source
13535
13544
  });
13536
- const { isCanFullRender, offsetY } = this.coordinate().getAddRowButtonIsFullRenderInfo(this.aiTable);
13545
+ const { isCanFullRender, offsetY } = this.coordinate().getAddRowButtonIsFullRenderInfo(this.aiTable, addRowIndex + 1);
13537
13546
  if (!isCanFullRender) {
13538
13547
  this.scrollAction({
13539
13548
  deltaX: 0,