@atlaskit/reactions 21.6.2 → 21.7.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 +16 -0
- package/dist/cjs/MockReactionsClient.js +3 -1
- package/dist/cjs/components/EmojiButton/EmojiButton.js +6 -1
- package/dist/cjs/components/Reaction/Reaction.js +8 -5
- package/dist/cjs/components/ReactionPicker/ReactionPicker.js +39 -49
- package/dist/cjs/components/ReactionPicker/styles.js +3 -1
- package/dist/cjs/components/Reactions/Reactions.js +33 -38
- package/dist/cjs/components/Reactions/index.js +0 -6
- package/dist/cjs/components/ShowMore/ShowMore.js +1 -1
- package/dist/cjs/components/Trigger/Trigger.js +21 -7
- package/dist/cjs/components/Trigger/index.js +6 -0
- package/dist/cjs/components/Trigger/styles.js +10 -4
- package/dist/cjs/hooks/useClickAway.js +5 -3
- package/dist/cjs/shared/i18n.js +10 -0
- 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/components/EmojiButton/EmojiButton.js +6 -2
- package/dist/es2019/components/Reaction/Reaction.js +8 -6
- package/dist/es2019/components/ReactionPicker/ReactionPicker.js +21 -8
- package/dist/es2019/components/ReactionPicker/styles.js +3 -1
- package/dist/es2019/components/Reactions/Reactions.js +32 -33
- package/dist/es2019/components/Reactions/index.js +1 -1
- package/dist/es2019/components/ShowMore/ShowMore.js +1 -1
- package/dist/es2019/components/Trigger/Trigger.js +17 -5
- package/dist/es2019/components/Trigger/index.js +1 -1
- package/dist/es2019/components/Trigger/styles.js +10 -5
- package/dist/es2019/hooks/useClickAway.js +5 -4
- package/dist/es2019/shared/i18n.js +10 -0
- 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/components/EmojiButton/EmojiButton.js +6 -2
- package/dist/esm/components/Reaction/Reaction.js +8 -6
- package/dist/esm/components/ReactionPicker/ReactionPicker.js +38 -49
- package/dist/esm/components/ReactionPicker/styles.js +3 -1
- package/dist/esm/components/Reactions/Reactions.js +30 -33
- package/dist/esm/components/Reactions/index.js +1 -1
- package/dist/esm/components/ShowMore/ShowMore.js +1 -1
- package/dist/esm/components/Trigger/Trigger.js +18 -6
- package/dist/esm/components/Trigger/index.js +1 -1
- package/dist/esm/components/Trigger/styles.js +11 -5
- package/dist/esm/hooks/useClickAway.js +5 -3
- package/dist/esm/shared/i18n.js +10 -0
- 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/components/FlashAnimation/styles.d.ts +3 -1
- package/dist/types/components/ReactionPicker/ReactionPicker.d.ts +2 -5
- package/dist/types/components/Reactions/Reactions.d.ts +7 -15
- package/dist/types/components/Reactions/index.d.ts +1 -1
- package/dist/types/components/Selector/Selector.d.ts +1 -1
- package/dist/types/components/Selector/styles.d.ts +3 -1
- package/dist/types/components/Trigger/Trigger.d.ts +9 -1
- package/dist/types/components/Trigger/index.d.ts +1 -1
- package/dist/types/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +1 -1
- package/dist/types/hooks/useClickAway.d.ts +2 -1
- 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/components/FlashAnimation/styles.d.ts +3 -1
- package/dist/types-ts4.0/components/ReactionPicker/ReactionPicker.d.ts +2 -5
- package/dist/types-ts4.0/components/Reactions/Reactions.d.ts +7 -15
- package/dist/types-ts4.0/components/Reactions/index.d.ts +1 -1
- package/dist/types-ts4.0/components/Selector/Selector.d.ts +1 -1
- package/dist/types-ts4.0/components/Selector/styles.d.ts +3 -1
- package/dist/types-ts4.0/components/Trigger/Trigger.d.ts +9 -1
- package/dist/types-ts4.0/components/Trigger/index.d.ts +1 -1
- package/dist/types-ts4.0/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +1 -1
- package/dist/types-ts4.0/hooks/useClickAway.d.ts +2 -1
- 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 +6 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl-next';
|
|
3
4
|
import { jsx } from '@emotion/core';
|
|
4
5
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
6
|
import { ResourcedEmoji } from '@atlaskit/emoji';
|
|
@@ -7,7 +8,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';
|
|
2
|
+
import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/core';
|
|
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
|
/**
|
|
@@ -56,7 +58,8 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
56
58
|
pickerQuickReactionEmojiIds,
|
|
57
59
|
onShowMore,
|
|
58
60
|
onOpen,
|
|
59
|
-
onCancel
|
|
61
|
+
onCancel,
|
|
62
|
+
tooltipContent = jsx(FormattedMessage, i18n.messages.addReaction)
|
|
60
63
|
} = props;
|
|
61
64
|
/**
|
|
62
65
|
* Container <div /> reference (used by custom hook to detect click outside)
|
|
@@ -67,7 +70,7 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
67
70
|
* a function you can ask Popper to recompute your tooltip's position. It will directly call the Popper#update method
|
|
68
71
|
*/
|
|
69
72
|
|
|
70
|
-
const updatePopper = useRef(
|
|
73
|
+
const updatePopper = useRef();
|
|
71
74
|
const [settings, setSettings] = useState({
|
|
72
75
|
/**
|
|
73
76
|
* Show the picker floating panel
|
|
@@ -89,7 +92,7 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
close();
|
|
92
|
-
});
|
|
95
|
+
}, 'click', true);
|
|
93
96
|
/**
|
|
94
97
|
* Event callback when the picker is closed
|
|
95
98
|
* @param _id Optional id if an emoji button was selected or undefineed if was clicked outside the picker
|
|
@@ -114,10 +117,8 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
114
117
|
* @param e event param
|
|
115
118
|
*/
|
|
116
119
|
|
|
117
|
-
const onSelectMoreClick = useCallback(
|
|
120
|
+
const onSelectMoreClick = useCallback(e => {
|
|
118
121
|
e.preventDefault();
|
|
119
|
-
await updatePopper.current(); // Update popper position
|
|
120
|
-
|
|
121
122
|
setSettings({
|
|
122
123
|
isOpen: true,
|
|
123
124
|
showFullPicker: true
|
|
@@ -160,7 +161,18 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
160
161
|
|
|
161
162
|
UFO.PickerRender.success();
|
|
162
163
|
};
|
|
164
|
+
/**
|
|
165
|
+
* When picker is opened, re-calculate the picker position
|
|
166
|
+
*/
|
|
163
167
|
|
|
168
|
+
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (settings.isOpen) {
|
|
171
|
+
if (updatePopper.current) {
|
|
172
|
+
updatePopper.current();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}, [settings]);
|
|
164
176
|
const wrapperClassName = ` ${settings.isOpen ? 'isOpen' : ''} ${miniMode ? 'miniMode' : ''} ${className}`;
|
|
165
177
|
return jsx("div", {
|
|
166
178
|
className: wrapperClassName,
|
|
@@ -174,7 +186,8 @@ export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
|
174
186
|
ref: popperRef,
|
|
175
187
|
onClick: onTriggerClick,
|
|
176
188
|
miniMode: miniMode,
|
|
177
|
-
disabled: disabled
|
|
189
|
+
disabled: disabled,
|
|
190
|
+
tooltipContent: tooltipContent
|
|
178
191
|
})), jsx(Popper, {
|
|
179
192
|
placement: "bottom-start",
|
|
180
193
|
modifiers: popperModifiers
|
|
@@ -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,6 @@
|
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/core';
|
|
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';
|
|
@@ -32,7 +32,7 @@ export const ShowMore = ({
|
|
|
32
32
|
}, jsx("button", {
|
|
33
33
|
className: className.button,
|
|
34
34
|
css: [styles.moreButtonStyle, buttonStyle],
|
|
35
|
-
|
|
35
|
+
"aria-label": i18n.messages.moreEmoji.defaultMessage,
|
|
36
36
|
type: "button",
|
|
37
37
|
style: style.button,
|
|
38
38
|
onMouseDown: onClick,
|
|
@@ -2,25 +2,37 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { jsx } from '@emotion/core';
|
|
4
4
|
import Button from '@atlaskit/button/standard-button';
|
|
5
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
5
6
|
import EmojiAddIcon from '@atlaskit/icon/glyph/emoji-add';
|
|
6
7
|
import * as styles from './styles';
|
|
8
|
+
/**
|
|
9
|
+
* Test id for the tooltip
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const RENDER_TOOLTIP_TRIGGER_TESTID = 'render-tooltip-trigger';
|
|
7
13
|
|
|
8
14
|
/**
|
|
9
|
-
* Render
|
|
15
|
+
* Render an emoji button to open the reactions select picker
|
|
10
16
|
*/
|
|
11
17
|
export const Trigger = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
12
18
|
const {
|
|
19
|
+
onClick,
|
|
13
20
|
miniMode,
|
|
21
|
+
tooltipContent,
|
|
14
22
|
disabled = false
|
|
15
23
|
} = props;
|
|
16
24
|
|
|
17
25
|
const handleMouseDown = (e, analyticsEvent) => {
|
|
18
|
-
if (
|
|
19
|
-
|
|
26
|
+
if (onClick && !disabled) {
|
|
27
|
+
onClick(e, analyticsEvent);
|
|
20
28
|
}
|
|
21
29
|
};
|
|
22
30
|
|
|
23
|
-
return jsx(
|
|
31
|
+
return jsx(Tooltip, {
|
|
32
|
+
testId: RENDER_TOOLTIP_TRIGGER_TESTID,
|
|
33
|
+
content: tooltipContent,
|
|
34
|
+
position: "top"
|
|
35
|
+
}, jsx(Button, {
|
|
24
36
|
css: styles.triggerStyle({
|
|
25
37
|
miniMode,
|
|
26
38
|
disabled
|
|
@@ -34,5 +46,5 @@ export const Trigger = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
34
46
|
}),
|
|
35
47
|
spacing: "none",
|
|
36
48
|
ref: ref
|
|
37
|
-
});
|
|
49
|
+
}));
|
|
38
50
|
});
|
|
@@ -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
2
|
import { css } from '@emotion/core';
|
|
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
|
});
|
|
@@ -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
|
}
|
|
@@ -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',
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* MetaData for Reaction object
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Metadata for composing a summary of emojis that will be shown in the the primary view even if the reaction count is zero
|
|
11
|
+
*/
|
|
12
|
+
|
|
9
13
|
/**
|
|
10
14
|
* Event handler for when the user clicks on the reaction
|
|
11
15
|
* @param id give id for the emoji
|
|
@@ -31,4 +35,5 @@ export let ReactionStatus;
|
|
|
31
35
|
ReactionStatus["loading"] = "LOADING";
|
|
32
36
|
ReactionStatus["error"] = "ERROR";
|
|
33
37
|
ReactionStatus["notLoaded"] = "NOT_LOADED";
|
|
38
|
+
ReactionStatus["disabled"] = "DISABLED";
|
|
34
39
|
})(ReactionStatus || (ReactionStatus = {}));
|
package/dist/es2019/version.json
CHANGED
|
@@ -33,13 +33,11 @@ var getReactionKey = function getReactionKey(containerAri, ari) {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
var 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')];
|
|
36
|
-
|
|
37
|
-
var mockData = _defineProperty({}, getReactionKey(containerAri, ari), [getReactionSummary(':fire:', 1, true), getReactionSummary(':thumbsup:', 999, false), getReactionSummary(':astonished:', 9, false), getReactionSummary(':heart:', 99, false)]);
|
|
36
|
+
export var mockData = _defineProperty({}, getReactionKey(containerAri, ari), [getReactionSummary(':fire:', 1, true), getReactionSummary(':thumbsup:', 999, false), getReactionSummary(':astonished:', 9, false), getReactionSummary(':heart:', 99, false)]);
|
|
38
37
|
/**
|
|
39
38
|
* Mocked version of the client to fetch user information
|
|
40
39
|
*/
|
|
41
40
|
|
|
42
|
-
|
|
43
41
|
export var MockReactionsClient = /*#__PURE__*/function () {
|
|
44
42
|
function MockReactionsClient() {
|
|
45
43
|
var _this = this;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl-next';
|
|
3
4
|
import { jsx } from '@emotion/core';
|
|
4
5
|
import { ResourcedEmoji } from '@atlaskit/emoji';
|
|
5
|
-
import { utils } from '../../shared';
|
|
6
|
+
import { i18n, utils } from '../../shared';
|
|
6
7
|
import * as styles from './styles';
|
|
7
8
|
export var RENDER_BUTTON_TESTID = 'button-emoji-id';
|
|
8
9
|
|
|
@@ -22,10 +23,13 @@ export var EmojiButton = function EmojiButton(_ref) {
|
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
var intl = useIntl();
|
|
25
27
|
return jsx("button", {
|
|
26
28
|
"data-testid": RENDER_BUTTON_TESTID,
|
|
27
29
|
onClick: onButtonClick,
|
|
28
|
-
|
|
30
|
+
"aria-label": intl.formatMessage(i18n.messages.reactWithEmoji, {
|
|
31
|
+
emoji: emojiId.shortName
|
|
32
|
+
}),
|
|
29
33
|
type: "button",
|
|
30
34
|
css: styles.emojiButtonStyle
|
|
31
35
|
}, jsx(ResourcedEmoji, {
|
|
@@ -4,6 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { useIntl } from 'react-intl-next';
|
|
7
8
|
import { jsx } from '@emotion/core';
|
|
8
9
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
9
10
|
import { ResourcedEmoji } from '@atlaskit/emoji';
|
|
@@ -11,7 +12,7 @@ import { Analytics } from '../../analytics';
|
|
|
11
12
|
import { Counter } from '../Counter';
|
|
12
13
|
import { FlashAnimation } from '../FlashAnimation';
|
|
13
14
|
import { ReactionTooltip } from '../ReactionTooltip';
|
|
14
|
-
import { utils } from '../../shared';
|
|
15
|
+
import { i18n, utils } from '../../shared';
|
|
15
16
|
import * as styles from './styles';
|
|
16
17
|
/**
|
|
17
18
|
* Test id for Reaction item wrapper div
|
|
@@ -59,10 +60,7 @@ export var Reaction = function Reaction(_ref) {
|
|
|
59
60
|
case 2:
|
|
60
61
|
emojiResource = _context.sent;
|
|
61
62
|
_context.next = 5;
|
|
62
|
-
return emojiResource.
|
|
63
|
-
shortName: '',
|
|
64
|
-
id: reaction.emojiId
|
|
65
|
-
});
|
|
63
|
+
return emojiResource.findById(reaction.emojiId);
|
|
66
64
|
|
|
67
65
|
case 5:
|
|
68
66
|
foundEmoji = _context.sent;
|
|
@@ -102,14 +100,18 @@ export var Reaction = function Reaction(_ref) {
|
|
|
102
100
|
onMouseEnter(reaction, event);
|
|
103
101
|
}
|
|
104
102
|
}, [createAnalyticsEvent, reaction, onMouseEnter]);
|
|
103
|
+
var intl = useIntl();
|
|
105
104
|
return jsx(ReactionTooltip, {
|
|
106
105
|
emojiName: emojiName,
|
|
107
106
|
reaction: reaction
|
|
108
107
|
}, jsx("button", {
|
|
109
108
|
className: className,
|
|
110
109
|
css: [styles.reactionStyle, reaction.reacted && styles.reactedStyle],
|
|
111
|
-
|
|
110
|
+
"aria-label": intl.formatMessage(i18n.messages.reactWithEmoji, {
|
|
111
|
+
emoji: emojiName
|
|
112
|
+
}),
|
|
112
113
|
type: "button",
|
|
114
|
+
"data-emoji-id": reaction.emojiId,
|
|
113
115
|
"data-testid": RENDER_REACTION_TESTID,
|
|
114
116
|
onMouseUp: handleMouseUp,
|
|
115
117
|
onMouseEnter: handleMouseEnter
|