@hi-ui/hiui 4.1.18 → 4.1.20

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/lib/cjs/_virtual/index.js +18 -0
  3. package/lib/cjs/index.js +12 -7
  4. package/lib/cjs/node_modules/classnames/index.js +76 -0
  5. package/lib/cjs/packages/ui/ellipsis-tooltip/lib/esm/EllipsisTooltip.js +130 -0
  6. package/lib/cjs/packages/ui/ellipsis-tooltip/lib/esm/styles/index.scss.js +42 -0
  7. package/lib/cjs/packages/utils/classname/lib/esm/index.js +45 -0
  8. package/lib/esm/_virtual/index.js +13 -0
  9. package/lib/esm/index.js +4 -2
  10. package/lib/esm/node_modules/classnames/index.js +69 -0
  11. package/lib/esm/packages/ui/ellipsis-tooltip/lib/esm/EllipsisTooltip.js +106 -0
  12. package/lib/esm/packages/ui/ellipsis-tooltip/lib/esm/styles/index.scss.js +25 -0
  13. package/lib/esm/packages/utils/classname/lib/esm/index.js +37 -0
  14. package/lib/types/index.d.ts +2 -0
  15. package/package.json +11 -11
  16. /package/lib/cjs/{ui → packages/ui}/locale-context/lib/esm/LocaleContext.js +0 -0
  17. /package/lib/cjs/{ui → packages/ui}/locale-context/lib/esm/LocaleProvider.js +0 -0
  18. /package/lib/cjs/{ui → packages/ui}/locale-context/lib/esm/locale/en-US.js +0 -0
  19. /package/lib/cjs/{ui → packages/ui}/locale-context/lib/esm/locale/index.js +0 -0
  20. /package/lib/cjs/{ui → packages/ui}/locale-context/lib/esm/locale/zh-CN.js +0 -0
  21. /package/lib/cjs/{ui → packages/ui}/locale-context/lib/esm/locale/zh-HK.js +0 -0
  22. /package/lib/cjs/{ui → packages/ui}/locale-context/lib/esm/locale/zh-TW.js +0 -0
  23. /package/lib/cjs/{ui → packages/ui}/locale-context/lib/esm/types.js +0 -0
  24. /package/lib/cjs/{utils → packages/utils}/array-utils/lib/esm/index.js +0 -0
  25. /package/lib/cjs/{utils → packages/utils}/env/lib/esm/index.js +0 -0
  26. /package/lib/cjs/{utils → packages/utils}/object-utils/lib/esm/index.js +0 -0
  27. /package/lib/cjs/{utils → packages/utils}/type-assertion/lib/esm/index.js +0 -0
  28. /package/lib/esm/{ui → packages/ui}/locale-context/lib/esm/LocaleContext.js +0 -0
  29. /package/lib/esm/{ui → packages/ui}/locale-context/lib/esm/LocaleProvider.js +0 -0
  30. /package/lib/esm/{ui → packages/ui}/locale-context/lib/esm/locale/en-US.js +0 -0
  31. /package/lib/esm/{ui → packages/ui}/locale-context/lib/esm/locale/index.js +0 -0
  32. /package/lib/esm/{ui → packages/ui}/locale-context/lib/esm/locale/zh-CN.js +0 -0
  33. /package/lib/esm/{ui → packages/ui}/locale-context/lib/esm/locale/zh-HK.js +0 -0
  34. /package/lib/esm/{ui → packages/ui}/locale-context/lib/esm/locale/zh-TW.js +0 -0
  35. /package/lib/esm/{ui → packages/ui}/locale-context/lib/esm/types.js +0 -0
  36. /package/lib/esm/{utils → packages/utils}/array-utils/lib/esm/index.js +0 -0
  37. /package/lib/esm/{utils → packages/utils}/env/lib/esm/index.js +0 -0
  38. /package/lib/esm/{utils → packages/utils}/object-utils/lib/esm/index.js +0 -0
  39. /package/lib/esm/{utils → packages/utils}/type-assertion/lib/esm/index.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @hi-ui/hiui
2
2
 
3
+ ## 4.1.20
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2423](https://github.com/XiaoMi/hiui/pull/2423) [`2916a5578`](https://github.com/XiaoMi/hiui/commit/2916a557818fe232978562c1f3d4ce6dbb991218) Thanks [@zyprepare](https://github.com/zyprepare)! - DatePicker 交互优化: 日期选择中,左右切换年或月时触发 onSelect 回调
8
+
9
+ - [#2417](https://github.com/XiaoMi/hiui/pull/2417) [`14f0e2d53`](https://github.com/XiaoMi/hiui/commit/14f0e2d5313cf1575f6e6378659e5406f8045529) Thanks [@zyprepare](https://github.com/zyprepare)! - Tooltip Slider 修复问题: 鼠标拖动过程中 tooltip 没有跟随显示
10
+
11
+ - [#2419](https://github.com/XiaoMi/hiui/pull/2419) [`2a752a458`](https://github.com/XiaoMi/hiui/commit/2a752a458300331acefa250d20fd8c0785e6683b) Thanks [@zyprepare](https://github.com/zyprepare)! - Upload 问题修复: type="avatar" 模式下,图片裁剪后的格式默认都变成了 png
12
+
13
+ - Updated dependencies [[`2916a5578`](https://github.com/XiaoMi/hiui/commit/2916a557818fe232978562c1f3d4ce6dbb991218), [`2a752a458`](https://github.com/XiaoMi/hiui/commit/2a752a458300331acefa250d20fd8c0785e6683b), [`f8488d3c3`](https://github.com/XiaoMi/hiui/commit/f8488d3c3235d8bf2fc38e0ca3bfaed75bd0ce09), [`14f0e2d53`](https://github.com/XiaoMi/hiui/commit/14f0e2d5313cf1575f6e6378659e5406f8045529)]:
14
+ - @hi-ui/date-picker@4.0.14
15
+ - @hi-ui/upload@4.1.1
16
+ - @hi-ui/descriptions@4.1.1
17
+ - @hi-ui/slider@4.0.7
18
+ - @hi-ui/tooltip@4.0.6
19
+
20
+ ## 4.1.19
21
+
22
+ ### Patch Changes
23
+
24
+ - [#2411](https://github.com/XiaoMi/hiui/pull/2411) [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117) Thanks [@zyprepare](https://github.com/zyprepare)! - Tabs 问题修复: 在 tab 过多滚动场景下,如果选中的 tab 在最左侧,点击右箭头时无效果
25
+
26
+ - [#2411](https://github.com/XiaoMi/hiui/pull/2411) [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117) Thanks [@zyprepare](https://github.com/zyprepare)! - Select CheckSelect 体验优化: 大数据列表中,打开下拉列表时有一次滚动条提示
27
+
28
+ - [#2411](https://github.com/XiaoMi/hiui/pull/2411) [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117) Thanks [@zyprepare](https://github.com/zyprepare)! - Tree 增加 expandOnClick api
29
+
30
+ - [#2411](https://github.com/XiaoMi/hiui/pull/2411) [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117) Thanks [@zyprepare](https://github.com/zyprepare)! - DatePicker 修复问题: 日期选择中,选择月份后会有一个闪动的界面
31
+
32
+ - [#2411](https://github.com/XiaoMi/hiui/pull/2411) [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117) Thanks [@zyprepare](https://github.com/zyprepare)! - Modal 修复问题: 设置 height 为表达式时,组件中会有 max-height 限制导致无效
33
+
34
+ - Updated dependencies [[`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117), [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117), [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117), [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117), [`f7d1257ad`](https://github.com/XiaoMi/hiui/commit/f7d1257ad2006fd40cabb2d16f1fde77677f3117)]:
35
+ - @hi-ui/tree@4.2.0
36
+ - @hi-ui/tabs@4.0.8
37
+ - @hi-ui/modal@4.0.10
38
+ - @hi-ui/check-select@4.1.2
39
+ - @hi-ui/select@4.0.10
40
+ - @hi-ui/date-picker@4.0.13
41
+
3
42
  ## 4.1.18
4
43
 
5
44
  ### Patch Changes
@@ -0,0 +1,18 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+ var classnames = {
16
+ exports: {}
17
+ };
18
+ exports.classnames = classnames;
package/lib/cjs/index.js CHANGED
@@ -51,6 +51,10 @@ var drawer = require('@hi-ui/drawer');
51
51
 
52
52
  var dropdown = require('@hi-ui/dropdown');
53
53
 
54
+ require('./packages/ui/ellipsis-tooltip/lib/esm/styles/index.scss.js');
55
+
56
+ var EllipsisTooltip = require('./packages/ui/ellipsis-tooltip/lib/esm/EllipsisTooltip.js');
57
+
54
58
  var emptyState = require('@hi-ui/empty-state');
55
59
 
56
60
  var filter = require('@hi-ui/filter');
@@ -67,9 +71,9 @@ var list = require('@hi-ui/list');
67
71
 
68
72
  var loading = require('@hi-ui/loading');
69
73
 
70
- var LocaleContext = require('./ui/locale-context/lib/esm/LocaleContext.js');
74
+ var LocaleContext = require('./packages/ui/locale-context/lib/esm/LocaleContext.js');
71
75
 
72
- var LocaleProvider = require('./ui/locale-context/lib/esm/LocaleProvider.js');
76
+ var LocaleProvider = require('./packages/ui/locale-context/lib/esm/LocaleProvider.js');
73
77
 
74
78
  var menu = require('@hi-ui/menu');
75
79
 
@@ -125,7 +129,7 @@ var timePicker = require('@hi-ui/time-picker');
125
129
 
126
130
  var timeline = require('@hi-ui/timeline');
127
131
 
128
- var tooltip = require('@hi-ui/tooltip');
132
+ var Tooltip = require('@hi-ui/tooltip');
129
133
 
130
134
  var transfer = require('@hi-ui/transfer');
131
135
 
@@ -259,7 +263,7 @@ var timePicker__default = /*#__PURE__*/_interopDefaultLegacy(timePicker);
259
263
 
260
264
  var timeline__default = /*#__PURE__*/_interopDefaultLegacy(timeline);
261
265
 
262
- var tooltip__default = /*#__PURE__*/_interopDefaultLegacy(tooltip);
266
+ var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
263
267
 
264
268
  var transfer__default = /*#__PURE__*/_interopDefaultLegacy(transfer);
265
269
 
@@ -389,6 +393,7 @@ Object.defineProperty(exports, 'Dropdown', {
389
393
  return dropdown__default["default"];
390
394
  }
391
395
  });
396
+ exports.EllipsisTooltip = EllipsisTooltip.EllipsisTooltip;
392
397
  Object.defineProperty(exports, 'EmptyState', {
393
398
  enumerable: true,
394
399
  get: function get() {
@@ -606,7 +611,7 @@ Object.defineProperty(exports, 'Timeline', {
606
611
  Object.defineProperty(exports, 'Tooltip', {
607
612
  enumerable: true,
608
613
  get: function get() {
609
- return tooltip__default["default"];
614
+ return Tooltip__default["default"];
610
615
  }
611
616
  });
612
617
  Object.defineProperty(exports, 'Transfer', {
@@ -1093,11 +1098,11 @@ Object.keys(timeline).forEach(function (k) {
1093
1098
  }
1094
1099
  });
1095
1100
  });
1096
- Object.keys(tooltip).forEach(function (k) {
1101
+ Object.keys(Tooltip).forEach(function (k) {
1097
1102
  if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1098
1103
  enumerable: true,
1099
1104
  get: function get() {
1100
- return tooltip[k];
1105
+ return Tooltip[k];
1101
1106
  }
1102
1107
  });
1103
1108
  });
@@ -0,0 +1,76 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ var _typeof = require("@babel/runtime/helpers/typeof");
13
+
14
+ Object.defineProperty(exports, '__esModule', {
15
+ value: true
16
+ });
17
+
18
+ var index = require('../../_virtual/index.js');
19
+ /*!
20
+ Copyright (c) 2018 Jed Watson.
21
+ Licensed under the MIT License (MIT), see
22
+ http://jedwatson.github.io/classnames
23
+ */
24
+
25
+
26
+ (function (module) {
27
+ /* global define */
28
+ (function () {
29
+ var hasOwn = {}.hasOwnProperty;
30
+
31
+ function classNames() {
32
+ var classes = [];
33
+
34
+ for (var i = 0; i < arguments.length; i++) {
35
+ var arg = arguments[i];
36
+ if (!arg) continue;
37
+
38
+ var argType = _typeof(arg);
39
+
40
+ if (argType === 'string' || argType === 'number') {
41
+ classes.push(arg);
42
+ } else if (Array.isArray(arg)) {
43
+ if (arg.length) {
44
+ var inner = classNames.apply(null, arg);
45
+
46
+ if (inner) {
47
+ classes.push(inner);
48
+ }
49
+ }
50
+ } else if (argType === 'object') {
51
+ if (arg.toString === Object.prototype.toString) {
52
+ for (var key in arg) {
53
+ if (hasOwn.call(arg, key) && arg[key]) {
54
+ classes.push(key);
55
+ }
56
+ }
57
+ } else {
58
+ classes.push(arg.toString());
59
+ }
60
+ }
61
+ }
62
+
63
+ return classes.join(' ');
64
+ }
65
+
66
+ if (module.exports) {
67
+ classNames["default"] = classNames;
68
+ module.exports = classNames;
69
+ } else {
70
+ window.classNames = classNames;
71
+ }
72
+ })();
73
+ })(index.classnames);
74
+
75
+ var cx = index.classnames.exports;
76
+ exports["default"] = cx;
@@ -0,0 +1,130 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ var _typeof = require("@babel/runtime/helpers/typeof");
13
+
14
+ Object.defineProperty(exports, '__esModule', {
15
+ value: true
16
+ });
17
+
18
+ var tslib = require('tslib');
19
+
20
+ var React = require('react');
21
+
22
+ var index$2 = require('../../../../utils/classname/lib/esm/index.js');
23
+
24
+ var index$1 = require('../../../../utils/env/lib/esm/index.js');
25
+
26
+ var Tooltip = require('@hi-ui/tooltip');
27
+
28
+ var index = require('../../../../../node_modules/classnames/index.js');
29
+
30
+ function _interopDefaultLegacy(e) {
31
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
32
+ 'default': e
33
+ };
34
+ }
35
+
36
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
37
+
38
+ var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
39
+ /** @LICENSE
40
+ * @hi-ui/ellipsis-tooltip
41
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/ellipsis-tooltip#readme
42
+ *
43
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE file in the root directory of this source tree.
47
+ */
48
+
49
+
50
+ var ELLIPSIS_TOOLTIP_PREFIX = index$2.getPrefixCls('ellipsis-tooltip'); // 格式化子文本,超出规定字数时展示...
51
+
52
+ var formatChildText = function formatChildText(text, maxTextCount) {
53
+ var stringText = text === null || text === void 0 ? void 0 : text.toString();
54
+ var canTooltip = maxTextCount > 0 && stringText.length > maxTextCount;
55
+ return canTooltip ? stringText.slice(0, maxTextCount) + "..." : text;
56
+ };
57
+ /**
58
+ * 这是一个文字超出后,展示省略号,并且鼠标悬停时出现全部描述的组件
59
+ */
60
+
61
+
62
+ var EllipsisTooltip = function EllipsisTooltip(_a) {
63
+ var _cx;
64
+
65
+ var _a$prefixCls = _a.prefixCls,
66
+ prefixCls = _a$prefixCls === void 0 ? ELLIPSIS_TOOLTIP_PREFIX : _a$prefixCls,
67
+ _a$role = _a.role,
68
+ role = _a$role === void 0 ? 'ellipsis-tooltip' : _a$role,
69
+ className = _a.className,
70
+ children = _a.children,
71
+ _a$numberOfLines = _a.numberOfLines,
72
+ numberOfLines = _a$numberOfLines === void 0 ? 1 : _a$numberOfLines,
73
+ _a$maxTextCount = _a.maxTextCount,
74
+ maxTextCount = _a$maxTextCount === void 0 ? 0 : _a$maxTextCount,
75
+ rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children", "numberOfLines", "maxTextCount"]);
76
+
77
+ var cls = index["default"](prefixCls, className, (_cx = {}, _cx[prefixCls + "--single"] = maxTextCount === 0 && (!numberOfLines || numberOfLines <= 1), _cx[prefixCls + "--multiple"] = numberOfLines > 1, _cx));
78
+
79
+ var _useState = React.useState(true),
80
+ disableTooltip = _useState[0],
81
+ setDisableTooltip = _useState[1];
82
+
83
+ var contentRef = React.useRef(null); // 检查文本超出省略号
84
+
85
+ var handleCheckEllipsis = React.useCallback(function () {
86
+ var _a, _b, _c;
87
+
88
+ if (contentRef.current) {
89
+ // 多行超出
90
+ if (numberOfLines > 1) {
91
+ var style = window.getComputedStyle(contentRef.current, null);
92
+ var fontSize = style.fontSize;
93
+ var lineHeight = style.lineHeight === 'normal' ? +fontSize : +style.lineHeight;
94
+ var textLines = Math.round(+style.height / lineHeight);
95
+ setDisableTooltip(textLines <= numberOfLines);
96
+ } else {
97
+ // 单行超出
98
+ var rect = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
99
+ var parentRect = (_c = (_b = contentRef.current) === null || _b === void 0 ? void 0 : _b.parentNode) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
100
+ setDisableTooltip(+(rect === null || rect === void 0 ? void 0 : rect.width) <= parentRect.width);
101
+ }
102
+ }
103
+ }, [numberOfLines]);
104
+ React.useEffect(function () {
105
+ // 当文字字数超出有配置时,单独处理
106
+ if (maxTextCount > 0 && maxTextCount < (children === null || children === void 0 ? void 0 : children.length)) {
107
+ setDisableTooltip(false);
108
+ } else {
109
+ handleCheckEllipsis();
110
+ }
111
+ }, [children, maxTextCount, handleCheckEllipsis]);
112
+ return /*#__PURE__*/React__default["default"].createElement(Tooltip__default["default"], Object.assign({
113
+ title: children,
114
+ disabled: disableTooltip
115
+ }, rest), /*#__PURE__*/React__default["default"].createElement("div", {
116
+ role: role,
117
+ className: cls,
118
+ style: {
119
+ WebkitLineClamp: numberOfLines > 1 ? numberOfLines : undefined
120
+ }
121
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
122
+ ref: contentRef
123
+ }, formatChildText(children, maxTextCount))));
124
+ };
125
+
126
+ if (index$1.__DEV__) {
127
+ EllipsisTooltip.displayName = 'EllipsisTooltip';
128
+ }
129
+
130
+ exports.EllipsisTooltip = EllipsisTooltip;
@@ -0,0 +1,42 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ var _typeof = require("@babel/runtime/helpers/typeof");
13
+
14
+ Object.defineProperty(exports, '__esModule', {
15
+ value: true
16
+ });
17
+
18
+ var __styleInject__ = require('inject-head-style');
19
+
20
+ function _interopDefaultLegacy(e) {
21
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
22
+ 'default': e
23
+ };
24
+ }
25
+
26
+ var __styleInject____default = /*#__PURE__*/_interopDefaultLegacy(__styleInject__);
27
+ /** @LICENSE
28
+ * @hi-ui/ellipsis-tooltip
29
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/ellipsis-tooltip#readme
30
+ *
31
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE file in the root directory of this source tree.
35
+ */
36
+
37
+
38
+ var css_248z = ".hi-v4-ellipsis-tooltip.hi-v4-ellipsis-tooltip--single {overflow: hidden;white-space: nowrap;text-overflow: ellipsis; }.hi-v4-ellipsis-tooltip.hi-v4-ellipsis-tooltip--multiple {overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical; }";
39
+
40
+ __styleInject____default["default"](css_248z);
41
+
42
+ exports["default"] = css_248z;
@@ -0,0 +1,45 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ Object.defineProperty(exports, '__esModule', {
13
+ value: true
14
+ });
15
+
16
+ var index = require('../../../../../node_modules/classnames/index.js');
17
+ /** @LICENSE
18
+ * @hi-ui/classname
19
+ * https://github.com/XiaoMi/hiui#readme
20
+ *
21
+ * Copyright (c) Flcwl <flcwl@vip.qq.com>.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */
26
+
27
+ /**
28
+ * 给组件选择器类添加上 hiui 版本控制
29
+ *
30
+ * @param cls 选择器类
31
+ * @param componentPrefix 类前缀
32
+ * @returns 带版本控制的选择器类
33
+ */
34
+
35
+
36
+ var getPrefixCls = function getPrefixCls(cls, componentPrefix) {
37
+ if (componentPrefix === void 0) {
38
+ componentPrefix = 'hi-v4';
39
+ }
40
+
41
+ return componentPrefix + "-" + cls;
42
+ };
43
+
44
+ exports.cx = index["default"];
45
+ exports.getPrefixCls = getPrefixCls;
@@ -0,0 +1,13 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ var classnames = {
11
+ exports: {}
12
+ };
13
+ export { classnames as c };
package/lib/esm/index.js CHANGED
@@ -43,6 +43,8 @@ export * from '@hi-ui/drawer';
43
43
  export { default as Drawer } from '@hi-ui/drawer';
44
44
  export * from '@hi-ui/dropdown';
45
45
  export { default as Dropdown } from '@hi-ui/dropdown';
46
+ import './packages/ui/ellipsis-tooltip/lib/esm/styles/index.scss.js';
47
+ export { EllipsisTooltip } from './packages/ui/ellipsis-tooltip/lib/esm/EllipsisTooltip.js';
46
48
  export * from '@hi-ui/empty-state';
47
49
  export { default as EmptyState } from '@hi-ui/empty-state';
48
50
  export * from '@hi-ui/filter';
@@ -59,8 +61,8 @@ export * from '@hi-ui/list';
59
61
  export { default as List } from '@hi-ui/list';
60
62
  export * from '@hi-ui/loading';
61
63
  export { default as Loading } from '@hi-ui/loading';
62
- export { getLanguage, useLocaleContext } from './ui/locale-context/lib/esm/LocaleContext.js';
63
- export { LocaleProvider as LocaleContext, LocaleProvider } from './ui/locale-context/lib/esm/LocaleProvider.js';
64
+ export { getLanguage, useLocaleContext } from './packages/ui/locale-context/lib/esm/LocaleContext.js';
65
+ export { LocaleProvider as LocaleContext, LocaleProvider } from './packages/ui/locale-context/lib/esm/LocaleProvider.js';
64
66
  export * from '@hi-ui/menu';
65
67
  export { default as Menu } from '@hi-ui/menu';
66
68
  export * from '@hi-ui/message';
@@ -0,0 +1,69 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+
3
+ /** @LICENSE
4
+ * @hi-ui/hiui
5
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
6
+ *
7
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ import { c as classnames } from '../../_virtual/index.js';
13
+ /*!
14
+ Copyright (c) 2018 Jed Watson.
15
+ Licensed under the MIT License (MIT), see
16
+ http://jedwatson.github.io/classnames
17
+ */
18
+
19
+ (function (module) {
20
+ /* global define */
21
+ (function () {
22
+ var hasOwn = {}.hasOwnProperty;
23
+
24
+ function classNames() {
25
+ var classes = [];
26
+
27
+ for (var i = 0; i < arguments.length; i++) {
28
+ var arg = arguments[i];
29
+ if (!arg) continue;
30
+
31
+ var argType = _typeof(arg);
32
+
33
+ if (argType === 'string' || argType === 'number') {
34
+ classes.push(arg);
35
+ } else if (Array.isArray(arg)) {
36
+ if (arg.length) {
37
+ var inner = classNames.apply(null, arg);
38
+
39
+ if (inner) {
40
+ classes.push(inner);
41
+ }
42
+ }
43
+ } else if (argType === 'object') {
44
+ if (arg.toString === Object.prototype.toString) {
45
+ for (var key in arg) {
46
+ if (hasOwn.call(arg, key) && arg[key]) {
47
+ classes.push(key);
48
+ }
49
+ }
50
+ } else {
51
+ classes.push(arg.toString());
52
+ }
53
+ }
54
+ }
55
+
56
+ return classes.join(' ');
57
+ }
58
+
59
+ if (module.exports) {
60
+ classNames["default"] = classNames;
61
+ module.exports = classNames;
62
+ } else {
63
+ window.classNames = classNames;
64
+ }
65
+ })();
66
+ })(classnames);
67
+
68
+ var cx = classnames.exports;
69
+ export { cx as default };
@@ -0,0 +1,106 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import { __rest } from 'tslib';
11
+ import React, { useState, useRef, useCallback, useEffect } from 'react';
12
+ import { getPrefixCls } from '../../../../utils/classname/lib/esm/index.js';
13
+ import { __DEV__ } from '../../../../utils/env/lib/esm/index.js';
14
+ import Tooltip__default from '@hi-ui/tooltip';
15
+ import cx from '../../../../../node_modules/classnames/index.js';
16
+ /** @LICENSE
17
+ * @hi-ui/ellipsis-tooltip
18
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/ellipsis-tooltip#readme
19
+ *
20
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
21
+ *
22
+ * This source code is licensed under the MIT license found in the
23
+ * LICENSE file in the root directory of this source tree.
24
+ */
25
+
26
+ var ELLIPSIS_TOOLTIP_PREFIX = getPrefixCls('ellipsis-tooltip'); // 格式化子文本,超出规定字数时展示...
27
+
28
+ var formatChildText = function formatChildText(text, maxTextCount) {
29
+ var stringText = text === null || text === void 0 ? void 0 : text.toString();
30
+ var canTooltip = maxTextCount > 0 && stringText.length > maxTextCount;
31
+ return canTooltip ? stringText.slice(0, maxTextCount) + "..." : text;
32
+ };
33
+ /**
34
+ * 这是一个文字超出后,展示省略号,并且鼠标悬停时出现全部描述的组件
35
+ */
36
+
37
+
38
+ var EllipsisTooltip = function EllipsisTooltip(_a) {
39
+ var _cx;
40
+
41
+ var _a$prefixCls = _a.prefixCls,
42
+ prefixCls = _a$prefixCls === void 0 ? ELLIPSIS_TOOLTIP_PREFIX : _a$prefixCls,
43
+ _a$role = _a.role,
44
+ role = _a$role === void 0 ? 'ellipsis-tooltip' : _a$role,
45
+ className = _a.className,
46
+ children = _a.children,
47
+ _a$numberOfLines = _a.numberOfLines,
48
+ numberOfLines = _a$numberOfLines === void 0 ? 1 : _a$numberOfLines,
49
+ _a$maxTextCount = _a.maxTextCount,
50
+ maxTextCount = _a$maxTextCount === void 0 ? 0 : _a$maxTextCount,
51
+ rest = __rest(_a, ["prefixCls", "role", "className", "children", "numberOfLines", "maxTextCount"]);
52
+
53
+ var cls = cx(prefixCls, className, (_cx = {}, _cx[prefixCls + "--single"] = maxTextCount === 0 && (!numberOfLines || numberOfLines <= 1), _cx[prefixCls + "--multiple"] = numberOfLines > 1, _cx));
54
+
55
+ var _useState = useState(true),
56
+ disableTooltip = _useState[0],
57
+ setDisableTooltip = _useState[1];
58
+
59
+ var contentRef = useRef(null); // 检查文本超出省略号
60
+
61
+ var handleCheckEllipsis = useCallback(function () {
62
+ var _a, _b, _c;
63
+
64
+ if (contentRef.current) {
65
+ // 多行超出
66
+ if (numberOfLines > 1) {
67
+ var style = window.getComputedStyle(contentRef.current, null);
68
+ var fontSize = style.fontSize;
69
+ var lineHeight = style.lineHeight === 'normal' ? +fontSize : +style.lineHeight;
70
+ var textLines = Math.round(+style.height / lineHeight);
71
+ setDisableTooltip(textLines <= numberOfLines);
72
+ } else {
73
+ // 单行超出
74
+ var rect = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
75
+ var parentRect = (_c = (_b = contentRef.current) === null || _b === void 0 ? void 0 : _b.parentNode) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
76
+ setDisableTooltip(+(rect === null || rect === void 0 ? void 0 : rect.width) <= parentRect.width);
77
+ }
78
+ }
79
+ }, [numberOfLines]);
80
+ useEffect(function () {
81
+ // 当文字字数超出有配置时,单独处理
82
+ if (maxTextCount > 0 && maxTextCount < (children === null || children === void 0 ? void 0 : children.length)) {
83
+ setDisableTooltip(false);
84
+ } else {
85
+ handleCheckEllipsis();
86
+ }
87
+ }, [children, maxTextCount, handleCheckEllipsis]);
88
+ return /*#__PURE__*/React.createElement(Tooltip__default, Object.assign({
89
+ title: children,
90
+ disabled: disableTooltip
91
+ }, rest), /*#__PURE__*/React.createElement("div", {
92
+ role: role,
93
+ className: cls,
94
+ style: {
95
+ WebkitLineClamp: numberOfLines > 1 ? numberOfLines : undefined
96
+ }
97
+ }, /*#__PURE__*/React.createElement("span", {
98
+ ref: contentRef
99
+ }, formatChildText(children, maxTextCount))));
100
+ };
101
+
102
+ if (__DEV__) {
103
+ EllipsisTooltip.displayName = 'EllipsisTooltip';
104
+ }
105
+
106
+ export { EllipsisTooltip };
@@ -0,0 +1,25 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import __styleInject__ from 'inject-head-style';
11
+ /** @LICENSE
12
+ * @hi-ui/ellipsis-tooltip
13
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/ellipsis-tooltip#readme
14
+ *
15
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ var css_248z = ".hi-v4-ellipsis-tooltip.hi-v4-ellipsis-tooltip--single {overflow: hidden;white-space: nowrap;text-overflow: ellipsis; }.hi-v4-ellipsis-tooltip.hi-v4-ellipsis-tooltip--multiple {overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical; }";
22
+
23
+ __styleInject__(css_248z);
24
+
25
+ export { css_248z as default };
@@ -0,0 +1,37 @@
1
+ /** @LICENSE
2
+ * @hi-ui/hiui
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/hiui#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ export { default as cx } from '../../../../../node_modules/classnames/index.js';
11
+ /** @LICENSE
12
+ * @hi-ui/classname
13
+ * https://github.com/XiaoMi/hiui#readme
14
+ *
15
+ * Copyright (c) Flcwl <flcwl@vip.qq.com>.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ /**
22
+ * 给组件选择器类添加上 hiui 版本控制
23
+ *
24
+ * @param cls 选择器类
25
+ * @param componentPrefix 类前缀
26
+ * @returns 带版本控制的选择器类
27
+ */
28
+
29
+ var getPrefixCls = function getPrefixCls(cls, componentPrefix) {
30
+ if (componentPrefix === void 0) {
31
+ componentPrefix = 'hi-v4';
32
+ }
33
+
34
+ return componentPrefix + "-" + cls;
35
+ };
36
+
37
+ export { getPrefixCls };
@@ -34,6 +34,8 @@ export * from '@hi-ui/drawer';
34
34
  export { default as Drawer } from '@hi-ui/drawer';
35
35
  export * from '@hi-ui/dropdown';
36
36
  export { default as Dropdown } from '@hi-ui/dropdown';
37
+ export * from '@hi-ui/ellipsis-tooltip';
38
+ export { default as EllipsisTooltip } from '@hi-ui/ellipsis-tooltip';
37
39
  export * from '@hi-ui/empty-state';
38
40
  export { default as EmptyState } from '@hi-ui/empty-state';
39
41
  export * from '@hi-ui/filter';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/hiui",
3
- "version": "4.1.18",
3
+ "version": "4.1.20",
4
4
  "description": "The root-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -54,13 +54,13 @@
54
54
  "@hi-ui/carousel": "^4.0.4",
55
55
  "@hi-ui/cascader": "^4.0.9",
56
56
  "@hi-ui/check-cascader": "^4.0.9",
57
- "@hi-ui/check-select": "^4.1.1",
57
+ "@hi-ui/check-select": "^4.1.2",
58
58
  "@hi-ui/check-tree-select": "^4.0.10",
59
59
  "@hi-ui/checkbox": "^4.0.5",
60
60
  "@hi-ui/collapse": "^4.1.0",
61
61
  "@hi-ui/counter": "^4.0.5",
62
- "@hi-ui/date-picker": "^4.0.12",
63
- "@hi-ui/descriptions": "^4.1.0",
62
+ "@hi-ui/date-picker": "^4.0.14",
63
+ "@hi-ui/descriptions": "^4.1.1",
64
64
  "@hi-ui/drawer": "^4.0.7",
65
65
  "@hi-ui/dropdown": "^4.0.5",
66
66
  "@hi-ui/empty-state": "^4.0.4",
@@ -74,7 +74,7 @@
74
74
  "@hi-ui/loading": "^4.0.4",
75
75
  "@hi-ui/menu": "^4.0.8",
76
76
  "@hi-ui/message": "^4.0.4",
77
- "@hi-ui/modal": "^4.0.9",
77
+ "@hi-ui/modal": "^4.0.10",
78
78
  "@hi-ui/notification": "^4.0.6",
79
79
  "@hi-ui/number-input": "^4.0.5",
80
80
  "@hi-ui/pagination": "^4.0.9",
@@ -89,24 +89,24 @@
89
89
  "@hi-ui/result": "^4.0.4",
90
90
  "@hi-ui/scrollbar": "^4.0.1",
91
91
  "@hi-ui/search": "^4.0.8",
92
- "@hi-ui/select": "^4.0.9",
93
- "@hi-ui/slider": "^4.0.6",
92
+ "@hi-ui/select": "^4.0.10",
93
+ "@hi-ui/slider": "^4.0.7",
94
94
  "@hi-ui/space": "^4.0.6",
95
95
  "@hi-ui/spinner": "^4.0.4",
96
96
  "@hi-ui/stepper": "^4.0.4",
97
97
  "@hi-ui/svg-icon": "^4.0.4",
98
98
  "@hi-ui/switch": "^4.0.6",
99
99
  "@hi-ui/table": "^4.0.13",
100
- "@hi-ui/tabs": "^4.0.7",
100
+ "@hi-ui/tabs": "^4.0.8",
101
101
  "@hi-ui/tag": "^4.0.7",
102
102
  "@hi-ui/textarea": "^4.0.6",
103
103
  "@hi-ui/time-picker": "^4.0.8",
104
104
  "@hi-ui/timeline": "^4.0.4",
105
- "@hi-ui/tooltip": "^4.0.5",
105
+ "@hi-ui/tooltip": "^4.0.6",
106
106
  "@hi-ui/transfer": "^4.0.9",
107
- "@hi-ui/tree": "^4.1.2",
107
+ "@hi-ui/tree": "^4.2.0",
108
108
  "@hi-ui/tree-select": "^4.0.10",
109
- "@hi-ui/upload": "^4.1.0",
109
+ "@hi-ui/upload": "^4.1.1",
110
110
  "@hi-ui/watermark": "^4.0.4",
111
111
  "@hi-ui/zen-mode": "^4.0.4"
112
112
  },