@douyinfe/semi-ui 2.30.1 → 2.31.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 (73) hide show
  1. package/dist/css/semi.css +66 -51
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +203 -71
  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/_base/base.d.ts +3 -3
  8. package/lib/cjs/anchor/index.d.ts +1 -1
  9. package/lib/cjs/autoComplete/index.d.ts +1 -1
  10. package/lib/cjs/button/Button.d.ts +1 -1
  11. package/lib/cjs/cascader/index.js +2 -1
  12. package/lib/cjs/checkbox/checkbox.d.ts +1 -1
  13. package/lib/cjs/checkbox/checkboxGroup.d.ts +1 -1
  14. package/lib/cjs/descriptions/index.d.ts +1 -1
  15. package/lib/cjs/form/baseForm.js +9 -4
  16. package/lib/cjs/layout/index.d.ts +1 -1
  17. package/lib/cjs/modal/confirm.d.ts +303 -26
  18. package/lib/cjs/modal/confirm.js +7 -2
  19. package/lib/cjs/popover/index.d.ts +1 -0
  20. package/lib/cjs/progress/index.d.ts +3 -3
  21. package/lib/cjs/radio/radio.d.ts +1 -1
  22. package/lib/cjs/table/Body/index.js +4 -8
  23. package/lib/cjs/table/Table.js +7 -4
  24. package/lib/cjs/table/TableCell.js +30 -7
  25. package/lib/cjs/table/TableContextProvider.d.ts +1 -1
  26. package/lib/cjs/table/TableContextProvider.js +5 -3
  27. package/lib/cjs/table/TableHeaderRow.js +28 -9
  28. package/lib/cjs/table/index.d.ts +3 -0
  29. package/lib/cjs/table/index.js +11 -3
  30. package/lib/cjs/table/interface.d.ts +1 -0
  31. package/lib/cjs/table/table-context.d.ts +2 -0
  32. package/lib/cjs/tabs/interface.d.ts +1 -1
  33. package/lib/cjs/tag/index.js +6 -3
  34. package/lib/cjs/tagInput/index.d.ts +1 -1
  35. package/lib/cjs/tagInput/index.js +1 -3
  36. package/lib/cjs/tooltip/index.d.ts +4 -0
  37. package/lib/cjs/tooltip/index.js +21 -6
  38. package/lib/cjs/typography/copyable.d.ts +3 -0
  39. package/lib/cjs/typography/copyable.js +30 -9
  40. package/lib/es/_base/base.d.ts +3 -3
  41. package/lib/es/anchor/index.d.ts +1 -1
  42. package/lib/es/autoComplete/index.d.ts +1 -1
  43. package/lib/es/button/Button.d.ts +1 -1
  44. package/lib/es/cascader/index.js +2 -1
  45. package/lib/es/checkbox/checkbox.d.ts +1 -1
  46. package/lib/es/checkbox/checkboxGroup.d.ts +1 -1
  47. package/lib/es/descriptions/index.d.ts +1 -1
  48. package/lib/es/form/baseForm.js +9 -4
  49. package/lib/es/layout/index.d.ts +1 -1
  50. package/lib/es/modal/confirm.d.ts +303 -26
  51. package/lib/es/modal/confirm.js +6 -2
  52. package/lib/es/popover/index.d.ts +1 -0
  53. package/lib/es/progress/index.d.ts +3 -3
  54. package/lib/es/radio/radio.d.ts +1 -1
  55. package/lib/es/table/Body/index.js +4 -7
  56. package/lib/es/table/Table.js +7 -4
  57. package/lib/es/table/TableCell.js +31 -8
  58. package/lib/es/table/TableContextProvider.d.ts +1 -1
  59. package/lib/es/table/TableContextProvider.js +5 -3
  60. package/lib/es/table/TableHeaderRow.js +29 -10
  61. package/lib/es/table/index.d.ts +3 -0
  62. package/lib/es/table/index.js +10 -3
  63. package/lib/es/table/interface.d.ts +1 -0
  64. package/lib/es/table/table-context.d.ts +2 -0
  65. package/lib/es/tabs/interface.d.ts +1 -1
  66. package/lib/es/tag/index.js +9 -3
  67. package/lib/es/tagInput/index.d.ts +1 -1
  68. package/lib/es/tagInput/index.js +1 -3
  69. package/lib/es/tooltip/index.d.ts +4 -0
  70. package/lib/es/tooltip/index.js +21 -6
  71. package/lib/es/typography/copyable.d.ts +3 -0
  72. package/lib/es/typography/copyable.js +28 -9
  73. package/package.json +9 -9
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import NormalTable from './Table';
4
4
  import Column from './Column';
5
5
  import { TableProps, Data } from './interface';
6
+ import { ContextValue } from '../configProvider/context';
6
7
  declare class Table<RecordType extends Record<string, any> = Data> extends React.PureComponent<TableProps<RecordType>> {
7
8
  static Column: typeof Column;
8
9
  static DEFAULT_KEY_COLUMN_SELECTION: "column-selection";
@@ -91,7 +92,9 @@ declare class Table<RecordType extends Record<string, any> = Data> extends React
91
92
  static defaultProps: {
92
93
  hideExpandedColumn: boolean;
93
94
  };
95
+ static contextType: React.Context<ContextValue>;
94
96
  tableRef: React.RefObject<NormalTable<RecordType>>;
97
+ context: ContextValue;
95
98
  constructor(props: TableProps);
96
99
  getCurrentPageData: () => any;
97
100
  render(): JSX.Element;
@@ -4,6 +4,7 @@ import NormalTable from './Table';
4
4
  import ResizableTable from './ResizableTable';
5
5
  import Column from './Column';
6
6
  import { strings } from '@douyinfe/semi-foundation/lib/es/table/constants';
7
+ import ConfigContext from '../configProvider/context';
7
8
 
8
9
  class Table extends React.PureComponent {
9
10
  constructor(props) {
@@ -15,16 +16,21 @@ class Table extends React.PureComponent {
15
16
  }
16
17
 
17
18
  render() {
18
- // eslint-disable-next-line prefer-destructuring
19
+ var _a; // eslint-disable-next-line prefer-destructuring
20
+
21
+
19
22
  const props = this.props;
23
+ const direction = (_a = this.props.direction) !== null && _a !== void 0 ? _a : this.context.direction;
20
24
 
21
25
  if (props.resizable) {
22
26
  return /*#__PURE__*/React.createElement(ResizableTable, Object.assign({}, props, {
23
- ref: this.tableRef
27
+ ref: this.tableRef,
28
+ direction: direction
24
29
  }));
25
30
  } else {
26
31
  return /*#__PURE__*/React.createElement(NormalTable, Object.assign({}, props, {
27
- ref: this.tableRef
32
+ ref: this.tableRef,
33
+ direction: direction
28
34
  }));
29
35
  }
30
36
  }
@@ -40,5 +46,6 @@ Table.propTypes = Object.assign(Object.assign({}, NormalTable.propTypes), {
40
46
  Table.defaultProps = {
41
47
  hideExpandedColumn: true
42
48
  };
49
+ Table.contextType = ConfigContext;
43
50
  export * from './interface';
44
51
  export default Table;
@@ -56,6 +56,7 @@ export interface TableProps<RecordType extends Record<string, any> = any> extend
56
56
  onHeaderRow?: OnHeaderRow<RecordType>;
57
57
  onRow?: OnRow<RecordType>;
58
58
  sticky?: Sticky;
59
+ direction?: Direction;
59
60
  }
60
61
  export interface ColumnProps<RecordType extends Record<string, any> = any> {
61
62
  [x: string]: any;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ColumnProps, GetVirtualizedListRef, RowKey } from './interface';
3
3
  import { BaseHeadWidth } from '@douyinfe/semi-foundation/lib/es/table/foundation';
4
+ import type { ContextValue } from '../configProvider/context';
4
5
  export interface TableContextProps {
5
6
  children?: React.ReactNode;
6
7
  anyColumnFixed?: boolean;
@@ -15,6 +16,7 @@ export interface TableContextProps {
15
16
  renderSelection?: (record?: Record<string, any>, isHeader?: boolean) => React.ReactNode;
16
17
  getVirtualizedListRef?: GetVirtualizedListRef;
17
18
  setBodyHasScrollbar?: (bodyHasScrollBar: boolean) => void;
19
+ direction?: ContextValue['direction'];
18
20
  }
19
21
  declare const TableContext: React.Context<TableContextProps>;
20
22
  export default TableContext;
@@ -54,7 +54,7 @@ export interface TabBarProps {
54
54
  }
55
55
  export interface TabPaneProps {
56
56
  className?: string;
57
- children?: React.ReactNode | undefined;
57
+ children?: React.ReactNode;
58
58
  disabled?: boolean;
59
59
  icon?: ReactNode;
60
60
  itemKey?: string;
@@ -21,6 +21,7 @@ import Avatar from '../avatar/index';
21
21
  import { IconClose } from '@douyinfe/semi-icons';
22
22
  import { handlePrevent } from '@douyinfe/semi-foundation/lib/es/utils/a11y';
23
23
  import '@douyinfe/semi-foundation/lib/es/tag/tag.css';
24
+ import cls from 'classnames';
24
25
  export * from './interface';
25
26
  const prefixCls = cssClasses.PREFIX;
26
27
  const tagColors = strings.TAG_COLOR;
@@ -140,11 +141,12 @@ export default class Tag extends Component {
140
141
 
141
142
  const a11yProps = {
142
143
  role: 'button',
143
- tabIndex: tabIndex | 0,
144
+ tabIndex: tabIndex || 0,
144
145
  onKeyDown: this.handleKeyDown
145
146
  };
146
147
  const baseProps = Object.assign(Object.assign({}, attr), {
147
148
  onClick,
149
+ tabIndex: tabIndex,
148
150
  className: classNames(prefixCls, {
149
151
  [`${prefixCls}-default`]: size === 'default',
150
152
  [`${prefixCls}-small`]: size === 'small',
@@ -168,10 +170,14 @@ export default class Tag extends Component {
168
170
  }, /*#__PURE__*/React.createElement(IconClose, {
169
171
  size: "small"
170
172
  })) : null;
173
+
174
+ const stringChild = _isString(children);
175
+
176
+ const contentCls = cls(`${prefixCls}-content`, `${prefixCls}-content-${stringChild ? 'ellipsis' : 'center'}`);
171
177
  return /*#__PURE__*/React.createElement("div", Object.assign({
172
- "aria-label": this.props['aria-label'] || _isString(children) ? `${closable ? 'Closable ' : ''}Tag: ${children}` : ''
178
+ "aria-label": this.props['aria-label'] || stringChild ? `${closable ? 'Closable ' : ''}Tag: ${children}` : ''
173
179
  }, wrapProps), avatarSrc ? this.renderAvatar() : null, /*#__PURE__*/React.createElement("div", {
174
- className: `${prefixCls}-content`
180
+ className: contentCls
175
181
  }, children), closeIcon);
176
182
  }
177
183
 
@@ -46,7 +46,7 @@ export interface TagInputProps {
46
46
  style?: React.CSSProperties;
47
47
  suffix?: React.ReactNode;
48
48
  validateStatus?: ValidateStatus;
49
- value?: string[] | undefined;
49
+ value?: string[];
50
50
  autoFocus?: boolean;
51
51
  'aria-label'?: string;
52
52
  preventScroll?: boolean;
@@ -140,15 +140,13 @@ class TagInput extends BaseComponent {
140
140
  key: elementKey,
141
141
  visible: true,
142
142
  "aria-label": `${!disabled ? 'Closable ' : ''}Tag: ${value}`
143
- }, /*#__PURE__*/React.createElement("div", {
144
- className: `${prefixCls}-tag-content-wrapper`
145
143
  }, showIconHandler && /*#__PURE__*/React.createElement(DragHandle, null), /*#__PURE__*/React.createElement(Paragraph, {
146
144
  className: typoCls,
147
145
  ellipsis: {
148
146
  showTooltip: showContentTooltip,
149
147
  rows: 1
150
148
  }
151
- }, value)));
149
+ }, value));
152
150
  }
153
151
  });
154
152
  };
@@ -63,6 +63,7 @@ export interface TooltipProps extends BaseProps {
63
63
  preventScroll?: boolean;
64
64
  disableFocusListener?: boolean;
65
65
  afterClose?: () => void;
66
+ keepDOM?: boolean;
66
67
  }
67
68
  interface TooltipState {
68
69
  visible: boolean;
@@ -79,6 +80,7 @@ interface TooltipState {
79
80
  transitionStyle: Record<string, any>;
80
81
  isPositionUpdated: boolean;
81
82
  id: string;
83
+ displayNone: boolean;
82
84
  }
83
85
  export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
84
86
  static contextType: React.Context<ContextValue>;
@@ -120,6 +122,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
120
122
  guardFocus: PropTypes.Requireable<boolean>;
121
123
  returnFocusOnClose: PropTypes.Requireable<boolean>;
122
124
  preventScroll: PropTypes.Requireable<boolean>;
125
+ keepDOM: PropTypes.Requireable<boolean>;
123
126
  };
124
127
  static defaultProps: {
125
128
  arrowBounding: {
@@ -151,6 +154,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
151
154
  onEscKeyDown: (...args: any[]) => void;
152
155
  disableFocusListener: boolean;
153
156
  disableArrowKeyDown: boolean;
157
+ keepDOM: boolean;
154
158
  };
155
159
  eventManager: Event;
156
160
  triggerEl: React.RefObject<unknown>;
@@ -85,7 +85,12 @@ export default class Tooltip extends BaseComponent {
85
85
 
86
86
 
87
87
  this.didLeave = () => {
88
- this.foundation.removePortal();
88
+ if (this.props.keepDOM) {
89
+ this.foundation.setDisplayNone(true);
90
+ } else {
91
+ this.foundation.removePortal();
92
+ }
93
+
89
94
  this.foundation.unBindEvent();
90
95
  };
91
96
 
@@ -155,6 +160,7 @@ export default class Tooltip extends BaseComponent {
155
160
  visible,
156
161
  portalEventSet,
157
162
  placement,
163
+ displayNone,
158
164
  transitionState,
159
165
  id,
160
166
  isPositionUpdated
@@ -209,7 +215,9 @@ export default class Tooltip extends BaseComponent {
209
215
  } = _ref;
210
216
  return /*#__PURE__*/React.createElement("div", Object.assign({
211
217
  className: classNames(className, animationClassName),
212
- style: Object.assign(Object.assign(Object.assign(Object.assign({}, animationStyle), {
218
+ style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, animationStyle), displayNone ? {
219
+ display: "none"
220
+ } : {}), {
213
221
  transformOrigin
214
222
  }), style), {
215
223
  opacity: isPositionUpdated ? opacity : "0"
@@ -299,8 +307,8 @@ export default class Tooltip extends BaseComponent {
299
307
  placement: props.position || 'top',
300
308
  transitionStyle: {},
301
309
  isPositionUpdated: false,
302
- id: props.wrapperId // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
303
-
310
+ id: props.wrapperId,
311
+ displayNone: false
304
312
  };
305
313
  this.foundation = new TooltipFoundation(this.adapter);
306
314
  this.eventManager = new Event();
@@ -424,6 +432,11 @@ export default class Tooltip extends BaseComponent {
424
432
  this.eventManager.emit('positionUpdated');
425
433
  });
426
434
  },
435
+ setDisplayNone: (displayNone, cb) => {
436
+ this.setState({
437
+ displayNone
438
+ }, cb);
439
+ },
427
440
  updatePlacementAttr: placement => {
428
441
  this.setState({
429
442
  placement
@@ -730,7 +743,8 @@ Tooltip.propTypes = {
730
743
  wrapWhenSpecial: PropTypes.bool,
731
744
  guardFocus: PropTypes.bool,
732
745
  returnFocusOnClose: PropTypes.bool,
733
- preventScroll: PropTypes.bool
746
+ preventScroll: PropTypes.bool,
747
+ keepDOM: PropTypes.bool
734
748
  };
735
749
  Tooltip.defaultProps = {
736
750
  arrowBounding: numbers.ARROW_BOUNDING,
@@ -756,5 +770,6 @@ Tooltip.defaultProps = {
756
770
  returnFocusOnClose: false,
757
771
  onEscKeyDown: _noop,
758
772
  disableFocusListener: false,
759
- disableArrowKeyDown: false
773
+ disableArrowKeyDown: false,
774
+ keepDOM: false
760
775
  };
@@ -8,6 +8,7 @@ export interface CopyableProps extends BaseProps {
8
8
  duration?: number;
9
9
  forwardRef?: React.RefObject<any>;
10
10
  successTip?: React.ReactNode;
11
+ icon?: React.ReactNode;
11
12
  onCopy?: (e: React.MouseEvent, content: string, res: boolean) => void;
12
13
  }
13
14
  interface CopyableState {
@@ -23,6 +24,7 @@ export declare class Copyable extends React.PureComponent<CopyableProps, Copyabl
23
24
  duration: PropTypes.Requireable<number>;
24
25
  style: PropTypes.Requireable<object>;
25
26
  className: PropTypes.Requireable<string>;
27
+ icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
26
28
  };
27
29
  static defaultProps: {
28
30
  content: string;
@@ -38,6 +40,7 @@ export declare class Copyable extends React.PureComponent<CopyableProps, Copyabl
38
40
  setCopied: (item: string, timer: number) => void;
39
41
  resetCopied: () => void;
40
42
  renderSuccessTip: () => string | number | boolean | React.ReactFragment | JSX.Element;
43
+ renderCopyIcon: () => JSX.Element;
41
44
  render(): JSX.Element;
42
45
  }
43
46
  export default Copyable;
@@ -59,6 +59,31 @@ export class Copyable extends React.PureComponent {
59
59
  }, locale => /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(IconTick, null), locale.copied));
60
60
  };
61
61
 
62
+ this.renderCopyIcon = () => {
63
+ const {
64
+ icon
65
+ } = this.props;
66
+ const copyProps = {
67
+ role: "button",
68
+ tabIndex: 0,
69
+ onClick: this.copy,
70
+ onKeyPress: e => isEnterPress(e) && this.copy(e)
71
+ };
72
+ {
73
+ /* TODO: replace `a` tag with `span` in next major version
74
+ NOTE: may have effect on style */
75
+ }
76
+ const defaultIcon =
77
+ /*#__PURE__*/
78
+ // eslint-disable-next-line jsx-a11y/anchor-is-valid
79
+ React.createElement("a", {
80
+ className: `${prefixCls}-action-copy-icon`
81
+ }, /*#__PURE__*/React.createElement(IconCopy, Object.assign({
82
+ onClick: this.copy
83
+ }, copyProps)));
84
+ return /*#__PURE__*/React.isValidElement(icon) ? /*#__PURE__*/React.cloneElement(icon, copyProps) : defaultIcon;
85
+ };
86
+
62
87
  this.state = {
63
88
  copied: false,
64
89
  item: ''
@@ -96,14 +121,7 @@ export class Copyable extends React.PureComponent {
96
121
  ref: forwardRef
97
122
  }, copied ? this.renderSuccessTip() : /*#__PURE__*/React.createElement(Tooltip, {
98
123
  content: typeof copyTip !== 'undefined' ? copyTip : locale.copy
99
- }, /*#__PURE__*/React.createElement("a", {
100
- className: `${prefixCls}-action-copy-icon`
101
- }, /*#__PURE__*/React.createElement(IconCopy, {
102
- role: "button",
103
- tabIndex: 0,
104
- onClick: this.copy,
105
- onKeyPress: e => isEnterPress(e) && this.copy(e)
106
- })))));
124
+ }, this.renderCopyIcon())));
107
125
  }
108
126
 
109
127
  }
@@ -114,7 +132,8 @@ Copyable.propTypes = {
114
132
  copyTip: PropTypes.node,
115
133
  duration: PropTypes.number,
116
134
  style: PropTypes.object,
117
- className: PropTypes.string
135
+ className: PropTypes.string,
136
+ icon: PropTypes.node
118
137
  };
119
138
  Copyable.defaultProps = {
120
139
  content: '',
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.30.1",
3
+ "version": "2.31.0-beta.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
7
7
  "typings": "lib/es/index.d.ts",
8
8
  "scripts": {
9
9
  "clean": "rimraf dist lib",
10
- "build:lib": "export NODE_OPTIONS=--no-experimental-fetch && node ./scripts/compileLib.js",
10
+ "build:lib": "node ./scripts/compileLib.js",
11
11
  "build:js": "node scripts/compileDist.js",
12
12
  "build:css": "node scripts/compileScss.js",
13
13
  "prepublishOnly": "npm run clean && npm run build:lib && npm run build:js && npm run build:css"
@@ -17,12 +17,12 @@
17
17
  "lib/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@douyinfe/semi-animation": "2.30.1",
21
- "@douyinfe/semi-animation-react": "2.30.1",
22
- "@douyinfe/semi-foundation": "2.30.1",
23
- "@douyinfe/semi-icons": "2.30.1",
24
- "@douyinfe/semi-illustrations": "2.30.1",
25
- "@douyinfe/semi-theme-default": "2.30.1",
20
+ "@douyinfe/semi-animation": "2.31.0-beta.0",
21
+ "@douyinfe/semi-animation-react": "2.31.0-beta.0",
22
+ "@douyinfe/semi-foundation": "2.31.0-beta.0",
23
+ "@douyinfe/semi-icons": "2.31.0-beta.0",
24
+ "@douyinfe/semi-illustrations": "2.31.0-beta.0",
25
+ "@douyinfe/semi-theme-default": "2.31.0-beta.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": "653ba5577ec669cc8b9daf2f9bd29044843df197",
72
+ "gitHead": "8b378259f169ca3bfb9af17118e962d717efa685",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",