@ai-table/grid 0.1.43 → 0.1.45

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.
@@ -4,7 +4,7 @@ import * as i0 from "@angular/core";
4
4
  export declare class DateCellEditorComponent extends AbstractEditCellEditor<DateFieldValue> {
5
5
  placeholder: string;
6
6
  ngOnInit(): void;
7
- updateValue(value: number): void;
7
+ updateValue(timestamp: number): void;
8
8
  thyOpenChange(isOpen: Boolean): void;
9
9
  static ɵfac: i0.ɵɵFactoryDeclaration<DateCellEditorComponent, never>;
10
10
  static ɵcmp: i0.ɵɵComponentDeclaration<DateCellEditorComponent, "date-cell-editor", never, {}, {}, never, never, true, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"date-editor.component.d.ts","sourceRoot":"","sources":["../../../../../packages/grid/src/components/cell-editors/date/date-editor.component.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAI3E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;;AAEjD,qBAyBa,uBAAwB,SAAQ,sBAAsB,CAAC,cAAc,CAAC;IAC/E,WAAW,SAAM;IAER,QAAQ,IAAI,IAAI;IAazB,WAAW,CAAC,KAAK,EAAE,MAAM;IAUzB,aAAa,CAAC,MAAM,EAAE,OAAO;yCA1BpB,uBAAuB;2CAAvB,uBAAuB;CA+BnC"}
1
+ {"version":3,"file":"date-editor.component.d.ts","sourceRoot":"","sources":["../../../../../packages/grid/src/components/cell-editors/date/date-editor.component.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAI3E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;;AAEjD,qBAyBa,uBAAwB,SAAQ,sBAAsB,CAAC,cAAc,CAAC;IAC/E,WAAW,SAAM;IAER,QAAQ,IAAI,IAAI;IAazB,WAAW,CAAC,SAAS,EAAE,MAAM;IAW7B,aAAa,CAAC,MAAM,EAAE,OAAO;yCA3BpB,uBAAuB;2CAAvB,uBAAuB;CAgCnC"}
@@ -1731,10 +1731,11 @@ class DateCellEditorComponent extends AbstractEditCellEditor {
1731
1731
  })();
1732
1732
  this.placeholder = getI18nTextByKey(this.aiTable, AITableGridI18nKey.dataPickerPlaceholder);
1733
1733
  }
1734
- updateValue(value) {
1734
+ updateValue(timestamp) {
1735
+ const value = timestamp ? { timestamp: timestamp } : null;
1735
1736
  this.updateFieldValues.emit([
1736
1737
  {
1737
- value: { timestamp: value },
1738
+ value,
1738
1739
  path: [this.record()._id, this.field()._id]
1739
1740
  }
1740
1741
  ]);
@@ -2018,16 +2019,19 @@ function getColumnIndicesSizeMap(aiTable, fields) {
2018
2019
  */
2019
2020
  function getCellHorizontalPosition(options) {
2020
2021
  let { columnWidth, columnIndex, columnCount, depth = 0 } = options;
2022
+ const isGroupAndFirstColumn = depth > 0 && columnIndex === 0;
2023
+ columnWidth = isGroupAndFirstColumn ? columnWidth - AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE : columnWidth;
2021
2024
  depth += 1;
2022
2025
  if (!depth)
2023
2026
  return { width: columnWidth, offset: 0 };
2024
2027
  const firstIndent = columnIndex === 0 && depth;
2025
2028
  const lastIndent = columnIndex === columnCount - 1 && depth === 3;
2026
- const offset = firstIndent ? (depth - 1) * AI_TABLE_ROW_GROUP_OFFSET + 0.5 : 0;
2029
+ let offset = firstIndent ? (depth - 1) * AI_TABLE_ROW_GROUP_OFFSET + 0.5 : 0;
2027
2030
  const width = lastIndent && !firstIndent ? columnWidth - AI_TABLE_ROW_GROUP_OFFSET : columnWidth - offset;
2028
2031
  return {
2029
2032
  width,
2030
- offset
2033
+ offset,
2034
+ isGroupAndFirstColumn
2031
2035
  };
2032
2036
  }
2033
2037
  function transformToCellText(cellValue, options) {
@@ -2282,12 +2286,15 @@ function getPlaceHolderCellsConfigs(options) {
2282
2286
  }
2283
2287
  // 当前行的 Y 轴偏移量,并根据列宽和列索引获取单元格的水平位置(宽度和偏移量)
2284
2288
  const y = coordinate.getRowOffset(rowIndex) + AI_TABLE_OFFSET * 2;
2285
- const { width, offset } = getCellHorizontalPosition({
2289
+ let { width, offset, isGroupAndFirstColumn } = getCellHorizontalPosition({
2286
2290
  columnWidth,
2287
2291
  columnIndex,
2288
2292
  columnCount,
2289
2293
  depth
2290
2294
  });
2295
+ if (isGroupAndFirstColumn) {
2296
+ offset += AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE;
2297
+ }
2291
2298
  const height = rowHeight - AI_TABLE_OFFSET * 4;
2292
2299
  configs.unshift({
2293
2300
  key: `placeholder-cell-${fieldId}-${recordId}`,
@@ -5457,11 +5464,17 @@ const createActiveCellBorder = (config) => {
5457
5464
  const y = coordinate.getRowOffset(rowIndex);
5458
5465
  const columnWidth = coordinate.getColumnWidth(columnIndex);
5459
5466
  const isFrozenColumn = columnIndex < frozenColumnCount;
5460
- const { offset, width } = getCellHorizontalPosition({
5467
+ const row = aiTable.context?.linearRows()[rowIndex];
5468
+ const depth = row?.depth ?? 0;
5469
+ let { offset, width, isGroupAndFirstColumn } = getCellHorizontalPosition({
5461
5470
  columnWidth,
5462
5471
  columnIndex,
5463
- columnCount: totalColumnCount
5472
+ columnCount: totalColumnCount,
5473
+ depth
5464
5474
  });
5475
+ if (isGroupAndFirstColumn) {
5476
+ offset += AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE;
5477
+ }
5465
5478
  const currentConfig = {
5466
5479
  x: x + offset + AI_TABLE_OFFSET,
5467
5480
  y: y + AI_TABLE_OFFSET,
@@ -5661,7 +5674,7 @@ class AddRowLayout extends Layout {
5661
5674
  if (this.isFirst || this.isLast)
5662
5675
  return;
5663
5676
  this.renderCell({
5664
- width: this.columnWidth,
5677
+ width: this.columnWidth + AI_TABLE_CELL_LINE_BORDER,
5665
5678
  isHoverRow
5666
5679
  });
5667
5680
  }
@@ -6202,13 +6215,13 @@ class CellDrawer extends Drawer {
6202
6215
  }
6203
6216
  }
6204
6217
  renderCellCheckbox(render, ctx) {
6205
- const { x, y, field, columnWidth, transformValue, isCoverCell } = render;
6218
+ const { x, y, field, columnWidth, transformValue, isCoverCell, isGroupFirstRender } = render;
6206
6219
  if (isCoverCell) {
6207
6220
  return;
6208
6221
  }
6209
6222
  const isChecked = !isEmpty(transformValue) && !!transformValue;
6210
6223
  const checkboxSize = AI_TABLE_ICON_COMMON_SIZE;
6211
- const checkboxX = x + (columnWidth - checkboxSize) / 2;
6224
+ const checkboxX = isGroupFirstRender ? x + AI_TABLE_CELL_PADDING : x + (columnWidth - checkboxSize) / 2;
6212
6225
  const checkboxY = y + (AI_TABLE_ROW_BLANK_HEIGHT - checkboxSize) / 2;
6213
6226
  this.path({
6214
6227
  x: checkboxX,
@@ -6219,7 +6232,7 @@ class CellDrawer extends Drawer {
6219
6232
  });
6220
6233
  }
6221
6234
  renderCellText(render, ctx) {
6222
- const { x, y, transformValue, field, columnWidth, style } = render;
6235
+ const { x, y, transformValue, field, columnWidth, style, isGroupFirstRender } = render;
6223
6236
  if (isUndefinedOrNull(transformValue)) {
6224
6237
  return;
6225
6238
  }
@@ -6273,7 +6286,7 @@ class CellDrawer extends Drawer {
6273
6286
  lineHeight: DEFAULT_TEXT_LINE_HEIGHT,
6274
6287
  textAlign,
6275
6288
  verticalAlign: DEFAULT_TEXT_VERTICAL_ALIGN_MIDDLE,
6276
- fillStyle: fieldType === AITableFieldType.link ? Colors.primary : color,
6289
+ fillStyle: fieldType === AITableFieldType.link && !isGroupFirstRender ? Colors.primary : color,
6277
6290
  fontWeight,
6278
6291
  textDecoration,
6279
6292
  fieldType,
@@ -6629,7 +6642,7 @@ class CellDrawer extends Drawer {
6629
6642
  });
6630
6643
  }
6631
6644
  renderCellProgress(render, ctx) {
6632
- const { x, y, transformValue, columnWidth, style } = render;
6645
+ const { x, y, transformValue, columnWidth, style, isGroupFirstRender } = render;
6633
6646
  const colors = AITable.getColors();
6634
6647
  let validateTransformValue = transformValue;
6635
6648
  if (isUndefinedOrNull(validateTransformValue)) {
@@ -6641,31 +6654,41 @@ class CellDrawer extends Drawer {
6641
6654
  const offsetX = AI_TABLE_CELL_PADDING;
6642
6655
  const offsetY = (AI_TABLE_ROW_BLANK_HEIGHT - AI_TABLE_PROGRESS_BAR_HEIGHT) / 2;
6643
6656
  const textOffsetY = (AI_TABLE_ROW_BLANK_HEIGHT - textHeight) / 2;
6644
- // 绘制背景
6645
- this.rect({
6646
- x: x + offsetX,
6647
- y: y + offsetY,
6648
- width,
6649
- height,
6650
- radius: AI_TABLE_PROGRESS_BAR_RADIUS,
6651
- fill: colors.gray200
6652
- });
6653
- // 计算并绘制进度
6654
- const progressWidth = (validateTransformValue / 100) * width;
6655
- this.rect({
6656
- x: x + offsetX,
6657
- y: y + offsetY,
6658
- width: progressWidth,
6659
- height,
6660
- radius: AI_TABLE_PROGRESS_BAR_RADIUS,
6661
- fill: colors.success
6662
- });
6663
- this.text({
6664
- x: x + offsetX + width + AI_TABLE_TEXT_GAP,
6665
- y: y + textOffsetY,
6666
- text: `${validateTransformValue}%`,
6667
- fillStyle: colors.gray800
6668
- });
6657
+ if (isGroupFirstRender) {
6658
+ this.text({
6659
+ x: x + offsetX,
6660
+ y: y + textOffsetY,
6661
+ text: `${validateTransformValue}%`,
6662
+ fillStyle: colors.gray800
6663
+ });
6664
+ }
6665
+ else {
6666
+ // 绘制背景
6667
+ this.rect({
6668
+ x: x + offsetX,
6669
+ y: y + offsetY,
6670
+ width,
6671
+ height,
6672
+ radius: AI_TABLE_PROGRESS_BAR_RADIUS,
6673
+ fill: colors.gray200
6674
+ });
6675
+ // 计算并绘制进度
6676
+ const progressWidth = (validateTransformValue / 100) * width;
6677
+ this.rect({
6678
+ x: x + offsetX,
6679
+ y: y + offsetY,
6680
+ width: progressWidth,
6681
+ height,
6682
+ radius: AI_TABLE_PROGRESS_BAR_RADIUS,
6683
+ fill: colors.success
6684
+ });
6685
+ this.text({
6686
+ x: x + offsetX + width + AI_TABLE_TEXT_GAP,
6687
+ y: y + textOffsetY,
6688
+ text: `${validateTransformValue}%`,
6689
+ fillStyle: colors.gray800
6690
+ });
6691
+ }
6669
6692
  }
6670
6693
  renderCellMember(render, ctx) {
6671
6694
  const { references, x, y, field, transformValue, rowHeight, columnWidth, isActive } = render;
@@ -6995,12 +7018,13 @@ class GroupLayout extends Layout {
6995
7018
  });
6996
7019
  }
6997
7020
  const iconContainerWidth = AI_TABLE_ICON_COMMON_SIZE + AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE;
6998
- if (!isEmpty(groupValue)) {
7021
+ if (!isEmpty(groupValue) || [AITableFieldType.checkbox, AITableFieldType.progress].includes(field.type)) {
6999
7022
  cellDrawer.initStyle(field, style);
7000
7023
  cellDrawer.renderCell({
7001
7024
  ...render,
7002
7025
  x: render.x + iconContainerWidth,
7003
- columnWidth: render.columnWidth - iconContainerWidth
7026
+ columnWidth: render.columnWidth - iconContainerWidth,
7027
+ isGroupFirstRender: true
7004
7028
  }, this.ctx, columnWidth);
7005
7029
  }
7006
7030
  else {
@@ -7141,10 +7165,9 @@ const createCells = (config) => {
7141
7165
  isHoverRow: isHoverRecord(isHover, targetName),
7142
7166
  isCheckedRow: isSelectedRecord(recordId, aiTable)
7143
7167
  });
7144
- const isGroupAndFirstColumn = depth > 0 && columnIndex === 0;
7145
- const { width, offset } = getCellHorizontalPosition({
7168
+ const { width, offset, isGroupAndFirstColumn } = getCellHorizontalPosition({
7146
7169
  columnIndex,
7147
- columnWidth: isGroupAndFirstColumn ? columnWidth - AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE : columnWidth,
7170
+ columnWidth,
7148
7171
  columnCount,
7149
7172
  depth
7150
7173
  });
@@ -7213,12 +7236,15 @@ const createCells = (config) => {
7213
7236
  frozenColumnCount,
7214
7237
  xIsScroll
7215
7238
  });
7216
- const { width, offset } = getCellHorizontalPosition({
7239
+ let { width, offset, isGroupAndFirstColumn } = getCellHorizontalPosition({
7217
7240
  columnIndex,
7218
7241
  columnWidth,
7219
7242
  columnCount,
7220
7243
  depth
7221
7244
  });
7245
+ if (isGroupAndFirstColumn) {
7246
+ width += AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE;
7247
+ }
7222
7248
  const realX = x + offset + AI_TABLE_OFFSET;
7223
7249
  const realY = y + AI_TABLE_OFFSET;
7224
7250
  const style = { fontWeight: DEFAULT_FONT_STYLE };
@@ -8969,10 +8995,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
8969
8995
  const createGroupCells = (config) => {
8970
8996
  const { coordinate, rowStartIndex, rowStopIndex, columnStartIndex, columnStopIndex, aiTable, actions, readonly } = config;
8971
8997
  const linearRows = aiTable.context?.linearRows();
8972
- const { columnCount } = coordinate;
8998
+ const { rowCount, columnCount } = coordinate;
8973
8999
  const groups = [];
8974
9000
  for (let rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
8975
- if (rowIndex > columnCount - 1)
9001
+ if (rowIndex > rowCount - 1)
8976
9002
  break;
8977
9003
  if (rowIndex < 0)
8978
9004
  continue;
@@ -9512,6 +9538,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
9512
9538
  class AITableGroups {
9513
9539
  constructor() {
9514
9540
  this.config = input.required();
9541
+ this.trackBy = (groupStat) => {
9542
+ return groupStat.groupRow._id + groupStat.columnIndex;
9543
+ };
9515
9544
  this.frozenColumnCount = computed(() => {
9516
9545
  const { coordinate } = this.config();
9517
9546
  return coordinate.frozenColumnCount ?? 0;
@@ -9547,7 +9576,7 @@ class AITableGroups {
9547
9576
  }
9548
9577
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AITableGroups, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
9549
9578
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.10", type: AITableGroups, isStandalone: true, selector: "ai-table-groups", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
9550
- @for (groupCell of groupCells(); track $index) {
9579
+ @for (groupCell of groupCells(); track trackBy(groupCell.groupStat!)) {
9551
9580
  <ai-table-field-stat [config]="groupCell.groupStat!"></ai-table-field-stat>
9552
9581
  }
9553
9582
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: AITableFieldStat, selector: "ai-table-field-stat", inputs: ["config"], outputs: ["hover"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
@@ -9557,7 +9586,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
9557
9586
  args: [{
9558
9587
  selector: 'ai-table-groups',
9559
9588
  template: `
9560
- @for (groupCell of groupCells(); track $index) {
9589
+ @for (groupCell of groupCells(); track trackBy(groupCell.groupStat!)) {
9561
9590
  <ai-table-field-stat [config]="groupCell.groupStat!"></ai-table-field-stat>
9562
9591
  }
9563
9592
  `,
@@ -9745,10 +9774,9 @@ class AITableCoverCellEntry {
9745
9774
  const x = coordinate.getColumnOffset(columnIndex) + AI_TABLE_OFFSET;
9746
9775
  const columnWidth = coordinate.getColumnWidth(columnIndex);
9747
9776
  const y = coordinate.getRowOffset(rowIndex) + AI_TABLE_OFFSET;
9748
- const isGroupAndFirstColumn = depth > 0 && columnIndex === 0;
9749
- const { width, offset } = getCellHorizontalPosition({
9777
+ const { width, offset, isGroupAndFirstColumn } = getCellHorizontalPosition({
9750
9778
  columnIndex,
9751
- columnWidth: isGroupAndFirstColumn ? columnWidth - AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE : columnWidth,
9779
+ columnWidth,
9752
9780
  columnCount,
9753
9781
  depth
9754
9782
  });
@@ -9835,6 +9863,9 @@ class AITableFieldStats {
9835
9863
  this.config = input.required();
9836
9864
  this.hover = output();
9837
9865
  this.isHover = signal(false);
9866
+ this.trackBy = (groupStat) => {
9867
+ return groupStat.columnIndex;
9868
+ };
9838
9869
  this.statConfigs = computed(() => createFieldStats(this.config()));
9839
9870
  }
9840
9871
  onMouseenter(e) {
@@ -9846,7 +9877,7 @@ class AITableFieldStats {
9846
9877
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AITableFieldStats, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
9847
9878
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.10", type: AITableFieldStats, isStandalone: true, selector: "ai-table-column-stats", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { hover: "hover" }, ngImport: i0, template: `
9848
9879
  <ko-group>
9849
- @for (config of statConfigs(); track $index) {
9880
+ @for (config of statConfigs(); track trackBy(config)) {
9850
9881
  <ai-table-field-stat [config]="config" (hover)="hover.emit($event)"></ai-table-field-stat>
9851
9882
  }
9852
9883
  </ko-group>
@@ -9858,7 +9889,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
9858
9889
  selector: 'ai-table-column-stats',
9859
9890
  template: `
9860
9891
  <ko-group>
9861
- @for (config of statConfigs(); track $index) {
9892
+ @for (config of statConfigs(); track trackBy(config)) {
9862
9893
  <ai-table-field-stat [config]="config" (hover)="hover.emit($event)"></ai-table-field-stat>
9863
9894
  }
9864
9895
  </ko-group>
@@ -9955,7 +9986,6 @@ class AITableRenderer {
9955
9986
  return {
9956
9987
  clipX: 0,
9957
9988
  clipY: AI_TABLE_FIELD_HEAD_HEIGHT,
9958
- clipWidth: this.frozenAreaWidth() + AI_TABLE_SHADOW_DEFAULT_WIDTH,
9959
9989
  clipHeight: this.gridContainerHeight()
9960
9990
  };
9961
9991
  });
@@ -11889,11 +11919,18 @@ class AITableGridEventService {
11889
11919
  const originX = coordinate.getColumnOffset(columnIndex);
11890
11920
  const originY = coordinate.getRowOffset(rowIndex);
11891
11921
  const columnWidth = coordinate.getColumnWidth(columnIndex);
11892
- const { width: originWidth, offset: originOffset } = getCellHorizontalPosition({
11922
+ const row = aiTable.context?.linearRows()[rowIndex];
11923
+ const depth = row?.depth ?? 0;
11924
+ const isGroupAndFirstColumn = depth > 0 && columnIndex === 0;
11925
+ let { width: originWidth, offset: originOffset } = getCellHorizontalPosition({
11893
11926
  columnWidth,
11894
11927
  columnIndex,
11895
- columnCount
11928
+ columnCount,
11929
+ depth
11896
11930
  });
11931
+ if (isGroupAndFirstColumn) {
11932
+ originOffset += AI_TABLE_FIELD_HEAD_ICON_GAP_SIZE;
11933
+ }
11897
11934
  const originRect = container.getBoundingClientRect();
11898
11935
  const isFrozenColumn = AITable.isFrozenColumn(aiTable, columnIndex);
11899
11936
  const scrollLeft = isFrozenColumn ? 0 : scrollState().scrollLeft;
@@ -12996,8 +13033,9 @@ class AITableGrid extends AITableGridBase {
12996
13033
  const scrollTop = this.aiTable.context.scrollState().scrollTop;
12997
13034
  const rowIndices = this.toolTipRowIndices();
12998
13035
  return rowIndices.map((rowIndex) => {
13036
+ const offset = this.coordinate().getRowOffset(rowIndex);
12999
13037
  return {
13000
- top: rowIndex * AI_TABLE_ROW_HEIGHT - scrollTop,
13038
+ top: offset - scrollTop - AI_TABLE_FIELD_HEAD_HEIGHT,
13001
13039
  left: 0
13002
13040
  };
13003
13041
  });