@atlaskit/reactions 21.4.0 → 21.5.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 +11 -0
- package/dist/cjs/client/MockReactionsClient.js +202 -107
- package/dist/cjs/client/index.js +33 -1
- package/dist/cjs/components/Reaction.js +7 -4
- package/dist/cjs/components/ReactionPicker.js +13 -5
- package/dist/cjs/components/Reactions.js +1 -1
- package/dist/cjs/containers/ConnectedReactionPicker.js +9 -0
- package/dist/cjs/shared/constants.js +13 -0
- package/dist/cjs/shared/index.js +16 -0
- package/dist/cjs/store/ReactionsStore.js +5 -1
- package/dist/cjs/types/ReactionStatus.js +4 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/MockReactionsClient.js +90 -86
- package/dist/es2019/client/index.js +2 -1
- package/dist/es2019/components/Reaction.js +5 -2
- package/dist/es2019/components/ReactionPicker.js +13 -5
- package/dist/es2019/components/Reactions.js +1 -1
- package/dist/es2019/containers/ConnectedReactionPicker.js +9 -0
- package/dist/es2019/shared/constants.js +4 -0
- package/dist/es2019/shared/index.js +2 -0
- package/dist/es2019/store/ReactionsStore.js +8 -1
- package/dist/es2019/types/ReactionStatus.js +3 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/MockReactionsClient.js +196 -102
- package/dist/esm/client/index.js +2 -1
- package/dist/esm/components/Reaction.js +7 -4
- package/dist/esm/components/ReactionPicker.js +13 -5
- package/dist/esm/components/Reactions.js +1 -1
- package/dist/esm/containers/ConnectedReactionPicker.js +9 -0
- package/dist/esm/shared/constants.js +4 -0
- package/dist/esm/shared/index.js +2 -0
- package/dist/esm/store/ReactionsStore.js +8 -1
- package/dist/esm/types/ReactionStatus.js +3 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/client/MockReactionsClient.d.ts +6 -13
- package/dist/types/client/ReactionClient.d.ts +5 -2
- package/dist/types/client/index.d.ts +1 -0
- package/dist/types/components/Counter.d.ts +18 -0
- package/dist/types/components/EmojiButton.d.ts +9 -0
- package/dist/types/components/FlashAnimation.d.ts +7 -2
- package/dist/types/components/Reaction.d.ts +26 -7
- package/dist/types/components/ReactionPicker.d.ts +36 -1
- package/dist/types/components/ReactionTooltip.d.ts +7 -2
- package/dist/types/components/Reactions.d.ts +42 -8
- package/dist/types/components/Selector.d.ts +12 -0
- package/dist/types/components/ShowMore.d.ts +12 -0
- package/dist/types/components/Trigger.d.ts +9 -0
- package/dist/types/containers/ConnectedReactionPicker.d.ts +9 -3
- package/dist/types/containers/ConnectedReactionsView.d.ts +12 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared/constants.d.ts +3 -0
- package/dist/types/shared/index.d.ts +1 -0
- package/dist/types/store/ReactionsStore.d.ts +42 -5
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/types/Actions.d.ts +17 -4
- package/dist/types/types/ReactionSource.d.ts +3 -0
- package/dist/types/types/ReactionStatus.d.ts +3 -0
- package/dist/types/types/ReactionsState.d.ts +3 -0
- package/dist/types/types/index.d.ts +1 -1
- package/docs/0-intro.tsx +118 -27
- package/docs/1-connected-reaction-picker.tsx +133 -0
- package/docs/2-connected-reactions-view.tsx +130 -0
- package/docs/3-reactions-store.tsx +71 -0
- package/docs/4-reaction-service-client.tsx +42 -0
- package/extract-react-type/ConnectedReactionPicker.ts +8 -0
- package/extract-react-type/ConnectedReactionsView.ts +8 -0
- package/extract-react-type/Reaction.ts +8 -0
- package/extract-react-type/Reactions.ts +8 -0
- package/extract-react-type/actions.ts +8 -0
- package/extract-react-type/reactionClient.ts +8 -0
- package/extract-react-type/reactionsStore.ts +8 -0
- package/package.json +5 -4
|
@@ -1,123 +1,127 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { defaultReactionsByShortName } from '../components/Selector';
|
|
3
|
-
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { Constants } from '../shared';
|
|
4
|
+
export const containerAri = `${Constants.ContainerAriPrefix}1`;
|
|
5
|
+
export const ari = `${Constants.AriPrefix}1`;
|
|
6
|
+
export const getReactionSummary = (shortName, count, reacted) => {
|
|
7
|
+
return {
|
|
8
|
+
ari,
|
|
9
|
+
containerAri,
|
|
10
|
+
emojiId: defaultReactionsByShortName.get(shortName).id,
|
|
11
|
+
count,
|
|
12
|
+
reacted
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export const getUser = (id, displayName) => ({
|
|
13
16
|
id,
|
|
14
17
|
displayName
|
|
15
18
|
});
|
|
16
19
|
|
|
17
|
-
const
|
|
20
|
+
const getReactionKey = (containerAri, ari) => {
|
|
18
21
|
return `${containerAri}|${ari}`;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
|
-
const defaultUsers = [
|
|
24
|
+
const defaultUsers = [getUser('oscar', 'Oscar Wallhult'), getUser('julien', 'Julien Michel Hoarau'), getUser('craig', 'Craig Petchell'), getUser('jerome', 'Jerome Touffe-Blin'), getUser('esoares', 'Eduardo Soares'), getUser('lpereira', 'Luiz Pereira'), getUser('pcurren', 'Paul Curren'), getUser('ttjandra', 'Tara Tjandra'), getUser('severington', 'Ste Everington'), getUser('sguillope', 'Sylvain Guillope'), getUser('alunnon', 'Alex Lunnon')];
|
|
25
|
+
const mockData = {
|
|
26
|
+
[getReactionKey(containerAri, ari)]: [getReactionSummary(':fire:', 1, true), getReactionSummary(':thumbsup:', 999, false), getReactionSummary(':astonished:', 9, false), getReactionSummary(':heart:', 99, false)]
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Mocked version of the client to fetch user information
|
|
30
|
+
*/
|
|
31
|
+
|
|
22
32
|
export class MockReactionsClient {
|
|
23
33
|
constructor(delay = 0) {
|
|
24
|
-
_defineProperty(this, "mockData", {
|
|
25
|
-
[objectReactionKey(containerAri, ari)]: [reaction(':fire:', 1, true), reaction(':thumbsup:', 9, false), reaction(':astonished:', 5, false), reaction(':heart:', 100, false)]
|
|
26
|
-
});
|
|
27
|
-
|
|
28
34
|
_defineProperty(this, "delayPromise", () => new Promise(resolve => window.setTimeout(resolve, this.delay)));
|
|
29
35
|
|
|
30
36
|
this.delay = delay;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
getReactions(containerAri, aris) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
async getReactions(containerAri, aris) {
|
|
40
|
+
await this.delayPromise();
|
|
41
|
+
return aris.reduce((results, ari) => {
|
|
42
|
+
const reactionKey = getReactionKey(containerAri, ari);
|
|
43
|
+
results[ari] = mockData[reactionKey] || [];
|
|
37
44
|
return results;
|
|
38
|
-
}, {})
|
|
45
|
+
}, {});
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
getDetailedReaction(containerAri, ari, emojiId) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
async getDetailedReaction(containerAri, ari, emojiId) {
|
|
49
|
+
await this.delayPromise();
|
|
50
|
+
const reactionKey = `${containerAri}|${ari}`;
|
|
51
|
+
const reactionsMockData = mockData[reactionKey];
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
if (reactionsMockData) {
|
|
54
|
+
const reaction = reactionsMockData.find(reaction_1 => reaction_1.emojiId === emojiId);
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
if (reaction) {
|
|
57
|
+
const users = [...defaultUsers].slice(Math.floor(Math.random() * 4), Math.floor(Math.random() * 9) + 4).slice(0, reaction.count);
|
|
58
|
+
return { ...reaction,
|
|
59
|
+
users
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
containerAri,
|
|
66
|
+
ari,
|
|
67
|
+
emojiId,
|
|
68
|
+
count: 1,
|
|
69
|
+
reacted: true,
|
|
70
|
+
users: []
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async addReaction(containerAri, ari, emojiId) {
|
|
75
|
+
await this.delayPromise();
|
|
76
|
+
const reactionKey = getReactionKey(containerAri, ari);
|
|
77
|
+
let found = false;
|
|
78
|
+
const reactionsMockData = mockData[reactionKey];
|
|
79
|
+
|
|
80
|
+
if (reactionsMockData) {
|
|
81
|
+
mockData[reactionKey] = reactionsMockData.map(reaction => {
|
|
82
|
+
if (reaction.emojiId === emojiId) {
|
|
83
|
+
found = true;
|
|
51
84
|
return { ...reaction,
|
|
52
|
-
|
|
85
|
+
count: reaction.count + 1,
|
|
86
|
+
reacted: true
|
|
53
87
|
};
|
|
54
88
|
}
|
|
55
|
-
}
|
|
56
89
|
|
|
57
|
-
|
|
90
|
+
return reaction;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!found) {
|
|
95
|
+
mockData[reactionKey] = [...(reactionsMockData ? reactionsMockData : []), {
|
|
58
96
|
containerAri,
|
|
59
97
|
ari,
|
|
60
98
|
emojiId,
|
|
61
99
|
count: 1,
|
|
62
|
-
reacted: true
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
addReaction(containerAri, ari, emojiId) {
|
|
69
|
-
return this.delayPromise().then(() => {
|
|
70
|
-
const reactionKey = objectReactionKey(containerAri, ari);
|
|
71
|
-
let found = false;
|
|
72
|
-
const reactionsMockData = this.mockData[reactionKey];
|
|
73
|
-
|
|
74
|
-
if (reactionsMockData) {
|
|
75
|
-
this.mockData[reactionKey] = reactionsMockData.map(reaction => {
|
|
76
|
-
if (reaction.emojiId === emojiId) {
|
|
77
|
-
found = true;
|
|
78
|
-
return { ...reaction,
|
|
79
|
-
count: reaction.count + 1,
|
|
80
|
-
reacted: true
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return reaction;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
100
|
+
reacted: true
|
|
101
|
+
}];
|
|
102
|
+
}
|
|
87
103
|
|
|
88
|
-
|
|
89
|
-
this.mockData[reactionKey] = [...(reactionsMockData ? reactionsMockData : []), {
|
|
90
|
-
containerAri,
|
|
91
|
-
ari,
|
|
92
|
-
emojiId,
|
|
93
|
-
count: 1,
|
|
94
|
-
reacted: true
|
|
95
|
-
}];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return this.mockData[reactionKey];
|
|
99
|
-
});
|
|
104
|
+
return mockData[reactionKey];
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
deleteReaction(containerAri, ari, emojiId) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return { ...reaction,
|
|
112
|
-
count: reaction.count - 1,
|
|
113
|
-
reacted: false
|
|
114
|
-
};
|
|
107
|
+
async deleteReaction(containerAri, ari, emojiId) {
|
|
108
|
+
await this.delayPromise();
|
|
109
|
+
const reactionKey = getReactionKey(containerAri, ari);
|
|
110
|
+
mockData[reactionKey] = mockData[reactionKey].map(reaction => {
|
|
111
|
+
if (reaction.emojiId === emojiId) {
|
|
112
|
+
if (reaction.count === 1) {
|
|
113
|
+
return undefined;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
return reaction
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
return { ...reaction,
|
|
117
|
+
count: reaction.count - 1,
|
|
118
|
+
reacted: false
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return reaction;
|
|
123
|
+
}).filter(reaction_1 => !!reaction_1);
|
|
124
|
+
return mockData[reactionKey];
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ReactionServiceClient } from './ReactionServiceClient';
|
|
1
|
+
export { ReactionServiceClient } from './ReactionServiceClient';
|
|
2
|
+
export { MockReactionsClient, ari, containerAri, getReactionSummary, getUser } from './MockReactionsClient';
|
|
@@ -59,6 +59,10 @@ const flashStyle = css({
|
|
|
59
59
|
borderRadius: '10px',
|
|
60
60
|
height: `${flashHeight}px`
|
|
61
61
|
});
|
|
62
|
+
/**
|
|
63
|
+
* @param id give id for the emoji
|
|
64
|
+
* @param event selected mouse event proerties
|
|
65
|
+
*/
|
|
62
66
|
|
|
63
67
|
class ReactionWithoutAnalytics extends PureComponent {
|
|
64
68
|
constructor(props) {
|
|
@@ -171,8 +175,7 @@ class ReactionWithoutAnalytics extends PureComponent {
|
|
|
171
175
|
_defineProperty(ReactionWithoutAnalytics, "defaultProps", {
|
|
172
176
|
flash: false,
|
|
173
177
|
className: undefined,
|
|
174
|
-
onMouseEnter: undefined
|
|
175
|
-
flashOnMount: false
|
|
178
|
+
onMouseEnter: undefined
|
|
176
179
|
});
|
|
177
180
|
|
|
178
181
|
_defineProperty(ReactionWithoutAnalytics, "displayName", 'Reaction');
|
|
@@ -33,6 +33,10 @@ const popupStyle = css({
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
function noop() {}
|
|
36
|
+
/**
|
|
37
|
+
* This renders the picker component (wrapped by the ConnectedReactionPicker)
|
|
38
|
+
*/
|
|
39
|
+
|
|
36
40
|
|
|
37
41
|
export class ReactionPicker extends PureComponent {
|
|
38
42
|
constructor(props) {
|
|
@@ -63,11 +67,11 @@ export class ReactionPicker extends PureComponent {
|
|
|
63
67
|
_defineProperty(this, "showFullPicker", e => {
|
|
64
68
|
e.preventDefault();
|
|
65
69
|
const {
|
|
66
|
-
|
|
70
|
+
onShowMore
|
|
67
71
|
} = this.props;
|
|
68
72
|
|
|
69
|
-
if (
|
|
70
|
-
|
|
73
|
+
if (onShowMore) {
|
|
74
|
+
onShowMore();
|
|
71
75
|
} // Update popper position
|
|
72
76
|
|
|
73
77
|
|
|
@@ -138,11 +142,15 @@ export class ReactionPicker extends PureComponent {
|
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
componentDidMount() {
|
|
141
|
-
document.addEventListener('click', this.handleClickOutside
|
|
145
|
+
document.addEventListener('click', this.handleClickOutside, {
|
|
146
|
+
capture: true
|
|
147
|
+
});
|
|
142
148
|
}
|
|
143
149
|
|
|
144
150
|
componentWillUnmount() {
|
|
145
|
-
document.removeEventListener('click', this.handleClickOutside
|
|
151
|
+
document.removeEventListener('click', this.handleClickOutside, {
|
|
152
|
+
capture: true
|
|
153
|
+
});
|
|
146
154
|
UFO.PickerRender.abort({
|
|
147
155
|
metadata: {
|
|
148
156
|
source: 'Reaction-Picker',
|
|
@@ -128,7 +128,7 @@ export class ReactionsWithoutAnalytics extends React.PureComponent {
|
|
|
128
128
|
onSelection: this.handleOnSelection,
|
|
129
129
|
onOpen: this.handlePickerOpen,
|
|
130
130
|
onCancel: this.handleOnCancel,
|
|
131
|
-
|
|
131
|
+
onShowMore: this.handleOnMore
|
|
132
132
|
}));
|
|
133
133
|
}
|
|
134
134
|
|
|
@@ -11,8 +11,17 @@ export const ConnectedReactionPicker = props => {
|
|
|
11
11
|
const renderChild = innerProps => {
|
|
12
12
|
return /*#__PURE__*/React.createElement(ReactionPicker, _extends({}, props, innerProps));
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Mapping actions for the picker selection
|
|
16
|
+
* @param actions
|
|
17
|
+
* @returns void
|
|
18
|
+
*/
|
|
19
|
+
|
|
14
20
|
|
|
15
21
|
const actionsMapper = actions => ({
|
|
22
|
+
/**
|
|
23
|
+
* Event handler when an emoji gets selected
|
|
24
|
+
*/
|
|
16
25
|
onSelection: emojiId => {
|
|
17
26
|
actions.addReaction(props.containerAri, props.ari, emojiId);
|
|
18
27
|
}
|
|
@@ -6,6 +6,9 @@ import * as utils from './utils';
|
|
|
6
6
|
import { isRealErrorFromService } from './utils';
|
|
7
7
|
import { SAMPLING_RATE_REACTIONS_RENDERED_EXP } from '../analytics/constants';
|
|
8
8
|
import { sampledReactionsRendered } from '../analytics/ufo';
|
|
9
|
+
/**
|
|
10
|
+
* store main structure
|
|
11
|
+
*/
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Set of all available UFO experiences relating to reaction element
|
|
@@ -31,6 +34,10 @@ export const ufoExperiences = {
|
|
|
31
34
|
*/
|
|
32
35
|
fetchDetails: Analytics.UFO.ReactionDetailsFetch
|
|
33
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Collection of methods to manage internal state across the different Reaction container components ConnectedReactionPicker and ConnectedReactionsView
|
|
39
|
+
*/
|
|
40
|
+
|
|
34
41
|
export class MemoryReactionsStore {
|
|
35
42
|
constructor(client, state = {
|
|
36
43
|
reactions: {},
|
|
@@ -302,7 +309,7 @@ export class MemoryReactionsStore {
|
|
|
302
309
|
return updater => {
|
|
303
310
|
const reactionsState = this.getReactionsState(containerAri, ari);
|
|
304
311
|
|
|
305
|
-
if (reactionsState.status === Types.ReactionStatus.ready) {
|
|
312
|
+
if (reactionsState && reactionsState.status === Types.ReactionStatus.ready) {
|
|
306
313
|
const updated = updater(reactionsState);
|
|
307
314
|
|
|
308
315
|
if (updated) {
|
package/dist/es2019/version.json
CHANGED