@hw-component/table 1.9.39 → 1.9.40
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/index.d.ts +1 -1
- package/es/HTableHeader/hooks/config.d.ts +1 -1
- package/es/HTableHeader/hooks/useHeaderDefaultProps.d.ts +1 -1
- package/es/HTableHeader/hooks/useHideMoreTitle.d.ts +3 -3
- package/es/hooks/useCurrentTable.js +4 -1
- package/es/modal.d.ts +1 -1
- package/es/render/Text.d.ts +1 -0
- package/lib/HTableBody/index.d.ts +1 -1
- package/lib/HTableHeader/hooks/config.d.ts +1 -1
- package/lib/HTableHeader/hooks/useHeaderDefaultProps.d.ts +1 -1
- package/lib/HTableHeader/hooks/useHideMoreTitle.d.ts +3 -3
- package/lib/hooks/useCurrentTable.js +4 -1
- package/lib/modal.d.ts +1 -1
- package/lib/render/Text.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/DialogTable/hooks.ts +10 -10
- package/src/components/HTableBody/index.tsx +4 -3
- package/src/components/HTableHeader/hooks/config.tsx +35 -35
- package/src/components/HTableHeader/hooks/useHeaderDefaultProps.ts +33 -25
- package/src/components/HTableHeader/hooks/useHideMoreTitle.tsx +146 -152
- package/src/components/HTableHeader/index.tsx +21 -7
- package/src/components/hooks/useCurrentTable.ts +4 -1
- package/src/components/modal.ts +1 -1
- package/src/components/render/config.tsx +3 -3
- package/src/pages/DwTable/index.tsx +7 -5
- package/src/pages/Table/index.tsx +3 -2
package/es/HTableBody/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
2
2
|
import type { ActionRenderFn, ConfigDataModal, ParamsModal, HTableInstance, HRowSelection } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { IPaginationProps } from "../HTablePagination";
|
|
4
|
+
import type { IPaginationProps } from "../HTablePagination";
|
|
5
5
|
import type { AffixProps } from "antd/lib/affix";
|
|
6
6
|
import type { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
7
7
|
export interface OptionModal extends OptionConfig {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IHeaderProps } from "../modal";
|
|
2
|
-
declare const _default: ({ configData, loading, onFinish, hideLabel, labelWidth, table }: IHeaderProps) => {
|
|
2
|
+
declare const _default: ({ configData, loading, onFinish, hideLabel, labelWidth, table, }: IHeaderProps) => {
|
|
3
3
|
tableInstance: import("../../modal").HTableInstance;
|
|
4
4
|
tableLabelWidth: number | undefined;
|
|
5
5
|
tableHideLabel: boolean | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHeaderProps } from "../modal";
|
|
2
|
-
import { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
3
|
-
declare const _default: ({ searchSpan, configData, table
|
|
1
|
+
import type { IHeaderProps } from "../modal";
|
|
2
|
+
import type { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
3
|
+
declare const _default: ({ searchSpan, configData, table }: IHeaderProps) => HItemProps[];
|
|
4
4
|
export default _default;
|
|
@@ -22,7 +22,10 @@ var useCurrentTable = (function (_ref) {
|
|
|
22
22
|
resultTable.table.getSelectedRowData = function () {
|
|
23
23
|
return selectedRowData;
|
|
24
24
|
};
|
|
25
|
-
resultTable.table.getTableSourceData = function () {
|
|
25
|
+
resultTable.table.getTableSourceData = function (full) {
|
|
26
|
+
if (full) {
|
|
27
|
+
return dataSource;
|
|
28
|
+
}
|
|
26
29
|
return dataSource === null || dataSource === void 0 ? void 0 : dataSource.records;
|
|
27
30
|
};
|
|
28
31
|
return resultTable;
|
package/es/modal.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export interface TableInstance {
|
|
|
93
93
|
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
94
94
|
getParams: () => any;
|
|
95
95
|
getSelectedRowData: () => RowObj;
|
|
96
|
-
getTableSourceData: () => any;
|
|
96
|
+
getTableSourceData: (full?: boolean) => any;
|
|
97
97
|
getColSettingKeys: () => ColCheckResultKeys;
|
|
98
98
|
}
|
|
99
99
|
export interface HTableInstance {
|
package/es/render/Text.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProTableProps } from "@ant-design/pro-table";
|
|
2
2
|
import type { ActionRenderFn, ConfigDataModal, ParamsModal, HTableInstance, HRowSelection } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { IPaginationProps } from "../HTablePagination";
|
|
4
|
+
import type { IPaginationProps } from "../HTablePagination";
|
|
5
5
|
import type { AffixProps } from "antd/lib/affix";
|
|
6
6
|
import type { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
7
7
|
export interface OptionModal extends OptionConfig {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IHeaderProps } from "../modal";
|
|
2
|
-
declare const _default: ({ configData, loading, onFinish, hideLabel, labelWidth, table }: IHeaderProps) => {
|
|
2
|
+
declare const _default: ({ configData, loading, onFinish, hideLabel, labelWidth, table, }: IHeaderProps) => {
|
|
3
3
|
tableInstance: import("../../modal").HTableInstance;
|
|
4
4
|
tableLabelWidth: number | undefined;
|
|
5
5
|
tableHideLabel: boolean | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHeaderProps } from "../modal";
|
|
2
|
-
import { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
3
|
-
declare const _default: ({ searchSpan, configData, table
|
|
1
|
+
import type { IHeaderProps } from "../modal";
|
|
2
|
+
import type { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
3
|
+
declare const _default: ({ searchSpan, configData, table }: IHeaderProps) => HItemProps[];
|
|
4
4
|
export default _default;
|
|
@@ -25,7 +25,10 @@ var useCurrentTable = (function (_ref) {
|
|
|
25
25
|
resultTable.table.getSelectedRowData = function () {
|
|
26
26
|
return selectedRowData;
|
|
27
27
|
};
|
|
28
|
-
resultTable.table.getTableSourceData = function () {
|
|
28
|
+
resultTable.table.getTableSourceData = function (full) {
|
|
29
|
+
if (full) {
|
|
30
|
+
return dataSource;
|
|
31
|
+
}
|
|
29
32
|
return dataSource === null || dataSource === void 0 ? void 0 : dataSource.records;
|
|
30
33
|
};
|
|
31
34
|
return resultTable;
|
package/lib/modal.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export interface TableInstance {
|
|
|
93
93
|
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
94
94
|
getParams: () => any;
|
|
95
95
|
getSelectedRowData: () => RowObj;
|
|
96
|
-
getTableSourceData: () => any;
|
|
96
|
+
getTableSourceData: (full?: boolean) => any;
|
|
97
97
|
getColSettingKeys: () => ColCheckResultKeys;
|
|
98
98
|
}
|
|
99
99
|
export interface HTableInstance {
|
package/lib/render/Text.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -35,16 +35,16 @@ export const useTableProps = ({
|
|
|
35
35
|
request,
|
|
36
36
|
dataSource,
|
|
37
37
|
});
|
|
38
|
-
useEffect(()=>{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},[configData])
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (configData) {
|
|
40
|
+
setModalTableParams((oldVal) => {
|
|
41
|
+
return {
|
|
42
|
+
...oldVal,
|
|
43
|
+
configData,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}, [configData]);
|
|
48
48
|
return {
|
|
49
49
|
modalTableParams,
|
|
50
50
|
setModalTableParams,
|
|
@@ -17,7 +17,8 @@ import { useHTableContext } from "../context";
|
|
|
17
17
|
import React from "react";
|
|
18
18
|
import { ConfigProvider, Empty, Alert, Space } from "antd";
|
|
19
19
|
import { useHTableConfigContext } from "../TableConfig";
|
|
20
|
-
import
|
|
20
|
+
import type { IPaginationProps } from "../HTablePagination";
|
|
21
|
+
import HTablePagination from "../HTablePagination";
|
|
21
22
|
import { useClassName } from "../hooks";
|
|
22
23
|
import AlertMsg from "./AlertMsg";
|
|
23
24
|
import type { AffixProps } from "antd/lib/affix";
|
|
@@ -31,7 +32,7 @@ export interface OptionModal extends OptionConfig {
|
|
|
31
32
|
export interface HTableBodyProps
|
|
32
33
|
extends Omit<
|
|
33
34
|
ProTableProps<any, any>,
|
|
34
|
-
"dataSource" | "rowSelection" | "options"|"pagination"
|
|
35
|
+
"dataSource" | "rowSelection" | "options" | "pagination"
|
|
35
36
|
> {
|
|
36
37
|
configData?: ConfigDataModal;
|
|
37
38
|
onPageChange?: (params: ParamsModal) => void;
|
|
@@ -51,7 +52,7 @@ export interface HTableBodyProps
|
|
|
51
52
|
localSorter?: boolean;
|
|
52
53
|
options?: OptionModal | false;
|
|
53
54
|
table?: HTableInstance;
|
|
54
|
-
pagination?:IPaginationProps|false;
|
|
55
|
+
pagination?: IPaginationProps | false;
|
|
55
56
|
}
|
|
56
57
|
const defaultRender = () => {
|
|
57
58
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import {HFormInstance, HItemProps} from "@hw-component/form/es/Form/modal";
|
|
1
|
+
import type { HFormInstance, HItemProps } from "@hw-component/form/es/Form/modal";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {DefaultSubComponent} from "../defaultSubComponent";
|
|
3
|
+
import { DefaultSubComponent } from "../defaultSubComponent";
|
|
4
4
|
|
|
5
5
|
export const sizeObj = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
xl: {
|
|
7
|
+
min: 1200,
|
|
8
|
+
max: 1600,
|
|
9
|
+
},
|
|
10
|
+
xxl: {
|
|
11
|
+
min: 1600,
|
|
12
|
+
},
|
|
13
|
+
lg: {
|
|
14
|
+
min: 992,
|
|
15
|
+
max: 1200,
|
|
16
|
+
},
|
|
17
|
+
md: {
|
|
18
|
+
min: 768,
|
|
19
|
+
max: 992,
|
|
20
|
+
},
|
|
21
|
+
sm: {
|
|
22
|
+
min: 576,
|
|
23
|
+
max: 768,
|
|
24
|
+
},
|
|
25
|
+
xs: {
|
|
26
|
+
max: 576,
|
|
27
|
+
},
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export const defaultSubItem = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
type: "submit",
|
|
32
|
+
itemProps: {
|
|
33
|
+
position: "end",
|
|
34
|
+
},
|
|
35
|
+
style: {
|
|
36
|
+
padding: 0,
|
|
37
|
+
marginLeft: -20,
|
|
38
|
+
},
|
|
39
|
+
render: (item: HItemProps, node: React.ReactNode, form: HFormInstance) => {
|
|
40
|
+
return <DefaultSubComponent form={form} />;
|
|
41
|
+
},
|
|
42
42
|
};
|
|
@@ -2,28 +2,36 @@ import type { IHeaderProps } from "../modal";
|
|
|
2
2
|
import { useHTableContext } from "../../context";
|
|
3
3
|
import useHTable from "../../hooks/useHTable";
|
|
4
4
|
|
|
5
|
-
export default ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
export default ({
|
|
6
|
+
configData,
|
|
7
|
+
loading,
|
|
8
|
+
onFinish,
|
|
9
|
+
hideLabel,
|
|
10
|
+
labelWidth,
|
|
11
|
+
table,
|
|
12
|
+
}: IHeaderProps) => {
|
|
13
|
+
const {
|
|
14
|
+
tableInstance: contextTableInstance,
|
|
15
|
+
loading: contextLoading,
|
|
16
|
+
onFinish: contextOnFinish,
|
|
17
|
+
configData: contextConfigData,
|
|
18
|
+
hideLabel: contextHideLabel,
|
|
19
|
+
labelWidth: contextLabelWidth,
|
|
20
|
+
} = useHTableContext();
|
|
21
|
+
const defaultTable = useHTable();
|
|
22
|
+
const headerConfigData = configData || contextConfigData;
|
|
23
|
+
const submitLoading = contextLoading || loading;
|
|
24
|
+
const subOnFinish = onFinish || contextOnFinish;
|
|
25
|
+
const tableHideLabel =
|
|
26
|
+
typeof hideLabel === "undefined" ? contextHideLabel : hideLabel;
|
|
27
|
+
const tableLabelWidth = labelWidth || contextLabelWidth;
|
|
28
|
+
const tableInstance = table || contextTableInstance;
|
|
29
|
+
return {
|
|
30
|
+
tableInstance: tableInstance || defaultTable,
|
|
31
|
+
tableLabelWidth,
|
|
32
|
+
tableHideLabel,
|
|
33
|
+
subOnFinish,
|
|
34
|
+
submitLoading,
|
|
35
|
+
headerConfigData,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -1,174 +1,168 @@
|
|
|
1
|
-
import {FormConfigDataItemProviderModal, IHeaderProps} from "../modal";
|
|
2
|
-
import {useEffect, useState} from "react";
|
|
3
|
-
import {HItemProps} from "@hw-component/form/es/Form/modal";
|
|
4
|
-
import {defaultSubItem, sizeObj} from "./config";
|
|
5
|
-
import {useHTableContext} from "../../context";
|
|
6
|
-
import {useClassName} from "../../hooks";
|
|
7
|
-
import {HTableInstance} from "../../modal";
|
|
8
|
-
import {ColProps} from "antd";
|
|
9
|
-
import {renderData} from "../defaultFormRender";
|
|
1
|
+
import type { FormConfigDataItemProviderModal, IHeaderProps } from "../modal";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import type { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
4
|
+
import { defaultSubItem, sizeObj } from "./config";
|
|
5
|
+
import { useHTableContext } from "../../context";
|
|
6
|
+
import { useClassName } from "../../hooks";
|
|
7
|
+
import type { HTableInstance } from "../../modal";
|
|
8
|
+
import type { ColProps } from "antd";
|
|
9
|
+
import { renderData } from "../defaultFormRender";
|
|
10
10
|
|
|
11
11
|
const formConfigDataItemProvider = (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
{
|
|
13
|
+
searchType,
|
|
14
|
+
title,
|
|
15
|
+
name,
|
|
16
|
+
dataIndex,
|
|
17
|
+
itemProps = {},
|
|
18
|
+
searchRender,
|
|
19
|
+
childrenDataIndex,
|
|
20
|
+
showSearch,
|
|
21
|
+
hideInTable,
|
|
22
|
+
align,
|
|
23
|
+
searchLabel,
|
|
24
|
+
titleStr,
|
|
25
|
+
...props
|
|
26
|
+
}: FormConfigDataItemProviderModal,
|
|
27
|
+
table: HTableInstance
|
|
28
28
|
): HItemProps => {
|
|
29
|
-
|
|
29
|
+
const { allowClear = true } = itemProps as any;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
return {
|
|
32
|
+
...props,
|
|
33
|
+
itemProps: {
|
|
34
|
+
...itemProps,
|
|
35
|
+
allowClear,
|
|
36
|
+
},
|
|
37
|
+
label: searchLabel || titleStr || title,
|
|
38
|
+
type: searchType,
|
|
39
|
+
name: name || (dataIndex as string),
|
|
40
|
+
render: (item, node, form) => {
|
|
41
|
+
if (searchRender) {
|
|
42
|
+
return searchRender(item, node, form, table);
|
|
43
|
+
}
|
|
44
|
+
const defaultRender = renderData[searchType || ""];
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
return defaultRender ? defaultRender(item) : node;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const getCuSpanMaxNum = (searchSpan: ColProps = { span: 6 }) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
const clientWidth = document.documentElement.clientWidth;
|
|
53
|
+
const keys = Object.keys(sizeObj);
|
|
54
|
+
const index = keys.findIndex((value) => {
|
|
55
|
+
const { min = 0, max = Number.MAX_VALUE } = sizeObj[value];
|
|
56
|
+
return clientWidth >= min && clientWidth < max;
|
|
57
|
+
});
|
|
58
|
+
const cuKey = keys[index];
|
|
59
|
+
const cuSpan = searchSpan[cuKey] || searchSpan.span;
|
|
60
|
+
return 24 / cuSpan;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
|
|
64
63
|
const mkNewConfig = ({ configData = [], table }: IHeaderProps) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
64
|
+
let subConfigData: HItemProps | undefined;
|
|
65
|
+
const realConfigData: HItemProps[] = [];
|
|
66
|
+
configData.forEach((value) => {
|
|
67
|
+
const { searchType, showSearch } = value;
|
|
68
|
+
if (!showSearch) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (searchType === "submit") {
|
|
72
|
+
subConfigData = formConfigDataItemProvider(
|
|
73
|
+
value,
|
|
74
|
+
table as HTableInstance
|
|
75
|
+
);
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
realConfigData.push(
|
|
79
|
+
formConfigDataItemProvider(value, table as HTableInstance)
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
realConfigData,
|
|
84
|
+
subConfigData,
|
|
85
|
+
};
|
|
87
86
|
};
|
|
88
87
|
|
|
89
88
|
const filterHideFormItem = (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
configData: HItemProps[],
|
|
90
|
+
className: string,
|
|
91
|
+
searchSpan?: ColProps
|
|
93
92
|
) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
lessData: configData,
|
|
100
|
-
hideData: [],
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
const index = startIndex === 0 ? 1 : startIndex;
|
|
104
|
-
const lessData = configData.slice(0, index);
|
|
105
|
-
const bigData = configData.slice(index);
|
|
106
|
-
const hideData = bigData.map((value) => {
|
|
107
|
-
return {
|
|
108
|
-
...value,
|
|
109
|
-
className,
|
|
110
|
-
};
|
|
111
|
-
});
|
|
93
|
+
const maxNum = getCuSpanMaxNum(searchSpan);
|
|
94
|
+
const len = configData.length;
|
|
95
|
+
const startIndex = maxNum - 1;
|
|
96
|
+
if (len <= startIndex) {
|
|
112
97
|
return {
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
lessData: configData,
|
|
99
|
+
hideData: [],
|
|
115
100
|
};
|
|
101
|
+
}
|
|
102
|
+
const index = startIndex === 0 ? 1 : startIndex;
|
|
103
|
+
const lessData = configData.slice(0, index);
|
|
104
|
+
const bigData = configData.slice(index);
|
|
105
|
+
const hideData = bigData.map((value) => {
|
|
106
|
+
return {
|
|
107
|
+
...value,
|
|
108
|
+
className,
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
lessData,
|
|
113
|
+
hideData,
|
|
114
|
+
};
|
|
116
115
|
};
|
|
117
116
|
|
|
118
|
-
const useDefaultOpen=()=>{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
headerOpen,
|
|
124
|
-
setHeaderOpen
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
export default ({
|
|
128
|
-
searchSpan,
|
|
129
|
-
configData,
|
|
130
|
-
table,
|
|
131
|
-
}: IHeaderProps) => {
|
|
117
|
+
const useDefaultOpen = () => {
|
|
118
|
+
const [open, setOpen] = useState(false);
|
|
119
|
+
const { headerOpen = open, setHeaderOpen = setOpen } = useHTableContext();
|
|
132
120
|
|
|
133
|
-
|
|
134
|
-
|
|
121
|
+
return {
|
|
122
|
+
headerOpen,
|
|
123
|
+
setHeaderOpen,
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export default ({ searchSpan, configData, table }: IHeaderProps) => {
|
|
127
|
+
const [formConfigData, setFormConfigData] = useState<HItemProps[]>([]);
|
|
128
|
+
const [subData, setSubData] = useState<HItemProps>(defaultSubItem as any);
|
|
135
129
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
130
|
+
const { headerOpen, setHeaderOpen } = useDefaultOpen();
|
|
131
|
+
const className = useClassName("hw-table-header-item-hide");
|
|
132
|
+
const mkNewFn = () => {
|
|
133
|
+
const { realConfigData, subConfigData } = mkNewConfig({
|
|
134
|
+
searchSpan,
|
|
135
|
+
configData,
|
|
136
|
+
table,
|
|
137
|
+
});
|
|
138
|
+
const changeClassName = headerOpen ? "" : className;
|
|
139
|
+
const { lessData, hideData } = filterHideFormItem(
|
|
140
|
+
realConfigData,
|
|
141
|
+
changeClassName,
|
|
142
|
+
searchSpan
|
|
143
|
+
);
|
|
144
|
+
if (subConfigData) {
|
|
145
|
+
setSubData(subConfigData);
|
|
146
|
+
}
|
|
147
|
+
setHeaderOpen((oldVal) => {
|
|
148
|
+
if (hideData.length === 0) {
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
if (typeof oldVal === "undefined") {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return oldVal;
|
|
155
|
+
});
|
|
156
|
+
setFormConfigData([...lessData, ...hideData]);
|
|
157
|
+
};
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
mkNewFn();
|
|
160
|
+
}, [configData, searchSpan, headerOpen]);
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
window.addEventListener("resize", mkNewFn);
|
|
163
|
+
return () => {
|
|
164
|
+
window.removeEventListener("resize", mkNewFn);
|
|
163
165
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
useEffect(() => {
|
|
168
|
-
window.addEventListener("resize", mkNewFn);
|
|
169
|
-
return () => {
|
|
170
|
-
window.removeEventListener("resize", mkNewFn);
|
|
171
|
-
};
|
|
172
|
-
}, [configData, searchSpan, headerOpen]);
|
|
173
|
-
return [...formConfigData, subData];
|
|
174
|
-
};
|
|
166
|
+
}, [configData, searchSpan, headerOpen]);
|
|
167
|
+
return [...formConfigData, subData];
|
|
168
|
+
};
|