@teamix/pro 1.5.11-beta.1 → 1.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pro.css +1 -1
- package/dist/pro.js +465 -96
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/index.d.ts +2 -2
- package/es/actions/index.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/page-header/index.d.ts +2 -2
- package/es/page-header/index.js +1 -1
- package/es/sidebar/index.d.ts +2 -2
- package/es/sidebar/index.js +1 -1
- package/es/sidebar/utils/index.d.ts +2 -2
- package/es/skeleton/index.d.ts +2 -3
- package/es/skeleton/index.js +1 -2
- package/es/table/components/ToolBar/FilterColumnIcon.js +28 -23
- package/es/table/components/ToolBar/RefreshIcon.js +162 -24
- package/es/table/components/ToolBar/index.scss +17 -0
- package/es/table/index.d.ts +2 -3
- package/es/table/index.js +64 -25
- package/es/table/typing.d.ts +17 -3
- package/es/timeline/ProTimeLineItem/index.js +1 -1
- package/lib/actions/index.d.ts +2 -2
- package/lib/actions/index.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/page-header/index.d.ts +2 -2
- package/lib/page-header/index.js +1 -1
- package/lib/sidebar/index.d.ts +2 -2
- package/lib/sidebar/index.js +1 -1
- package/lib/sidebar/utils/index.d.ts +2 -2
- package/lib/skeleton/index.d.ts +2 -3
- package/lib/skeleton/index.js +1 -3
- package/lib/table/components/ToolBar/FilterColumnIcon.js +27 -22
- package/lib/table/components/ToolBar/RefreshIcon.js +164 -27
- package/lib/table/components/ToolBar/index.scss +17 -0
- package/lib/table/index.d.ts +2 -3
- package/lib/table/index.js +63 -24
- package/lib/table/typing.d.ts +17 -3
- package/lib/timeline/ProTimeLineItem/index.js +1 -1
- package/package.json +1 -1
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
@@ -7,43 +8,179 @@ exports.default = void 0;
|
|
7
8
|
var _components = require("@alicloudfe/components");
|
8
9
|
var _icon = _interopRequireDefault(require("@teamix/icon"));
|
9
10
|
var _utils = require("@teamix/utils");
|
10
|
-
var _react =
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
12
|
+
var _utils2 = require("../../utils");
|
11
13
|
require("./index.scss");
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
12
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
21
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
17
23
|
var cls = (0, _utils.usePrefixCls)('teamix-pro-table-toolbar-icon');
|
18
24
|
var LayoutIcon = function LayoutIcon(props) {
|
19
|
-
var
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
//
|
34
|
-
|
25
|
+
var _autoRefreshProps$dat;
|
26
|
+
var actionRef = props.actionRef,
|
27
|
+
autoRefresh = props.autoRefresh,
|
28
|
+
autoRefreshProps = props.autoRefreshProps;
|
29
|
+
var autoRefreshRadio = (_autoRefreshProps$dat = autoRefreshProps === null || autoRefreshProps === void 0 ? void 0 : autoRefreshProps.dataSource) !== null && _autoRefreshProps$dat !== void 0 ? _autoRefreshProps$dat : [{
|
30
|
+
label: '每 1 分钟',
|
31
|
+
value: 60000
|
32
|
+
}, {
|
33
|
+
label: '每 3 分钟',
|
34
|
+
value: 180000
|
35
|
+
}, {
|
36
|
+
label: '每 5 分钟',
|
37
|
+
value: 300000
|
38
|
+
}];
|
39
|
+
// dropdown 开关
|
40
|
+
var _useState = (0, _react.useState)(false),
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
42
|
+
dropdownVisible = _useState2[0],
|
43
|
+
setDropdownVisible = _useState2[1];
|
44
|
+
// 自动刷新状态
|
45
|
+
var _useState3 = (0, _react.useState)(!!autoRefresh),
|
46
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
47
|
+
autoRefreshVisible = _useState4[0],
|
48
|
+
setAutoRefreshVisible = _useState4[1];
|
49
|
+
// 间隔时间 ms
|
50
|
+
var _useState5 = (0, _react.useState)(60000),
|
51
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
52
|
+
times = _useState6[0],
|
53
|
+
setTimes = _useState6[1];
|
54
|
+
// 展示计时器时间 s
|
55
|
+
var _useState7 = (0, _react.useState)(60),
|
56
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
57
|
+
remainTime = _useState8[0],
|
58
|
+
setRemainTime = _useState8[1];
|
59
|
+
// 循环计时器
|
60
|
+
var timerRef = (0, _react.useRef)({
|
61
|
+
timer: undefined,
|
62
|
+
remain: 60
|
63
|
+
});
|
64
|
+
(0, _react.useEffect)(function () {
|
65
|
+
(0, _utils2.on)(function (timer) {
|
66
|
+
setTimes(timer);
|
67
|
+
timerRef.current.remain = timer / 1000;
|
68
|
+
if (timerRef.current.timer) {
|
69
|
+
clearInterval(timerRef.current.timer);
|
70
|
+
timerRef.current.timer = undefined;
|
71
|
+
}
|
72
|
+
timerRef.current.timer = setInterval(function () {
|
73
|
+
var remainTime = timerRef.current.remain - 1;
|
74
|
+
if (remainTime >= 0) {
|
75
|
+
setRemainTime(remainTime);
|
76
|
+
timerRef.current.remain = remainTime;
|
77
|
+
}
|
78
|
+
}, 1000);
|
79
|
+
}, 'PRO_TABLE_REFRESH_TIMER_FLAG');
|
80
|
+
}, []);
|
81
|
+
// 下拉菜单显示隐藏回调
|
82
|
+
var onDropdownVisibleChange = function onDropdownVisibleChange(state) {
|
83
|
+
setDropdownVisible(state);
|
84
|
+
};
|
85
|
+
// 自动刷新开启关闭回调
|
86
|
+
var onAutoRefreshChange = function onAutoRefreshChange(visible) {
|
87
|
+
if (visible) {
|
88
|
+
var _actionRef$current, _actionRef$current$se;
|
89
|
+
(_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$se = _actionRef$current.setAutoRefreshTimers) === null || _actionRef$current$se === void 0 ? void 0 : _actionRef$current$se.call(_actionRef$current, times);
|
90
|
+
} else {
|
91
|
+
var _actionRef$current2, _actionRef$current2$c;
|
92
|
+
(_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$c = _actionRef$current2.clearAutoRefreshTimers) === null || _actionRef$current2$c === void 0 ? void 0 : _actionRef$current2$c.call(_actionRef$current2);
|
93
|
+
if (timerRef.current.timer) {
|
94
|
+
clearInterval(timerRef.current.timer);
|
95
|
+
timerRef.current.timer = undefined;
|
96
|
+
timerRef.current.remain = times / 1000;
|
97
|
+
setRemainTime(times / 1000);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
setAutoRefreshVisible(visible);
|
101
|
+
};
|
102
|
+
// 手动刷新回调
|
103
|
+
var onManualRefresh = function onManualRefresh() {
|
104
|
+
var _actionRef$current3, _actionRef$current3$r;
|
105
|
+
(_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$r = _actionRef$current3.refresh) === null || _actionRef$current3$r === void 0 ? void 0 : _actionRef$current3$r.call(_actionRef$current3);
|
106
|
+
onDropdownVisibleChange(false);
|
107
|
+
};
|
108
|
+
// 选择间隔时间回调
|
109
|
+
var onTimeRadioChange = function onTimeRadioChange(timer) {
|
110
|
+
var _actionRef$current4, _actionRef$current4$s;
|
111
|
+
setTimes(timer);
|
112
|
+
(_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$s = _actionRef$current4.setAutoRefreshTimers) === null || _actionRef$current4$s === void 0 ? void 0 : _actionRef$current4$s.call(_actionRef$current4, timer);
|
113
|
+
};
|
114
|
+
// 渲染刷新图标
|
115
|
+
var renderRefreshIcon = function renderRefreshIcon() {
|
116
|
+
if (!!autoRefresh && autoRefreshVisible && typeof autoRefresh !== 'function') {
|
117
|
+
return /*#__PURE__*/_react.default.createElement(_icon.default, {
|
118
|
+
size: "small",
|
119
|
+
type: "auto-refresh-on-line"
|
120
|
+
});
|
121
|
+
}
|
122
|
+
if (!!autoRefresh && !autoRefreshVisible && typeof autoRefresh !== 'function') {
|
123
|
+
return /*#__PURE__*/_react.default.createElement(_icon.default, {
|
124
|
+
size: "small",
|
125
|
+
type: "auto-refresh-off-line"
|
126
|
+
});
|
127
|
+
}
|
128
|
+
return /*#__PURE__*/_react.default.createElement(_icon.default, {
|
129
|
+
size: "small",
|
130
|
+
type: "refresh-line"
|
131
|
+
});
|
132
|
+
};
|
133
|
+
// 渲染 Radio
|
134
|
+
var renderRadio = autoRefreshRadio.map(function (item) {
|
135
|
+
return /*#__PURE__*/_react.default.createElement(_components.Menu.RadioItem, {
|
136
|
+
className: cls('time-radio'),
|
137
|
+
key: item.value,
|
138
|
+
disabled: !autoRefreshVisible,
|
139
|
+
checked: times === item.value,
|
140
|
+
onChange: function onChange() {
|
141
|
+
var _item$value;
|
142
|
+
return onTimeRadioChange((_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : 0);
|
143
|
+
}
|
144
|
+
}, item.label);
|
145
|
+
});
|
146
|
+
if (autoRefresh && typeof autoRefresh !== 'function') {
|
147
|
+
return /*#__PURE__*/_react.default.createElement(_components.Dropdown, {
|
148
|
+
trigger: /*#__PURE__*/_react.default.createElement(_components.Button, {
|
149
|
+
iconSize: "small",
|
150
|
+
className: cls()
|
151
|
+
}, renderRefreshIcon()),
|
152
|
+
visible: dropdownVisible,
|
153
|
+
onVisibleChange: onDropdownVisibleChange,
|
154
|
+
followTrigger: true,
|
155
|
+
cache: true,
|
156
|
+
triggerType: ['click'],
|
157
|
+
align: "tr br"
|
158
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
159
|
+
className: cls()
|
160
|
+
}, /*#__PURE__*/_react.default.createElement(_components.Menu, {
|
161
|
+
className: cls('auto-refresh')
|
162
|
+
}, /*#__PURE__*/_react.default.createElement(_components.Menu.CheckboxItem, {
|
163
|
+
checked: autoRefreshVisible,
|
164
|
+
onChange: onAutoRefreshChange
|
165
|
+
}, (0, _utils.getMessage)('autoRefresh'), autoRefreshVisible && /*#__PURE__*/_react.default.createElement("span", null, "\uFF08", remainTime, "s\uFF09")), renderRadio, /*#__PURE__*/_react.default.createElement(_components.Menu.Divider, {
|
166
|
+
key: "divider"
|
167
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
168
|
+
className: cls('manual-refresh')
|
169
|
+
}, /*#__PURE__*/_react.default.createElement(_components.Button, {
|
170
|
+
type: "primary",
|
171
|
+
text: true,
|
172
|
+
onClick: onManualRefresh
|
173
|
+
}, (0, _utils.getMessage)('manualRefresh'))))));
|
174
|
+
}
|
35
175
|
return /*#__PURE__*/_react.default.createElement(_components.Balloon.Tooltip, {
|
36
176
|
trigger: /*#__PURE__*/_react.default.createElement(_components.Button, {
|
37
177
|
iconSize: "small",
|
38
178
|
className: cls(),
|
39
179
|
onClick: function onClick() {
|
40
|
-
var _actionRef$
|
41
|
-
return (_actionRef$
|
180
|
+
var _actionRef$current5, _actionRef$current5$r;
|
181
|
+
return (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$r = _actionRef$current5.refresh) === null || _actionRef$current5$r === void 0 ? void 0 : _actionRef$current5$r.call(_actionRef$current5);
|
42
182
|
}
|
43
|
-
},
|
44
|
-
size: "small",
|
45
|
-
type: "refresh-line"
|
46
|
-
})),
|
183
|
+
}, renderRefreshIcon()),
|
47
184
|
align: "t"
|
48
185
|
}, (0, _utils.getMessage)('refresh'));
|
49
186
|
};
|
@@ -158,3 +158,20 @@
|
|
158
158
|
padding-right: 8px;
|
159
159
|
}
|
160
160
|
}
|
161
|
+
|
162
|
+
// refresh
|
163
|
+
.teamix-pro-table-toolbar-icon {
|
164
|
+
&-auto-refresh {
|
165
|
+
width: 145px;
|
166
|
+
}
|
167
|
+
|
168
|
+
&-manual-refresh {
|
169
|
+
text-align: center;
|
170
|
+
line-height: 1;
|
171
|
+
margin-bottom: 2px;
|
172
|
+
}
|
173
|
+
|
174
|
+
.teamix-pro-table-toolbar-icon-time-radio.teamix-pro-table-toolbar-icon-time-radio.teamix-pro-table-toolbar-icon-time-radio {
|
175
|
+
padding-left: 32px;
|
176
|
+
}
|
177
|
+
}
|
package/lib/table/index.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import React from 'react';
|
2
1
|
import { ProTableProps } from './typing';
|
3
2
|
import './index.scss';
|
4
3
|
export * from './typing';
|
5
|
-
declare const
|
6
|
-
export default
|
4
|
+
declare const ProTable: (props: ProTableProps) => JSX.Element;
|
5
|
+
export default ProTable;
|
package/lib/table/index.js
CHANGED
@@ -24,7 +24,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
24
24
|
var _pageContainer = _interopRequireDefault(require("../page-container"));
|
25
25
|
var _lodash = _interopRequireDefault(require("lodash.debounce"));
|
26
26
|
var _CardView = _interopRequireDefault(require("./components/CardView"));
|
27
|
-
var _lodash2 = _interopRequireDefault(require("lodash.clonedeep"));
|
28
27
|
var _typing = require("./typing");
|
29
28
|
Object.keys(_typing).forEach(function (key) {
|
30
29
|
if (key === "default" || key === "__esModule") return;
|
@@ -37,7 +36,7 @@ Object.keys(_typing).forEach(function (key) {
|
|
37
36
|
}
|
38
37
|
});
|
39
38
|
});
|
40
|
-
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree", "toolBarAutoWidth", "data-teamix-spm", "switchCardView", "cardViewProps", "defaultView", "emptyProps"],
|
39
|
+
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "autoRefreshProps", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree", "toolBarAutoWidth", "data-teamix-spm", "switchCardView", "cardViewProps", "defaultView", "emptyProps"],
|
41
40
|
_excluded2 = ["onChange"];
|
42
41
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
43
42
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -47,9 +46,6 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
47
46
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
48
47
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
49
48
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
50
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
51
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
52
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
53
49
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
54
50
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
55
51
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
@@ -58,6 +54,9 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
58
54
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
59
55
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
60
56
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
57
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
58
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
59
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
61
60
|
var cls = (0, _utils.usePrefixCls)('teamix-pro-table');
|
62
61
|
/**
|
63
62
|
* 处理原生传入的 columns 以便于 选择列 方便处理
|
@@ -67,8 +66,8 @@ var cls = (0, _utils.usePrefixCls)('teamix-pro-table');
|
|
67
66
|
var processColumns = function processColumns(columns, initialColumns) {
|
68
67
|
var _getGlobalConfig;
|
69
68
|
var globalFilterColumns = (_getGlobalConfig = (0, _utils.getGlobalConfig)('ProTable')) === null || _getGlobalConfig === void 0 ? void 0 : _getGlobalConfig.filterColumns;
|
70
|
-
var filterColumns =
|
71
|
-
return item.columnFilters !== false && (item === null || item === void 0 ? void 0 : item.hidden) !== true && (!globalFilterColumns || globalFilterColumns(item));
|
69
|
+
var filterColumns = columns.filter(function (item) {
|
70
|
+
return item.columnFilters !== false && (item === null || item === void 0 ? void 0 : item.hidden) !== true && (!globalFilterColumns || globalFilterColumns(_objectSpread({}, item)));
|
72
71
|
});
|
73
72
|
// 处理只剩一列批量选择的情况下宽度错乱问题
|
74
73
|
if (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) {
|
@@ -154,9 +153,8 @@ var ProTable = function ProTable(props) {
|
|
154
153
|
_props$footerSuction = props.footerSuction,
|
155
154
|
footerSuction = _props$footerSuction === void 0 ? false : _props$footerSuction,
|
156
155
|
_props$autoRefresh = props.autoRefresh,
|
157
|
-
autoRefresh = _props$autoRefresh === void 0 ?
|
158
|
-
|
159
|
-
} : _props$autoRefresh,
|
156
|
+
autoRefresh = _props$autoRefresh === void 0 ? false : _props$autoRefresh,
|
157
|
+
autoRefreshProps = props.autoRefreshProps,
|
160
158
|
customRequest = props.customRequest,
|
161
159
|
_props$filterColumnTy = props.filterColumnType,
|
162
160
|
filterColumnType = _props$filterColumnTy === void 0 ? 'auto' : _props$filterColumnTy,
|
@@ -642,6 +640,19 @@ var ProTable = function ProTable(props) {
|
|
642
640
|
}
|
643
641
|
}
|
644
642
|
getHeaderHeight(fullscreenState);
|
643
|
+
},
|
644
|
+
setAutoRefreshTimers: function setAutoRefreshTimers(timers) {
|
645
|
+
clearTimeout(autoRefreshTimerRef.current);
|
646
|
+
autoRefreshTimerRef.current = null;
|
647
|
+
autoRefreshTimerRef.current = setTimeout(function () {
|
648
|
+
var _actionRef$current5, _actionRef$current5$r;
|
649
|
+
(_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$r = _actionRef$current5.refresh) === null || _actionRef$current5$r === void 0 ? void 0 : _actionRef$current5$r.call(_actionRef$current5);
|
650
|
+
}, timers);
|
651
|
+
(0, _utils2.emit)('PRO_TABLE_REFRESH_TIMER_FLAG', timers);
|
652
|
+
},
|
653
|
+
clearAutoRefreshTimers: function clearAutoRefreshTimers() {
|
654
|
+
clearTimeout(autoRefreshTimerRef.current);
|
655
|
+
autoRefreshTimerRef.current = null;
|
645
656
|
}
|
646
657
|
});
|
647
658
|
// 将 Actions 绑定到传入的 propsActionRef 中
|
@@ -650,12 +661,19 @@ var ProTable = function ProTable(props) {
|
|
650
661
|
}
|
651
662
|
function onFormatResult(next) {
|
652
663
|
props.onFormatResult && props.onFormatResult(next);
|
653
|
-
var time =
|
664
|
+
var time = 0;
|
665
|
+
if (autoRefresh) {
|
666
|
+
time = 60 * 1000;
|
667
|
+
}
|
668
|
+
if (autoRefresh && typeof autoRefresh !== 'boolean') {
|
669
|
+
time = autoRefresh ? autoRefresh(next.data) : 0;
|
670
|
+
}
|
654
671
|
if (Number.isInteger(time) && time >= 1000) {
|
655
672
|
autoRefreshTimerRef.current = setTimeout(function () {
|
656
673
|
// 自动刷新不显示 loading
|
657
674
|
_request({}, true);
|
658
675
|
}, Number(time));
|
676
|
+
(0, _utils2.emit)('PRO_TABLE_REFRESH_TIMER_FLAG', Number(time));
|
659
677
|
}
|
660
678
|
// 设置 dataSource、total
|
661
679
|
if (switchViewState === 'table' || currentPage === 1) {
|
@@ -695,6 +713,10 @@ var ProTable = function ProTable(props) {
|
|
695
713
|
data: (0, _utils.getDeepValue)(formatResult.data, result) || [],
|
696
714
|
total: isNaN(dataTotal) ? 0 : Number(dataTotal)
|
697
715
|
};
|
716
|
+
} else if (typeof formatResult === 'string') {
|
717
|
+
nextData = (0, _utils.getTargetValue)(formatResult, {
|
718
|
+
res: result
|
719
|
+
});
|
698
720
|
}
|
699
721
|
}
|
700
722
|
if (nextData instanceof Promise) {
|
@@ -732,7 +754,7 @@ var ProTable = function ProTable(props) {
|
|
732
754
|
});
|
733
755
|
// 请求函数
|
734
756
|
function _request(params, noLoading, filterParams) {
|
735
|
-
var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$
|
757
|
+
var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$current6, _actionRef$current6$g, _objectSpread3;
|
736
758
|
// 如果没有传 url 且没有 customRequest,直接返回
|
737
759
|
if (!url && !customRequest) {
|
738
760
|
return;
|
@@ -745,9 +767,17 @@ var ProTable = function ProTable(props) {
|
|
745
767
|
// 筛选区请求参数
|
746
768
|
var dataFilterParams = filterParams !== null && filterParams !== void 0 ? filterParams : (_dataFilterFormRef$cu2 = dataFilterFormRef.current) === null || _dataFilterFormRef$cu2 === void 0 ? void 0 : _dataFilterFormRef$cu2.values;
|
747
769
|
// 列过滤请求参数
|
748
|
-
var columnsFilterParams = (_actionRef$current$ge = (_actionRef$
|
770
|
+
var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$g = _actionRef$current6.getFilterRules) === null || _actionRef$current6$g === void 0 ? void 0 : _actionRef$current6$g.call(_actionRef$current6)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {};
|
749
771
|
// 格式化后的请求参数
|
750
|
-
var requestData =
|
772
|
+
var requestData = {};
|
773
|
+
var preParams = _objectSpread(_objectSpread({}, !showPagination ? _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, dataFilterParams), propsParams), sortParams), columnsFilterParams) : _objectSpread(_objectSpread(_objectSpread(_objectSpread((_objectSpread3 = {}, _defineProperty(_objectSpread3, targetPageKey, currentPage), _defineProperty(_objectSpread3, targetPageSizeKey, pageSize), _objectSpread3), dataFilterParams), propsParams), sortParams), columnsFilterParams)), params);
|
774
|
+
if (typeof formatParams === 'string') {
|
775
|
+
requestData = (0, _utils.getTargetValue)(formatParams, {
|
776
|
+
params: preParams
|
777
|
+
});
|
778
|
+
} else {
|
779
|
+
requestData = formatParams(preParams);
|
780
|
+
}
|
751
781
|
if (requestData) {
|
752
782
|
if (autoRefreshTimerRef.current) {
|
753
783
|
clearTimeout(autoRefreshTimerRef.current);
|
@@ -795,12 +825,19 @@ var ProTable = function ProTable(props) {
|
|
795
825
|
getHeaderHeight(fullscreenState);
|
796
826
|
}
|
797
827
|
// customRequest 中支持 autoRefresh
|
798
|
-
var time =
|
828
|
+
var time = 0;
|
829
|
+
if (autoRefresh) {
|
830
|
+
time = 60 * 1000;
|
831
|
+
}
|
832
|
+
if (autoRefresh && typeof autoRefresh !== 'boolean') {
|
833
|
+
time = autoRefresh ? autoRefresh(data) : 0;
|
834
|
+
}
|
799
835
|
if (Number.isInteger(time) && time >= 1000) {
|
800
836
|
autoRefreshTimerRef.current = setTimeout(function () {
|
801
837
|
// 自动刷新不显示 loading
|
802
|
-
_request(
|
838
|
+
_request({}, true);
|
803
839
|
}, Number(time));
|
840
|
+
(0, _utils2.emit)('PRO_TABLE_REFRESH_TIMER_FLAG', Number(time));
|
804
841
|
}
|
805
842
|
});
|
806
843
|
} else {
|
@@ -826,7 +863,7 @@ var ProTable = function ProTable(props) {
|
|
826
863
|
return true;
|
827
864
|
} : undefined,
|
828
865
|
onFilter: function onFilter(values) {
|
829
|
-
var _actionRef$
|
866
|
+
var _actionRef$current7, _actionRef$current7$c;
|
830
867
|
// 全屏状态,判断全屏表单onFilter是否禁用
|
831
868
|
if (fullscreenState && !filterEnableRef.current.fullscreen) {
|
832
869
|
filterEnableRef.current.fullscreen = true;
|
@@ -839,7 +876,7 @@ var ProTable = function ProTable(props) {
|
|
839
876
|
}
|
840
877
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(values));
|
841
878
|
// 搜索变化时,暂时先清空选择
|
842
|
-
(_actionRef$
|
879
|
+
(_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
|
843
880
|
setCurrentPage(1);
|
844
881
|
_request(_defineProperty({}, targetPageKey, 1), false, values);
|
845
882
|
},
|
@@ -882,7 +919,9 @@ var ProTable = function ProTable(props) {
|
|
882
919
|
toolBarAutoWidth: toolBarAutoWidth,
|
883
920
|
dataTeamixSpm: dataTeamixSpm,
|
884
921
|
switchCardView: switchCardView,
|
885
|
-
defaultView: defaultView
|
922
|
+
defaultView: defaultView,
|
923
|
+
autoRefresh: autoRefresh,
|
924
|
+
autoRefreshProps: autoRefreshProps
|
886
925
|
}), switchViewState === 'table' && /*#__PURE__*/_react.default.createElement(_components.Table.StickyLock, _objectSpread({
|
887
926
|
hasBorder: false,
|
888
927
|
dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
|
@@ -950,8 +989,8 @@ var ProTable = function ProTable(props) {
|
|
950
989
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
951
990
|
// 翻页默认清空选择
|
952
991
|
if (!reserveSelectedRecords) {
|
953
|
-
var _actionRef$
|
954
|
-
(_actionRef$
|
992
|
+
var _actionRef$current8, _actionRef$current8$c;
|
993
|
+
(_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
|
955
994
|
}
|
956
995
|
setCurrentPage(currentPage);
|
957
996
|
_request(_objectSpread(_defineProperty({}, targetPageKey, currentPage), params));
|
@@ -960,8 +999,8 @@ var ProTable = function ProTable(props) {
|
|
960
999
|
var _request8;
|
961
1000
|
// 翻页默认清空选择
|
962
1001
|
if (!reserveSelectedRecords) {
|
963
|
-
var _actionRef$
|
964
|
-
(_actionRef$
|
1002
|
+
var _actionRef$current9, _actionRef$current9$c;
|
1003
|
+
(_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$c = _actionRef$current9.clearRowSelection) === null || _actionRef$current9$c === void 0 ? void 0 : _actionRef$current9$c.call(_actionRef$current9);
|
965
1004
|
}
|
966
1005
|
setPageSize(currentPageSize);
|
967
1006
|
setCurrentPage(1);
|
@@ -1069,5 +1108,5 @@ var ProTable = function ProTable(props) {
|
|
1069
1108
|
}, renderTable(isFullScreen), fixFooterState && /*#__PURE__*/_react.default.createElement(_pageContainer.default.FixedFooter, null, renderFooter()), !fixFooterState && renderFooter());
|
1070
1109
|
});
|
1071
1110
|
};
|
1072
|
-
var _default =
|
1111
|
+
var _default = ProTable;
|
1073
1112
|
exports.default = _default;
|
package/lib/table/typing.d.ts
CHANGED
@@ -78,9 +78,9 @@ export declare type ProTableProps = {
|
|
78
78
|
/** sort 排序请求参数处理函数 */
|
79
79
|
formatSort?: (sort: object) => object;
|
80
80
|
/** 如需自定义调用参数格式,则可以设定此值在请求前对 params 进行自定义,如果返回false则可以阻止请求 */
|
81
|
-
formatParams?: (params: any) => typeof params;
|
81
|
+
formatParams?: ((params: any) => typeof params) | string;
|
82
82
|
/** 对返回值的 data,total 进行映射处理 */
|
83
|
-
formatResult?: TDataService | ((res: any) => TDataService);
|
83
|
+
formatResult?: TDataService | ((res: any) => TDataService) | string;
|
84
84
|
/** 请求成功后经过 formatResult 转换后的回调 */
|
85
85
|
onFormatResult?: (data: any[]) => void;
|
86
86
|
/** 是否第一次加载时就发起请求 */
|
@@ -131,7 +131,15 @@ export declare type ProTableProps = {
|
|
131
131
|
/** 非全屏模式下是否吸底 默认状态下取用 ProPageContainer 作为参照物。如果传入了 Dom,则取用 Dom 作为参照物 */
|
132
132
|
footerSuction?: boolean | Element;
|
133
133
|
/** 当满足条件时开启自动刷新,返回值为自动刷新间隔时间,如果返回 0 或 false 则停止自动刷新,每次触发翻页、搜索都将重置时间 */
|
134
|
-
autoRefresh?: (dataSource: any[]) => number | boolean;
|
134
|
+
autoRefresh?: ((dataSource: any[]) => number | boolean) | boolean;
|
135
|
+
/** 自动刷新配置 */
|
136
|
+
autoRefreshProps?: {
|
137
|
+
/** 可选间隔列表 **/
|
138
|
+
dataSource?: {
|
139
|
+
label?: React.ReactNode;
|
140
|
+
value?: number;
|
141
|
+
}[];
|
142
|
+
};
|
135
143
|
/** 自定义请求方法,必需返回 success,data 字段,如果需要手动分页 total 也是必需的 */
|
136
144
|
customRequest?: (params: any) => Promise<{
|
137
145
|
success: boolean;
|
@@ -231,6 +239,10 @@ export declare type ProTableActionType = {
|
|
231
239
|
/** 设置数据源 **/
|
232
240
|
setData?: (data: any[]) => void;
|
233
241
|
setCardViewScrollPosition?: (scrollTop: number) => void;
|
242
|
+
/** 刷新定时器间隔时间 */
|
243
|
+
setAutoRefreshTimers?: (timers: number) => void;
|
244
|
+
/** 清除刷新定时器 */
|
245
|
+
clearAutoRefreshTimers?: () => void;
|
234
246
|
} & ProTableActionTypeMutations;
|
235
247
|
/** action State 定义 */
|
236
248
|
export declare type ProTableActionTypeMutations = {
|
@@ -301,6 +313,8 @@ export declare type ProTableLayoutProps = {
|
|
301
313
|
dataTeamixSpm?: string;
|
302
314
|
switchCardView?: boolean;
|
303
315
|
defaultView?: 'table' | 'card';
|
316
|
+
autoRefresh?: ProTableProps['autoRefresh'];
|
317
|
+
autoRefreshProps?: ProTableProps['autoRefreshProps'];
|
304
318
|
} & ProTableTopAreaProps;
|
305
319
|
/** columns 列过滤 */
|
306
320
|
export declare type ProTableColumnsFilterItemProps = {
|
@@ -68,7 +68,7 @@ var ProTimeLineItem = function ProTimeLineItem(props) {
|
|
68
68
|
};
|
69
69
|
/** 对枚举参数进行处理 */
|
70
70
|
var formatTime = function formatTime(time) {
|
71
|
-
if (typeof time === 'string') return (0, _utils.dateFormat)(time, '', 'YYYY-MM-DD
|
71
|
+
if (typeof time === 'string') return (0, _utils.dateFormat)(time, '', 'YYYY-MM-DD HH:mm:ss');
|
72
72
|
return time;
|
73
73
|
};
|
74
74
|
var formatShape = function formatShape() {
|