@atlaskit/mention 26.0.4 → 26.2.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 (54) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/cjs/api/ContextMentionResource.js +14 -0
  3. package/dist/cjs/api/MentionResource.js +6 -0
  4. package/dist/cjs/components/DisabledMentionTooltip/index.js +20 -0
  5. package/dist/cjs/components/DisabledMentionTooltip/main.js +24 -0
  6. package/dist/cjs/components/Mention/PrimitiveMention.js +8 -1
  7. package/dist/cjs/components/Mention/index.js +51 -12
  8. package/dist/cjs/components/MentionItem/index.js +9 -1
  9. package/dist/cjs/components/MentionItem/styles.js +5 -2
  10. package/dist/cjs/item.js +6 -0
  11. package/dist/cjs/types.js +10 -0
  12. package/dist/cjs/util/analytics.js +1 -1
  13. package/dist/es2019/api/ContextMentionResource.js +12 -0
  14. package/dist/es2019/api/MentionResource.js +4 -0
  15. package/dist/es2019/components/DisabledMentionTooltip/index.js +7 -0
  16. package/dist/es2019/components/DisabledMentionTooltip/main.js +14 -0
  17. package/dist/es2019/components/Mention/PrimitiveMention.js +8 -0
  18. package/dist/es2019/components/Mention/index.js +50 -12
  19. package/dist/es2019/components/MentionItem/index.js +4 -2
  20. package/dist/es2019/components/MentionItem/styles.js +16 -11
  21. package/dist/es2019/item.js +2 -2
  22. package/dist/es2019/types.js +12 -0
  23. package/dist/es2019/util/analytics.js +1 -1
  24. package/dist/esm/api/ContextMentionResource.js +14 -0
  25. package/dist/esm/api/MentionResource.js +6 -0
  26. package/dist/esm/components/DisabledMentionTooltip/index.js +9 -0
  27. package/dist/esm/components/DisabledMentionTooltip/main.js +17 -0
  28. package/dist/esm/components/Mention/PrimitiveMention.js +8 -1
  29. package/dist/esm/components/Mention/index.js +51 -12
  30. package/dist/esm/components/MentionItem/index.js +4 -2
  31. package/dist/esm/components/MentionItem/styles.js +4 -1
  32. package/dist/esm/item.js +2 -2
  33. package/dist/esm/types.js +12 -0
  34. package/dist/esm/util/analytics.js +1 -1
  35. package/dist/types/api/ContextMentionResource.d.ts +6 -1
  36. package/dist/types/api/MentionResource.d.ts +2 -1
  37. package/dist/types/components/DisabledMentionTooltip/index.d.ts +6 -0
  38. package/dist/types/components/DisabledMentionTooltip/main.d.ts +12 -0
  39. package/dist/types/components/Mention/index.d.ts +12 -0
  40. package/dist/types/components/MentionItem/index.d.ts +2 -1
  41. package/dist/types/components/MentionItem/styles.d.ts +2 -0
  42. package/dist/types/item.d.ts +2 -2
  43. package/dist/types/types.d.ts +67 -1
  44. package/dist/types-ts4.5/api/ContextMentionResource.d.ts +6 -1
  45. package/dist/types-ts4.5/api/MentionResource.d.ts +2 -1
  46. package/dist/types-ts4.5/components/DisabledMentionTooltip/index.d.ts +6 -0
  47. package/dist/types-ts4.5/components/DisabledMentionTooltip/main.d.ts +12 -0
  48. package/dist/types-ts4.5/components/Mention/index.d.ts +12 -0
  49. package/dist/types-ts4.5/components/MentionItem/index.d.ts +2 -1
  50. package/dist/types-ts4.5/components/MentionItem/styles.d.ts +2 -0
  51. package/dist/types-ts4.5/item.d.ts +2 -2
  52. package/dist/types-ts4.5/types.d.ts +67 -1
  53. package/docs/0-intro.tsx +21 -0
  54. package/package.json +7 -7
@@ -69,18 +69,23 @@ export const TimeStyle = styled.div({
69
69
  font: "var(--ds-font-body-small, normal 400 12px/16px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)"
70
70
  });
71
71
  export const MENTION_ITEM_HEIGHT = 48;
72
+ export const MENTION_ITEM_HEIGHT_REFRESHED = 44;
72
73
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-styled, @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/ui-styling-standard/no-dynamic-styles -- Ignored via go/DSP-18766
73
- export const MentionItemStyle = styled.div(props => ({
74
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
75
- backgroundColor: props.selected ? "var(--ds-background-selected, #E9F2FE)" : 'transparent',
76
- display: 'block',
77
- overflow: 'hidden',
78
- listStyleType: 'none',
79
- height: `${MENTION_ITEM_HEIGHT}px`,
80
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
81
- lineHeight: 1.2,
82
- cursor: 'pointer'
83
- }));
74
+ export const MentionItemStyle = styled.div(props => {
75
+ var _props$height;
76
+ return {
77
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
78
+ backgroundColor: props.selected ? "var(--ds-background-selected, #E9F2FE)" : 'transparent',
79
+ display: 'block',
80
+ overflow: 'hidden',
81
+ listStyleType: 'none',
82
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
83
+ height: `${(_props$height = props.height) !== null && _props$height !== void 0 ? _props$height : MENTION_ITEM_HEIGHT}px`,
84
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
85
+ lineHeight: 1.2,
86
+ cursor: 'pointer'
87
+ };
88
+ });
84
89
 
85
90
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-styled, @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
86
91
  export const AccessSectionStyle = styled.div({
@@ -1,4 +1,4 @@
1
- import MentionItem, { MENTION_ITEM_HEIGHT } from './components/MentionItem';
1
+ import MentionItem, { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from './components/MentionItem';
2
2
  export {
3
3
  // Components
4
- MentionItem, MENTION_ITEM_HEIGHT };
4
+ MentionItem, MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED };
@@ -6,12 +6,24 @@
6
6
  * and `refreshedSecurityProvider` fields.
7
7
  */
8
8
 
9
+ /**
10
+ * Describes whether a mention should be rendered in its disabled visual
11
+ * state and what tooltip (if any) should be shown on hover.
12
+ */
13
+
14
+ /**
15
+ * The minimal input shape used by `getMentionDisabledState`. Kept as a named
16
+ * type so the config callback and the provider method share the same input
17
+ * surface, and so callers do not have to fabricate fields they do not have.
18
+ */
19
+
9
20
  // data is returned from team search service
10
21
 
11
22
  export let MentionType = /*#__PURE__*/function (MentionType) {
12
23
  MentionType[MentionType["SELF"] = 0] = "SELF";
13
24
  MentionType[MentionType["RESTRICTED"] = 1] = "RESTRICTED";
14
25
  MentionType[MentionType["DEFAULT"] = 2] = "DEFAULT";
26
+ MentionType[MentionType["DISABLED"] = 3] = "DISABLED";
15
27
  return MentionType;
16
28
  }({});
17
29
  export let UserAccessLevel = /*#__PURE__*/function (UserAccessLevel) {
@@ -2,7 +2,7 @@ import { OPERATIONAL_EVENT_TYPE, UI_EVENT_TYPE } from '@atlaskit/analytics-gas-t
2
2
  import { ELEMENTS_CHANNEL } from '../_constants';
3
3
  import { ComponentNames, isSpecialMentionText } from '../types';
4
4
  const packageName = "@atlaskit/mention";
5
- const packageVersion = "26.0.3";
5
+ const packageVersion = "26.1.0";
6
6
  export const SLI_EVENT_TYPE = 'sli';
7
7
  export const SMART_EVENT_TYPE = 'smart';
8
8
  export const fireAnalyticsMentionTypeaheadEvent = props => (action, duration, userIds = [], query) => {
@@ -36,6 +36,20 @@ var ContextMentionResource = /*#__PURE__*/function () {
36
36
  _defineProperty(this, "filter", this.callWithContextIds('filter', 1));
37
37
  _defineProperty(this, "recordMentionSelection", this.callWithContextIds('recordMentionSelection', 1));
38
38
  _defineProperty(this, "shouldHighlightMention", this.callDefault('shouldHighlightMention'));
39
+ _defineProperty(this, "getMentionDisabledState", function (mention) {
40
+ var _this$mentionProvider3, _this$mentionProvider4;
41
+ return (_this$mentionProvider3 = (_this$mentionProvider4 = _this.mentionProvider).getMentionDisabledState) === null || _this$mentionProvider3 === void 0 ? void 0 : _this$mentionProvider3.call(_this$mentionProvider4, mention);
42
+ });
43
+ _defineProperty(this, "subscribeToDisabledStateChanges", function (listener) {
44
+ var _this$mentionProvider5, _this$mentionProvider6, _this$mentionProvider7;
45
+ return (_this$mentionProvider5 = (_this$mentionProvider6 = (_this$mentionProvider7 = _this.mentionProvider).subscribeToDisabledStateChanges) === null || _this$mentionProvider6 === void 0 ? void 0 : _this$mentionProvider6.call(_this$mentionProvider7, listener)) !== null && _this$mentionProvider5 !== void 0 ? _this$mentionProvider5 : function () {
46
+ return undefined;
47
+ };
48
+ });
49
+ _defineProperty(this, "notifyMentionDestroyed", function (mention) {
50
+ var _this$mentionProvider8, _this$mentionProvider9;
51
+ return (_this$mentionProvider8 = (_this$mentionProvider9 = _this.mentionProvider).notifyMentionDestroyed) === null || _this$mentionProvider8 === void 0 ? void 0 : _this$mentionProvider8.call(_this$mentionProvider9, mention);
52
+ });
39
53
  _defineProperty(this, "isFiltering", this.callDefault('isFiltering'));
40
54
  this.mentionProvider = mentionProvider;
41
55
  this.contextIdentifier = contextIdentifier;
@@ -203,6 +203,12 @@ export var MentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
203
203
  }
204
204
  return false;
205
205
  }
206
+ }, {
207
+ key: "getMentionDisabledState",
208
+ value: function getMentionDisabledState(mention) {
209
+ var _this$config$getMenti, _this$config;
210
+ return (_this$config$getMenti = (_this$config = this.config).getMentionDisabledState) === null || _this$config$getMenti === void 0 ? void 0 : _this$config$getMenti.call(_this$config, mention);
211
+ }
206
212
  }, {
207
213
  key: "notify",
208
214
  value: function notify(searchTime, mentionResult, query) {
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ var AsyncDisabledMentionTooltip = /*#__PURE__*/React.lazy(function () {
3
+ return import( /* webpackChunkName: "@atlaskit-internal_@atlaskit/mention/disabled-mention-tooltip" */'./main').then(function (module) {
4
+ return {
5
+ default: module.DisabledMentionTooltip
6
+ };
7
+ });
8
+ });
9
+ export default AsyncDisabledMentionTooltip;
@@ -0,0 +1,17 @@
1
+ import Tooltip from '@atlaskit/tooltip';
2
+ import React from 'react';
3
+ /**
4
+ * Wraps a disabled `<Mention>` chip with a tooltip explaining why the chip
5
+ * is disabled. The chip itself remains non-interactive; the tooltip is the
6
+ * sole hover affordance.
7
+ */
8
+ export var DisabledMentionTooltip = function DisabledMentionTooltip(_ref) {
9
+ var tooltip = _ref.tooltip,
10
+ children = _ref.children;
11
+ return /*#__PURE__*/React.createElement(Tooltip, {
12
+ content: tooltip,
13
+ position: "top"
14
+ }, function (triggerProps) {
15
+ return /*#__PURE__*/React.createElement("span", triggerProps, children);
16
+ });
17
+ };
@@ -13,7 +13,7 @@ var _excluded = ["mentionType"];
13
13
  import { jsx, css } from '@emotion/react';
14
14
  import { MentionType } from '../../types';
15
15
  import { forwardRef } from 'react';
16
- var mentionStyle = _defineProperty(_defineProperty(_defineProperty({}, MentionType.SELF, {
16
+ var mentionStyle = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, MentionType.SELF, {
17
17
  background: "var(--ds-background-brand-bold, #1868DB)",
18
18
  borderColor: 'transparent',
19
19
  text: "var(--ds-text-inverse, #FFFFFF)",
@@ -31,6 +31,13 @@ var mentionStyle = _defineProperty(_defineProperty(_defineProperty({}, MentionTy
31
31
  text: "var(--ds-text-subtle, #505258)",
32
32
  hoveredBackground: "var(--ds-background-neutral-hovered, #0B120E24)",
33
33
  pressedBackground: "var(--ds-background-neutral-pressed, #080F214A)"
34
+ }), MentionType.DISABLED, {
35
+ background: "var(--ds-background-disabled, #0515240F)",
36
+ borderColor: 'transparent',
37
+ text: "var(--ds-text-disabled, #080F214A)",
38
+ // Disabled chips do not change on hover / press.
39
+ hoveredBackground: "var(--ds-background-disabled, #0515240F)",
40
+ pressedBackground: "var(--ds-background-disabled, #0515240F)"
34
41
  });
35
42
  var getStyle = function getStyle(_ref, property) {
36
43
  var mentionType = _ref.mentionType;
@@ -5,6 +5,8 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
6
  import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+ 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; }
9
+ 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) { _defineProperty(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; }
8
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
11
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
12
  import React from 'react';
@@ -12,6 +14,7 @@ import FocusRing from '@atlaskit/focus-ring';
12
14
  import MessagesIntlProvider from '../MessagesIntlProvider';
13
15
  import PrimitiveMention from './PrimitiveMention';
14
16
  import AsyncNoAccessTooltip from '../NoAccessTooltip';
17
+ import AsyncDisabledMentionTooltip from '../DisabledMentionTooltip';
15
18
  import { isRestricted, MentionType } from '../../types';
16
19
  import { fireAnalyticsMentionEvent } from '../../util/analytics';
17
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
@@ -29,7 +32,12 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
29
32
  var _this$props = _this.props,
30
33
  id = _this$props.id,
31
34
  text = _this$props.text,
32
- onClick = _this$props.onClick;
35
+ onClick = _this$props.onClick,
36
+ isDisabled = _this$props.isDisabled;
37
+ if (isDisabled) {
38
+ // Disabled chips do not invoke their click handler.
39
+ return;
40
+ }
33
41
  if (onClick) {
34
42
  onClick(id, text, e);
35
43
  }
@@ -65,7 +73,11 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
65
73
  _defineProperty(_this, "getMentionType", function () {
66
74
  var _this$props4 = _this.props,
67
75
  accessLevel = _this$props4.accessLevel,
68
- isHighlighted = _this$props4.isHighlighted;
76
+ isHighlighted = _this$props4.isHighlighted,
77
+ isDisabled = _this$props4.isDisabled;
78
+ if (isDisabled) {
79
+ return MentionType.DISABLED;
80
+ }
69
81
  if (isHighlighted) {
70
82
  return MentionType.SELF;
71
83
  }
@@ -115,11 +127,25 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
115
127
  var text = props.text,
116
128
  id = props.id,
117
129
  accessLevel = props.accessLevel,
118
- localId = props.localId;
130
+ localId = props.localId,
131
+ disabledTooltip = props.disabledTooltip;
119
132
  var mentionType = this.getMentionType();
120
133
  var failedMention = text === "@".concat(UNKNOWN_USER_ID);
121
- var showTooltip = mentionType === MentionType.RESTRICTED;
122
- var mentionComponent = /*#__PURE__*/React.createElement(FocusRing, null, /*#__PURE__*/React.createElement(PrimitiveMention, {
134
+ var showRestrictedTooltip = mentionType === MentionType.RESTRICTED;
135
+ var showDisabledTooltip = mentionType === MentionType.DISABLED && !!disabledTooltip;
136
+
137
+ // A11y: when the chip is in the disabled visual state, expose
138
+ // `aria-disabled` so assistive tech announces it as such. The
139
+ // disabled-tooltip text is mirrored into `aria-label` so the
140
+ // announcement carries the reason even without portal-id wiring for
141
+ // `aria-describedby`.
142
+ var isDisabledChip = mentionType === MentionType.DISABLED;
143
+ var disabledA11yProps = isDisabledChip ? _objectSpread({
144
+ 'aria-disabled': true
145
+ }, disabledTooltip ? {
146
+ 'aria-label': "".concat(text || '@...', " \u2014 ").concat(disabledTooltip)
147
+ } : {}) : {};
148
+ var mentionComponent = /*#__PURE__*/React.createElement(FocusRing, null, /*#__PURE__*/React.createElement(PrimitiveMention, _extends({
123
149
  mentionType: mentionType,
124
150
  onClick: handleOnClick,
125
151
  onMouseEnter: handleOnMouseEnter,
@@ -127,11 +153,28 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
127
153
  spellCheck: false,
128
154
  "data-testid": "mention-".concat(id),
129
155
  "data-mention-type": mentionType,
130
- "data-mention-tooltip": showTooltip
131
- }, failedMention ? this.renderUnknownUserError(id) : text || '@...'));
156
+ "data-mention-tooltip": showRestrictedTooltip || showDisabledTooltip
157
+ }, disabledA11yProps), failedMention ? this.renderUnknownUserError(id) : text || '@...'));
132
158
  var ssrPlaceholderProp = props.ssrPlaceholderId ? {
133
159
  'data-ssr-placeholder': props.ssrPlaceholderId
134
160
  } : {};
161
+ var wrappedMention = function () {
162
+ if (showRestrictedTooltip) {
163
+ return /*#__PURE__*/React.createElement(React.Suspense, {
164
+ fallback: mentionComponent
165
+ }, /*#__PURE__*/React.createElement(AsyncNoAccessTooltip, {
166
+ name: text
167
+ }, mentionComponent));
168
+ }
169
+ if (showDisabledTooltip) {
170
+ return /*#__PURE__*/React.createElement(React.Suspense, {
171
+ fallback: mentionComponent
172
+ }, /*#__PURE__*/React.createElement(AsyncDisabledMentionTooltip, {
173
+ tooltip: disabledTooltip
174
+ }, mentionComponent));
175
+ }
176
+ return mentionComponent;
177
+ }();
135
178
  return /*#__PURE__*/React.createElement(UfoErrorBoundary, {
136
179
  id: id
137
180
  }, /*#__PURE__*/React.createElement("span", _extends({
@@ -140,11 +183,7 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
140
183
  "data-local-id": localId,
141
184
  "data-access-level": accessLevel,
142
185
  spellCheck: false
143
- }, ssrPlaceholderProp), /*#__PURE__*/React.createElement(MessagesIntlProvider, null, showTooltip ? /*#__PURE__*/React.createElement(React.Suspense, {
144
- fallback: mentionComponent
145
- }, /*#__PURE__*/React.createElement(AsyncNoAccessTooltip, {
146
- name: text
147
- }, mentionComponent)) : mentionComponent)));
186
+ }, ssrPlaceholderProp), /*#__PURE__*/React.createElement(MessagesIntlProvider, null, wrappedMention)));
148
187
  }
149
188
  }]);
150
189
  }(React.PureComponent);
@@ -23,7 +23,7 @@ import { renderHighlight } from './MentionHighlightHelpers';
23
23
  import MentionDescriptionByline from '../MentionDescriptionByline';
24
24
  import MessagesIntlProvider from '../MessagesIntlProvider';
25
25
  import { MentionAvatar } from '../MentionAvatar';
26
- export { MENTION_ITEM_HEIGHT } from './styles';
26
+ export { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from './styles';
27
27
  var lozengeAppearanceToTagColor = {
28
28
  default: 'standard',
29
29
  success: 'lime',
@@ -107,7 +107,8 @@ var MentionItem = /*#__PURE__*/function (_React$PureComponent) {
107
107
  var _this$props = this.props,
108
108
  mention = _this$props.mention,
109
109
  selected = _this$props.selected,
110
- forwardedRef = _this$props.forwardedRef;
110
+ forwardedRef = _this$props.forwardedRef,
111
+ height = _this$props.height;
111
112
  var id = mention.id,
112
113
  highlight = mention.highlight,
113
114
  presence = mention.presence,
@@ -123,6 +124,7 @@ var MentionItem = /*#__PURE__*/function (_React$PureComponent) {
123
124
  var xProductUserInfoIconColor = selected ? "var(--ds-icon-selected, #1868DB)" : "var(--ds-icon, #292A2E)";
124
125
  return /*#__PURE__*/React.createElement(MessagesIntlProvider, null, /*#__PURE__*/React.createElement(MentionItemStyle, {
125
126
  selected: selected,
127
+ height: height,
126
128
  onMouseDown: this.onMentionSelected,
127
129
  onMouseMove: this.onMentionMenuItemMouseMove,
128
130
  onMouseEnter: this.onMentionMenuItemMouseEnter,
@@ -75,15 +75,18 @@ export var TimeStyle = styled.div({
75
75
  font: "var(--ds-font-body-small, normal 400 12px/16px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)"
76
76
  });
77
77
  export var MENTION_ITEM_HEIGHT = 48;
78
+ export var MENTION_ITEM_HEIGHT_REFRESHED = 44;
78
79
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-styled, @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/ui-styling-standard/no-dynamic-styles -- Ignored via go/DSP-18766
79
80
  export var MentionItemStyle = styled.div(function (props) {
81
+ var _props$height;
80
82
  return {
81
83
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
82
84
  backgroundColor: props.selected ? "var(--ds-background-selected, #E9F2FE)" : 'transparent',
83
85
  display: 'block',
84
86
  overflow: 'hidden',
85
87
  listStyleType: 'none',
86
- height: "".concat(MENTION_ITEM_HEIGHT, "px"),
88
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
89
+ height: "".concat((_props$height = props.height) !== null && _props$height !== void 0 ? _props$height : MENTION_ITEM_HEIGHT, "px"),
87
90
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
88
91
  lineHeight: 1.2,
89
92
  cursor: 'pointer'
package/dist/esm/item.js CHANGED
@@ -1,4 +1,4 @@
1
- import MentionItem, { MENTION_ITEM_HEIGHT } from './components/MentionItem';
1
+ import MentionItem, { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from './components/MentionItem';
2
2
  export {
3
3
  // Components
4
- MentionItem, MENTION_ITEM_HEIGHT };
4
+ MentionItem, MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED };
package/dist/esm/types.js CHANGED
@@ -6,12 +6,24 @@
6
6
  * and `refreshedSecurityProvider` fields.
7
7
  */
8
8
 
9
+ /**
10
+ * Describes whether a mention should be rendered in its disabled visual
11
+ * state and what tooltip (if any) should be shown on hover.
12
+ */
13
+
14
+ /**
15
+ * The minimal input shape used by `getMentionDisabledState`. Kept as a named
16
+ * type so the config callback and the provider method share the same input
17
+ * surface, and so callers do not have to fabricate fields they do not have.
18
+ */
19
+
9
20
  // data is returned from team search service
10
21
 
11
22
  export var MentionType = /*#__PURE__*/function (MentionType) {
12
23
  MentionType[MentionType["SELF"] = 0] = "SELF";
13
24
  MentionType[MentionType["RESTRICTED"] = 1] = "RESTRICTED";
14
25
  MentionType[MentionType["DEFAULT"] = 2] = "DEFAULT";
26
+ MentionType[MentionType["DISABLED"] = 3] = "DISABLED";
15
27
  return MentionType;
16
28
  }({});
17
29
  export var UserAccessLevel = /*#__PURE__*/function (UserAccessLevel) {
@@ -5,7 +5,7 @@ import { OPERATIONAL_EVENT_TYPE, UI_EVENT_TYPE } from '@atlaskit/analytics-gas-t
5
5
  import { ELEMENTS_CHANNEL } from '../_constants';
6
6
  import { ComponentNames, isSpecialMentionText } from '../types';
7
7
  var packageName = "@atlaskit/mention";
8
- var packageVersion = "26.0.3";
8
+ var packageVersion = "26.1.0";
9
9
  export var SLI_EVENT_TYPE = 'sli';
10
10
  export var SMART_EVENT_TYPE = 'smart';
11
11
  export var fireAnalyticsMentionTypeaheadEvent = function fireAnalyticsMentionTypeaheadEvent(props) {
@@ -1,5 +1,5 @@
1
1
  import { type MentionProvider, type MentionContextIdentifier, ErrorCallback, InfoCallback, ResultCallback } from './MentionResource';
2
- import { type MentionDescription, type InviteFromMentionProvider, type XProductInviteMentionProvider, type AnalyticsCallback } from '../types';
2
+ import { type MentionDescription, type MentionDisabledState, type MentionDisabledStateInput, type InviteFromMentionProvider, type XProductInviteMentionProvider, type AnalyticsCallback } from '../types';
3
3
  export type { MentionDescription };
4
4
  export type MentionProviderFunctions = Omit<{
5
5
  [Key in keyof MentionProvider]: MentionProvider[Key] extends Function ? MentionProvider[Key] : never;
@@ -19,5 +19,10 @@ export default class ContextMentionResource implements MentionProvider {
19
19
  filter: (query?: string, contextIdentifier?: MentionContextIdentifier) => void;
20
20
  recordMentionSelection: (mention: MentionDescription, contextIdentifier?: MentionContextIdentifier) => void;
21
21
  shouldHighlightMention: (mention: MentionDescription) => boolean;
22
+ getMentionDisabledState: (mention: MentionDisabledStateInput) => MentionDisabledState | undefined;
23
+ subscribeToDisabledStateChanges: (listener: () => void) => (() => void);
24
+ notifyMentionDestroyed: (mention: {
25
+ id: string;
26
+ }) => void;
22
27
  isFiltering: (query: string) => boolean;
23
28
  }
@@ -1,4 +1,4 @@
1
- import { type AnalyticsCallback, type ErrorCallback, type InfoCallback, type InviteFlow, type MentionContextIdentifier, type MentionDescription, type MentionNameDetails, type MentionProvider, type MentionResourceConfig, type MentionsResult, type MentionStats, type ResourceProvider, type ResultCallback, type UserRole } from '../types';
1
+ import { type AnalyticsCallback, type ErrorCallback, type InfoCallback, type InviteFlow, type MentionContextIdentifier, type MentionDescription, type MentionDisabledState, type MentionDisabledStateInput, type MentionNameDetails, type MentionProvider, type MentionResourceConfig, type MentionsResult, type MentionStats, type ResourceProvider, type ResultCallback, type UserRole } from '../types';
2
2
  export type { MentionStats, ResultCallback, ErrorCallback, InfoCallback, MentionResourceConfig, ResourceProvider, MentionContextIdentifier, MentionProvider, } from '../types';
3
3
  /**
4
4
  * Configuration for the TeamMentionResource, which extends {@link MentionResourceConfig}
@@ -62,6 +62,7 @@ export declare class MentionResource extends AbstractMentionResource implements
62
62
  inviteXProductUser?: (userId: string, mentionName: string) => Promise<void>;
63
63
  constructor(config: MentionResourceConfig);
64
64
  shouldHighlightMention(mention: MentionDescription): boolean;
65
+ getMentionDisabledState(mention: MentionDisabledStateInput): MentionDisabledState | undefined;
65
66
  notify(searchTime: number, mentionResult: MentionsResult, query?: string): void;
66
67
  notifyError(error: Error, query?: string): void;
67
68
  filter(query?: string, contextIdentifier?: MentionContextIdentifier): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare const AsyncDisabledMentionTooltip: React.LazyExoticComponent<({ tooltip, children }: {
3
+ children: React.ReactNode;
4
+ tooltip: string;
5
+ }) => React.JSX.Element>;
6
+ export default AsyncDisabledMentionTooltip;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ type Props = {
3
+ children: React.ReactNode;
4
+ tooltip: string;
5
+ };
6
+ /**
7
+ * Wraps a disabled `<Mention>` chip with a tooltip explaining why the chip
8
+ * is disabled. The chip itself remains non-interactive; the tooltip is the
9
+ * sole hover affordance.
10
+ */
11
+ export declare const DisabledMentionTooltip: ({ tooltip, children }: Props) => React.JSX.Element;
12
+ export {};
@@ -5,7 +5,19 @@ export declare const ANALYTICS_HOVER_DELAY = 1000;
5
5
  export declare const UNKNOWN_USER_ID = "_|unknown|_";
6
6
  export type OwnProps = {
7
7
  accessLevel?: string;
8
+ /**
9
+ * Tooltip text shown on hover when the chip is disabled. Ignored when
10
+ * `isDisabled` is false. When omitted, no tooltip is rendered even if
11
+ * `isDisabled` is true.
12
+ */
13
+ disabledTooltip?: string;
8
14
  id: string;
15
+ /**
16
+ * When true, the mention chip is rendered in its disabled visual state
17
+ * (`MentionType.DISABLED`) and click handlers are not invoked. Takes
18
+ * precedence over `isHighlighted` and the restricted state.
19
+ */
20
+ isDisabled?: boolean;
9
21
  isHighlighted?: boolean;
10
22
  localId?: string;
11
23
  onClick?: MentionEventHandler;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import { type MentionDescription, type OnMentionEvent } from '../../types';
3
- export { MENTION_ITEM_HEIGHT } from './styles';
3
+ export { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from './styles';
4
4
  export interface Props {
5
5
  forwardedRef?: React.Ref<HTMLDivElement>;
6
+ height?: number;
6
7
  mention: MentionDescription;
7
8
  onMouseEnter?: OnMentionEvent;
8
9
  onMouseMove?: OnMentionEvent;
@@ -2,6 +2,7 @@ import { type StyledComponent } from '@emotion/styled';
2
2
  import type { Theme } from '@emotion/react';
3
3
  import type { DetailedHTMLProps, HTMLAttributes } from 'react';
4
4
  export interface MentionItemStyleProps {
5
+ height?: number;
5
6
  selected?: boolean;
6
7
  }
7
8
  export interface AvatarSectionStyleProps {
@@ -38,6 +39,7 @@ export declare const TimeStyle: StyledComponent<{
38
39
  theme?: Theme;
39
40
  }, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
40
41
  export declare const MENTION_ITEM_HEIGHT = 48;
42
+ export declare const MENTION_ITEM_HEIGHT_REFRESHED = 44;
41
43
  export declare const MentionItemStyle: StyledComponent<{
42
44
  as?: React.ElementType;
43
45
  theme?: Theme;
@@ -1,2 +1,2 @@
1
- import MentionItem, { MENTION_ITEM_HEIGHT } from './components/MentionItem';
2
- export { MentionItem, MENTION_ITEM_HEIGHT, };
1
+ import MentionItem, { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from './components/MentionItem';
2
+ export { MentionItem, MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED, };
@@ -39,6 +39,24 @@ export interface MentionResourceConfig extends ServiceConfig {
39
39
  * calls to `filter` will be debounced to reduce the number of network requests.
40
40
  */
41
41
  debounceTime?: number;
42
+ /**
43
+ * A function to determine whether a given mention should be rendered in
44
+ * its disabled visual state (`MentionType.DISABLED`), and what tooltip
45
+ * (if any) to display when the disabled chip is hovered.
46
+ *
47
+ * Returning `{ disabled: false }` (or `undefined`) leaves the mention in
48
+ * whatever state the other predicates resolve to.
49
+ *
50
+ * The input deliberately exposes only the mention's `id` because the
51
+ * canonical caller (the editor mentions `NodeView`) does not have the
52
+ * full `MentionDescription` in scope. Implementations should look the
53
+ * additional context they need (e.g. agent metadata) up via the `id`.
54
+ *
55
+ * @param mention - The minimal mention identifier to evaluate.
56
+ * @returns `{ disabled, tooltip? }` describing the disabled visual state,
57
+ * or `undefined` to leave it unchanged.
58
+ */
59
+ getMentionDisabledState?: (mention: MentionDisabledStateInput) => MentionDisabledState | undefined;
42
60
  /**
43
61
  * Custom HTTP headers to include in mention service requests.
44
62
  */
@@ -94,6 +112,22 @@ export interface MentionResourceConfig extends ServiceConfig {
94
112
  */
95
113
  userRole?: UserRole;
96
114
  }
115
+ /**
116
+ * Describes whether a mention should be rendered in its disabled visual
117
+ * state and what tooltip (if any) should be shown on hover.
118
+ */
119
+ export interface MentionDisabledState {
120
+ disabled: boolean;
121
+ tooltip?: string;
122
+ }
123
+ /**
124
+ * The minimal input shape used by `getMentionDisabledState`. Kept as a named
125
+ * type so the config callback and the provider method share the same input
126
+ * surface, and so callers do not have to fabricate fields they do not have.
127
+ */
128
+ export interface MentionDisabledStateInput {
129
+ id: string;
130
+ }
97
131
  export interface ResourceProvider<Result> {
98
132
  /**
99
133
  * Subscribe to ResourceProvider results
@@ -119,9 +153,40 @@ export type MentionContextIdentifier = {
119
153
  };
120
154
  export interface MentionProvider extends ResourceProvider<MentionDescription[]>, InviteFromMentionProvider, XProductInviteMentionProvider {
121
155
  filter(query?: string, contextIdentifier?: MentionContextIdentifier): void;
156
+ /**
157
+ * Optional. When implemented, lets the rendering surface ask whether a
158
+ * mention should be displayed in its disabled visual state, and what
159
+ * tooltip to surface on hover. Returning `undefined` (or omitting the
160
+ * method entirely) is equivalent to "not disabled".
161
+ */
162
+ getMentionDisabledState?(mention: MentionDisabledStateInput): MentionDisabledState | undefined;
122
163
  isFiltering(query: string): boolean;
164
+ /**
165
+ * Optional. Called by the rendering surface (e.g. the editor NodeView)
166
+ * when a mention chip is destroyed (removed from the doc). This is the
167
+ * lowest-level deletion signal — it fires regardless of how the chip was
168
+ * removed (backspace, select-and-delete, programmatic replace, …) and
169
+ * does not depend on the editor's debounced `onChange` callback.
170
+ *
171
+ * Implementations typically forward the call to consumers via the chat
172
+ * layer so they can react (e.g. update `selectedAgentIds`).
173
+ */
174
+ notifyMentionDestroyed?(mention: {
175
+ id: string;
176
+ }): void;
123
177
  recordMentionSelection(mention: MentionDescription, contextIdentifier?: MentionContextIdentifier): void;
124
178
  shouldHighlightMention(mention: MentionDescription): boolean;
179
+ /**
180
+ * Optional. When implemented, lets the rendering surface subscribe to
181
+ * changes in the disabled-state predicate so already-rendered chips can
182
+ * re-evaluate themselves when the external state that drives
183
+ * `getMentionDisabledState` changes (e.g. the active agent selection in
184
+ * Rovo Chat). Implementations should invoke the listener after their
185
+ * own state changes.
186
+ *
187
+ * Returns an unsubscribe function. Callers MUST invoke it on teardown.
188
+ */
189
+ subscribeToDisabledStateChanges?(listener: () => void): () => void;
125
190
  }
126
191
  export interface HighlightDetail {
127
192
  end: number;
@@ -188,7 +253,8 @@ export interface OnMentionEvent {
188
253
  export declare enum MentionType {
189
254
  SELF = 0,
190
255
  RESTRICTED = 1,
191
- DEFAULT = 2
256
+ DEFAULT = 2,
257
+ DISABLED = 3
192
258
  }
193
259
  export declare enum UserAccessLevel {
194
260
  NONE = 0,
@@ -1,5 +1,5 @@
1
1
  import { type MentionProvider, type MentionContextIdentifier, ErrorCallback, InfoCallback, ResultCallback } from './MentionResource';
2
- import { type MentionDescription, type InviteFromMentionProvider, type XProductInviteMentionProvider, type AnalyticsCallback } from '../types';
2
+ import { type MentionDescription, type MentionDisabledState, type MentionDisabledStateInput, type InviteFromMentionProvider, type XProductInviteMentionProvider, type AnalyticsCallback } from '../types';
3
3
  export type { MentionDescription };
4
4
  export type MentionProviderFunctions = Omit<{
5
5
  [Key in keyof MentionProvider]: MentionProvider[Key] extends Function ? MentionProvider[Key] : never;
@@ -19,5 +19,10 @@ export default class ContextMentionResource implements MentionProvider {
19
19
  filter: (query?: string, contextIdentifier?: MentionContextIdentifier) => void;
20
20
  recordMentionSelection: (mention: MentionDescription, contextIdentifier?: MentionContextIdentifier) => void;
21
21
  shouldHighlightMention: (mention: MentionDescription) => boolean;
22
+ getMentionDisabledState: (mention: MentionDisabledStateInput) => MentionDisabledState | undefined;
23
+ subscribeToDisabledStateChanges: (listener: () => void) => (() => void);
24
+ notifyMentionDestroyed: (mention: {
25
+ id: string;
26
+ }) => void;
22
27
  isFiltering: (query: string) => boolean;
23
28
  }
@@ -1,4 +1,4 @@
1
- import { type AnalyticsCallback, type ErrorCallback, type InfoCallback, type InviteFlow, type MentionContextIdentifier, type MentionDescription, type MentionNameDetails, type MentionProvider, type MentionResourceConfig, type MentionsResult, type MentionStats, type ResourceProvider, type ResultCallback, type UserRole } from '../types';
1
+ import { type AnalyticsCallback, type ErrorCallback, type InfoCallback, type InviteFlow, type MentionContextIdentifier, type MentionDescription, type MentionDisabledState, type MentionDisabledStateInput, type MentionNameDetails, type MentionProvider, type MentionResourceConfig, type MentionsResult, type MentionStats, type ResourceProvider, type ResultCallback, type UserRole } from '../types';
2
2
  export type { MentionStats, ResultCallback, ErrorCallback, InfoCallback, MentionResourceConfig, ResourceProvider, MentionContextIdentifier, MentionProvider, } from '../types';
3
3
  /**
4
4
  * Configuration for the TeamMentionResource, which extends {@link MentionResourceConfig}
@@ -62,6 +62,7 @@ export declare class MentionResource extends AbstractMentionResource implements
62
62
  inviteXProductUser?: (userId: string, mentionName: string) => Promise<void>;
63
63
  constructor(config: MentionResourceConfig);
64
64
  shouldHighlightMention(mention: MentionDescription): boolean;
65
+ getMentionDisabledState(mention: MentionDisabledStateInput): MentionDisabledState | undefined;
65
66
  notify(searchTime: number, mentionResult: MentionsResult, query?: string): void;
66
67
  notifyError(error: Error, query?: string): void;
67
68
  filter(query?: string, contextIdentifier?: MentionContextIdentifier): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare const AsyncDisabledMentionTooltip: React.LazyExoticComponent<({ tooltip, children }: {
3
+ children: React.ReactNode;
4
+ tooltip: string;
5
+ }) => React.JSX.Element>;
6
+ export default AsyncDisabledMentionTooltip;