@hw-component/table 1.9.78 → 1.9.80
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.js +41 -5
- package/es/HTableBody/RowCheckBox/Title.d.ts +1 -1
- package/es/HTableBody/RowCheckBox/hooks.d.ts +1 -1
- package/es/HTableBody/RowRadioBoxSelection.d.ts +3 -3
- package/es/HTableBody/hooks/colsMk.d.ts +1 -1
- package/es/HTableBody/hooks/useControl.d.ts +1 -1
- package/es/index.css +24 -2
- package/es/render/CopyComponent.js +10 -1
- package/es/render/Text.d.ts +0 -1
- package/lib/HTableBody/HeaderTitle/index.js +40 -4
- package/lib/HTableBody/RowCheckBox/Title.d.ts +1 -1
- package/lib/HTableBody/RowCheckBox/hooks.d.ts +1 -1
- package/lib/HTableBody/RowRadioBoxSelection.d.ts +3 -3
- package/lib/HTableBody/hooks/colsMk.d.ts +1 -1
- package/lib/HTableBody/hooks/useControl.d.ts +1 -1
- package/lib/index.css +24 -2
- package/lib/render/CopyComponent.js +10 -1
- package/lib/render/Text.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/HTableBody/HeaderTitle/index.tsx +40 -9
- package/src/components/HTableBody/RowCheckBox/RowItem.tsx +40 -41
- package/src/components/HTableBody/RowCheckBox/Title.tsx +59 -63
- package/src/components/HTableBody/RowCheckBox/hooks.ts +64 -63
- package/src/components/HTableBody/RowRadioBoxSelection.tsx +24 -24
- package/src/components/HTableBody/hooks/colsMk.tsx +47 -47
- package/src/components/HTableBody/hooks/useColData.tsx +9 -9
- package/src/components/HTableBody/hooks/useControl.tsx +12 -10
- package/src/components/HTableBody/index.tsx +14 -5
- package/src/components/Table.tsx +10 -4
- package/src/components/hooks/useRowObj.ts +11 -11
- package/src/components/index.less +8 -3
- package/src/components/modal.ts +2 -2
- package/src/components/render/CopyComponent.tsx +10 -1
- package/src/components/render/TagsComponent.tsx +18 -8
- package/src/pages/DwTable/index.tsx +4 -4
- package/src/pages/Table/index.tsx +16 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
2
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
4
|
-
import React from 'react';
|
|
4
|
+
import React, { useRef, useState, useLayoutEffect, useEffect } from 'react';
|
|
5
5
|
import { useHTableContext } from '../../context.js';
|
|
6
6
|
import { useClassName } from '../../hooks/index.js';
|
|
7
7
|
|
|
@@ -14,20 +14,55 @@ var HeaderTitle = (function (_ref) {
|
|
|
14
14
|
selectedRowData = _useHTableContext.selectedRowData,
|
|
15
15
|
rowOnChange = _useHTableContext.rowOnChange,
|
|
16
16
|
allSelectChange = _useHTableContext.allSelectChange;
|
|
17
|
+
var bodyRef = useRef();
|
|
18
|
+
var titleContentRef = useRef();
|
|
19
|
+
var rightNodeRef = useRef();
|
|
20
|
+
var _useState = useState({}),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
style = _useState2[0],
|
|
23
|
+
setStyle = _useState2[1];
|
|
17
24
|
var headerBox = useClassName("hw-table-header-title-box");
|
|
18
25
|
var headerBoxContent = useClassName("hw-table-header-title-box-content");
|
|
26
|
+
var titleClassname = useClassName("hw-table-header-title");
|
|
19
27
|
var rightNodeClassname = useClassName("hw-table-header-right-node");
|
|
28
|
+
var setHeaderStyle = function setHeaderStyle() {
|
|
29
|
+
var _bodyRef$current, _titleContentRef$curr, _rightNodeRef$current;
|
|
30
|
+
var headerWidth = ((_bodyRef$current = bodyRef.current) === null || _bodyRef$current === void 0 ? void 0 : _bodyRef$current.clientWidth) || 0;
|
|
31
|
+
var titleWidth = ((_titleContentRef$curr = titleContentRef.current) === null || _titleContentRef$curr === void 0 ? void 0 : _titleContentRef$curr.clientWidth) || 0;
|
|
32
|
+
var rightNodeWidth = ((_rightNodeRef$current = rightNodeRef.current) === null || _rightNodeRef$current === void 0 ? void 0 : _rightNodeRef$current.clientWidth) || 0;
|
|
33
|
+
if (rightNodeWidth + titleWidth >= headerWidth) {
|
|
34
|
+
setStyle({
|
|
35
|
+
overflow: "auto"
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
setStyle({});
|
|
40
|
+
};
|
|
41
|
+
useLayoutEffect(function () {
|
|
42
|
+
setHeaderStyle();
|
|
43
|
+
}, []);
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
var resizeFn = function resizeFn() {
|
|
46
|
+
setHeaderStyle();
|
|
47
|
+
};
|
|
48
|
+
window.addEventListener('resize', resizeFn);
|
|
49
|
+
return function () {
|
|
50
|
+
window.removeEventListener("resize", resizeFn);
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
20
53
|
if (!headerTitle && !rNode) {
|
|
21
54
|
return null;
|
|
22
55
|
}
|
|
23
|
-
return jsxs(
|
|
24
|
-
|
|
25
|
-
|
|
56
|
+
return jsxs("div", {
|
|
57
|
+
ref: bodyRef,
|
|
58
|
+
className: titleClassname,
|
|
26
59
|
style: contentStyle,
|
|
27
60
|
children: [jsx("div", {
|
|
28
61
|
className: headerBox,
|
|
62
|
+
style: style,
|
|
29
63
|
children: jsx("div", {
|
|
30
64
|
className: headerBoxContent,
|
|
65
|
+
ref: titleContentRef,
|
|
31
66
|
children: headerTitle && /*#__PURE__*/React.cloneElement(headerTitle, {
|
|
32
67
|
selectedRowData: selectedRowData,
|
|
33
68
|
allSelectChange: allSelectChange,
|
|
@@ -37,6 +72,7 @@ var HeaderTitle = (function (_ref) {
|
|
|
37
72
|
})
|
|
38
73
|
}), rNode && jsx("div", {
|
|
39
74
|
className: rightNodeClassname,
|
|
75
|
+
ref: rightNodeRef,
|
|
40
76
|
children: rNode
|
|
41
77
|
})]
|
|
42
78
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { HRowSelection } from "@/components/modal";
|
|
2
|
+
import type { HRowSelection } from "@/components/modal";
|
|
3
3
|
declare const _default: ({ allPageCheck, onChange, getCheckboxProps, }: HRowSelection) => JSX.Element;
|
|
4
4
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Key } from "react";
|
|
1
|
+
import type { Key } from "react";
|
|
2
2
|
import type { HRowSelection } from "../../modal";
|
|
3
3
|
export declare const useAllChecked: (keys?: Key[], data?: any[]) => boolean;
|
|
4
4
|
export declare const useCheckControl: (data: any[] | undefined, onChange: HRowSelection["onChange"]) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { HRowSelection } from "@/components/modal";
|
|
3
|
-
interface
|
|
2
|
+
import type { HRowSelection } from "@/components/modal";
|
|
3
|
+
interface RowRadioSelectionProps {
|
|
4
4
|
data: any;
|
|
5
5
|
onChange?: HRowSelection["onChange"];
|
|
6
6
|
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
7
7
|
index: number;
|
|
8
8
|
}
|
|
9
|
-
export declare const RowRadioSelection: ({ data, onChange, index, getCheckboxProps, }:
|
|
9
|
+
export declare const RowRadioSelection: ({ data, onChange, index, getCheckboxProps, }: RowRadioSelectionProps) => JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -2,7 +2,7 @@ import type React from "react";
|
|
|
2
2
|
import type { SizeType } from "antd/lib/config-provider/SizeContext";
|
|
3
3
|
import type { HTableBodyProps } from "../modal";
|
|
4
4
|
import type { GetRowKey } from "rc-table/lib/interface";
|
|
5
|
-
import { RowObj } from "@/components/modal";
|
|
5
|
+
import type { RowObj } from "@/components/modal";
|
|
6
6
|
export declare const useSize: (size: SizeType) => {
|
|
7
7
|
cuSize: "small" | "middle" | "large" | undefined;
|
|
8
8
|
setCuSize: React.Dispatch<React.SetStateAction<"small" | "middle" | "large" | undefined>>;
|
package/es/index.css
CHANGED
|
@@ -119,14 +119,36 @@
|
|
|
119
119
|
display: flex;
|
|
120
120
|
position: relative;
|
|
121
121
|
box-sizing: border-box;
|
|
122
|
-
overflow: auto;
|
|
123
122
|
margin: -10px 0px;
|
|
124
123
|
padding: 10px 0px;
|
|
125
|
-
margin-right: 12px;
|
|
126
124
|
}
|
|
127
125
|
.ant-hw-table-header-title-box .ant-hw-table-header-title-box-content {
|
|
128
126
|
white-space: nowrap;
|
|
129
127
|
}
|
|
128
|
+
.ant-hw-table-header-title {
|
|
129
|
+
display: -webkit-box;
|
|
130
|
+
display: -webkit-flex;
|
|
131
|
+
display: -ms-flexbox;
|
|
132
|
+
display: flex;
|
|
133
|
+
-webkit-box-pack: justify;
|
|
134
|
+
-webkit-justify-content: space-between;
|
|
135
|
+
-ms-flex-pack: justify;
|
|
136
|
+
justify-content: space-between;
|
|
137
|
+
-webkit-align-content: center;
|
|
138
|
+
-ms-flex-line-pack: center;
|
|
139
|
+
align-content: center;
|
|
140
|
+
}
|
|
141
|
+
.ant-hw-table-header-right-node {
|
|
142
|
+
padding-left: 12px;
|
|
143
|
+
display: -webkit-box;
|
|
144
|
+
display: -webkit-flex;
|
|
145
|
+
display: -ms-flexbox;
|
|
146
|
+
display: flex;
|
|
147
|
+
-webkit-box-align: center;
|
|
148
|
+
-webkit-align-items: center;
|
|
149
|
+
-ms-flex-align: center;
|
|
150
|
+
align-items: center;
|
|
151
|
+
}
|
|
130
152
|
.ant-hw-table-render-copy {
|
|
131
153
|
margin-bottom: 0 !important;
|
|
132
154
|
color: #1890ff !important;
|
|
@@ -3,6 +3,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import copy from 'copy-to-clipboard';
|
|
4
4
|
import { Typography, message } from 'antd';
|
|
5
5
|
import { useClassName } from '../hooks/index.js';
|
|
6
|
+
import { useMemo } from 'react';
|
|
6
7
|
|
|
7
8
|
var Paragraph = Typography.Paragraph;
|
|
8
9
|
var CopyComponent = (function (_ref) {
|
|
@@ -11,8 +12,16 @@ var CopyComponent = (function (_ref) {
|
|
|
11
12
|
successMsg = _ref.successMsg,
|
|
12
13
|
ellipsis = _ref.ellipsis;
|
|
13
14
|
var className = useClassName("hw-table-render-copy");
|
|
15
|
+
var propsEllipsis = useMemo(function () {
|
|
16
|
+
if (ellipsis === true) {
|
|
17
|
+
return {
|
|
18
|
+
tooltip: text
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return ellipsis;
|
|
22
|
+
}, [ellipsis, text]);
|
|
14
23
|
return jsx(Paragraph, {
|
|
15
|
-
ellipsis:
|
|
24
|
+
ellipsis: propsEllipsis,
|
|
16
25
|
className: className,
|
|
17
26
|
style: {
|
|
18
27
|
margin: 0,
|
package/es/render/Text.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var antd = require('antd');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var context = require('../../context.js');
|
|
9
9
|
var index = require('../../hooks/index.js');
|
|
@@ -17,20 +17,55 @@ var HeaderTitle = (function (_ref) {
|
|
|
17
17
|
selectedRowData = _useHTableContext.selectedRowData,
|
|
18
18
|
rowOnChange = _useHTableContext.rowOnChange,
|
|
19
19
|
allSelectChange = _useHTableContext.allSelectChange;
|
|
20
|
+
var bodyRef = React.useRef();
|
|
21
|
+
var titleContentRef = React.useRef();
|
|
22
|
+
var rightNodeRef = React.useRef();
|
|
23
|
+
var _useState = React.useState({}),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
style = _useState2[0],
|
|
26
|
+
setStyle = _useState2[1];
|
|
20
27
|
var headerBox = index.useClassName("hw-table-header-title-box");
|
|
21
28
|
var headerBoxContent = index.useClassName("hw-table-header-title-box-content");
|
|
29
|
+
var titleClassname = index.useClassName("hw-table-header-title");
|
|
22
30
|
var rightNodeClassname = index.useClassName("hw-table-header-right-node");
|
|
31
|
+
var setHeaderStyle = function setHeaderStyle() {
|
|
32
|
+
var _bodyRef$current, _titleContentRef$curr, _rightNodeRef$current;
|
|
33
|
+
var headerWidth = ((_bodyRef$current = bodyRef.current) === null || _bodyRef$current === void 0 ? void 0 : _bodyRef$current.clientWidth) || 0;
|
|
34
|
+
var titleWidth = ((_titleContentRef$curr = titleContentRef.current) === null || _titleContentRef$curr === void 0 ? void 0 : _titleContentRef$curr.clientWidth) || 0;
|
|
35
|
+
var rightNodeWidth = ((_rightNodeRef$current = rightNodeRef.current) === null || _rightNodeRef$current === void 0 ? void 0 : _rightNodeRef$current.clientWidth) || 0;
|
|
36
|
+
if (rightNodeWidth + titleWidth >= headerWidth) {
|
|
37
|
+
setStyle({
|
|
38
|
+
overflow: "auto"
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setStyle({});
|
|
43
|
+
};
|
|
44
|
+
React.useLayoutEffect(function () {
|
|
45
|
+
setHeaderStyle();
|
|
46
|
+
}, []);
|
|
47
|
+
React.useEffect(function () {
|
|
48
|
+
var resizeFn = function resizeFn() {
|
|
49
|
+
setHeaderStyle();
|
|
50
|
+
};
|
|
51
|
+
window.addEventListener('resize', resizeFn);
|
|
52
|
+
return function () {
|
|
53
|
+
window.removeEventListener("resize", resizeFn);
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
23
56
|
if (!headerTitle && !rNode) {
|
|
24
57
|
return null;
|
|
25
58
|
}
|
|
26
|
-
return jsxRuntime.jsxs(
|
|
27
|
-
|
|
28
|
-
|
|
59
|
+
return jsxRuntime.jsxs("div", {
|
|
60
|
+
ref: bodyRef,
|
|
61
|
+
className: titleClassname,
|
|
29
62
|
style: contentStyle,
|
|
30
63
|
children: [jsxRuntime.jsx("div", {
|
|
31
64
|
className: headerBox,
|
|
65
|
+
style: style,
|
|
32
66
|
children: jsxRuntime.jsx("div", {
|
|
33
67
|
className: headerBoxContent,
|
|
68
|
+
ref: titleContentRef,
|
|
34
69
|
children: headerTitle && /*#__PURE__*/React.cloneElement(headerTitle, {
|
|
35
70
|
selectedRowData: selectedRowData,
|
|
36
71
|
allSelectChange: allSelectChange,
|
|
@@ -40,6 +75,7 @@ var HeaderTitle = (function (_ref) {
|
|
|
40
75
|
})
|
|
41
76
|
}), rNode && jsxRuntime.jsx("div", {
|
|
42
77
|
className: rightNodeClassname,
|
|
78
|
+
ref: rightNodeRef,
|
|
43
79
|
children: rNode
|
|
44
80
|
})]
|
|
45
81
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { HRowSelection } from "@/components/modal";
|
|
2
|
+
import type { HRowSelection } from "@/components/modal";
|
|
3
3
|
declare const _default: ({ allPageCheck, onChange, getCheckboxProps, }: HRowSelection) => JSX.Element;
|
|
4
4
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Key } from "react";
|
|
1
|
+
import type { Key } from "react";
|
|
2
2
|
import type { HRowSelection } from "../../modal";
|
|
3
3
|
export declare const useAllChecked: (keys?: Key[], data?: any[]) => boolean;
|
|
4
4
|
export declare const useCheckControl: (data: any[] | undefined, onChange: HRowSelection["onChange"]) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { HRowSelection } from "@/components/modal";
|
|
3
|
-
interface
|
|
2
|
+
import type { HRowSelection } from "@/components/modal";
|
|
3
|
+
interface RowRadioSelectionProps {
|
|
4
4
|
data: any;
|
|
5
5
|
onChange?: HRowSelection["onChange"];
|
|
6
6
|
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
7
7
|
index: number;
|
|
8
8
|
}
|
|
9
|
-
export declare const RowRadioSelection: ({ data, onChange, index, getCheckboxProps, }:
|
|
9
|
+
export declare const RowRadioSelection: ({ data, onChange, index, getCheckboxProps, }: RowRadioSelectionProps) => JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -2,7 +2,7 @@ import type React from "react";
|
|
|
2
2
|
import type { SizeType } from "antd/lib/config-provider/SizeContext";
|
|
3
3
|
import type { HTableBodyProps } from "../modal";
|
|
4
4
|
import type { GetRowKey } from "rc-table/lib/interface";
|
|
5
|
-
import { RowObj } from "@/components/modal";
|
|
5
|
+
import type { RowObj } from "@/components/modal";
|
|
6
6
|
export declare const useSize: (size: SizeType) => {
|
|
7
7
|
cuSize: "small" | "middle" | "large" | undefined;
|
|
8
8
|
setCuSize: React.Dispatch<React.SetStateAction<"small" | "middle" | "large" | undefined>>;
|
package/lib/index.css
CHANGED
|
@@ -119,14 +119,36 @@
|
|
|
119
119
|
display: flex;
|
|
120
120
|
position: relative;
|
|
121
121
|
box-sizing: border-box;
|
|
122
|
-
overflow: auto;
|
|
123
122
|
margin: -10px 0px;
|
|
124
123
|
padding: 10px 0px;
|
|
125
|
-
margin-right: 12px;
|
|
126
124
|
}
|
|
127
125
|
.ant-hw-table-header-title-box .ant-hw-table-header-title-box-content {
|
|
128
126
|
white-space: nowrap;
|
|
129
127
|
}
|
|
128
|
+
.ant-hw-table-header-title {
|
|
129
|
+
display: -webkit-box;
|
|
130
|
+
display: -webkit-flex;
|
|
131
|
+
display: -ms-flexbox;
|
|
132
|
+
display: flex;
|
|
133
|
+
-webkit-box-pack: justify;
|
|
134
|
+
-webkit-justify-content: space-between;
|
|
135
|
+
-ms-flex-pack: justify;
|
|
136
|
+
justify-content: space-between;
|
|
137
|
+
-webkit-align-content: center;
|
|
138
|
+
-ms-flex-line-pack: center;
|
|
139
|
+
align-content: center;
|
|
140
|
+
}
|
|
141
|
+
.ant-hw-table-header-right-node {
|
|
142
|
+
padding-left: 12px;
|
|
143
|
+
display: -webkit-box;
|
|
144
|
+
display: -webkit-flex;
|
|
145
|
+
display: -ms-flexbox;
|
|
146
|
+
display: flex;
|
|
147
|
+
-webkit-box-align: center;
|
|
148
|
+
-webkit-align-items: center;
|
|
149
|
+
-ms-flex-align: center;
|
|
150
|
+
align-items: center;
|
|
151
|
+
}
|
|
130
152
|
.ant-hw-table-render-copy {
|
|
131
153
|
margin-bottom: 0 !important;
|
|
132
154
|
color: #1890ff !important;
|
|
@@ -6,6 +6,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var copy = require('copy-to-clipboard');
|
|
7
7
|
var antd = require('antd');
|
|
8
8
|
var index = require('../hooks/index.js');
|
|
9
|
+
var React = require('react');
|
|
9
10
|
|
|
10
11
|
var Paragraph = antd.Typography.Paragraph;
|
|
11
12
|
var CopyComponent = (function (_ref) {
|
|
@@ -14,8 +15,16 @@ var CopyComponent = (function (_ref) {
|
|
|
14
15
|
successMsg = _ref.successMsg,
|
|
15
16
|
ellipsis = _ref.ellipsis;
|
|
16
17
|
var className = index.useClassName("hw-table-render-copy");
|
|
18
|
+
var propsEllipsis = React.useMemo(function () {
|
|
19
|
+
if (ellipsis === true) {
|
|
20
|
+
return {
|
|
21
|
+
tooltip: text
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return ellipsis;
|
|
25
|
+
}, [ellipsis, text]);
|
|
17
26
|
return jsxRuntime.jsx(Paragraph, {
|
|
18
|
-
ellipsis:
|
|
27
|
+
ellipsis: propsEllipsis,
|
|
19
28
|
className: className,
|
|
20
29
|
style: {
|
|
21
30
|
margin: 0,
|
package/lib/render/Text.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Row } from "antd";
|
|
2
2
|
import type { HTableBodyProps } from "../modal";
|
|
3
3
|
import type { DetailedReactHTMLElement } from "react";
|
|
4
|
-
import React from "react";
|
|
4
|
+
import React, {useEffect, useLayoutEffect, useRef, useState} from "react";
|
|
5
5
|
import { useHTableContext } from "../../context";
|
|
6
6
|
import { useClassName } from "../../hooks";
|
|
7
7
|
interface IProps {
|
|
@@ -10,18 +10,49 @@ interface IProps {
|
|
|
10
10
|
rNode?: React.ReactNode;
|
|
11
11
|
}
|
|
12
12
|
export default ({ headerTitle, contentStyle, rNode }: IProps) => {
|
|
13
|
-
const { tableInstance, selectedRowData, rowOnChange, allSelectChange } =
|
|
14
|
-
|
|
13
|
+
const { tableInstance, selectedRowData, rowOnChange, allSelectChange } = useHTableContext();
|
|
14
|
+
const bodyRef=useRef<any>();
|
|
15
|
+
const titleContentRef=useRef<any>();
|
|
16
|
+
const rightNodeRef=useRef<any>();
|
|
17
|
+
const [style,setStyle]=useState({
|
|
18
|
+
|
|
19
|
+
});
|
|
15
20
|
const headerBox = useClassName("hw-table-header-title-box");
|
|
16
21
|
const headerBoxContent = useClassName("hw-table-header-title-box-content");
|
|
17
|
-
const
|
|
22
|
+
const titleClassname=useClassName("hw-table-header-title")
|
|
23
|
+
const rightNodeClassname = useClassName("hw-table-header-right-node");
|
|
24
|
+
const setHeaderStyle=()=>{
|
|
25
|
+
const headerWidth=bodyRef.current?.clientWidth||0;
|
|
26
|
+
const titleWidth=titleContentRef.current?.clientWidth||0;
|
|
27
|
+
const rightNodeWidth=rightNodeRef.current?.clientWidth||0;
|
|
28
|
+
if (rightNodeWidth+titleWidth>=headerWidth){
|
|
29
|
+
setStyle({
|
|
30
|
+
overflow:"auto"
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
setStyle({});
|
|
35
|
+
}
|
|
36
|
+
useLayoutEffect(()=>{
|
|
37
|
+
setHeaderStyle()
|
|
38
|
+
},[]);
|
|
39
|
+
useEffect(()=>{
|
|
40
|
+
const resizeFn=()=>{
|
|
41
|
+
setHeaderStyle();
|
|
42
|
+
}
|
|
43
|
+
window.addEventListener('resize', resizeFn);
|
|
44
|
+
return ()=>{
|
|
45
|
+
window.removeEventListener("resize",resizeFn);
|
|
46
|
+
}
|
|
47
|
+
},[]);
|
|
18
48
|
if (!headerTitle && !rNode) {
|
|
19
49
|
return null;
|
|
20
50
|
}
|
|
51
|
+
|
|
21
52
|
return (
|
|
22
|
-
<
|
|
23
|
-
<div className={headerBox}>
|
|
24
|
-
<div className={headerBoxContent}>
|
|
53
|
+
<div ref={bodyRef} className={titleClassname} style={contentStyle}>
|
|
54
|
+
<div className={headerBox} style={style}>
|
|
55
|
+
<div className={headerBoxContent} ref={titleContentRef}>
|
|
25
56
|
{headerTitle &&
|
|
26
57
|
React.cloneElement(
|
|
27
58
|
headerTitle as DetailedReactHTMLElement<any, any>,
|
|
@@ -29,7 +60,7 @@ export default ({ headerTitle, contentStyle, rNode }: IProps) => {
|
|
|
29
60
|
)}
|
|
30
61
|
</div>
|
|
31
62
|
</div>
|
|
32
|
-
{rNode && <div className={rightNodeClassname}>{rNode}</div>}
|
|
33
|
-
</
|
|
63
|
+
{rNode && <div className={rightNodeClassname} ref={rightNodeRef}>{rNode}</div>}
|
|
64
|
+
</div>
|
|
34
65
|
);
|
|
35
66
|
};
|
|
@@ -2,48 +2,47 @@ import { useHTableContext } from "../../context";
|
|
|
2
2
|
import { Checkbox } from "antd";
|
|
3
3
|
import type { HRowSelection } from "../../modal";
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
interface RowSelectionBoxProps {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
data: any;
|
|
7
|
+
onChange?: HRowSelection["onChange"];
|
|
8
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
9
|
+
index: number;
|
|
11
10
|
}
|
|
12
11
|
export default ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
12
|
+
data,
|
|
13
|
+
onChange,
|
|
14
|
+
index,
|
|
15
|
+
getCheckboxProps,
|
|
16
|
+
}: RowSelectionBoxProps) => {
|
|
17
|
+
const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
|
|
18
|
+
const { rowData = [], keys = [] } = selectedRowData;
|
|
19
|
+
const key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
20
|
+
const add = () => {
|
|
21
|
+
const newKeys = [...keys];
|
|
22
|
+
const newRowData = [...rowData];
|
|
23
|
+
newKeys.push(key);
|
|
24
|
+
newRowData.push(data);
|
|
25
|
+
rowOnChange(newKeys, newRowData);
|
|
26
|
+
onChange?.(newKeys, newRowData);
|
|
27
|
+
};
|
|
28
|
+
const cancel = () => {
|
|
29
|
+
const newKeys = [...keys];
|
|
30
|
+
const newRowData = [...rowData];
|
|
31
|
+
const keyIndex = newKeys.indexOf(key);
|
|
32
|
+
newKeys.splice(keyIndex, 1);
|
|
33
|
+
newRowData.splice(keyIndex, 1);
|
|
34
|
+
rowOnChange(newKeys, newRowData);
|
|
35
|
+
onChange?.(newKeys, newRowData);
|
|
36
|
+
};
|
|
37
|
+
const check = (e) => {
|
|
38
|
+
const checked = e.target.checked;
|
|
39
|
+
if (checked) {
|
|
40
|
+
add();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
cancel();
|
|
44
|
+
};
|
|
45
|
+
const { disabled = false } = getCheckboxProps?.(data) || {};
|
|
46
|
+
const checked = keys.indexOf(key) !== -1;
|
|
47
|
+
return <Checkbox checked={checked} onChange={check} disabled={disabled} />;
|
|
49
48
|
};
|