@atlaskit/user-picker 10.13.2 → 10.13.4

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 (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/analytics.js +1 -1
  3. package/dist/cjs/components/BaseUserPicker.js +29 -3
  4. package/dist/cjs/components/MultiValueContainer.js +11 -3
  5. package/dist/cjs/components/SingleValueContainer.js +21 -7
  6. package/dist/cjs/components/ValueContainerWrapper.js +26 -0
  7. package/dist/es2019/analytics.js +1 -1
  8. package/dist/es2019/components/BaseUserPicker.js +27 -3
  9. package/dist/es2019/components/MultiValueContainer.js +8 -3
  10. package/dist/es2019/components/SingleValueContainer.js +19 -4
  11. package/dist/es2019/components/ValueContainerWrapper.js +21 -0
  12. package/dist/esm/analytics.js +1 -1
  13. package/dist/esm/components/BaseUserPicker.js +29 -3
  14. package/dist/esm/components/MultiValueContainer.js +8 -3
  15. package/dist/esm/components/SingleValueContainer.js +18 -4
  16. package/dist/esm/components/ValueContainerWrapper.js +20 -0
  17. package/dist/types/components/BaseUserPicker.d.ts +8 -1
  18. package/dist/types/components/MultiValueContainer.d.ts +2 -1
  19. package/dist/types/components/PopupUserPicker.d.ts +1 -1
  20. package/dist/types/components/SingleValueContainer.d.ts +7 -3
  21. package/dist/types/components/UserPicker.d.ts +1 -1
  22. package/dist/types/components/ValueContainerWrapper.d.ts +13 -0
  23. package/dist/types/types.d.ts +8 -0
  24. package/dist/types-ts4.5/components/BaseUserPicker.d.ts +8 -1
  25. package/dist/types-ts4.5/components/MultiValueContainer.d.ts +2 -1
  26. package/dist/types-ts4.5/components/PopupUserPicker.d.ts +1 -1
  27. package/dist/types-ts4.5/components/SingleValueContainer.d.ts +7 -3
  28. package/dist/types-ts4.5/components/UserPicker.d.ts +1 -1
  29. package/dist/types-ts4.5/components/ValueContainerWrapper.d.ts +13 -0
  30. package/dist/types-ts4.5/types.d.ts +8 -0
  31. package/package.json +6 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/user-picker
2
2
 
3
+ ## 10.13.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#64330](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64330) [`797c300a51d4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/797c300a51d4) - Minor internal refactor to reduce bundle size
8
+
9
+ ## 10.13.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#61371](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/61371) [`eae2cd4f6dc2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/eae2cd4f6dc2) - Adds new prop, UNSAFE_hasDraggableParentComponent, as a workaround when using user pickers inside of a react-beautiful-dnd Draggable.
14
+
3
15
  ## 10.13.2
4
16
 
5
17
  ### Patch Changes
@@ -12,7 +12,7 @@ var _utils = require("./components/utils");
12
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
14
  var packageName = "@atlaskit/user-picker";
15
- var packageVersion = "10.13.2";
15
+ var packageVersion = "10.13.4";
16
16
  var UUID_REGEXP_TEAMS_GROUPS = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
17
17
  var UUID_REGEXP_OLD_AAID = /^[a-fA-F0-9]{1,8}:[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
18
18
  var UUID_REGEXP_NEW_AAID = /^[a-fA-F0-9]{24,24}$/;
@@ -262,6 +262,7 @@ var BaseUserPickerWithoutAnalytics = exports.BaseUserPickerWithoutAnalytics = /*
262
262
  _this.abortOptionsShownUfoExperience();
263
263
  _this.setState({
264
264
  menuIsOpen: false,
265
+ initialFocusHandled: false,
265
266
  options: []
266
267
  });
267
268
  });
@@ -387,6 +388,27 @@ var BaseUserPickerWithoutAnalytics = exports.BaseUserPickerWithoutAnalytics = /*
387
388
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getAppearance", function () {
388
389
  return _this.props.appearance ? _this.props.appearance : 'normal';
389
390
  });
391
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClickDraggableParentComponent", function () {
392
+ if (_this.state.initialFocusHandled) {
393
+ // As <Select /> is already focused, calling this.selectRef.current.focus() again no longer triggers its own handlers (i.e. onMenuOpen, onMenuClose)
394
+ // We have to manually handle the open and close states of the dropdown menu based on a user's click from this point onwards to prevent the bug
395
+ if (_this.state.menuIsOpen) {
396
+ _this.handleClose();
397
+ } else {
398
+ _this.handleOpen();
399
+ }
400
+ } else if (!_this.state.menuIsOpen) {
401
+ // Trigger focus state when ValueContainer is clicked for the first time
402
+ // The focused state will then invoke <Select /> instance's own handlers (e.g. onMenuOpen, onMenuClose)
403
+ // to manage the state of the dropdown menu
404
+ _this.focus();
405
+ _this.setState(function () {
406
+ return {
407
+ initialFocusHandled: true
408
+ };
409
+ });
410
+ }
411
+ });
390
412
  _this.state = {
391
413
  options: [],
392
414
  isDefaultSet: false,
@@ -396,7 +418,8 @@ var BaseUserPickerWithoutAnalytics = exports.BaseUserPickerWithoutAnalytics = /*
396
418
  menuIsOpen: !!_this.props.open,
397
419
  inputValue: props.search || '',
398
420
  resolving: false,
399
- showError: false
421
+ showError: false,
422
+ initialFocusHandled: false
400
423
  };
401
424
  _this.optionsShownUfoExperienceInstance = _ufoExperiences.userPickerOptionsShownUfoExperience.getInstance((0, _uuid.v4)());
402
425
  return _this;
@@ -505,7 +528,8 @@ var BaseUserPickerWithoutAnalytics = exports.BaseUserPickerWithoutAnalytics = /*
505
528
  ariaLabel = _this$props4.ariaLabel,
506
529
  name = _this$props4.name,
507
530
  header = _this$props4.header,
508
- required = _this$props4.required;
531
+ required = _this$props4.required,
532
+ UNSAFE_hasDraggableParentComponent = _this$props4.UNSAFE_hasDraggableParentComponent;
509
533
  var _this$state3 = this.state,
510
534
  count = _this$state3.count,
511
535
  hoveringClearIndicator = _this$state3.hoveringClearIndicator,
@@ -573,7 +597,9 @@ var BaseUserPickerWithoutAnalytics = exports.BaseUserPickerWithoutAnalytics = /*
573
597
  maxPickerHeight: maxPickerHeight,
574
598
  textFieldBackgroundColor: textFieldBackgroundColor,
575
599
  header: header
576
- }, this.ariaProps, pickerProps));
600
+ }, this.ariaProps, pickerProps, UNSAFE_hasDraggableParentComponent && {
601
+ onValueContainerClick: this.handleClickDraggableParentComponent
602
+ }));
577
603
  }
578
604
  }], [{
579
605
  key: "getDerivedStateFromProps",
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -14,12 +15,15 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
14
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
17
  var _select = require("@atlaskit/select");
17
- var _react = _interopRequireDefault(require("react"));
18
+ var _react = _interopRequireWildcard(require("react"));
18
19
  var _reactDom = _interopRequireDefault(require("react-dom"));
19
20
  var _reactIntlNext = require("react-intl-next");
20
21
  var _i18n = require("./i18n");
21
22
  var _utils = require("./utils");
23
+ var _ValueContainerWrapper = _interopRequireDefault(require("./ValueContainerWrapper"));
22
24
  var _excluded = ["children", "innerProps"];
25
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
26
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
27
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
29
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
@@ -54,7 +58,7 @@ var MultiValueContainer = exports.MultiValueContainer = /*#__PURE__*/function (_
54
58
  placeholder: placeholder
55
59
  }) : child;
56
60
  });
57
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
61
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children);
58
62
  });
59
63
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderChildren", function () {
60
64
  var _this$props$selectPro = _this.props.selectProps,
@@ -77,6 +81,7 @@ var MultiValueContainer = exports.MultiValueContainer = /*#__PURE__*/function (_
77
81
  }
78
82
  return _this.addPlaceholder(addMoreMessage);
79
83
  });
84
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onValueContainerClick", _this.props.selectProps.onValueContainerClick);
80
85
  _this.state = {
81
86
  valueSize: 0,
82
87
  previousValueSize: 0
@@ -118,7 +123,10 @@ var MultiValueContainer = exports.MultiValueContainer = /*#__PURE__*/function (_
118
123
  var props = _objectSpread(_objectSpread({}, valueContainerProps), {}, {
119
124
  innerProps: this.valueContainerInnerProps
120
125
  });
121
- return /*#__PURE__*/_react.default.createElement(_select.components.ValueContainer, props, this.renderChildren());
126
+ return /*#__PURE__*/_react.default.createElement(_ValueContainerWrapper.default, {
127
+ isEnabled: this.onValueContainerClick,
128
+ onMouseDown: this.onValueContainerClick
129
+ }, /*#__PURE__*/_react.default.createElement(_select.components.ValueContainer, props, this.renderChildren()));
122
130
  }
123
131
  }], [{
124
132
  key: "getDerivedStateFromProps",
@@ -13,15 +13,16 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
13
13
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _react = _interopRequireDefault(require("react"));
17
- var _react2 = require("@emotion/react");
18
16
  var _select = require("@atlaskit/select");
17
+ var _react = require("@emotion/react");
18
+ var _react2 = _interopRequireDefault(require("react"));
19
19
  var _SizeableAvatar = require("./SizeableAvatar");
20
20
  var _styles = require("./styles");
21
+ var _ValueContainerWrapper = _interopRequireDefault(require("./ValueContainerWrapper"));
21
22
  var _excluded = ["children"];
22
23
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
23
24
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
24
- var placeholderIconContainer = (0, _react2.css)({
25
+ var placeholderIconContainer = (0, _react.css)({
25
26
  paddingLeft: "".concat(_styles.BORDER_PADDING, "px"),
26
27
  lineHeight: 0,
27
28
  gridArea: '1/1/2/2'
@@ -48,13 +49,23 @@ var SingleValueContainer = exports.SingleValueContainer = /*#__PURE__*/function
48
49
  inputValue = _this$props$selectPro.inputValue,
49
50
  value = _this$props$selectPro.value;
50
51
  if (isFocused || !hasValue) {
51
- return (0, _react2.jsx)(_SizeableAvatar.SizeableAvatar, {
52
+ return (0, _react.jsx)(_SizeableAvatar.SizeableAvatar, {
52
53
  appearance: appearance,
53
54
  src: showUserAvatar(inputValue, value) ? value.data.avatarUrl : undefined
54
55
  });
55
56
  }
56
57
  return null;
57
58
  });
59
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onValueContainerClick", _this.props.selectProps.onValueContainerClick);
60
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "Wrapper", function (_ref) {
61
+ var children = _ref.children;
62
+ return _this.onValueContainerClick ? (0, _react.jsx)("div", {
63
+ css: (0, _react.css)({
64
+ flexGrow: 1
65
+ }),
66
+ onMouseDown: _this.onValueContainerClick
67
+ }, children) : children;
68
+ });
58
69
  return _this;
59
70
  }
60
71
  (0, _createClass2.default)(SingleValueContainer, [{
@@ -63,10 +74,13 @@ var SingleValueContainer = exports.SingleValueContainer = /*#__PURE__*/function
63
74
  var _this$props2 = this.props,
64
75
  children = _this$props2.children,
65
76
  valueContainerProps = (0, _objectWithoutProperties2.default)(_this$props2, _excluded);
66
- return (0, _react2.jsx)(_select.components.ValueContainer, valueContainerProps, (0, _react2.jsx)("div", {
77
+ return (0, _react.jsx)(_ValueContainerWrapper.default, {
78
+ isEnabled: this.onValueContainerClick,
79
+ onMouseDown: this.onValueContainerClick
80
+ }, (0, _react.jsx)(_select.components.ValueContainer, valueContainerProps, (0, _react.jsx)("div", {
67
81
  css: placeholderIconContainer
68
- }, this.renderAvatar()), children);
82
+ }, this.renderAvatar()), children));
69
83
  }
70
84
  }]);
71
85
  return SingleValueContainer;
72
- }(_react.default.Component);
86
+ }(_react2.default.Component);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("@emotion/react");
8
+ /** @jsx jsx */
9
+
10
+ /**
11
+ * Conditional wrapper for the ValueContainer in Select. Provides a workaround
12
+ * for issues using react-select on react-beautiful-dnd Draggable elements.
13
+ * @returns
14
+ */
15
+ var ValueContainerWrapper = function ValueContainerWrapper(_ref) {
16
+ var children = _ref.children,
17
+ isEnabled = _ref.isEnabled,
18
+ onMouseDown = _ref.onMouseDown;
19
+ return isEnabled ? (0, _react.jsx)("div", {
20
+ css: (0, _react.css)({
21
+ flexGrow: 1
22
+ }),
23
+ onMouseDown: onMouseDown
24
+ }, children) : children;
25
+ };
26
+ var _default = exports.default = ValueContainerWrapper;
@@ -2,7 +2,7 @@ import { createAndFireEvent } from '@atlaskit/analytics-next';
2
2
  import { v4 as uuidv4 } from 'uuid';
3
3
  import { isCustom, isExternalUser } from './components/utils';
4
4
  const packageName = "@atlaskit/user-picker";
5
- const packageVersion = "10.13.2";
5
+ const packageVersion = "10.13.4";
6
6
  const UUID_REGEXP_TEAMS_GROUPS = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
7
7
  const UUID_REGEXP_OLD_AAID = /^[a-fA-F0-9]{1,8}:[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
8
8
  const UUID_REGEXP_NEW_AAID = /^[a-fA-F0-9]{24,24}$/;
@@ -251,6 +251,7 @@ export class BaseUserPickerWithoutAnalytics extends React.Component {
251
251
  this.abortOptionsShownUfoExperience();
252
252
  this.setState({
253
253
  menuIsOpen: false,
254
+ initialFocusHandled: false,
254
255
  options: []
255
256
  });
256
257
  });
@@ -364,6 +365,25 @@ export class BaseUserPickerWithoutAnalytics extends React.Component {
364
365
  return options;
365
366
  });
366
367
  _defineProperty(this, "getAppearance", () => this.props.appearance ? this.props.appearance : 'normal');
368
+ _defineProperty(this, "handleClickDraggableParentComponent", () => {
369
+ if (this.state.initialFocusHandled) {
370
+ // As <Select /> is already focused, calling this.selectRef.current.focus() again no longer triggers its own handlers (i.e. onMenuOpen, onMenuClose)
371
+ // We have to manually handle the open and close states of the dropdown menu based on a user's click from this point onwards to prevent the bug
372
+ if (this.state.menuIsOpen) {
373
+ this.handleClose();
374
+ } else {
375
+ this.handleOpen();
376
+ }
377
+ } else if (!this.state.menuIsOpen) {
378
+ // Trigger focus state when ValueContainer is clicked for the first time
379
+ // The focused state will then invoke <Select /> instance's own handlers (e.g. onMenuOpen, onMenuClose)
380
+ // to manage the state of the dropdown menu
381
+ this.focus();
382
+ this.setState(() => ({
383
+ initialFocusHandled: true
384
+ }));
385
+ }
386
+ });
367
387
  this.state = {
368
388
  options: [],
369
389
  isDefaultSet: false,
@@ -373,7 +393,8 @@ export class BaseUserPickerWithoutAnalytics extends React.Component {
373
393
  menuIsOpen: !!this.props.open,
374
394
  inputValue: props.search || '',
375
395
  resolving: false,
376
- showError: false
396
+ showError: false,
397
+ initialFocusHandled: false
377
398
  };
378
399
  this.optionsShownUfoExperienceInstance = userPickerOptionsShownUfoExperience.getInstance(uuidv4());
379
400
  }
@@ -476,7 +497,8 @@ export class BaseUserPickerWithoutAnalytics extends React.Component {
476
497
  ariaLabel,
477
498
  name,
478
499
  header,
479
- required
500
+ required,
501
+ UNSAFE_hasDraggableParentComponent
480
502
  } = this.props;
481
503
  const {
482
504
  count,
@@ -544,7 +566,9 @@ export class BaseUserPickerWithoutAnalytics extends React.Component {
544
566
  maxPickerHeight: maxPickerHeight,
545
567
  textFieldBackgroundColor: textFieldBackgroundColor,
546
568
  header: header
547
- }, this.ariaProps, pickerProps));
569
+ }, this.ariaProps, pickerProps, UNSAFE_hasDraggableParentComponent && {
570
+ onValueContainerClick: this.handleClickDraggableParentComponent
571
+ }));
548
572
  }
549
573
  }
550
574
  _defineProperty(BaseUserPickerWithoutAnalytics, "defaultProps", {
@@ -1,10 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { components } from '@atlaskit/select';
3
- import React from 'react';
3
+ import React, { Fragment } from 'react';
4
4
  import ReactDOM from 'react-dom';
5
5
  import { FormattedMessage } from 'react-intl-next';
6
6
  import { messages } from './i18n';
7
7
  import { isChildInput } from './utils';
8
+ import ValueContainerWrapper from './ValueContainerWrapper';
8
9
  export class MultiValueContainer extends React.PureComponent {
9
10
  static getDerivedStateFromProps(nextProps, prevState) {
10
11
  return {
@@ -43,7 +44,7 @@ export class MultiValueContainer extends React.PureComponent {
43
44
  const children = React.Children.map(this.props.children, child => isChildInput(child) && this.showPlaceholder() ? /*#__PURE__*/React.cloneElement(child, {
44
45
  placeholder
45
46
  }) : child);
46
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
47
+ return /*#__PURE__*/React.createElement(Fragment, null, children);
47
48
  });
48
49
  _defineProperty(this, "renderChildren", () => {
49
50
  const {
@@ -69,6 +70,7 @@ export class MultiValueContainer extends React.PureComponent {
69
70
  }
70
71
  return this.addPlaceholder(addMoreMessage);
71
72
  });
73
+ _defineProperty(this, "onValueContainerClick", this.props.selectProps.onValueContainerClick);
72
74
  this.state = {
73
75
  valueSize: 0,
74
76
  previousValueSize: 0
@@ -108,6 +110,9 @@ export class MultiValueContainer extends React.PureComponent {
108
110
  ...valueContainerProps,
109
111
  innerProps: this.valueContainerInnerProps
110
112
  };
111
- return /*#__PURE__*/React.createElement(components.ValueContainer, props, this.renderChildren());
113
+ return /*#__PURE__*/React.createElement(ValueContainerWrapper, {
114
+ isEnabled: this.onValueContainerClick,
115
+ onMouseDown: this.onValueContainerClick
116
+ }, /*#__PURE__*/React.createElement(components.ValueContainer, props, this.renderChildren()));
112
117
  }
113
118
  }
@@ -1,10 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  /** @jsx jsx */
3
- import React from 'react';
4
- import { css, jsx } from '@emotion/react';
5
3
  import { components } from '@atlaskit/select';
4
+ import { css, jsx } from '@emotion/react';
5
+ import React from 'react';
6
6
  import { SizeableAvatar } from './SizeableAvatar';
7
7
  import { BORDER_PADDING } from './styles';
8
+ import ValueContainerWrapper from './ValueContainerWrapper';
8
9
  const placeholderIconContainer = css({
9
10
  paddingLeft: `${BORDER_PADDING}px`,
10
11
  lineHeight: 0,
@@ -32,14 +33,28 @@ export class SingleValueContainer extends React.Component {
32
33
  }
33
34
  return null;
34
35
  });
36
+ _defineProperty(this, "onValueContainerClick", this.props.selectProps.onValueContainerClick);
37
+ _defineProperty(this, "Wrapper", ({
38
+ children
39
+ }) => {
40
+ return this.onValueContainerClick ? jsx("div", {
41
+ css: css({
42
+ flexGrow: 1
43
+ }),
44
+ onMouseDown: this.onValueContainerClick
45
+ }, children) : children;
46
+ });
35
47
  }
36
48
  render() {
37
49
  const {
38
50
  children,
39
51
  ...valueContainerProps
40
52
  } = this.props;
41
- return jsx(components.ValueContainer, valueContainerProps, jsx("div", {
53
+ return jsx(ValueContainerWrapper, {
54
+ isEnabled: this.onValueContainerClick,
55
+ onMouseDown: this.onValueContainerClick
56
+ }, jsx(components.ValueContainer, valueContainerProps, jsx("div", {
42
57
  css: placeholderIconContainer
43
- }, this.renderAvatar()), children);
58
+ }, this.renderAvatar()), children));
44
59
  }
45
60
  }
@@ -0,0 +1,21 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/react';
3
+
4
+ /**
5
+ * Conditional wrapper for the ValueContainer in Select. Provides a workaround
6
+ * for issues using react-select on react-beautiful-dnd Draggable elements.
7
+ * @returns
8
+ */
9
+ const ValueContainerWrapper = ({
10
+ children,
11
+ isEnabled,
12
+ onMouseDown
13
+ }) => {
14
+ return isEnabled ? jsx("div", {
15
+ css: css({
16
+ flexGrow: 1
17
+ }),
18
+ onMouseDown: onMouseDown
19
+ }, children) : children;
20
+ };
21
+ export default ValueContainerWrapper;
@@ -5,7 +5,7 @@ import { createAndFireEvent } from '@atlaskit/analytics-next';
5
5
  import { v4 as uuidv4 } from 'uuid';
6
6
  import { isCustom, isExternalUser } from './components/utils';
7
7
  var packageName = "@atlaskit/user-picker";
8
- var packageVersion = "10.13.2";
8
+ var packageVersion = "10.13.4";
9
9
  var UUID_REGEXP_TEAMS_GROUPS = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
10
10
  var UUID_REGEXP_OLD_AAID = /^[a-fA-F0-9]{1,8}:[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/;
11
11
  var UUID_REGEXP_NEW_AAID = /^[a-fA-F0-9]{24,24}$/;
@@ -255,6 +255,7 @@ export var BaseUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compon
255
255
  _this.abortOptionsShownUfoExperience();
256
256
  _this.setState({
257
257
  menuIsOpen: false,
258
+ initialFocusHandled: false,
258
259
  options: []
259
260
  });
260
261
  });
@@ -380,6 +381,27 @@ export var BaseUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compon
380
381
  _defineProperty(_assertThisInitialized(_this), "getAppearance", function () {
381
382
  return _this.props.appearance ? _this.props.appearance : 'normal';
382
383
  });
384
+ _defineProperty(_assertThisInitialized(_this), "handleClickDraggableParentComponent", function () {
385
+ if (_this.state.initialFocusHandled) {
386
+ // As <Select /> is already focused, calling this.selectRef.current.focus() again no longer triggers its own handlers (i.e. onMenuOpen, onMenuClose)
387
+ // We have to manually handle the open and close states of the dropdown menu based on a user's click from this point onwards to prevent the bug
388
+ if (_this.state.menuIsOpen) {
389
+ _this.handleClose();
390
+ } else {
391
+ _this.handleOpen();
392
+ }
393
+ } else if (!_this.state.menuIsOpen) {
394
+ // Trigger focus state when ValueContainer is clicked for the first time
395
+ // The focused state will then invoke <Select /> instance's own handlers (e.g. onMenuOpen, onMenuClose)
396
+ // to manage the state of the dropdown menu
397
+ _this.focus();
398
+ _this.setState(function () {
399
+ return {
400
+ initialFocusHandled: true
401
+ };
402
+ });
403
+ }
404
+ });
383
405
  _this.state = {
384
406
  options: [],
385
407
  isDefaultSet: false,
@@ -389,7 +411,8 @@ export var BaseUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compon
389
411
  menuIsOpen: !!_this.props.open,
390
412
  inputValue: props.search || '',
391
413
  resolving: false,
392
- showError: false
414
+ showError: false,
415
+ initialFocusHandled: false
393
416
  };
394
417
  _this.optionsShownUfoExperienceInstance = userPickerOptionsShownUfoExperience.getInstance(uuidv4());
395
418
  return _this;
@@ -498,7 +521,8 @@ export var BaseUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compon
498
521
  ariaLabel = _this$props4.ariaLabel,
499
522
  name = _this$props4.name,
500
523
  header = _this$props4.header,
501
- required = _this$props4.required;
524
+ required = _this$props4.required,
525
+ UNSAFE_hasDraggableParentComponent = _this$props4.UNSAFE_hasDraggableParentComponent;
502
526
  var _this$state3 = this.state,
503
527
  count = _this$state3.count,
504
528
  hoveringClearIndicator = _this$state3.hoveringClearIndicator,
@@ -566,7 +590,9 @@ export var BaseUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compon
566
590
  maxPickerHeight: maxPickerHeight,
567
591
  textFieldBackgroundColor: textFieldBackgroundColor,
568
592
  header: header
569
- }, this.ariaProps, pickerProps));
593
+ }, this.ariaProps, pickerProps, UNSAFE_hasDraggableParentComponent && {
594
+ onValueContainerClick: this.handleClickDraggableParentComponent
595
+ }));
570
596
  }
571
597
  }], [{
572
598
  key: "getDerivedStateFromProps",
@@ -12,11 +12,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
12
12
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
14
  import { components } from '@atlaskit/select';
15
- import React from 'react';
15
+ import React, { Fragment } from 'react';
16
16
  import ReactDOM from 'react-dom';
17
17
  import { FormattedMessage } from 'react-intl-next';
18
18
  import { messages } from './i18n';
19
19
  import { isChildInput } from './utils';
20
+ import ValueContainerWrapper from './ValueContainerWrapper';
20
21
  export var MultiValueContainer = /*#__PURE__*/function (_React$PureComponent) {
21
22
  _inherits(MultiValueContainer, _React$PureComponent);
22
23
  var _super = _createSuper(MultiValueContainer);
@@ -47,7 +48,7 @@ export var MultiValueContainer = /*#__PURE__*/function (_React$PureComponent) {
47
48
  placeholder: placeholder
48
49
  }) : child;
49
50
  });
50
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
51
+ return /*#__PURE__*/React.createElement(Fragment, null, children);
51
52
  });
52
53
  _defineProperty(_assertThisInitialized(_this), "renderChildren", function () {
53
54
  var _this$props$selectPro = _this.props.selectProps,
@@ -70,6 +71,7 @@ export var MultiValueContainer = /*#__PURE__*/function (_React$PureComponent) {
70
71
  }
71
72
  return _this.addPlaceholder(addMoreMessage);
72
73
  });
74
+ _defineProperty(_assertThisInitialized(_this), "onValueContainerClick", _this.props.selectProps.onValueContainerClick);
73
75
  _this.state = {
74
76
  valueSize: 0,
75
77
  previousValueSize: 0
@@ -111,7 +113,10 @@ export var MultiValueContainer = /*#__PURE__*/function (_React$PureComponent) {
111
113
  var props = _objectSpread(_objectSpread({}, valueContainerProps), {}, {
112
114
  innerProps: this.valueContainerInnerProps
113
115
  });
114
- return /*#__PURE__*/React.createElement(components.ValueContainer, props, this.renderChildren());
116
+ return /*#__PURE__*/React.createElement(ValueContainerWrapper, {
117
+ isEnabled: this.onValueContainerClick,
118
+ onMouseDown: this.onValueContainerClick
119
+ }, /*#__PURE__*/React.createElement(components.ValueContainer, props, this.renderChildren()));
115
120
  }
116
121
  }], [{
117
122
  key: "getDerivedStateFromProps",
@@ -10,11 +10,12 @@ var _excluded = ["children"];
10
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
12
  /** @jsx jsx */
13
- import React from 'react';
14
- import { css, jsx } from '@emotion/react';
15
13
  import { components } from '@atlaskit/select';
14
+ import { css, jsx } from '@emotion/react';
15
+ import React from 'react';
16
16
  import { SizeableAvatar } from './SizeableAvatar';
17
17
  import { BORDER_PADDING } from './styles';
18
+ import ValueContainerWrapper from './ValueContainerWrapper';
18
19
  var placeholderIconContainer = css({
19
20
  paddingLeft: "".concat(BORDER_PADDING, "px"),
20
21
  lineHeight: 0,
@@ -49,6 +50,16 @@ export var SingleValueContainer = /*#__PURE__*/function (_React$Component) {
49
50
  }
50
51
  return null;
51
52
  });
53
+ _defineProperty(_assertThisInitialized(_this), "onValueContainerClick", _this.props.selectProps.onValueContainerClick);
54
+ _defineProperty(_assertThisInitialized(_this), "Wrapper", function (_ref) {
55
+ var children = _ref.children;
56
+ return _this.onValueContainerClick ? jsx("div", {
57
+ css: css({
58
+ flexGrow: 1
59
+ }),
60
+ onMouseDown: _this.onValueContainerClick
61
+ }, children) : children;
62
+ });
52
63
  return _this;
53
64
  }
54
65
  _createClass(SingleValueContainer, [{
@@ -57,9 +68,12 @@ export var SingleValueContainer = /*#__PURE__*/function (_React$Component) {
57
68
  var _this$props2 = this.props,
58
69
  children = _this$props2.children,
59
70
  valueContainerProps = _objectWithoutProperties(_this$props2, _excluded);
60
- return jsx(components.ValueContainer, valueContainerProps, jsx("div", {
71
+ return jsx(ValueContainerWrapper, {
72
+ isEnabled: this.onValueContainerClick,
73
+ onMouseDown: this.onValueContainerClick
74
+ }, jsx(components.ValueContainer, valueContainerProps, jsx("div", {
61
75
  css: placeholderIconContainer
62
- }, this.renderAvatar()), children);
76
+ }, this.renderAvatar()), children));
63
77
  }
64
78
  }]);
65
79
  return SingleValueContainer;
@@ -0,0 +1,20 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/react';
3
+
4
+ /**
5
+ * Conditional wrapper for the ValueContainer in Select. Provides a workaround
6
+ * for issues using react-select on react-beautiful-dnd Draggable elements.
7
+ * @returns
8
+ */
9
+ var ValueContainerWrapper = function ValueContainerWrapper(_ref) {
10
+ var children = _ref.children,
11
+ isEnabled = _ref.isEnabled,
12
+ onMouseDown = _ref.onMouseDown;
13
+ return isEnabled ? jsx("div", {
14
+ css: css({
15
+ flexGrow: 1
16
+ }),
17
+ onMouseDown: onMouseDown
18
+ }, children) : children;
19
+ };
20
+ export default ValueContainerWrapper;
@@ -7,6 +7,12 @@ export type BaseUserPickerProps = UserPickerProps & {
7
7
  components: any;
8
8
  width: string | number;
9
9
  name?: string;
10
+ /**
11
+ * @deprecated This is a temporary prop to enable user-pickers to work in Draggable elements in react-beautiful-dnd.
12
+ * See https://product-fabric.atlassian.net/browse/DSP-15701 for more details.
13
+ * It may be removed in a future minor or patch when a longer-term workaround is found.
14
+ */
15
+ UNSAFE_hasDraggableParentComponent?: boolean;
10
16
  };
11
17
  export declare class BaseUserPickerWithoutAnalytics extends React.Component<BaseUserPickerProps, UserPickerState> {
12
18
  static defaultProps: {
@@ -55,9 +61,10 @@ export declare class BaseUserPickerWithoutAnalytics extends React.Component<Base
55
61
  private getOptions;
56
62
  private getAppearance;
57
63
  get ariaProps(): {};
64
+ private handleClickDraggableParentComponent;
58
65
  render(): JSX.Element;
59
66
  }
60
- export declare const BaseUserPicker: React.ForwardRefExoticComponent<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "components" | "inputId" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "defaultValue" | "fieldId" | "width" | "menuMinWidth" | "maxPickerHeight" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "SelectComponent" | "pickerProps"> & Partial<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isClearable" | "isMulti" | "textFieldBackgroundColor" | "loadOptionsErrorMessage" | "subtle" | "noBorder">> & Partial<Pick<{
67
+ export declare const BaseUserPicker: React.ForwardRefExoticComponent<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "components" | "inputId" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "defaultValue" | "fieldId" | "width" | "menuMinWidth" | "maxPickerHeight" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "UNSAFE_hasDraggableParentComponent" | "SelectComponent" | "pickerProps"> & Partial<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isClearable" | "isMulti" | "textFieldBackgroundColor" | "loadOptionsErrorMessage" | "subtle" | "noBorder">> & Partial<Pick<{
61
68
  isMulti: boolean;
62
69
  subtle: boolean;
63
70
  noBorder: boolean;
@@ -1,6 +1,6 @@
1
1
  import { MultiValueProps } from '@atlaskit/select';
2
2
  import React from 'react';
3
- import { User, Option } from '../types';
3
+ import { Option, User } from '../types';
4
4
  export type State = {
5
5
  valueSize: number;
6
6
  previousValueSize: number;
@@ -25,6 +25,7 @@ export declare class MultiValueContainer extends React.PureComponent<Props, Stat
25
25
  private showPlaceholder;
26
26
  private addPlaceholder;
27
27
  private renderChildren;
28
+ onValueContainerClick: any;
28
29
  render(): JSX.Element;
29
30
  }
30
31
  export {};
@@ -27,7 +27,7 @@ export declare class PopupUserPickerWithoutAnalytics extends React.Component<Pop
27
27
  };
28
28
  render(): JSX.Element;
29
29
  }
30
- export declare const PopupUserPicker: React.ForwardRefExoticComponent<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "target" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadOptionsErrorMessage" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "popupTitle"> & Partial<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "offset" | "isMulti" | "width" | "placement" | "rootBoundary" | "boundariesElement" | "shouldFlip">> & Partial<Pick<{
30
+ export declare const PopupUserPicker: React.ForwardRefExoticComponent<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "target" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadOptionsErrorMessage" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "UNSAFE_hasDraggableParentComponent" | "popupTitle"> & Partial<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "offset" | "isMulti" | "width" | "placement" | "rootBoundary" | "boundariesElement" | "shouldFlip">> & Partial<Pick<{
31
31
  boundariesElement: string;
32
32
  width: number;
33
33
  isMulti: boolean;
@@ -1,9 +1,13 @@
1
1
  /** @jsx jsx */
2
- import React from 'react';
3
- import { jsx } from '@emotion/react';
4
2
  import { ValueContainerProps } from '@atlaskit/select';
5
- import { User, Option } from '../types';
3
+ import { jsx } from '@emotion/react';
4
+ import React from 'react';
5
+ import { Option, User } from '../types';
6
6
  export declare class SingleValueContainer extends React.Component<ValueContainerProps<Option<User>>> {
7
7
  private renderAvatar;
8
+ onValueContainerClick: any;
9
+ Wrapper: ({ children }: {
10
+ children: React.ReactElement;
11
+ }) => jsx.JSX.Element;
8
12
  render(): jsx.JSX.Element;
9
13
  }
@@ -10,7 +10,7 @@ export declare class UserPickerWithoutAnalytics extends React.Component<UserPick
10
10
  componentDidMount(): void;
11
11
  render(): JSX.Element;
12
12
  }
13
- export declare const UserPicker: React.ForwardRefExoticComponent<Pick<Omit<UserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadOptionsErrorMessage" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required"> & Partial<Pick<Omit<UserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isMulti" | "width">> & Partial<Pick<{
13
+ export declare const UserPicker: React.ForwardRefExoticComponent<Pick<Omit<UserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadOptionsErrorMessage" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "UNSAFE_hasDraggableParentComponent"> & Partial<Pick<Omit<UserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isMulti" | "width">> & Partial<Pick<{
14
14
  width: number;
15
15
  isMulti: boolean;
16
16
  }, never>> & React.RefAttributes<any>>;
@@ -0,0 +1,13 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ /**
4
+ * Conditional wrapper for the ValueContainer in Select. Provides a workaround
5
+ * for issues using react-select on react-beautiful-dnd Draggable elements.
6
+ * @returns
7
+ */
8
+ declare const ValueContainerWrapper: ({ children, isEnabled, onMouseDown, }: {
9
+ children: React.ReactElement;
10
+ isEnabled: boolean;
11
+ onMouseDown: () => void;
12
+ }) => jsx.JSX.Element;
13
+ export default ValueContainerWrapper;
@@ -156,7 +156,14 @@ export type UserPickerProps = WithAnalyticsEventsProps & {
156
156
  name?: string;
157
157
  /** Header to be displayed in MenuList */
158
158
  header?: React.ReactNode;
159
+ /** Accessibility: A field to dictate if this is a mandatory field in the form. */
159
160
  required?: boolean;
161
+ /**
162
+ * Enables workaround for when <Select /> is nested inside <Draggable /> from react-beautiful-dnd
163
+ * This relationship prevents the dropdown menu from opening because of bugs in the default focus state and clicking in a particular area of <Select />
164
+ * Context: https://hello.atlassian.net/wiki/spaces/~989411314/pages/2861097485/Investigation+Notes+for+atlaskit+select+react-beautiful-dnd#Temporary-Solution
165
+ */
166
+ UNSAFE_hasDraggableParentComponent?: boolean;
160
167
  };
161
168
  export type PopupUserPickerProps = UserPickerProps & {
162
169
  /** Whether to use the popup version of the single picker */
@@ -204,6 +211,7 @@ export type UserPickerState = {
204
211
  inputValue: string;
205
212
  resolving: boolean;
206
213
  showError: boolean;
214
+ initialFocusHandled: boolean;
207
215
  };
208
216
  export interface HighlightRange {
209
217
  start: number;
@@ -7,6 +7,12 @@ export type BaseUserPickerProps = UserPickerProps & {
7
7
  components: any;
8
8
  width: string | number;
9
9
  name?: string;
10
+ /**
11
+ * @deprecated This is a temporary prop to enable user-pickers to work in Draggable elements in react-beautiful-dnd.
12
+ * See https://product-fabric.atlassian.net/browse/DSP-15701 for more details.
13
+ * It may be removed in a future minor or patch when a longer-term workaround is found.
14
+ */
15
+ UNSAFE_hasDraggableParentComponent?: boolean;
10
16
  };
11
17
  export declare class BaseUserPickerWithoutAnalytics extends React.Component<BaseUserPickerProps, UserPickerState> {
12
18
  static defaultProps: {
@@ -55,9 +61,10 @@ export declare class BaseUserPickerWithoutAnalytics extends React.Component<Base
55
61
  private getOptions;
56
62
  private getAppearance;
57
63
  get ariaProps(): {};
64
+ private handleClickDraggableParentComponent;
58
65
  render(): JSX.Element;
59
66
  }
60
- export declare const BaseUserPicker: React.ForwardRefExoticComponent<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "components" | "inputId" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "defaultValue" | "fieldId" | "width" | "menuMinWidth" | "maxPickerHeight" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "SelectComponent" | "pickerProps"> & Partial<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isClearable" | "isMulti" | "textFieldBackgroundColor" | "loadOptionsErrorMessage" | "subtle" | "noBorder">> & Partial<Pick<{
67
+ export declare const BaseUserPicker: React.ForwardRefExoticComponent<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "components" | "inputId" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "defaultValue" | "fieldId" | "width" | "menuMinWidth" | "maxPickerHeight" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "UNSAFE_hasDraggableParentComponent" | "SelectComponent" | "pickerProps"> & Partial<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isClearable" | "isMulti" | "textFieldBackgroundColor" | "loadOptionsErrorMessage" | "subtle" | "noBorder">> & Partial<Pick<{
61
68
  isMulti: boolean;
62
69
  subtle: boolean;
63
70
  noBorder: boolean;
@@ -1,6 +1,6 @@
1
1
  import { MultiValueProps } from '@atlaskit/select';
2
2
  import React from 'react';
3
- import { User, Option } from '../types';
3
+ import { Option, User } from '../types';
4
4
  export type State = {
5
5
  valueSize: number;
6
6
  previousValueSize: number;
@@ -25,6 +25,7 @@ export declare class MultiValueContainer extends React.PureComponent<Props, Stat
25
25
  private showPlaceholder;
26
26
  private addPlaceholder;
27
27
  private renderChildren;
28
+ onValueContainerClick: any;
28
29
  render(): JSX.Element;
29
30
  }
30
31
  export {};
@@ -27,7 +27,7 @@ export declare class PopupUserPickerWithoutAnalytics extends React.Component<Pop
27
27
  };
28
28
  render(): JSX.Element;
29
29
  }
30
- export declare const PopupUserPicker: React.ForwardRefExoticComponent<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "target" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadOptionsErrorMessage" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "popupTitle"> & Partial<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "offset" | "isMulti" | "width" | "placement" | "rootBoundary" | "boundariesElement" | "shouldFlip">> & Partial<Pick<{
30
+ export declare const PopupUserPicker: React.ForwardRefExoticComponent<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "target" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadOptionsErrorMessage" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "UNSAFE_hasDraggableParentComponent" | "popupTitle"> & Partial<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "offset" | "isMulti" | "width" | "placement" | "rootBoundary" | "boundariesElement" | "shouldFlip">> & Partial<Pick<{
31
31
  boundariesElement: string;
32
32
  width: number;
33
33
  isMulti: boolean;
@@ -1,9 +1,13 @@
1
1
  /** @jsx jsx */
2
- import React from 'react';
3
- import { jsx } from '@emotion/react';
4
2
  import { ValueContainerProps } from '@atlaskit/select';
5
- import { User, Option } from '../types';
3
+ import { jsx } from '@emotion/react';
4
+ import React from 'react';
5
+ import { Option, User } from '../types';
6
6
  export declare class SingleValueContainer extends React.Component<ValueContainerProps<Option<User>>> {
7
7
  private renderAvatar;
8
+ onValueContainerClick: any;
9
+ Wrapper: ({ children }: {
10
+ children: React.ReactElement;
11
+ }) => jsx.JSX.Element;
8
12
  render(): jsx.JSX.Element;
9
13
  }
@@ -10,7 +10,7 @@ export declare class UserPickerWithoutAnalytics extends React.Component<UserPick
10
10
  componentDidMount(): void;
11
11
  render(): JSX.Element;
12
12
  }
13
- export declare const UserPicker: React.ForwardRefExoticComponent<Pick<Omit<UserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadOptionsErrorMessage" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required"> & Partial<Pick<Omit<UserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isMulti" | "width">> & Partial<Pick<{
13
+ export declare const UserPicker: React.ForwardRefExoticComponent<Pick<Omit<UserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "placeholder" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "name" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "onKeyDown" | "styles" | "value" | "footer" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadOptionsErrorMessage" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onOpen" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabel" | "ariaLabelledBy" | "ariaLive" | "header" | "required" | "UNSAFE_hasDraggableParentComponent"> & Partial<Pick<Omit<UserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isMulti" | "width">> & Partial<Pick<{
14
14
  width: number;
15
15
  isMulti: boolean;
16
16
  }, never>> & React.RefAttributes<any>>;
@@ -0,0 +1,13 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ /**
4
+ * Conditional wrapper for the ValueContainer in Select. Provides a workaround
5
+ * for issues using react-select on react-beautiful-dnd Draggable elements.
6
+ * @returns
7
+ */
8
+ declare const ValueContainerWrapper: ({ children, isEnabled, onMouseDown, }: {
9
+ children: React.ReactElement;
10
+ isEnabled: boolean;
11
+ onMouseDown: () => void;
12
+ }) => jsx.JSX.Element;
13
+ export default ValueContainerWrapper;
@@ -156,7 +156,14 @@ export type UserPickerProps = WithAnalyticsEventsProps & {
156
156
  name?: string;
157
157
  /** Header to be displayed in MenuList */
158
158
  header?: React.ReactNode;
159
+ /** Accessibility: A field to dictate if this is a mandatory field in the form. */
159
160
  required?: boolean;
161
+ /**
162
+ * Enables workaround for when <Select /> is nested inside <Draggable /> from react-beautiful-dnd
163
+ * This relationship prevents the dropdown menu from opening because of bugs in the default focus state and clicking in a particular area of <Select />
164
+ * Context: https://hello.atlassian.net/wiki/spaces/~989411314/pages/2861097485/Investigation+Notes+for+atlaskit+select+react-beautiful-dnd#Temporary-Solution
165
+ */
166
+ UNSAFE_hasDraggableParentComponent?: boolean;
160
167
  };
161
168
  export type PopupUserPickerProps = UserPickerProps & {
162
169
  /** Whether to use the popup version of the single picker */
@@ -207,6 +214,7 @@ export type UserPickerState = {
207
214
  inputValue: string;
208
215
  resolving: boolean;
209
216
  showError: boolean;
217
+ initialFocusHandled: boolean;
210
218
  };
211
219
  export interface HighlightRange {
212
220
  start: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/user-picker",
3
- "version": "10.13.2",
3
+ "version": "10.13.4",
4
4
  "description": "Fabric component for display a dropdown to select a user from",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -44,8 +44,8 @@
44
44
  "@atlaskit/select": "^17.0.3",
45
45
  "@atlaskit/spinner": "^16.0.0",
46
46
  "@atlaskit/theme": "^12.6.0",
47
- "@atlaskit/tokens": "^1.29.0",
48
- "@atlaskit/tooltip": "^18.0.0",
47
+ "@atlaskit/tokens": "^1.33.0",
48
+ "@atlaskit/tooltip": "^18.1.0",
49
49
  "@atlaskit/ufo": "^0.2.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1",
@@ -61,6 +61,8 @@
61
61
  "devDependencies": {
62
62
  "@atlaskit/analytics-viewer": "^0.5.0",
63
63
  "@atlaskit/elements-test-helpers": "^0.7.0",
64
+ "@atlaskit/heading": "^1.4.0",
65
+ "@atlaskit/primitives": "^1.16.0",
64
66
  "@atlaskit/visual-regression": "*",
65
67
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
66
68
  "@emotion/styled": "^11.0.0",
@@ -72,6 +74,7 @@
72
74
  "@types/uuid": "^3.4.4",
73
75
  "enzyme": "^3.10.0",
74
76
  "mock-apollo-client": "^0.1.0",
77
+ "react-beautiful-dnd": "^12.1.1",
75
78
  "react-intl-next": "npm:react-intl@^5.18.1",
76
79
  "react-select-event": "^5.5.0",
77
80
  "typescript": "~4.9.5"