@zat-design/sisyphus-react 3.13.1-beta.2 → 3.13.1-beta.4
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/es/ProForm/propsType.d.ts +4 -0
- package/es/ProIcon/index.js +7 -4
- package/es/ProTooltip/index.d.ts +0 -1
- package/es/ProTooltip/index.js +48 -59
- package/es/ProTooltip/propsType.d.ts +4 -4
- package/es/utils/index.d.ts +8 -0
- package/es/utils/index.js +17 -0
- package/lib/ProForm/propsType.d.ts +4 -0
- package/lib/ProIcon/index.js +7 -4
- package/lib/ProTooltip/index.d.ts +0 -1
- package/lib/ProTooltip/index.js +47 -58
- package/lib/ProTooltip/propsType.d.ts +4 -4
- package/lib/utils/index.d.ts +8 -0
- package/lib/utils/index.js +18 -1
- package/package.json +1 -1
@@ -65,6 +65,10 @@ export interface ProFormType<Values = any> extends FormProps<Values> {
|
|
65
65
|
/** 全局控制优先 */
|
66
66
|
globalControl?: boolean;
|
67
67
|
mode?: ModeEnum;
|
68
|
+
/**
|
69
|
+
* 如果有formKey,则会在全局中查找或创建表单实例
|
70
|
+
* 可以不需要手动传入form实例 且formKey的优先级高于form
|
71
|
+
*/
|
68
72
|
formKey?: string;
|
69
73
|
/** 是否查看 */
|
70
74
|
isView?: boolean;
|
package/es/ProIcon/index.js
CHANGED
@@ -135,6 +135,9 @@ var ProIcon = function ProIcon(props) {
|
|
135
135
|
}, rotateStyle), style)
|
136
136
|
};
|
137
137
|
var icon = !src ? _jsx("svg", _objectSpread(_objectSpread({}, svgProps), {}, {
|
138
|
+
style: _objectSpread({
|
139
|
+
color: color
|
140
|
+
}, svgProps === null || svgProps === void 0 ? void 0 : svgProps.style),
|
138
141
|
onClick: onClick,
|
139
142
|
"aria-hidden": "true",
|
140
143
|
children: _jsx("use", {
|
@@ -151,13 +154,13 @@ var ProIcon = function ProIcon(props) {
|
|
151
154
|
actionMap: actionMap,
|
152
155
|
primaryColor: isQiankun ? qiankunPrimaryColor : primaryColor
|
153
156
|
});
|
157
|
+
if (color) {
|
158
|
+
svg.setAttribute('fill', color);
|
159
|
+
}
|
154
160
|
}
|
155
161
|
}));
|
156
162
|
var RenderIcon = _jsx("span", _objectSpread(_objectSpread({
|
157
|
-
className: "anticon"
|
158
|
-
style: {
|
159
|
-
color: color
|
160
|
-
}
|
163
|
+
className: "anticon"
|
161
164
|
}, reset), {}, {
|
162
165
|
children: _jsx(_Tooltip, {
|
163
166
|
title: iconText,
|
package/es/ProTooltip/index.d.ts
CHANGED
package/es/ProTooltip/index.js
CHANGED
@@ -4,32 +4,31 @@ import "antd/es/tooltip/style";
|
|
4
4
|
import _Tooltip from "antd/es/tooltip";
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
6
6
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
7
|
-
var _excluded = ["text", "mode", "width", "line", "
|
7
|
+
var _excluded = ["text", "mode", "width", "line", "className", "style", "lineHeight", "scrollFollowParent"];
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
9
|
-
import { useSize, useSetState, useDebounce
|
9
|
+
import { useSize, useSetState, useDebounce } from 'ahooks';
|
10
10
|
import { useEffect, useRef } from 'react';
|
11
11
|
import classnames from 'classnames';
|
12
|
-
import '
|
12
|
+
import { isEllipsisActive } from '../utils';
|
13
13
|
var ProTooltip = function ProTooltip(props) {
|
14
|
-
var _useSize;
|
14
|
+
var _useSize, _parentElement$tagNam;
|
15
15
|
var ref = useRef();
|
16
16
|
var childRef = useRef();
|
17
17
|
var contentWrapRef = useRef();
|
18
18
|
var text = props.text,
|
19
19
|
_props$mode = props.mode,
|
20
20
|
mode = _props$mode === void 0 ? 'default' : _props$mode,
|
21
|
-
|
22
|
-
width = _props$width === void 0 ? '120px' : _props$width,
|
21
|
+
width = props.width,
|
23
22
|
_props$line = props.line,
|
24
23
|
line = _props$line === void 0 ? 1 : _props$line,
|
25
|
-
_props$isResponsiveWi = props.isResponsiveWidth,
|
26
|
-
isResponsiveWidth = _props$isResponsiveWi === void 0 ? false : _props$isResponsiveWi,
|
27
24
|
_props$className = props.className,
|
28
25
|
className = _props$className === void 0 ? '' : _props$className,
|
29
26
|
_props$style = props.style,
|
30
27
|
style = _props$style === void 0 ? {} : _props$style,
|
31
28
|
_props$lineHeight = props.lineHeight,
|
32
29
|
lineHeight = _props$lineHeight === void 0 ? 22 : _props$lineHeight,
|
30
|
+
_props$scrollFollowPa = props.scrollFollowParent,
|
31
|
+
scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa,
|
33
32
|
restProps = _objectWithoutProperties(props, _excluded);
|
34
33
|
var _width = mode === 'auto' ? 'auto' : width;
|
35
34
|
var content = text !== null && text !== void 0 ? text : '-';
|
@@ -59,6 +58,7 @@ var ProTooltip = function ProTooltip(props) {
|
|
59
58
|
});
|
60
59
|
var _ref = (_useSize = useSize(localElement)) !== null && _useSize !== void 0 ? _useSize : {},
|
61
60
|
_localSizeWidth = _ref.width;
|
61
|
+
var isTable = (parentElement === null || parentElement === void 0 ? void 0 : (_parentElement$tagNam = parentElement.tagName) === null || _parentElement$tagNam === void 0 ? void 0 : _parentElement$tagNam.toLowerCase()) === 'td';
|
62
62
|
var overlayStyle = mode === 'auto' ? {
|
63
63
|
maxWidth: _localSizeWidth
|
64
64
|
} : {};
|
@@ -141,23 +141,6 @@ var ProTooltip = function ProTooltip(props) {
|
|
141
141
|
}
|
142
142
|
return line > 1 ? _jsx(AutoMixinMulti, {}) : _jsx(AutoMixinSingle, {});
|
143
143
|
};
|
144
|
-
useDebounceEffect(function () {
|
145
|
-
if (isResponsiveWidth && parentElement) {
|
146
|
-
var cWidth = parentElement.clientWidth - 32;
|
147
|
-
var contentDom = childRef.current;
|
148
|
-
setState({
|
149
|
-
isShowToolTip: contentDom.scrollWidth > contentDom.offsetWidth,
|
150
|
-
localWidth: cWidth
|
151
|
-
});
|
152
|
-
}
|
153
|
-
if (!isResponsiveWidth) {
|
154
|
-
setState({
|
155
|
-
localWidth: _width
|
156
|
-
});
|
157
|
-
}
|
158
|
-
}, [isResponsiveWidth, size], {
|
159
|
-
wait: 300
|
160
|
-
});
|
161
144
|
useEffect(function () {
|
162
145
|
if (mode === 'auto' && line === 1) {
|
163
146
|
var localDom = ref.current;
|
@@ -237,57 +220,63 @@ var ProTooltip = function ProTooltip(props) {
|
|
237
220
|
}, [debouncedValue]);
|
238
221
|
useEffect(function () {
|
239
222
|
var localDom = ref.current;
|
240
|
-
var
|
223
|
+
var isEllipsis = isEllipsisActive(childRef === null || childRef === void 0 ? void 0 : childRef.current);
|
241
224
|
setState({
|
242
225
|
parentElement: localDom.parentElement,
|
243
|
-
isShowToolTip:
|
226
|
+
isShowToolTip: isEllipsis
|
244
227
|
});
|
245
228
|
}, []);
|
246
229
|
var cls = classnames(_defineProperty({
|
247
230
|
'pro-tooltip': true
|
248
231
|
}, "".concat(className), className));
|
249
|
-
|
250
|
-
|
251
|
-
ref: ref,
|
252
|
-
style: _objectSpread(_objectSpread(_objectSpread({}, style), multiStyle), {}, {
|
253
|
-
width: localWidth
|
254
|
-
}),
|
255
|
-
children: isResponsiveWidth && isShowToolTip ? _jsx(_Tooltip, _objectSpread(_objectSpread({
|
256
|
-
title: text,
|
257
|
-
getPopupContainer: function getPopupContainer(triggerNode) {
|
258
|
-
return triggerNode.parentNode;
|
259
|
-
}
|
260
|
-
}, restProps), {}, {
|
261
|
-
children: _jsx("div", {
|
262
|
-
className: isMultiLine ? 'multiLine' : 'singleLine',
|
263
|
-
style: _objectSpread(_objectSpread({}, multiStyle), {}, {
|
264
|
-
width: localWidth
|
265
|
-
}),
|
266
|
-
ref: childRef,
|
267
|
-
children: content
|
268
|
-
})
|
269
|
-
})) : isResponsiveWidth ? _jsx("div", {
|
232
|
+
var renderContentBox = function renderContentBox() {
|
233
|
+
return _jsx("div", {
|
270
234
|
className: isMultiLine ? 'multiLine' : 'singleLine',
|
271
235
|
style: _objectSpread(_objectSpread({}, multiStyle), {}, {
|
272
236
|
width: localWidth
|
273
237
|
}),
|
274
238
|
ref: childRef,
|
275
239
|
children: content
|
276
|
-
})
|
240
|
+
});
|
241
|
+
};
|
242
|
+
var renderTooltipContent = function renderTooltipContent() {
|
243
|
+
return _jsx(_Tooltip, _objectSpread(_objectSpread({
|
277
244
|
title: text,
|
278
245
|
getPopupContainer: function getPopupContainer(triggerNode) {
|
279
|
-
|
246
|
+
// 修复scrollFollowParent为false时tooltip不显示的问题
|
247
|
+
// 当scrollFollowParent为false时,应该返回document.body而不是triggerNode本身
|
248
|
+
return scrollFollowParent ? triggerNode.parentNode : document.body;
|
280
249
|
}
|
281
250
|
}, restProps), {}, {
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
})
|
290
|
-
}
|
251
|
+
overlayStyle: mode === 'auto' ? overlayStyle : {},
|
252
|
+
children: renderContentBox()
|
253
|
+
}));
|
254
|
+
};
|
255
|
+
var renderContent = function renderContent() {
|
256
|
+
// 自动模式使用专门的渲染逻辑
|
257
|
+
if (mode === 'auto') {
|
258
|
+
return _jsx(AutoMixin, {});
|
259
|
+
}
|
260
|
+
// 响应式宽度模式,根据是否需要显示tooltip决定渲染内容 且 父元素为table
|
261
|
+
if (isTable) {
|
262
|
+
if (isShowToolTip) {
|
263
|
+
return renderTooltipContent();
|
264
|
+
}
|
265
|
+
return renderContentBox();
|
266
|
+
}
|
267
|
+
// 默认模式始终显示tooltip
|
268
|
+
if (mode === 'default') {
|
269
|
+
return renderTooltipContent();
|
270
|
+
}
|
271
|
+
return renderContentBox();
|
272
|
+
};
|
273
|
+
return _jsx("div", {
|
274
|
+
className: cls,
|
275
|
+
ref: ref,
|
276
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, style), multiStyle), {}, {
|
277
|
+
width: localWidth
|
278
|
+
}),
|
279
|
+
children: renderContent()
|
291
280
|
});
|
292
281
|
};
|
293
282
|
export default ProTooltip;
|
@@ -19,11 +19,11 @@ export interface ProTooltipType {
|
|
19
19
|
*/
|
20
20
|
line?: number;
|
21
21
|
/**
|
22
|
-
*
|
23
|
-
* @description
|
24
|
-
* @default
|
22
|
+
* 是否跟随父元素滚动
|
23
|
+
* @description 启用后,提示框将跟随父元素滚动
|
24
|
+
* @default true
|
25
25
|
*/
|
26
|
-
|
26
|
+
scrollFollowParent?: boolean;
|
27
27
|
/**
|
28
28
|
* 自定义类名
|
29
29
|
* @description 额外的CSS类名
|
package/es/utils/index.d.ts
CHANGED
@@ -3,4 +3,12 @@
|
|
3
3
|
* 空值 或者 仅包含空值的数组视为空
|
4
4
|
*/
|
5
5
|
export declare const isEmpty: (value: any, emptyValue?: string) => boolean;
|
6
|
+
/**
|
7
|
+
* 判断一个元素是否触发了省略号(文本溢出)
|
8
|
+
* 如果元素设置为单行(white-space: nowrap)则比较 scrollWidth 与 clientWidth,
|
9
|
+
* 如果是多行文本(例如使用 -webkit-line-clamp 实现多行截断)则比较 scrollHeight 与 clientHeight。
|
10
|
+
* @param {HTMLElement} element 要检测的元素
|
11
|
+
* @returns {boolean} 如果内容溢出返回 true,否则返回 false
|
12
|
+
*/
|
13
|
+
export declare const isEllipsisActive: (element: Element) => boolean;
|
6
14
|
export declare const useFocus: (element: Element) => boolean;
|
package/es/utils/index.js
CHANGED
@@ -19,6 +19,23 @@ export var isEmpty = function isEmpty(value, emptyValue) {
|
|
19
19
|
}
|
20
20
|
return false;
|
21
21
|
};
|
22
|
+
/**
|
23
|
+
* 判断一个元素是否触发了省略号(文本溢出)
|
24
|
+
* 如果元素设置为单行(white-space: nowrap)则比较 scrollWidth 与 clientWidth,
|
25
|
+
* 如果是多行文本(例如使用 -webkit-line-clamp 实现多行截断)则比较 scrollHeight 与 clientHeight。
|
26
|
+
* @param {HTMLElement} element 要检测的元素
|
27
|
+
* @returns {boolean} 如果内容溢出返回 true,否则返回 false
|
28
|
+
*/
|
29
|
+
export var isEllipsisActive = function isEllipsisActive(element) {
|
30
|
+
if (!element) return false;
|
31
|
+
var computedStyle = window.getComputedStyle(element);
|
32
|
+
// 如果使用单行显示(nowrap),则判断宽度是否足够
|
33
|
+
if (computedStyle.whiteSpace === 'nowrap') {
|
34
|
+
return element.scrollWidth > element.clientWidth;
|
35
|
+
}
|
36
|
+
// 多行情况下,判断高度是否足够
|
37
|
+
return element.scrollHeight > element.clientHeight;
|
38
|
+
};
|
22
39
|
export var useFocus = function useFocus(element) {
|
23
40
|
var _useState = useState(false),
|
24
41
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -65,6 +65,10 @@ export interface ProFormType<Values = any> extends FormProps<Values> {
|
|
65
65
|
/** 全局控制优先 */
|
66
66
|
globalControl?: boolean;
|
67
67
|
mode?: ModeEnum;
|
68
|
+
/**
|
69
|
+
* 如果有formKey,则会在全局中查找或创建表单实例
|
70
|
+
* 可以不需要手动传入form实例 且formKey的优先级高于form
|
71
|
+
*/
|
68
72
|
formKey?: string;
|
69
73
|
/** 是否查看 */
|
70
74
|
isView?: boolean;
|
package/lib/ProIcon/index.js
CHANGED
@@ -137,6 +137,9 @@ var ProIcon = function ProIcon(props) {
|
|
137
137
|
}, rotateStyle), style)
|
138
138
|
};
|
139
139
|
var icon = !src ? (0, _jsxRuntime.jsx)("svg", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, svgProps), {}, {
|
140
|
+
style: (0, _objectSpread2.default)({
|
141
|
+
color: color
|
142
|
+
}, svgProps === null || svgProps === void 0 ? void 0 : svgProps.style),
|
140
143
|
onClick: onClick,
|
141
144
|
"aria-hidden": "true",
|
142
145
|
children: (0, _jsxRuntime.jsx)("use", {
|
@@ -153,13 +156,13 @@ var ProIcon = function ProIcon(props) {
|
|
153
156
|
actionMap: actionMap,
|
154
157
|
primaryColor: isQiankun ? qiankunPrimaryColor : primaryColor
|
155
158
|
});
|
159
|
+
if (color) {
|
160
|
+
svg.setAttribute('fill', color);
|
161
|
+
}
|
156
162
|
}
|
157
163
|
}));
|
158
164
|
var RenderIcon = (0, _jsxRuntime.jsx)("span", (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
159
|
-
className: "anticon"
|
160
|
-
style: {
|
161
|
-
color: color
|
162
|
-
}
|
165
|
+
className: "anticon"
|
163
166
|
}, reset), {}, {
|
164
167
|
children: (0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
165
168
|
title: iconText,
|
package/lib/ProTooltip/index.js
CHANGED
@@ -14,28 +14,27 @@ var _ahooks = require("ahooks");
|
|
14
14
|
var _antd = require("antd");
|
15
15
|
var _react = require("react");
|
16
16
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
17
|
-
require("
|
18
|
-
var _excluded = ["text", "mode", "width", "line", "
|
17
|
+
var _utils = require("../utils");
|
18
|
+
var _excluded = ["text", "mode", "width", "line", "className", "style", "lineHeight", "scrollFollowParent"];
|
19
19
|
var ProTooltip = function ProTooltip(props) {
|
20
|
-
var _useSize;
|
20
|
+
var _useSize, _parentElement$tagNam;
|
21
21
|
var ref = (0, _react.useRef)();
|
22
22
|
var childRef = (0, _react.useRef)();
|
23
23
|
var contentWrapRef = (0, _react.useRef)();
|
24
24
|
var text = props.text,
|
25
25
|
_props$mode = props.mode,
|
26
26
|
mode = _props$mode === void 0 ? 'default' : _props$mode,
|
27
|
-
|
28
|
-
width = _props$width === void 0 ? '120px' : _props$width,
|
27
|
+
width = props.width,
|
29
28
|
_props$line = props.line,
|
30
29
|
line = _props$line === void 0 ? 1 : _props$line,
|
31
|
-
_props$isResponsiveWi = props.isResponsiveWidth,
|
32
|
-
isResponsiveWidth = _props$isResponsiveWi === void 0 ? false : _props$isResponsiveWi,
|
33
30
|
_props$className = props.className,
|
34
31
|
className = _props$className === void 0 ? '' : _props$className,
|
35
32
|
_props$style = props.style,
|
36
33
|
style = _props$style === void 0 ? {} : _props$style,
|
37
34
|
_props$lineHeight = props.lineHeight,
|
38
35
|
lineHeight = _props$lineHeight === void 0 ? 22 : _props$lineHeight,
|
36
|
+
_props$scrollFollowPa = props.scrollFollowParent,
|
37
|
+
scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa,
|
39
38
|
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
40
39
|
var _width = mode === 'auto' ? 'auto' : width;
|
41
40
|
var content = text !== null && text !== void 0 ? text : '-';
|
@@ -65,6 +64,7 @@ var ProTooltip = function ProTooltip(props) {
|
|
65
64
|
});
|
66
65
|
var _ref = (_useSize = (0, _ahooks.useSize)(localElement)) !== null && _useSize !== void 0 ? _useSize : {},
|
67
66
|
_localSizeWidth = _ref.width;
|
67
|
+
var isTable = (parentElement === null || parentElement === void 0 ? void 0 : (_parentElement$tagNam = parentElement.tagName) === null || _parentElement$tagNam === void 0 ? void 0 : _parentElement$tagNam.toLowerCase()) === 'td';
|
68
68
|
var overlayStyle = mode === 'auto' ? {
|
69
69
|
maxWidth: _localSizeWidth
|
70
70
|
} : {};
|
@@ -147,23 +147,6 @@ var ProTooltip = function ProTooltip(props) {
|
|
147
147
|
}
|
148
148
|
return line > 1 ? (0, _jsxRuntime.jsx)(AutoMixinMulti, {}) : (0, _jsxRuntime.jsx)(AutoMixinSingle, {});
|
149
149
|
};
|
150
|
-
(0, _ahooks.useDebounceEffect)(function () {
|
151
|
-
if (isResponsiveWidth && parentElement) {
|
152
|
-
var cWidth = parentElement.clientWidth - 32;
|
153
|
-
var contentDom = childRef.current;
|
154
|
-
setState({
|
155
|
-
isShowToolTip: contentDom.scrollWidth > contentDom.offsetWidth,
|
156
|
-
localWidth: cWidth
|
157
|
-
});
|
158
|
-
}
|
159
|
-
if (!isResponsiveWidth) {
|
160
|
-
setState({
|
161
|
-
localWidth: _width
|
162
|
-
});
|
163
|
-
}
|
164
|
-
}, [isResponsiveWidth, size], {
|
165
|
-
wait: 300
|
166
|
-
});
|
167
150
|
(0, _react.useEffect)(function () {
|
168
151
|
if (mode === 'auto' && line === 1) {
|
169
152
|
var localDom = ref.current;
|
@@ -243,57 +226,63 @@ var ProTooltip = function ProTooltip(props) {
|
|
243
226
|
}, [debouncedValue]);
|
244
227
|
(0, _react.useEffect)(function () {
|
245
228
|
var localDom = ref.current;
|
246
|
-
var
|
229
|
+
var isEllipsis = (0, _utils.isEllipsisActive)(childRef === null || childRef === void 0 ? void 0 : childRef.current);
|
247
230
|
setState({
|
248
231
|
parentElement: localDom.parentElement,
|
249
|
-
isShowToolTip:
|
232
|
+
isShowToolTip: isEllipsis
|
250
233
|
});
|
251
234
|
}, []);
|
252
235
|
var cls = (0, _classnames2.default)((0, _defineProperty2.default)({
|
253
236
|
'pro-tooltip': true
|
254
237
|
}, "".concat(className), className));
|
255
|
-
|
256
|
-
|
257
|
-
ref: ref,
|
258
|
-
style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, style), multiStyle), {}, {
|
259
|
-
width: localWidth
|
260
|
-
}),
|
261
|
-
children: isResponsiveWidth && isShowToolTip ? (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
262
|
-
title: text,
|
263
|
-
getPopupContainer: function getPopupContainer(triggerNode) {
|
264
|
-
return triggerNode.parentNode;
|
265
|
-
}
|
266
|
-
}, restProps), {}, {
|
267
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
268
|
-
className: isMultiLine ? 'multiLine' : 'singleLine',
|
269
|
-
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, multiStyle), {}, {
|
270
|
-
width: localWidth
|
271
|
-
}),
|
272
|
-
ref: childRef,
|
273
|
-
children: content
|
274
|
-
})
|
275
|
-
})) : isResponsiveWidth ? (0, _jsxRuntime.jsx)("div", {
|
238
|
+
var renderContentBox = function renderContentBox() {
|
239
|
+
return (0, _jsxRuntime.jsx)("div", {
|
276
240
|
className: isMultiLine ? 'multiLine' : 'singleLine',
|
277
241
|
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, multiStyle), {}, {
|
278
242
|
width: localWidth
|
279
243
|
}),
|
280
244
|
ref: childRef,
|
281
245
|
children: content
|
282
|
-
})
|
246
|
+
});
|
247
|
+
};
|
248
|
+
var renderTooltipContent = function renderTooltipContent() {
|
249
|
+
return (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
283
250
|
title: text,
|
284
251
|
getPopupContainer: function getPopupContainer(triggerNode) {
|
285
|
-
|
252
|
+
// 修复scrollFollowParent为false时tooltip不显示的问题
|
253
|
+
// 当scrollFollowParent为false时,应该返回document.body而不是triggerNode本身
|
254
|
+
return scrollFollowParent ? triggerNode.parentNode : document.body;
|
286
255
|
}
|
287
256
|
}, restProps), {}, {
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
})
|
296
|
-
}
|
257
|
+
overlayStyle: mode === 'auto' ? overlayStyle : {},
|
258
|
+
children: renderContentBox()
|
259
|
+
}));
|
260
|
+
};
|
261
|
+
var renderContent = function renderContent() {
|
262
|
+
// 自动模式使用专门的渲染逻辑
|
263
|
+
if (mode === 'auto') {
|
264
|
+
return (0, _jsxRuntime.jsx)(AutoMixin, {});
|
265
|
+
}
|
266
|
+
// 响应式宽度模式,根据是否需要显示tooltip决定渲染内容 且 父元素为table
|
267
|
+
if (isTable) {
|
268
|
+
if (isShowToolTip) {
|
269
|
+
return renderTooltipContent();
|
270
|
+
}
|
271
|
+
return renderContentBox();
|
272
|
+
}
|
273
|
+
// 默认模式始终显示tooltip
|
274
|
+
if (mode === 'default') {
|
275
|
+
return renderTooltipContent();
|
276
|
+
}
|
277
|
+
return renderContentBox();
|
278
|
+
};
|
279
|
+
return (0, _jsxRuntime.jsx)("div", {
|
280
|
+
className: cls,
|
281
|
+
ref: ref,
|
282
|
+
style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, style), multiStyle), {}, {
|
283
|
+
width: localWidth
|
284
|
+
}),
|
285
|
+
children: renderContent()
|
297
286
|
});
|
298
287
|
};
|
299
288
|
var _default = exports.default = ProTooltip;
|
@@ -19,11 +19,11 @@ export interface ProTooltipType {
|
|
19
19
|
*/
|
20
20
|
line?: number;
|
21
21
|
/**
|
22
|
-
*
|
23
|
-
* @description
|
24
|
-
* @default
|
22
|
+
* 是否跟随父元素滚动
|
23
|
+
* @description 启用后,提示框将跟随父元素滚动
|
24
|
+
* @default true
|
25
25
|
*/
|
26
|
-
|
26
|
+
scrollFollowParent?: boolean;
|
27
27
|
/**
|
28
28
|
* 自定义类名
|
29
29
|
* @description 额外的CSS类名
|
package/lib/utils/index.d.ts
CHANGED
@@ -3,4 +3,12 @@
|
|
3
3
|
* 空值 或者 仅包含空值的数组视为空
|
4
4
|
*/
|
5
5
|
export declare const isEmpty: (value: any, emptyValue?: string) => boolean;
|
6
|
+
/**
|
7
|
+
* 判断一个元素是否触发了省略号(文本溢出)
|
8
|
+
* 如果元素设置为单行(white-space: nowrap)则比较 scrollWidth 与 clientWidth,
|
9
|
+
* 如果是多行文本(例如使用 -webkit-line-clamp 实现多行截断)则比较 scrollHeight 与 clientHeight。
|
10
|
+
* @param {HTMLElement} element 要检测的元素
|
11
|
+
* @returns {boolean} 如果内容溢出返回 true,否则返回 false
|
12
|
+
*/
|
13
|
+
export declare const isEllipsisActive: (element: Element) => boolean;
|
6
14
|
export declare const useFocus: (element: Element) => boolean;
|
package/lib/utils/index.js
CHANGED
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
5
5
|
value: true
|
6
6
|
});
|
7
|
-
exports.useFocus = exports.isEmpty = void 0;
|
7
|
+
exports.useFocus = exports.isEmpty = exports.isEllipsisActive = void 0;
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
9
9
|
var _react = require("react");
|
10
10
|
var EMPTY_VALUE = [undefined, null, ''];
|
@@ -26,6 +26,23 @@ var isEmpty = exports.isEmpty = function isEmpty(value, emptyValue) {
|
|
26
26
|
}
|
27
27
|
return false;
|
28
28
|
};
|
29
|
+
/**
|
30
|
+
* 判断一个元素是否触发了省略号(文本溢出)
|
31
|
+
* 如果元素设置为单行(white-space: nowrap)则比较 scrollWidth 与 clientWidth,
|
32
|
+
* 如果是多行文本(例如使用 -webkit-line-clamp 实现多行截断)则比较 scrollHeight 与 clientHeight。
|
33
|
+
* @param {HTMLElement} element 要检测的元素
|
34
|
+
* @returns {boolean} 如果内容溢出返回 true,否则返回 false
|
35
|
+
*/
|
36
|
+
var isEllipsisActive = exports.isEllipsisActive = function isEllipsisActive(element) {
|
37
|
+
if (!element) return false;
|
38
|
+
var computedStyle = window.getComputedStyle(element);
|
39
|
+
// 如果使用单行显示(nowrap),则判断宽度是否足够
|
40
|
+
if (computedStyle.whiteSpace === 'nowrap') {
|
41
|
+
return element.scrollWidth > element.clientWidth;
|
42
|
+
}
|
43
|
+
// 多行情况下,判断高度是否足够
|
44
|
+
return element.scrollHeight > element.clientHeight;
|
45
|
+
};
|
29
46
|
var useFocus = exports.useFocus = function useFocus(element) {
|
30
47
|
var _useState = (0, _react.useState)(false),
|
31
48
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|