@atlaskit/reactions 22.5.3 → 22.5.4
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 +70 -64
- package/dist/cjs/MockReactionsClient.js +10 -15
- package/dist/cjs/analytics/index.js +130 -8
- package/dist/cjs/client/ReactionServiceClient.js +2 -3
- package/dist/cjs/components/Counter/Counter.js +11 -15
- package/dist/cjs/components/Counter/index.js +1 -7
- package/dist/cjs/components/Counter/styles.js +5 -9
- package/dist/cjs/components/EmojiButton/EmojiButton.js +9 -13
- package/dist/cjs/components/EmojiButton/styles.js +2 -3
- package/dist/cjs/components/FlashAnimation/FlashAnimation.js +5 -10
- package/dist/cjs/components/FlashAnimation/styles.js +4 -7
- package/dist/cjs/components/Reaction/Reaction.js +14 -15
- package/dist/cjs/components/Reaction/styles.js +7 -11
- package/dist/cjs/components/ReactionDialog/ReactionView.js +4 -5
- package/dist/cjs/components/ReactionDialog/ReactionsDialog.js +10 -11
- package/dist/cjs/components/ReactionDialog/ReactionsList.js +2 -3
- package/dist/cjs/components/ReactionDialog/styles.js +13 -23
- package/dist/cjs/components/ReactionPicker/ReactionPicker.js +18 -21
- package/dist/cjs/components/ReactionPicker/RepositionOnUpdate.js +2 -3
- package/dist/cjs/components/ReactionPicker/styles.js +5 -9
- package/dist/cjs/components/ReactionTooltip/ReactionTooltip.js +12 -16
- package/dist/cjs/components/ReactionTooltip/styles.js +6 -11
- package/dist/cjs/components/Reactions/Reactions.js +26 -30
- package/dist/cjs/components/Reactions/styles.js +5 -8
- package/dist/cjs/components/Selector/Selector.js +10 -12
- package/dist/cjs/components/Selector/index.js +1 -7
- package/dist/cjs/components/Selector/styles.js +6 -11
- package/dist/cjs/components/ShowMore/ShowMore.js +11 -17
- package/dist/cjs/components/ShowMore/styles.js +4 -7
- package/dist/cjs/components/Trigger/Trigger.js +6 -12
- package/dist/cjs/components/Trigger/styles.js +3 -5
- package/dist/cjs/components/UfoErrorBoundary/UfoErrorBoundary.js +2 -3
- package/dist/cjs/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +4 -5
- package/dist/cjs/containers/ConnectedReactionsView/ConnectedReactionsView.js +5 -8
- package/dist/cjs/containers/index.js +13 -21
- package/dist/cjs/hooks/useFocusTrap.js +2 -3
- package/dist/cjs/i18n/cs.js +2 -3
- package/dist/cjs/i18n/da.js +2 -3
- package/dist/cjs/i18n/de.js +2 -3
- package/dist/cjs/i18n/en.js +2 -3
- package/dist/cjs/i18n/en_GB.js +2 -3
- package/dist/cjs/i18n/en_ZZ.js +2 -3
- package/dist/cjs/i18n/es.js +2 -3
- package/dist/cjs/i18n/et.js +2 -3
- package/dist/cjs/i18n/fi.js +2 -3
- package/dist/cjs/i18n/fr.js +2 -3
- package/dist/cjs/i18n/hu.js +2 -3
- package/dist/cjs/i18n/is.js +2 -3
- package/dist/cjs/i18n/it.js +2 -3
- package/dist/cjs/i18n/ja.js +2 -3
- package/dist/cjs/i18n/ko.js +2 -3
- package/dist/cjs/i18n/languages.js +2 -3
- package/dist/cjs/i18n/nb.js +2 -3
- package/dist/cjs/i18n/nl.js +2 -3
- package/dist/cjs/i18n/pl.js +2 -3
- package/dist/cjs/i18n/pt_BR.js +2 -3
- package/dist/cjs/i18n/pt_PT.js +2 -3
- package/dist/cjs/i18n/ro.js +2 -3
- package/dist/cjs/i18n/ru.js +2 -3
- package/dist/cjs/i18n/sk.js +2 -3
- package/dist/cjs/i18n/sv.js +2 -3
- package/dist/cjs/i18n/th.js +2 -3
- package/dist/cjs/i18n/tr.js +2 -3
- package/dist/cjs/i18n/uk.js +2 -3
- package/dist/cjs/i18n/vi.js +2 -3
- package/dist/cjs/i18n/zh.js +2 -3
- package/dist/cjs/i18n/zh_TW.js +2 -3
- package/dist/cjs/index.js +28 -15
- package/dist/cjs/shared/constants.js +7 -14
- package/dist/cjs/shared/i18n.js +2 -3
- package/dist/cjs/shared/utils.js +5 -9
- package/dist/cjs/store/MemoryReactionsStore.js +29 -35
- package/dist/cjs/store/ReactionConsumer.js +2 -3
- package/dist/cjs/store/utils.js +7 -14
- package/dist/cjs/types/reaction.js +2 -3
- package/dist/cjs/ufo/index.js +92 -0
- package/dist/es2019/MockReactionsClient.js +2 -2
- package/dist/es2019/analytics/index.js +95 -2
- package/dist/es2019/components/Counter/Counter.js +6 -6
- package/dist/es2019/components/Counter/index.js +1 -2
- package/dist/es2019/components/EmojiButton/EmojiButton.js +6 -5
- package/dist/es2019/components/FlashAnimation/FlashAnimation.js +2 -2
- package/dist/es2019/components/Reaction/Reaction.js +12 -11
- package/dist/es2019/components/ReactionDialog/ReactionView.js +2 -2
- package/dist/es2019/components/ReactionDialog/ReactionsDialog.js +5 -4
- package/dist/es2019/components/ReactionDialog/styles.js +2 -2
- package/dist/es2019/components/ReactionPicker/ReactionPicker.js +13 -13
- package/dist/es2019/components/ReactionTooltip/ReactionTooltip.js +9 -8
- package/dist/es2019/components/Reactions/Reactions.js +21 -21
- package/dist/es2019/components/Reactions/styles.js +1 -1
- package/dist/es2019/components/Selector/Selector.js +7 -7
- package/dist/es2019/components/Selector/index.js +1 -2
- package/dist/es2019/components/ShowMore/ShowMore.js +7 -7
- package/dist/es2019/components/Trigger/Trigger.js +2 -2
- package/dist/es2019/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +2 -2
- package/dist/es2019/containers/index.js +2 -2
- package/dist/es2019/index.js +27 -5
- package/dist/es2019/store/MemoryReactionsStore.js +21 -23
- package/dist/esm/MockReactionsClient.js +2 -2
- package/dist/esm/analytics/index.js +127 -4
- package/dist/esm/components/Counter/Counter.js +6 -6
- package/dist/esm/components/Counter/index.js +1 -3
- package/dist/esm/components/EmojiButton/EmojiButton.js +6 -5
- package/dist/esm/components/FlashAnimation/FlashAnimation.js +2 -2
- package/dist/esm/components/Reaction/Reaction.js +12 -11
- package/dist/esm/components/ReactionDialog/ReactionView.js +2 -2
- package/dist/esm/components/ReactionDialog/ReactionsDialog.js +7 -6
- package/dist/esm/components/ReactionDialog/styles.js +2 -2
- package/dist/esm/components/ReactionPicker/ReactionPicker.js +14 -14
- package/dist/esm/components/ReactionTooltip/ReactionTooltip.js +9 -8
- package/dist/esm/components/Reactions/Reactions.js +21 -21
- package/dist/esm/components/Reactions/styles.js +1 -1
- package/dist/esm/components/Selector/Selector.js +7 -7
- package/dist/esm/components/Selector/index.js +1 -3
- package/dist/esm/components/ShowMore/ShowMore.js +7 -7
- package/dist/esm/components/Trigger/Trigger.js +2 -2
- package/dist/esm/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +2 -2
- package/dist/esm/containers/ConnectedReactionsView/ConnectedReactionsView.js +1 -1
- package/dist/esm/containers/index.js +2 -2
- package/dist/esm/index.js +27 -5
- package/dist/esm/store/MemoryReactionsStore.js +21 -23
- package/dist/types/analytics/index.d.ts +121 -2
- package/dist/types/components/Counter/index.d.ts +0 -1
- package/dist/types/components/ReactionPicker/ReactionPicker.d.ts +1 -1
- package/dist/types/components/Reactions/styles.d.ts +1 -1
- package/dist/types/components/Selector/Selector.d.ts +1 -1
- package/dist/types/components/Selector/index.d.ts +0 -1
- package/dist/types/containers/index.d.ts +2 -2
- package/dist/types/index.d.ts +24 -3
- package/dist/types/store/MemoryReactionsStore.d.ts +6 -6
- package/dist/types-ts4.5/analytics/index.d.ts +121 -2
- package/dist/types-ts4.5/components/Counter/index.d.ts +0 -1
- package/dist/types-ts4.5/components/ReactionPicker/ReactionPicker.d.ts +1 -1
- package/dist/types-ts4.5/components/Reactions/styles.d.ts +1 -1
- package/dist/types-ts4.5/components/Selector/Selector.d.ts +1 -1
- package/dist/types-ts4.5/components/Selector/index.d.ts +0 -1
- package/dist/types-ts4.5/containers/index.d.ts +2 -2
- package/dist/types-ts4.5/index.d.ts +24 -3
- package/dist/types-ts4.5/store/MemoryReactionsStore.d.ts +6 -6
- package/package.json +7 -8
- package/report.api.md +494 -0
- package/tmp/api-report-tmp.d.ts +398 -0
- package/dist/cjs/analytics/analytics.js +0 -149
- package/dist/cjs/analytics/ufo.js +0 -103
- package/dist/cjs/hooks/index.js +0 -12
- package/dist/cjs/shared/index.js +0 -15
- package/dist/es2019/analytics/analytics.js +0 -95
- package/dist/es2019/hooks/index.js +0 -1
- package/dist/es2019/shared/index.js +0 -3
- package/dist/esm/analytics/analytics.js +0 -127
- package/dist/esm/hooks/index.js +0 -1
- package/dist/esm/shared/index.js +0 -6
- package/dist/types/analytics/analytics.d.ts +0 -121
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/shared/index.d.ts +0 -3
- package/dist/types-ts4.5/analytics/analytics.d.ts +0 -121
- package/dist/types-ts4.5/hooks/index.d.ts +0 -1
- package/dist/types-ts4.5/shared/index.d.ts +0 -3
- /package/dist/es2019/{analytics/ufo.js → ufo/index.js} +0 -0
- /package/dist/esm/{analytics/ufo.js → ufo/index.js} +0 -0
- /package/dist/types/{analytics/ufo.d.ts → ufo/index.d.ts} +0 -0
- /package/dist/types-ts4.5/{analytics/ufo.d.ts → ufo/index.d.ts} +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { createAndFireSafe, createRestFailedEvent, createRestSucceededEvent, extractErrorInfo } from '../analytics';
|
|
3
|
+
import { ReactionStatus } from '../types';
|
|
4
4
|
import { batch, batchByKey } from './batched';
|
|
5
|
-
import
|
|
6
|
-
import { isRealErrorFromService } from './utils';
|
|
5
|
+
import { addOne, byEmojiId, flattenAris, getReactionsSortFunction, isRealErrorFromService, readyState, removeOne, updateByEmojiId } from './utils';
|
|
7
6
|
import { SAMPLING_RATE_REACTIONS_RENDERED_EXP } from '../shared/constants';
|
|
8
|
-
import { sampledReactionsRendered } from '../
|
|
9
|
-
import { extractErrorInfo } from '../analytics/analytics';
|
|
7
|
+
import { ReactionsAdd, ReactionDetailsFetch, ReactionsRemove, sampledReactionsRendered } from '../ufo';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* Set of all available UFO experiences relating to reaction element
|
|
@@ -15,11 +13,11 @@ export const ufoExperiences = {
|
|
|
15
13
|
/**
|
|
16
14
|
* Experience when a reaction emoji gets added
|
|
17
15
|
*/
|
|
18
|
-
add:
|
|
16
|
+
add: ReactionsAdd,
|
|
19
17
|
/**
|
|
20
18
|
* Experience when a reaction emoji gets removed/decrement
|
|
21
19
|
*/
|
|
22
|
-
remove:
|
|
20
|
+
remove: ReactionsRemove,
|
|
23
21
|
/**
|
|
24
22
|
* Experience when the list of reactions gets rendered with sampling
|
|
25
23
|
*/
|
|
@@ -27,7 +25,7 @@ export const ufoExperiences = {
|
|
|
27
25
|
/**
|
|
28
26
|
* Experience when a reaction details gets fetched
|
|
29
27
|
*/
|
|
30
|
-
fetchDetails:
|
|
28
|
+
fetchDetails: ReactionDetailsFetch
|
|
31
29
|
};
|
|
32
30
|
|
|
33
31
|
/**
|
|
@@ -113,7 +111,7 @@ export class MemoryReactionsStore {
|
|
|
113
111
|
});
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
|
-
return
|
|
114
|
+
return readyState(reactions);
|
|
117
115
|
});
|
|
118
116
|
});
|
|
119
117
|
_defineProperty(this, "doAddReaction", reaction => {
|
|
@@ -122,7 +120,7 @@ export class MemoryReactionsStore {
|
|
|
122
120
|
ari,
|
|
123
121
|
emojiId
|
|
124
122
|
} = reaction;
|
|
125
|
-
this.optmisticUpdate(containerAri, ari, emojiId)(
|
|
123
|
+
this.optmisticUpdate(containerAri, ari, emojiId)(addOne);
|
|
126
124
|
this.flash(reaction);
|
|
127
125
|
const exp = ufoExperiences.add.getInstance(`${ari}|${emojiId}`);
|
|
128
126
|
// ufo start reaction experience
|
|
@@ -136,13 +134,13 @@ export class MemoryReactionsStore {
|
|
|
136
134
|
});
|
|
137
135
|
this.client.addReaction(containerAri, ari, emojiId, this.metadata).then(_ => {
|
|
138
136
|
if (this.createAnalyticsEvent) {
|
|
139
|
-
|
|
137
|
+
createAndFireSafe(this.createAnalyticsEvent, createRestSucceededEvent, 'addReaction');
|
|
140
138
|
}
|
|
141
139
|
// ufo add reaction success
|
|
142
140
|
exp.success();
|
|
143
141
|
}).catch(error => {
|
|
144
142
|
if (isRealErrorFromService(error.code)) {
|
|
145
|
-
this.createAnalyticsEvent &&
|
|
143
|
+
this.createAnalyticsEvent && createAndFireSafe(this.createAnalyticsEvent, createRestFailedEvent, 'addReaction', error.code);
|
|
146
144
|
// ufo add reaction failure
|
|
147
145
|
exp.failure({
|
|
148
146
|
metadata: {
|
|
@@ -172,7 +170,7 @@ export class MemoryReactionsStore {
|
|
|
172
170
|
containerAri,
|
|
173
171
|
emojiId
|
|
174
172
|
});
|
|
175
|
-
this.optmisticUpdate(containerAri, ari, emojiId)(
|
|
173
|
+
this.optmisticUpdate(containerAri, ari, emojiId)(removeOne);
|
|
176
174
|
this.client.deleteReaction(containerAri, ari, emojiId, this.metadata).then(_ => {
|
|
177
175
|
// ufo add reaction success
|
|
178
176
|
exp.success();
|
|
@@ -195,7 +193,7 @@ export class MemoryReactionsStore {
|
|
|
195
193
|
* All reactions are usually fetched in a single call to reactions-service. Need to check why "getReactions" gets called randomly 1-2 times everytime on each fetch request despite using same containerAri.
|
|
196
194
|
*/
|
|
197
195
|
const sampledExp = ufoExperiences.render(containerAri);
|
|
198
|
-
const arisArr = aris.reduce(
|
|
196
|
+
const arisArr = aris.reduce(flattenAris);
|
|
199
197
|
// ufo start reaction experience
|
|
200
198
|
sampledExp.start({
|
|
201
199
|
samplingRate: SAMPLING_RATE_REACTIONS_RENDERED_EXP
|
|
@@ -209,18 +207,18 @@ export class MemoryReactionsStore {
|
|
|
209
207
|
this.client.getReactions(containerAri, arisArr).then(value => {
|
|
210
208
|
Object.keys(value).map(ari => {
|
|
211
209
|
const reactionsState = this.getReactionsState(containerAri, ari);
|
|
212
|
-
const reactions = reactionsState && reactionsState.status ===
|
|
213
|
-
this.setReactions(containerAri, ari,
|
|
210
|
+
const reactions = reactionsState && reactionsState.status === ReactionStatus.ready ? reactionsState.reactions : undefined;
|
|
211
|
+
this.setReactions(containerAri, ari, readyState(value[ari].sort(getReactionsSortFunction(reactions))));
|
|
214
212
|
});
|
|
215
213
|
}).then(() => {
|
|
216
214
|
if (this.createAnalyticsEvent) {
|
|
217
|
-
|
|
215
|
+
createAndFireSafe(this.createAnalyticsEvent, createRestSucceededEvent, 'getReactions');
|
|
218
216
|
}
|
|
219
217
|
sampledExp.success();
|
|
220
218
|
}).catch(error => {
|
|
221
219
|
if (isRealErrorFromService(error.code)) {
|
|
222
220
|
if (this.createAnalyticsEvent) {
|
|
223
|
-
|
|
221
|
+
createAndFireSafe(this.createAnalyticsEvent, createRestFailedEvent, 'getReactions');
|
|
224
222
|
}
|
|
225
223
|
sampledExp.failure({
|
|
226
224
|
metadata: {
|
|
@@ -233,7 +231,7 @@ export class MemoryReactionsStore {
|
|
|
233
231
|
...acc,
|
|
234
232
|
[`${containerAri}|${ari}`]: {
|
|
235
233
|
reactions: [],
|
|
236
|
-
status:
|
|
234
|
+
status: ReactionStatus.error
|
|
237
235
|
}
|
|
238
236
|
}), {});
|
|
239
237
|
this.setState({
|
|
@@ -310,7 +308,7 @@ export class MemoryReactionsStore {
|
|
|
310
308
|
withReadyReaction(containerAri, ari) {
|
|
311
309
|
return updater => {
|
|
312
310
|
const reactionsState = this.getReactionsState(containerAri, ari);
|
|
313
|
-
if (reactionsState && reactionsState.status ===
|
|
311
|
+
if (reactionsState && reactionsState.status === ReactionStatus.ready) {
|
|
314
312
|
const updated = updater(reactionsState);
|
|
315
313
|
if (updated) {
|
|
316
314
|
this.setReactions(containerAri, ari, updated);
|
|
@@ -335,7 +333,7 @@ export class MemoryReactionsStore {
|
|
|
335
333
|
withReaction(reactedCallback, notReactedCallback) {
|
|
336
334
|
return (containerAri, ari, emojiId) => {
|
|
337
335
|
this.withReadyReaction(containerAri, ari)(reactionsState => {
|
|
338
|
-
const reaction = reactionsState.reactions.find(
|
|
336
|
+
const reaction = reactionsState.reactions.find(byEmojiId(emojiId)) || {
|
|
339
337
|
containerAri,
|
|
340
338
|
ari,
|
|
341
339
|
emojiId,
|
|
@@ -345,7 +343,7 @@ export class MemoryReactionsStore {
|
|
|
345
343
|
const callback = reaction.reacted || !notReactedCallback ? reactedCallback : notReactedCallback;
|
|
346
344
|
const updatedReaction = callback(reaction);
|
|
347
345
|
if (updatedReaction && !(updatedReaction instanceof Function)) {
|
|
348
|
-
return
|
|
346
|
+
return readyState(reactionsState.reactions.map(updateByEmojiId(emojiId, updatedReaction)));
|
|
349
347
|
}
|
|
350
348
|
return;
|
|
351
349
|
});
|
|
@@ -6,11 +6,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
6
6
|
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; }
|
|
7
7
|
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
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
-
import {
|
|
9
|
+
import { DefaultReactionsByShortName, ExtendedReactionsByShortName } from './shared/constants';
|
|
10
10
|
export var containerAri = 'ari:cloud:owner:demo-cloud-id:container/1';
|
|
11
11
|
export var ari = 'ari:cloud:owner:demo-cloud-id:item/1';
|
|
12
12
|
export var getReactionSummary = function getReactionSummary(shortName, count, reacted, extendedReactions) {
|
|
13
|
-
var getReactionsByShortName = extendedReactions ?
|
|
13
|
+
var getReactionsByShortName = extendedReactions ? ExtendedReactionsByShortName.get(shortName) : DefaultReactionsByShortName.get(shortName);
|
|
14
14
|
return {
|
|
15
15
|
ari: ari,
|
|
16
16
|
containerAri: containerAri,
|
|
@@ -1,4 +1,127 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
5
|
+
import { UI_EVENT_TYPE, OPERATIONAL_EVENT_TYPE } from '@atlaskit/analytics-gas-types';
|
|
6
|
+
var packageName = "@atlaskit/reactions";
|
|
7
|
+
var packageVersion = "22.5.4";
|
|
8
|
+
/**
|
|
9
|
+
* TODO: move to utility package?
|
|
10
|
+
* A random sampling function
|
|
11
|
+
* sampling algorithm is from @atlassian/jira-coinflip at https://stash.atlassian.com/projects/JIRACLOUD/repos/jira-frontend/browse/src/packages/platform/app-framework/coinflip/src/index.tsx
|
|
12
|
+
* E.g. isSampled(2) will pass 50% of the time
|
|
13
|
+
* @param rate The chance that it will pass (1 in <rate> times)
|
|
14
|
+
* @returns bool, if it passes or not
|
|
15
|
+
*/ // default sampling function to determine which one to be sampled
|
|
16
|
+
export var isSampled = function isSampled(rate) {
|
|
17
|
+
if (rate === 1) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (rate === 0) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return Math.random() * rate <= 1;
|
|
24
|
+
};
|
|
25
|
+
export var createAndFireEventInElementsChannel = createAndFireEvent('fabric-elements');
|
|
26
|
+
export var createAndFireSafe = function createAndFireSafe(createAnalyticsEvent, creator) {
|
|
27
|
+
if (createAnalyticsEvent) {
|
|
28
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
29
|
+
args[_key - 2] = arguments[_key];
|
|
30
|
+
}
|
|
31
|
+
createAndFireEventInElementsChannel(creator.apply(void 0, args))(createAnalyticsEvent);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var createPayload = function createPayload(action, actionSubject, eventType, actionSubjectId) {
|
|
35
|
+
return function () {
|
|
36
|
+
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
37
|
+
return {
|
|
38
|
+
action: action,
|
|
39
|
+
actionSubject: actionSubject,
|
|
40
|
+
eventType: eventType,
|
|
41
|
+
actionSubjectId: actionSubjectId,
|
|
42
|
+
attributes: _objectSpread(_objectSpread({}, attributes), {}, {
|
|
43
|
+
packageName: packageName,
|
|
44
|
+
packageVersion: packageVersion
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
var calculateDuration = function calculateDuration(startTime) {
|
|
50
|
+
return startTime ? Date.now() - startTime : undefined;
|
|
51
|
+
};
|
|
52
|
+
var getPreviousState = function getPreviousState(reaction) {
|
|
53
|
+
if (reaction) {
|
|
54
|
+
if (reaction.reacted) {
|
|
55
|
+
return 'existingReacted';
|
|
56
|
+
}
|
|
57
|
+
return 'existingNotReacted';
|
|
58
|
+
}
|
|
59
|
+
return 'new';
|
|
60
|
+
};
|
|
61
|
+
export var createRestSucceededEvent = function createRestSucceededEvent(actionSubject) {
|
|
62
|
+
return createPayload('succeeded', actionSubject, OPERATIONAL_EVENT_TYPE)();
|
|
63
|
+
};
|
|
64
|
+
export var createRestFailedEvent = function createRestFailedEvent(actionSubject, errorCode) {
|
|
65
|
+
return createPayload('failed', actionSubject, OPERATIONAL_EVENT_TYPE)({
|
|
66
|
+
errorCode: errorCode
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
export var createReactionsRenderedEvent = function createReactionsRenderedEvent(startTime) {
|
|
70
|
+
return createPayload('rendered', 'reactionView', OPERATIONAL_EVENT_TYPE)({
|
|
71
|
+
duration: calculateDuration(startTime)
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export var createPickerButtonClickedEvent = function createPickerButtonClickedEvent(reactionEmojiCount) {
|
|
75
|
+
return createPayload('clicked', 'reactionPickerButton', UI_EVENT_TYPE)({
|
|
76
|
+
reactionEmojiCount: reactionEmojiCount
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
export var createPickerCancelledEvent = function createPickerCancelledEvent(startTime) {
|
|
80
|
+
return createPayload('cancelled', 'reactionPicker', UI_EVENT_TYPE)({
|
|
81
|
+
duration: calculateDuration(startTime)
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
export var createPickerMoreClickedEvent = function createPickerMoreClickedEvent(startTime) {
|
|
85
|
+
return createPayload('clicked', 'reactionPicker', UI_EVENT_TYPE, 'more')({
|
|
86
|
+
duration: calculateDuration(startTime)
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
export var createReactionSelectionEvent = function createReactionSelectionEvent(source, emojiId, reaction, startTime) {
|
|
90
|
+
return createPayload('clicked', 'reactionPicker', UI_EVENT_TYPE, 'emoji')({
|
|
91
|
+
duration: calculateDuration(startTime),
|
|
92
|
+
source: source,
|
|
93
|
+
previousState: getPreviousState(reaction),
|
|
94
|
+
emojiId: emojiId
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
export var createReactionHoveredEvent = function createReactionHoveredEvent(startTime) {
|
|
98
|
+
return createPayload('hovered', 'existingReaction', UI_EVENT_TYPE)({
|
|
99
|
+
duration: calculateDuration(startTime)
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
export var createReactionFocusedEvent = function createReactionFocusedEvent(startTime) {
|
|
103
|
+
return createPayload('focused', 'existingReaction', UI_EVENT_TYPE)({
|
|
104
|
+
duration: calculateDuration(startTime)
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
export var createReactionClickedEvent = function createReactionClickedEvent(added, emojiId) {
|
|
108
|
+
return createPayload('clicked', 'existingReaction', UI_EVENT_TYPE)({
|
|
109
|
+
added: added,
|
|
110
|
+
emojiId: emojiId
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Used for store failure metadata for analytics
|
|
116
|
+
* @param error The error could be a service error with {code, reason} or an Error
|
|
117
|
+
* @returns any
|
|
118
|
+
*/
|
|
119
|
+
export var extractErrorInfo = function extractErrorInfo(error) {
|
|
120
|
+
if (error instanceof Error) {
|
|
121
|
+
return {
|
|
122
|
+
name: error.name,
|
|
123
|
+
message: error.message
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return error;
|
|
127
|
+
};
|
|
@@ -4,8 +4,8 @@ import { jsx, css } from '@emotion/react';
|
|
|
4
4
|
import { SlideIn, ExitingPersistence, mediumDurationMs } from '@atlaskit/motion';
|
|
5
5
|
// eslint-disable-next-line @atlaskit/design-system/no-banned-imports
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
7
|
+
import { formatLargeNumber } from '../../shared/utils';
|
|
8
|
+
import { containerStyle, counterLabelStyle, countStyle, highlightStyle } from './styles';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Test id for component top level div
|
|
@@ -40,7 +40,7 @@ export var Counter = function Counter(_ref) {
|
|
|
40
40
|
} else if (value === 0) {
|
|
41
41
|
return '';
|
|
42
42
|
} else {
|
|
43
|
-
return
|
|
43
|
+
return formatLargeNumber(value);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
var lastValue = useRef();
|
|
@@ -54,7 +54,7 @@ export var Counter = function Counter(_ref) {
|
|
|
54
54
|
return jsx("div", {
|
|
55
55
|
className: className,
|
|
56
56
|
"data-testid": RENDER_COMPONENT_WRAPPER,
|
|
57
|
-
css:
|
|
57
|
+
css: countStyle
|
|
58
58
|
}, jsx(ExitingPersistence, null, jsx(SlideIn, {
|
|
59
59
|
enterFrom: isIncreasing ? 'top' : 'bottom',
|
|
60
60
|
exitTo: isIncreasing ? 'top' : 'bottom',
|
|
@@ -63,14 +63,14 @@ export var Counter = function Counter(_ref) {
|
|
|
63
63
|
}, function (motion, direction) {
|
|
64
64
|
return jsx("div", {
|
|
65
65
|
ref: motion.ref,
|
|
66
|
-
css: [
|
|
66
|
+
css: [containerStyle, css({
|
|
67
67
|
position: direction === 'exiting' ? 'absolute' : undefined
|
|
68
68
|
})],
|
|
69
69
|
className: motion.className,
|
|
70
70
|
"data-testid": RENDER_COUNTER_TESTID
|
|
71
71
|
}, jsx("span", {
|
|
72
72
|
"data-testid": RENDER_LABEL_TESTID,
|
|
73
|
-
css: highlight ? [
|
|
73
|
+
css: highlight ? [counterLabelStyle, highlightStyle] : counterLabelStyle,
|
|
74
74
|
key: value
|
|
75
75
|
}, label));
|
|
76
76
|
})));
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export { Counter, RENDER_COUNTER_TESTID, RENDER_COMPONENT_WRAPPER, RENDER_LABEL_TESTID } from './Counter';
|
|
2
|
-
import * as _styles from './styles';
|
|
3
|
-
export { _styles as styles };
|
|
1
|
+
export { Counter, RENDER_COUNTER_TESTID, RENDER_COMPONENT_WRAPPER, RENDER_LABEL_TESTID } from './Counter';
|
|
@@ -3,8 +3,9 @@ import React from 'react';
|
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
5
|
import { ResourcedEmoji } from '@atlaskit/emoji';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
6
|
+
import { messages } from '../../shared/i18n';
|
|
7
|
+
import { isLeftClick } from '../../shared/utils';
|
|
8
|
+
import { emojiButtonStyle } from './styles';
|
|
8
9
|
export var RENDER_BUTTON_TESTID = 'button-emoji-id';
|
|
9
10
|
/**
|
|
10
11
|
* custom button to render the custom emoji selector inside the reaction picker
|
|
@@ -15,7 +16,7 @@ export var EmojiButton = function EmojiButton(_ref) {
|
|
|
15
16
|
emojiProvider = _ref.emojiProvider;
|
|
16
17
|
var onButtonClick = function onButtonClick(event) {
|
|
17
18
|
event.preventDefault();
|
|
18
|
-
if (onClick &&
|
|
19
|
+
if (onClick && isLeftClick(event)) {
|
|
19
20
|
onClick(emojiId, undefined, event);
|
|
20
21
|
}
|
|
21
22
|
};
|
|
@@ -23,11 +24,11 @@ export var EmojiButton = function EmojiButton(_ref) {
|
|
|
23
24
|
return jsx("button", {
|
|
24
25
|
"data-testid": RENDER_BUTTON_TESTID,
|
|
25
26
|
onClick: onButtonClick,
|
|
26
|
-
"aria-label": intl.formatMessage(
|
|
27
|
+
"aria-label": intl.formatMessage(messages.reactWithEmoji, {
|
|
27
28
|
emoji: emojiId.shortName
|
|
28
29
|
}),
|
|
29
30
|
type: "button",
|
|
30
|
-
css:
|
|
31
|
+
css: emojiButtonStyle
|
|
31
32
|
}, jsx(ResourcedEmoji, {
|
|
32
33
|
emojiProvider: emojiProvider,
|
|
33
34
|
emojiId: emojiId
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
-
import
|
|
4
|
+
import { containerStyle, flashStyle } from './styles';
|
|
5
5
|
/**
|
|
6
6
|
* Test id for wrapper FlashAnimation div
|
|
7
7
|
*/
|
|
@@ -13,7 +13,7 @@ export var RENDER_FLASHANIMATION_TESTID = 'flash-animation';
|
|
|
13
13
|
export var FlashAnimation = function FlashAnimation(props) {
|
|
14
14
|
return jsx("div", {
|
|
15
15
|
className: props.className,
|
|
16
|
-
css: [
|
|
16
|
+
css: [containerStyle, props.flash && flashStyle],
|
|
17
17
|
"data-testid": RENDER_FLASHANIMATION_TESTID
|
|
18
18
|
}, props.children);
|
|
19
19
|
};
|
|
@@ -7,12 +7,13 @@ import { useIntl } from 'react-intl-next';
|
|
|
7
7
|
import { jsx } from '@emotion/react';
|
|
8
8
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
9
9
|
import { ResourcedEmoji } from '@atlaskit/emoji';
|
|
10
|
-
import {
|
|
10
|
+
import { createAndFireSafe, createReactionClickedEvent, createReactionFocusedEvent, createReactionHoveredEvent } from '../../analytics';
|
|
11
11
|
import { Counter } from '../Counter';
|
|
12
12
|
import { FlashAnimation } from '../FlashAnimation';
|
|
13
13
|
import { ReactionTooltip } from '../ReactionTooltip';
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
14
|
+
import { messages } from '../../shared/i18n';
|
|
15
|
+
import { isLeftClick } from '../../shared/utils';
|
|
16
|
+
import { emojiStyle, flashStyle, reactedStyle, reactionStyle } from './styles';
|
|
16
17
|
/**
|
|
17
18
|
* Test id for Reaction item wrapper div
|
|
18
19
|
*/
|
|
@@ -80,10 +81,10 @@ export var Reaction = function Reaction(_ref) {
|
|
|
80
81
|
}, [emojiProvider, reaction.emojiId]);
|
|
81
82
|
var handleClick = useCallback(function (event) {
|
|
82
83
|
event.preventDefault();
|
|
83
|
-
if (
|
|
84
|
+
if (isLeftClick(event)) {
|
|
84
85
|
var reacted = reaction.reacted,
|
|
85
86
|
_emojiId = reaction.emojiId;
|
|
86
|
-
|
|
87
|
+
createAndFireSafe(createAnalyticsEvent, createReactionClickedEvent, !reacted, _emojiId);
|
|
87
88
|
onClick(reaction.emojiId, event);
|
|
88
89
|
}
|
|
89
90
|
}, [createAnalyticsEvent, reaction, onClick]);
|
|
@@ -93,7 +94,7 @@ export var Reaction = function Reaction(_ref) {
|
|
|
93
94
|
if (!reaction.users || !reaction.users.length) {
|
|
94
95
|
focusStart.current = Date.now();
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
+
createAndFireSafe(createAnalyticsEvent, createReactionHoveredEvent, focusStart.current);
|
|
97
98
|
onMouseEnter(reaction.emojiId, event);
|
|
98
99
|
}, [createAnalyticsEvent, reaction, onMouseEnter]);
|
|
99
100
|
var handleFocused = useCallback(function (event) {
|
|
@@ -102,7 +103,7 @@ export var Reaction = function Reaction(_ref) {
|
|
|
102
103
|
if (!reaction.users || !reaction.users.length) {
|
|
103
104
|
hoverStart.current = Date.now();
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
createAndFireSafe(createAnalyticsEvent, createReactionFocusedEvent, hoverStart.current);
|
|
106
107
|
onFocused(reaction.emojiId, event);
|
|
107
108
|
}, [createAnalyticsEvent, reaction, onFocused]);
|
|
108
109
|
var handleOpenReactionsDialog = function handleOpenReactionsDialog(emojiId) {
|
|
@@ -117,8 +118,8 @@ export var Reaction = function Reaction(_ref) {
|
|
|
117
118
|
isEnabled: isTooltipEnabled
|
|
118
119
|
}, jsx("button", {
|
|
119
120
|
className: className,
|
|
120
|
-
css: [
|
|
121
|
-
"aria-label": intl.formatMessage(
|
|
121
|
+
css: [reactionStyle, reaction.reacted && reactedStyle],
|
|
122
|
+
"aria-label": intl.formatMessage(messages.reactWithEmoji, {
|
|
122
123
|
emoji: emojiName
|
|
123
124
|
}),
|
|
124
125
|
type: "button",
|
|
@@ -130,9 +131,9 @@ export var Reaction = function Reaction(_ref) {
|
|
|
130
131
|
"data-emoji-button-id": reaction.emojiId
|
|
131
132
|
}, jsx(FlashAnimation, {
|
|
132
133
|
flash: flash,
|
|
133
|
-
css:
|
|
134
|
+
css: flashStyle
|
|
134
135
|
}, jsx("div", {
|
|
135
|
-
css: [
|
|
136
|
+
css: [emojiStyle, reaction.count === 0 && {
|
|
136
137
|
padding: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-025, 2px)", " ", "var(--ds-space-050, 4px)", " 10px")
|
|
137
138
|
}]
|
|
138
139
|
}, jsx(ResourcedEmoji, {
|
|
@@ -10,7 +10,7 @@ import { ResourcedEmoji } from '@atlaskit/emoji/element';
|
|
|
10
10
|
import Avatar from '@atlaskit/avatar/Avatar';
|
|
11
11
|
import Spinner from '@atlaskit/spinner';
|
|
12
12
|
import { useTabPanel } from '@atlaskit/tabs';
|
|
13
|
-
import {
|
|
13
|
+
import { messages } from '../../shared/i18n';
|
|
14
14
|
import { reactionViewStyle, userListStyle, userStyle, centerSpinner } from './styles';
|
|
15
15
|
export var ReactionView = function ReactionView(_ref) {
|
|
16
16
|
var selectedEmojiId = _ref.selectedEmojiId,
|
|
@@ -65,7 +65,7 @@ export var ReactionView = function ReactionView(_ref) {
|
|
|
65
65
|
shortName: ''
|
|
66
66
|
},
|
|
67
67
|
fitToHeight: 24
|
|
68
|
-
}), intl.formatMessage(
|
|
68
|
+
}), intl.formatMessage(messages.emojiName, {
|
|
69
69
|
emojiName: emojiName
|
|
70
70
|
})), alphabeticalNames.length === 0 ? jsx("div", {
|
|
71
71
|
css: centerSpinner
|
|
@@ -5,7 +5,8 @@ import { useIntl } from 'react-intl-next';
|
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import Button from '@atlaskit/button/standard-button';
|
|
7
7
|
import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
|
|
8
|
-
import {
|
|
8
|
+
import { NUMBER_OF_REACTIONS_TO_DISPLAY } from '../../shared/constants';
|
|
9
|
+
import { messages } from '../../shared/i18n';
|
|
9
10
|
import { ReactionsList } from './ReactionsList';
|
|
10
11
|
import { containerStyle, titleStyle } from './styles';
|
|
11
12
|
|
|
@@ -54,7 +55,7 @@ export var ReactionsDialog = function ReactionsDialog(_ref) {
|
|
|
54
55
|
|
|
55
56
|
/* set Reactions Border Width , 9 Number of reactions to display*/
|
|
56
57
|
var reactionsBorderWidth = useMemo(function () {
|
|
57
|
-
return Math.ceil(reactions.length /
|
|
58
|
+
return Math.ceil(reactions.length / NUMBER_OF_REACTIONS_TO_DISPLAY) * 100;
|
|
58
59
|
}, [reactions]);
|
|
59
60
|
|
|
60
61
|
/* Callback from IntersectionObserver to set/unset classNames based on visibility to toggle styles*/
|
|
@@ -63,7 +64,7 @@ export var ReactionsDialog = function ReactionsDialog(_ref) {
|
|
|
63
64
|
var _dataset;
|
|
64
65
|
var element = entry.target;
|
|
65
66
|
var emojiElement = element === null || element === void 0 ? void 0 : element.querySelector('[data-emoji-id]');
|
|
66
|
-
var emojiId = emojiElement === null || emojiElement === void 0
|
|
67
|
+
var emojiId = emojiElement === null || emojiElement === void 0 || (_dataset = emojiElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.emojiId;
|
|
67
68
|
if (entry.intersectionRatio < 1) {
|
|
68
69
|
element.classList.add('disabled');
|
|
69
70
|
/*Check if selectedEmoji (passed as props based on what user selects) is out of viewport */
|
|
@@ -106,7 +107,7 @@ export var ReactionsDialog = function ReactionsDialog(_ref) {
|
|
|
106
107
|
reactionElementsRef.current = reactionsContainerRef.querySelectorAll('.reaction-elements');
|
|
107
108
|
reactionElementsRef.current && reactionElementsRef.current.length > 0 && reactionElementsRef.current.forEach(function (child) {
|
|
108
109
|
var _observerRef$current;
|
|
109
|
-
observerRef === null || observerRef === void 0
|
|
110
|
+
observerRef === null || observerRef === void 0 || (_observerRef$current = observerRef.current) === null || _observerRef$current === void 0 || _observerRef$current.observe(child);
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
return function () {
|
|
@@ -128,7 +129,7 @@ export var ReactionsDialog = function ReactionsDialog(_ref) {
|
|
|
128
129
|
testId: RENDER_MODAL_TESTID
|
|
129
130
|
}, jsx(ModalHeader, null, jsx("div", {
|
|
130
131
|
css: titleStyle
|
|
131
|
-
}, jsx(ModalTitle, null, intl.formatMessage(
|
|
132
|
+
}, jsx(ModalTitle, null, intl.formatMessage(messages.reactionsCount, {
|
|
132
133
|
count: totalReactionsCount
|
|
133
134
|
})))), jsx(ModalBody, null, jsx("div", {
|
|
134
135
|
css: containerStyle(reactionsBorderWidth),
|
|
@@ -142,5 +143,5 @@ export var ReactionsDialog = function ReactionsDialog(_ref) {
|
|
|
142
143
|
appearance: "primary",
|
|
143
144
|
onClick: handleCloseReactionsDialog,
|
|
144
145
|
autoFocus: true
|
|
145
|
-
}, intl.formatMessage(
|
|
146
|
+
}, intl.formatMessage(messages.closeReactionsDialog))));
|
|
146
147
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
3
|
import { B400, N500, N800 } from '@atlaskit/theme/colors';
|
|
4
|
-
import {
|
|
4
|
+
import { NUMBER_OF_REACTIONS_TO_DISPLAY } from '../../shared/constants';
|
|
5
5
|
var REACTIONS_CONTAINER_WIDTH = 48;
|
|
6
6
|
var REACTION_RIGHT_MARGIN = 8;
|
|
7
7
|
/* we want to display around 9 reactions and show 10th one as faded so removing 2px from REACTIONS_CONTAINER_WIDTH*/
|
|
8
|
-
var CONTAINER_WIDTH =
|
|
8
|
+
var CONTAINER_WIDTH = NUMBER_OF_REACTIONS_TO_DISPLAY * (REACTIONS_CONTAINER_WIDTH + REACTION_RIGHT_MARGIN) + REACTIONS_CONTAINER_WIDTH - 2;
|
|
9
9
|
var REACTION_CONTAINER_HEIGHT = 48;
|
|
10
10
|
|
|
11
11
|
/*Reactions Container. Using pseudo Element :after to set border since with onClick of Reaction to higlight the
|
|
@@ -9,13 +9,13 @@ import { FormattedMessage } from 'react-intl-next';
|
|
|
9
9
|
import { EmojiPicker } from '@atlaskit/emoji/picker';
|
|
10
10
|
import { Manager, Popper, Reference } from '@atlaskit/popper';
|
|
11
11
|
import { layers } from '@atlaskit/theme/constants';
|
|
12
|
+
import { useCloseManager } from '../../hooks/useCloseManager';
|
|
13
|
+
import { useFocusTrap } from '../../hooks/useFocusTrap';
|
|
14
|
+
import { messages } from '../../shared/i18n';
|
|
15
|
+
import { PickerRender } from '../../ufo';
|
|
12
16
|
import { Selector } from '../Selector';
|
|
13
17
|
import { Trigger } from '../Trigger';
|
|
14
|
-
import {
|
|
15
|
-
import { i18n } from '../../shared';
|
|
16
|
-
import { useCloseManager } from '../../hooks';
|
|
17
|
-
import * as styles from './styles';
|
|
18
|
-
import { useFocusTrap } from '../../hooks/useFocusTrap';
|
|
18
|
+
import { contentStyle, pickerStyle, popupStyle, popupWrapperStyle } from './styles';
|
|
19
19
|
import { RepositionOnUpdate } from './RepositionOnUpdate';
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -77,7 +77,7 @@ export var ReactionPicker = /*#__PURE__*/React.memo(function (props) {
|
|
|
77
77
|
_props$onCancel = props.onCancel,
|
|
78
78
|
onCancel = _props$onCancel === void 0 ? function () {} : _props$onCancel,
|
|
79
79
|
_props$tooltipContent = props.tooltipContent,
|
|
80
|
-
tooltipContent = _props$tooltipContent === void 0 ? jsx(FormattedMessage,
|
|
80
|
+
tooltipContent = _props$tooltipContent === void 0 ? jsx(FormattedMessage, messages.addReaction) : _props$tooltipContent,
|
|
81
81
|
emojiPickerSize = props.emojiPickerSize;
|
|
82
82
|
var _useState = useState(null),
|
|
83
83
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -125,7 +125,7 @@ export var ReactionPicker = /*#__PURE__*/React.memo(function (props) {
|
|
|
125
125
|
isOpen: false
|
|
126
126
|
}));
|
|
127
127
|
// ufo abort reaction experience
|
|
128
|
-
|
|
128
|
+
PickerRender.abort({
|
|
129
129
|
metadata: {
|
|
130
130
|
emojiId: _id,
|
|
131
131
|
source: 'ReactionPicker',
|
|
@@ -165,23 +165,23 @@ export var ReactionPicker = /*#__PURE__*/React.memo(function (props) {
|
|
|
165
165
|
*/
|
|
166
166
|
var onTriggerClick = function onTriggerClick() {
|
|
167
167
|
// ufo start reactions picker open experience
|
|
168
|
-
|
|
168
|
+
PickerRender.start();
|
|
169
169
|
setSettings({
|
|
170
170
|
isOpen: !settings.isOpen,
|
|
171
171
|
showFullPicker: !!allowAllEmojis && Array.isArray(pickerQuickReactionEmojiIds) && pickerQuickReactionEmojiIds.length === 0
|
|
172
172
|
});
|
|
173
173
|
onOpen();
|
|
174
174
|
// ufo reactions picker opened success
|
|
175
|
-
|
|
175
|
+
PickerRender.success();
|
|
176
176
|
};
|
|
177
177
|
var wrapperClassName = " ".concat(settings.isOpen ? 'isOpen' : '', " ").concat(miniMode ? 'miniMode' : '', " ").concat(className);
|
|
178
178
|
useLayoutEffect(function () {
|
|
179
179
|
var _updatePopper$current;
|
|
180
|
-
(_updatePopper$current = updatePopper.current) === null || _updatePopper$current === void 0
|
|
180
|
+
(_updatePopper$current = updatePopper.current) === null || _updatePopper$current === void 0 || _updatePopper$current.call(updatePopper);
|
|
181
181
|
}, [settings]);
|
|
182
182
|
return jsx("div", {
|
|
183
183
|
className: wrapperClassName,
|
|
184
|
-
css:
|
|
184
|
+
css: pickerStyle,
|
|
185
185
|
"data-testid": RENDER_REACTIONPICKER_TESTID,
|
|
186
186
|
ref: wrapperRef
|
|
187
187
|
}, jsx(Manager, null, jsx(Reference, null, function (_ref) {
|
|
@@ -216,7 +216,7 @@ export var ReactionPicker = /*#__PURE__*/React.memo(function (props) {
|
|
|
216
216
|
onSelection: onEmojiSelected,
|
|
217
217
|
size: emojiPickerSize
|
|
218
218
|
}) : jsx("div", {
|
|
219
|
-
css:
|
|
219
|
+
css: contentStyle
|
|
220
220
|
}, jsx(Selector, {
|
|
221
221
|
emojiProvider: emojiProvider,
|
|
222
222
|
onSelection: onEmojiSelected,
|
|
@@ -262,13 +262,13 @@ var PopperWrapper = function PopperWrapper(props) {
|
|
|
262
262
|
setPopupRef(node);
|
|
263
263
|
}
|
|
264
264
|
},
|
|
265
|
-
css:
|
|
265
|
+
css: popupWrapperStyle,
|
|
266
266
|
tabIndex: 0
|
|
267
267
|
}, jsx(RepositionOnUpdate, {
|
|
268
268
|
update: update,
|
|
269
269
|
settings: settings
|
|
270
270
|
}, jsx("div", {
|
|
271
|
-
css:
|
|
271
|
+
css: popupStyle
|
|
272
272
|
}, children)));
|
|
273
273
|
});
|
|
274
274
|
};
|