@ai-table/grid 0.2.4 → 0.3.0
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.
- package/components/drag/drag.component.d.ts +1 -0
- package/components/drag/drag.component.d.ts.map +1 -1
- package/fesm2022/ai-table-grid.mjs +127 -91
- package/fesm2022/ai-table-grid.mjs.map +1 -1
- package/grid.component.d.ts +2 -0
- package/grid.component.d.ts.map +1 -1
- package/package.json +1 -1
- package/renderer/components/cells/single-text.component.d.ts +1 -0
- package/renderer/components/cells/single-text.component.d.ts.map +1 -1
- package/renderer/components/field-stat/stat.component.d.ts +1 -0
- package/renderer/components/field-stat/stat.component.d.ts.map +1 -1
- package/utils/clipboard/clipboard.d.ts +2 -2
- package/utils/clipboard/clipboard.d.ts.map +1 -1
- package/utils/clipboard/paste.d.ts +1 -1
- package/utils/clipboard/paste.d.ts.map +1 -1
|
@@ -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,u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C"}
|
|
@@ -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.
|
|
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
|
|
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
|
|
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
|
|
2290
|
+
width,
|
|
2291
2291
|
height,
|
|
2292
2292
|
fill: Colors.transparent,
|
|
2293
2293
|
strokeEnabled: false,
|
|
@@ -2414,7 +2414,7 @@ const isClipboardReadSupported = () => {
|
|
|
2414
2414
|
const isClipboardReadTextSupported = () => {
|
|
2415
2415
|
return 'clipboard' in navigator && 'readText' in navigator.clipboard;
|
|
2416
2416
|
};
|
|
2417
|
-
const writeToClipboard = async (data) => {
|
|
2417
|
+
const writeToClipboard = async (data, dataTransfer) => {
|
|
2418
2418
|
try {
|
|
2419
2419
|
const { text, html } = data;
|
|
2420
2420
|
if (isClipboardWriteSupported()) {
|
|
@@ -2423,24 +2423,24 @@ const writeToClipboard = async (data) => {
|
|
|
2423
2423
|
'text/html': new Blob([html], { type: 'text/html' })
|
|
2424
2424
|
});
|
|
2425
2425
|
await navigator.clipboard.write([clipboardItem]);
|
|
2426
|
+
return;
|
|
2426
2427
|
}
|
|
2427
|
-
|
|
2428
|
-
|
|
2428
|
+
if (dataTransfer) {
|
|
2429
|
+
dataTransfer.setData(`text/html`, html);
|
|
2430
|
+
dataTransfer.setData(`text/plain`, text);
|
|
2431
|
+
window.dataTransfer = dataTransfer;
|
|
2432
|
+
return;
|
|
2429
2433
|
}
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
document.body.appendChild(textarea);
|
|
2434
|
-
textarea.select();
|
|
2435
|
-
document.execCommand('copy');
|
|
2436
|
-
document.body.removeChild(textarea);
|
|
2434
|
+
if (isClipboardWriteTextSupported()) {
|
|
2435
|
+
await navigator.clipboard.writeText(text);
|
|
2436
|
+
return;
|
|
2437
2437
|
}
|
|
2438
2438
|
}
|
|
2439
2439
|
catch (error) {
|
|
2440
2440
|
console.warn('Failed to write clipboard:', error);
|
|
2441
2441
|
}
|
|
2442
2442
|
};
|
|
2443
|
-
const readFromClipboard = async () => {
|
|
2443
|
+
const readFromClipboard = async (dataTransfer) => {
|
|
2444
2444
|
try {
|
|
2445
2445
|
let clipboardData = {};
|
|
2446
2446
|
if (isClipboardReadSupported()) {
|
|
@@ -2457,32 +2457,28 @@ const readFromClipboard = async () => {
|
|
|
2457
2457
|
}
|
|
2458
2458
|
}
|
|
2459
2459
|
}
|
|
2460
|
+
const { html, text } = clipboardData;
|
|
2461
|
+
if (html || text) {
|
|
2462
|
+
return clipboardData;
|
|
2463
|
+
}
|
|
2460
2464
|
}
|
|
2461
|
-
|
|
2462
|
-
const
|
|
2463
|
-
|
|
2465
|
+
if (dataTransfer) {
|
|
2466
|
+
const html = dataTransfer.getData(`text/html`);
|
|
2467
|
+
const text = dataTransfer.getData(`text/plain`);
|
|
2468
|
+
html && (clipboardData.html = html);
|
|
2469
|
+
text && (clipboardData.text = text);
|
|
2470
|
+
if (html || text) {
|
|
2471
|
+
return clipboardData;
|
|
2472
|
+
}
|
|
2464
2473
|
}
|
|
2465
|
-
|
|
2466
|
-
const
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
const html = e.clipboardData?.getData('text/html') || '';
|
|
2472
|
-
resolve({
|
|
2473
|
-
text,
|
|
2474
|
-
html: html || undefined
|
|
2475
|
-
});
|
|
2476
|
-
textarea.removeEventListener('paste', handlePaste);
|
|
2477
|
-
};
|
|
2478
|
-
textarea.addEventListener('paste', handlePaste);
|
|
2479
|
-
textarea.focus();
|
|
2480
|
-
document.execCommand('paste');
|
|
2481
|
-
document.body.removeChild(textarea);
|
|
2482
|
-
});
|
|
2483
|
-
clipboardData = await pastePromise;
|
|
2474
|
+
if (isClipboardReadTextSupported()) {
|
|
2475
|
+
const text = await navigator.clipboard.readText();
|
|
2476
|
+
text && (clipboardData.text = text);
|
|
2477
|
+
if (text) {
|
|
2478
|
+
return clipboardData;
|
|
2479
|
+
}
|
|
2484
2480
|
}
|
|
2485
|
-
return
|
|
2481
|
+
return null;
|
|
2486
2482
|
}
|
|
2487
2483
|
catch (error) {
|
|
2488
2484
|
console.warn('Failed to read clipboard:', error);
|
|
@@ -3666,8 +3662,8 @@ function extractAITableContentFromClipboardHtml(clipboardHtml) {
|
|
|
3666
3662
|
}
|
|
3667
3663
|
return null;
|
|
3668
3664
|
}
|
|
3669
|
-
const readClipboardData = async () => {
|
|
3670
|
-
const clipboardData = await readFromClipboard();
|
|
3665
|
+
const readClipboardData = async (dataTransfer) => {
|
|
3666
|
+
const clipboardData = await readFromClipboard(dataTransfer);
|
|
3671
3667
|
let clipboardContent = [];
|
|
3672
3668
|
let aiTableContent = null;
|
|
3673
3669
|
if (clipboardData) {
|
|
@@ -3737,7 +3733,7 @@ function appendField(aiTable, originField, actions) {
|
|
|
3737
3733
|
defaultValue: defaultFieldValue
|
|
3738
3734
|
});
|
|
3739
3735
|
}
|
|
3740
|
-
const writeToAITable = async (aiTable, actions) => {
|
|
3736
|
+
const writeToAITable = async (aiTable, actions, dataTransfer) => {
|
|
3741
3737
|
const selectedCells = Array.from(aiTable.selection().selectedCells);
|
|
3742
3738
|
const result = {
|
|
3743
3739
|
isPasteSuccess: false,
|
|
@@ -3747,7 +3743,7 @@ const writeToAITable = async (aiTable, actions) => {
|
|
|
3747
3743
|
if (!selectedCells.length) {
|
|
3748
3744
|
return result;
|
|
3749
3745
|
}
|
|
3750
|
-
const { clipboardContent, aiTableContent } = await readClipboardData();
|
|
3746
|
+
const { clipboardContent, aiTableContent } = await readClipboardData(dataTransfer);
|
|
3751
3747
|
if (!clipboardContent.length) {
|
|
3752
3748
|
return result;
|
|
3753
3749
|
}
|
|
@@ -9266,15 +9262,6 @@ class AITableFieldStat {
|
|
|
9266
9262
|
config.strokeWidth = AI_TABLE_CELL_LINE_BORDER;
|
|
9267
9263
|
}
|
|
9268
9264
|
}
|
|
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
9265
|
return config;
|
|
9279
9266
|
});
|
|
9280
9267
|
this.field = computed(() => {
|
|
@@ -9505,6 +9492,32 @@ class AITableFieldStat {
|
|
|
9505
9492
|
listening: false
|
|
9506
9493
|
};
|
|
9507
9494
|
});
|
|
9495
|
+
effect(() => {
|
|
9496
|
+
const isGroupStat = this.isGroupStat();
|
|
9497
|
+
const bgConfigWidth = this.bgConfig().width;
|
|
9498
|
+
const renderTexts = this.renderTexts();
|
|
9499
|
+
untracked(() => {
|
|
9500
|
+
if (isGroupStat && this.isFirstColumn()) {
|
|
9501
|
+
const config = this.config();
|
|
9502
|
+
const { aiTable, groupRow, field } = config;
|
|
9503
|
+
const groupStatContainerWidthMap = this.groupStatContainerWidthMap();
|
|
9504
|
+
const groupStatCellKey = `${groupRow.groupId}:${groupRow.fieldId}`;
|
|
9505
|
+
const originGroupStatContainerWidth = groupStatContainerWidthMap.get(groupStatCellKey);
|
|
9506
|
+
// 计算新的宽度
|
|
9507
|
+
const groupStatContainerWidth = renderTexts ? bgConfigWidth : 0;
|
|
9508
|
+
// 只有当值发生变化时才更新
|
|
9509
|
+
if (originGroupStatContainerWidth !== groupStatContainerWidth) {
|
|
9510
|
+
if (groupStatContainerWidth > 0) {
|
|
9511
|
+
groupStatContainerWidthMap.set(groupStatCellKey, groupStatContainerWidth);
|
|
9512
|
+
}
|
|
9513
|
+
else {
|
|
9514
|
+
groupStatContainerWidthMap.delete(groupStatCellKey);
|
|
9515
|
+
}
|
|
9516
|
+
aiTable.context?.groupStatContainerWidthMap.set(groupStatContainerWidthMap);
|
|
9517
|
+
}
|
|
9518
|
+
}
|
|
9519
|
+
});
|
|
9520
|
+
});
|
|
9508
9521
|
}
|
|
9509
9522
|
onHoverChange(isHover) {
|
|
9510
9523
|
this.isHover.set(isHover);
|
|
@@ -9608,7 +9621,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
9608
9621
|
imports: [KoContainer, AITableTextComponent, AITableIcon, AITableBackground],
|
|
9609
9622
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
9610
9623
|
}]
|
|
9611
|
-
}] });
|
|
9624
|
+
}], ctorParameters: () => [] });
|
|
9612
9625
|
|
|
9613
9626
|
class AITableGroups {
|
|
9614
9627
|
constructor() {
|
|
@@ -10832,11 +10845,16 @@ class AITableCellText extends CoverCellBase {
|
|
|
10832
10845
|
const { columnWidth } = render;
|
|
10833
10846
|
if (isExpand) {
|
|
10834
10847
|
return {
|
|
10848
|
+
name: generateTargetName({
|
|
10849
|
+
targetName: AI_TABLE_CELL,
|
|
10850
|
+
fieldId: field._id,
|
|
10851
|
+
recordId
|
|
10852
|
+
}),
|
|
10835
10853
|
width: columnWidth - AI_TABLE_CELL_BORDER / 2,
|
|
10836
10854
|
height: this.height(),
|
|
10837
10855
|
stroke: Colors.primary,
|
|
10838
10856
|
strokeWidth: 2,
|
|
10839
|
-
listening:
|
|
10857
|
+
listening: true
|
|
10840
10858
|
};
|
|
10841
10859
|
}
|
|
10842
10860
|
return null;
|
|
@@ -12752,12 +12770,7 @@ class AITableDragComponent {
|
|
|
12752
12770
|
this.setAuxiliaryLineStyles({
|
|
12753
12771
|
left: `${nextColumnStartX - scrollPosition.x}px`
|
|
12754
12772
|
});
|
|
12755
|
-
this.
|
|
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
|
-
};
|
|
12773
|
+
this.setMovingFieldDragData(DragType.field, drag.sourceIds, targetColumnIndex + 1);
|
|
12761
12774
|
return;
|
|
12762
12775
|
}
|
|
12763
12776
|
}
|
|
@@ -12767,16 +12780,7 @@ class AITableDragComponent {
|
|
|
12767
12780
|
top: 0,
|
|
12768
12781
|
left: `${lineLeft}px`
|
|
12769
12782
|
});
|
|
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
|
-
};
|
|
12783
|
+
this.setMovingFieldDragData(DragType.field, drag.sourceIds, targetColumnIndex);
|
|
12780
12784
|
}
|
|
12781
12785
|
else {
|
|
12782
12786
|
this.resetAuxiliaryLine();
|
|
@@ -12956,6 +12960,24 @@ class AITableDragComponent {
|
|
|
12956
12960
|
}
|
|
12957
12961
|
}
|
|
12958
12962
|
}
|
|
12963
|
+
setMovingFieldDragData(type, sourceIds, targetIndex) {
|
|
12964
|
+
const aiTable = this.aiTableGridEventService.aiTable;
|
|
12965
|
+
const fields = aiTable.gridData().fields;
|
|
12966
|
+
this.draggedData = {
|
|
12967
|
+
type,
|
|
12968
|
+
fieldIds: sourceIds,
|
|
12969
|
+
targetIndex
|
|
12970
|
+
};
|
|
12971
|
+
if (targetIndex === 0) {
|
|
12972
|
+
this.draggedData.beforeFieldId = fields[0]._id;
|
|
12973
|
+
}
|
|
12974
|
+
else if (targetIndex >= fields.length) {
|
|
12975
|
+
this.draggedData.afterFieldId = fields[fields.length - 1]._id;
|
|
12976
|
+
}
|
|
12977
|
+
else {
|
|
12978
|
+
this.draggedData.afterFieldId = fields[targetIndex - 1]._id;
|
|
12979
|
+
}
|
|
12980
|
+
}
|
|
12959
12981
|
handleDragEnd() {
|
|
12960
12982
|
if (this.draggedData) {
|
|
12961
12983
|
this.dragEnd.emit({ ...this.draggedData });
|
|
@@ -13237,6 +13259,8 @@ class AITableGrid extends AITableGridBase {
|
|
|
13237
13259
|
this.bindGlobalMousedown();
|
|
13238
13260
|
this.containerResizeListener();
|
|
13239
13261
|
this.bindShortcuts();
|
|
13262
|
+
this.subscribeCopyEvent();
|
|
13263
|
+
this.subscribePasteEvent();
|
|
13240
13264
|
});
|
|
13241
13265
|
effect(() => {
|
|
13242
13266
|
if (this.hasContainerRect() && this.horizontalBarRef() && this.verticalBarRef()) {
|
|
@@ -13728,6 +13752,30 @@ class AITableGrid extends AITableGridBase {
|
|
|
13728
13752
|
clearCoverCell(this.aiTable);
|
|
13729
13753
|
});
|
|
13730
13754
|
}
|
|
13755
|
+
subscribeCopyEvent() {
|
|
13756
|
+
fromEvent(document, 'copy')
|
|
13757
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
13758
|
+
.subscribe((event) => {
|
|
13759
|
+
if (this.aiReadonly()) {
|
|
13760
|
+
return;
|
|
13761
|
+
}
|
|
13762
|
+
const dataTransfer = event.clipboardData;
|
|
13763
|
+
this.copyCells(dataTransfer);
|
|
13764
|
+
event.preventDefault();
|
|
13765
|
+
});
|
|
13766
|
+
}
|
|
13767
|
+
subscribePasteEvent() {
|
|
13768
|
+
fromEvent(document, 'paste')
|
|
13769
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
13770
|
+
.subscribe((event) => {
|
|
13771
|
+
if (this.aiReadonly()) {
|
|
13772
|
+
return;
|
|
13773
|
+
}
|
|
13774
|
+
const dataTransfer = event.clipboardData;
|
|
13775
|
+
this.pasteCells(dataTransfer);
|
|
13776
|
+
event.preventDefault();
|
|
13777
|
+
});
|
|
13778
|
+
}
|
|
13731
13779
|
updateDragSelectState(isDragging, startCell) {
|
|
13732
13780
|
this.dragSelectState = {
|
|
13733
13781
|
isDragging: isDragging,
|
|
@@ -13844,7 +13892,6 @@ class AITableGrid extends AITableGridBase {
|
|
|
13844
13892
|
if (hasContentEditable) {
|
|
13845
13893
|
return;
|
|
13846
13894
|
}
|
|
13847
|
-
const isCopyOrPaste = (event.ctrlKey || event.metaKey) && (event.key === 'c' || event.key === 'v');
|
|
13848
13895
|
const isDeleteOrBackspace = event.key === 'Backspace' || event.key === 'Delete';
|
|
13849
13896
|
const isDirectionKey = event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight';
|
|
13850
13897
|
const isShiftDirectionKey = event.shiftKey &&
|
|
@@ -13887,16 +13934,6 @@ class AITableGrid extends AITableGridBase {
|
|
|
13887
13934
|
event.preventDefault();
|
|
13888
13935
|
return;
|
|
13889
13936
|
}
|
|
13890
|
-
if (isCopyOrPaste) {
|
|
13891
|
-
if (event.key === 'c') {
|
|
13892
|
-
this.copyCells();
|
|
13893
|
-
}
|
|
13894
|
-
else if (event.key === 'v') {
|
|
13895
|
-
this.pasteCells();
|
|
13896
|
-
}
|
|
13897
|
-
event.preventDefault();
|
|
13898
|
-
return;
|
|
13899
|
-
}
|
|
13900
13937
|
if (isDeleteOrBackspace) {
|
|
13901
13938
|
clearCells(this.aiTable, this.actions);
|
|
13902
13939
|
event.preventDefault();
|
|
@@ -13924,10 +13961,10 @@ class AITableGrid extends AITableGridBase {
|
|
|
13924
13961
|
}
|
|
13925
13962
|
});
|
|
13926
13963
|
}
|
|
13927
|
-
copyCells() {
|
|
13964
|
+
copyCells(dataTransfer) {
|
|
13928
13965
|
const clipboardData = buildClipboardData(this.aiTable);
|
|
13929
13966
|
if (clipboardData) {
|
|
13930
|
-
writeToClipboard(clipboardData).then(() => {
|
|
13967
|
+
writeToClipboard(clipboardData, dataTransfer).then(() => {
|
|
13931
13968
|
const copiedCellsCount = this.aiTable.selection().selectedCells.size;
|
|
13932
13969
|
const message = getI18nTextByKey(this.aiTable, AITableGridI18nKey.copiedCells).replace('{count}', copiedCellsCount.toString());
|
|
13933
13970
|
this.notifyService.success(message, undefined, {
|
|
@@ -13936,8 +13973,8 @@ class AITableGrid extends AITableGridBase {
|
|
|
13936
13973
|
});
|
|
13937
13974
|
}
|
|
13938
13975
|
}
|
|
13939
|
-
pasteCells() {
|
|
13940
|
-
writeToAITable(this.aiTable, this.actions).then((result) => {
|
|
13976
|
+
pasteCells(dataTransfer) {
|
|
13977
|
+
writeToAITable(this.aiTable, this.actions, dataTransfer).then((result) => {
|
|
13941
13978
|
if (result.isPasteOverMaxRecords || result.isPasteOverMaxFields) {
|
|
13942
13979
|
return;
|
|
13943
13980
|
}
|
|
@@ -13978,13 +14015,12 @@ class AITableGrid extends AITableGridBase {
|
|
|
13978
14015
|
dragEnd(data) {
|
|
13979
14016
|
switch (data.type) {
|
|
13980
14017
|
case DragType.field:
|
|
13981
|
-
if (data.
|
|
13982
|
-
|
|
13983
|
-
|
|
13984
|
-
|
|
13985
|
-
|
|
13986
|
-
|
|
13987
|
-
}
|
|
14018
|
+
if (data.fieldIds && (data.beforeFieldId || data.afterFieldId)) {
|
|
14019
|
+
this.aiMoveField.emit({
|
|
14020
|
+
fieldIds: Array.from(data.fieldIds),
|
|
14021
|
+
beforeFieldId: data.beforeFieldId,
|
|
14022
|
+
afterFieldId: data.afterFieldId
|
|
14023
|
+
});
|
|
13988
14024
|
}
|
|
13989
14025
|
break;
|
|
13990
14026
|
case DragType.columnWidth:
|