@hw-component/table 1.10.5 → 1.10.7
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/DialogTable/Content.js +1 -0
- package/es/HTableBody/RowCheckBox/hooks.js +110 -11
- package/es/HTableBody/hooks/useColData.d.ts +2 -2
- package/es/HTableBody/hooks/useColData.js +4 -2
- package/es/HTableBody/index.js +12 -6
- package/es/HTableBody/modal.d.ts +2 -1
- package/es/Table.d.ts +1 -1
- package/es/Table.js +22 -30
- package/es/TableConfig.d.ts +4 -2
- package/es/TableConfig.js +6 -3
- package/es/TableCustomize.js +4 -2
- package/es/TableProvider.d.ts +6 -0
- package/es/TableProvider.js +57 -0
- package/es/context.d.ts +1 -2
- package/es/modal.d.ts +2 -0
- package/lib/DialogTable/Content.js +1 -0
- package/lib/HTableBody/RowCheckBox/hooks.js +110 -11
- package/lib/HTableBody/hooks/useColData.d.ts +2 -2
- package/lib/HTableBody/hooks/useColData.js +4 -2
- package/lib/HTableBody/index.js +12 -6
- package/lib/HTableBody/modal.d.ts +2 -1
- package/lib/Table.d.ts +1 -1
- package/lib/Table.js +22 -30
- package/lib/TableConfig.d.ts +4 -2
- package/lib/TableConfig.js +6 -3
- package/lib/TableCustomize.js +4 -2
- package/lib/TableProvider.d.ts +6 -0
- package/lib/TableProvider.js +60 -0
- package/lib/context.d.ts +1 -2
- package/lib/modal.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/EditTable/modal.ts +5 -6
- package/src/components/HTableBody/RowCheckBox/hooks.ts +77 -8
- package/src/components/HTableBody/hooks/useColData.tsx +12 -2
- package/src/components/HTableBody/index.tsx +13 -1
- package/src/components/HTableBody/modal.ts +2 -0
- package/src/components/Table.tsx +20 -27
- package/src/components/TableConfig.tsx +5 -0
- package/src/components/TableCustomize.tsx +2 -0
- package/src/components/TableProvider.tsx +55 -0
- package/src/components/context.ts +1 -1
- package/src/components/modal.ts +2 -0
- package/src/components/render/TagsComponent.tsx +10 -7
- package/src/pages/Table/index.tsx +30 -11
package/lib/Table.js
CHANGED
|
@@ -19,19 +19,18 @@ var index$1 = require('./HTableHeader/index.js');
|
|
|
19
19
|
var index$2 = require('./HTableBody/index.js');
|
|
20
20
|
var useCurrentTable = require('./hooks/useCurrentTable.js');
|
|
21
21
|
var useRowObj = require('./hooks/useRowObj.js');
|
|
22
|
-
var context = require('./context.js');
|
|
23
22
|
var useReq = require('./hooks/useReq.js');
|
|
24
23
|
var useDispatch = require('./hooks/useDispatch.js');
|
|
25
24
|
var React = require('react');
|
|
26
25
|
var index = require('./hooks/index.js');
|
|
26
|
+
var TableProvider = require('./TableProvider.js');
|
|
27
27
|
|
|
28
|
-
var _excluded = ["request", "
|
|
28
|
+
var _excluded = ["request", "searchSpan", "table", "hideHeader", "headerStyle", "tableStyle", "action", "spaceSize", "className", "paginationStyle", "rowKey", "onFinish", "manual", "formInitValues", "onReset", "style", "dataSource", "reload", "loading", "error", "rowSelection"];
|
|
29
29
|
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
30
|
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; }
|
|
31
31
|
var Table = (function (_ref) {
|
|
32
32
|
var _context;
|
|
33
33
|
var request = _ref.request,
|
|
34
|
-
configData = _ref.configData,
|
|
35
34
|
searchSpan = _ref.searchSpan,
|
|
36
35
|
table = _ref.table,
|
|
37
36
|
hideHeader = _ref.hideHeader,
|
|
@@ -48,8 +47,6 @@ var Table = (function (_ref) {
|
|
|
48
47
|
onFinish = _ref.onFinish,
|
|
49
48
|
manual = _ref.manual,
|
|
50
49
|
formInitValues = _ref.formInitValues,
|
|
51
|
-
hideLabel = _ref.hideLabel,
|
|
52
|
-
labelWidth = _ref.labelWidth,
|
|
53
50
|
onReset = _ref.onReset,
|
|
54
51
|
style = _ref.style,
|
|
55
52
|
dataSource = _ref.dataSource,
|
|
@@ -101,31 +98,26 @@ var Table = (function (_ref) {
|
|
|
101
98
|
dataSource: data
|
|
102
99
|
});
|
|
103
100
|
var contentClassName = index.useClassName("hw-table-content");
|
|
104
|
-
return jsxRuntime.jsx(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
loading: propsLoading || loading,
|
|
112
|
-
allSelectChange: allSelectChange,
|
|
113
|
-
action: action,
|
|
114
|
-
configData: configData,
|
|
115
|
-
onFinish: function onFinish(value) {
|
|
116
|
-
rowSelectionReload();
|
|
117
|
-
return run(_objectSpread(_objectSpread({}, value), {}, {
|
|
118
|
-
current: 1
|
|
119
|
-
}));
|
|
120
|
-
},
|
|
121
|
-
onPageChange: tableInstance.table.reloadWithParams,
|
|
122
|
-
setSelectedRowData: setSelectedRowData,
|
|
123
|
-
rowKey: rowKey,
|
|
124
|
-
headerOpen: open,
|
|
125
|
-
setHeaderOpen: setOpen,
|
|
126
|
-
hideLabel: hideLabel,
|
|
127
|
-
labelWidth: labelWidth
|
|
101
|
+
return jsxRuntime.jsx(TableProvider.default, _objectSpread(_objectSpread({}, props), {}, {
|
|
102
|
+
tableInstance: tableInstance,
|
|
103
|
+
onFinish: function onFinish(value) {
|
|
104
|
+
rowSelectionReload();
|
|
105
|
+
return run(_objectSpread(_objectSpread({}, value), {}, {
|
|
106
|
+
current: 1
|
|
107
|
+
}));
|
|
128
108
|
},
|
|
109
|
+
selectedRowData: selectedRowData,
|
|
110
|
+
rowOnChange: rowOnChange,
|
|
111
|
+
data: data,
|
|
112
|
+
error: propsError || error,
|
|
113
|
+
loading: propsLoading || loading,
|
|
114
|
+
allSelectChange: allSelectChange,
|
|
115
|
+
action: action,
|
|
116
|
+
setSelectedRowData: setSelectedRowData,
|
|
117
|
+
rowKey: rowKey,
|
|
118
|
+
headerOpen: open,
|
|
119
|
+
setHeaderOpen: setOpen,
|
|
120
|
+
rowSelection: rowSelection,
|
|
129
121
|
children: jsxRuntime.jsxs("div", {
|
|
130
122
|
style: _objectSpread({}, style),
|
|
131
123
|
className: _concatInstanceProperty(_context = "".concat(contentClassName, " ")).call(_context, className),
|
|
@@ -144,7 +136,7 @@ var Table = (function (_ref) {
|
|
|
144
136
|
rowSelection: rowSelection
|
|
145
137
|
}, props))]
|
|
146
138
|
})
|
|
147
|
-
});
|
|
139
|
+
}));
|
|
148
140
|
});
|
|
149
141
|
|
|
150
142
|
exports.default = Table;
|
package/lib/TableConfig.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { EmptyPageRender, ErrorPageRender, ValueTypeConfigModal } from "./modal";
|
|
2
|
+
import { ConfigItemModal, EmptyPageRender, ErrorPageRender, ValueTypeConfigModal } from "./modal";
|
|
3
3
|
interface HTableConfigContextModal {
|
|
4
4
|
emptyRender?: EmptyPageRender;
|
|
5
5
|
errorRender?: ErrorPageRender;
|
|
@@ -8,9 +8,10 @@ interface HTableConfigContextModal {
|
|
|
8
8
|
paginationStyle?: React.CSSProperties;
|
|
9
9
|
valueTypeConfig?: ValueTypeConfigModal;
|
|
10
10
|
defaultSelectedRowClassName?: string | null;
|
|
11
|
+
configItemRender?: (data: ConfigItemModal) => ConfigItemModal;
|
|
11
12
|
}
|
|
12
13
|
export declare const HTableConfigContext: React.Context<HTableConfigContextModal | null>;
|
|
13
|
-
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle, }: HTableConfigContextModal) => {
|
|
14
|
+
export declare const useHTableConfigContext: ({ emptyRender, errorRender, headerStyle, tableStyle, paginationStyle, configItemRender, }: HTableConfigContextModal) => {
|
|
14
15
|
errorRender: ErrorPageRender | undefined;
|
|
15
16
|
emptyRender: EmptyPageRender | undefined;
|
|
16
17
|
headerStyle: React.CSSProperties | undefined;
|
|
@@ -18,6 +19,7 @@ export declare const useHTableConfigContext: ({ emptyRender, errorRender, header
|
|
|
18
19
|
paginationStyle: React.CSSProperties | undefined;
|
|
19
20
|
valueTypeConfig: ValueTypeConfigModal;
|
|
20
21
|
defaultSelectedRowClassName: string | null | undefined;
|
|
22
|
+
configItemRender: ((data: ConfigItemModal) => ConfigItemModal) | undefined;
|
|
21
23
|
};
|
|
22
24
|
declare const Index: React.FC<HTableConfigContextModal>;
|
|
23
25
|
export default Index;
|
package/lib/TableConfig.js
CHANGED
|
@@ -13,7 +13,8 @@ var useHTableConfigContext = function useHTableConfigContext(_ref) {
|
|
|
13
13
|
errorRender = _ref.errorRender,
|
|
14
14
|
headerStyle = _ref.headerStyle,
|
|
15
15
|
tableStyle = _ref.tableStyle,
|
|
16
|
-
paginationStyle = _ref.paginationStyle
|
|
16
|
+
paginationStyle = _ref.paginationStyle,
|
|
17
|
+
configItemRender = _ref.configItemRender;
|
|
17
18
|
var _ref2 = React.useContext(HTableConfigContext) || {},
|
|
18
19
|
configErrorRender = _ref2.errorRender,
|
|
19
20
|
configEmptyRender = _ref2.emptyRender,
|
|
@@ -22,7 +23,8 @@ var useHTableConfigContext = function useHTableConfigContext(_ref) {
|
|
|
22
23
|
configPaginationStyle = _ref2.paginationStyle,
|
|
23
24
|
_ref2$valueTypeConfig = _ref2.valueTypeConfig,
|
|
24
25
|
valueTypeConfig = _ref2$valueTypeConfig === void 0 ? {} : _ref2$valueTypeConfig,
|
|
25
|
-
defaultSelectedRowClassName = _ref2.defaultSelectedRowClassName
|
|
26
|
+
defaultSelectedRowClassName = _ref2.defaultSelectedRowClassName,
|
|
27
|
+
contextConfigItemRender = _ref2.configItemRender;
|
|
26
28
|
return {
|
|
27
29
|
errorRender: errorRender || configErrorRender,
|
|
28
30
|
emptyRender: emptyRender || configEmptyRender,
|
|
@@ -30,7 +32,8 @@ var useHTableConfigContext = function useHTableConfigContext(_ref) {
|
|
|
30
32
|
tableStyle: tableStyle || configTableStyle,
|
|
31
33
|
paginationStyle: paginationStyle || configPaginationStyle,
|
|
32
34
|
valueTypeConfig: valueTypeConfig,
|
|
33
|
-
defaultSelectedRowClassName: defaultSelectedRowClassName
|
|
35
|
+
defaultSelectedRowClassName: defaultSelectedRowClassName,
|
|
36
|
+
configItemRender: configItemRender || contextConfigItemRender
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
var Index = function Index(_ref3) {
|
package/lib/TableCustomize.js
CHANGED
|
@@ -21,7 +21,7 @@ var useReq = require('./hooks/useReq.js');
|
|
|
21
21
|
var useDispatch = require('./hooks/useDispatch.js');
|
|
22
22
|
var React = require('react');
|
|
23
23
|
|
|
24
|
-
var _excluded = ["request", "configData", "table", "action", "children", "rowKey", "hideLabel", "labelWidth"];
|
|
24
|
+
var _excluded = ["request", "configData", "table", "action", "children", "rowKey", "hideLabel", "labelWidth", "configItemRender"];
|
|
25
25
|
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; }
|
|
26
26
|
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; }
|
|
27
27
|
var Index = function Index(_ref) {
|
|
@@ -34,6 +34,7 @@ var Index = function Index(_ref) {
|
|
|
34
34
|
rowKey = _ref.rowKey,
|
|
35
35
|
hideLabel = _ref.hideLabel,
|
|
36
36
|
labelWidth = _ref.labelWidth,
|
|
37
|
+
configItemRender = _ref.configItemRender,
|
|
37
38
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
38
39
|
var _useReq = useReq.default(_objectSpread({
|
|
39
40
|
request: request
|
|
@@ -96,7 +97,8 @@ var Index = function Index(_ref) {
|
|
|
96
97
|
headerOpen: open,
|
|
97
98
|
setHeaderOpen: setOpen,
|
|
98
99
|
hideLabel: hideLabel,
|
|
99
|
-
labelWidth: labelWidth
|
|
100
|
+
labelWidth: labelWidth,
|
|
101
|
+
configItemRender: configItemRender
|
|
100
102
|
},
|
|
101
103
|
children: children
|
|
102
104
|
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var context = require('./context.js');
|
|
8
|
+
|
|
9
|
+
var _excluded = ["children"];
|
|
10
|
+
var Index = function Index(_ref) {
|
|
11
|
+
var children = _ref.children,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
var configData = props.configData,
|
|
14
|
+
_props$action = props.action,
|
|
15
|
+
action = _props$action === void 0 ? {} : _props$action,
|
|
16
|
+
_props$rowKey = props.rowKey,
|
|
17
|
+
rowKey = _props$rowKey === void 0 ? "id" : _props$rowKey,
|
|
18
|
+
hideLabel = props.hideLabel,
|
|
19
|
+
labelWidth = props.labelWidth,
|
|
20
|
+
configItemRender = props.configItemRender,
|
|
21
|
+
tableInstance = props.tableInstance,
|
|
22
|
+
selectedRowData = props.selectedRowData,
|
|
23
|
+
rowOnChange = props.rowOnChange,
|
|
24
|
+
data = props.data,
|
|
25
|
+
error = props.error,
|
|
26
|
+
loading = props.loading,
|
|
27
|
+
allSelectChange = props.allSelectChange,
|
|
28
|
+
onFinish = props.onFinish,
|
|
29
|
+
setSelectedRowData = props.setSelectedRowData,
|
|
30
|
+
headerOpen = props.headerOpen,
|
|
31
|
+
setHeaderOpen = props.setHeaderOpen,
|
|
32
|
+
rowSelection = props.rowSelection;
|
|
33
|
+
return jsxRuntime.jsx(context.HTableContext.Provider, {
|
|
34
|
+
value: {
|
|
35
|
+
selectedRowData: selectedRowData,
|
|
36
|
+
rowOnChange: rowOnChange,
|
|
37
|
+
data: data,
|
|
38
|
+
error: error,
|
|
39
|
+
loading: loading,
|
|
40
|
+
allSelectChange: allSelectChange,
|
|
41
|
+
action: action,
|
|
42
|
+
configData: configData,
|
|
43
|
+
onFinish: onFinish,
|
|
44
|
+
onPageChange: tableInstance.table.reloadWithParams,
|
|
45
|
+
setSelectedRowData: setSelectedRowData,
|
|
46
|
+
rowKey: rowKey,
|
|
47
|
+
headerOpen: headerOpen,
|
|
48
|
+
setHeaderOpen: setHeaderOpen,
|
|
49
|
+
hideLabel: hideLabel,
|
|
50
|
+
labelWidth: labelWidth,
|
|
51
|
+
configItemRender: configItemRender,
|
|
52
|
+
tableInstance: tableInstance,
|
|
53
|
+
rowSelection: rowSelection
|
|
54
|
+
},
|
|
55
|
+
children: children
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
exports.default = Index;
|
|
60
|
+
// powered by h
|
package/lib/context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from "react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { HTableProps, ResultModal, RowObj, HTableInstance } from "./modal";
|
|
4
|
-
interface HContextModal extends Omit<HTableProps, "request"> {
|
|
4
|
+
export interface HContextModal extends Omit<HTableProps, "request"> {
|
|
5
5
|
tableInstance: HTableInstance;
|
|
6
6
|
data?: ResultModal;
|
|
7
7
|
selectedRowData: RowObj;
|
|
@@ -18,4 +18,3 @@ interface HContextModal extends Omit<HTableProps, "request"> {
|
|
|
18
18
|
}
|
|
19
19
|
export declare const HTableContext: React.Context<HContextModal | null>;
|
|
20
20
|
export declare const useHTableContext: () => HContextModal;
|
|
21
|
-
export {};
|
package/lib/modal.d.ts
CHANGED
|
@@ -50,10 +50,12 @@ export interface RowSelectionOuter {
|
|
|
50
50
|
}
|
|
51
51
|
export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
|
|
52
52
|
alwaysShowAlert?: boolean;
|
|
53
|
+
allCheckType?: "batch" | "single";
|
|
53
54
|
});
|
|
54
55
|
export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowSelection" | "pagination"> {
|
|
55
56
|
request?: (params: ParamsModal) => Promise<ResultModal>;
|
|
56
57
|
configData: ConfigDataModal;
|
|
58
|
+
configItemRender?: (data: ConfigItemModal) => ConfigItemModal;
|
|
57
59
|
searchSpan?: ColProps;
|
|
58
60
|
table?: HTableInstance;
|
|
59
61
|
actionRender?: ActionRenderFn;
|
package/package.json
CHANGED
|
@@ -4,16 +4,15 @@ import { IPaginationProps } from "../HTablePagination";
|
|
|
4
4
|
import { EmptyPageRender, ErrorPageRender } from "../modal";
|
|
5
5
|
import { ProColumns } from "@ant-design/pro-table/lib/typing";
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
export interface HEditTableProps<T = any>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
extends Omit<
|
|
9
|
+
EditableProTableProps<T, ParamsType>,
|
|
10
|
+
"recordCreatorProps" | "request" | "pagination"
|
|
11
|
+
> {
|
|
13
12
|
creatorButtonText?: string;
|
|
14
13
|
defaultRecordValue?: T;
|
|
15
14
|
recordCreatorProps?: Partial<
|
|
16
|
-
|
|
15
|
+
EditableProTableProps<T, ParamsType>["recordCreatorProps"]
|
|
17
16
|
>;
|
|
18
17
|
dataSource?: any[];
|
|
19
18
|
request?: (params: Record<string, any>) => Promise<T>;
|
|
@@ -8,6 +8,31 @@ const getRowKey = (item: any, index: number, rowKey: HTableProps["rowKey"]) => {
|
|
|
8
8
|
? rowKey(item, index)
|
|
9
9
|
: item[rowKey as string];
|
|
10
10
|
};
|
|
11
|
+
const getCuData=(data,rowKey)=>{
|
|
12
|
+
const rowKeys:Key[]=[];
|
|
13
|
+
const rowObjs:Record<string, any>={};
|
|
14
|
+
data.forEach((item,index) => {
|
|
15
|
+
const key=getRowKey(item, index, rowKey);
|
|
16
|
+
rowKeys.push(key);
|
|
17
|
+
rowObjs[key]=item;
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
rowKeys,
|
|
21
|
+
rowObjs
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const newRowDataMr=(data,rowObj)=>{
|
|
25
|
+
return data.map((item)=>{
|
|
26
|
+
return rowObj[item];
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const mkRowObj=(rowObj:Record<string, any>)=>{
|
|
31
|
+
const keys=Object.keys(rowObj);
|
|
32
|
+
return keys.map((key)=>{
|
|
33
|
+
return rowObj[key];
|
|
34
|
+
})
|
|
35
|
+
}
|
|
11
36
|
export const useAllChecked = (keys: Key[] = [], data: any[] = []) => {
|
|
12
37
|
const { rowKey = "id" } = useHTableContext();
|
|
13
38
|
const len = data?.length;
|
|
@@ -24,17 +49,61 @@ export const useCheckControl = (
|
|
|
24
49
|
data: any[] = [],
|
|
25
50
|
onChange: RowRadioSelectionProps["onChange"]
|
|
26
51
|
) => {
|
|
27
|
-
const {
|
|
52
|
+
const {
|
|
53
|
+
rowOnChange,
|
|
54
|
+
rowKey = "id",
|
|
55
|
+
allSelectChange,
|
|
56
|
+
rowSelection,
|
|
57
|
+
selectedRowData,
|
|
58
|
+
} = useHTableContext();
|
|
59
|
+
const getPreKeys = () => {
|
|
60
|
+
if (rowSelection === false) {
|
|
61
|
+
return {
|
|
62
|
+
rowKeys:[],
|
|
63
|
+
rowObjs:[]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const { allCheckType = "single" } = rowSelection || {};
|
|
67
|
+
const { keys = [],rowData=[] } = selectedRowData;
|
|
68
|
+
if (allCheckType === "single") {
|
|
69
|
+
const {rowKeys,rowObjs}=getCuData(data,rowKey);
|
|
70
|
+
return {
|
|
71
|
+
rowKeys,
|
|
72
|
+
rowObjs:mkRowObj(rowObjs)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const {rowKeys,rowObjs} = getCuData(data, rowKey);
|
|
76
|
+
const {rowObjs:oldRowObjs}=getCuData(rowData,rowKey);
|
|
77
|
+
const newKeys = new Set([...keys, ...rowKeys]);
|
|
78
|
+
return {
|
|
79
|
+
rowKeys:[...newKeys],
|
|
80
|
+
rowObjs:mkRowObj({...oldRowObjs,...rowObjs}),
|
|
81
|
+
}
|
|
82
|
+
};
|
|
28
83
|
const allCheck = () => {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
rowOnChange(setKeys, data);
|
|
33
|
-
onChange?.(setKeys, data);
|
|
84
|
+
const {rowKeys,rowObjs} = getPreKeys();
|
|
85
|
+
rowOnChange(rowKeys, rowObjs);
|
|
86
|
+
onChange?.(rowKeys, rowObjs);
|
|
34
87
|
};
|
|
35
88
|
const allCancel = () => {
|
|
36
|
-
|
|
37
|
-
|
|
89
|
+
if (rowSelection === false) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const { allCheckType = "single" } = rowSelection || {};
|
|
93
|
+
if (allCheckType === "single") {
|
|
94
|
+
rowOnChange([], []);
|
|
95
|
+
onChange?.([], []);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const {rowKeys} = getCuData(data, rowKey);
|
|
99
|
+
const { keys = [] ,rowData=[]} = selectedRowData;
|
|
100
|
+
const newKeys = keys.filter((item) => {
|
|
101
|
+
return rowKeys.indexOf(item) === -1;
|
|
102
|
+
});
|
|
103
|
+
const {rowObjs:oldRowObjs}=getCuData(rowData,rowKey);
|
|
104
|
+
const newRow = newRowDataMr(newKeys,oldRowObjs);
|
|
105
|
+
rowOnChange(newKeys, newRow);
|
|
106
|
+
onChange?.(newKeys, newRow);
|
|
38
107
|
};
|
|
39
108
|
|
|
40
109
|
const checkChange = (e) => {
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
HRowSelection,
|
|
7
7
|
HTableInstance,
|
|
8
8
|
HTableProps,
|
|
9
|
-
} from "
|
|
9
|
+
} from "../../modal";
|
|
10
10
|
import { useClassName } from "@/components/hooks";
|
|
11
11
|
import { useHTableConfigContext } from "@/components/TableConfig";
|
|
12
12
|
import { textTypes } from "@/components/render/config";
|
|
@@ -15,6 +15,7 @@ import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
|
15
15
|
import { mkChangeValue, outColSetting } from "@/components/HTableBody/utils";
|
|
16
16
|
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
17
17
|
import { radioSelectionCol, checkBoxSelectionCol } from "./colsMk";
|
|
18
|
+
|
|
18
19
|
const checkBoxMk = (rowSelection: HRowSelection) => {
|
|
19
20
|
const { type } = rowSelection;
|
|
20
21
|
if (type === "radio") {
|
|
@@ -27,27 +28,33 @@ export const useCols = ({
|
|
|
27
28
|
rowSelection,
|
|
28
29
|
table,
|
|
29
30
|
bordered,
|
|
31
|
+
configItemRender,
|
|
30
32
|
}: HTableProps) => {
|
|
31
33
|
const trClassname = useClassName("hw-table-col-hr");
|
|
32
34
|
const [cols, setCols] = useState<ConfigDataModal>([]);
|
|
33
35
|
const { valueTypeConfig } = useHTableConfigContext({});
|
|
36
|
+
|
|
34
37
|
const itemClassNameMk = (children: any[], lastChildren: any[]) => {
|
|
35
38
|
const lastChildLen = (lastChildren as any[]).length;
|
|
36
39
|
const childLen = children.length;
|
|
37
40
|
return !childLen && !!lastChildLen ? trClassname : "";
|
|
38
41
|
};
|
|
42
|
+
|
|
39
43
|
const itemProvider = (item: ConfigItemModal, lastItem?: ConfigItemModal) => {
|
|
40
44
|
const { children: lastChildren = [] } = lastItem || {};
|
|
45
|
+
|
|
41
46
|
const {
|
|
42
47
|
valueType = "",
|
|
43
48
|
valueTypeProps = {},
|
|
44
49
|
className = "",
|
|
45
50
|
children = [],
|
|
46
51
|
} = item;
|
|
52
|
+
|
|
47
53
|
const trClassName = bordered
|
|
48
54
|
? ""
|
|
49
55
|
: itemClassNameMk(children as any[], lastChildren as any[]);
|
|
50
56
|
const itemType = valueType as string;
|
|
57
|
+
|
|
51
58
|
if (textTypes.indexOf(itemType) !== -1) {
|
|
52
59
|
const { ellipsis } = valueTypeProps;
|
|
53
60
|
return {
|
|
@@ -57,12 +64,14 @@ export const useCols = ({
|
|
|
57
64
|
render: configRender(item, table as HTableInstance, valueTypeConfig),
|
|
58
65
|
};
|
|
59
66
|
}
|
|
67
|
+
|
|
60
68
|
return {
|
|
61
69
|
...item,
|
|
62
70
|
className: `${className} ${trClassName}`,
|
|
63
71
|
render: configRender(item, table as HTableInstance, valueTypeConfig),
|
|
64
72
|
};
|
|
65
73
|
};
|
|
74
|
+
|
|
66
75
|
const changeConfigData = (data: ConfigDataModal) => {
|
|
67
76
|
const colsArray = data.filter((item) => {
|
|
68
77
|
return !item.hideInTable;
|
|
@@ -72,7 +81,8 @@ export const useCols = ({
|
|
|
72
81
|
}
|
|
73
82
|
return colsArray.map((item, index) => {
|
|
74
83
|
const lastItem = colsArray[index - 1];
|
|
75
|
-
|
|
84
|
+
const resultItem = itemProvider(item, lastItem);
|
|
85
|
+
return configItemRender ? configItemRender(resultItem) : resultItem;
|
|
76
86
|
});
|
|
77
87
|
};
|
|
78
88
|
useEffect(() => {
|
|
@@ -45,10 +45,13 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
45
45
|
onChange: tableOnchange,
|
|
46
46
|
bordered,
|
|
47
47
|
rowClassName = "",
|
|
48
|
+
configItemRender,
|
|
48
49
|
...props
|
|
49
50
|
} = bodyProps;
|
|
51
|
+
|
|
50
52
|
const { selectedRowKeys, alwaysShowAlert: configAlwaysShowAlert } =
|
|
51
53
|
rowSelection || {};
|
|
54
|
+
|
|
52
55
|
const {
|
|
53
56
|
tableInstance: contextTableInstance,
|
|
54
57
|
configData: contextConfigData,
|
|
@@ -56,11 +59,19 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
56
59
|
selectedRowData,
|
|
57
60
|
error,
|
|
58
61
|
loading,
|
|
62
|
+
configItemRender: contextConfigItemRender = configItemRender,
|
|
59
63
|
} = useHTableContext();
|
|
64
|
+
|
|
60
65
|
const {
|
|
61
66
|
emptyRender: tableEmptyRender = emptyDefaultRender,
|
|
62
67
|
errorRender: tableErrorRender = errorDefaultRender,
|
|
63
|
-
|
|
68
|
+
configItemRender: tableConfigItemRender,
|
|
69
|
+
} = useHTableConfigContext({
|
|
70
|
+
emptyRender,
|
|
71
|
+
errorRender,
|
|
72
|
+
configItemRender: contextConfigItemRender,
|
|
73
|
+
});
|
|
74
|
+
|
|
64
75
|
const { cuSize, setCuSize } = useSize(size);
|
|
65
76
|
const bodyConfigData = configData || contextConfigData;
|
|
66
77
|
const { records } = data || {};
|
|
@@ -71,6 +82,7 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
71
82
|
table: tableInstance,
|
|
72
83
|
rowSelection,
|
|
73
84
|
bordered,
|
|
85
|
+
configItemRender: tableConfigItemRender,
|
|
74
86
|
});
|
|
75
87
|
const { value, onChange, resetCheckCol, ...selfColStatus } =
|
|
76
88
|
useColumnsStateType({
|
|
@@ -5,6 +5,7 @@ import type { ProTableProps } from "@ant-design/pro-table";
|
|
|
5
5
|
import {
|
|
6
6
|
ActionRenderFn,
|
|
7
7
|
ConfigDataModal,
|
|
8
|
+
ConfigItemModal,
|
|
8
9
|
EmptyPageRender,
|
|
9
10
|
ErrorPageRender,
|
|
10
11
|
HRowSelection,
|
|
@@ -38,6 +39,7 @@ export interface HTableBodyProps
|
|
|
38
39
|
options?: OptionModal | false;
|
|
39
40
|
table?: HTableInstance;
|
|
40
41
|
pagination?: IPaginationProps | false;
|
|
42
|
+
configItemRender?: (data: ConfigItemModal) => ConfigItemModal;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export interface RowRadioSelectionProps {
|
package/src/components/Table.tsx
CHANGED
|
@@ -2,16 +2,15 @@ import Header from "./HTableHeader";
|
|
|
2
2
|
import Body from "./HTableBody";
|
|
3
3
|
import useCurrentTable from "./hooks/useCurrentTable";
|
|
4
4
|
import useRowObj from "./hooks/useRowObj";
|
|
5
|
-
import { HTableContext } from "./context";
|
|
6
5
|
import type { HTableProps } from "./modal";
|
|
7
6
|
import useReq from "./hooks/useReq";
|
|
8
7
|
import useDispatch from "./hooks/useDispatch";
|
|
9
8
|
import { useState } from "react";
|
|
10
9
|
import { useClassName } from "./hooks";
|
|
10
|
+
import TableProvider from "./TableProvider";
|
|
11
11
|
|
|
12
12
|
export default ({
|
|
13
13
|
request,
|
|
14
|
-
configData,
|
|
15
14
|
searchSpan,
|
|
16
15
|
table,
|
|
17
16
|
hideHeader,
|
|
@@ -25,8 +24,6 @@ export default ({
|
|
|
25
24
|
onFinish,
|
|
26
25
|
manual,
|
|
27
26
|
formInitValues,
|
|
28
|
-
hideLabel,
|
|
29
|
-
labelWidth,
|
|
30
27
|
onReset,
|
|
31
28
|
style,
|
|
32
29
|
dataSource,
|
|
@@ -72,29 +69,25 @@ export default ({
|
|
|
72
69
|
});
|
|
73
70
|
const contentClassName = useClassName("hw-table-content");
|
|
74
71
|
return (
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
error: propsError || error,
|
|
82
|
-
loading: (propsLoading as boolean) || loading,
|
|
83
|
-
allSelectChange,
|
|
84
|
-
action,
|
|
85
|
-
configData,
|
|
86
|
-
onFinish: (value) => {
|
|
87
|
-
rowSelectionReload();
|
|
88
|
-
return run({ ...value, current: 1 });
|
|
89
|
-
},
|
|
90
|
-
onPageChange: tableInstance.table.reloadWithParams,
|
|
91
|
-
setSelectedRowData,
|
|
92
|
-
rowKey,
|
|
93
|
-
headerOpen: open,
|
|
94
|
-
setHeaderOpen: setOpen,
|
|
95
|
-
hideLabel,
|
|
96
|
-
labelWidth,
|
|
72
|
+
<TableProvider
|
|
73
|
+
{...props}
|
|
74
|
+
tableInstance={tableInstance}
|
|
75
|
+
onFinish={(value) => {
|
|
76
|
+
rowSelectionReload();
|
|
77
|
+
return run({ ...value, current: 1 });
|
|
97
78
|
}}
|
|
79
|
+
selectedRowData={selectedRowData}
|
|
80
|
+
rowOnChange={rowOnChange}
|
|
81
|
+
data={data}
|
|
82
|
+
error={propsError || error}
|
|
83
|
+
loading={(propsLoading as boolean) || loading}
|
|
84
|
+
allSelectChange={allSelectChange}
|
|
85
|
+
action={action}
|
|
86
|
+
setSelectedRowData={setSelectedRowData}
|
|
87
|
+
rowKey={rowKey}
|
|
88
|
+
headerOpen={open}
|
|
89
|
+
setHeaderOpen={setOpen}
|
|
90
|
+
rowSelection={rowSelection}
|
|
98
91
|
>
|
|
99
92
|
<div style={{ ...style }} className={`${contentClassName} ${className}`}>
|
|
100
93
|
{!hideHeader && (
|
|
@@ -116,6 +109,6 @@ export default ({
|
|
|
116
109
|
{...props}
|
|
117
110
|
/>
|
|
118
111
|
</div>
|
|
119
|
-
</
|
|
112
|
+
</TableProvider>
|
|
120
113
|
);
|
|
121
114
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import {
|
|
3
|
+
ConfigItemModal,
|
|
3
4
|
EmptyPageRender,
|
|
4
5
|
ErrorPageRender,
|
|
5
6
|
ValueTypeConfigModal,
|
|
@@ -13,6 +14,7 @@ interface HTableConfigContextModal {
|
|
|
13
14
|
paginationStyle?: React.CSSProperties;
|
|
14
15
|
valueTypeConfig?: ValueTypeConfigModal;
|
|
15
16
|
defaultSelectedRowClassName?: string | null;
|
|
17
|
+
configItemRender?: (data: ConfigItemModal) => ConfigItemModal;
|
|
16
18
|
}
|
|
17
19
|
export const HTableConfigContext =
|
|
18
20
|
React.createContext<HTableConfigContextModal | null>(null);
|
|
@@ -23,6 +25,7 @@ export const useHTableConfigContext = ({
|
|
|
23
25
|
headerStyle,
|
|
24
26
|
tableStyle,
|
|
25
27
|
paginationStyle,
|
|
28
|
+
configItemRender,
|
|
26
29
|
}: HTableConfigContextModal) => {
|
|
27
30
|
const {
|
|
28
31
|
errorRender: configErrorRender,
|
|
@@ -32,6 +35,7 @@ export const useHTableConfigContext = ({
|
|
|
32
35
|
paginationStyle: configPaginationStyle,
|
|
33
36
|
valueTypeConfig = {},
|
|
34
37
|
defaultSelectedRowClassName,
|
|
38
|
+
configItemRender: contextConfigItemRender,
|
|
35
39
|
} = useContext(HTableConfigContext) || {};
|
|
36
40
|
|
|
37
41
|
return {
|
|
@@ -42,6 +46,7 @@ export const useHTableConfigContext = ({
|
|
|
42
46
|
paginationStyle: paginationStyle || configPaginationStyle,
|
|
43
47
|
valueTypeConfig,
|
|
44
48
|
defaultSelectedRowClassName,
|
|
49
|
+
configItemRender: configItemRender || contextConfigItemRender,
|
|
45
50
|
};
|
|
46
51
|
};
|
|
47
52
|
const Index: React.FC<HTableConfigContextModal> = ({ children, ...props }) => {
|
|
@@ -15,6 +15,7 @@ const Index: React.FC<HTableProps> = ({
|
|
|
15
15
|
rowKey,
|
|
16
16
|
hideLabel,
|
|
17
17
|
labelWidth,
|
|
18
|
+
configItemRender,
|
|
18
19
|
...props
|
|
19
20
|
}) => {
|
|
20
21
|
const { run, loading, data, error, saveParams } = useReq({
|
|
@@ -68,6 +69,7 @@ const Index: React.FC<HTableProps> = ({
|
|
|
68
69
|
setHeaderOpen: setOpen,
|
|
69
70
|
hideLabel,
|
|
70
71
|
labelWidth,
|
|
72
|
+
configItemRender,
|
|
71
73
|
}}
|
|
72
74
|
>
|
|
73
75
|
{children}
|