@douyinfe/semi-ui 2.36.0 → 2.36.1-alpha.0

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.
@@ -111,7 +111,6 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
111
111
  shouldTruncated: (rows: number) => boolean;
112
112
  showTooltip: () => boolean | ShowTooltip | {
113
113
  type: string;
114
- opts: {};
115
114
  };
116
115
  getEllipsisState(): boolean;
117
116
  /**
@@ -170,7 +169,7 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
170
169
  renderCopy(): JSX.Element;
171
170
  renderIcon(): JSX.Element;
172
171
  renderContent(): JSX.Element;
173
- renderTipWrapper(): JSX.Element;
172
+ renderTipWrapper(): string | number | boolean | React.ReactFragment | JSX.Element;
174
173
  render(): JSX.Element;
175
174
  }
176
175
  export {};
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
7
8
  var _isNull2 = _interopRequireDefault(require("lodash/isNull"));
8
9
  var _isString2 = _interopRequireDefault(require("lodash/isString"));
9
10
  var _merge2 = _interopRequireDefault(require("lodash/merge"));
@@ -102,6 +103,7 @@ class Base extends _react.Component {
102
103
  return updateOverflow;
103
104
  };
104
105
  this.showTooltip = () => {
106
+ var _a, _b;
105
107
  const {
106
108
  isOverflowed,
107
109
  isTruncated,
@@ -119,8 +121,7 @@ class Base extends _react.Component {
119
121
  return show;
120
122
  }
121
123
  const defaultOpts = {
122
- type: 'tooltip',
123
- opts: {}
124
+ type: 'tooltip'
124
125
  };
125
126
  if (typeof showTooltip === 'object') {
126
127
  if (showTooltip.type && showTooltip.type.toLowerCase() === 'popover') {
@@ -131,7 +132,14 @@ class Base extends _react.Component {
131
132
  },
132
133
  showArrow: true
133
134
  }
134
- }, showTooltip);
135
+ }, showTooltip, {
136
+ opts: {
137
+ className: (0, _classnames.default)({
138
+ [`${prefixCls}-ellipsis-popover`]: true,
139
+ [(_a = showTooltip === null || showTooltip === void 0 ? void 0 : showTooltip.opts) === null || _a === void 0 ? void 0 : _a.className]: Boolean((_b = showTooltip === null || showTooltip === void 0 ? void 0 : showTooltip.opts) === null || _b === void 0 ? void 0 : _b.className)
140
+ })
141
+ }
142
+ });
135
143
  }
136
144
  return Object.assign(Object.assign({}, defaultOpts), showTooltip);
137
145
  }
@@ -406,6 +414,7 @@ class Base extends _react.Component {
406
414
  // Perform type conversion on children to prevent component crash due to non-string type of children
407
415
  String(children), extraNode, ELLIPSIS_STR, suffix, pos);
408
416
  this.setState({
417
+ isOverflowed: false,
409
418
  ellipsisContent: content,
410
419
  isTruncated: children !== content
411
420
  });
@@ -532,9 +541,12 @@ class Base extends _react.Component {
532
541
  if (showTooltip) {
533
542
  const {
534
543
  type,
535
- opts
544
+ opts,
545
+ renderTooltip
536
546
  } = showTooltip;
537
- if (type.toLowerCase() === 'popover') {
547
+ if ((0, _isFunction2.default)(renderTooltip)) {
548
+ return renderTooltip(children, content);
549
+ } else if (type.toLowerCase() === 'popover') {
538
550
  return /*#__PURE__*/_react.default.createElement(_index2.default, Object.assign({
539
551
  content: children,
540
552
  position: "top"
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { PopoverProps } from '../popover';
3
3
  import { TooltipProps } from '../tooltip';
4
4
  import { ArrayElement } from '../_base/base';
@@ -7,6 +7,7 @@ export type EllipsisPos = 'end' | 'middle';
7
7
  export type ShowTooltip = {
8
8
  type?: string;
9
9
  opts?: Partial<PopoverProps> & Partial<TooltipProps>;
10
+ renderTooltip?: (content: TooltipProps['content'], children: ReactNode) => ReactNode;
10
11
  };
11
12
  export type Ellipsis = {
12
13
  collapseText?: string;
@@ -111,7 +111,6 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
111
111
  shouldTruncated: (rows: number) => boolean;
112
112
  showTooltip: () => boolean | ShowTooltip | {
113
113
  type: string;
114
- opts: {};
115
114
  };
116
115
  getEllipsisState(): boolean;
117
116
  /**
@@ -170,7 +169,7 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
170
169
  renderCopy(): JSX.Element;
171
170
  renderIcon(): JSX.Element;
172
171
  renderContent(): JSX.Element;
173
- renderTipWrapper(): JSX.Element;
172
+ renderTipWrapper(): string | number | boolean | React.ReactFragment | JSX.Element;
174
173
  render(): JSX.Element;
175
174
  }
176
175
  export {};
@@ -1,3 +1,4 @@
1
+ import _isFunction from "lodash/isFunction";
1
2
  import _isNull from "lodash/isNull";
2
3
  import _isString from "lodash/isString";
3
4
  import _merge from "lodash/merge";
@@ -93,6 +94,7 @@ export default class Base extends Component {
93
94
  return updateOverflow;
94
95
  };
95
96
  this.showTooltip = () => {
97
+ var _a, _b;
96
98
  const {
97
99
  isOverflowed,
98
100
  isTruncated,
@@ -110,8 +112,7 @@ export default class Base extends Component {
110
112
  return show;
111
113
  }
112
114
  const defaultOpts = {
113
- type: 'tooltip',
114
- opts: {}
115
+ type: 'tooltip'
115
116
  };
116
117
  if (typeof showTooltip === 'object') {
117
118
  if (showTooltip.type && showTooltip.type.toLowerCase() === 'popover') {
@@ -122,7 +123,14 @@ export default class Base extends Component {
122
123
  },
123
124
  showArrow: true
124
125
  }
125
- }, showTooltip);
126
+ }, showTooltip, {
127
+ opts: {
128
+ className: cls({
129
+ [`${prefixCls}-ellipsis-popover`]: true,
130
+ [(_a = showTooltip === null || showTooltip === void 0 ? void 0 : showTooltip.opts) === null || _a === void 0 ? void 0 : _a.className]: Boolean((_b = showTooltip === null || showTooltip === void 0 ? void 0 : showTooltip.opts) === null || _b === void 0 ? void 0 : _b.className)
131
+ })
132
+ }
133
+ });
126
134
  }
127
135
  return Object.assign(Object.assign({}, defaultOpts), showTooltip);
128
136
  }
@@ -397,6 +405,7 @@ export default class Base extends Component {
397
405
  // Perform type conversion on children to prevent component crash due to non-string type of children
398
406
  String(children), extraNode, ELLIPSIS_STR, suffix, pos);
399
407
  this.setState({
408
+ isOverflowed: false,
400
409
  ellipsisContent: content,
401
410
  isTruncated: children !== content
402
411
  });
@@ -523,9 +532,12 @@ export default class Base extends Component {
523
532
  if (showTooltip) {
524
533
  const {
525
534
  type,
526
- opts
535
+ opts,
536
+ renderTooltip
527
537
  } = showTooltip;
528
- if (type.toLowerCase() === 'popover') {
538
+ if (_isFunction(renderTooltip)) {
539
+ return renderTooltip(children, content);
540
+ } else if (type.toLowerCase() === 'popover') {
529
541
  return /*#__PURE__*/React.createElement(Popover, Object.assign({
530
542
  content: children,
531
543
  position: "top"
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { PopoverProps } from '../popover';
3
3
  import { TooltipProps } from '../tooltip';
4
4
  import { ArrayElement } from '../_base/base';
@@ -7,6 +7,7 @@ export type EllipsisPos = 'end' | 'middle';
7
7
  export type ShowTooltip = {
8
8
  type?: string;
9
9
  opts?: Partial<PopoverProps> & Partial<TooltipProps>;
10
+ renderTooltip?: (content: TooltipProps['content'], children: ReactNode) => ReactNode;
10
11
  };
11
12
  export type Ellipsis = {
12
13
  collapseText?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.36.0",
3
+ "version": "2.36.1-alpha.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -17,12 +17,12 @@
17
17
  "lib/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@douyinfe/semi-animation": "2.36.0",
21
- "@douyinfe/semi-animation-react": "2.36.0",
22
- "@douyinfe/semi-foundation": "2.36.0",
23
- "@douyinfe/semi-icons": "2.36.0",
24
- "@douyinfe/semi-illustrations": "2.36.0",
25
- "@douyinfe/semi-theme-default": "2.36.0",
20
+ "@douyinfe/semi-animation": "2.36.1-alpha.0",
21
+ "@douyinfe/semi-animation-react": "2.36.1-alpha.0",
22
+ "@douyinfe/semi-foundation": "2.36.1-alpha.0",
23
+ "@douyinfe/semi-icons": "2.36.1-alpha.0",
24
+ "@douyinfe/semi-illustrations": "2.36.1-alpha.0",
25
+ "@douyinfe/semi-theme-default": "2.36.1-alpha.0",
26
26
  "async-validator": "^3.5.0",
27
27
  "classnames": "^2.2.6",
28
28
  "copy-text-to-clipboard": "^2.1.1",
@@ -69,7 +69,7 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "597a4a6279411ed623d2072f1bcde3f2f3983985",
72
+ "gitHead": "fd127e225a36521b18f4c4f57f18163864d99cd2",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",