@zat-design/sisyphus-react 3.13.1 → 3.13.2-beta.2
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/dist/index.esm.css +3 -0
- package/dist/less.esm.css +3 -0
- package/es/ProForm/components/render/RenderFields.js +5 -1
- package/es/ProForm/components/render/propsType.d.ts +6 -1
- package/es/ProForm/propsType.d.ts +4 -0
- package/es/ProForm/utils/processDependencies.d.ts +29 -0
- package/es/ProForm/utils/processDependencies.js +55 -0
- package/es/ProIcon/index.js +7 -4
- package/es/ProLayout/components/ProCollapse/index.js +2 -0
- package/es/ProStepTab/index.js +14 -10
- package/es/ProTable/components/RenderColumn/index.js +28 -25
- package/es/ProTable/hooks/useAntdTable.js +3 -9
- package/es/ProTable/style/index.less +3 -0
- package/es/ProTable/utils/index.d.ts +2 -6
- package/es/ProTable/utils/index.js +20 -14
- package/es/ProTooltip/index.d.ts +0 -1
- package/es/ProTooltip/index.js +54 -58
- package/es/ProTooltip/propsType.d.ts +5 -6
- package/es/utils/index.d.ts +8 -0
- package/es/utils/index.js +17 -0
- package/lib/ProForm/components/render/RenderFields.js +5 -1
- package/lib/ProForm/components/render/propsType.d.ts +6 -1
- package/lib/ProForm/propsType.d.ts +4 -0
- package/lib/ProForm/utils/processDependencies.d.ts +29 -0
- package/lib/ProForm/utils/processDependencies.js +63 -0
- package/lib/ProIcon/index.js +7 -4
- package/lib/ProLayout/components/ProCollapse/index.js +2 -0
- package/lib/ProStepTab/index.js +14 -10
- package/lib/ProTable/components/RenderColumn/index.js +26 -23
- package/lib/ProTable/hooks/useAntdTable.js +3 -9
- package/lib/ProTable/style/index.less +3 -0
- package/lib/ProTable/utils/index.d.ts +2 -6
- package/lib/ProTable/utils/index.js +21 -15
- package/lib/ProTooltip/index.d.ts +0 -1
- package/lib/ProTooltip/index.js +53 -57
- package/lib/ProTooltip/propsType.d.ts +5 -6
- package/lib/utils/index.d.ts +8 -0
- package/lib/utils/index.js +18 -1
- package/package.json +1 -1
package/lib/ProTooltip/index.js
CHANGED
@@ -14,8 +14,15 @@ 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
|
+
var _findTableParent = function findTableParent(element) {
|
20
|
+
var _element$tagName;
|
21
|
+
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
22
|
+
if (!element || depth >= 3) return false;
|
23
|
+
if (((_element$tagName = element.tagName) === null || _element$tagName === void 0 ? void 0 : _element$tagName.toLowerCase()) === 'td') return true;
|
24
|
+
return _findTableParent(element.parentElement, depth + 1);
|
25
|
+
};
|
19
26
|
var ProTooltip = function ProTooltip(props) {
|
20
27
|
var _useSize;
|
21
28
|
var ref = (0, _react.useRef)();
|
@@ -24,18 +31,17 @@ var ProTooltip = function ProTooltip(props) {
|
|
24
31
|
var text = props.text,
|
25
32
|
_props$mode = props.mode,
|
26
33
|
mode = _props$mode === void 0 ? 'default' : _props$mode,
|
27
|
-
|
28
|
-
width = _props$width === void 0 ? '120px' : _props$width,
|
34
|
+
width = props.width,
|
29
35
|
_props$line = props.line,
|
30
36
|
line = _props$line === void 0 ? 1 : _props$line,
|
31
|
-
_props$isResponsiveWi = props.isResponsiveWidth,
|
32
|
-
isResponsiveWidth = _props$isResponsiveWi === void 0 ? false : _props$isResponsiveWi,
|
33
37
|
_props$className = props.className,
|
34
38
|
className = _props$className === void 0 ? '' : _props$className,
|
35
39
|
_props$style = props.style,
|
36
40
|
style = _props$style === void 0 ? {} : _props$style,
|
37
41
|
_props$lineHeight = props.lineHeight,
|
38
42
|
lineHeight = _props$lineHeight === void 0 ? 22 : _props$lineHeight,
|
43
|
+
_props$scrollFollowPa = props.scrollFollowParent,
|
44
|
+
scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa,
|
39
45
|
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
40
46
|
var _width = mode === 'auto' ? 'auto' : width;
|
41
47
|
var content = text !== null && text !== void 0 ? text : '-';
|
@@ -65,6 +71,7 @@ var ProTooltip = function ProTooltip(props) {
|
|
65
71
|
});
|
66
72
|
var _ref = (_useSize = (0, _ahooks.useSize)(localElement)) !== null && _useSize !== void 0 ? _useSize : {},
|
67
73
|
_localSizeWidth = _ref.width;
|
74
|
+
var isTable = _findTableParent(ref.current);
|
68
75
|
var overlayStyle = mode === 'auto' ? {
|
69
76
|
maxWidth: _localSizeWidth
|
70
77
|
} : {};
|
@@ -147,23 +154,6 @@ var ProTooltip = function ProTooltip(props) {
|
|
147
154
|
}
|
148
155
|
return line > 1 ? (0, _jsxRuntime.jsx)(AutoMixinMulti, {}) : (0, _jsxRuntime.jsx)(AutoMixinSingle, {});
|
149
156
|
};
|
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
157
|
(0, _react.useEffect)(function () {
|
168
158
|
if (mode === 'auto' && line === 1) {
|
169
159
|
var localDom = ref.current;
|
@@ -243,57 +233,63 @@ var ProTooltip = function ProTooltip(props) {
|
|
243
233
|
}, [debouncedValue]);
|
244
234
|
(0, _react.useEffect)(function () {
|
245
235
|
var localDom = ref.current;
|
246
|
-
var
|
236
|
+
var isEllipsis = (0, _utils.isEllipsisActive)(childRef === null || childRef === void 0 ? void 0 : childRef.current);
|
247
237
|
setState({
|
248
238
|
parentElement: localDom.parentElement,
|
249
|
-
isShowToolTip:
|
239
|
+
isShowToolTip: isEllipsis
|
250
240
|
});
|
251
241
|
}, []);
|
252
242
|
var cls = (0, _classnames2.default)((0, _defineProperty2.default)({
|
253
243
|
'pro-tooltip': true
|
254
244
|
}, "".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", {
|
245
|
+
var renderContentBox = function renderContentBox() {
|
246
|
+
return (0, _jsxRuntime.jsx)("div", {
|
276
247
|
className: isMultiLine ? 'multiLine' : 'singleLine',
|
277
248
|
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, multiStyle), {}, {
|
278
249
|
width: localWidth
|
279
250
|
}),
|
280
251
|
ref: childRef,
|
281
252
|
children: content
|
282
|
-
})
|
253
|
+
});
|
254
|
+
};
|
255
|
+
var renderTooltipContent = function renderTooltipContent() {
|
256
|
+
return (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
283
257
|
title: text,
|
284
258
|
getPopupContainer: function getPopupContainer(triggerNode) {
|
285
|
-
|
259
|
+
// 修复scrollFollowParent为false时tooltip不显示的问题
|
260
|
+
// 当scrollFollowParent为false时,应该返回document.body而不是triggerNode本身
|
261
|
+
return scrollFollowParent ? triggerNode.parentNode : document.body;
|
286
262
|
}
|
287
263
|
}, restProps), {}, {
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
})
|
296
|
-
}
|
264
|
+
overlayStyle: mode === 'auto' ? overlayStyle : {},
|
265
|
+
children: renderContentBox()
|
266
|
+
}));
|
267
|
+
};
|
268
|
+
var renderContent = function renderContent() {
|
269
|
+
// 自动模式使用专门的渲染逻辑
|
270
|
+
if (mode === 'auto') {
|
271
|
+
return (0, _jsxRuntime.jsx)(AutoMixin, {});
|
272
|
+
}
|
273
|
+
// 响应式宽度模式,根据是否需要显示tooltip决定渲染内容 且 父元素为table
|
274
|
+
if (isTable) {
|
275
|
+
if (isShowToolTip) {
|
276
|
+
return renderTooltipContent();
|
277
|
+
}
|
278
|
+
return renderContentBox();
|
279
|
+
}
|
280
|
+
// 默认模式始终显示tooltip
|
281
|
+
if (mode === 'default') {
|
282
|
+
return renderTooltipContent();
|
283
|
+
}
|
284
|
+
return renderContentBox();
|
285
|
+
};
|
286
|
+
return (0, _jsxRuntime.jsx)("div", {
|
287
|
+
className: cls,
|
288
|
+
ref: ref,
|
289
|
+
style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, style), multiStyle), {}, {
|
290
|
+
width: localWidth
|
291
|
+
}),
|
292
|
+
children: renderContent()
|
297
293
|
});
|
298
294
|
};
|
299
295
|
var _default = exports.default = ProTooltip;
|
@@ -9,9 +9,8 @@ export interface ProTooltipType {
|
|
9
9
|
/**
|
10
10
|
* 提示框宽度
|
11
11
|
* @description 设置提示框的宽度,支持各种CSS宽度单位
|
12
|
-
* @default 'auto'
|
13
12
|
*/
|
14
|
-
width?: string;
|
13
|
+
width?: string | number;
|
15
14
|
/**
|
16
15
|
* 显示的行数
|
17
16
|
* @description 当内容超过设定行数时将截断显示
|
@@ -19,11 +18,11 @@ export interface ProTooltipType {
|
|
19
18
|
*/
|
20
19
|
line?: number;
|
21
20
|
/**
|
22
|
-
*
|
23
|
-
* @description
|
24
|
-
* @default
|
21
|
+
* 是否跟随父元素滚动
|
22
|
+
* @description 启用后,提示框将跟随父元素滚动
|
23
|
+
* @default true
|
25
24
|
*/
|
26
|
-
|
25
|
+
scrollFollowParent?: boolean;
|
27
26
|
/**
|
28
27
|
* 自定义类名
|
29
28
|
* @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),
|