@atlaskit/reactions 21.7.0 → 21.8.1
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 +19 -0
- 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 +3 -3
- 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 +7 -7
- package/dist/cjs/components/Reaction/styles.js +5 -5
- package/dist/cjs/components/ReactionPicker/ReactionPicker.js +22 -12
- package/dist/cjs/components/ReactionPicker/styles.js +4 -4
- 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 +7 -7
- 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 +12 -9
- 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 +10 -6
- package/dist/cjs/components/Trigger/styles.js +2 -2
- package/dist/cjs/containers/ConnectedReactionsView/ConnectedReactionsView.js +5 -7
- package/dist/cjs/shared/constants.js +14 -2
- package/dist/cjs/store/MemoryReactionsStore.js +33 -29
- package/dist/cjs/version.json +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 +1 -1
- 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 +1 -1
- package/dist/es2019/components/Reaction/styles.js +1 -1
- package/dist/es2019/components/ReactionPicker/ReactionPicker.js +12 -2
- package/dist/es2019/components/ReactionPicker/styles.js +1 -1
- 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 +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 +4 -2
- 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 +7 -4
- package/dist/es2019/components/Trigger/styles.js +1 -1
- package/dist/es2019/containers/ConnectedReactionsView/ConnectedReactionsView.js +5 -7
- package/dist/es2019/shared/constants.js +10 -0
- package/dist/es2019/store/MemoryReactionsStore.js +32 -29
- package/dist/es2019/version.json +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/esm/components/Reaction/styles.js +1 -1
- package/dist/esm/components/ReactionPicker/ReactionPicker.js +12 -2
- package/dist/esm/components/ReactionPicker/styles.js +1 -1
- 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 +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 +4 -2
- 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 +8 -4
- package/dist/esm/components/Trigger/styles.js +1 -1
- package/dist/esm/containers/ConnectedReactionsView/ConnectedReactionsView.js +5 -7
- package/dist/esm/shared/constants.js +10 -0
- package/dist/esm/store/MemoryReactionsStore.js +32 -29
- package/dist/esm/version.json +1 -1
- 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 +3 -3
- package/dist/types/components/Reaction/styles.d.ts +4 -4
- 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 +2 -1
- package/dist/types/components/Reactions/styles.d.ts +2 -2
- package/dist/types/components/Selector/styles.d.ts +4 -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 +5 -1
- package/dist/types/components/Trigger/styles.d.ts +1 -1
- package/dist/types/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +2 -2
- package/dist/types/shared/constants.d.ts +8 -0
- package/package.json +7 -15
- package/dist/types-ts4.0/MockReactionsClient.d.ts +0 -23
- package/dist/types-ts4.0/analytics/analytics.d.ts +0 -96
- package/dist/types-ts4.0/analytics/constants.d.ts +0 -1
- package/dist/types-ts4.0/analytics/index.d.ts +0 -2
- package/dist/types-ts4.0/analytics/ufo.d.ts +0 -40
- package/dist/types-ts4.0/client/ReactionServiceClient.d.ts +0 -35
- package/dist/types-ts4.0/client/index.d.ts +0 -1
- package/dist/types-ts4.0/components/Counter/Counter.d.ts +0 -40
- package/dist/types-ts4.0/components/Counter/index.d.ts +0 -3
- package/dist/types-ts4.0/components/Counter/styles.d.ts +0 -3
- package/dist/types-ts4.0/components/EmojiButton/EmojiButton.d.ts +0 -22
- package/dist/types-ts4.0/components/EmojiButton/index.d.ts +0 -2
- package/dist/types-ts4.0/components/EmojiButton/styles.d.ts +0 -1
- package/dist/types-ts4.0/components/FlashAnimation/FlashAnimation.d.ts +0 -20
- package/dist/types-ts4.0/components/FlashAnimation/index.d.ts +0 -2
- package/dist/types-ts4.0/components/FlashAnimation/styles.d.ts +0 -5
- package/dist/types-ts4.0/components/Reaction/Reaction.d.ts +0 -38
- package/dist/types-ts4.0/components/Reaction/index.d.ts +0 -2
- package/dist/types-ts4.0/components/Reaction/styles.d.ts +0 -10
- package/dist/types-ts4.0/components/ReactionPicker/ReactionPicker.d.ts +0 -50
- package/dist/types-ts4.0/components/ReactionPicker/index.d.ts +0 -2
- package/dist/types-ts4.0/components/ReactionPicker/styles.d.ts +0 -3
- package/dist/types-ts4.0/components/ReactionTooltip/ReactionTooltip.d.ts +0 -22
- package/dist/types-ts4.0/components/ReactionTooltip/index.d.ts +0 -2
- package/dist/types-ts4.0/components/ReactionTooltip/styles.d.ts +0 -4
- package/dist/types-ts4.0/components/Reactions/Reactions.d.ts +0 -56
- package/dist/types-ts4.0/components/Reactions/index.d.ts +0 -2
- package/dist/types-ts4.0/components/Reactions/styles.d.ts +0 -2
- package/dist/types-ts4.0/components/Selector/Selector.d.ts +0 -34
- package/dist/types-ts4.0/components/Selector/index.d.ts +0 -3
- package/dist/types-ts4.0/components/Selector/styles.d.ts +0 -12
- package/dist/types-ts4.0/components/ShowMore/ShowMore.d.ts +0 -34
- package/dist/types-ts4.0/components/ShowMore/index.d.ts +0 -2
- package/dist/types-ts4.0/components/ShowMore/styles.d.ts +0 -3
- package/dist/types-ts4.0/components/Trigger/Trigger.d.ts +0 -31
- package/dist/types-ts4.0/components/Trigger/index.d.ts +0 -2
- package/dist/types-ts4.0/components/Trigger/styles.d.ts +0 -5
- package/dist/types-ts4.0/components/UfoErrorBoundary/UfoErrorBoundary.d.ts +0 -16
- package/dist/types-ts4.0/components/UfoErrorBoundary/index.d.ts +0 -2
- package/dist/types-ts4.0/components/index.d.ts +0 -8
- package/dist/types-ts4.0/containers/ConnectedReactionPicker/ConnectedReactionPicker.d.ts +0 -27
- package/dist/types-ts4.0/containers/ConnectedReactionPicker/index.d.ts +0 -2
- package/dist/types-ts4.0/containers/ConnectedReactionsView/ConnectedReactionsView.d.ts +0 -52
- package/dist/types-ts4.0/containers/ConnectedReactionsView/index.d.ts +0 -2
- package/dist/types-ts4.0/containers/index.d.ts +0 -2
- package/dist/types-ts4.0/hooks/index.d.ts +0 -1
- package/dist/types-ts4.0/hooks/useClickAway.d.ts +0 -9
- package/dist/types-ts4.0/i18n/cs.d.ts +0 -13
- package/dist/types-ts4.0/i18n/da.d.ts +0 -13
- package/dist/types-ts4.0/i18n/de.d.ts +0 -13
- package/dist/types-ts4.0/i18n/en.d.ts +0 -7
- package/dist/types-ts4.0/i18n/en_GB.d.ts +0 -7
- package/dist/types-ts4.0/i18n/en_ZZ.d.ts +0 -13
- package/dist/types-ts4.0/i18n/es.d.ts +0 -13
- package/dist/types-ts4.0/i18n/et.d.ts +0 -12
- package/dist/types-ts4.0/i18n/fi.d.ts +0 -13
- package/dist/types-ts4.0/i18n/fr.d.ts +0 -13
- package/dist/types-ts4.0/i18n/hu.d.ts +0 -13
- package/dist/types-ts4.0/i18n/index.d.ts +0 -35
- package/dist/types-ts4.0/i18n/is.d.ts +0 -6
- package/dist/types-ts4.0/i18n/it.d.ts +0 -13
- package/dist/types-ts4.0/i18n/ja.d.ts +0 -13
- package/dist/types-ts4.0/i18n/ko.d.ts +0 -13
- package/dist/types-ts4.0/i18n/languages.d.ts +0 -27
- package/dist/types-ts4.0/i18n/nb.d.ts +0 -13
- package/dist/types-ts4.0/i18n/nl.d.ts +0 -13
- package/dist/types-ts4.0/i18n/pl.d.ts +0 -13
- package/dist/types-ts4.0/i18n/pt_BR.d.ts +0 -13
- package/dist/types-ts4.0/i18n/pt_PT.d.ts +0 -12
- package/dist/types-ts4.0/i18n/ro.d.ts +0 -6
- package/dist/types-ts4.0/i18n/ru.d.ts +0 -13
- package/dist/types-ts4.0/i18n/sk.d.ts +0 -12
- package/dist/types-ts4.0/i18n/sv.d.ts +0 -13
- package/dist/types-ts4.0/i18n/th.d.ts +0 -13
- package/dist/types-ts4.0/i18n/tr.d.ts +0 -13
- package/dist/types-ts4.0/i18n/uk.d.ts +0 -13
- package/dist/types-ts4.0/i18n/vi.d.ts +0 -13
- package/dist/types-ts4.0/i18n/zh.d.ts +0 -13
- package/dist/types-ts4.0/i18n/zh_TW.d.ts +0 -13
- package/dist/types-ts4.0/index.d.ts +0 -7
- package/dist/types-ts4.0/shared/constants.d.ts +0 -13
- package/dist/types-ts4.0/shared/i18n.d.ts +0 -32
- package/dist/types-ts4.0/shared/index.d.ts +0 -3
- package/dist/types-ts4.0/shared/utils.d.ts +0 -11
- package/dist/types-ts4.0/store/MemoryReactionsStore.d.ts +0 -94
- package/dist/types-ts4.0/store/ReactionConsumer.d.ts +0 -57
- package/dist/types-ts4.0/store/batched.d.ts +0 -2
- package/dist/types-ts4.0/store/index.d.ts +0 -3
- package/dist/types-ts4.0/store/utils.d.ts +0 -11
- package/dist/types-ts4.0/types/Actions.d.ts +0 -27
- package/dist/types-ts4.0/types/Updater.d.ts +0 -1
- package/dist/types-ts4.0/types/User.d.ts +0 -10
- package/dist/types-ts4.0/types/client.d.ts +0 -38
- package/dist/types-ts4.0/types/index.d.ts +0 -7
- package/dist/types-ts4.0/types/reaction.d.ts +0 -100
- package/dist/types-ts4.0/types/store.d.ts +0 -63
|
@@ -10,7 +10,7 @@ exports.getTooltip = getTooltip;
|
|
|
10
10
|
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _react2 = require("@emotion/react");
|
|
14
14
|
|
|
15
15
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
16
16
|
|
|
@@ -46,7 +46,7 @@ exports.RENDER_REACTIONS_TESTID = RENDER_REACTIONS_TESTID;
|
|
|
46
46
|
function getTooltip(status, errorMessage) {
|
|
47
47
|
switch (status) {
|
|
48
48
|
case _types.ReactionStatus.error:
|
|
49
|
-
return errorMessage || (0,
|
|
49
|
+
return errorMessage || (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _shared.i18n.messages.unexpectedError);
|
|
50
50
|
// When reaction is not available don't show any tooltip (e.g. Archive page in Confluence)
|
|
51
51
|
|
|
52
52
|
case _types.ReactionStatus.disabled:
|
|
@@ -54,10 +54,10 @@ function getTooltip(status, errorMessage) {
|
|
|
54
54
|
|
|
55
55
|
case _types.ReactionStatus.notLoaded:
|
|
56
56
|
case _types.ReactionStatus.loading:
|
|
57
|
-
return (0,
|
|
57
|
+
return (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _shared.i18n.messages.loadingReactions);
|
|
58
58
|
|
|
59
59
|
case _types.ReactionStatus.ready:
|
|
60
|
-
return (0,
|
|
60
|
+
return (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _shared.i18n.messages.addReaction);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -164,11 +164,11 @@ var Reactions = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
164
164
|
});
|
|
165
165
|
return reactions.concat(items);
|
|
166
166
|
}, [quickReactionEmojis, reactions]);
|
|
167
|
-
return (0,
|
|
167
|
+
return (0, _react2.jsx)("div", {
|
|
168
168
|
css: styles.wrapperStyle,
|
|
169
169
|
"data-testid": RENDER_REACTIONS_TESTID
|
|
170
170
|
}, memorizedReactions.map(function (reaction) {
|
|
171
|
-
return (0,
|
|
171
|
+
return (0, _react2.jsx)(_Reaction.Reaction, {
|
|
172
172
|
key: reaction.emojiId,
|
|
173
173
|
css: styles.reactionStyle,
|
|
174
174
|
reaction: reaction,
|
|
@@ -177,7 +177,7 @@ var Reactions = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
177
177
|
onMouseEnter: handleReactionMouseEnter,
|
|
178
178
|
flash: flash[reaction.emojiId]
|
|
179
179
|
});
|
|
180
|
-
}), (0,
|
|
180
|
+
}), (0, _react2.jsx)(_ReactionPicker.ReactionPicker, {
|
|
181
181
|
css: styles.reactionStyle,
|
|
182
182
|
emojiProvider: emojiProvider,
|
|
183
183
|
miniMode: true,
|
|
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.wrapperStyle = exports.reactionStyle = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _react = require("@emotion/react");
|
|
9
9
|
|
|
10
10
|
/** @jsx jsx */
|
|
11
|
-
var reactionStyle = (0,
|
|
11
|
+
var reactionStyle = (0, _react.css)({
|
|
12
12
|
display: 'inline-block',
|
|
13
13
|
// top margin of 2px to allow spacing between rows when wrapped (paired with top margin in reactionsStyle)
|
|
14
14
|
margin: '2px 4px 0 4px'
|
|
15
15
|
});
|
|
16
16
|
exports.reactionStyle = reactionStyle;
|
|
17
|
-
var wrapperStyle = (0,
|
|
17
|
+
var wrapperStyle = (0, _react.css)({
|
|
18
18
|
display: 'flex',
|
|
19
19
|
flexWrap: 'wrap',
|
|
20
20
|
position: 'relative',
|
|
@@ -13,7 +13,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
17
17
|
|
|
18
18
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
19
19
|
|
|
@@ -102,24 +102,24 @@ var Selector = function Selector(_ref) {
|
|
|
102
102
|
var renderEmoji = function renderEmoji(emoji, index) {
|
|
103
103
|
var _emoji$id;
|
|
104
104
|
|
|
105
|
-
return (0,
|
|
105
|
+
return (0, _react2.jsx)("div", {
|
|
106
106
|
key: (_emoji$id = emoji.id) !== null && _emoji$id !== void 0 ? _emoji$id : emoji.shortName,
|
|
107
107
|
className: emoji === selection ? 'selected' : undefined,
|
|
108
108
|
css: [styles.emojiStyle, styles.revealStyle],
|
|
109
109
|
style: emojiStyleAnimation(index),
|
|
110
110
|
"data-testid": RENDER_SELECTOR_TESTID
|
|
111
|
-
}, (0,
|
|
111
|
+
}, (0, _react2.jsx)(_tooltip.default, {
|
|
112
112
|
content: emoji.shortName
|
|
113
|
-
}, (0,
|
|
113
|
+
}, (0, _react2.jsx)(_EmojiButton.EmojiButton, {
|
|
114
114
|
emojiId: emoji,
|
|
115
115
|
emojiProvider: emojiProvider,
|
|
116
116
|
onClick: onSelected
|
|
117
117
|
})));
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
-
return (0,
|
|
120
|
+
return (0, _react2.jsx)("div", {
|
|
121
121
|
css: styles.selectorStyle
|
|
122
|
-
}, pickerQuickReactionEmojiIds ? pickerQuickReactionEmojiIds.map(renderEmoji) : null, showMore ? (0,
|
|
122
|
+
}, pickerQuickReactionEmojiIds ? pickerQuickReactionEmojiIds.map(renderEmoji) : null, showMore ? (0, _react2.jsx)(_ShowMore.ShowMore, {
|
|
123
123
|
key: "more",
|
|
124
124
|
buttonStyle: styles.revealStyle,
|
|
125
125
|
style: {
|
|
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.selectorStyle = exports.revealStyle = exports.revealAnimation = exports.emojiStyleAnimation = exports.emojiStyle = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _react = require("@emotion/react");
|
|
9
9
|
|
|
10
10
|
/** @jsx jsx */
|
|
11
|
-
var selectorStyle = (0,
|
|
11
|
+
var selectorStyle = (0, _react.css)({
|
|
12
12
|
boxSizing: 'border-box',
|
|
13
13
|
display: 'flex',
|
|
14
14
|
padding: 0
|
|
15
15
|
});
|
|
16
16
|
exports.selectorStyle = selectorStyle;
|
|
17
|
-
var emojiStyle = (0,
|
|
17
|
+
var emojiStyle = (0, _react.css)({
|
|
18
18
|
display: 'inline-block',
|
|
19
19
|
opacity: 0,
|
|
20
20
|
'&.selected': {
|
|
@@ -23,7 +23,7 @@ var emojiStyle = (0, _core.css)({
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
exports.emojiStyle = emojiStyle;
|
|
26
|
-
var revealAnimation = (0,
|
|
26
|
+
var revealAnimation = (0, _react.keyframes)({
|
|
27
27
|
'0%': {
|
|
28
28
|
opacity: 1,
|
|
29
29
|
transform: 'scale(0.5)'
|
|
@@ -37,7 +37,7 @@ var revealAnimation = (0, _core.keyframes)({
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
exports.revealAnimation = revealAnimation;
|
|
40
|
-
var revealStyle = (0,
|
|
40
|
+
var revealStyle = (0, _react.css)({
|
|
41
41
|
animation: "".concat(revealAnimation, " 150ms ease-in-out forwards")
|
|
42
42
|
});
|
|
43
43
|
/**
|
|
@@ -7,11 +7,11 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.ShowMore = exports.RENDER_SHOWMORE_TESTID = void 0;
|
|
10
|
+
exports.ShowMore = exports.RENDER_WRAPPER_TESTID = exports.RENDER_SHOWMORE_TESTID = void 0;
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _react2 = require("@emotion/react");
|
|
15
15
|
|
|
16
16
|
var _reactIntlNext = require("react-intl-next");
|
|
17
17
|
|
|
@@ -34,6 +34,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
34
34
|
*/
|
|
35
35
|
var RENDER_SHOWMORE_TESTID = 'show-more-button';
|
|
36
36
|
exports.RENDER_SHOWMORE_TESTID = RENDER_SHOWMORE_TESTID;
|
|
37
|
+
var RENDER_WRAPPER_TESTID = 'show-more-wrapper';
|
|
38
|
+
exports.RENDER_WRAPPER_TESTID = RENDER_WRAPPER_TESTID;
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* Show more custom emojis button
|
|
@@ -45,16 +47,17 @@ var ShowMore = function ShowMore(_ref) {
|
|
|
45
47
|
_ref$className = _ref.className,
|
|
46
48
|
className = _ref$className === void 0 ? {} : _ref$className,
|
|
47
49
|
buttonStyle = _ref.buttonStyle;
|
|
48
|
-
return (0,
|
|
50
|
+
return (0, _react2.jsx)("div", {
|
|
49
51
|
className: className.container,
|
|
50
52
|
css: styles.moreEmojiContainerStyle,
|
|
51
|
-
style: style.container
|
|
52
|
-
|
|
53
|
+
style: style.container,
|
|
54
|
+
"data-testid": RENDER_WRAPPER_TESTID
|
|
55
|
+
}, (0, _react2.jsx)("div", {
|
|
53
56
|
css: styles.separatorStyle
|
|
54
|
-
}), (0,
|
|
55
|
-
return (0,
|
|
57
|
+
}), (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _shared.i18n.messages.moreEmoji, function (message) {
|
|
58
|
+
return (0, _react2.jsx)(_tooltip.default, {
|
|
56
59
|
content: message
|
|
57
|
-
}, (0,
|
|
60
|
+
}, (0, _react2.jsx)("button", {
|
|
58
61
|
className: className.button,
|
|
59
62
|
css: [styles.moreButtonStyle, buttonStyle],
|
|
60
63
|
"aria-label": _shared.i18n.messages.moreEmoji.defaultMessage,
|
|
@@ -62,7 +65,7 @@ var ShowMore = function ShowMore(_ref) {
|
|
|
62
65
|
style: style.button,
|
|
63
66
|
onMouseDown: onClick,
|
|
64
67
|
"data-testid": RENDER_SHOWMORE_TESTID
|
|
65
|
-
}, (0,
|
|
68
|
+
}, (0, _react2.jsx)(_more.default, {
|
|
66
69
|
label: "More"
|
|
67
70
|
})));
|
|
68
71
|
}));
|
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "RENDER_SHOWMORE_TESTID", {
|
|
|
9
9
|
return _ShowMore.RENDER_SHOWMORE_TESTID;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "RENDER_WRAPPER_TESTID", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _ShowMore.RENDER_WRAPPER_TESTID;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "ShowMore", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function get() {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.separatorStyle = exports.moreEmojiContainerStyle = exports.moreButtonStyle = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _react = require("@emotion/react");
|
|
9
9
|
|
|
10
10
|
var _constants = require("@atlaskit/theme/constants");
|
|
11
11
|
|
|
@@ -14,11 +14,11 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
14
14
|
var _tokens = require("@atlaskit/tokens");
|
|
15
15
|
|
|
16
16
|
/** @jsx jsx */
|
|
17
|
-
var moreEmojiContainerStyle = (0,
|
|
17
|
+
var moreEmojiContainerStyle = (0, _react.css)({
|
|
18
18
|
display: 'flex'
|
|
19
19
|
});
|
|
20
20
|
exports.moreEmojiContainerStyle = moreEmojiContainerStyle;
|
|
21
|
-
var moreButtonStyle = (0,
|
|
21
|
+
var moreButtonStyle = (0, _react.css)({
|
|
22
22
|
opacity: 0,
|
|
23
23
|
outline: 'none',
|
|
24
24
|
backgroundColor: 'transparent',
|
|
@@ -34,7 +34,7 @@ var moreButtonStyle = (0, _core.css)({
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
exports.moreButtonStyle = moreButtonStyle;
|
|
37
|
-
var separatorStyle = (0,
|
|
37
|
+
var separatorStyle = (0, _react.css)({
|
|
38
38
|
backgroundColor: (0, _tokens.token)('color.border', _colors.N30A),
|
|
39
39
|
margin: '8px 8px 8px 4px',
|
|
40
40
|
width: '1px',
|
|
@@ -9,9 +9,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.Trigger = exports.RENDER_TOOLTIP_TRIGGER_TESTID = void 0;
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _react = _interopRequireDefault(require("react"));
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
15
17
|
|
|
16
18
|
var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
|
|
17
19
|
|
|
@@ -41,7 +43,9 @@ var Trigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
41
43
|
miniMode = props.miniMode,
|
|
42
44
|
tooltipContent = props.tooltipContent,
|
|
43
45
|
_props$disabled = props.disabled,
|
|
44
|
-
disabled = _props$disabled === void 0 ? false : _props$disabled
|
|
46
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
47
|
+
_props$ariaAttributes = props.ariaAttributes,
|
|
48
|
+
ariaAttributes = _props$ariaAttributes === void 0 ? {} : _props$ariaAttributes;
|
|
45
49
|
|
|
46
50
|
var handleMouseDown = function handleMouseDown(e, analyticsEvent) {
|
|
47
51
|
if (onClick && !disabled) {
|
|
@@ -49,11 +53,11 @@ var Trigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
49
53
|
}
|
|
50
54
|
};
|
|
51
55
|
|
|
52
|
-
return (0,
|
|
56
|
+
return (0, _react2.jsx)(_tooltip.default, {
|
|
53
57
|
testId: RENDER_TOOLTIP_TRIGGER_TESTID,
|
|
54
58
|
content: tooltipContent,
|
|
55
59
|
position: "top"
|
|
56
|
-
}, (0,
|
|
60
|
+
}, (0, _react2.jsx)(_standardButton.default, (0, _extends2.default)({
|
|
57
61
|
css: styles.triggerStyle({
|
|
58
62
|
miniMode: miniMode,
|
|
59
63
|
disabled: disabled
|
|
@@ -61,13 +65,13 @@ var Trigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
61
65
|
appearance: "subtle",
|
|
62
66
|
onClick: handleMouseDown,
|
|
63
67
|
"aria-disabled": disabled,
|
|
64
|
-
iconBefore: (0,
|
|
68
|
+
iconBefore: (0, _react2.jsx)(_emojiAdd.default, {
|
|
65
69
|
size: "small",
|
|
66
70
|
label: "Add reaction"
|
|
67
71
|
}),
|
|
68
72
|
spacing: "none",
|
|
69
73
|
ref: ref
|
|
70
|
-
}));
|
|
74
|
+
}, ariaAttributes)));
|
|
71
75
|
});
|
|
72
76
|
|
|
73
77
|
exports.Trigger = Trigger;
|
|
@@ -9,7 +9,7 @@ exports.triggerStyle = exports.DISABLED_BUTTON_COLOR = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _react = require("@emotion/react");
|
|
13
13
|
|
|
14
14
|
var _tokens = require("@atlaskit/tokens");
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ var triggerStyle = function triggerStyle(_ref) {
|
|
|
27
27
|
miniMode = _ref$miniMode === void 0 ? false : _ref$miniMode,
|
|
28
28
|
_ref$disabled = _ref.disabled,
|
|
29
29
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
30
|
-
return (0,
|
|
30
|
+
return (0, _react.css)(_objectSpread(_objectSpread(_objectSpread({
|
|
31
31
|
minWidth: '32px',
|
|
32
32
|
height: '32px',
|
|
33
33
|
display: 'flex',
|
|
@@ -34,7 +34,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
34
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Export the mapper function outside the component so easier to do unit tests
|
|
37
|
+
* Export the mapper function outside the component so easier to do unit tests
|
|
38
38
|
*/
|
|
39
39
|
var mapStateToPropsHelper = function mapStateToPropsHelper(containerAri, ari, state) {
|
|
40
40
|
var reactionsState = state && state.reactions["".concat(containerAri, "|").concat(ari)];
|
|
@@ -68,7 +68,7 @@ var mapStateToPropsHelper = function mapStateToPropsHelper(containerAri, ari, st
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
71
|
-
* Export the mapper function outside the component so easier to do unit tests
|
|
71
|
+
* Export the mapper function outside the component so easier to do unit tests
|
|
72
72
|
*/
|
|
73
73
|
|
|
74
74
|
|
|
@@ -127,11 +127,9 @@ var ConnectedReactionsView = function ConnectedReactionsView(props) {
|
|
|
127
127
|
|
|
128
128
|
(_experienceInstance$c = experienceInstance.current) === null || _experienceInstance$c === void 0 ? void 0 : _experienceInstance$c.abort({
|
|
129
129
|
metadata: {
|
|
130
|
-
source: '
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
containerAri: containerAri
|
|
134
|
-
},
|
|
130
|
+
source: 'ConnectedReactionsView',
|
|
131
|
+
ari: ari,
|
|
132
|
+
containerAri: containerAri,
|
|
135
133
|
reason: 'unmount'
|
|
136
134
|
}
|
|
137
135
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TOOLTIP_USERS_LIMIT = exports.DefaultReactionsByShortName = exports.DefaultReactions = void 0;
|
|
6
|
+
exports.TOOLTIP_USERS_LIMIT = exports.DefaultReactionsByShortName = exports.DefaultReactions = exports.DEFAULT_REACTION_TOP_LIMIT = exports.DEFAULT_OVER_THE_LIMIT_REACTION_LABEL = void 0;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Initial list of emoji to pick from
|
|
@@ -28,10 +28,22 @@ var DefaultReactions = [{
|
|
|
28
28
|
shortName: ':thinking:'
|
|
29
29
|
}];
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Default label to show for the overLimitLabel prop
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
exports.DefaultReactions = DefaultReactions;
|
|
35
|
+
var DEFAULT_OVER_THE_LIMIT_REACTION_LABEL = '1k+';
|
|
36
|
+
/**
|
|
37
|
+
* Default maximum value to use when the emoji received higher than top limit reactions
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
exports.DEFAULT_OVER_THE_LIMIT_REACTION_LABEL = DEFAULT_OVER_THE_LIMIT_REACTION_LABEL;
|
|
41
|
+
var DEFAULT_REACTION_TOP_LIMIT = 1000;
|
|
42
|
+
/**
|
|
43
|
+
* ES6 Map object from default emoji reactions (with key => shortName, value => entire emoji item)
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
exports.DEFAULT_REACTION_TOP_LIMIT = DEFAULT_REACTION_TOP_LIMIT;
|
|
35
47
|
var DefaultReactionsByShortName = new Map(DefaultReactions.map(function (reaction) {
|
|
36
48
|
return [reaction.shortName, reaction];
|
|
37
49
|
}));
|
|
@@ -27,6 +27,8 @@ var _constants = require("../analytics/constants");
|
|
|
27
27
|
|
|
28
28
|
var _ufo = require("../analytics/ufo");
|
|
29
29
|
|
|
30
|
+
var _analytics2 = require("../analytics/analytics");
|
|
31
|
+
|
|
30
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
33
|
|
|
32
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -164,6 +166,13 @@ var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
164
166
|
var exp = ufoExperiences.add.getInstance("".concat(ari, "|").concat(emojiId)); // ufo start reaction experience
|
|
165
167
|
|
|
166
168
|
exp.start();
|
|
169
|
+
exp.addMetadata({
|
|
170
|
+
source: 'MemoryReactionsStore',
|
|
171
|
+
storeMetadata: _this.metadata,
|
|
172
|
+
ari: ari,
|
|
173
|
+
containerAri: containerAri,
|
|
174
|
+
emojiId: emojiId
|
|
175
|
+
});
|
|
167
176
|
|
|
168
177
|
_this.client.addReaction(containerAri, ari, emojiId, _this.metadata).then(function (_) {
|
|
169
178
|
if (_this.createAnalyticsEvent) {
|
|
@@ -178,14 +187,7 @@ var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
178
187
|
|
|
179
188
|
exp.failure({
|
|
180
189
|
metadata: {
|
|
181
|
-
error: error,
|
|
182
|
-
source: 'Reaction-Store',
|
|
183
|
-
data: {
|
|
184
|
-
containerAri: containerAri,
|
|
185
|
-
ari: ari,
|
|
186
|
-
emojiId: emojiId,
|
|
187
|
-
metadata: _this.metadata
|
|
188
|
-
},
|
|
190
|
+
error: (0, _analytics2.extractErrorInfo)(error),
|
|
189
191
|
reason: 'addReaction fetch failed'
|
|
190
192
|
}
|
|
191
193
|
});
|
|
@@ -201,6 +203,13 @@ var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
201
203
|
var exp = ufoExperiences.remove.getInstance("".concat(ari, "|").concat(emojiId)); // ufo start reaction experience
|
|
202
204
|
|
|
203
205
|
exp.start();
|
|
206
|
+
exp.addMetadata({
|
|
207
|
+
source: 'MemoryReactionsStore',
|
|
208
|
+
storeMetadata: _this.metadata,
|
|
209
|
+
ari: ari,
|
|
210
|
+
containerAri: containerAri,
|
|
211
|
+
emojiId: emojiId
|
|
212
|
+
});
|
|
204
213
|
|
|
205
214
|
_this.optmisticUpdate(containerAri, ari, emojiId)(utils.removeOne);
|
|
206
215
|
|
|
@@ -211,14 +220,7 @@ var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
211
220
|
// ufo add reaction failure
|
|
212
221
|
exp.failure({
|
|
213
222
|
metadata: {
|
|
214
|
-
error: error,
|
|
215
|
-
source: 'Reaction-Store',
|
|
216
|
-
data: {
|
|
217
|
-
containerAri: containerAri,
|
|
218
|
-
ari: ari,
|
|
219
|
-
emojiId: emojiId,
|
|
220
|
-
metadata: _this.metadata
|
|
221
|
-
},
|
|
223
|
+
error: (0, _analytics2.extractErrorInfo)(error),
|
|
222
224
|
reason: 'deleteReaction fetch failed'
|
|
223
225
|
}
|
|
224
226
|
});
|
|
@@ -238,6 +240,12 @@ var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
238
240
|
sampledExp.start({
|
|
239
241
|
samplingRate: _constants.SAMPLING_RATE_REACTIONS_RENDERED_EXP
|
|
240
242
|
});
|
|
243
|
+
sampledExp.addMetadata({
|
|
244
|
+
source: 'MemoryReactionsStore',
|
|
245
|
+
storeMetadata: _this.metadata,
|
|
246
|
+
containerAri: containerAri,
|
|
247
|
+
aris: arisArr.join(',')
|
|
248
|
+
});
|
|
241
249
|
|
|
242
250
|
_this.client.getReactions(containerAri, arisArr).then(function (value) {
|
|
243
251
|
Object.keys(value).map(function (ari) {
|
|
@@ -261,12 +269,7 @@ var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
261
269
|
|
|
262
270
|
sampledExp.failure({
|
|
263
271
|
metadata: {
|
|
264
|
-
error: error,
|
|
265
|
-
source: 'Reaction-Store',
|
|
266
|
-
data: {
|
|
267
|
-
containerAri: containerAri,
|
|
268
|
-
aris: arisArr.join(',')
|
|
269
|
-
},
|
|
272
|
+
error: (0, _analytics2.extractErrorInfo)(error),
|
|
270
273
|
reason: 'getReactions fetch failed'
|
|
271
274
|
}
|
|
272
275
|
});
|
|
@@ -291,6 +294,13 @@ var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
291
294
|
(0, _defineProperty2.default)(this, "getDetailedReaction", function (containerAri, ari, emojiId) {
|
|
292
295
|
var exp = ufoExperiences.fetchDetails.getInstance("".concat(ari, "|").concat(emojiId));
|
|
293
296
|
exp.start();
|
|
297
|
+
exp.addMetadata({
|
|
298
|
+
source: 'MemoryReactionsStore',
|
|
299
|
+
storeMetadata: _this.metadata,
|
|
300
|
+
ari: ari,
|
|
301
|
+
containerAri: containerAri,
|
|
302
|
+
emojiId: emojiId
|
|
303
|
+
});
|
|
294
304
|
|
|
295
305
|
_this.client.getDetailedReaction(containerAri, ari, emojiId).then(function (summary) {
|
|
296
306
|
// ufo get reaction details success
|
|
@@ -301,13 +311,7 @@ var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
301
311
|
// ufo get reaction details failure
|
|
302
312
|
exp.failure({
|
|
303
313
|
metadata: {
|
|
304
|
-
error: error,
|
|
305
|
-
source: 'Reaction-Store',
|
|
306
|
-
data: {
|
|
307
|
-
containerAri: containerAri,
|
|
308
|
-
ari: ari,
|
|
309
|
-
emojiId: emojiId
|
|
310
|
-
},
|
|
314
|
+
error: (0, _analytics2.extractErrorInfo)(error),
|
|
311
315
|
reason: 'getDetailedReaction fetch failed'
|
|
312
316
|
}
|
|
313
317
|
});
|
package/dist/cjs/version.json
CHANGED
|
@@ -61,4 +61,20 @@ export const createReactionHoveredEvent = startTime => createPayload('hovered',
|
|
|
61
61
|
export const createReactionClickedEvent = (added, emojiId) => createPayload('clicked', 'existingReaction', UI_EVENT_TYPE)({
|
|
62
62
|
added,
|
|
63
63
|
emojiId
|
|
64
|
-
});
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Used for store failure metadata for analytics
|
|
67
|
+
* @param error The error could be a service error with {code, reason} or an Error
|
|
68
|
+
* @returns any
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
export const extractErrorInfo = error => {
|
|
72
|
+
if (error instanceof Error) {
|
|
73
|
+
return {
|
|
74
|
+
name: error.name,
|
|
75
|
+
message: error.message
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return error;
|
|
80
|
+
};
|
|
@@ -1,50 +1,54 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { jsx, css } from '@emotion/
|
|
3
|
+
import { jsx, css } from '@emotion/react';
|
|
4
4
|
import { SlideIn, ExitingPersistence, mediumDurationMs } from '@atlaskit/motion'; // eslint-disable-next-line @atlaskit/design-system/no-banned-imports
|
|
5
5
|
|
|
6
6
|
import usePreviousValue from '@atlaskit/ds-lib/use-previous-value';
|
|
7
|
+
import { constants } from '../../shared';
|
|
7
8
|
import * as styles from './styles';
|
|
8
9
|
/**
|
|
9
|
-
* Test id for
|
|
10
|
+
* Test id for component top level div
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
|
-
export const
|
|
13
|
+
export const RENDER_COMPONENT_WRAPPER = 'counter-wrapper';
|
|
13
14
|
/**
|
|
14
|
-
* Test id for
|
|
15
|
+
* Test id for wrapper div of the counter inside the slider
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
|
-
export const
|
|
18
|
+
export const RENDER_COUNTER_TESTID = 'counter-container';
|
|
19
|
+
/**
|
|
20
|
+
* Counter label value wrapper div
|
|
21
|
+
*/
|
|
18
22
|
|
|
23
|
+
export const RENDER_LABEL_TESTID = 'counter_label_wrapper';
|
|
24
|
+
export const getLabel = (value, overLimitLabel, limit) => {
|
|
25
|
+
// Check if reached limit
|
|
26
|
+
if (limit && value >= limit) {
|
|
27
|
+
return overLimitLabel || '';
|
|
28
|
+
} else if (value === 0) {
|
|
29
|
+
return '';
|
|
30
|
+
} else {
|
|
31
|
+
return value.toString();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
19
34
|
/**
|
|
20
35
|
* Display reaction count next to the emoji button
|
|
21
36
|
*/
|
|
37
|
+
|
|
22
38
|
export const Counter = ({
|
|
23
39
|
highlight = false,
|
|
24
|
-
limit =
|
|
25
|
-
overLimitLabel =
|
|
40
|
+
limit = constants.DEFAULT_REACTION_TOP_LIMIT,
|
|
41
|
+
overLimitLabel = constants.DEFAULT_OVER_THE_LIMIT_REACTION_LABEL,
|
|
26
42
|
className,
|
|
27
43
|
value,
|
|
28
44
|
animationDuration = mediumDurationMs
|
|
29
45
|
}) => {
|
|
30
|
-
const hasReachedLimit = value => limit && value >= limit;
|
|
31
|
-
|
|
32
|
-
const getLabel = value => {
|
|
33
|
-
if (hasReachedLimit(value)) {
|
|
34
|
-
return overLimitLabel || '';
|
|
35
|
-
} else if (value === 0) {
|
|
36
|
-
return '';
|
|
37
|
-
} else {
|
|
38
|
-
return value.toString();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
46
|
const previousValue = usePreviousValue(value);
|
|
43
|
-
const label = getLabel(value);
|
|
47
|
+
const label = getLabel(value, overLimitLabel, limit);
|
|
44
48
|
const increase = previousValue ? previousValue < value : false;
|
|
45
49
|
return jsx("div", {
|
|
46
50
|
className: className,
|
|
47
|
-
"data-testid":
|
|
51
|
+
"data-testid": RENDER_COMPONENT_WRAPPER,
|
|
48
52
|
css: [styles.countStyle, {
|
|
49
53
|
width: label.length * 7
|
|
50
54
|
}]
|
|
@@ -52,15 +56,18 @@ export const Counter = ({
|
|
|
52
56
|
enterFrom: increase ? 'bottom' : 'top',
|
|
53
57
|
key: value,
|
|
54
58
|
duration: animationDuration
|
|
55
|
-
}, (motion, direction) =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
}, (motion, direction) => {
|
|
60
|
+
return jsx("div", {
|
|
61
|
+
ref: motion.ref,
|
|
62
|
+
css: [styles.containerStyle, css({
|
|
63
|
+
position: direction === 'exiting' ? 'absolute' : undefined
|
|
64
|
+
})],
|
|
65
|
+
className: motion.className,
|
|
66
|
+
"data-testid": RENDER_COUNTER_TESTID
|
|
67
|
+
}, jsx("div", {
|
|
68
|
+
"data-testid": RENDER_LABEL_TESTID,
|
|
69
|
+
css: highlight && styles.highlightStyle,
|
|
70
|
+
key: value
|
|
71
|
+
}, label));
|
|
72
|
+
})));
|
|
66
73
|
};
|