@hw-component/table 1.9.95 → 1.9.97
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/EditTable/hooks.d.ts +1549 -1
- package/es/EditTable/hooks.js +56 -33
- package/es/EditTable/index.js +5 -2
- package/es/render/Text.d.ts +1 -0
- package/lib/EditTable/hooks.d.ts +1549 -1
- package/lib/EditTable/hooks.js +56 -32
- package/lib/EditTable/index.js +4 -1
- package/lib/render/Text.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/EditTable/hooks.ts +26 -2
- package/src/components/EditTable/index.tsx +3 -2
- package/src/pages/EditTable/index.tsx +2 -1
- package/src/pages/ModalEditTable/index.tsx +2 -3
package/lib/EditTable/hooks.js
CHANGED
|
@@ -12,8 +12,10 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
12
12
|
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
13
13
|
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
14
14
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
15
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
15
16
|
var ahooks = require('ahooks');
|
|
16
17
|
var React = require('react');
|
|
18
|
+
var config = require('../render/config.js');
|
|
17
19
|
|
|
18
20
|
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; }
|
|
19
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -22,40 +24,41 @@ var useListRequest = function useListRequest(_ref) {
|
|
|
22
24
|
dataSource = _ref.dataSource;
|
|
23
25
|
var saveParams = React.useMemo(function () {
|
|
24
26
|
return {
|
|
25
|
-
params: {
|
|
27
|
+
params: {
|
|
28
|
+
current: 1,
|
|
29
|
+
pageSize: 10
|
|
30
|
+
}
|
|
26
31
|
};
|
|
27
32
|
}, []);
|
|
28
|
-
return ahooks.useRequest( /*#__PURE__*/function () {
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
}(), {
|
|
33
|
+
return ahooks.useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
34
|
+
var params,
|
|
35
|
+
newParams,
|
|
36
|
+
_args = arguments;
|
|
37
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
38
|
+
while (1) switch (_context.prev = _context.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
41
|
+
newParams = _objectSpread(_objectSpread({}, saveParams.params), params);
|
|
42
|
+
saveParams.params = newParams;
|
|
43
|
+
if (!request) {
|
|
44
|
+
_context.next = 5;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
return _context.abrupt("return", request(newParams));
|
|
48
|
+
case 5:
|
|
49
|
+
if (!_Array$isArray(dataSource)) {
|
|
50
|
+
_context.next = 7;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return _context.abrupt("return", dataSource);
|
|
54
|
+
case 7:
|
|
55
|
+
return _context.abrupt("return", dataSource);
|
|
56
|
+
case 8:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}, _callee);
|
|
61
|
+
})), {
|
|
59
62
|
manual: true,
|
|
60
63
|
refreshDeps: [dataSource]
|
|
61
64
|
});
|
|
@@ -72,7 +75,28 @@ var useCuRef = function useCuRef(_ref3) {
|
|
|
72
75
|
cuEditableFormRef: cuEditableFormRef
|
|
73
76
|
};
|
|
74
77
|
};
|
|
78
|
+
var useColsMk = function useColsMk(_ref4) {
|
|
79
|
+
var configData = _ref4.configData;
|
|
80
|
+
return configData === null || configData === void 0 ? void 0 : _mapInstanceProperty(configData).call(configData, function (item) {
|
|
81
|
+
var valueType = item.valueType,
|
|
82
|
+
_render = item.render;
|
|
83
|
+
var configType = valueType;
|
|
84
|
+
if (!config.default[configType]) {
|
|
85
|
+
return item;
|
|
86
|
+
}
|
|
87
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
88
|
+
render: function render(dom, entity, index, action, schema) {
|
|
89
|
+
var node = config.default[configType](item, entity, index);
|
|
90
|
+
if (_render) {
|
|
91
|
+
return _render(node, entity, index, action, schema);
|
|
92
|
+
}
|
|
93
|
+
return node;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
75
98
|
|
|
99
|
+
exports.useColsMk = useColsMk;
|
|
76
100
|
exports.useCuRef = useCuRef;
|
|
77
101
|
exports.useListRequest = useListRequest;
|
|
78
102
|
// powered by h
|
package/lib/EditTable/index.js
CHANGED
|
@@ -75,6 +75,9 @@ var EditTable = (function (_ref) {
|
|
|
75
75
|
}),
|
|
76
76
|
cuActionRef = _useCuRef.cuActionRef,
|
|
77
77
|
cuEditableFormRef = _useCuRef.cuEditableFormRef;
|
|
78
|
+
var columns = hooks.useColsMk({
|
|
79
|
+
configData: configData
|
|
80
|
+
});
|
|
78
81
|
return jsxRuntime.jsxs("div", {
|
|
79
82
|
className: tableBody,
|
|
80
83
|
children: [jsxRuntime.jsx(antd.ConfigProvider, {
|
|
@@ -88,7 +91,7 @@ var EditTable = (function (_ref) {
|
|
|
88
91
|
return tableEmptyRender === null || tableEmptyRender === void 0 ? void 0 : tableEmptyRender();
|
|
89
92
|
},
|
|
90
93
|
children: jsxRuntime.jsx(ProTable.EditableProTable, _objectSpread({
|
|
91
|
-
columns:
|
|
94
|
+
columns: columns,
|
|
92
95
|
loading: loading,
|
|
93
96
|
rowKey: rowKey,
|
|
94
97
|
editableFormRef: cuEditableFormRef,
|
package/lib/render/Text.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -3,15 +3,19 @@ import { EditTableProps } from "./modal";
|
|
|
3
3
|
import { MutableRefObject, useMemo, useRef } from "react";
|
|
4
4
|
import type { ActionType } from "@ant-design/pro-table";
|
|
5
5
|
import { EditableFormInstance } from "@ant-design/pro-table/lib/components/EditableTable";
|
|
6
|
+
import config from "../render/config";
|
|
6
7
|
|
|
7
8
|
export const useListRequest = ({ request, dataSource }: EditTableProps) => {
|
|
8
9
|
const saveParams = useMemo(() => {
|
|
9
10
|
return {
|
|
10
|
-
params: {
|
|
11
|
+
params: {
|
|
12
|
+
current: 1,
|
|
13
|
+
pageSize: 10,
|
|
14
|
+
},
|
|
11
15
|
};
|
|
12
16
|
}, []);
|
|
13
17
|
return useRequest(
|
|
14
|
-
async (params) => {
|
|
18
|
+
async (params = {}) => {
|
|
15
19
|
const newParams = {
|
|
16
20
|
...saveParams.params,
|
|
17
21
|
...params,
|
|
@@ -41,3 +45,23 @@ export const useCuRef = ({ actionRef, editableFormRef }: EditTableProps) => {
|
|
|
41
45
|
cuEditableFormRef,
|
|
42
46
|
};
|
|
43
47
|
};
|
|
48
|
+
|
|
49
|
+
export const useColsMk = ({ configData }: EditTableProps) => {
|
|
50
|
+
return configData?.map((item) => {
|
|
51
|
+
const { valueType, render } = item;
|
|
52
|
+
const configType = valueType as string;
|
|
53
|
+
if (!config[configType]) {
|
|
54
|
+
return item;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
...item,
|
|
58
|
+
render: (dom, entity, index, action, schema) => {
|
|
59
|
+
const node = config[configType](item, entity, index);
|
|
60
|
+
if (render) {
|
|
61
|
+
return render(node, entity, index, action, schema);
|
|
62
|
+
}
|
|
63
|
+
return node;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
errorDefaultRender,
|
|
9
9
|
} from "@/components/HTableBody/defaultRender";
|
|
10
10
|
import { useHTableConfigContext } from "@/components/TableConfig";
|
|
11
|
-
import { useCuRef, useListRequest } from "./hooks";
|
|
11
|
+
import { useColsMk, useCuRef, useListRequest } from "./hooks";
|
|
12
12
|
import React from "react";
|
|
13
13
|
|
|
14
14
|
export default ({
|
|
@@ -46,6 +46,7 @@ export default ({
|
|
|
46
46
|
actionRef,
|
|
47
47
|
editableFormRef,
|
|
48
48
|
});
|
|
49
|
+
const columns = useColsMk({ configData });
|
|
49
50
|
|
|
50
51
|
return (
|
|
51
52
|
<div className={tableBody}>
|
|
@@ -61,7 +62,7 @@ export default ({
|
|
|
61
62
|
}}
|
|
62
63
|
>
|
|
63
64
|
<EditableProTable
|
|
64
|
-
columns={
|
|
65
|
+
columns={columns}
|
|
65
66
|
loading={loading}
|
|
66
67
|
rowKey={rowKey}
|
|
67
68
|
editableFormRef={cuEditableFormRef}
|
|
@@ -6,6 +6,7 @@ const dataSource = [
|
|
|
6
6
|
{
|
|
7
7
|
id: 1,
|
|
8
8
|
title: "1",
|
|
9
|
+
time: "1757574280",
|
|
9
10
|
},
|
|
10
11
|
{
|
|
11
12
|
id: 2,
|
|
@@ -46,7 +47,7 @@ export default () => {
|
|
|
46
47
|
dataSource={cuData}
|
|
47
48
|
configData={[
|
|
48
49
|
{ title: "标题", dataIndex: "title" },
|
|
49
|
-
{ title: "标题2", dataIndex: "
|
|
50
|
+
{ title: "标题2", dataIndex: "time", valueType: "date" },
|
|
50
51
|
{
|
|
51
52
|
title: "操作",
|
|
52
53
|
valueType: "option",
|
|
@@ -5,6 +5,7 @@ const dataSource = [
|
|
|
5
5
|
{
|
|
6
6
|
id: 1,
|
|
7
7
|
title: "1",
|
|
8
|
+
time: "1757574280",
|
|
8
9
|
},
|
|
9
10
|
{
|
|
10
11
|
id: 2,
|
|
@@ -42,7 +43,6 @@ export default () => {
|
|
|
42
43
|
dataSource={cuData}
|
|
43
44
|
editTableProps={{
|
|
44
45
|
onAdd: async (data) => {
|
|
45
|
-
console.log("addd");
|
|
46
46
|
const newData = [...cuData];
|
|
47
47
|
newData.push({
|
|
48
48
|
id: newData.length + 1,
|
|
@@ -59,7 +59,7 @@ export default () => {
|
|
|
59
59
|
dialogTable={dialogTable}
|
|
60
60
|
configData={[
|
|
61
61
|
{ title: "标题", dataIndex: "title" },
|
|
62
|
-
{ title: "标题2", dataIndex: "
|
|
62
|
+
{ title: "标题2", dataIndex: "time", valueType: "date" },
|
|
63
63
|
{
|
|
64
64
|
title: "操作",
|
|
65
65
|
valueType: "option",
|
|
@@ -69,7 +69,6 @@ export default () => {
|
|
|
69
69
|
key="editable"
|
|
70
70
|
type={"link"}
|
|
71
71
|
onClick={() => {
|
|
72
|
-
console.log(action);
|
|
73
72
|
action?.startEditable?.(record.id);
|
|
74
73
|
}}
|
|
75
74
|
>
|