@teamix/pro 1.5.3 → 1.5.4-beta.0
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 +20239 -19807
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/dist/pro.min.js.LICENSE.txt +2 -6
- package/es/actions/base.js +8 -21
- package/es/actions/dialog-component.js +2 -9
- package/es/actions/dialog-form.js +37 -75
- package/es/actions/dialog-info.js +1 -5
- package/es/actions/dialog.js +57 -95
- package/es/actions/index.d.ts +2 -0
- package/es/actions/index.js +70 -156
- package/es/actions/link.js +3 -5
- package/es/actions/quick.js +0 -6
- package/es/actions/request.js +12 -27
- package/es/actions/utils.js +1 -9
- package/es/card/card-container.js +0 -5
- package/es/card/divider.js +0 -5
- package/es/card/index.js +56 -95
- package/es/card/selectable.js +4 -13
- package/es/card/tab.js +1 -10
- package/es/card/utils.js +0 -2
- package/es/form/Components/Editable/index.js +16 -55
- package/es/form/Components/FormGroup/index.d.ts +1 -0
- package/es/form/Components/FormGroup/index.js +7 -22
- package/es/form/Components/LightFilter/index.js +15 -35
- package/es/form/Components/ProField/index.js +2 -14
- package/es/form/Components/ProField/mapDateFormat.js +2 -28
- package/es/form/Components/Text/index.d.ts +1 -0
- package/es/form/Components/Text/index.js +2 -11
- package/es/form/Filter/AdvancedFilter.js +11 -26
- package/es/form/Filter/Layout.js +11 -24
- package/es/form/Filter/LightFilter.js +13 -24
- package/es/form/Filter/SimpleFilter.js +7 -21
- package/es/form/Filter/index.js +106 -171
- package/es/form/Filter/index2.js +11 -28
- package/es/form/Filter/useBindUrl.js +18 -46
- package/es/form/Filter/useSpecialProps.js +8 -13
- package/es/form/ProForm/addCascadeEffect.js +10 -32
- package/es/form/ProForm/customComponent.js +0 -5
- package/es/form/ProForm/index.js +23 -34
- package/es/form/ProForm/useAutoLayout.js +21 -42
- package/es/form/ProForm/useAutoSubmit.js +3 -8
- package/es/form/ProForm/useFieldRequest.js +0 -5
- package/es/form/ProForm/useFormDisplayValues.js +12 -28
- package/es/form/ProForm/useInitialRequest.js +0 -5
- package/es/form/SchemaForm/adapterComponent.js +0 -3
- package/es/form/SchemaForm/adapterDecorator.d.ts +1 -1
- package/es/form/SchemaForm/adapterDecorator.js +0 -8
- package/es/form/SchemaForm/adapterType.js +0 -2
- package/es/form/SchemaForm/index.js +78 -114
- package/es/form/SchemaForm/initializeArrayCards.js +0 -6
- package/es/form/SchemaForm/initializeArrayCollapse.js +0 -6
- package/es/form/SchemaForm/initializeArrayItems.js +2 -9
- package/es/form/SchemaForm/initializeArrayTable.js +21 -34
- package/es/form/SchemaForm/initializeDataSource.js +2 -6
- package/es/form/SchemaForm/initializeFormButton.js +14 -31
- package/es/form/SchemaForm/initializeFormCollapse.js +8 -18
- package/es/form/SchemaForm/initializeFormGroup.js +10 -20
- package/es/form/SchemaForm/initializeFormStep.js +11 -23
- package/es/form/SchemaForm/initializeFormTab.js +10 -20
- package/es/form/SchemaForm/initializeReactions.js +9 -33
- package/es/form/SchemaForm/initializeRequest.js +2 -16
- package/es/form/SchemaForm/initializeRules.js +4 -22
- package/es/form/SchemaForm/initializeSelectTable.js +7 -33
- package/es/form/SchemaForm/reactions.js +19 -34
- package/es/form/docs/ActionResponse.d.ts +1 -0
- package/es/form/index.d.ts +9 -9
- package/es/form/index.js +0 -9
- package/es/form/typing.d.ts +6 -4
- package/es/form/utils.d.ts +1 -1
- package/es/form/utils.js +4 -49
- package/es/form/warning.js +2 -7
- package/es/index-without-icon.js +4 -3
- package/es/index.d.ts +1 -1
- package/es/index.js +7 -8
- package/es/info/components/InfoGroup/index.js +21 -32
- package/es/info/components/InfoValueItem/index.js +66 -119
- package/es/info/components/ProInfoItem/index.js +13 -21
- package/es/info/components/baseInfo/index.js +14 -26
- package/es/info/components/headerInfo/index.js +8 -20
- package/es/info/components/tableInfo/index.js +20 -50
- package/es/info/index.js +53 -82
- package/es/info/utils/index.js +0 -11
- package/es/nocode/configurators/common.js +5 -6
- package/es/nocode/configurators/index.js +2 -3
- package/es/nocode/index.js +6 -6
- package/es/nocode/pages/editor.js +5 -9
- package/es/nocode/pages/index.js +4 -4
- package/es/nocode/pages/playground.js +18 -35
- package/es/nocode/pages/renderer.js +9 -42
- package/es/nocode/playground.js +10 -23
- package/es/page-header/index.d.ts +2 -2
- package/es/page-header/index.js +39 -75
- package/es/sidebar/components/sidebar-container/index.js +41 -72
- package/es/sidebar/components/tree/index.js +88 -144
- package/es/sidebar/components/tree-node/components/HoverTooltip/index.js +11 -26
- package/es/sidebar/components/tree-node/components/IconAction/index.js +9 -35
- package/es/sidebar/components/tree-node/components/IconSwitch/index.js +12 -25
- package/es/sidebar/components/tree-node/index.js +41 -83
- package/es/sidebar/index.js +69 -94
- package/es/sidebar/utils/action-ref.js +2 -7
- package/es/sidebar/utils/index.d.ts +5 -2
- package/es/sidebar/utils/index.js +41 -98
- package/es/table/components/CardView/index.js +62 -149
- package/es/table/components/Filter/index.js +42 -83
- package/es/table/components/Layout/index.js +25 -45
- package/es/table/components/LoadMore/index.js +15 -34
- package/es/table/components/Pagination/index.js +25 -58
- package/es/table/components/QuickAction/index.js +3 -11
- package/es/table/components/ToolBar/CardSwitch.js +6 -17
- package/es/table/components/ToolBar/DensityIcon.js +18 -31
- package/es/table/components/ToolBar/FilterColumnIcon.js +50 -106
- package/es/table/components/ToolBar/FullScreenIcon.js +2 -6
- package/es/table/components/ToolBar/Fullscreen.js +19 -35
- package/es/table/components/ToolBar/RefreshIcon.js +2 -5
- package/es/table/components/ToolBar/index.js +23 -45
- package/es/table/index.js +226 -399
- package/es/table/utils/columnRender.d.ts +1 -1
- package/es/table/utils/columnRender.js +32 -76
- package/es/table/utils/genProColumnToColumn.js +5 -14
- package/es/table/utils/index.js +14 -47
- package/es/table/utils/pureColumnRender.js +21 -53
- package/es/table/utils/pureGenProColumnToColumn.d.ts +1 -1
- package/es/table/utils/pureGenProColumnToColumn.js +2 -10
- package/es/table/utils/useTableSelection.js +6 -33
- package/es/templates/List/index.js +2 -9
- package/es/timeline/ProTimeLineItem/index.js +24 -64
- package/es/timeline/index.js +8 -22
- package/es/timeline/typing.d.ts +1 -0
- package/es/utils/message.d.ts +2 -2
- package/es/utils/message.js +0 -5
- package/es/utils/useRealHistory.d.ts +8 -0
- package/es/utils/useRealHistory.js +23 -0
- package/lib/actions/base.js +8 -24
- package/lib/actions/confirm.js +0 -5
- package/lib/actions/danger-confirm.js +0 -5
- package/lib/actions/danger-pop-confirm.js +0 -4
- package/lib/actions/dialog-component.js +2 -15
- package/lib/actions/dialog-form.js +36 -88
- package/lib/actions/dialog-info.js +1 -10
- package/lib/actions/dialog-table.js +0 -5
- package/lib/actions/dialog.js +55 -111
- package/lib/actions/drawer-form.js +0 -3
- package/lib/actions/drawer-info.js +0 -3
- package/lib/actions/drawer-table.js +0 -3
- package/lib/actions/drawer.js +0 -4
- package/lib/actions/error.js +0 -5
- package/lib/actions/index.d.ts +2 -0
- package/lib/actions/index.js +70 -186
- package/lib/actions/link.js +3 -10
- package/lib/actions/notice.js +0 -5
- package/lib/actions/pop-confirm.js +0 -5
- package/lib/actions/quick.js +0 -13
- package/lib/actions/request.js +10 -32
- package/lib/actions/utils.js +1 -9
- package/lib/card/card-container.js +0 -9
- package/lib/card/divider.js +0 -7
- package/lib/card/index.js +56 -122
- package/lib/card/selectable.js +4 -20
- package/lib/card/tab.js +1 -14
- package/lib/card/utils.js +0 -6
- package/lib/field/index.js +0 -6
- package/lib/form/Components/Editable/index.js +15 -65
- package/lib/form/Components/FormGroup/index.d.ts +1 -0
- package/lib/form/Components/FormGroup/index.js +7 -28
- package/lib/form/Components/LightFilter/index.js +15 -47
- package/lib/form/Components/ProField/index.js +2 -21
- package/lib/form/Components/ProField/mapDateFormat.js +2 -32
- package/lib/form/Components/Text/index.d.ts +1 -0
- package/lib/form/Components/Text/index.js +2 -16
- package/lib/form/Filter/AdvancedFilter.js +11 -34
- package/lib/form/Filter/Layout.js +11 -33
- package/lib/form/Filter/LightFilter.js +13 -32
- package/lib/form/Filter/SimpleFilter.js +5 -27
- package/lib/form/Filter/index.js +105 -191
- package/lib/form/Filter/index2.js +11 -38
- package/lib/form/Filter/useBindUrl.js +18 -50
- package/lib/form/Filter/useSpecialProps.js +6 -13
- package/lib/form/ProForm/addCascadeEffect.js +10 -35
- package/lib/form/ProForm/customComponent.js +0 -8
- package/lib/form/ProForm/index.js +23 -57
- package/lib/form/ProForm/useAutoLayout.js +21 -45
- package/lib/form/ProForm/useAutoSubmit.js +3 -10
- package/lib/form/ProForm/useFieldRequest.js +0 -8
- package/lib/form/ProForm/useFormDisplayValues.js +12 -34
- package/lib/form/ProForm/useInitialRequest.js +0 -6
- package/lib/form/SchemaForm/adapterComponent.js +0 -6
- package/lib/form/SchemaForm/adapterDecorator.d.ts +1 -1
- package/lib/form/SchemaForm/adapterDecorator.js +0 -12
- package/lib/form/SchemaForm/adapterType.js +0 -5
- package/lib/form/SchemaForm/index.js +78 -144
- package/lib/form/SchemaForm/initializeArrayCards.js +0 -7
- package/lib/form/SchemaForm/initializeArrayCollapse.js +0 -7
- package/lib/form/SchemaForm/initializeArrayItems.js +2 -10
- package/lib/form/SchemaForm/initializeArrayTable.js +21 -34
- package/lib/form/SchemaForm/initializeDataSource.js +2 -8
- package/lib/form/SchemaForm/initializeFormButton.js +14 -32
- package/lib/form/SchemaForm/initializeFormCollapse.js +8 -18
- package/lib/form/SchemaForm/initializeFormGroup.js +10 -20
- package/lib/form/SchemaForm/initializeFormStep.js +11 -23
- package/lib/form/SchemaForm/initializeFormTab.js +10 -20
- package/lib/form/SchemaForm/initializeReactions.js +9 -37
- package/lib/form/SchemaForm/initializeRequest.js +2 -18
- package/lib/form/SchemaForm/initializeRules.js +4 -24
- package/lib/form/SchemaForm/initializeSelectTable.js +7 -36
- package/lib/form/SchemaForm/reactions.js +17 -37
- package/lib/form/docs/ActionResponse.d.ts +1 -0
- package/lib/form/docs/ActionResponse.js +0 -5
- package/lib/form/index.d.ts +9 -9
- package/lib/form/index.js +0 -25
- package/lib/form/typing.d.ts +6 -4
- package/lib/form/utils.d.ts +1 -1
- package/lib/form/utils.js +4 -61
- package/lib/form/warning.js +2 -8
- package/lib/hooks/index.js +0 -5
- package/lib/index-without-icon.js +2 -36
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -39
- package/lib/info/components/InfoGroup/index.js +21 -42
- package/lib/info/components/InfoValueItem/index.js +66 -134
- package/lib/info/components/ProInfoItem/index.js +13 -29
- package/lib/info/components/baseInfo/index.js +14 -38
- package/lib/info/components/headerInfo/index.js +8 -31
- package/lib/info/components/tableInfo/index.js +20 -62
- package/lib/info/index.js +53 -97
- package/lib/info/utils/index.js +0 -19
- package/lib/info/utils/utils.js +0 -1
- package/lib/nocode/configurators/PageHeader.js +0 -2
- package/lib/nocode/configurators/ProTable.js +0 -2
- package/lib/nocode/configurators/common.js +5 -10
- package/lib/nocode/configurators/index.js +2 -10
- package/lib/nocode/configurators/map.js +0 -5
- package/lib/nocode/index.js +0 -11
- package/lib/nocode/pages/editor.js +5 -19
- package/lib/nocode/pages/index.js +2 -9
- package/lib/nocode/pages/playground.js +18 -52
- package/lib/nocode/pages/renderer.js +9 -53
- package/lib/nocode/playground.js +10 -35
- package/lib/page-container/index.js +0 -6
- package/lib/page-header/index.d.ts +2 -2
- package/lib/page-header/index.js +38 -88
- package/lib/sidebar/components/sidebar-container/index.js +41 -84
- package/lib/sidebar/components/tree/index.js +88 -158
- package/lib/sidebar/components/tree-node/components/HoverTooltip/index.js +11 -34
- package/lib/sidebar/components/tree-node/components/IconAction/index.js +9 -46
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.js +12 -35
- package/lib/sidebar/components/tree-node/index.js +41 -99
- package/lib/sidebar/index.js +69 -112
- package/lib/sidebar/utils/action-ref.js +2 -8
- package/lib/sidebar/utils/index.d.ts +5 -2
- package/lib/sidebar/utils/index.js +41 -106
- package/lib/skeleton/index.js +0 -6
- package/lib/table/components/CardView/index.js +62 -161
- package/lib/table/components/EmptyContent/index.js +0 -6
- package/lib/table/components/Filter/index.js +42 -93
- package/lib/table/components/Layout/index.js +25 -58
- package/lib/table/components/LoadMore/index.js +15 -44
- package/lib/table/components/Pagination/index.js +25 -68
- package/lib/table/components/QuickAction/index.js +3 -15
- package/lib/table/components/ToolBar/CardSwitch.js +6 -28
- package/lib/table/components/ToolBar/DensityIcon.js +18 -42
- package/lib/table/components/ToolBar/FilterColumnIcon.js +50 -118
- package/lib/table/components/ToolBar/FullScreenIcon.js +3 -13
- package/lib/table/components/ToolBar/Fullscreen.js +19 -42
- package/lib/table/components/ToolBar/RefreshIcon.js +3 -12
- package/lib/table/components/ToolBar/index.js +23 -63
- package/lib/table/index.js +226 -423
- package/lib/table/utils/columnRender.d.ts +1 -1
- package/lib/table/utils/columnRender.js +32 -89
- package/lib/table/utils/genProColumnToColumn.js +5 -19
- package/lib/table/utils/getTableProps.js +0 -2
- package/lib/table/utils/getTableSortIcons.js +0 -5
- package/lib/table/utils/index.js +12 -55
- package/lib/table/utils/pureColumnRender.js +21 -64
- package/lib/table/utils/pureGenProColumnToColumn.d.ts +1 -1
- package/lib/table/utils/pureGenProColumnToColumn.js +2 -11
- package/lib/table/utils/useTableSelection.js +6 -35
- package/lib/templates/Detail/index.js +0 -5
- package/lib/templates/Form/index.js +0 -5
- package/lib/templates/List/index.js +2 -19
- package/lib/templates/index.js +0 -6
- package/lib/timeline/ProTimeLineItem/index.js +24 -75
- package/lib/timeline/index.js +8 -33
- package/lib/timeline/typing.d.ts +1 -0
- package/lib/utils/index.js +0 -6
- package/lib/utils/message.d.ts +2 -2
- package/lib/utils/message.js +0 -10
- package/lib/utils/useRealHistory.d.ts +8 -0
- package/lib/utils/useRealHistory.js +32 -0
- package/package.json +1 -1
@@ -1,29 +1,16 @@
|
|
1
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
2
|
-
|
3
2
|
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."); }
|
4
|
-
|
5
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
6
|
-
|
7
4
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
8
|
-
|
9
5
|
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; }
|
10
|
-
|
11
6
|
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; }
|
12
|
-
|
13
7
|
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; }
|
14
|
-
|
15
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
16
|
-
|
17
9
|
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."); }
|
18
|
-
|
19
10
|
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
|
-
|
21
11
|
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; }
|
22
|
-
|
23
12
|
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; }
|
24
|
-
|
25
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
26
|
-
|
27
14
|
// 表格项列筛选
|
28
15
|
import React, { useEffect, useMemo, useState } from 'react';
|
29
16
|
import TeamixIcon from '@teamix/icon';
|
@@ -33,47 +20,40 @@ import './index.scss';
|
|
33
20
|
var CheckboxItem = Menu.CheckboxItem;
|
34
21
|
var cls = usePrefixCls('teamix-pro-table-toolbar-filter');
|
35
22
|
var RadioItem = Menu.RadioItem;
|
36
|
-
|
37
23
|
var Filter = function Filter(props) {
|
38
24
|
var column = props.column,
|
39
|
-
|
40
|
-
|
25
|
+
actionRef = props.actionRef,
|
26
|
+
switchCardView = props.switchCardView;
|
41
27
|
var _column$filtersWidth = column.filtersWidth,
|
42
|
-
|
43
|
-
|
28
|
+
filtersWidth = _column$filtersWidth === void 0 ? 130 : _column$filtersWidth;
|
29
|
+
// 选中过滤项
|
44
30
|
var _useState = useState([]),
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
32
|
+
selected = _useState2[0],
|
33
|
+
setSelected = _useState2[1];
|
49
34
|
var _useState3 = useState(false),
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
36
|
+
visible = _useState4[0],
|
37
|
+
setVisible = _useState4[1];
|
54
38
|
useEffect(function () {
|
55
39
|
var _actionRef$current$ge, _actionRef$current, _actionRef$current$ge2, _actionRef$current$ge3, _actionRef$current$ge4, _actionRef$current$ge5;
|
56
|
-
|
57
40
|
// 从全局状态中读取上次存储的条件
|
58
41
|
var rules = (_actionRef$current$ge = (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$ge2 = _actionRef$current.getState) === null || _actionRef$current$ge2 === void 0 ? void 0 : (_actionRef$current$ge3 = _actionRef$current$ge2.call(_actionRef$current)) === null || _actionRef$current$ge3 === void 0 ? void 0 : (_actionRef$current$ge4 = _actionRef$current$ge3.filterRules) === null || _actionRef$current$ge4 === void 0 ? void 0 : (_actionRef$current$ge5 = _actionRef$current$ge4[column.dataIndex]) === null || _actionRef$current$ge5 === void 0 ? void 0 : _actionRef$current$ge5.rules) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : [];
|
59
42
|
setSelected(rules);
|
60
|
-
}, []);
|
61
|
-
|
43
|
+
}, []);
|
44
|
+
// 获取过滤项
|
62
45
|
var filters = useMemo(function () {
|
63
46
|
if (Array.isArray(column.filters)) {
|
64
47
|
return column.filters;
|
65
48
|
}
|
66
|
-
|
67
|
-
|
68
|
-
|
49
|
+
var filters = column.dataSource;
|
50
|
+
// 转换 valueEnum 为 options
|
69
51
|
if (!Array.isArray(column.dataSource)) {
|
70
52
|
filters = Object.entries(column.dataSource).map(function (_ref) {
|
71
53
|
var _nv$label, _nv$color;
|
72
|
-
|
73
54
|
var _ref2 = _slicedToArray(_ref, 2),
|
74
|
-
|
75
|
-
|
76
|
-
|
55
|
+
k = _ref2[0],
|
56
|
+
v = _ref2[1];
|
77
57
|
var nv = v;
|
78
58
|
return _objectSpread(_objectSpread({
|
79
59
|
value: k
|
@@ -82,18 +62,16 @@ var Filter = function Filter(props) {
|
|
82
62
|
color: (_nv$color = nv.color) !== null && _nv$color !== void 0 ? _nv$color : k
|
83
63
|
});
|
84
64
|
});
|
85
|
-
}
|
86
|
-
|
87
|
-
|
65
|
+
}
|
66
|
+
// console.log(filters);
|
88
67
|
return filters;
|
89
|
-
}, []);
|
90
|
-
|
68
|
+
}, []);
|
69
|
+
// 渲染单选
|
91
70
|
var renderSingle = function renderSingle() {
|
92
71
|
return filters === null || filters === void 0 ? void 0 : filters.map(function (_ref3) {
|
93
72
|
var _value$toString;
|
94
|
-
|
95
73
|
var label = _ref3.label,
|
96
|
-
|
74
|
+
value = _ref3.value;
|
97
75
|
var valueStr = (_value$toString = value === null || value === void 0 ? void 0 : value.toString()) !== null && _value$toString !== void 0 ? _value$toString : '';
|
98
76
|
return /*#__PURE__*/React.createElement(RadioItem, {
|
99
77
|
id: valueStr,
|
@@ -104,15 +82,13 @@ var Filter = function Filter(props) {
|
|
104
82
|
}
|
105
83
|
}, label);
|
106
84
|
});
|
107
|
-
};
|
108
|
-
|
109
|
-
|
85
|
+
};
|
86
|
+
// 渲染多选
|
110
87
|
var renderMultiple = function renderMultiple() {
|
111
88
|
return filters === null || filters === void 0 ? void 0 : filters.map(function (_ref4) {
|
112
89
|
var _value$toString2;
|
113
|
-
|
114
90
|
var label = _ref4.label,
|
115
|
-
|
91
|
+
value = _ref4.value;
|
116
92
|
var valueStr = (_value$toString2 = value === null || value === void 0 ? void 0 : value.toString()) !== null && _value$toString2 !== void 0 ? _value$toString2 : '';
|
117
93
|
return /*#__PURE__*/React.createElement(CheckboxItem, {
|
118
94
|
key: valueStr,
|
@@ -128,17 +104,14 @@ var Filter = function Filter(props) {
|
|
128
104
|
}
|
129
105
|
}, label);
|
130
106
|
});
|
131
|
-
};
|
132
|
-
|
133
|
-
|
107
|
+
};
|
108
|
+
// 渲染选择区域
|
134
109
|
var renderSelect = function renderSelect() {
|
135
110
|
if (column.filterMode === 'multiple') {
|
136
111
|
return renderMultiple();
|
137
112
|
}
|
138
|
-
|
139
113
|
return renderSingle();
|
140
114
|
};
|
141
|
-
|
142
115
|
return /*#__PURE__*/React.createElement(Dropdown, {
|
143
116
|
trigger: /*#__PURE__*/React.createElement(TeamixIcon, {
|
144
117
|
size: "small",
|
@@ -174,43 +147,35 @@ var Filter = function Filter(props) {
|
|
174
147
|
}),
|
175
148
|
onClick: function onClick() {
|
176
149
|
var _actionRef$current2, _actionRef$current2$f, _actionRef$current$ge6, _actionRef$current3, _actionRef$current3$g, _actionRef$current3$g2, _actionRef$current4, _actionRef$current4$s, _actionRef$current5, _actionRef$current7, _actionRef$current7$r, _actionRef$current8, _actionRef$current8$r, _actionRef$current9, _actionRef$current9$c;
|
177
|
-
|
178
|
-
|
179
|
-
|
150
|
+
(_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$f = _actionRef$current2.filterDataSource) === null || _actionRef$current2$f === void 0 ? void 0 : _actionRef$current2$f.call(_actionRef$current2, column.dataIndex);
|
151
|
+
// 先获取此列的param
|
180
152
|
var param = '';
|
181
|
-
|
182
153
|
if (column.beforeFilter) {
|
183
154
|
var _column$beforeFilter;
|
184
|
-
|
185
155
|
param = (_column$beforeFilter = column.beforeFilter) === null || _column$beforeFilter === void 0 ? void 0 : _column$beforeFilter.call(column, selected);
|
186
156
|
} else {
|
187
157
|
param = selected.join(',');
|
188
|
-
}
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
158
|
+
}
|
159
|
+
// 需要带上其他所有的信息
|
160
|
+
var rules = (_actionRef$current$ge6 = (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$g = _actionRef$current3.getState) === null || _actionRef$current3$g === void 0 ? void 0 : (_actionRef$current3$g2 = _actionRef$current3$g.call(_actionRef$current3)) === null || _actionRef$current3$g2 === void 0 ? void 0 : _actionRef$current3$g2.filterRules) !== null && _actionRef$current$ge6 !== void 0 ? _actionRef$current$ge6 : {};
|
161
|
+
// 再设置所有的列筛选状态
|
193
162
|
(_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$s = _actionRef$current4.setFilterRules) === null || _actionRef$current4$s === void 0 ? void 0 : _actionRef$current4$s.call(_actionRef$current4, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
|
194
163
|
rules: selected,
|
195
164
|
params: param
|
196
165
|
})));
|
197
166
|
var targetPageKey = 'currentPage';
|
198
167
|
var pageInfo = (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : _actionRef$current5.pageInfo;
|
199
|
-
|
200
168
|
if (pageInfo && (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey)) {
|
201
169
|
targetPageKey = pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey;
|
202
170
|
}
|
203
|
-
|
204
171
|
if (switchCardView === 'card') {
|
205
172
|
var _actionRef$current6, _actionRef$current6$s;
|
206
|
-
|
207
173
|
(_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$s = _actionRef$current6.setData) === null || _actionRef$current6$s === void 0 ? void 0 : _actionRef$current6$s.call(_actionRef$current6, []);
|
208
|
-
}
|
209
|
-
|
210
|
-
|
174
|
+
}
|
175
|
+
// 发送请求
|
211
176
|
(_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$r = _actionRef$current7.request) === null || _actionRef$current7$r === void 0 ? void 0 : _actionRef$current7$r.call(_actionRef$current7, _defineProperty({}, targetPageKey, 1));
|
212
|
-
(_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$r = _actionRef$current8.resetPage) === null || _actionRef$current8$r === void 0 ? void 0 : _actionRef$current8$r.call(_actionRef$current8);
|
213
|
-
|
177
|
+
(_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$r = _actionRef$current8.resetPage) === null || _actionRef$current8$r === void 0 ? void 0 : _actionRef$current8$r.call(_actionRef$current8);
|
178
|
+
// 清空表格选择
|
214
179
|
(_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);
|
215
180
|
setVisible(false);
|
216
181
|
}
|
@@ -222,7 +187,6 @@ var Filter = function Filter(props) {
|
|
222
187
|
}),
|
223
188
|
onClick: function onClick() {
|
224
189
|
var _actionRef$current$ge7, _actionRef$current10, _actionRef$current10$, _actionRef$current10$2, _actionRef$current11, _actionRef$current11$, _actionRef$current12, _actionRef$current12$;
|
225
|
-
|
226
190
|
setSelected([]);
|
227
191
|
var rules = (_actionRef$current$ge7 = (_actionRef$current10 = actionRef.current) === null || _actionRef$current10 === void 0 ? void 0 : (_actionRef$current10$ = _actionRef$current10.getState) === null || _actionRef$current10$ === void 0 ? void 0 : (_actionRef$current10$2 = _actionRef$current10$.call(_actionRef$current10)) === null || _actionRef$current10$2 === void 0 ? void 0 : _actionRef$current10$2.filterRules) !== null && _actionRef$current$ge7 !== void 0 ? _actionRef$current$ge7 : {};
|
228
192
|
(_actionRef$current11 = actionRef.current) === null || _actionRef$current11 === void 0 ? void 0 : (_actionRef$current11$ = _actionRef$current11.setFilterRules) === null || _actionRef$current11$ === void 0 ? void 0 : _actionRef$current11$.call(_actionRef$current11, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
|
@@ -230,26 +194,21 @@ var Filter = function Filter(props) {
|
|
230
194
|
params: ''
|
231
195
|
})));
|
232
196
|
(_actionRef$current12 = actionRef.current) === null || _actionRef$current12 === void 0 ? void 0 : (_actionRef$current12$ = _actionRef$current12.filterDataSource) === null || _actionRef$current12$ === void 0 ? void 0 : _actionRef$current12$.call(_actionRef$current12, column.dataIndex);
|
233
|
-
|
234
197
|
if (selected.length > 0) {
|
235
198
|
var _actionRef$current13, _actionRef$current14, _actionRef$current14$, _actionRef$current15, _actionRef$current15$, _actionRef$current16, _actionRef$current16$;
|
236
|
-
|
237
199
|
var targetPageKey = 'currentPage';
|
238
200
|
var pageInfo = (_actionRef$current13 = actionRef.current) === null || _actionRef$current13 === void 0 ? void 0 : _actionRef$current13.pageInfo;
|
239
|
-
|
240
201
|
if (pageInfo && (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey)) {
|
241
202
|
targetPageKey = pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey;
|
242
|
-
}
|
243
|
-
|
244
|
-
|
203
|
+
}
|
204
|
+
// 发送请求
|
245
205
|
(_actionRef$current14 = actionRef.current) === null || _actionRef$current14 === void 0 ? void 0 : (_actionRef$current14$ = _actionRef$current14.request) === null || _actionRef$current14$ === void 0 ? void 0 : _actionRef$current14$.call(_actionRef$current14, _defineProperty({}, targetPageKey, 1));
|
246
|
-
(_actionRef$current15 = actionRef.current) === null || _actionRef$current15 === void 0 ? void 0 : (_actionRef$current15$ = _actionRef$current15.resetPage) === null || _actionRef$current15$ === void 0 ? void 0 : _actionRef$current15$.call(_actionRef$current15);
|
247
|
-
|
206
|
+
(_actionRef$current15 = actionRef.current) === null || _actionRef$current15 === void 0 ? void 0 : (_actionRef$current15$ = _actionRef$current15.resetPage) === null || _actionRef$current15$ === void 0 ? void 0 : _actionRef$current15$.call(_actionRef$current15);
|
207
|
+
// 清空表格选择
|
248
208
|
(_actionRef$current16 = actionRef.current) === null || _actionRef$current16 === void 0 ? void 0 : (_actionRef$current16$ = _actionRef$current16.clearRowSelection) === null || _actionRef$current16$ === void 0 ? void 0 : _actionRef$current16$.call(_actionRef$current16);
|
249
|
-
}
|
250
|
-
|
209
|
+
}
|
210
|
+
// setVisible(!visible);
|
251
211
|
}
|
252
212
|
}, getMessage('reset'))))));
|
253
213
|
};
|
254
|
-
|
255
214
|
export default Filter;
|
@@ -1,17 +1,10 @@
|
|
1
1
|
var _excluded = ["header", "mainAction", "extra", "actionRef", "dataFilter", "dataFilterFormRef", "afterDataFilter", "rowSelection", "toolBar", "dataTeamixSpm"];
|
2
|
-
|
3
2
|
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; }
|
4
|
-
|
5
3
|
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; }
|
6
|
-
|
7
4
|
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; }
|
8
|
-
|
9
5
|
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); }
|
10
|
-
|
11
6
|
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; }
|
12
|
-
|
13
7
|
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; }
|
14
|
-
|
15
8
|
import React, { isValidElement } from 'react';
|
16
9
|
import { usePrefixCls } from '@teamix/utils';
|
17
10
|
import { Header } from '../../../field';
|
@@ -21,35 +14,30 @@ import ToolBar from '../ToolBar';
|
|
21
14
|
import QuickAction from '../QuickAction';
|
22
15
|
import './index.scss';
|
23
16
|
var cls = usePrefixCls('teamix-pro-table-layout');
|
24
|
-
|
25
17
|
var Layout = function Layout(props) {
|
26
18
|
var header = props.header,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
19
|
+
mainAction = props.mainAction,
|
20
|
+
extra = props.extra,
|
21
|
+
actionRef = props.actionRef,
|
22
|
+
dataFilter = props.dataFilter,
|
23
|
+
dataFilterFormRef = props.dataFilterFormRef,
|
24
|
+
afterDataFilter = props.afterDataFilter,
|
25
|
+
rowSelection = props.rowSelection,
|
26
|
+
toolBar = props.toolBar,
|
27
|
+
dataTeamixSpm = props.dataTeamixSpm,
|
28
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
29
|
+
// 渲染主操作区
|
39
30
|
var renderMainAction = function renderMainAction() {
|
40
31
|
var _mainAction$actions;
|
41
|
-
|
42
32
|
if (_typeof(mainAction) === 'object' && (mainAction === null || mainAction === void 0 ? void 0 : (_mainAction$actions = mainAction.actions) === null || _mainAction$actions === void 0 ? void 0 : _mainAction$actions.length) > 0) {
|
43
33
|
// 判断 actions 是否 visible 都为 false,是的话也不渲染
|
44
34
|
var isEmptyActions = mainAction === null || mainAction === void 0 ? void 0 : mainAction.actions.every(function (action) {
|
45
35
|
return (action === null || action === void 0 ? void 0 : action.visible) === false;
|
46
36
|
});
|
47
|
-
|
48
37
|
if (isEmptyActions) {
|
49
38
|
return;
|
50
|
-
}
|
51
|
-
|
52
|
-
|
39
|
+
}
|
40
|
+
// 默认 context
|
53
41
|
var defaultContext = {
|
54
42
|
action: actionRef.current,
|
55
43
|
rowSelection: rowSelection
|
@@ -61,9 +49,8 @@ var Layout = function Layout(props) {
|
|
61
49
|
"data-teamix-spm": dataTeamixSpm ? "".concat(dataTeamixSpm, "-mainAction") : undefined
|
62
50
|
})));
|
63
51
|
} else return mainAction;
|
64
|
-
};
|
65
|
-
|
66
|
-
|
52
|
+
};
|
53
|
+
// 渲染 addonAfter
|
67
54
|
var renderAddonAfter = function renderAddonAfter() {
|
68
55
|
return /*#__PURE__*/React.createElement("div", {
|
69
56
|
className: cls('addon-after-wrapper')
|
@@ -75,15 +62,12 @@ var Layout = function Layout(props) {
|
|
75
62
|
actionRef: actionRef,
|
76
63
|
toolBar: toolBar
|
77
64
|
}, otherProps)));
|
78
|
-
};
|
79
|
-
|
80
|
-
|
65
|
+
};
|
66
|
+
// 渲染新版 QueryFilter
|
81
67
|
var renderQueryFilter = function renderQueryFilter() {
|
82
68
|
var _dataFilter$schema;
|
83
|
-
|
84
69
|
if (dataFilter === null || dataFilter === void 0 ? void 0 : (_dataFilter$schema = dataFilter.schema) === null || _dataFilter$schema === void 0 ? void 0 : _dataFilter$schema.length) {
|
85
70
|
var _dataFilter$schema2;
|
86
|
-
|
87
71
|
if ( /*#__PURE__*/isValidElement(dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.content)) {
|
88
72
|
// 自定义渲染内容
|
89
73
|
return /*#__PURE__*/React.createElement(QueryFilterLayout, _objectSpread({
|
@@ -91,11 +75,12 @@ var Layout = function Layout(props) {
|
|
91
75
|
// 全屏模式下展开收起过滤器需要重新计算tableMaxHeight
|
92
76
|
setTimeout(function () {
|
93
77
|
var _actionRef$current, _actionRef$current$re;
|
94
|
-
|
95
78
|
// if (actionRef.current?.getState?.().fullScreenState) {
|
96
79
|
// 偏移量8像素为面板展开后的下margin
|
97
|
-
(_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$re = _actionRef$current.resetTableMaxBodyHeight) === null || _actionRef$current$re === void 0 ? void 0 : _actionRef$current$re.call(_actionRef$current, expand ? 8 : 0);
|
80
|
+
(_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$re = _actionRef$current.resetTableMaxBodyHeight) === null || _actionRef$current$re === void 0 ? void 0 : _actionRef$current$re.call(_actionRef$current, expand ? 8 : 0);
|
81
|
+
// }
|
98
82
|
});
|
83
|
+
|
99
84
|
(dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.onExpand) && (dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.onExpand(expand));
|
100
85
|
},
|
101
86
|
panelContent: dataFilter.content,
|
@@ -109,11 +94,12 @@ var Layout = function Layout(props) {
|
|
109
94
|
// 全屏模式下展开收起过滤器需要重新计算tableMaxHeight
|
110
95
|
setTimeout(function () {
|
111
96
|
var _actionRef$current2, _actionRef$current2$r;
|
112
|
-
|
113
97
|
// if (actionRef.current?.getState?.().fullScreenState) {
|
114
98
|
// 偏移量8像素为面板展开后的下margin
|
115
|
-
(_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$r = _actionRef$current2.resetTableMaxBodyHeight) === null || _actionRef$current2$r === void 0 ? void 0 : _actionRef$current2$r.call(_actionRef$current2, expand ? 8 : 0);
|
99
|
+
(_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$r = _actionRef$current2.resetTableMaxBodyHeight) === null || _actionRef$current2$r === void 0 ? void 0 : _actionRef$current2$r.call(_actionRef$current2, expand ? 8 : 0);
|
100
|
+
// }
|
116
101
|
});
|
102
|
+
|
117
103
|
(dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.onExpand) && (dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.onExpand(expand));
|
118
104
|
},
|
119
105
|
addonBefore: renderMainAction(),
|
@@ -139,9 +125,8 @@ var Layout = function Layout(props) {
|
|
139
125
|
}, afterDataFilter) : null
|
140
126
|
}));
|
141
127
|
}
|
142
|
-
};
|
143
|
-
|
144
|
-
|
128
|
+
};
|
129
|
+
// 区域组合渲染
|
145
130
|
var renderLayout = function renderLayout() {
|
146
131
|
if (header && mainAction) {
|
147
132
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
@@ -157,7 +142,6 @@ var Layout = function Layout(props) {
|
|
157
142
|
}))), renderQueryFilter());
|
158
143
|
} else if (header && !mainAction) {
|
159
144
|
var _dataFilter$schema3, _dataFilter$schema4;
|
160
|
-
|
161
145
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
162
146
|
className: cls('wrapper')
|
163
147
|
}, /*#__PURE__*/React.createElement("div", {
|
@@ -175,18 +159,14 @@ var Layout = function Layout(props) {
|
|
175
159
|
if (!dataFilterFormRef && !extra) {
|
176
160
|
return null;
|
177
161
|
}
|
178
|
-
|
179
162
|
return /*#__PURE__*/React.createElement(React.Fragment, null, renderQueryFilter());
|
180
163
|
}
|
181
164
|
};
|
182
|
-
|
183
165
|
if ((dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.schema) || mainAction || header || extra || toolBar !== false) {
|
184
166
|
return /*#__PURE__*/React.createElement("div", {
|
185
167
|
className: cls()
|
186
168
|
}, renderLayout());
|
187
169
|
}
|
188
|
-
|
189
170
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
190
171
|
};
|
191
|
-
|
192
172
|
export default /*#__PURE__*/React.memo(Layout);
|
@@ -1,47 +1,36 @@
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
-
|
3
2
|
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."); }
|
4
|
-
|
5
3
|
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); }
|
6
|
-
|
7
4
|
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; }
|
8
|
-
|
9
5
|
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; }
|
10
|
-
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
-
|
13
7
|
import React, { useEffect, useRef, useState } from 'react';
|
14
8
|
import { usePrefixCls } from '@teamix/utils';
|
15
9
|
import './index.scss';
|
16
10
|
import TeamixIcon from '@teamix/icon';
|
17
11
|
import debounce from 'lodash.debounce';
|
18
12
|
var cls = usePrefixCls('teamix-pro-load-more');
|
19
|
-
|
20
13
|
var LoadMore = function LoadMore(props) {
|
21
14
|
var children = props.children,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
var scrollDom = useRef(null);
|
29
|
-
|
15
|
+
onChangeLoadState = props.onChangeLoadState,
|
16
|
+
onLoadMore = props.onLoadMore,
|
17
|
+
scrollHeight = props.scrollHeight,
|
18
|
+
onScrollBottom = props.onScrollBottom,
|
19
|
+
loadStateProp = props.loadState,
|
20
|
+
scrollPositionProp = props.scrollPosition;
|
21
|
+
var scrollDom = useRef(null);
|
22
|
+
// 加载状态
|
30
23
|
var _useState = useState('loadMore'),
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
25
|
+
loadState = _useState2[0],
|
26
|
+
setLoadState = _useState2[1];
|
35
27
|
useEffect(function () {
|
36
28
|
var _scrollDom$current;
|
37
|
-
|
38
29
|
scrollDom === null || scrollDom === void 0 ? void 0 : (_scrollDom$current = scrollDom.current) === null || _scrollDom$current === void 0 ? void 0 : _scrollDom$current.addEventListener('scroll', debounce(function (e) {
|
39
30
|
var _e$target, _e$target2, _e$target3;
|
40
|
-
|
41
31
|
var scrollTop = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.scrollTop;
|
42
32
|
var clientHeight = e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.clientHeight;
|
43
33
|
var scrollHeight = e === null || e === void 0 ? void 0 : (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.scrollHeight;
|
44
|
-
|
45
34
|
if (scrollTop + clientHeight + 5 >= scrollHeight) {
|
46
35
|
onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom();
|
47
36
|
}
|
@@ -49,19 +38,16 @@ var LoadMore = function LoadMore(props) {
|
|
49
38
|
}, []);
|
50
39
|
useEffect(function () {
|
51
40
|
setLoadState(loadStateProp);
|
52
|
-
}, [loadStateProp]);
|
53
|
-
|
41
|
+
}, [loadStateProp]);
|
42
|
+
// 更改加载状态
|
54
43
|
var onLoadState = function onLoadState(state) {
|
55
44
|
setLoadState(state);
|
56
|
-
|
57
45
|
if (state === 'loading') {
|
58
46
|
onLoadMore === null || onLoadMore === void 0 ? void 0 : onLoadMore();
|
59
47
|
}
|
60
|
-
|
61
48
|
onChangeLoadState === null || onChangeLoadState === void 0 ? void 0 : onChangeLoadState(state);
|
62
|
-
};
|
63
|
-
|
64
|
-
|
49
|
+
};
|
50
|
+
// 渲染加载更多和正在加载区域
|
65
51
|
var renderLoadMore = function renderLoadMore() {
|
66
52
|
if (loadState === 'loadMore') {
|
67
53
|
return /*#__PURE__*/React.createElement("div", {
|
@@ -75,7 +61,6 @@ var LoadMore = function LoadMore(props) {
|
|
75
61
|
className: cls('bottom-text-icon')
|
76
62
|
}), "\u52A0\u8F7D\u66F4\u591A");
|
77
63
|
}
|
78
|
-
|
79
64
|
if (loadState === 'loading') {
|
80
65
|
return /*#__PURE__*/React.createElement("div", {
|
81
66
|
className: cls('bottom-text')
|
@@ -85,16 +70,13 @@ var LoadMore = function LoadMore(props) {
|
|
85
70
|
className: cls('bottom-text-icon')
|
86
71
|
}), "\u52A0\u8F7D\u4E2D");
|
87
72
|
}
|
88
|
-
|
89
73
|
if (loadState === 'noMore') {
|
90
74
|
return /*#__PURE__*/React.createElement("div", {
|
91
75
|
className: cls('bottom-text')
|
92
76
|
}, "\u6CA1\u6709\u66F4\u591A\u4E86");
|
93
77
|
}
|
94
|
-
|
95
78
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
96
79
|
};
|
97
|
-
|
98
80
|
return /*#__PURE__*/React.createElement("div", {
|
99
81
|
className: cls(),
|
100
82
|
style: {
|
@@ -103,5 +85,4 @@ var LoadMore = function LoadMore(props) {
|
|
103
85
|
ref: scrollDom
|
104
86
|
}, children, renderLoadMore());
|
105
87
|
};
|
106
|
-
|
107
88
|
export default LoadMore;
|