@atlaskit/mention 23.0.4 → 23.1.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 +1397 -1396
- package/dist/cjs/api/MentionNameResolver.js +28 -0
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/es2019/api/MentionNameResolver.js +25 -1
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/esm/api/MentionNameResolver.js +28 -0
- package/dist/esm/util/analytics.js +1 -1
- package/dist/types/api/MentionNameResolver.d.ts +6 -1
- package/dist/types-ts4.5/api/MentionNameResolver.d.ts +6 -1
- package/package.json +1 -3
|
@@ -18,12 +18,15 @@ var DefaultMentionNameResolver = exports.DefaultMentionNameResolver = /*#__PURE_
|
|
|
18
18
|
function DefaultMentionNameResolver(client) {
|
|
19
19
|
var _this = this;
|
|
20
20
|
var analyticsProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
|
+
var onResolvedAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
21
22
|
(0, _classCallCheck2.default)(this, DefaultMentionNameResolver);
|
|
22
23
|
(0, _defineProperty2.default)(this, "nameCache", new Map());
|
|
23
24
|
(0, _defineProperty2.default)(this, "nameQueue", new Map());
|
|
24
25
|
(0, _defineProperty2.default)(this, "nameStartTime", new Map());
|
|
25
26
|
(0, _defineProperty2.default)(this, "processingQueue", new Map());
|
|
26
27
|
(0, _defineProperty2.default)(this, "debounce", 0);
|
|
28
|
+
(0, _defineProperty2.default)(this, "debounceOnResolve", null);
|
|
29
|
+
(0, _defineProperty2.default)(this, "isOnResolvedAllCalled", false);
|
|
27
30
|
(0, _defineProperty2.default)(this, "processQueue", function () {
|
|
28
31
|
clearTimeout(_this.debounce);
|
|
29
32
|
_this.debounce = 0;
|
|
@@ -58,10 +61,15 @@ var DefaultMentionNameResolver = exports.DefaultMentionNameResolver = /*#__PURE_
|
|
|
58
61
|
// Make sure anything left in the queue gets processed.
|
|
59
62
|
if (_this.nameQueue.size > 0) {
|
|
60
63
|
_this.scheduleProcessQueue();
|
|
64
|
+
} else {
|
|
65
|
+
_this.scheduleOnAllResolved();
|
|
61
66
|
}
|
|
62
67
|
});
|
|
63
68
|
this.client = client;
|
|
64
69
|
this.fireHydrationEvent = (0, _analytics.fireAnalyticsMentionHydrationEvent)(analyticsProps);
|
|
70
|
+
// If provided, this will be called once all pending mentions in the queue are resolved.
|
|
71
|
+
// A sample usage is scrolling to a mention on page load, after the mentions have loadad.
|
|
72
|
+
this.onResolvedAll = onResolvedAll;
|
|
65
73
|
}
|
|
66
74
|
(0, _createClass2.default)(DefaultMentionNameResolver, [{
|
|
67
75
|
key: "lookupName",
|
|
@@ -70,6 +78,9 @@ var DefaultMentionNameResolver = exports.DefaultMentionNameResolver = /*#__PURE_
|
|
|
70
78
|
var name = this.nameCache.get(id);
|
|
71
79
|
if (name) {
|
|
72
80
|
this.fireAnalytics(true, name);
|
|
81
|
+
if (this.nameQueue.size === 0) {
|
|
82
|
+
this.scheduleOnAllResolved();
|
|
83
|
+
}
|
|
73
84
|
return name;
|
|
74
85
|
}
|
|
75
86
|
return new Promise(function (resolve) {
|
|
@@ -104,6 +115,21 @@ var DefaultMentionNameResolver = exports.DefaultMentionNameResolver = /*#__PURE_
|
|
|
104
115
|
this.debounce = window.setTimeout(this.processQueue, DefaultMentionNameResolver.waitForBatch);
|
|
105
116
|
}
|
|
106
117
|
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "scheduleOnAllResolved",
|
|
120
|
+
value: function scheduleOnAllResolved() {
|
|
121
|
+
var _this3 = this;
|
|
122
|
+
if (this.debounceOnResolve) {
|
|
123
|
+
clearTimeout(this.debounceOnResolve);
|
|
124
|
+
}
|
|
125
|
+
this.debounceOnResolve = window.setTimeout(function () {
|
|
126
|
+
if (_this3.isOnResolvedAllCalled) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
_this3.onResolvedAll();
|
|
130
|
+
_this3.isOnResolvedAllCalled = true;
|
|
131
|
+
}, DefaultMentionNameResolver.waitForResolveAll);
|
|
132
|
+
}
|
|
107
133
|
}, {
|
|
108
134
|
key: "isQueueAtLimit",
|
|
109
135
|
value: function isQueueAtLimit() {
|
|
@@ -155,6 +181,8 @@ var DefaultMentionNameResolver = exports.DefaultMentionNameResolver = /*#__PURE_
|
|
|
155
181
|
* This addresses [this ticket](https://product-fabric.atlassian.net/browse/QS-3789).
|
|
156
182
|
*/
|
|
157
183
|
(0, _defineProperty2.default)(DefaultMentionNameResolver, "waitForBatch", 100);
|
|
184
|
+
// ms
|
|
185
|
+
(0, _defineProperty2.default)(DefaultMentionNameResolver, "waitForResolveAll", 800);
|
|
158
186
|
function mergeNameResolverQueues(queueA, queueB) {
|
|
159
187
|
var queueBeingMerged = new Map((0, _toConsumableArray2.default)(queueA));
|
|
160
188
|
|
|
@@ -12,7 +12,7 @@ var _types = require("../types");
|
|
|
12
12
|
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; }
|
|
13
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
14
|
var packageName = "@atlaskit/mention";
|
|
15
|
-
var packageVersion = "23.0
|
|
15
|
+
var packageVersion = "23.1.0";
|
|
16
16
|
var SLI_EVENT_TYPE = exports.SLI_EVENT_TYPE = 'sli';
|
|
17
17
|
var SMART_EVENT_TYPE = exports.SMART_EVENT_TYPE = 'smart';
|
|
18
18
|
var SliNames = exports.SliNames = /*#__PURE__*/function (SliNames) {
|
|
@@ -5,12 +5,14 @@ import { fireAnalyticsMentionHydrationEvent } from '../util/analytics';
|
|
|
5
5
|
/** A queue for user ids */
|
|
6
6
|
|
|
7
7
|
export class DefaultMentionNameResolver {
|
|
8
|
-
constructor(client, analyticsProps = {}) {
|
|
8
|
+
constructor(client, analyticsProps = {}, onResolvedAll = () => {}) {
|
|
9
9
|
_defineProperty(this, "nameCache", new Map());
|
|
10
10
|
_defineProperty(this, "nameQueue", new Map());
|
|
11
11
|
_defineProperty(this, "nameStartTime", new Map());
|
|
12
12
|
_defineProperty(this, "processingQueue", new Map());
|
|
13
13
|
_defineProperty(this, "debounce", 0);
|
|
14
|
+
_defineProperty(this, "debounceOnResolve", null);
|
|
15
|
+
_defineProperty(this, "isOnResolvedAllCalled", false);
|
|
14
16
|
_defineProperty(this, "processQueue", () => {
|
|
15
17
|
clearTimeout(this.debounce);
|
|
16
18
|
this.debounce = 0;
|
|
@@ -48,15 +50,23 @@ export class DefaultMentionNameResolver {
|
|
|
48
50
|
// Make sure anything left in the queue gets processed.
|
|
49
51
|
if (this.nameQueue.size > 0) {
|
|
50
52
|
this.scheduleProcessQueue();
|
|
53
|
+
} else {
|
|
54
|
+
this.scheduleOnAllResolved();
|
|
51
55
|
}
|
|
52
56
|
});
|
|
53
57
|
this.client = client;
|
|
54
58
|
this.fireHydrationEvent = fireAnalyticsMentionHydrationEvent(analyticsProps);
|
|
59
|
+
// If provided, this will be called once all pending mentions in the queue are resolved.
|
|
60
|
+
// A sample usage is scrolling to a mention on page load, after the mentions have loadad.
|
|
61
|
+
this.onResolvedAll = onResolvedAll;
|
|
55
62
|
}
|
|
56
63
|
lookupName(id) {
|
|
57
64
|
const name = this.nameCache.get(id);
|
|
58
65
|
if (name) {
|
|
59
66
|
this.fireAnalytics(true, name);
|
|
67
|
+
if (this.nameQueue.size === 0) {
|
|
68
|
+
this.scheduleOnAllResolved();
|
|
69
|
+
}
|
|
60
70
|
return name;
|
|
61
71
|
}
|
|
62
72
|
return new Promise(resolve => {
|
|
@@ -87,6 +97,18 @@ export class DefaultMentionNameResolver {
|
|
|
87
97
|
this.debounce = window.setTimeout(this.processQueue, DefaultMentionNameResolver.waitForBatch);
|
|
88
98
|
}
|
|
89
99
|
}
|
|
100
|
+
scheduleOnAllResolved() {
|
|
101
|
+
if (this.debounceOnResolve) {
|
|
102
|
+
clearTimeout(this.debounceOnResolve);
|
|
103
|
+
}
|
|
104
|
+
this.debounceOnResolve = window.setTimeout(() => {
|
|
105
|
+
if (this.isOnResolvedAllCalled) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.onResolvedAll();
|
|
109
|
+
this.isOnResolvedAllCalled = true;
|
|
110
|
+
}, DefaultMentionNameResolver.waitForResolveAll);
|
|
111
|
+
}
|
|
90
112
|
isQueueAtLimit() {
|
|
91
113
|
return this.nameQueue.size >= this.client.getLookupLimit();
|
|
92
114
|
}
|
|
@@ -133,6 +155,8 @@ export class DefaultMentionNameResolver {
|
|
|
133
155
|
* This addresses [this ticket](https://product-fabric.atlassian.net/browse/QS-3789).
|
|
134
156
|
*/
|
|
135
157
|
_defineProperty(DefaultMentionNameResolver, "waitForBatch", 100);
|
|
158
|
+
// ms
|
|
159
|
+
_defineProperty(DefaultMentionNameResolver, "waitForResolveAll", 800);
|
|
136
160
|
export function mergeNameResolverQueues(queueA, queueB) {
|
|
137
161
|
const queueBeingMerged = new Map([...queueA]);
|
|
138
162
|
|
|
@@ -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 { isSpecialMentionText } from '../types';
|
|
4
4
|
const packageName = "@atlaskit/mention";
|
|
5
|
-
const packageVersion = "23.0
|
|
5
|
+
const packageVersion = "23.1.0";
|
|
6
6
|
export const SLI_EVENT_TYPE = 'sli';
|
|
7
7
|
export const SMART_EVENT_TYPE = 'smart';
|
|
8
8
|
export let SliNames = /*#__PURE__*/function (SliNames) {
|
|
@@ -12,12 +12,15 @@ export var DefaultMentionNameResolver = /*#__PURE__*/function () {
|
|
|
12
12
|
function DefaultMentionNameResolver(client) {
|
|
13
13
|
var _this = this;
|
|
14
14
|
var analyticsProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
15
|
+
var onResolvedAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
15
16
|
_classCallCheck(this, DefaultMentionNameResolver);
|
|
16
17
|
_defineProperty(this, "nameCache", new Map());
|
|
17
18
|
_defineProperty(this, "nameQueue", new Map());
|
|
18
19
|
_defineProperty(this, "nameStartTime", new Map());
|
|
19
20
|
_defineProperty(this, "processingQueue", new Map());
|
|
20
21
|
_defineProperty(this, "debounce", 0);
|
|
22
|
+
_defineProperty(this, "debounceOnResolve", null);
|
|
23
|
+
_defineProperty(this, "isOnResolvedAllCalled", false);
|
|
21
24
|
_defineProperty(this, "processQueue", function () {
|
|
22
25
|
clearTimeout(_this.debounce);
|
|
23
26
|
_this.debounce = 0;
|
|
@@ -52,10 +55,15 @@ export var DefaultMentionNameResolver = /*#__PURE__*/function () {
|
|
|
52
55
|
// Make sure anything left in the queue gets processed.
|
|
53
56
|
if (_this.nameQueue.size > 0) {
|
|
54
57
|
_this.scheduleProcessQueue();
|
|
58
|
+
} else {
|
|
59
|
+
_this.scheduleOnAllResolved();
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
62
|
this.client = client;
|
|
58
63
|
this.fireHydrationEvent = fireAnalyticsMentionHydrationEvent(analyticsProps);
|
|
64
|
+
// If provided, this will be called once all pending mentions in the queue are resolved.
|
|
65
|
+
// A sample usage is scrolling to a mention on page load, after the mentions have loadad.
|
|
66
|
+
this.onResolvedAll = onResolvedAll;
|
|
59
67
|
}
|
|
60
68
|
_createClass(DefaultMentionNameResolver, [{
|
|
61
69
|
key: "lookupName",
|
|
@@ -64,6 +72,9 @@ export var DefaultMentionNameResolver = /*#__PURE__*/function () {
|
|
|
64
72
|
var name = this.nameCache.get(id);
|
|
65
73
|
if (name) {
|
|
66
74
|
this.fireAnalytics(true, name);
|
|
75
|
+
if (this.nameQueue.size === 0) {
|
|
76
|
+
this.scheduleOnAllResolved();
|
|
77
|
+
}
|
|
67
78
|
return name;
|
|
68
79
|
}
|
|
69
80
|
return new Promise(function (resolve) {
|
|
@@ -98,6 +109,21 @@ export var DefaultMentionNameResolver = /*#__PURE__*/function () {
|
|
|
98
109
|
this.debounce = window.setTimeout(this.processQueue, DefaultMentionNameResolver.waitForBatch);
|
|
99
110
|
}
|
|
100
111
|
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "scheduleOnAllResolved",
|
|
114
|
+
value: function scheduleOnAllResolved() {
|
|
115
|
+
var _this3 = this;
|
|
116
|
+
if (this.debounceOnResolve) {
|
|
117
|
+
clearTimeout(this.debounceOnResolve);
|
|
118
|
+
}
|
|
119
|
+
this.debounceOnResolve = window.setTimeout(function () {
|
|
120
|
+
if (_this3.isOnResolvedAllCalled) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
_this3.onResolvedAll();
|
|
124
|
+
_this3.isOnResolvedAllCalled = true;
|
|
125
|
+
}, DefaultMentionNameResolver.waitForResolveAll);
|
|
126
|
+
}
|
|
101
127
|
}, {
|
|
102
128
|
key: "isQueueAtLimit",
|
|
103
129
|
value: function isQueueAtLimit() {
|
|
@@ -150,6 +176,8 @@ export var DefaultMentionNameResolver = /*#__PURE__*/function () {
|
|
|
150
176
|
* This addresses [this ticket](https://product-fabric.atlassian.net/browse/QS-3789).
|
|
151
177
|
*/
|
|
152
178
|
_defineProperty(DefaultMentionNameResolver, "waitForBatch", 100);
|
|
179
|
+
// ms
|
|
180
|
+
_defineProperty(DefaultMentionNameResolver, "waitForResolveAll", 800);
|
|
153
181
|
export function mergeNameResolverQueues(queueA, queueB) {
|
|
154
182
|
var queueBeingMerged = new Map(_toConsumableArray(queueA));
|
|
155
183
|
|
|
@@ -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 { isSpecialMentionText } from '../types';
|
|
7
7
|
var packageName = "@atlaskit/mention";
|
|
8
|
-
var packageVersion = "23.0
|
|
8
|
+
var packageVersion = "23.1.0";
|
|
9
9
|
export var SLI_EVENT_TYPE = 'sli';
|
|
10
10
|
export var SMART_EVENT_TYPE = 'smart';
|
|
11
11
|
export var SliNames = /*#__PURE__*/function (SliNames) {
|
|
@@ -9,17 +9,22 @@ export type { MentionNameResolver } from '../types';
|
|
|
9
9
|
type Queue = Map<string, Callback[]>;
|
|
10
10
|
export declare class DefaultMentionNameResolver implements MentionNameResolver {
|
|
11
11
|
static waitForBatch: number;
|
|
12
|
+
private static waitForResolveAll;
|
|
12
13
|
private client;
|
|
13
14
|
private nameCache;
|
|
14
15
|
private nameQueue;
|
|
15
16
|
private nameStartTime;
|
|
16
17
|
private processingQueue;
|
|
17
18
|
private debounce;
|
|
19
|
+
private debounceOnResolve;
|
|
20
|
+
private onResolvedAll;
|
|
21
|
+
private isOnResolvedAllCalled;
|
|
18
22
|
private fireHydrationEvent;
|
|
19
|
-
constructor(client: MentionNameClient, analyticsProps?: WithAnalyticsEventsProps);
|
|
23
|
+
constructor(client: MentionNameClient, analyticsProps?: WithAnalyticsEventsProps, onResolvedAll?: () => void);
|
|
20
24
|
lookupName(id: string): Promise<MentionNameDetails> | MentionNameDetails;
|
|
21
25
|
cacheName(id: string, name: string): void;
|
|
22
26
|
private scheduleProcessQueue;
|
|
27
|
+
private scheduleOnAllResolved;
|
|
23
28
|
private isQueueAtLimit;
|
|
24
29
|
private splitQueueAtLimit;
|
|
25
30
|
private resolveQueueItem;
|
|
@@ -9,17 +9,22 @@ export type { MentionNameResolver } from '../types';
|
|
|
9
9
|
type Queue = Map<string, Callback[]>;
|
|
10
10
|
export declare class DefaultMentionNameResolver implements MentionNameResolver {
|
|
11
11
|
static waitForBatch: number;
|
|
12
|
+
private static waitForResolveAll;
|
|
12
13
|
private client;
|
|
13
14
|
private nameCache;
|
|
14
15
|
private nameQueue;
|
|
15
16
|
private nameStartTime;
|
|
16
17
|
private processingQueue;
|
|
17
18
|
private debounce;
|
|
19
|
+
private debounceOnResolve;
|
|
20
|
+
private onResolvedAll;
|
|
21
|
+
private isOnResolvedAllCalled;
|
|
18
22
|
private fireHydrationEvent;
|
|
19
|
-
constructor(client: MentionNameClient, analyticsProps?: WithAnalyticsEventsProps);
|
|
23
|
+
constructor(client: MentionNameClient, analyticsProps?: WithAnalyticsEventsProps, onResolvedAll?: () => void);
|
|
20
24
|
lookupName(id: string): Promise<MentionNameDetails> | MentionNameDetails;
|
|
21
25
|
cacheName(id: string, name: string): void;
|
|
22
26
|
private scheduleProcessQueue;
|
|
27
|
+
private scheduleOnAllResolved;
|
|
23
28
|
private isQueueAtLimit;
|
|
24
29
|
private splitQueueAtLimit;
|
|
25
30
|
private resolveQueueItem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/mention",
|
|
3
|
-
"version": "23.0
|
|
3
|
+
"version": "23.1.0",
|
|
4
4
|
"description": "A React component used to display user profiles in a list for 'Mention' functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@atlaskit/elements-test-helpers": "^0.7.0",
|
|
63
63
|
"@atlaskit/visual-regression": "*",
|
|
64
|
-
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
65
64
|
"@types/query-string": "^4.3.1",
|
|
66
65
|
"@types/serialize-javascript": "^5.0.0",
|
|
67
66
|
"enzyme": "^3.10.0",
|
|
@@ -91,7 +90,6 @@
|
|
|
91
90
|
]
|
|
92
91
|
}
|
|
93
92
|
},
|
|
94
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
|
|
95
93
|
"af:exports": {
|
|
96
94
|
".": "./src/index.ts",
|
|
97
95
|
"./element": "./src/element.ts",
|