@kdcloudjs/table 1.2.1-canary.7-hotfix.1 → 1.2.2-canary.11
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/LICENSE +568 -568
- package/README.md +111 -111
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.css.map +0 -0
- package/dist/@kdcloudjs/table.js +4095 -2984
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +12 -10
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/dist/default-theme.js +0 -0
- package/dist/kd-ui-complete.less +777 -777
- package/dist/kd-ui.less +0 -0
- package/dist/theme.js +0 -0
- package/es/_utils/formatUtil.js +1 -5
- package/es/_utils/hooks.js +3 -3
- package/es/_utils/usePopper.js +13 -13
- package/es/locale/locale.js +6 -7
- package/es/style/color/colors.less +1 -1
- package/es/style/core/index.less +1 -1
- package/es/style/core/motion/other.less +27 -27
- package/es/style/core/motion/slide.less +53 -53
- package/es/style/core/motion.less +1 -1
- package/es/style/core/reset.less +185 -185
- package/es/style/index.less +1 -1
- package/es/style/mixins/index.less +18 -18
- package/es/style/mixins/overlay.less +21 -21
- package/es/style/mixins/reset.less +12 -12
- package/es/style/themes/default.less +445 -445
- package/es/table/base/calculations.js +3 -3
- package/es/table/base/empty.js +2 -2
- package/es/table/base/globalStyleComponent.d.ts +4 -0
- package/es/table/base/globalStyleComponent.js +24 -0
- package/es/table/base/header.js +5 -7
- package/es/table/base/helpers/SpanManager.js +1 -2
- package/es/table/base/helpers/TableDOMUtils.js +5 -6
- package/es/table/base/html-table.js +3 -4
- package/es/table/base/loading.js +2 -2
- package/es/table/base/renderTemplates.js +16 -16
- package/es/table/base/styles.d.ts +11 -0
- package/es/table/base/styles.js +18 -7
- package/es/table/base/table.js +18 -20
- package/es/table/base/utils.js +3 -3
- package/es/table/interfaces.d.ts +41 -0
- package/es/table/pipeline/const.d.ts +3 -0
- package/es/table/pipeline/const.js +3 -0
- package/es/table/pipeline/features/columnDrag.js +0 -1
- package/es/table/pipeline/features/columnFilter.js +1 -3
- package/es/table/pipeline/features/columnResizeWidth.js +2 -2
- package/es/table/pipeline/features/contextMenu.js +4 -6
- package/es/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
- package/es/table/pipeline/features/featureApi/RowDragApi.js +66 -0
- package/es/table/pipeline/features/featureApi/utils.d.ts +2 -0
- package/es/table/pipeline/features/featureApi/utils.js +10 -0
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +4 -5
- package/es/table/pipeline/features/filter/Filter.js +2 -3
- package/es/table/pipeline/features/rangeSelection.js +10 -10
- package/es/table/pipeline/features/rowDetail.js +2 -2
- package/es/table/pipeline/features/rowDrag.d.ts +12 -12
- package/es/table/pipeline/features/rowDrag.js +605 -192
- package/es/table/pipeline/features/rowGrouping.js +2 -2
- package/es/table/pipeline/features/sort.js +6 -7
- package/es/table/pipeline/features/tips.js +4 -4
- package/es/table/pipeline/features/treeMode.d.ts +1 -0
- package/es/table/pipeline/features/treeMode.js +39 -12
- package/es/table/pipeline/features/treeSelect.js +2 -2
- package/es/table/pipeline/pipeline.d.ts +3 -0
- package/es/table/pipeline/pipeline.js +24 -3
- package/es/table/pivot/cross-table/buildCrossTable.js +6 -8
- package/es/table/pivot/cross-table/cross-table.js +1 -3
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +8 -10
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +8 -11
- package/es/table/pivot/pivot-utils/builders.js +3 -3
- package/es/table/pivot/pivot-utils/convert-utils.js +3 -3
- package/es/table/style/index.less +1 -1
- package/es/table/transforms/autoWidth.js +3 -3
- package/es/table/transforms/columnResize.js +3 -5
- package/es/table/transforms/sort.js +6 -8
- package/es/table/transforms/tips.js +4 -4
- package/es/table/transforms/treeMode.js +6 -8
- package/es/table/utils/buildTree.js +3 -3
- package/es/table/utils/collectNodes.js +3 -3
- package/es/table/utils/exportTableAsExcel.js +3 -3
- package/es/table/utils/getTreeDepth.js +3 -3
- package/es/table/utils/groupBy.js +3 -3
- package/es/table/utils/makeRecursiveMapper.js +3 -3
- package/es/table/utils/mergeCellProps.js +0 -1
- package/es/table/utils/others.js +3 -3
- package/es/table/utils/traverseColumn.js +3 -3
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +7 -8
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +4 -5
- package/lib/_utils/arrayUtil.js +2 -3
- package/lib/_utils/formatUtil.js +1 -5
- package/lib/_utils/hooks.js +3 -3
- package/lib/_utils/index.js +2 -3
- package/lib/_utils/type.js +3 -5
- package/lib/_utils/usePopper.js +18 -21
- package/lib/config-provider/ConfigContext.js +1 -2
- package/lib/config-provider/compDefaultProps.js +1 -2
- package/lib/config-provider/configProvider.js +3 -4
- package/lib/config-provider/defaultConfig.js +1 -2
- package/lib/config-provider/index.js +1 -2
- package/lib/locale/index.js +3 -4
- package/lib/locale/locale.js +10 -14
- package/lib/locale/zh-CN.js +1 -2
- package/lib/style/color/colors.less +2 -0
- package/lib/style/components.less +1 -1
- package/lib/style/core/index.less +2 -0
- package/lib/style/core/motion/other.less +28 -0
- package/lib/style/core/motion/slide.less +53 -0
- package/lib/style/core/motion.less +2 -0
- package/lib/style/core/reset.less +186 -0
- package/lib/style/index.css +410 -0
- package/lib/style/index.less +2 -0
- package/lib/style/mixins/index.less +19 -0
- package/lib/style/mixins/overlay.less +22 -0
- package/lib/style/mixins/reset.less +13 -0
- package/lib/style/themes/default.less +445 -0
- package/lib/style/themes/index.less +1 -0
- package/lib/table/base/calculations.js +3 -3
- package/lib/table/base/empty.js +4 -4
- package/lib/table/base/globalStyleComponent.d.ts +4 -0
- package/lib/table/base/globalStyleComponent.js +35 -0
- package/lib/table/base/header.js +5 -7
- package/lib/table/base/helpers/SpanManager.js +3 -5
- package/lib/table/base/helpers/TableDOMUtils.js +7 -9
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +2 -2
- package/lib/table/base/html-table.js +3 -4
- package/lib/table/base/loading.js +2 -2
- package/lib/table/base/renderTemplates.js +18 -18
- package/lib/table/base/styles.d.ts +11 -0
- package/lib/table/base/styles.js +25 -21
- package/lib/table/base/table.js +30 -31
- package/lib/table/base/utils.js +13 -20
- package/lib/table/common-views.js +4 -8
- package/lib/table/interfaces.d.ts +41 -0
- package/lib/table/internals.js +2 -3
- package/lib/table/pipeline/const.d.ts +3 -0
- package/lib/table/pipeline/const.js +9 -0
- package/lib/table/pipeline/features/autoFill.js +3 -6
- package/lib/table/pipeline/features/colGroupExtendable.js +2 -3
- package/lib/table/pipeline/features/columnDrag.js +0 -1
- package/lib/table/pipeline/features/columnFilter.js +1 -3
- package/lib/table/pipeline/features/columnResizeWidth.js +7 -10
- package/lib/table/pipeline/features/contextMenu.js +6 -8
- package/lib/table/pipeline/features/featureApi/RowDragApi.d.ts +15 -0
- package/lib/table/pipeline/features/featureApi/RowDragApi.js +72 -0
- package/lib/table/pipeline/features/featureApi/utils.d.ts +2 -0
- package/lib/table/pipeline/features/featureApi/utils.js +17 -0
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +7 -9
- package/lib/table/pipeline/features/filter/Filter.js +5 -7
- package/lib/table/pipeline/features/filter/FilterPanel.js +3 -4
- package/lib/table/pipeline/features/filter/util.js +2 -3
- package/lib/table/pipeline/features/footerDataSource.js +1 -2
- package/lib/table/pipeline/features/rangeSelection.js +12 -14
- package/lib/table/pipeline/features/rowDetail.js +2 -2
- package/lib/table/pipeline/features/rowDrag.d.ts +12 -12
- package/lib/table/pipeline/features/rowDrag.js +608 -197
- package/lib/table/pipeline/features/rowGrouping.js +2 -2
- package/lib/table/pipeline/features/sort.js +6 -7
- package/lib/table/pipeline/features/tips.js +4 -4
- package/lib/table/pipeline/features/treeMode.d.ts +1 -0
- package/lib/table/pipeline/features/treeMode.js +41 -14
- package/lib/table/pipeline/features/treeSelect.js +2 -2
- package/lib/table/pipeline/index.js +2 -2
- package/lib/table/pipeline/pipeline.d.ts +3 -0
- package/lib/table/pipeline/pipeline.js +25 -5
- package/lib/table/pivot/cross-table/buildCrossTable.js +6 -8
- package/lib/table/pivot/cross-table/constants.js +1 -2
- package/lib/table/pivot/cross-table/cross-table.js +3 -6
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +8 -10
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +9 -13
- package/lib/table/pivot/pivot-utils/builders.js +3 -3
- package/lib/table/pivot/pivot-utils/convert-utils.js +3 -3
- package/lib/table/style/index.css +0 -0
- package/lib/table/style/index.less +1 -0
- package/lib/table/transforms/autoWidth.js +5 -5
- package/lib/table/transforms/columnResize.js +5 -7
- package/lib/table/transforms/sort.js +8 -10
- package/lib/table/transforms/tips.js +4 -4
- package/lib/table/transforms/treeMode.js +8 -10
- package/lib/table/use/useResizeObserver.js +1 -2
- package/lib/table/utils/browserType.js +2 -4
- package/lib/table/utils/buildTree.js +3 -3
- package/lib/table/utils/collectNodes.js +3 -3
- package/lib/table/utils/console.js +2 -3
- package/lib/table/utils/copyToClipboard.js +1 -2
- package/lib/table/utils/exportTableAsExcel.js +3 -3
- package/lib/table/utils/getTreeDepth.js +3 -3
- package/lib/table/utils/groupBy.js +3 -3
- package/lib/table/utils/keyCode.js +1 -2
- package/lib/table/utils/makeRecursiveMapper.js +3 -3
- package/lib/table/utils/mergeCellProps.js +0 -1
- package/lib/table/utils/others.js +4 -5
- package/lib/table/utils/proto.js +1 -2
- package/lib/table/utils/selectColumn.js +2 -4
- package/lib/table/utils/traverseColumn.js +3 -3
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +9 -11
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +6 -8
- package/package.json +218 -219
|
@@ -8,20 +8,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
});
|
|
9
9
|
exports.ROW_DRAG_COLUMN_CODE = void 0;
|
|
10
10
|
exports.rowDrag = rowDrag;
|
|
11
|
-
exports.rowDragKey = void 0;
|
|
11
|
+
exports.rowDragOptionsKey = exports.rowDragKey = void 0;
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
13
|
-
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
14
13
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
14
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
15
|
+
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
16
|
+
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
15
17
|
var _react = _interopRequireDefault(require("react"));
|
|
16
18
|
var _rxjs = require("rxjs");
|
|
17
19
|
var _operators = require("rxjs/operators");
|
|
18
20
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
21
|
var _styles = require("../../base/styles");
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
exports.rowDragKey = rowDragKey;
|
|
22
|
+
var _const = require("../const");
|
|
23
|
+
var _internals = require("../../internals");
|
|
24
|
+
var ROW_DRAG_COLUMN_CODE = exports.ROW_DRAG_COLUMN_CODE = '$_row_drag_column_&';
|
|
25
|
+
var rowDragKey = exports.rowDragKey = 'rowDragKey';
|
|
26
|
+
var rowDragOptionsKey = exports.rowDragOptionsKey = 'rowDragOptions';
|
|
24
27
|
var SCROLL_OFFSET = 30;
|
|
28
|
+
var SCROLL_START_OFFSET = 20;
|
|
25
29
|
var defaultRowDragColumn = {
|
|
26
30
|
name: '拖拽列',
|
|
27
31
|
code: ROW_DRAG_COLUMN_CODE,
|
|
@@ -53,163 +57,305 @@ function rowDrag(opt) {
|
|
|
53
57
|
var _context;
|
|
54
58
|
var tableBody = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.tableBody;
|
|
55
59
|
var artTable = pipeline.ref.current.domHelper && pipeline.ref.current.domHelper.artTable;
|
|
60
|
+
var rowDragApi = pipeline.addFeatureApi(_const.FeatureName.rowDrag);
|
|
61
|
+
pipeline.setFeatureOptions(rowDragOptionsKey, opt);
|
|
56
62
|
if (!tableBody) return pipeline;
|
|
57
63
|
var dataSource = pipeline.getDataSource();
|
|
58
|
-
var
|
|
59
|
-
|
|
64
|
+
var getRowDragEvent = function getRowDragEvent(dropTargetEvent, isFinished) {
|
|
65
|
+
var dragItem = dropTargetEvent.dragItem,
|
|
66
|
+
x = dropTargetEvent.x,
|
|
67
|
+
y = dropTargetEvent.y,
|
|
68
|
+
dropZoneTarget = dropTargetEvent.dropZoneTarget,
|
|
69
|
+
startDropZoneTagret = dropTargetEvent.startDropZoneTagret,
|
|
70
|
+
commonParams = dropTargetEvent.commonParams,
|
|
71
|
+
startCommonParams = dropTargetEvent.startCommonParams,
|
|
72
|
+
event = dropTargetEvent.event,
|
|
73
|
+
dropZoneTableParams = dropTargetEvent.dropZoneTableParams;
|
|
74
|
+
var getDataSource = dropZoneTableParams.getDataSource,
|
|
75
|
+
getTreeModeOptions = dropZoneTableParams.getTreeModeOptions,
|
|
76
|
+
getRowDragOptions = dropZoneTableParams.getRowDragOptions;
|
|
77
|
+
var dataSource = getDataSource();
|
|
78
|
+
var treeModeOptions = getTreeModeOptions();
|
|
79
|
+
var rowDragOptions = getRowDragOptions();
|
|
80
|
+
var allowDragIntoRow = !!treeModeOptions && (rowDragOptions === null || rowDragOptions === void 0 ? void 0 : rowDragOptions.allowDragIntoRow);
|
|
81
|
+
var isLeave = !isMouseOnDropTarget(event, dropZoneTarget);
|
|
82
|
+
var overIndex = -1;
|
|
83
|
+
var direction = 'bottom';
|
|
84
|
+
if (!isLeave && dataSource.length > 0) {
|
|
85
|
+
var overDragItem = getDragRowItem(event.target, dropZoneTarget, dataSource);
|
|
86
|
+
if (overDragItem) {
|
|
87
|
+
var rowIndex = overDragItem.rowIndex,
|
|
88
|
+
cell = overDragItem.cell;
|
|
89
|
+
overIndex = rowIndex;
|
|
90
|
+
direction = getDirection(cell, event.clientY, allowDragIntoRow);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (overIndex === -1 && dataSource.length > 0 && dropZoneTarget.contains(event.target)) {
|
|
94
|
+
overIndex = dataSource.length - 1;
|
|
95
|
+
direction = 'bottom';
|
|
96
|
+
}
|
|
97
|
+
var overRow = overIndex >= 0 ? dataSource[overIndex] : null;
|
|
98
|
+
return {
|
|
99
|
+
startRowIndex: dragItem.rowIndex,
|
|
100
|
+
startRow: dragItem.row,
|
|
101
|
+
endRowIndex: overIndex,
|
|
102
|
+
endRow: overRow,
|
|
103
|
+
startDropZoneTagret: startDropZoneTagret,
|
|
104
|
+
startCommonParams: startCommonParams,
|
|
105
|
+
commonParams: commonParams,
|
|
106
|
+
dropZoneTarget: dropZoneTarget,
|
|
107
|
+
event: event,
|
|
108
|
+
dragPosition: direction,
|
|
109
|
+
isFinished: isFinished,
|
|
110
|
+
x: x,
|
|
111
|
+
y: y
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
var onDragging = function onDragging(event) {
|
|
60
115
|
var _a;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
116
|
+
var rowDragEvent = getRowDragEvent(event, false);
|
|
117
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragMove) === null || _a === void 0 ? void 0 : _a.call(opt, rowDragEvent);
|
|
118
|
+
pipeline.setStateAtKey(rowDragKey, rowDragEvent);
|
|
64
119
|
};
|
|
65
|
-
var
|
|
120
|
+
var onDragStop = function onDragStop(event) {
|
|
66
121
|
var _a;
|
|
67
|
-
|
|
68
|
-
pipeline.setStateAtKey(rowDragKey,
|
|
122
|
+
var rowDragEvent = getRowDragEvent(event, true);
|
|
123
|
+
pipeline.setStateAtKey(rowDragKey, rowDragEvent);
|
|
124
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(opt, rowDragEvent);
|
|
69
125
|
};
|
|
70
|
-
var
|
|
126
|
+
var onDragStart = function onDragStart(event) {
|
|
71
127
|
var _a;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// 超出拖拽范围不触发dragend事件
|
|
75
|
-
if (isValid) {
|
|
76
|
-
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(opt, event);
|
|
77
|
-
}
|
|
128
|
+
var rowDragEvent = getRowDragEvent(event, false);
|
|
129
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragStart) === null || _a === void 0 ? void 0 : _a.call(opt, rowDragEvent);
|
|
78
130
|
};
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
startRowIndex: startRowInfo.rowIndex,
|
|
85
|
-
startRow: startRowInfo.row,
|
|
86
|
-
endRowIndex: endRowInfo.rowIndex,
|
|
87
|
-
endRow: endRowInfo.row,
|
|
88
|
-
dragPosition: dragPosition,
|
|
89
|
-
isFinished: isFinished
|
|
90
|
-
};
|
|
131
|
+
var onDragLeave = function onDragLeave(event) {
|
|
132
|
+
var _a;
|
|
133
|
+
var rowDragEvent = getRowDragEvent(event, false);
|
|
134
|
+
pipeline.setStateAtKey(rowDragKey, rowDragEvent);
|
|
135
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragLeave) === null || _a === void 0 ? void 0 : _a.call(opt, rowDragEvent);
|
|
91
136
|
};
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
var
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
137
|
+
var onDragEnter = function onDragEnter(event) {
|
|
138
|
+
var _a;
|
|
139
|
+
var rowDragEvent = getRowDragEvent(event, false);
|
|
140
|
+
pipeline.setStateAtKey(rowDragKey, rowDragEvent);
|
|
141
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(opt, rowDragEvent);
|
|
142
|
+
};
|
|
143
|
+
var currentDropZone = {
|
|
144
|
+
getContainer: function getContainer() {
|
|
145
|
+
var lastPipeline = pipeline.getLastPipeline();
|
|
146
|
+
return lastPipeline.ref.current.domHelper.tableBody;
|
|
147
|
+
},
|
|
148
|
+
onDragEnter: onDragEnter,
|
|
149
|
+
onDragLeave: onDragLeave,
|
|
150
|
+
onDragging: onDragging,
|
|
151
|
+
onDragStop: onDragStop,
|
|
152
|
+
isTable: true,
|
|
153
|
+
tableParams: {
|
|
154
|
+
getDataSource: function getDataSource() {
|
|
155
|
+
var lastPipeline = pipeline.getLastPipeline();
|
|
156
|
+
return lastPipeline.getDataSource();
|
|
157
|
+
},
|
|
158
|
+
getTreeModeOptions: function getTreeModeOptions() {
|
|
159
|
+
var lastPipeline = pipeline.getLastPipeline();
|
|
160
|
+
return lastPipeline.getFeatureOptions('treeModeOptions');
|
|
161
|
+
},
|
|
162
|
+
getRowDragOptions: function getRowDragOptions() {
|
|
163
|
+
var lastPipeline = pipeline.getLastPipeline();
|
|
164
|
+
return lastPipeline.getFeatureOptions('rowDragOptions');
|
|
165
|
+
}
|
|
103
166
|
}
|
|
104
167
|
};
|
|
105
|
-
var onMouseDown = function onMouseDown(
|
|
168
|
+
var onMouseDown = function onMouseDown(event) {
|
|
106
169
|
var _a;
|
|
107
|
-
var
|
|
108
|
-
var
|
|
109
|
-
if (!
|
|
110
|
-
if ((_a = opt === null || opt === void 0 ? void 0 : opt.isDisabled) === null || _a === void 0 ? void 0 : _a.call(opt,
|
|
111
|
-
// 默认拖拽插入的位置是向下
|
|
112
|
-
var dragPosition = 'bottom';
|
|
113
|
-
var isOutOfRange = false;
|
|
170
|
+
var mouseDownEvent = event.nativeEvent;
|
|
171
|
+
var startDataItem = getDragRowItem(mouseDownEvent.target, tableBody, dataSource);
|
|
172
|
+
if (!startDataItem || startDataItem.code !== rowDragColumn.code) return;
|
|
173
|
+
if ((_a = opt === null || opt === void 0 ? void 0 : opt.isDisabled) === null || _a === void 0 ? void 0 : _a.call(opt, startDataItem.row, startDataItem.rowIndex)) return;
|
|
114
174
|
var isValidDrag = false;
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
175
|
+
var isDragging = false;
|
|
176
|
+
var dragElement = null;
|
|
177
|
+
var dragLine = null;
|
|
178
|
+
var lastDropTarget = null;
|
|
179
|
+
var timeoutId = null;
|
|
180
|
+
var intervalId = null;
|
|
181
|
+
var expandRowTimeoutId = null;
|
|
182
|
+
var expandRowCallBackList = [];
|
|
183
|
+
var updateScrollPosition = function updateScrollPosition(tableBody, mouseMoveEvent) {
|
|
184
|
+
if (opt === null || opt === void 0 ? void 0 : opt.suppressScrollMove) return;
|
|
185
|
+
if (timeoutId) {
|
|
186
|
+
clearTimeout(timeoutId);
|
|
187
|
+
}
|
|
188
|
+
if (intervalId) {
|
|
189
|
+
clearInterval(intervalId);
|
|
190
|
+
}
|
|
191
|
+
if (!tableBody) return;
|
|
192
|
+
var moveOffset = getScrollMoveOffset(tableBody, mouseMoveEvent);
|
|
193
|
+
if (moveOffset === 0) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
timeoutId = setTimeout(function () {
|
|
197
|
+
intervalId = setInterval(function () {
|
|
198
|
+
tableBody.scrollTop += moveOffset;
|
|
199
|
+
}, 50);
|
|
200
|
+
}, 500);
|
|
134
201
|
};
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
202
|
+
var handleDragStart = function handleDragStart(mouseDownEvent) {
|
|
203
|
+
var _a;
|
|
204
|
+
dragElement = createDragElement(mouseDownEvent, tableBody); // 创建拖拽悬浮框
|
|
205
|
+
var isTreeTable = !!pipeline.getFeatureOptions('treeModeOptions');
|
|
206
|
+
dragLine = createDragLine(isTreeTable); // 创建拖拽插入指示线
|
|
207
|
+
var dragText = (opt === null || opt === void 0 ? void 0 : opt.rowDragText) ? (_a = opt === null || opt === void 0 ? void 0 : opt.rowDragText) === null || _a === void 0 ? void 0 : _a.call(opt, startDataItem.row, startDataItem.rowIndex) : "\u7B2C".concat(startDataItem.rowIndex, "\u884C\u5185\u5BB9");
|
|
208
|
+
setDragText(dragElement, dragText); // 设置悬浮框显示文本
|
|
209
|
+
artTable.classList.add((0, _classnames.default)(_styles.Classes.rowDragging));
|
|
210
|
+
rowDragApi.setDragStatus('start');
|
|
211
|
+
var dragEvent = createDropTargetEvent(currentDropZone, mouseDownEvent, startDataItem, currentDropZone);
|
|
212
|
+
onDragStart(dragEvent);
|
|
213
|
+
};
|
|
214
|
+
var handleDragMove = function handleDragMove(mouseMoveEvent) {
|
|
215
|
+
var _a;
|
|
216
|
+
positionDragElemment(dragElement, mouseMoveEvent); // 更新拖拽悬浮框位置
|
|
217
|
+
rowDragApi.setDragStatus('dragging');
|
|
218
|
+
setDragElementIcon(dragElement, 'move');
|
|
219
|
+
var rowDropZones = rowDragApi.getRowDropZone();
|
|
220
|
+
var validDropZones = (0, _concat.default)(rowDropZones).call(rowDropZones, currentDropZone); // 可放置区域加上自身
|
|
221
|
+
var dropTarget = (0, _find.default)(validDropZones).call(validDropZones, function (zone) {
|
|
222
|
+
return isMouseOnDropTarget(mouseMoveEvent, zone.getContainer());
|
|
223
|
+
}) || null;
|
|
224
|
+
updateScrollPosition(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.getContainer(), mouseMoveEvent); // 拖拽到底时让滚动条可以滚动
|
|
225
|
+
if (dropTarget !== lastDropTarget) {
|
|
226
|
+
// 拖拽离开表格
|
|
227
|
+
if (lastDropTarget !== null && dropTarget === null) {
|
|
228
|
+
if (lastDropTarget.onDragLeave) {
|
|
229
|
+
setDragElementIcon(dragElement, 'notAllowed');
|
|
230
|
+
hiddenDragLine(dragLine);
|
|
231
|
+
lastDropTarget.getContainer().classList.remove(_styles.Classes.rowDragNoData);
|
|
232
|
+
var dragEvent = createDropTargetEvent(lastDropTarget, mouseMoveEvent, startDataItem, currentDropZone);
|
|
233
|
+
lastDropTarget.onDragLeave(dragEvent);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// 拖拽进入表格
|
|
237
|
+
if (lastDropTarget === null && dropTarget !== null) {
|
|
238
|
+
if (dropTarget.onDragEnter) {
|
|
239
|
+
setDragElementIcon(dragElement, 'move');
|
|
240
|
+
if (dropTarget.isTable) {
|
|
241
|
+
showDragLine(dragLine);
|
|
242
|
+
var getTreeModeOptions = dropTarget.tableParams.getTreeModeOptions;
|
|
243
|
+
var treeModeOptions = getTreeModeOptions();
|
|
244
|
+
var isTreeTable = !!treeModeOptions;
|
|
245
|
+
// 判断拖拽进入的表格是否是树形表格,控制指示线样式
|
|
246
|
+
if (isTreeTable) {
|
|
247
|
+
dragLine.classList.add(_styles.Classes.treeTableRowDragLine);
|
|
248
|
+
} else {
|
|
249
|
+
dragLine.classList.remove(_styles.Classes.treeTableRowDragLine);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
var _dragEvent = createDropTargetEvent(dropTarget, mouseMoveEvent, startDataItem, currentDropZone);
|
|
253
|
+
dropTarget.onDragEnter(_dragEvent);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
lastDropTarget = dropTarget;
|
|
257
|
+
}
|
|
258
|
+
if (dropTarget) {
|
|
259
|
+
// 拖拽区域在表格中,更新拖拽插入指示线位置
|
|
260
|
+
if (dropTarget.isTable) {
|
|
261
|
+
positionDragLine({
|
|
262
|
+
lineElement: dragLine,
|
|
263
|
+
dragZone: dropTarget,
|
|
264
|
+
event: mouseMoveEvent
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
// 树形表格悬停1s展开对应行节点
|
|
268
|
+
if ((_a = dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.tableParams) === null || _a === void 0 ? void 0 : _a.getTreeModeOptions()) {
|
|
269
|
+
if (expandRowTimeoutId) {
|
|
270
|
+
clearTimeout(expandRowTimeoutId);
|
|
271
|
+
}
|
|
272
|
+
expandRowTimeoutId = setTimeout(function () {
|
|
273
|
+
var treeModeOptions = dropTarget.tableParams.getTreeModeOptions();
|
|
274
|
+
var treeMetaKey = treeModeOptions.treeMetaKey,
|
|
275
|
+
onExpand = treeModeOptions.onExpand,
|
|
276
|
+
isExpanded = treeModeOptions.isExpanded,
|
|
277
|
+
onCollapse = treeModeOptions.onCollapse;
|
|
278
|
+
// 鼠标悬停所在的拖拽行信息
|
|
279
|
+
var dataSource = dropTarget.tableParams.getDataSource();
|
|
280
|
+
var dragItem = getDragRowItem(mouseMoveEvent.target, dropTarget.getContainer(), dataSource);
|
|
281
|
+
if (!dragItem) return;
|
|
282
|
+
var row = dragItem.row;
|
|
283
|
+
var _row$treeMetaKey = row[treeMetaKey],
|
|
284
|
+
rowKey = _row$treeMetaKey.rowKey,
|
|
285
|
+
isLeaf = _row$treeMetaKey.isLeaf;
|
|
286
|
+
if (!isLeaf && !isExpanded(rowKey)) {
|
|
287
|
+
onExpand(rowKey);
|
|
288
|
+
expandRowCallBackList.push(function () {
|
|
289
|
+
return onCollapse(rowKey);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}, 1000);
|
|
293
|
+
}
|
|
294
|
+
if (dropTarget.onDragging) {
|
|
295
|
+
var _dragEvent2 = createDropTargetEvent(dropTarget, mouseMoveEvent, startDataItem, currentDropZone);
|
|
296
|
+
dropTarget.onDragging(_dragEvent2);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
var handleDragStop = function handleDragStop(mouseUpEvent) {
|
|
301
|
+
if (!isValidDrag) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
removeElement(dragElement);
|
|
305
|
+
removeElement(dragLine);
|
|
306
|
+
artTable.classList.remove((0, _classnames.default)(_styles.Classes.rowDragging));
|
|
307
|
+
rowDragApi.setDragStatus('finished');
|
|
308
|
+
clearTimeout(timeoutId);
|
|
309
|
+
clearInterval(intervalId);
|
|
310
|
+
clearTimeout(expandRowTimeoutId);
|
|
311
|
+
var rowDropZones = rowDragApi.getRowDropZone();
|
|
312
|
+
rowDropZones.forEach(function (dropzone) {
|
|
313
|
+
var container = dropzone.getContainer();
|
|
314
|
+
container && container.classList.remove(_styles.Classes.rowDragNoData);
|
|
315
|
+
});
|
|
316
|
+
var validDropZones = (0, _concat.default)(rowDropZones).call(rowDropZones, currentDropZone);
|
|
317
|
+
var dropTarget = (0, _find.default)(validDropZones).call(validDropZones, function (zone) {
|
|
318
|
+
return isMouseOnDropTarget(mouseUpEvent, zone.getContainer());
|
|
143
319
|
});
|
|
144
|
-
|
|
145
|
-
|
|
320
|
+
if (dropTarget && dropTarget.onDragStop) {
|
|
321
|
+
var dragEvent = createDropTargetEvent(dropTarget, mouseUpEvent, startDataItem, currentDropZone);
|
|
322
|
+
dropTarget.onDragStop(dragEvent);
|
|
323
|
+
}
|
|
324
|
+
while (expandRowCallBackList.length > 0) {
|
|
325
|
+
var callback = expandRowCallBackList.pop();
|
|
326
|
+
callback();
|
|
327
|
+
}
|
|
146
328
|
};
|
|
147
|
-
|
|
148
|
-
var
|
|
329
|
+
var mousemove$ = (0, _rxjs.fromEvent)(window, 'mousemove');
|
|
330
|
+
var mouseup$ = (0, _rxjs.fromEvent)(window, 'mouseup');
|
|
331
|
+
var rowDragMove$ = mousemove$.pipe((0, _filterInstanceProperty(_operators))(function (mouseMoveEvent) {
|
|
149
332
|
var mouseMoveClientY = mouseMoveEvent.clientY;
|
|
333
|
+
var mouseDownClientY = mouseDownEvent.clientY;
|
|
150
334
|
// 上下移动偏移量大于5才是有效的拖拽
|
|
151
335
|
if (Math.abs(mouseMoveClientY - mouseDownClientY) > 5) {
|
|
152
336
|
isValidDrag = true;
|
|
153
337
|
}
|
|
154
338
|
return isValidDrag;
|
|
155
339
|
}), (0, _mapInstanceProperty(_operators))(function (mouseMoveEvent) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
endRowInfo = tagretRow;
|
|
340
|
+
if (!isDragging) {
|
|
341
|
+
isDragging = true;
|
|
342
|
+
handleDragStart(mouseDownEvent);
|
|
343
|
+
handleDragMove(mouseDownEvent);
|
|
161
344
|
}
|
|
162
|
-
|
|
163
|
-
// 判断拖拽插入的位置,拖拽框上边框位于目标行之上则向上插入,否则向下插入
|
|
164
|
-
var isMoveToTop = clientY - startOffset < targetRowRects.top;
|
|
165
|
-
dragPosition = isMoveToTop ? 'top' : 'bottom';
|
|
166
|
-
isOutOfRange = isOutOfDragRange({
|
|
167
|
-
x: clientX,
|
|
168
|
-
y: clientY
|
|
169
|
-
}, dragRange);
|
|
170
|
-
mousePosition = {
|
|
171
|
-
x: clientX,
|
|
172
|
-
y: clientY
|
|
173
|
-
};
|
|
174
|
-
updateScrollPosition(mouseMoveEvent); // 拖拽到底时让滚动条可以滚动
|
|
175
|
-
updateDragElementPosition(dragElement, dragRange, {
|
|
176
|
-
x: clientX,
|
|
177
|
-
y: clientY,
|
|
178
|
-
startOffset: startOffset
|
|
179
|
-
});
|
|
180
|
-
updateCurSorStyle(isOutOfRange);
|
|
181
|
-
return {
|
|
182
|
-
startRowInfo: startRowInfo,
|
|
183
|
-
endRowInfo: endRowInfo,
|
|
184
|
-
dragPosition: dragPosition
|
|
185
|
-
};
|
|
345
|
+
handleDragMove(mouseMoveEvent);
|
|
186
346
|
}), (0, _operators.takeUntil)(mouseup$));
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
isFinished: false,
|
|
194
|
-
dragPosition: dragPosition
|
|
195
|
-
});
|
|
196
|
-
handleDragMove(dragMoveEvent);
|
|
197
|
-
},
|
|
198
|
-
complete: function complete() {
|
|
199
|
-
var dragEndEvent = getDragEvent(startRowInfo, endRowInfo, {
|
|
200
|
-
isFinished: true,
|
|
201
|
-
dragPosition: dragPosition
|
|
202
|
-
});
|
|
203
|
-
var isValid = isValidDrag && !isOutOfRange;
|
|
204
|
-
handleDragEnd(dragEndEvent, isValid);
|
|
205
|
-
removeDragElement(dragElement);
|
|
206
|
-
removeCurSorStyle();
|
|
207
|
-
document.removeEventListener('scroll', scrollCallback, true);
|
|
347
|
+
rowDragMove$.subscribe();
|
|
348
|
+
var rowDragEnd$ = mouseup$.pipe((0, _mapInstanceProperty(_operators))(function (mouseUpEvent) {
|
|
349
|
+
handleDragStop(mouseUpEvent);
|
|
350
|
+
})).subscribe({
|
|
351
|
+
next: function next() {
|
|
352
|
+
rowDragEnd$.unsubscribe();
|
|
208
353
|
}
|
|
209
354
|
});
|
|
210
355
|
};
|
|
211
356
|
var rowDragColumn = (opt === null || opt === void 0 ? void 0 : opt.rowDragColumn) || defaultRowDragColumn;
|
|
212
357
|
pipeline.setFeatureOptions('rowDragColumnKey', rowDragColumn.code);
|
|
358
|
+
rowDragApi.setRowDropZoneParams(currentDropZone);
|
|
213
359
|
var nextColumns = (0, _slice.default)(_context = pipeline.getColumns()).call(_context);
|
|
214
360
|
nextColumns.unshift(rowDragColumn);
|
|
215
361
|
pipeline.columns(nextColumns);
|
|
@@ -217,15 +363,28 @@ function rowDrag(opt) {
|
|
|
217
363
|
onMouseDown: onMouseDown
|
|
218
364
|
});
|
|
219
365
|
pipeline.appendRowPropsGetter(function (row, rowIndex) {
|
|
220
|
-
var _cx;
|
|
221
366
|
var rowDragEvent = pipeline.getStateAtKey(rowDragKey) || {};
|
|
367
|
+
var dragStatus = rowDragApi.getDragStatus();
|
|
222
368
|
var startRowIndex = rowDragEvent.startRowIndex,
|
|
223
369
|
endRowIndex = rowDragEvent.endRowIndex,
|
|
370
|
+
endRow = rowDragEvent.endRow,
|
|
224
371
|
isFinished = rowDragEvent.isFinished,
|
|
225
372
|
dragPosition = rowDragEvent.dragPosition;
|
|
226
373
|
var isFooterCell = row[pipeline.getFeatureOptions('footerRowMetaKey')];
|
|
227
|
-
|
|
228
|
-
var
|
|
374
|
+
var treeModeOptions = pipeline.getFeatureOptions('treeModeOptions');
|
|
375
|
+
var isTreeTable = !!treeModeOptions;
|
|
376
|
+
if (isFooterCell || isFinished || !isTreeTable && rowIndex !== startRowIndex && rowIndex !== endRowIndex) return;
|
|
377
|
+
var parentRowKeyIndex = -1;
|
|
378
|
+
if (isTreeTable && endRow) {
|
|
379
|
+
var _context2;
|
|
380
|
+
var treeMetaKey = treeModeOptions.treeMetaKey;
|
|
381
|
+
var parentRowKey = endRow[treeMetaKey].parentRowKey;
|
|
382
|
+
var primaryKey = pipeline.ensurePrimaryKey('rowDrag');
|
|
383
|
+
parentRowKeyIndex = (0, _findIndex.default)(_context2 = pipeline.getDataSource()).call(_context2, function (row) {
|
|
384
|
+
return _internals.internals.safeGetRowKey(primaryKey, row, -1) === parentRowKey;
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
var className = (0, _classnames.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _styles.Classes.rowDragStart, rowIndex === startRowIndex && dragStatus !== 'finished'), _styles.Classes.rowDragEnd, rowIndex === endRowIndex), _styles.Classes.rowDragEndParent, isTreeTable && rowIndex === parentRowKeyIndex && dragPosition !== 'into'), _styles.Classes.rowDragEndInto, rowIndex === endRowIndex && dragPosition === 'into'), _styles.Classes.rowDragEndToTop, rowIndex === endRowIndex && dragPosition === 'top'), _styles.Classes.rowDragEndToBottom, rowIndex === endRowIndex && dragPosition === 'bottom'));
|
|
229
388
|
return {
|
|
230
389
|
className: className
|
|
231
390
|
};
|
|
@@ -233,7 +392,7 @@ function rowDrag(opt) {
|
|
|
233
392
|
return pipeline;
|
|
234
393
|
};
|
|
235
394
|
}
|
|
236
|
-
function
|
|
395
|
+
function getDragRowItem(target, tableBody, record) {
|
|
237
396
|
while (target && tableBody.contains(target)) {
|
|
238
397
|
if (target.getAttribute('data-role') === 'table-cell') {
|
|
239
398
|
var code = target.getAttribute('data-code');
|
|
@@ -252,6 +411,15 @@ function getTargetRowInfo(target, tableBody, record) {
|
|
|
252
411
|
}
|
|
253
412
|
return null;
|
|
254
413
|
}
|
|
414
|
+
function findTargetRow(target, tableBody) {
|
|
415
|
+
while (target && tableBody.contains(target)) {
|
|
416
|
+
if (target.getAttribute('data-role') === 'table-row') {
|
|
417
|
+
return target;
|
|
418
|
+
}
|
|
419
|
+
target = target.parentElement;
|
|
420
|
+
}
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
255
423
|
function isEleInFooter(target) {
|
|
256
424
|
while (target && !target.classList.contains(_styles.Classes.artTable)) {
|
|
257
425
|
if (target.classList.contains(_styles.Classes.tableFooter)) {
|
|
@@ -261,75 +429,318 @@ function isEleInFooter(target) {
|
|
|
261
429
|
}
|
|
262
430
|
return false;
|
|
263
431
|
}
|
|
264
|
-
function createDragElement(
|
|
265
|
-
var
|
|
266
|
-
var
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
x: x,
|
|
280
|
-
y: y
|
|
281
|
-
}, dragRange);
|
|
282
|
-
element.style.top = validPosition.y - startOffset + 'px';
|
|
283
|
-
return element;
|
|
432
|
+
function createDragElement(mouseDownEvent, tableBody) {
|
|
433
|
+
var _context3, _context4;
|
|
434
|
+
var ELEMENT_TEMPLATE = (0, _concat.default)(_context3 = (0, _concat.default)(_context4 = "<div class='".concat(_styles.Classes.rowDragElement, "'>\n <span class='")).call(_context4, _styles.Classes.rowDragElementIcon, "'></span>\n <div class='")).call(_context3, _styles.Classes.rowDragElementLabel, "'></div>\n </div>");
|
|
435
|
+
var element = document.createElement('div');
|
|
436
|
+
element.innerHTML = ELEMENT_TEMPLATE;
|
|
437
|
+
var dragElement = element.firstChild;
|
|
438
|
+
var targetRow = findTargetRow(mouseDownEvent.target, tableBody);
|
|
439
|
+
if (targetRow) {
|
|
440
|
+
var rect = targetRow.getBoundingClientRect();
|
|
441
|
+
dragElement.style.height = rect.height + 'px';
|
|
442
|
+
}
|
|
443
|
+
var bodyRect = tableBody.getBoundingClientRect();
|
|
444
|
+
dragElement.style.maxWidth = bodyRect.width + 'px';
|
|
445
|
+
document.body.appendChild(dragElement);
|
|
446
|
+
return dragElement;
|
|
284
447
|
}
|
|
285
|
-
function
|
|
286
|
-
document.
|
|
448
|
+
function createDragLine(isTreeTable) {
|
|
449
|
+
var dragLine = document.createElement('div');
|
|
450
|
+
dragLine.classList.add(_styles.Classes.rowDragLine);
|
|
451
|
+
if (isTreeTable) {
|
|
452
|
+
dragLine.classList.add(_styles.Classes.treeTableRowDragLine);
|
|
453
|
+
}
|
|
454
|
+
document.body.appendChild(dragLine);
|
|
455
|
+
return dragLine;
|
|
287
456
|
}
|
|
288
|
-
function
|
|
289
|
-
|
|
290
|
-
|
|
457
|
+
function positionDragLine(_ref) {
|
|
458
|
+
var _context7;
|
|
459
|
+
var lineElement = _ref.lineElement,
|
|
460
|
+
dragZone = _ref.dragZone,
|
|
461
|
+
event = _ref.event;
|
|
462
|
+
var tableContainer = dragZone.getContainer();
|
|
463
|
+
var _dragZone$tableParams = dragZone.tableParams,
|
|
464
|
+
getDataSource = _dragZone$tableParams.getDataSource,
|
|
465
|
+
getTreeModeOptions = _dragZone$tableParams.getTreeModeOptions,
|
|
466
|
+
getRowDragOptions = _dragZone$tableParams.getRowDragOptions;
|
|
467
|
+
var dataSource = getDataSource();
|
|
468
|
+
var treeModeOptions = getTreeModeOptions();
|
|
469
|
+
var rowDragOptions = getRowDragOptions() || {};
|
|
470
|
+
var allowDragIntoRow = rowDragOptions.allowDragIntoRow;
|
|
471
|
+
var isTreeTable = !!treeModeOptions;
|
|
472
|
+
var bodyRect = tableContainer.getBoundingClientRect();
|
|
473
|
+
var offsetParentSize = getElementRectWithOffset(document.body);
|
|
474
|
+
if (dataSource.length === 0) {
|
|
475
|
+
tableContainer.classList.add(_styles.Classes.rowDragNoData);
|
|
476
|
+
lineElement.style.display = 'none';
|
|
291
477
|
} else {
|
|
292
|
-
|
|
478
|
+
tableContainer.classList.remove(_styles.Classes.rowDragNoData);
|
|
479
|
+
lineElement.style.display = 'block';
|
|
480
|
+
}
|
|
481
|
+
// 鼠标悬停所在的拖拽行信息
|
|
482
|
+
var dragItem = getDragRowItem(event.target, tableContainer, dataSource);
|
|
483
|
+
if (!dragItem) {
|
|
484
|
+
if (dataSource.length > 0 && tableContainer.contains(event.target)) {
|
|
485
|
+
var _context5, _context6;
|
|
486
|
+
var _rowIndex = dataSource.length - 1;
|
|
487
|
+
var _row = dataSource[_rowIndex];
|
|
488
|
+
var _direction = 'bottom';
|
|
489
|
+
var _targetCell = isTreeTable ? tableContainer.querySelector((0, _concat.default)(_context5 = "tr[data-rowindex=\"".concat(_rowIndex, "\"] .")).call(_context5, _styles.Classes.tableExtendCell)) : tableContainer.querySelector((0, _concat.default)(_context6 = "tr[data-rowindex=\"".concat(_rowIndex, "\"] .")).call(_context6, _styles.Classes.rowDragCell));
|
|
490
|
+
if (!_targetCell) return;
|
|
491
|
+
var _getLinePosition = getLinePosition({
|
|
492
|
+
treeModeOptions: treeModeOptions,
|
|
493
|
+
cell: _targetCell,
|
|
494
|
+
row: _row,
|
|
495
|
+
direction: _direction,
|
|
496
|
+
offsetParentSize: offsetParentSize,
|
|
497
|
+
bodyRect: bodyRect
|
|
498
|
+
}),
|
|
499
|
+
_top = _getLinePosition.top,
|
|
500
|
+
_left = _getLinePosition.left,
|
|
501
|
+
_width = _getLinePosition.width;
|
|
502
|
+
lineElement.style.left = "".concat(_left, "px");
|
|
503
|
+
lineElement.style.top = "".concat(_top, "px");
|
|
504
|
+
lineElement.style.width = "".concat(_width, "px");
|
|
505
|
+
}
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
var cell = dragItem.cell,
|
|
509
|
+
rowIndex = dragItem.rowIndex,
|
|
510
|
+
row = dragItem.row;
|
|
511
|
+
var allowDragInto = isTreeTable && allowDragIntoRow;
|
|
512
|
+
var direction = getDirection(cell, event.clientY, allowDragInto);
|
|
513
|
+
var targetCell = isTreeTable ? tableContainer.querySelector((0, _concat.default)(_context7 = "tr[data-rowindex=\"".concat(rowIndex, "\"] .")).call(_context7, _styles.Classes.tableExtendCell)) : cell;
|
|
514
|
+
if (!targetCell) return;
|
|
515
|
+
var _getLinePosition2 = getLinePosition({
|
|
516
|
+
treeModeOptions: treeModeOptions,
|
|
517
|
+
cell: targetCell,
|
|
518
|
+
row: row,
|
|
519
|
+
direction: direction,
|
|
520
|
+
offsetParentSize: offsetParentSize,
|
|
521
|
+
bodyRect: bodyRect
|
|
522
|
+
}),
|
|
523
|
+
top = _getLinePosition2.top,
|
|
524
|
+
left = _getLinePosition2.left,
|
|
525
|
+
width = _getLinePosition2.width;
|
|
526
|
+
lineElement.style.left = "".concat(left, "px");
|
|
527
|
+
lineElement.style.top = "".concat(top, "px");
|
|
528
|
+
lineElement.style.width = "".concat(width, "px");
|
|
529
|
+
if (direction === 'into') {
|
|
530
|
+
lineElement.style.display = 'none';
|
|
531
|
+
} else {
|
|
532
|
+
lineElement.style.display = 'block';
|
|
293
533
|
}
|
|
294
534
|
}
|
|
295
|
-
function
|
|
296
|
-
|
|
535
|
+
function showDragLine(lineElement) {
|
|
536
|
+
lineElement.style.display = 'block';
|
|
297
537
|
}
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
var
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
538
|
+
function hiddenDragLine(lineElement) {
|
|
539
|
+
lineElement.style.display = 'none';
|
|
540
|
+
}
|
|
541
|
+
function positionDragElemment(element, event) {
|
|
542
|
+
var _a, _b, _c, _d, _e, _f;
|
|
543
|
+
if (!element) return;
|
|
544
|
+
var elementRect = element.getBoundingClientRect();
|
|
545
|
+
var eleHeight = elementRect.height;
|
|
546
|
+
var browserWidth = (_b = (_a = document.body) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : window.innerHeight || ((_c = document.documentElement) === null || _c === void 0 ? void 0 : _c.clientWidth) || 0;
|
|
547
|
+
var browserHeight = (_e = (_d = document.body) === null || _d === void 0 ? void 0 : _d.clientHeight) !== null && _e !== void 0 ? _e : window.innerHeight || ((_f = document.documentElement) === null || _f === void 0 ? void 0 : _f.clientHeight) || 0;
|
|
548
|
+
var offsetParentSize = getElementRectWithOffset(element.offsetParent);
|
|
549
|
+
var clientX = event.clientX,
|
|
550
|
+
clientY = event.clientY;
|
|
551
|
+
var top = clientY - offsetParentSize.top - eleHeight / 2;
|
|
552
|
+
var left = clientX - offsetParentSize.left;
|
|
553
|
+
var windowScrollX = window.pageXOffset;
|
|
554
|
+
var windowScrollY = window.pageYOffset;
|
|
555
|
+
if (browserWidth > 0 && left + element.clientWidth > browserWidth + windowScrollX) {
|
|
556
|
+
left = Math.max(browserWidth + windowScrollX - element.clientWidth, 0);
|
|
557
|
+
}
|
|
558
|
+
if (browserHeight > 0 && top + element.clientHeight > browserHeight + windowScrollY) {
|
|
559
|
+
top = Math.max(browserHeight + windowScrollY - element.clientHeight, 0);
|
|
560
|
+
}
|
|
561
|
+
element.style.left = "".concat(left, "px");
|
|
562
|
+
element.style.top = "".concat(top, "px");
|
|
563
|
+
}
|
|
564
|
+
function getElementRectWithOffset(el) {
|
|
565
|
+
var offsetElementRect = el.getBoundingClientRect();
|
|
566
|
+
var _getElementSize2 = _getElementSize(el),
|
|
567
|
+
borderTopWidth = _getElementSize2.borderTopWidth,
|
|
568
|
+
borderLeftWidth = _getElementSize2.borderLeftWidth,
|
|
569
|
+
borderRightWidth = _getElementSize2.borderRightWidth,
|
|
570
|
+
borderBottomWidth = _getElementSize2.borderBottomWidth;
|
|
306
571
|
return {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
572
|
+
top: offsetElementRect.top + (borderTopWidth || 0),
|
|
573
|
+
left: offsetElementRect.left + (borderLeftWidth || 0),
|
|
574
|
+
right: offsetElementRect.right + (borderRightWidth || 0),
|
|
575
|
+
bottom: offsetElementRect.bottom + (borderBottomWidth || 0)
|
|
311
576
|
};
|
|
312
577
|
}
|
|
313
|
-
function
|
|
314
|
-
var
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
578
|
+
function _getElementSize(el) {
|
|
579
|
+
var _window$getComputedSt = window.getComputedStyle(el),
|
|
580
|
+
height = _window$getComputedSt.height,
|
|
581
|
+
width = _window$getComputedSt.width,
|
|
582
|
+
borderTopWidth = _window$getComputedSt.borderTopWidth,
|
|
583
|
+
borderRightWidth = _window$getComputedSt.borderRightWidth,
|
|
584
|
+
borderBottomWidth = _window$getComputedSt.borderBottomWidth,
|
|
585
|
+
borderLeftWidth = _window$getComputedSt.borderLeftWidth,
|
|
586
|
+
paddingTop = _window$getComputedSt.paddingTop,
|
|
587
|
+
paddingRight = _window$getComputedSt.paddingRight,
|
|
588
|
+
paddingBottom = _window$getComputedSt.paddingBottom,
|
|
589
|
+
paddingLeft = _window$getComputedSt.paddingLeft,
|
|
590
|
+
marginTop = _window$getComputedSt.marginTop,
|
|
591
|
+
marginRight = _window$getComputedSt.marginRight,
|
|
592
|
+
marginBottom = _window$getComputedSt.marginBottom,
|
|
593
|
+
marginLeft = _window$getComputedSt.marginLeft,
|
|
594
|
+
boxSizing = _window$getComputedSt.boxSizing;
|
|
322
595
|
return {
|
|
323
|
-
|
|
324
|
-
|
|
596
|
+
height: parseFloat(height || '0'),
|
|
597
|
+
width: parseFloat(width || '0'),
|
|
598
|
+
borderTopWidth: parseFloat(borderTopWidth || '0'),
|
|
599
|
+
borderRightWidth: parseFloat(borderRightWidth || '0'),
|
|
600
|
+
borderBottomWidth: parseFloat(borderBottomWidth || '0'),
|
|
601
|
+
borderLeftWidth: parseFloat(borderLeftWidth || '0'),
|
|
602
|
+
paddingTop: parseFloat(paddingTop || '0'),
|
|
603
|
+
paddingRight: parseFloat(paddingRight || '0'),
|
|
604
|
+
paddingBottom: parseFloat(paddingBottom || '0'),
|
|
605
|
+
paddingLeft: parseFloat(paddingLeft || '0'),
|
|
606
|
+
marginTop: parseFloat(marginTop || '0'),
|
|
607
|
+
marginRight: parseFloat(marginRight || '0'),
|
|
608
|
+
marginBottom: parseFloat(marginBottom || '0'),
|
|
609
|
+
marginLeft: parseFloat(marginLeft || '0'),
|
|
610
|
+
boxSizing: boxSizing
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function removeElement(element) {
|
|
614
|
+
document.body.removeChild(element);
|
|
615
|
+
}
|
|
616
|
+
function setDragElementIcon(element, iconName) {
|
|
617
|
+
var elementIcon = element.querySelector(".".concat(_styles.Classes.rowDragElementIcon));
|
|
618
|
+
clearElementChildren(elementIcon);
|
|
619
|
+
iconName = iconName || 'notAllowed';
|
|
620
|
+
var iconElement = document.createElement('span');
|
|
621
|
+
if (iconName === 'move') {
|
|
622
|
+
iconElement.classList.add(_styles.Classes.iconMove);
|
|
623
|
+
} else if (iconName === 'notAllowed') {
|
|
624
|
+
iconElement.classList.add(_styles.Classes.iconNotAllowed);
|
|
625
|
+
}
|
|
626
|
+
elementIcon.appendChild(iconElement);
|
|
627
|
+
}
|
|
628
|
+
function clearElementChildren(element) {
|
|
629
|
+
while (element && element.firstChild) {
|
|
630
|
+
element.removeChild(element.firstChild);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
function getScrollMoveOffset(tableBody, mouseMoveEvent) {
|
|
634
|
+
var clientY = mouseMoveEvent.clientY;
|
|
635
|
+
var tableBodyClientRect = tableBody.getBoundingClientRect();
|
|
636
|
+
var top = tableBodyClientRect.top,
|
|
637
|
+
height = tableBodyClientRect.height;
|
|
638
|
+
if (clientY >= top + height - SCROLL_START_OFFSET && clientY <= top + height) {
|
|
639
|
+
return SCROLL_OFFSET;
|
|
640
|
+
}
|
|
641
|
+
if (clientY >= top && clientY <= top + SCROLL_START_OFFSET) {
|
|
642
|
+
return -SCROLL_OFFSET;
|
|
643
|
+
}
|
|
644
|
+
return 0;
|
|
645
|
+
}
|
|
646
|
+
function setDragText(element, dragText) {
|
|
647
|
+
var dragTextString = dragText.toString();
|
|
648
|
+
var elementIcon = element.querySelector(".".concat(_styles.Classes.rowDragElementLabel));
|
|
649
|
+
var stringNode = document.createTextNode(dragTextString);
|
|
650
|
+
elementIcon.appendChild(stringNode);
|
|
651
|
+
}
|
|
652
|
+
function isMouseOnDropTarget(mouseEvent, target) {
|
|
653
|
+
return target.contains(mouseEvent.target);
|
|
654
|
+
}
|
|
655
|
+
function createDropTargetEvent(dropZone, event, dragItem, startDropZone) {
|
|
656
|
+
var dropZoneTarget = dropZone.getContainer();
|
|
657
|
+
var startDropZoneTagret = startDropZone.getContainer();
|
|
658
|
+
var rect = dropZoneTarget.getBoundingClientRect();
|
|
659
|
+
var x = event.clientX - rect.left;
|
|
660
|
+
var y = event.clientY - rect.top;
|
|
661
|
+
var startDropZoneOptions = startDropZone.tableParams.getRowDragOptions();
|
|
662
|
+
var startCommonParams = startDropZoneOptions === null || startDropZoneOptions === void 0 ? void 0 : startDropZoneOptions.commonParams;
|
|
663
|
+
var targetEvent = {
|
|
664
|
+
dragItem: dragItem,
|
|
665
|
+
startDropZoneTagret: startDropZoneTagret,
|
|
666
|
+
startCommonParams: startCommonParams,
|
|
667
|
+
dropZoneTarget: dropZoneTarget,
|
|
668
|
+
event: event,
|
|
669
|
+
x: x,
|
|
670
|
+
y: y
|
|
325
671
|
};
|
|
672
|
+
if (dropZone.isTable) {
|
|
673
|
+
var dropZoneOptions = dropZone.tableParams.getRowDragOptions();
|
|
674
|
+
var commonParams = dropZoneOptions === null || dropZoneOptions === void 0 ? void 0 : dropZoneOptions.commonParams;
|
|
675
|
+
targetEvent.dropZoneTableParams = dropZone.tableParams;
|
|
676
|
+
targetEvent.commonParams = commonParams;
|
|
677
|
+
}
|
|
678
|
+
return targetEvent;
|
|
679
|
+
}
|
|
680
|
+
function getDirection(cell, clientY) {
|
|
681
|
+
var isTreeTable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
682
|
+
var _cell$getBoundingClie = cell.getBoundingClientRect(),
|
|
683
|
+
height = _cell$getBoundingClie.height,
|
|
684
|
+
y = _cell$getBoundingClie.y;
|
|
685
|
+
var direction = 'bottom';
|
|
686
|
+
if (isTreeTable) {
|
|
687
|
+
if (y + height / 4 > clientY) {
|
|
688
|
+
direction = 'top';
|
|
689
|
+
} else if (y + height * 3 / 4 > clientY) {
|
|
690
|
+
direction = 'into';
|
|
691
|
+
}
|
|
692
|
+
} else if (y + height / 2 > clientY) {
|
|
693
|
+
direction = 'top';
|
|
694
|
+
}
|
|
695
|
+
return direction;
|
|
326
696
|
}
|
|
327
|
-
function
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
697
|
+
var getLinePosition = function getLinePosition(_ref2) {
|
|
698
|
+
var treeModeOptions = _ref2.treeModeOptions,
|
|
699
|
+
cell = _ref2.cell,
|
|
700
|
+
row = _ref2.row,
|
|
701
|
+
direction = _ref2.direction,
|
|
702
|
+
offsetParentSize = _ref2.offsetParentSize,
|
|
703
|
+
bodyRect = _ref2.bodyRect;
|
|
704
|
+
var isTreeTable = !!treeModeOptions;
|
|
705
|
+
if (isTreeTable) {
|
|
706
|
+
var iconWidth = treeModeOptions.iconWidth,
|
|
707
|
+
iconIndent = treeModeOptions.iconIndent,
|
|
708
|
+
iconGap = treeModeOptions.iconGap,
|
|
709
|
+
indentSize = treeModeOptions.indentSize,
|
|
710
|
+
treeMetaKey = treeModeOptions.treeMetaKey;
|
|
711
|
+
var _getElementSize3 = _getElementSize(cell),
|
|
712
|
+
paddingLeft = _getElementSize3.paddingLeft;
|
|
713
|
+
var expandCellRect = cell.getBoundingClientRect();
|
|
714
|
+
var _row$treeMetaKey2 = row[treeMetaKey],
|
|
715
|
+
rowKey = _row$treeMetaKey2.rowKey,
|
|
716
|
+
depth = _row$treeMetaKey2.depth,
|
|
717
|
+
isLeaf = _row$treeMetaKey2.isLeaf,
|
|
718
|
+
expanded = _row$treeMetaKey2.expanded;
|
|
719
|
+
var addWidth = isLeaf ? iconWidth + iconGap : 0;
|
|
720
|
+
var indent = iconIndent + depth * indentSize + addWidth;
|
|
721
|
+
var x = expandCellRect.x,
|
|
722
|
+
_y = expandCellRect.y,
|
|
723
|
+
_height = expandCellRect.height;
|
|
724
|
+
var _top2 = direction === 'bottom' ? _y + _height - offsetParentSize.top : _y - offsetParentSize.top;
|
|
725
|
+
var offsetX = Math.max(x + paddingLeft + indent - bodyRect.x, 0);
|
|
726
|
+
var _left2 = bodyRect.x + offsetX - offsetParentSize.left;
|
|
727
|
+
var _width2 = bodyRect.width - offsetX;
|
|
728
|
+
return {
|
|
729
|
+
top: _top2,
|
|
730
|
+
left: _left2,
|
|
731
|
+
width: _width2
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
// 根据鼠标悬停位置所在单元格和显示位置计算拖拽线的位置
|
|
735
|
+
var rect = cell.getBoundingClientRect();
|
|
736
|
+
var y = rect.y,
|
|
737
|
+
height = rect.height;
|
|
738
|
+
var top = direction === 'bottom' ? y + height - offsetParentSize.top : y - offsetParentSize.top;
|
|
739
|
+
var left = bodyRect.x - offsetParentSize.left;
|
|
740
|
+
var width = bodyRect.width;
|
|
741
|
+
return {
|
|
742
|
+
top: top,
|
|
743
|
+
left: left,
|
|
744
|
+
width: width
|
|
745
|
+
};
|
|
746
|
+
};
|