@atlaskit/reactions 21.8.1 → 22.0.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 +26 -0
- package/dist/cjs/MockReactionsClient.js +24 -16
- package/dist/cjs/analytics/analytics.js +9 -1
- package/dist/cjs/analytics/ufo.js +24 -2
- package/dist/cjs/components/Counter/Counter.js +16 -20
- package/dist/cjs/components/Reaction/Reaction.js +52 -18
- package/dist/cjs/components/Reaction/styles.js +8 -1
- package/dist/cjs/components/ReactionDialog/ReactionView.js +121 -0
- package/dist/cjs/components/ReactionDialog/ReactionsDialog.js +187 -0
- package/dist/cjs/components/ReactionDialog/ReactionsList.js +104 -0
- package/dist/cjs/components/ReactionDialog/index.js +13 -0
- package/dist/cjs/components/ReactionDialog/styles.js +202 -0
- package/dist/cjs/components/ReactionPicker/ReactionPicker.js +15 -20
- package/dist/cjs/components/ReactionTooltip/ReactionTooltip.js +26 -12
- package/dist/cjs/components/ReactionTooltip/styles.js +11 -2
- package/dist/cjs/components/Reactions/Reactions.js +166 -21
- package/dist/cjs/components/Reactions/styles.js +11 -6
- package/dist/cjs/components/Trigger/Trigger.js +1 -2
- package/dist/cjs/components/index.js +9 -1
- package/dist/cjs/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +6 -2
- package/dist/cjs/containers/ConnectedReactionsView/ConnectedReactionsView.js +9 -4
- package/dist/cjs/shared/constants.js +62 -10
- package/dist/cjs/shared/i18n.js +40 -0
- package/dist/cjs/shared/utils.js +60 -2
- package/dist/cjs/types/reaction.js +13 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/MockReactionsClient.js +22 -14
- package/dist/es2019/analytics/analytics.js +3 -0
- package/dist/es2019/analytics/ufo.js +19 -0
- package/dist/es2019/components/Counter/Counter.js +16 -15
- package/dist/es2019/components/Reaction/Reaction.js +43 -18
- package/dist/es2019/components/Reaction/styles.js +9 -2
- package/dist/es2019/components/ReactionDialog/ReactionView.js +69 -0
- package/dist/es2019/components/ReactionDialog/ReactionsDialog.js +145 -0
- package/dist/es2019/components/ReactionDialog/ReactionsList.js +69 -0
- package/dist/es2019/components/ReactionDialog/index.js +1 -0
- package/dist/es2019/components/ReactionDialog/styles.js +169 -0
- package/dist/es2019/components/ReactionPicker/ReactionPicker.js +12 -20
- package/dist/es2019/components/ReactionTooltip/ReactionTooltip.js +22 -12
- package/dist/es2019/components/ReactionTooltip/styles.js +9 -1
- package/dist/es2019/components/Reactions/Reactions.js +146 -22
- package/dist/es2019/components/Reactions/styles.js +9 -5
- package/dist/es2019/components/Trigger/Trigger.js +1 -2
- package/dist/es2019/components/index.js +2 -1
- package/dist/es2019/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +8 -2
- package/dist/es2019/containers/ConnectedReactionsView/ConnectedReactionsView.js +5 -4
- package/dist/es2019/shared/constants.js +55 -6
- package/dist/es2019/shared/i18n.js +43 -0
- package/dist/es2019/shared/utils.js +51 -0
- package/dist/es2019/types/reaction.js +13 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/MockReactionsClient.js +24 -13
- package/dist/esm/analytics/analytics.js +5 -0
- package/dist/esm/analytics/ufo.js +19 -0
- package/dist/esm/components/Counter/Counter.js +17 -17
- package/dist/esm/components/Reaction/Reaction.js +51 -19
- package/dist/esm/components/Reaction/styles.js +9 -2
- package/dist/esm/components/ReactionDialog/ReactionView.js +98 -0
- package/dist/esm/components/ReactionDialog/ReactionsDialog.js +161 -0
- package/dist/esm/components/ReactionDialog/ReactionsList.js +79 -0
- package/dist/esm/components/ReactionDialog/index.js +1 -0
- package/dist/esm/components/ReactionDialog/styles.js +177 -0
- package/dist/esm/components/ReactionPicker/ReactionPicker.js +15 -20
- package/dist/esm/components/ReactionTooltip/ReactionTooltip.js +26 -12
- package/dist/esm/components/ReactionTooltip/styles.js +9 -1
- package/dist/esm/components/Reactions/Reactions.js +158 -22
- package/dist/esm/components/Reactions/styles.js +9 -5
- package/dist/esm/components/Trigger/Trigger.js +1 -2
- package/dist/esm/components/index.js +2 -1
- package/dist/esm/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +6 -2
- package/dist/esm/containers/ConnectedReactionsView/ConnectedReactionsView.js +8 -4
- package/dist/esm/shared/constants.js +57 -6
- package/dist/esm/shared/i18n.js +40 -0
- package/dist/esm/shared/utils.js +53 -0
- package/dist/esm/types/reaction.js +13 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/MockReactionsClient.d.ts +7 -3
- package/dist/types/analytics/analytics.d.ts +10 -0
- package/dist/types/analytics/ufo.d.ts +18 -2
- package/dist/types/components/Counter/Counter.d.ts +0 -1
- package/dist/types/components/Reaction/Reaction.d.ts +11 -1
- package/dist/types/components/ReactionDialog/ReactionView.d.ts +19 -0
- package/dist/types/components/ReactionDialog/ReactionsDialog.d.ts +32 -0
- package/dist/types/components/ReactionDialog/ReactionsList.d.ts +23 -0
- package/dist/types/components/ReactionDialog/index.d.ts +1 -0
- package/dist/types/components/ReactionDialog/styles.d.ts +11 -0
- package/dist/types/components/ReactionPicker/ReactionPicker.d.ts +5 -0
- package/dist/types/components/ReactionTooltip/ReactionTooltip.d.ts +12 -0
- package/dist/types/components/ReactionTooltip/styles.d.ts +1 -0
- package/dist/types/components/Reactions/Reactions.d.ts +45 -6
- package/dist/types/components/Reactions/styles.d.ts +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/containers/ConnectedReactionPicker/ConnectedReactionPicker.d.ts +0 -4
- package/dist/types/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +2 -11
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared/constants.d.ts +11 -5
- package/dist/types/shared/i18n.d.ts +40 -0
- package/dist/types/shared/utils.d.ts +7 -0
- package/dist/types/types/User.d.ts +10 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/reaction.d.ts +15 -2
- package/docs/0-intro.tsx +3 -0
- package/docs/5-graphql-support.tsx +153 -0
- package/package.json +8 -6
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { md, code, Props } from '@atlaskit/docs';
|
|
3
|
+
import SectionMessage from '@atlaskit/section-message';
|
|
4
|
+
|
|
5
|
+
export default md`
|
|
6
|
+
|
|
7
|
+
### How to get reactions support GraphQL?
|
|
8
|
+
|
|
9
|
+
The pre-built \`ReactionClient\` is supporting REST APIs, if you want to support GraphQL, please follow best practice below.
|
|
10
|
+
|
|
11
|
+
We have a \`ReactionClient\` interface which can be extended to support integrating with Graphql APIs.
|
|
12
|
+
|
|
13
|
+
You can simply create your own \`ReactionGraphQLClient\` to extend our \`ReactionClient\` interface, and implement each method from interface by using your own GraphQL queries or mutations. Just ensure the payload is matched with the type defined from interface. You may need the data transformation before return the promise.
|
|
14
|
+
|
|
15
|
+
#### 1. Create your own \`ReactionsGraphQLClient\` to support your own GraphQL APIs:
|
|
16
|
+
|
|
17
|
+
${code`
|
|
18
|
+
import type { ReactionClient } from "@atlaskit/reactions"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* demo purpose, assume apolloClient has initialized in 'graphqlClient'
|
|
22
|
+
*/
|
|
23
|
+
import apolloClient from 'graphqlClient'
|
|
24
|
+
|
|
25
|
+
export class ReactionsGraphQLClient implements ReactionClient {
|
|
26
|
+
private clientConfig: ClientConfig;
|
|
27
|
+
// optional, you can set up a clientConfig if you need some extra options that params from methods of ReactionClient doesn't provide.
|
|
28
|
+
constructor(clientConfig: ClientConfig) {
|
|
29
|
+
this.clientConfig = clientConfig;
|
|
30
|
+
}
|
|
31
|
+
getReactions(containerAri: string, aris: string[]) {
|
|
32
|
+
return apolloClient.
|
|
33
|
+
.query({
|
|
34
|
+
query: GET_REACTIONS_QUERY, // your own query to fetch reactions
|
|
35
|
+
variables: {
|
|
36
|
+
containerAri,
|
|
37
|
+
aris,
|
|
38
|
+
})
|
|
39
|
+
.then((response) => {
|
|
40
|
+
// transform data if needed to match return type from interface
|
|
41
|
+
return response.data; // type needs to be Reactions
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getDetailedReaction(containerAri: string, ari: string, emojiId: string) {
|
|
45
|
+
return apolloClient.
|
|
46
|
+
.query({
|
|
47
|
+
query: GET_DETAILED_REACTION, // your own query to fetch detailed reaction
|
|
48
|
+
variables: {
|
|
49
|
+
containerAri,
|
|
50
|
+
aris,
|
|
51
|
+
})
|
|
52
|
+
.then((response) => {
|
|
53
|
+
// transform data if needed to match return type from interface
|
|
54
|
+
return response.data; // type needs to be Reactions
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
addReaction(containerAri: string, ari: string, emojiId: string) {
|
|
58
|
+
return apolloClient.
|
|
59
|
+
.mutate({
|
|
60
|
+
mutation: ADD_REACTION, // your own mutation to add reaction
|
|
61
|
+
variables: {
|
|
62
|
+
containerAri,
|
|
63
|
+
ari,
|
|
64
|
+
emojiId,
|
|
65
|
+
})
|
|
66
|
+
.then((response) => {
|
|
67
|
+
// transform data if needed to match return type from interface
|
|
68
|
+
return response.data; // type needs to be Reactions
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
deleteReaction(containerAri: string, ari: string, emojiId: string) {
|
|
72
|
+
return apolloClient.
|
|
73
|
+
.mutate({
|
|
74
|
+
mutation: REMOVE_REACTION, // your own mutation to delete reaction
|
|
75
|
+
variables: {
|
|
76
|
+
containerAri,
|
|
77
|
+
ari,
|
|
78
|
+
emojiId,
|
|
79
|
+
})
|
|
80
|
+
.then((response) => {
|
|
81
|
+
// transform data if needed to match return type from interface
|
|
82
|
+
return response.data; // type needs to be Reactions
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`}
|
|
87
|
+
|
|
88
|
+
#### 2. Set up ReactionsStore with \`ReactionGraphQLClient\`:
|
|
89
|
+
|
|
90
|
+
${code`
|
|
91
|
+
const intialState: State = {
|
|
92
|
+
reactions: {},
|
|
93
|
+
flash: {}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const reactionsStore = useMemo(() => {
|
|
97
|
+
return new MemoryReactionsStore(
|
|
98
|
+
new ReactionsGraphQLClient(
|
|
99
|
+
clientConfig, // client config from your own to provie extra options for your GraphQL APIs
|
|
100
|
+
),
|
|
101
|
+
initialState,
|
|
102
|
+
{
|
|
103
|
+
subproduct: 'atlaskit', // e.g. jira, confluence, etc
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}, [clientConfig]);
|
|
107
|
+
`}
|
|
108
|
+
|
|
109
|
+
#### 3. Consume your reactionsStore in your ConnectedReactionsView
|
|
110
|
+
|
|
111
|
+
${code`
|
|
112
|
+
ReactDOM.render(
|
|
113
|
+
<ConnectedReactionsView
|
|
114
|
+
store={reactionsStore}
|
|
115
|
+
containerAri={containerAri}
|
|
116
|
+
ari={demoAri}
|
|
117
|
+
emojiProvider={Promise.resolve(emojiResource)}
|
|
118
|
+
/>
|
|
119
|
+
container,
|
|
120
|
+
};`}
|
|
121
|
+
|
|
122
|
+
${(
|
|
123
|
+
<>
|
|
124
|
+
<br />
|
|
125
|
+
<SectionMessage
|
|
126
|
+
appearance="information"
|
|
127
|
+
title="There should be only one instance of EmojiResource in your application"
|
|
128
|
+
>
|
|
129
|
+
<p>
|
|
130
|
+
Above examples show the best practice to integrate Graphql APIs. By
|
|
131
|
+
extending from our `ReactionsClient` interface, you are free to use any
|
|
132
|
+
GrapqhQL client, any queries or mutations, as long as they return the
|
|
133
|
+
same type as defined in the interface.
|
|
134
|
+
</p>
|
|
135
|
+
</SectionMessage>
|
|
136
|
+
<br />
|
|
137
|
+
<SectionMessage appearance="warning">
|
|
138
|
+
Use base UI Components `Reactions` from `@atlaskit/reactions` directly
|
|
139
|
+
with your own implementation around to support GraphQL or custom behavior
|
|
140
|
+
is at your own risk. Without using ReactionsStore, we can't track the
|
|
141
|
+
operations of reactions, please add your own tracking to measure. The
|
|
142
|
+
custom implementation will lead to limited support from us.
|
|
143
|
+
</SectionMessage>
|
|
144
|
+
</>
|
|
145
|
+
)}
|
|
146
|
+
|
|
147
|
+
${(
|
|
148
|
+
<Props
|
|
149
|
+
heading="ReactionClient type"
|
|
150
|
+
props={require('!!extract-react-types-loader!../extract-react-type/reactionClient')}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/reactions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"description": "Reactions component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,12 +28,16 @@
|
|
|
28
28
|
"@atlaskit/analytics-gas-types": "^5.0.0",
|
|
29
29
|
"@atlaskit/analytics-namespaced-context": "^6.5.0",
|
|
30
30
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
31
|
-
"@atlaskit/
|
|
31
|
+
"@atlaskit/avatar": "^21.0.0",
|
|
32
|
+
"@atlaskit/button": "^16.5.0",
|
|
32
33
|
"@atlaskit/ds-lib": "^2.1.0",
|
|
33
|
-
"@atlaskit/emoji": "^66.
|
|
34
|
+
"@atlaskit/emoji": "^66.1.0",
|
|
34
35
|
"@atlaskit/icon": "^21.11.0",
|
|
36
|
+
"@atlaskit/modal-dialog": "^12.2.0",
|
|
35
37
|
"@atlaskit/motion": "^1.3.0",
|
|
36
|
-
"@atlaskit/popper": "^5.
|
|
38
|
+
"@atlaskit/popper": "^5.4.0",
|
|
39
|
+
"@atlaskit/spinner": "^15.3.0",
|
|
40
|
+
"@atlaskit/tabs": "^13.2.12",
|
|
37
41
|
"@atlaskit/theme": "^12.2.0",
|
|
38
42
|
"@atlaskit/tokens": "^0.11.0",
|
|
39
43
|
"@atlaskit/tooltip": "^17.6.0",
|
|
@@ -64,8 +68,6 @@
|
|
|
64
68
|
"@testing-library/react-hooks": "^8.0.1",
|
|
65
69
|
"@testing-library/user-event": "^14.4.3",
|
|
66
70
|
"dotenv": "^8.2.0",
|
|
67
|
-
"enzyme": "^3.10.0",
|
|
68
|
-
"enzyme-adapter-react-16": "^1.15.1",
|
|
69
71
|
"es6-promise": "^4.0.5",
|
|
70
72
|
"fetch-mock": "^8.0.0",
|
|
71
73
|
"react": "^16.8.0",
|