@kdcloudjs/table 1.1.4 → 1.1.5-canary.1
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 +860 -310
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +10 -9
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/table/base/html-table.js +1 -1
- package/es/table/base/styles.d.ts +11 -2
- package/es/table/base/styles.js +18 -7
- package/es/table/base/table.d.ts +2 -0
- package/es/table/base/table.js +32 -54
- package/es/table/base/utils.d.ts +7 -0
- package/es/table/base/utils.js +36 -2
- package/es/table/pipeline/features/colGroupExtendable.d.ts +6 -0
- package/es/table/pipeline/features/colGroupExtendable.js +103 -0
- package/es/table/pipeline/features/columnDrag.js +5 -4
- package/es/table/pipeline/features/columnFilter.d.ts +4 -2
- package/es/table/pipeline/features/columnFilter.js +39 -19
- package/es/table/pipeline/features/columnResizeWidth.js +1 -1
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +22 -2
- package/es/table/pipeline/features/filter/DefaultFilterIcon.d.ts +5 -0
- package/es/table/pipeline/features/filter/DefaultFilterIcon.js +20 -0
- package/es/table/pipeline/features/filter/Filter.d.ts +3 -2
- package/es/table/pipeline/features/filter/Filter.js +54 -35
- package/es/table/pipeline/features/filter/FilterPanel.d.ts +2 -1
- package/es/table/pipeline/features/filter/FilterPanel.js +40 -21
- package/es/table/pipeline/features/filter/util.js +4 -4
- package/es/table/pipeline/features/footerDataSource.d.ts +9 -0
- package/es/table/pipeline/features/footerDataSource.js +25 -0
- package/es/table/pipeline/features/index.d.ts +2 -0
- package/es/table/pipeline/features/index.js +3 -1
- package/es/table/pipeline/features/multiSelect.js +7 -2
- package/es/table/pipeline/features/rangeSelection.d.ts +1 -1
- package/es/table/pipeline/features/rangeSelection.js +170 -30
- package/es/table/pipeline/features/singleSelect.js +4 -0
- package/es/table/pipeline/features/treeMode.d.ts +2 -0
- package/es/table/pipeline/features/treeMode.js +20 -21
- package/es/table/pipeline/pipeline.d.ts +5 -1
- package/es/table/pipeline/pipeline.js +11 -10
- package/es/table/utils/element.d.ts +1 -0
- package/es/table/utils/element.js +4 -0
- package/es/table/utils/keyCode.d.ts +5 -0
- package/es/table/utils/keyCode.js +5 -0
- package/es/table/utils/mergeCellProps.js +2 -6
- package/lib/table/base/html-table.js +1 -1
- package/lib/table/base/styles.d.ts +11 -2
- package/lib/table/base/styles.js +18 -7
- package/lib/table/base/table.d.ts +2 -0
- package/lib/table/base/table.js +32 -54
- package/lib/table/base/utils.d.ts +7 -0
- package/lib/table/base/utils.js +43 -2
- package/lib/table/pipeline/features/colGroupExtendable.d.ts +6 -0
- package/lib/table/pipeline/features/colGroupExtendable.js +124 -0
- package/lib/table/pipeline/features/columnDrag.js +5 -4
- package/lib/table/pipeline/features/columnFilter.d.ts +4 -2
- package/lib/table/pipeline/features/columnFilter.js +37 -19
- package/lib/table/pipeline/features/columnResizeWidth.js +1 -1
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +23 -1
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.d.ts +5 -0
- package/lib/table/pipeline/features/filter/DefaultFilterIcon.js +30 -0
- package/lib/table/pipeline/features/filter/Filter.d.ts +3 -2
- package/lib/table/pipeline/features/filter/Filter.js +57 -35
- package/lib/table/pipeline/features/filter/FilterPanel.d.ts +2 -1
- package/lib/table/pipeline/features/filter/FilterPanel.js +42 -20
- package/lib/table/pipeline/features/filter/util.js +4 -4
- package/lib/table/pipeline/features/footerDataSource.d.ts +9 -0
- package/lib/table/pipeline/features/footerDataSource.js +41 -0
- package/lib/table/pipeline/features/index.d.ts +2 -0
- package/lib/table/pipeline/features/index.js +23 -1
- package/lib/table/pipeline/features/multiSelect.js +6 -1
- package/lib/table/pipeline/features/rangeSelection.d.ts +1 -1
- package/lib/table/pipeline/features/rangeSelection.js +173 -32
- package/lib/table/pipeline/features/singleSelect.js +4 -0
- package/lib/table/pipeline/features/treeMode.d.ts +2 -0
- package/lib/table/pipeline/features/treeMode.js +21 -23
- package/lib/table/pipeline/pipeline.d.ts +5 -1
- package/lib/table/pipeline/pipeline.js +12 -10
- package/lib/table/utils/element.d.ts +1 -0
- package/lib/table/utils/element.js +6 -0
- package/lib/table/utils/keyCode.d.ts +5 -0
- package/lib/table/utils/keyCode.js +12 -0
- package/lib/table/utils/mergeCellProps.js +2 -6
- package/package.json +3 -3
|
@@ -28,7 +28,8 @@ export function filter() {
|
|
|
28
28
|
keepDataSource = opts.keepDataSource,
|
|
29
29
|
mode = opts.mode,
|
|
30
30
|
filterIcon = opts.filterIcon,
|
|
31
|
-
stopClickEventPropagation = opts.stopClickEventPropagation
|
|
31
|
+
stopClickEventPropagation = opts.stopClickEventPropagation,
|
|
32
|
+
hideFilterPopupHeader = opts.hideFilterPopupHeader;
|
|
32
33
|
var inputFilters = (_b = (_a = filters !== null && filters !== void 0 ? filters : pipeline.getStateAtKey(stateKey)) !== null && _a !== void 0 ? _a : defaultFilters) !== null && _b !== void 0 ? _b : [];
|
|
33
34
|
inputFilters = mode === 'single' ? _sliceInstanceProperty(inputFilters).call(inputFilters, 0, 1) : inputFilters;
|
|
34
35
|
var inputFiltersMap = new _Map(_mapInstanceProperty(inputFilters).call(inputFilters, function (filterItem) {
|
|
@@ -39,7 +40,7 @@ export function filter() {
|
|
|
39
40
|
return _mapInstanceProperty(columns).call(columns, dfs);
|
|
40
41
|
|
|
41
42
|
function dfs(col) {
|
|
42
|
-
var _a, _b, _c, _d, _e;
|
|
43
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
43
44
|
|
|
44
45
|
var result = _extends({}, col);
|
|
45
46
|
|
|
@@ -81,18 +82,18 @@ export function filter() {
|
|
|
81
82
|
};
|
|
82
83
|
|
|
83
84
|
var filterPanel = (_d = col.features) === null || _d === void 0 ? void 0 : _d.filterPanel;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}))])), [/*#__PURE__*/React.createElement(Filter, {
|
|
85
|
+
var colFilterIcon = (_f = (_e = col.features) === null || _e === void 0 ? void 0 : _e.filterIcon) !== null && _f !== void 0 ? _f : filterIcon;
|
|
86
|
+
result.title = _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(_concatInstanceProperty(_context2 = []).call(_context2, (_g = result.title) !== null && _g !== void 0 ? _g : [internals.safeRenderHeader(_extends({}, col))])), [/*#__PURE__*/React.createElement(Filter, {
|
|
87
87
|
key: "filter",
|
|
88
88
|
FilterPanelContent: filterPanel,
|
|
89
|
-
filterIcon:
|
|
89
|
+
filterIcon: colFilterIcon,
|
|
90
90
|
filterModel: inputFiltersMap.get(col.code),
|
|
91
91
|
setFilterModel: handleFilterChanged,
|
|
92
92
|
setFilter: setFilter,
|
|
93
93
|
isFilterActive: filterActive,
|
|
94
94
|
className: cx((_cx = {}, _defineProperty(_cx, Classes.tableFilterTrigger, true), _defineProperty(_cx, "active", filterActive), _cx)),
|
|
95
|
-
stopClickEventPropagation: stopClickEventPropagation
|
|
95
|
+
stopClickEventPropagation: stopClickEventPropagation,
|
|
96
|
+
hideFilterPopupHeader: hideFilterPopupHeader
|
|
96
97
|
})]); // result.headerCellProps = mergeCellProps(col.headerCellProps, {
|
|
97
98
|
// style: {
|
|
98
99
|
// paddingRight: '18px'
|
|
@@ -134,8 +135,8 @@ export function filter() {
|
|
|
134
135
|
return [item.key, _extends({}, item)];
|
|
135
136
|
}));
|
|
136
137
|
|
|
137
|
-
function isMatchedFilterCondition(record
|
|
138
|
-
return
|
|
138
|
+
function isMatchedFilterCondition(record) {
|
|
139
|
+
return filtersKeys.every(function (key) {
|
|
139
140
|
var _a, _b;
|
|
140
141
|
|
|
141
142
|
var filterItem = inputFiltersMap.get(key);
|
|
@@ -149,24 +150,43 @@ export function filter() {
|
|
|
149
150
|
} else {
|
|
150
151
|
console.warn("\u5217[".concat(key, "]\u672A\u914D\u7F6E\u7B5B\u9009\u51FD\u6570\uFF0C\u8BF7\u8BBE\u7F6E column.features.filterable \u6765\u4F5C\u4E3A\u8BE5\u5217\u7684\u7B5B\u9009\u51FD\u6570, \u76EE\u524D\u4F7F\u7528\u9ED8\u8BA4\u5305\u542B\u7B5B\u9009\u51FD\u6570"));
|
|
151
152
|
comparisonFn = _filterInstanceProperty(defaultFilterOptionsMap.get('contain'));
|
|
152
|
-
}
|
|
153
|
+
}
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
return !comparisonFn(_filterInstanceProperty(filterItem), filterItem)(internals.safeGetValue(columnsMap.get(key), record, rowIndex), record);
|
|
155
|
+
return comparisonFn(_filterInstanceProperty(filterItem), filterItem)(internals.safeGetValue(columnsMap.get(key), record, -1), record);
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
return dataSource
|
|
160
|
-
if (isMatchedFilterCondition(record, rowIndex)) {
|
|
161
|
-
return _concatInstanceProperty(pre).call(pre, [record]);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return pre;
|
|
165
|
-
}, []);
|
|
159
|
+
return layeredFilter(dataSource, isMatchedFilterCondition);
|
|
166
160
|
}
|
|
167
161
|
|
|
168
162
|
pipeline.dataSource(processDataSource(dataSource));
|
|
169
163
|
pipeline.columns(processColumns(columns));
|
|
170
164
|
return pipeline;
|
|
171
165
|
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function layeredFilter(array, matchFn) {
|
|
169
|
+
return dfs(array);
|
|
170
|
+
|
|
171
|
+
function dfs(rows) {
|
|
172
|
+
var _context6;
|
|
173
|
+
|
|
174
|
+
var parentMatched = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
175
|
+
return _filterInstanceProperty(_context6 = _mapInstanceProperty(rows).call(rows, function (row) {
|
|
176
|
+
var currentMatched = matchFn(row);
|
|
177
|
+
|
|
178
|
+
if (isLeafNode(row)) {
|
|
179
|
+
return (parentMatched || currentMatched) && _extends({}, row);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
var children = row.children;
|
|
183
|
+
|
|
184
|
+
var rowAfterFilterChildren = _extends(_extends({}, row), {
|
|
185
|
+
children: dfs(children, parentMatched || currentMatched)
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
var matchedByChildren = !isLeafNode(rowAfterFilterChildren);
|
|
189
|
+
return (parentMatched || currentMatched || matchedByChildren) && rowAfterFilterChildren;
|
|
190
|
+
})).call(_context6, Boolean);
|
|
191
|
+
}
|
|
172
192
|
}
|
|
@@ -12,7 +12,7 @@ import * as op from 'rxjs/operators';
|
|
|
12
12
|
import { mergeCellProps, collectNodes, makeRecursiveMapper, isGroupColumn } from '../../utils';
|
|
13
13
|
import { internals } from '../../internals';
|
|
14
14
|
import { Classes } from '../../base/styles';
|
|
15
|
-
var TableHeaderCellResize = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n right: -5px;\n height: 100%;\n width: 10px;\n cursor: ew-resize;\n display: flex;\n flex-direction: column;\n align-items: center;\n z-index:1;\n\n &:after {\n content: \"\";\n position: absolute;\n display: block;\n left: calc(50% - 1px);\n width: 1px;\n height: calc(100% - 14px);\n top: 7px;\n
|
|
15
|
+
var TableHeaderCellResize = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n right: -5px;\n height: 100%;\n width: 10px;\n cursor: ew-resize;\n display: flex;\n flex-direction: column;\n align-items: center;\n z-index:1;\n\n &:after {\n content: \"\";\n position: absolute;\n display: block;\n left: calc(50% - 1px);\n width: 1px;\n height: calc(100% - 14px);\n top: 7px;\n }\n"])));
|
|
16
16
|
var TableHeaderGroupCellResize = styled(TableHeaderCellResize)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &:after {\n height: 100%;\n top: 0;\n }\n"])));
|
|
17
17
|
|
|
18
18
|
function clamp(min, x, max) {
|
|
@@ -6,11 +6,12 @@ var _templateObject;
|
|
|
6
6
|
|
|
7
7
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
8
8
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
9
|
-
import React, { useEffect } from 'react';
|
|
9
|
+
import React, { useEffect, useRef } from 'react';
|
|
10
10
|
import styled from 'styled-components';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { DEFAULT_FILTER_OPTIONS } from './util';
|
|
13
13
|
import { Classes, ButtonCSS } from '../../../base/styles';
|
|
14
|
+
import KeyCode from '../../../utils/keyCode';
|
|
14
15
|
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);
|
|
15
16
|
|
|
16
17
|
function DefaultFilterContent(_ref) {
|
|
@@ -30,6 +31,7 @@ function DefaultFilterContent(_ref) {
|
|
|
30
31
|
innerValue = _React$useState4[0],
|
|
31
32
|
setInnerValue = _React$useState4[1];
|
|
32
33
|
|
|
34
|
+
var inputRef = useRef();
|
|
33
35
|
var handleClick = React.useCallback(function (option) {
|
|
34
36
|
setSelectedValue(option.key);
|
|
35
37
|
}, []);
|
|
@@ -47,10 +49,26 @@ function DefaultFilterContent(_ref) {
|
|
|
47
49
|
});
|
|
48
50
|
};
|
|
49
51
|
|
|
52
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
53
|
+
if (e.keyCode === KeyCode.ENTER) {
|
|
54
|
+
confirm();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
50
58
|
useEffect(function () {
|
|
51
59
|
setSelectedValue((filterModel === null || filterModel === void 0 ? void 0 : filterModel.filterCondition) || 'contain');
|
|
52
60
|
setInnerValue((filterModel === null || filterModel === void 0 ? void 0 : _filterInstanceProperty(filterModel)) || '');
|
|
53
61
|
}, [filterModel]);
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
// 兼容设置焦点后发生滚动
|
|
64
|
+
setTimeout(function () {
|
|
65
|
+
var _a;
|
|
66
|
+
|
|
67
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus({
|
|
68
|
+
preventScroll: true
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}, []);
|
|
54
72
|
return /*#__PURE__*/React.createElement(DefaultFilterContentStyle, null, /*#__PURE__*/React.createElement("div", {
|
|
55
73
|
className: 'filter-option-list'
|
|
56
74
|
}, /*#__PURE__*/React.createElement("ul", null, _mapInstanceProperty(DEFAULT_FILTER_OPTIONS).call(DEFAULT_FILTER_OPTIONS, function (option, index) {
|
|
@@ -72,7 +90,9 @@ function DefaultFilterContent(_ref) {
|
|
|
72
90
|
value: innerValue,
|
|
73
91
|
onChange: function onChange(e) {
|
|
74
92
|
setInnerValue(e.target.value);
|
|
75
|
-
}
|
|
93
|
+
},
|
|
94
|
+
onKeyDown: handleKeyDown,
|
|
95
|
+
ref: inputRef
|
|
76
96
|
})), /*#__PURE__*/React.createElement("div", {
|
|
77
97
|
className: 'filter-footer'
|
|
78
98
|
}, /*#__PURE__*/React.createElement("button", {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export default function DefaultFilterIcon(_ref) {
|
|
3
|
+
var width = _ref.width,
|
|
4
|
+
height = _ref.height;
|
|
5
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
6
|
+
width: width,
|
|
7
|
+
height: height,
|
|
8
|
+
style: {
|
|
9
|
+
verticalAlign: 'middle'
|
|
10
|
+
},
|
|
11
|
+
viewBox: "0 0 1024 1024",
|
|
12
|
+
focusable: "false",
|
|
13
|
+
"data-icon": "filter",
|
|
14
|
+
fill: "currentColor",
|
|
15
|
+
version: "1.1",
|
|
16
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
17
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
18
|
+
d: "M891.448889 159.573333L626.460444 460.231111v443.221333c0 32.881778-25.429333 63.658667-55.864888 63.658667l-170.268445-172.942222V456.419556L132.266667 159.857778A59.619556 59.619556 0 0 1 173.511111 56.888889h676.977778c32.995556 0 59.733333 26.680889 59.733333 59.562667 0 17.066667-7.224889 32.312889-18.773333 43.121777z"
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
@@ -6,12 +6,13 @@ interface FilterProps {
|
|
|
6
6
|
size?: number;
|
|
7
7
|
isFilterActive: boolean;
|
|
8
8
|
FilterPanelContent?: FilterPanelType;
|
|
9
|
-
filterIcon?: ReactNode;
|
|
9
|
+
filterIcon?: ReactNode | ((filtered: boolean) => ReactNode);
|
|
10
10
|
setFilterModel: DefaultFilterPanelProps['setFilterModel'];
|
|
11
11
|
filterModel: DefaultFilterPanelProps['filterModel'];
|
|
12
12
|
setFilter: CustomeFilterPanelProps['setFilter'];
|
|
13
13
|
onClick?: (e: React.MouseEvent) => any;
|
|
14
14
|
stopClickEventPropagation?: boolean;
|
|
15
|
+
hideFilterPopupHeader?: boolean;
|
|
15
16
|
}
|
|
16
|
-
declare function Filter({ size, style, className, FilterPanelContent, filterIcon, setFilter, setFilterModel, filterModel, isFilterActive, stopClickEventPropagation }: FilterProps): JSX.Element;
|
|
17
|
+
declare function Filter({ size, style, className, FilterPanelContent, filterIcon, setFilter, setFilterModel, filterModel, isFilterActive, stopClickEventPropagation, hideFilterPopupHeader }: FilterProps): JSX.Element;
|
|
17
18
|
export default Filter;
|
|
@@ -7,29 +7,29 @@ var _templateObject;
|
|
|
7
7
|
import React, { useEffect } from 'react';
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
9
9
|
import styled from 'styled-components';
|
|
10
|
+
import cx from 'classnames';
|
|
10
11
|
import { Classes } from '../../../base/styles';
|
|
11
12
|
import FilterPanel from './FilterPanel';
|
|
12
13
|
import DefaultFilterContent from './DefaultFilterContent';
|
|
14
|
+
import DefaultFilterIcon from './DefaultFilterIcon';
|
|
13
15
|
import { calculatePopupRelative } from '../../../utils';
|
|
14
16
|
import { addResizeObserver } from '../../../base/utils';
|
|
15
|
-
import
|
|
16
|
-
var HEADER_ICON_OFFSET_Y =
|
|
17
|
+
import KeyCode from '../../../utils/keyCode';
|
|
18
|
+
var HEADER_ICON_OFFSET_Y = 8 + 1; // padding-top + border
|
|
17
19
|
|
|
18
20
|
var HEADER_ICON_OFFSET_X = 16 + 1; // padding-left+ border
|
|
19
21
|
|
|
20
|
-
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"])));
|
|
22
|
+
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);
|
|
21
23
|
|
|
22
24
|
function Panel(_ref) {
|
|
23
25
|
var ele = _ref.ele,
|
|
24
26
|
filterIcon = _ref.filterIcon,
|
|
25
27
|
hidePanel = _ref.hidePanel,
|
|
26
|
-
renderPanelContent = _ref.renderPanelContent
|
|
28
|
+
renderPanelContent = _ref.renderPanelContent,
|
|
29
|
+
hideFilterPopupHeader = _ref.hideFilterPopupHeader;
|
|
27
30
|
var filterPanelRef = React.useRef(null);
|
|
28
31
|
|
|
29
|
-
var _React$useState = React.useState(calculatePopupRelative(ele, document.body,
|
|
30
|
-
x: HEADER_ICON_OFFSET_X,
|
|
31
|
-
y: HEADER_ICON_OFFSET_Y
|
|
32
|
-
})),
|
|
32
|
+
var _React$useState = React.useState(calculatePopupRelative(ele, document.body, _getPanelOffset(ele, hideFilterPopupHeader))),
|
|
33
33
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
34
34
|
position = _React$useState2[0],
|
|
35
35
|
setPosition = _React$useState2[1];
|
|
@@ -40,10 +40,7 @@ function Panel(_ref) {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
var handleFilterPanelResize = function handleFilterPanelResize(resize) {
|
|
43
|
-
setPosition(calculatePopupRelative(ele, document.body,
|
|
44
|
-
x: HEADER_ICON_OFFSET_X,
|
|
45
|
-
y: HEADER_ICON_OFFSET_Y
|
|
46
|
-
}));
|
|
43
|
+
setPosition(calculatePopupRelative(ele, document.body, _getPanelOffset(ele, hideFilterPopupHeader)));
|
|
47
44
|
};
|
|
48
45
|
|
|
49
46
|
useEffect(function () {
|
|
@@ -58,7 +55,8 @@ function Panel(_ref) {
|
|
|
58
55
|
style: style,
|
|
59
56
|
onClose: hidePanel,
|
|
60
57
|
position: position,
|
|
61
|
-
filterIcon: filterIcon
|
|
58
|
+
filterIcon: filterIcon,
|
|
59
|
+
hideFilterPopupHeader: hideFilterPopupHeader
|
|
62
60
|
}, renderPanelContent()));
|
|
63
61
|
}
|
|
64
62
|
|
|
@@ -75,7 +73,8 @@ function Filter(_ref2) {
|
|
|
75
73
|
setFilterModel = _ref2.setFilterModel,
|
|
76
74
|
filterModel = _ref2.filterModel,
|
|
77
75
|
isFilterActive = _ref2.isFilterActive,
|
|
78
|
-
stopClickEventPropagation = _ref2.stopClickEventPropagation
|
|
76
|
+
stopClickEventPropagation = _ref2.stopClickEventPropagation,
|
|
77
|
+
hideFilterPopupHeader = _ref2.hideFilterPopupHeader;
|
|
79
78
|
|
|
80
79
|
var _React$useState3 = React.useState(false),
|
|
81
80
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
@@ -83,15 +82,12 @@ function Filter(_ref2) {
|
|
|
83
82
|
setShowPanel = _React$useState4[1];
|
|
84
83
|
|
|
85
84
|
var iconRef = React.useRef(null);
|
|
85
|
+
var iconWrapRef = React.useRef();
|
|
86
86
|
|
|
87
87
|
var hidePanel = function hidePanel() {
|
|
88
88
|
return setShowPanel(false);
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
var handleMouseDown = function handleMouseDown(e) {
|
|
92
|
-
e.stopPropagation(); // 阻止触发拖拽
|
|
93
|
-
};
|
|
94
|
-
|
|
95
91
|
var renderPanelContent = function renderPanelContent() {
|
|
96
92
|
if (FilterPanelContent) {
|
|
97
93
|
return /*#__PURE__*/React.createElement(FilterPanelContent, {
|
|
@@ -111,6 +107,12 @@ function Filter(_ref2) {
|
|
|
111
107
|
};
|
|
112
108
|
|
|
113
109
|
var handleIconClick = function handleIconClick(e) {
|
|
110
|
+
// 只有当icon区域点击会触发面板展开
|
|
111
|
+
// 防止 createPortal 区域的点击触发该事件
|
|
112
|
+
if (!e.currentTarget.contains(e.target)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
114
116
|
if (stopClickEventPropagation) {
|
|
115
117
|
e.stopPropagation();
|
|
116
118
|
}
|
|
@@ -118,31 +120,48 @@ function Filter(_ref2) {
|
|
|
118
120
|
setShowPanel(true);
|
|
119
121
|
};
|
|
120
122
|
|
|
123
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
124
|
+
if (e.currentTarget.contains(e.target) && e.keyCode === KeyCode.ESC) {
|
|
125
|
+
setShowPanel(false);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
121
129
|
var iconClassName = cx((_cx = {}, _defineProperty(_cx, className, true), _defineProperty(_cx, 'filter-panel-open', showPanel), _cx));
|
|
130
|
+
var displayFilterIcon = typeof filterIcon === 'function' ? filterIcon(isFilterActive) : filterIcon;
|
|
122
131
|
return /*#__PURE__*/React.createElement(FilterIconSpanStyle, {
|
|
123
132
|
style: style,
|
|
124
133
|
className: iconClassName,
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
onClick: handleIconClick,
|
|
135
|
+
onKeyDown: handleKeyDown,
|
|
136
|
+
ref: iconWrapRef,
|
|
137
|
+
tabIndex: -1
|
|
127
138
|
}, /*#__PURE__*/React.createElement("span", {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
},
|
|
139
|
+
ref: iconRef,
|
|
140
|
+
className: Classes.filterIcon
|
|
141
|
+
}, displayFilterIcon || /*#__PURE__*/React.createElement(DefaultFilterIcon, {
|
|
131
142
|
width: size,
|
|
132
|
-
height: size
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
fill: "currentColor",
|
|
137
|
-
"aria-hidden": "true"
|
|
138
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
139
|
-
d: "M349 838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3\n 31.8-32V642H349v196zm531.1-684H143.9c-24.5 0-39.8 26.7-27.5\n 48l221.3 376h348.8l221.3-376c12.1-21.3-3.2-48-27.7-48z"
|
|
140
|
-
}))), showPanel && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(Panel, {
|
|
141
|
-
ele: iconRef.current,
|
|
142
|
-
filterIcon: filterIcon,
|
|
143
|
+
height: size
|
|
144
|
+
})), showPanel && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(Panel, {
|
|
145
|
+
ele: hideFilterPopupHeader ? iconWrapRef.current : iconRef.current,
|
|
146
|
+
filterIcon: displayFilterIcon,
|
|
143
147
|
hidePanel: hidePanel,
|
|
144
|
-
renderPanelContent: renderPanelContent
|
|
148
|
+
renderPanelContent: renderPanelContent,
|
|
149
|
+
hideFilterPopupHeader: hideFilterPopupHeader
|
|
145
150
|
}), document.body));
|
|
146
151
|
}
|
|
147
152
|
|
|
153
|
+
function _getPanelOffset(ele, hideFilterPopupHeader) {
|
|
154
|
+
if (hideFilterPopupHeader) {
|
|
155
|
+
return {
|
|
156
|
+
x: 0,
|
|
157
|
+
y: 0 - ele.offsetHeight
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
x: HEADER_ICON_OFFSET_X,
|
|
163
|
+
y: HEADER_ICON_OFFSET_Y
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
148
167
|
export default Filter;
|
|
@@ -10,11 +10,12 @@ export interface FilterPanel {
|
|
|
10
10
|
filterIcon: ReactNode;
|
|
11
11
|
children?: ReactNode;
|
|
12
12
|
}
|
|
13
|
-
declare function FilterPanel({ style, children, position, filterIcon, onClose }: {
|
|
13
|
+
declare function FilterPanel({ style, children, position, filterIcon, onClose, hideFilterPopupHeader }: {
|
|
14
14
|
style: any;
|
|
15
15
|
children: any;
|
|
16
16
|
position: any;
|
|
17
17
|
filterIcon: any;
|
|
18
18
|
onClose: any;
|
|
19
|
+
hideFilterPopupHeader: any;
|
|
19
20
|
}): JSX.Element;
|
|
20
21
|
export default FilterPanel;
|
|
@@ -4,10 +4,13 @@ import _taggedTemplateLiteral from "@babel/runtime-corejs3/helpers/taggedTemplat
|
|
|
4
4
|
|
|
5
5
|
var _templateObject;
|
|
6
6
|
|
|
7
|
-
import React, { useEffect, useState } from 'react';
|
|
7
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
import { isElementInEventPath, keepWithinBounds } from '../../../utils/';
|
|
10
|
-
|
|
10
|
+
import DefaultFilterIcon from './DefaultFilterIcon';
|
|
11
|
+
import { Classes } from '../../../base/styles';
|
|
12
|
+
import KeyCode from '../../../utils/keyCode';
|
|
13
|
+
var FilterPanelStyle = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n max-height: 450px;\n min-width: 160px;\n border-radius: 2px;\n background-color: #fff;\n box-shadow: 0 0 5px 0 rgba(154,154,154,.5);\n cursor: default;\n\n .", " {\n display: flex;\n background-color: #ebedf1;\n\n .", " {\n display: flex;\n color:#666;\n background-color: #fff;\n padding: 8px 16px 8px 16px;\n border-right: 1px solid transparent;\n border-left: 1px solid transparent;\n border-top: 1px solid transparent;\n border-top-right-radius: 2px;\n border-top-left-radius: 2px;\n }\n }\n\n .", " {\n display: flex;\n }\n"])), Classes.popupHeader, Classes.filterIcon, Classes.popupBody);
|
|
11
14
|
|
|
12
15
|
var useWindowEvents = function useWindowEvents(func, evens) {
|
|
13
16
|
React.useEffect(function () {
|
|
@@ -27,7 +30,8 @@ function FilterPanel(_ref) {
|
|
|
27
30
|
children = _ref.children,
|
|
28
31
|
position = _ref.position,
|
|
29
32
|
filterIcon = _ref.filterIcon,
|
|
30
|
-
onClose = _ref.onClose
|
|
33
|
+
onClose = _ref.onClose,
|
|
34
|
+
hideFilterPopupHeader = _ref.hideFilterPopupHeader;
|
|
31
35
|
|
|
32
36
|
var _useState = useState(position),
|
|
33
37
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -49,32 +53,47 @@ function FilterPanel(_ref) {
|
|
|
49
53
|
setPerfectPosition(keepWithinBounds(document.body, ref.current, position.x, position.y, true));
|
|
50
54
|
setVisible(true);
|
|
51
55
|
}, [position]);
|
|
56
|
+
var hasPopupMouseEvent = useRef(false);
|
|
57
|
+
|
|
58
|
+
var handleMouseEvent = function handleMouseEvent() {
|
|
59
|
+
// 当弹出的过滤面板内部发生鼠标按下、抬起事件时,标记当前事件,并在click捕获期清除标记,用来确定鼠标按下、抬起发生在过滤面板内部
|
|
60
|
+
// 利用了React.createPortal冒泡是根据React Tree的特性:
|
|
61
|
+
// https://jwwnz.medium.com/react-portals-and-event-bubbling-8df3e35ca3f1
|
|
62
|
+
hasPopupMouseEvent.current = true;
|
|
63
|
+
};
|
|
64
|
+
|
|
52
65
|
useWindowEvents(function (e) {
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
!isContainPanel(e) && !hasPopupMouseEvent.current && onClose();
|
|
67
|
+
hasPopupMouseEvent.current = false;
|
|
68
|
+
}, ['click']);
|
|
69
|
+
|
|
70
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
71
|
+
if (e.currentTarget.contains(e.target) && e.keyCode === KeyCode.ESC) {
|
|
72
|
+
onClose();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
55
76
|
return /*#__PURE__*/React.createElement(FilterPanelStyle, {
|
|
77
|
+
className: Classes.popup,
|
|
56
78
|
style: _extends(_extends({}, style), {
|
|
57
79
|
left: visible ? perfectPosition.x : 0,
|
|
58
80
|
top: visible ? perfectPosition.y : 0,
|
|
59
81
|
opacity: visible ? 1 : 0
|
|
60
82
|
}),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
onMouseDown: handleMouseEvent,
|
|
84
|
+
onMouseUp: handleMouseEvent,
|
|
85
|
+
onKeyDown: handleKeyDown,
|
|
86
|
+
ref: ref,
|
|
87
|
+
tabIndex: -1
|
|
88
|
+
}, !hideFilterPopupHeader ? /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
className: Classes.popupHeader
|
|
64
90
|
}, /*#__PURE__*/React.createElement("span", {
|
|
65
|
-
className:
|
|
66
|
-
}, filterIcon || /*#__PURE__*/React.createElement(
|
|
67
|
-
width:
|
|
68
|
-
height:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"data-icon": "filter",
|
|
72
|
-
fill: "currentColor",
|
|
73
|
-
"aria-hidden": "true"
|
|
74
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
75
|
-
d: "M349 838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3\n 31.8-32V642H349v196zm531.1-684H143.9c-24.5 0-39.8 26.7-27.5\n 48l221.3 376h348.8l221.3-376c12.1-21.3-3.2-48-27.7-48z"
|
|
76
|
-
})))), /*#__PURE__*/React.createElement("div", {
|
|
77
|
-
className: "popup-body"
|
|
91
|
+
className: Classes.filterIcon
|
|
92
|
+
}, filterIcon || /*#__PURE__*/React.createElement(DefaultFilterIcon, {
|
|
93
|
+
width: 12,
|
|
94
|
+
height: 12
|
|
95
|
+
}))) : null, /*#__PURE__*/React.createElement("div", {
|
|
96
|
+
className: Classes.popupBody
|
|
78
97
|
}, children));
|
|
79
98
|
}
|
|
80
99
|
|
|
@@ -12,7 +12,7 @@ var DEFAULT_FILTER_OPTIONS = [{
|
|
|
12
12
|
data = data + '';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
return _includesInstanceProperty(data).call(data, value);
|
|
15
|
+
return _includesInstanceProperty(data).call(data, value[0]);
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}, {
|
|
@@ -28,7 +28,7 @@ var DEFAULT_FILTER_OPTIONS = [{
|
|
|
28
28
|
data = data + '';
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
return !_includesInstanceProperty(data).call(data, value);
|
|
31
|
+
return !_includesInstanceProperty(data).call(data, value[0]);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
}, {
|
|
@@ -36,7 +36,7 @@ var DEFAULT_FILTER_OPTIONS = [{
|
|
|
36
36
|
key: 'equal',
|
|
37
37
|
filter: function filter(value) {
|
|
38
38
|
return function (data) {
|
|
39
|
-
return value
|
|
39
|
+
return value[0] === data;
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
}, {
|
|
@@ -44,7 +44,7 @@ var DEFAULT_FILTER_OPTIONS = [{
|
|
|
44
44
|
key: 'notEqual',
|
|
45
45
|
filter: function filter(value) {
|
|
46
46
|
return function (data) {
|
|
47
|
-
return value !== data;
|
|
47
|
+
return value[0] !== data;
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}, {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TablePipeline } from '../pipeline';
|
|
2
|
+
export interface FooterDataSourceFeatureOptions {
|
|
3
|
+
/** 指定表格页脚每一行元信息的记录字段 */
|
|
4
|
+
footerRowMetaKey?: string | symbol;
|
|
5
|
+
/** 表格页脚数据源 */
|
|
6
|
+
dataSource?: any[];
|
|
7
|
+
}
|
|
8
|
+
export declare const footerRowMetaSymbol: unique symbol;
|
|
9
|
+
export declare function footerDataSource(opts?: FooterDataSourceFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
3
|
+
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
4
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
5
|
+
export var footerRowMetaSymbol = _Symbol('footer-row');
|
|
6
|
+
export function footerDataSource() {
|
|
7
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8
|
+
return function footerDataSourceStep(pipeline) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
|
|
11
|
+
var footerDataSource = (_a = opts.dataSource) !== null && _a !== void 0 ? _a : pipeline.getFooterDataSource();
|
|
12
|
+
var footerRowMetaKey = (_b = opts.footerRowMetaKey) !== null && _b !== void 0 ? _b : footerRowMetaSymbol;
|
|
13
|
+
pipeline.setFeatureOptions('footerRowMetaKey', footerRowMetaKey);
|
|
14
|
+
|
|
15
|
+
if (footerDataSource) {
|
|
16
|
+
pipeline.footerDataSource(_mapInstanceProperty(footerDataSource).call(footerDataSource, function (row) {
|
|
17
|
+
return _extends(_defineProperty({}, footerRowMetaKey, true), row);
|
|
18
|
+
}));
|
|
19
|
+
} else {
|
|
20
|
+
console.warn('调用 pipeline.use(features.footerDataSource()) 前请先设置页脚数据源,设置方法有:pipeline.use(features.footerDataSource({dataSource:any[]})) 或者 pipeline.footerDataSource(any[])');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return pipeline;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -16,3 +16,5 @@ export { contextMenu, ContextMenuFeatureOptions } from './contextMenu';
|
|
|
16
16
|
export { filter, FilterFeatureOptions } from './columnFilter';
|
|
17
17
|
export { rangeSelection, RangeSelectionFeatureOptions } from './rangeSelection';
|
|
18
18
|
export { mergeCellHover } from './mergeCellHover';
|
|
19
|
+
export { footerDataSource, FooterDataSourceFeatureOptions, footerRowMetaSymbol } from './footerDataSource';
|
|
20
|
+
export { colGroupExtendable, colGroupExtendOption } from './colGroupExtendable';
|
|
@@ -15,4 +15,6 @@ export { columnResize } from './columnResizeWidth';
|
|
|
15
15
|
export { contextMenu } from './contextMenu';
|
|
16
16
|
export { filter } from './columnFilter';
|
|
17
17
|
export { rangeSelection } from './rangeSelection';
|
|
18
|
-
export { mergeCellHover } from './mergeCellHover';
|
|
18
|
+
export { mergeCellHover } from './mergeCellHover';
|
|
19
|
+
export { footerDataSource, footerRowMetaSymbol } from './footerDataSource';
|
|
20
|
+
export { colGroupExtendable } from './colGroupExtendable';
|
|
@@ -5,7 +5,7 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { internals } from '../../internals';
|
|
7
7
|
import { always, arrayUtils } from '../../utils/others';
|
|
8
|
-
import { mergeCellProps } from '../../utils';
|
|
8
|
+
import { collectNodes, mergeCellProps } from '../../utils';
|
|
9
9
|
export function multiSelect() {
|
|
10
10
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
11
|
return function multiSelectStep(pipeline) {
|
|
@@ -44,7 +44,8 @@ export function multiSelect() {
|
|
|
44
44
|
/** 所有有效的 keys(disable 状态为 false) */
|
|
45
45
|
|
|
46
46
|
var allKeys = [];
|
|
47
|
-
|
|
47
|
+
var flatDataSource = collectNodes(dataSource);
|
|
48
|
+
flatDataSource.forEach(function (row, rowIndex) {
|
|
48
49
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
49
50
|
fullKeySet.add(rowKey); // 在 allKeys 中排除被禁用的 key
|
|
50
51
|
|
|
@@ -110,6 +111,10 @@ export function multiSelect() {
|
|
|
110
111
|
return mergeCellProps(preCellProps, checkboxCellProps);
|
|
111
112
|
},
|
|
112
113
|
render: function render(_, row, rowIndex) {
|
|
114
|
+
if (row[pipeline.getFeatureOptions('footerRowMetaKey')]) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
113
118
|
var key = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
114
119
|
var checked = set.has(key);
|
|
115
120
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
@@ -6,5 +6,5 @@ export interface RangeSelectionFeatureOptions {
|
|
|
6
6
|
preventkDefaultOfKeyDownEvent?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare const rangeSelectionKey = "rangeSelection";
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const lastClickCellKey = "lastClickCell";
|
|
10
10
|
export declare function rangeSelection(opts: RangeSelectionFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
|