@kdcloudjs/table 1.2.0-canary.15 → 1.2.0-canary.16-hotfix
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/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +2051 -3489
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +16 -16
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/_utils/arrayUtil.js +0 -3
- package/es/_utils/devwarning.js +0 -1
- package/es/_utils/formatUtil.js +35 -96
- package/es/_utils/hooks.js +18 -42
- package/es/_utils/index.js +0 -2
- package/es/_utils/numberUtil.js +32 -55
- package/es/_utils/omit.js +0 -2
- package/es/_utils/type.js +0 -2
- package/es/_utils/usePopper.js +74 -137
- package/es/config-provider/compDefaultProps.js +0 -1
- package/es/config-provider/configProvider.js +2 -7
- package/es/config-provider/defaultConfig.js +0 -1
- package/es/index.js +0 -2
- package/es/locale/locale.js +5 -43
- package/es/table/base/calculations.js +22 -72
- package/es/table/base/colgroup.js +0 -1
- package/es/table/base/empty.js +4 -4
- package/es/table/base/header.js +14 -67
- package/es/table/base/helpers/SpanManager.js +3 -9
- package/es/table/base/helpers/TableDOMUtils.js +4 -27
- package/es/table/base/helpers/__test__/SpanManager.test.js +2 -2
- package/es/table/base/helpers/__test__/TableDOMUtils.test.js +0 -1
- package/es/table/base/helpers/getRichVisibleRectsStream.js +11 -44
- package/es/table/base/helpers/rowHeightManager.js +0 -28
- package/es/table/base/html-table.js +14 -35
- package/es/table/base/loading.js +6 -8
- package/es/table/base/renderTemplates.js +26 -44
- package/es/table/base/styles.js +1 -10
- package/es/table/base/table.js +96 -179
- package/es/table/base/utils.js +14 -54
- package/es/table/common-views.js +0 -7
- package/es/table/internals.js +0 -13
- package/es/table/pipeline/features/autoFill.js +11 -40
- package/es/table/pipeline/features/autoRowSpan.js +1 -14
- package/es/table/pipeline/features/colGroupExtendable.js +4 -19
- package/es/table/pipeline/features/columnDrag.d.ts +1 -0
- package/es/table/pipeline/features/columnDrag.js +236 -303
- package/es/table/pipeline/features/columnFilter.js +11 -48
- package/es/table/pipeline/features/columnHover.js +1 -7
- package/es/table/pipeline/features/columnRangeHover.js +1 -8
- package/es/table/pipeline/features/columnResizeWidth.js +51 -42
- package/es/table/pipeline/features/contextMenu.js +18 -89
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +10 -25
- package/es/table/pipeline/features/filter/DefaultFilterIcon.js +1 -1
- package/es/table/pipeline/features/filter/Filter.js +25 -48
- package/es/table/pipeline/features/filter/FilterPanel.js +11 -25
- package/es/table/pipeline/features/filter/util.js +0 -4
- package/es/table/pipeline/features/footerDataSource.js +0 -3
- package/es/table/pipeline/features/mergeCellHover.js +0 -1
- package/es/table/pipeline/features/multiSelect.js +15 -57
- package/es/table/pipeline/features/rangeSelection.js +65 -143
- package/es/table/pipeline/features/rowDetail.js +2 -41
- package/es/table/pipeline/features/rowDrag.js +36 -71
- package/es/table/pipeline/features/rowGrouping.js +2 -35
- package/es/table/pipeline/features/singleSelect.js +0 -24
- package/es/table/pipeline/features/sort.js +31 -83
- package/es/table/pipeline/features/tips.js +0 -6
- package/es/table/pipeline/features/treeMode.js +9 -44
- package/es/table/pipeline/features/treeSelect.js +0 -26
- package/es/table/pipeline/features/utils/touchEventUtils.d.ts +15 -0
- package/es/table/pipeline/features/utils/touchEventUtils.js +65 -0
- package/es/table/pipeline/pipeline.js +11 -51
- package/es/table/pivot/cross-table/buildCrossTable.js +15 -64
- package/es/table/pivot/cross-table/cross-table.js +22 -28
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -47
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +28 -50
- package/es/table/pivot/pivot-utils/buildDrillTree.js +10 -23
- package/es/table/pivot/pivot-utils/builders.js +31 -71
- package/es/table/pivot/pivot-utils/convert-utils.js +13 -39
- package/es/table/pivot/pivot-utils/simpleEncode.js +0 -1
- package/es/table/transforms/autoRowSpan.js +1 -15
- package/es/table/transforms/autoWidth.js +10 -32
- package/es/table/transforms/buildTree.js +1 -2
- package/es/table/transforms/columnHover.js +9 -15
- package/es/table/transforms/columnRangeHover.js +12 -19
- package/es/table/transforms/columnResize.js +15 -37
- package/es/table/transforms/flatten.js +0 -3
- package/es/table/transforms/orderField.js +0 -3
- package/es/table/transforms/sort.js +36 -88
- package/es/table/transforms/tips.js +1 -6
- package/es/table/transforms/treeMode.js +30 -69
- package/es/table/transforms/visible.js +0 -2
- package/es/table/use/useResizeObserver.js +1 -4
- package/es/table/utils/applyTransforms.js +0 -1
- package/es/table/utils/buildTree.js +4 -19
- package/es/table/utils/collectNodes.js +1 -10
- package/es/table/utils/console.js +0 -14
- package/es/table/utils/copyToClipboard.js +0 -4
- package/es/table/utils/element.js +14 -41
- package/es/table/utils/exportTableAsExcel.js +4 -40
- package/es/table/utils/getTreeDepth.js +1 -9
- package/es/table/utils/groupBy.js +1 -10
- package/es/table/utils/layeredFilter.js +0 -4
- package/es/table/utils/layeredSort.js +0 -5
- package/es/table/utils/makeRecursiveMapper.js +1 -12
- package/es/table/utils/mergeCellProps.js +6 -13
- package/es/table/utils/others.js +3 -16
- package/es/table/utils/proto.js +2 -30
- package/es/table/utils/smartCompare.js +4 -12
- package/es/table/utils/traverseColumn.js +2 -15
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -22
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +15 -69
- package/lib/_utils/arrayUtil.js +0 -5
- package/lib/_utils/devwarning.js +0 -5
- package/lib/_utils/formatUtil.js +35 -100
- package/lib/_utils/hooks.js +18 -53
- package/lib/_utils/index.js +0 -6
- package/lib/_utils/numberUtil.js +32 -63
- package/lib/_utils/omit.js +0 -5
- package/lib/_utils/react-children.js +0 -5
- package/lib/_utils/type.js +0 -6
- package/lib/_utils/usePopper.js +74 -158
- package/lib/config-provider/ConfigContext.js +1 -4
- package/lib/config-provider/compDefaultProps.js +0 -1
- package/lib/config-provider/configProvider.js +3 -18
- package/lib/config-provider/defaultConfig.js +0 -5
- package/lib/config-provider/index.js +0 -6
- package/lib/index.js +2 -8
- package/lib/locale/index.js +0 -7
- package/lib/locale/locale.js +5 -57
- package/lib/table/base/calculations.js +22 -83
- package/lib/table/base/colgroup.js +0 -5
- package/lib/table/base/empty.js +4 -16
- package/lib/table/base/header.js +14 -77
- package/lib/table/base/helpers/SpanManager.js +3 -11
- package/lib/table/base/helpers/TableDOMUtils.js +2 -27
- package/lib/table/base/helpers/__test__/SpanManager.test.js +2 -4
- package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +0 -5
- package/lib/table/base/helpers/__test__/rowHeightManager.test.js +0 -1
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +11 -62
- package/lib/table/base/helpers/rowHeightManager.js +0 -33
- package/lib/table/base/html-table.js +14 -45
- package/lib/table/base/index.js +0 -2
- package/lib/table/base/loading.js +6 -12
- package/lib/table/base/renderTemplates.js +27 -58
- package/lib/table/base/styles.js +1 -22
- package/lib/table/base/table.js +96 -212
- package/lib/table/base/utils.js +14 -89
- package/lib/table/common-views.js +0 -16
- package/lib/table/index.js +0 -13
- package/lib/table/internals.js +0 -14
- package/lib/table/pipeline/features/autoFill.js +11 -47
- package/lib/table/pipeline/features/autoRowSpan.js +1 -19
- package/lib/table/pipeline/features/buildTree.js +0 -2
- package/lib/table/pipeline/features/colGroupExtendable.js +4 -32
- package/lib/table/pipeline/features/columnDrag.d.ts +1 -0
- package/lib/table/pipeline/features/columnDrag.js +236 -309
- package/lib/table/pipeline/features/columnFilter.js +11 -62
- package/lib/table/pipeline/features/columnHover.js +1 -11
- package/lib/table/pipeline/features/columnRangeHover.js +1 -13
- package/lib/table/pipeline/features/columnResizeWidth.js +51 -58
- package/lib/table/pipeline/features/contextMenu.js +18 -113
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +10 -43
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +1 -4
- package/lib/table/pipeline/features/filter/Filter.js +25 -70
- package/lib/table/pipeline/features/filter/FilterPanel.js +11 -40
- package/lib/table/pipeline/features/filter/index.js +0 -5
- package/lib/table/pipeline/features/filter/util.js +0 -7
- package/lib/table/pipeline/features/footerDataSource.js +0 -10
- package/lib/table/pipeline/features/index.js +0 -23
- package/lib/table/pipeline/features/mergeCellHover.js +0 -5
- package/lib/table/pipeline/features/multiSelect.js +15 -71
- package/lib/table/pipeline/features/rangeSelection.js +65 -160
- package/lib/table/pipeline/features/rowDetail.js +2 -65
- package/lib/table/pipeline/features/rowDrag.js +36 -81
- package/lib/table/pipeline/features/rowGrouping.js +2 -55
- package/lib/table/pipeline/features/singleSelect.js +0 -34
- package/lib/table/pipeline/features/sort.js +31 -103
- package/lib/table/pipeline/features/tips.js +0 -15
- package/lib/table/pipeline/features/treeMode.js +9 -65
- package/lib/table/pipeline/features/treeSelect.js +0 -34
- package/lib/table/pipeline/features/utils/touchEventUtils.d.ts +15 -0
- package/lib/table/pipeline/features/utils/touchEventUtils.js +76 -0
- package/lib/table/pipeline/index.js +0 -8
- package/lib/table/pipeline/pipeline.js +11 -60
- package/lib/table/pivot/cross-table/buildCrossTable.js +15 -75
- package/lib/table/pivot/cross-table/cross-table.js +22 -36
- package/lib/table/pivot/cross-table/index.js +0 -4
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +14 -60
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +28 -60
- package/lib/table/pivot/cross-tree-table/index.js +0 -3
- package/lib/table/pivot/pivot-utils/buildDrillTree.js +10 -29
- package/lib/table/pivot/pivot-utils/builders.js +31 -82
- package/lib/table/pivot/pivot-utils/convert-utils.js +13 -57
- package/lib/table/pivot/pivot-utils/index.js +0 -7
- package/lib/table/pivot/pivot-utils/simpleEncode.js +0 -2
- package/lib/table/style/css.js +0 -1
- package/lib/table/style/index.js +0 -1
- package/lib/table/transforms/autoRowSpan.js +1 -21
- package/lib/table/transforms/autoWidth.js +10 -53
- package/lib/table/transforms/buildTree.js +1 -4
- package/lib/table/transforms/columnHover.js +9 -22
- package/lib/table/transforms/columnRangeHover.js +12 -27
- package/lib/table/transforms/columnResize.js +15 -56
- package/lib/table/transforms/flatten.js +0 -5
- package/lib/table/transforms/index.js +0 -12
- package/lib/table/transforms/orderField.js +0 -7
- package/lib/table/transforms/sort.js +36 -112
- package/lib/table/transforms/tips.js +1 -16
- package/lib/table/transforms/treeMode.js +30 -96
- package/lib/table/transforms/visible.js +0 -7
- package/lib/table/transforms/warnTransformsDeprecated.js +0 -4
- package/lib/table/use/useResizeObserver.js +1 -8
- package/lib/table/utils/applyTransforms.js +0 -2
- package/lib/table/utils/buildTree.js +4 -30
- package/lib/table/utils/collectNodes.js +1 -15
- package/lib/table/utils/console.js +0 -16
- package/lib/table/utils/copyToClipboard.js +0 -6
- package/lib/table/utils/element.js +14 -46
- package/lib/table/utils/exportTableAsExcel.js +4 -49
- package/lib/table/utils/getTreeDepth.js +1 -14
- package/lib/table/utils/groupBy.js +1 -14
- package/lib/table/utils/index.js +0 -21
- package/lib/table/utils/isGroupColumn.js +0 -3
- package/lib/table/utils/isLeafNode.js +0 -1
- package/lib/table/utils/layeredFilter.js +0 -10
- package/lib/table/utils/layeredSort.js +0 -10
- package/lib/table/utils/makeRecursiveMapper.js +1 -21
- package/lib/table/utils/mergeCellProps.js +6 -17
- package/lib/table/utils/others.js +3 -31
- package/lib/table/utils/proto.js +2 -33
- package/lib/table/utils/selectColumn.js +0 -1
- package/lib/table/utils/smartCompare.js +4 -13
- package/lib/table/utils/traverseColumn.js +2 -22
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +1 -30
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +15 -82
- package/package.json +2 -1
|
@@ -17,26 +17,22 @@ export function contextMenu() {
|
|
|
17
17
|
var popupParent = opts.popupParent || document.body;
|
|
18
18
|
var menuClassName = opts.menuClassName;
|
|
19
19
|
var menuHelper = new MenuHelper();
|
|
20
|
-
|
|
21
20
|
var addPopup = function addPopup(menu) {
|
|
22
21
|
var ePopupDiv = document.createElement('div');
|
|
23
22
|
ePopupDiv.setAttribute('class', 'kd-table-popup');
|
|
24
23
|
popupParent.appendChild(ePopupDiv);
|
|
25
24
|
var popupHidden = false;
|
|
26
25
|
var eventList = ['mousedown', 'contextmenu'];
|
|
27
|
-
|
|
28
26
|
var hidePopup = function hidePopup(event) {
|
|
29
27
|
if (isEventFromCurrentPopup(event, ePopupDiv) || popupHidden) {
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
popupHidden = true;
|
|
34
31
|
popupParent.removeChild(ePopupDiv);
|
|
35
32
|
eventList.forEach(function (eventType) {
|
|
36
33
|
window.removeEventListener(eventType, hidePopup, true);
|
|
37
34
|
});
|
|
38
35
|
};
|
|
39
|
-
|
|
40
36
|
ReactDOM.render(menu, ePopupDiv, function () {
|
|
41
37
|
setTimeout(function () {
|
|
42
38
|
eventList.forEach(function (eventType) {
|
|
@@ -46,7 +42,6 @@ export function contextMenu() {
|
|
|
46
42
|
});
|
|
47
43
|
return hidePopup;
|
|
48
44
|
};
|
|
49
|
-
|
|
50
45
|
var onContextMenu = function onContextMenu(e) {
|
|
51
46
|
if (canShowContextMenu(e, pipeline)) {
|
|
52
47
|
e.preventDefault();
|
|
@@ -54,18 +49,14 @@ export function contextMenu() {
|
|
|
54
49
|
showContextMenu(e);
|
|
55
50
|
}
|
|
56
51
|
};
|
|
57
|
-
|
|
58
52
|
pipeline.addTableProps({
|
|
59
53
|
onContextMenu: onContextMenu
|
|
60
54
|
});
|
|
61
|
-
|
|
62
55
|
var getContextMenuOptions = function getContextMenuOptions(record, column, value, event) {
|
|
63
56
|
var defaultMenuOptions = [];
|
|
64
|
-
|
|
65
57
|
if (column) {
|
|
66
58
|
defaultMenuOptions.push(getCopyItem(value));
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
if (opts.getContextMenuItems) {
|
|
70
61
|
var params = {
|
|
71
62
|
record: record,
|
|
@@ -75,25 +66,20 @@ export function contextMenu() {
|
|
|
75
66
|
};
|
|
76
67
|
return opts.getContextMenuItems(params);
|
|
77
68
|
}
|
|
78
|
-
|
|
79
69
|
return defaultMenuOptions;
|
|
80
70
|
};
|
|
81
|
-
|
|
82
71
|
var hideContextMenu = function hideContextMenu() {
|
|
83
72
|
menuHelper.destroy();
|
|
84
73
|
};
|
|
85
|
-
|
|
86
74
|
var getPopupParent = function getPopupParent() {
|
|
87
75
|
return popupParent;
|
|
88
76
|
};
|
|
89
|
-
|
|
90
77
|
var showContextMenu = function showContextMenu(e) {
|
|
91
78
|
var path = getEventPath(e);
|
|
92
79
|
var cellEle = getCellEleInEventPath(path);
|
|
93
80
|
var code;
|
|
94
81
|
var rowIndex;
|
|
95
82
|
var isInFooter;
|
|
96
|
-
|
|
97
83
|
if (cellEle) {
|
|
98
84
|
code = cellEle.getAttribute('data-code');
|
|
99
85
|
rowIndex = cellEle.getAttribute('data-rowindex');
|
|
@@ -103,7 +89,6 @@ export function contextMenu() {
|
|
|
103
89
|
rowIndex = rowEle === null || rowEle === void 0 ? void 0 : rowEle.getAttribute('data-rowindex');
|
|
104
90
|
isInFooter = isElementInsideTheFooter(rowEle);
|
|
105
91
|
}
|
|
106
|
-
|
|
107
92
|
var dataSource = isInFooter ? pipeline.getFooterDataSource() || [] : pipeline.getDataSource();
|
|
108
93
|
var record = dataSource[rowIndex];
|
|
109
94
|
var column = code !== undefined && findByTree(pipeline.getColumns(), function (item) {
|
|
@@ -111,12 +96,10 @@ export function contextMenu() {
|
|
|
111
96
|
});
|
|
112
97
|
var value = column && record && internals.safeGetValue(column, record, rowIndex);
|
|
113
98
|
var options = getContextMenuOptions(record, column, value, e);
|
|
114
|
-
|
|
115
99
|
if (options.length === 0) {
|
|
116
100
|
console.warn('context menu options is empty');
|
|
117
101
|
return;
|
|
118
102
|
}
|
|
119
|
-
|
|
120
103
|
var position = positionForMenu(e, popupParent);
|
|
121
104
|
var menu = /*#__PURE__*/React.createElement(Menu, {
|
|
122
105
|
options: options,
|
|
@@ -125,54 +108,42 @@ export function contextMenu() {
|
|
|
125
108
|
getPopupParent: getPopupParent,
|
|
126
109
|
className: menuClassName
|
|
127
110
|
});
|
|
128
|
-
|
|
129
111
|
var _hidePopup = addPopup(menu);
|
|
130
|
-
|
|
131
112
|
menuHelper.init(_hidePopup);
|
|
132
113
|
};
|
|
133
|
-
|
|
134
114
|
return pipeline;
|
|
135
115
|
};
|
|
136
116
|
}
|
|
137
|
-
|
|
138
117
|
function getMenuItemKey(_ref) {
|
|
139
118
|
var name = _ref.name,
|
|
140
|
-
|
|
141
|
-
|
|
119
|
+
index = _ref.index;
|
|
142
120
|
if (name) {
|
|
143
121
|
var _context;
|
|
144
|
-
|
|
145
122
|
var _key = 0;
|
|
146
123
|
name = name + '';
|
|
147
|
-
|
|
148
124
|
for (var i = 0; i < name.length; i++) {
|
|
149
125
|
_key += name.charCodeAt(name[i]);
|
|
150
126
|
}
|
|
151
|
-
|
|
152
127
|
return _concatInstanceProperty(_context = "".concat(_key, "_")).call(_context, index);
|
|
153
128
|
}
|
|
154
|
-
|
|
155
129
|
return index;
|
|
156
130
|
}
|
|
157
|
-
|
|
158
131
|
function Menu(props) {
|
|
159
132
|
var className = props.className,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
133
|
+
_props$options = props.options,
|
|
134
|
+
options = _props$options === void 0 ? [] : _props$options,
|
|
135
|
+
hideContextMenu = props.hideContextMenu,
|
|
136
|
+
position = props.position,
|
|
137
|
+
getPopupParent = props.getPopupParent;
|
|
165
138
|
var menuRef = useRef();
|
|
166
139
|
useEffect(function () {
|
|
167
140
|
if (menuRef.current) {
|
|
168
141
|
var popupParent = getPopupParent();
|
|
169
142
|
var x = position.x,
|
|
170
|
-
|
|
171
|
-
|
|
143
|
+
y = position.y;
|
|
172
144
|
var _keepWithinBounds = keepWithinBounds(popupParent, menuRef.current, x, y),
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
145
|
+
_x = _keepWithinBounds.x,
|
|
146
|
+
_y = _keepWithinBounds.y;
|
|
176
147
|
menuRef.current.style.left = _x + 'px';
|
|
177
148
|
menuRef.current.style.top = _y + 'px';
|
|
178
149
|
}
|
|
@@ -200,50 +171,40 @@ function Menu(props) {
|
|
|
200
171
|
});
|
|
201
172
|
})));
|
|
202
173
|
}
|
|
203
|
-
|
|
204
174
|
function MenuItem(props) {
|
|
205
175
|
var name = props.name,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
176
|
+
action = props.action,
|
|
177
|
+
className = props.className,
|
|
178
|
+
disabled = props.disabled,
|
|
179
|
+
hideContextMenu = props.hideContextMenu;
|
|
210
180
|
var itemRef = useRef();
|
|
211
|
-
|
|
212
181
|
var handleClick = function handleClick() {
|
|
213
182
|
if (disabled) {
|
|
214
183
|
return;
|
|
215
184
|
}
|
|
216
|
-
|
|
217
185
|
hideContextMenu();
|
|
218
186
|
typeof action === 'function' && action();
|
|
219
187
|
};
|
|
220
|
-
|
|
221
188
|
var handleMouseEnter = function handleMouseEnter(e) {
|
|
222
189
|
if (disabled) {
|
|
223
190
|
return;
|
|
224
191
|
}
|
|
225
|
-
|
|
226
192
|
var itemDom = itemRef.current;
|
|
227
|
-
|
|
228
193
|
if (itemDom) {
|
|
229
194
|
itemDom.classList.add(MenuClasses.menuOptionActive);
|
|
230
195
|
}
|
|
231
196
|
};
|
|
232
|
-
|
|
233
197
|
var handleMouseLeave = function handleMouseLeave(e) {
|
|
234
198
|
if (disabled) {
|
|
235
199
|
return;
|
|
236
200
|
}
|
|
237
|
-
|
|
238
201
|
var itemDom = itemRef.current;
|
|
239
|
-
|
|
240
202
|
if (itemDom) {
|
|
241
203
|
setTimeout(function () {
|
|
242
204
|
itemDom.classList.remove(MenuClasses.menuOptionActive);
|
|
243
205
|
}, 10);
|
|
244
206
|
}
|
|
245
207
|
};
|
|
246
|
-
|
|
247
208
|
return /*#__PURE__*/React.createElement("div", {
|
|
248
209
|
className: cx(MenuClasses.menuOption, className, _defineProperty({}, MenuClasses.menuOptionDisable, disabled)),
|
|
249
210
|
ref: itemRef,
|
|
@@ -254,40 +215,29 @@ function MenuItem(props) {
|
|
|
254
215
|
className: MenuClasses.menuOptionText
|
|
255
216
|
}, name));
|
|
256
217
|
}
|
|
257
|
-
|
|
258
218
|
var MenuHelper = /*#__PURE__*/_createClass(function MenuHelper() {
|
|
259
219
|
var _this = this;
|
|
260
|
-
|
|
261
220
|
_classCallCheck(this, MenuHelper);
|
|
262
|
-
|
|
263
221
|
this.init = function (hidePopup) {
|
|
264
222
|
_this.hidePopup = hidePopup;
|
|
265
223
|
};
|
|
266
|
-
|
|
267
224
|
this.destroy = function () {
|
|
268
225
|
_this.hidePopup && _this.hidePopup();
|
|
269
226
|
_this.hidePopup = null;
|
|
270
227
|
};
|
|
271
228
|
});
|
|
272
229
|
/** 是否点击是外部 start */
|
|
273
|
-
|
|
274
|
-
|
|
275
230
|
function isEventFromCurrentPopup(event, ele) {
|
|
276
231
|
if (!event || !ele) {
|
|
277
232
|
return false;
|
|
278
233
|
}
|
|
279
|
-
|
|
280
234
|
if (isElementInEventPath(ele, event)) {
|
|
281
235
|
return true;
|
|
282
236
|
}
|
|
283
|
-
|
|
284
237
|
return false;
|
|
285
238
|
}
|
|
286
239
|
/** 是否点击是外部 end */
|
|
287
|
-
|
|
288
240
|
/** 计算位置 start */
|
|
289
|
-
|
|
290
|
-
|
|
291
241
|
function calculatePointerRelative(event, popupParent) {
|
|
292
242
|
var parentRect = popupParent.getBoundingClientRect();
|
|
293
243
|
var documentRect = document.documentElement.getBoundingClientRect();
|
|
@@ -296,31 +246,25 @@ function calculatePointerRelative(event, popupParent) {
|
|
|
296
246
|
y: event.clientY - (popupParent === document.body ? documentRect.top : parentRect.top)
|
|
297
247
|
};
|
|
298
248
|
}
|
|
299
|
-
|
|
300
249
|
function positionForMenu(event, popupParent, params) {
|
|
301
250
|
var _calculatePointerRela = calculatePointerRelative(event, popupParent),
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
251
|
+
x = _calculatePointerRela.x,
|
|
252
|
+
y = _calculatePointerRela.y;
|
|
305
253
|
if (params) {
|
|
306
254
|
var offsetX = params.offsetX,
|
|
307
|
-
|
|
308
|
-
|
|
255
|
+
offsetY = params.offsetY;
|
|
309
256
|
if (offsetX) {
|
|
310
257
|
x -= offsetX;
|
|
311
258
|
}
|
|
312
|
-
|
|
313
259
|
if (offsetY) {
|
|
314
260
|
y -= offsetY;
|
|
315
261
|
}
|
|
316
262
|
}
|
|
317
|
-
|
|
318
263
|
return {
|
|
319
264
|
x: x,
|
|
320
265
|
y: y
|
|
321
266
|
};
|
|
322
267
|
}
|
|
323
|
-
|
|
324
268
|
function keepWithinBounds(popupParent, ePopup, x, y) {
|
|
325
269
|
var parentRect = popupParent.getBoundingClientRect();
|
|
326
270
|
var docElement = document.documentElement;
|
|
@@ -328,14 +272,12 @@ function keepWithinBounds(popupParent, ePopup, x, y) {
|
|
|
328
272
|
var ePopupRect = ePopup.getBoundingClientRect();
|
|
329
273
|
var parentWidth = parentRect.width;
|
|
330
274
|
var parentHeight = parentRect.height;
|
|
331
|
-
|
|
332
275
|
if (popupParent === document.body) {
|
|
333
276
|
parentWidth = documentRect.width;
|
|
334
277
|
parentWidth -= Math.abs(documentRect.left - parentRect.left);
|
|
335
278
|
parentHeight = documentRect.height + docElement.scrollTop;
|
|
336
279
|
parentHeight -= Math.abs(documentRect.top - parentRect.top);
|
|
337
280
|
}
|
|
338
|
-
|
|
339
281
|
if (x) {
|
|
340
282
|
var minWidth = Math.min(ePopupRect.width, 120);
|
|
341
283
|
ePopup.style.minWidth = minWidth + 'px';
|
|
@@ -355,49 +297,36 @@ function keepWithinBounds(popupParent, ePopup, x, y) {
|
|
|
355
297
|
};
|
|
356
298
|
}
|
|
357
299
|
/** 计算位置 end */
|
|
358
|
-
|
|
359
300
|
/** 获得点击的元素 start */
|
|
360
|
-
|
|
361
|
-
|
|
362
301
|
function getCellEleInEventPath(path) {
|
|
363
302
|
return getTargetEleInEventPath(path, function (ele) {
|
|
364
303
|
return ele && ele.getAttribute('data-role') === 'table-cell';
|
|
365
304
|
});
|
|
366
305
|
}
|
|
367
|
-
|
|
368
306
|
function getRowEleInEventPath(path) {
|
|
369
307
|
return getTargetEleInEventPath(path, function (ele) {
|
|
370
308
|
return ele && ele.getAttribute('data-role') === 'table-row';
|
|
371
309
|
});
|
|
372
310
|
}
|
|
373
311
|
/** 获得点击的元素 end */
|
|
374
|
-
|
|
375
|
-
|
|
376
312
|
function isElementInsideTheFooter(ele) {
|
|
377
313
|
var pointer = ele;
|
|
378
|
-
|
|
379
314
|
while (pointer) {
|
|
380
315
|
if (pointer.tagName === 'TFOOT') {
|
|
381
316
|
return true;
|
|
382
317
|
}
|
|
383
|
-
|
|
384
318
|
if (pointer.tagName === 'TABLE' || pointer.tagName === 'TBODY') {
|
|
385
319
|
return false;
|
|
386
320
|
}
|
|
387
|
-
|
|
388
321
|
pointer = pointer.parentElement;
|
|
389
322
|
}
|
|
390
|
-
|
|
391
323
|
return false;
|
|
392
324
|
}
|
|
393
|
-
|
|
394
325
|
function canShowContextMenu(e, pipeline) {
|
|
395
326
|
var _a, _b;
|
|
396
|
-
|
|
397
327
|
return ((_a = pipeline.ref.current.domHelper) === null || _a === void 0 ? void 0 : _a.tableBody.contains(e.target)) || ((_b = pipeline.ref.current.domHelper) === null || _b === void 0 ? void 0 : _b.tableFooter.contains(e.target));
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
328
|
+
}
|
|
329
|
+
// 默认选项
|
|
401
330
|
function getCopyItem(v) {
|
|
402
331
|
return {
|
|
403
332
|
name: '复制',
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
|
|
4
|
-
|
|
5
4
|
var _templateObject;
|
|
6
|
-
|
|
7
5
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
8
6
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
9
7
|
import React, { useEffect, useRef } from 'react';
|
|
@@ -13,38 +11,30 @@ import { DEFAULT_FILTER_OPTIONS } from './util';
|
|
|
13
11
|
import { Classes, ButtonCSS } from '../../../base/styles';
|
|
14
12
|
import KeyCode from '../../../utils/keyCode';
|
|
15
13
|
var DefaultFilterContentStyle = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n background-color: #ffffff;\n border-radius: 2px;\n width: 100%;\n\n ", "\n .filter-option-list {\n display: flex;\n flex-direction: column;\n margin-top: 8px;\n ul {\n margin: 0;\n padding: 0;\n li {\n display: flex;\n position: relative;\n flex-shrink: 0;\n height: 32px;\n align-items: center;\n border-radius: 2px;\n font-size: 12px;\n color: var(--color);\n padding: 0 12px;\n overflow: hidden;\n cursor: pointer;\n &:hover{\n background-color: var(--primary-color-level1);\n }\n }\n li.active{\n background-color: var(--primary-color-level1);\n }\n }\n }\n\n .filter-search {\n display: flex;\n padding: 6px 12px;\n\n .filter-search-inner {\n width: 100%;\n font-size: 12px;\n color: #333333;\n height: 28px;\n line-height: 28px;\n padding: 0 8px;\n outline: none;\n background-color: #FAFAFA;\n border-radius: 2px;\n border: 1px solid var(--strong-border-color);\n &:hover{\n border-color: var(--primary-color)\n } \n &:focus{\n border-color: var(--primary-color)\n } \n }\n }\n\n .filter-footer {\n display: flex;\n flex-direction: row;\n padding: 8px 12px;\n justify-content: space-between;\n\n .filter-btn {\n text-align: center;\n font-size: 12px;\n width: 60px;\n height: 24px;\n line-height: 24px;\n }\n \n }\n"])), ButtonCSS);
|
|
16
|
-
|
|
17
14
|
function DefaultFilterContent(_ref) {
|
|
18
15
|
var _cx2;
|
|
19
|
-
|
|
20
16
|
var setFilterModel = _ref.setFilterModel,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
filterModel = _ref.filterModel,
|
|
18
|
+
hidePanel = _ref.hidePanel,
|
|
19
|
+
_ref$localeText = _ref.localeText,
|
|
20
|
+
localeText = _ref$localeText === void 0 ? {} : _ref$localeText;
|
|
26
21
|
var _a, _b;
|
|
27
|
-
|
|
28
22
|
var _React$useState = React.useState((filterModel === null || filterModel === void 0 ? void 0 : filterModel.filterCondition) || 'contain'),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
24
|
+
selectedValue = _React$useState2[0],
|
|
25
|
+
setSelectedValue = _React$useState2[1];
|
|
33
26
|
var _React$useState3 = React.useState((filterModel === null || filterModel === void 0 ? void 0 : _filterInstanceProperty(filterModel)) || []),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
28
|
+
innerValue = _React$useState4[0],
|
|
29
|
+
setInnerValue = _React$useState4[1];
|
|
38
30
|
var inputRef = useRef();
|
|
39
31
|
var handleClick = React.useCallback(function (option) {
|
|
40
32
|
setSelectedValue(option.key);
|
|
41
33
|
}, []);
|
|
42
|
-
|
|
43
34
|
var reset = function reset() {
|
|
44
35
|
hidePanel();
|
|
45
36
|
setFilterModel();
|
|
46
37
|
};
|
|
47
|
-
|
|
48
38
|
var confirm = function confirm() {
|
|
49
39
|
hidePanel();
|
|
50
40
|
setFilterModel({
|
|
@@ -52,13 +42,11 @@ function DefaultFilterContent(_ref) {
|
|
|
52
42
|
filterCondition: selectedValue
|
|
53
43
|
});
|
|
54
44
|
};
|
|
55
|
-
|
|
56
45
|
var handleKeyDown = function handleKeyDown(e) {
|
|
57
46
|
if (e.keyCode === KeyCode.ENTER) {
|
|
58
47
|
confirm();
|
|
59
48
|
}
|
|
60
49
|
};
|
|
61
|
-
|
|
62
50
|
useEffect(function () {
|
|
63
51
|
setSelectedValue((filterModel === null || filterModel === void 0 ? void 0 : filterModel.filterCondition) || 'contain');
|
|
64
52
|
setInnerValue((filterModel === null || filterModel === void 0 ? void 0 : _filterInstanceProperty(filterModel)) || []);
|
|
@@ -67,7 +55,6 @@ function DefaultFilterContent(_ref) {
|
|
|
67
55
|
// 兼容设置焦点后发生滚动
|
|
68
56
|
setTimeout(function () {
|
|
69
57
|
var _a;
|
|
70
|
-
|
|
71
58
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus({
|
|
72
59
|
preventScroll: true
|
|
73
60
|
});
|
|
@@ -77,7 +64,6 @@ function DefaultFilterContent(_ref) {
|
|
|
77
64
|
className: 'filter-option-list'
|
|
78
65
|
}, /*#__PURE__*/React.createElement("ul", null, _mapInstanceProperty(DEFAULT_FILTER_OPTIONS).call(DEFAULT_FILTER_OPTIONS, function (option, index) {
|
|
79
66
|
var _a;
|
|
80
|
-
|
|
81
67
|
return (
|
|
82
68
|
/*#__PURE__*/
|
|
83
69
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
@@ -113,5 +99,4 @@ function DefaultFilterContent(_ref) {
|
|
|
113
99
|
onClick: confirm
|
|
114
100
|
}, (_b = localeText.confirmFilter) !== null && _b !== void 0 ? _b : '确定')));
|
|
115
101
|
}
|
|
116
|
-
|
|
117
102
|
export default DefaultFilterContent;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplateLiteral";
|
|
4
|
-
|
|
5
4
|
var _templateObject;
|
|
6
|
-
|
|
7
5
|
import React, { useEffect } from 'react';
|
|
8
6
|
import { createPortal } from 'react-dom';
|
|
9
7
|
import styled from 'styled-components';
|
|
@@ -16,34 +14,27 @@ import { calculatePopupRelative } from '../../../utils';
|
|
|
16
14
|
import { addResizeObserver } from '../../../base/utils';
|
|
17
15
|
import KeyCode from '../../../utils/keyCode';
|
|
18
16
|
var HEADER_ICON_OFFSET_Y = 8 + 1; // padding-top + border
|
|
19
|
-
|
|
20
17
|
var HEADER_ICON_OFFSET_X = 16 + 1; // padding-left+ border
|
|
21
|
-
|
|
22
18
|
var FilterIconSpanStyle = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n // position: absolute;\n // right: 4px;\n // cursor: pointer;\n // transform: translateY(-50%);\n // top: 50%;\n // height: 12px; \n > .", " {\n display: flex\n }\n"])), Classes.filterIcon);
|
|
23
|
-
|
|
24
19
|
function Panel(_ref) {
|
|
25
20
|
var ele = _ref.ele,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
filterIcon = _ref.filterIcon,
|
|
22
|
+
hidePanel = _ref.hidePanel,
|
|
23
|
+
renderPanelContent = _ref.renderPanelContent,
|
|
24
|
+
hideFilterPopupHeader = _ref.hideFilterPopupHeader,
|
|
25
|
+
popupParent = _ref.popupParent;
|
|
31
26
|
var filterPanelRef = React.useRef(null);
|
|
32
|
-
|
|
33
27
|
var _React$useState = React.useState(calculatePopupRelative(ele, popupParent, _getPanelOffset(ele, hideFilterPopupHeader))),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
29
|
+
position = _React$useState2[0],
|
|
30
|
+
setPosition = _React$useState2[1];
|
|
38
31
|
var style = {
|
|
39
32
|
position: 'absolute',
|
|
40
33
|
zIndex: 1050
|
|
41
34
|
};
|
|
42
|
-
|
|
43
35
|
var handleFilterPanelResize = function handleFilterPanelResize(resize) {
|
|
44
36
|
setPosition(calculatePopupRelative(ele, popupParent, _getPanelOffset(ele, hideFilterPopupHeader)));
|
|
45
37
|
};
|
|
46
|
-
|
|
47
38
|
useEffect(function () {
|
|
48
39
|
var resizeObserver = addResizeObserver(filterPanelRef.current.children[0], handleFilterPanelResize);
|
|
49
40
|
return function () {
|
|
@@ -60,38 +51,32 @@ function Panel(_ref) {
|
|
|
60
51
|
hideFilterPopupHeader: hideFilterPopupHeader
|
|
61
52
|
}, renderPanelContent()));
|
|
62
53
|
}
|
|
63
|
-
|
|
64
54
|
function Filter(_ref2) {
|
|
65
55
|
var _cx;
|
|
66
|
-
|
|
67
56
|
var _ref2$size = _ref2.size,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
57
|
+
size = _ref2$size === void 0 ? 12 : _ref2$size,
|
|
58
|
+
style = _ref2.style,
|
|
59
|
+
className = _ref2.className,
|
|
60
|
+
FilterPanelContent = _ref2.FilterPanelContent,
|
|
61
|
+
filterIcon = _ref2.filterIcon,
|
|
62
|
+
setFilter = _ref2.setFilter,
|
|
63
|
+
setFilterModel = _ref2.setFilterModel,
|
|
64
|
+
filterModel = _ref2.filterModel,
|
|
65
|
+
isFilterActive = _ref2.isFilterActive,
|
|
66
|
+
stopClickEventPropagation = _ref2.stopClickEventPropagation,
|
|
67
|
+
stopESCKeyDownEventPropagation = _ref2.stopESCKeyDownEventPropagation,
|
|
68
|
+
hideFilterPopupHeader = _ref2.hideFilterPopupHeader,
|
|
69
|
+
getPopupParent = _ref2.getPopupParent,
|
|
70
|
+
localeText = _ref2.localeText;
|
|
83
71
|
var _React$useState3 = React.useState(false),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
73
|
+
showPanel = _React$useState4[0],
|
|
74
|
+
setShowPanel = _React$useState4[1];
|
|
88
75
|
var iconRef = React.useRef(null);
|
|
89
76
|
var iconWrapRef = React.useRef();
|
|
90
|
-
|
|
91
77
|
var hidePanel = function hidePanel() {
|
|
92
78
|
return setShowPanel(false);
|
|
93
79
|
};
|
|
94
|
-
|
|
95
80
|
var renderPanelContent = function renderPanelContent() {
|
|
96
81
|
if (FilterPanelContent) {
|
|
97
82
|
return /*#__PURE__*/React.createElement(FilterPanelContent, {
|
|
@@ -110,31 +95,26 @@ function Filter(_ref2) {
|
|
|
110
95
|
});
|
|
111
96
|
}
|
|
112
97
|
};
|
|
113
|
-
|
|
114
98
|
var handleIconClick = function handleIconClick(e) {
|
|
115
99
|
// 只有当icon区域点击会触发面板展开
|
|
116
100
|
// 防止 createPortal 区域的点击触发该事件
|
|
117
101
|
if (e.currentTarget.contains(e.target)) {
|
|
118
102
|
setShowPanel(true);
|
|
119
103
|
}
|
|
120
|
-
|
|
121
104
|
if (stopClickEventPropagation) {
|
|
122
105
|
e.stopPropagation();
|
|
123
106
|
}
|
|
124
107
|
};
|
|
125
|
-
|
|
126
108
|
var handleKeyDown = function handleKeyDown(e) {
|
|
127
109
|
if (e.keyCode === KeyCode.ESC) {
|
|
128
110
|
if (e.currentTarget.contains(e.target)) {
|
|
129
111
|
setShowPanel(false);
|
|
130
112
|
}
|
|
131
|
-
|
|
132
113
|
if (stopESCKeyDownEventPropagation) {
|
|
133
114
|
e.stopPropagation();
|
|
134
115
|
}
|
|
135
116
|
}
|
|
136
117
|
};
|
|
137
|
-
|
|
138
118
|
var iconClassName = cx((_cx = {}, _defineProperty(_cx, className, true), _defineProperty(_cx, 'filter-panel-open', showPanel), _cx));
|
|
139
119
|
var displayFilterIcon = typeof filterIcon === 'function' ? filterIcon(isFilterActive) : filterIcon;
|
|
140
120
|
var popupParent = (getPopupParent === null || getPopupParent === void 0 ? void 0 : getPopupParent(iconWrapRef.current)) || document.body;
|
|
@@ -160,7 +140,6 @@ function Filter(_ref2) {
|
|
|
160
140
|
popupParent: popupParent
|
|
161
141
|
}), popupParent));
|
|
162
142
|
}
|
|
163
|
-
|
|
164
143
|
function _getPanelOffset(ele, hideFilterPopupHeader) {
|
|
165
144
|
if (hideFilterPopupHeader) {
|
|
166
145
|
return {
|
|
@@ -168,11 +147,9 @@ function _getPanelOffset(ele, hideFilterPopupHeader) {
|
|
|
168
147
|
y: 0 - ele.offsetHeight
|
|
169
148
|
};
|
|
170
149
|
}
|
|
171
|
-
|
|
172
150
|
return {
|
|
173
151
|
x: HEADER_ICON_OFFSET_X,
|
|
174
152
|
y: HEADER_ICON_OFFSET_Y
|
|
175
153
|
};
|
|
176
154
|
}
|
|
177
|
-
|
|
178
155
|
export default Filter;
|