@douyinfe/semi-ui 2.38.0-beta.0 → 2.38.1

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.
@@ -20,6 +20,7 @@ var _trigger = _interopRequireDefault(require("../trigger"));
20
20
  var _option = _interopRequireDefault(require("./option"));
21
21
  var _warning = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/warning"));
22
22
  require("@douyinfe/semi-foundation/lib/cjs/autoComplete/autoComplete.css");
23
+ var _reactDom = _interopRequireDefault(require("react-dom"));
23
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
25
  /* eslint-disable @typescript-eslint/ban-types, max-len */
25
26
 
@@ -147,6 +148,24 @@ class AutoComplete extends _baseComponent.default {
147
148
  this.setState({
148
149
  rePosKey
149
150
  });
151
+ },
152
+ registerClickOutsideHandler: cb => {
153
+ const clickOutsideHandler = e => {
154
+ const optionInstance = this.optionsRef && this.optionsRef.current;
155
+ const triggerDom = this.triggerRef && this.triggerRef.current;
156
+ const optionsDom = _reactDom.default.findDOMNode(optionInstance);
157
+ const target = e.target;
158
+ if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target)) {
159
+ cb(e);
160
+ }
161
+ };
162
+ this.clickOutsideHandler = clickOutsideHandler;
163
+ document.addEventListener('mousedown', clickOutsideHandler, false);
164
+ },
165
+ unregisterClickOutsideHandler: () => {
166
+ if (this.clickOutsideHandler) {
167
+ document.removeEventListener('mousedown', this.clickOutsideHandler, false);
168
+ }
150
169
  }
151
170
  });
152
171
  }
@@ -539,7 +539,7 @@ class Select extends _baseComponent.default {
539
539
  key: option.key || option.label + option.value + optionIndex,
540
540
  renderOptionItem: renderOptionItem,
541
541
  inputValue: inputValue,
542
- id: `${this.selectID}-option-${optionIndex}`
542
+ semiOptionId: `${this.selectID}-option-${optionIndex}`
543
543
  }), option.label);
544
544
  }
545
545
  return optionContent;
@@ -75,9 +75,9 @@ class Option extends _react.PureComponent {
75
75
  prefixCls,
76
76
  renderOptionItem,
77
77
  inputValue,
78
- id
78
+ semiOptionId
79
79
  } = _a,
80
- rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue", "id"]);
80
+ rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue", "semiOptionId"]);
81
81
  const optionClassName = (0, _classnames.default)(prefixCls, {
82
82
  [`${prefixCls}-disabled`]: disabled,
83
83
  [`${prefixCls}-selected`]: selected,
@@ -136,7 +136,7 @@ class Option extends _react.PureComponent {
136
136
  },
137
137
  onMouseEnter: e => onMouseEnter && onMouseEnter(e),
138
138
  role: "option",
139
- id: id,
139
+ id: semiOptionId,
140
140
  "aria-selected": selected ? "true" : "false",
141
141
  "aria-disabled": disabled ? "true" : "false",
142
142
  style: style
@@ -180,7 +180,7 @@ class Tooltip extends _baseComponent.default {
180
180
  const icon = this.renderIcon();
181
181
  const portalInnerStyle = (0, _omit2.default)(containerStyle, motion ? ['transformOrigin'] : undefined);
182
182
  const transformOrigin = (0, _get2.default)(containerStyle, 'transformOrigin');
183
- const userOpacity = (0, _get2.default)(style, 'opacity');
183
+ const userOpacity = (0, _get2.default)(style, 'opacity', null);
184
184
  const opacity = userOpacity ? userOpacity : 1;
185
185
  const inner = /*#__PURE__*/_react.default.createElement(_cssAnimation.default, {
186
186
  fillMode: "forwards",
@@ -206,9 +206,9 @@ class Tooltip extends _baseComponent.default {
206
206
  display: "none"
207
207
  } : {}), {
208
208
  transformOrigin
209
- }), style), {
209
+ }), style), userOpacity ? {
210
210
  opacity: isPositionUpdated ? opacity : "0"
211
- })
211
+ } : {})
212
212
  }, portalEventSet, animationEventsNeedBind, {
213
213
  role: role,
214
214
  "x-placement": placement,
@@ -15,6 +15,7 @@ import Trigger from '../trigger';
15
15
  import Option from './option';
16
16
  import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
17
17
  import '@douyinfe/semi-foundation/lib/es/autoComplete/autoComplete.css';
18
+ import ReactDOM from 'react-dom';
18
19
  const prefixCls = cssClasses.PREFIX;
19
20
  const sizeSet = strings.SIZE;
20
21
  const positionSet = strings.POSITION;
@@ -139,6 +140,24 @@ class AutoComplete extends BaseComponent {
139
140
  this.setState({
140
141
  rePosKey
141
142
  });
143
+ },
144
+ registerClickOutsideHandler: cb => {
145
+ const clickOutsideHandler = e => {
146
+ const optionInstance = this.optionsRef && this.optionsRef.current;
147
+ const triggerDom = this.triggerRef && this.triggerRef.current;
148
+ const optionsDom = ReactDOM.findDOMNode(optionInstance);
149
+ const target = e.target;
150
+ if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target)) {
151
+ cb(e);
152
+ }
153
+ };
154
+ this.clickOutsideHandler = clickOutsideHandler;
155
+ document.addEventListener('mousedown', clickOutsideHandler, false);
156
+ },
157
+ unregisterClickOutsideHandler: () => {
158
+ if (this.clickOutsideHandler) {
159
+ document.removeEventListener('mousedown', this.clickOutsideHandler, false);
160
+ }
142
161
  }
143
162
  });
144
163
  }
@@ -530,7 +530,7 @@ class Select extends BaseComponent {
530
530
  key: option.key || option.label + option.value + optionIndex,
531
531
  renderOptionItem: renderOptionItem,
532
532
  inputValue: inputValue,
533
- id: `${this.selectID}-option-${optionIndex}`
533
+ semiOptionId: `${this.selectID}-option-${optionIndex}`
534
534
  }), option.label);
535
535
  }
536
536
  return optionContent;
@@ -65,9 +65,9 @@ class Option extends PureComponent {
65
65
  prefixCls,
66
66
  renderOptionItem,
67
67
  inputValue,
68
- id
68
+ semiOptionId
69
69
  } = _a,
70
- rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue", "id"]);
70
+ rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue", "semiOptionId"]);
71
71
  const optionClassName = classNames(prefixCls, {
72
72
  [`${prefixCls}-disabled`]: disabled,
73
73
  [`${prefixCls}-selected`]: selected,
@@ -126,7 +126,7 @@ class Option extends PureComponent {
126
126
  },
127
127
  onMouseEnter: e => onMouseEnter && onMouseEnter(e),
128
128
  role: "option",
129
- id: id,
129
+ id: semiOptionId,
130
130
  "aria-selected": selected ? "true" : "false",
131
131
  "aria-disabled": disabled ? "true" : "false",
132
132
  style: style
@@ -170,7 +170,7 @@ export default class Tooltip extends BaseComponent {
170
170
  const icon = this.renderIcon();
171
171
  const portalInnerStyle = _omit(containerStyle, motion ? ['transformOrigin'] : undefined);
172
172
  const transformOrigin = _get(containerStyle, 'transformOrigin');
173
- const userOpacity = _get(style, 'opacity');
173
+ const userOpacity = _get(style, 'opacity', null);
174
174
  const opacity = userOpacity ? userOpacity : 1;
175
175
  const inner = /*#__PURE__*/React.createElement(CSSAnimation, {
176
176
  fillMode: "forwards",
@@ -196,9 +196,9 @@ export default class Tooltip extends BaseComponent {
196
196
  display: "none"
197
197
  } : {}), {
198
198
  transformOrigin
199
- }), style), {
199
+ }), style), userOpacity ? {
200
200
  opacity: isPositionUpdated ? opacity : "0"
201
- })
201
+ } : {})
202
202
  }, portalEventSet, animationEventsNeedBind, {
203
203
  role: role,
204
204
  "x-placement": placement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.38.0-beta.0",
3
+ "version": "2.38.1",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -17,12 +17,12 @@
17
17
  "lib/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@douyinfe/semi-animation": "2.38.0-beta.0",
21
- "@douyinfe/semi-animation-react": "2.38.0-beta.0",
22
- "@douyinfe/semi-foundation": "2.38.0-beta.0",
23
- "@douyinfe/semi-icons": "2.38.0-beta.0",
24
- "@douyinfe/semi-illustrations": "2.38.0-beta.0",
25
- "@douyinfe/semi-theme-default": "2.38.0-beta.0",
20
+ "@douyinfe/semi-animation": "2.38.1",
21
+ "@douyinfe/semi-animation-react": "2.38.1",
22
+ "@douyinfe/semi-foundation": "2.38.1",
23
+ "@douyinfe/semi-icons": "2.38.1",
24
+ "@douyinfe/semi-illustrations": "2.38.1",
25
+ "@douyinfe/semi-theme-default": "2.38.1",
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": "f9fa7bba4ffc5635489ad1687740b336b0395948",
72
+ "gitHead": "aaad3c86114e9bd2d9a61c8b78260e18ffc0eec6",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",