@atlaskit/mention 27.17.1 → 27.18.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.
- package/CHANGELOG.md +34 -0
- package/dist/cjs/api/AbstractMentionResource.js +111 -0
- package/dist/cjs/api/AbstractPresenceResource.js +41 -0
- package/dist/cjs/api/AbstractResource.js +48 -0
- package/dist/cjs/api/Callback.js +5 -0
- package/dist/cjs/api/DefaultMentionNameResolver.js +178 -0
- package/dist/cjs/api/DefaultPresenceCache.js +159 -0
- package/dist/cjs/api/DefaultPresenceParser.js +91 -0
- package/dist/cjs/api/HttpError.js +16 -0
- package/dist/cjs/api/MentionNameResolver.js +13 -201
- package/dist/cjs/api/MentionResource.js +52 -157
- package/dist/cjs/api/PresenceResource.js +39 -263
- package/dist/cjs/api/Queue.js +5 -0
- package/dist/cjs/api/isResolvingMentionProvider.js +9 -0
- package/dist/cjs/api/mergeNameResolverQueues.js +36 -0
- package/dist/cjs/components/Mention/MentionInternal.js +247 -0
- package/dist/cjs/components/Mention/ResourcedMention.js +5 -4
- package/dist/cjs/components/Mention/index.js +29 -243
- package/dist/cjs/components/MentionAvatar/index.js +5 -4
- package/dist/cjs/components/MentionItem/index.js +18 -12
- package/dist/cjs/components/MentionList/index.js +4 -3
- package/dist/cjs/components/MentionPicker/MentionPicker.js +231 -0
- package/dist/cjs/components/MentionPicker/index.js +18 -225
- package/dist/cjs/components/MessagesIntlProvider/index.js +2 -2
- package/dist/cjs/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +228 -0
- package/dist/cjs/components/ResourcedMentionList/index.js +14 -223
- package/dist/cjs/index.js +17 -15
- package/dist/cjs/is-agent-mention.js +12 -0
- package/dist/cjs/is-app-mention.js +10 -0
- package/dist/cjs/is-promise.js +9 -0
- package/dist/cjs/is-restricted.js +10 -0
- package/dist/cjs/is-special-mention-text.js +9 -0
- package/dist/cjs/is-special-mention.js +10 -0
- package/dist/cjs/is-team-mention.js +10 -0
- package/dist/cjs/resource.js +15 -12
- package/dist/cjs/team-resource.js +9 -9
- package/dist/cjs/typeahead.js +4 -0
- package/dist/cjs/types.js +71 -30
- package/dist/cjs/util/actual-mouse-move.js +14 -0
- package/dist/cjs/util/analytics.js +91 -107
- package/dist/cjs/util/build-sli-payload.js +27 -0
- package/dist/cjs/util/fire-analytics-mention-event.js +32 -0
- package/dist/cjs/util/fire-analytics-mention-hydration-event.js +33 -0
- package/dist/cjs/util/fire-analytics-mention-typeahead-event.js +34 -0
- package/dist/cjs/util/fire-analytics.js +18 -0
- package/dist/cjs/util/fire-sli-analytics-event.js +16 -0
- package/dist/cjs/util/get-messages-for-locale.js +233 -0
- package/dist/cjs/util/i18n.js +9 -254
- package/dist/cjs/util/left-click.js +9 -0
- package/dist/cjs/util/mouse-location.js +12 -0
- package/dist/cjs/util/mouse.js +1 -26
- package/dist/cjs/util/package-name.js +7 -0
- package/dist/cjs/util/package-version.js +7 -0
- package/dist/cjs/util/prop-formatter.js +25 -0
- package/dist/es2019/api/AbstractMentionResource.js +73 -0
- package/dist/es2019/api/AbstractPresenceResource.js +17 -0
- package/dist/es2019/api/AbstractResource.js +33 -0
- package/dist/es2019/api/Callback.js +1 -0
- package/dist/es2019/api/DefaultMentionNameResolver.js +152 -0
- package/dist/es2019/api/DefaultPresenceCache.js +111 -0
- package/dist/es2019/api/DefaultPresenceParser.js +58 -0
- package/dist/es2019/api/HttpError.js +8 -0
- package/dist/es2019/api/MentionNameResolver.js +13 -176
- package/dist/es2019/api/MentionResource.js +28 -122
- package/dist/es2019/api/PresenceResource.js +19 -185
- package/dist/es2019/api/Queue.js +1 -0
- package/dist/es2019/api/isResolvingMentionProvider.js +1 -0
- package/dist/es2019/api/mergeNameResolverQueues.js +25 -0
- package/dist/es2019/components/Mention/MentionInternal.js +225 -0
- package/dist/es2019/components/Mention/ResourcedMention.js +4 -3
- package/dist/es2019/components/Mention/index.js +19 -223
- package/dist/es2019/components/MentionAvatar/index.js +3 -2
- package/dist/es2019/components/MentionItem/index.js +14 -8
- package/dist/es2019/components/MentionList/index.js +2 -1
- package/dist/es2019/components/MentionPicker/MentionPicker.js +198 -0
- package/dist/es2019/components/MentionPicker/index.js +15 -198
- package/dist/es2019/components/MessagesIntlProvider/index.js +1 -1
- package/dist/es2019/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +187 -0
- package/dist/es2019/components/ResourcedMentionList/index.js +9 -187
- package/dist/es2019/element.js +5 -0
- package/dist/es2019/index.js +13 -9
- package/dist/es2019/is-agent-mention.js +6 -0
- package/dist/es2019/is-app-mention.js +4 -0
- package/dist/es2019/is-promise.js +1 -0
- package/dist/es2019/is-restricted.js +4 -0
- package/dist/es2019/is-special-mention-text.js +3 -0
- package/dist/es2019/is-special-mention.js +4 -0
- package/dist/es2019/is-team-mention.js +4 -0
- package/dist/es2019/item.js +5 -0
- package/dist/es2019/resource.js +15 -5
- package/dist/es2019/team-resource.js +10 -4
- package/dist/es2019/typeahead.js +5 -0
- package/dist/es2019/types.js +30 -21
- package/dist/es2019/util/actual-mouse-move.js +8 -0
- package/dist/es2019/util/analytics.js +35 -91
- package/dist/es2019/util/build-sli-payload.js +18 -0
- package/dist/es2019/util/fire-analytics-mention-event.js +24 -0
- package/dist/es2019/util/fire-analytics-mention-hydration-event.js +25 -0
- package/dist/es2019/util/fire-analytics-mention-typeahead-event.js +24 -0
- package/dist/es2019/util/fire-analytics.js +10 -0
- package/dist/es2019/util/fire-sli-analytics-event.js +8 -0
- package/dist/es2019/util/get-messages-for-locale.js +145 -0
- package/dist/es2019/util/i18n.js +2 -165
- package/dist/es2019/util/left-click.js +3 -0
- package/dist/es2019/util/mouse-location.js +6 -0
- package/dist/es2019/util/mouse.js +0 -18
- package/dist/es2019/util/package-name.js +1 -0
- package/dist/es2019/util/package-version.js +1 -0
- package/dist/es2019/util/prop-formatter.js +18 -0
- package/dist/esm/api/AbstractMentionResource.js +104 -0
- package/dist/esm/api/AbstractPresenceResource.js +34 -0
- package/dist/esm/api/AbstractResource.js +41 -0
- package/dist/esm/api/Callback.js +1 -0
- package/dist/esm/api/DefaultMentionNameResolver.js +171 -0
- package/dist/esm/api/DefaultPresenceCache.js +152 -0
- package/dist/esm/api/DefaultPresenceParser.js +84 -0
- package/dist/esm/api/HttpError.js +9 -0
- package/dist/esm/api/MentionNameResolver.js +13 -198
- package/dist/esm/api/MentionResource.js +30 -154
- package/dist/esm/api/PresenceResource.js +22 -256
- package/dist/esm/api/Queue.js +1 -0
- package/dist/esm/api/isResolvingMentionProvider.js +3 -0
- package/dist/esm/api/mergeNameResolverQueues.js +29 -0
- package/dist/esm/components/Mention/MentionInternal.js +242 -0
- package/dist/esm/components/Mention/ResourcedMention.js +4 -3
- package/dist/esm/components/Mention/index.js +19 -240
- package/dist/esm/components/MentionAvatar/index.js +3 -2
- package/dist/esm/components/MentionItem/index.js +14 -8
- package/dist/esm/components/MentionList/index.js +2 -1
- package/dist/esm/components/MentionPicker/MentionPicker.js +225 -0
- package/dist/esm/components/MentionPicker/index.js +15 -225
- package/dist/esm/components/MessagesIntlProvider/index.js +1 -1
- package/dist/esm/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +221 -0
- package/dist/esm/components/ResourcedMentionList/index.js +9 -221
- package/dist/esm/element.js +5 -0
- package/dist/esm/index.js +13 -9
- package/dist/esm/is-agent-mention.js +6 -0
- package/dist/esm/is-app-mention.js +4 -0
- package/dist/esm/is-promise.js +3 -0
- package/dist/esm/is-restricted.js +4 -0
- package/dist/esm/is-special-mention-text.js +3 -0
- package/dist/esm/is-special-mention.js +4 -0
- package/dist/esm/is-team-mention.js +4 -0
- package/dist/esm/item.js +5 -0
- package/dist/esm/resource.js +15 -5
- package/dist/esm/team-resource.js +10 -4
- package/dist/esm/typeahead.js +5 -0
- package/dist/esm/types.js +30 -23
- package/dist/esm/util/actual-mouse-move.js +8 -0
- package/dist/esm/util/analytics.js +35 -105
- package/dist/esm/util/build-sli-payload.js +20 -0
- package/dist/esm/util/fire-analytics-mention-event.js +26 -0
- package/dist/esm/util/fire-analytics-mention-hydration-event.js +27 -0
- package/dist/esm/util/fire-analytics-mention-typeahead-event.js +28 -0
- package/dist/esm/util/fire-analytics.js +12 -0
- package/dist/esm/util/fire-sli-analytics-event.js +10 -0
- package/dist/esm/util/get-messages-for-locale.js +163 -0
- package/dist/esm/util/i18n.js +2 -183
- package/dist/esm/util/left-click.js +3 -0
- package/dist/esm/util/mouse-location.js +6 -0
- package/dist/esm/util/mouse.js +0 -18
- package/dist/esm/util/package-name.js +1 -0
- package/dist/esm/util/package-version.js +1 -0
- package/dist/esm/util/prop-formatter.js +18 -0
- package/dist/types/api/AbstractMentionResource.d.ts +15 -0
- package/dist/types/api/AbstractPresenceResource.d.ts +6 -0
- package/dist/types/api/AbstractResource.d.ts +11 -0
- package/dist/types/api/Callback.d.ts +4 -0
- package/dist/types/api/DefaultMentionNameResolver.d.ts +27 -0
- package/dist/types/api/DefaultPresenceCache.d.ts +57 -0
- package/dist/types/api/DefaultPresenceParser.d.ts +8 -0
- package/dist/types/api/HttpError.d.ts +7 -0
- package/dist/types/api/MentionNameResolver.d.ts +14 -35
- package/dist/types/api/MentionResource.d.ts +18 -33
- package/dist/types/api/PresenceResource.d.ts +15 -69
- package/dist/types/api/Queue.d.ts +2 -0
- package/dist/types/api/isResolvingMentionProvider.d.ts +2 -0
- package/dist/types/api/mergeNameResolverQueues.d.ts +6 -0
- package/dist/types/components/Mention/MentionInternal.d.ts +27 -0
- package/dist/types/components/Mention/ResourcedMention.d.ts +1 -1
- package/dist/types/components/Mention/index.d.ts +9 -20
- package/dist/types/components/MentionAvatar/index.d.ts +1 -1
- package/dist/types/components/MentionItem/index.d.ts +4 -1
- package/dist/types/components/MentionPicker/MentionPicker.d.ts +46 -0
- package/dist/types/components/MentionPicker/index.d.ts +5 -42
- package/dist/types/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.d.ts +30 -0
- package/dist/types/components/ResourcedMentionList/index.d.ts +5 -27
- package/dist/types/element.d.ts +3 -0
- package/dist/types/index.d.ts +15 -10
- package/dist/types/is-agent-mention.d.ts +2 -0
- package/dist/types/is-app-mention.d.ts +2 -0
- package/dist/types/is-promise.d.ts +1 -0
- package/dist/types/is-restricted.d.ts +1 -0
- package/dist/types/is-special-mention-text.d.ts +1 -0
- package/dist/types/is-special-mention.d.ts +2 -0
- package/dist/types/is-team-mention.d.ts +2 -0
- package/dist/types/item.d.ts +3 -0
- package/dist/types/resource.d.ts +15 -6
- package/dist/types/team-resource.d.ts +10 -4
- package/dist/types/typeahead.d.ts +3 -0
- package/dist/types/types.d.ts +28 -8
- package/dist/types/util/actual-mouse-move.d.ts +2 -0
- package/dist/types/util/analytics.d.ts +33 -10
- package/dist/types/util/build-sli-payload.d.ts +4 -0
- package/dist/types/util/fire-analytics-mention-event.d.ts +1 -0
- package/dist/types/util/fire-analytics-mention-hydration-event.d.ts +1 -0
- package/dist/types/util/fire-analytics-mention-typeahead-event.d.ts +1 -0
- package/dist/types/util/fire-analytics.d.ts +1 -0
- package/dist/types/util/fire-sli-analytics-event.d.ts +1 -0
- package/dist/types/util/get-messages-for-locale.d.ts +11 -0
- package/dist/types/util/i18n.d.ts +0 -15
- package/dist/types/util/left-click.d.ts +2 -0
- package/dist/types/util/mouse-location.d.ts +3 -0
- package/dist/types/util/mouse.d.ts +0 -4
- package/dist/types/util/package-name.d.ts +1 -0
- package/dist/types/util/package-version.d.ts +1 -0
- package/dist/types/util/prop-formatter.d.ts +5 -0
- package/package.json +1 -1
- package/dist/cjs/i18n/index.js +0 -216
- package/dist/es2019/i18n/index.js +0 -37
- package/dist/esm/i18n/index.js +0 -37
- package/dist/types/i18n/index.d.ts +0 -37
- /package/dist/cjs/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
- /package/dist/es2019/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
- /package/dist/esm/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
|
|
2
|
+
|
|
2
3
|
import { buildAtlAttributionHeaderValue } from '../util/atl-attribution';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
4
|
+
import { AbstractPresenceResource } from './AbstractPresenceResource';
|
|
5
|
+
import { DefaultPresenceCache } from './DefaultPresenceCache';
|
|
6
|
+
import { DefaultPresenceParser } from './DefaultPresenceParser';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Configuration for the PresenceResource, which manages real-time user
|
|
@@ -9,31 +11,7 @@ import { AbstractResource } from './MentionResource';
|
|
|
9
11
|
* presence service.
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
|
-
class
|
|
13
|
-
constructor(pres, timeout) {
|
|
14
|
-
this.presence = pres;
|
|
15
|
-
this.expiry = Date.now() + timeout;
|
|
16
|
-
}
|
|
17
|
-
expired() {
|
|
18
|
-
return Date.now() > this.expiry;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
class AbstractPresenceResource extends AbstractResource {
|
|
22
|
-
refreshPresence(userIds) {
|
|
23
|
-
throw new Error(`not yet implemented.\nParams: userIds=${userIds}`);
|
|
24
|
-
}
|
|
25
|
-
notifyListeners(presences) {
|
|
26
|
-
this.changeListeners.forEach((listener, key) => {
|
|
27
|
-
try {
|
|
28
|
-
listener(presences);
|
|
29
|
-
} catch (e) {
|
|
30
|
-
// ignore error from listener
|
|
31
|
-
debug(`error from listener '${key}', ignoring`, e);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
class PresenceResource extends AbstractPresenceResource {
|
|
14
|
+
export class PresenceResource extends AbstractPresenceResource {
|
|
37
15
|
constructor(config) {
|
|
38
16
|
super();
|
|
39
17
|
if (!config.url) {
|
|
@@ -102,163 +80,19 @@ class PresenceResource extends AbstractPresenceResource {
|
|
|
102
80
|
return url;
|
|
103
81
|
}
|
|
104
82
|
}
|
|
105
|
-
export
|
|
106
|
-
constructor(cacheTimeout, cacheTrigger) {
|
|
107
|
-
this.expiryInMillis = cacheTimeout ? cacheTimeout : DefaultPresenceCache.defaultTimeout;
|
|
108
|
-
this.flushTrigger = cacheTrigger ? cacheTrigger : DefaultPresenceCache.defaultFlushTrigger;
|
|
109
|
-
this.cache = {};
|
|
110
|
-
this.size = 0;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Precondition: _delete is only called internally if userId exists in cache
|
|
115
|
-
* Removes cache entry
|
|
116
|
-
* @param userId
|
|
117
|
-
*/
|
|
118
|
-
_delete(userId) {
|
|
119
|
-
delete this.cache[userId];
|
|
120
|
-
this.size--;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Checks a cache entry and calls delete if the info has expired
|
|
125
|
-
* @param userId
|
|
126
|
-
*/
|
|
127
|
-
_deleteIfExpired(userId) {
|
|
128
|
-
if (this.contains(userId) && this.cache[userId].expired()) {
|
|
129
|
-
this._delete(userId);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Cleans expired entries from cache
|
|
135
|
-
*/
|
|
136
|
-
_removeExpired() {
|
|
137
|
-
Object.keys(this.cache).forEach(id => {
|
|
138
|
-
this._deleteIfExpired(id);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Checks if a user exists in the cache
|
|
144
|
-
* @param userId
|
|
145
|
-
*/
|
|
146
|
-
contains(userId) {
|
|
147
|
-
return this.cache.hasOwnProperty(userId);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Retrieves a presence from the cache after checking for expired entries
|
|
152
|
-
* @param userId - to index the cache
|
|
153
|
-
* @returns Presence - the presence that matches the userId
|
|
154
|
-
*/
|
|
155
|
-
get(userId) {
|
|
156
|
-
this._deleteIfExpired(userId);
|
|
157
|
-
if (!this.contains(userId)) {
|
|
158
|
-
return {};
|
|
159
|
-
}
|
|
160
|
-
return this.cache[userId].presence;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Retrieve multiple presences at once from the cache
|
|
165
|
-
* @param userIds - to index the cache
|
|
166
|
-
* @returns PresenceMap - A map of userIds to cached Presences
|
|
167
|
-
*/
|
|
168
|
-
getBulk(userIds) {
|
|
169
|
-
const presences = {};
|
|
170
|
-
for (const userId of userIds) {
|
|
171
|
-
if (this.contains(userId)) {
|
|
172
|
-
presences[userId] = this.get(userId);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return presences;
|
|
176
|
-
}
|
|
83
|
+
export default PresenceResource;
|
|
177
84
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
* @returns string[] - ids missing from the cache
|
|
183
|
-
*/
|
|
184
|
-
getMissingUserIds(userIds) {
|
|
185
|
-
return userIds.filter(id => !this.contains(id));
|
|
186
|
-
}
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated Use `import { DefaultPresenceCache } from '@atlaskit/mention/presence-resource'` instead.
|
|
87
|
+
*/
|
|
88
|
+
export { DefaultPresenceCache } from './DefaultPresenceCache';
|
|
187
89
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
* @param presMap
|
|
193
|
-
*/
|
|
194
|
-
update(presMap) {
|
|
195
|
-
if (this.size >= this.flushTrigger) {
|
|
196
|
-
this._removeExpired();
|
|
197
|
-
}
|
|
198
|
-
Object.keys(presMap).forEach(userId => {
|
|
199
|
-
this.cache[userId] = new CacheEntry(presMap[userId], this.expiryInMillis);
|
|
200
|
-
this.size++;
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
_defineProperty(DefaultPresenceCache, "defaultTimeout", 20000);
|
|
205
|
-
_defineProperty(DefaultPresenceCache, "defaultFlushTrigger", 50);
|
|
206
|
-
export class DefaultPresenceParser {
|
|
207
|
-
mapState(state) {
|
|
208
|
-
if (state === 'unavailable') {
|
|
209
|
-
return 'offline';
|
|
210
|
-
} else if (state === 'available') {
|
|
211
|
-
return 'online';
|
|
212
|
-
} else {
|
|
213
|
-
return state;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
parse(response) {
|
|
217
|
-
const presences = {};
|
|
218
|
-
if (response.hasOwnProperty('data') && response['data'].hasOwnProperty('PresenceBulk')) {
|
|
219
|
-
const results = response['data'].PresenceBulk;
|
|
220
|
-
// Store map of state and time indexed by userId. Ignore null results.
|
|
221
|
-
for (const user of results) {
|
|
222
|
-
if (user.userId && user.state) {
|
|
223
|
-
const state = DefaultPresenceParser.extractState(user) || user.state;
|
|
224
|
-
presences[user.userId] = {
|
|
225
|
-
status: this.mapState(state)
|
|
226
|
-
};
|
|
227
|
-
} else if (!user.hasOwnProperty('userId') || !user.hasOwnProperty('state')) {
|
|
228
|
-
// eslint-disable-next-line no-console
|
|
229
|
-
console.error('Unexpected response from presence service contains keys: ' + Object.keys(user));
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return presences;
|
|
234
|
-
}
|
|
235
|
-
static extractState(presence) {
|
|
236
|
-
if (DefaultPresenceParser.isFocusState(presence)) {
|
|
237
|
-
return DefaultPresenceParser.FOCUS_STATE;
|
|
238
|
-
}
|
|
239
|
-
return presence.state;
|
|
240
|
-
}
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use `import { DefaultPresenceParser } from '@atlaskit/mention/presence-resource'` instead.
|
|
92
|
+
*/
|
|
93
|
+
export { DefaultPresenceParser } from './DefaultPresenceParser';
|
|
241
94
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
*/
|
|
247
|
-
static isFocusState(presence) {
|
|
248
|
-
if (presence.stateMetadata) {
|
|
249
|
-
try {
|
|
250
|
-
const metadata = JSON.parse(presence.stateMetadata);
|
|
251
|
-
return metadata && !!metadata.focus;
|
|
252
|
-
} catch (e) {
|
|
253
|
-
// eslint-disable-next-line no-console
|
|
254
|
-
console.error(`Failed to parse presence's stateMetadata for user with id ${presence.userId}: ${presence.stateMetadata}`);
|
|
255
|
-
// eslint-disable-next-line no-console
|
|
256
|
-
console.error(e);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
_defineProperty(DefaultPresenceParser, "FOCUS_STATE", 'focus');
|
|
263
|
-
export { AbstractPresenceResource };
|
|
264
|
-
export default PresenceResource;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated Use `import { AbstractPresenceResource } from '@atlaskit/mention/presence-resource'` instead.
|
|
97
|
+
*/
|
|
98
|
+
export { AbstractPresenceResource } from './AbstractPresenceResource';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isResolvingMentionProvider = p => !!(p && p.supportsMentionNameResolving && p.supportsMentionNameResolving());
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge the two queues making sure to merge callback arrays for items in queueB already in queueA.
|
|
3
|
+
* This addresses [this ticket](https://product-fabric.atlassian.net/browse/QS-3789).
|
|
4
|
+
*/
|
|
5
|
+
export function mergeNameResolverQueues(queueA, queueB) {
|
|
6
|
+
const queueBeingMerged = new Map([...queueA]);
|
|
7
|
+
|
|
8
|
+
// now add the items from the second queue that are not already in the
|
|
9
|
+
// merged queue being built
|
|
10
|
+
[...queueB].forEach(item => {
|
|
11
|
+
const [key, queueBCallbacks] = item;
|
|
12
|
+
const itemAlreadyInMergedQueue = queueBeingMerged.has(key);
|
|
13
|
+
if (!itemAlreadyInMergedQueue) {
|
|
14
|
+
queueBeingMerged.set(key, queueBCallbacks);
|
|
15
|
+
} else {
|
|
16
|
+
var _queueBeingMerged$get;
|
|
17
|
+
// item already in merged queue, merge the callback arrays
|
|
18
|
+
const queueACallbacks = (_queueBeingMerged$get = queueBeingMerged.get(key)) !== null && _queueBeingMerged$get !== void 0 ? _queueBeingMerged$get : [];
|
|
19
|
+
const mergedCallbacks = new Set([...queueBCallbacks, ...queueACallbacks]);
|
|
20
|
+
const deduplicatedCallbacks = Array.from(mergedCallbacks.values()); // prevents calling them twice
|
|
21
|
+
queueBeingMerged.set(key, deduplicatedCallbacks);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return queueBeingMerged;
|
|
25
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/* MentionInternal.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import "./MentionInternal.compiled.css";
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
+
/* eslint-disable @atlaskit/design-system/no-deprecated-imports, @typescript-eslint/ban-types -- Preserve existing mention implementation while focus-ring usage is reviewed separately. */
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import FocusRing from '@atlaskit/focus-ring';
|
|
10
|
+
import { UFOExperienceState } from '@atlaskit/ufo';
|
|
11
|
+
import { UNKNOWN_USER_ID } from '../../_constants';
|
|
12
|
+
import { isRestricted } from '../../is-restricted';
|
|
13
|
+
import { MentionType } from '../../types';
|
|
14
|
+
import { UnknownUserError } from '../../util/i18n';
|
|
15
|
+
import AsyncDisabledMentionTooltip from '../DisabledMentionTooltip';
|
|
16
|
+
import MessagesIntlProvider from '../MessagesIntlProvider';
|
|
17
|
+
import AsyncNoAccessTooltip from '../NoAccessTooltip';
|
|
18
|
+
import PrimitiveMention from './PrimitiveMention';
|
|
19
|
+
import { ANALYTICS_HOVER_DELAY } from './index';
|
|
20
|
+
import { UfoErrorBoundary, mentionRenderedUfoExperience } from './ufoExperiences';
|
|
21
|
+
const avatarStyles = null;
|
|
22
|
+
const avatarFallbackStyles = null;
|
|
23
|
+
const avatarImageStyles = null;
|
|
24
|
+
const agentAvatarStyles = null;
|
|
25
|
+
export class MentionInternal extends React.PureComponent {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
_defineProperty(this, "state", {
|
|
29
|
+
hasAvatarError: false
|
|
30
|
+
});
|
|
31
|
+
_defineProperty(this, "handleAvatarError", () => {
|
|
32
|
+
this.setState({
|
|
33
|
+
hasAvatarError: true
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
_defineProperty(this, "handleOnClick", e => {
|
|
37
|
+
const {
|
|
38
|
+
id,
|
|
39
|
+
text,
|
|
40
|
+
onClick,
|
|
41
|
+
isDisabled
|
|
42
|
+
} = this.props;
|
|
43
|
+
if (isDisabled) {
|
|
44
|
+
// Disabled chips do not invoke their click handler.
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (onClick) {
|
|
48
|
+
onClick(id, text, e);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
_defineProperty(this, "handleOnMouseEnter", e => {
|
|
52
|
+
const {
|
|
53
|
+
id,
|
|
54
|
+
text,
|
|
55
|
+
onMouseEnter,
|
|
56
|
+
onHover
|
|
57
|
+
} = this.props;
|
|
58
|
+
if (onMouseEnter) {
|
|
59
|
+
onMouseEnter(id, text, e);
|
|
60
|
+
}
|
|
61
|
+
this.hoverTimeout = window.setTimeout(() => {
|
|
62
|
+
if (onHover) {
|
|
63
|
+
onHover();
|
|
64
|
+
}
|
|
65
|
+
this.hoverTimeout = undefined;
|
|
66
|
+
}, ANALYTICS_HOVER_DELAY);
|
|
67
|
+
});
|
|
68
|
+
_defineProperty(this, "handleOnMouseLeave", e => {
|
|
69
|
+
const {
|
|
70
|
+
id,
|
|
71
|
+
text,
|
|
72
|
+
onMouseLeave
|
|
73
|
+
} = this.props;
|
|
74
|
+
if (onMouseLeave) {
|
|
75
|
+
onMouseLeave(id, text, e);
|
|
76
|
+
}
|
|
77
|
+
if (this.hoverTimeout) {
|
|
78
|
+
clearTimeout(this.hoverTimeout);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
_defineProperty(this, "getMentionType", () => {
|
|
82
|
+
const {
|
|
83
|
+
accessLevel,
|
|
84
|
+
isHighlighted,
|
|
85
|
+
isDisabled
|
|
86
|
+
} = this.props;
|
|
87
|
+
if (isDisabled) {
|
|
88
|
+
return MentionType.DISABLED;
|
|
89
|
+
}
|
|
90
|
+
if (isHighlighted) {
|
|
91
|
+
return MentionType.SELF;
|
|
92
|
+
}
|
|
93
|
+
if (isRestricted(accessLevel)) {
|
|
94
|
+
return MentionType.RESTRICTED;
|
|
95
|
+
}
|
|
96
|
+
return MentionType.DEFAULT;
|
|
97
|
+
});
|
|
98
|
+
mentionRenderedUfoExperience.getInstance(props.id).start();
|
|
99
|
+
}
|
|
100
|
+
componentDidMount() {
|
|
101
|
+
mentionRenderedUfoExperience.getInstance(this.props.id).success();
|
|
102
|
+
}
|
|
103
|
+
static getDerivedStateFromProps(props, state) {
|
|
104
|
+
if (props.avatarUrl !== state.avatarUrl) {
|
|
105
|
+
return {
|
|
106
|
+
avatarUrl: props.avatarUrl,
|
|
107
|
+
hasAvatarError: false
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
componentWillUnmount() {
|
|
113
|
+
if (this.hoverTimeout) {
|
|
114
|
+
clearTimeout(this.hoverTimeout);
|
|
115
|
+
}
|
|
116
|
+
const ufoInstance = mentionRenderedUfoExperience.getInstance(this.props.id);
|
|
117
|
+
if ([UFOExperienceState['STARTED'], UFOExperienceState['IN_PROGRESS']].includes(ufoInstance.state)) {
|
|
118
|
+
ufoInstance.abort();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
renderUnknownUserError(id) {
|
|
122
|
+
return /*#__PURE__*/React.createElement(UnknownUserError, {
|
|
123
|
+
values: {
|
|
124
|
+
userId: id.slice(-5)
|
|
125
|
+
}
|
|
126
|
+
}, message => /*#__PURE__*/React.createElement(React.Fragment, null, `@${message}`));
|
|
127
|
+
}
|
|
128
|
+
render() {
|
|
129
|
+
const {
|
|
130
|
+
handleAvatarError,
|
|
131
|
+
handleOnClick,
|
|
132
|
+
handleOnMouseEnter,
|
|
133
|
+
handleOnMouseLeave,
|
|
134
|
+
props
|
|
135
|
+
} = this;
|
|
136
|
+
const {
|
|
137
|
+
appType,
|
|
138
|
+
avatarUrl,
|
|
139
|
+
text,
|
|
140
|
+
id,
|
|
141
|
+
accessLevel,
|
|
142
|
+
localId,
|
|
143
|
+
disabledTooltip,
|
|
144
|
+
isAvatarImagePreShaped,
|
|
145
|
+
renderAvatarSlot
|
|
146
|
+
} = props;
|
|
147
|
+
const mentionType = this.getMentionType();
|
|
148
|
+
const failedMention = text === `@${UNKNOWN_USER_ID}`;
|
|
149
|
+
const showAvatarSlot = Boolean(renderAvatarSlot) && !failedMention;
|
|
150
|
+
const visibleText = showAvatarSlot && text.startsWith('@') ? text.slice(1) : text;
|
|
151
|
+
const shouldApplyAgentShape = appType === 'agent' && !isAvatarImagePreShaped;
|
|
152
|
+
const shouldRenderAvatar = avatarUrl && !this.state.hasAvatarError;
|
|
153
|
+
const showRestrictedTooltip = mentionType === MentionType.RESTRICTED;
|
|
154
|
+
const showDisabledTooltip = mentionType === MentionType.DISABLED && !!disabledTooltip;
|
|
155
|
+
|
|
156
|
+
// A11y: when the chip is in the disabled visual state, expose
|
|
157
|
+
// `aria-disabled` so assistive tech announces it as such. The
|
|
158
|
+
// disabled-tooltip text is mirrored into `aria-label` so the
|
|
159
|
+
// announcement carries the reason even without portal-id wiring for
|
|
160
|
+
// `aria-describedby`.
|
|
161
|
+
const isDisabledChip = mentionType === MentionType.DISABLED;
|
|
162
|
+
const disabledA11yProps = isDisabledChip ? {
|
|
163
|
+
'aria-disabled': true,
|
|
164
|
+
tabIndex: 0,
|
|
165
|
+
...(disabledTooltip ? {
|
|
166
|
+
'aria-label': `${text || '@...'} — ${disabledTooltip}`
|
|
167
|
+
} : {})
|
|
168
|
+
} : {};
|
|
169
|
+
const mentionComponent = /*#__PURE__*/React.createElement(FocusRing, null, /*#__PURE__*/React.createElement(PrimitiveMention, _extends({
|
|
170
|
+
isAvatarVisible: showAvatarSlot,
|
|
171
|
+
mentionType: mentionType,
|
|
172
|
+
onClick: handleOnClick,
|
|
173
|
+
onMouseEnter: handleOnMouseEnter,
|
|
174
|
+
onMouseLeave: handleOnMouseLeave,
|
|
175
|
+
spellCheck: false,
|
|
176
|
+
"data-testid": `mention-${id}`,
|
|
177
|
+
"data-mention-type": mentionType,
|
|
178
|
+
"data-mention-tooltip": showRestrictedTooltip || showDisabledTooltip
|
|
179
|
+
}, disabledA11yProps), failedMention ? this.renderUnknownUserError(id) : showAvatarSlot ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
180
|
+
"aria-hidden": "true",
|
|
181
|
+
"data-testid": "mention-avatar-slot",
|
|
182
|
+
className: ax(["_1reo15vq _18m915vq _2rko1rr0 _1e0c116y _1bsb7vkz _4t3i7vkz _4cvr1h6o _1bah1h6o _1o9zidpf _12l21b66 _s7n410e5", shouldApplyAgentShape && "_2rkoidpf _mkrz1l17", this.state.hasAvatarError && "_s7n41q9y"])
|
|
183
|
+
}, shouldRenderAvatar ? /*#__PURE__*/React.createElement("img", {
|
|
184
|
+
alt: "",
|
|
185
|
+
decoding: "async",
|
|
186
|
+
draggable: false,
|
|
187
|
+
height: 16,
|
|
188
|
+
loading: "lazy",
|
|
189
|
+
onError: handleAvatarError,
|
|
190
|
+
src: avatarUrl,
|
|
191
|
+
"data-testid": "mention-avatar",
|
|
192
|
+
width: 16,
|
|
193
|
+
className: ax(["_1e0c1ule _1bsb1osq _4t3i1osq _5ral1dfr"])
|
|
194
|
+
}) : this.state.hasAvatarError ? '@' : null), /*#__PURE__*/React.createElement("span", null, visibleText || '...')) : text || '@...'));
|
|
195
|
+
const ssrPlaceholderProp = props.ssrPlaceholderId ? {
|
|
196
|
+
'data-ssr-placeholder': props.ssrPlaceholderId
|
|
197
|
+
} : {};
|
|
198
|
+
const wrappedMention = (() => {
|
|
199
|
+
if (showRestrictedTooltip) {
|
|
200
|
+
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
201
|
+
fallback: mentionComponent
|
|
202
|
+
}, /*#__PURE__*/React.createElement(AsyncNoAccessTooltip, {
|
|
203
|
+
name: text
|
|
204
|
+
}, mentionComponent));
|
|
205
|
+
}
|
|
206
|
+
if (showDisabledTooltip) {
|
|
207
|
+
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
208
|
+
fallback: mentionComponent
|
|
209
|
+
}, /*#__PURE__*/React.createElement(AsyncDisabledMentionTooltip, {
|
|
210
|
+
tooltip: disabledTooltip
|
|
211
|
+
}, mentionComponent));
|
|
212
|
+
}
|
|
213
|
+
return mentionComponent;
|
|
214
|
+
})();
|
|
215
|
+
return /*#__PURE__*/React.createElement(UfoErrorBoundary, {
|
|
216
|
+
id: id
|
|
217
|
+
}, /*#__PURE__*/React.createElement("span", _extends({
|
|
218
|
+
id: localId,
|
|
219
|
+
"data-mention-id": id,
|
|
220
|
+
"data-local-id": localId,
|
|
221
|
+
"data-access-level": accessLevel,
|
|
222
|
+
spellCheck: false
|
|
223
|
+
}, ssrPlaceholderProp), /*#__PURE__*/React.createElement(MessagesIntlProvider, null, wrappedMention)));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { isResolvingMentionProvider } from '../../api/
|
|
4
|
-
import { isPromise
|
|
5
|
-
import
|
|
3
|
+
import { isResolvingMentionProvider } from '../../api/isResolvingMentionProvider';
|
|
4
|
+
import { isPromise } from '../../is-promise';
|
|
5
|
+
import { MentionNameStatus } from '../../types';
|
|
6
6
|
import debug from '../../util/logger';
|
|
7
|
+
import Mention, { UNKNOWN_USER_ID } from './';
|
|
7
8
|
export default class ResourcedMention extends React.PureComponent {
|
|
8
9
|
constructor(_props) {
|
|
9
10
|
super(_props);
|