@atlaskit/user-picker 9.5.1 → 9.6.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/analytics.js +8 -2
  3. package/dist/cjs/components/CustomOption/index.js +29 -0
  4. package/dist/cjs/components/CustomOption/main.js +115 -0
  5. package/dist/cjs/components/MultiValue.js +2 -2
  6. package/dist/cjs/components/Option.js +9 -0
  7. package/dist/cjs/components/styles.js +1 -1
  8. package/dist/cjs/components/utils.js +8 -2
  9. package/dist/cjs/index.js +6 -0
  10. package/dist/cjs/types.js +4 -2
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/analytics.js +9 -3
  13. package/dist/es2019/components/CustomOption/index.js +9 -0
  14. package/dist/es2019/components/CustomOption/main.js +73 -0
  15. package/dist/es2019/components/MultiValue.js +2 -2
  16. package/dist/es2019/components/Option.js +9 -1
  17. package/dist/es2019/components/styles.js +1 -1
  18. package/dist/es2019/components/utils.js +3 -2
  19. package/dist/es2019/index.js +1 -1
  20. package/dist/es2019/types.js +2 -1
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/esm/analytics.js +9 -3
  23. package/dist/esm/components/CustomOption/index.js +11 -0
  24. package/dist/esm/components/CustomOption/main.js +99 -0
  25. package/dist/esm/components/MultiValue.js +2 -2
  26. package/dist/esm/components/Option.js +9 -1
  27. package/dist/esm/components/styles.js +1 -1
  28. package/dist/esm/components/utils.js +5 -2
  29. package/dist/esm/index.js +1 -1
  30. package/dist/esm/types.js +2 -1
  31. package/dist/esm/version.json +1 -1
  32. package/dist/types/components/BaseUserPicker.d.ts +1 -1
  33. package/dist/types/components/CustomOption/index.d.ts +3 -0
  34. package/dist/{types-ts4.0/components/TeamOption → types/components/CustomOption}/main.d.ts +5 -6
  35. package/dist/types/components/PopupUserPicker.d.ts +1 -1
  36. package/dist/types/components/UserPicker.d.ts +1 -1
  37. package/dist/types/components/utils.d.ts +2 -1
  38. package/dist/types/index.d.ts +2 -2
  39. package/dist/types/types.d.ts +12 -1
  40. package/package.json +6 -14
  41. package/report.api.md +24 -1
  42. package/tmp/api-report-tmp.d.ts +24 -1
  43. package/dist/types-ts4.0/analytics.d.ts +0 -24
  44. package/dist/types-ts4.0/clients/UserSourceProvider.d.ts +0 -11
  45. package/dist/types-ts4.0/components/AddOptionAvatar.d.ts +0 -6
  46. package/dist/types-ts4.0/components/AvatarItemOption.d.ts +0 -12
  47. package/dist/types-ts4.0/components/BaseUserPicker.d.ts +0 -60
  48. package/dist/types-ts4.0/components/ClearIndicator.d.ts +0 -6
  49. package/dist/types-ts4.0/components/EmailOption/index.d.ts +0 -3
  50. package/dist/types-ts4.0/components/EmailOption/main.d.ts +0 -17
  51. package/dist/types-ts4.0/components/ExternalUserOption/ExternalAvatarItemOption.d.ts +0 -10
  52. package/dist/types-ts4.0/components/ExternalUserOption/InfoIcon.d.ts +0 -3
  53. package/dist/types-ts4.0/components/ExternalUserOption/SourcesTooltipContent.d.ts +0 -6
  54. package/dist/types-ts4.0/components/ExternalUserOption/index.d.ts +0 -3
  55. package/dist/types-ts4.0/components/ExternalUserOption/main.d.ts +0 -12
  56. package/dist/types-ts4.0/components/ExternalUserSourcesContainer.d.ts +0 -15
  57. package/dist/types-ts4.0/components/GroupOption/index.d.ts +0 -3
  58. package/dist/types-ts4.0/components/GroupOption/main.d.ts +0 -15
  59. package/dist/types-ts4.0/components/HighlightText.d.ts +0 -9
  60. package/dist/types-ts4.0/components/Input.d.ts +0 -11
  61. package/dist/types-ts4.0/components/MessagesIntlProvider.d.ts +0 -3
  62. package/dist/types-ts4.0/components/MultiValue.d.ts +0 -25
  63. package/dist/types-ts4.0/components/MultiValueContainer.d.ts +0 -30
  64. package/dist/types-ts4.0/components/Option.d.ts +0 -14
  65. package/dist/types-ts4.0/components/PopupControl.d.ts +0 -6
  66. package/dist/types-ts4.0/components/PopupInput.d.ts +0 -13
  67. package/dist/types-ts4.0/components/PopupUserPicker.d.ts +0 -39
  68. package/dist/types-ts4.0/components/SingleValue.d.ts +0 -8
  69. package/dist/types-ts4.0/components/SingleValueContainer.d.ts +0 -8
  70. package/dist/types-ts4.0/components/SizeableAvatar.d.ts +0 -10
  71. package/dist/types-ts4.0/components/TeamOption/index.d.ts +0 -3
  72. package/dist/types-ts4.0/components/UserOption.d.ts +0 -14
  73. package/dist/types-ts4.0/components/UserPicker.d.ts +0 -16
  74. package/dist/types-ts4.0/components/assets/github.d.ts +0 -2
  75. package/dist/types-ts4.0/components/assets/google.d.ts +0 -2
  76. package/dist/types-ts4.0/components/assets/microsoft.d.ts +0 -2
  77. package/dist/types-ts4.0/components/assets/slack.d.ts +0 -2
  78. package/dist/types-ts4.0/components/batch.d.ts +0 -1
  79. package/dist/types-ts4.0/components/components.d.ts +0 -55
  80. package/dist/types-ts4.0/components/creatable.d.ts +0 -12
  81. package/dist/types-ts4.0/components/creatableEmailSuggestion.d.ts +0 -19
  82. package/dist/types-ts4.0/components/emailValidation.d.ts +0 -3
  83. package/dist/types-ts4.0/components/i18n.d.ts +0 -127
  84. package/dist/types-ts4.0/components/popup.d.ts +0 -48
  85. package/dist/types-ts4.0/components/styles.d.ts +0 -17
  86. package/dist/types-ts4.0/components/utils.d.ts +0 -28
  87. package/dist/types-ts4.0/i18n/cs.d.ts +0 -33
  88. package/dist/types-ts4.0/i18n/da.d.ts +0 -33
  89. package/dist/types-ts4.0/i18n/de.d.ts +0 -33
  90. package/dist/types-ts4.0/i18n/en.d.ts +0 -7
  91. package/dist/types-ts4.0/i18n/en_GB.d.ts +0 -7
  92. package/dist/types-ts4.0/i18n/en_ZZ.d.ts +0 -33
  93. package/dist/types-ts4.0/i18n/es.d.ts +0 -33
  94. package/dist/types-ts4.0/i18n/et.d.ts +0 -15
  95. package/dist/types-ts4.0/i18n/fi.d.ts +0 -33
  96. package/dist/types-ts4.0/i18n/fr.d.ts +0 -33
  97. package/dist/types-ts4.0/i18n/hu.d.ts +0 -33
  98. package/dist/types-ts4.0/i18n/index.d.ts +0 -36
  99. package/dist/types-ts4.0/i18n/is.d.ts +0 -7
  100. package/dist/types-ts4.0/i18n/it.d.ts +0 -33
  101. package/dist/types-ts4.0/i18n/ja.d.ts +0 -33
  102. package/dist/types-ts4.0/i18n/ko.d.ts +0 -33
  103. package/dist/types-ts4.0/i18n/languages.d.ts +0 -27
  104. package/dist/types-ts4.0/i18n/nb.d.ts +0 -33
  105. package/dist/types-ts4.0/i18n/nl.d.ts +0 -33
  106. package/dist/types-ts4.0/i18n/pl.d.ts +0 -33
  107. package/dist/types-ts4.0/i18n/pt_BR.d.ts +0 -33
  108. package/dist/types-ts4.0/i18n/pt_PT.d.ts +0 -15
  109. package/dist/types-ts4.0/i18n/ro.d.ts +0 -7
  110. package/dist/types-ts4.0/i18n/ru.d.ts +0 -33
  111. package/dist/types-ts4.0/i18n/sk.d.ts +0 -15
  112. package/dist/types-ts4.0/i18n/sv.d.ts +0 -33
  113. package/dist/types-ts4.0/i18n/th.d.ts +0 -33
  114. package/dist/types-ts4.0/i18n/tr.d.ts +0 -33
  115. package/dist/types-ts4.0/i18n/uk.d.ts +0 -33
  116. package/dist/types-ts4.0/i18n/vi.d.ts +0 -33
  117. package/dist/types-ts4.0/i18n/zh.d.ts +0 -33
  118. package/dist/types-ts4.0/i18n/zh_TW.d.ts +0 -33
  119. package/dist/types-ts4.0/index.d.ts +0 -7
  120. package/dist/types-ts4.0/types.d.ts +0 -296
  121. package/dist/types-ts4.0/util/i18n-util.d.ts +0 -11
  122. package/dist/types-ts4.0/util/ufoExperiences.d.ts +0 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/user-picker
2
2
 
3
+ ## 9.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8ad846932fc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8ad846932fc) - [ux] Fixes incorrect border colour displayed when hovering a user picker with subtle appearance applied.
8
+
9
+ ## 9.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`faf391ab64a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/faf391ab64a) - Implementing new CustomOption which will allow for a custom avatar
14
+
3
15
  ## 9.5.1
4
16
 
5
17
  ### Patch Changes
@@ -74,9 +74,15 @@ var optionData2Analytics = function optionData2Analytics(option) {
74
74
  sources: option.sources,
75
75
  externalUserType: option.externalUserType
76
76
  });
77
- } else {
78
- return validatedData;
79
77
  }
78
+
79
+ if ((0, _utils.isCustom)(option) && option.analyticsType) {
80
+ return _objectSpread(_objectSpread({}, validatedData), {}, {
81
+ type: option.analyticsType
82
+ });
83
+ }
84
+
85
+ return validatedData;
80
86
  };
81
87
 
82
88
  var buildValueForAnalytics = function buildValueForAnalytics(value) {
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ 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); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || (0, _typeof2.default)(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; }
17
+
18
+ var AsyncCustomOption = /*#__PURE__*/_react.default.lazy(function () {
19
+ return Promise.resolve().then(function () {
20
+ return _interopRequireWildcard(require('./main'));
21
+ }).then(function (module) {
22
+ return {
23
+ default: module.CustomOption
24
+ };
25
+ });
26
+ });
27
+
28
+ var _default = AsyncCustomOption;
29
+ exports.default = _default;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CustomOption = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _colors = require("@atlaskit/theme/colors");
25
+
26
+ var _tokens = require("@atlaskit/tokens");
27
+
28
+ var _core = require("@emotion/core");
29
+
30
+ var _react = _interopRequireDefault(require("react"));
31
+
32
+ var _AvatarItemOption = require("../AvatarItemOption");
33
+
34
+ var _HighlightText = require("../HighlightText");
35
+
36
+ var _SizeableAvatar = require("../SizeableAvatar");
37
+
38
+ 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); }; }
39
+
40
+ 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; } }
41
+
42
+ var CustomOption = /*#__PURE__*/function (_React$PureComponent) {
43
+ (0, _inherits2.default)(CustomOption, _React$PureComponent);
44
+
45
+ var _super = _createSuper(CustomOption);
46
+
47
+ function CustomOption() {
48
+ var _this;
49
+
50
+ (0, _classCallCheck2.default)(this, CustomOption);
51
+
52
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
53
+ args[_key] = arguments[_key];
54
+ }
55
+
56
+ _this = _super.call.apply(_super, [this].concat(args));
57
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getPrimaryText", function () {
58
+ var _this$props$data = _this.props.data,
59
+ name = _this$props$data.name,
60
+ highlight = _this$props$data.highlight;
61
+ return [(0, _core.jsx)("span", {
62
+ key: "name",
63
+ css: (0, _AvatarItemOption.textWrapper)(_this.props.isSelected ? (0, _tokens.token)('color.text.selected', _colors.B400) : (0, _tokens.token)('color.text', _colors.N800))
64
+ }, (0, _core.jsx)(_HighlightText.HighlightText, {
65
+ highlights: highlight && highlight.name
66
+ }, name))];
67
+ });
68
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getBylineComponent", function (isSelected, message) {
69
+ return (0, _core.jsx)("span", {
70
+ css: (0, _AvatarItemOption.textWrapper)(isSelected ? (0, _tokens.token)('color.text.selected', _colors.B400) : (0, _tokens.token)('color.text.subtlest', _colors.N200))
71
+ }, message);
72
+ });
73
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderByline", function () {
74
+ var _this$props$data2;
75
+
76
+ if (!((_this$props$data2 = _this.props.data) !== null && _this$props$data2 !== void 0 && _this$props$data2.byline)) {
77
+ return undefined;
78
+ }
79
+
80
+ return _this.getBylineComponent(_this.props.isSelected, _this.props.data.byline);
81
+ });
82
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderAvatar", function () {
83
+ var _this$props$data3 = _this.props.data,
84
+ avatarUrl = _this$props$data3.avatarUrl,
85
+ name = _this$props$data3.name;
86
+ return (0, _core.jsx)(_SizeableAvatar.SizeableAvatar, {
87
+ appearance: "big",
88
+ src: avatarUrl,
89
+ name: name
90
+ });
91
+ });
92
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getLozengeProps", function () {
93
+ return typeof _this.props.data.lozenge === 'string' ? {
94
+ text: _this.props.data.lozenge
95
+ } : _this.props.data.lozenge;
96
+ });
97
+ return _this;
98
+ }
99
+
100
+ (0, _createClass2.default)(CustomOption, [{
101
+ key: "render",
102
+ value: function render() {
103
+ return (0, _core.jsx)(_AvatarItemOption.AvatarItemOption, {
104
+ avatar: this.renderAvatar(),
105
+ isDisabled: this.props.data.isDisabled,
106
+ lozenge: this.getLozengeProps(),
107
+ primaryText: this.getPrimaryText(),
108
+ secondaryText: this.renderByline()
109
+ });
110
+ }
111
+ }]);
112
+ return CustomOption;
113
+ }(_react.default.PureComponent);
114
+
115
+ exports.CustomOption = CustomOption;
@@ -144,8 +144,8 @@ var MultiValue = /*#__PURE__*/function (_React$Component) {
144
144
  nextLabel = _nextProps$data.label,
145
145
  nextData = _nextProps$data.data,
146
146
  nextInnerProps = nextProps.innerProps,
147
- nextIsFocused = nextProps.isFocused; // We can ignore onRemove here because it is a anonymous function
148
- // that will recreated every time but with the same implementation.
147
+ nextIsFocused = nextProps.isFocused; // We can ignore onRemove here because it is an anonymous function
148
+ // that will be recreated every time but with the same implementation.
149
149
 
150
150
  return data !== nextData || label !== nextLabel || innerProps !== nextInnerProps || isFocused !== nextIsFocused;
151
151
  }
@@ -21,6 +21,8 @@ var _GroupOption = _interopRequireDefault(require("./GroupOption"));
21
21
 
22
22
  var _EmailOption = _interopRequireDefault(require("./EmailOption"));
23
23
 
24
+ var _CustomOption = _interopRequireDefault(require("./CustomOption"));
25
+
24
26
  var _utils = require("./utils");
25
27
 
26
28
  var _emailValidation = require("./emailValidation");
@@ -81,6 +83,13 @@ var dataOption = function dataOption(_ref2) {
81
83
  });
82
84
  }
83
85
 
86
+ if ((0, _utils.isCustom)(data)) {
87
+ return /*#__PURE__*/_react.default.createElement(_CustomOption.default, {
88
+ data: data,
89
+ isSelected: isSelected
90
+ });
91
+ }
92
+
84
93
  return null;
85
94
  };
86
95
 
@@ -57,7 +57,7 @@ var getStyles = (0, _memoizeOne.default)(function (width, isMulti, isCompact, ov
57
57
  opacity: 1
58
58
  },
59
59
  ':hover': _objectSpread(_objectSpread({}, css[':hover']), {}, {
60
- borderColor: state.isFocused ? css[':hover'] ? (0, _tokens.token)('color.border.focused', css[':hover'].borderColor) : (0, _tokens.token)('color.border.focused', _colors.B100) : state.selectProps.subtle ? state.selectProps.hoveringClearIndicator ? (0, _tokens.token)('color.icon.danger', _colors.R50) : (0, _tokens.token)('color.icon', _colors.N30) : (0, _tokens.token)('color.border.input', _colors.N40),
60
+ borderColor: state.isFocused ? css[':hover'] ? (0, _tokens.token)('color.border.focused', css[':hover'].borderColor) : (0, _tokens.token)('color.border.focused', _colors.B100) : state.selectProps.subtle ? 'transparent' : (0, _tokens.token)('color.border.input', _colors.N40),
61
61
  backgroundColor: state.selectProps.subtle && state.selectProps.hoveringClearIndicator ? (0, _tokens.token)('color.background.danger', _colors.R50) : state.isFocused ? css[':hover'] ? (0, _tokens.token)('color.background.input', css[':hover'].backgroundColor) : (0, _tokens.token)('color.background.input', _colors.N0) : state.isDisabled ? (0, _tokens.token)('color.background.disabled', _colors.N10) : (0, _tokens.token)('color.background.input.hovered', _colors.N30)
62
62
  }),
63
63
  padding: 0,
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.optionToSelectableOptions = exports.optionToSelectableOption = exports.isUser = exports.isTeam = exports.isSingleValue = exports.isPopupUserPickerByProps = exports.isPopupUserPickerByComponent = exports.isLozengeText = exports.isIterable = exports.isGroup = exports.isExternalUser = exports.isEmail = exports.isDefaultValuePopulated = exports.isChildInput = exports.hasValue = exports.getOptions = exports.getAvatarUrl = exports.getAvatarSize = exports.extractOptionValue = exports.callCallback = void 0;
8
+ exports.optionToSelectableOptions = exports.optionToSelectableOption = exports.isUser = exports.isTeam = exports.isSingleValue = exports.isPopupUserPickerByProps = exports.isPopupUserPickerByComponent = exports.isLozengeText = exports.isIterable = exports.isGroup = exports.isExternalUser = exports.isEmail = exports.isDefaultValuePopulated = exports.isCustom = exports.isChildInput = exports.hasValue = exports.getOptions = exports.getAvatarUrl = exports.getAvatarSize = exports.extractOptionValue = exports.callCallback = void 0;
9
9
 
10
10
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
11
 
@@ -51,6 +51,12 @@ var isEmail = function isEmail(option) {
51
51
 
52
52
  exports.isEmail = isEmail;
53
53
 
54
+ var isCustom = function isCustom(option) {
55
+ return option.type === _types.CustomType;
56
+ };
57
+
58
+ exports.isCustom = isCustom;
59
+
54
60
  var isDefaultValuePopulated = function isDefaultValuePopulated(value) {
55
61
  return value && !Array.isArray(value) || Array.isArray(value) && value.length > 0;
56
62
  };
@@ -165,7 +171,7 @@ var callCallback = function callCallback(callback) {
165
171
  exports.callCallback = callCallback;
166
172
 
167
173
  var getAvatarUrl = function getAvatarUrl(optionData) {
168
- if (isUser(optionData) || isTeam(optionData)) {
174
+ if (isUser(optionData) || isTeam(optionData) || isCustom(optionData)) {
169
175
  return optionData.avatarUrl;
170
176
  }
171
177
 
package/dist/cjs/index.js CHANGED
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "CustomType", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _types.CustomType;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "EmailType", {
7
13
  enumerable: true,
8
14
  get: function get() {
package/dist/cjs/types.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.UserType = exports.TeamType = exports.GroupType = exports.EmailType = void 0;
6
+ exports.UserType = exports.TeamType = exports.GroupType = exports.EmailType = exports.CustomType = void 0;
7
7
  var UserType = 'user';
8
8
  exports.UserType = UserType;
9
9
  var TeamType = 'team';
@@ -11,4 +11,6 @@ exports.TeamType = TeamType;
11
11
  var GroupType = 'group';
12
12
  exports.GroupType = GroupType;
13
13
  var EmailType = 'email';
14
- exports.EmailType = EmailType;
14
+ exports.EmailType = EmailType;
15
+ var CustomType = 'custom';
16
+ exports.CustomType = CustomType;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/user-picker",
3
- "version": "9.5.1",
3
+ "version": "9.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import { createAndFireEvent } from '@atlaskit/analytics-next';
2
2
  import { v4 as uuidv4 } from 'uuid';
3
3
  import versionJson from './version.json';
4
- import { isExternalUser } from './components/utils';
4
+ import { isCustom, isExternalUser } from './components/utils';
5
5
  const packageName = versionJson.name;
6
6
  const packageVersion = versionJson.version;
7
7
  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}$/;
@@ -49,9 +49,15 @@ const optionData2Analytics = option => {
49
49
  sources: option.sources,
50
50
  externalUserType: option.externalUserType
51
51
  };
52
- } else {
53
- return validatedData;
54
52
  }
53
+
54
+ if (isCustom(option) && option.analyticsType) {
55
+ return { ...validatedData,
56
+ type: option.analyticsType
57
+ };
58
+ }
59
+
60
+ return validatedData;
55
61
  };
56
62
 
57
63
  const buildValueForAnalytics = value => {
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ const AsyncCustomOption = /*#__PURE__*/React.lazy(() => import(
3
+ /* webpackChunkName: "@atlaskit-internal_@atlassian/user-picker/custom-option" */
4
+ './main').then(module => {
5
+ return {
6
+ default: module.CustomOption
7
+ };
8
+ }));
9
+ export default AsyncCustomOption;
@@ -0,0 +1,73 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ /** @jsx jsx */
4
+ import { B400, N800, N200 } from '@atlaskit/theme/colors';
5
+ import { token } from '@atlaskit/tokens';
6
+ import { jsx } from '@emotion/core';
7
+ import React from 'react';
8
+ import { AvatarItemOption, textWrapper } from '../AvatarItemOption';
9
+ import { HighlightText } from '../HighlightText';
10
+ import { SizeableAvatar } from '../SizeableAvatar';
11
+ export class CustomOption extends React.PureComponent {
12
+ constructor(...args) {
13
+ super(...args);
14
+
15
+ _defineProperty(this, "getPrimaryText", () => {
16
+ const {
17
+ data: {
18
+ name,
19
+ highlight
20
+ }
21
+ } = this.props;
22
+ return [jsx("span", {
23
+ key: "name",
24
+ css: textWrapper(this.props.isSelected ? token('color.text.selected', B400) : token('color.text', N800))
25
+ }, jsx(HighlightText, {
26
+ highlights: highlight && highlight.name
27
+ }, name))];
28
+ });
29
+
30
+ _defineProperty(this, "getBylineComponent", (isSelected, message) => jsx("span", {
31
+ css: textWrapper(isSelected ? token('color.text.selected', B400) : token('color.text.subtlest', N200))
32
+ }, message));
33
+
34
+ _defineProperty(this, "renderByline", () => {
35
+ var _this$props$data;
36
+
37
+ if (!((_this$props$data = this.props.data) !== null && _this$props$data !== void 0 && _this$props$data.byline)) {
38
+ return undefined;
39
+ }
40
+
41
+ return this.getBylineComponent(this.props.isSelected, this.props.data.byline);
42
+ });
43
+
44
+ _defineProperty(this, "renderAvatar", () => {
45
+ const {
46
+ data: {
47
+ avatarUrl,
48
+ name
49
+ }
50
+ } = this.props;
51
+ return jsx(SizeableAvatar, {
52
+ appearance: "big",
53
+ src: avatarUrl,
54
+ name: name
55
+ });
56
+ });
57
+
58
+ _defineProperty(this, "getLozengeProps", () => typeof this.props.data.lozenge === 'string' ? {
59
+ text: this.props.data.lozenge
60
+ } : this.props.data.lozenge);
61
+ }
62
+
63
+ render() {
64
+ return jsx(AvatarItemOption, {
65
+ avatar: this.renderAvatar(),
66
+ isDisabled: this.props.data.isDisabled,
67
+ lozenge: this.getLozengeProps(),
68
+ primaryText: this.getPrimaryText(),
69
+ secondaryText: this.renderByline()
70
+ });
71
+ }
72
+
73
+ }
@@ -102,8 +102,8 @@ export class MultiValue extends React.Component {
102
102
  },
103
103
  innerProps: nextInnerProps,
104
104
  isFocused: nextIsFocused
105
- } = nextProps; // We can ignore onRemove here because it is a anonymous function
106
- // that will recreated every time but with the same implementation.
105
+ } = nextProps; // We can ignore onRemove here because it is an anonymous function
106
+ // that will be recreated every time but with the same implementation.
107
107
 
108
108
  return data !== nextData || label !== nextLabel || innerProps !== nextInnerProps || isFocused !== nextIsFocused;
109
109
  }
@@ -5,7 +5,8 @@ import AsyncExternalOption from './ExternalUserOption';
5
5
  import AsyncTeamOption from './TeamOption';
6
6
  import AsyncGroupOption from './GroupOption';
7
7
  import AsyncEmailOption from './EmailOption';
8
- import { isEmail, isTeam, isUser, isGroup, isExternalUser } from './utils';
8
+ import AsyncCustomOption from './CustomOption';
9
+ import { isCustom, isEmail, isTeam, isUser, isGroup, isExternalUser } from './utils';
9
10
  import { isValidEmail } from './emailValidation';
10
11
 
11
12
  const defaultOption = ({
@@ -67,6 +68,13 @@ const dataOption = ({
67
68
  });
68
69
  }
69
70
 
71
+ if (isCustom(data)) {
72
+ return /*#__PURE__*/React.createElement(AsyncCustomOption, {
73
+ data: data,
74
+ isSelected: isSelected
75
+ });
76
+ }
77
+
70
78
  return null;
71
79
  };
72
80
 
@@ -25,7 +25,7 @@ export const getStyles = memoizeOne((width, isMulti, isCompact, overrideStyles)
25
25
  opacity: 1
26
26
  },
27
27
  ':hover': { ...css[':hover'],
28
- borderColor: state.isFocused ? css[':hover'] ? token('color.border.focused', css[':hover'].borderColor) : token('color.border.focused', B100) : state.selectProps.subtle ? state.selectProps.hoveringClearIndicator ? token('color.icon.danger', R50) : token('color.icon', N30) : token('color.border.input', N40),
28
+ borderColor: state.isFocused ? css[':hover'] ? token('color.border.focused', css[':hover'].borderColor) : token('color.border.focused', B100) : state.selectProps.subtle ? 'transparent' : token('color.border.input', N40),
29
29
  backgroundColor: state.selectProps.subtle && state.selectProps.hoveringClearIndicator ? token('color.background.danger', R50) : state.isFocused ? css[':hover'] ? token('color.background.input', css[':hover'].backgroundColor) : token('color.background.input', N0) : state.isDisabled ? token('color.background.disabled', N10) : token('color.background.input.hovered', N30)
30
30
  },
31
31
  padding: 0,
@@ -1,11 +1,12 @@
1
1
  import memoizeOne from 'memoize-one';
2
- import { EmailType, TeamType, GroupType, UserType } from '../types';
2
+ import { CustomType, EmailType, TeamType, GroupType, UserType } from '../types';
3
3
  import { PopupSelect } from '@atlaskit/select';
4
4
  export const isExternalUser = option => isUser(option) && Boolean(option.isExternal);
5
5
  export const isUser = option => option.type === undefined || option.type === UserType;
6
6
  export const isTeam = option => option.type === TeamType;
7
7
  export const isGroup = option => option.type === GroupType;
8
8
  export const isEmail = option => option.type === EmailType;
9
+ export const isCustom = option => option.type === CustomType;
9
10
  export const isDefaultValuePopulated = value => value && !Array.isArray(value) || Array.isArray(value) && value.length > 0;
10
11
 
11
12
  const isOptionData = option => option.name !== undefined;
@@ -71,7 +72,7 @@ export const callCallback = (callback, ...args) => {
71
72
  }
72
73
  };
73
74
  export const getAvatarUrl = optionData => {
74
- if (isUser(optionData) || isTeam(optionData)) {
75
+ if (isUser(optionData) || isTeam(optionData) || isCustom(optionData)) {
75
76
  return optionData.avatarUrl;
76
77
  }
77
78
 
@@ -3,4 +3,4 @@ export { UserPicker as default } from './components/UserPicker';
3
3
  export { PopupUserPicker } from './components/PopupUserPicker';
4
4
  export { isEmail, isExternalUser, isTeam, isUser } from './components/utils';
5
5
  export { // Constants
6
- EmailType, GroupType, TeamType, UserType } from './types';
6
+ CustomType, EmailType, GroupType, TeamType, UserType } from './types';
@@ -1,4 +1,5 @@
1
1
  export const UserType = 'user';
2
2
  export const TeamType = 'team';
3
3
  export const GroupType = 'group';
4
- export const EmailType = 'email';
4
+ export const EmailType = 'email';
5
+ export const CustomType = 'custom';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/user-picker",
3
- "version": "9.5.1",
3
+ "version": "9.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -7,7 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
  import { createAndFireEvent } from '@atlaskit/analytics-next';
8
8
  import { v4 as uuidv4 } from 'uuid';
9
9
  import versionJson from './version.json';
10
- import { isExternalUser } from './components/utils';
10
+ import { isCustom, isExternalUser } from './components/utils';
11
11
  var packageName = versionJson.name;
12
12
  var packageVersion = versionJson.version;
13
13
  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}$/;
@@ -57,9 +57,15 @@ var optionData2Analytics = function optionData2Analytics(option) {
57
57
  sources: option.sources,
58
58
  externalUserType: option.externalUserType
59
59
  });
60
- } else {
61
- return validatedData;
62
60
  }
61
+
62
+ if (isCustom(option) && option.analyticsType) {
63
+ return _objectSpread(_objectSpread({}, validatedData), {}, {
64
+ type: option.analyticsType
65
+ });
66
+ }
67
+
68
+ return validatedData;
63
69
  };
64
70
 
65
71
  var buildValueForAnalytics = function buildValueForAnalytics(value) {
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ var AsyncCustomOption = /*#__PURE__*/React.lazy(function () {
3
+ return import(
4
+ /* webpackChunkName: "@atlaskit-internal_@atlassian/user-picker/custom-option" */
5
+ './main').then(function (module) {
6
+ return {
7
+ default: module.CustomOption
8
+ };
9
+ });
10
+ });
11
+ export default AsyncCustomOption;
@@ -0,0 +1,99 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+
9
+ 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); }; }
10
+
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
+
13
+ /** @jsx jsx */
14
+ import { B400, N800, N200 } from '@atlaskit/theme/colors';
15
+ import { token } from '@atlaskit/tokens';
16
+ import { jsx } from '@emotion/core';
17
+ import React from 'react';
18
+ import { AvatarItemOption, textWrapper } from '../AvatarItemOption';
19
+ import { HighlightText } from '../HighlightText';
20
+ import { SizeableAvatar } from '../SizeableAvatar';
21
+ export var CustomOption = /*#__PURE__*/function (_React$PureComponent) {
22
+ _inherits(CustomOption, _React$PureComponent);
23
+
24
+ var _super = _createSuper(CustomOption);
25
+
26
+ function CustomOption() {
27
+ var _this;
28
+
29
+ _classCallCheck(this, CustomOption);
30
+
31
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32
+ args[_key] = arguments[_key];
33
+ }
34
+
35
+ _this = _super.call.apply(_super, [this].concat(args));
36
+
37
+ _defineProperty(_assertThisInitialized(_this), "getPrimaryText", function () {
38
+ var _this$props$data = _this.props.data,
39
+ name = _this$props$data.name,
40
+ highlight = _this$props$data.highlight;
41
+ return [jsx("span", {
42
+ key: "name",
43
+ css: textWrapper(_this.props.isSelected ? token('color.text.selected', B400) : token('color.text', N800))
44
+ }, jsx(HighlightText, {
45
+ highlights: highlight && highlight.name
46
+ }, name))];
47
+ });
48
+
49
+ _defineProperty(_assertThisInitialized(_this), "getBylineComponent", function (isSelected, message) {
50
+ return jsx("span", {
51
+ css: textWrapper(isSelected ? token('color.text.selected', B400) : token('color.text.subtlest', N200))
52
+ }, message);
53
+ });
54
+
55
+ _defineProperty(_assertThisInitialized(_this), "renderByline", function () {
56
+ var _this$props$data2;
57
+
58
+ if (!((_this$props$data2 = _this.props.data) !== null && _this$props$data2 !== void 0 && _this$props$data2.byline)) {
59
+ return undefined;
60
+ }
61
+
62
+ return _this.getBylineComponent(_this.props.isSelected, _this.props.data.byline);
63
+ });
64
+
65
+ _defineProperty(_assertThisInitialized(_this), "renderAvatar", function () {
66
+ var _this$props$data3 = _this.props.data,
67
+ avatarUrl = _this$props$data3.avatarUrl,
68
+ name = _this$props$data3.name;
69
+ return jsx(SizeableAvatar, {
70
+ appearance: "big",
71
+ src: avatarUrl,
72
+ name: name
73
+ });
74
+ });
75
+
76
+ _defineProperty(_assertThisInitialized(_this), "getLozengeProps", function () {
77
+ return typeof _this.props.data.lozenge === 'string' ? {
78
+ text: _this.props.data.lozenge
79
+ } : _this.props.data.lozenge;
80
+ });
81
+
82
+ return _this;
83
+ }
84
+
85
+ _createClass(CustomOption, [{
86
+ key: "render",
87
+ value: function render() {
88
+ return jsx(AvatarItemOption, {
89
+ avatar: this.renderAvatar(),
90
+ isDisabled: this.props.data.isDisabled,
91
+ lozenge: this.getLozengeProps(),
92
+ primaryText: this.getPrimaryText(),
93
+ secondaryText: this.renderByline()
94
+ });
95
+ }
96
+ }]);
97
+
98
+ return CustomOption;
99
+ }(React.PureComponent);
@@ -118,8 +118,8 @@ export var MultiValue = /*#__PURE__*/function (_React$Component) {
118
118
  nextLabel = _nextProps$data.label,
119
119
  nextData = _nextProps$data.data,
120
120
  nextInnerProps = nextProps.innerProps,
121
- nextIsFocused = nextProps.isFocused; // We can ignore onRemove here because it is a anonymous function
122
- // that will recreated every time but with the same implementation.
121
+ nextIsFocused = nextProps.isFocused; // We can ignore onRemove here because it is an anonymous function
122
+ // that will be recreated every time but with the same implementation.
123
123
 
124
124
  return data !== nextData || label !== nextLabel || innerProps !== nextInnerProps || isFocused !== nextIsFocused;
125
125
  }