@hw-component/table 1.10.2 → 1.10.5
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.
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TooltipProps } from "antd/lib/tooltip";
|
|
3
|
-
import type { HTableInstance } from "
|
|
3
|
+
import type { HTableInstance } from "../modal";
|
|
4
4
|
type CloseFn = (key: string, tableInstance?: HTableInstance) => void;
|
|
5
|
+
type TooltipRender = (item: any) => TooltipProps;
|
|
5
6
|
interface IProps {
|
|
6
7
|
data: any[];
|
|
7
8
|
closable?: boolean;
|
|
8
9
|
onClose?: CloseFn;
|
|
9
10
|
color?: string;
|
|
10
11
|
icon?: React.ReactNode;
|
|
11
|
-
tooltip?: boolean | TooltipProps;
|
|
12
|
+
tooltip?: boolean | TooltipProps | TooltipRender;
|
|
12
13
|
fieldNames?: {
|
|
13
14
|
label?: string;
|
|
14
15
|
value?: string;
|
|
@@ -22,7 +22,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
22
22
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[_Symbol$toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
23
|
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; }
|
|
24
24
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
|
-
var getTooltipProps = function getTooltipProps(
|
|
25
|
+
var getTooltipProps = function getTooltipProps(item, tooltip) {
|
|
26
|
+
var title = item.title;
|
|
26
27
|
if (!tooltip) {
|
|
27
28
|
return {
|
|
28
29
|
title: null
|
|
@@ -33,6 +34,9 @@ var getTooltipProps = function getTooltipProps(title, tooltip) {
|
|
|
33
34
|
title: title
|
|
34
35
|
};
|
|
35
36
|
}
|
|
37
|
+
if (typeof tooltip === "function") {
|
|
38
|
+
return tooltip(item);
|
|
39
|
+
}
|
|
36
40
|
return _objectSpread(_objectSpread({}, tooltip), {}, {
|
|
37
41
|
title: title
|
|
38
42
|
});
|
|
@@ -84,7 +88,9 @@ var TagsComponent = function TagsComponent(props) {
|
|
|
84
88
|
};
|
|
85
89
|
var indexKey = index.toString();
|
|
86
90
|
if (typeof tagItem === "string") {
|
|
87
|
-
var _tooltipProps = getTooltipProps(
|
|
91
|
+
var _tooltipProps = getTooltipProps({
|
|
92
|
+
title: tagItem
|
|
93
|
+
}, tooltip);
|
|
88
94
|
return jsx(Tooltip, _objectSpread(_objectSpread({}, _tooltipProps), {}, {
|
|
89
95
|
children: jsx(Tag, _objectSpread(_objectSpread({}, tagProps), {}, {
|
|
90
96
|
onClose: function onClose(e) {
|
|
@@ -98,7 +104,10 @@ var TagsComponent = function TagsComponent(props) {
|
|
|
98
104
|
var tagLabel = tagItem[label],
|
|
99
105
|
tagValue = tagItem[value],
|
|
100
106
|
itemProps = _objectWithoutProperties(tagItem, _mapInstanceProperty(_context = [label, value]).call(_context, _toPropertyKey));
|
|
101
|
-
var tooltipProps = getTooltipProps(
|
|
107
|
+
var tooltipProps = getTooltipProps(_objectSpread({
|
|
108
|
+
title: tagLabel,
|
|
109
|
+
value: tagValue
|
|
110
|
+
}, itemProps), tooltip);
|
|
102
111
|
var cuTagProps = _objectSpread(_objectSpread({}, tagProps), itemProps);
|
|
103
112
|
var cuKey = tagValue || indexKey;
|
|
104
113
|
return jsx(Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TooltipProps } from "antd/lib/tooltip";
|
|
3
|
-
import type { HTableInstance } from "
|
|
3
|
+
import type { HTableInstance } from "../modal";
|
|
4
4
|
type CloseFn = (key: string, tableInstance?: HTableInstance) => void;
|
|
5
|
+
type TooltipRender = (item: any) => TooltipProps;
|
|
5
6
|
interface IProps {
|
|
6
7
|
data: any[];
|
|
7
8
|
closable?: boolean;
|
|
8
9
|
onClose?: CloseFn;
|
|
9
10
|
color?: string;
|
|
10
11
|
icon?: React.ReactNode;
|
|
11
|
-
tooltip?: boolean | TooltipProps;
|
|
12
|
+
tooltip?: boolean | TooltipProps | TooltipRender;
|
|
12
13
|
fieldNames?: {
|
|
13
14
|
label?: string;
|
|
14
15
|
value?: string;
|
|
@@ -25,7 +25,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
25
25
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[_Symbol$toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
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; }
|
|
27
27
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
28
|
-
var getTooltipProps = function getTooltipProps(
|
|
28
|
+
var getTooltipProps = function getTooltipProps(item, tooltip) {
|
|
29
|
+
var title = item.title;
|
|
29
30
|
if (!tooltip) {
|
|
30
31
|
return {
|
|
31
32
|
title: null
|
|
@@ -36,6 +37,9 @@ var getTooltipProps = function getTooltipProps(title, tooltip) {
|
|
|
36
37
|
title: title
|
|
37
38
|
};
|
|
38
39
|
}
|
|
40
|
+
if (typeof tooltip === "function") {
|
|
41
|
+
return tooltip(item);
|
|
42
|
+
}
|
|
39
43
|
return _objectSpread(_objectSpread({}, tooltip), {}, {
|
|
40
44
|
title: title
|
|
41
45
|
});
|
|
@@ -87,7 +91,9 @@ var TagsComponent = function TagsComponent(props) {
|
|
|
87
91
|
};
|
|
88
92
|
var indexKey = index.toString();
|
|
89
93
|
if (typeof tagItem === "string") {
|
|
90
|
-
var _tooltipProps = getTooltipProps(
|
|
94
|
+
var _tooltipProps = getTooltipProps({
|
|
95
|
+
title: tagItem
|
|
96
|
+
}, tooltip);
|
|
91
97
|
return jsxRuntime.jsx(antd.Tooltip, _objectSpread(_objectSpread({}, _tooltipProps), {}, {
|
|
92
98
|
children: jsxRuntime.jsx(antd.Tag, _objectSpread(_objectSpread({}, tagProps), {}, {
|
|
93
99
|
onClose: function onClose(e) {
|
|
@@ -101,7 +107,10 @@ var TagsComponent = function TagsComponent(props) {
|
|
|
101
107
|
var tagLabel = tagItem[label],
|
|
102
108
|
tagValue = tagItem[value],
|
|
103
109
|
itemProps = _objectWithoutProperties(tagItem, _mapInstanceProperty(_context = [label, value]).call(_context, _toPropertyKey));
|
|
104
|
-
var tooltipProps = getTooltipProps(
|
|
110
|
+
var tooltipProps = getTooltipProps(_objectSpread({
|
|
111
|
+
title: tagLabel,
|
|
112
|
+
value: tagValue
|
|
113
|
+
}, itemProps), tooltip);
|
|
105
114
|
var cuTagProps = _objectSpread(_objectSpread({}, tagProps), itemProps);
|
|
106
115
|
var cuKey = tagValue || indexKey;
|
|
107
116
|
return jsxRuntime.jsx(antd.Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, {
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Row, Tag, Tooltip, Popover } from "antd";
|
|
2
2
|
import React, { useMemo } from "react";
|
|
3
3
|
import type { TooltipProps } from "antd/lib/tooltip";
|
|
4
|
-
import type { HTableInstance } from "
|
|
4
|
+
import type { HTableInstance } from "../modal";
|
|
5
|
+
|
|
5
6
|
type CloseFn = (key: string, tableInstance?: HTableInstance) => void;
|
|
7
|
+
type TooltipRender=(item:any)=>TooltipProps;
|
|
8
|
+
|
|
6
9
|
interface IProps {
|
|
7
10
|
data: any[];
|
|
8
11
|
closable?: boolean;
|
|
9
12
|
onClose?: CloseFn;
|
|
10
13
|
color?: string;
|
|
11
14
|
icon?: React.ReactNode;
|
|
12
|
-
tooltip?: boolean | TooltipProps;
|
|
15
|
+
tooltip?: boolean | TooltipProps|TooltipRender;
|
|
13
16
|
fieldNames?: { label?: string; value?: string };
|
|
14
17
|
tableInstance?: HTableInstance;
|
|
15
18
|
maxLen?: number | null;
|
|
@@ -18,9 +21,10 @@ interface IProps {
|
|
|
18
21
|
extra?: React.ReactNode;
|
|
19
22
|
}
|
|
20
23
|
const getTooltipProps = (
|
|
21
|
-
|
|
22
|
-
tooltip?: boolean | TooltipProps
|
|
24
|
+
item: any,
|
|
25
|
+
tooltip?: boolean | TooltipProps|TooltipRender
|
|
23
26
|
): TooltipProps => {
|
|
27
|
+
const {title}=item;
|
|
24
28
|
if (!tooltip) {
|
|
25
29
|
return {
|
|
26
30
|
title: null,
|
|
@@ -31,6 +35,9 @@ const getTooltipProps = (
|
|
|
31
35
|
title,
|
|
32
36
|
};
|
|
33
37
|
}
|
|
38
|
+
if (typeof tooltip === "function") {
|
|
39
|
+
return tooltip(item);
|
|
40
|
+
}
|
|
34
41
|
return {
|
|
35
42
|
...tooltip,
|
|
36
43
|
title,
|
|
@@ -77,7 +84,7 @@ const TagsComponent = (props: IProps) => {
|
|
|
77
84
|
};
|
|
78
85
|
const indexKey = index.toString();
|
|
79
86
|
if (typeof tagItem === "string") {
|
|
80
|
-
const tooltipProps = getTooltipProps(tagItem, tooltip);
|
|
87
|
+
const tooltipProps = getTooltipProps({title:tagItem}, tooltip);
|
|
81
88
|
return (
|
|
82
89
|
<Tooltip {...tooltipProps}>
|
|
83
90
|
<Tag
|
|
@@ -94,7 +101,7 @@ const TagsComponent = (props: IProps) => {
|
|
|
94
101
|
);
|
|
95
102
|
}
|
|
96
103
|
const { [label]: tagLabel, [value]: tagValue, ...itemProps } = tagItem;
|
|
97
|
-
const tooltipProps =
|
|
104
|
+
const tooltipProps = getTooltipProps({title:tagLabel,value:tagValue,...itemProps}, tooltip);
|
|
98
105
|
const cuTagProps = {
|
|
99
106
|
...tagProps,
|
|
100
107
|
...itemProps,
|
|
@@ -20,29 +20,8 @@ import { SettingOutlined } from "@ant-design/icons";
|
|
|
20
20
|
import ProTable from "@ant-design/pro-table";
|
|
21
21
|
import { useRequest } from "ahooks";
|
|
22
22
|
import { useEffect, useState } from "react";
|
|
23
|
+
import TagsComponent from "@/components/render/TagsComponent";
|
|
23
24
|
|
|
24
|
-
const TagsComponent = ({ data, labelKey }) => {
|
|
25
|
-
const len = data?.length;
|
|
26
|
-
if (!len) {
|
|
27
|
-
return <>-</>;
|
|
28
|
-
}
|
|
29
|
-
return (
|
|
30
|
-
<>
|
|
31
|
-
{data?.map((item, index) => {
|
|
32
|
-
const label =
|
|
33
|
-
"483607ad55fc115ae45219f661248a42b6c40a487f95469b39ee49420a2dc";
|
|
34
|
-
console.log(label.length);
|
|
35
|
-
return (
|
|
36
|
-
<Tag key={index} style={{ width: 120 }}>
|
|
37
|
-
<Typography.Text ellipsis copyable>
|
|
38
|
-
{label}
|
|
39
|
-
</Typography.Text>
|
|
40
|
-
</Tag>
|
|
41
|
-
);
|
|
42
|
-
})}
|
|
43
|
-
</>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
25
|
const Testd = (props) => {
|
|
47
26
|
return (
|
|
48
27
|
<div>
|
|
@@ -178,6 +157,11 @@ export default () => {
|
|
|
178
157
|
const [keys, setKeys] = useState([]);
|
|
179
158
|
return (
|
|
180
159
|
<HFormConfigProvider>
|
|
160
|
+
<TagsComponent data={["213123"]} tooltip={()=>{
|
|
161
|
+
return {
|
|
162
|
+
title:"3123"
|
|
163
|
+
}
|
|
164
|
+
}}/>
|
|
181
165
|
<div>
|
|
182
166
|
<div
|
|
183
167
|
onClick={() => {
|