@douyinfe/semi-ui 2.52.0-beta.1 → 2.53.0-beta.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.
Files changed (138) hide show
  1. package/dist/css/semi.css +1 -0
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +930 -1249
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/cjs/_utils/index.d.ts +2 -0
  8. package/lib/cjs/_utils/index.js +77 -0
  9. package/lib/cjs/_utils/semi-global.d.ts +46 -0
  10. package/lib/cjs/_utils/semi-global.js +13 -0
  11. package/lib/cjs/autoComplete/index.d.ts +2 -25
  12. package/lib/cjs/autoComplete/index.js +4 -2
  13. package/lib/cjs/avatar/index.d.ts +2 -10
  14. package/lib/cjs/avatar/index.js +4 -2
  15. package/lib/cjs/backtop/index.d.ts +2 -5
  16. package/lib/cjs/backtop/index.js +4 -2
  17. package/lib/cjs/button/Button.d.ts +1 -1
  18. package/lib/cjs/button/index.d.ts +3 -1
  19. package/lib/cjs/button/index.js +3 -0
  20. package/lib/cjs/carousel/index.d.ts +2 -2
  21. package/lib/cjs/cascader/index.d.ts +5 -33
  22. package/lib/cjs/cascader/index.js +34 -23
  23. package/lib/cjs/collapse/index.d.ts +2 -7
  24. package/lib/cjs/collapse/index.js +4 -2
  25. package/lib/cjs/collapsible/index.d.ts +3 -9
  26. package/lib/cjs/collapsible/index.js +4 -2
  27. package/lib/cjs/configProvider/index.d.ts +2 -1
  28. package/lib/cjs/configProvider/index.js +5 -2
  29. package/lib/cjs/datePicker/datePicker.d.ts +2 -44
  30. package/lib/cjs/datePicker/datePicker.js +5 -3
  31. package/lib/cjs/datePicker/yearAndMonth.js +20 -16
  32. package/lib/cjs/dropdown/index.d.ts +2 -12
  33. package/lib/cjs/dropdown/index.js +4 -2
  34. package/lib/cjs/form/arrayField.js +3 -3
  35. package/lib/cjs/form/hoc/withField.d.ts +3 -3
  36. package/lib/cjs/modal/Modal.d.ts +2 -20
  37. package/lib/cjs/modal/Modal.js +5 -4
  38. package/lib/cjs/modal/confirm.d.ts +14 -14
  39. package/lib/cjs/navigation/index.d.ts +2 -15
  40. package/lib/cjs/navigation/index.js +4 -2
  41. package/lib/cjs/notification/notice.d.ts +2 -12
  42. package/lib/cjs/notification/notice.js +3 -2
  43. package/lib/cjs/overflowList/index.d.ts +2 -9
  44. package/lib/cjs/overflowList/index.js +3 -2
  45. package/lib/cjs/popconfirm/index.d.ts +2 -15
  46. package/lib/cjs/popconfirm/index.js +4 -2
  47. package/lib/cjs/popover/index.d.ts +2 -23
  48. package/lib/cjs/popover/index.js +4 -2
  49. package/lib/cjs/resizeObserver/index.d.ts +14 -2
  50. package/lib/cjs/resizeObserver/index.js +66 -32
  51. package/lib/cjs/select/index.d.ts +1 -0
  52. package/lib/cjs/select/index.js +3 -2
  53. package/lib/cjs/select/option.js +2 -1
  54. package/lib/cjs/sideSheet/index.d.ts +1 -0
  55. package/lib/cjs/sideSheet/index.js +3 -2
  56. package/lib/cjs/table/ResizableTable.js +1 -1
  57. package/lib/cjs/tabs/index.d.ts +1 -0
  58. package/lib/cjs/tabs/index.js +4 -2
  59. package/lib/cjs/timePicker/TimePicker.d.ts +1 -1
  60. package/lib/cjs/timePicker/index.d.ts +2 -34
  61. package/lib/cjs/timePicker/index.js +3 -1
  62. package/lib/cjs/toast/toast.d.ts +2 -11
  63. package/lib/cjs/toast/toast.js +3 -2
  64. package/lib/cjs/tooltip/index.d.ts +2 -32
  65. package/lib/cjs/tooltip/index.js +3 -2
  66. package/lib/cjs/typography/base.d.ts +7 -4
  67. package/lib/cjs/typography/base.js +127 -64
  68. package/lib/cjs/typography/numeral.d.ts +1 -1
  69. package/lib/cjs/typography/paragraph.d.ts +1 -1
  70. package/lib/cjs/typography/text.d.ts +1 -1
  71. package/lib/cjs/typography/title.d.ts +1 -1
  72. package/lib/es/_utils/index.d.ts +2 -0
  73. package/lib/es/_utils/index.js +75 -0
  74. package/lib/es/_utils/semi-global.d.ts +46 -0
  75. package/lib/es/_utils/semi-global.js +6 -0
  76. package/lib/es/autoComplete/index.d.ts +2 -25
  77. package/lib/es/autoComplete/index.js +4 -2
  78. package/lib/es/avatar/index.d.ts +2 -10
  79. package/lib/es/avatar/index.js +4 -2
  80. package/lib/es/backtop/index.d.ts +2 -5
  81. package/lib/es/backtop/index.js +4 -2
  82. package/lib/es/button/Button.d.ts +1 -1
  83. package/lib/es/button/index.d.ts +3 -1
  84. package/lib/es/button/index.js +3 -0
  85. package/lib/es/carousel/index.d.ts +2 -2
  86. package/lib/es/cascader/index.d.ts +5 -33
  87. package/lib/es/cascader/index.js +35 -24
  88. package/lib/es/collapse/index.d.ts +2 -7
  89. package/lib/es/collapse/index.js +4 -2
  90. package/lib/es/collapsible/index.d.ts +3 -9
  91. package/lib/es/collapsible/index.js +4 -2
  92. package/lib/es/configProvider/index.d.ts +2 -1
  93. package/lib/es/configProvider/index.js +5 -2
  94. package/lib/es/datePicker/datePicker.d.ts +2 -44
  95. package/lib/es/datePicker/datePicker.js +5 -3
  96. package/lib/es/datePicker/yearAndMonth.js +20 -16
  97. package/lib/es/dropdown/index.d.ts +2 -12
  98. package/lib/es/dropdown/index.js +4 -2
  99. package/lib/es/form/arrayField.js +3 -3
  100. package/lib/es/form/hoc/withField.d.ts +3 -3
  101. package/lib/es/modal/Modal.d.ts +2 -20
  102. package/lib/es/modal/Modal.js +6 -5
  103. package/lib/es/modal/confirm.d.ts +14 -14
  104. package/lib/es/navigation/index.d.ts +2 -15
  105. package/lib/es/navigation/index.js +4 -2
  106. package/lib/es/notification/notice.d.ts +2 -12
  107. package/lib/es/notification/notice.js +4 -3
  108. package/lib/es/overflowList/index.d.ts +2 -9
  109. package/lib/es/overflowList/index.js +4 -3
  110. package/lib/es/popconfirm/index.d.ts +2 -15
  111. package/lib/es/popconfirm/index.js +4 -2
  112. package/lib/es/popover/index.d.ts +2 -23
  113. package/lib/es/popover/index.js +4 -2
  114. package/lib/es/resizeObserver/index.d.ts +14 -2
  115. package/lib/es/resizeObserver/index.js +64 -31
  116. package/lib/es/select/index.d.ts +1 -0
  117. package/lib/es/select/index.js +4 -3
  118. package/lib/es/select/option.js +2 -1
  119. package/lib/es/sideSheet/index.d.ts +1 -0
  120. package/lib/es/sideSheet/index.js +4 -3
  121. package/lib/es/table/ResizableTable.js +1 -1
  122. package/lib/es/tabs/index.d.ts +1 -0
  123. package/lib/es/tabs/index.js +4 -2
  124. package/lib/es/timePicker/TimePicker.d.ts +1 -1
  125. package/lib/es/timePicker/index.d.ts +2 -34
  126. package/lib/es/timePicker/index.js +3 -1
  127. package/lib/es/toast/toast.d.ts +2 -11
  128. package/lib/es/toast/toast.js +4 -3
  129. package/lib/es/tooltip/index.d.ts +2 -32
  130. package/lib/es/tooltip/index.js +4 -3
  131. package/lib/es/typography/base.d.ts +7 -4
  132. package/lib/es/typography/base.js +128 -65
  133. package/lib/es/typography/numeral.d.ts +1 -1
  134. package/lib/es/typography/paragraph.d.ts +1 -1
  135. package/lib/es/typography/text.d.ts +1 -1
  136. package/lib/es/typography/title.d.ts +1 -1
  137. package/package.json +9 -9
  138. package/dist/umd/semi-ui.min.js.LICENSE.txt +0 -5
@@ -20,6 +20,7 @@ import TabBar from './TabBar';
20
20
  import TabPane from './TabPane';
21
21
  import TabItem from './TabItem';
22
22
  import TabsContext from './tabs-context';
23
+ import { getDefaultPropsFromGlobalConfig } from "../_utils";
23
24
  const panePickKeys = ['className', 'style', 'disabled', 'itemKey', 'tab', 'icon'];
24
25
  export * from './interface';
25
26
  class Tabs extends BaseComponent {
@@ -320,7 +321,8 @@ Tabs.propTypes = {
320
321
  onTabClose: PropTypes.func,
321
322
  preventScroll: PropTypes.bool
322
323
  };
323
- Tabs.defaultProps = {
324
+ Tabs.__SemiComponentName__ = "Tabs";
325
+ Tabs.defaultProps = getDefaultPropsFromGlobalConfig(Tabs.__SemiComponentName__, {
324
326
  children: [],
325
327
  collapsible: false,
326
328
  keepDOM: true,
@@ -332,5 +334,5 @@ Tabs.defaultProps = {
332
334
  tabPosition: 'top',
333
335
  type: 'line',
334
336
  onTabClose: () => undefined
335
- };
337
+ });
336
338
  export default Tabs;
@@ -12,7 +12,7 @@ export interface Panel {
12
12
  panelHeader?: React.ReactNode | React.ReactNode[];
13
13
  panelFooter?: React.ReactNode | React.ReactNode[];
14
14
  }
15
- export type BaseValueType = string | number | Date;
15
+ export type BaseValueType = string | number | Date | undefined;
16
16
  export type Type = 'time' | 'timeRange';
17
17
  export type TimePickerProps = {
18
18
  'aria-describedby'?: React.AriaAttributes['aria-describedby'];
@@ -72,39 +72,7 @@ export default class LocaleTimePicker extends React.PureComponent<LocalePickerPr
72
72
  motion: import("prop-types").Requireable<NonNullable<boolean | object>>;
73
73
  autoAdjustOverflow: import("prop-types").Requireable<boolean>;
74
74
  };
75
- static defaultProps: {
76
- autoAdjustOverflow: boolean;
77
- borderless: boolean;
78
- getPopupContainer: () => HTMLElement;
79
- showClear: boolean;
80
- zIndex: number;
81
- rangeSeparator: " ~ ";
82
- onOpenChange: (...args: any[]) => void;
83
- clearText: string;
84
- prefixCls: string;
85
- inputReadOnly: boolean;
86
- style: {};
87
- stopPropagation: boolean;
88
- className: string;
89
- popupClassName: string;
90
- popupStyle: {
91
- left: string;
92
- top: string;
93
- };
94
- disabledHours: () => number[];
95
- disabledMinutes: () => number[];
96
- disabledSeconds: () => number[];
97
- hideDisabledOptions: boolean;
98
- onFocus: (...args: any[]) => void;
99
- onBlur: (...args: any[]) => void;
100
- onChange: (...args: any[]) => void;
101
- onChangeWithDateFirst: boolean;
102
- use12Hours: boolean;
103
- focusOnOpen: boolean;
104
- onKeyDown: (...args: any[]) => void;
105
- size: "default";
106
- type: "time";
107
- motion: boolean;
108
- };
75
+ static __SemiComponentName__: string;
76
+ static defaultProps: any;
109
77
  render(): JSX.Element;
110
78
  }
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import LocaleConsumer from '../locale/localeConsumer';
4
4
  import BaseTimePicker from './TimePicker';
5
5
  import ConfigContext from '../configProvider/context';
6
+ import { getDefaultPropsFromGlobalConfig } from "../_utils";
6
7
  export default class LocaleTimePicker extends React.PureComponent {
7
8
  render() {
8
9
  const {
@@ -26,4 +27,5 @@ export default class LocaleTimePicker extends React.PureComponent {
26
27
  }
27
28
  }
28
29
  LocaleTimePicker.propTypes = BaseTimePicker.propTypes;
29
- LocaleTimePicker.defaultProps = BaseTimePicker.defaultProps;
30
+ LocaleTimePicker.__SemiComponentName__ = "TimePicker";
31
+ LocaleTimePicker.defaultProps = getDefaultPropsFromGlobalConfig(LocaleTimePicker.__SemiComponentName__, BaseTimePicker.defaultProps);
@@ -35,17 +35,8 @@ declare class Toast extends BaseComponent<ToastReactProps, ToastState> {
35
35
  icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
36
36
  direction: PropTypes.Requireable<string>;
37
37
  };
38
- static defaultProps: {
39
- onClose: (...args: any[]) => void;
40
- content: string;
41
- close: (...args: any[]) => void;
42
- duration: number;
43
- textMaxWidth: number;
44
- showClose: boolean;
45
- stack: boolean;
46
- stackExpanded: boolean;
47
- theme: string;
48
- };
38
+ static __SemiComponentName__: string;
39
+ static defaultProps: any;
49
40
  constructor(props: ToastReactProps);
50
41
  context: ContextValue;
51
42
  get adapter(): ToastAdapter;
@@ -8,7 +8,7 @@ import { numbers, cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/t
8
8
  import BaseComponent from '../_base/baseComponent';
9
9
  import Button from '../iconButton/index';
10
10
  import { IconClose, IconAlertTriangle, IconInfoCircle, IconTickCircle, IconAlertCircle } from '@douyinfe/semi-icons';
11
- import { isSemiIcon } from '../_utils';
11
+ import { getDefaultPropsFromGlobalConfig, isSemiIcon } from '../_utils';
12
12
  const prefixCls = cssClasses.PREFIX;
13
13
  class Toast extends BaseComponent {
14
14
  constructor(props) {
@@ -153,7 +153,8 @@ Toast.propTypes = {
153
153
  icon: PropTypes.node,
154
154
  direction: PropTypes.oneOf(strings.directions)
155
155
  };
156
- Toast.defaultProps = {
156
+ Toast.__SemiComponentName__ = "Toast";
157
+ Toast.defaultProps = getDefaultPropsFromGlobalConfig(Toast.__SemiComponentName__, {
157
158
  onClose: _noop,
158
159
  content: '',
159
160
  close: _noop,
@@ -163,5 +164,5 @@ Toast.defaultProps = {
163
164
  stack: false,
164
165
  stackExpanded: false,
165
166
  theme: 'normal'
166
- };
167
+ });
167
168
  export default Toast;
@@ -127,38 +127,8 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
127
127
  preventScroll: PropTypes.Requireable<boolean>;
128
128
  keepDOM: PropTypes.Requireable<boolean>;
129
129
  };
130
- static defaultProps: {
131
- arrowBounding: {
132
- readonly offsetX: 0;
133
- readonly offsetY: 2;
134
- readonly width: 24;
135
- readonly height: 7;
136
- };
137
- autoAdjustOverflow: boolean;
138
- arrowPointAtCenter: boolean;
139
- trigger: string;
140
- transformFromCenter: boolean;
141
- position: string;
142
- prefixCls: "semi-tooltip";
143
- role: string;
144
- mouseEnterDelay: 50;
145
- mouseLeaveDelay: 50;
146
- motion: boolean;
147
- onVisibleChange: (...args: any[]) => void;
148
- onClickOutSide: (...args: any[]) => void;
149
- spacing: 8;
150
- margin: 0;
151
- showArrow: boolean;
152
- wrapWhenSpecial: boolean;
153
- zIndex: 1060;
154
- closeOnEsc: boolean;
155
- guardFocus: boolean;
156
- returnFocusOnClose: boolean;
157
- onEscKeyDown: (...args: any[]) => void;
158
- disableFocusListener: boolean;
159
- disableArrowKeyDown: boolean;
160
- keepDOM: boolean;
161
- };
130
+ static __SemiComponentName__: string;
131
+ static defaultProps: any;
162
132
  eventManager: Event;
163
133
  triggerEl: React.RefObject<unknown>;
164
134
  containerEl: React.RefObject<HTMLDivElement>;
@@ -28,7 +28,7 @@ import { getUuidShort } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
28
28
  import '@douyinfe/semi-foundation/lib/es/tooltip/tooltip.css';
29
29
  import BaseComponent from '../_base/baseComponent';
30
30
  import { isHTMLElement } from '../_base/reactUtils';
31
- import { getActiveElement, getFocusableElements, stopPropagation } from '../_utils';
31
+ import { getActiveElement, getDefaultPropsFromGlobalConfig, getFocusableElements, stopPropagation } from '../_utils';
32
32
  import Portal from '../_portal/index';
33
33
  import ConfigContext from '../configProvider/context';
34
34
  import TriangleArrow from './TriangleArrow';
@@ -672,7 +672,8 @@ Tooltip.propTypes = {
672
672
  preventScroll: PropTypes.bool,
673
673
  keepDOM: PropTypes.bool
674
674
  };
675
- Tooltip.defaultProps = {
675
+ Tooltip.__SemiComponentName__ = "Tooltip";
676
+ Tooltip.defaultProps = getDefaultPropsFromGlobalConfig(Tooltip.__SemiComponentName__, {
676
677
  arrowBounding: numbers.ARROW_BOUNDING,
677
678
  autoAdjustOverflow: true,
678
679
  arrowPointAtCenter: true,
@@ -698,4 +699,4 @@ Tooltip.defaultProps = {
698
699
  disableFocusListener: false,
699
700
  disableArrowKeyDown: false,
700
701
  keepDOM: false
701
- };
702
+ });
@@ -1,8 +1,9 @@
1
1
  import React, { Component } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Ellipsis, ShowTooltip, TypographyBaseSize, TypographyBaseType } from './interface';
3
+ import type { Ellipsis, ShowTooltip, TypographyBaseSize, TypographyBaseType } from './interface';
4
4
  import { CopyableConfig, LinkType } from './title';
5
5
  import { BaseProps } from '../_base/baseComponent';
6
+ import { ResizeEntry } from '../resizeObserver';
6
7
  export interface BaseTypographyProps extends BaseProps {
7
8
  copyable?: CopyableConfig | boolean;
8
9
  delete?: boolean;
@@ -85,7 +86,7 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
85
86
  spacing: PropTypes.Requireable<"normal" | "extended">;
86
87
  strong: PropTypes.Requireable<boolean>;
87
88
  size: PropTypes.Requireable<"small" | "normal">;
88
- type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
89
+ type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
89
90
  style: PropTypes.Requireable<object>;
90
91
  className: PropTypes.Requireable<string>;
91
92
  icon: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
@@ -115,12 +116,13 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
115
116
  rafId: ReturnType<typeof requestAnimationFrame>;
116
117
  expandStr: string;
117
118
  collapseStr: string;
119
+ observerTakingEffect: boolean;
118
120
  constructor(props: BaseTypographyProps);
119
121
  componentDidMount(): void;
120
122
  static getDerivedStateFromProps(props: BaseTypographyProps, prevState: BaseTypographyState): Partial<BaseTypographyState>;
121
123
  componentDidUpdate(prevProps: BaseTypographyProps): void;
122
124
  componentWillUnmount(): void;
123
- onResize: () => void;
125
+ onResize: (entries?: ResizeEntry[]) => Promise<void>;
124
126
  canUseCSSEllipsis: () => boolean;
125
127
  /**
126
128
  * whether truncated
@@ -133,7 +135,8 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
133
135
  showTooltip: () => boolean | ShowTooltip | {
134
136
  type: string;
135
137
  };
136
- getEllipsisState(): boolean;
138
+ onHover: () => any;
139
+ getEllipsisState: () => Promise<void>;
137
140
  /**
138
141
  * Triggered when the fold button is clicked to save the latest expanded state
139
142
  * @param {Event} e
@@ -4,6 +4,33 @@ import _isString from "lodash/isString";
4
4
  import _merge from "lodash/merge";
5
5
  import _omit from "lodash/omit";
6
6
  import _isUndefined from "lodash/isUndefined";
7
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) {
9
+ return value instanceof P ? value : new P(function (resolve) {
10
+ resolve(value);
11
+ });
12
+ }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) {
15
+ try {
16
+ step(generator.next(value));
17
+ } catch (e) {
18
+ reject(e);
19
+ }
20
+ }
21
+ function rejected(value) {
22
+ try {
23
+ step(generator["throw"](value));
24
+ } catch (e) {
25
+ reject(e);
26
+ }
27
+ }
28
+ function step(result) {
29
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
30
+ }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
7
34
  var __rest = this && this.__rest || function (s, e) {
8
35
  var t = {};
9
36
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -24,8 +51,8 @@ import getRenderText from './util';
24
51
  import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
25
52
  import isEnterPress from '@douyinfe/semi-foundation/lib/es/utils/isEnterPress';
26
53
  import LocaleConsumer from '../locale/localeConsumer';
27
- import { isSemiIcon } from '../_utils';
28
- import ResizeObserver from '../resizeObserver';
54
+ import { isSemiIcon, runAfterTicks } from '../_utils';
55
+ import ResizeObserver, { ObserverProperty } from '../resizeObserver';
29
56
  const prefixCls = cssClasses.PREFIX;
30
57
  const ELLIPSIS_STR = '...';
31
58
  const wrapperDecorations = (props, content) => {
@@ -59,12 +86,18 @@ const wrapperDecorations = (props, content) => {
59
86
  export default class Base extends Component {
60
87
  constructor(props) {
61
88
  super(props);
62
- this.onResize = () => {
89
+ this.observerTakingEffect = false;
90
+ this.onResize = entries => __awaiter(this, void 0, void 0, function* () {
63
91
  if (this.rafId) {
64
92
  window.cancelAnimationFrame(this.rafId);
65
93
  }
66
- this.rafId = window.requestAnimationFrame(this.getEllipsisState.bind(this));
67
- };
94
+ return new Promise(resolve => {
95
+ this.rafId = window.requestAnimationFrame(() => __awaiter(this, void 0, void 0, function* () {
96
+ yield this.getEllipsisState();
97
+ resolve();
98
+ }));
99
+ });
100
+ });
68
101
  // if it needs to use js overflowed:
69
102
  // 1. text is expandable 2. expandText need to be shown 3. has extra operation 4. text need to ellipse from mid
70
103
  this.canUseCSSEllipsis = () => {
@@ -134,6 +167,80 @@ export default class Base extends Component {
134
167
  }
135
168
  return defaultOpts;
136
169
  };
170
+ this.onHover = () => {
171
+ const canUseCSSEllipsis = this.canUseCSSEllipsis();
172
+ if (canUseCSSEllipsis) {
173
+ const {
174
+ rows,
175
+ suffix,
176
+ pos
177
+ } = this.getEllipsisOpt();
178
+ const updateOverflow = this.shouldTruncated(rows);
179
+ // isOverflowed needs to be updated to show tooltip when using css ellipsis
180
+ this.setState({
181
+ isOverflowed: updateOverflow,
182
+ isTruncated: false
183
+ });
184
+ return undefined;
185
+ }
186
+ };
187
+ this.getEllipsisState = () => __awaiter(this, void 0, void 0, function* () {
188
+ const {
189
+ rows,
190
+ suffix,
191
+ pos
192
+ } = this.getEllipsisOpt();
193
+ const {
194
+ children
195
+ } = this.props;
196
+ // wait until element mounted
197
+ if (!this.wrapperRef || !this.wrapperRef.current) {
198
+ yield this.onResize();
199
+ return;
200
+ }
201
+ const {
202
+ expanded
203
+ } = this.state;
204
+ const canUseCSSEllipsis = this.canUseCSSEllipsis();
205
+ if (canUseCSSEllipsis) {
206
+ // const updateOverflow = this.shouldTruncated(rows);
207
+ // // isOverflowed needs to be updated to show tooltip when using css ellipsis
208
+ // this.setState({
209
+ // isOverflowed: updateOverflow,
210
+ // isTruncated: false
211
+ // });
212
+ return;
213
+ }
214
+ // If children is null, css/js truncated flag isTruncate is false
215
+ if (_isNull(children)) {
216
+ return new Promise(resolve => {
217
+ this.setState({
218
+ isTruncated: false,
219
+ isOverflowed: false
220
+ }, resolve);
221
+ });
222
+ }
223
+ // Currently only text truncation is supported, if there is non-text,
224
+ // both css truncation and js truncation should throw a warning
225
+ warning('children' in this.props && typeof children !== 'string', "[Semi Typography] Only children with pure text could be used with ellipsis at this moment.");
226
+ if (!rows || rows < 0 || expanded) {
227
+ return;
228
+ }
229
+ const extraNode = {
230
+ expand: this.expandRef.current,
231
+ copy: this.copyRef && this.copyRef.current
232
+ };
233
+ const content = getRenderText(this.wrapperRef.current, rows,
234
+ // Perform type conversion on children to prevent component crash due to non-string type of children
235
+ String(children), extraNode, ELLIPSIS_STR, suffix, pos);
236
+ return new Promise(resolve => {
237
+ this.setState({
238
+ isOverflowed: false,
239
+ ellipsisContent: content,
240
+ isTruncated: children !== content
241
+ }, resolve);
242
+ });
243
+ });
137
244
  /**
138
245
  * Triggered when the fold button is clicked to save the latest expanded state
139
246
  * @param {Event} e
@@ -300,9 +407,13 @@ export default class Base extends Component {
300
407
  ellipsisContent
301
408
  } = this.state;
302
409
  if (expanded || !isTruncated) {
303
- return /*#__PURE__*/React.createElement(React.Fragment, null, children, suffix && suffix.length ? suffix : null);
410
+ return /*#__PURE__*/React.createElement("span", {
411
+ onMouseEnter: this.onHover
412
+ }, children, suffix && suffix.length ? suffix : null);
304
413
  }
305
- return /*#__PURE__*/React.createElement("span", null, ellipsisContent, suffix);
414
+ return /*#__PURE__*/React.createElement("span", {
415
+ onMouseEnter: this.onHover
416
+ }, ellipsisContent, suffix);
306
417
  };
307
418
  this.state = {
308
419
  editable: false,
@@ -322,7 +433,8 @@ export default class Base extends Component {
322
433
  }
323
434
  componentDidMount() {
324
435
  if (this.props.ellipsis) {
325
- this.onResize();
436
+ // runAfterTicks: make sure start observer on the next tick
437
+ this.onResize().then(() => runAfterTicks(() => this.observerTakingEffect = true, 1));
326
438
  }
327
439
  }
328
440
  static getDerivedStateFromProps(props, prevState) {
@@ -354,61 +466,6 @@ export default class Base extends Component {
354
466
  window.cancelAnimationFrame(this.rafId);
355
467
  }
356
468
  }
357
- getEllipsisState() {
358
- const {
359
- rows,
360
- suffix,
361
- pos
362
- } = this.getEllipsisOpt();
363
- const {
364
- children
365
- } = this.props;
366
- // wait until element mounted
367
- if (!this.wrapperRef || !this.wrapperRef.current) {
368
- this.onResize();
369
- return false;
370
- }
371
- const {
372
- expanded
373
- } = this.state;
374
- const canUseCSSEllipsis = this.canUseCSSEllipsis();
375
- // If children is null, css/js truncated flag isTruncate is false
376
- if (_isNull(children)) {
377
- this.setState({
378
- isTruncated: false,
379
- isOverflowed: false
380
- });
381
- return undefined;
382
- }
383
- // Currently only text truncation is supported, if there is non-text,
384
- // both css truncation and js truncation should throw a warning
385
- warning('children' in this.props && typeof children !== 'string', "[Semi Typography] Only children with pure text could be used with ellipsis at this moment.");
386
- if (!rows || rows < 0 || expanded) {
387
- return undefined;
388
- }
389
- if (canUseCSSEllipsis) {
390
- const updateOverflow = this.shouldTruncated(rows);
391
- // isOverflowed needs to be updated to show tooltip when using css ellipsis
392
- this.setState({
393
- isOverflowed: updateOverflow,
394
- isTruncated: false
395
- });
396
- return undefined;
397
- }
398
- const extraNode = {
399
- expand: this.expandRef.current,
400
- copy: this.copyRef && this.copyRef.current
401
- };
402
- const content = getRenderText(this.wrapperRef.current, rows,
403
- // Perform type conversion on children to prevent component crash due to non-string type of children
404
- String(children), extraNode, ELLIPSIS_STR, suffix, pos);
405
- this.setState({
406
- isOverflowed: false,
407
- ellipsisContent: content,
408
- isTruncated: children !== content
409
- });
410
- return undefined;
411
- }
412
469
  renderOperations() {
413
470
  return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderExpandable(), this.renderCopy());
414
471
  }
@@ -550,6 +607,7 @@ export default class Base extends Component {
550
607
  }
551
608
  }
552
609
  render() {
610
+ var _this = this;
553
611
  const content = /*#__PURE__*/React.createElement(LocaleConsumer, {
554
612
  componentName: "Typography"
555
613
  }, locale => {
@@ -559,8 +617,13 @@ export default class Base extends Component {
559
617
  });
560
618
  if (this.props.ellipsis) {
561
619
  return /*#__PURE__*/React.createElement(ResizeObserver, {
562
- onResize: this.onResize,
563
- observeParent: true
620
+ onResize: function () {
621
+ if (_this.observerTakingEffect) {
622
+ _this.onResize(...arguments);
623
+ }
624
+ },
625
+ observeParent: true,
626
+ observerProperty: ObserverProperty.Width
564
627
  }, content);
565
628
  }
566
629
  return content;
@@ -38,7 +38,7 @@ export default class Numeral extends PureComponent<NumeralProps> {
38
38
  underline: PropTypes.Requireable<boolean>;
39
39
  link: PropTypes.Requireable<NonNullable<boolean | object>>;
40
40
  strong: PropTypes.Requireable<boolean>;
41
- type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
41
+ type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
42
42
  size: PropTypes.Requireable<"small" | "normal">;
43
43
  style: PropTypes.Requireable<object>;
44
44
  className: PropTypes.Requireable<string>;
@@ -50,7 +50,7 @@ export default class Paragraph extends PureComponent<ParagraphProps> {
50
50
  link: PropTypes.Requireable<NonNullable<boolean | object>>;
51
51
  underline: PropTypes.Requireable<boolean>;
52
52
  strong: PropTypes.Requireable<boolean>;
53
- type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
53
+ type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
54
54
  size: PropTypes.Requireable<"small" | "normal">;
55
55
  spacing: PropTypes.Requireable<"normal" | "extended">;
56
56
  style: PropTypes.Requireable<object>;
@@ -53,7 +53,7 @@ export default class Text extends PureComponent<TextProps> {
53
53
  underline: PropTypes.Requireable<boolean>;
54
54
  link: PropTypes.Requireable<NonNullable<boolean | object>>;
55
55
  strong: PropTypes.Requireable<boolean>;
56
- type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
56
+ type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
57
57
  size: PropTypes.Requireable<"small" | "normal">;
58
58
  style: PropTypes.Requireable<object>;
59
59
  className: PropTypes.Requireable<string>;
@@ -59,7 +59,7 @@ export default class Title extends PureComponent<TitleProps> {
59
59
  link: PropTypes.Requireable<NonNullable<boolean | object>>;
60
60
  underline: PropTypes.Requireable<boolean>;
61
61
  strong: PropTypes.Requireable<boolean>;
62
- type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
62
+ type: PropTypes.Requireable<"warning" | "success" | "primary" | "secondary" | "danger" | "tertiary" | "quaternary">;
63
63
  heading: PropTypes.Requireable<1 | 2 | 3 | 4 | 5 | 6>;
64
64
  style: PropTypes.Requireable<object>;
65
65
  className: PropTypes.Requireable<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.52.0-beta.1",
3
+ "version": "2.53.0-beta.0",
4
4
  "description": "A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -20,22 +20,22 @@
20
20
  "@dnd-kit/core": "^6.0.8",
21
21
  "@dnd-kit/sortable": "^7.0.2",
22
22
  "@dnd-kit/utilities": "^3.2.1",
23
- "@douyinfe/semi-animation": "2.52.0-beta.1",
24
- "@douyinfe/semi-animation-react": "2.52.0-beta.1",
25
- "@douyinfe/semi-foundation": "2.52.0-beta.1",
26
- "@douyinfe/semi-icons": "2.52.0-beta.1",
27
- "@douyinfe/semi-illustrations": "2.52.0-beta.1",
28
- "@douyinfe/semi-theme-default": "2.52.0-beta.1",
23
+ "@douyinfe/semi-animation": "2.53.0-beta.0",
24
+ "@douyinfe/semi-animation-react": "2.53.0-beta.0",
25
+ "@douyinfe/semi-foundation": "2.53.0-beta.0",
26
+ "@douyinfe/semi-icons": "2.53.0-beta.0",
27
+ "@douyinfe/semi-illustrations": "2.53.0-beta.0",
28
+ "@douyinfe/semi-theme-default": "2.53.0-beta.0",
29
29
  "async-validator": "^3.5.0",
30
30
  "classnames": "^2.2.6",
31
31
  "copy-text-to-clipboard": "^2.1.1",
32
32
  "date-fns": "^2.29.3",
33
33
  "date-fns-tz": "^1.3.8",
34
+ "fast-copy": "^3.0.1 ",
34
35
  "lodash": "^4.17.21",
35
36
  "prop-types": "^15.7.2",
36
37
  "react-resizable": "^3.0.5",
37
38
  "react-window": "^1.8.2",
38
- "resize-observer-polyfill": "^1.5.1",
39
39
  "scroll-into-view-if-needed": "^2.2.24",
40
40
  "utility-types": "^3.10.0"
41
41
  },
@@ -75,7 +75,7 @@
75
75
  ],
76
76
  "author": "",
77
77
  "license": "MIT",
78
- "gitHead": "f06aca5797fda6a3f03a003ddd24591da9a4e6d4",
78
+ "gitHead": "89f93e5a8ad3b801d7b0db62e9bff8acbe0c50c0",
79
79
  "devDependencies": {
80
80
  "@babel/plugin-proposal-decorators": "^7.15.8",
81
81
  "@babel/plugin-transform-runtime": "^7.15.8",
@@ -1,5 +0,0 @@
1
- /*!
2
- Copyright (c) 2018 Jed Watson.
3
- Licensed under the MIT License (MIT), see
4
- http://jedwatson.github.io/classnames
5
- */