@zykj2024/much-library 1.1.0 → 1.1.1-beta.1
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.
@@ -20,6 +20,28 @@ export default (function () {
|
|
20
20
|
},
|
21
21
|
text: "\u8FD9\u662F\u4E00\u6BB5\u6709\u6EA2\u51FA\u7684\u6587\u5B57\uFF0C\u8FD9\u662F\u4E00\u6BB5\u6709\u6EA2\u51FA\u7684\u6587\u5B57",
|
22
22
|
suffixCount: 4
|
23
|
+
}), /*#__PURE__*/_jsx(McEllipsisMiddle, {
|
24
|
+
style: {
|
25
|
+
width: 250
|
26
|
+
},
|
27
|
+
tooltip: "\u8FD9\u662Ftooltip\u7684\u5185\u5BB9",
|
28
|
+
noTooltip: true,
|
29
|
+
symbol: function symbol() {
|
30
|
+
return /*#__PURE__*/_jsx("div", {
|
31
|
+
children: "123"
|
32
|
+
});
|
33
|
+
},
|
34
|
+
text: "\u6587\u5B57\u548Ctooltip\u4F7F\u7528\u4E0D\u540C\u7684\u5185\u5BB9,\u6587\u5B57\u548Ctooltip\u4F7F\u7528\u4E0D\u540C\u7684\u5185\u5BB9",
|
35
|
+
suffixCount: 4
|
36
|
+
}), /*#__PURE__*/_jsx(McEllipsisMiddle, {
|
37
|
+
style: {
|
38
|
+
width: 150,
|
39
|
+
marginLeft: 12
|
40
|
+
},
|
41
|
+
tooltip: "\u8FD9\u662Ftooltip\u7684\u5185\u5BB9",
|
42
|
+
noTooltip: true,
|
43
|
+
text: "\u6211\u4E0D\u9700\u8981\u7701\u7565\u53F7",
|
44
|
+
suffixCount: 4
|
23
45
|
})]
|
24
46
|
});
|
25
47
|
});
|
@@ -3,9 +3,11 @@ import { TextProps } from 'antd/es/typography/Text';
|
|
3
3
|
import './index.less';
|
4
4
|
export interface McEllipsisMiddleProps extends TextProps {
|
5
5
|
text: string;
|
6
|
+
/** 自定义tooltip时, 无论是否省略都会展示 */
|
7
|
+
tooltip?: string;
|
6
8
|
/** 省略号结尾显示的字个数 */
|
7
9
|
suffixCount: number;
|
8
10
|
style?: React.CSSProperties;
|
9
11
|
className?: string;
|
10
12
|
}
|
11
|
-
export declare const McEllipsisMiddle: ({ text, suffixCount, style, className, ...rest }: McEllipsisMiddleProps) => import("react/jsx-runtime").JSX.Element;
|
13
|
+
export declare const McEllipsisMiddle: ({ text, tooltip, suffixCount, style, className, ...rest }: McEllipsisMiddleProps) => import("react/jsx-runtime").JSX.Element;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3
|
-
var _excluded = ["text", "suffixCount", "style", "className"];
|
4
|
-
import { Typography } from 'antd';
|
3
|
+
var _excluded = ["text", "tooltip", "suffixCount", "style", "className"];
|
4
|
+
import { Tooltip, Typography } from 'antd';
|
5
5
|
import "./index.css";
|
6
6
|
|
7
7
|
/** 中间省略 */
|
@@ -9,6 +9,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
var Text = Typography.Text;
|
10
10
|
export var McEllipsisMiddle = function McEllipsisMiddle(_ref) {
|
11
11
|
var text = _ref.text,
|
12
|
+
tooltip = _ref.tooltip,
|
12
13
|
suffixCount = _ref.suffixCount,
|
13
14
|
style = _ref.style,
|
14
15
|
className = _ref.className,
|
@@ -17,16 +18,25 @@ export var McEllipsisMiddle = function McEllipsisMiddle(_ref) {
|
|
17
18
|
var isBeyond = labelStr.length > suffixCount;
|
18
19
|
var start = isBeyond ? labelStr.slice(0, labelStr.length - suffixCount) : labelStr;
|
19
20
|
var suffix = isBeyond ? labelStr.slice(-suffixCount).trim() : '';
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
var renderText = function renderText(noTooltip) {
|
22
|
+
return /*#__PURE__*/_jsx(Text, _objectSpread(_objectSpread({
|
23
|
+
className: ['mc-ellipsis-middle', className].filter(Boolean).join(' '),
|
24
|
+
style: _objectSpread({
|
25
|
+
width: '100%'
|
26
|
+
}, style),
|
27
|
+
ellipsis: {
|
28
|
+
tooltip: !noTooltip && labelStr ? labelStr : false,
|
29
|
+
suffix: suffix
|
30
|
+
}
|
31
|
+
}, rest), {}, {
|
32
|
+
children: start
|
33
|
+
}));
|
34
|
+
};
|
35
|
+
if (tooltip) {
|
36
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
37
|
+
title: tooltip,
|
38
|
+
children: renderText(true)
|
39
|
+
});
|
40
|
+
}
|
41
|
+
return renderText(false);
|
32
42
|
};
|