@ai-table/grid 0.0.48 → 0.0.49
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 +3 -0
- package/components/drag/drag.component.d.ts.map +1 -1
- package/core/coordinate.d.ts.map +1 -1
- package/esm2022/components/drag/drag.component.mjs +35 -3
- package/esm2022/core/coordinate.mjs +3 -3
- package/esm2022/grid.component.mjs +22 -26
- package/esm2022/renderer/components/add-field-column.component.mjs +5 -2
- package/esm2022/renderer/creations/create-cells.mjs +2 -2
- package/esm2022/utils/style.mjs +5 -2
- package/fesm2022/ai-table-grid.mjs +66 -32
- package/fesm2022/ai-table-grid.mjs.map +1 -1
- package/grid.component.d.ts +1 -0
- package/grid.component.d.ts.map +1 -1
- package/package.json +1 -1
- package/renderer/components/add-field-column.component.d.ts.map +1 -1
- package/utils/style.d.ts +1 -1
- package/utils/style.d.ts.map +1 -1
package/esm2022/utils/style.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AI_TABLE_FIELD_ADD_BUTTON, AI_TABLE_FIELD_HEAD_MORE, AI_TABLE_FIELD_HEAD_OPACITY_LINE, AI_TABLE_FIELD_HEAD_SELECT_CHECKBOX, AI_TABLE_ROW_ADD_BUTTON, AI_TABLE_ROW_SELECT_CHECKBOX } from '../constants';
|
2
2
|
import { AITableAreaType } from '../types';
|
3
3
|
import { getDetailByTargetName } from './common';
|
4
|
-
export const handleMouseStyle = (realTargetName, areaType = AITableAreaType.grid, container) => {
|
4
|
+
export const handleMouseStyle = (realTargetName, areaType = AITableAreaType.grid, container, isReadOnly) => {
|
5
5
|
const { targetName, mouseStyle } = getDetailByTargetName(realTargetName);
|
6
6
|
if (mouseStyle)
|
7
7
|
return setMouseStyle(mouseStyle, container);
|
@@ -16,6 +16,9 @@ export const handleMouseStyle = (realTargetName, areaType = AITableAreaType.grid
|
|
16
16
|
return setMouseStyle('pointer', container);
|
17
17
|
}
|
18
18
|
case AI_TABLE_FIELD_HEAD_OPACITY_LINE: {
|
19
|
+
if (isReadOnly) {
|
20
|
+
return setMouseStyle('default', container);
|
21
|
+
}
|
19
22
|
return setMouseStyle('col-resize', container);
|
20
23
|
}
|
21
24
|
default:
|
@@ -25,4 +28,4 @@ export const handleMouseStyle = (realTargetName, areaType = AITableAreaType.grid
|
|
25
28
|
export const setMouseStyle = (mouseStyle, container) => {
|
26
29
|
container.style.cursor = mouseStyle;
|
27
30
|
};
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3R5bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wYWNrYWdlcy9ncmlkL3NyYy91dGlscy9zdHlsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0gseUJBQXlCLEVBQ3pCLHdCQUF3QixFQUN4QixnQ0FBZ0MsRUFDaEMsbUNBQW1DLEVBQ25DLHVCQUF1QixFQUN2Qiw0QkFBNEIsRUFDL0IsTUFBTSxjQUFjLENBQUM7QUFDdEIsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLFVBQVUsQ0FBQztBQUMzQyxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxVQUFVLENBQUM7QUFFakQsTUFBTSxDQUFDLE1BQU0sZ0JBQWdCLEdBQUcsQ0FDNUIsY0FBc0IsRUFDdEIsV0FBNEIsZUFBZSxDQUFDLElBQUksRUFDaEQsU0FBeUIsRUFDekIsVUFBb0IsRUFDdEIsRUFBRTtJQUNBLE1BQU0sRUFBRSxVQUFVLEVBQUUsVUFBVSxFQUFFLEdBQUcscUJBQXFCLENBQUMsY0FBYyxDQUFDLENBQUM7SUFDekUsSUFBSSxVQUFVO1FBQUUsT0FBTyxhQUFhLENBQUMsVUFBVSxFQUFFLFNBQVMsQ0FBQyxDQUFD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T1g6XG4gICAgICAgIGNhc2UgQUlfVEFCTEVfUk9XX0FERF9CVVRUT046XG4gICAgICAgIGNhc2UgQUlfVEFCTEVfRklFTERfQUREX0JVVFRPTjoge1xuICAgICAgICAgICAgcmV0dXJuIHNldE1vdXNlU3R5bGUoJ3BvaW50ZXInLCBjb250YWluZXIpO1xuICAgICAgICB9XG4gICAgICAgIGNhc2UgQUlfVEFCTEVfRklFTERfSEVBRF9PUEFDSVRZX0xJTkU6IHtcbiAgICAgICAgICAgIGlmIChpc1JlYWRPbmx5KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHNldE1vdXNlU3R5bGUoJ2RlZmF1bHQnLCBjb250YWluZXIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHNldE1vdXNlU3R5bGUoJ2NvbC1yZXNpemUnLCBjb250YWluZXIpO1xuICAgICAgICB9XG5cbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIHJldHVybiBzZXRNb3VzZVN0eWxlKCdkZWZhdWx0JywgY29udGFpbmVyKTtcbiAgICB9XG59O1xuXG5leHBvcnQgY29uc3Qgc2V0TW91c2VTdHlsZSA9IChtb3VzZVN0eWxlOiBzdHJpbmcsIGNvbnRhaW5lcjogSFRNTERpdkVsZW1lbnQpID0+IHtcbiAgICBjb250YWluZXIuc3R5bGUuY3Vyc29yID0gbW91c2VTdHlsZTtcbn07XG4iXX0=
|
@@ -956,7 +956,7 @@ class Coordinate {
|
|
956
956
|
* 根据 columnIndex 获取对应列宽
|
957
957
|
*/
|
958
958
|
getColumnWidth(index) {
|
959
|
-
return this.columnIndicesSizeMap[index];
|
959
|
+
return this.columnIndicesSizeMap[index] ?? 0;
|
960
960
|
}
|
961
961
|
/**
|
962
962
|
* 获取每个 cell 垂直/水平方向的坐标信息
|
@@ -980,7 +980,7 @@ class Coordinate {
|
|
980
980
|
offset = itemMetadata.offset + itemMetadata.size;
|
981
981
|
}
|
982
982
|
for (let i = lastMeasuredIndex + 1; i <= index; i++) {
|
983
|
-
const size = isColumnType ? this.columnIndicesSizeMap[i] : (this.rowIndicesSizeMap[i] ?? this.rowHeight);
|
983
|
+
const size = isColumnType ? (this.columnIndicesSizeMap[i] ?? 0) : (this.rowIndicesSizeMap[i] ?? this.rowHeight);
|
984
984
|
cellMetadataMap[i] = {
|
985
985
|
offset,
|
986
986
|
size
|
@@ -4211,7 +4211,7 @@ const getHoverEditorBoxOffset = () => {
|
|
4211
4211
|
return borderSpace / 2;
|
4212
4212
|
};
|
4213
4213
|
|
4214
|
-
const handleMouseStyle = (realTargetName, areaType = AITableAreaType.grid, container) => {
|
4214
|
+
const handleMouseStyle = (realTargetName, areaType = AITableAreaType.grid, container, isReadOnly) => {
|
4215
4215
|
const { targetName, mouseStyle } = getDetailByTargetName(realTargetName);
|
4216
4216
|
if (mouseStyle)
|
4217
4217
|
return setMouseStyle(mouseStyle, container);
|
@@ -4226,6 +4226,9 @@ const handleMouseStyle = (realTargetName, areaType = AITableAreaType.grid, conta
|
|
4226
4226
|
return setMouseStyle('pointer', container);
|
4227
4227
|
}
|
4228
4228
|
case AI_TABLE_FIELD_HEAD_OPACITY_LINE: {
|
4229
|
+
if (isReadOnly) {
|
4230
|
+
return setMouseStyle('default', container);
|
4231
|
+
}
|
4229
4232
|
return setMouseStyle('col-resize', container);
|
4230
4233
|
}
|
4231
4234
|
default:
|
@@ -6775,10 +6778,13 @@ class AITableAddField {
|
|
6775
6778
|
this.rectConfig = computed(() => {
|
6776
6779
|
const { pointPosition: { targetName }, readonly } = this.config();
|
6777
6780
|
const fill = targetName === AI_TABLE_FIELD_ADD_BUTTON ? Colors.gray80 : Colors.white;
|
6781
|
+
const fields = this.config().fields || [];
|
6782
|
+
const index = this.config().columnStopIndex;
|
6783
|
+
const fieldId = fields.length && index < fields.length ? fields[index]._id : '';
|
6778
6784
|
return {
|
6779
6785
|
name: generateTargetName({
|
6780
6786
|
targetName: AI_TABLE_FIELD_ADD_BUTTON,
|
6781
|
-
fieldId
|
6787
|
+
fieldId,
|
6782
6788
|
mouseStyle: readonly ? 'default' : 'pointer'
|
6783
6789
|
}),
|
6784
6790
|
x: AI_TABLE_OFFSET,
|
@@ -7813,7 +7819,7 @@ const createCells = (config) => {
|
|
7813
7819
|
// 获取该列对应的宽度
|
7814
7820
|
const columnWidth = coordinate.getColumnWidth(columnIndex);
|
7815
7821
|
const x = coordinate.getColumnOffset(columnIndex) + AI_TABLE_OFFSET;
|
7816
|
-
const isLastColumn = columnIndex === aiTable.fields
|
7822
|
+
const isLastColumn = columnIndex === aiTable.gridData().fields?.length - 1;
|
7817
7823
|
if (columnIndex === 1) {
|
7818
7824
|
cellDrawer.initStyle(field, { fontWeight: DEFAULT_FONT_STYLE });
|
7819
7825
|
}
|
@@ -8996,6 +9002,8 @@ class AITableDragComponent {
|
|
8996
9002
|
this.draggedData = null;
|
8997
9003
|
this.mouseStartPosition = null;
|
8998
9004
|
this.aiTableDrag = null;
|
9005
|
+
this.mouseDownTimeout = null;
|
9006
|
+
this.isDraggingEnabled = false;
|
8999
9007
|
effect(() => this.handleDragStateChange());
|
9000
9008
|
}
|
9001
9009
|
ngOnInit() {
|
@@ -9009,8 +9017,18 @@ class AITableDragComponent {
|
|
9009
9017
|
setupEventListeners() {
|
9010
9018
|
this.mousedownListener = this.render2.listen('window', 'mousedown', (e) => {
|
9011
9019
|
this.mouseStartPosition = { x: e.x, y: e.y };
|
9020
|
+
if (this.mouseDownTimeout) {
|
9021
|
+
clearTimeout(this.mouseDownTimeout);
|
9022
|
+
}
|
9023
|
+
this.isDraggingEnabled = false;
|
9024
|
+
this.mouseDownTimeout = setTimeout(() => {
|
9025
|
+
this.isDraggingEnabled = true;
|
9026
|
+
}, 200);
|
9012
9027
|
});
|
9013
9028
|
this.mousemoveListener = this.render2.listen('window', 'mousemove', (e) => {
|
9029
|
+
if (!this.isDraggingEnabled) {
|
9030
|
+
return;
|
9031
|
+
}
|
9014
9032
|
if (this.timer) {
|
9015
9033
|
cancelAnimationFrame(this.timer);
|
9016
9034
|
}
|
@@ -9021,6 +9039,11 @@ class AITableDragComponent {
|
|
9021
9039
|
});
|
9022
9040
|
});
|
9023
9041
|
this.mouseupListener = this.render2.listen('window', 'mouseup', () => {
|
9042
|
+
if (this.mouseDownTimeout) {
|
9043
|
+
clearTimeout(this.mouseDownTimeout);
|
9044
|
+
this.mouseDownTimeout = null;
|
9045
|
+
}
|
9046
|
+
this.isDraggingEnabled = false;
|
9024
9047
|
this.mouseStartPosition = null;
|
9025
9048
|
this.aiTableDrag = null;
|
9026
9049
|
this.handleDragEnd();
|
@@ -9135,11 +9158,26 @@ class AITableDragComponent {
|
|
9135
9158
|
};
|
9136
9159
|
}
|
9137
9160
|
handleDragEnd() {
|
9138
|
-
this.setDisplayStyle('none');
|
9139
9161
|
if (this.draggedData) {
|
9140
9162
|
this.dragEnd.emit({ ...this.draggedData });
|
9141
|
-
this.draggedData = null;
|
9142
9163
|
}
|
9164
|
+
this.clearDragState();
|
9165
|
+
}
|
9166
|
+
clearDragState() {
|
9167
|
+
this.setDisplayStyle('none');
|
9168
|
+
this.setRectStyles({
|
9169
|
+
width: '0',
|
9170
|
+
height: '0',
|
9171
|
+
top: '0',
|
9172
|
+
left: '0'
|
9173
|
+
});
|
9174
|
+
this.setAuxiliaryLineStyles({
|
9175
|
+
width: '0',
|
9176
|
+
height: '0',
|
9177
|
+
top: '0',
|
9178
|
+
left: '0'
|
9179
|
+
});
|
9180
|
+
this.draggedData = null;
|
9143
9181
|
}
|
9144
9182
|
calculateDragWidth(fields, coordinate, drag) {
|
9145
9183
|
let width = 0;
|
@@ -9373,7 +9411,7 @@ class AITableGrid extends AITableGridBase {
|
|
9373
9411
|
const { context } = this.aiTable;
|
9374
9412
|
const { x, y } = pos;
|
9375
9413
|
const curMousePosition = getMousePosition(this.aiTable, x, y, this.coordinate(), AITable.getVisibleFields(this.aiTable), context, targetName);
|
9376
|
-
handleMouseStyle(curMousePosition.realTargetName, curMousePosition.areaType, this.containerElement());
|
9414
|
+
handleMouseStyle(curMousePosition.realTargetName, curMousePosition.areaType, this.containerElement(), this.aiReadonly());
|
9377
9415
|
context.setPointPosition(curMousePosition);
|
9378
9416
|
this.timer = null;
|
9379
9417
|
if (this.isDragSelecting) {
|
@@ -9410,12 +9448,7 @@ class AITableGrid extends AITableGridBase {
|
|
9410
9448
|
mouseEvent.preventDefault();
|
9411
9449
|
if (!fieldId)
|
9412
9450
|
return;
|
9413
|
-
this.
|
9414
|
-
type: DragType.columnWidth,
|
9415
|
-
sourceIds: new Set([fieldId]),
|
9416
|
-
scroll: this.getScrollPosition(),
|
9417
|
-
coordinate: this.coordinate()
|
9418
|
-
});
|
9451
|
+
this.handleFieldWidthDragStart(fieldId);
|
9419
9452
|
return;
|
9420
9453
|
case AI_TABLE_CELL:
|
9421
9454
|
if (!recordId || !fieldId)
|
@@ -9467,6 +9500,11 @@ class AITableGrid extends AITableGridBase {
|
|
9467
9500
|
});
|
9468
9501
|
}
|
9469
9502
|
stageClick(e) {
|
9503
|
+
const targetNameDetail = getDetailByTargetName(e.event.target.name());
|
9504
|
+
this.aiClick.emit({
|
9505
|
+
...e,
|
9506
|
+
targetNameDetail
|
9507
|
+
});
|
9470
9508
|
const mouseEvent = e.event.evt;
|
9471
9509
|
mouseEvent.preventDefault();
|
9472
9510
|
this.aiTableGridEventService.closeCellEditor();
|
@@ -9528,23 +9566,15 @@ class AITableGrid extends AITableGridBase {
|
|
9528
9566
|
}
|
9529
9567
|
break;
|
9530
9568
|
}
|
9531
|
-
const targetNameDetail = getDetailByTargetName(e.event.target.name());
|
9532
|
-
this.aiClick.emit({
|
9533
|
-
...e,
|
9534
|
-
targetNameDetail
|
9535
|
-
});
|
9536
9569
|
return;
|
9537
9570
|
}
|
9538
9571
|
stageDblclick(e) {
|
9539
9572
|
const _targetName = e.event.target.name();
|
9540
9573
|
const targetNameDetail = getDetailByTargetName(_targetName);
|
9541
|
-
|
9542
|
-
|
9543
|
-
|
9544
|
-
|
9545
|
-
});
|
9546
|
-
return;
|
9547
|
-
}
|
9574
|
+
this.aiDbClick.emit({
|
9575
|
+
...e,
|
9576
|
+
targetNameDetail
|
9577
|
+
});
|
9548
9578
|
const { fieldId, recordId } = targetNameDetail;
|
9549
9579
|
if (!recordId || !fieldId) {
|
9550
9580
|
return;
|
@@ -9566,12 +9596,6 @@ class AITableGrid extends AITableGridBase {
|
|
9566
9596
|
});
|
9567
9597
|
}, 0);
|
9568
9598
|
}
|
9569
|
-
else {
|
9570
|
-
this.aiDbClick.emit({
|
9571
|
-
...e,
|
9572
|
-
targetNameDetail
|
9573
|
-
});
|
9574
|
-
}
|
9575
9599
|
}
|
9576
9600
|
bindWheel() {
|
9577
9601
|
fromEvent(this.containerElement(), 'wheel', { passive: false })
|
@@ -9739,6 +9763,16 @@ class AITableGrid extends AITableGridBase {
|
|
9739
9763
|
});
|
9740
9764
|
}
|
9741
9765
|
}
|
9766
|
+
handleFieldWidthDragStart(fieldId) {
|
9767
|
+
if (!this.aiReadonly() && fieldId) {
|
9768
|
+
this.aiTableGridSelectionService.drag({
|
9769
|
+
type: DragType.columnWidth,
|
9770
|
+
sourceIds: new Set([fieldId]),
|
9771
|
+
scroll: this.getScrollPosition(),
|
9772
|
+
coordinate: this.coordinate()
|
9773
|
+
});
|
9774
|
+
}
|
9775
|
+
}
|
9742
9776
|
getScrollPosition() {
|
9743
9777
|
const horizontalBar = this.horizontalBarRef()?.nativeElement;
|
9744
9778
|
const verticalBar = this.verticalBarRef()?.nativeElement;
|