@atlaskit/editor-plugin-mentions 17.0.1 → 17.1.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 (35) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/mentionsPlugin.js +1 -0
  3. package/dist/cjs/nodeviews/mentionNodeView.js +1 -1
  4. package/dist/cjs/pm-plugins/main.js +1 -1
  5. package/dist/cjs/ui/PopperWrapper.js +14 -9
  6. package/dist/cjs/ui/ProfileCardComponent.js +36 -11
  7. package/dist/cjs/ui/type-ahead/MentionItemWithProfileCard.js +106 -0
  8. package/dist/cjs/ui/type-ahead/index.js +80 -71
  9. package/dist/cjs/ui/type-ahead/utils.js +7 -1
  10. package/dist/cjs/ui/useFocusTrap.js +5 -3
  11. package/dist/es2019/mentionsPlugin.js +1 -0
  12. package/dist/es2019/nodeviews/mentionNodeView.js +2 -0
  13. package/dist/es2019/pm-plugins/main.js +1 -1
  14. package/dist/es2019/ui/PopperWrapper.js +10 -8
  15. package/dist/es2019/ui/ProfileCardComponent.js +35 -10
  16. package/dist/es2019/ui/type-ahead/MentionItemWithProfileCard.js +91 -0
  17. package/dist/es2019/ui/type-ahead/index.js +22 -8
  18. package/dist/es2019/ui/type-ahead/utils.js +2 -0
  19. package/dist/es2019/ui/useFocusTrap.js +4 -3
  20. package/dist/esm/mentionsPlugin.js +1 -0
  21. package/dist/esm/nodeviews/mentionNodeView.js +2 -0
  22. package/dist/esm/pm-plugins/main.js +1 -1
  23. package/dist/esm/ui/PopperWrapper.js +13 -8
  24. package/dist/esm/ui/ProfileCardComponent.js +36 -11
  25. package/dist/esm/ui/type-ahead/MentionItemWithProfileCard.js +98 -0
  26. package/dist/esm/ui/type-ahead/index.js +78 -69
  27. package/dist/esm/ui/type-ahead/utils.js +6 -0
  28. package/dist/esm/ui/useFocusTrap.js +5 -3
  29. package/dist/types/ui/PopperWrapper.d.ts +15 -2
  30. package/dist/types/ui/ProfileCardComponent.d.ts +6 -1
  31. package/dist/types/ui/type-ahead/MentionItemWithProfileCard.d.ts +15 -0
  32. package/dist/types/ui/type-ahead/index.d.ts +3 -1
  33. package/dist/types/ui/type-ahead/utils.d.ts +2 -0
  34. package/dist/types/ui/useFocusTrap.d.ts +2 -1
  35. package/package.json +11 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 17.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 17.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`6997a74055219`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6997a74055219) -
14
+ Add profile card on hover in the mentions typeahead for agent mentions
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 17.0.1
4
21
 
5
22
  ### Patch Changes
@@ -111,6 +111,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
111
111
  handleMentionsChanged: options === null || options === void 0 ? void 0 : options.handleMentionsChanged,
112
112
  enableAgentSectioning: options === null || options === void 0 ? void 0 : options.enableAgentSectioning,
113
113
  showAgentMentionsLabsLozenge: options === null || options === void 0 ? void 0 : options.showAgentMentionsLabsLozenge,
114
+ profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
114
115
  fireEvent: fireEvent,
115
116
  api: api
116
117
  });
@@ -24,7 +24,7 @@ var _disabledTooltipRenderer = require("./disabledTooltipRenderer");
24
24
  var _mentionAvatarRenderer = require("./mentionAvatarRenderer");
25
25
  var _profileCardRenderer2 = require("./profileCardRenderer");
26
26
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
27
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // oxlint-disable-next-line import/no-duplicates
28
28
  var primitiveClassName = 'editor-mention-primitive';
29
29
  var primitiveWithAvatarClassName = 'editor-mention-primitive-with-avatar';
30
30
  var avatarContainerClassName = 'editor-mention-avatar';
@@ -67,7 +67,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
67
67
  var AGENT_MENTION_INACTIVITY_MS = 3000;
68
68
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
69
69
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
70
- var PACKAGE_VERSION = "17.0.0";
70
+ var PACKAGE_VERSION = "17.1.0";
71
71
  var setProvider = function setProvider(provider) {
72
72
  return function (state, dispatch) {
73
73
  if (dispatch) {
@@ -10,7 +10,7 @@ exports.RepositionOnUpdate = void 0;
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
- var _popper = require("@atlaskit/popper");
13
+ var _main = require("@atlaskit/popper/main");
14
14
  var _portal = _interopRequireDefault(require("@atlaskit/portal"));
15
15
  var _constants = require("@atlaskit/theme/constants");
16
16
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
@@ -84,22 +84,27 @@ function useResizeAwarePopper(_ref2) {
84
84
  */
85
85
  function Popup(_ref3) {
86
86
  var referenceElement = _ref3.referenceElement,
87
- children = _ref3.children;
87
+ children = _ref3.children,
88
+ _ref3$placement = _ref3.placement,
89
+ placement = _ref3$placement === void 0 ? 'bottom-end' : _ref3$placement,
90
+ _ref3$offset = _ref3.offset,
91
+ offset = _ref3$offset === void 0 ? [0, 8] : _ref3$offset,
92
+ _ref3$disableFocusTra = _ref3.disableFocusTrap,
93
+ disableFocusTrap = _ref3$disableFocusTra === void 0 ? false : _ref3$disableFocusTra;
88
94
  var _React$useState = _react.default.useState(null),
89
95
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
90
96
  targetRef = _React$useState2[0],
91
97
  setPopupRef = _React$useState2[1];
92
98
  (0, _useFocusTrap.useFocusTrap)({
93
- targetRef: targetRef
99
+ targetRef: targetRef,
100
+ enabled: !disableFocusTrap
94
101
  });
95
102
  return /*#__PURE__*/_react.default.createElement(_react.Suspense, null, /*#__PURE__*/_react.default.createElement(_portal.default, {
96
103
  zIndex: _constants.layers.modal()
97
- }, /*#__PURE__*/_react.default.createElement(_popper.Popper, {
98
- referenceElement: referenceElement
99
- // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
100
- ,
101
- offset: [0, 8],
102
- placement: "bottom-end",
104
+ }, /*#__PURE__*/_react.default.createElement(_main.Popper, {
105
+ referenceElement: referenceElement,
106
+ offset: offset,
107
+ placement: placement,
103
108
  strategy: "fixed"
104
109
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
105
110
  ,
@@ -154,7 +154,11 @@ function ProfileCardComponent(_ref5) {
154
154
  activeMention = _ref5.activeMention,
155
155
  dom = _ref5.dom,
156
156
  closeComponent = _ref5.closeComponent,
157
- onAgentMentionChatClick = _ref5.onAgentMentionChatClick;
157
+ onAgentMentionChatClick = _ref5.onAgentMentionChatClick,
158
+ placement = _ref5.placement,
159
+ offset = _ref5.offset,
160
+ disableFocusTrap = _ref5.disableFocusTrap,
161
+ hideActions = _ref5.hideActions;
158
162
  var _useState11 = (0, _react.useState)(undefined),
159
163
  _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
160
164
  provider = _useState12[0],
@@ -181,20 +185,28 @@ function ProfileCardComponent(_ref5) {
181
185
  });
182
186
  if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
183
187
  return /*#__PURE__*/React.createElement(_PopperWrapper.Popup, {
184
- referenceElement: dom
188
+ referenceElement: dom,
189
+ placement: placement,
190
+ offset: offset,
191
+ disableFocusTrap: disableFocusTrap
185
192
  }, /*#__PURE__*/React.createElement(UserProfileCardContent, {
186
193
  accessLevel: accessLevel,
187
194
  id: id,
188
195
  provider: provider,
189
- text: text
196
+ text: text,
197
+ hideActions: hideActions
190
198
  }));
191
199
  }
192
200
  var isAgentMention = isAgentMentionType(userType);
193
201
  return /*#__PURE__*/React.createElement(_PopperWrapper.Popup, {
194
- referenceElement: dom
202
+ referenceElement: dom,
203
+ placement: placement,
204
+ offset: offset,
205
+ disableFocusTrap: disableFocusTrap
195
206
  }, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
196
207
  accountId: id,
197
208
  provider: provider,
209
+ hideActions: hideActions,
198
210
  text: (0, _expVal.expVal)('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? text : undefined,
199
211
  onChatClick: onAgentMentionChatClick && (0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes') ? function (event, agentStudioId) {
200
212
  return (
@@ -207,17 +219,19 @@ function ProfileCardComponent(_ref5) {
207
219
  accessLevel: accessLevel,
208
220
  id: id,
209
221
  provider: provider,
210
- text: text
222
+ text: text,
223
+ hideActions: hideActions
211
224
  }));
212
225
  }
213
226
  var UserProfileCardContent = function UserProfileCardContent(_ref8) {
214
227
  var accessLevel = _ref8.accessLevel,
215
228
  id = _ref8.id,
216
229
  provider = _ref8.provider,
217
- text = _ref8.text;
230
+ text = _ref8.text,
231
+ hideActions = _ref8.hideActions;
218
232
  var actions = (0, _react.useMemo)(function () {
219
- return provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel);
220
- }, [accessLevel, id, provider, text]);
233
+ return hideActions ? [] : provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel);
234
+ }, [hideActions, accessLevel, id, provider, text]);
221
235
  var _useProfileCardState = useProfileCardState({
222
236
  id: id,
223
237
  provider: provider
@@ -259,18 +273,29 @@ var AgentProfileCardContent = function AgentProfileCardContent(_ref9) {
259
273
  var accountId = _ref9.accountId,
260
274
  provider = _ref9.provider,
261
275
  text = _ref9.text,
262
- onChatClick = _ref9.onChatClick;
276
+ onChatClick = _ref9.onChatClick,
277
+ hideActions = _ref9.hideActions;
263
278
  var agentName = (text !== null && text !== void 0 ? text : '').replace(LEADING_AT_SIGN_RE, '');
264
279
  return (0, _expVal.expVal)('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
265
280
  accountId: accountId,
266
281
  cloudId: provider.cloudId,
267
282
  resourceClient: provider.resourceClient,
268
283
  agentName: agentName,
269
- onChatClick: onChatClick
284
+ onChatClick: onChatClick,
285
+ hideAgentActions: hideActions,
286
+ hideConversationStarters: hideActions,
287
+ hideStarButton: hideActions,
288
+ hideAiDisclaimer: hideActions,
289
+ showCreatorNameWithoutLink: hideActions
270
290
  }) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
271
291
  accountId: accountId,
272
292
  cloudId: provider.cloudId,
273
293
  resourceClient: provider.resourceClient,
274
- onChatClick: onChatClick
294
+ onChatClick: onChatClick,
295
+ hideAgentActions: hideActions,
296
+ hideConversationStarters: hideActions,
297
+ hideStarButton: hideActions,
298
+ hideAiDisclaimer: hideActions,
299
+ showCreatorNameWithoutLink: hideActions
275
300
  });
276
301
  };
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.MentionItemWithProfileCard = MentionItemWithProfileCard;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _item = require("@atlaskit/mention/item");
12
+ var _compiled = require("@atlaskit/primitives/compiled");
13
+ var _ProfileCardComponent = require("../ProfileCardComponent");
14
+ var _utils = require("./utils");
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
+ // Delay before mounting the card and fetching the profile data
17
+ var SHOW_DELAY_MS = 600;
18
+ var HIDE_DELAY_MS = 200;
19
+ /**
20
+ * Renders a mentions typeahead row that shows a (reduced) profile card
21
+ * when hovered
22
+ */
23
+ function MentionItemWithProfileCard(_ref) {
24
+ var mention = _ref.mention,
25
+ selected = _ref.selected,
26
+ onSelection = _ref.onSelection,
27
+ height = _ref.height,
28
+ profilecardProvider = _ref.profilecardProvider;
29
+ var _useState = (0, _react.useState)(null),
30
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
31
+ referenceElement = _useState2[0],
32
+ setReferenceElement = _useState2[1];
33
+ var showTimerRef = (0, _react.useRef)();
34
+ var hideTimerRef = (0, _react.useRef)();
35
+ var clearTimers = (0, _react.useCallback)(function () {
36
+ clearTimeout(showTimerRef.current);
37
+ clearTimeout(hideTimerRef.current);
38
+ }, []);
39
+ (0, _react.useEffect)(function () {
40
+ return clearTimers;
41
+ }, [clearTimers]);
42
+ var isAgent = (0, _utils.isAgentMention)(mention);
43
+ var handleMouseEnter = (0, _react.useCallback)(function (_mention, event) {
44
+ // Currently showing profile cards for agents only
45
+ if (mention.isPlaceholder || !mention.id || !profilecardProvider || !isAgent) {
46
+ return;
47
+ }
48
+ var rowElement = event === null || event === void 0 ? void 0 : event.currentTarget;
49
+ if (!(rowElement instanceof HTMLElement)) {
50
+ return;
51
+ }
52
+ clearTimers();
53
+ showTimerRef.current = setTimeout(function () {
54
+ setReferenceElement(rowElement);
55
+ }, SHOW_DELAY_MS);
56
+ }, [mention.isPlaceholder, mention.id, isAgent, profilecardProvider, clearTimers]);
57
+ var scheduleHide = (0, _react.useCallback)(function () {
58
+ clearTimeout(hideTimerRef.current);
59
+ hideTimerRef.current = setTimeout(function () {
60
+ setReferenceElement(null);
61
+ }, HIDE_DELAY_MS);
62
+ }, []);
63
+ var cancelHide = (0, _react.useCallback)(function () {
64
+ clearTimeout(hideTimerRef.current);
65
+ }, []);
66
+ var handleMouseLeave = (0, _react.useCallback)(function () {
67
+ clearTimeout(showTimerRef.current);
68
+ scheduleHide();
69
+ }, [scheduleHide]);
70
+ var closeCard = (0, _react.useCallback)(function () {
71
+ clearTimers();
72
+ setReferenceElement(null);
73
+ }, [clearTimers]);
74
+ var userType = isAgent ? 'APP' : undefined;
75
+ var activeMention = (0, _react.useMemo)(function () {
76
+ return {
77
+ attrs: {
78
+ id: mention.id,
79
+ text: mention.name,
80
+ userType: userType,
81
+ accessLevel: mention.accessLevel
82
+ }
83
+ };
84
+ }, [mention.id, mention.name, mention.accessLevel, userType]);
85
+ return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
86
+ testId: "mention-item-with-profile-card",
87
+ onMouseOver: cancelHide,
88
+ onMouseOut: scheduleHide,
89
+ onMouseLeave: handleMouseLeave,
90
+ onBlur: handleMouseLeave
91
+ }, /*#__PURE__*/_react.default.createElement(_item.MentionItem, {
92
+ mention: mention,
93
+ selected: selected,
94
+ onMouseEnter: handleMouseEnter,
95
+ onSelection: onSelection,
96
+ height: height
97
+ }), referenceElement && profilecardProvider && /*#__PURE__*/_react.default.createElement(_ProfileCardComponent.ProfileCardComponent, {
98
+ activeMention: activeMention,
99
+ profilecardProvider: profilecardProvider,
100
+ dom: referenceElement,
101
+ closeComponent: closeCard,
102
+ placement: "right",
103
+ disableFocusTrap: true,
104
+ hideActions: true
105
+ }));
106
+ }
@@ -30,6 +30,7 @@ var _utils2 = require("../../pm-plugins/utils");
30
30
  var _InviteItem = _interopRequireWildcard(require("../InviteItem"));
31
31
  var _InviteItemWithEmailDomain = _interopRequireDefault(require("../InviteItem/InviteItemWithEmailDomain"));
32
32
  var _analytics = require("./analytics");
33
+ var _MentionItemWithProfileCard = require("./MentionItemWithProfileCard");
33
34
  var _utils3 = require("./utils");
34
35
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
35
36
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
@@ -37,14 +38,8 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
37
38
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
38
39
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
39
40
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
40
- var isAgentUserType = function isAgentUserType(userType) {
41
- return userType === 'APP' || userType === 'AGENT';
42
- };
43
- var isAgentMention = function isAgentMention(mention) {
44
- return isAgentUserType(mention.userType) || mention.appType === 'agent';
45
- };
46
41
  var isAgentTypeAheadItem = function isAgentTypeAheadItem(item) {
47
- return item.mention ? isAgentMention(item.mention) : false;
42
+ return item.mention ? (0, _utils3.isAgentMention)(item.mention) : false;
48
43
  };
49
44
 
50
45
  // A non-selectable loading placeholder injected by the provider (e.g.
@@ -109,16 +104,24 @@ var withInviteItem = function withInviteItem(_ref3) {
109
104
  inviteItem]);
110
105
  };
111
106
  };
112
- var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(useRefreshedItemHeight) {
107
+ var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(_ref4) {
108
+ var useRefreshedItemHeight = _ref4.useRefreshedItemHeight,
109
+ profilecardProvider = _ref4.profilecardProvider;
113
110
  return function (mention) {
114
111
  var itemHeight = useRefreshedItemHeight ? _item.MENTION_ITEM_HEIGHT_REFRESHED : _item.MENTION_ITEM_HEIGHT;
115
112
  return {
116
113
  title: mention.id,
117
- render: function render(_ref4) {
118
- var isSelected = _ref4.isSelected,
119
- onClick = _ref4.onClick,
120
- onHover = _ref4.onHover;
121
- return /*#__PURE__*/_react.default.createElement(_item.MentionItem, {
114
+ render: function render(_ref5) {
115
+ var isSelected = _ref5.isSelected,
116
+ onClick = _ref5.onClick,
117
+ onHover = _ref5.onHover;
118
+ return (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) && (0, _platformFeatureFlags.fg)('platform_editor_mention_typeahead_profilecard') ? /*#__PURE__*/_react.default.createElement(_MentionItemWithProfileCard.MentionItemWithProfileCard, {
119
+ mention: mention,
120
+ selected: isSelected,
121
+ onSelection: onClick,
122
+ height: itemHeight,
123
+ profilecardProvider: profilecardProvider
124
+ }) : /*#__PURE__*/_react.default.createElement(_item.MentionItem, {
122
125
  mention: mention,
123
126
  selected: isSelected,
124
127
  onMouseEnter: onHover,
@@ -134,7 +137,9 @@ var makeMentionToTypeaheadItem = function makeMentionToTypeaheadItem(useRefreshe
134
137
  };
135
138
  };
136
139
  var mentionToTypeaheadItem = exports.mentionToTypeaheadItem = function mentionToTypeaheadItem(mention) {
137
- return makeMentionToTypeaheadItem((0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false))(mention);
140
+ return makeMentionToTypeaheadItem({
141
+ useRefreshedItemHeight: (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)
142
+ })(mention);
138
143
  };
139
144
 
140
145
  /**
@@ -163,12 +168,12 @@ function memoize(fn
163
168
  };
164
169
  }
165
170
  var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAheadAnalytics(fireEvent) {
166
- return function (_ref5) {
167
- var query = _ref5.query,
168
- mentions = _ref5.mentions,
169
- stats = _ref5.stats,
170
- mentionTypeaheadSessionId = _ref5.mentionTypeaheadSessionId,
171
- agentAnalytics = _ref5.agentAnalytics;
171
+ return function (_ref6) {
172
+ var query = _ref6.query,
173
+ mentions = _ref6.mentions,
174
+ stats = _ref6.stats,
175
+ mentionTypeaheadSessionId = _ref6.mentionTypeaheadSessionId,
176
+ agentAnalytics = _ref6.agentAnalytics;
172
177
  var duration = 0;
173
178
  var userOrTeamIds = null;
174
179
  var teams = null;
@@ -270,19 +275,19 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
270
275
  * `createTypeAheadConfig` and intentionally mutated here as a
271
276
  * side-effect — preserves the existing single-shot semantics.
272
277
  */
273
- var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToTypeAheadItems(_ref6) {
274
- var fireEvent = _ref6.fireEvent,
275
- getFirstQueryWithoutResults = _ref6.getFirstQueryWithoutResults,
276
- setFirstQueryWithoutResults = _ref6.setFirstQueryWithoutResults,
277
- toItem = _ref6.toItem,
278
- enableAgentSectioning = _ref6.enableAgentSectioning;
279
- return function (_ref7) {
280
- var mentions = _ref7.mentions,
281
- query = _ref7.query,
282
- stats = _ref7.stats,
283
- mentionProvider = _ref7.mentionProvider,
284
- contextIdentifierProvider = _ref7.contextIdentifierProvider,
285
- sessionId = _ref7.sessionId;
278
+ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToTypeAheadItems(_ref7) {
279
+ var fireEvent = _ref7.fireEvent,
280
+ getFirstQueryWithoutResults = _ref7.getFirstQueryWithoutResults,
281
+ setFirstQueryWithoutResults = _ref7.setFirstQueryWithoutResults,
282
+ toItem = _ref7.toItem,
283
+ enableAgentSectioning = _ref7.enableAgentSectioning;
284
+ return function (_ref8) {
285
+ var mentions = _ref8.mentions,
286
+ query = _ref8.query,
287
+ stats = _ref8.stats,
288
+ mentionProvider = _ref8.mentionProvider,
289
+ contextIdentifierProvider = _ref8.contextIdentifierProvider,
290
+ sessionId = _ref8.sessionId;
286
291
  var mentionItems = mentions.map(function (mention) {
287
292
  return toItem(mention);
288
293
  });
@@ -292,7 +297,7 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
292
297
  var realMentions = mentions.filter(function (mention) {
293
298
  return !isLoadingPlaceholder(mention);
294
299
  });
295
- var agentCount = realMentions.filter(isAgentMention).length;
300
+ var agentCount = realMentions.filter(_utils3.isAgentMention).length;
296
301
  var agentAnalytics = {
297
302
  agentCount: agentCount,
298
303
  agentSectioningEnabled: enableAgentSectioning
@@ -329,17 +334,18 @@ var makeTransformMentionsToTypeAheadItems = function makeTransformMentionsToType
329
334
  })(mentionItems);
330
335
  };
331
336
  };
332
- var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
333
- var sanitizePrivateContent = _ref8.sanitizePrivateContent,
334
- mentionInsertDisplayName = _ref8.mentionInsertDisplayName,
335
- fireEvent = _ref8.fireEvent,
336
- HighlightComponent = _ref8.HighlightComponent,
337
- api = _ref8.api,
338
- handleMentionsChanged = _ref8.handleMentionsChanged,
339
- _ref8$enableAgentSect = _ref8.enableAgentSectioning,
340
- enableAgentSectioning = _ref8$enableAgentSect === void 0 ? false : _ref8$enableAgentSect,
341
- _ref8$showAgentMentio = _ref8.showAgentMentionsLabsLozenge,
342
- showAgentMentionsLabsLozenge = _ref8$showAgentMentio === void 0 ? false : _ref8$showAgentMentio;
337
+ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeAheadConfig(_ref9) {
338
+ var sanitizePrivateContent = _ref9.sanitizePrivateContent,
339
+ mentionInsertDisplayName = _ref9.mentionInsertDisplayName,
340
+ fireEvent = _ref9.fireEvent,
341
+ HighlightComponent = _ref9.HighlightComponent,
342
+ api = _ref9.api,
343
+ handleMentionsChanged = _ref9.handleMentionsChanged,
344
+ _ref9$enableAgentSect = _ref9.enableAgentSectioning,
345
+ enableAgentSectioning = _ref9$enableAgentSect === void 0 ? false : _ref9$enableAgentSect,
346
+ _ref9$showAgentMentio = _ref9.showAgentMentionsLabsLozenge,
347
+ showAgentMentionsLabsLozenge = _ref9$showAgentMentio === void 0 ? false : _ref9$showAgentMentio,
348
+ profilecardProvider = _ref9.profilecardProvider;
343
349
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
344
350
  var sessionId = (0, _uuid.default)();
345
351
  var firstQueryWithoutResults = null;
@@ -353,7 +359,10 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
353
359
  setFirstQueryWithoutResults: function setFirstQueryWithoutResults(query) {
354
360
  firstQueryWithoutResults = query;
355
361
  },
356
- toItem: memoize(makeMentionToTypeaheadItem(enableAgentSectioning)).call
362
+ toItem: memoize(makeMentionToTypeaheadItem({
363
+ useRefreshedItemHeight: enableAgentSectioning,
364
+ profilecardProvider: profilecardProvider
365
+ })).call
357
366
  });
358
367
  var typeAhead = {
359
368
  id: _typeAhead.TypeAheadAvailableNodes.MENTION,
@@ -368,17 +377,17 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
368
377
  }
369
378
  return null;
370
379
  },
371
- getItems: function getItems(_ref9) {
380
+ getItems: function getItems(_ref0) {
372
381
  var _api$contextIdentifie, _api$contextIdentifie2;
373
- var query = _ref9.query,
374
- editorState = _ref9.editorState;
382
+ var query = _ref0.query,
383
+ editorState = _ref0.editorState;
375
384
  var pluginState = (0, _utils2.getMentionPluginState)(editorState);
376
385
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider)) {
377
386
  return Promise.resolve([]);
378
387
  }
379
388
  var mentionProvider = pluginState.mentionProvider;
380
- var _ref0 = (_api$contextIdentifie = api === null || api === void 0 || (_api$contextIdentifie2 = api.contextIdentifier) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.sharedState.currentState()) !== null && _api$contextIdentifie !== void 0 ? _api$contextIdentifie : {},
381
- contextIdentifierProvider = _ref0.contextIdentifierProvider;
389
+ var _ref1 = (_api$contextIdentifie = api === null || api === void 0 || (_api$contextIdentifie2 = api.contextIdentifier) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.sharedState.currentState()) !== null && _api$contextIdentifie !== void 0 ? _api$contextIdentifie : {},
390
+ contextIdentifierProvider = _ref1.contextIdentifierProvider;
382
391
  return new Promise(function (resolve, reject) {
383
392
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
384
393
  var key = "loadingMentionsForTypeAhead_".concat((0, _uuid.default)());
@@ -413,8 +422,8 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
413
422
  }));
414
423
  });
415
424
  },
416
- getSections: function getSections(_ref1) {
417
- var intl = _ref1.intl;
425
+ getSections: function getSections(_ref10) {
426
+ var intl = _ref10.intl;
418
427
  if (!enableAgentSectioning) {
419
428
  return [];
420
429
  }
@@ -448,12 +457,12 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
448
457
  onOpen: function onOpen() {
449
458
  firstQueryWithoutResults = null;
450
459
  },
451
- selectItem: function selectItem(state, item, insert, _ref10) {
460
+ selectItem: function selectItem(state, item, insert, _ref11) {
452
461
  var _api$contextIdentifie3, _api$contextIdentifie4;
453
- var mode = _ref10.mode,
454
- stats = _ref10.stats,
455
- query = _ref10.query,
456
- sourceListItem = _ref10.sourceListItem;
462
+ var mode = _ref11.mode,
463
+ stats = _ref11.stats,
464
+ query = _ref11.query,
465
+ sourceListItem = _ref11.sourceListItem;
457
466
  var schema = state.schema;
458
467
 
459
468
  // Placeholder isn't selectable. Return `false` (not a transaction) so
@@ -470,12 +479,12 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
470
479
  accessLevel = _item$mention.accessLevel,
471
480
  userType = _item$mention.userType,
472
481
  isXProductUser = _item$mention.isXProductUser;
473
- var _ref11 = (_api$contextIdentifie3 = api === null || api === void 0 || (_api$contextIdentifie4 = api.contextIdentifier) === null || _api$contextIdentifie4 === void 0 ? void 0 : _api$contextIdentifie4.sharedState.currentState()) !== null && _api$contextIdentifie3 !== void 0 ? _api$contextIdentifie3 : {},
474
- contextIdentifierProvider = _ref11.contextIdentifierProvider;
482
+ var _ref12 = (_api$contextIdentifie3 = api === null || api === void 0 || (_api$contextIdentifie4 = api.contextIdentifier) === null || _api$contextIdentifie4 === void 0 ? void 0 : _api$contextIdentifie4.sharedState.currentState()) !== null && _api$contextIdentifie3 !== void 0 ? _api$contextIdentifie3 : {},
483
+ contextIdentifierProvider = _ref12.contextIdentifierProvider;
475
484
  var mentionContext = _objectSpread(_objectSpread({}, contextIdentifierProvider), {}, {
476
485
  sessionId: sessionId
477
486
  });
478
- var isAgentMentionSelection = isAgentMention(item.mention);
487
+ var isAgentMentionSelection = (0, _utils3.isAgentMention)(item.mention);
479
488
  var isAgentMentionInsertion = isAgentMentionSelection && (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false);
480
489
  // userType can be missing for provider-only agent mentions. Copy/paste cannot
481
490
  // see appType, so persist APP only when there is no explicit userType.
@@ -598,11 +607,11 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
598
607
  }
599
608
  return tr;
600
609
  },
601
- dismiss: function dismiss(_ref12) {
602
- var editorState = _ref12.editorState,
603
- query = _ref12.query,
604
- stats = _ref12.stats,
605
- wasItemInserted = _ref12.wasItemInserted;
610
+ dismiss: function dismiss(_ref13) {
611
+ var editorState = _ref13.editorState,
612
+ query = _ref13.query,
613
+ stats = _ref13.stats,
614
+ wasItemInserted = _ref13.wasItemInserted;
606
615
  firstQueryWithoutResults = null;
607
616
  var pickerElapsedTime = stats.startedAt ? performance.now() - stats.startedAt : 0;
608
617
  if (!wasItemInserted) {
@@ -646,10 +655,10 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
646
655
  * so we only attach it when the gate is on — otherwise the proven
647
656
  * single-shot `getItems` path continues to drive every consumer.
648
657
  */
649
- var subscribeToItemsUpdates = function subscribeToItemsUpdates(_ref13) {
658
+ var subscribeToItemsUpdates = function subscribeToItemsUpdates(_ref14) {
650
659
  var _api$contextIdentifie5, _api$contextIdentifie6;
651
- var query = _ref13.query,
652
- editorState = _ref13.editorState;
660
+ var query = _ref14.query,
661
+ editorState = _ref14.editorState;
653
662
  var pluginState = (0, _utils2.getMentionPluginState)(editorState);
654
663
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider)) {
655
664
  return {
@@ -660,8 +669,8 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
660
669
  };
661
670
  }
662
671
  var mentionProvider = pluginState.mentionProvider;
663
- var _ref14 = (_api$contextIdentifie5 = api === null || api === void 0 || (_api$contextIdentifie6 = api.contextIdentifier) === null || _api$contextIdentifie6 === void 0 ? void 0 : _api$contextIdentifie6.sharedState.currentState()) !== null && _api$contextIdentifie5 !== void 0 ? _api$contextIdentifie5 : {},
664
- contextIdentifierProvider = _ref14.contextIdentifierProvider;
672
+ var _ref15 = (_api$contextIdentifie5 = api === null || api === void 0 || (_api$contextIdentifie6 = api.contextIdentifier) === null || _api$contextIdentifie6 === void 0 ? void 0 : _api$contextIdentifie6.sharedState.currentState()) !== null && _api$contextIdentifie5 !== void 0 ? _api$contextIdentifie5 : {},
673
+ contextIdentifierProvider = _ref15.contextIdentifierProvider;
665
674
 
666
675
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
667
676
  var key = "loadingMentionsForTypeAhead_".concat((0, _uuid.default)());
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.shouldKeepInviteItem = exports.isTeamType = exports.isTeamStats = exports.isInviteItem = void 0;
6
+ exports.shouldKeepInviteItem = exports.isTeamType = exports.isTeamStats = exports.isInviteItem = exports.isAgentUserType = exports.isAgentMention = void 0;
7
7
  var _InviteItem = require("../InviteItem");
8
8
  // Ignored via go/ees005
9
9
  // eslint-disable-next-line require-unicode-regexp
@@ -23,6 +23,12 @@ var isTeamStats = exports.isTeamStats = function isTeamStats(stat) {
23
23
  var isInviteItem = exports.isInviteItem = function isInviteItem(mention) {
24
24
  return mention && mention.id === _InviteItem.INVITE_ITEM_DESCRIPTION.id;
25
25
  };
26
+ var isAgentUserType = exports.isAgentUserType = function isAgentUserType(userType) {
27
+ return userType === 'APP' || userType === 'AGENT';
28
+ };
29
+ var isAgentMention = exports.isAgentMention = function isAgentMention(mention) {
30
+ return isAgentUserType(mention.userType) || mention.appType === 'agent';
31
+ };
26
32
 
27
33
  /**
28
34
  * Actions
@@ -14,9 +14,11 @@ var _focusTrap = _interopRequireDefault(require("focus-trap"));
14
14
  */
15
15
 
16
16
  var useFocusTrap = exports.useFocusTrap = function useFocusTrap(_ref) {
17
- var targetRef = _ref.targetRef;
17
+ var targetRef = _ref.targetRef,
18
+ _ref$enabled = _ref.enabled,
19
+ enabled = _ref$enabled === void 0 ? true : _ref$enabled;
18
20
  (0, _react.useEffect)(function () {
19
- if (!targetRef) {
21
+ if (!targetRef || !enabled) {
20
22
  return;
21
23
  }
22
24
  var trapConfig = {
@@ -40,5 +42,5 @@ var useFocusTrap = exports.useFocusTrap = function useFocusTrap(_ref) {
40
42
  }
41
43
  focusTrap.deactivate();
42
44
  };
43
- }, [targetRef]);
45
+ }, [targetRef, enabled]);
44
46
  };
@@ -107,6 +107,7 @@ const mentionsPlugin = ({
107
107
  handleMentionsChanged: options === null || options === void 0 ? void 0 : options.handleMentionsChanged,
108
108
  enableAgentSectioning: options === null || options === void 0 ? void 0 : options.enableAgentSectioning,
109
109
  showAgentMentionsLabsLozenge: options === null || options === void 0 ? void 0 : options.showAgentMentionsLabsLozenge,
110
+ profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
110
111
  fireEvent,
111
112
  api
112
113
  });
@@ -2,6 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
3
3
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
4
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
+ // oxlint-disable-next-line import/no-duplicates
6
+
5
7
  import { UNKNOWN_USER_ID } from '@atlaskit/mention/constants';
6
8
  import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention/resource';
7
9
  import { isRestricted } from '@atlaskit/mention/types';