@atlaskit/mention 27.17.1 → 27.18.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 (225) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/cjs/api/AbstractMentionResource.js +111 -0
  3. package/dist/cjs/api/AbstractPresenceResource.js +41 -0
  4. package/dist/cjs/api/AbstractResource.js +48 -0
  5. package/dist/cjs/api/Callback.js +5 -0
  6. package/dist/cjs/api/DefaultMentionNameResolver.js +178 -0
  7. package/dist/cjs/api/DefaultPresenceCache.js +159 -0
  8. package/dist/cjs/api/DefaultPresenceParser.js +91 -0
  9. package/dist/cjs/api/HttpError.js +16 -0
  10. package/dist/cjs/api/MentionNameResolver.js +13 -201
  11. package/dist/cjs/api/MentionResource.js +52 -157
  12. package/dist/cjs/api/PresenceResource.js +39 -263
  13. package/dist/cjs/api/Queue.js +5 -0
  14. package/dist/cjs/api/isResolvingMentionProvider.js +9 -0
  15. package/dist/cjs/api/mergeNameResolverQueues.js +36 -0
  16. package/dist/cjs/components/Mention/MentionInternal.js +247 -0
  17. package/dist/cjs/components/Mention/ResourcedMention.js +5 -4
  18. package/dist/cjs/components/Mention/index.js +29 -243
  19. package/dist/cjs/components/MentionAvatar/index.js +5 -4
  20. package/dist/cjs/components/MentionItem/index.js +18 -12
  21. package/dist/cjs/components/MentionList/index.js +4 -3
  22. package/dist/cjs/components/MentionPicker/MentionPicker.js +231 -0
  23. package/dist/cjs/components/MentionPicker/index.js +18 -225
  24. package/dist/cjs/components/MessagesIntlProvider/index.js +2 -2
  25. package/dist/cjs/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +228 -0
  26. package/dist/cjs/components/ResourcedMentionList/index.js +14 -223
  27. package/dist/cjs/index.js +17 -15
  28. package/dist/cjs/is-agent-mention.js +12 -0
  29. package/dist/cjs/is-app-mention.js +10 -0
  30. package/dist/cjs/is-promise.js +9 -0
  31. package/dist/cjs/is-restricted.js +10 -0
  32. package/dist/cjs/is-special-mention-text.js +9 -0
  33. package/dist/cjs/is-special-mention.js +10 -0
  34. package/dist/cjs/is-team-mention.js +10 -0
  35. package/dist/cjs/resource.js +15 -12
  36. package/dist/cjs/team-resource.js +9 -9
  37. package/dist/cjs/typeahead.js +4 -0
  38. package/dist/cjs/types.js +71 -30
  39. package/dist/cjs/util/actual-mouse-move.js +14 -0
  40. package/dist/cjs/util/analytics.js +91 -107
  41. package/dist/cjs/util/build-sli-payload.js +27 -0
  42. package/dist/cjs/util/fire-analytics-mention-event.js +32 -0
  43. package/dist/cjs/util/fire-analytics-mention-hydration-event.js +33 -0
  44. package/dist/cjs/util/fire-analytics-mention-typeahead-event.js +34 -0
  45. package/dist/cjs/util/fire-analytics.js +18 -0
  46. package/dist/cjs/util/fire-sli-analytics-event.js +16 -0
  47. package/dist/cjs/util/get-messages-for-locale.js +233 -0
  48. package/dist/cjs/util/i18n.js +9 -254
  49. package/dist/cjs/util/left-click.js +9 -0
  50. package/dist/cjs/util/mouse-location.js +12 -0
  51. package/dist/cjs/util/mouse.js +1 -26
  52. package/dist/cjs/util/package-name.js +7 -0
  53. package/dist/cjs/util/package-version.js +7 -0
  54. package/dist/cjs/util/prop-formatter.js +25 -0
  55. package/dist/es2019/api/AbstractMentionResource.js +73 -0
  56. package/dist/es2019/api/AbstractPresenceResource.js +17 -0
  57. package/dist/es2019/api/AbstractResource.js +33 -0
  58. package/dist/es2019/api/Callback.js +1 -0
  59. package/dist/es2019/api/DefaultMentionNameResolver.js +152 -0
  60. package/dist/es2019/api/DefaultPresenceCache.js +111 -0
  61. package/dist/es2019/api/DefaultPresenceParser.js +58 -0
  62. package/dist/es2019/api/HttpError.js +8 -0
  63. package/dist/es2019/api/MentionNameResolver.js +13 -176
  64. package/dist/es2019/api/MentionResource.js +28 -122
  65. package/dist/es2019/api/PresenceResource.js +19 -185
  66. package/dist/es2019/api/Queue.js +1 -0
  67. package/dist/es2019/api/isResolvingMentionProvider.js +1 -0
  68. package/dist/es2019/api/mergeNameResolverQueues.js +25 -0
  69. package/dist/es2019/components/Mention/MentionInternal.js +225 -0
  70. package/dist/es2019/components/Mention/ResourcedMention.js +4 -3
  71. package/dist/es2019/components/Mention/index.js +19 -223
  72. package/dist/es2019/components/MentionAvatar/index.js +3 -2
  73. package/dist/es2019/components/MentionItem/index.js +14 -8
  74. package/dist/es2019/components/MentionList/index.js +2 -1
  75. package/dist/es2019/components/MentionPicker/MentionPicker.js +198 -0
  76. package/dist/es2019/components/MentionPicker/index.js +15 -198
  77. package/dist/es2019/components/MessagesIntlProvider/index.js +1 -1
  78. package/dist/es2019/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +187 -0
  79. package/dist/es2019/components/ResourcedMentionList/index.js +9 -187
  80. package/dist/es2019/element.js +5 -0
  81. package/dist/es2019/index.js +13 -9
  82. package/dist/es2019/is-agent-mention.js +6 -0
  83. package/dist/es2019/is-app-mention.js +4 -0
  84. package/dist/es2019/is-promise.js +1 -0
  85. package/dist/es2019/is-restricted.js +4 -0
  86. package/dist/es2019/is-special-mention-text.js +3 -0
  87. package/dist/es2019/is-special-mention.js +4 -0
  88. package/dist/es2019/is-team-mention.js +4 -0
  89. package/dist/es2019/item.js +5 -0
  90. package/dist/es2019/resource.js +15 -5
  91. package/dist/es2019/team-resource.js +10 -4
  92. package/dist/es2019/typeahead.js +5 -0
  93. package/dist/es2019/types.js +30 -21
  94. package/dist/es2019/util/actual-mouse-move.js +8 -0
  95. package/dist/es2019/util/analytics.js +35 -91
  96. package/dist/es2019/util/build-sli-payload.js +18 -0
  97. package/dist/es2019/util/fire-analytics-mention-event.js +24 -0
  98. package/dist/es2019/util/fire-analytics-mention-hydration-event.js +25 -0
  99. package/dist/es2019/util/fire-analytics-mention-typeahead-event.js +24 -0
  100. package/dist/es2019/util/fire-analytics.js +10 -0
  101. package/dist/es2019/util/fire-sli-analytics-event.js +8 -0
  102. package/dist/es2019/util/get-messages-for-locale.js +145 -0
  103. package/dist/es2019/util/i18n.js +2 -165
  104. package/dist/es2019/util/left-click.js +3 -0
  105. package/dist/es2019/util/mouse-location.js +6 -0
  106. package/dist/es2019/util/mouse.js +0 -18
  107. package/dist/es2019/util/package-name.js +1 -0
  108. package/dist/es2019/util/package-version.js +1 -0
  109. package/dist/es2019/util/prop-formatter.js +18 -0
  110. package/dist/esm/api/AbstractMentionResource.js +104 -0
  111. package/dist/esm/api/AbstractPresenceResource.js +34 -0
  112. package/dist/esm/api/AbstractResource.js +41 -0
  113. package/dist/esm/api/Callback.js +1 -0
  114. package/dist/esm/api/DefaultMentionNameResolver.js +171 -0
  115. package/dist/esm/api/DefaultPresenceCache.js +152 -0
  116. package/dist/esm/api/DefaultPresenceParser.js +84 -0
  117. package/dist/esm/api/HttpError.js +9 -0
  118. package/dist/esm/api/MentionNameResolver.js +13 -198
  119. package/dist/esm/api/MentionResource.js +30 -154
  120. package/dist/esm/api/PresenceResource.js +22 -256
  121. package/dist/esm/api/Queue.js +1 -0
  122. package/dist/esm/api/isResolvingMentionProvider.js +3 -0
  123. package/dist/esm/api/mergeNameResolverQueues.js +29 -0
  124. package/dist/esm/components/Mention/MentionInternal.js +242 -0
  125. package/dist/esm/components/Mention/ResourcedMention.js +4 -3
  126. package/dist/esm/components/Mention/index.js +19 -240
  127. package/dist/esm/components/MentionAvatar/index.js +3 -2
  128. package/dist/esm/components/MentionItem/index.js +14 -8
  129. package/dist/esm/components/MentionList/index.js +2 -1
  130. package/dist/esm/components/MentionPicker/MentionPicker.js +225 -0
  131. package/dist/esm/components/MentionPicker/index.js +15 -225
  132. package/dist/esm/components/MessagesIntlProvider/index.js +1 -1
  133. package/dist/esm/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +221 -0
  134. package/dist/esm/components/ResourcedMentionList/index.js +9 -221
  135. package/dist/esm/element.js +5 -0
  136. package/dist/esm/index.js +13 -9
  137. package/dist/esm/is-agent-mention.js +6 -0
  138. package/dist/esm/is-app-mention.js +4 -0
  139. package/dist/esm/is-promise.js +3 -0
  140. package/dist/esm/is-restricted.js +4 -0
  141. package/dist/esm/is-special-mention-text.js +3 -0
  142. package/dist/esm/is-special-mention.js +4 -0
  143. package/dist/esm/is-team-mention.js +4 -0
  144. package/dist/esm/item.js +5 -0
  145. package/dist/esm/resource.js +15 -5
  146. package/dist/esm/team-resource.js +10 -4
  147. package/dist/esm/typeahead.js +5 -0
  148. package/dist/esm/types.js +30 -23
  149. package/dist/esm/util/actual-mouse-move.js +8 -0
  150. package/dist/esm/util/analytics.js +35 -105
  151. package/dist/esm/util/build-sli-payload.js +20 -0
  152. package/dist/esm/util/fire-analytics-mention-event.js +26 -0
  153. package/dist/esm/util/fire-analytics-mention-hydration-event.js +27 -0
  154. package/dist/esm/util/fire-analytics-mention-typeahead-event.js +28 -0
  155. package/dist/esm/util/fire-analytics.js +12 -0
  156. package/dist/esm/util/fire-sli-analytics-event.js +10 -0
  157. package/dist/esm/util/get-messages-for-locale.js +163 -0
  158. package/dist/esm/util/i18n.js +2 -183
  159. package/dist/esm/util/left-click.js +3 -0
  160. package/dist/esm/util/mouse-location.js +6 -0
  161. package/dist/esm/util/mouse.js +0 -18
  162. package/dist/esm/util/package-name.js +1 -0
  163. package/dist/esm/util/package-version.js +1 -0
  164. package/dist/esm/util/prop-formatter.js +18 -0
  165. package/dist/types/api/AbstractMentionResource.d.ts +15 -0
  166. package/dist/types/api/AbstractPresenceResource.d.ts +6 -0
  167. package/dist/types/api/AbstractResource.d.ts +11 -0
  168. package/dist/types/api/Callback.d.ts +4 -0
  169. package/dist/types/api/DefaultMentionNameResolver.d.ts +27 -0
  170. package/dist/types/api/DefaultPresenceCache.d.ts +57 -0
  171. package/dist/types/api/DefaultPresenceParser.d.ts +8 -0
  172. package/dist/types/api/HttpError.d.ts +7 -0
  173. package/dist/types/api/MentionNameResolver.d.ts +14 -35
  174. package/dist/types/api/MentionResource.d.ts +18 -33
  175. package/dist/types/api/PresenceResource.d.ts +15 -69
  176. package/dist/types/api/Queue.d.ts +2 -0
  177. package/dist/types/api/isResolvingMentionProvider.d.ts +2 -0
  178. package/dist/types/api/mergeNameResolverQueues.d.ts +6 -0
  179. package/dist/types/components/Mention/MentionInternal.d.ts +27 -0
  180. package/dist/types/components/Mention/ResourcedMention.d.ts +1 -1
  181. package/dist/types/components/Mention/index.d.ts +9 -20
  182. package/dist/types/components/MentionAvatar/index.d.ts +1 -1
  183. package/dist/types/components/MentionItem/index.d.ts +4 -1
  184. package/dist/types/components/MentionPicker/MentionPicker.d.ts +46 -0
  185. package/dist/types/components/MentionPicker/index.d.ts +5 -42
  186. package/dist/types/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.d.ts +30 -0
  187. package/dist/types/components/ResourcedMentionList/index.d.ts +5 -27
  188. package/dist/types/element.d.ts +3 -0
  189. package/dist/types/index.d.ts +15 -10
  190. package/dist/types/is-agent-mention.d.ts +2 -0
  191. package/dist/types/is-app-mention.d.ts +2 -0
  192. package/dist/types/is-promise.d.ts +1 -0
  193. package/dist/types/is-restricted.d.ts +1 -0
  194. package/dist/types/is-special-mention-text.d.ts +1 -0
  195. package/dist/types/is-special-mention.d.ts +2 -0
  196. package/dist/types/is-team-mention.d.ts +2 -0
  197. package/dist/types/item.d.ts +3 -0
  198. package/dist/types/resource.d.ts +15 -6
  199. package/dist/types/team-resource.d.ts +10 -4
  200. package/dist/types/typeahead.d.ts +3 -0
  201. package/dist/types/types.d.ts +28 -8
  202. package/dist/types/util/actual-mouse-move.d.ts +2 -0
  203. package/dist/types/util/analytics.d.ts +33 -10
  204. package/dist/types/util/build-sli-payload.d.ts +4 -0
  205. package/dist/types/util/fire-analytics-mention-event.d.ts +1 -0
  206. package/dist/types/util/fire-analytics-mention-hydration-event.d.ts +1 -0
  207. package/dist/types/util/fire-analytics-mention-typeahead-event.d.ts +1 -0
  208. package/dist/types/util/fire-analytics.d.ts +1 -0
  209. package/dist/types/util/fire-sli-analytics-event.d.ts +1 -0
  210. package/dist/types/util/get-messages-for-locale.d.ts +11 -0
  211. package/dist/types/util/i18n.d.ts +0 -15
  212. package/dist/types/util/left-click.d.ts +2 -0
  213. package/dist/types/util/mouse-location.d.ts +3 -0
  214. package/dist/types/util/mouse.d.ts +0 -4
  215. package/dist/types/util/package-name.d.ts +1 -0
  216. package/dist/types/util/package-version.d.ts +1 -0
  217. package/dist/types/util/prop-formatter.d.ts +5 -0
  218. package/package.json +2 -2
  219. package/dist/cjs/i18n/index.js +0 -216
  220. package/dist/es2019/i18n/index.js +0 -37
  221. package/dist/esm/i18n/index.js +0 -37
  222. package/dist/types/i18n/index.d.ts +0 -37
  223. /package/dist/cjs/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
  224. /package/dist/es2019/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
  225. /package/dist/esm/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
@@ -1,203 +1,20 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React from 'react';
3
- import { IntlProvider, injectIntl } from 'react-intl';
4
- import { Text } from '@atlaskit/primitives/compiled';
5
- import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
6
- import { fireAnalyticsMentionTypeaheadEvent } from '../../util/analytics';
7
- import uniqueId from '../../util/id';
8
- import debug from '../../util/logger';
9
- import Popup from '../Popup';
10
- import ResourcedMentionList from '../ResourcedMentionList';
11
- import { MentionPickerInfoStyle, MentionPickerStyle } from './styles';
12
- /**
13
- * @class MentionPicker
14
- */
15
- export class MentionPicker extends React.PureComponent {
16
- constructor(props) {
17
- super(props);
18
- _defineProperty(this, "selectNext", () => {
19
- if (this.mentionListRef) {
20
- this.mentionListRef.selectNext();
21
- }
22
- });
23
- _defineProperty(this, "selectPrevious", () => {
24
- if (this.mentionListRef) {
25
- this.mentionListRef.selectPrevious();
26
- }
27
- });
28
- _defineProperty(this, "selectIndex", (index, callback) => {
29
- if (this.mentionListRef) {
30
- this.mentionListRef.selectIndex(index, callback);
31
- }
32
- });
33
- _defineProperty(this, "selectId", (id, callback) => {
34
- if (this.mentionListRef) {
35
- this.mentionListRef.selectId(id, callback);
36
- }
37
- });
38
- _defineProperty(this, "chooseCurrentSelection", () => {
39
- if (this.mentionListRef) {
40
- this.mentionListRef.chooseCurrentSelection();
41
- }
42
- });
43
- _defineProperty(this, "mentionsCount", () => {
44
- if (this.mentionListRef) {
45
- return this.mentionListRef.mentionsCount();
46
- }
47
- return 0;
48
- });
49
- /**
50
- * Called after the 'visible' state is changed to decide whether the onOpen or onClose
51
- * handlers should be called.
52
- *
53
- * It should be noted that the visible state of the component is not considered in
54
- * this function. Instead the old state and new state should be passed as parameters.
55
- */
56
- _defineProperty(this, "onFilterVisibilityChange", (oldVisibility, newVisibility) => {
57
- if (oldVisibility !== newVisibility) {
58
- if (newVisibility) {
59
- if (this.props.onOpen) {
60
- this.props.onOpen();
61
- }
62
- } else {
63
- if (this.props.onClose) {
64
- this.props.onClose();
65
- }
66
- }
67
- }
68
- });
69
- // internal, used for callbacks
70
- _defineProperty(this, "filterChange", (mentions, query, stats) => {
71
- debug('ak-mention-picker.filterChange', mentions.length);
72
- const wasVisible = this.state.visible;
73
- const visible = mentions.length > 0;
74
- this.setState({
75
- visible
76
- });
77
- this.onFilterVisibilityChange(wasVisible, visible);
78
- fireAnalyticsMentionTypeaheadEvent(this.props)('rendered', stats && stats.duration, mentions.map(mention => mention.id), query);
79
- });
80
- _defineProperty(this, "filterError", error => {
81
- debug('ak-mention-picker.filterError', error);
82
- const wasVisible = this.state.visible;
83
- this.setState({
84
- visible: true,
85
- info: undefined
86
- });
87
- this.onFilterVisibilityChange(wasVisible, true);
88
- });
89
- _defineProperty(this, "filterInfo", info => {
90
- debug('ak-mention-picker.filterInfo', info);
91
- this.setState({
92
- info
93
- });
94
- });
95
- _defineProperty(this, "handleMentionListRef", ref => {
96
- this.mentionListRef = ref;
97
- });
98
- this.subscriberKey = uniqueId('ak-mention-picker');
99
- this.state = {
100
- visible: false
101
- };
102
- this.applyPropChanges({}, props);
103
- }
104
- componentDidMount() {
105
- this.subscribeResourceProvider(this.props.resourceProvider);
106
- }
107
- UNSAFE_componentWillReceiveProps(nextProps) {
108
- this.applyPropChanges(this.props, nextProps);
109
- }
110
- componentWillUnmount() {
111
- this.unsubscribeResourceProvider(this.props.resourceProvider);
112
- }
113
- // Internal
114
- applyPropChanges(prevProps, nextProps) {
115
- const oldResourceProvider = prevProps.resourceProvider;
116
- const newResourceProvider = nextProps.resourceProvider;
117
- const resourceProviderChanged = oldResourceProvider !== newResourceProvider;
1
+ /* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
118
2
 
119
- // resource provider
120
- if (resourceProviderChanged) {
121
- this.unsubscribeResourceProvider(oldResourceProvider);
122
- this.subscribeResourceProvider(newResourceProvider);
123
- }
124
- }
125
- subscribeResourceProvider(resourceProvider) {
126
- if (resourceProvider) {
127
- resourceProvider.subscribe(this.subscriberKey, this.filterChange, this.filterError, this.filterInfo, undefined);
128
- }
129
- }
130
- unsubscribeResourceProvider(resourceProvider) {
131
- if (resourceProvider) {
132
- resourceProvider.unsubscribe(this.subscriberKey);
133
- }
134
- }
135
- render() {
136
- const {
137
- resourceProvider,
138
- presenceProvider,
139
- onSelection,
140
- query,
141
- target,
142
- position,
143
- zIndex,
144
- offsetX,
145
- offsetY,
146
- intl
147
- } = this.props;
148
- const {
149
- visible,
150
- info
151
- } = this.state;
152
- const resourceMentionList = /*#__PURE__*/React.createElement(ResourcedMentionList, {
153
- resourceProvider: resourceProvider,
154
- presenceProvider: presenceProvider,
155
- onSelection: onSelection,
156
- query: query,
157
- ref: this.handleMentionListRef
158
- });
159
- const infoContent = info && !visible ? /*#__PURE__*/React.createElement(MentionPickerInfoStyle, null, /*#__PURE__*/React.createElement(Text, {
160
- as: "p"
161
- }, info)) : null;
162
- let content;
163
- if (position) {
164
- debug('target, position', target, position);
165
- if (target) {
166
- content = /*#__PURE__*/React.createElement(Popup, {
167
- target: target,
168
- relativePosition: position,
169
- zIndex: zIndex,
170
- offsetX: offsetX,
171
- offsetY: offsetY
172
- }, /*#__PURE__*/React.createElement(IntlProvider, {
173
- locale: (intl === null || intl === void 0 ? void 0 : intl.locale) || 'en'
174
- }, /*#__PURE__*/React.createElement("div", null, resourceMentionList, infoContent)));
175
- } else {
176
- // don't show if we have a position, but no target yet
177
- content = null;
178
- }
179
- } else {
180
- content = /*#__PURE__*/React.createElement("div", null, resourceMentionList, infoContent);
181
- }
182
- return (
183
- /*#__PURE__*/
184
- /* old classnames are essential for Confluence tests */
185
- React.createElement(MentionPickerStyle
186
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
187
- , {
188
- className: "ak-mention-picker",
189
- visible: visible || info
190
- }, content)
191
- );
192
- }
193
- }
194
- _defineProperty(MentionPicker, "defaultProps", {
195
- onSelection: () => {},
196
- onOpen: () => {},
197
- onClose: () => {}
198
- });
3
+ import { injectIntl } from 'react-intl';
4
+ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
5
+ import { MentionPicker } from './MentionPicker';
199
6
  const MentionPickerWithIntl = injectIntl(MentionPicker, {
200
7
  forwardRef: true
201
8
  });
202
9
  export const MentionPickerWithAnalytics = withAnalyticsEvents({})(MentionPickerWithIntl);
203
- export default MentionPickerWithAnalytics;
10
+
11
+ // Merges with the `const` above so that `MentionPickerWithAnalytics` is usable in a type
12
+ // position as the component instance type (e.g. for refs). Both halves of a declaration
13
+ // merge must live in the same module, so this alias cannot be split out.
14
+
15
+ export default MentionPickerWithAnalytics;
16
+
17
+ /**
18
+ * @deprecated Use `import { MentionPicker } from '@atlaskit/mention/mention-picker'` instead.
19
+ */
20
+ export { MentionPicker } from './MentionPicker';
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { IntlProvider, useIntl } from 'react-intl';
4
- import { getMessagesForLocale } from '../../util/i18n';
4
+ import { getMessagesForLocale } from '../../util/get-messages-for-locale';
5
5
  const EMPTY = {};
6
6
  const useI18n = locale => {
7
7
  const [messages, setMessages] = React.useState(EMPTY);
@@ -0,0 +1,187 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import React from 'react';
3
+ import { SLI_EVENT_TYPE } from '../../util/analytics';
4
+ import { fireSliAnalyticsEvent } from '../../util/fire-sli-analytics-event';
5
+ import uniqueId from '../../util/id';
6
+ import debug from '../../util/logger';
7
+ import MentionList from '../MentionList';
8
+ function applyPresence(mentions, presences) {
9
+ const updatedMentions = [];
10
+ for (let i = 0; i < mentions.length; i++) {
11
+ // Shallow copy
12
+ const mention = {
13
+ ...mentions[i]
14
+ };
15
+ const presence = presences[mention.id];
16
+ if (presence) {
17
+ mention.presence = presence;
18
+ }
19
+ updatedMentions.push(mention);
20
+ }
21
+ return updatedMentions;
22
+ }
23
+ function extractPresences(mentions) {
24
+ const presences = {};
25
+ for (let i = 0; i < mentions.length; i++) {
26
+ const mention = mentions[i];
27
+ if (mention.presence) {
28
+ presences[mention.id] = mention.presence;
29
+ }
30
+ }
31
+ return presences;
32
+ }
33
+ export class ResourcedMentionListWithoutAnalytics extends React.PureComponent {
34
+ constructor(props) {
35
+ super(props);
36
+ // API
37
+ _defineProperty(this, "selectNext", () => {
38
+ if (this.mentionListRef) {
39
+ this.mentionListRef.selectNext();
40
+ }
41
+ });
42
+ _defineProperty(this, "selectPrevious", () => {
43
+ if (this.mentionListRef) {
44
+ this.mentionListRef.selectPrevious();
45
+ }
46
+ });
47
+ _defineProperty(this, "selectIndex", (index, callback) => {
48
+ if (this.mentionListRef) {
49
+ this.mentionListRef.selectIndex(index, callback);
50
+ }
51
+ });
52
+ _defineProperty(this, "selectId", (id, callback) => {
53
+ if (this.mentionListRef) {
54
+ this.mentionListRef.selectId(id, callback);
55
+ }
56
+ });
57
+ _defineProperty(this, "chooseCurrentSelection", () => {
58
+ if (this.mentionListRef) {
59
+ this.mentionListRef.chooseCurrentSelection();
60
+ }
61
+ });
62
+ _defineProperty(this, "mentionsCount", () => {
63
+ if (this.mentionListRef) {
64
+ return this.mentionListRef.mentionsCount();
65
+ }
66
+ return 0;
67
+ });
68
+ // internal, used for callbacks
69
+ _defineProperty(this, "filterChange", mentions => {
70
+ // Retain known presence
71
+ const currentPresences = extractPresences(this.state.mentions);
72
+ this.setState({
73
+ resourceError: undefined,
74
+ mentions: applyPresence(mentions, currentPresences)
75
+ });
76
+ this.refreshPresences(mentions);
77
+ });
78
+ _defineProperty(this, "sendAnalytics", (event, actionSubject, action) => {
79
+ if (event === SLI_EVENT_TYPE) {
80
+ fireSliAnalyticsEvent(this.props)(actionSubject, action);
81
+ }
82
+ });
83
+ _defineProperty(this, "filterError", error => {
84
+ debug('ak-resourced-mentions-list._filterError', error);
85
+ this.setState({
86
+ resourceError: error
87
+ });
88
+ });
89
+ _defineProperty(this, "presenceUpdate", presences => {
90
+ this.setState({
91
+ mentions: applyPresence(this.state.mentions, presences)
92
+ });
93
+ });
94
+ _defineProperty(this, "notifySelection", mention => {
95
+ this.props.resourceProvider.recordMentionSelection(mention);
96
+ if (this.props.onSelection) {
97
+ this.props.onSelection(mention);
98
+ }
99
+ });
100
+ _defineProperty(this, "handleMentionListRef", ref => {
101
+ this.mentionListRef = ref;
102
+ });
103
+ this.subscriberKey = uniqueId('ak-resourced-mention-list');
104
+ this.state = {
105
+ resourceError: undefined,
106
+ mentions: []
107
+ };
108
+ this.applyPropChanges({}, props);
109
+ }
110
+ componentDidMount() {
111
+ this.subscribeMentionProvider(this.props.resourceProvider);
112
+ this.subscribePresenceProvider(this.props.presenceProvider);
113
+ }
114
+ UNSAFE_componentWillReceiveProps(nextProps) {
115
+ this.applyPropChanges(this.props, nextProps);
116
+ }
117
+ componentWillUnmount() {
118
+ this.unsubscribeMentionProvider(this.props.resourceProvider);
119
+ this.unsubscribePresenceProvider(this.props.presenceProvider);
120
+ }
121
+ // internal
122
+ subscribeMentionProvider(mentionProvider) {
123
+ if (mentionProvider) {
124
+ mentionProvider.subscribe(this.subscriberKey, this.filterChange, this.filterError, undefined, undefined, this.sendAnalytics);
125
+ }
126
+ }
127
+ subscribePresenceProvider(presenceProvider) {
128
+ if (presenceProvider) {
129
+ presenceProvider.subscribe(this.subscriberKey, this.presenceUpdate);
130
+ }
131
+ }
132
+ unsubscribeMentionProvider(mentionProvider) {
133
+ if (mentionProvider) {
134
+ mentionProvider.unsubscribe(this.subscriberKey);
135
+ }
136
+ }
137
+ unsubscribePresenceProvider(presenceProvider) {
138
+ if (presenceProvider) {
139
+ presenceProvider.unsubscribe(this.subscriberKey);
140
+ }
141
+ }
142
+ applyPropChanges(prevProps, nextProps) {
143
+ const oldResourceProvider = prevProps.resourceProvider;
144
+ const oldPresenceProvider = prevProps.presenceProvider;
145
+ const oldQuery = prevProps.query;
146
+ const newResourceProvider = nextProps.resourceProvider;
147
+ const newPresenceProvider = nextProps.presenceProvider;
148
+ const newQuery = nextProps.query;
149
+ const resourceProviderChanged = oldResourceProvider !== newResourceProvider;
150
+ const queryChanged = oldQuery !== newQuery;
151
+ const canFilter = !!(typeof newQuery === 'string' && newResourceProvider);
152
+ const shouldFilter = canFilter && (queryChanged || resourceProviderChanged);
153
+
154
+ // resource provider
155
+ if (resourceProviderChanged) {
156
+ this.unsubscribeMentionProvider(oldResourceProvider);
157
+ this.subscribeMentionProvider(newResourceProvider);
158
+ }
159
+
160
+ // presence provider
161
+ if (oldPresenceProvider !== newPresenceProvider) {
162
+ this.unsubscribePresenceProvider(oldPresenceProvider);
163
+ this.subscribePresenceProvider(newPresenceProvider);
164
+ }
165
+ if (shouldFilter) {
166
+ newResourceProvider.filter(newQuery);
167
+ }
168
+ }
169
+ refreshPresences(mentions) {
170
+ if (this.props.presenceProvider) {
171
+ const ids = mentions.map(mention => mention.id);
172
+ this.props.presenceProvider.refreshPresence(ids);
173
+ }
174
+ }
175
+ render() {
176
+ const {
177
+ mentions,
178
+ resourceError
179
+ } = this.state;
180
+ return /*#__PURE__*/React.createElement(MentionList, {
181
+ mentions: mentions,
182
+ resourceError: resourceError,
183
+ onSelection: this.notifySelection,
184
+ ref: this.handleMentionListRef
185
+ });
186
+ }
187
+ }
@@ -1,189 +1,11 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React from 'react';
3
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
4
- import uniqueId from '../../util/id';
5
- import debug from '../../util/logger';
6
- import MentionList from '../MentionList';
7
- import { fireSliAnalyticsEvent, SLI_EVENT_TYPE } from '../../util/analytics';
8
- function applyPresence(mentions, presences) {
9
- const updatedMentions = [];
10
- for (let i = 0; i < mentions.length; i++) {
11
- // Shallow copy
12
- const mention = {
13
- ...mentions[i]
14
- };
15
- const presence = presences[mention.id];
16
- if (presence) {
17
- mention.presence = presence;
18
- }
19
- updatedMentions.push(mention);
20
- }
21
- return updatedMentions;
22
- }
23
- function extractPresences(mentions) {
24
- const presences = {};
25
- for (let i = 0; i < mentions.length; i++) {
26
- const mention = mentions[i];
27
- if (mention.presence) {
28
- presences[mention.id] = mention.presence;
29
- }
30
- }
31
- return presences;
32
- }
33
- export class ResourcedMentionListWithoutAnalytics extends React.PureComponent {
34
- constructor(props) {
35
- super(props);
36
- // API
37
- _defineProperty(this, "selectNext", () => {
38
- if (this.mentionListRef) {
39
- this.mentionListRef.selectNext();
40
- }
41
- });
42
- _defineProperty(this, "selectPrevious", () => {
43
- if (this.mentionListRef) {
44
- this.mentionListRef.selectPrevious();
45
- }
46
- });
47
- _defineProperty(this, "selectIndex", (index, callback) => {
48
- if (this.mentionListRef) {
49
- this.mentionListRef.selectIndex(index, callback);
50
- }
51
- });
52
- _defineProperty(this, "selectId", (id, callback) => {
53
- if (this.mentionListRef) {
54
- this.mentionListRef.selectId(id, callback);
55
- }
56
- });
57
- _defineProperty(this, "chooseCurrentSelection", () => {
58
- if (this.mentionListRef) {
59
- this.mentionListRef.chooseCurrentSelection();
60
- }
61
- });
62
- _defineProperty(this, "mentionsCount", () => {
63
- if (this.mentionListRef) {
64
- return this.mentionListRef.mentionsCount();
65
- }
66
- return 0;
67
- });
68
- // internal, used for callbacks
69
- _defineProperty(this, "filterChange", mentions => {
70
- // Retain known presence
71
- const currentPresences = extractPresences(this.state.mentions);
72
- this.setState({
73
- resourceError: undefined,
74
- mentions: applyPresence(mentions, currentPresences)
75
- });
76
- this.refreshPresences(mentions);
77
- });
78
- _defineProperty(this, "sendAnalytics", (event, actionSubject, action) => {
79
- if (event === SLI_EVENT_TYPE) {
80
- fireSliAnalyticsEvent(this.props)(actionSubject, action);
81
- }
82
- });
83
- _defineProperty(this, "filterError", error => {
84
- debug('ak-resourced-mentions-list._filterError', error);
85
- this.setState({
86
- resourceError: error
87
- });
88
- });
89
- _defineProperty(this, "presenceUpdate", presences => {
90
- this.setState({
91
- mentions: applyPresence(this.state.mentions, presences)
92
- });
93
- });
94
- _defineProperty(this, "notifySelection", mention => {
95
- this.props.resourceProvider.recordMentionSelection(mention);
96
- if (this.props.onSelection) {
97
- this.props.onSelection(mention);
98
- }
99
- });
100
- _defineProperty(this, "handleMentionListRef", ref => {
101
- this.mentionListRef = ref;
102
- });
103
- this.subscriberKey = uniqueId('ak-resourced-mention-list');
104
- this.state = {
105
- resourceError: undefined,
106
- mentions: []
107
- };
108
- this.applyPropChanges({}, props);
109
- }
110
- componentDidMount() {
111
- this.subscribeMentionProvider(this.props.resourceProvider);
112
- this.subscribePresenceProvider(this.props.presenceProvider);
113
- }
114
- UNSAFE_componentWillReceiveProps(nextProps) {
115
- this.applyPropChanges(this.props, nextProps);
116
- }
117
- componentWillUnmount() {
118
- this.unsubscribeMentionProvider(this.props.resourceProvider);
119
- this.unsubscribePresenceProvider(this.props.presenceProvider);
120
- }
121
- // internal
122
- subscribeMentionProvider(mentionProvider) {
123
- if (mentionProvider) {
124
- mentionProvider.subscribe(this.subscriberKey, this.filterChange, this.filterError, undefined, undefined, this.sendAnalytics);
125
- }
126
- }
127
- subscribePresenceProvider(presenceProvider) {
128
- if (presenceProvider) {
129
- presenceProvider.subscribe(this.subscriberKey, this.presenceUpdate);
130
- }
131
- }
132
- unsubscribeMentionProvider(mentionProvider) {
133
- if (mentionProvider) {
134
- mentionProvider.unsubscribe(this.subscriberKey);
135
- }
136
- }
137
- unsubscribePresenceProvider(presenceProvider) {
138
- if (presenceProvider) {
139
- presenceProvider.unsubscribe(this.subscriberKey);
140
- }
141
- }
142
- applyPropChanges(prevProps, nextProps) {
143
- const oldResourceProvider = prevProps.resourceProvider;
144
- const oldPresenceProvider = prevProps.presenceProvider;
145
- const oldQuery = prevProps.query;
146
- const newResourceProvider = nextProps.resourceProvider;
147
- const newPresenceProvider = nextProps.presenceProvider;
148
- const newQuery = nextProps.query;
149
- const resourceProviderChanged = oldResourceProvider !== newResourceProvider;
150
- const queryChanged = oldQuery !== newQuery;
151
- const canFilter = !!(typeof newQuery === 'string' && newResourceProvider);
152
- const shouldFilter = canFilter && (queryChanged || resourceProviderChanged);
153
-
154
- // resource provider
155
- if (resourceProviderChanged) {
156
- this.unsubscribeMentionProvider(oldResourceProvider);
157
- this.subscribeMentionProvider(newResourceProvider);
158
- }
1
+ /* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
159
2
 
160
- // presence provider
161
- if (oldPresenceProvider !== newPresenceProvider) {
162
- this.unsubscribePresenceProvider(oldPresenceProvider);
163
- this.subscribePresenceProvider(newPresenceProvider);
164
- }
165
- if (shouldFilter) {
166
- newResourceProvider.filter(newQuery);
167
- }
168
- }
169
- refreshPresences(mentions) {
170
- if (this.props.presenceProvider) {
171
- const ids = mentions.map(mention => mention.id);
172
- this.props.presenceProvider.refreshPresence(ids);
173
- }
174
- }
175
- render() {
176
- const {
177
- mentions,
178
- resourceError
179
- } = this.state;
180
- return /*#__PURE__*/React.createElement(MentionList, {
181
- mentions: mentions,
182
- resourceError: resourceError,
183
- onSelection: this.notifySelection,
184
- ref: this.handleMentionListRef
185
- });
186
- }
187
- }
3
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
4
+ import { ResourcedMentionListWithoutAnalytics } from './ResourcedMentionListWithoutAnalytics';
188
5
  const ResourcedMentionList = withAnalyticsEvents({})(ResourcedMentionListWithoutAnalytics);
189
- export default ResourcedMentionList;
6
+ export default ResourcedMentionList;
7
+
8
+ /**
9
+ * @deprecated Use `import { ResourcedMentionListWithoutAnalytics } from '@atlaskit/mention/resourced-mention-list'` instead.
10
+ */
11
+ export { ResourcedMentionListWithoutAnalytics } from './ResourcedMentionListWithoutAnalytics';
@@ -1,5 +1,10 @@
1
+ /* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
1
2
  import Mention from './components/Mention';
2
3
  import ResourcedMention from './components/Mention/ResourcedMention';
4
+
5
+ /**
6
+ * @deprecated Use `import Mention from '@atlaskit/mention/mention'` instead.
7
+ */
3
8
  export {
4
9
  // Components
5
10
  Mention, ResourcedMention };
@@ -1,16 +1,20 @@
1
- import MentionResource, { AbstractMentionResource, isResolvingMentionProvider } from './api/MentionResource';
1
+ import { ELEMENTS_CHANNEL } from './_constants';
2
+ import { AbstractMentionResource } from './api/AbstractMentionResource';
3
+ import { AbstractPresenceResource } from './api/AbstractPresenceResource';
4
+ import ContextMentionResource from './api/ContextMentionResource';
5
+ import { DefaultMentionNameResolver } from './api/DefaultMentionNameResolver';
6
+ import MentionResource from './api/MentionResource';
7
+ import { isResolvingMentionProvider } from './api/isResolvingMentionProvider';
8
+ import PresenceResource from './api/PresenceResource';
2
9
  import TeamMentionResource from './api/TeamMentionResource';
3
- import PresenceResource, { AbstractPresenceResource } from './api/PresenceResource';
4
- import { DefaultMentionNameResolver } from './api/MentionNameResolver';
10
+ import Mention from './components/Mention';
11
+ import ResourcedMention from './components/Mention/ResourcedMention';
5
12
  import MentionItem from './components/MentionItem';
6
13
  import MentionList from './components/MentionList';
7
- import ResourcedMentionList from './components/ResourcedMentionList';
8
14
  import { MentionPickerWithAnalytics as MentionPicker } from './components/MentionPicker';
9
- import Mention from './components/Mention';
10
- import ResourcedMention from './components/Mention/ResourcedMention';
11
- import { MentionNameStatus, isSpecialMention, UserAccessLevel, UserType, ComponentNames, Actions, SliNames } from './types';
12
- import { ELEMENTS_CHANNEL } from './_constants';
13
- import ContextMentionResource from './api/ContextMentionResource';
15
+ import ResourcedMentionList from './components/ResourcedMentionList';
16
+ import { isSpecialMention } from './is-special-mention';
17
+ import { MentionNameStatus, UserAccessLevel, UserType, ComponentNames, Actions, SliNames } from './types';
14
18
  export {
15
19
  // Classes
16
20
  ContextMentionResource, MentionResource, TeamMentionResource, PresenceResource, DefaultMentionNameResolver, AbstractMentionResource, AbstractPresenceResource, MentionNameStatus,
@@ -0,0 +1,6 @@
1
+ import { UserType } from './types';
2
+ export function isAgentMention(mention) {
3
+ // Like `isAgentTypeAheadItem` in `editor-plugin-mentions/src/ui/type-ahead/index.tsx`
4
+ // and `isAgentUserType` in `editor-plugin-mentions/src/pm-plugins/agent.ts`
5
+ return mention.userType === UserType[UserType.APP] || mention.userType === 'AGENT' || mention.appType === 'agent';
6
+ }
@@ -0,0 +1,4 @@
1
+ import { UserType } from './types';
2
+ export function isAppMention(mention) {
3
+ return mention.userType && mention.userType === UserType[UserType.APP];
4
+ }
@@ -0,0 +1 @@
1
+ export const isPromise = p => !!(p && p.then);
@@ -0,0 +1,4 @@
1
+ import { UserAccessLevel } from './types';
2
+ export function isRestricted(accessLevel) {
3
+ return !!accessLevel && accessLevel === UserAccessLevel[UserAccessLevel.NONE];
4
+ }
@@ -0,0 +1,3 @@
1
+ export function isSpecialMentionText(mentionText) {
2
+ return mentionText && (mentionText === '@all' || mentionText === '@here');
3
+ }