@zat-design/sisyphus-react 3.11.14-beta.12 → 3.11.14-beta.14
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/es/ProEnum/hooks/useEnum.d.ts +2 -2
- package/es/ProEnum/hooks/useEnum.js +46 -17
- package/es/ProEnum/utils/index.d.ts +8 -1
- package/es/ProEnum/utils/index.js +9 -2
- package/es/ProTable/components/RenderTabs/index.d.ts +4 -0
- package/es/ProTable/components/RenderTabs/index.js +78 -0
- package/es/ProTable/components/index.d.ts +25 -0
- package/es/ProTable/components/index.js +26 -1
- package/es/ProTable/hooks/useAntdTable.d.ts +1 -92
- package/es/ProTable/hooks/useAntdTable.js +6 -2
- package/es/ProTable/index.js +6 -3
- package/es/ProTable/propsType.d.ts +61 -15
- package/lib/ProEnum/hooks/useEnum.d.ts +2 -2
- package/lib/ProEnum/hooks/useEnum.js +48 -17
- package/lib/ProEnum/utils/index.d.ts +8 -1
- package/lib/ProEnum/utils/index.js +9 -2
- package/lib/ProTable/components/RenderTabs/index.d.ts +4 -0
- package/lib/ProTable/components/RenderTabs/index.js +82 -0
- package/lib/ProTable/components/index.d.ts +25 -0
- package/lib/ProTable/components/index.js +8 -1
- package/lib/ProTable/hooks/useAntdTable.d.ts +1 -92
- package/lib/ProTable/hooks/useAntdTable.js +5 -1
- package/lib/ProTable/index.js +5 -2
- package/lib/ProTable/propsType.d.ts +61 -15
- package/package.json +1 -1
- package/.vscode/extensions.json +0 -5
- package/coverage/lcov-report/src/.umi/core/devScripts.ts.html +0 -241
- package/coverage/lcov-report/src/.umi/core/history.ts.html +0 -148
- package/coverage/lcov-report/src/.umi/core/index.html +0 -206
- package/coverage/lcov-report/src/.umi/core/plugin.ts.html +0 -109
- package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +0 -160
- package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +0 -97
- package/coverage/lcov-report/src/.umi/core/routes.ts.html +0 -29149
- package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +0 -112
- package/coverage/lcov-report/src/.umi/dumi/index.html +0 -116
- package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +0 -109
- package/coverage/lcov-report/src/.umi/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-antd/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +0 -172
- package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +0 -94
- package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +0 -196
- package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +0 -106
- package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +0 -88
- package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +0 -124
- package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +0 -1246
- package/coverage/lcov-report/src/.umi/plugin-locale/index.html +0 -161
- package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +0 -268
- package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +0 -778
- package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +0 -115
- package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +0 -202
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +0 -97
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +0 -142
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +0 -334
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-model/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +0 -121
- package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +0 -298
- package/coverage/lcov-report/src/.umi/plugin-request/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +0 -919
- package/coverage/lcov-report/src/.umi/umi.ts.html +0 -268
- package/coverage/src/.umi/core/devScripts.ts.html +0 -241
- package/coverage/src/.umi/core/history.ts.html +0 -148
- package/coverage/src/.umi/core/index.html +0 -206
- package/coverage/src/.umi/core/plugin.ts.html +0 -109
- package/coverage/src/.umi/core/pluginRegister.ts.html +0 -160
- package/coverage/src/.umi/core/polyfill.ts.html +0 -97
- package/coverage/src/.umi/core/routes.ts.html +0 -29149
- package/coverage/src/.umi/core/umiExports.ts.html +0 -112
- package/coverage/src/.umi/dumi/index.html +0 -116
- package/coverage/src/.umi/dumi/layout.tsx.html +0 -109
- package/coverage/src/.umi/index.html +0 -116
- package/coverage/src/.umi/plugin-antd/index.html +0 -116
- package/coverage/src/.umi/plugin-antd/runtime.tsx.html +0 -172
- package/coverage/src/.umi/plugin-helmet/exports.ts.html +0 -94
- package/coverage/src/.umi/plugin-helmet/index.html +0 -116
- package/coverage/src/.umi/plugin-initial-state/Provider.tsx.html +0 -196
- package/coverage/src/.umi/plugin-initial-state/exports.ts.html +0 -106
- package/coverage/src/.umi/plugin-initial-state/index.html +0 -146
- package/coverage/src/.umi/plugin-initial-state/models/index.html +0 -116
- package/coverage/src/.umi/plugin-initial-state/models/initialState.ts.html +0 -88
- package/coverage/src/.umi/plugin-initial-state/runtime.tsx.html +0 -124
- package/coverage/src/.umi/plugin-locale/SelectLang.tsx.html +0 -1246
- package/coverage/src/.umi/plugin-locale/index.html +0 -161
- package/coverage/src/.umi/plugin-locale/locale.tsx.html +0 -268
- package/coverage/src/.umi/plugin-locale/localeExports.ts.html +0 -778
- package/coverage/src/.umi/plugin-locale/runtime.tsx.html +0 -115
- package/coverage/src/.umi/plugin-model/Provider.tsx.html +0 -202
- package/coverage/src/.umi/plugin-model/helpers/constant.tsx.html +0 -97
- package/coverage/src/.umi/plugin-model/helpers/dispatcher.tsx.html +0 -142
- package/coverage/src/.umi/plugin-model/helpers/executor.tsx.html +0 -334
- package/coverage/src/.umi/plugin-model/helpers/index.html +0 -146
- package/coverage/src/.umi/plugin-model/index.html +0 -146
- package/coverage/src/.umi/plugin-model/runtime.tsx.html +0 -121
- package/coverage/src/.umi/plugin-model/useModel.tsx.html +0 -298
- package/coverage/src/.umi/plugin-request/index.html +0 -116
- package/coverage/src/.umi/plugin-request/request.ts.html +0 -919
- package/coverage/src/.umi/umi.ts.html +0 -268
- package/test/__mocks__/fileMock.js +0 -0
- package/test/__mocks__/styleMock.js +0 -0
@@ -1,14 +1,25 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
exports.default = void 0;
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
7
9
|
var _ProConfigProvider = require("../../ProConfigProvider");
|
8
10
|
var _utils = require("../utils");
|
9
|
-
var _ref;
|
10
11
|
/* eslint-disable no-redeclare */
|
11
|
-
|
12
|
+
|
13
|
+
var baseEnumStorage = null;
|
14
|
+
try {
|
15
|
+
var storedData = window.localStorage.getItem('zat-design-pro-component-cacheKey');
|
16
|
+
if (storedData) {
|
17
|
+
baseEnumStorage = JSON.parse(storedData);
|
18
|
+
}
|
19
|
+
} catch (error) {
|
20
|
+
console.error('解析枚举缓存数据失败', error);
|
21
|
+
baseEnumStorage = null;
|
22
|
+
}
|
12
23
|
/**
|
13
24
|
* 根据 code 从枚举缓存取出对应的 options 、以及回显
|
14
25
|
* @param codes
|
@@ -17,24 +28,44 @@ var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-compon
|
|
17
28
|
* @returns
|
18
29
|
*/
|
19
30
|
function useEnum(codes, value, compose) {
|
20
|
-
var
|
21
|
-
|
22
|
-
storage =
|
23
|
-
var
|
24
|
-
|
25
|
-
cacheKey =
|
26
|
-
|
27
|
-
fieldNames =
|
28
|
-
|
29
|
-
clear =
|
30
|
-
|
31
|
+
var _ref = (0, _ProConfigProvider.useProConfig)('globalConfig') || {},
|
32
|
+
_ref$storage = _ref.storage,
|
33
|
+
storage = _ref$storage === void 0 ? 'localStorage' : _ref$storage;
|
34
|
+
var _ref2 = (0, _ProConfigProvider.useProConfig)('ProEnum') || {},
|
35
|
+
_ref2$cacheKey = _ref2.cacheKey,
|
36
|
+
cacheKey = _ref2$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref2$cacheKey,
|
37
|
+
_ref2$fieldNames = _ref2.fieldNames,
|
38
|
+
fieldNames = _ref2$fieldNames === void 0 ? {} : _ref2$fieldNames,
|
39
|
+
_ref2$clear = _ref2.clear,
|
40
|
+
clear = _ref2$clear === void 0 ? true : _ref2$clear,
|
41
|
+
_ref2$dataSource = _ref2.dataSource,
|
42
|
+
dataSource = _ref2$dataSource === void 0 ? {} : _ref2$dataSource;
|
43
|
+
var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage, dataSource);
|
31
44
|
// 默认枚举缓存数据
|
32
45
|
baseEnumStorage = catchData;
|
33
46
|
if (!codes) {
|
47
|
+
if (!Object.keys(catchData).length) {
|
48
|
+
return [];
|
49
|
+
}
|
34
50
|
return catchData;
|
35
51
|
}
|
36
52
|
var fieldLabel = '';
|
37
53
|
var fieldValue = '';
|
54
|
+
// 获取枚举数据源
|
55
|
+
var enumDataSource = (catchData === null || catchData === void 0 ? void 0 : catchData.data) || {};
|
56
|
+
// 当dataSource有值时,检查是否需要合并
|
57
|
+
if (dataSource && Object.keys(dataSource).length > 0) {
|
58
|
+
// 创建合并后的数据源
|
59
|
+
var mergedDataSource = (0, _objectSpread2.default)({}, enumDataSource);
|
60
|
+
// 遍历dataSource中的每个键
|
61
|
+
Object.keys(dataSource).forEach(function (key) {
|
62
|
+
// 如果enumDataSource中不存在该键或者该键对应的值为空数组,则合并
|
63
|
+
if (!enumDataSource[key] || enumDataSource[key].length === 0) {
|
64
|
+
mergedDataSource[key] = dataSource[key];
|
65
|
+
}
|
66
|
+
});
|
67
|
+
enumDataSource = mergedDataSource;
|
68
|
+
}
|
38
69
|
if (fieldNames && Object.keys(fieldNames).length) {
|
39
70
|
fieldLabel = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label;
|
40
71
|
fieldValue = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
|
@@ -44,8 +75,8 @@ function useEnum(codes, value, compose) {
|
|
44
75
|
fieldValue = 'value';
|
45
76
|
}
|
46
77
|
if (typeof codes === 'string') {
|
47
|
-
var
|
48
|
-
var options = (
|
78
|
+
var _enumDataSource;
|
79
|
+
var options = ((_enumDataSource = enumDataSource) === null || _enumDataSource === void 0 ? void 0 : _enumDataSource[codes]) || [];
|
49
80
|
var getEnumLabel = function getEnumLabel(v, composezTow) {
|
50
81
|
var option = options.find(function (item) {
|
51
82
|
return item[fieldValue] === v;
|
@@ -68,8 +99,8 @@ function useEnum(codes, value, compose) {
|
|
68
99
|
if (Array.isArray(codes)) {
|
69
100
|
var _options = {};
|
70
101
|
codes.forEach(function (code) {
|
71
|
-
var
|
72
|
-
var values =
|
102
|
+
var _enumDataSource2;
|
103
|
+
var values = (_enumDataSource2 = enumDataSource) === null || _enumDataSource2 === void 0 ? void 0 : _enumDataSource2[code];
|
73
104
|
if (Array.isArray(values) && values.length) {
|
74
105
|
_options[code] = values;
|
75
106
|
}
|
@@ -4,7 +4,14 @@ interface EnumRes {
|
|
4
4
|
data: Record<string, DataOption[]>;
|
5
5
|
[key: string]: any;
|
6
6
|
}
|
7
|
-
|
7
|
+
/**
|
8
|
+
* 获取枚举数据
|
9
|
+
* @param storage
|
10
|
+
* @param cacheKey
|
11
|
+
* @param baseEnumStorage
|
12
|
+
* @returns
|
13
|
+
*/
|
14
|
+
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any, dataSource?: any[]): EnumRes;
|
8
15
|
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
|
9
16
|
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
|
10
17
|
export declare function isObject(obj: any): boolean;
|
@@ -14,8 +14,15 @@ exports.setEnumData = setEnumData;
|
|
14
14
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15
15
|
var _lodash = require("lodash");
|
16
16
|
var _excluded = ["children"];
|
17
|
-
|
18
|
-
|
17
|
+
/**
|
18
|
+
* 获取枚举数据
|
19
|
+
* @param storage
|
20
|
+
* @param cacheKey
|
21
|
+
* @param baseEnumStorage
|
22
|
+
* @returns
|
23
|
+
*/
|
24
|
+
function getEnumData(storage, cacheKey, baseEnumStorage, dataSource) {
|
25
|
+
if (baseEnumStorage && cacheKey === 'zat-design-pro-component-cacheKey') {
|
19
26
|
return baseEnumStorage;
|
20
27
|
}
|
21
28
|
if (storage === 'localStorage') {
|
@@ -0,0 +1,82 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.default = void 0;
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
|
+
var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
13
|
+
var _antd = require("antd");
|
14
|
+
var _react = require("react");
|
15
|
+
var _useEnum3 = _interopRequireDefault(require("../../../ProEnum/hooks/useEnum"));
|
16
|
+
var RenderTabs = function RenderTabs(props) {
|
17
|
+
var code = props.code,
|
18
|
+
_props$dataSource = props.dataSource,
|
19
|
+
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
20
|
+
transformResponse = props.transformResponse,
|
21
|
+
tabsProps = props.tabsProps,
|
22
|
+
name = props.name,
|
23
|
+
formTableProps = props.formTableProps;
|
24
|
+
var _ref = formTableProps || {},
|
25
|
+
form = _ref.form,
|
26
|
+
onSearch = _ref.onSearch;
|
27
|
+
var _useState = (0, _react.useState)(props.activeKey),
|
28
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
29
|
+
activeKey = _useState2[0],
|
30
|
+
setActiveKey = _useState2[1];
|
31
|
+
var _useEnum = (0, _useEnum3.default)(code),
|
32
|
+
_useEnum2 = (0, _slicedToArray2.default)(_useEnum, 1),
|
33
|
+
options = _useEnum2[0];
|
34
|
+
var fieldValue = _antd.Form.useWatch(name, form);
|
35
|
+
// 使用useMemo计算派生状态
|
36
|
+
var tabItems = (0, _react.useMemo)(function () {
|
37
|
+
var defaultItems = [].concat((0, _toConsumableArray2.default)(dataSource), (0, _toConsumableArray2.default)(options || []));
|
38
|
+
// 合并数据源并转换格式
|
39
|
+
var mergedData = defaultItems.map(function (item) {
|
40
|
+
return {
|
41
|
+
key: item.value,
|
42
|
+
label: item.label
|
43
|
+
};
|
44
|
+
});
|
45
|
+
if (transformResponse && typeof transformResponse === 'function') {
|
46
|
+
mergedData = transformResponse(defaultItems, formTableProps);
|
47
|
+
return mergedData.map(function (item) {
|
48
|
+
return {
|
49
|
+
key: String(item.value),
|
50
|
+
label: item.label
|
51
|
+
};
|
52
|
+
});
|
53
|
+
}
|
54
|
+
return mergedData.map(function (item) {
|
55
|
+
return {
|
56
|
+
key: String(item.key),
|
57
|
+
label: item.label
|
58
|
+
};
|
59
|
+
});
|
60
|
+
}, [dataSource, options, transformResponse]);
|
61
|
+
(0, _react.useEffect)(function () {
|
62
|
+
var _tabItems$;
|
63
|
+
setActiveKey(fieldValue || (tabItems === null || tabItems === void 0 ? void 0 : (_tabItems$ = tabItems[0]) === null || _tabItems$ === void 0 ? void 0 : _tabItems$.key));
|
64
|
+
}, [fieldValue]);
|
65
|
+
if (!(tabItems === null || tabItems === void 0 ? void 0 : tabItems.length)) {
|
66
|
+
return null;
|
67
|
+
}
|
68
|
+
return (0, _jsxRuntime.jsx)(_antd.Tabs, (0, _objectSpread3.default)((0, _objectSpread3.default)({
|
69
|
+
className: "pro-table-tabs",
|
70
|
+
onChange: function onChange(key) {
|
71
|
+
var fieldsValues = (form === null || form === void 0 ? void 0 : form.getFieldsValue()) || {};
|
72
|
+
setActiveKey(key);
|
73
|
+
form.setFieldValue(name, key);
|
74
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch((0, _objectSpread3.default)((0, _objectSpread3.default)({}, fieldsValues), {}, (0, _defineProperty2.default)({}, name, key)));
|
75
|
+
},
|
76
|
+
type: "card"
|
77
|
+
}, tabsProps), {}, {
|
78
|
+
items: tabItems,
|
79
|
+
activeKey: activeKey
|
80
|
+
}));
|
81
|
+
};
|
82
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(RenderTabs);
|
@@ -1,5 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* 表格可伸缩列组件
|
3
|
+
* @description 实现表格列宽可调整功能
|
4
|
+
*/
|
1
5
|
export { default as TableResizable } from './TableResizable';
|
6
|
+
/**
|
7
|
+
* 表格空数据渲染组件
|
8
|
+
* @description 当表格数据为空时的显示内容
|
9
|
+
*/
|
2
10
|
export { default as RenderEmptyText } from './RenderEmptyText';
|
11
|
+
/**
|
12
|
+
* 表格汇总行组件
|
13
|
+
* @description 用于渲染表格底部的汇总信息
|
14
|
+
*/
|
3
15
|
export { default as RenderSummary } from './RenderSummary';
|
16
|
+
/**
|
17
|
+
* 表格头部渲染组件
|
18
|
+
* @description 自定义表格头部区域,支持自定义内容和操作按钮
|
19
|
+
*/
|
4
20
|
export { default as RenderTableHeader } from './RenderTableHeader';
|
21
|
+
/**
|
22
|
+
* 表格底部渲染组件
|
23
|
+
* @description 自定义表格底部区域,支持添加额外操作按钮
|
24
|
+
*/
|
5
25
|
export { default as RenderFooter } from './RenderFooter';
|
26
|
+
/**
|
27
|
+
* 表格标签页组件
|
28
|
+
* @description 实现表格顶部的标签页切换功能,用于数据分类展示
|
29
|
+
*/
|
30
|
+
export { default as RenderTabs } from './RenderTabs';
|
@@ -28,6 +28,12 @@ Object.defineProperty(exports, "RenderTableHeader", {
|
|
28
28
|
return _RenderTableHeader.default;
|
29
29
|
}
|
30
30
|
});
|
31
|
+
Object.defineProperty(exports, "RenderTabs", {
|
32
|
+
enumerable: true,
|
33
|
+
get: function get() {
|
34
|
+
return _RenderTabs.default;
|
35
|
+
}
|
36
|
+
});
|
31
37
|
Object.defineProperty(exports, "TableResizable", {
|
32
38
|
enumerable: true,
|
33
39
|
get: function get() {
|
@@ -38,4 +44,5 @@ var _TableResizable = _interopRequireDefault(require("./TableResizable"));
|
|
38
44
|
var _RenderEmptyText = _interopRequireDefault(require("./RenderEmptyText"));
|
39
45
|
var _RenderSummary = _interopRequireDefault(require("./RenderSummary"));
|
40
46
|
var _RenderTableHeader = _interopRequireDefault(require("./RenderTableHeader"));
|
41
|
-
var _RenderFooter = _interopRequireDefault(require("./RenderFooter"));
|
47
|
+
var _RenderFooter = _interopRequireDefault(require("./RenderFooter"));
|
48
|
+
var _RenderTabs = _interopRequireDefault(require("./RenderTabs"));
|
@@ -1,95 +1,4 @@
|
|
1
|
-
import { Key } from 'react';
|
2
1
|
import { useRequest } from 'ahooks';
|
3
2
|
import type { ProTableRequestOptionsType, ProTableServiceType } from '../propsType';
|
4
|
-
declare function useAntdTable<I, R extends Record<string, any>, S extends ProTableServiceType<I, R>>(service: S, options?: ProTableRequestOptionsType<I, R>, useRequestOptions?: Parameters<typeof useRequest>[1]):
|
5
|
-
data: R[];
|
6
|
-
params: any;
|
7
|
-
rowSelection: {
|
8
|
-
fixed: boolean;
|
9
|
-
type: import("antd/es/table/interface").RowSelectionType;
|
10
|
-
columnWidth: number;
|
11
|
-
selectedRowKeys: Key[];
|
12
|
-
onChange(rowKeys: Key[], rows: any[]): void;
|
13
|
-
onSelectAll: (selected: boolean) => void;
|
14
|
-
getCheckboxProps: (record?: any) => {
|
15
|
-
className: string;
|
16
|
-
};
|
17
|
-
selections: boolean | ({
|
18
|
-
key: string;
|
19
|
-
text: string;
|
20
|
-
onSelect: (changeableRowKeys: Key[]) => void;
|
21
|
-
} | {
|
22
|
-
key: string;
|
23
|
-
text: any;
|
24
|
-
onSelect: () => Promise<void>;
|
25
|
-
})[];
|
26
|
-
};
|
27
|
-
searchValues: I;
|
28
|
-
allSelected: boolean;
|
29
|
-
selectedTip: string;
|
30
|
-
selectedRowKeys: Key[];
|
31
|
-
selectedRecords: R[];
|
32
|
-
clearSelected: () => void;
|
33
|
-
setSelectedRowKeys: (selectedRowKeys: Key[]) => void;
|
34
|
-
setSelectedRecords: (selectedRecords: R[]) => void;
|
35
|
-
pagination: {
|
36
|
-
current: number;
|
37
|
-
pageSize: number;
|
38
|
-
showSizeChanger: boolean;
|
39
|
-
showQuickJumper: boolean;
|
40
|
-
onPaginationChange: boolean;
|
41
|
-
total: number;
|
42
|
-
showTotal: (total: any) => string;
|
43
|
-
onShowSizeChange: (current: number, pageSize: number) => void;
|
44
|
-
onChange: (current: number, pageSize: number) => void;
|
45
|
-
};
|
46
|
-
onReset: () => void;
|
47
|
-
onSearch: (values: any) => void;
|
48
|
-
refresh: () => Promise<void>;
|
49
|
-
tableProps: {
|
50
|
-
rowKey: string | import("rc-table/lib/interface").GetRowKey<R>;
|
51
|
-
loading: boolean;
|
52
|
-
dataSource: R[];
|
53
|
-
rowSelection: {
|
54
|
-
fixed: boolean;
|
55
|
-
type: import("antd/es/table/interface").RowSelectionType;
|
56
|
-
columnWidth: number;
|
57
|
-
selectedRowKeys: Key[];
|
58
|
-
onChange(rowKeys: Key[], rows: any[]): void;
|
59
|
-
onSelectAll: (selected: boolean) => void;
|
60
|
-
getCheckboxProps: (record?: any) => {
|
61
|
-
className: string;
|
62
|
-
};
|
63
|
-
selections: boolean | ({
|
64
|
-
key: string;
|
65
|
-
text: string;
|
66
|
-
onSelect: (changeableRowKeys: Key[]) => void;
|
67
|
-
} | {
|
68
|
-
key: string;
|
69
|
-
text: any;
|
70
|
-
onSelect: () => Promise<void>;
|
71
|
-
})[];
|
72
|
-
};
|
73
|
-
pagination: {
|
74
|
-
current: number;
|
75
|
-
pageSize: number;
|
76
|
-
showSizeChanger: boolean;
|
77
|
-
showQuickJumper: boolean;
|
78
|
-
onPaginationChange: boolean;
|
79
|
-
total: number;
|
80
|
-
showTotal: (total: any) => string;
|
81
|
-
onShowSizeChange: (current: number, pageSize: number) => void;
|
82
|
-
onChange: (current: number, pageSize: number) => void;
|
83
|
-
};
|
84
|
-
onChange: (pagination: any, filters: any, sorter: any, extra: any) => void;
|
85
|
-
};
|
86
|
-
handleSetStateCallback: (values: any) => void;
|
87
|
-
loading: boolean;
|
88
|
-
error?: Error;
|
89
|
-
cancel: () => void;
|
90
|
-
refreshAsync: () => Promise<unknown>;
|
91
|
-
run: (...params: any[]) => void;
|
92
|
-
runAsync: (...params: any[]) => Promise<unknown>;
|
93
|
-
mutate: (data?: unknown) => void;
|
94
|
-
};
|
3
|
+
declare function useAntdTable<I, R extends Record<string, any>, S extends ProTableServiceType<I, R>>(service: S, options?: ProTableRequestOptionsType<I, R>, useRequestOptions?: Parameters<typeof useRequest>[1]): any;
|
95
4
|
export default useAntdTable;
|
@@ -482,7 +482,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
482
482
|
onShowSizeChange: handlePageChange,
|
483
483
|
onChange: handlePageChange
|
484
484
|
};
|
485
|
-
|
485
|
+
var useAntdTableProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, result), {}, {
|
486
486
|
data: data,
|
487
487
|
params: params,
|
488
488
|
rowSelection: rowSelection,
|
@@ -516,5 +516,9 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
516
516
|
},
|
517
517
|
handleSetStateCallback: handleSetStateCallback
|
518
518
|
});
|
519
|
+
useAntdTableProps.tableProps.formTableProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(useAntdTableProps, 'tableProps')), {}, {
|
520
|
+
form: form
|
521
|
+
});
|
522
|
+
return useAntdTableProps;
|
519
523
|
}
|
520
524
|
var _default = exports.default = useAntdTable;
|
package/lib/ProTable/index.js
CHANGED
@@ -27,7 +27,7 @@ var _reset = _interopRequireDefault(require("../assets/reset.svg"));
|
|
27
27
|
var _customColumn = _interopRequireDefault(require("../assets/customColumn.svg"));
|
28
28
|
var _utils = require("./utils");
|
29
29
|
var _locale = _interopRequireDefault(require("../locale"));
|
30
|
-
var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "diffConfig", "onDragStart", "onDragEnd"],
|
30
|
+
var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "diffConfig", "onDragStart", "onDragEnd", "tabs"],
|
31
31
|
_excluded2 = ["resizeColumn", "columnConfig", "cacheTime", "storage"];
|
32
32
|
var defaultCacheTime = 1; // columns 配置保存时间为一天
|
33
33
|
// 全局上下文
|
@@ -62,6 +62,7 @@ var ProTable = function ProTable(props) {
|
|
62
62
|
diffConfig = props.diffConfig,
|
63
63
|
onDragStartGuard = props.onDragStart,
|
64
64
|
onDragEndGuard = props.onDragEnd,
|
65
|
+
tabs = props.tabs,
|
65
66
|
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
66
67
|
var _props$scrollFollowPa = props.scrollFollowParent,
|
67
68
|
scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa;
|
@@ -400,7 +401,9 @@ var ProTable = function ProTable(props) {
|
|
400
401
|
},
|
401
402
|
children: (0, _jsxRuntime.jsxs)("div", {
|
402
403
|
className: cls,
|
403
|
-
children: [(0, _jsxRuntime.jsx)(_components.
|
404
|
+
children: [tabs && (0, _jsxRuntime.jsx)(_components.RenderTabs, (0, _objectSpread4.default)((0, _objectSpread4.default)({}, tabs), {}, {
|
405
|
+
formTableProps: restProps === null || restProps === void 0 ? void 0 : restProps.formTableProps
|
406
|
+
})), (0, _jsxRuntime.jsx)(_components.RenderTableHeader, {
|
404
407
|
dataSource: {
|
405
408
|
headerRender: headerRender,
|
406
409
|
columnConfig: columnConfig,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Key, ReactNode } from 'react';
|
2
2
|
import { TableProps } from 'antd/es/table/Table';
|
3
|
+
import { NamePath } from 'antd/es/form/interface';
|
3
4
|
import { ColumnType, GetRowKey, RowSelectionType } from 'antd/es/table/interface';
|
4
5
|
import { FormInstance } from 'antd';
|
5
6
|
import type { TooltipProps } from 'antd';
|
@@ -314,6 +315,54 @@ export interface ProTableDiffConfigType {
|
|
314
315
|
*/
|
315
316
|
addTipColor?: string;
|
316
317
|
}
|
318
|
+
export interface ProTableTabsType {
|
319
|
+
/**
|
320
|
+
* 激活的 key
|
321
|
+
* @description 激活的 key
|
322
|
+
* @default undefined
|
323
|
+
*/
|
324
|
+
activeKey?: string;
|
325
|
+
/**
|
326
|
+
* 枚举 code
|
327
|
+
* @description 枚举 code
|
328
|
+
* @default undefined
|
329
|
+
*/
|
330
|
+
code?: string;
|
331
|
+
/**
|
332
|
+
* 枚举数据源
|
333
|
+
* @description 枚举数据源
|
334
|
+
* @default undefined
|
335
|
+
*/
|
336
|
+
dataSource?: {
|
337
|
+
label: string;
|
338
|
+
value: string;
|
339
|
+
}[];
|
340
|
+
/**
|
341
|
+
* 枚举数据源转换
|
342
|
+
* @description 枚举数据源转换
|
343
|
+
* @default undefined
|
344
|
+
*/
|
345
|
+
transformResponse?: (dataSource: {
|
346
|
+
label: string;
|
347
|
+
value: string;
|
348
|
+
}[], useAntdTableProps: ProTableUseAntdTableType<any, any>) => {
|
349
|
+
key: string;
|
350
|
+
label: string | ReactNode;
|
351
|
+
}[];
|
352
|
+
/**
|
353
|
+
* 标签属性
|
354
|
+
* @description 标签属性
|
355
|
+
* @default undefined
|
356
|
+
*/
|
357
|
+
tabsProps?: TabsProps;
|
358
|
+
/**
|
359
|
+
* 表单字段名
|
360
|
+
* @description 表单字段名
|
361
|
+
* @default undefined
|
362
|
+
*/
|
363
|
+
name: NamePath;
|
364
|
+
[key: string]: any;
|
365
|
+
}
|
317
366
|
/**
|
318
367
|
* ProTable 主要属性
|
319
368
|
*/
|
@@ -321,30 +370,25 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
|
|
321
370
|
/**
|
322
371
|
* table 唯一标识
|
323
372
|
* @description 用于缓存和获取 columns 配置,在开启 resizeColumn/columnConfig 功能时需要传递以保证缓存和获取到正确的 columns 配置
|
324
|
-
* @default
|
373
|
+
* @default -
|
325
374
|
*/
|
326
375
|
tableId?: string;
|
327
376
|
/**
|
328
377
|
* 表格 tabs查询 配置
|
329
378
|
* @description 用于配置表格的 tabs 选项
|
330
|
-
* @default
|
379
|
+
* @default -
|
331
380
|
*/
|
332
|
-
tabs?:
|
333
|
-
code: string;
|
334
|
-
dataSource: any[];
|
335
|
-
transformResponse?: (res: any) => any[];
|
336
|
-
tabsProps?: TabsProps;
|
337
|
-
};
|
381
|
+
tabs?: ProTableTabsType;
|
338
382
|
/**
|
339
383
|
* 表格行 key 的取值
|
340
384
|
* @description 表格行数据的唯一标识字段
|
341
|
-
* @default
|
385
|
+
* @default -
|
342
386
|
*/
|
343
387
|
rowKey?: string | GetRowKey<any>;
|
344
388
|
/**
|
345
389
|
* 自定义 table header 左侧渲染
|
346
390
|
* @description 可以是 ReactNode 或返回 ReactNode 的函数
|
347
|
-
* @default
|
391
|
+
* @default -
|
348
392
|
*/
|
349
393
|
headerRender?: ReactNode | (() => ReactNode);
|
350
394
|
/**
|
@@ -394,7 +438,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
|
|
394
438
|
/**
|
395
439
|
* 自定义 table footer 左侧渲染
|
396
440
|
* @description 可以是 ReactNode 或返回 ReactNode 的函数
|
397
|
-
* @default
|
441
|
+
* @default -
|
398
442
|
*/
|
399
443
|
footerRender?: ReactNode | (() => ReactNode);
|
400
444
|
/**
|
@@ -430,7 +474,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
|
|
430
474
|
/**
|
431
475
|
* 行禁用判断
|
432
476
|
* @description 判断指定行是否禁用
|
433
|
-
* @default
|
477
|
+
* @default -
|
434
478
|
*/
|
435
479
|
rowDisabled?: (record?: T) => string | boolean;
|
436
480
|
/**
|
@@ -448,19 +492,19 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
|
|
448
492
|
/**
|
449
493
|
* 表单比对配置
|
450
494
|
* @description 用于标记数据变化的配置
|
451
|
-
* @default
|
495
|
+
* @default -
|
452
496
|
*/
|
453
497
|
diffConfig?: ProTableDiffConfigType;
|
454
498
|
/**
|
455
499
|
* 开始拖拽回调
|
456
500
|
* @description 拖拽开始时触发
|
457
|
-
* @default
|
501
|
+
* @default -
|
458
502
|
*/
|
459
503
|
onDragStart?: ProTableDragStartGuardType;
|
460
504
|
/**
|
461
505
|
* 结束拖拽回调
|
462
506
|
* @description 拖拽结束时触发,务必返回变更后的数据源
|
463
|
-
* @default
|
507
|
+
* @default -
|
464
508
|
*/
|
465
509
|
onDragEnd?: ProTableDragEndGuardType;
|
466
510
|
/**
|
@@ -469,6 +513,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
|
|
469
513
|
* @default true
|
470
514
|
*/
|
471
515
|
scrollFollowParent?: boolean;
|
516
|
+
[key: string]: any;
|
472
517
|
}
|
473
518
|
/**
|
474
519
|
* ProTable 值类型
|
@@ -702,6 +747,7 @@ export interface ProTableUseAntdTableType<I, R> {
|
|
702
747
|
* @default false
|
703
748
|
*/
|
704
749
|
allSelected: boolean;
|
750
|
+
[key: string]: any;
|
705
751
|
}
|
706
752
|
export type ProTableProps<T = any> = ProTableType<T>;
|
707
753
|
export type ProTableColumn = ProTableColumnType;
|
package/package.json
CHANGED