@ant-design/pro-components 3.0.1-0 → 3.1.0-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-components.min.js +1 -1
- package/es/card/ProCard.js +4 -2
- package/es/card/components/Actions/style.d.ts +1 -1
- package/es/card/components/Card/index.js +8 -4
- package/es/card/components/Card/style.d.ts +1 -1
- package/es/card/components/CheckCard/index.d.ts +6 -0
- package/es/card/components/CheckCard/index.js +2 -1
- package/es/card/components/CheckCard/style.d.ts +1 -1
- package/es/card/components/Divider/style.d.ts +1 -1
- package/es/card/components/Loading/style.d.ts +1 -1
- package/es/card/components/Operation/style.d.ts +1 -1
- package/es/card/components/Statistic/style.d.ts +1 -1
- package/es/card/components/Statistic/style.js +2 -6
- package/es/card/components/StatisticCard/index.js +4 -2
- package/es/card/components/StatisticCard/style.d.ts +1 -1
- package/es/card/typing.d.ts +5 -0
- package/es/descriptions/index.js +2 -1
- package/es/field/ValueTypeToComponent.js +4 -4
- package/es/field/components/Cascader/index.d.ts +0 -1
- package/es/field/components/Checkbox/index.d.ts +0 -1
- package/es/field/components/ColorPicker/index.d.ts +1 -1
- package/es/field/components/Percent/util.d.ts +1 -1
- package/es/field/components/Radio/index.d.ts +0 -1
- package/es/field/components/Segmented/index.d.ts +0 -1
- package/es/field/components/Select/LightSelect/index.js +1 -2
- package/es/field/components/Select/SearchSelect/index.d.ts +6 -1
- package/es/field/components/Select/SearchSelect/index.js +101 -15
- package/es/field/components/Select/index.d.ts +0 -3
- package/es/field/components/Select/index.js +5 -3
- package/es/field/components/TreeSelect/index.d.ts +0 -1
- package/es/form/BaseForm/BaseForm.d.ts +3 -0
- package/es/form/BaseForm/BaseForm.js +9 -2
- package/es/form/BaseForm/LightWrapper/style.d.ts +1 -1
- package/es/form/components/Captcha/index.d.ts +8 -2
- package/es/form/components/Captcha/index.js +9 -1
- package/es/form/components/DatePicker/BaseDatePicker.js +20 -12
- package/es/form/components/DateRangePicker/BaseDateRanger.js +38 -13
- package/es/form/components/FormItem/Group/index.js +1 -1
- package/es/form/components/FormItem/Group/style.d.ts +1 -1
- package/es/form/components/List/index.d.ts +1 -1
- package/es/form/components/List/style.d.ts +1 -1
- package/es/form/components/SchemaForm/index.js +1 -2
- package/es/form/components/Text/index.js +4 -2
- package/es/form/components/UploadButton/index.d.ts +1 -1
- package/es/form/components/UploadButton/index.js +3 -3
- package/es/form/index.d.ts +1 -0
- package/es/form/layouts/DrawerForm/index.d.ts +1 -1
- package/es/form/layouts/DrawerForm/index.js +3 -2
- package/es/form/layouts/DrawerForm/style.d.ts +1 -1
- package/es/form/layouts/LightFilter/style.d.ts +1 -1
- package/es/form/layouts/LoginForm/index.d.ts +1 -1
- package/es/form/layouts/LoginForm/style.d.ts +1 -1
- package/es/form/layouts/LoginFormPage/index.d.ts +1 -1
- package/es/form/layouts/LoginFormPage/style.d.ts +1 -1
- package/es/form/layouts/ModalForm/index.js +2 -1
- package/es/form/layouts/ProForm/index.d.ts +1 -1
- package/es/form/layouts/QueryFilter/index.d.ts +2 -1
- package/es/form/layouts/QueryFilter/style.d.ts +1 -1
- package/es/form/layouts/StepsForm/index.js +15 -2
- package/es/form/layouts/StepsForm/style.d.ts +1 -1
- package/es/layout/components/AppsLogoComponents/index.js +3 -1
- package/es/layout/components/AppsLogoComponents/style/index.d.ts +1 -1
- package/es/layout/components/CollapsedIcon/style.d.ts +1 -1
- package/es/layout/components/FooterToolbar/style/index.d.ts +1 -1
- package/es/layout/components/FooterToolbar/style/stylish.d.ts +1 -1
- package/es/layout/components/GlobalFooter/index.d.ts +1 -1
- package/es/layout/components/GlobalFooter/style.d.ts +1 -1
- package/es/layout/components/GlobalHeader/rightContentStyle.d.ts +1 -1
- package/es/layout/components/GlobalHeader/style.d.ts +1 -1
- package/es/layout/components/GridContent/style.d.ts +1 -1
- package/es/layout/components/Header/style/header.d.ts +1 -1
- package/es/layout/components/Header/style/stylish.d.ts +1 -1
- package/es/layout/components/Help/ProHelpDrawer.d.ts +1 -1
- package/es/layout/components/Help/ProHelpDrawer.js +3 -1
- package/es/layout/components/Help/ProHelpPopover.js +1 -1
- package/es/layout/components/Help/style.d.ts +1 -1
- package/es/layout/components/PageContainer/style/index.d.ts +1 -1
- package/es/layout/components/PageContainer/style/stylish.d.ts +1 -1
- package/es/layout/components/PageHeader/style/index.d.ts +1 -1
- package/es/layout/components/SettingDrawer/index.js +2 -2
- package/es/layout/components/SettingDrawer/style/index.d.ts +1 -1
- package/es/layout/components/SiderMenu/BaseMenu.d.ts +1 -1
- package/es/layout/components/SiderMenu/BaseMenu.js +3 -3
- package/es/layout/components/SiderMenu/SiderMenu.js +8 -8
- package/es/layout/components/SiderMenu/index.js +11 -6
- package/es/layout/components/SiderMenu/style/index.d.ts +1 -1
- package/es/layout/components/SiderMenu/style/menu.d.ts +1 -1
- package/es/layout/components/SiderMenu/style/stylish.d.ts +1 -1
- package/es/layout/components/TopNavHeader/style.d.ts +1 -1
- package/es/layout/defaultSettings.d.ts +6 -0
- package/es/layout/style/index.d.ts +1 -1
- package/es/list/style/index.d.ts +1 -1
- package/es/provider/index.d.ts +1 -0
- package/es/provider/index.js +11 -6
- package/es/provider/useStyle/index.d.ts +2 -1
- package/es/provider/useStyle/index.js +20 -12
- package/es/table/Table.js +412 -280
- package/es/table/components/Alert/index.d.ts +1 -1
- package/es/table/components/Alert/style.d.ts +1 -1
- package/es/table/components/ColumnSetting/index.d.ts +1 -1
- package/es/table/components/ColumnSetting/index.js +15 -3
- package/es/table/components/ColumnSetting/style.d.ts +1 -1
- package/es/table/components/DragSortTable/index.d.ts +1 -1
- package/es/table/components/DragSortTable/style.d.ts +1 -1
- package/es/table/components/EditableTable/index.js +530 -197
- package/es/table/components/ListToolBar/style.d.ts +1 -1
- package/es/table/style/index.d.ts +1 -1
- package/es/table/typing.d.ts +37 -12
- package/es/table/useFetchData.js +8 -13
- package/es/table/utils/columnRender.d.ts +1 -1
- package/es/table/utils/genProColumnToColumn.d.ts +2 -2
- package/es/table/utils/genProColumnToColumn.js +5 -17
- package/es/table/utils/index.d.ts +60 -5
- package/es/table/utils/index.js +157 -18
- package/es/utils/components/DropdownFooter/style.d.ts +1 -1
- package/es/utils/components/FieldLabel/style.d.ts +1 -1
- package/es/utils/components/FilterDropdown/index.js +1 -1
- package/es/utils/components/FilterDropdown/style.d.ts +1 -1
- package/es/utils/components/InlineErrorFormItem/style.d.ts +1 -1
- package/es/utils/components/LabelIconTip/style.d.ts +1 -1
- package/es/utils/conversionMomentValue/index.js +14 -2
- package/es/utils/proFieldParsingText/index.js +1 -1
- package/es/utils/typing.d.ts +1 -1
- package/es/utils/useEditableArray/index.d.ts +3 -6
- package/es/utils/useEditableArray/index.js +562 -318
- package/es/utils/useEditableMap/index.js +82 -25
- package/es/utils/useMediaQuery/query.js +11 -5
- package/lib/card/ProCard.js +4 -2
- package/lib/card/components/Actions/style.d.ts +1 -1
- package/lib/card/components/Card/index.js +8 -4
- package/lib/card/components/Card/style.d.ts +1 -1
- package/lib/card/components/CheckCard/index.d.ts +6 -0
- package/lib/card/components/CheckCard/index.js +2 -1
- package/lib/card/components/CheckCard/style.d.ts +1 -1
- package/lib/card/components/Divider/style.d.ts +1 -1
- package/lib/card/components/Loading/style.d.ts +1 -1
- package/lib/card/components/Operation/style.d.ts +1 -1
- package/lib/card/components/Statistic/style.d.ts +1 -1
- package/lib/card/components/Statistic/style.js +2 -6
- package/lib/card/components/StatisticCard/index.js +4 -2
- package/lib/card/components/StatisticCard/style.d.ts +1 -1
- package/lib/card/typing.d.ts +5 -0
- package/lib/descriptions/index.js +2 -1
- package/lib/field/ValueTypeToComponent.js +4 -4
- package/lib/field/components/Cascader/index.d.ts +0 -1
- package/lib/field/components/Checkbox/index.d.ts +0 -1
- package/lib/field/components/ColorPicker/index.d.ts +1 -1
- package/lib/field/components/Percent/util.d.ts +1 -1
- package/lib/field/components/Radio/index.d.ts +0 -1
- package/lib/field/components/Segmented/index.d.ts +0 -1
- package/lib/field/components/Select/LightSelect/index.js +1 -2
- package/lib/field/components/Select/SearchSelect/index.d.ts +6 -1
- package/lib/field/components/Select/SearchSelect/index.js +101 -15
- package/lib/field/components/Select/index.d.ts +0 -3
- package/lib/field/components/Select/index.js +5 -3
- package/lib/field/components/TreeSelect/index.d.ts +0 -1
- package/lib/form/BaseForm/BaseForm.d.ts +3 -0
- package/lib/form/BaseForm/BaseForm.js +9 -2
- package/lib/form/BaseForm/LightWrapper/style.d.ts +1 -1
- package/lib/form/components/Captcha/index.d.ts +8 -2
- package/lib/form/components/Captcha/index.js +9 -1
- package/lib/form/components/DatePicker/BaseDatePicker.js +19 -11
- package/lib/form/components/DateRangePicker/BaseDateRanger.js +37 -12
- package/lib/form/components/Digit/DigitRange.d.ts +1 -1
- package/lib/form/components/FormItem/Group/index.js +1 -1
- package/lib/form/components/FormItem/Group/style.d.ts +1 -1
- package/lib/form/components/List/index.d.ts +1 -1
- package/lib/form/components/List/style.d.ts +1 -1
- package/lib/form/components/SchemaForm/index.js +1 -2
- package/lib/form/components/Text/index.js +4 -2
- package/lib/form/components/UploadButton/index.d.ts +1 -1
- package/lib/form/components/UploadButton/index.js +3 -3
- package/lib/form/index.d.ts +1 -0
- package/lib/form/layouts/DrawerForm/index.d.ts +1 -1
- package/lib/form/layouts/DrawerForm/index.js +3 -2
- package/lib/form/layouts/DrawerForm/style.d.ts +1 -1
- package/lib/form/layouts/LightFilter/style.d.ts +1 -1
- package/lib/form/layouts/LoginForm/index.d.ts +1 -1
- package/lib/form/layouts/LoginForm/style.d.ts +1 -1
- package/lib/form/layouts/LoginFormPage/index.d.ts +1 -1
- package/lib/form/layouts/LoginFormPage/style.d.ts +1 -1
- package/lib/form/layouts/ModalForm/index.js +2 -1
- package/lib/form/layouts/ProForm/index.d.ts +2 -2
- package/lib/form/layouts/QueryFilter/index.d.ts +2 -1
- package/lib/form/layouts/QueryFilter/style.d.ts +1 -1
- package/lib/form/layouts/StepsForm/index.js +15 -2
- package/lib/form/layouts/StepsForm/style.d.ts +1 -1
- package/lib/layout/components/AppsLogoComponents/index.js +3 -1
- package/lib/layout/components/AppsLogoComponents/style/index.d.ts +1 -1
- package/lib/layout/components/CollapsedIcon/style.d.ts +1 -1
- package/lib/layout/components/FooterToolbar/style/index.d.ts +1 -1
- package/lib/layout/components/FooterToolbar/style/stylish.d.ts +1 -1
- package/lib/layout/components/GlobalFooter/index.d.ts +1 -1
- package/lib/layout/components/GlobalFooter/style.d.ts +1 -1
- package/lib/layout/components/GlobalHeader/rightContentStyle.d.ts +1 -1
- package/lib/layout/components/GlobalHeader/style.d.ts +1 -1
- package/lib/layout/components/GridContent/style.d.ts +1 -1
- package/lib/layout/components/Header/style/header.d.ts +1 -1
- package/lib/layout/components/Header/style/stylish.d.ts +1 -1
- package/lib/layout/components/Help/ProHelpDrawer.d.ts +1 -1
- package/lib/layout/components/Help/ProHelpDrawer.js +3 -1
- package/lib/layout/components/Help/ProHelpPopover.js +1 -1
- package/lib/layout/components/Help/style.d.ts +1 -1
- package/lib/layout/components/PageContainer/style/index.d.ts +1 -1
- package/lib/layout/components/PageContainer/style/stylish.d.ts +1 -1
- package/lib/layout/components/PageHeader/style/index.d.ts +1 -1
- package/lib/layout/components/SettingDrawer/index.js +2 -2
- package/lib/layout/components/SettingDrawer/style/index.d.ts +1 -1
- package/lib/layout/components/SiderMenu/BaseMenu.d.ts +1 -1
- package/lib/layout/components/SiderMenu/BaseMenu.js +3 -3
- package/lib/layout/components/SiderMenu/SiderMenu.js +8 -8
- package/lib/layout/components/SiderMenu/index.js +11 -6
- package/lib/layout/components/SiderMenu/style/index.d.ts +1 -1
- package/lib/layout/components/SiderMenu/style/menu.d.ts +1 -1
- package/lib/layout/components/SiderMenu/style/stylish.d.ts +1 -1
- package/lib/layout/components/TopNavHeader/style.d.ts +1 -1
- package/lib/layout/defaultSettings.d.ts +6 -0
- package/lib/layout/style/index.d.ts +1 -1
- package/lib/list/style/index.d.ts +1 -1
- package/lib/provider/index.d.ts +1 -0
- package/lib/provider/index.js +11 -6
- package/lib/provider/useStyle/index.d.ts +2 -1
- package/lib/provider/useStyle/index.js +20 -12
- package/lib/table/Table.js +422 -290
- package/lib/table/components/Alert/index.d.ts +1 -1
- package/lib/table/components/Alert/style.d.ts +1 -1
- package/lib/table/components/ColumnSetting/index.d.ts +1 -1
- package/lib/table/components/ColumnSetting/index.js +15 -3
- package/lib/table/components/ColumnSetting/style.d.ts +1 -1
- package/lib/table/components/DragSortTable/index.d.ts +1 -1
- package/lib/table/components/DragSortTable/style.d.ts +1 -1
- package/lib/table/components/EditableTable/index.js +529 -196
- package/lib/table/components/ListToolBar/style.d.ts +1 -1
- package/lib/table/style/index.d.ts +1 -1
- package/lib/table/typing.d.ts +37 -12
- package/lib/table/useFetchData.js +8 -13
- package/lib/table/utils/columnRender.d.ts +1 -1
- package/lib/table/utils/genProColumnToColumn.d.ts +2 -2
- package/lib/table/utils/genProColumnToColumn.js +4 -16
- package/lib/table/utils/index.d.ts +60 -5
- package/lib/table/utils/index.js +159 -20
- package/lib/utils/components/DropdownFooter/style.d.ts +1 -1
- package/lib/utils/components/FieldLabel/style.d.ts +1 -1
- package/lib/utils/components/FilterDropdown/index.js +1 -1
- package/lib/utils/components/FilterDropdown/style.d.ts +1 -1
- package/lib/utils/components/InlineErrorFormItem/style.d.ts +1 -1
- package/lib/utils/components/LabelIconTip/style.d.ts +1 -1
- package/lib/utils/conversionMomentValue/index.js +14 -2
- package/lib/utils/proFieldParsingText/index.js +1 -1
- package/lib/utils/typing.d.ts +1 -1
- package/lib/utils/useEditableArray/index.d.ts +3 -6
- package/lib/utils/useEditableArray/index.js +568 -324
- package/lib/utils/useEditableMap/index.js +82 -25
- package/lib/utils/useMediaQuery/query.js +10 -4
- package/package.json +45 -45
package/es/table/Table.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
4
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
4
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
7
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
8
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
9
|
-
|
|
6
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
7
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
8
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
9
|
+
var _excluded = ["rowKey", "tableClassName", "defaultClassName", "action", "tableColumn", "type", "pagination", "rowSelection", "size", "defaultSize", "tableStyle", "toolbarDom", "hideToolbar", "searchNode", "style", "cardProps", "alertDom", "name", "onSortChange", "onFilterChange", "options", "isLightFilter", "className", "cardBordered", "editableUtils", "getRowKey", "tableRef"],
|
|
10
10
|
_excluded2 = ["cardBordered", "request", "className", "params", "defaultData", "headerTitle", "postData", "ghost", "pagination", "actionRef", "columns", "toolBarRender", "optionsRender", "onLoad", "onRequestError", "style", "cardProps", "tableStyle", "tableClassName", "options", "search", "name", "onLoadingChange", "rowSelection", "beforeSearchSubmit", "tableAlertRender", "defaultClassName", "formRef", "type", "columnEmptyText", "toolbar", "rowKey", "manualRequest", "polling", "tooltip", "revalidateOnFocus", "searchFormRender"];
|
|
11
11
|
import { ConfigProvider, Table } from 'antd';
|
|
12
12
|
import classNames from 'classnames';
|
|
@@ -24,14 +24,277 @@ import Toolbar from "./components/ToolBar";
|
|
|
24
24
|
import { Container, TableContext } from "./Store/Provide";
|
|
25
25
|
import { useStyle } from "./style";
|
|
26
26
|
import useFetchData from "./useFetchData";
|
|
27
|
-
import { genColumnKey, isBordered, mergePagination,
|
|
27
|
+
import { flattenColumns, genColumnKey, getServerFilterResult, getServerSorterResult, isBordered, mergePagination, parseServerDefaultColumnConfig, useActionType } from "./utils";
|
|
28
28
|
import { columnSort } from "./utils/columnSort";
|
|
29
29
|
import { genProColumnToColumn } from "./utils/genProColumnToColumn";
|
|
30
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
30
|
import { createElement as _createElement } from "react";
|
|
32
31
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
33
32
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
|
+
function useEditableDataSource(_ref) {
|
|
35
|
+
var dataSource = _ref.dataSource,
|
|
36
|
+
editableUtils = _ref.editableUtils,
|
|
37
|
+
pagination = _ref.pagination,
|
|
38
|
+
getRowKey = _ref.getRowKey,
|
|
39
|
+
childrenColumnName = _ref.childrenColumnName;
|
|
40
|
+
return useMemo(function () {
|
|
41
|
+
var baseData = Array.isArray(dataSource) ? _toConsumableArray(dataSource) : [];
|
|
42
|
+
var newLineConfig = editableUtils === null || editableUtils === void 0 ? void 0 : editableUtils.newLineRecord;
|
|
43
|
+
var defaultValue = newLineConfig === null || newLineConfig === void 0 ? void 0 : newLineConfig.defaultValue;
|
|
44
|
+
if (!newLineConfig || !defaultValue) {
|
|
45
|
+
return baseData;
|
|
46
|
+
}
|
|
47
|
+
var newLineOptions = newLineConfig.options;
|
|
48
|
+
var childrenName = childrenColumnName || 'children';
|
|
49
|
+
if (newLineOptions !== null && newLineOptions !== void 0 && newLineOptions.parentKey) {
|
|
50
|
+
var _recordKeyToString, _newLineOptions$recor;
|
|
51
|
+
var newRow = _objectSpread(_objectSpread({}, defaultValue), {}, {
|
|
52
|
+
map_row_parentKey: (_recordKeyToString = recordKeyToString(newLineOptions.parentKey)) === null || _recordKeyToString === void 0 ? void 0 : _recordKeyToString.toString()
|
|
53
|
+
});
|
|
54
|
+
var actionProps = {
|
|
55
|
+
data: baseData,
|
|
56
|
+
getRowKey: getRowKey,
|
|
57
|
+
row: newRow,
|
|
58
|
+
key: (_newLineOptions$recor = newLineOptions === null || newLineOptions === void 0 ? void 0 : newLineOptions.recordKey) !== null && _newLineOptions$recor !== void 0 ? _newLineOptions$recor : getRowKey(newRow, -1),
|
|
59
|
+
childrenColumnName: childrenName
|
|
60
|
+
};
|
|
61
|
+
return editableRowByKey(actionProps, (newLineOptions === null || newLineOptions === void 0 ? void 0 : newLineOptions.position) === 'top' ? 'top' : 'update');
|
|
62
|
+
}
|
|
63
|
+
if ((newLineOptions === null || newLineOptions === void 0 ? void 0 : newLineOptions.position) === 'top') {
|
|
64
|
+
return [defaultValue].concat(_toConsumableArray(baseData));
|
|
65
|
+
}
|
|
66
|
+
var pageConfig = pagination && _typeof(pagination) === 'object' ? pagination : undefined;
|
|
67
|
+
if (pageConfig !== null && pageConfig !== void 0 && pageConfig.current && pageConfig !== null && pageConfig !== void 0 && pageConfig.pageSize) {
|
|
68
|
+
if (pageConfig.pageSize > baseData.length) {
|
|
69
|
+
baseData.push(defaultValue);
|
|
70
|
+
return baseData;
|
|
71
|
+
}
|
|
72
|
+
var insertIndex = pageConfig.current * pageConfig.pageSize - 1;
|
|
73
|
+
baseData.splice(insertIndex, 0, defaultValue);
|
|
74
|
+
return baseData;
|
|
75
|
+
}
|
|
76
|
+
baseData.push(defaultValue);
|
|
77
|
+
return baseData;
|
|
78
|
+
}, [childrenColumnName, dataSource, editableUtils === null || editableUtils === void 0 ? void 0 : editableUtils.newLineRecord, getRowKey, pagination]);
|
|
79
|
+
}
|
|
80
|
+
function useTableCardBodyStyle(_ref2) {
|
|
81
|
+
var propsCardProps = _ref2.propsCardProps,
|
|
82
|
+
notNeedCardDom = _ref2.notNeedCardDom,
|
|
83
|
+
name = _ref2.name,
|
|
84
|
+
hideToolbar = _ref2.hideToolbar,
|
|
85
|
+
toolbarDom = _ref2.toolbarDom,
|
|
86
|
+
pagination = _ref2.pagination;
|
|
87
|
+
return useMemo(function () {
|
|
88
|
+
if (propsCardProps === false || notNeedCardDom || !!name) {
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
if (hideToolbar) {
|
|
92
|
+
return {
|
|
93
|
+
padding: 0
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (toolbarDom) {
|
|
97
|
+
return {
|
|
98
|
+
paddingBlockStart: 0
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
padding: 0
|
|
103
|
+
};
|
|
104
|
+
}, [hideToolbar, name, notNeedCardDom, pagination, propsCardProps, toolbarDom]);
|
|
105
|
+
}
|
|
106
|
+
function useTableContent(_ref3) {
|
|
107
|
+
var editable = _ref3.editable,
|
|
108
|
+
name = _ref3.name,
|
|
109
|
+
toolbarDom = _ref3.toolbarDom,
|
|
110
|
+
alertDom = _ref3.alertDom,
|
|
111
|
+
tableDom = _ref3.tableDom,
|
|
112
|
+
dateFormatter = _ref3.dateFormatter,
|
|
113
|
+
editableOnValuesChange = _ref3.editableOnValuesChange;
|
|
114
|
+
return useMemo(function () {
|
|
115
|
+
if (editable && !name) {
|
|
116
|
+
var _editable$formProps;
|
|
117
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
118
|
+
children: [toolbarDom, alertDom, /*#__PURE__*/_createElement(ProForm, _objectSpread(_objectSpread({}, editable.formProps), {}, {
|
|
119
|
+
formRef: (_editable$formProps = editable.formProps) === null || _editable$formProps === void 0 ? void 0 : _editable$formProps.formRef,
|
|
120
|
+
component: false,
|
|
121
|
+
form: editable.form,
|
|
122
|
+
onValuesChange: editableOnValuesChange,
|
|
123
|
+
key: "table",
|
|
124
|
+
submitter: false,
|
|
125
|
+
omitNil: false,
|
|
126
|
+
dateFormatter: dateFormatter
|
|
127
|
+
}), tableDom)]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
131
|
+
children: [toolbarDom, alertDom, tableDom]
|
|
132
|
+
});
|
|
133
|
+
}, [alertDom, dateFormatter, editable, editableOnValuesChange, name, tableDom, toolbarDom]);
|
|
134
|
+
}
|
|
135
|
+
function useRowKey(_ref4) {
|
|
136
|
+
var rowKey = _ref4.rowKey,
|
|
137
|
+
name = _ref4.name;
|
|
138
|
+
return useMemo(function () {
|
|
139
|
+
if (typeof rowKey === 'function') {
|
|
140
|
+
return rowKey;
|
|
141
|
+
}
|
|
142
|
+
return function (record, index) {
|
|
143
|
+
var _ref5;
|
|
144
|
+
if (index === -1) {
|
|
145
|
+
return record === null || record === void 0 ? void 0 : record[rowKey];
|
|
146
|
+
}
|
|
147
|
+
if (name) {
|
|
148
|
+
return index === null || index === void 0 ? void 0 : index.toString();
|
|
149
|
+
}
|
|
150
|
+
return (_ref5 = record === null || record === void 0 ? void 0 : record[rowKey]) !== null && _ref5 !== void 0 ? _ref5 : index === null || index === void 0 ? void 0 : index.toString();
|
|
151
|
+
};
|
|
152
|
+
}, [name, rowKey]);
|
|
153
|
+
}
|
|
154
|
+
function useMergedPagination(_ref6) {
|
|
155
|
+
var propsPagination = _ref6.propsPagination,
|
|
156
|
+
action = _ref6.action,
|
|
157
|
+
intl = _ref6.intl,
|
|
158
|
+
request = _ref6.request,
|
|
159
|
+
type = _ref6.type;
|
|
160
|
+
return useMemo(function () {
|
|
161
|
+
var newPropsPagination = propsPagination === false ? false : _objectSpread({}, propsPagination || {});
|
|
162
|
+
var pageConfig = _objectSpread(_objectSpread({}, action.pageInfo), {}, {
|
|
163
|
+
setPageInfo: function setPageInfo(_ref7) {
|
|
164
|
+
var pageSize = _ref7.pageSize,
|
|
165
|
+
current = _ref7.current;
|
|
166
|
+
var pageInfo = action.pageInfo;
|
|
167
|
+
if (pageSize === pageInfo.pageSize || pageInfo.current === 1) {
|
|
168
|
+
action.setPageInfo({
|
|
169
|
+
pageSize: pageSize,
|
|
170
|
+
current: current
|
|
171
|
+
});
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (request) action.setDataSource([]);
|
|
175
|
+
action.setPageInfo({
|
|
176
|
+
pageSize: pageSize,
|
|
177
|
+
current: type === 'list' ? current : 1
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
if (request && newPropsPagination) {
|
|
182
|
+
delete newPropsPagination.onChange;
|
|
183
|
+
delete newPropsPagination.onShowSizeChange;
|
|
184
|
+
}
|
|
185
|
+
return mergePagination(newPropsPagination, pageConfig, intl);
|
|
186
|
+
}, [action, intl, propsPagination, request, type]);
|
|
187
|
+
}
|
|
188
|
+
function useSearchNode(_ref8) {
|
|
189
|
+
var search = _ref8.search,
|
|
190
|
+
type = _ref8.type,
|
|
191
|
+
pagination = _ref8.pagination,
|
|
192
|
+
beforeSearchSubmit = _ref8.beforeSearchSubmit,
|
|
193
|
+
actionRef = _ref8.actionRef,
|
|
194
|
+
columns = _ref8.columns,
|
|
195
|
+
_onFormSearchSubmit = _ref8.onFormSearchSubmit,
|
|
196
|
+
ghost = _ref8.ghost,
|
|
197
|
+
onReset = _ref8.onReset,
|
|
198
|
+
onSubmit = _ref8.onSubmit,
|
|
199
|
+
loading = _ref8.loading,
|
|
200
|
+
manualRequest = _ref8.manualRequest,
|
|
201
|
+
form = _ref8.form,
|
|
202
|
+
formRef = _ref8.formRef,
|
|
203
|
+
cardBordered = _ref8.cardBordered,
|
|
204
|
+
dateFormatter = _ref8.dateFormatter,
|
|
205
|
+
searchFormRender = _ref8.searchFormRender,
|
|
206
|
+
proTableProps = _ref8.proTableProps;
|
|
207
|
+
return useMemo(function () {
|
|
208
|
+
var node = search === false && type !== 'form' ? null : /*#__PURE__*/_jsx(FormRender, {
|
|
209
|
+
pagination: pagination,
|
|
210
|
+
beforeSearchSubmit: beforeSearchSubmit,
|
|
211
|
+
action: actionRef,
|
|
212
|
+
columns: columns,
|
|
213
|
+
onFormSearchSubmit: function onFormSearchSubmit(values) {
|
|
214
|
+
_onFormSearchSubmit(values);
|
|
215
|
+
},
|
|
216
|
+
ghost: ghost,
|
|
217
|
+
onReset: onReset,
|
|
218
|
+
onSubmit: onSubmit,
|
|
219
|
+
loading: loading,
|
|
220
|
+
manualRequest: manualRequest,
|
|
221
|
+
search: search,
|
|
222
|
+
form: form,
|
|
223
|
+
formRef: formRef,
|
|
224
|
+
type: type || 'table',
|
|
225
|
+
cardBordered: cardBordered,
|
|
226
|
+
dateFormatter: dateFormatter
|
|
227
|
+
});
|
|
228
|
+
if (searchFormRender && node) {
|
|
229
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
230
|
+
children: searchFormRender(proTableProps, node)
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return node;
|
|
234
|
+
}, [actionRef, beforeSearchSubmit, cardBordered, columns, dateFormatter, form, formRef, ghost, loading, manualRequest, _onFormSearchSubmit, onReset, onSubmit, pagination, proTableProps, search, searchFormRender, type]);
|
|
235
|
+
}
|
|
236
|
+
function useToolbarDom(context) {
|
|
237
|
+
var toolBarRender = context.toolBarRender,
|
|
238
|
+
headerTitle = context.headerTitle,
|
|
239
|
+
hideToolbar = context.hideToolbar,
|
|
240
|
+
selectedRows = context.selectedRows,
|
|
241
|
+
selectedRowKeys = context.selectedRowKeys,
|
|
242
|
+
tableColumn = context.tableColumn,
|
|
243
|
+
tooltip = context.tooltip,
|
|
244
|
+
toolbar = context.toolbar,
|
|
245
|
+
isLightFilter = context.isLightFilter,
|
|
246
|
+
searchNode = context.searchNode,
|
|
247
|
+
options = context.options,
|
|
248
|
+
optionsRender = context.optionsRender,
|
|
249
|
+
actionRef = context.actionRef,
|
|
250
|
+
setFormSearch = context.setFormSearch,
|
|
251
|
+
formSearch = context.formSearch;
|
|
252
|
+
return useMemo(function () {
|
|
253
|
+
if (toolBarRender === false) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
return /*#__PURE__*/_jsx(Toolbar, {
|
|
257
|
+
headerTitle: headerTitle,
|
|
258
|
+
hideToolbar: hideToolbar,
|
|
259
|
+
selectedRows: selectedRows,
|
|
260
|
+
selectedRowKeys: selectedRowKeys,
|
|
261
|
+
tableColumn: tableColumn,
|
|
262
|
+
tooltip: tooltip,
|
|
263
|
+
toolbar: toolbar,
|
|
264
|
+
onFormSearchSubmit: function onFormSearchSubmit(newValues) {
|
|
265
|
+
setFormSearch(_objectSpread(_objectSpread({}, formSearch || {}), newValues));
|
|
266
|
+
},
|
|
267
|
+
searchNode: isLightFilter ? searchNode : null,
|
|
268
|
+
options: options,
|
|
269
|
+
optionsRender: optionsRender,
|
|
270
|
+
actionRef: actionRef,
|
|
271
|
+
toolBarRender: toolBarRender
|
|
272
|
+
});
|
|
273
|
+
}, [actionRef, formSearch, headerTitle, hideToolbar, isLightFilter, options, optionsRender, searchNode, selectedRowKeys, selectedRows, setFormSearch, tableColumn, toolBarRender, tooltip, toolbar]);
|
|
274
|
+
}
|
|
275
|
+
function useAlertDom(_ref9) {
|
|
276
|
+
var propsRowSelection = _ref9.propsRowSelection,
|
|
277
|
+
selectedRowKeys = _ref9.selectedRowKeys,
|
|
278
|
+
selectedRows = _ref9.selectedRows,
|
|
279
|
+
onCleanSelected = _ref9.onCleanSelected,
|
|
280
|
+
tableAlertOptionRender = _ref9.tableAlertOptionRender,
|
|
281
|
+
tableAlertRender = _ref9.tableAlertRender;
|
|
282
|
+
return useMemo(function () {
|
|
283
|
+
if (propsRowSelection === false) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
return /*#__PURE__*/_jsx(Alert, {
|
|
287
|
+
selectedRowKeys: selectedRowKeys,
|
|
288
|
+
selectedRows: selectedRows,
|
|
289
|
+
onCleanSelected: onCleanSelected,
|
|
290
|
+
alertOptionRender: tableAlertOptionRender,
|
|
291
|
+
alertInfoRender: tableAlertRender,
|
|
292
|
+
alwaysShowAlert: propsRowSelection === null || propsRowSelection === void 0 ? void 0 : propsRowSelection.alwaysShowAlert
|
|
293
|
+
});
|
|
294
|
+
}, [onCleanSelected, propsRowSelection, selectedRowKeys, selectedRows, tableAlertOptionRender, tableAlertRender]);
|
|
295
|
+
}
|
|
34
296
|
function TableRender(props) {
|
|
297
|
+
var _props$expandable;
|
|
35
298
|
var rowKey = props.rowKey,
|
|
36
299
|
tableClassName = props.tableClassName,
|
|
37
300
|
defaultClassName = props.defaultClassName,
|
|
@@ -58,8 +321,16 @@ function TableRender(props) {
|
|
|
58
321
|
cardBordered = props.cardBordered,
|
|
59
322
|
editableUtils = props.editableUtils,
|
|
60
323
|
getRowKey = props.getRowKey,
|
|
324
|
+
tableRef = props.tableRef,
|
|
61
325
|
rest = _objectWithoutProperties(props, _excluded);
|
|
62
326
|
var counter = useContext(TableContext);
|
|
327
|
+
var mergedDataSource = useEditableDataSource({
|
|
328
|
+
dataSource: action.dataSource,
|
|
329
|
+
editableUtils: editableUtils,
|
|
330
|
+
pagination: pagination,
|
|
331
|
+
getRowKey: getRowKey,
|
|
332
|
+
childrenColumnName: ((_props$expandable = props.expandable) === null || _props$expandable === void 0 ? void 0 : _props$expandable.childrenColumnName) || 'children'
|
|
333
|
+
});
|
|
63
334
|
|
|
64
335
|
/** 需要遍历一下,不然不支持嵌套表格 */
|
|
65
336
|
var columns = useMemo(function () {
|
|
@@ -82,44 +353,13 @@ function TableRender(props) {
|
|
|
82
353
|
return loopFilter(tableColumns);
|
|
83
354
|
}, [counter.columnsMap, tableColumns]);
|
|
84
355
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
newLineOptions = _ref.options,
|
|
93
|
-
row = _ref.defaultValue;
|
|
94
|
-
var isNewLineRecordAtTop = (newLineOptions === null || newLineOptions === void 0 ? void 0 : newLineOptions.position) === 'top';
|
|
95
|
-
if (newLineOptions !== null && newLineOptions !== void 0 && newLineOptions.parentKey) {
|
|
96
|
-
var _recordKeyToString, _props$expandable;
|
|
97
|
-
var actionProps = {
|
|
98
|
-
data: dataSource,
|
|
99
|
-
getRowKey: getRowKey,
|
|
100
|
-
row: _objectSpread(_objectSpread({}, row), {}, {
|
|
101
|
-
map_row_parentKey: (_recordKeyToString = recordKeyToString(newLineOptions.parentKey)) === null || _recordKeyToString === void 0 ? void 0 : _recordKeyToString.toString()
|
|
102
|
-
}),
|
|
103
|
-
key: newLineOptions === null || newLineOptions === void 0 ? void 0 : newLineOptions.recordKey,
|
|
104
|
-
childrenColumnName: ((_props$expandable = props.expandable) === null || _props$expandable === void 0 ? void 0 : _props$expandable.childrenColumnName) || 'children'
|
|
105
|
-
};
|
|
106
|
-
return editableRowByKey(actionProps, isNewLineRecordAtTop ? 'top' : 'update');
|
|
107
|
-
}
|
|
108
|
-
if (isNewLineRecordAtTop) {
|
|
109
|
-
return [row].concat(_toConsumableArray(action.dataSource));
|
|
110
|
-
}
|
|
111
|
-
// 如果有分页的功能,我们加到这一页的末尾
|
|
112
|
-
if (pagination && pagination !== null && pagination !== void 0 && pagination.current && pagination !== null && pagination !== void 0 && pagination.pageSize) {
|
|
113
|
-
var newDataSource = _toConsumableArray(action.dataSource);
|
|
114
|
-
if ((pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) > newDataSource.length) {
|
|
115
|
-
newDataSource.push(row);
|
|
116
|
-
return newDataSource;
|
|
117
|
-
}
|
|
118
|
-
newDataSource.splice((pagination === null || pagination === void 0 ? void 0 : pagination.current) * (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) - 1, 0, row);
|
|
119
|
-
return newDataSource;
|
|
120
|
-
}
|
|
121
|
-
return [].concat(_toConsumableArray(action.dataSource), [row]);
|
|
122
|
-
};
|
|
356
|
+
// 需要进行筛选的列
|
|
357
|
+
var useFilterColumns = useMemo(function () {
|
|
358
|
+
var _columns = flattenColumns(columns);
|
|
359
|
+
return _columns.filter(function (column) {
|
|
360
|
+
return !!column.filters;
|
|
361
|
+
});
|
|
362
|
+
}, [columns]);
|
|
123
363
|
var getTableProps = function getTableProps() {
|
|
124
364
|
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
125
365
|
size: size,
|
|
@@ -128,27 +368,19 @@ function TableRender(props) {
|
|
|
128
368
|
style: tableStyle,
|
|
129
369
|
columns: columns,
|
|
130
370
|
loading: action.loading,
|
|
131
|
-
dataSource:
|
|
371
|
+
dataSource: mergedDataSource,
|
|
132
372
|
pagination: pagination,
|
|
133
373
|
onChange: function onChange(changePagination, filters, sorter, extra) {
|
|
134
374
|
var _rest$onChange;
|
|
135
375
|
(_rest$onChange = rest.onChange) === null || _rest$onChange === void 0 || _rest$onChange.call(rest, changePagination, filters, sorter, extra);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}, {});
|
|
145
|
-
onSortChange((_omitUndefined = omitUndefined(data)) !== null && _omitUndefined !== void 0 ? _omitUndefined : {});
|
|
146
|
-
} else {
|
|
147
|
-
var _sorter$column, _omitUndefined2;
|
|
148
|
-
var sorterOfColumn = (_sorter$column = sorter.column) === null || _sorter$column === void 0 ? void 0 : _sorter$column.sorter;
|
|
149
|
-
var isSortByField = (sorterOfColumn === null || sorterOfColumn === void 0 ? void 0 : sorterOfColumn.toString()) === sorterOfColumn;
|
|
150
|
-
onSortChange((_omitUndefined2 = omitUndefined(_defineProperty({}, "".concat(isSortByField ? sorterOfColumn : sorter.field), sorter.order))) !== null && _omitUndefined2 !== void 0 ? _omitUndefined2 : {});
|
|
151
|
-
}
|
|
376
|
+
|
|
377
|
+
// 传递服务端筛选数据
|
|
378
|
+
var serverFilter = getServerFilterResult(filters, useFilterColumns);
|
|
379
|
+
onFilterChange(omitUndefined(serverFilter));
|
|
380
|
+
|
|
381
|
+
// 传递服务端排序数据
|
|
382
|
+
var serverSorter = getServerSorterResult(sorter);
|
|
383
|
+
onSortChange(omitUndefined(serverSorter));
|
|
152
384
|
}
|
|
153
385
|
});
|
|
154
386
|
};
|
|
@@ -171,7 +403,8 @@ function TableRender(props) {
|
|
|
171
403
|
rowProps: undefined
|
|
172
404
|
},
|
|
173
405
|
children: /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({}, getTableProps()), {}, {
|
|
174
|
-
rowKey: rowKey
|
|
406
|
+
rowKey: rowKey,
|
|
407
|
+
ref: tableRef
|
|
175
408
|
}))
|
|
176
409
|
});
|
|
177
410
|
|
|
@@ -179,55 +412,23 @@ function TableRender(props) {
|
|
|
179
412
|
var tableDom = props.tableViewRender ? props.tableViewRender(_objectSpread(_objectSpread({}, getTableProps()), {}, {
|
|
180
413
|
rowSelection: rowSelection !== false ? rowSelection : undefined
|
|
181
414
|
}), baseTableDom) : baseTableDom;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
omitNil: false,
|
|
200
|
-
dateFormatter: props.dateFormatter
|
|
201
|
-
}), tableDom)]
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
205
|
-
children: [toolbarDom, alertDom, tableDom]
|
|
206
|
-
});
|
|
207
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
208
|
-
}, [alertDom, props.loading, !!props.editable, tableDom, toolbarDom]);
|
|
209
|
-
var cardBodyStyle = useMemo(function () {
|
|
210
|
-
if (propsCardProps === false || notNeedCardDom === true || !!props.name) return {};
|
|
211
|
-
if (hideToolbar) {
|
|
212
|
-
return {
|
|
213
|
-
padding: 0
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
if (toolbarDom) {
|
|
217
|
-
return {
|
|
218
|
-
paddingBlockStart: 0
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
if (toolbarDom && pagination === false) {
|
|
222
|
-
return {
|
|
223
|
-
paddingBlockStart: 0
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
// if (!toolbarDom)
|
|
227
|
-
return {
|
|
228
|
-
padding: 0
|
|
229
|
-
};
|
|
230
|
-
}, [notNeedCardDom, pagination, props.name, propsCardProps, toolbarDom, hideToolbar]);
|
|
415
|
+
var tableContentDom = useTableContent({
|
|
416
|
+
editable: props.editable,
|
|
417
|
+
name: props.name,
|
|
418
|
+
toolbarDom: toolbarDom,
|
|
419
|
+
alertDom: alertDom,
|
|
420
|
+
tableDom: tableDom,
|
|
421
|
+
dateFormatter: props.dateFormatter,
|
|
422
|
+
editableOnValuesChange: editableUtils.onValuesChange
|
|
423
|
+
});
|
|
424
|
+
var cardBodyStyle = useTableCardBodyStyle({
|
|
425
|
+
propsCardProps: propsCardProps,
|
|
426
|
+
notNeedCardDom: notNeedCardDom,
|
|
427
|
+
name: props.name,
|
|
428
|
+
hideToolbar: hideToolbar,
|
|
429
|
+
toolbarDom: toolbarDom,
|
|
430
|
+
pagination: pagination
|
|
431
|
+
});
|
|
231
432
|
|
|
232
433
|
/** Table 区域的 dom,为了方便 render */
|
|
233
434
|
var tableAreaDom =
|
|
@@ -235,7 +436,9 @@ function TableRender(props) {
|
|
|
235
436
|
propsCardProps === false || notNeedCardDom === true || !!props.name ? tableContentDom : /*#__PURE__*/_jsx(ProCard, _objectSpread(_objectSpread({
|
|
236
437
|
ghost: props.ghost,
|
|
237
438
|
variant: isBordered('table', cardBordered) ? 'outlined' : 'borderless',
|
|
238
|
-
|
|
439
|
+
styles: {
|
|
440
|
+
body: cardBodyStyle
|
|
441
|
+
}
|
|
239
442
|
}, propsCardProps), {}, {
|
|
240
443
|
children: tableContentDom
|
|
241
444
|
}));
|
|
@@ -272,7 +475,7 @@ function TableRender(props) {
|
|
|
272
475
|
}
|
|
273
476
|
var emptyObj = {};
|
|
274
477
|
var ProTable = function ProTable(props) {
|
|
275
|
-
var _props$expandable2;
|
|
478
|
+
var _props$expandable2, _counter$rootDomRef;
|
|
276
479
|
var cardBordered = props.cardBordered,
|
|
277
480
|
request = props.request,
|
|
278
481
|
propsClassName = props.className,
|
|
@@ -324,6 +527,8 @@ var ProTable = function ProTable(props) {
|
|
|
324
527
|
|
|
325
528
|
/** 通用的来操作子节点的工具类 */
|
|
326
529
|
var actionRef = useRef();
|
|
530
|
+
// antd Table 实例 ref(仅用于转发 scrollTo 能力)
|
|
531
|
+
var antTableRef = useRef(null);
|
|
327
532
|
var defaultFormRef = useRef();
|
|
328
533
|
var formRef = propRef || defaultFormRef;
|
|
329
534
|
useImperativeHandle(propsActionRef, function () {
|
|
@@ -348,54 +553,25 @@ var ProTable = function ProTable(props) {
|
|
|
348
553
|
_useMountMergeState4 = _slicedToArray(_useMountMergeState3, 2),
|
|
349
554
|
formSearch = _useMountMergeState4[0],
|
|
350
555
|
setFormSearch = _useMountMergeState4[1];
|
|
351
|
-
var
|
|
556
|
+
var _useMemo = useMemo(function () {
|
|
557
|
+
var _parseServerDefaultCo = parseServerDefaultColumnConfig(flattenColumns(propsColumns)),
|
|
558
|
+
sort = _parseServerDefaultCo.sort,
|
|
559
|
+
filter = _parseServerDefaultCo.filter;
|
|
560
|
+
return {
|
|
561
|
+
defaultProFilter: filter,
|
|
562
|
+
defaultProSort: sort
|
|
563
|
+
};
|
|
564
|
+
}, [propsColumns]),
|
|
565
|
+
defaultProFilter = _useMemo.defaultProFilter,
|
|
566
|
+
defaultProSort = _useMemo.defaultProSort;
|
|
567
|
+
var _useMountMergeState5 = useMountMergeState(defaultProFilter),
|
|
352
568
|
_useMountMergeState6 = _slicedToArray(_useMountMergeState5, 2),
|
|
353
569
|
proFilter = _useMountMergeState6[0],
|
|
354
570
|
setProFilter = _useMountMergeState6[1];
|
|
355
|
-
var _useMountMergeState7 = useMountMergeState(
|
|
571
|
+
var _useMountMergeState7 = useMountMergeState(defaultProSort),
|
|
356
572
|
_useMountMergeState8 = _slicedToArray(_useMountMergeState7, 2),
|
|
357
573
|
proSort = _useMountMergeState8[0],
|
|
358
574
|
setProSort = _useMountMergeState8[1];
|
|
359
|
-
|
|
360
|
-
// 平铺所有columns, 用于判断是用的是本地筛选/排序
|
|
361
|
-
var loopColumns = useCallback(function (data) {
|
|
362
|
-
var _columns = [];
|
|
363
|
-
for (var i = 0; i < data.length; i++) {
|
|
364
|
-
var _curItem = data[i];
|
|
365
|
-
if (_curItem.children) {
|
|
366
|
-
loopColumns(_curItem.children);
|
|
367
|
-
} else {
|
|
368
|
-
_columns.push(_curItem);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
return _columns;
|
|
372
|
-
}, []);
|
|
373
|
-
|
|
374
|
-
/** 如果所有列中的 filters = true | undefined 说明是用的是本地筛选 任何一列配置 filters=false,就能绕过这个判断 */
|
|
375
|
-
var useLocaleFilter = useMemo(function () {
|
|
376
|
-
var _columns = loopColumns(propsColumns);
|
|
377
|
-
return _columns === null || _columns === void 0 ? void 0 : _columns.every(function (column) {
|
|
378
|
-
return !!column.filters && !!column.onFilter || column.filters === undefined && column.onFilter === undefined;
|
|
379
|
-
});
|
|
380
|
-
}, [loopColumns, propsColumns]);
|
|
381
|
-
|
|
382
|
-
/** 如果所有列中的 sorter != true 说明是用的是本地排序 任何一列配置 sorter=true,就能绕过这个判断 */
|
|
383
|
-
var useLocaleSorter = useMemo(function () {
|
|
384
|
-
var _columns = loopColumns(propsColumns);
|
|
385
|
-
return _columns === null || _columns === void 0 ? void 0 : _columns.every(function (column) {
|
|
386
|
-
return column.sorter !== true;
|
|
387
|
-
});
|
|
388
|
-
}, [loopColumns, propsColumns]);
|
|
389
|
-
|
|
390
|
-
/** 设置默认的服務端排序和筛选值 */
|
|
391
|
-
useEffect(function () {
|
|
392
|
-
var _parseDefaultColumnCo = parseDefaultColumnConfig(propsColumns),
|
|
393
|
-
sort = _parseDefaultColumnCo.sort,
|
|
394
|
-
filter = _parseDefaultColumnCo.filter;
|
|
395
|
-
if (!useLocaleFilter) setProFilter(filter);
|
|
396
|
-
if (!useLocaleSorter) setProSort(sort);
|
|
397
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
398
|
-
}, []);
|
|
399
575
|
var intl = useIntl();
|
|
400
576
|
|
|
401
577
|
/** 需要初始化 不然默认可能报错 这里取了 defaultCurrent 和 current 为了保证不会重复刷新 */
|
|
@@ -411,7 +587,7 @@ var ProTable = function ProTable(props) {
|
|
|
411
587
|
var fetchData = useMemo(function () {
|
|
412
588
|
if (!request) return undefined;
|
|
413
589
|
return /*#__PURE__*/function () {
|
|
414
|
-
var
|
|
590
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(pageParams) {
|
|
415
591
|
var actionParams, response;
|
|
416
592
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
417
593
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -430,7 +606,7 @@ var ProTable = function ProTable(props) {
|
|
|
430
606
|
}, _callee);
|
|
431
607
|
}));
|
|
432
608
|
return function (_x) {
|
|
433
|
-
return
|
|
609
|
+
return _ref10.apply(this, arguments);
|
|
434
610
|
};
|
|
435
611
|
}();
|
|
436
612
|
}, [formSearch, params, proFilter, proSort, request]);
|
|
@@ -483,22 +659,10 @@ var ProTable = function ProTable(props) {
|
|
|
483
659
|
var preserveRecordsRef = React.useRef(new Map());
|
|
484
660
|
|
|
485
661
|
// ============================ RowKey ============================
|
|
486
|
-
var getRowKey =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return function (record, index) {
|
|
491
|
-
var _ref3;
|
|
492
|
-
if (index === -1) {
|
|
493
|
-
return record === null || record === void 0 ? void 0 : record[rowKey];
|
|
494
|
-
}
|
|
495
|
-
// 如果 props 中有name 的话,用index 来做行号,这样方便转化为 index
|
|
496
|
-
if (props.name) {
|
|
497
|
-
return index === null || index === void 0 ? void 0 : index.toString();
|
|
498
|
-
}
|
|
499
|
-
return (_ref3 = record === null || record === void 0 ? void 0 : record[rowKey]) !== null && _ref3 !== void 0 ? _ref3 : index === null || index === void 0 ? void 0 : index.toString();
|
|
500
|
-
};
|
|
501
|
-
}, [props.name, rowKey]);
|
|
662
|
+
var getRowKey = useRowKey({
|
|
663
|
+
rowKey: rowKey,
|
|
664
|
+
name: props.name
|
|
665
|
+
});
|
|
502
666
|
useMemo(function () {
|
|
503
667
|
var _action$dataSource;
|
|
504
668
|
if ((_action$dataSource = action.dataSource) !== null && _action$dataSource !== void 0 && _action$dataSource.length) {
|
|
@@ -513,40 +677,13 @@ var ProTable = function ProTable(props) {
|
|
|
513
677
|
}, [action.dataSource, getRowKey]);
|
|
514
678
|
|
|
515
679
|
/** 页面编辑的计算 */
|
|
516
|
-
var pagination =
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
// pageSize 发生改变,并且你不是在第一页,切回到第一页
|
|
525
|
-
// 这样可以防止出现 跳转到一个空的数据页的问题
|
|
526
|
-
if (pageSize === pageInfo.pageSize || pageInfo.current === 1) {
|
|
527
|
-
action.setPageInfo({
|
|
528
|
-
pageSize: pageSize,
|
|
529
|
-
current: current
|
|
530
|
-
});
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// 通过request的时候清空数据,然后刷新不然可能会导致 pageSize 没有数据多
|
|
535
|
-
if (request) action.setDataSource([]);
|
|
536
|
-
action.setPageInfo({
|
|
537
|
-
pageSize: pageSize,
|
|
538
|
-
// 目前只有 List 和 Table 支持分页, List 有分页的时候 还是使用之前的当前页码
|
|
539
|
-
current: type === 'list' ? current : 1
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
if (request && newPropsPagination) {
|
|
544
|
-
delete newPropsPagination.onChange;
|
|
545
|
-
delete newPropsPagination.onShowSizeChange;
|
|
546
|
-
}
|
|
547
|
-
return mergePagination(newPropsPagination, pageConfig, intl);
|
|
548
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
549
|
-
}, [propsPagination, action, intl]);
|
|
680
|
+
var pagination = useMergedPagination({
|
|
681
|
+
propsPagination: propsPagination,
|
|
682
|
+
action: action,
|
|
683
|
+
intl: intl,
|
|
684
|
+
request: request,
|
|
685
|
+
type: type
|
|
686
|
+
});
|
|
550
687
|
useDeepCompareEffect(function () {
|
|
551
688
|
var _action$pageInfo;
|
|
552
689
|
// request 存在且params不为空,且已经请求过数据才需要设置。
|
|
@@ -579,8 +716,8 @@ var ProTable = function ProTable(props) {
|
|
|
579
716
|
childrenColumnName: ((_props$expandable2 = props.expandable) === null || _props$expandable2 === void 0 ? void 0 : _props$expandable2.childrenColumnName) || 'children',
|
|
580
717
|
dataSource: action.dataSource || [],
|
|
581
718
|
setDataSource: function setDataSource(data) {
|
|
582
|
-
var _props$
|
|
583
|
-
(_props$
|
|
719
|
+
var _props$editable, _props$editable$onVal;
|
|
720
|
+
(_props$editable = props.editable) === null || _props$editable === void 0 || (_props$editable$onVal = _props$editable.onValuesChange) === null || _props$editable$onVal === void 0 || _props$editable$onVal.call(_props$editable, undefined, data);
|
|
584
721
|
action.setDataSource(data);
|
|
585
722
|
}
|
|
586
723
|
}));
|
|
@@ -591,16 +728,22 @@ var ProTable = function ProTable(props) {
|
|
|
591
728
|
|
|
592
729
|
/** 绑定 action */
|
|
593
730
|
useActionType(actionRef, action, {
|
|
731
|
+
nativeElement: ((_counter$rootDomRef = counter.rootDomRef) === null || _counter$rootDomRef === void 0 ? void 0 : _counter$rootDomRef.current) || undefined,
|
|
732
|
+
focus: function focus() {
|
|
733
|
+
var _counter$rootDomRef2;
|
|
734
|
+
// 聚焦到表格根元素
|
|
735
|
+
(_counter$rootDomRef2 = counter.rootDomRef) === null || _counter$rootDomRef2 === void 0 || (_counter$rootDomRef2 = _counter$rootDomRef2.current) === null || _counter$rootDomRef2 === void 0 || _counter$rootDomRef2.focus();
|
|
736
|
+
},
|
|
594
737
|
fullScreen: function fullScreen() {
|
|
595
|
-
var _counter$
|
|
596
|
-
if (!((_counter$
|
|
738
|
+
var _counter$rootDomRef3;
|
|
739
|
+
if (!((_counter$rootDomRef3 = counter.rootDomRef) !== null && _counter$rootDomRef3 !== void 0 && _counter$rootDomRef3.current) || !document.fullscreenEnabled) {
|
|
597
740
|
return;
|
|
598
741
|
}
|
|
599
742
|
if (document.fullscreenElement) {
|
|
600
743
|
document.exitFullscreen();
|
|
601
744
|
} else {
|
|
602
|
-
var _counter$
|
|
603
|
-
(_counter$
|
|
745
|
+
var _counter$rootDomRef4;
|
|
746
|
+
(_counter$rootDomRef4 = counter.rootDomRef) === null || _counter$rootDomRef4 === void 0 || _counter$rootDomRef4.current.requestFullscreen();
|
|
604
747
|
}
|
|
605
748
|
},
|
|
606
749
|
onCleanSelected: function onCleanSelected() {
|
|
@@ -611,13 +754,6 @@ var ProTable = function ProTable(props) {
|
|
|
611
754
|
var _formRef$current;
|
|
612
755
|
// 清空选中行
|
|
613
756
|
_onCleanSelected();
|
|
614
|
-
var _parseDefaultColumnCo2 = parseDefaultColumnConfig(propsColumns),
|
|
615
|
-
sort = _parseDefaultColumnCo2.sort,
|
|
616
|
-
filter = _parseDefaultColumnCo2.filter;
|
|
617
|
-
// 清空筛选
|
|
618
|
-
setProFilter(filter);
|
|
619
|
-
// 清空排序
|
|
620
|
-
setProSort(sort);
|
|
621
757
|
|
|
622
758
|
// 清空 toolbar 搜索
|
|
623
759
|
counter.setKeyWords(undefined);
|
|
@@ -626,11 +762,19 @@ var ProTable = function ProTable(props) {
|
|
|
626
762
|
current: 1
|
|
627
763
|
});
|
|
628
764
|
|
|
765
|
+
// 重置绑定筛选值
|
|
766
|
+
setProFilter(defaultProFilter);
|
|
767
|
+
// 重置绑定排序值
|
|
768
|
+
setProSort(defaultProSort);
|
|
769
|
+
|
|
629
770
|
// 重置表单
|
|
630
771
|
formRef === null || formRef === void 0 || (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.resetFields();
|
|
631
|
-
setFormSearch({});
|
|
632
772
|
},
|
|
633
|
-
editableUtils: editableUtils
|
|
773
|
+
editableUtils: editableUtils,
|
|
774
|
+
scrollTo: function scrollTo(arg) {
|
|
775
|
+
var _current, _current$scrollTo;
|
|
776
|
+
return antTableRef === null || antTableRef === void 0 || (_current = antTableRef.current) === null || _current === void 0 || (_current$scrollTo = _current.scrollTo) === null || _current$scrollTo === void 0 ? void 0 : _current$scrollTo.call(_current, arg);
|
|
777
|
+
}
|
|
634
778
|
});
|
|
635
779
|
|
|
636
780
|
/** 同步 action */
|
|
@@ -670,11 +814,11 @@ var ProTable = function ProTable(props) {
|
|
|
670
814
|
/** 同步 Pagination,支持受控的 页码 和 pageSize */
|
|
671
815
|
useDeepCompareEffect(function () {
|
|
672
816
|
var pageInfo = action.pageInfo;
|
|
673
|
-
var
|
|
674
|
-
|
|
675
|
-
current =
|
|
676
|
-
|
|
677
|
-
pageSize =
|
|
817
|
+
var _ref11 = propsPagination || {},
|
|
818
|
+
_ref11$current = _ref11.current,
|
|
819
|
+
current = _ref11$current === void 0 ? pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.current : _ref11$current,
|
|
820
|
+
_ref11$pageSize = _ref11.pageSize,
|
|
821
|
+
pageSize = _ref11$pageSize === void 0 ? pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.pageSize : _ref11$pageSize;
|
|
678
822
|
if (propsPagination && (current || pageSize) && (pageSize !== (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.pageSize) || current !== (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.current))) {
|
|
679
823
|
action.setPageInfo({
|
|
680
824
|
pageSize: pageSize || pageInfo.pageSize,
|
|
@@ -697,13 +841,13 @@ var ProTable = function ProTable(props) {
|
|
|
697
841
|
|
|
698
842
|
/** 是不是 LightFilter, LightFilter 有一些特殊的处理 */
|
|
699
843
|
var isLightFilter = search !== false && (search === null || search === void 0 ? void 0 : search.filterType) === 'light';
|
|
700
|
-
var
|
|
844
|
+
var onFormSearchSubmit = useCallback(function (values) {
|
|
701
845
|
// 判断search.onSearch返回值决定是否更新formSearch
|
|
702
846
|
if (options && options.search) {
|
|
703
847
|
var _options$search, _options$search$onSea;
|
|
704
|
-
var
|
|
705
|
-
|
|
706
|
-
name =
|
|
848
|
+
var _ref12 = options.search === true ? {} : options.search,
|
|
849
|
+
_ref12$name = _ref12.name,
|
|
850
|
+
name = _ref12$name === void 0 ? 'keyword' : _ref12$name;
|
|
707
851
|
|
|
708
852
|
/** 如果传入的 onSearch 返回值为 false,则不要把options.search.name对应的值set到formSearch */
|
|
709
853
|
var success = (_options$search = options.search) === null || _options$search === void 0 || (_options$search$onSea = _options$search.onSearch) === null || _options$search$onSea === void 0 ? void 0 : _options$search$onSea.call(_options$search, counter.keyWords);
|
|
@@ -721,35 +865,26 @@ var ProTable = function ProTable(props) {
|
|
|
721
865
|
}
|
|
722
866
|
return action.loading;
|
|
723
867
|
}, [action.loading]);
|
|
724
|
-
var searchNode =
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
});
|
|
745
|
-
if (searchFormRender && node) {
|
|
746
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
747
|
-
children: searchFormRender(props, node)
|
|
748
|
-
});
|
|
749
|
-
} else {
|
|
750
|
-
return node;
|
|
751
|
-
}
|
|
752
|
-
}, [beforeSearchSubmit, formRef, ghost, loading, manualRequest, _onFormSearchSubmit, pagination, props, propsColumns, search, searchFormRender, type]);
|
|
868
|
+
var searchNode = useSearchNode({
|
|
869
|
+
search: search,
|
|
870
|
+
type: type,
|
|
871
|
+
pagination: pagination,
|
|
872
|
+
beforeSearchSubmit: beforeSearchSubmit,
|
|
873
|
+
actionRef: actionRef,
|
|
874
|
+
columns: propsColumns,
|
|
875
|
+
onFormSearchSubmit: onFormSearchSubmit,
|
|
876
|
+
ghost: ghost,
|
|
877
|
+
onReset: props.onReset,
|
|
878
|
+
onSubmit: props.onSubmit,
|
|
879
|
+
loading: !!loading,
|
|
880
|
+
manualRequest: manualRequest,
|
|
881
|
+
form: props.form,
|
|
882
|
+
formRef: formRef,
|
|
883
|
+
cardBordered: props.cardBordered,
|
|
884
|
+
dateFormatter: props.dateFormatter,
|
|
885
|
+
searchFormRender: searchFormRender,
|
|
886
|
+
proTableProps: props
|
|
887
|
+
});
|
|
753
888
|
var selectedRows = useMemo(function () {
|
|
754
889
|
return selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.map(function (key) {
|
|
755
890
|
var _preserveRecordsRef$c;
|
|
@@ -759,9 +894,8 @@ var ProTable = function ProTable(props) {
|
|
|
759
894
|
var hideToolbar = useMemo(function () {
|
|
760
895
|
return options === false && !headerTitle && !toolBarRender && !toolbar && !isLightFilter;
|
|
761
896
|
}, [options, headerTitle, toolBarRender, toolbar, isLightFilter]);
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
var toolbarDom = toolBarRender === false ? null : /*#__PURE__*/_jsx(Toolbar, {
|
|
897
|
+
var toolbarDom = useToolbarDom({
|
|
898
|
+
toolBarRender: toolBarRender,
|
|
765
899
|
headerTitle: headerTitle,
|
|
766
900
|
hideToolbar: hideToolbar,
|
|
767
901
|
selectedRows: selectedRows,
|
|
@@ -769,25 +903,22 @@ var ProTable = function ProTable(props) {
|
|
|
769
903
|
tableColumn: tableColumn,
|
|
770
904
|
tooltip: tooltip,
|
|
771
905
|
toolbar: toolbar,
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
},
|
|
775
|
-
searchNode: isLightFilter ? searchNode : null,
|
|
906
|
+
isLightFilter: isLightFilter,
|
|
907
|
+
searchNode: searchNode,
|
|
776
908
|
options: options,
|
|
777
909
|
optionsRender: optionsRender,
|
|
778
910
|
actionRef: actionRef,
|
|
779
|
-
|
|
911
|
+
setFormSearch: setFormSearch,
|
|
912
|
+
formSearch: formSearch
|
|
780
913
|
});
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
var alertDom = propsRowSelection !== false ? /*#__PURE__*/_jsx(Alert, {
|
|
914
|
+
var alertDom = useAlertDom({
|
|
915
|
+
propsRowSelection: propsRowSelection,
|
|
784
916
|
selectedRowKeys: selectedRowKeys,
|
|
785
917
|
selectedRows: selectedRows,
|
|
786
918
|
onCleanSelected: _onCleanSelected,
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}) : null;
|
|
919
|
+
tableAlertOptionRender: rest.tableAlertOptionRender,
|
|
920
|
+
tableAlertRender: tableAlertRender
|
|
921
|
+
});
|
|
791
922
|
return wrapSSR( /*#__PURE__*/_jsx(TableRender, _objectSpread(_objectSpread({}, props), {}, {
|
|
792
923
|
name: isEditorTable,
|
|
793
924
|
defaultClassName: defaultClassName,
|
|
@@ -804,15 +935,16 @@ var ProTable = function ProTable(props) {
|
|
|
804
935
|
toolbarDom: toolbarDom,
|
|
805
936
|
hideToolbar: hideToolbar,
|
|
806
937
|
onSortChange: function onSortChange(sortConfig) {
|
|
807
|
-
if (
|
|
808
|
-
setProSort(sortConfig);
|
|
938
|
+
if (isEqual(sortConfig, proSort)) return;
|
|
939
|
+
setProSort(sortConfig !== null && sortConfig !== void 0 ? sortConfig : {});
|
|
809
940
|
},
|
|
810
941
|
onFilterChange: function onFilterChange(filterConfig) {
|
|
811
|
-
if (
|
|
812
|
-
setProFilter(filterConfig);
|
|
942
|
+
if (isEqual(filterConfig, proFilter)) return;
|
|
943
|
+
setProFilter(filterConfig !== null && filterConfig !== void 0 ? filterConfig : {});
|
|
813
944
|
},
|
|
814
945
|
editableUtils: editableUtils,
|
|
815
|
-
getRowKey: getRowKey
|
|
946
|
+
getRowKey: getRowKey,
|
|
947
|
+
tableRef: antTableRef
|
|
816
948
|
})));
|
|
817
949
|
};
|
|
818
950
|
|