@ai-table/grid 0.0.36 → 0.0.38

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.
@@ -32,7 +32,7 @@ import { ThyEmptyModule } from 'ngx-tethys/empty';
32
32
  import { ThyIcon } from 'ngx-tethys/icon';
33
33
  import { ThySelect } from 'ngx-tethys/select';
34
34
  import { ThyTag } from 'ngx-tethys/tag';
35
- import { ThyDropdownDirective, ThyDropdownMenuComponent, ThyDropdownMenuItemDirective, ThyDropdownMenuItemNameDirective, ThyDropdownAbstractMenu, ThyDropdownMenuItemIconDirective } from 'ngx-tethys/dropdown';
35
+ import { ThyDropdownDirective, ThyDropdownMenuComponent, ThyDropdownMenuItemDirective, ThyDropdownMenuItemNameDirective, ThyDropdownAbstractMenu } from 'ngx-tethys/dropdown';
36
36
  import { ThyListItem } from 'ngx-tethys/list';
37
37
  import { of, Subject, fromEvent, debounceTime, mergeWith, filter } from 'rxjs';
38
38
  import * as i4 from 'ngx-tethys/avatar';
@@ -200,14 +200,14 @@ const FieldOptions = [
200
200
  type: AITableFieldType.text,
201
201
  name: '单行文本',
202
202
  icon: 'font',
203
- width: 200
203
+ width: 300
204
204
  },
205
205
  // 多行文本
206
206
  {
207
207
  type: AITableFieldType.select,
208
208
  name: '单选',
209
209
  icon: 'check-circle',
210
- width: 200
210
+ width: 160
211
211
  },
212
212
  {
213
213
  type: AITableFieldType.select,
@@ -222,7 +222,7 @@ const FieldOptions = [
222
222
  type: AITableFieldType.number,
223
223
  name: '数字',
224
224
  icon: 'hashtag',
225
- width: 200
225
+ width: 140
226
226
  },
227
227
  {
228
228
  type: AITableFieldType.date,
@@ -234,7 +234,7 @@ const FieldOptions = [
234
234
  type: AITableFieldType.member,
235
235
  name: '单个成员',
236
236
  icon: 'user',
237
- width: 200
237
+ width: 160
238
238
  },
239
239
  {
240
240
  type: AITableFieldType.member,
@@ -257,19 +257,19 @@ const FieldOptions = [
257
257
  type: AITableFieldType.rate,
258
258
  name: '评分',
259
259
  icon: 'star-circle',
260
- width: 200
260
+ width: 160
261
261
  },
262
262
  {
263
263
  type: AITableFieldType.link,
264
264
  name: '链接',
265
265
  icon: 'link-insert',
266
- width: 300
266
+ width: 200
267
267
  },
268
268
  {
269
269
  type: AITableFieldType.createdBy,
270
270
  name: '创建人',
271
271
  icon: 'user',
272
- width: 200
272
+ width: 160
273
273
  },
274
274
  {
275
275
  type: AITableFieldType.createdAt,
@@ -281,7 +281,7 @@ const FieldOptions = [
281
281
  type: AITableFieldType.updatedBy,
282
282
  name: '更新人',
283
283
  icon: 'user',
284
- width: 200
284
+ width: 160
285
285
  },
286
286
  {
287
287
  type: AITableFieldType.updatedAt,
@@ -917,7 +917,7 @@ class DateCellEditorComponent extends AbstractEditCellEditor {
917
917
  <thy-date-picker
918
918
  class="h-100"
919
919
  thyTimestampPrecision="seconds"
920
- thyPlaceHolder="选择时间"
920
+ thyPlaceHolder="选择日期"
921
921
  [ngModel]="modelValue.timestamp"
922
922
  (ngModelChange)="updateValue($event)"
923
923
  (thyOpenChange)="thyOpenChange($event)"
@@ -939,7 +939,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
939
939
  <thy-date-picker
940
940
  class="h-100"
941
941
  thyTimestampPrecision="seconds"
942
- thyPlaceHolder="选择时间"
942
+ thyPlaceHolder="选择日期"
943
943
  [ngModel]="modelValue.timestamp"
944
944
  (ngModelChange)="updateValue($event)"
945
945
  (thyOpenChange)="thyOpenChange($event)"
@@ -1399,7 +1399,7 @@ class SelectCellEditorComponent extends AbstractEditCellEditor {
1399
1399
  }
1400
1400
  }
1401
1401
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SelectCellEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1402
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: SelectCellEditorComponent, isStandalone: true, selector: "select-cell-editor", host: { classAttribute: "d-block h-100 select-cell-editor" }, usesInheritance: true, ngImport: i0, template: "<thy-select\n [(ngModel)]=\"modelValue\"\n [thyAutoExpand]=\"true\"\n [thyAllowClear]=\"true\"\n [thyPreset]=\"preset()\"\n [thyMode]=\"field().settings.is_multiple ? 'multiple' : ''\"\n (thyOnExpandStatusChange)=\"updateValue($event)\"\n>\n <ng-template #selectedDisplay let-option>\n <select-option [field]=\"field()\" [displayOption]=\"option\"></select-option>\n </ng-template>\n @for (option of selectOptions(); track option._id) {\n <thy-option [thyValue]=\"option._id\" [thyRawValue]=\"option\" [thyShowOptionCustom]=\"true\" [thyLabelText]=\"option.text\">\n <select-option [field]=\"field()\" [displayOption]=\"option\"></select-option>\n </thy-option>\n }\n</thy-select>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ThySelect, selector: "thy-select,thy-custom-select", inputs: ["thyDropdownWidthMode", "thyShowSearch", "thyPlaceHolder", "thyServerSearch", "thyLoadState", "thyAutoActiveFirstItem", "thyMode", "thySize", "thyEmptyStateText", "thyEmptySearchMessageText", "thyEnableScrollLoad", "thyAllowClear", "thyDisabled", "thySortComparator", "thyFooterTemplate", "thyPlacement", "thyOrigin", "thyFooterClass", "thyAutoExpand", "thyHasBackdrop", "thyMaxTagCount", "thyBorderless", "thyOptions", "thyPreset"], outputs: ["thyOnSearch", "thyOnScrollToBottom", "thyOnExpandStatusChange"], exportAs: ["thySelect"] }, { kind: "component", type: ThyOption, selector: "thy-option", inputs: ["thyValue", "thyRawValue", "thyLabelText", "thyShowOptionCustom", "thySearchKey", "thyDisabled"], outputs: ["selectionChange", "visibleChange"] }, { kind: "ngmodule", type: ThyTooltipModule }, { kind: "component", type: SelectOptionComponent, selector: "select-option", inputs: ["field", "displayOption"] }, { kind: "ngmodule", type: ThyEmptyModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1402
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: SelectCellEditorComponent, isStandalone: true, selector: "select-cell-editor", host: { classAttribute: "d-block h-100 select-cell-editor" }, usesInheritance: true, ngImport: i0, template: "<thy-select\n [(ngModel)]=\"modelValue\"\n [thyAutoExpand]=\"true\"\n [thyAllowClear]=\"true\"\n [thyPlaceHolder]=\"''\"\n [thyPreset]=\"preset()\"\n [thyMode]=\"field().settings.is_multiple ? 'multiple' : ''\"\n (thyOnExpandStatusChange)=\"updateValue($event)\"\n>\n <ng-template #selectedDisplay let-option>\n <select-option [field]=\"field()\" [displayOption]=\"option\"></select-option>\n </ng-template>\n @for (option of selectOptions(); track option._id) {\n <thy-option [thyValue]=\"option._id\" [thyRawValue]=\"option\" [thyShowOptionCustom]=\"true\" [thyLabelText]=\"option.text\">\n <select-option [field]=\"field()\" [displayOption]=\"option\"></select-option>\n </thy-option>\n }\n</thy-select>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ThySelect, selector: "thy-select,thy-custom-select", inputs: ["thyDropdownWidthMode", "thyShowSearch", "thyPlaceHolder", "thyServerSearch", "thyLoadState", "thyAutoActiveFirstItem", "thyMode", "thySize", "thyEmptyStateText", "thyEmptySearchMessageText", "thyEnableScrollLoad", "thyAllowClear", "thyDisabled", "thySortComparator", "thyFooterTemplate", "thyPlacement", "thyOrigin", "thyFooterClass", "thyAutoExpand", "thyHasBackdrop", "thyMaxTagCount", "thyBorderless", "thyOptions", "thyPreset"], outputs: ["thyOnSearch", "thyOnScrollToBottom", "thyOnExpandStatusChange"], exportAs: ["thySelect"] }, { kind: "component", type: ThyOption, selector: "thy-option", inputs: ["thyValue", "thyRawValue", "thyLabelText", "thyShowOptionCustom", "thySearchKey", "thyDisabled"], outputs: ["selectionChange", "visibleChange"] }, { kind: "ngmodule", type: ThyTooltipModule }, { kind: "component", type: SelectOptionComponent, selector: "select-option", inputs: ["field", "displayOption"] }, { kind: "ngmodule", type: ThyEmptyModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1403
1403
  }
1404
1404
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SelectCellEditorComponent, decorators: [{
1405
1405
  type: Component,
@@ -1418,7 +1418,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
1418
1418
  SelectOptionPipe,
1419
1419
  SelectOptionComponent,
1420
1420
  ThyEmptyModule
1421
- ], template: "<thy-select\n [(ngModel)]=\"modelValue\"\n [thyAutoExpand]=\"true\"\n [thyAllowClear]=\"true\"\n [thyPreset]=\"preset()\"\n [thyMode]=\"field().settings.is_multiple ? 'multiple' : ''\"\n (thyOnExpandStatusChange)=\"updateValue($event)\"\n>\n <ng-template #selectedDisplay let-option>\n <select-option [field]=\"field()\" [displayOption]=\"option\"></select-option>\n </ng-template>\n @for (option of selectOptions(); track option._id) {\n <thy-option [thyValue]=\"option._id\" [thyRawValue]=\"option\" [thyShowOptionCustom]=\"true\" [thyLabelText]=\"option.text\">\n <select-option [field]=\"field()\" [displayOption]=\"option\"></select-option>\n </thy-option>\n }\n</thy-select>\n" }]
1421
+ ], template: "<thy-select\n [(ngModel)]=\"modelValue\"\n [thyAutoExpand]=\"true\"\n [thyAllowClear]=\"true\"\n [thyPlaceHolder]=\"''\"\n [thyPreset]=\"preset()\"\n [thyMode]=\"field().settings.is_multiple ? 'multiple' : ''\"\n (thyOnExpandStatusChange)=\"updateValue($event)\"\n>\n <ng-template #selectedDisplay let-option>\n <select-option [field]=\"field()\" [displayOption]=\"option\"></select-option>\n </ng-template>\n @for (option of selectOptions(); track option._id) {\n <thy-option [thyValue]=\"option._id\" [thyRawValue]=\"option\" [thyShowOptionCustom]=\"true\" [thyLabelText]=\"option.text\">\n <select-option [field]=\"field()\" [displayOption]=\"option\"></select-option>\n </thy-option>\n }\n</thy-select>\n" }]
1422
1422
  }], ctorParameters: () => [] });
1423
1423
 
1424
1424
  class TextCellEditorComponent extends AbstractEditCellEditor {
@@ -1663,18 +1663,18 @@ class AITableGridSelectionService {
1663
1663
  }
1664
1664
  selectCells(startCell, endCell) {
1665
1665
  const [startRecordId, startFieldId] = startCell;
1666
- const records = this.aiTable.records();
1667
- const fields = this.aiTable.fields();
1666
+ const records = this.aiTable.context.linearRows();
1667
+ const fields = AITable.getVisibleFields(this.aiTable);
1668
1668
  const selectedCells = new Set();
1669
1669
  if (!endCell) {
1670
1670
  selectedCells.add(`${startRecordId}:${startFieldId}`);
1671
1671
  }
1672
1672
  else {
1673
1673
  const [endRecordId, endFieldId] = endCell;
1674
- const startRowIndex = records.findIndex((record) => record._id === startRecordId);
1675
- const endRowIndex = records.findIndex((record) => record._id === endRecordId);
1676
- const startColIndex = fields.findIndex((field) => field._id === startFieldId);
1677
- const endColIndex = fields.findIndex((field) => field._id === endFieldId);
1674
+ const startRowIndex = this.aiTable.context.visibleRowsIndexMap().get(startRecordId);
1675
+ const endRowIndex = this.aiTable.context.visibleRowsIndexMap().get(endRecordId);
1676
+ const startColIndex = this.aiTable.context.visibleColumnsIndexMap().get(startFieldId);
1677
+ const endColIndex = this.aiTable.context.visibleColumnsIndexMap().get(endFieldId);
1678
1678
  const minRowIndex = Math.min(startRowIndex, endRowIndex);
1679
1679
  const maxRowIndex = Math.max(startRowIndex, endRowIndex);
1680
1680
  const minColIndex = Math.min(startColIndex, endColIndex);
@@ -1894,15 +1894,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
1894
1894
  type: Component,
1895
1895
  args: [{ selector: 'ai-table-field-menu', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
1896
1896
  class: 'field-menu'
1897
- }, imports: [
1898
- ThyIcon,
1899
- ThyDivider,
1900
- ThyDropdownMenuComponent,
1901
- ThyDropdownMenuItemDirective,
1902
- ThyDropdownMenuItemNameDirective,
1903
- ThyDropdownMenuItemIconDirective,
1904
- NgClass
1905
- ], template: "@for (menu of fieldMenus; track index; let index = $index) {\n @if ((menu.hidden && !menu.hidden(aiTable, field)) || !menu.hidden) {\n @if (menu.type === 'divider') {\n <thy-divider [thyStyle]=\"'solid'\"></thy-divider>\n } @else {\n @let disabled = !!(menu.disabled && menu.disabled(aiTable, field));\n @let isRemoveField = menu.type === 'removeField';\n <a\n thyDropdownMenuItem\n href=\"javascript:;\"\n [ngClass]=\"{ 'remove-field': isRemoveField && !disabled }\"\n (click)=\"execute(menu)\"\n [thyDisabled]=\"disabled\"\n >\n <thy-icon [thyIconName]=\"menu.icon!\"></thy-icon>\n <span>{{ menu.name! }}</span>\n </a>\n }\n }\n}\n" }]
1897
+ }, imports: [ThyIcon, ThyDivider, ThyDropdownMenuItemDirective, NgClass], template: "@for (menu of fieldMenus; track index; let index = $index) {\n @if ((menu.hidden && !menu.hidden(aiTable, field)) || !menu.hidden) {\n @if (menu.type === 'divider') {\n <thy-divider [thyStyle]=\"'solid'\"></thy-divider>\n } @else {\n @let disabled = !!(menu.disabled && menu.disabled(aiTable, field));\n @let isRemoveField = menu.type === 'removeField';\n <a\n thyDropdownMenuItem\n href=\"javascript:;\"\n [ngClass]=\"{ 'remove-field': isRemoveField && !disabled }\"\n (click)=\"execute(menu)\"\n [thyDisabled]=\"disabled\"\n >\n <thy-icon [thyIconName]=\"menu.icon!\"></thy-icon>\n <span>{{ menu.name! }}</span>\n </a>\n }\n }\n}\n" }]
1906
1898
  }], propDecorators: { fieldId: [{
1907
1899
  type: Input,
1908
1900
  args: [{ required: true }]
@@ -3210,6 +3202,12 @@ class AITableText {
3210
3202
  this.koMouseMove = output();
3211
3203
  this.textConfig = computed(() => {
3212
3204
  const { x, y, width, height, text, padding, align = DEFAULT_TEXT_ALIGN_LEFT, verticalAlign = DEFAULT_TEXT_VERTICAL_ALIGN_MIDDLE, fill = DEFAULT_TEXT_FILL, textDecoration, fontSize = DEFAULT_FONT_SIZE, fontStyle = DEFAULT_FONT_STYLE, ellipsis = DEFAULT_TEXT_ELLIPSIS, wrap = DEFAULT_TEXT_WRAP, transformsEnabled = DEFAULT_TEXT_TRANSFORMS_ENABLED, listening = DEFAULT_TEXT_LISTENING, fontFamily = DEFAULT_FONT_FAMILY, ...rest } = this.config();
3205
+ const tmpText = new Konva.Text({
3206
+ text,
3207
+ fontSize,
3208
+ fontFamily
3209
+ });
3210
+ const textBounds = tmpText.getClientRect();
3213
3211
  return {
3214
3212
  x,
3215
3213
  y,
@@ -3228,6 +3226,12 @@ class AITableText {
3228
3226
  transformsEnabled,
3229
3227
  listening,
3230
3228
  fontFamily,
3229
+ hitFunc: function (context) {
3230
+ context.beginPath();
3231
+ context.rect(AI_TABLE_OFFSET, (height - textBounds.height) / 2 - AI_TABLE_OFFSET, textBounds.width, textBounds.height);
3232
+ context.closePath();
3233
+ context.fillStrokeShape(this);
3234
+ },
3231
3235
  ...rest
3232
3236
  };
3233
3237
  });
@@ -4220,6 +4224,7 @@ class AITableCellLink {
4220
4224
  lineHeight: 1.84,
4221
4225
  listening: true,
4222
4226
  ellipsis: true,
4227
+ textDecoration: 'underline',
4223
4228
  zIndex
4224
4229
  };
4225
4230
  }
@@ -4282,8 +4287,9 @@ function getHoverCell(aiTable) {
4282
4287
  if (!recordId || !fieldId) {
4283
4288
  return;
4284
4289
  }
4290
+ const record = aiTable.recordsMap()[recordId];
4285
4291
  const field = aiTable.fieldsMap()[fieldId];
4286
- if (!field || !recordId || !fieldId) {
4292
+ if (!record || !field || !recordId || !fieldId) {
4287
4293
  return;
4288
4294
  }
4289
4295
  const cellValue = AITableQueries.getFieldValue(aiTable, [recordId, fieldId]);