@atlaskit/user-picker 9.5.1 → 9.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +6 -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/utils.js +8 -2
  8. package/dist/cjs/index.js +6 -0
  9. package/dist/cjs/types.js +4 -2
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/analytics.js +9 -3
  12. package/dist/es2019/components/CustomOption/index.js +9 -0
  13. package/dist/es2019/components/CustomOption/main.js +73 -0
  14. package/dist/es2019/components/MultiValue.js +2 -2
  15. package/dist/es2019/components/Option.js +9 -1
  16. package/dist/es2019/components/utils.js +3 -2
  17. package/dist/es2019/index.js +1 -1
  18. package/dist/es2019/types.js +2 -1
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/analytics.js +9 -3
  21. package/dist/esm/components/CustomOption/index.js +11 -0
  22. package/dist/esm/components/CustomOption/main.js +99 -0
  23. package/dist/esm/components/MultiValue.js +2 -2
  24. package/dist/esm/components/Option.js +9 -1
  25. package/dist/esm/components/utils.js +5 -2
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/types.js +2 -1
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/components/BaseUserPicker.d.ts +1 -1
  30. package/dist/types/components/CustomOption/index.d.ts +3 -0
  31. package/dist/types/components/CustomOption/main.d.ts +14 -0
  32. package/dist/types/components/PopupUserPicker.d.ts +1 -1
  33. package/dist/types/components/UserPicker.d.ts +1 -1
  34. package/dist/types/components/utils.d.ts +2 -1
  35. package/dist/types/index.d.ts +2 -2
  36. package/dist/types/types.d.ts +12 -1
  37. package/dist/types-ts4.0/components/BaseUserPicker.d.ts +1 -1
  38. package/dist/types-ts4.0/components/CustomOption/index.d.ts +3 -0
  39. package/dist/types-ts4.0/components/CustomOption/main.d.ts +14 -0
  40. package/dist/types-ts4.0/components/PopupUserPicker.d.ts +1 -1
  41. package/dist/types-ts4.0/components/UserPicker.d.ts +1 -1
  42. package/dist/types-ts4.0/components/utils.d.ts +2 -1
  43. package/dist/types-ts4.0/index.d.ts +2 -2
  44. package/dist/types-ts4.0/types.d.ts +12 -1
  45. package/package.json +6 -6
  46. package/report.api.md +24 -1
  47. package/tmp/api-report-tmp.d.ts +24 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/user-picker
2
2
 
3
+ ## 9.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`faf391ab64a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/faf391ab64a) - Implementing new CustomOption which will allow for a custom avatar
8
+
3
9
  ## 9.5.1
4
10
 
5
11
  ### 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
 
@@ -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.0",
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
 
@@ -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.0",
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
  }
@@ -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
  var defaultOption = function defaultOption(_ref) {
@@ -64,6 +65,13 @@ var dataOption = function dataOption(_ref2) {
64
65
  });
65
66
  }
66
67
 
68
+ if (isCustom(data)) {
69
+ return /*#__PURE__*/React.createElement(AsyncCustomOption, {
70
+ data: data,
71
+ isSelected: isSelected
72
+ });
73
+ }
74
+
67
75
  return null;
68
76
  };
69
77
 
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
 
8
8
  import memoizeOne from 'memoize-one';
9
- import { EmailType, TeamType, GroupType, UserType } from '../types';
9
+ import { CustomType, EmailType, TeamType, GroupType, UserType } from '../types';
10
10
  import { PopupSelect } from '@atlaskit/select';
11
11
  export var isExternalUser = function isExternalUser(option) {
12
12
  return isUser(option) && Boolean(option.isExternal);
@@ -23,6 +23,9 @@ export var isGroup = function isGroup(option) {
23
23
  export var isEmail = function isEmail(option) {
24
24
  return option.type === EmailType;
25
25
  };
26
+ export var isCustom = function isCustom(option) {
27
+ return option.type === CustomType;
28
+ };
26
29
  export var isDefaultValuePopulated = function isDefaultValuePopulated(value) {
27
30
  return value && !Array.isArray(value) || Array.isArray(value) && value.length > 0;
28
31
  };
@@ -109,7 +112,7 @@ export var callCallback = function callCallback(callback) {
109
112
  }
110
113
  };
111
114
  export var getAvatarUrl = function getAvatarUrl(optionData) {
112
- if (isUser(optionData) || isTeam(optionData)) {
115
+ if (isUser(optionData) || isTeam(optionData) || isCustom(optionData)) {
113
116
  return optionData.avatarUrl;
114
117
  }
115
118
 
package/dist/esm/index.js CHANGED
@@ -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';
package/dist/esm/types.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export var UserType = 'user';
2
2
  export var TeamType = 'team';
3
3
  export var GroupType = 'group';
4
- export var EmailType = 'email';
4
+ export var EmailType = 'email';
5
+ export var CustomType = 'custom';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/user-picker",
3
- "version": "9.5.1",
3
+ "version": "9.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -51,7 +51,7 @@ export declare class BaseUserPickerWithoutAnalytics extends React.Component<Base
51
51
  private getAppearance;
52
52
  render(): JSX.Element;
53
53
  }
54
- export declare const BaseUserPicker: React.ForwardRefExoticComponent<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "components" | "inputId" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "options" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "width" | "menuMinWidth" | "maxPickerHeight" | "loadOptions" | "loadUserSource" | "search" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive" | "SelectComponent" | "pickerProps"> & Partial<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isClearable" | "isMulti" | "textFieldBackgroundColor" | "subtle" | "noBorder">> & Partial<Pick<{
54
+ export declare const BaseUserPicker: React.ForwardRefExoticComponent<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "components" | "inputId" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "width" | "menuMinWidth" | "maxPickerHeight" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive" | "SelectComponent" | "pickerProps"> & Partial<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isClearable" | "isMulti" | "textFieldBackgroundColor" | "subtle" | "noBorder">> & Partial<Pick<{
55
55
  isMulti: boolean;
56
56
  subtle: boolean;
57
57
  noBorder: boolean;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const AsyncCustomOption: React.LazyExoticComponent<typeof import("./main").CustomOption>;
3
+ export default AsyncCustomOption;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Custom } from '../../types';
3
+ export declare type CustomOptionProps = {
4
+ data: Custom;
5
+ isSelected: boolean;
6
+ };
7
+ export declare class CustomOption extends React.PureComponent<CustomOptionProps> {
8
+ private getPrimaryText;
9
+ private getBylineComponent;
10
+ private renderByline;
11
+ private renderAvatar;
12
+ private getLozengeProps;
13
+ render(): JSX.Element;
14
+ }
@@ -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>, "isDisabled" | "target" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "options" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadUserSource" | "search" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive" | "popupTitle"> & Partial<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "offset" | "isMulti" | "width" | "rootBoundary" | "boundariesElement" | "placement" | "shouldFlip">> & Partial<Pick<{
30
+ export declare const PopupUserPicker: React.ForwardRefExoticComponent<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "isDisabled" | "target" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive" | "popupTitle"> & Partial<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "offset" | "isMulti" | "width" | "rootBoundary" | "boundariesElement" | "placement" | "shouldFlip">> & Partial<Pick<{
31
31
  boundariesElement: string;
32
32
  width: number;
33
33
  isMulti: boolean;
@@ -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>, "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "options" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadUserSource" | "search" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive"> & 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" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive"> & 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>>;
@@ -1,10 +1,11 @@
1
1
  import { ReactChild, ReactElement, ReactNode } from 'react';
2
- import { AtlaskitSelectValue, ExternalUser, Email, Option, OptionData, Promisable, Team, Group, User, OptionIdentifier, DefaultValue, LozengeProps } from '../types';
2
+ import { AtlaskitSelectValue, ExternalUser, Custom, Email, Option, OptionData, Promisable, Team, Group, User, OptionIdentifier, DefaultValue, LozengeProps } from '../types';
3
3
  export declare const isExternalUser: (option: OptionData) => option is ExternalUser;
4
4
  export declare const isUser: (option: OptionData) => option is User;
5
5
  export declare const isTeam: (option: OptionData) => option is Team;
6
6
  export declare const isGroup: (option: OptionData) => option is Group;
7
7
  export declare const isEmail: (option: OptionData) => option is Email;
8
+ export declare const isCustom: (option: OptionData) => option is Custom;
8
9
  export declare const isDefaultValuePopulated: (value?: DefaultValue) => boolean;
9
10
  export declare const optionToSelectableOption: (option: OptionData | OptionIdentifier) => Option;
10
11
  export declare const extractOptionValue: (value: AtlaskitSelectValue) => OptionData | OptionData[] | undefined;
@@ -3,5 +3,5 @@ export type { EmailValidationResponse, EmailValidator, } from './components/emai
3
3
  export { UserPicker as default } from './components/UserPicker';
4
4
  export { PopupUserPicker } from './components/PopupUserPicker';
5
5
  export { isEmail, isExternalUser, isTeam, isUser } from './components/utils';
6
- export { EmailType, GroupType, TeamType, UserType, } from './types';
7
- export type { ActionTypes, Appearance, AtlasKitSelectChange, AtlaskitSelectValue, DefaultValue, InputActionTypes, LozengeProps, OnChange, OnInputChange, OnOption, OnPicker, Option, OptionData, OptionIdentifier, PopupUserPickerProps, Promisable, Target, UserPickerProps, UserPickerState, Value, Email, Group, GroupHighlight, HighlightRange, LoadOptions, Team, TeamMember, TeamHighlight, User, UserHighlight, ExternalUser, UserSource, } from './types';
6
+ export { CustomType, EmailType, GroupType, TeamType, UserType, } from './types';
7
+ export type { ActionTypes, Appearance, AtlasKitSelectChange, AtlaskitSelectValue, DefaultValue, InputActionTypes, LozengeProps, OnChange, OnInputChange, OnOption, OnPicker, Option, OptionData, OptionIdentifier, PopupUserPickerProps, Promisable, Target, UserPickerProps, UserPickerState, Value, Custom, Email, Group, GroupHighlight, HighlightRange, LoadOptions, Team, TeamMember, TeamHighlight, User, UserHighlight, ExternalUser, UserSource, } from './types';
@@ -197,6 +197,9 @@ export interface TeamHighlight {
197
197
  export interface GroupHighlight {
198
198
  name: HighlightRange[];
199
199
  }
200
+ export interface CustomHighlight {
201
+ name: HighlightRange[];
202
+ }
200
203
  export interface OptionData {
201
204
  avatarUrl?: any;
202
205
  fixed?: boolean;
@@ -204,7 +207,7 @@ export interface OptionData {
204
207
  isDisabled?: boolean;
205
208
  lozenge?: string | LozengeProps | ReactNode;
206
209
  name: string;
207
- type?: 'user' | 'team' | 'email' | 'group';
210
+ type?: 'user' | 'team' | 'email' | 'group' | 'custom';
208
211
  }
209
212
  export declare const UserType = "user";
210
213
  export declare type UserSource = 'google' | 'slack' | 'microsoft' | 'github' | 'jira' | 'confluence' | 'other-atlassian';
@@ -249,10 +252,18 @@ export interface Group extends OptionData {
249
252
  highlight?: GroupHighlight;
250
253
  type: 'group';
251
254
  }
255
+ export interface Custom extends OptionData {
256
+ avatarUrl?: string;
257
+ byline?: string;
258
+ highlight?: CustomHighlight;
259
+ analyticsType?: string;
260
+ type: 'custom';
261
+ }
252
262
  export declare type Value = OptionData | OptionData[] | null | undefined;
253
263
  export declare type DefaultValue = Value | OptionIdentifier | OptionIdentifier[];
254
264
  export declare type OptionIdentifier = Pick<OptionData, 'id' | 'type' | 'isDisabled'>;
255
265
  export declare const EmailType = "email";
266
+ export declare const CustomType = "custom";
256
267
  export interface Email extends OptionData {
257
268
  type: 'email';
258
269
  suggestion?: boolean;
@@ -51,7 +51,7 @@ export declare class BaseUserPickerWithoutAnalytics extends React.Component<Base
51
51
  private getAppearance;
52
52
  render(): JSX.Element;
53
53
  }
54
- export declare const BaseUserPicker: React.ForwardRefExoticComponent<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "components" | "inputId" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "options" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "width" | "menuMinWidth" | "maxPickerHeight" | "loadOptions" | "loadUserSource" | "search" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive" | "SelectComponent" | "pickerProps"> & Partial<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isClearable" | "isMulti" | "textFieldBackgroundColor" | "subtle" | "noBorder">> & Partial<Pick<{
54
+ export declare const BaseUserPicker: React.ForwardRefExoticComponent<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "components" | "inputId" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "width" | "menuMinWidth" | "maxPickerHeight" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive" | "SelectComponent" | "pickerProps"> & Partial<Pick<Omit<BaseUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "isClearable" | "isMulti" | "textFieldBackgroundColor" | "subtle" | "noBorder">> & Partial<Pick<{
55
55
  isMulti: boolean;
56
56
  subtle: boolean;
57
57
  noBorder: boolean;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const AsyncCustomOption: React.LazyExoticComponent<typeof import("./main").CustomOption>;
3
+ export default AsyncCustomOption;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Custom } from '../../types';
3
+ export declare type CustomOptionProps = {
4
+ data: Custom;
5
+ isSelected: boolean;
6
+ };
7
+ export declare class CustomOption extends React.PureComponent<CustomOptionProps> {
8
+ private getPrimaryText;
9
+ private getBylineComponent;
10
+ private renderByline;
11
+ private renderAvatar;
12
+ private getLozengeProps;
13
+ render(): JSX.Element;
14
+ }
@@ -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>, "isDisabled" | "target" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "options" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadUserSource" | "search" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive" | "popupTitle"> & Partial<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "offset" | "isMulti" | "width" | "rootBoundary" | "boundariesElement" | "placement" | "shouldFlip">> & Partial<Pick<{
30
+ export declare const PopupUserPicker: React.ForwardRefExoticComponent<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "options" | "search" | "isDisabled" | "target" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive" | "popupTitle"> & Partial<Pick<Omit<PopupUserPickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "offset" | "isMulti" | "width" | "rootBoundary" | "boundariesElement" | "placement" | "shouldFlip">> & Partial<Pick<{
31
31
  boundariesElement: string;
32
32
  width: number;
33
33
  isMulti: boolean;
@@ -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>, "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "options" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadUserSource" | "search" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive"> & 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" | "isDisabled" | "autoFocus" | "captureMenuScroll" | "closeMenuOnScroll" | "inputId" | "isClearable" | "isLoading" | "menuPosition" | "menuPortalTarget" | "menuShouldBlockScroll" | "noOptionsMessage" | "onBlur" | "onChange" | "onFocus" | "onInputChange" | "placeholder" | "styles" | "value" | "defaultValue" | "fieldId" | "menuMinWidth" | "maxPickerHeight" | "textFieldBackgroundColor" | "loadOptions" | "loadUserSource" | "anchor" | "open" | "onSelection" | "onClear" | "onClose" | "appearance" | "subtle" | "noBorder" | "addMoreMessage" | "clearValueLabel" | "allowEmail" | "suggestEmailsForDomain" | "emailLabel" | "disableInput" | "isValidEmail" | "maxOptions" | "ariaLabelledBy" | "ariaLive"> & 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>>;
@@ -1,10 +1,11 @@
1
1
  import { ReactChild, ReactElement, ReactNode } from 'react';
2
- import { AtlaskitSelectValue, ExternalUser, Email, Option, OptionData, Promisable, Team, Group, User, OptionIdentifier, DefaultValue, LozengeProps } from '../types';
2
+ import { AtlaskitSelectValue, ExternalUser, Custom, Email, Option, OptionData, Promisable, Team, Group, User, OptionIdentifier, DefaultValue, LozengeProps } from '../types';
3
3
  export declare const isExternalUser: (option: OptionData) => option is ExternalUser;
4
4
  export declare const isUser: (option: OptionData) => option is User;
5
5
  export declare const isTeam: (option: OptionData) => option is Team;
6
6
  export declare const isGroup: (option: OptionData) => option is Group;
7
7
  export declare const isEmail: (option: OptionData) => option is Email;
8
+ export declare const isCustom: (option: OptionData) => option is Custom;
8
9
  export declare const isDefaultValuePopulated: (value?: DefaultValue) => boolean;
9
10
  export declare const optionToSelectableOption: (option: OptionData | OptionIdentifier) => Option;
10
11
  export declare const extractOptionValue: (value: AtlaskitSelectValue) => OptionData | OptionData[] | undefined;
@@ -3,5 +3,5 @@ export type { EmailValidationResponse, EmailValidator, } from './components/emai
3
3
  export { UserPicker as default } from './components/UserPicker';
4
4
  export { PopupUserPicker } from './components/PopupUserPicker';
5
5
  export { isEmail, isExternalUser, isTeam, isUser } from './components/utils';
6
- export { EmailType, GroupType, TeamType, UserType, } from './types';
7
- export type { ActionTypes, Appearance, AtlasKitSelectChange, AtlaskitSelectValue, DefaultValue, InputActionTypes, LozengeProps, OnChange, OnInputChange, OnOption, OnPicker, Option, OptionData, OptionIdentifier, PopupUserPickerProps, Promisable, Target, UserPickerProps, UserPickerState, Value, Email, Group, GroupHighlight, HighlightRange, LoadOptions, Team, TeamMember, TeamHighlight, User, UserHighlight, ExternalUser, UserSource, } from './types';
6
+ export { CustomType, EmailType, GroupType, TeamType, UserType, } from './types';
7
+ export type { ActionTypes, Appearance, AtlasKitSelectChange, AtlaskitSelectValue, DefaultValue, InputActionTypes, LozengeProps, OnChange, OnInputChange, OnOption, OnPicker, Option, OptionData, OptionIdentifier, PopupUserPickerProps, Promisable, Target, UserPickerProps, UserPickerState, Value, Custom, Email, Group, GroupHighlight, HighlightRange, LoadOptions, Team, TeamMember, TeamHighlight, User, UserHighlight, ExternalUser, UserSource, } from './types';
@@ -200,6 +200,9 @@ export interface TeamHighlight {
200
200
  export interface GroupHighlight {
201
201
  name: HighlightRange[];
202
202
  }
203
+ export interface CustomHighlight {
204
+ name: HighlightRange[];
205
+ }
203
206
  export interface OptionData {
204
207
  avatarUrl?: any;
205
208
  fixed?: boolean;
@@ -207,7 +210,7 @@ export interface OptionData {
207
210
  isDisabled?: boolean;
208
211
  lozenge?: string | LozengeProps | ReactNode;
209
212
  name: string;
210
- type?: 'user' | 'team' | 'email' | 'group';
213
+ type?: 'user' | 'team' | 'email' | 'group' | 'custom';
211
214
  }
212
215
  export declare const UserType = "user";
213
216
  export declare type UserSource = 'google' | 'slack' | 'microsoft' | 'github' | 'jira' | 'confluence' | 'other-atlassian';
@@ -252,10 +255,18 @@ export interface Group extends OptionData {
252
255
  highlight?: GroupHighlight;
253
256
  type: 'group';
254
257
  }
258
+ export interface Custom extends OptionData {
259
+ avatarUrl?: string;
260
+ byline?: string;
261
+ highlight?: CustomHighlight;
262
+ analyticsType?: string;
263
+ type: 'custom';
264
+ }
255
265
  export declare type Value = OptionData | OptionData[] | null | undefined;
256
266
  export declare type DefaultValue = Value | OptionIdentifier | OptionIdentifier[];
257
267
  export declare type OptionIdentifier = Pick<OptionData, 'id' | 'type' | 'isDisabled'>;
258
268
  export declare const EmailType = "email";
269
+ export declare const CustomType = "custom";
259
270
  export interface Email extends OptionData {
260
271
  type: 'email';
261
272
  suggestion?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/user-picker",
3
- "version": "9.5.1",
3
+ "version": "9.6.0",
4
4
  "description": "Fabric component for display a dropdown to select a user from",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -38,10 +38,10 @@
38
38
  "@atlaskit/avatar": "^21.1.0",
39
39
  "@atlaskit/icon": "^21.11.0",
40
40
  "@atlaskit/logo": "^13.10.0",
41
- "@atlaskit/lozenge": "^11.2.0",
41
+ "@atlaskit/lozenge": "^11.3.0",
42
42
  "@atlaskit/popper": "^5.0.0",
43
43
  "@atlaskit/select": "^15.7.0",
44
- "@atlaskit/spinner": "^15.1.4",
44
+ "@atlaskit/spinner": "^15.2.0",
45
45
  "@atlaskit/theme": "^12.2.0",
46
46
  "@atlaskit/tokens": "^0.10.19",
47
47
  "@atlaskit/tooltip": "^17.6.0",
@@ -59,15 +59,15 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@atlaskit/analytics-viewer": "^0.4.0",
62
- "@atlaskit/button": "^16.3.0",
62
+ "@atlaskit/button": "^16.4.0",
63
63
  "@atlaskit/docs": "*",
64
64
  "@atlaskit/elements-test-helpers": "^0.7.0",
65
65
  "@atlaskit/modal-dialog": "^12.4.0",
66
66
  "@atlaskit/radio": "^5.4.0",
67
- "@atlaskit/range": "^6.1.0",
67
+ "@atlaskit/range": "^7.0.0",
68
68
  "@atlaskit/section-message": "^6.3.0",
69
69
  "@atlaskit/textfield": "^5.3.0",
70
- "@atlaskit/util-data-test": "^17.5.0",
70
+ "@atlaskit/util-data-test": "^17.6.0",
71
71
  "@atlaskit/visual-regression": "*",
72
72
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
73
73
  "@emotion/styled": "^10.0.7",
package/report.api.md CHANGED
@@ -49,6 +49,29 @@ export type AtlaskitSelectValue = Array<Option_2> | Option_2 | null | undefined;
49
49
  // @public (undocumented)
50
50
  type BoundariesElement = 'scrollParent' | 'viewport' | 'window' | HTMLElement;
51
51
 
52
+ // @public (undocumented)
53
+ export interface Custom extends OptionData {
54
+ // (undocumented)
55
+ analyticsType?: string;
56
+ // (undocumented)
57
+ avatarUrl?: string;
58
+ // (undocumented)
59
+ byline?: string;
60
+ // (undocumented)
61
+ highlight?: CustomHighlight;
62
+ // (undocumented)
63
+ type: 'custom';
64
+ }
65
+
66
+ // @public (undocumented)
67
+ interface CustomHighlight {
68
+ // (undocumented)
69
+ name: HighlightRange[];
70
+ }
71
+
72
+ // @public (undocumented)
73
+ export const CustomType = 'custom';
74
+
52
75
  // @public (undocumented)
53
76
  export type DefaultValue = OptionIdentifier | OptionIdentifier[] | Value;
54
77
 
@@ -199,7 +222,7 @@ export interface OptionData {
199
222
  // (undocumented)
200
223
  name: string;
201
224
  // (undocumented)
202
- type?: 'email' | 'group' | 'team' | 'user';
225
+ type?: 'custom' | 'email' | 'group' | 'team' | 'user';
203
226
  }
204
227
 
205
228
  // @public (undocumented)
@@ -29,6 +29,29 @@ export type AtlaskitSelectValue = Array<Option_2> | Option_2 | null | undefined;
29
29
  // @public (undocumented)
30
30
  type BoundariesElement = 'scrollParent' | 'viewport' | 'window' | HTMLElement;
31
31
 
32
+ // @public (undocumented)
33
+ export interface Custom extends OptionData {
34
+ // (undocumented)
35
+ analyticsType?: string;
36
+ // (undocumented)
37
+ avatarUrl?: string;
38
+ // (undocumented)
39
+ byline?: string;
40
+ // (undocumented)
41
+ highlight?: CustomHighlight;
42
+ // (undocumented)
43
+ type: 'custom';
44
+ }
45
+
46
+ // @public (undocumented)
47
+ interface CustomHighlight {
48
+ // (undocumented)
49
+ name: HighlightRange[];
50
+ }
51
+
52
+ // @public (undocumented)
53
+ export const CustomType = "custom";
54
+
32
55
  // @public (undocumented)
33
56
  export type DefaultValue = OptionIdentifier | OptionIdentifier[] | Value;
34
57
 
@@ -165,7 +188,7 @@ export interface OptionData {
165
188
  // (undocumented)
166
189
  name: string;
167
190
  // (undocumented)
168
- type?: 'email' | 'group' | 'team' | 'user';
191
+ type?: 'custom' | 'email' | 'group' | 'team' | 'user';
169
192
  }
170
193
 
171
194
  // @public (undocumented)