ebaoferc 1.0.5 → 1.0.7

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.
@@ -0,0 +1,16 @@
1
+ import { TooltipProps } from 'antd';
2
+ import React from 'react';
3
+ interface OverflowTooltipProps {
4
+ /**显示的文本 */
5
+ text: string;
6
+ /** 支持最大显示行数 数字 */
7
+ maxLines?: number;
8
+ /** 自定义 Tooltip 属性 */
9
+ tooltipProps?: TooltipProps;
10
+ /** 自定义样式类名 */
11
+ className?: string;
12
+ /** 可选:指定最大宽度或使用容器宽度 */
13
+ tooltipMaxWidth?: number | 'container';
14
+ }
15
+ declare const OverflowTooltip: React.FC<OverflowTooltipProps>;
16
+ export default OverflowTooltip;
@@ -0,0 +1,102 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import { Tooltip } from 'antd';
14
+ import React, { useEffect, useRef, useState } from 'react';
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ var OverflowTooltip = function OverflowTooltip(_ref) {
17
+ var text = _ref.text,
18
+ _ref$maxLines = _ref.maxLines,
19
+ maxLines = _ref$maxLines === void 0 ? 2 : _ref$maxLines,
20
+ _ref$tooltipProps = _ref.tooltipProps,
21
+ tooltipProps = _ref$tooltipProps === void 0 ? {} : _ref$tooltipProps,
22
+ _ref$className = _ref.className,
23
+ className = _ref$className === void 0 ? '' : _ref$className,
24
+ _ref$tooltipMaxWidth = _ref.tooltipMaxWidth,
25
+ tooltipMaxWidth = _ref$tooltipMaxWidth === void 0 ? 'container' : _ref$tooltipMaxWidth;
26
+ var textRef = useRef(null);
27
+ var _useState = useState(false),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ showTooltip = _useState2[0],
30
+ setShowTooltip = _useState2[1];
31
+ var containerRef = useRef(null);
32
+ var _useState3 = useState(undefined),
33
+ _useState4 = _slicedToArray(_useState3, 2),
34
+ computedWidth = _useState4[0],
35
+ setComputedWidth = _useState4[1];
36
+
37
+ // 确定 Tooltip 宽度
38
+ var getTooltipWidth = function getTooltipWidth() {
39
+ if (typeof tooltipMaxWidth === 'number') return tooltipMaxWidth;
40
+ if (tooltipMaxWidth === 'container') return (computedWidth || 0) + 100;
41
+ return undefined;
42
+ };
43
+
44
+ // 组件挂载/更新时计算宽度
45
+ useEffect(function () {
46
+ if (containerRef.current && tooltipMaxWidth === 'container') {
47
+ setComputedWidth(containerRef.current.offsetWidth);
48
+ }
49
+ }, [text, tooltipMaxWidth]);
50
+
51
+ // 检测文本是否溢出
52
+ var checkOverflow = function checkOverflow() {
53
+ if (textRef.current) {
54
+ var _textRef$current = textRef.current,
55
+ scrollHeight = _textRef$current.scrollHeight,
56
+ clientHeight = _textRef$current.clientHeight;
57
+ setShowTooltip(scrollHeight > clientHeight);
58
+ }
59
+ };
60
+ var handleMouseEnter = function handleMouseEnter() {
61
+ checkOverflow();
62
+ };
63
+
64
+ // 动态生成行数限制样式
65
+ var lineClampStyle = {
66
+ display: '-webkit-box',
67
+ WebkitBoxOrient: 'vertical',
68
+ WebkitLineClamp: maxLines,
69
+ overflow: 'hidden',
70
+ textOverflow: 'ellipsis',
71
+ wordBreak: 'break-word' // 添加自动换行
72
+ };
73
+ return /*#__PURE__*/_jsx("div", {
74
+ ref: containerRef,
75
+ onMouseEnter: handleMouseEnter,
76
+ children: showTooltip ? /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({
77
+ title: text,
78
+ color: "#fff",
79
+ styles: {
80
+ body: {
81
+ width: getTooltipWidth(),
82
+ color: '#000',
83
+ lineHeight: '20px',
84
+ padding: '12px'
85
+ }
86
+ }
87
+ }, tooltipProps), {}, {
88
+ children: /*#__PURE__*/_jsx("div", {
89
+ ref: textRef,
90
+ style: lineClampStyle,
91
+ className: className,
92
+ children: text
93
+ })
94
+ })) : /*#__PURE__*/_jsx("div", {
95
+ ref: textRef,
96
+ style: lineClampStyle,
97
+ className: className,
98
+ children: text
99
+ })
100
+ });
101
+ };
102
+ export default OverflowTooltip;
@@ -1,6 +1,7 @@
1
1
  export { default as FlexRowCol } from './FlexRowCol';
2
2
  export * from './ImageViewTrigger';
3
3
  export * from './MindGraph';
4
+ export { default as OverflowTooltip } from './OverflowTooltip';
4
5
  export { default as QueryProCard } from './QueryProCard';
5
6
  export * from './SectionTitleBar';
6
7
  export { default as SliderVerify } from './SliderVerify';
@@ -1,6 +1,7 @@
1
1
  export { default as FlexRowCol } from "./FlexRowCol";
2
2
  export * from "./ImageViewTrigger";
3
3
  export * from "./MindGraph";
4
+ export { default as OverflowTooltip } from "./OverflowTooltip";
4
5
  export { default as QueryProCard } from "./QueryProCard";
5
6
  export * from "./SectionTitleBar";
6
7
  export { default as SliderVerify } from "./SliderVerify";
@@ -1,4 +1,3 @@
1
1
  export * from './useBIHooks';
2
2
  export * from './useEnhancePagination';
3
- export * from './useTabRouteWatcher';
4
3
  export * from './useTabsTablePagination/index';
@@ -1,4 +1,3 @@
1
1
  export * from "./useBIHooks";
2
2
  export * from "./useEnhancePagination";
3
- export * from "./useTabRouteWatcher";
4
3
  export * from "./useTabsTablePagination/index";
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "ebaoferc",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A react library developed with dumi",
5
- "license": "MIT",
6
5
  "module": "dist/index.js",
7
6
  "types": "dist/index.d.ts",
8
7
  "files": [
@@ -46,8 +45,7 @@
46
45
  },
47
46
  "dependencies": {
48
47
  "d3": "^7.9.0",
49
- "dagre": "^0.8.5",
50
- "@umijs/max": "^4.3.6"
48
+ "dagre": "^0.8.5"
51
49
  },
52
50
  "devDependencies": {
53
51
  "@ant-design/icons": "^5.3.7",
@@ -62,7 +60,7 @@
62
60
  "@umijs/max": "^4.3.6",
63
61
  "@vitest/coverage-v8": "^0.34.6",
64
62
  "ahooks": "^3.7.10",
65
- "antd": "^5.17.0",
63
+ "antd": "^5.24.7",
66
64
  "classnames": "^2.5.1",
67
65
  "connect-history-api-fallback": "^2.0.0",
68
66
  "cross-env": "^7.0.3",
@@ -1,5 +0,0 @@
1
- /**
2
- * 项目多tab模式,某个tab下,监听路由变化,当重新回到该tab时,执行回调
3
- * @param onRefresh 路由变化时执行的回调
4
- */
5
- export declare const useTabRouteWatcher: (onRefresh: () => void) => void;
@@ -1,26 +0,0 @@
1
- import { history } from '@umijs/max';
2
- import { useEffect, useRef } from 'react';
3
-
4
- /**
5
- * 项目多tab模式,某个tab下,监听路由变化,当重新回到该tab时,执行回调
6
- * @param onRefresh 路由变化时执行的回调
7
- */
8
- export var useTabRouteWatcher = function useTabRouteWatcher(onRefresh) {
9
- var pathname = useRef(window.location.pathname);
10
- useEffect(function () {
11
- var unlisten = history.listen(function (_ref) {
12
- var location = _ref.location;
13
- if (location.pathname === pathname.current) {
14
- try {
15
- onRefresh === null || onRefresh === void 0 || onRefresh();
16
- } catch (error) {
17
- console.error(error);
18
- }
19
- }
20
- });
21
- return function () {
22
- unlisten();
23
- };
24
- // eslint-disable-next-line react-hooks/exhaustive-deps
25
- }, []);
26
- };