@douyinfe/semi-ui 2.29.0 → 2.30.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 (71) hide show
  1. package/dist/css/semi.css +9 -2
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +170 -81
  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/cascader/index.d.ts +2 -0
  8. package/lib/cjs/cascader/index.js +8 -0
  9. package/lib/cjs/locale/source/ar.js +5 -5
  10. package/lib/cjs/locale/source/de.js +5 -5
  11. package/lib/cjs/locale/source/en_GB.js +5 -5
  12. package/lib/cjs/locale/source/en_US.js +4 -4
  13. package/lib/cjs/locale/source/es.js +5 -5
  14. package/lib/cjs/locale/source/fr.js +5 -5
  15. package/lib/cjs/locale/source/id_ID.js +4 -4
  16. package/lib/cjs/locale/source/it.js +5 -5
  17. package/lib/cjs/locale/source/ja_JP.js +5 -5
  18. package/lib/cjs/locale/source/ko_KR.js +4 -4
  19. package/lib/cjs/locale/source/ms_MY.js +4 -4
  20. package/lib/cjs/locale/source/nl_NL.d.ts +1 -1
  21. package/lib/cjs/locale/source/nl_NL.js +6 -6
  22. package/lib/cjs/locale/source/pl_PL.js +4 -4
  23. package/lib/cjs/locale/source/pt_BR.js +5 -5
  24. package/lib/cjs/locale/source/ro.d.ts +13 -0
  25. package/lib/cjs/locale/source/ro.js +17 -4
  26. package/lib/cjs/locale/source/ru_RU.js +4 -4
  27. package/lib/cjs/locale/source/sv_SE.js +4 -4
  28. package/lib/cjs/locale/source/th_TH.js +5 -5
  29. package/lib/cjs/locale/source/tr_TR.js +5 -5
  30. package/lib/cjs/locale/source/vi_VN.js +5 -5
  31. package/lib/cjs/locale/source/zh_CN.js +4 -4
  32. package/lib/cjs/locale/source/zh_TW.js +4 -4
  33. package/lib/cjs/popconfirm/index.d.ts +11 -7
  34. package/lib/cjs/popconfirm/index.js +97 -60
  35. package/lib/cjs/popover/index.d.ts +7 -1
  36. package/lib/cjs/popover/index.js +15 -3
  37. package/lib/cjs/tooltip/index.d.ts +7 -3
  38. package/lib/cjs/tooltip/index.js +10 -0
  39. package/lib/es/cascader/index.d.ts +2 -0
  40. package/lib/es/cascader/index.js +8 -0
  41. package/lib/es/locale/source/ar.js +5 -5
  42. package/lib/es/locale/source/de.js +5 -5
  43. package/lib/es/locale/source/en_GB.js +5 -5
  44. package/lib/es/locale/source/en_US.js +4 -4
  45. package/lib/es/locale/source/es.js +5 -5
  46. package/lib/es/locale/source/fr.js +5 -5
  47. package/lib/es/locale/source/id_ID.js +4 -4
  48. package/lib/es/locale/source/it.js +5 -5
  49. package/lib/es/locale/source/ja_JP.js +5 -5
  50. package/lib/es/locale/source/ko_KR.js +4 -4
  51. package/lib/es/locale/source/ms_MY.js +4 -4
  52. package/lib/es/locale/source/nl_NL.d.ts +1 -1
  53. package/lib/es/locale/source/nl_NL.js +6 -6
  54. package/lib/es/locale/source/pl_PL.js +4 -4
  55. package/lib/es/locale/source/pt_BR.js +5 -5
  56. package/lib/es/locale/source/ro.d.ts +13 -0
  57. package/lib/es/locale/source/ro.js +17 -4
  58. package/lib/es/locale/source/ru_RU.js +4 -4
  59. package/lib/es/locale/source/sv_SE.js +4 -4
  60. package/lib/es/locale/source/th_TH.js +5 -5
  61. package/lib/es/locale/source/tr_TR.js +5 -5
  62. package/lib/es/locale/source/vi_VN.js +5 -5
  63. package/lib/es/locale/source/zh_CN.js +4 -4
  64. package/lib/es/locale/source/zh_TW.js +4 -4
  65. package/lib/es/popconfirm/index.d.ts +11 -7
  66. package/lib/es/popconfirm/index.js +95 -60
  67. package/lib/es/popover/index.d.ts +7 -1
  68. package/lib/es/popover/index.js +15 -3
  69. package/lib/es/tooltip/index.d.ts +7 -3
  70. package/lib/es/tooltip/index.js +10 -0
  71. package/package.json +9 -9
@@ -1,3 +1,5 @@
1
+ import _omit from "lodash/omit";
2
+ import _isFunction from "lodash/isFunction";
1
3
  import _get from "lodash/get";
2
4
  import _noop from "lodash/noop";
3
5
 
@@ -40,12 +42,74 @@ export default class Popconfirm extends BaseComponent {
40
42
 
41
43
  this.stopImmediatePropagation = e => e && e.nativeEvent && e.nativeEvent.stopImmediatePropagation();
42
44
 
45
+ this.renderConfirmPopCard = _ref => {
46
+ let {
47
+ initialFocusRef
48
+ } = _ref;
49
+ const {
50
+ content,
51
+ title,
52
+ className,
53
+ style,
54
+ cancelType,
55
+ icon,
56
+ prefixCls
57
+ } = this.props;
58
+ const {
59
+ direction
60
+ } = this.context;
61
+ const popCardCls = cls(prefixCls, className, {
62
+ [`${prefixCls}-rtl`]: direction === 'rtl'
63
+ });
64
+ const showTitle = title !== null && typeof title !== 'undefined';
65
+ const showContent = !(content === null || typeof content === 'undefined');
66
+ return (
67
+ /*#__PURE__*/
68
+
69
+ /* eslint-disable-next-line jsx-a11y/no-static-element-interactions */
70
+ React.createElement("div", {
71
+ className: popCardCls,
72
+ onClick: this.stopImmediatePropagation,
73
+ style: style
74
+ }, /*#__PURE__*/React.createElement("div", {
75
+ className: `${prefixCls}-inner`
76
+ }, /*#__PURE__*/React.createElement("div", {
77
+ className: `${prefixCls}-header`
78
+ }, /*#__PURE__*/React.createElement("i", {
79
+ className: `${prefixCls}-header-icon`,
80
+ "x-semi-prop": "icon"
81
+ }, /*#__PURE__*/React.isValidElement(icon) ? icon : null), /*#__PURE__*/React.createElement("div", {
82
+ className: `${prefixCls}-header-body`
83
+ }, showTitle ? /*#__PURE__*/React.createElement("div", {
84
+ className: `${prefixCls}-header-title`,
85
+ "x-semi-prop": "title"
86
+ }, title) : null), /*#__PURE__*/React.createElement(Button, {
87
+ className: `${prefixCls}-btn-close`,
88
+ icon: /*#__PURE__*/React.createElement(IconClose, null),
89
+ size: "small",
90
+ theme: 'borderless',
91
+ type: cancelType,
92
+ onClick: this.handleCancel
93
+ })), showContent ? /*#__PURE__*/React.createElement("div", {
94
+ className: `${prefixCls}-body`,
95
+ "x-semi-prop": "content"
96
+ }, _isFunction(content) ? content({
97
+ initialFocusRef
98
+ }) : content) : null, /*#__PURE__*/React.createElement("div", {
99
+ className: `${prefixCls}-footer`,
100
+ ref: this.footerRef
101
+ }, this.renderControls())))
102
+ );
103
+ };
104
+
43
105
  this.state = {
44
106
  cancelLoading: false,
45
107
  confirmLoading: false,
46
108
  visible: props.defaultVisible || false
47
109
  };
48
110
  this.foundation = new PopconfirmFoundation(this.adapter);
111
+ this.footerRef = /*#__PURE__*/React.createRef();
112
+ this.popoverRef = /*#__PURE__*/React.createRef();
49
113
  }
50
114
 
51
115
  static getDerivedStateFromProps(props, state) {
@@ -75,7 +139,28 @@ export default class Popconfirm extends BaseComponent {
75
139
  notifyConfirm: e => this.props.onConfirm(e),
76
140
  notifyCancel: e => this.props.onCancel(e),
77
141
  notifyVisibleChange: visible => this.props.onVisibleChange(visible),
78
- notifyClickOutSide: e => this.props.onClickOutSide(e)
142
+ notifyClickOutSide: e => this.props.onClickOutSide(e),
143
+ focusCancelButton: () => {
144
+ var _a, _b;
145
+
146
+ const buttonNode = (_b = (_a = this.footerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.querySelector('[data-type=cancel]');
147
+ buttonNode === null || buttonNode === void 0 ? void 0 : buttonNode.focus({
148
+ preventScroll: true
149
+ });
150
+ },
151
+ focusOkButton: () => {
152
+ var _a, _b;
153
+
154
+ const buttonNode = (_b = (_a = this.footerRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.querySelector('[data-type=ok]');
155
+ buttonNode === null || buttonNode === void 0 ? void 0 : buttonNode.focus({
156
+ preventScroll: true
157
+ });
158
+ },
159
+ focusPrevFocusElement: () => {
160
+ var _a;
161
+
162
+ (_a = this.popoverRef.current) === null || _a === void 0 ? void 0 : _a.focusTrigger();
163
+ }
79
164
  });
80
165
  }
81
166
 
@@ -95,68 +180,17 @@ export default class Popconfirm extends BaseComponent {
95
180
  return /*#__PURE__*/React.createElement(LocaleConsumer, {
96
181
  componentName: "Popconfirm"
97
182
  }, (locale, localeCode) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, Object.assign({
183
+ "data-type": "cancel",
98
184
  type: cancelType,
99
185
  onClick: this.handleCancel,
100
186
  loading: cancelLoading
101
- }, cancelButtonProps), cancelText || _get(locale, 'cancel')), /*#__PURE__*/React.createElement(Button, Object.assign({
187
+ }, _omit(cancelButtonProps, 'autoFocus')), cancelText || _get(locale, 'cancel')), /*#__PURE__*/React.createElement(Button, Object.assign({
188
+ "data-type": "ok",
102
189
  type: okType,
103
190
  theme: "solid",
104
191
  onClick: this.handleConfirm,
105
192
  loading: confirmLoading
106
- }, okButtonProps), okText || _get(locale, 'confirm'))));
107
- }
108
-
109
- renderConfirmPopCard() {
110
- const {
111
- content,
112
- title,
113
- className,
114
- style,
115
- cancelType,
116
- icon,
117
- prefixCls
118
- } = this.props;
119
- const {
120
- direction
121
- } = this.context;
122
- const popCardCls = cls(prefixCls, className, {
123
- [`${prefixCls}-rtl`]: direction === 'rtl'
124
- });
125
- const showTitle = title !== null && typeof title !== 'undefined';
126
- const showContent = !(content === null || typeof content === 'undefined');
127
- return (
128
- /*#__PURE__*/
129
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
130
- React.createElement("div", {
131
- className: popCardCls,
132
- onClick: this.stopImmediatePropagation,
133
- style: style
134
- }, /*#__PURE__*/React.createElement("div", {
135
- className: `${prefixCls}-inner`
136
- }, /*#__PURE__*/React.createElement("div", {
137
- className: `${prefixCls}-header`
138
- }, /*#__PURE__*/React.createElement("i", {
139
- className: `${prefixCls}-header-icon`,
140
- "x-semi-prop": "icon"
141
- }, /*#__PURE__*/React.isValidElement(icon) ? icon : null), /*#__PURE__*/React.createElement("div", {
142
- className: `${prefixCls}-header-body`
143
- }, showTitle ? /*#__PURE__*/React.createElement("div", {
144
- className: `${prefixCls}-header-title`,
145
- "x-semi-prop": "title"
146
- }, title) : null), /*#__PURE__*/React.createElement(Button, {
147
- className: `${prefixCls}-btn-close`,
148
- icon: /*#__PURE__*/React.createElement(IconClose, null),
149
- size: "small",
150
- theme: 'borderless',
151
- type: cancelType,
152
- onClick: this.handleCancel
153
- })), showContent ? /*#__PURE__*/React.createElement("div", {
154
- className: `${prefixCls}-body`,
155
- "x-semi-prop": "content"
156
- }, content) : null, /*#__PURE__*/React.createElement("div", {
157
- className: `${prefixCls}-footer`
158
- }, this.renderControls())))
159
- );
193
+ }, _omit(okButtonProps, 'autoFocus')), okText || _get(locale, 'confirm'))));
160
194
  }
161
195
 
162
196
  render() {
@@ -184,7 +218,6 @@ export default class Popconfirm extends BaseComponent {
184
218
  const {
185
219
  visible
186
220
  } = this.state;
187
- const popContent = this.renderConfirmPopCard();
188
221
  const popProps = {
189
222
  onVisibleChange: this.handleVisibleChange,
190
223
  className: cssClasses.POPOVER,
@@ -195,8 +228,10 @@ export default class Popconfirm extends BaseComponent {
195
228
  popProps.trigger = 'custom';
196
229
  }
197
230
 
198
- return /*#__PURE__*/React.createElement(Popover, Object.assign({}, attrs, {
199
- content: popContent,
231
+ return /*#__PURE__*/React.createElement(Popover, Object.assign({
232
+ ref: this.popoverRef
233
+ }, attrs, {
234
+ content: this.renderConfirmPopCard,
200
235
  visible: visible,
201
236
  position: position
202
237
  }, popProps), children);
@@ -207,7 +242,7 @@ Popconfirm.contextType = ConfigContext;
207
242
  Popconfirm.propTypes = {
208
243
  motion: PropTypes.oneOfType([PropTypes.bool, PropTypes.func, PropTypes.object]),
209
244
  disabled: PropTypes.bool,
210
- content: PropTypes.any,
245
+ content: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
211
246
  title: PropTypes.any,
212
247
  prefixCls: PropTypes.string,
213
248
  className: PropTypes.string,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { ContextValue } from '../configProvider/context';
4
- import { ArrowBounding, Position, TooltipProps, Trigger, RenderContentProps } from '../tooltip/index';
4
+ import Tooltip, { ArrowBounding, Position, TooltipProps, Trigger, RenderContentProps } from '../tooltip/index';
5
5
  import '@douyinfe/semi-foundation/lib/es/popover/popover.css';
6
6
  import { BaseProps } from '../_base/baseComponent';
7
7
  import type { ArrowProps } from './Arrow';
@@ -101,6 +101,12 @@ declare class Popover extends React.PureComponent<PopoverProps, PopoverState> {
101
101
  disableFocusListener: boolean;
102
102
  };
103
103
  context: ContextValue;
104
+ tooltipRef: React.RefObject<Tooltip | null>;
105
+ constructor(props: PopoverProps);
106
+ /**
107
+ * focus on tooltip trigger
108
+ */
109
+ focusTrigger: () => void;
104
110
  renderPopCard: ({ initialFocusRef }: {
105
111
  initialFocusRef: RenderContentProps['initialFocusRef'];
106
112
  }) => JSX.Element;
@@ -24,8 +24,17 @@ const positionSet = strings.POSITION_SET;
24
24
  const triggerSet = strings.TRIGGER_SET;
25
25
 
26
26
  class Popover extends React.PureComponent {
27
- constructor() {
28
- super(...arguments);
27
+ constructor(props) {
28
+ super(props);
29
+ /**
30
+ * focus on tooltip trigger
31
+ */
32
+
33
+ this.focusTrigger = () => {
34
+ var _a;
35
+
36
+ (_a = this.tooltipRef.current) === null || _a === void 0 ? void 0 : _a.focusTrigger();
37
+ };
29
38
 
30
39
  this.renderPopCard = _ref => {
31
40
  let {
@@ -63,6 +72,8 @@ class Popover extends React.PureComponent {
63
72
  };
64
73
  return !_isFunction(content) ? content : content(contentProps);
65
74
  };
75
+
76
+ this.tooltipRef = /*#__PURE__*/React.createRef();
66
77
  }
67
78
 
68
79
  render() {
@@ -96,7 +107,8 @@ class Popover extends React.PureComponent {
96
107
 
97
108
  const role = trigger === 'click' || trigger === 'custom' ? 'dialog' : 'tooltip';
98
109
  return /*#__PURE__*/React.createElement(Tooltip, Object.assign({
99
- guardFocus: true
110
+ guardFocus: true,
111
+ ref: this.tooltipRef
100
112
  }, attr, {
101
113
  trigger: trigger,
102
114
  position: position,
@@ -15,10 +15,10 @@ export interface ArrowBounding {
15
15
  width?: number;
16
16
  height?: number;
17
17
  }
18
- export interface RenderContentProps {
19
- initialFocusRef?: React.RefObject<HTMLElement>;
18
+ export interface RenderContentProps<T = HTMLElement> {
19
+ initialFocusRef?: React.RefObject<T>;
20
20
  }
21
- export declare type RenderContent = (props: RenderContentProps) => React.ReactNode;
21
+ export declare type RenderContent<T = HTMLElement> = (props: RenderContentProps<T>) => React.ReactNode;
22
22
  export interface TooltipProps extends BaseProps {
23
23
  children?: React.ReactNode;
24
24
  motion?: boolean;
@@ -172,6 +172,10 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
172
172
  get adapter(): TooltipAdapter<TooltipProps, TooltipState>;
173
173
  componentDidMount(): void;
174
174
  componentWillUnmount(): void;
175
+ /**
176
+ * focus on tooltip trigger
177
+ */
178
+ focusTrigger(): void;
175
179
  isSpecial: (elem: React.ReactNode | HTMLElement | any) => boolean | "disabled" | "loading";
176
180
  didLeave: () => void;
177
181
  /** for transition - end */
@@ -226,6 +226,8 @@ export default class Tooltip extends BaseComponent {
226
226
  zIndex
227
227
  }
228
228
  }, /*#__PURE__*/React.createElement("div", {
229
+ // listen keyboard event, don't move tabIndex -1
230
+ tabIndex: -1,
229
231
  className: `${BASE_CLASS_PREFIX}-portal-inner`,
230
232
  style: portalInnerStyle,
231
233
  ref: this.setContainerEl,
@@ -579,6 +581,14 @@ export default class Tooltip extends BaseComponent {
579
581
  this.mounted = false;
580
582
  this.foundation.destroy();
581
583
  }
584
+ /**
585
+ * focus on tooltip trigger
586
+ */
587
+
588
+
589
+ focusTrigger() {
590
+ this.foundation.focusTrigger();
591
+ }
582
592
  /** for transition - end */
583
593
 
584
594
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.29.0",
3
+ "version": "2.30.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": "node ./scripts/compileLib.js",
10
+ "build:lib": "export NODE_OPTIONS=--no-experimental-fetch && 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.29.0",
21
- "@douyinfe/semi-animation-react": "2.29.0",
22
- "@douyinfe/semi-foundation": "2.29.0",
23
- "@douyinfe/semi-icons": "2.29.0",
24
- "@douyinfe/semi-illustrations": "2.29.0",
25
- "@douyinfe/semi-theme-default": "2.29.0",
20
+ "@douyinfe/semi-animation": "2.30.0-beta.0",
21
+ "@douyinfe/semi-animation-react": "2.30.0-beta.0",
22
+ "@douyinfe/semi-foundation": "2.30.0-beta.0",
23
+ "@douyinfe/semi-icons": "2.30.0-beta.0",
24
+ "@douyinfe/semi-illustrations": "2.30.0-beta.0",
25
+ "@douyinfe/semi-theme-default": "2.30.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": "cf2c6529fb778787c2d3f6cb826e64af358a5215",
72
+ "gitHead": "330e8cf3c8bced4dee7d5c77c7e3931a0f40376b",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",