ztxkui 4.2.18-116 → 4.2.18-118
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.
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React, { useState } from 'react';
|
|
13
|
+
// 注意:不要从 '../../index'(入口文件)导入组件
|
|
14
|
+
// 入口文件 index.tsx 依赖 './UI',从这里导入会形成循环引用,
|
|
15
|
+
// 导致模块顶层解构时组件还是 undefined
|
|
16
|
+
import Select from '../../components/Select';
|
|
17
|
+
import EnhanceSelect from '../../components/EnhanceSelect';
|
|
18
|
+
import FetchSelect from '../../components/FetchSelect';
|
|
19
|
+
var Option = Select.Option, OptGroup = Select.OptGroup;
|
|
20
|
+
var sectionStyle = {
|
|
21
|
+
marginBottom: 24,
|
|
22
|
+
};
|
|
23
|
+
var labelStyle = {
|
|
24
|
+
display: 'block',
|
|
25
|
+
marginBottom: 8,
|
|
26
|
+
fontSize: 14,
|
|
27
|
+
fontWeight: 600,
|
|
28
|
+
color: '#333',
|
|
29
|
+
};
|
|
30
|
+
var descStyle = {
|
|
31
|
+
marginTop: 4,
|
|
32
|
+
fontSize: 12,
|
|
33
|
+
color: '#999',
|
|
34
|
+
};
|
|
35
|
+
var widthStyle = { width: 240 };
|
|
36
|
+
/** 基础选项数据 */
|
|
37
|
+
var fruitOptions = [
|
|
38
|
+
{ id: 'apple', name: '苹果' },
|
|
39
|
+
{ id: 'banana', name: '香蕉' },
|
|
40
|
+
{ id: 'orange', name: '橙子' },
|
|
41
|
+
{ id: 'grape', name: '葡萄' },
|
|
42
|
+
{ id: 'peach', name: '桃子' },
|
|
43
|
+
];
|
|
44
|
+
/** 模拟远程接口:FetchSelect 要求返回 { status: 200, data: { code: 200, data: { records: [] } } } */
|
|
45
|
+
function mockRequest(options) {
|
|
46
|
+
var _a;
|
|
47
|
+
var searchKey = ((_a = options === null || options === void 0 ? void 0 : options.params) === null || _a === void 0 ? void 0 : _a.name) || '';
|
|
48
|
+
var allUsers = [
|
|
49
|
+
{ id: '1', name: '张三' },
|
|
50
|
+
{ id: '2', name: '李四' },
|
|
51
|
+
{ id: '3', name: '王五' },
|
|
52
|
+
{ id: '4', name: '赵六' },
|
|
53
|
+
{ id: '5', name: '孙七' },
|
|
54
|
+
];
|
|
55
|
+
var records = allUsers.filter(function (item) { return item.name.indexOf(searchKey) >= 0; });
|
|
56
|
+
return Promise.resolve({
|
|
57
|
+
status: 200,
|
|
58
|
+
data: { code: 200, data: { records: records } },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 下拉框示例
|
|
63
|
+
*
|
|
64
|
+
* - Select:对 antd Select 的封装,点击已选中项可再次展开下拉框
|
|
65
|
+
* - EnhanceSelect:增强下拉框,支持直接传 list、远程搜索、全选/反选、拼接字段等
|
|
66
|
+
* - FetchSelect:远程获取数据的下拉框,输入时防抖远程搜索
|
|
67
|
+
*/
|
|
68
|
+
var SelectDemo = function () {
|
|
69
|
+
var _a = useState('apple'), singleValue = _a[0], setSingleValue = _a[1];
|
|
70
|
+
var _b = useState(['banana', 'orange']), multiValue = _b[0], setMultiValue = _b[1];
|
|
71
|
+
var _c = useState(), enhanceSingleValue = _c[0], setEnhanceSingleValue = _c[1];
|
|
72
|
+
var _d = useState([]), enhanceMultiValue = _d[0], setEnhanceMultiValue = _d[1];
|
|
73
|
+
var _e = useState(), fetchValue = _e[0], setFetchValue = _e[1];
|
|
74
|
+
var _f = useState(), enhanceCurrentData = _f[0], setEnhanceCurrentData = _f[1];
|
|
75
|
+
return (React.createElement("div", { style: { padding: '20px', maxWidth: 600 } },
|
|
76
|
+
React.createElement("h2", null, "\u4E0B\u62C9\u6846"),
|
|
77
|
+
React.createElement("div", { style: sectionStyle },
|
|
78
|
+
React.createElement("label", { style: labelStyle }, "\u57FA\u7840\u7528\u6CD5\uFF08Select.Option\uFF0C\u53EF\u6E05\u7A7A\uFF09"),
|
|
79
|
+
React.createElement(Select, { style: widthStyle, allowClear: true, placeholder: "\u8BF7\u9009\u62E9\u6C34\u679C", value: singleValue, onChange: function (value) { return setSingleValue(value); } }, fruitOptions.map(function (item) { return (React.createElement(Option, { key: item.id, value: item.id }, item.name)); })),
|
|
80
|
+
React.createElement("div", { style: descStyle },
|
|
81
|
+
"\u5F53\u524D\u9009\u4E2D\uFF1A",
|
|
82
|
+
singleValue || '未选择')),
|
|
83
|
+
React.createElement("div", { style: sectionStyle },
|
|
84
|
+
React.createElement("label", { style: labelStyle }, "\u7981\u7528\u72B6\u6001\uFF08\u7EC4\u4EF6\u7981\u7528 + \u9009\u9879\u7981\u7528\uFF09"),
|
|
85
|
+
React.createElement(Select, { style: widthStyle, defaultValue: "apple", disabled: true }, fruitOptions.map(function (item) { return (React.createElement(Option, { key: item.id, value: item.id }, item.name)); })),
|
|
86
|
+
React.createElement(Select, { style: __assign(__assign({}, widthStyle), { marginLeft: 12 }), placeholder: "\u8461\u8404\u4E0D\u53EF\u9009" }, fruitOptions.map(function (item) { return (React.createElement(Option, { key: item.id, value: item.id, disabled: item.id === 'grape' }, item.name)); }))),
|
|
87
|
+
React.createElement("div", { style: sectionStyle },
|
|
88
|
+
React.createElement("label", { style: labelStyle }, "\u591A\u9009\u6A21\u5F0F\uFF08mode=\"multiple\"\uFF09"),
|
|
89
|
+
React.createElement(Select, { style: { width: 360 }, mode: "multiple", allowClear: true, placeholder: "\u8BF7\u9009\u62E9\u591A\u4E2A\u6C34\u679C", value: multiValue, onChange: function (value) { return setMultiValue(value); } }, fruitOptions.map(function (item) { return (React.createElement(Option, { key: item.id, value: item.id }, item.name)); })),
|
|
90
|
+
React.createElement("div", { style: descStyle },
|
|
91
|
+
"\u5F53\u524D\u9009\u4E2D\uFF1A",
|
|
92
|
+
multiValue.join('、') || '未选择')),
|
|
93
|
+
React.createElement("div", { style: sectionStyle },
|
|
94
|
+
React.createElement("label", { style: labelStyle }, "\u672C\u5730\u641C\u7D22\uFF08showSearch\uFF0C\u6309\u9009\u9879\u6587\u672C\u8FC7\u6EE4\uFF09"),
|
|
95
|
+
React.createElement(Select, { style: widthStyle, showSearch: true, allowClear: true, placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u641C\u7D22", optionFilterProp: "children" }, fruitOptions.map(function (item) { return (React.createElement(Option, { key: item.id, value: item.id }, item.name)); })),
|
|
96
|
+
React.createElement("div", { style: descStyle }, "optionFilterProp=\"children\" \u8868\u793A\u6309\u9009\u9879\u5185\u5BB9\u5339\u914D\uFF08\u4E0D\u533A\u5206\u5927\u5C0F\u5199\uFF09")),
|
|
97
|
+
React.createElement("div", { style: sectionStyle },
|
|
98
|
+
React.createElement("label", { style: labelStyle }, "\u5206\u7EC4\uFF08Select.OptGroup\uFF09"),
|
|
99
|
+
React.createElement(Select, { style: widthStyle, placeholder: "\u8BF7\u9009\u62E9" },
|
|
100
|
+
React.createElement(OptGroup, { label: "\u6C34\u679C" },
|
|
101
|
+
React.createElement(Option, { value: "apple" }, "\u82F9\u679C"),
|
|
102
|
+
React.createElement(Option, { value: "banana" }, "\u9999\u8549")),
|
|
103
|
+
React.createElement(OptGroup, { label: "\u852C\u83DC" },
|
|
104
|
+
React.createElement(Option, { value: "potato" }, "\u571F\u8C46"),
|
|
105
|
+
React.createElement(Option, { value: "tomato" }, "\u897F\u7EA2\u67FF")))),
|
|
106
|
+
React.createElement("div", { style: sectionStyle },
|
|
107
|
+
React.createElement("label", { style: labelStyle }, "\u589E\u5F3A\u4E0B\u62C9\u6846\uFF08EnhanceSelect\uFF0C\u76F4\u63A5\u4F20 list \u6570\u636E\uFF09"),
|
|
108
|
+
React.createElement(EnhanceSelect, { style: widthStyle, allowClear: true, placeholder: "\u8BF7\u9009\u62E9\u6C34\u679C", list: fruitOptions, dataKey: "id", titleKey: "name", value: enhanceSingleValue, onChange: function (value, _option, currentData) {
|
|
109
|
+
setEnhanceSingleValue(value);
|
|
110
|
+
setEnhanceCurrentData(currentData);
|
|
111
|
+
} }),
|
|
112
|
+
React.createElement("div", { style: descStyle },
|
|
113
|
+
"\u5F53\u524D\u9009\u4E2D\uFF1A",
|
|
114
|
+
enhanceSingleValue || '未选择',
|
|
115
|
+
enhanceCurrentData
|
|
116
|
+
? "\uFF08\u5B8C\u6574\u6570\u636E\uFF1A" + JSON.stringify(enhanceCurrentData) + "\uFF09"
|
|
117
|
+
: ''),
|
|
118
|
+
React.createElement("div", { style: descStyle }, "onChange \u7B2C\u4E09\u4E2A\u53C2\u6570 currentData \u662F\u5F53\u524D\u9009\u4E2D\u9879\u7684\u539F\u59CB\u6570\u636E\u5BF9\u8C61")),
|
|
119
|
+
React.createElement("div", { style: sectionStyle },
|
|
120
|
+
React.createElement("label", { style: labelStyle }, "\u589E\u5F3A\u4E0B\u62C9\u6846\uFF08\u663E\u793A\"\u5168\u90E8\"\u9009\u9879 + \u62FC\u63A5\u5B57\u6BB5 joinKey\uFF09"),
|
|
121
|
+
React.createElement(EnhanceSelect, { style: { width: 360 }, allowClear: true, placeholder: "\u8BF7\u9009\u62E9", list: [
|
|
122
|
+
{ id: '1', name: '张三', code: 'A001', dept: '人事部' },
|
|
123
|
+
{ id: '2', name: '李四', code: 'A002', dept: '财务部' },
|
|
124
|
+
{ id: '3', name: '王五', code: 'A003', dept: '人事部' },
|
|
125
|
+
{ id: '3', name: '王五', code: '', dept: '人事部' },
|
|
126
|
+
], dataKey: "id", titleKey: "name", joinKey: ['code', 'dept'], joinStr: "-", showAll: true }),
|
|
127
|
+
React.createElement("div", { style: descStyle }, "showAll \u4F1A\u5728\u6700\u4E0A\u65B9\u8FFD\u52A0\u4E00\u9879 value \u4E3A\u7A7A\u5B57\u7B26\u4E32\u7684\"\u5168\u90E8\"\uFF1BjoinKey \u628A\u591A\u4E2A\u5B57\u6BB5\u7528 joinStr \u62FC\u63A5\u5C55\u793A")),
|
|
128
|
+
React.createElement("div", { style: sectionStyle },
|
|
129
|
+
React.createElement("label", { style: labelStyle }, "\u589E\u5F3A\u4E0B\u62C9\u6846\uFF08\u591A\u9009 + \u4E0B\u62C9\u5E95\u90E8\u5168\u9009/\u53CD\u9009\u6309\u94AE\uFF09"),
|
|
130
|
+
React.createElement(EnhanceSelect, { style: { width: 360 }, mode: "multiple", allowClear: true, placeholder: "\u8BF7\u9009\u62E9\u591A\u4E2A", list: fruitOptions, dataKey: "id", titleKey: "name", value: enhanceMultiValue,
|
|
131
|
+
// 多选模式下 value 实际是数组,但组件 onChange 类型声明为 string,这里做一次断言
|
|
132
|
+
onChange: function (value) {
|
|
133
|
+
return setEnhanceMultiValue(value || []);
|
|
134
|
+
} }),
|
|
135
|
+
React.createElement("div", { style: descStyle },
|
|
136
|
+
"mode=\"multiple\" \u65F6\u4E0B\u62C9\u5E95\u90E8\u81EA\u52A8\u51FA\u73B0\u300C\u5168\u9009\u300D\u300C\u53CD\u9009\u300D\u6309\u94AE\uFF1B\u5F53\u524D\u9009\u4E2D\uFF1A",
|
|
137
|
+
enhanceMultiValue.join('、') || '未选择')),
|
|
138
|
+
React.createElement("div", { style: sectionStyle },
|
|
139
|
+
React.createElement("label", { style: labelStyle }, "\u589E\u5F3A\u4E0B\u62C9\u6846\uFF08\u7981\u7528\u6307\u5B9A\u9009\u9879 disabledValues\uFF09"),
|
|
140
|
+
React.createElement(EnhanceSelect, { style: widthStyle, placeholder: "\u8461\u8404\u3001\u6843\u5B50\u88AB\u7981\u7528", list: fruitOptions, dataKey: "id", titleKey: "name", disabledValues: ['grape', 'peach'] })),
|
|
141
|
+
React.createElement("div", { style: sectionStyle },
|
|
142
|
+
React.createElement("label", { style: labelStyle }, "\u8FDC\u7A0B\u6570\u636E\u4E0B\u62C9\u6846\uFF08FetchSelect + mock \u63A5\u53E3\uFF09"),
|
|
143
|
+
React.createElement(FetchSelect, { style: widthStyle, allowClear: true, placeholder: "\u8F93\u5165\u59D3\u540D\u8FDC\u7A0B\u641C\u7D22", url: "/mock/users", request: mockRequest, dataKey: "id", dataTitle: "name", value: fetchValue, onChange: function (value) { return setFetchValue(value); } }),
|
|
144
|
+
React.createElement("div", { style: descStyle },
|
|
145
|
+
"\u5F53\u524D\u9009\u4E2D\uFF1A",
|
|
146
|
+
fetchValue || '未选择'),
|
|
147
|
+
React.createElement("div", { style: descStyle }, "FetchSelect \u521D\u59CB\u5316\u81EA\u52A8\u8BF7\u6C42\u4E00\u6B21\uFF0C\u8F93\u5165\u65F6 300ms \u9632\u6296\u8FDC\u7A0B\u641C\u7D22\uFF1B\u5B9E\u9645\u9879\u76EE\u4E2D request \u4E00\u822C\u4F20 axios \u5B9E\u4F8B\uFF0Curl \u4F20\u63A5\u53E3\u5730\u5740\uFF0C\u8FD4\u56DE\u683C\u5F0F\u8981\u6C42 data.records")),
|
|
148
|
+
React.createElement("div", { style: sectionStyle },
|
|
149
|
+
React.createElement("label", { style: labelStyle }, "\u5BF9\u6BD4\u5C0F\u7ED3"),
|
|
150
|
+
React.createElement("ul", { style: { fontSize: 13, color: '#555', lineHeight: '22px' } },
|
|
151
|
+
React.createElement("li", null, "Select\uFF1A\u57FA\u7840\u5C01\u88C5\uFF0C\u7528\u6CD5\u540C antd Select\uFF0C\u4FEE\u590D\u4E86\"\u70B9\u51FB\u5DF2\u9009\u4E2D\u9879\u4E0D\u5C55\u5F00\"\u7684\u95EE\u9898"),
|
|
152
|
+
React.createElement("li", null, "EnhanceSelect\uFF1A\u4F18\u5148\u4F7F\u7528\uFF0C\u652F\u6301 list \u672C\u5730\u6570\u636E\u3001url+request \u8FDC\u7A0B\u6570\u636E\u3001\u8FDC\u7A0B\u641C\u7D22\u3001\u5168\u9009/\u53CD\u9009\u3001\u5B57\u6BB5\u62FC\u63A5\u3001\u6570\u636E\u7F13\u5B58\uFF08isCatch\uFF09\u7B49"),
|
|
153
|
+
React.createElement("li", null, "FetchSelect\uFF1A\u8F7B\u91CF\u8FDC\u7A0B\u6570\u636E\u4E0B\u62C9\u6846\uFF0C\u53EA\u505A\"\u62C9\u53D6 + \u641C\u7D22\"\uFF0C\u8FD4\u56DE\u683C\u5F0F\u8981\u6C42 data.records"),
|
|
154
|
+
React.createElement("li", null, "\u4E09\u4E2A\u7EC4\u4EF6\u7684 onChange \u90FD\u4F1A\u56DE\u4F20 (value, option)\uFF0CEnhanceSelect \u989D\u5916\u56DE\u4F20\u7B2C\u4E09\u4E2A\u53C2\u6570 currentData\uFF08\u9009\u4E2D\u9879\u539F\u59CB\u6570\u636E\uFF09")))));
|
|
155
|
+
};
|
|
156
|
+
export default SelectDemo;
|
package/dist/UI/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import TableDemo from './Table';
|
|
|
6
6
|
import TreeSelectDemo from './TreeSelect';
|
|
7
7
|
import InputNumberDemo from './InputNumber';
|
|
8
8
|
import InputDemo from './Input';
|
|
9
|
+
import SelectDemo from './Select';
|
|
9
10
|
export default function UIComponent() {
|
|
10
11
|
return (React.createElement("div", { style: { padding: '10px' } },
|
|
11
12
|
React.createElement(Link, { to: "/ui/form", style: { marginRight: '10px' } }, "\u8868\u5355"),
|
|
@@ -14,6 +15,7 @@ export default function UIComponent() {
|
|
|
14
15
|
React.createElement(Link, { to: "/ui/tree-select", style: { marginRight: '10px' } }, "\u6811\u4E0B\u62C9\u6846"),
|
|
15
16
|
React.createElement(Link, { to: "/ui/input-number", style: { marginRight: '10px' } }, "\u6570\u5B57\u8F93\u5165\u6846"),
|
|
16
17
|
React.createElement(Link, { to: "/ui/input", style: { marginRight: '10px' } }, "\u8F93\u5165\u6846"),
|
|
18
|
+
React.createElement(Link, { to: "/ui/select", style: { marginRight: '10px' } }, "\u4E0B\u62C9\u6846"),
|
|
17
19
|
React.createElement(Switch, null,
|
|
18
20
|
React.createElement(Route, { path: "/ui/form" },
|
|
19
21
|
React.createElement(Form, null)),
|
|
@@ -26,5 +28,7 @@ export default function UIComponent() {
|
|
|
26
28
|
React.createElement(Route, { path: "/ui/input-number" },
|
|
27
29
|
React.createElement(InputNumberDemo, null)),
|
|
28
30
|
React.createElement(Route, { path: "/ui/input" },
|
|
29
|
-
React.createElement(InputDemo, null))
|
|
31
|
+
React.createElement(InputDemo, null)),
|
|
32
|
+
React.createElement(Route, { path: "/ui/select" },
|
|
33
|
+
React.createElement(SelectDemo, null)))));
|
|
30
34
|
}
|
|
@@ -796,16 +796,22 @@ function EnhanceSelect(_a) {
|
|
|
796
796
|
var linefeedTitle = [];
|
|
797
797
|
if (joinKey) {
|
|
798
798
|
joinTitle = Array.isArray(joinKey)
|
|
799
|
-
? joinKey
|
|
799
|
+
? joinKey
|
|
800
|
+
// 字段不存在(null/undefined/空字符串)时跳过,避免拼接出多余的连接符
|
|
801
|
+
.map(function (joinItem) { return item[joinItem]; })
|
|
802
|
+
.filter(function (joinValue) { return !isFalsy(joinValue); })
|
|
803
|
+
.map(function (joinValue) { return dangerouslySetXss(joinValue); })
|
|
800
804
|
: item[joinKey]
|
|
801
805
|
? [dangerouslySetXss(item[joinKey])]
|
|
802
806
|
: [];
|
|
803
807
|
}
|
|
804
808
|
if (lineFeedKey) {
|
|
805
809
|
linefeedTitle = Array.isArray(lineFeedKey)
|
|
806
|
-
? lineFeedKey
|
|
807
|
-
|
|
808
|
-
|
|
810
|
+
? lineFeedKey
|
|
811
|
+
// 字段不存在(null/undefined/空字符串)时跳过,避免拼接出多余的连接符
|
|
812
|
+
.map(function (joinItem) { return item[joinItem]; })
|
|
813
|
+
.filter(function (lineFeedValue) { return !isFalsy(lineFeedValue); })
|
|
814
|
+
.map(function (lineFeedValue) { return dangerouslySetXss(lineFeedValue); })
|
|
809
815
|
: item[lineFeedKey]
|
|
810
816
|
? [dangerouslySetXss(item[lineFeedKey])]
|
|
811
817
|
: [];
|
|
@@ -164,7 +164,7 @@ function Table(props) {
|
|
|
164
164
|
var _this = this;
|
|
165
165
|
var _a, _b, _c, _d;
|
|
166
166
|
var className = props.className, scroll = props.scroll, _e = props.pagination, pagination = _e === void 0 ? false : _e, _f = props.bordered, bordered = _f === void 0 ? true : _f, _columns = props.columns, initColumns = props.initColumns, dataSource = props.dataSource, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, showDelAllBtn = props.showDelAllBtn, delAllChange = props.delAllChange, delIconText = props.delIconText, hiddenColumnDynamicIcon = props.hiddenColumnDynamicIcon, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, summaryConfig = props.summaryConfig, summaryFixed = props.summaryFixed, summary = props.summary, onMoveRow = props.onMoveRow, onEditableSave = props.onEditableSave, onDynamicChange = props.onDynamicChange, _g = props.isResizableColumn, isResizableColumn = _g === void 0 ? true : _g, configInfo = props.configInfo, tableHandleRef = props.tableHandleRef, tableName = props.tableName, isFlex = props.isFlex, onTableChange = props.onTableChange, rowSelection = props.rowSelection, showInnerPagination = props.showInnerPagination, defaultInnerPageSize = props.defaultInnerPageSize, virtualTableKey = props.virtualTableKey, isSort = props.isSort, isFilter = props.isFilter, onSortChange = props.onSortChange, onFillDownChange = props.onFillDownChange, _h = props.isModalInput, isModalInput = _h === void 0 ? false : _h, // 默认关闭这个功能
|
|
167
|
-
onRow = props.onRow, isOpenVirtualScrollBar = props.isOpenVirtualScrollBar, _j = props.isNumberInputThousandth, isNumberInputThousandth = _j === void 0 ? true : _j, _k = props.isNumberInputAlignRight, isNumberInputAlignRight = _k === void 0 ? true : _k, _l = props.isContextMenuFullscreen, isContextMenuFullscreen = _l === void 0 ? true : _l, isContextMenu = props.isContextMenu, restProps = __rest(props, ["className", "scroll", "pagination", "bordered", "columns", "initColumns", "dataSource", "onAddAndDelHandle", "hideAddIcon", "addIconText", "hideDelIcon", "showDelAllBtn", "delAllChange", "delIconText", "hiddenColumnDynamicIcon", "showColumnDynamic", "showColumnDynamicKey", "summaryConfig", "summaryFixed", "summary", "onMoveRow", "onEditableSave", "onDynamicChange", "isResizableColumn", "configInfo", "tableHandleRef", "tableName", "isFlex", "onTableChange", "rowSelection", "showInnerPagination", "defaultInnerPageSize", "virtualTableKey", "isSort", "isFilter", "onSortChange", "onFillDownChange", "isModalInput", "onRow", "isOpenVirtualScrollBar", "isNumberInputThousandth", "isNumberInputAlignRight", "isContextMenuFullscreen", "isContextMenu"]);
|
|
167
|
+
onRow = props.onRow, isOpenVirtualScrollBar = props.isOpenVirtualScrollBar, _j = props.isNumberInputThousandth, isNumberInputThousandth = _j === void 0 ? true : _j, _k = props.isNumberInputAlignRight, isNumberInputAlignRight = _k === void 0 ? true : _k, _l = props.isContextMenuFullscreen, isContextMenuFullscreen = _l === void 0 ? true : _l, isContextMenu = props.isContextMenu, originGetPopupContainer = props.getPopupContainer, restProps = __rest(props, ["className", "scroll", "pagination", "bordered", "columns", "initColumns", "dataSource", "onAddAndDelHandle", "hideAddIcon", "addIconText", "hideDelIcon", "showDelAllBtn", "delAllChange", "delIconText", "hiddenColumnDynamicIcon", "showColumnDynamic", "showColumnDynamicKey", "summaryConfig", "summaryFixed", "summary", "onMoveRow", "onEditableSave", "onDynamicChange", "isResizableColumn", "configInfo", "tableHandleRef", "tableName", "isFlex", "onTableChange", "rowSelection", "showInnerPagination", "defaultInnerPageSize", "virtualTableKey", "isSort", "isFilter", "onSortChange", "onFillDownChange", "isModalInput", "onRow", "isOpenVirtualScrollBar", "isNumberInputThousandth", "isNumberInputAlignRight", "isContextMenuFullscreen", "isContextMenu", "getPopupContainer"]);
|
|
168
168
|
var onChange = restProps.onChange;
|
|
169
169
|
var classes = classNames('zt-table', className, {
|
|
170
170
|
'zt-table--flex': isFlex,
|
|
@@ -190,6 +190,43 @@ function Table(props) {
|
|
|
190
190
|
var menuShow = useContextMenu({
|
|
191
191
|
id: menuId,
|
|
192
192
|
}).show;
|
|
193
|
+
/**
|
|
194
|
+
* 浏览器全屏时,全屏元素位于 top layer,挂在 body 上的浮层(过滤下拉等)会被遮挡。
|
|
195
|
+
* 1. getPopupContainer:全屏时把表格浮层挂到表格容器内(实时读取 fullscreenElement,不依赖状态);
|
|
196
|
+
* 2. fullscreenchange:rc-util 的弹层容器只在首次打开时确定挂载点,
|
|
197
|
+
* 非全屏时打开过的过滤弹层仍留在 body,进入全屏后需迁移到全屏元素内,退出时迁回。
|
|
198
|
+
*/
|
|
199
|
+
useEffect(function () {
|
|
200
|
+
var onFullscreenChange = function () {
|
|
201
|
+
var fullscreenEl = document.fullscreenElement;
|
|
202
|
+
if (fullscreenEl) {
|
|
203
|
+
// 仅当前表格在全屏元素内时才迁移(全屏的可能是别的容器)
|
|
204
|
+
if (!tableRef.current || !fullscreenEl.contains(tableRef.current)) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
Array.from(document.body.children).forEach(function (node) {
|
|
208
|
+
var el = node;
|
|
209
|
+
if (el.tagName === 'DIV' &&
|
|
210
|
+
el.querySelector('.ant-table-filter-dropdown')) {
|
|
211
|
+
el.dataset.ztPopupMoved = 'fullscreen';
|
|
212
|
+
fullscreenEl.appendChild(el);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
document
|
|
218
|
+
.querySelectorAll('[data-zt-popup-moved]')
|
|
219
|
+
.forEach(function (el) {
|
|
220
|
+
delete el.dataset.ztPopupMoved;
|
|
221
|
+
document.body.appendChild(el);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
document.addEventListener('fullscreenchange', onFullscreenChange);
|
|
226
|
+
return function () {
|
|
227
|
+
document.removeEventListener('fullscreenchange', onFullscreenChange);
|
|
228
|
+
};
|
|
229
|
+
}, []);
|
|
193
230
|
// 内部分页相关配置
|
|
194
231
|
var _q = useInnerPagination(showInnerPagination, defaultInnerPageSize), paginationConfig = _q.paginationConfig, currentPage = _q.currentPage, setCurrent = _q.setCurrent, pageSize = _q.pageSize;
|
|
195
232
|
var rowSelectionDataSource = useRef({});
|
|
@@ -920,7 +957,18 @@ function Table(props) {
|
|
|
920
957
|
: paginationConfig
|
|
921
958
|
: pagination, scroll: myScroll, columns: mergeColumns, dataSource: sortDataSource ? sortDataSource : expandableDataSource, components: tableComponents, onRow: onInnerRowHandle,
|
|
922
959
|
// onRow={onMoveRow ? onRowHandle : onRowFn}
|
|
923
|
-
summary: summaryConfig ? onSummaryHandle : summary, rowSelection: rowSelection ? rowSelectionObj : rowSelection, locale: tableLocal }, restProps)
|
|
960
|
+
summary: summaryConfig ? onSummaryHandle : summary, rowSelection: rowSelection ? rowSelectionObj : rowSelection, locale: tableLocal }, restProps, { getPopupContainer: function (triggerNode) {
|
|
961
|
+
// 全屏时浮层必须挂到全屏元素内部,否则会被全屏元素遮挡(浏览器 top layer 机制)。
|
|
962
|
+
// 实时读取 fullscreenElement,不依赖 isFull 状态。
|
|
963
|
+
var fullscreenEl = document.fullscreenElement;
|
|
964
|
+
if (fullscreenEl &&
|
|
965
|
+
tableRef.current &&
|
|
966
|
+
fullscreenEl.contains(tableRef.current)) {
|
|
967
|
+
return tableRef.current;
|
|
968
|
+
}
|
|
969
|
+
// 不能返回 undefined:rc-trigger 拿不到挂载点会无限重试,弹层永不显示
|
|
970
|
+
return (originGetPopupContainer === null || originGetPopupContainer === void 0 ? void 0 : originGetPopupContainer(triggerNode)) || document.body;
|
|
971
|
+
} })),
|
|
924
972
|
showColumnDynamic && dynamicVisible && (React.createElement(TableDynamic, { visible: dynamicVisible, onClose: hideDynamicHandle, onSave: saveDynamicHandle, onReset: resetDynamicHandle, columns: dynamicColumns, dynamicStorageKey: showColumnDynamicKey }))),
|
|
925
973
|
React.createElement("div", { ref: tipRef, className: "table-subtotal--tip" }),
|
|
926
974
|
menuId && (React.createElement(TableMenu, { ref: tableMenuRef, menuId: menuId, columns: newColumns, originColumns: _columns, tableRef: tableRef, virtualTableKey: virtualTableKey, onEditableSave: onEditableSave, isContextMenuFullscreen: isContextMenuFullscreen, className: className }))));
|