@hw-component/table 1.9.79 → 1.9.81
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/config.d.ts +1 -1
- package/es/render/config.js +5 -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/config.d.ts +1 -1
- package/lib/render/config.js +5 -1
- package/package.json +2 -2
- package/src/components/HTableBody/HeaderTitle/index.tsx +41 -7
- 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 +9 -9
- package/src/components/render/TagsComponent.tsx +18 -8
- package/src/components/render/config.tsx +8 -1
- package/src/pages/DwTable/index.tsx +4 -4
- package/src/pages/Table/index.tsx +38 -109
|
@@ -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;
|
package/es/render/config.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare const _default: {
|
|
|
7
7
|
copy: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
8
8
|
link: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
9
9
|
text: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
10
|
-
image: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
10
|
+
image: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
11
11
|
avatar: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
12
12
|
};
|
|
13
13
|
export default _default;
|
package/es/render/config.js
CHANGED
|
@@ -133,9 +133,13 @@ var textRender = function textRender(config, itemData) {
|
|
|
133
133
|
var imageRender = function imageRender(config, itemData) {
|
|
134
134
|
var _config$valueTypeProp6 = config.valueTypeProps,
|
|
135
135
|
valueTypeProps = _config$valueTypeProp6 === void 0 ? {} : _config$valueTypeProp6;
|
|
136
|
+
var fallback = valueTypeProps.fallback;
|
|
136
137
|
var tableVal = getTableVal(config, itemData);
|
|
138
|
+
if (!fallback && tableVal === null) {
|
|
139
|
+
return "-";
|
|
140
|
+
}
|
|
137
141
|
return jsx(Image, _objectSpread({
|
|
138
|
-
src: tableVal,
|
|
142
|
+
src: tableVal || "",
|
|
139
143
|
width: 48
|
|
140
144
|
}, valueTypeProps));
|
|
141
145
|
};
|
|
@@ -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;
|
package/lib/render/config.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare const _default: {
|
|
|
7
7
|
copy: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
8
8
|
link: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
9
9
|
text: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
10
|
-
image: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
10
|
+
image: (config: ConfigItemModal, itemData: any) => "-" | JSX.Element;
|
|
11
11
|
avatar: (config: ConfigItemModal, itemData: any) => JSX.Element;
|
|
12
12
|
};
|
|
13
13
|
export default _default;
|
package/lib/render/config.js
CHANGED
|
@@ -136,9 +136,13 @@ var textRender = function textRender(config, itemData) {
|
|
|
136
136
|
var imageRender = function imageRender(config, itemData) {
|
|
137
137
|
var _config$valueTypeProp6 = config.valueTypeProps,
|
|
138
138
|
valueTypeProps = _config$valueTypeProp6 === void 0 ? {} : _config$valueTypeProp6;
|
|
139
|
+
var fallback = valueTypeProps.fallback;
|
|
139
140
|
var tableVal = getTableVal(config, itemData);
|
|
141
|
+
if (!fallback && tableVal === null) {
|
|
142
|
+
return "-";
|
|
143
|
+
}
|
|
140
144
|
return jsxRuntime.jsx(antd.Image, _objectSpread({
|
|
141
|
-
src: tableVal,
|
|
145
|
+
src: tableVal || "",
|
|
142
146
|
width: 48
|
|
143
147
|
}, valueTypeProps));
|
|
144
148
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/table",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.81",
|
|
4
4
|
"description": "基于antd二次开发table组件",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"table"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@babel/preset-env": "^7.23.2",
|
|
41
41
|
"@babel/preset-react": "^7.18.6",
|
|
42
42
|
"@babel/preset-typescript": "^7.21.5",
|
|
43
|
-
"@hw-component/form": "
|
|
43
|
+
"@hw-component/form": "1.10.37",
|
|
44
44
|
"@rollup/plugin-babel": "^6.0.3",
|
|
45
45
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
46
46
|
"@rollup/plugin-image": "^3.0.3",
|
|
@@ -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 {
|
|
@@ -12,16 +12,46 @@ interface IProps {
|
|
|
12
12
|
export default ({ headerTitle, contentStyle, rNode }: IProps) => {
|
|
13
13
|
const { tableInstance, selectedRowData, rowOnChange, allSelectChange } =
|
|
14
14
|
useHTableContext();
|
|
15
|
+
const bodyRef = useRef<any>();
|
|
16
|
+
const titleContentRef = useRef<any>();
|
|
17
|
+
const rightNodeRef = useRef<any>();
|
|
18
|
+
const [style, setStyle] = useState({});
|
|
15
19
|
const headerBox = useClassName("hw-table-header-title-box");
|
|
16
20
|
const headerBoxContent = useClassName("hw-table-header-title-box-content");
|
|
17
|
-
const
|
|
21
|
+
const titleClassname = useClassName("hw-table-header-title");
|
|
22
|
+
const rightNodeClassname = useClassName("hw-table-header-right-node");
|
|
23
|
+
const setHeaderStyle = () => {
|
|
24
|
+
const headerWidth = bodyRef.current?.clientWidth || 0;
|
|
25
|
+
const titleWidth = titleContentRef.current?.clientWidth || 0;
|
|
26
|
+
const rightNodeWidth = rightNodeRef.current?.clientWidth || 0;
|
|
27
|
+
if (rightNodeWidth + titleWidth >= headerWidth) {
|
|
28
|
+
setStyle({
|
|
29
|
+
overflow: "auto",
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setStyle({});
|
|
34
|
+
};
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
setHeaderStyle();
|
|
37
|
+
}, []);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const resizeFn = () => {
|
|
40
|
+
setHeaderStyle();
|
|
41
|
+
};
|
|
42
|
+
window.addEventListener("resize", resizeFn);
|
|
43
|
+
return () => {
|
|
44
|
+
window.removeEventListener("resize", resizeFn);
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
18
47
|
if (!headerTitle && !rNode) {
|
|
19
48
|
return null;
|
|
20
49
|
}
|
|
50
|
+
|
|
21
51
|
return (
|
|
22
|
-
<
|
|
23
|
-
<div className={headerBox} >
|
|
24
|
-
<div className={headerBoxContent}>
|
|
52
|
+
<div ref={bodyRef} className={titleClassname} style={contentStyle}>
|
|
53
|
+
<div className={headerBox} style={style}>
|
|
54
|
+
<div className={headerBoxContent} ref={titleContentRef}>
|
|
25
55
|
{headerTitle &&
|
|
26
56
|
React.cloneElement(
|
|
27
57
|
headerTitle as DetailedReactHTMLElement<any, any>,
|
|
@@ -29,7 +59,11 @@ export default ({ headerTitle, contentStyle, rNode }: IProps) => {
|
|
|
29
59
|
)}
|
|
30
60
|
</div>
|
|
31
61
|
</div>
|
|
32
|
-
{rNode &&
|
|
33
|
-
|
|
62
|
+
{rNode && (
|
|
63
|
+
<div className={rightNodeClassname} ref={rightNodeRef}>
|
|
64
|
+
{rNode}
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
</div>
|
|
34
68
|
);
|
|
35
69
|
};
|
|
@@ -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
|
};
|