@douyinfe/semi-ui 2.42.3 → 2.43.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.
@@ -44,7 +44,11 @@ class DropdownItem extends _baseComponent.default {
44
44
  const events = {};
45
45
  if (!disabled) {
46
46
  ['onClick', 'onMouseEnter', 'onMouseLeave', 'onContextMenu'].forEach(eventName => {
47
- events[eventName] = this.props[eventName];
47
+ if (eventName === "onClick") {
48
+ events["onMouseDown"] = this.props[eventName];
49
+ } else {
50
+ events[eventName] = this.props[eventName];
51
+ }
48
52
  });
49
53
  }
50
54
  let tick = null;
@@ -123,20 +123,25 @@ const ResizableTable = function () {
123
123
  };
124
124
  const resizableRender = function (col, index) {
125
125
  let level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
126
+ let originalHeaderCellProps = arguments.length > 3 ? arguments[3] : undefined;
126
127
  return Object.assign(Object.assign({}, col), {
127
- onHeaderCell: column => ({
128
- width: column.width,
129
- onResize: handleResize(column),
130
- onResizeStart: handleResizeStart(column),
131
- onResizeStop: handleResizeStop(column)
132
- })
128
+ onHeaderCell: column => {
129
+ return Object.assign(Object.assign({}, originalHeaderCellProps), {
130
+ width: column.width,
131
+ onResize: handleResize(column),
132
+ onResizeStart: handleResizeStart(column),
133
+ onResizeStop: handleResizeStop(column)
134
+ });
135
+ }
133
136
  });
134
137
  };
135
138
  const assignResizableRender = function () {
136
139
  let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
137
140
  let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
138
141
  return Array.isArray(columns) && columns.length ? columns.map((col, index) => {
139
- Object.assign(col, resizableRender(col, index, level));
142
+ var _a, _b;
143
+ const originalHeaderCellProps = (_b = (_a = col.onHeaderCell) === null || _a === void 0 ? void 0 : _a.call(col, col, index, level)) !== null && _b !== void 0 ? _b : {};
144
+ Object.assign(col, resizableRender(col, index, level, originalHeaderCellProps));
140
145
  const children = col[childrenColumnName];
141
146
  if (Array.isArray(children) && children.length) {
142
147
  col[childrenColumnName] = assignResizableRender(children, level + 1);
@@ -393,7 +393,9 @@ class TreeNode extends _react.PureComponent {
393
393
  expandStatus: {
394
394
  expanded,
395
395
  loading
396
- }
396
+ },
397
+ filtered,
398
+ searchWord: rest.keyword
397
399
  };
398
400
  const dragProps = {
399
401
  onDoubleClick: this.onDoubleClick,
@@ -8,6 +8,27 @@ export interface BaseTypographyProps extends BaseProps {
8
8
  delete?: boolean;
9
9
  disabled?: boolean;
10
10
  icon?: React.ReactNode;
11
+ /**
12
+ * ellipsis 用于设置截断相关参数.
13
+ * Ellipsis is used to set ellipsis related parameters.
14
+ * ellipsis 仅支持纯文本的截断,不支持 reactNode 等复杂类型,请确保 children 传入内容类型为 string.
15
+ * Ellipsis only supports ellipsis of plain text, and does not support complex types such as reactNode.
16
+ * Please ensure that the content type of children is string.
17
+ * Semi 截断有两种策略, CSS 截断和 JS 截断。
18
+ * Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis.
19
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
20
+ * - When setting middle ellipsis (pos='middle')、expandable、suffix is not empty string、copyable,
21
+ * the JS ellipsis strategy is enabled
22
+ * - 非以上场景,启用 CSS 截断策略
23
+ * - Otherwise, enable the CSS ellipsis strategy
24
+ *
25
+ * 通常来说 CSS 截断的性能优于 JS 截断。在 children 不变, 容器尺寸不变的情况下,CSS 截断只涉及 1-2 次计算,js 截断基于二分法,可能涉及多次计算。
26
+ * In general CSS ellipsis performs better than JS ellipsis. when the children and container size remain unchanged,
27
+ * CSS ellipsis only involves 1-2 calculations, while JS ellipsis is based on dichotomy and may require multiple calculations.
28
+ * 同时使用大量带有截断功能的 Typography 需注意性能消耗,如在 Table 中,可通过设置合理的页容量进行分页减少性能损耗
29
+ * Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table,
30
+ * you can reduce performance loss by setting a reasonable pageSize for paging
31
+ */
11
32
  ellipsis?: Ellipsis | boolean;
12
33
  mark?: boolean;
13
34
  underline?: boolean;
@@ -125,8 +146,8 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
125
146
  * 获取文本的缩略class和style
126
147
  *
127
148
  * 截断类型:
128
- * - CSS 截断,仅在 rows=1 且没有 expandable、pos、suffix 时生效
129
- * - JS 截断,应对 CSS 无法阶段的场景
149
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
150
+ * - 非以上场景,启用 CSS 截断策略
130
151
  * 相关变量
131
152
  * props:
132
153
  * - ellipsis:
@@ -142,8 +163,8 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
142
163
  * Get the abbreviated class and style of the text
143
164
  *
144
165
  * Truncation type:
145
- * -CSS truncation, which only takes effect when rows = 1 and there is no expandable, pos, suffix
146
- * -JS truncation, dealing with scenarios where CSS cannot stage
166
+ * -When setting middle ellipsis (pos='middle')、expandable、suffix is not empty、copyable, the JS ellipsis strategy is enabled
167
+ * -Otherwise, enable the CSS ellipsis strategy
147
168
  * related variables
148
169
  * props:
149
170
  * -ellipsis:
@@ -218,8 +218,8 @@ class Base extends _react.Component {
218
218
  * 获取文本的缩略class和style
219
219
  *
220
220
  * 截断类型:
221
- * - CSS 截断,仅在 rows=1 且没有 expandable、pos、suffix 时生效
222
- * - JS 截断,应对 CSS 无法阶段的场景
221
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
222
+ * - 非以上场景,启用 CSS 截断策略
223
223
  * 相关变量
224
224
  * props:
225
225
  * - ellipsis:
@@ -235,8 +235,8 @@ class Base extends _react.Component {
235
235
  * Get the abbreviated class and style of the text
236
236
  *
237
237
  * Truncation type:
238
- * -CSS truncation, which only takes effect when rows = 1 and there is no expandable, pos, suffix
239
- * -JS truncation, dealing with scenarios where CSS cannot stage
238
+ * -When setting middle ellipsis (pos='middle')、expandable、suffix is not empty、copyable, the JS ellipsis strategy is enabled
239
+ * -Otherwise, enable the CSS ellipsis strategy
240
240
  * related variables
241
241
  * props:
242
242
  * -ellipsis:
@@ -9,6 +9,27 @@ export interface ParagraphProps extends Omit<React.HTMLAttributes<HTMLParagraphE
9
9
  copyable?: CopyableConfig | boolean;
10
10
  delete?: boolean;
11
11
  disabled?: boolean;
12
+ /**
13
+ * ellipsis 用于设置截断相关参数.
14
+ * Ellipsis is used to set ellipsis related parameters.
15
+ * ellipsis 仅支持纯文本的截断,不支持 reactNode 等复杂类型,请确保 children 传入内容类型为 string.
16
+ * Ellipsis only supports ellipsis of plain text, and does not support complex types such as reactNode.
17
+ * Please ensure that the content type of children is string.
18
+ * Semi 截断有两种策略, CSS 截断和 JS 截断。
19
+ * Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis.
20
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
21
+ * - When setting middle ellipsis (pos='middle')、expandable、suffix is not empty string、copyable,
22
+ * the JS ellipsis strategy is enabled
23
+ * - 非以上场景,启用 CSS 截断策略
24
+ * - Otherwise, enable the CSS ellipsis strategy
25
+ *
26
+ * 通常来说 CSS 截断的性能优于 JS 截断。在 children 不变, 容器尺寸不变的情况下,CSS 截断只涉及 1-2 次计算,js 截断基于二分法,可能涉及多次计算。
27
+ * In general CSS ellipsis performs better than JS ellipsis. when the children and container size remain unchanged,
28
+ * CSS ellipsis only involves 1-2 calculations, while JS ellipsis is based on dichotomy and may require multiple calculations.
29
+ * 同时使用大量带有截断功能的 Typography 需注意性能消耗,如在 Table 中,可通过设置合理的页容量进行分页减少性能损耗
30
+ * Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table,
31
+ * you can reduce performance loss by setting a reasonable pageSize for paging
32
+ */
12
33
  ellipsis?: Ellipsis | boolean;
13
34
  link?: LinkType;
14
35
  mark?: boolean;
@@ -11,6 +11,27 @@ export interface TextProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, O
11
11
  copyable?: CopyableConfig | boolean;
12
12
  delete?: boolean;
13
13
  disabled?: boolean;
14
+ /**
15
+ * ellipsis 用于设置截断相关参数.
16
+ * Ellipsis is used to set ellipsis related parameters.
17
+ * ellipsis 仅支持纯文本的截断,不支持 reactNode 等复杂类型,请确保 children 传入内容类型为 string.
18
+ * Ellipsis only supports ellipsis of plain text, and does not support complex types such as reactNode.
19
+ * Please ensure that the content type of children is string.
20
+ * Semi 截断有两种策略, CSS 截断和 JS 截断。
21
+ * Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis.
22
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
23
+ * - When setting middle ellipsis (pos='middle')、expandable、suffix is not empty string、copyable,
24
+ * the JS ellipsis strategy is enabled
25
+ * - 非以上场景,启用 CSS 截断策略
26
+ * - Otherwise, enable the CSS ellipsis strategy
27
+ *
28
+ * 通常来说 CSS 截断的性能优于 JS 截断。在 children 不变, 容器尺寸不变的情况下,CSS 截断只涉及 1-2 次计算,js 截断基于二分法,可能涉及多次计算。
29
+ * In general CSS ellipsis performs better than JS ellipsis. when the children and container size remain unchanged,
30
+ * CSS ellipsis only involves 1-2 calculations, while JS ellipsis is based on dichotomy and may require multiple calculations.
31
+ * 同时使用大量带有截断功能的 Typography 需注意性能消耗,如在 Table 中,可通过设置合理的页容量进行分页减少性能损耗
32
+ * Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table,
33
+ * you can reduce performance loss by setting a reasonable pageSize for paging
34
+ */
14
35
  ellipsis?: Ellipsis | boolean;
15
36
  icon?: React.ReactNode | string;
16
37
  link?: LinkType;
@@ -18,6 +18,27 @@ export interface TitleProps extends Omit<React.HTMLAttributes<HTMLHeadingElement
18
18
  copyable?: CopyableConfig | boolean;
19
19
  delete?: boolean;
20
20
  disabled?: boolean;
21
+ /**
22
+ * ellipsis 用于设置截断相关参数.
23
+ * Ellipsis is used to set ellipsis related parameters.
24
+ * ellipsis 仅支持纯文本的截断,不支持 reactNode 等复杂类型,请确保 children 传入内容类型为 string.
25
+ * Ellipsis only supports ellipsis of plain text, and does not support complex types such as reactNode.
26
+ * Please ensure that the content type of children is string.
27
+ * Semi 截断有两种策略, CSS 截断和 JS 截断。
28
+ * Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis.
29
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
30
+ * - When setting middle ellipsis (pos='middle')、expandable、suffix is not empty string、copyable,
31
+ * the JS ellipsis strategy is enabled
32
+ * - 非以上场景,启用 CSS 截断策略
33
+ * - Otherwise, enable the CSS ellipsis strategy
34
+ *
35
+ * 通常来说 CSS 截断的性能优于 JS 截断。在 children 不变, 容器尺寸不变的情况下,CSS 截断只涉及 1-2 次计算,js 截断基于二分法,可能涉及多次计算。
36
+ * In general CSS ellipsis performs better than JS ellipsis. when the children and container size remain unchanged,
37
+ * CSS ellipsis only involves 1-2 calculations, while JS ellipsis is based on dichotomy and may require multiple calculations.
38
+ * 同时使用大量带有截断功能的 Typography 需注意性能消耗,如在 Table 中,可通过设置合理的页容量进行分页减少性能损耗
39
+ * Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table,
40
+ * you can reduce performance loss by setting a reasonable pageSize for paging
41
+ */
21
42
  ellipsis?: Ellipsis | boolean;
22
43
  heading?: ArrayElement<typeof strings.HEADING>;
23
44
  link?: LinkType;
@@ -28,6 +28,7 @@ export interface UploadProps {
28
28
  dragMainText?: ReactNode;
29
29
  dragSubText?: ReactNode;
30
30
  draggable?: boolean;
31
+ addOnPasting?: boolean;
31
32
  fileList?: Array<FileItem>;
32
33
  fileName?: string;
33
34
  headers?: Record<string, any> | ((file: File) => Record<string, string>);
@@ -44,6 +45,7 @@ export interface UploadProps {
44
45
  onClear?: () => void;
45
46
  onDrop?: (e: Event, files: Array<File>, fileList: Array<FileItem>) => void;
46
47
  onError?: (e: CustomError, file: File, fileList: Array<FileItem>, xhr: XMLHttpRequest) => void;
48
+ onPastingError?: (error: Error | PermissionStatus) => void;
47
49
  onExceed?: (fileList: Array<File>) => void;
48
50
  onFileChange?: (files: Array<File>) => void;
49
51
  onOpenFileDialog?: () => void;
@@ -88,6 +90,7 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
88
90
  static propTypes: {
89
91
  accept: PropTypes.Requireable<string>;
90
92
  action: PropTypes.Validator<string>;
93
+ addOnPasting: PropTypes.Requireable<boolean>;
91
94
  afterUpload: PropTypes.Requireable<(...args: any[]) => any>;
92
95
  beforeClear: PropTypes.Requireable<(...args: any[]) => any>;
93
96
  beforeRemove: PropTypes.Requireable<(...args: any[]) => any>;
@@ -128,6 +131,7 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
128
131
  onRetry: PropTypes.Requireable<(...args: any[]) => any>;
129
132
  onSizeError: PropTypes.Requireable<(...args: any[]) => any>;
130
133
  onSuccess: PropTypes.Requireable<(...args: any[]) => any>;
134
+ onPastingError: PropTypes.Requireable<(...args: any[]) => any>;
131
135
  previewFile: PropTypes.Requireable<(...args: any[]) => any>;
132
136
  prompt: PropTypes.Requireable<PropTypes.ReactNodeLike>;
133
137
  promptPosition: PropTypes.Requireable<"left" | "right" | "bottom">;
@@ -168,6 +172,8 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
168
172
  foundation: UploadFoundation;
169
173
  inputRef: RefObject<HTMLInputElement>;
170
174
  replaceInputRef: RefObject<HTMLInputElement>;
175
+ pastingCb: null | ((params: any) => void);
176
+ componentDidMount(): void;
171
177
  componentWillUnmount(): void;
172
178
  onClick: () => void;
173
179
  onChange: (e: ChangeEvent<HTMLInputElement>) => void;
@@ -446,6 +446,19 @@ class Upload extends _baseComponent.default {
446
446
  replaceInputKey: Math.random()
447
447
  }));
448
448
  },
449
+ isMac: () => {
450
+ return navigator.platform.toUpperCase().indexOf('MAC') >= 0;
451
+ },
452
+ registerPastingHandler: cb => {
453
+ document.body.addEventListener('keydown', cb);
454
+ this.pastingCb = cb;
455
+ },
456
+ unRegisterPastingHandler: () => {
457
+ if (this.pastingCb) {
458
+ document.body.removeEventListener('keydown', this.pastingCb);
459
+ }
460
+ },
461
+ notifyPastingError: error => this.props.onPastingError(error),
449
462
  updateDragAreaStatus: dragAreaStatus => this.setState({
450
463
  dragAreaStatus
451
464
  }),
@@ -470,6 +483,9 @@ class Upload extends _baseComponent.default {
470
483
  notifyBeforeClear: fileList => this.props.beforeClear(fileList)
471
484
  });
472
485
  }
486
+ componentDidMount() {
487
+ this.foundation.init();
488
+ }
473
489
  componentWillUnmount() {
474
490
  this.foundation.destroy();
475
491
  }
@@ -545,6 +561,7 @@ class Upload extends _baseComponent.default {
545
561
  Upload.propTypes = {
546
562
  accept: _propTypes.default.string,
547
563
  action: _propTypes.default.string.isRequired,
564
+ addOnPasting: _propTypes.default.bool,
548
565
  afterUpload: _propTypes.default.func,
549
566
  beforeClear: _propTypes.default.func,
550
567
  beforeRemove: _propTypes.default.func,
@@ -585,6 +602,7 @@ Upload.propTypes = {
585
602
  onRetry: _propTypes.default.func,
586
603
  onSizeError: _propTypes.default.func,
587
604
  onSuccess: _propTypes.default.func,
605
+ onPastingError: _propTypes.default.func,
588
606
  previewFile: _propTypes.default.func,
589
607
  prompt: _propTypes.default.node,
590
608
  promptPosition: _propTypes.default.oneOf(_constants.strings.PROMPT_POSITION),
@@ -629,6 +647,7 @@ Upload.defaultProps = {
629
647
  onRetry: _noop2.default,
630
648
  onSizeError: _noop2.default,
631
649
  onSuccess: _noop2.default,
650
+ onPastingError: _noop2.default,
632
651
  promptPosition: 'right',
633
652
  showClear: true,
634
653
  showPicInfo: false,
@@ -37,7 +37,11 @@ class DropdownItem extends BaseComponent {
37
37
  const events = {};
38
38
  if (!disabled) {
39
39
  ['onClick', 'onMouseEnter', 'onMouseLeave', 'onContextMenu'].forEach(eventName => {
40
- events[eventName] = this.props[eventName];
40
+ if (eventName === "onClick") {
41
+ events["onMouseDown"] = this.props[eventName];
42
+ } else {
43
+ events[eventName] = this.props[eventName];
44
+ }
41
45
  });
42
46
  }
43
47
  let tick = null;
@@ -113,20 +113,25 @@ const ResizableTable = function () {
113
113
  };
114
114
  const resizableRender = function (col, index) {
115
115
  let level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
116
+ let originalHeaderCellProps = arguments.length > 3 ? arguments[3] : undefined;
116
117
  return Object.assign(Object.assign({}, col), {
117
- onHeaderCell: column => ({
118
- width: column.width,
119
- onResize: handleResize(column),
120
- onResizeStart: handleResizeStart(column),
121
- onResizeStop: handleResizeStop(column)
122
- })
118
+ onHeaderCell: column => {
119
+ return Object.assign(Object.assign({}, originalHeaderCellProps), {
120
+ width: column.width,
121
+ onResize: handleResize(column),
122
+ onResizeStart: handleResizeStart(column),
123
+ onResizeStop: handleResizeStop(column)
124
+ });
125
+ }
123
126
  });
124
127
  };
125
128
  const assignResizableRender = function () {
126
129
  let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
127
130
  let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
128
131
  return Array.isArray(columns) && columns.length ? columns.map((col, index) => {
129
- Object.assign(col, resizableRender(col, index, level));
132
+ var _a, _b;
133
+ const originalHeaderCellProps = (_b = (_a = col.onHeaderCell) === null || _a === void 0 ? void 0 : _a.call(col, col, index, level)) !== null && _b !== void 0 ? _b : {};
134
+ Object.assign(col, resizableRender(col, index, level, originalHeaderCellProps));
130
135
  const children = col[childrenColumnName];
131
136
  if (Array.isArray(children) && children.length) {
132
137
  col[childrenColumnName] = assignResizableRender(children, level + 1);
@@ -384,7 +384,9 @@ export default class TreeNode extends PureComponent {
384
384
  expandStatus: {
385
385
  expanded,
386
386
  loading
387
- }
387
+ },
388
+ filtered,
389
+ searchWord: rest.keyword
388
390
  };
389
391
  const dragProps = {
390
392
  onDoubleClick: this.onDoubleClick,
@@ -8,6 +8,27 @@ export interface BaseTypographyProps extends BaseProps {
8
8
  delete?: boolean;
9
9
  disabled?: boolean;
10
10
  icon?: React.ReactNode;
11
+ /**
12
+ * ellipsis 用于设置截断相关参数.
13
+ * Ellipsis is used to set ellipsis related parameters.
14
+ * ellipsis 仅支持纯文本的截断,不支持 reactNode 等复杂类型,请确保 children 传入内容类型为 string.
15
+ * Ellipsis only supports ellipsis of plain text, and does not support complex types such as reactNode.
16
+ * Please ensure that the content type of children is string.
17
+ * Semi 截断有两种策略, CSS 截断和 JS 截断。
18
+ * Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis.
19
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
20
+ * - When setting middle ellipsis (pos='middle')、expandable、suffix is not empty string、copyable,
21
+ * the JS ellipsis strategy is enabled
22
+ * - 非以上场景,启用 CSS 截断策略
23
+ * - Otherwise, enable the CSS ellipsis strategy
24
+ *
25
+ * 通常来说 CSS 截断的性能优于 JS 截断。在 children 不变, 容器尺寸不变的情况下,CSS 截断只涉及 1-2 次计算,js 截断基于二分法,可能涉及多次计算。
26
+ * In general CSS ellipsis performs better than JS ellipsis. when the children and container size remain unchanged,
27
+ * CSS ellipsis only involves 1-2 calculations, while JS ellipsis is based on dichotomy and may require multiple calculations.
28
+ * 同时使用大量带有截断功能的 Typography 需注意性能消耗,如在 Table 中,可通过设置合理的页容量进行分页减少性能损耗
29
+ * Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table,
30
+ * you can reduce performance loss by setting a reasonable pageSize for paging
31
+ */
11
32
  ellipsis?: Ellipsis | boolean;
12
33
  mark?: boolean;
13
34
  underline?: boolean;
@@ -125,8 +146,8 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
125
146
  * 获取文本的缩略class和style
126
147
  *
127
148
  * 截断类型:
128
- * - CSS 截断,仅在 rows=1 且没有 expandable、pos、suffix 时生效
129
- * - JS 截断,应对 CSS 无法阶段的场景
149
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
150
+ * - 非以上场景,启用 CSS 截断策略
130
151
  * 相关变量
131
152
  * props:
132
153
  * - ellipsis:
@@ -142,8 +163,8 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
142
163
  * Get the abbreviated class and style of the text
143
164
  *
144
165
  * Truncation type:
145
- * -CSS truncation, which only takes effect when rows = 1 and there is no expandable, pos, suffix
146
- * -JS truncation, dealing with scenarios where CSS cannot stage
166
+ * -When setting middle ellipsis (pos='middle')、expandable、suffix is not empty、copyable, the JS ellipsis strategy is enabled
167
+ * -Otherwise, enable the CSS ellipsis strategy
147
168
  * related variables
148
169
  * props:
149
170
  * -ellipsis:
@@ -209,8 +209,8 @@ export default class Base extends Component {
209
209
  * 获取文本的缩略class和style
210
210
  *
211
211
  * 截断类型:
212
- * - CSS 截断,仅在 rows=1 且没有 expandable、pos、suffix 时生效
213
- * - JS 截断,应对 CSS 无法阶段的场景
212
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
213
+ * - 非以上场景,启用 CSS 截断策略
214
214
  * 相关变量
215
215
  * props:
216
216
  * - ellipsis:
@@ -226,8 +226,8 @@ export default class Base extends Component {
226
226
  * Get the abbreviated class and style of the text
227
227
  *
228
228
  * Truncation type:
229
- * -CSS truncation, which only takes effect when rows = 1 and there is no expandable, pos, suffix
230
- * -JS truncation, dealing with scenarios where CSS cannot stage
229
+ * -When setting middle ellipsis (pos='middle')、expandable、suffix is not empty、copyable, the JS ellipsis strategy is enabled
230
+ * -Otherwise, enable the CSS ellipsis strategy
231
231
  * related variables
232
232
  * props:
233
233
  * -ellipsis:
@@ -9,6 +9,27 @@ export interface ParagraphProps extends Omit<React.HTMLAttributes<HTMLParagraphE
9
9
  copyable?: CopyableConfig | boolean;
10
10
  delete?: boolean;
11
11
  disabled?: boolean;
12
+ /**
13
+ * ellipsis 用于设置截断相关参数.
14
+ * Ellipsis is used to set ellipsis related parameters.
15
+ * ellipsis 仅支持纯文本的截断,不支持 reactNode 等复杂类型,请确保 children 传入内容类型为 string.
16
+ * Ellipsis only supports ellipsis of plain text, and does not support complex types such as reactNode.
17
+ * Please ensure that the content type of children is string.
18
+ * Semi 截断有两种策略, CSS 截断和 JS 截断。
19
+ * Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis.
20
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
21
+ * - When setting middle ellipsis (pos='middle')、expandable、suffix is not empty string、copyable,
22
+ * the JS ellipsis strategy is enabled
23
+ * - 非以上场景,启用 CSS 截断策略
24
+ * - Otherwise, enable the CSS ellipsis strategy
25
+ *
26
+ * 通常来说 CSS 截断的性能优于 JS 截断。在 children 不变, 容器尺寸不变的情况下,CSS 截断只涉及 1-2 次计算,js 截断基于二分法,可能涉及多次计算。
27
+ * In general CSS ellipsis performs better than JS ellipsis. when the children and container size remain unchanged,
28
+ * CSS ellipsis only involves 1-2 calculations, while JS ellipsis is based on dichotomy and may require multiple calculations.
29
+ * 同时使用大量带有截断功能的 Typography 需注意性能消耗,如在 Table 中,可通过设置合理的页容量进行分页减少性能损耗
30
+ * Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table,
31
+ * you can reduce performance loss by setting a reasonable pageSize for paging
32
+ */
12
33
  ellipsis?: Ellipsis | boolean;
13
34
  link?: LinkType;
14
35
  mark?: boolean;
@@ -11,6 +11,27 @@ export interface TextProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, O
11
11
  copyable?: CopyableConfig | boolean;
12
12
  delete?: boolean;
13
13
  disabled?: boolean;
14
+ /**
15
+ * ellipsis 用于设置截断相关参数.
16
+ * Ellipsis is used to set ellipsis related parameters.
17
+ * ellipsis 仅支持纯文本的截断,不支持 reactNode 等复杂类型,请确保 children 传入内容类型为 string.
18
+ * Ellipsis only supports ellipsis of plain text, and does not support complex types such as reactNode.
19
+ * Please ensure that the content type of children is string.
20
+ * Semi 截断有两种策略, CSS 截断和 JS 截断。
21
+ * Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis.
22
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
23
+ * - When setting middle ellipsis (pos='middle')、expandable、suffix is not empty string、copyable,
24
+ * the JS ellipsis strategy is enabled
25
+ * - 非以上场景,启用 CSS 截断策略
26
+ * - Otherwise, enable the CSS ellipsis strategy
27
+ *
28
+ * 通常来说 CSS 截断的性能优于 JS 截断。在 children 不变, 容器尺寸不变的情况下,CSS 截断只涉及 1-2 次计算,js 截断基于二分法,可能涉及多次计算。
29
+ * In general CSS ellipsis performs better than JS ellipsis. when the children and container size remain unchanged,
30
+ * CSS ellipsis only involves 1-2 calculations, while JS ellipsis is based on dichotomy and may require multiple calculations.
31
+ * 同时使用大量带有截断功能的 Typography 需注意性能消耗,如在 Table 中,可通过设置合理的页容量进行分页减少性能损耗
32
+ * Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table,
33
+ * you can reduce performance loss by setting a reasonable pageSize for paging
34
+ */
14
35
  ellipsis?: Ellipsis | boolean;
15
36
  icon?: React.ReactNode | string;
16
37
  link?: LinkType;
@@ -18,6 +18,27 @@ export interface TitleProps extends Omit<React.HTMLAttributes<HTMLHeadingElement
18
18
  copyable?: CopyableConfig | boolean;
19
19
  delete?: boolean;
20
20
  disabled?: boolean;
21
+ /**
22
+ * ellipsis 用于设置截断相关参数.
23
+ * Ellipsis is used to set ellipsis related parameters.
24
+ * ellipsis 仅支持纯文本的截断,不支持 reactNode 等复杂类型,请确保 children 传入内容类型为 string.
25
+ * Ellipsis only supports ellipsis of plain text, and does not support complex types such as reactNode.
26
+ * Please ensure that the content type of children is string.
27
+ * Semi 截断有两种策略, CSS 截断和 JS 截断。
28
+ * Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis.
29
+ * - 当设置中间截断(pos='middle')、可展开(expandable)、有后缀(suffix 非空)、可复制(copyable),启用 JS 截断策略
30
+ * - When setting middle ellipsis (pos='middle')、expandable、suffix is not empty string、copyable,
31
+ * the JS ellipsis strategy is enabled
32
+ * - 非以上场景,启用 CSS 截断策略
33
+ * - Otherwise, enable the CSS ellipsis strategy
34
+ *
35
+ * 通常来说 CSS 截断的性能优于 JS 截断。在 children 不变, 容器尺寸不变的情况下,CSS 截断只涉及 1-2 次计算,js 截断基于二分法,可能涉及多次计算。
36
+ * In general CSS ellipsis performs better than JS ellipsis. when the children and container size remain unchanged,
37
+ * CSS ellipsis only involves 1-2 calculations, while JS ellipsis is based on dichotomy and may require multiple calculations.
38
+ * 同时使用大量带有截断功能的 Typography 需注意性能消耗,如在 Table 中,可通过设置合理的页容量进行分页减少性能损耗
39
+ * Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table,
40
+ * you can reduce performance loss by setting a reasonable pageSize for paging
41
+ */
21
42
  ellipsis?: Ellipsis | boolean;
22
43
  heading?: ArrayElement<typeof strings.HEADING>;
23
44
  link?: LinkType;
@@ -28,6 +28,7 @@ export interface UploadProps {
28
28
  dragMainText?: ReactNode;
29
29
  dragSubText?: ReactNode;
30
30
  draggable?: boolean;
31
+ addOnPasting?: boolean;
31
32
  fileList?: Array<FileItem>;
32
33
  fileName?: string;
33
34
  headers?: Record<string, any> | ((file: File) => Record<string, string>);
@@ -44,6 +45,7 @@ export interface UploadProps {
44
45
  onClear?: () => void;
45
46
  onDrop?: (e: Event, files: Array<File>, fileList: Array<FileItem>) => void;
46
47
  onError?: (e: CustomError, file: File, fileList: Array<FileItem>, xhr: XMLHttpRequest) => void;
48
+ onPastingError?: (error: Error | PermissionStatus) => void;
47
49
  onExceed?: (fileList: Array<File>) => void;
48
50
  onFileChange?: (files: Array<File>) => void;
49
51
  onOpenFileDialog?: () => void;
@@ -88,6 +90,7 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
88
90
  static propTypes: {
89
91
  accept: PropTypes.Requireable<string>;
90
92
  action: PropTypes.Validator<string>;
93
+ addOnPasting: PropTypes.Requireable<boolean>;
91
94
  afterUpload: PropTypes.Requireable<(...args: any[]) => any>;
92
95
  beforeClear: PropTypes.Requireable<(...args: any[]) => any>;
93
96
  beforeRemove: PropTypes.Requireable<(...args: any[]) => any>;
@@ -128,6 +131,7 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
128
131
  onRetry: PropTypes.Requireable<(...args: any[]) => any>;
129
132
  onSizeError: PropTypes.Requireable<(...args: any[]) => any>;
130
133
  onSuccess: PropTypes.Requireable<(...args: any[]) => any>;
134
+ onPastingError: PropTypes.Requireable<(...args: any[]) => any>;
131
135
  previewFile: PropTypes.Requireable<(...args: any[]) => any>;
132
136
  prompt: PropTypes.Requireable<PropTypes.ReactNodeLike>;
133
137
  promptPosition: PropTypes.Requireable<"left" | "right" | "bottom">;
@@ -168,6 +172,8 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
168
172
  foundation: UploadFoundation;
169
173
  inputRef: RefObject<HTMLInputElement>;
170
174
  replaceInputRef: RefObject<HTMLInputElement>;
175
+ pastingCb: null | ((params: any) => void);
176
+ componentDidMount(): void;
171
177
  componentWillUnmount(): void;
172
178
  onClick: () => void;
173
179
  onChange: (e: ChangeEvent<HTMLInputElement>) => void;
@@ -439,6 +439,19 @@ class Upload extends BaseComponent {
439
439
  replaceInputKey: Math.random()
440
440
  }));
441
441
  },
442
+ isMac: () => {
443
+ return navigator.platform.toUpperCase().indexOf('MAC') >= 0;
444
+ },
445
+ registerPastingHandler: cb => {
446
+ document.body.addEventListener('keydown', cb);
447
+ this.pastingCb = cb;
448
+ },
449
+ unRegisterPastingHandler: () => {
450
+ if (this.pastingCb) {
451
+ document.body.removeEventListener('keydown', this.pastingCb);
452
+ }
453
+ },
454
+ notifyPastingError: error => this.props.onPastingError(error),
442
455
  updateDragAreaStatus: dragAreaStatus => this.setState({
443
456
  dragAreaStatus
444
457
  }),
@@ -463,6 +476,9 @@ class Upload extends BaseComponent {
463
476
  notifyBeforeClear: fileList => this.props.beforeClear(fileList)
464
477
  });
465
478
  }
479
+ componentDidMount() {
480
+ this.foundation.init();
481
+ }
466
482
  componentWillUnmount() {
467
483
  this.foundation.destroy();
468
484
  }
@@ -538,6 +554,7 @@ class Upload extends BaseComponent {
538
554
  Upload.propTypes = {
539
555
  accept: PropTypes.string,
540
556
  action: PropTypes.string.isRequired,
557
+ addOnPasting: PropTypes.bool,
541
558
  afterUpload: PropTypes.func,
542
559
  beforeClear: PropTypes.func,
543
560
  beforeRemove: PropTypes.func,
@@ -578,6 +595,7 @@ Upload.propTypes = {
578
595
  onRetry: PropTypes.func,
579
596
  onSizeError: PropTypes.func,
580
597
  onSuccess: PropTypes.func,
598
+ onPastingError: PropTypes.func,
581
599
  previewFile: PropTypes.func,
582
600
  prompt: PropTypes.node,
583
601
  promptPosition: PropTypes.oneOf(strings.PROMPT_POSITION),
@@ -622,6 +640,7 @@ Upload.defaultProps = {
622
640
  onRetry: _noop,
623
641
  onSizeError: _noop,
624
642
  onSuccess: _noop,
643
+ onPastingError: _noop,
625
644
  promptPosition: 'right',
626
645
  showClear: true,
627
646
  showPicInfo: false,