@atlaskit/reactions 21.6.2 → 21.8.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 +29 -0
- package/dist/cjs/MockReactionsClient.js +3 -1
- package/dist/cjs/analytics/analytics.js +21 -2
- package/dist/cjs/components/Counter/Counter.js +39 -31
- package/dist/cjs/components/Counter/index.js +8 -2
- package/dist/cjs/components/Counter/styles.js +4 -4
- package/dist/cjs/components/EmojiButton/EmojiButton.js +9 -4
- package/dist/cjs/components/EmojiButton/styles.js +2 -2
- package/dist/cjs/components/FlashAnimation/FlashAnimation.js +2 -2
- package/dist/cjs/components/FlashAnimation/styles.js +4 -4
- package/dist/cjs/components/Reaction/Reaction.js +15 -12
- package/dist/cjs/components/Reaction/styles.js +5 -5
- package/dist/cjs/components/ReactionPicker/ReactionPicker.js +59 -59
- package/dist/cjs/components/ReactionPicker/styles.js +7 -5
- package/dist/cjs/components/ReactionTooltip/ReactionTooltip.js +8 -8
- package/dist/cjs/components/ReactionTooltip/styles.js +4 -4
- package/dist/cjs/components/Reactions/Reactions.js +36 -41
- package/dist/cjs/components/Reactions/index.js +0 -6
- package/dist/cjs/components/Reactions/styles.js +3 -3
- package/dist/cjs/components/Selector/Selector.js +6 -6
- package/dist/cjs/components/Selector/styles.js +5 -5
- package/dist/cjs/components/ShowMore/ShowMore.js +13 -10
- package/dist/cjs/components/ShowMore/index.js +6 -0
- package/dist/cjs/components/ShowMore/styles.js +4 -4
- package/dist/cjs/components/Trigger/Trigger.js +28 -10
- package/dist/cjs/components/Trigger/index.js +6 -0
- package/dist/cjs/components/Trigger/styles.js +11 -5
- package/dist/cjs/containers/ConnectedReactionsView/ConnectedReactionsView.js +5 -7
- package/dist/cjs/hooks/useClickAway.js +5 -3
- package/dist/cjs/shared/constants.js +14 -2
- package/dist/cjs/shared/i18n.js +10 -0
- package/dist/cjs/store/MemoryReactionsStore.js +33 -29
- package/dist/cjs/types/reaction.js +5 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/MockReactionsClient.js +1 -1
- package/dist/es2019/analytics/analytics.js +17 -1
- package/dist/es2019/components/Counter/Counter.js +39 -32
- package/dist/es2019/components/Counter/index.js +1 -1
- package/dist/es2019/components/Counter/styles.js +1 -1
- package/dist/es2019/components/EmojiButton/EmojiButton.js +7 -3
- package/dist/es2019/components/EmojiButton/styles.js +1 -1
- package/dist/es2019/components/FlashAnimation/FlashAnimation.js +1 -1
- package/dist/es2019/components/FlashAnimation/styles.js +1 -1
- package/dist/es2019/components/Reaction/Reaction.js +9 -7
- package/dist/es2019/components/Reaction/styles.js +1 -1
- package/dist/es2019/components/ReactionPicker/ReactionPicker.js +33 -10
- package/dist/es2019/components/ReactionPicker/styles.js +4 -2
- package/dist/es2019/components/ReactionTooltip/ReactionTooltip.js +2 -2
- package/dist/es2019/components/ReactionTooltip/styles.js +1 -1
- package/dist/es2019/components/Reactions/Reactions.js +33 -34
- package/dist/es2019/components/Reactions/index.js +1 -1
- package/dist/es2019/components/Reactions/styles.js +1 -1
- package/dist/es2019/components/Selector/Selector.js +1 -1
- package/dist/es2019/components/Selector/styles.js +1 -1
- package/dist/es2019/components/ShowMore/ShowMore.js +5 -3
- package/dist/es2019/components/ShowMore/index.js +1 -1
- package/dist/es2019/components/ShowMore/styles.js +1 -1
- package/dist/es2019/components/Trigger/Trigger.js +22 -7
- package/dist/es2019/components/Trigger/index.js +1 -1
- package/dist/es2019/components/Trigger/styles.js +11 -6
- package/dist/es2019/containers/ConnectedReactionsView/ConnectedReactionsView.js +5 -7
- package/dist/es2019/hooks/useClickAway.js +5 -4
- package/dist/es2019/shared/constants.js +10 -0
- package/dist/es2019/shared/i18n.js +10 -0
- package/dist/es2019/store/MemoryReactionsStore.js +32 -29
- package/dist/es2019/types/reaction.js +5 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/MockReactionsClient.js +1 -3
- package/dist/esm/analytics/analytics.js +16 -0
- package/dist/esm/components/Counter/Counter.js +26 -24
- package/dist/esm/components/Counter/index.js +1 -1
- package/dist/esm/components/Counter/styles.js +1 -1
- package/dist/esm/components/EmojiButton/EmojiButton.js +7 -3
- package/dist/esm/components/EmojiButton/styles.js +1 -1
- package/dist/esm/components/FlashAnimation/FlashAnimation.js +1 -1
- package/dist/esm/components/FlashAnimation/styles.js +1 -1
- package/dist/esm/components/Reaction/Reaction.js +9 -7
- package/dist/esm/components/Reaction/styles.js +1 -1
- package/dist/esm/components/ReactionPicker/ReactionPicker.js +50 -51
- package/dist/esm/components/ReactionPicker/styles.js +4 -2
- package/dist/esm/components/ReactionTooltip/ReactionTooltip.js +2 -2
- package/dist/esm/components/ReactionTooltip/styles.js +1 -1
- package/dist/esm/components/Reactions/Reactions.js +31 -34
- package/dist/esm/components/Reactions/index.js +1 -1
- package/dist/esm/components/Reactions/styles.js +1 -1
- package/dist/esm/components/Selector/Selector.js +1 -1
- package/dist/esm/components/Selector/styles.js +1 -1
- package/dist/esm/components/ShowMore/ShowMore.js +5 -3
- package/dist/esm/components/ShowMore/index.js +1 -1
- package/dist/esm/components/ShowMore/styles.js +1 -1
- package/dist/esm/components/Trigger/Trigger.js +24 -8
- package/dist/esm/components/Trigger/index.js +1 -1
- package/dist/esm/components/Trigger/styles.js +12 -6
- package/dist/esm/containers/ConnectedReactionsView/ConnectedReactionsView.js +5 -7
- package/dist/esm/hooks/useClickAway.js +5 -3
- package/dist/esm/shared/constants.js +10 -0
- package/dist/esm/shared/i18n.js +10 -0
- package/dist/esm/store/MemoryReactionsStore.js +32 -29
- package/dist/esm/types/reaction.js +5 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/MockReactionsClient.d.ts +3 -0
- package/dist/types/analytics/analytics.d.ts +6 -0
- package/dist/types/components/Counter/Counter.d.ts +8 -3
- package/dist/types/components/Counter/index.d.ts +1 -1
- package/dist/types/components/Counter/styles.d.ts +3 -3
- package/dist/types/components/EmojiButton/styles.d.ts +1 -1
- package/dist/types/components/FlashAnimation/styles.d.ts +5 -3
- package/dist/types/components/Reaction/styles.d.ts +4 -4
- package/dist/types/components/ReactionPicker/ReactionPicker.d.ts +2 -5
- package/dist/types/components/ReactionPicker/styles.d.ts +3 -3
- package/dist/types/components/ReactionTooltip/styles.d.ts +3 -3
- package/dist/types/components/Reactions/Reactions.d.ts +8 -15
- package/dist/types/components/Reactions/index.d.ts +1 -1
- package/dist/types/components/Reactions/styles.d.ts +2 -2
- package/dist/types/components/Selector/Selector.d.ts +1 -1
- package/dist/types/components/Selector/styles.d.ts +6 -4
- package/dist/types/components/ShowMore/ShowMore.d.ts +2 -1
- package/dist/types/components/ShowMore/index.d.ts +1 -1
- package/dist/types/components/ShowMore/styles.d.ts +3 -3
- package/dist/types/components/Trigger/Trigger.d.ts +14 -2
- package/dist/types/components/Trigger/index.d.ts +1 -1
- package/dist/types/components/Trigger/styles.d.ts +1 -1
- package/dist/types/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +3 -3
- package/dist/types/hooks/useClickAway.d.ts +2 -1
- package/dist/types/shared/constants.d.ts +8 -0
- package/dist/types/shared/i18n.d.ts +10 -0
- package/dist/types/types/Actions.d.ts +2 -2
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/reaction.d.ts +19 -1
- package/dist/types-ts4.0/MockReactionsClient.d.ts +3 -0
- package/dist/types-ts4.0/analytics/analytics.d.ts +6 -0
- package/dist/types-ts4.0/components/Counter/Counter.d.ts +8 -3
- package/dist/types-ts4.0/components/Counter/index.d.ts +1 -1
- package/dist/types-ts4.0/components/Counter/styles.d.ts +3 -3
- package/dist/types-ts4.0/components/EmojiButton/styles.d.ts +1 -1
- package/dist/types-ts4.0/components/FlashAnimation/styles.d.ts +5 -3
- package/dist/types-ts4.0/components/Reaction/styles.d.ts +4 -4
- package/dist/types-ts4.0/components/ReactionPicker/ReactionPicker.d.ts +2 -5
- package/dist/types-ts4.0/components/ReactionPicker/styles.d.ts +3 -3
- package/dist/types-ts4.0/components/ReactionTooltip/styles.d.ts +3 -3
- package/dist/types-ts4.0/components/Reactions/Reactions.d.ts +8 -15
- package/dist/types-ts4.0/components/Reactions/index.d.ts +1 -1
- package/dist/types-ts4.0/components/Reactions/styles.d.ts +2 -2
- package/dist/types-ts4.0/components/Selector/Selector.d.ts +1 -1
- package/dist/types-ts4.0/components/Selector/styles.d.ts +6 -4
- package/dist/types-ts4.0/components/ShowMore/ShowMore.d.ts +2 -1
- package/dist/types-ts4.0/components/ShowMore/index.d.ts +1 -1
- package/dist/types-ts4.0/components/ShowMore/styles.d.ts +3 -3
- package/dist/types-ts4.0/components/Trigger/Trigger.d.ts +14 -2
- package/dist/types-ts4.0/components/Trigger/index.d.ts +1 -1
- package/dist/types-ts4.0/components/Trigger/styles.d.ts +1 -1
- package/dist/types-ts4.0/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +3 -3
- package/dist/types-ts4.0/hooks/useClickAway.d.ts +2 -1
- package/dist/types-ts4.0/shared/constants.d.ts +8 -0
- package/dist/types-ts4.0/shared/i18n.d.ts +10 -0
- package/dist/types-ts4.0/types/Actions.d.ts +2 -2
- package/dist/types-ts4.0/types/index.d.ts +1 -1
- package/dist/types-ts4.0/types/reaction.d.ts +19 -1
- package/package.json +11 -9
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useIntl } from 'react-intl-next';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
4
5
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
6
|
import { ResourcedEmoji } from '@atlaskit/emoji';
|
|
6
7
|
import { Analytics } from '../../analytics';
|
|
7
8
|
import { Counter } from '../Counter';
|
|
8
9
|
import { FlashAnimation } from '../FlashAnimation';
|
|
9
10
|
import { ReactionTooltip } from '../ReactionTooltip';
|
|
10
|
-
import { utils } from '../../shared';
|
|
11
|
+
import { i18n, utils } from '../../shared';
|
|
11
12
|
import * as styles from './styles';
|
|
12
13
|
/**
|
|
13
14
|
* Test id for Reaction item wrapper div
|
|
@@ -40,10 +41,7 @@ export const Reaction = ({
|
|
|
40
41
|
useEffect(() => {
|
|
41
42
|
(async () => {
|
|
42
43
|
const emojiResource = await Promise.resolve(emojiProvider);
|
|
43
|
-
const foundEmoji = await emojiResource.
|
|
44
|
-
shortName: '',
|
|
45
|
-
id: reaction.emojiId
|
|
46
|
-
});
|
|
44
|
+
const foundEmoji = await emojiResource.findById(reaction.emojiId);
|
|
47
45
|
|
|
48
46
|
if (foundEmoji) {
|
|
49
47
|
setEmojiName(foundEmoji.name);
|
|
@@ -75,14 +73,18 @@ export const Reaction = ({
|
|
|
75
73
|
onMouseEnter(reaction, event);
|
|
76
74
|
}
|
|
77
75
|
}, [createAnalyticsEvent, reaction, onMouseEnter]);
|
|
76
|
+
const intl = useIntl();
|
|
78
77
|
return jsx(ReactionTooltip, {
|
|
79
78
|
emojiName: emojiName,
|
|
80
79
|
reaction: reaction
|
|
81
80
|
}, jsx("button", {
|
|
82
81
|
className: className,
|
|
83
82
|
css: [styles.reactionStyle, reaction.reacted && styles.reactedStyle],
|
|
84
|
-
|
|
83
|
+
"aria-label": intl.formatMessage(i18n.messages.reactWithEmoji, {
|
|
84
|
+
emoji: emojiName
|
|
85
|
+
}),
|
|
85
86
|
type: "button",
|
|
87
|
+
"data-emoji-id": reaction.emojiId,
|
|
86
88
|
"data-testid": RENDER_REACTION_TESTID,
|
|
87
89
|
onMouseUp: handleMouseUp,
|
|
88
90
|
onMouseEnter: handleMouseEnter
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import React, { Fragment, useCallback, useRef, useState } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/
|
|
2
|
+
import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
4
5
|
import { EmojiPicker } from '@atlaskit/emoji/picker';
|
|
5
6
|
import { Manager, Popper, Reference } from '@atlaskit/popper';
|
|
6
7
|
import { layers } from '@atlaskit/theme/constants';
|
|
7
8
|
import { Selector } from '../Selector';
|
|
8
9
|
import { Trigger } from '../Trigger';
|
|
9
10
|
import { UFO } from '../../analytics';
|
|
11
|
+
import { i18n } from '../../shared';
|
|
10
12
|
import { useClickAway } from '../../hooks';
|
|
11
13
|
import * as styles from './styles';
|
|
12
14
|
/**
|
|
@@ -14,6 +16,11 @@ import * as styles from './styles';
|
|
|
14
16
|
*/
|
|
15
17
|
|
|
16
18
|
export const RENDER_REACTIONPICKER_TESTID = 'reactionPicker-testid';
|
|
19
|
+
/**
|
|
20
|
+
* Emoji Picker Controller Id for Accessibility Labels
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const PICKER_CONTROL_ID = 'emoji-picker';
|
|
17
24
|
const popperModifiers = [
|
|
18
25
|
/**
|
|
19
26
|
Removing this applyStyle modifier as it throws client errors ref:
|
|
@@ -56,7 +63,8 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
56
63
|
pickerQuickReactionEmojiIds,
|
|
57
64
|
onShowMore,
|
|
58
65
|
onOpen,
|
|
59
|
-
onCancel
|
|
66
|
+
onCancel,
|
|
67
|
+
tooltipContent = jsx(FormattedMessage, i18n.messages.addReaction)
|
|
60
68
|
} = props;
|
|
61
69
|
/**
|
|
62
70
|
* Container <div /> reference (used by custom hook to detect click outside)
|
|
@@ -67,7 +75,7 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
67
75
|
* a function you can ask Popper to recompute your tooltip's position. It will directly call the Popper#update method
|
|
68
76
|
*/
|
|
69
77
|
|
|
70
|
-
const updatePopper = useRef(
|
|
78
|
+
const updatePopper = useRef();
|
|
71
79
|
const [settings, setSettings] = useState({
|
|
72
80
|
/**
|
|
73
81
|
* Show the picker floating panel
|
|
@@ -89,7 +97,7 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
close();
|
|
92
|
-
});
|
|
100
|
+
}, 'click', true);
|
|
93
101
|
/**
|
|
94
102
|
* Event callback when the picker is closed
|
|
95
103
|
* @param _id Optional id if an emoji button was selected or undefineed if was clicked outside the picker
|
|
@@ -104,7 +112,7 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
104
112
|
UFO.PickerRender.abort({
|
|
105
113
|
metadata: {
|
|
106
114
|
emojiId: _id,
|
|
107
|
-
source: '
|
|
115
|
+
source: 'ReactionPicker',
|
|
108
116
|
reason: 'close dialog'
|
|
109
117
|
}
|
|
110
118
|
});
|
|
@@ -114,10 +122,8 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
114
122
|
* @param e event param
|
|
115
123
|
*/
|
|
116
124
|
|
|
117
|
-
const onSelectMoreClick = useCallback(
|
|
125
|
+
const onSelectMoreClick = useCallback(e => {
|
|
118
126
|
e.preventDefault();
|
|
119
|
-
await updatePopper.current(); // Update popper position
|
|
120
|
-
|
|
121
127
|
setSettings({
|
|
122
128
|
isOpen: true,
|
|
123
129
|
showFullPicker: true
|
|
@@ -160,7 +166,18 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
160
166
|
|
|
161
167
|
UFO.PickerRender.success();
|
|
162
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* When picker is opened, re-calculate the picker position
|
|
171
|
+
*/
|
|
172
|
+
|
|
163
173
|
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (settings.isOpen) {
|
|
176
|
+
if (updatePopper.current) {
|
|
177
|
+
updatePopper.current();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}, [settings]);
|
|
164
181
|
const wrapperClassName = ` ${settings.isOpen ? 'isOpen' : ''} ${miniMode ? 'miniMode' : ''} ${className}`;
|
|
165
182
|
return jsx("div", {
|
|
166
183
|
className: wrapperClassName,
|
|
@@ -171,10 +188,15 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
171
188
|
ref: popperRef
|
|
172
189
|
}) => // Render a button to open the <Selector /> panel
|
|
173
190
|
jsx(Trigger, {
|
|
191
|
+
ariaAttributes: {
|
|
192
|
+
'aria-expanded': settings.isOpen,
|
|
193
|
+
'aria-controls': PICKER_CONTROL_ID
|
|
194
|
+
},
|
|
174
195
|
ref: popperRef,
|
|
175
196
|
onClick: onTriggerClick,
|
|
176
197
|
miniMode: miniMode,
|
|
177
|
-
disabled: disabled
|
|
198
|
+
disabled: disabled,
|
|
199
|
+
tooltipContent: tooltipContent
|
|
178
200
|
})), jsx(Popper, {
|
|
179
201
|
placement: "bottom-start",
|
|
180
202
|
modifiers: popperModifiers
|
|
@@ -185,6 +207,7 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
185
207
|
}) => {
|
|
186
208
|
updatePopper.current = update;
|
|
187
209
|
return jsx(Fragment, null, settings.isOpen && jsx("div", {
|
|
210
|
+
id: PICKER_CONTROL_ID,
|
|
188
211
|
style: {
|
|
189
212
|
zIndex: layers.layer(),
|
|
190
213
|
...style
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { css } from '@emotion/
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
3
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
4
4
|
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
5
5
|
import { token } from '@atlaskit/tokens';
|
|
@@ -18,6 +18,8 @@ export const popupStyle = css({
|
|
|
18
18
|
borderRadius: `${borderRadius()}px`,
|
|
19
19
|
boxShadow: token('elevation.shadow.overlay', `0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`),
|
|
20
20
|
'&> div': {
|
|
21
|
-
boxShadow: undefined
|
|
21
|
+
boxShadow: undefined,
|
|
22
|
+
marginTop: '4px',
|
|
23
|
+
marginBottom: '4px'
|
|
22
24
|
}
|
|
23
25
|
});
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { jsx } from '@emotion/
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
6
|
import Tooltip from '@atlaskit/tooltip';
|
|
7
7
|
import { FormattedMessage } from 'react-intl-next';
|
|
8
8
|
import { constants, i18n } from '../../shared';
|
|
@@ -41,6 +41,6 @@ export const ReactionTooltip = ({
|
|
|
41
41
|
return jsx(Tooltip, {
|
|
42
42
|
content: content,
|
|
43
43
|
position: "bottom",
|
|
44
|
-
|
|
44
|
+
testId: RENDER_REACTIONTOOLTIP_TESTID
|
|
45
45
|
}, React.Children.only(children));
|
|
46
46
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
4
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
|
-
import Tooltip from '@atlaskit/tooltip';
|
|
6
5
|
import { FormattedMessage } from 'react-intl-next';
|
|
7
6
|
import { Analytics } from '../../analytics';
|
|
8
7
|
import { ReactionStatus } from '../../types';
|
|
@@ -10,28 +9,42 @@ import { i18n } from '../../shared';
|
|
|
10
9
|
import { Reaction } from '../Reaction';
|
|
11
10
|
import { ReactionPicker } from '../ReactionPicker';
|
|
12
11
|
import * as styles from './styles';
|
|
13
|
-
|
|
14
12
|
/**
|
|
15
13
|
* Test id for wrapper Reactions div
|
|
16
14
|
*/
|
|
15
|
+
|
|
17
16
|
export const RENDER_REACTIONS_TESTID = 'render-reactions';
|
|
17
|
+
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Get content of the tooltip
|
|
20
20
|
*/
|
|
21
|
+
export function getTooltip(status, errorMessage) {
|
|
22
|
+
switch (status) {
|
|
23
|
+
case ReactionStatus.error:
|
|
24
|
+
return errorMessage || jsx(FormattedMessage, i18n.messages.unexpectedError);
|
|
25
|
+
// When reaction is not available don't show any tooltip (e.g. Archive page in Confluence)
|
|
26
|
+
|
|
27
|
+
case ReactionStatus.disabled:
|
|
28
|
+
return null;
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
case ReactionStatus.notLoaded:
|
|
31
|
+
case ReactionStatus.loading:
|
|
32
|
+
return jsx(FormattedMessage, i18n.messages.loadingReactions);
|
|
23
33
|
|
|
34
|
+
case ReactionStatus.ready:
|
|
35
|
+
return jsx(FormattedMessage, i18n.messages.addReaction);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
24
38
|
/**
|
|
25
39
|
* Renders list of reactions
|
|
26
40
|
*/
|
|
41
|
+
|
|
27
42
|
export const Reactions = /*#__PURE__*/React.memo(({
|
|
28
43
|
flash = {},
|
|
29
44
|
status,
|
|
30
45
|
errorMessage,
|
|
31
46
|
loadReaction,
|
|
32
|
-
|
|
33
|
-
containerAri,
|
|
34
|
-
ari,
|
|
47
|
+
quickReactionEmojis,
|
|
35
48
|
pickerQuickReactionEmojiIds,
|
|
36
49
|
onReactionHover,
|
|
37
50
|
onSelection,
|
|
@@ -61,23 +74,6 @@ export const Reactions = /*#__PURE__*/React.memo(({
|
|
|
61
74
|
renderTime.current = undefined;
|
|
62
75
|
}
|
|
63
76
|
}, [createAnalyticsEvent, status]);
|
|
64
|
-
/**
|
|
65
|
-
* Get content of the tooltip
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
const getTooltip = () => {
|
|
69
|
-
switch (status) {
|
|
70
|
-
case ReactionStatus.error:
|
|
71
|
-
return errorMessage || jsx(FormattedMessage, i18n.messages.unexpectedError);
|
|
72
|
-
|
|
73
|
-
case ReactionStatus.loading:
|
|
74
|
-
case ReactionStatus.notLoaded:
|
|
75
|
-
return jsx(FormattedMessage, i18n.messages.loadingReactions);
|
|
76
|
-
|
|
77
|
-
default:
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
77
|
|
|
82
78
|
const handleReactionMouseEnter = summary => {
|
|
83
79
|
if (onReactionHover) {
|
|
@@ -111,12 +107,17 @@ export const Reactions = /*#__PURE__*/React.memo(({
|
|
|
111
107
|
/**
|
|
112
108
|
* If reactions not empty, don't show quick reactions Pre defined emoji or if its empty => return the current list of reactions
|
|
113
109
|
*/
|
|
114
|
-
if (reactions.length > 0 || !
|
|
110
|
+
if (reactions.length > 0 || !quickReactionEmojis) {
|
|
115
111
|
return reactions;
|
|
116
112
|
} // add any missing default reactions
|
|
117
113
|
|
|
118
114
|
|
|
119
|
-
const
|
|
115
|
+
const {
|
|
116
|
+
ari,
|
|
117
|
+
containerAri,
|
|
118
|
+
emojiIds
|
|
119
|
+
} = quickReactionEmojis;
|
|
120
|
+
const items = emojiIds.filter(emojiId => !reactions.some(reaction => reaction.emojiId === emojiId)).map(emojiId => {
|
|
120
121
|
return {
|
|
121
122
|
ari,
|
|
122
123
|
containerAri,
|
|
@@ -126,7 +127,7 @@ export const Reactions = /*#__PURE__*/React.memo(({
|
|
|
126
127
|
};
|
|
127
128
|
});
|
|
128
129
|
return reactions.concat(items);
|
|
129
|
-
}, [
|
|
130
|
+
}, [quickReactionEmojis, reactions]);
|
|
130
131
|
return jsx("div", {
|
|
131
132
|
css: styles.wrapperStyle,
|
|
132
133
|
"data-testid": RENDER_REACTIONS_TESTID
|
|
@@ -138,10 +139,7 @@ export const Reactions = /*#__PURE__*/React.memo(({
|
|
|
138
139
|
onClick: onReactionClick,
|
|
139
140
|
onMouseEnter: handleReactionMouseEnter,
|
|
140
141
|
flash: flash[reaction.emojiId]
|
|
141
|
-
})), jsx(
|
|
142
|
-
testId: RENDER_TOOLTIP_TESTID,
|
|
143
|
-
content: getTooltip()
|
|
144
|
-
}, jsx(ReactionPicker, {
|
|
142
|
+
})), jsx(ReactionPicker, {
|
|
145
143
|
css: styles.reactionStyle,
|
|
146
144
|
emojiProvider: emojiProvider,
|
|
147
145
|
miniMode: true,
|
|
@@ -151,6 +149,7 @@ export const Reactions = /*#__PURE__*/React.memo(({
|
|
|
151
149
|
onSelection: handleOnSelection,
|
|
152
150
|
onOpen: handlePickerOpen,
|
|
153
151
|
onCancel: handleOnCancel,
|
|
154
|
-
onShowMore: handleOnMore
|
|
155
|
-
|
|
152
|
+
onShowMore: handleOnMore,
|
|
153
|
+
tooltipContent: getTooltip(status, errorMessage)
|
|
154
|
+
}));
|
|
156
155
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Reactions, RENDER_REACTIONS_TESTID
|
|
1
|
+
export { Reactions, RENDER_REACTIONS_TESTID } from './Reactions';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
4
|
import Tooltip from '@atlaskit/tooltip';
|
|
5
5
|
import { constants } from '../../shared';
|
|
6
6
|
import { EmojiButton } from '../EmojiButton';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { jsx } from '@emotion/
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
4
|
import { FormattedMessage } from 'react-intl-next';
|
|
5
5
|
import EditorMoreIcon from '@atlaskit/icon/glyph/editor/more';
|
|
6
6
|
import Tooltip from '@atlaskit/tooltip';
|
|
@@ -11,6 +11,7 @@ import * as styles from './styles';
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export const RENDER_SHOWMORE_TESTID = 'show-more-button';
|
|
14
|
+
export const RENDER_WRAPPER_TESTID = 'show-more-wrapper';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Show more custom emojis button
|
|
@@ -24,7 +25,8 @@ export const ShowMore = ({
|
|
|
24
25
|
return jsx("div", {
|
|
25
26
|
className: className.container,
|
|
26
27
|
css: styles.moreEmojiContainerStyle,
|
|
27
|
-
style: style.container
|
|
28
|
+
style: style.container,
|
|
29
|
+
"data-testid": RENDER_WRAPPER_TESTID
|
|
28
30
|
}, jsx("div", {
|
|
29
31
|
css: styles.separatorStyle
|
|
30
32
|
}), jsx(FormattedMessage, i18n.messages.moreEmoji, message => jsx(Tooltip, {
|
|
@@ -32,7 +34,7 @@ export const ShowMore = ({
|
|
|
32
34
|
}, jsx("button", {
|
|
33
35
|
className: className.button,
|
|
34
36
|
css: [styles.moreButtonStyle, buttonStyle],
|
|
35
|
-
|
|
37
|
+
"aria-label": i18n.messages.moreEmoji.defaultMessage,
|
|
36
38
|
type: "button",
|
|
37
39
|
style: style.button,
|
|
38
40
|
onMouseDown: onClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ShowMore, RENDER_SHOWMORE_TESTID } from './ShowMore';
|
|
1
|
+
export { ShowMore, RENDER_SHOWMORE_TESTID, RENDER_WRAPPER_TESTID } from './ShowMore';
|
|
@@ -1,26 +1,41 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
|
|
1
3
|
/** @jsx jsx */
|
|
2
4
|
import React from 'react';
|
|
3
|
-
import { jsx } from '@emotion/
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
4
6
|
import Button from '@atlaskit/button/standard-button';
|
|
7
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
5
8
|
import EmojiAddIcon from '@atlaskit/icon/glyph/emoji-add';
|
|
6
9
|
import * as styles from './styles';
|
|
10
|
+
/**
|
|
11
|
+
* Test id for the tooltip
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export const RENDER_TOOLTIP_TRIGGER_TESTID = 'render-tooltip-trigger';
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
|
-
* Render
|
|
17
|
+
* Render an emoji button to open the reactions select picker
|
|
10
18
|
*/
|
|
11
19
|
export const Trigger = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
12
20
|
const {
|
|
21
|
+
onClick,
|
|
13
22
|
miniMode,
|
|
14
|
-
|
|
23
|
+
tooltipContent,
|
|
24
|
+
disabled = false,
|
|
25
|
+
ariaAttributes = {}
|
|
15
26
|
} = props;
|
|
16
27
|
|
|
17
28
|
const handleMouseDown = (e, analyticsEvent) => {
|
|
18
|
-
if (
|
|
19
|
-
|
|
29
|
+
if (onClick && !disabled) {
|
|
30
|
+
onClick(e, analyticsEvent);
|
|
20
31
|
}
|
|
21
32
|
};
|
|
22
33
|
|
|
23
|
-
return jsx(
|
|
34
|
+
return jsx(Tooltip, {
|
|
35
|
+
testId: RENDER_TOOLTIP_TRIGGER_TESTID,
|
|
36
|
+
content: tooltipContent,
|
|
37
|
+
position: "top"
|
|
38
|
+
}, jsx(Button, _extends({
|
|
24
39
|
css: styles.triggerStyle({
|
|
25
40
|
miniMode,
|
|
26
41
|
disabled
|
|
@@ -34,5 +49,5 @@ export const Trigger = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
34
49
|
}),
|
|
35
50
|
spacing: "none",
|
|
36
51
|
ref: ref
|
|
37
|
-
});
|
|
52
|
+
}, ariaAttributes)));
|
|
38
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Trigger } from './Trigger';
|
|
1
|
+
export { Trigger, RENDER_TOOLTIP_TRIGGER_TESTID } from './Trigger';
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { css } from '@emotion/
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
3
|
import { token } from '@atlaskit/tokens';
|
|
4
|
-
import { N70 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { N70, N20, N40 } from '@atlaskit/theme/colors';
|
|
5
5
|
export const DISABLED_BUTTON_COLOR = `${token('color.text.disabled', N70)} !important`;
|
|
6
6
|
export const triggerStyle = ({
|
|
7
7
|
miniMode = false,
|
|
8
8
|
disabled = false
|
|
9
9
|
}) => css({
|
|
10
|
-
|
|
10
|
+
minWidth: '32px',
|
|
11
11
|
height: '32px',
|
|
12
12
|
display: 'flex',
|
|
13
13
|
justifyContent: 'center',
|
|
14
14
|
alignItems: 'center',
|
|
15
15
|
lineHeight: '16px',
|
|
16
16
|
...(miniMode && {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
height: '24px',
|
|
18
|
+
padding: 0,
|
|
19
|
+
border: `1px solid ${token('color.border', N40)}`,
|
|
20
|
+
borderRadius: '20px'
|
|
19
21
|
}),
|
|
20
22
|
...(disabled && {
|
|
21
23
|
color: DISABLED_BUTTON_COLOR,
|
|
22
24
|
cursor: 'not-allowed'
|
|
23
|
-
})
|
|
25
|
+
}),
|
|
26
|
+
'&:hover': {
|
|
27
|
+
background: `${token('color.background.neutral.subtle.hovered', N20)}`
|
|
28
|
+
}
|
|
24
29
|
});
|
|
@@ -7,7 +7,7 @@ import { ufoExperiences } from '../../store';
|
|
|
7
7
|
import { ReactionStatus } from '../../types';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Export the mapper function outside the component so easier to do unit tests
|
|
10
|
+
* Export the mapper function outside the component so easier to do unit tests
|
|
11
11
|
*/
|
|
12
12
|
export const mapStateToPropsHelper = (containerAri, ari, state) => {
|
|
13
13
|
const reactionsState = state && state.reactions[`${containerAri}|${ari}`];
|
|
@@ -41,7 +41,7 @@ export const mapStateToPropsHelper = (containerAri, ari, state) => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
|
-
* Export the mapper function outside the component so easier to do unit tests
|
|
44
|
+
* Export the mapper function outside the component so easier to do unit tests
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
47
|
export const mapDispatchToPropsHelper = (actions, containerAri, ari) => {
|
|
@@ -87,11 +87,9 @@ export const ConnectedReactionsView = props => {
|
|
|
87
87
|
|
|
88
88
|
(_experienceInstance$c = experienceInstance.current) === null || _experienceInstance$c === void 0 ? void 0 : _experienceInstance$c.abort({
|
|
89
89
|
metadata: {
|
|
90
|
-
source: '
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
containerAri
|
|
94
|
-
},
|
|
90
|
+
source: 'ConnectedReactionsView',
|
|
91
|
+
ari,
|
|
92
|
+
containerAri,
|
|
95
93
|
reason: 'unmount'
|
|
96
94
|
}
|
|
97
95
|
});
|
|
@@ -4,9 +4,10 @@ import { useEffect } from 'react';
|
|
|
4
4
|
* @param ref ref object to an html element
|
|
5
5
|
* @param callback event callback when detected a click outside the ref object
|
|
6
6
|
* @param type (Optional) type of event to listen to. @default click
|
|
7
|
+
* @param useCapture (Optional) use capture phase of event. @default false
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
export function useClickAway(ref, callback, type = 'click') {
|
|
10
|
+
export function useClickAway(ref, callback, type = 'click', useCapture = false) {
|
|
10
11
|
useEffect(() => {
|
|
11
12
|
/**
|
|
12
13
|
* Alert if clicked on outside of element
|
|
@@ -18,10 +19,10 @@ export function useClickAway(ref, callback, type = 'click') {
|
|
|
18
19
|
} // Bind the event listener
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
document.addEventListener(type, handleClickOutside);
|
|
22
|
+
document.addEventListener(type, handleClickOutside, useCapture);
|
|
22
23
|
return () => {
|
|
23
24
|
// Unbind the event listener on clean up
|
|
24
|
-
document.removeEventListener(type, handleClickOutside);
|
|
25
|
+
document.removeEventListener(type, handleClickOutside, useCapture);
|
|
25
26
|
};
|
|
26
|
-
}, [ref, callback, type]);
|
|
27
|
+
}, [ref, callback, type, useCapture]);
|
|
27
28
|
}
|
|
@@ -20,6 +20,16 @@ export const DefaultReactions = [{
|
|
|
20
20
|
id: '1f914',
|
|
21
21
|
shortName: ':thinking:'
|
|
22
22
|
}];
|
|
23
|
+
/**
|
|
24
|
+
* Default label to show for the overLimitLabel prop
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export const DEFAULT_OVER_THE_LIMIT_REACTION_LABEL = '1k+';
|
|
28
|
+
/**
|
|
29
|
+
* Default maximum value to use when the emoji received higher than top limit reactions
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export const DEFAULT_REACTION_TOP_LIMIT = 1000;
|
|
23
33
|
/**
|
|
24
34
|
* ES6 Map object from default emoji reactions (with key => shortName, value => entire emoji item)
|
|
25
35
|
*/
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { defineMessages } from 'react-intl-next';
|
|
2
2
|
export const messages = defineMessages({
|
|
3
|
+
addReaction: {
|
|
4
|
+
id: 'fabric.reactions.add',
|
|
5
|
+
defaultMessage: 'Add reaction',
|
|
6
|
+
description: 'Message for add reaction button'
|
|
7
|
+
},
|
|
3
8
|
loadingReactions: {
|
|
4
9
|
id: 'fabric.reactions.loading',
|
|
5
10
|
defaultMessage: 'Loading...',
|
|
@@ -10,6 +15,11 @@ export const messages = defineMessages({
|
|
|
10
15
|
defaultMessage: 'More emojis',
|
|
11
16
|
description: 'Tooltip of the "show more" button in the quick reaction selector. The full emoji selector is displayed when the user clicks on it.'
|
|
12
17
|
},
|
|
18
|
+
reactWithEmoji: {
|
|
19
|
+
id: 'fabric.reactions.reactwithemoji',
|
|
20
|
+
defaultMessage: 'React with {emoji} emoji',
|
|
21
|
+
description: 'Aria label on reaction button'
|
|
22
|
+
},
|
|
13
23
|
unexpectedError: {
|
|
14
24
|
id: 'fabric.reactions.error.unexpected',
|
|
15
25
|
defaultMessage: 'Reactions are temporarily unavailable',
|