@hw-component/table 1.2.7 → 1.2.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/RowSelection.js +3 -3
- package/es/TableConfig.d.ts +1 -1
- package/es/render/TagsComponent.d.ts +2 -2
- package/es/render/TagsComponent.js +6 -6
- package/es/render/config.d.ts +3 -1
- package/es/render/config.js +28 -2
- package/es/render/index.d.ts +4 -4
- package/es/render/index.js +7 -6
- package/lib/HTableBody/RowSelection.js +3 -3
- package/lib/TableConfig.d.ts +1 -1
- package/lib/render/TagsComponent.d.ts +2 -2
- package/lib/render/TagsComponent.js +6 -6
- package/lib/render/config.d.ts +3 -1
- package/lib/render/config.js +27 -1
- package/lib/render/index.d.ts +4 -4
- package/lib/render/index.js +7 -6
- package/package.json +1 -1
- package/src/components/HTableBody/RowSelection.tsx +10 -8
- package/src/components/HTableBody/hooks.tsx +4 -4
- package/src/components/HTableBody/index.tsx +64 -67
- package/src/components/HTableHeader/index.tsx +4 -2
- package/src/components/HTablePagination/index.tsx +4 -2
- package/src/components/Table.tsx +9 -4
- package/src/components/TableConfig.tsx +18 -13
- package/src/components/modal.ts +10 -5
- package/src/components/render/TagsComponent.tsx +117 -86
- package/src/components/render/config.tsx +104 -68
- package/src/components/render/index.tsx +25 -20
- package/src/pages/Table/index.tsx +133 -123
|
@@ -143,9 +143,9 @@ var RowSelectionBox = function RowSelectionBox(_ref5) {
|
|
|
143
143
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
var
|
|
147
|
-
_spliceInstanceProperty(newKeys).call(newKeys,
|
|
148
|
-
_spliceInstanceProperty(newRowData).call(newRowData,
|
|
146
|
+
var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
|
|
147
|
+
_spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
|
|
148
|
+
_spliceInstanceProperty(newRowData).call(newRowData, keyIndex, 1);
|
|
149
149
|
rowOnChange(newKeys, newRowData);
|
|
150
150
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
151
151
|
};
|
package/es/TableConfig.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface HTableConfigContextModal {
|
|
|
9
9
|
valueTypeConfig?: ValueTypeConfigModal;
|
|
10
10
|
}
|
|
11
11
|
export declare const HTableConfigContext: React.Context<HTableConfigContextModal | null>;
|
|
12
|
-
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle }: HTableConfigContextModal) => {
|
|
12
|
+
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle, }: HTableConfigContextModal) => {
|
|
13
13
|
errorRender: ((table: HTableInstance, error: Error) => React.ReactNode) | undefined;
|
|
14
14
|
emptyRender: ((table: HTableInstance) => React.ReactNode) | undefined;
|
|
15
15
|
headerStyle: React.CSSProperties | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TooltipProps } from "antd/lib/tooltip";
|
|
3
|
-
import { HTableInstance } from "@/components/modal";
|
|
2
|
+
import type { TooltipProps } from "antd/lib/tooltip";
|
|
3
|
+
import type { HTableInstance } from "@/components/modal";
|
|
4
4
|
type CloseFn = (key: string, tableInstance?: HTableInstance) => void;
|
|
5
5
|
interface IProps {
|
|
6
6
|
data: any[];
|
|
@@ -60,11 +60,11 @@ var TagsComponent = function TagsComponent(props) {
|
|
|
60
60
|
tagData: data
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
var
|
|
64
|
-
var
|
|
63
|
+
var resultTagData = _sliceInstanceProperty(data).call(data, 0, maxLen);
|
|
64
|
+
var resultMoreTag = _sliceInstanceProperty(data).call(data, maxLen);
|
|
65
65
|
return {
|
|
66
|
-
tagData:
|
|
67
|
-
moreTag:
|
|
66
|
+
tagData: resultTagData,
|
|
67
|
+
moreTag: resultMoreTag
|
|
68
68
|
};
|
|
69
69
|
}, [data, maxLen]),
|
|
70
70
|
tagData = _useMemo.tagData,
|
|
@@ -95,9 +95,9 @@ var TagsComponent = function TagsComponent(props) {
|
|
|
95
95
|
}
|
|
96
96
|
var tagLabel = tagItem[label],
|
|
97
97
|
tagValue = tagItem[value],
|
|
98
|
-
|
|
98
|
+
itemProps = _objectWithoutProperties(tagItem, _mapInstanceProperty(_context = [label, value]).call(_context, _toPropertyKey));
|
|
99
99
|
var tooltipProps = getTooltipProps(tagLabel, tooltip);
|
|
100
|
-
var cuTagProps = _objectSpread(_objectSpread({}, tagProps),
|
|
100
|
+
var cuTagProps = _objectSpread(_objectSpread({}, tagProps), itemProps);
|
|
101
101
|
var cuKey = tagValue || indexKey;
|
|
102
102
|
return jsx(Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, {
|
|
103
103
|
children: jsx(Tag, _objectSpread(_objectSpread({}, cuTagProps), {}, {
|
package/es/render/config.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
1
|
+
import type { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
2
2
|
declare const _default: {
|
|
3
3
|
date: (config: ConfigItemModal, itemData: any) => string;
|
|
4
4
|
tags: (config: ConfigItemModal, itemData: any, index: number, tableInstance: HTableInstance) => "-" | JSX.Element;
|
|
5
5
|
copy: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
6
6
|
link: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
7
7
|
text: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
8
|
+
image: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
9
|
+
avatar: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
8
10
|
};
|
|
9
11
|
export default _default;
|
package/es/render/config.js
CHANGED
|
@@ -12,7 +12,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
12
12
|
import moment from 'moment';
|
|
13
13
|
import TagsComponent from './TagsComponent.js';
|
|
14
14
|
import copy from 'copy-to-clipboard';
|
|
15
|
-
import { Typography, message } from 'antd';
|
|
15
|
+
import { Typography, message, Image, Avatar } from 'antd';
|
|
16
16
|
|
|
17
17
|
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; }
|
|
18
18
|
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; }
|
|
@@ -67,6 +67,9 @@ var copyRender = function copyRender(config, itemData) {
|
|
|
67
67
|
cpText = text(itemData);
|
|
68
68
|
}
|
|
69
69
|
return jsx(Link, {
|
|
70
|
+
style: {
|
|
71
|
+
wordBreak: 'break-all'
|
|
72
|
+
},
|
|
70
73
|
onClick: function onClick() {
|
|
71
74
|
copy(cpText || tableVal);
|
|
72
75
|
message.success(msg);
|
|
@@ -88,6 +91,9 @@ var linkRender = function linkRender(config, itemData) {
|
|
|
88
91
|
return jsx(Link, {
|
|
89
92
|
href: hrefUrl || tableVal,
|
|
90
93
|
target: target,
|
|
94
|
+
style: {
|
|
95
|
+
wordBreak: 'break-all'
|
|
96
|
+
},
|
|
91
97
|
children: tableVal
|
|
92
98
|
});
|
|
93
99
|
};
|
|
@@ -105,12 +111,32 @@ var textRender = function textRender(config, itemData) {
|
|
|
105
111
|
children: [addonBefore, tableVal, addonAfter]
|
|
106
112
|
});
|
|
107
113
|
};
|
|
114
|
+
var imageRender = function imageRender(config, itemData) {
|
|
115
|
+
var _config$valueTypeProp6 = config.valueTypeProps,
|
|
116
|
+
valueTypeProps = _config$valueTypeProp6 === void 0 ? {} : _config$valueTypeProp6;
|
|
117
|
+
var tableVal = getTableVal(config, itemData);
|
|
118
|
+
return jsx(Image, _objectSpread({
|
|
119
|
+
src: tableVal,
|
|
120
|
+
width: 48
|
|
121
|
+
}, valueTypeProps));
|
|
122
|
+
};
|
|
123
|
+
var avatarRender = function avatarRender(config, itemData) {
|
|
124
|
+
var _config$valueTypeProp7 = config.valueTypeProps,
|
|
125
|
+
valueTypeProps = _config$valueTypeProp7 === void 0 ? {} : _config$valueTypeProp7;
|
|
126
|
+
var tableVal = getTableVal(config, itemData);
|
|
127
|
+
return jsx(Avatar, _objectSpread({
|
|
128
|
+
src: tableVal,
|
|
129
|
+
size: 32
|
|
130
|
+
}, valueTypeProps));
|
|
131
|
+
};
|
|
108
132
|
var config = {
|
|
109
133
|
date: dateRender,
|
|
110
134
|
tags: tagsRender,
|
|
111
135
|
copy: copyRender,
|
|
112
136
|
link: linkRender,
|
|
113
|
-
text: textRender
|
|
137
|
+
text: textRender,
|
|
138
|
+
image: imageRender,
|
|
139
|
+
avatar: avatarRender
|
|
114
140
|
};
|
|
115
141
|
|
|
116
142
|
export { config as default };
|
package/es/render/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { ValueTypeConfigModal } from
|
|
4
|
-
declare const _default: (item: ConfigItemModal, tableInstance: HTableInstance, valueTypeConfig: ValueTypeConfigModal) => (dom: React.ReactNode, itemData: any, index: number) =>
|
|
1
|
+
import type { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { ValueTypeConfigModal } from "../modal";
|
|
4
|
+
declare const _default: (item: ConfigItemModal, tableInstance: HTableInstance, valueTypeConfig: ValueTypeConfigModal) => (dom: React.ReactNode, itemData: any, index: number) => React.ReactNode;
|
|
5
5
|
export default _default;
|
package/es/render/index.js
CHANGED
|
@@ -7,16 +7,17 @@ var configRender = (function (item, tableInstance, valueTypeConfig) {
|
|
|
7
7
|
valueType = _item$valueType === void 0 ? "" : _item$valueType;
|
|
8
8
|
return function (dom, itemData, index) {
|
|
9
9
|
var valType = valueType;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var node = dom;
|
|
11
|
+
if (config[valType]) {
|
|
12
|
+
node = config[valType](item, itemData, index, tableInstance);
|
|
12
13
|
}
|
|
13
14
|
if (valueTypeConfig[valType]) {
|
|
14
|
-
|
|
15
|
+
node = valueTypeConfig[valType](item, itemData, index, tableInstance);
|
|
15
16
|
}
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
17
|
+
if (render) {
|
|
18
|
+
return render(node, itemData, index, tableInstance);
|
|
18
19
|
}
|
|
19
|
-
return
|
|
20
|
+
return node;
|
|
20
21
|
};
|
|
21
22
|
});
|
|
22
23
|
|
|
@@ -144,9 +144,9 @@ var RowSelectionBox = function RowSelectionBox(_ref5) {
|
|
|
144
144
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
var
|
|
148
|
-
_spliceInstanceProperty(newKeys).call(newKeys,
|
|
149
|
-
_spliceInstanceProperty(newRowData).call(newRowData,
|
|
147
|
+
var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
|
|
148
|
+
_spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
|
|
149
|
+
_spliceInstanceProperty(newRowData).call(newRowData, keyIndex, 1);
|
|
150
150
|
rowOnChange(newKeys, newRowData);
|
|
151
151
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
152
152
|
};
|
package/lib/TableConfig.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface HTableConfigContextModal {
|
|
|
9
9
|
valueTypeConfig?: ValueTypeConfigModal;
|
|
10
10
|
}
|
|
11
11
|
export declare const HTableConfigContext: React.Context<HTableConfigContextModal | null>;
|
|
12
|
-
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle }: HTableConfigContextModal) => {
|
|
12
|
+
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle, }: HTableConfigContextModal) => {
|
|
13
13
|
errorRender: ((table: HTableInstance, error: Error) => React.ReactNode) | undefined;
|
|
14
14
|
emptyRender: ((table: HTableInstance) => React.ReactNode) | undefined;
|
|
15
15
|
headerStyle: React.CSSProperties | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TooltipProps } from "antd/lib/tooltip";
|
|
3
|
-
import { HTableInstance } from "@/components/modal";
|
|
2
|
+
import type { TooltipProps } from "antd/lib/tooltip";
|
|
3
|
+
import type { HTableInstance } from "@/components/modal";
|
|
4
4
|
type CloseFn = (key: string, tableInstance?: HTableInstance) => void;
|
|
5
5
|
interface IProps {
|
|
6
6
|
data: any[];
|
|
@@ -63,11 +63,11 @@ var TagsComponent = function TagsComponent(props) {
|
|
|
63
63
|
tagData: data
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
var
|
|
67
|
-
var
|
|
66
|
+
var resultTagData = _sliceInstanceProperty(data).call(data, 0, maxLen);
|
|
67
|
+
var resultMoreTag = _sliceInstanceProperty(data).call(data, maxLen);
|
|
68
68
|
return {
|
|
69
|
-
tagData:
|
|
70
|
-
moreTag:
|
|
69
|
+
tagData: resultTagData,
|
|
70
|
+
moreTag: resultMoreTag
|
|
71
71
|
};
|
|
72
72
|
}, [data, maxLen]),
|
|
73
73
|
tagData = _useMemo.tagData,
|
|
@@ -98,9 +98,9 @@ var TagsComponent = function TagsComponent(props) {
|
|
|
98
98
|
}
|
|
99
99
|
var tagLabel = tagItem[label],
|
|
100
100
|
tagValue = tagItem[value],
|
|
101
|
-
|
|
101
|
+
itemProps = _objectWithoutProperties(tagItem, _mapInstanceProperty(_context = [label, value]).call(_context, _toPropertyKey));
|
|
102
102
|
var tooltipProps = getTooltipProps(tagLabel, tooltip);
|
|
103
|
-
var cuTagProps = _objectSpread(_objectSpread({}, tagProps),
|
|
103
|
+
var cuTagProps = _objectSpread(_objectSpread({}, tagProps), itemProps);
|
|
104
104
|
var cuKey = tagValue || indexKey;
|
|
105
105
|
return jsxRuntime.jsx(antd.Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, {
|
|
106
106
|
children: jsxRuntime.jsx(antd.Tag, _objectSpread(_objectSpread({}, cuTagProps), {}, {
|
package/lib/render/config.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
1
|
+
import type { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
2
2
|
declare const _default: {
|
|
3
3
|
date: (config: ConfigItemModal, itemData: any) => string;
|
|
4
4
|
tags: (config: ConfigItemModal, itemData: any, index: number, tableInstance: HTableInstance) => "-" | JSX.Element;
|
|
5
5
|
copy: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
6
6
|
link: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
7
7
|
text: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
8
|
+
image: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
9
|
+
avatar: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
8
10
|
};
|
|
9
11
|
export default _default;
|
package/lib/render/config.js
CHANGED
|
@@ -70,6 +70,9 @@ var copyRender = function copyRender(config, itemData) {
|
|
|
70
70
|
cpText = text(itemData);
|
|
71
71
|
}
|
|
72
72
|
return jsxRuntime.jsx(Link, {
|
|
73
|
+
style: {
|
|
74
|
+
wordBreak: 'break-all'
|
|
75
|
+
},
|
|
73
76
|
onClick: function onClick() {
|
|
74
77
|
copy(cpText || tableVal);
|
|
75
78
|
antd.message.success(msg);
|
|
@@ -91,6 +94,9 @@ var linkRender = function linkRender(config, itemData) {
|
|
|
91
94
|
return jsxRuntime.jsx(Link, {
|
|
92
95
|
href: hrefUrl || tableVal,
|
|
93
96
|
target: target,
|
|
97
|
+
style: {
|
|
98
|
+
wordBreak: 'break-all'
|
|
99
|
+
},
|
|
94
100
|
children: tableVal
|
|
95
101
|
});
|
|
96
102
|
};
|
|
@@ -108,12 +114,32 @@ var textRender = function textRender(config, itemData) {
|
|
|
108
114
|
children: [addonBefore, tableVal, addonAfter]
|
|
109
115
|
});
|
|
110
116
|
};
|
|
117
|
+
var imageRender = function imageRender(config, itemData) {
|
|
118
|
+
var _config$valueTypeProp6 = config.valueTypeProps,
|
|
119
|
+
valueTypeProps = _config$valueTypeProp6 === void 0 ? {} : _config$valueTypeProp6;
|
|
120
|
+
var tableVal = getTableVal(config, itemData);
|
|
121
|
+
return jsxRuntime.jsx(antd.Image, _objectSpread({
|
|
122
|
+
src: tableVal,
|
|
123
|
+
width: 48
|
|
124
|
+
}, valueTypeProps));
|
|
125
|
+
};
|
|
126
|
+
var avatarRender = function avatarRender(config, itemData) {
|
|
127
|
+
var _config$valueTypeProp7 = config.valueTypeProps,
|
|
128
|
+
valueTypeProps = _config$valueTypeProp7 === void 0 ? {} : _config$valueTypeProp7;
|
|
129
|
+
var tableVal = getTableVal(config, itemData);
|
|
130
|
+
return jsxRuntime.jsx(antd.Avatar, _objectSpread({
|
|
131
|
+
src: tableVal,
|
|
132
|
+
size: 32
|
|
133
|
+
}, valueTypeProps));
|
|
134
|
+
};
|
|
111
135
|
var config = {
|
|
112
136
|
date: dateRender,
|
|
113
137
|
tags: tagsRender,
|
|
114
138
|
copy: copyRender,
|
|
115
139
|
link: linkRender,
|
|
116
|
-
text: textRender
|
|
140
|
+
text: textRender,
|
|
141
|
+
image: imageRender,
|
|
142
|
+
avatar: avatarRender
|
|
117
143
|
};
|
|
118
144
|
|
|
119
145
|
exports.default = config;
|
package/lib/render/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { ValueTypeConfigModal } from
|
|
4
|
-
declare const _default: (item: ConfigItemModal, tableInstance: HTableInstance, valueTypeConfig: ValueTypeConfigModal) => (dom: React.ReactNode, itemData: any, index: number) =>
|
|
1
|
+
import type { ConfigItemModal, HTableInstance } from "@/components/modal";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { ValueTypeConfigModal } from "../modal";
|
|
4
|
+
declare const _default: (item: ConfigItemModal, tableInstance: HTableInstance, valueTypeConfig: ValueTypeConfigModal) => (dom: React.ReactNode, itemData: any, index: number) => React.ReactNode;
|
|
5
5
|
export default _default;
|
package/lib/render/index.js
CHANGED
|
@@ -10,16 +10,17 @@ var configRender = (function (item, tableInstance, valueTypeConfig) {
|
|
|
10
10
|
valueType = _item$valueType === void 0 ? "" : _item$valueType;
|
|
11
11
|
return function (dom, itemData, index) {
|
|
12
12
|
var valType = valueType;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var node = dom;
|
|
14
|
+
if (config.default[valType]) {
|
|
15
|
+
node = config.default[valType](item, itemData, index, tableInstance);
|
|
15
16
|
}
|
|
16
17
|
if (valueTypeConfig[valType]) {
|
|
17
|
-
|
|
18
|
+
node = valueTypeConfig[valType](item, itemData, index, tableInstance);
|
|
18
19
|
}
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
20
|
+
if (render) {
|
|
21
|
+
return render(node, itemData, index, tableInstance);
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return node;
|
|
23
24
|
};
|
|
24
25
|
});
|
|
25
26
|
|
package/package.json
CHANGED
|
@@ -21,8 +21,10 @@ export const RowSelectionTitle = ({
|
|
|
21
21
|
});
|
|
22
22
|
const { keys, selectAll } = selectedRowData;
|
|
23
23
|
const allCheck = () => {
|
|
24
|
-
const setKeys = newData.map((item,index) => {
|
|
25
|
-
return typeof rowKey==="function"
|
|
24
|
+
const setKeys = newData.map((item, index) => {
|
|
25
|
+
return typeof rowKey === "function"
|
|
26
|
+
? rowKey(item, index)
|
|
27
|
+
: item[rowKey as string];
|
|
26
28
|
});
|
|
27
29
|
rowOnChange(setKeys, newData);
|
|
28
30
|
onChange?.(setKeys, newData);
|
|
@@ -106,17 +108,17 @@ interface RowSelectionBoxProps {
|
|
|
106
108
|
data: any;
|
|
107
109
|
onChange?: HRowSelection["onChange"];
|
|
108
110
|
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
109
|
-
index:number;
|
|
111
|
+
index: number;
|
|
110
112
|
}
|
|
111
113
|
export const RowSelectionBox = ({
|
|
112
114
|
data,
|
|
113
115
|
onChange,
|
|
114
|
-
|
|
116
|
+
index,
|
|
115
117
|
getCheckboxProps,
|
|
116
118
|
}: RowSelectionBoxProps) => {
|
|
117
119
|
const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
|
|
118
120
|
const { rowData = [], keys = [] } = selectedRowData;
|
|
119
|
-
const key = typeof rowKey==="function"?rowKey(data,index):data[rowKey];
|
|
121
|
+
const key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
120
122
|
const check = (e) => {
|
|
121
123
|
const checked = e.target.checked;
|
|
122
124
|
const newKeys = [...keys];
|
|
@@ -128,9 +130,9 @@ export const RowSelectionBox = ({
|
|
|
128
130
|
onChange?.(newKeys, newRowData);
|
|
129
131
|
return;
|
|
130
132
|
}
|
|
131
|
-
const
|
|
132
|
-
newKeys.splice(
|
|
133
|
-
newRowData.splice(
|
|
133
|
+
const keyIndex = newKeys.indexOf(key);
|
|
134
|
+
newKeys.splice(keyIndex, 1);
|
|
135
|
+
newRowData.splice(keyIndex, 1);
|
|
134
136
|
rowOnChange(newKeys, newRowData);
|
|
135
137
|
onChange?.(newKeys, newRowData);
|
|
136
138
|
};
|
|
@@ -13,7 +13,7 @@ import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
|
13
13
|
import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
14
14
|
import { mkChangeValue, outColSetting } from "./utils";
|
|
15
15
|
import configRender from "../render";
|
|
16
|
-
import {useHTableConfigContext} from "@/components/TableConfig";
|
|
16
|
+
import { useHTableConfigContext } from "@/components/TableConfig";
|
|
17
17
|
const rowSelectionCol = (rowSelection?: HRowSelection) => {
|
|
18
18
|
const { allPageCheck, onChange, getCheckboxProps } = rowSelection || {};
|
|
19
19
|
return {
|
|
@@ -27,7 +27,7 @@ const rowSelectionCol = (rowSelection?: HRowSelection) => {
|
|
|
27
27
|
width: 32,
|
|
28
28
|
rowSelectionTitle: true,
|
|
29
29
|
fixed: "left",
|
|
30
|
-
render: (dom, data,index) => {
|
|
30
|
+
render: (dom, data, index) => {
|
|
31
31
|
return (
|
|
32
32
|
<RowSelectionBox
|
|
33
33
|
data={data}
|
|
@@ -41,7 +41,7 @@ const rowSelectionCol = (rowSelection?: HRowSelection) => {
|
|
|
41
41
|
};
|
|
42
42
|
export const useCols = ({ configData, rowSelection, table }: HTableProps) => {
|
|
43
43
|
const [cols, setCols] = useState<ConfigDataModal>([]);
|
|
44
|
-
const {valueTypeConfig}=useHTableConfigContext({});
|
|
44
|
+
const { valueTypeConfig } = useHTableConfigContext({});
|
|
45
45
|
const changeConfigData = (data: ConfigDataModal) => {
|
|
46
46
|
const colsArray = data.filter((item) => {
|
|
47
47
|
return !item.hideInTable;
|
|
@@ -52,7 +52,7 @@ export const useCols = ({ configData, rowSelection, table }: HTableProps) => {
|
|
|
52
52
|
return colsArray.map((item) => {
|
|
53
53
|
return {
|
|
54
54
|
...item,
|
|
55
|
-
render:configRender(item,
|
|
55
|
+
render: configRender(item, table as HTableInstance, valueTypeConfig),
|
|
56
56
|
};
|
|
57
57
|
});
|
|
58
58
|
};
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./hooks";
|
|
16
16
|
import { useHTableContext } from "../context";
|
|
17
17
|
import React from "react";
|
|
18
|
-
import {ConfigProvider, Empty, Alert, Space} from "antd";
|
|
18
|
+
import { ConfigProvider, Empty, Alert, Space } from "antd";
|
|
19
19
|
import { useHTableConfigContext } from "../TableConfig";
|
|
20
20
|
import HTablePagination from "../HTablePagination";
|
|
21
21
|
import { useClassName } from "../hooks";
|
|
@@ -125,76 +125,73 @@ export default ({
|
|
|
125
125
|
: optionsNode;
|
|
126
126
|
const alwaysShowAlert = keys.length > 0 || selectAll || configAlwaysShowAlert;
|
|
127
127
|
const className = useClassName("hw-table-body");
|
|
128
|
-
const {tableStyle:defaultTableStyle}=useHTableConfigContext({
|
|
128
|
+
const { tableStyle: defaultTableStyle } = useHTableConfigContext({
|
|
129
|
+
tableStyle,
|
|
130
|
+
});
|
|
129
131
|
return (
|
|
130
132
|
<div style={defaultTableStyle} className={`hw_table_body ${className}`}>
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return tableEmptyRender?.(tableInstance);
|
|
148
|
-
}}
|
|
149
|
-
>
|
|
133
|
+
<Space size={16} direction={"vertical"} style={{ width: "100%" }}>
|
|
134
|
+
{alwaysShowAlert && (
|
|
135
|
+
<Alert
|
|
136
|
+
message={<AlertMsg actionRender={actionRender} />}
|
|
137
|
+
type="info"
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
<HeaderTitle headerTitle={headerTitle} rNode={defaultOptionsNode} />
|
|
141
|
+
<ConfigProvider
|
|
142
|
+
renderEmpty={() => {
|
|
143
|
+
if (error) {
|
|
144
|
+
return tableErrorRender?.(tableInstance, error);
|
|
145
|
+
}
|
|
146
|
+
return tableEmptyRender?.(tableInstance);
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
150
149
|
<ProTable
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
pagination={false}
|
|
184
|
-
|
|
150
|
+
{...props}
|
|
151
|
+
columnsState={{
|
|
152
|
+
...selfColStatus,
|
|
153
|
+
value,
|
|
154
|
+
}}
|
|
155
|
+
columns={cols as any}
|
|
156
|
+
size={cuSize}
|
|
157
|
+
search={false}
|
|
158
|
+
onChange={(page, filters, sorter) => {
|
|
159
|
+
if (localSorter) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const { field, order } = sorter as any;
|
|
163
|
+
const orderByField =
|
|
164
|
+
typeof order === "undefined" ? undefined : field;
|
|
165
|
+
const asc =
|
|
166
|
+
typeof order === "undefined" ? undefined : order === "ascend";
|
|
167
|
+
tableInstance.table.reloadWithParams({
|
|
168
|
+
current: 1,
|
|
169
|
+
orderByField,
|
|
170
|
+
asc,
|
|
171
|
+
});
|
|
172
|
+
}}
|
|
173
|
+
tableStyle={{
|
|
174
|
+
paddingBottom: 0,
|
|
175
|
+
}}
|
|
176
|
+
options={false}
|
|
177
|
+
rowSelection={false}
|
|
178
|
+
loading={loading}
|
|
179
|
+
rowKey={rowKey}
|
|
180
|
+
dataSource={records}
|
|
181
|
+
pagination={false}
|
|
185
182
|
/>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
183
|
+
{pagination !== false && (
|
|
184
|
+
<HTablePagination
|
|
185
|
+
onPageChange={onPageChange}
|
|
186
|
+
paginationStyle={paginationStyle}
|
|
187
|
+
affixProps={affixProps}
|
|
188
|
+
goTop={goTop}
|
|
189
|
+
actionRender={paginationActionRender}
|
|
190
|
+
{...pagination}
|
|
191
|
+
/>
|
|
192
|
+
)}
|
|
193
|
+
</ConfigProvider>
|
|
194
|
+
</Space>
|
|
198
195
|
</div>
|
|
199
196
|
);
|
|
200
197
|
};
|
|
@@ -6,7 +6,7 @@ import { useClassName } from "../hooks";
|
|
|
6
6
|
import type { IHeaderProps } from "./modal";
|
|
7
7
|
import { useHideMoreTitle } from "./hooks";
|
|
8
8
|
import { HeaderProvider } from "./Context";
|
|
9
|
-
import {useHTableConfigContext} from "../TableConfig";
|
|
9
|
+
import { useHTableConfigContext } from "../TableConfig";
|
|
10
10
|
|
|
11
11
|
const defaultSearchSpan = {
|
|
12
12
|
xxl: 4,
|
|
@@ -45,7 +45,9 @@ export default ({
|
|
|
45
45
|
typeof hideLabel === "undefined" ? contextHideLabel : hideLabel;
|
|
46
46
|
const tableLabelWidth = labelWidth || contextLabelWidth;
|
|
47
47
|
const className = useClassName("hw-table-header");
|
|
48
|
-
const {headerStyle:defaultHeaderStyle}=useHTableConfigContext({
|
|
48
|
+
const { headerStyle: defaultHeaderStyle } = useHTableConfigContext({
|
|
49
|
+
headerStyle,
|
|
50
|
+
});
|
|
49
51
|
return (
|
|
50
52
|
<Card
|
|
51
53
|
style={defaultHeaderStyle}
|
|
@@ -6,7 +6,7 @@ import { useClassName } from "../hooks";
|
|
|
6
6
|
import React, { useState } from "react";
|
|
7
7
|
import type { AffixProps } from "antd/lib/affix";
|
|
8
8
|
import GoTop from "../GoTop";
|
|
9
|
-
import {useHTableConfigContext} from "@/components/TableConfig";
|
|
9
|
+
import { useHTableConfigContext } from "@/components/TableConfig";
|
|
10
10
|
export interface IPaginationProps extends PaginationProps {
|
|
11
11
|
onPageChange?: (params: ParamsModal) => void;
|
|
12
12
|
paginationStyle?: React.CSSProperties;
|
|
@@ -37,7 +37,9 @@ export default ({
|
|
|
37
37
|
if (!data) {
|
|
38
38
|
return <></>;
|
|
39
39
|
}
|
|
40
|
-
const {paginationStyle:defaultPaginationStyle}=useHTableConfigContext({
|
|
40
|
+
const { paginationStyle: defaultPaginationStyle } = useHTableConfigContext({
|
|
41
|
+
paginationStyle,
|
|
42
|
+
});
|
|
41
43
|
|
|
42
44
|
if (affixProps === false) {
|
|
43
45
|
return (
|