@hw-component/table 0.0.9-beta-v2 → 0.0.9-beta-v6
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/HeaderTitle/index.d.ts +9 -0
- package/es/HTableBody/HeaderTitle/index.js +38 -0
- package/es/HTableBody/Options/index.js +0 -2
- package/es/HTableBody/Options/utils.d.ts +1 -1
- package/es/HTableBody/index.js +17 -18
- package/es/HTableHeader/hooks.d.ts +1 -1
- package/es/HTableHeader/hooks.js +15 -7
- package/es/HTableHeader/index.js +2 -1
- package/es/HTableHeader/modal.d.ts +2 -0
- package/es/index.css +12 -3
- package/es/modal.d.ts +2 -2
- package/lib/HTableBody/HeaderTitle/index.d.ts +9 -0
- package/lib/HTableBody/HeaderTitle/index.js +41 -0
- package/lib/HTableBody/Options/index.js +0 -2
- package/lib/HTableBody/Options/utils.d.ts +1 -1
- package/lib/HTableBody/index.js +18 -19
- package/lib/HTableHeader/hooks.d.ts +1 -1
- package/lib/HTableHeader/hooks.js +15 -7
- package/lib/HTableHeader/index.js +2 -1
- package/lib/HTableHeader/modal.d.ts +2 -0
- package/lib/index.css +12 -3
- package/lib/modal.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/HTableBody/HeaderTitle/index.tsx +31 -0
- package/src/components/HTableBody/Options/index.tsx +1 -2
- package/src/components/HTableBody/index.tsx +9 -12
- package/src/components/HTableHeader/hooks.tsx +13 -6
- package/src/components/HTableHeader/index.tsx +1 -0
- package/src/components/HTableHeader/modal.ts +3 -1
- package/src/components/Table.tsx +2 -2
- package/src/components/index.less +6 -4
- package/src/components/modal.ts +2 -2
- package/src/pages/ModalTable/index.tsx +1 -1
- package/src/pages/Table/index.tsx +7 -15
- package/src/pages/TableCustomize/index.tsx +1 -1
package/es/HTableBody/index.js
CHANGED
|
@@ -14,13 +14,13 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
14
14
|
import ProTable from '@ant-design/pro-table';
|
|
15
15
|
import { useSize, useCols, useSynchronousKeys } from './hooks.js';
|
|
16
16
|
import { useHTableContext } from '../context.js';
|
|
17
|
-
import
|
|
18
|
-
import { Row, Alert, ConfigProvider, Empty } from 'antd';
|
|
17
|
+
import { Alert, ConfigProvider, Empty } from 'antd';
|
|
19
18
|
import { useHTableConfigContext } from '../TableConfig.js';
|
|
20
19
|
import HTablePagination from '../HTablePagination/index.js';
|
|
21
20
|
import { useClassName } from '../hooks/index.js';
|
|
22
21
|
import AlertMsg from './AlertMsg.js';
|
|
23
22
|
import Options from './Options/index.js';
|
|
23
|
+
import HeaderTitle from './HeaderTitle/index.js';
|
|
24
24
|
|
|
25
25
|
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender"];
|
|
26
26
|
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; }
|
|
@@ -64,11 +64,11 @@ var Body = (function (_ref) {
|
|
|
64
64
|
tableInstance = _useHTableContext.tableInstance,
|
|
65
65
|
contextConfigData = _useHTableContext.configData,
|
|
66
66
|
data = _useHTableContext.data,
|
|
67
|
-
selectedRowData = _useHTableContext.selectedRowData
|
|
68
|
-
|
|
69
|
-
error = _useHTableContext.error,
|
|
70
|
-
loading = _useHTableContext.loading
|
|
71
|
-
|
|
67
|
+
selectedRowData = _useHTableContext.selectedRowData;
|
|
68
|
+
_useHTableContext.rowOnChange;
|
|
69
|
+
var error = _useHTableContext.error,
|
|
70
|
+
loading = _useHTableContext.loading;
|
|
71
|
+
_useHTableContext.allSelectChange;
|
|
72
72
|
var _useHTableConfigConte = useHTableConfigContext({
|
|
73
73
|
emptyRender: emptyRender,
|
|
74
74
|
errorRender: errorRender
|
|
@@ -108,21 +108,13 @@ var Body = (function (_ref) {
|
|
|
108
108
|
var _selectedRowData$keys = _keysInstanceProperty(selectedRowData),
|
|
109
109
|
keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys,
|
|
110
110
|
selectAll = selectedRowData.selectAll;
|
|
111
|
+
var defaultOptionsNode = optionsRender ? optionsRender(optionsNode) : optionsNode;
|
|
111
112
|
var alwaysShowAlert = keys.length > 0 || selectAll || configAlwaysShowAlert;
|
|
112
113
|
var className = useClassName("hw-table-body");
|
|
113
114
|
return jsxs("div", {
|
|
114
115
|
style: tableStyle,
|
|
115
116
|
className: "hw_table_body ".concat(className),
|
|
116
|
-
children: [
|
|
117
|
-
gutter: [0, 8],
|
|
118
|
-
style: contentStyle,
|
|
119
|
-
children: /*#__PURE__*/React.cloneElement(headerTitle, {
|
|
120
|
-
selectedRowData: selectedRowData,
|
|
121
|
-
allSelectChange: allSelectChange,
|
|
122
|
-
rowOnChange: rowOnChange,
|
|
123
|
-
tableInstance: tableInstance
|
|
124
|
-
})
|
|
125
|
-
}), alwaysShowAlert && jsx("div", {
|
|
117
|
+
children: [alwaysShowAlert && jsx("div", {
|
|
126
118
|
style: contentStyle,
|
|
127
119
|
children: jsx(Alert, {
|
|
128
120
|
message: jsx(AlertMsg, {
|
|
@@ -130,7 +122,11 @@ var Body = (function (_ref) {
|
|
|
130
122
|
}),
|
|
131
123
|
type: "info"
|
|
132
124
|
})
|
|
133
|
-
}),
|
|
125
|
+
}), jsx(HeaderTitle, {
|
|
126
|
+
headerTitle: headerTitle,
|
|
127
|
+
contentStyle: contentStyle,
|
|
128
|
+
rNode: defaultOptionsNode
|
|
129
|
+
}), jsxs(ConfigProvider, {
|
|
134
130
|
renderEmpty: function renderEmpty() {
|
|
135
131
|
if (error) {
|
|
136
132
|
return tableErrorRender === null || tableErrorRender === void 0 ? void 0 : tableErrorRender(tableInstance, error);
|
|
@@ -141,6 +137,9 @@ var Body = (function (_ref) {
|
|
|
141
137
|
columns: cols,
|
|
142
138
|
size: cuSize,
|
|
143
139
|
search: false,
|
|
140
|
+
onChange: function onChange(pagination, filters, sorter) {
|
|
141
|
+
console.log(filters, sorter);
|
|
142
|
+
},
|
|
144
143
|
options: false,
|
|
145
144
|
tableStyle: {
|
|
146
145
|
paddingBottom: 0
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IHeaderProps } from "./modal";
|
|
2
2
|
import type { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
3
|
-
export declare const useHideMoreTitle: ({ searchSpan, configData }: IHeaderProps) => HItemProps[];
|
|
3
|
+
export declare const useHideMoreTitle: ({ searchSpan, configData, table }: IHeaderProps) => HItemProps[];
|
package/es/HTableHeader/hooks.js
CHANGED
|
@@ -83,7 +83,7 @@ var getCuSpanMaxNum = function getCuSpanMaxNum() {
|
|
|
83
83
|
var cuSpan = searchSpan[cuKey] || searchSpan.span;
|
|
84
84
|
return 24 / cuSpan;
|
|
85
85
|
};
|
|
86
|
-
var formConfigDataItemProvider = function formConfigDataItemProvider(_ref) {
|
|
86
|
+
var formConfigDataItemProvider = function formConfigDataItemProvider(_ref, table) {
|
|
87
87
|
var _ref$colon = _ref.colon,
|
|
88
88
|
colon = _ref$colon === void 0 ? false : _ref$colon,
|
|
89
89
|
searchType = _ref.searchType,
|
|
@@ -108,12 +108,18 @@ var formConfigDataItemProvider = function formConfigDataItemProvider(_ref) {
|
|
|
108
108
|
colon: colon,
|
|
109
109
|
type: searchType,
|
|
110
110
|
name: name || dataIndex,
|
|
111
|
-
render:
|
|
111
|
+
render: function render(item, node, form) {
|
|
112
|
+
if (searchRender) {
|
|
113
|
+
return searchRender(item, node, form, table);
|
|
114
|
+
}
|
|
115
|
+
return node;
|
|
116
|
+
}
|
|
112
117
|
});
|
|
113
118
|
};
|
|
114
119
|
var mkNewConfig = function mkNewConfig(_ref2) {
|
|
115
120
|
var _ref2$configData = _ref2.configData,
|
|
116
|
-
configData = _ref2$configData === void 0 ? [] : _ref2$configData
|
|
121
|
+
configData = _ref2$configData === void 0 ? [] : _ref2$configData,
|
|
122
|
+
table = _ref2.table;
|
|
117
123
|
var subConfigData;
|
|
118
124
|
var realConfigData = [];
|
|
119
125
|
_forEachInstanceProperty(configData).call(configData, function (value) {
|
|
@@ -123,10 +129,10 @@ var mkNewConfig = function mkNewConfig(_ref2) {
|
|
|
123
129
|
return false;
|
|
124
130
|
}
|
|
125
131
|
if (searchType === "submit") {
|
|
126
|
-
subConfigData = formConfigDataItemProvider(value);
|
|
132
|
+
subConfigData = formConfigDataItemProvider(value, table);
|
|
127
133
|
return false;
|
|
128
134
|
}
|
|
129
|
-
realConfigData.push(formConfigDataItemProvider(value));
|
|
135
|
+
realConfigData.push(formConfigDataItemProvider(value, table));
|
|
130
136
|
});
|
|
131
137
|
return {
|
|
132
138
|
realConfigData: realConfigData,
|
|
@@ -159,7 +165,8 @@ var filterHideFormItem = function filterHideFormItem(configData, className, sear
|
|
|
159
165
|
var useHideMoreTitle = function useHideMoreTitle(_ref3) {
|
|
160
166
|
var _context2;
|
|
161
167
|
var searchSpan = _ref3.searchSpan,
|
|
162
|
-
configData = _ref3.configData
|
|
168
|
+
configData = _ref3.configData,
|
|
169
|
+
table = _ref3.table;
|
|
163
170
|
var _useState = useState([]),
|
|
164
171
|
_useState2 = _slicedToArray(_useState, 2),
|
|
165
172
|
formConfigData = _useState2[0],
|
|
@@ -176,7 +183,8 @@ var useHideMoreTitle = function useHideMoreTitle(_ref3) {
|
|
|
176
183
|
var _context;
|
|
177
184
|
var _mkNewConfig = mkNewConfig({
|
|
178
185
|
searchSpan: searchSpan,
|
|
179
|
-
configData: configData
|
|
186
|
+
configData: configData,
|
|
187
|
+
table: table
|
|
180
188
|
}),
|
|
181
189
|
realConfigData = _mkNewConfig.realConfigData,
|
|
182
190
|
subConfigData = _mkNewConfig.subConfigData;
|
package/es/HTableHeader/index.js
CHANGED
|
@@ -40,7 +40,8 @@ var Header = (function (_ref) {
|
|
|
40
40
|
var subOnFinish = onFinish || contextOnFinish;
|
|
41
41
|
var nConfigData = useHideMoreTitle({
|
|
42
42
|
searchSpan: searchSpan,
|
|
43
|
-
configData: headerConfigData
|
|
43
|
+
configData: headerConfigData,
|
|
44
|
+
table: tableInstance
|
|
44
45
|
});
|
|
45
46
|
var className = useClassName("hw-table-header");
|
|
46
47
|
return jsx(Card, {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { ConfigDataModal, ConfigItemModal } from "../modal";
|
|
2
2
|
import type { ColProps } from "antd";
|
|
3
3
|
import type React from "react";
|
|
4
|
+
import { HTableInstance } from "../modal";
|
|
4
5
|
export interface IHeaderProps {
|
|
5
6
|
configData?: ConfigDataModal;
|
|
6
7
|
onFinish?: (value: Record<string, any>) => Promise<any>;
|
|
7
8
|
searchSpan?: ColProps;
|
|
8
9
|
loading?: boolean;
|
|
9
10
|
headerStyle?: React.CSSProperties;
|
|
11
|
+
table?: HTableInstance;
|
|
10
12
|
}
|
|
11
13
|
export interface FormConfigDataItemProviderModal extends ConfigItemModal {
|
|
12
14
|
className?: string;
|
package/es/index.css
CHANGED
|
@@ -41,9 +41,6 @@
|
|
|
41
41
|
.ant-hw-table-header .ant-hw-table-header-item-hide {
|
|
42
42
|
display: none;
|
|
43
43
|
}
|
|
44
|
-
.ant-hw-table-body-option {
|
|
45
|
-
padding: 0px 24px 16px 24px;
|
|
46
|
-
}
|
|
47
44
|
.ant-hw-table-body-option-icon {
|
|
48
45
|
font-size: 16px;
|
|
49
46
|
}
|
|
@@ -84,3 +81,15 @@
|
|
|
84
81
|
.ant-hw-table-pointer:hover {
|
|
85
82
|
color: #1890ff;
|
|
86
83
|
}
|
|
84
|
+
.ant-hw-table-header-title-box {
|
|
85
|
+
-webkit-box-flex: 1;
|
|
86
|
+
-webkit-flex: 1;
|
|
87
|
+
-ms-flex: 1;
|
|
88
|
+
flex: 1;
|
|
89
|
+
display: -webkit-box;
|
|
90
|
+
display: -webkit-flex;
|
|
91
|
+
display: -ms-flexbox;
|
|
92
|
+
display: flex;
|
|
93
|
+
position: relative;
|
|
94
|
+
margin-right: 12px;
|
|
95
|
+
}
|
package/es/modal.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProColumns } from "@ant-design/pro-table/lib/typing";
|
|
2
2
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
3
3
|
import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal";
|
|
4
|
-
import type { ColProps } from "antd";
|
|
4
|
+
import type { ColProps, FormInstance } from "antd";
|
|
5
5
|
import type React from "react";
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
7
|
import type { TableProps } from "antd/lib/table";
|
|
@@ -25,7 +25,7 @@ interface HColumns extends Omit<ProColumns, "render" | "title"> {
|
|
|
25
25
|
render?: (dom: React.ReactNode, data: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
|
|
26
26
|
showSearch?: boolean;
|
|
27
27
|
searchType?: HItemProps["type"];
|
|
28
|
-
searchRender?: HItemProps
|
|
28
|
+
searchRender?: (item: HItemProps, node: React.ReactNode, form: FormInstance, tableInstance: HTableInstance) => React.ReactNode;
|
|
29
29
|
rowSelectionTitle?: boolean;
|
|
30
30
|
title?: string | React.ReactNode;
|
|
31
31
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTableBodyProps } from "../index";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface IProps {
|
|
4
|
+
headerTitle: HTableBodyProps["headerTitle"];
|
|
5
|
+
contentStyle?: React.CSSProperties;
|
|
6
|
+
rNode?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: ({ headerTitle, contentStyle, rNode }: IProps) => JSX.Element | null;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var antd = require('antd');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var context = require('../../context.js');
|
|
9
|
+
var index = require('../../hooks/index.js');
|
|
10
|
+
|
|
11
|
+
var HeaderTitle = (function (_ref) {
|
|
12
|
+
var headerTitle = _ref.headerTitle,
|
|
13
|
+
contentStyle = _ref.contentStyle,
|
|
14
|
+
rNode = _ref.rNode;
|
|
15
|
+
var _useHTableContext = context.useHTableContext(),
|
|
16
|
+
tableInstance = _useHTableContext.tableInstance,
|
|
17
|
+
selectedRowData = _useHTableContext.selectedRowData,
|
|
18
|
+
rowOnChange = _useHTableContext.rowOnChange,
|
|
19
|
+
allSelectChange = _useHTableContext.allSelectChange;
|
|
20
|
+
var headerBox = index.useClassName('hw-table-header-title-box');
|
|
21
|
+
if (!headerTitle && !rNode) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return jsxRuntime.jsxs(antd.Row, {
|
|
25
|
+
justify: "space-between",
|
|
26
|
+
align: "middle",
|
|
27
|
+
style: contentStyle,
|
|
28
|
+
children: [jsxRuntime.jsx("div", {
|
|
29
|
+
className: headerBox,
|
|
30
|
+
children: headerTitle && /*#__PURE__*/React.cloneElement(headerTitle, {
|
|
31
|
+
selectedRowData: selectedRowData,
|
|
32
|
+
allSelectChange: allSelectChange,
|
|
33
|
+
rowOnChange: rowOnChange,
|
|
34
|
+
tableInstance: tableInstance
|
|
35
|
+
})
|
|
36
|
+
}), rNode && rNode]
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
exports.default = HeaderTitle;
|
|
41
|
+
// powered by h
|
|
@@ -23,7 +23,6 @@ var Options = (function (_ref) {
|
|
|
23
23
|
setSizeChange = _ref.setSizeChange,
|
|
24
24
|
columns = _ref.columns,
|
|
25
25
|
onChange = _ref.onChange;
|
|
26
|
-
var className = index.useClassName("hw-table-body-option");
|
|
27
26
|
var pointer = index.useClassName(["hw-table-pointer", "hw-table-body-option-icon"]);
|
|
28
27
|
var ref = React.useRef(null);
|
|
29
28
|
var _useState = React.useState([]),
|
|
@@ -72,7 +71,6 @@ var Options = (function (_ref) {
|
|
|
72
71
|
};
|
|
73
72
|
return jsxRuntime.jsx(antd.Row, {
|
|
74
73
|
justify: "end",
|
|
75
|
-
className: className,
|
|
76
74
|
ref: ref,
|
|
77
75
|
children: jsxRuntime.jsxs(antd.Space, {
|
|
78
76
|
size: 20,
|
|
@@ -55,7 +55,7 @@ export declare const getItemValue: (data: ConfigItemModal) => {
|
|
|
55
55
|
render?: ((dom: React.ReactNode, data: any, index: number, tableInstance: import("../../modal").HTableInstance) => React.ReactNode) | undefined;
|
|
56
56
|
showSearch?: boolean | undefined;
|
|
57
57
|
searchType?: string | undefined;
|
|
58
|
-
searchRender?: ((
|
|
58
|
+
searchRender?: ((item: import("@hw-component/form/es/Form/modal").HItemProps, node: React.ReactNode, form: import("antd").FormInstance<any>, tableInstance: import("../../modal").HTableInstance) => React.ReactNode) | undefined;
|
|
59
59
|
rowSelectionTitle?: boolean | undefined;
|
|
60
60
|
index?: number | undefined;
|
|
61
61
|
filters?: boolean | import("antd/lib/table/interface").ColumnFilterItem[] | undefined;
|
package/lib/HTableBody/index.js
CHANGED
|
@@ -17,13 +17,13 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
17
17
|
var ProTable = require('@ant-design/pro-table');
|
|
18
18
|
var hooks = require('./hooks.js');
|
|
19
19
|
var context = require('../context.js');
|
|
20
|
-
var React = require('react');
|
|
21
20
|
var antd = require('antd');
|
|
22
21
|
var TableConfig = require('../TableConfig.js');
|
|
23
|
-
var index$
|
|
22
|
+
var index$3 = require('../HTablePagination/index.js');
|
|
24
23
|
var index$1 = require('../hooks/index.js');
|
|
25
24
|
var AlertMsg = require('./AlertMsg.js');
|
|
26
25
|
var index = require('./Options/index.js');
|
|
26
|
+
var index$2 = require('./HeaderTitle/index.js');
|
|
27
27
|
|
|
28
28
|
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender"];
|
|
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; }
|
|
@@ -67,11 +67,11 @@ var Body = (function (_ref) {
|
|
|
67
67
|
tableInstance = _useHTableContext.tableInstance,
|
|
68
68
|
contextConfigData = _useHTableContext.configData,
|
|
69
69
|
data = _useHTableContext.data,
|
|
70
|
-
selectedRowData = _useHTableContext.selectedRowData
|
|
71
|
-
|
|
72
|
-
error = _useHTableContext.error,
|
|
73
|
-
loading = _useHTableContext.loading
|
|
74
|
-
|
|
70
|
+
selectedRowData = _useHTableContext.selectedRowData;
|
|
71
|
+
_useHTableContext.rowOnChange;
|
|
72
|
+
var error = _useHTableContext.error,
|
|
73
|
+
loading = _useHTableContext.loading;
|
|
74
|
+
_useHTableContext.allSelectChange;
|
|
75
75
|
var _useHTableConfigConte = TableConfig.useHTableConfigContext({
|
|
76
76
|
emptyRender: emptyRender,
|
|
77
77
|
errorRender: errorRender
|
|
@@ -111,21 +111,13 @@ var Body = (function (_ref) {
|
|
|
111
111
|
var _selectedRowData$keys = _keysInstanceProperty(selectedRowData),
|
|
112
112
|
keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys,
|
|
113
113
|
selectAll = selectedRowData.selectAll;
|
|
114
|
+
var defaultOptionsNode = optionsRender ? optionsRender(optionsNode) : optionsNode;
|
|
114
115
|
var alwaysShowAlert = keys.length > 0 || selectAll || configAlwaysShowAlert;
|
|
115
116
|
var className = index$1.useClassName("hw-table-body");
|
|
116
117
|
return jsxRuntime.jsxs("div", {
|
|
117
118
|
style: tableStyle,
|
|
118
119
|
className: "hw_table_body ".concat(className),
|
|
119
|
-
children: [
|
|
120
|
-
gutter: [0, 8],
|
|
121
|
-
style: contentStyle,
|
|
122
|
-
children: /*#__PURE__*/React.cloneElement(headerTitle, {
|
|
123
|
-
selectedRowData: selectedRowData,
|
|
124
|
-
allSelectChange: allSelectChange,
|
|
125
|
-
rowOnChange: rowOnChange,
|
|
126
|
-
tableInstance: tableInstance
|
|
127
|
-
})
|
|
128
|
-
}), alwaysShowAlert && jsxRuntime.jsx("div", {
|
|
120
|
+
children: [alwaysShowAlert && jsxRuntime.jsx("div", {
|
|
129
121
|
style: contentStyle,
|
|
130
122
|
children: jsxRuntime.jsx(antd.Alert, {
|
|
131
123
|
message: jsxRuntime.jsx(AlertMsg.default, {
|
|
@@ -133,7 +125,11 @@ var Body = (function (_ref) {
|
|
|
133
125
|
}),
|
|
134
126
|
type: "info"
|
|
135
127
|
})
|
|
136
|
-
}),
|
|
128
|
+
}), jsxRuntime.jsx(index$2.default, {
|
|
129
|
+
headerTitle: headerTitle,
|
|
130
|
+
contentStyle: contentStyle,
|
|
131
|
+
rNode: defaultOptionsNode
|
|
132
|
+
}), jsxRuntime.jsxs(antd.ConfigProvider, {
|
|
137
133
|
renderEmpty: function renderEmpty() {
|
|
138
134
|
if (error) {
|
|
139
135
|
return tableErrorRender === null || tableErrorRender === void 0 ? void 0 : tableErrorRender(tableInstance, error);
|
|
@@ -144,6 +140,9 @@ var Body = (function (_ref) {
|
|
|
144
140
|
columns: cols,
|
|
145
141
|
size: cuSize,
|
|
146
142
|
search: false,
|
|
143
|
+
onChange: function onChange(pagination, filters, sorter) {
|
|
144
|
+
console.log(filters, sorter);
|
|
145
|
+
},
|
|
147
146
|
options: false,
|
|
148
147
|
tableStyle: {
|
|
149
148
|
paddingBottom: 0
|
|
@@ -153,7 +152,7 @@ var Body = (function (_ref) {
|
|
|
153
152
|
rowKey: rowKey,
|
|
154
153
|
dataSource: records,
|
|
155
154
|
pagination: false
|
|
156
|
-
})), pagination !== false && jsxRuntime.jsx(index$
|
|
155
|
+
})), pagination !== false && jsxRuntime.jsx(index$3.default, _objectSpread({
|
|
157
156
|
onPageChange: onPageChange,
|
|
158
157
|
paginationStyle: paginationStyle,
|
|
159
158
|
affixProps: affixProps,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IHeaderProps } from "./modal";
|
|
2
2
|
import type { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
3
|
-
export declare const useHideMoreTitle: ({ searchSpan, configData }: IHeaderProps) => HItemProps[];
|
|
3
|
+
export declare const useHideMoreTitle: ({ searchSpan, configData, table }: IHeaderProps) => HItemProps[];
|
|
@@ -84,7 +84,7 @@ var getCuSpanMaxNum = function getCuSpanMaxNum() {
|
|
|
84
84
|
var cuSpan = searchSpan[cuKey] || searchSpan.span;
|
|
85
85
|
return 24 / cuSpan;
|
|
86
86
|
};
|
|
87
|
-
var formConfigDataItemProvider = function formConfigDataItemProvider(_ref) {
|
|
87
|
+
var formConfigDataItemProvider = function formConfigDataItemProvider(_ref, table) {
|
|
88
88
|
var _ref$colon = _ref.colon,
|
|
89
89
|
colon = _ref$colon === void 0 ? false : _ref$colon,
|
|
90
90
|
searchType = _ref.searchType,
|
|
@@ -109,12 +109,18 @@ var formConfigDataItemProvider = function formConfigDataItemProvider(_ref) {
|
|
|
109
109
|
colon: colon,
|
|
110
110
|
type: searchType,
|
|
111
111
|
name: name || dataIndex,
|
|
112
|
-
render:
|
|
112
|
+
render: function render(item, node, form) {
|
|
113
|
+
if (searchRender) {
|
|
114
|
+
return searchRender(item, node, form, table);
|
|
115
|
+
}
|
|
116
|
+
return node;
|
|
117
|
+
}
|
|
113
118
|
});
|
|
114
119
|
};
|
|
115
120
|
var mkNewConfig = function mkNewConfig(_ref2) {
|
|
116
121
|
var _ref2$configData = _ref2.configData,
|
|
117
|
-
configData = _ref2$configData === void 0 ? [] : _ref2$configData
|
|
122
|
+
configData = _ref2$configData === void 0 ? [] : _ref2$configData,
|
|
123
|
+
table = _ref2.table;
|
|
118
124
|
var subConfigData;
|
|
119
125
|
var realConfigData = [];
|
|
120
126
|
_forEachInstanceProperty(configData).call(configData, function (value) {
|
|
@@ -124,10 +130,10 @@ var mkNewConfig = function mkNewConfig(_ref2) {
|
|
|
124
130
|
return false;
|
|
125
131
|
}
|
|
126
132
|
if (searchType === "submit") {
|
|
127
|
-
subConfigData = formConfigDataItemProvider(value);
|
|
133
|
+
subConfigData = formConfigDataItemProvider(value, table);
|
|
128
134
|
return false;
|
|
129
135
|
}
|
|
130
|
-
realConfigData.push(formConfigDataItemProvider(value));
|
|
136
|
+
realConfigData.push(formConfigDataItemProvider(value, table));
|
|
131
137
|
});
|
|
132
138
|
return {
|
|
133
139
|
realConfigData: realConfigData,
|
|
@@ -160,7 +166,8 @@ var filterHideFormItem = function filterHideFormItem(configData, className, sear
|
|
|
160
166
|
var useHideMoreTitle = function useHideMoreTitle(_ref3) {
|
|
161
167
|
var _context2;
|
|
162
168
|
var searchSpan = _ref3.searchSpan,
|
|
163
|
-
configData = _ref3.configData
|
|
169
|
+
configData = _ref3.configData,
|
|
170
|
+
table = _ref3.table;
|
|
164
171
|
var _useState = React.useState([]),
|
|
165
172
|
_useState2 = _slicedToArray(_useState, 2),
|
|
166
173
|
formConfigData = _useState2[0],
|
|
@@ -177,7 +184,8 @@ var useHideMoreTitle = function useHideMoreTitle(_ref3) {
|
|
|
177
184
|
var _context;
|
|
178
185
|
var _mkNewConfig = mkNewConfig({
|
|
179
186
|
searchSpan: searchSpan,
|
|
180
|
-
configData: configData
|
|
187
|
+
configData: configData,
|
|
188
|
+
table: table
|
|
181
189
|
}),
|
|
182
190
|
realConfigData = _mkNewConfig.realConfigData,
|
|
183
191
|
subConfigData = _mkNewConfig.subConfigData;
|
|
@@ -43,7 +43,8 @@ var Header = (function (_ref) {
|
|
|
43
43
|
var subOnFinish = onFinish || contextOnFinish;
|
|
44
44
|
var nConfigData = hooks.useHideMoreTitle({
|
|
45
45
|
searchSpan: searchSpan,
|
|
46
|
-
configData: headerConfigData
|
|
46
|
+
configData: headerConfigData,
|
|
47
|
+
table: tableInstance
|
|
47
48
|
});
|
|
48
49
|
var className = index.useClassName("hw-table-header");
|
|
49
50
|
return jsxRuntime.jsx(antd.Card, {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { ConfigDataModal, ConfigItemModal } from "../modal";
|
|
2
2
|
import type { ColProps } from "antd";
|
|
3
3
|
import type React from "react";
|
|
4
|
+
import { HTableInstance } from "../modal";
|
|
4
5
|
export interface IHeaderProps {
|
|
5
6
|
configData?: ConfigDataModal;
|
|
6
7
|
onFinish?: (value: Record<string, any>) => Promise<any>;
|
|
7
8
|
searchSpan?: ColProps;
|
|
8
9
|
loading?: boolean;
|
|
9
10
|
headerStyle?: React.CSSProperties;
|
|
11
|
+
table?: HTableInstance;
|
|
10
12
|
}
|
|
11
13
|
export interface FormConfigDataItemProviderModal extends ConfigItemModal {
|
|
12
14
|
className?: string;
|
package/lib/index.css
CHANGED
|
@@ -41,9 +41,6 @@
|
|
|
41
41
|
.ant-hw-table-header .ant-hw-table-header-item-hide {
|
|
42
42
|
display: none;
|
|
43
43
|
}
|
|
44
|
-
.ant-hw-table-body-option {
|
|
45
|
-
padding: 0px 24px 16px 24px;
|
|
46
|
-
}
|
|
47
44
|
.ant-hw-table-body-option-icon {
|
|
48
45
|
font-size: 16px;
|
|
49
46
|
}
|
|
@@ -84,3 +81,15 @@
|
|
|
84
81
|
.ant-hw-table-pointer:hover {
|
|
85
82
|
color: #1890ff;
|
|
86
83
|
}
|
|
84
|
+
.ant-hw-table-header-title-box {
|
|
85
|
+
-webkit-box-flex: 1;
|
|
86
|
+
-webkit-flex: 1;
|
|
87
|
+
-ms-flex: 1;
|
|
88
|
+
flex: 1;
|
|
89
|
+
display: -webkit-box;
|
|
90
|
+
display: -webkit-flex;
|
|
91
|
+
display: -ms-flexbox;
|
|
92
|
+
display: flex;
|
|
93
|
+
position: relative;
|
|
94
|
+
margin-right: 12px;
|
|
95
|
+
}
|
package/lib/modal.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProColumns } from "@ant-design/pro-table/lib/typing";
|
|
2
2
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
3
3
|
import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal";
|
|
4
|
-
import type { ColProps } from "antd";
|
|
4
|
+
import type { ColProps, FormInstance } from "antd";
|
|
5
5
|
import type React from "react";
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
7
|
import type { TableProps } from "antd/lib/table";
|
|
@@ -25,7 +25,7 @@ interface HColumns extends Omit<ProColumns, "render" | "title"> {
|
|
|
25
25
|
render?: (dom: React.ReactNode, data: any, index: number, tableInstance: HTableInstance) => React.ReactNode;
|
|
26
26
|
showSearch?: boolean;
|
|
27
27
|
searchType?: HItemProps["type"];
|
|
28
|
-
searchRender?: HItemProps
|
|
28
|
+
searchRender?: (item: HItemProps, node: React.ReactNode, form: FormInstance, tableInstance: HTableInstance) => React.ReactNode;
|
|
29
29
|
rowSelectionTitle?: boolean;
|
|
30
30
|
title?: string | React.ReactNode;
|
|
31
31
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {Row, Space} from "antd";
|
|
2
|
+
import {HTableBodyProps} from "../index";
|
|
3
|
+
import React, {DetailedReactHTMLElement} from "react";
|
|
4
|
+
import { useHTableContext } from "../../context";
|
|
5
|
+
import {useClassName} from "../../hooks";
|
|
6
|
+
interface IProps {
|
|
7
|
+
headerTitle:HTableBodyProps["headerTitle"];
|
|
8
|
+
contentStyle?:React.CSSProperties;
|
|
9
|
+
rNode?:React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export default ({headerTitle,contentStyle,rNode}:IProps)=>{
|
|
12
|
+
const {
|
|
13
|
+
tableInstance,
|
|
14
|
+
selectedRowData,
|
|
15
|
+
rowOnChange,
|
|
16
|
+
allSelectChange,
|
|
17
|
+
} = useHTableContext();
|
|
18
|
+
const headerBox=useClassName('hw-table-header-title-box');
|
|
19
|
+
if (!headerTitle&&!rNode){
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
return <Row justify={"space-between"} align={"middle"} style={contentStyle}>
|
|
23
|
+
<div className={headerBox}>
|
|
24
|
+
{headerTitle && React.cloneElement(
|
|
25
|
+
headerTitle as DetailedReactHTMLElement<any, any>,
|
|
26
|
+
{ selectedRowData, allSelectChange, rowOnChange, tableInstance }
|
|
27
|
+
)}
|
|
28
|
+
</div>
|
|
29
|
+
{rNode&&rNode}
|
|
30
|
+
</Row>
|
|
31
|
+
}
|
|
@@ -20,7 +20,6 @@ export default ({
|
|
|
20
20
|
columns,
|
|
21
21
|
onChange,
|
|
22
22
|
}: IProps) => {
|
|
23
|
-
const className = useClassName("hw-table-body-option");
|
|
24
23
|
const pointer = useClassName([
|
|
25
24
|
"hw-table-pointer",
|
|
26
25
|
"hw-table-body-option-icon",
|
|
@@ -59,7 +58,7 @@ export default ({
|
|
|
59
58
|
);
|
|
60
59
|
};
|
|
61
60
|
return (
|
|
62
|
-
<Row justify={"end"}
|
|
61
|
+
<Row justify={"end"} ref={ref}>
|
|
63
62
|
<Space size={20}>
|
|
64
63
|
{reload && (
|
|
65
64
|
<Tooltip title="刷新">
|
|
@@ -14,6 +14,7 @@ import AlertMsg from "./AlertMsg";
|
|
|
14
14
|
import type { HRowSelection } from "../modal";
|
|
15
15
|
import type { AffixProps } from "antd/lib/affix";
|
|
16
16
|
import Options from "./Options";
|
|
17
|
+
import HeaderTitle from './HeaderTitle';
|
|
17
18
|
export interface HTableBodyProps
|
|
18
19
|
extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
|
|
19
20
|
configData?: ConfigDataModal;
|
|
@@ -59,7 +60,8 @@ export default ({
|
|
|
59
60
|
...props
|
|
60
61
|
}: HTableBodyProps) => {
|
|
61
62
|
// @ts-ignore
|
|
62
|
-
const { selectedRowKeys
|
|
63
|
+
const { selectedRowKeys, alwaysShowAlert: configAlwaysShowAlert } =
|
|
64
|
+
rowSelection || {};
|
|
63
65
|
const {
|
|
64
66
|
tableInstance,
|
|
65
67
|
configData: contextConfigData,
|
|
@@ -96,19 +98,11 @@ export default ({
|
|
|
96
98
|
/>
|
|
97
99
|
);
|
|
98
100
|
const { keys = [], selectAll } = selectedRowData;
|
|
99
|
-
|
|
100
|
-
const alwaysShowAlert = keys.length > 0 || selectAll||configAlwaysShowAlert;
|
|
101
|
+
const defaultOptionsNode=optionsRender ? optionsRender(optionsNode) : optionsNode;
|
|
102
|
+
const alwaysShowAlert = keys.length > 0 || selectAll || configAlwaysShowAlert;
|
|
101
103
|
const className = useClassName("hw-table-body");
|
|
102
104
|
return (
|
|
103
105
|
<div style={tableStyle} className={`hw_table_body ${className}`}>
|
|
104
|
-
{headerTitle && (
|
|
105
|
-
<Row gutter={[0, 8]} style={contentStyle}>
|
|
106
|
-
{React.cloneElement(
|
|
107
|
-
headerTitle as DetailedReactHTMLElement<any, any>,
|
|
108
|
-
{ selectedRowData, allSelectChange, rowOnChange, tableInstance }
|
|
109
|
-
)}
|
|
110
|
-
</Row>
|
|
111
|
-
)}
|
|
112
106
|
{alwaysShowAlert && (
|
|
113
107
|
<div style={contentStyle}>
|
|
114
108
|
<Alert
|
|
@@ -117,7 +111,7 @@ export default ({
|
|
|
117
111
|
/>
|
|
118
112
|
</div>
|
|
119
113
|
)}
|
|
120
|
-
{
|
|
114
|
+
<HeaderTitle headerTitle={headerTitle} contentStyle={contentStyle} rNode={defaultOptionsNode}/>
|
|
121
115
|
<ConfigProvider
|
|
122
116
|
renderEmpty={() => {
|
|
123
117
|
if (error) {
|
|
@@ -131,6 +125,9 @@ export default ({
|
|
|
131
125
|
columns={cols as any}
|
|
132
126
|
size={cuSize}
|
|
133
127
|
search={false}
|
|
128
|
+
onChange={(pagination, filters, sorter)=>{
|
|
129
|
+
console.log(filters,sorter)
|
|
130
|
+
}}
|
|
134
131
|
options={false}
|
|
135
132
|
tableStyle={{
|
|
136
133
|
paddingBottom: 0,
|