@hw-component/table 1.1.7 → 1.1.9
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/.eslintcache +1 -1
- package/es/HTableBody/Options/Content.d.ts +1 -1
- package/es/HTableBody/Options/Content.js +11 -25
- package/es/HTableBody/Options/Title.d.ts +1 -1
- package/es/HTableBody/Options/Title.js +25 -32
- package/es/HTableBody/Options/hooks.d.ts +2 -0
- package/es/HTableBody/Options/hooks.js +32 -0
- package/es/HTableBody/Options/index.d.ts +1 -1
- package/es/HTableBody/Options/index.js +31 -43
- package/es/HTableBody/Options/utils.d.ts +2 -7
- package/es/HTableBody/Options/utils.js +2 -57
- package/es/HTableBody/hooks.d.ts +13 -1
- package/es/HTableBody/hooks.js +52 -8
- package/es/HTableBody/index.d.ts +7 -2
- package/es/HTableBody/index.js +20 -6
- package/es/HTableBody/utils.d.ts +7 -0
- package/es/HTableBody/utils.js +99 -0
- package/es/HTableHeader/Context.d.ts +1 -1
- package/es/HTableHeader/defaultSubComponent.js +5 -1
- package/es/HTableHeader/index.d.ts +1 -1
- package/es/hooks/useHTable.js +3 -1
- package/es/modal.d.ts +7 -4
- package/lib/HTableBody/Options/Content.d.ts +1 -1
- package/lib/HTableBody/Options/Content.js +11 -25
- package/lib/HTableBody/Options/Title.d.ts +1 -1
- package/lib/HTableBody/Options/Title.js +25 -32
- package/lib/HTableBody/Options/hooks.d.ts +2 -0
- package/lib/HTableBody/Options/hooks.js +33 -0
- package/lib/HTableBody/Options/index.d.ts +1 -1
- package/lib/HTableBody/Options/index.js +30 -42
- package/lib/HTableBody/Options/utils.d.ts +2 -7
- package/lib/HTableBody/Options/utils.js +1 -57
- package/lib/HTableBody/hooks.d.ts +13 -1
- package/lib/HTableBody/hooks.js +51 -6
- package/lib/HTableBody/index.d.ts +7 -2
- package/lib/HTableBody/index.js +19 -5
- package/lib/HTableBody/utils.d.ts +7 -0
- package/lib/HTableBody/utils.js +101 -0
- package/lib/HTableHeader/Context.d.ts +1 -1
- package/lib/HTableHeader/defaultSubComponent.js +5 -1
- package/lib/HTableHeader/index.d.ts +1 -1
- package/lib/hooks/useHTable.js +3 -1
- package/lib/modal.d.ts +7 -4
- package/package.json +1 -1
- package/src/components/HTableBody/Options/Content.tsx +10 -14
- package/src/components/HTableBody/Options/Title.tsx +21 -20
- package/src/components/HTableBody/Options/hooks.ts +24 -0
- package/src/components/HTableBody/Options/index.tsx +23 -26
- package/src/components/HTableBody/Options/modal.d.ts +10 -2
- package/src/components/HTableBody/Options/utils.ts +1 -54
- package/src/components/HTableBody/hooks.tsx +49 -5
- package/src/components/HTableBody/index.tsx +29 -6
- package/src/components/HTableBody/utils.ts +93 -0
- package/src/components/HTableHeader/Context.tsx +7 -7
- package/src/components/HTableHeader/defaultSubComponent.tsx +7 -3
- package/src/components/HTableHeader/index.tsx +15 -15
- package/src/components/HTableHeader/modal.ts +1 -1
- package/src/components/hooks/useHTable.tsx +5 -3
- package/src/components/modal.ts +7 -10
- package/src/pages/Table/index.tsx +27 -9
- package/src/pages/TableCustomize/index.tsx +16 -2
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
6
|
-
var _keysInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/keys');
|
|
7
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
6
|
var index = require('../../hooks/index.js');
|
|
9
7
|
var antd = require('antd');
|
|
@@ -11,8 +9,7 @@ var icons = require('@ant-design/icons');
|
|
|
11
9
|
var React = require('react');
|
|
12
10
|
var Content = require('./Content.js');
|
|
13
11
|
var Title = require('./Title.js');
|
|
14
|
-
var
|
|
15
|
-
var utils = require('./utils.js');
|
|
12
|
+
var hooks = require('./hooks.js');
|
|
16
13
|
|
|
17
14
|
var Options = (function (_ref) {
|
|
18
15
|
var reload = _ref.reload,
|
|
@@ -22,26 +19,16 @@ var Options = (function (_ref) {
|
|
|
22
19
|
density = _ref$density === void 0 ? true : _ref$density,
|
|
23
20
|
setSizeChange = _ref.setSizeChange,
|
|
24
21
|
columns = _ref.columns,
|
|
25
|
-
onChange = _ref.onChange
|
|
22
|
+
onChange = _ref.onChange,
|
|
23
|
+
colStatusValue = _ref.colStatusValue,
|
|
24
|
+
reset = _ref.reset,
|
|
25
|
+
settingRender = _ref.settingRender;
|
|
26
26
|
var pointer = index.useClassName(["hw-table-pointer", "hw-table-body-option-icon"]);
|
|
27
27
|
var ref = React.useRef(null);
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _useHTableContext = context.useHTableContext(),
|
|
33
|
-
tableInstance = _useHTableContext.tableInstance;
|
|
34
|
-
React.useEffect(function () {
|
|
35
|
-
var _defaultKeys = utils.defaultKeys(columns),
|
|
36
|
-
changeKeys = _keysInstanceProperty(_defaultKeys),
|
|
37
|
-
allKeys = _defaultKeys.allKeys,
|
|
38
|
-
checkCols = _defaultKeys.checkCols;
|
|
39
|
-
tableInstance.table.settingKeys = {
|
|
40
|
-
keys: allKeys,
|
|
41
|
-
checkCols: checkCols
|
|
42
|
-
};
|
|
43
|
-
setKeys(changeKeys);
|
|
44
|
-
}, [columns]);
|
|
28
|
+
var checkKeys = hooks.useCheckKeys({
|
|
29
|
+
columns: columns,
|
|
30
|
+
colStatusValue: colStatusValue
|
|
31
|
+
});
|
|
45
32
|
var SizeItem = function SizeItem() {
|
|
46
33
|
var MenuComponent = antd.Menu;
|
|
47
34
|
var MenuItem = antd.Menu.Item;
|
|
@@ -71,9 +58,8 @@ var Options = (function (_ref) {
|
|
|
71
58
|
};
|
|
72
59
|
return jsxRuntime.jsx(antd.Row, {
|
|
73
60
|
justify: "end",
|
|
74
|
-
ref: ref,
|
|
75
61
|
children: jsxRuntime.jsxs(antd.Space, {
|
|
76
|
-
size:
|
|
62
|
+
size: 15,
|
|
77
63
|
children: [reload && jsxRuntime.jsx(antd.Tooltip, {
|
|
78
64
|
title: "\u5237\u65B0",
|
|
79
65
|
children: jsxRuntime.jsx(icons.ReloadOutlined, {
|
|
@@ -97,24 +83,26 @@ var Options = (function (_ref) {
|
|
|
97
83
|
width: 24
|
|
98
84
|
})
|
|
99
85
|
})
|
|
100
|
-
}), jsxRuntime.jsx(antd.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
86
|
+
}), jsxRuntime.jsx(antd.Popover, {
|
|
87
|
+
content: jsxRuntime.jsx(Content.ColsSettingContent, {
|
|
88
|
+
columns: columns,
|
|
89
|
+
checkKeys: checkKeys,
|
|
90
|
+
onCheck: onChange
|
|
91
|
+
}),
|
|
92
|
+
title: jsxRuntime.jsx(Title.Title, {
|
|
93
|
+
columns: columns,
|
|
94
|
+
reset: reset,
|
|
95
|
+
checkKeys: checkKeys,
|
|
96
|
+
onCheck: onChange
|
|
97
|
+
}),
|
|
98
|
+
placement: "bottomRight",
|
|
99
|
+
getPopupContainer: function getPopupContainer() {
|
|
100
|
+
return ref.current || document.body;
|
|
101
|
+
},
|
|
102
|
+
arrowPointAtCenter: true,
|
|
103
|
+
trigger: "click",
|
|
104
|
+
children: settingRender ? settingRender() : jsxRuntime.jsx(antd.Tooltip, {
|
|
105
|
+
title: "\u5217\u8BBE\u7F6E",
|
|
118
106
|
children: jsxRuntime.jsx(icons.SettingOutlined, {
|
|
119
107
|
className: pointer,
|
|
120
108
|
width: 24
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConfigItemModal } from "../../modal";
|
|
2
2
|
import React from "react";
|
|
3
3
|
export declare const getItemValue: (data: ConfigItemModal) => {
|
|
4
4
|
name?: string | undefined;
|
|
@@ -1124,12 +1124,7 @@ export declare const getItemValue: (data: ConfigItemModal) => {
|
|
|
1124
1124
|
onChange?: ((color: string) => void) | undefined;
|
|
1125
1125
|
colors?: string[] | undefined;
|
|
1126
1126
|
}))) | undefined;
|
|
1127
|
-
childrenDataIndex?:
|
|
1127
|
+
childrenDataIndex?: string[] | ConfigItemModal[] | undefined;
|
|
1128
1128
|
title: any;
|
|
1129
1129
|
dataIndex: ((string | number | (string | number)[]) & import("rc-table/lib/interface").DataIndex) | undefined;
|
|
1130
1130
|
};
|
|
1131
|
-
export declare const defaultKeys: (cols: ConfigDataModal) => {
|
|
1132
|
-
keys: string[];
|
|
1133
|
-
allKeys: string[];
|
|
1134
|
-
checkCols: ConfigDataModal;
|
|
1135
|
-
};
|
|
@@ -4,16 +4,12 @@ var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
|
|
|
4
4
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
|
|
5
5
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
|
|
6
6
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
|
|
7
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
7
8
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
|
|
8
9
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
|
|
9
10
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
|
|
10
|
-
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
11
11
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
12
12
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
13
|
-
require('core-js/modules/es.object.to-string.js');
|
|
14
|
-
require('core-js/modules/es.regexp.to-string.js');
|
|
15
|
-
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
16
|
-
var _keysInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/keys');
|
|
17
13
|
var React = require('react');
|
|
18
14
|
|
|
19
15
|
var _excluded = ["dataIndex", "title", "titleStr"];
|
|
@@ -33,58 +29,6 @@ var getItemValue = function getItemValue(data) {
|
|
|
33
29
|
dataIndex: dataIndex
|
|
34
30
|
}, oData);
|
|
35
31
|
};
|
|
36
|
-
var childDataIndexProvider = function childDataIndexProvider(data, title) {
|
|
37
|
-
var keys = [];
|
|
38
|
-
var cols = [];
|
|
39
|
-
_forEachInstanceProperty(data).call(data, function (value) {
|
|
40
|
-
if (typeof value === "string") {
|
|
41
|
-
keys.push(value);
|
|
42
|
-
cols.push(getItemValue({
|
|
43
|
-
title: title,
|
|
44
|
-
dataIndex: value
|
|
45
|
-
}));
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
keys.push(value.dataIndex);
|
|
49
|
-
cols.push(getItemValue(value));
|
|
50
|
-
});
|
|
51
|
-
return {
|
|
52
|
-
keys: keys,
|
|
53
|
-
cols: cols
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
var defaultKeys = function defaultKeys(cols) {
|
|
57
|
-
var keys = [];
|
|
58
|
-
var allKeys = [];
|
|
59
|
-
var checkCols = [];
|
|
60
|
-
_forEachInstanceProperty(cols).call(cols, function (value) {
|
|
61
|
-
var title = value.title,
|
|
62
|
-
titleStr = value.titleStr,
|
|
63
|
-
dataIndex = value.dataIndex,
|
|
64
|
-
hideInTable = value.hideInTable,
|
|
65
|
-
childrenDataIndex = value.childrenDataIndex;
|
|
66
|
-
if (hideInTable || !dataIndex) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
keys.push(dataIndex.toString());
|
|
70
|
-
if (childrenDataIndex) {
|
|
71
|
-
var _childDataIndexProvid = childDataIndexProvider(childrenDataIndex, titleStr || title),
|
|
72
|
-
childKeys = _keysInstanceProperty(_childDataIndexProvid),
|
|
73
|
-
childCols = _childDataIndexProvid.cols;
|
|
74
|
-
allKeys.push.apply(allKeys, _toConsumableArray(childKeys));
|
|
75
|
-
checkCols.push.apply(checkCols, _toConsumableArray(childCols));
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
allKeys.push(dataIndex.toString());
|
|
79
|
-
checkCols.push(getItemValue(value));
|
|
80
|
-
});
|
|
81
|
-
return {
|
|
82
|
-
keys: keys,
|
|
83
|
-
allKeys: allKeys,
|
|
84
|
-
checkCols: checkCols
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
32
|
|
|
88
|
-
exports.defaultKeys = defaultKeys;
|
|
89
33
|
exports.getItemValue = getItemValue;
|
|
90
34
|
// powered by h
|
|
@@ -2,9 +2,10 @@ import type { HTableProps, ConfigDataModal } from "../modal";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { GetRowKey } from "rc-table/lib/interface";
|
|
4
4
|
import type { SizeType } from "antd/lib/config-provider/SizeContext";
|
|
5
|
+
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
6
|
+
import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
5
7
|
export declare const useCols: ({ configData, rowSelection, table }: HTableProps) => {
|
|
6
8
|
cols: ConfigDataModal;
|
|
7
|
-
changeCols: (cuCols: ConfigDataModal) => void;
|
|
8
9
|
};
|
|
9
10
|
interface FilterKeysModal {
|
|
10
11
|
selectedRowKeys?: React.Key[];
|
|
@@ -16,4 +17,15 @@ export declare const useSize: (size: SizeType) => {
|
|
|
16
17
|
cuSize: "small" | "middle" | "large" | undefined;
|
|
17
18
|
setCuSize: React.Dispatch<React.SetStateAction<"small" | "middle" | "large" | undefined>>;
|
|
18
19
|
};
|
|
20
|
+
interface useColumnsStateTypeModal {
|
|
21
|
+
columnsState?: ColumnsStateType;
|
|
22
|
+
columns: ConfigDataModal;
|
|
23
|
+
}
|
|
24
|
+
export declare const useColumnsStateType: ({ columnsState, columns, }: useColumnsStateTypeModal) => {
|
|
25
|
+
persistenceType: "localStorage" | "sessionStorage" | undefined;
|
|
26
|
+
persistenceKey: string | undefined;
|
|
27
|
+
value: Record<string, ColumnsState> | undefined;
|
|
28
|
+
onChange: (keys: string[], notCheck: string[]) => void;
|
|
29
|
+
reset: () => void;
|
|
30
|
+
};
|
|
19
31
|
export {};
|
package/lib/HTableBody/hooks.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
|
|
4
4
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
|
|
5
5
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
|
|
6
|
-
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
7
6
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
|
|
8
7
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
|
|
9
8
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
|
|
@@ -13,10 +12,12 @@ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/f
|
|
|
13
12
|
var _spliceInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/splice');
|
|
14
13
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
15
14
|
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/index-of');
|
|
15
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
16
16
|
var jsxRuntime = require('react/jsx-runtime');
|
|
17
17
|
var React = require('react');
|
|
18
18
|
var context = require('../context.js');
|
|
19
19
|
var RowSelection = require('./RowSelection.js');
|
|
20
|
+
var utils = require('./utils.js');
|
|
20
21
|
|
|
21
22
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -73,12 +74,8 @@ var useCols = function useCols(_ref2) {
|
|
|
73
74
|
React.useEffect(function () {
|
|
74
75
|
setCols(changeConfigData(configData));
|
|
75
76
|
}, [configData, table, rowSelection]);
|
|
76
|
-
var changeCols = function changeCols(cuCols) {
|
|
77
|
-
setCols(cuCols);
|
|
78
|
-
};
|
|
79
77
|
return {
|
|
80
|
-
cols: cols
|
|
81
|
-
changeCols: changeCols
|
|
78
|
+
cols: cols
|
|
82
79
|
};
|
|
83
80
|
};
|
|
84
81
|
var useSynchronousKeys = function useSynchronousKeys(_ref3) {
|
|
@@ -110,8 +107,56 @@ var useSize = function useSize(size) {
|
|
|
110
107
|
setCuSize: setCuSize
|
|
111
108
|
};
|
|
112
109
|
};
|
|
110
|
+
var useColumnsStateType = function useColumnsStateType(_ref4) {
|
|
111
|
+
var columnsState = _ref4.columnsState,
|
|
112
|
+
columns = _ref4.columns;
|
|
113
|
+
var _useHTableContext2 = context.useHTableContext(),
|
|
114
|
+
tableInstance = _useHTableContext2.tableInstance;
|
|
115
|
+
var _ref5 = columnsState || {},
|
|
116
|
+
persistenceType = _ref5.persistenceType,
|
|
117
|
+
persistenceKey = _ref5.persistenceKey,
|
|
118
|
+
value = _ref5.value,
|
|
119
|
+
defaultValue = _ref5.defaultValue,
|
|
120
|
+
onChange = _ref5.onChange;
|
|
121
|
+
var _useState5 = React.useState(defaultValue),
|
|
122
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
123
|
+
selfValue = _useState6[0],
|
|
124
|
+
setSelfValue = _useState6[1];
|
|
125
|
+
var initTableColsVal = React.useMemo(function () {
|
|
126
|
+
return selfValue;
|
|
127
|
+
}, []);
|
|
128
|
+
React.useEffect(function () {
|
|
129
|
+
tableInstance.table.getColSettingKeys = function () {
|
|
130
|
+
return utils.outColSetting(columns, selfValue);
|
|
131
|
+
};
|
|
132
|
+
}, [selfValue]);
|
|
133
|
+
React.useEffect(function () {
|
|
134
|
+
setSelfValue(utils.mkChangeValue(columnsState));
|
|
135
|
+
}, [value]);
|
|
136
|
+
var change = function change(keys, notCheck) {
|
|
137
|
+
var newObj = {};
|
|
138
|
+
_forEachInstanceProperty(notCheck).call(notCheck, function (key) {
|
|
139
|
+
newObj[key] = {
|
|
140
|
+
show: false
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
setSelfValue(newObj);
|
|
144
|
+
onChange === null || onChange === void 0 || onChange(newObj);
|
|
145
|
+
};
|
|
146
|
+
var reset = function reset() {
|
|
147
|
+
setSelfValue(initTableColsVal);
|
|
148
|
+
};
|
|
149
|
+
return {
|
|
150
|
+
persistenceType: persistenceType,
|
|
151
|
+
persistenceKey: persistenceKey,
|
|
152
|
+
value: selfValue,
|
|
153
|
+
onChange: change,
|
|
154
|
+
reset: reset
|
|
155
|
+
};
|
|
156
|
+
};
|
|
113
157
|
|
|
114
158
|
exports.useCols = useCols;
|
|
159
|
+
exports.useColumnsStateType = useColumnsStateType;
|
|
115
160
|
exports.useSize = useSize;
|
|
116
161
|
exports.useSynchronousKeys = useSynchronousKeys;
|
|
117
162
|
// powered by h
|
|
@@ -2,7 +2,11 @@ import type { ProTableProps } from "@ant-design/pro-table";
|
|
|
2
2
|
import type { ActionRenderFn, ConfigDataModal, ParamsModal, HTableInstance, HRowSelection } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import type { AffixProps } from "antd/lib/affix";
|
|
5
|
-
|
|
5
|
+
import { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
6
|
+
export interface OptionModal extends OptionConfig {
|
|
7
|
+
settingRender?: () => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection" | "options"> {
|
|
6
10
|
configData?: ConfigDataModal;
|
|
7
11
|
onPageChange?: (params: ParamsModal) => void;
|
|
8
12
|
emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
@@ -16,6 +20,7 @@ export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSour
|
|
|
16
20
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
17
21
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
18
22
|
localSorter?: boolean;
|
|
23
|
+
options?: OptionModal | false;
|
|
19
24
|
}
|
|
20
|
-
declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, size, optionsRender, paginationActionRender, localSorter, ...props }: HTableBodyProps) => JSX.Element;
|
|
25
|
+
declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, size, optionsRender, paginationActionRender, localSorter, columnsState, ...props }: HTableBodyProps) => JSX.Element;
|
|
21
26
|
export default _default;
|
package/lib/HTableBody/index.js
CHANGED
|
@@ -25,7 +25,8 @@ var AlertMsg = require('./AlertMsg.js');
|
|
|
25
25
|
var index = require('./Options/index.js');
|
|
26
26
|
var index$2 = require('./HeaderTitle/index.js');
|
|
27
27
|
|
|
28
|
-
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender", "paginationActionRender", "localSorter"]
|
|
28
|
+
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender", "paginationActionRender", "localSorter", "columnsState"],
|
|
29
|
+
_excluded2 = ["value", "onChange", "reset"];
|
|
29
30
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
31
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
32
|
var defaultRender = function defaultRender() {
|
|
@@ -61,6 +62,7 @@ var Body = (function (_ref) {
|
|
|
61
62
|
optionsRender = _ref.optionsRender,
|
|
62
63
|
paginationActionRender = _ref.paginationActionRender,
|
|
63
64
|
localSorter = _ref.localSorter,
|
|
65
|
+
columnsState = _ref.columnsState,
|
|
64
66
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
65
67
|
var _ref2 = rowSelection || {},
|
|
66
68
|
selectedRowKeys = _ref2.selectedRowKeys,
|
|
@@ -93,8 +95,15 @@ var Body = (function (_ref) {
|
|
|
93
95
|
table: tableInstance,
|
|
94
96
|
rowSelection: rowSelection
|
|
95
97
|
}),
|
|
96
|
-
cols = _useCols.cols
|
|
97
|
-
|
|
98
|
+
cols = _useCols.cols;
|
|
99
|
+
var _useColumnsStateType = hooks.useColumnsStateType({
|
|
100
|
+
columnsState: columnsState,
|
|
101
|
+
columns: cols
|
|
102
|
+
}),
|
|
103
|
+
value = _useColumnsStateType.value,
|
|
104
|
+
onChange = _useColumnsStateType.onChange,
|
|
105
|
+
reset = _useColumnsStateType.reset,
|
|
106
|
+
selfColStatus = _objectWithoutProperties(_useColumnsStateType, _excluded2);
|
|
98
107
|
hooks.useSynchronousKeys({
|
|
99
108
|
selectedRowKeys: selectedRowKeys,
|
|
100
109
|
records: records,
|
|
@@ -108,7 +117,9 @@ var Body = (function (_ref) {
|
|
|
108
117
|
size: cuSize,
|
|
109
118
|
columns: cols,
|
|
110
119
|
setSizeChange: setCuSize,
|
|
111
|
-
|
|
120
|
+
colStatusValue: value || {},
|
|
121
|
+
onChange: onChange,
|
|
122
|
+
reset: reset
|
|
112
123
|
}));
|
|
113
124
|
var _selectedRowData$keys = _keysInstanceProperty(selectedRowData),
|
|
114
125
|
keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys,
|
|
@@ -139,6 +150,9 @@ var Body = (function (_ref) {
|
|
|
139
150
|
return tableEmptyRender === null || tableEmptyRender === void 0 ? void 0 : tableEmptyRender(tableInstance);
|
|
140
151
|
},
|
|
141
152
|
children: [jsxRuntime.jsx(ProTable, _objectSpread(_objectSpread({}, props), {}, {
|
|
153
|
+
columnsState: _objectSpread(_objectSpread({}, selfColStatus), {}, {
|
|
154
|
+
value: value
|
|
155
|
+
}),
|
|
142
156
|
columns: cols,
|
|
143
157
|
size: cuSize,
|
|
144
158
|
search: false,
|
|
@@ -156,10 +170,10 @@ var Body = (function (_ref) {
|
|
|
156
170
|
asc: asc
|
|
157
171
|
});
|
|
158
172
|
},
|
|
159
|
-
options: false,
|
|
160
173
|
tableStyle: {
|
|
161
174
|
paddingBottom: 0
|
|
162
175
|
},
|
|
176
|
+
options: false,
|
|
163
177
|
rowSelection: false,
|
|
164
178
|
loading: loading,
|
|
165
179
|
rowKey: rowKey,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
2
|
+
import type { ConfigDataModal } from "@/components/modal";
|
|
3
|
+
export declare const mkChangeValue: (columnsState?: ColumnsStateType) => any;
|
|
4
|
+
export declare const outColSetting: (columns: ConfigDataModal, columnsState?: ColumnsStateType) => {
|
|
5
|
+
checkCols: ConfigDataModal;
|
|
6
|
+
keys: string[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
4
|
+
var _typeof = require('@babel/runtime-corejs3/helpers/typeof');
|
|
5
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
6
|
+
var _keysInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/keys');
|
|
7
|
+
require('core-js/modules/es.object.keys.js');
|
|
8
|
+
require('core-js/modules/es.object.to-string.js');
|
|
9
|
+
require('core-js/modules/es.regexp.to-string.js');
|
|
10
|
+
var utils = require('./Options/utils.js');
|
|
11
|
+
|
|
12
|
+
var strToJson = function strToJson(str) {
|
|
13
|
+
if (!str) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
var result = JSON.parse(str);
|
|
18
|
+
if (_typeof(result) === "object") {
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
return {};
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var mkChangeValue = function mkChangeValue(columnsState) {
|
|
27
|
+
var _ref = columnsState || {},
|
|
28
|
+
persistenceType = _ref.persistenceType,
|
|
29
|
+
persistenceKey = _ref.persistenceKey,
|
|
30
|
+
value = _ref.value;
|
|
31
|
+
_ref.defaultValue;
|
|
32
|
+
_ref.onChange;
|
|
33
|
+
if (value) {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
if (!persistenceKey) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
var cuPersistenceType = persistenceType || "localStorage";
|
|
40
|
+
var saveValStr = window[cuPersistenceType].getItem(persistenceKey);
|
|
41
|
+
return strToJson(saveValStr);
|
|
42
|
+
};
|
|
43
|
+
var childDataIndexProvider = function childDataIndexProvider(data, title) {
|
|
44
|
+
var keys = [];
|
|
45
|
+
var cols = [];
|
|
46
|
+
_forEachInstanceProperty(data).call(data, function (value) {
|
|
47
|
+
if (typeof value === "string") {
|
|
48
|
+
keys.push(value);
|
|
49
|
+
cols.push(utils.getItemValue({
|
|
50
|
+
title: title,
|
|
51
|
+
dataIndex: value
|
|
52
|
+
}));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
keys.push(value.dataIndex);
|
|
56
|
+
cols.push(utils.getItemValue(value));
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
keys: keys,
|
|
60
|
+
cols: cols
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var outColSetting = function outColSetting(columns) {
|
|
64
|
+
var columnsState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
65
|
+
var keys = [];
|
|
66
|
+
var checkCols = [];
|
|
67
|
+
_forEachInstanceProperty(columns).call(columns, function (value) {
|
|
68
|
+
var dataIndex = value.dataIndex,
|
|
69
|
+
titleStr = value.titleStr,
|
|
70
|
+
title = value.title,
|
|
71
|
+
hideInTable = value.hideInTable,
|
|
72
|
+
childrenDataIndex = value.childrenDataIndex;
|
|
73
|
+
if (hideInTable || !dataIndex) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
var _ref2 = columnsState[dataIndex.toString()] || {},
|
|
77
|
+
_ref2$show = _ref2.show,
|
|
78
|
+
show = _ref2$show === void 0 ? true : _ref2$show;
|
|
79
|
+
if (!show) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (childrenDataIndex) {
|
|
83
|
+
var _childDataIndexProvid = childDataIndexProvider(childrenDataIndex, titleStr || title),
|
|
84
|
+
childKeys = _keysInstanceProperty(_childDataIndexProvid),
|
|
85
|
+
childCols = _childDataIndexProvid.cols;
|
|
86
|
+
keys.push.apply(keys, _toConsumableArray(childKeys));
|
|
87
|
+
checkCols.push.apply(checkCols, _toConsumableArray(childCols));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
keys.push(dataIndex.toString());
|
|
91
|
+
checkCols.push(utils.getItemValue(value));
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
checkCols: checkCols,
|
|
95
|
+
keys: keys
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.mkChangeValue = mkChangeValue;
|
|
100
|
+
exports.outColSetting = outColSetting;
|
|
101
|
+
// powered by h
|
|
@@ -82,7 +82,11 @@ var DefaultSubComponent = function DefaultSubComponent(_ref) {
|
|
|
82
82
|
borderRadius: 4
|
|
83
83
|
},
|
|
84
84
|
onClick: function onClick() {
|
|
85
|
-
|
|
85
|
+
if (onReset) {
|
|
86
|
+
onReset();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
form.resetFields();
|
|
86
90
|
},
|
|
87
91
|
children: "\u91CD\u7F6E"
|
|
88
92
|
}), hide ? null : jsxRuntime.jsx(OpenComponent, {})]
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IHeaderProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, onFinish, searchSpan, headerStyle, initValues, hideLabel, labelWidth, onReset }: IHeaderProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, onFinish, searchSpan, headerStyle, initValues, hideLabel, labelWidth, onReset, }: IHeaderProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/lib/hooks/useHTable.js
CHANGED
|
@@ -21,12 +21,14 @@ var useHTable = (function () {
|
|
|
21
21
|
getParams: function getParams() {
|
|
22
22
|
return {};
|
|
23
23
|
},
|
|
24
|
-
settingKeys: {},
|
|
25
24
|
getSelectedRowData: function getSelectedRowData() {
|
|
26
25
|
return {};
|
|
27
26
|
},
|
|
28
27
|
getTableSourceData: function getTableSourceData() {
|
|
29
28
|
return [];
|
|
29
|
+
},
|
|
30
|
+
getColSettingKeys: function getColSettingKeys() {
|
|
31
|
+
return {};
|
|
30
32
|
}
|
|
31
33
|
};
|
|
32
34
|
}, []);
|
package/lib/modal.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type React from "react";
|
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
7
|
import type { TableProps } from "antd/lib/table";
|
|
8
8
|
import type { AffixProps } from "antd/lib/affix";
|
|
9
|
+
import { OptionModal } from "./HTableBody";
|
|
9
10
|
export interface RowObj {
|
|
10
11
|
keys?: React.Key[];
|
|
11
12
|
rowData?: any[];
|
|
@@ -75,6 +76,11 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
75
76
|
formInitValues?: Record<string, any>;
|
|
76
77
|
labelWidth?: number;
|
|
77
78
|
hideLabel?: boolean;
|
|
79
|
+
options?: OptionModal | false;
|
|
80
|
+
}
|
|
81
|
+
interface ColCheckResultKeys {
|
|
82
|
+
keys?: string[];
|
|
83
|
+
checkCols?: ConfigDataModal;
|
|
78
84
|
}
|
|
79
85
|
export interface TableInstance {
|
|
80
86
|
reload: (params?: ParamsModal) => Promise<any>;
|
|
@@ -82,12 +88,9 @@ export interface TableInstance {
|
|
|
82
88
|
dispatch: (key: string, params: any) => void;
|
|
83
89
|
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
84
90
|
getParams: () => any;
|
|
85
|
-
settingKeys: {
|
|
86
|
-
keys?: string[];
|
|
87
|
-
checkCols?: ConfigDataModal;
|
|
88
|
-
};
|
|
89
91
|
getSelectedRowData: () => RowObj;
|
|
90
92
|
getTableSourceData: () => any;
|
|
93
|
+
getColSettingKeys: () => ColCheckResultKeys;
|
|
91
94
|
}
|
|
92
95
|
export interface HTableInstance {
|
|
93
96
|
form: HFormInstance;
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { getItemValue } from "./utils";
|
|
|
7
7
|
|
|
8
8
|
export const ColsSettingContent = ({
|
|
9
9
|
columns,
|
|
10
|
-
|
|
10
|
+
onCheck,
|
|
11
11
|
checkKeys,
|
|
12
12
|
}: ItemProps) => {
|
|
13
13
|
const content = useClassName("hw-table-body-option-setting-content");
|
|
@@ -29,20 +29,16 @@ export const ColsSettingContent = ({
|
|
|
29
29
|
});
|
|
30
30
|
return treeData;
|
|
31
31
|
}, [columns]);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const check = (keys: string[]) => {
|
|
33
|
+
const notCheck: string[] = [];
|
|
34
|
+
contentTreeData.forEach(({ key }) => {
|
|
35
|
+
const cuKey = key as string;
|
|
36
|
+
const index = keys.indexOf(cuKey);
|
|
37
|
+
if (index === -1) {
|
|
38
|
+
notCheck.push(cuKey);
|
|
37
39
|
}
|
|
38
|
-
const strDataIndex = dataIndex.toString();
|
|
39
|
-
const item = newCols[index];
|
|
40
|
-
newCols[index] = {
|
|
41
|
-
...item,
|
|
42
|
-
hideInTable: key.indexOf(strDataIndex) == -1,
|
|
43
|
-
};
|
|
44
40
|
});
|
|
45
|
-
|
|
41
|
+
onCheck(keys, notCheck);
|
|
46
42
|
};
|
|
47
43
|
return (
|
|
48
44
|
<div className={content}>
|
|
@@ -52,7 +48,7 @@ export const ColsSettingContent = ({
|
|
|
52
48
|
className={treeClass}
|
|
53
49
|
checkedKeys={checkKeys}
|
|
54
50
|
onCheck={(key) => {
|
|
55
|
-
|
|
51
|
+
check(key as string[]);
|
|
56
52
|
}}
|
|
57
53
|
height={268}
|
|
58
54
|
treeData={contentTreeData}
|