@atlaskit/reactions 23.0.2 → 24.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/analytics/index.js +1 -1
- package/dist/cjs/components/ReactionDialog/ReactionView.js +11 -10
- package/dist/cjs/components/ReactionDialog/ReactionsDialog.js +61 -8
- package/dist/cjs/components/ReactionDialog/ReactionsList.js +25 -4
- package/dist/cjs/components/ReactionDialog/styles.js +3 -64
- package/dist/cjs/components/Reactions/Reactions.js +13 -3
- package/dist/cjs/shared/constants.js +2 -2
- package/dist/es2019/analytics/index.js +1 -1
- package/dist/es2019/components/ReactionDialog/ReactionView.js +11 -10
- package/dist/es2019/components/ReactionDialog/ReactionsDialog.js +53 -9
- package/dist/es2019/components/ReactionDialog/ReactionsList.js +25 -6
- package/dist/es2019/components/ReactionDialog/styles.js +3 -62
- package/dist/es2019/components/Reactions/Reactions.js +16 -6
- package/dist/es2019/shared/constants.js +2 -2
- package/dist/esm/analytics/index.js +1 -1
- package/dist/esm/components/ReactionDialog/ReactionView.js +12 -11
- package/dist/esm/components/ReactionDialog/ReactionsDialog.js +61 -9
- package/dist/esm/components/ReactionDialog/ReactionsList.js +27 -6
- package/dist/esm/components/ReactionDialog/styles.js +3 -64
- package/dist/esm/components/Reactions/Reactions.js +13 -3
- package/dist/esm/shared/constants.js +2 -2
- package/dist/types/components/ReactionDialog/ReactionsDialog.d.ts +2 -1
- package/dist/types/components/ReactionDialog/styles.d.ts +0 -2
- package/dist/types/shared/constants.d.ts +2 -2
- package/dist/types/types/reaction.d.ts +1 -1
- package/dist/types-ts4.5/components/ReactionDialog/ReactionsDialog.d.ts +2 -1
- package/dist/types-ts4.5/components/ReactionDialog/styles.d.ts +0 -2
- package/dist/types-ts4.5/shared/constants.d.ts +2 -2
- package/dist/types-ts4.5/types/reaction.d.ts +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/reactions
|
|
2
2
|
|
|
3
|
+
## 24.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#105233](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105233)
|
|
8
|
+
[`e66f08655d260`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e66f08655d260) -
|
|
9
|
+
[ux] Update Reactions Dialog to use pagination instead of horizontal scroll
|
|
10
|
+
|
|
3
11
|
## 23.0.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ var _analyticsGasTypes = require("@atlaskit/analytics-gas-types");
|
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
13
|
var packageName = "@atlaskit/reactions";
|
|
14
|
-
var packageVersion = "
|
|
14
|
+
var packageVersion = "24.0.0";
|
|
15
15
|
/**
|
|
16
16
|
* TODO: move to utility package?
|
|
17
17
|
* A random sampling function
|
|
@@ -30,11 +30,10 @@ var ReactionView = exports.ReactionView = function ReactionView(_ref) {
|
|
|
30
30
|
var selectedEmojiId = _ref.selectedEmojiId,
|
|
31
31
|
emojiProvider = _ref.emojiProvider,
|
|
32
32
|
reaction = _ref.reaction;
|
|
33
|
-
var intl = (0, _reactIntlNext.useIntl)();
|
|
34
33
|
var _useState = (0, _react.useState)(''),
|
|
35
34
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
emojiShortName = _useState2[0],
|
|
36
|
+
setEmojiShortName = _useState2[1];
|
|
38
37
|
(0, _react.useEffect)(function () {
|
|
39
38
|
(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
40
39
|
var provider, emoji;
|
|
@@ -52,8 +51,8 @@ var ReactionView = exports.ReactionView = function ReactionView(_ref) {
|
|
|
52
51
|
});
|
|
53
52
|
case 5:
|
|
54
53
|
emoji = _context.sent;
|
|
55
|
-
if (emoji && emoji.
|
|
56
|
-
|
|
54
|
+
if (emoji !== null && emoji !== void 0 && emoji.shortName) {
|
|
55
|
+
setEmojiShortName(emoji.shortName);
|
|
57
56
|
}
|
|
58
57
|
case 7:
|
|
59
58
|
case "end":
|
|
@@ -61,7 +60,7 @@ var ReactionView = exports.ReactionView = function ReactionView(_ref) {
|
|
|
61
60
|
}
|
|
62
61
|
}, _callee);
|
|
63
62
|
}))();
|
|
64
|
-
}, [emojiProvider, selectedEmojiId]);
|
|
63
|
+
}, [emojiProvider, selectedEmojiId, reaction]);
|
|
65
64
|
var alphabeticalNames = (0, _react.useMemo)(function () {
|
|
66
65
|
var _reactionObj$users;
|
|
67
66
|
var reactionObj = reaction;
|
|
@@ -76,15 +75,17 @@ var ReactionView = exports.ReactionView = function ReactionView(_ref) {
|
|
|
76
75
|
css: _styles.reactionViewStyle
|
|
77
76
|
}, tabPanelAttributes), (0, _react2.jsx)(_primitives.Text, {
|
|
78
77
|
as: "p"
|
|
79
|
-
}, (0, _react2.jsx)(
|
|
78
|
+
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _i18n.messages.peopleWhoReactedSubheading, {
|
|
79
|
+
values: {
|
|
80
|
+
emojiShortName: emojiShortName
|
|
81
|
+
}
|
|
82
|
+
})), (0, _react2.jsx)(_element.ResourcedEmoji, {
|
|
80
83
|
emojiProvider: emojiProvider,
|
|
81
84
|
emojiId: {
|
|
82
85
|
id: selectedEmojiId,
|
|
83
86
|
shortName: ''
|
|
84
87
|
},
|
|
85
|
-
fitToHeight:
|
|
86
|
-
}), intl.formatMessage(_i18n.messages.emojiName, {
|
|
87
|
-
emojiName: emojiName
|
|
88
|
+
fitToHeight: 16
|
|
88
89
|
})), alphabeticalNames.length === 0 ?
|
|
89
90
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
90
91
|
(0, _react2.jsx)("div", {
|
|
@@ -10,8 +10,11 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _reactIntlNext = require("react-intl-next");
|
|
12
12
|
var _react2 = require("@emotion/react");
|
|
13
|
-
var
|
|
13
|
+
var _primitives = require("@atlaskit/primitives");
|
|
14
|
+
var _new = _interopRequireWildcard(require("@atlaskit/button/new"));
|
|
14
15
|
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
|
|
16
|
+
var _chevronLeft = _interopRequireDefault(require("@atlaskit/icon/utility/chevron-left"));
|
|
17
|
+
var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/utility/chevron-right"));
|
|
15
18
|
var _constants = require("../../shared/constants");
|
|
16
19
|
var _i18n = require("../../shared/i18n");
|
|
17
20
|
var _ReactionsList = require("./ReactionsList");
|
|
@@ -25,6 +28,10 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
25
28
|
|
|
26
29
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
27
30
|
|
|
31
|
+
var fullWidthStyle = (0, _primitives.xcss)({
|
|
32
|
+
width: '100%'
|
|
33
|
+
});
|
|
34
|
+
|
|
28
35
|
/**
|
|
29
36
|
* Test id for the Reactions modal dialog
|
|
30
37
|
*/
|
|
@@ -37,6 +44,7 @@ var getDimensions = function getDimensions(container) {
|
|
|
37
44
|
};
|
|
38
45
|
};
|
|
39
46
|
var ReactionsDialog = exports.ReactionsDialog = function ReactionsDialog(_ref) {
|
|
47
|
+
var _currentReactions$;
|
|
40
48
|
var _ref$reactions = _ref.reactions,
|
|
41
49
|
reactions = _ref$reactions === void 0 ? [] : _ref$reactions,
|
|
42
50
|
_ref$handleCloseReact = _ref.handleCloseReactionsDialog,
|
|
@@ -44,7 +52,9 @@ var ReactionsDialog = exports.ReactionsDialog = function ReactionsDialog(_ref) {
|
|
|
44
52
|
emojiProvider = _ref.emojiProvider,
|
|
45
53
|
selectedEmojiId = _ref.selectedEmojiId,
|
|
46
54
|
_ref$handleSelectReac = _ref.handleSelectReaction,
|
|
47
|
-
handleSelectReaction = _ref$handleSelectReac === void 0 ? function () {} : _ref$handleSelectReac
|
|
55
|
+
handleSelectReaction = _ref$handleSelectReac === void 0 ? function () {} : _ref$handleSelectReac,
|
|
56
|
+
_ref$handlePagination = _ref.handlePaginationChange,
|
|
57
|
+
handlePaginationChange = _ref$handlePagination === void 0 ? function () {} : _ref$handlePagination;
|
|
48
58
|
var _useState = (0, _react.useState)(),
|
|
49
59
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
50
60
|
elementToScroll = _useState2[0],
|
|
@@ -67,15 +77,42 @@ var ReactionsDialog = exports.ReactionsDialog = function ReactionsDialog(_ref) {
|
|
|
67
77
|
return (b === null || b === void 0 ? void 0 : b.count) - (a === null || a === void 0 ? void 0 : a.count);
|
|
68
78
|
});
|
|
69
79
|
}, [reactions]);
|
|
80
|
+
var maxPages = Math.max(1, Math.ceil(reactions.length / _constants.NUMBER_OF_REACTIONS_TO_DISPLAY));
|
|
81
|
+
var _useState5 = (0, _react.useState)(1),
|
|
82
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
83
|
+
currentPage = _useState6[0],
|
|
84
|
+
setCurrentPage = _useState6[1];
|
|
85
|
+
var currentReactions = (0, _react.useMemo)(function () {
|
|
86
|
+
var start = (currentPage - 1) * _constants.NUMBER_OF_REACTIONS_TO_DISPLAY;
|
|
87
|
+
var end = start + _constants.NUMBER_OF_REACTIONS_TO_DISPLAY;
|
|
88
|
+
return sortedReactions.slice(start, end);
|
|
89
|
+
}, [sortedReactions, currentPage]);
|
|
90
|
+
var handleNextPage = function handleNextPage() {
|
|
91
|
+
setCurrentPage(function (prevPage) {
|
|
92
|
+
return Math.min(prevPage + 1, maxPages);
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
var handlePreviousPage = function handlePreviousPage() {
|
|
96
|
+
setCurrentPage(function (prevPage) {
|
|
97
|
+
return Math.max(prevPage - 1, 1);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var firstEmojiOnPage = (_currentReactions$ = currentReactions[0]) === null || _currentReactions$ === void 0 ? void 0 : _currentReactions$.emojiId;
|
|
101
|
+
(0, _react.useEffect)(function () {
|
|
102
|
+
// trigger the handler with the first emoji when the page changes
|
|
103
|
+
if (firstEmojiOnPage) {
|
|
104
|
+
handlePaginationChange(firstEmojiOnPage);
|
|
105
|
+
}
|
|
106
|
+
}, [currentPage, firstEmojiOnPage, handlePaginationChange]);
|
|
70
107
|
|
|
71
|
-
/* set Reactions Border Width ,
|
|
108
|
+
/* set Reactions Border Width , 8 Number of reactions to display*/
|
|
72
109
|
var reactionsBorderWidth = (0, _react.useMemo)(function () {
|
|
73
110
|
return Math.ceil(reactions.length / _constants.NUMBER_OF_REACTIONS_TO_DISPLAY) * 100;
|
|
74
111
|
}, [reactions]);
|
|
75
112
|
|
|
76
113
|
/* Callback from IntersectionObserver to set/unset classNames based on visibility to toggle styles*/
|
|
77
114
|
var handleNavigation = (0, _react.useCallback)(function (entries) {
|
|
78
|
-
entries.forEach(function (entry
|
|
115
|
+
entries.forEach(function (entry) {
|
|
79
116
|
var _dataset;
|
|
80
117
|
var element = entry.target;
|
|
81
118
|
var emojiElement = element === null || element === void 0 ? void 0 : element.querySelector('[data-emoji-id]');
|
|
@@ -142,16 +179,32 @@ var ReactionsDialog = exports.ReactionsDialog = function ReactionsDialog(_ref) {
|
|
|
142
179
|
onClose: handleCloseReactionsDialog,
|
|
143
180
|
height: 600,
|
|
144
181
|
testId: RENDER_MODAL_TESTID
|
|
145
|
-
}, (0, _react2.jsx)(_modalDialog.ModalHeader, null, (0, _react2.jsx)(
|
|
146
|
-
|
|
147
|
-
|
|
182
|
+
}, (0, _react2.jsx)(_modalDialog.ModalHeader, null, (0, _react2.jsx)(_primitives.Flex, {
|
|
183
|
+
direction: "row",
|
|
184
|
+
justifyContent: "space-between",
|
|
185
|
+
alignItems: "center",
|
|
186
|
+
xcss: fullWidthStyle
|
|
187
|
+
}, (0, _react2.jsx)("div", null, (0, _react2.jsx)(_modalDialog.ModalTitle, null, intl.formatMessage(_i18n.messages.reactionsCount, {
|
|
148
188
|
count: totalReactionsCount
|
|
189
|
+
}))), (0, _react2.jsx)(_primitives.Flex, {
|
|
190
|
+
alignItems: "center",
|
|
191
|
+
gap: "space.100"
|
|
192
|
+
}, (0, _react2.jsx)(_new.IconButton, {
|
|
193
|
+
isDisabled: currentPage === 1,
|
|
194
|
+
onClick: handlePreviousPage,
|
|
195
|
+
icon: _chevronLeft.default,
|
|
196
|
+
label: intl.formatMessage(_i18n.messages.leftNavigateLabel)
|
|
197
|
+
}), (0, _react2.jsx)(_new.IconButton, {
|
|
198
|
+
onClick: handleNextPage,
|
|
199
|
+
isDisabled: currentPage === maxPages,
|
|
200
|
+
icon: _chevronRight.default,
|
|
201
|
+
label: intl.formatMessage(_i18n.messages.rightNavigateLabel)
|
|
149
202
|
})))), (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)("div", {
|
|
150
203
|
css: (0, _styles.containerStyle)(reactionsBorderWidth),
|
|
151
204
|
ref: setRef
|
|
152
205
|
}, (0, _react2.jsx)(_ReactionsList.ReactionsList, {
|
|
153
206
|
initialEmojiId: selectedEmojiId,
|
|
154
|
-
reactions:
|
|
207
|
+
reactions: currentReactions,
|
|
155
208
|
emojiProvider: emojiProvider,
|
|
156
209
|
onReactionChanged: handleSelectReaction
|
|
157
210
|
}))), (0, _react2.jsx)(_modalDialog.ModalFooter, null, (0, _react2.jsx)(_new.default, {
|
|
@@ -12,6 +12,7 @@ var _react2 = require("@emotion/react");
|
|
|
12
12
|
var _element = require("@atlaskit/emoji/element");
|
|
13
13
|
var _tabs = _interopRequireWildcard(require("@atlaskit/tabs"));
|
|
14
14
|
var _tokens = require("@atlaskit/tokens");
|
|
15
|
+
var _primitives = require("@atlaskit/primitives");
|
|
15
16
|
var _Counter = require("../Counter");
|
|
16
17
|
var _styles = require("./styles");
|
|
17
18
|
var _ReactionView = require("./ReactionView");
|
|
@@ -24,6 +25,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
24
25
|
|
|
25
26
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
26
27
|
|
|
28
|
+
var emojiStyles = (0, _primitives.xcss)({
|
|
29
|
+
minWidth: '36px'
|
|
30
|
+
});
|
|
27
31
|
var ReactionsList = exports.ReactionsList = function ReactionsList(_ref) {
|
|
28
32
|
var reactions = _ref.reactions,
|
|
29
33
|
initialEmojiId = _ref.initialEmojiId,
|
|
@@ -43,6 +47,19 @@ var ReactionsList = exports.ReactionsList = function ReactionsList(_ref) {
|
|
|
43
47
|
setSelectedEmoji = _useState2[1];
|
|
44
48
|
var _useThemeObserver = (0, _tokens.useThemeObserver)(),
|
|
45
49
|
colorMode = _useThemeObserver.colorMode;
|
|
50
|
+
(0, _react.useEffect)(function () {
|
|
51
|
+
// select first emoji when navigating to a new page
|
|
52
|
+
var currentPageEmojis = reactions.map(function (reaction) {
|
|
53
|
+
return reaction.emojiId;
|
|
54
|
+
});
|
|
55
|
+
if (!currentPageEmojis.includes(selectedEmoji.id)) {
|
|
56
|
+
setSelectedEmoji({
|
|
57
|
+
index: 0,
|
|
58
|
+
id: initialEmojiId
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
|
+
}, [reactions, initialEmojiId]);
|
|
46
63
|
var onTabChange = (0, _react.useCallback)(function (index, analyticsEvent) {
|
|
47
64
|
if (index === selectedEmoji.index) {
|
|
48
65
|
return;
|
|
@@ -74,14 +91,18 @@ var ReactionsList = exports.ReactionsList = function ReactionsList(_ref) {
|
|
|
74
91
|
className: "reaction-elements",
|
|
75
92
|
key: reaction.emojiId,
|
|
76
93
|
"data-testid": emojiId === null || emojiId === void 0 ? void 0 : emojiId.id
|
|
77
|
-
}, (0, _react2.jsx)(_tabs.Tab, null, (0, _react2.jsx)(
|
|
94
|
+
}, (0, _react2.jsx)(_tabs.Tab, null, (0, _react2.jsx)(_primitives.Flex, {
|
|
95
|
+
justifyContent: "center",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
direction: "row"
|
|
98
|
+
}, (0, _react2.jsx)(_primitives.Box, {
|
|
99
|
+
xcss: emojiStyles
|
|
100
|
+
}, (0, _react2.jsx)(_element.ResourcedEmoji, {
|
|
78
101
|
emojiProvider: emojiProvider,
|
|
79
102
|
emojiId: emojiId,
|
|
80
103
|
fitToHeight: 16,
|
|
81
104
|
showTooltip: true
|
|
82
|
-
}), (0, _react2.jsx)(
|
|
83
|
-
css: (0, _styles.counterStyle)((emojiId === null || emojiId === void 0 ? void 0 : emojiId.id) === selectedEmoji.id)
|
|
84
|
-
}, (0, _react2.jsx)(_Counter.Counter, {
|
|
105
|
+
})), (0, _react2.jsx)(_Counter.Counter, {
|
|
85
106
|
value: reaction.count
|
|
86
107
|
}))));
|
|
87
108
|
}))), reactions.map(function (reaction) {
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.userStyle = exports.userListStyle = exports.
|
|
6
|
+
exports.userStyle = exports.userListStyle = exports.reactionViewStyle = exports.navigationContainerStyle = exports.customTabWrapper = exports.customTabListStyles = exports.containerStyle = exports.centerSpinner = void 0;
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
var _colors = require("@atlaskit/theme/colors");
|
|
9
|
-
var _constants = require("../../shared/constants");
|
|
10
9
|
/**
|
|
11
10
|
* @jsxRuntime classic
|
|
12
11
|
* @jsx jsx
|
|
@@ -14,13 +13,7 @@ var _constants = require("../../shared/constants");
|
|
|
14
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
15
14
|
|
|
16
15
|
var REACTIONS_CONTAINER_WIDTH = 48;
|
|
17
|
-
|
|
18
|
-
// These margin values must match
|
|
19
|
-
var REACTION_RIGHT_MARGIN = 8;
|
|
20
|
-
var REACTION_RIGHT_MARGIN_TOKEN = "var(--ds-space-100, 8px)";
|
|
21
|
-
/* we want to display around 9 reactions and show 10th one as faded so removing 2px from REACTIONS_CONTAINER_WIDTH*/
|
|
22
|
-
var CONTAINER_WIDTH = _constants.NUMBER_OF_REACTIONS_TO_DISPLAY * (REACTIONS_CONTAINER_WIDTH + REACTION_RIGHT_MARGIN) + REACTIONS_CONTAINER_WIDTH - 2;
|
|
23
|
-
var REACTION_CONTAINER_HEIGHT = 48;
|
|
16
|
+
var REACTION_CONTAINER_HEIGHT = 40;
|
|
24
17
|
|
|
25
18
|
/*Reactions Container. Using pseudo Element :after to set border since with onClick of Reaction to higlight the
|
|
26
19
|
border blue below the reaction. Setting Border Width based on number of reactions to make sure it shows up
|
|
@@ -29,7 +22,6 @@ var containerStyle = exports.containerStyle = function containerStyle(reactionsB
|
|
|
29
22
|
return (0, _react.css)({
|
|
30
23
|
overflow: 'hidden',
|
|
31
24
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
32
|
-
maxWidth: "".concat(CONTAINER_WIDTH, "px"),
|
|
33
25
|
height: '100%',
|
|
34
26
|
display: 'flex',
|
|
35
27
|
justifyContent: 'start',
|
|
@@ -47,42 +39,10 @@ var containerStyle = exports.containerStyle = function containerStyle(reactionsB
|
|
|
47
39
|
}
|
|
48
40
|
});
|
|
49
41
|
};
|
|
50
|
-
|
|
51
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
52
|
-
var titleStyle = exports.titleStyle = (0, _react.css)({
|
|
53
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
54
|
-
'& > h1': {
|
|
55
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
56
|
-
fontSize: '24px!important',
|
|
57
|
-
color: "".concat("var(--ds-text, ".concat(_colors.N800, ")"))
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
42
|
var containerEdgeAngle = {
|
|
61
43
|
rightEdge: 270,
|
|
62
44
|
leftEdge: 90
|
|
63
45
|
};
|
|
64
|
-
var counterStyle = exports.counterStyle = function counterStyle(isSelected) {
|
|
65
|
-
return (0, _react.css)({
|
|
66
|
-
display: 'flex',
|
|
67
|
-
alignSelf: 'center',
|
|
68
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
69
|
-
lineHeight: '14px',
|
|
70
|
-
font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
71
|
-
paddingRight: '0px',
|
|
72
|
-
marginTop: "var(--ds-space-075, 6px)",
|
|
73
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
74
|
-
'> div': {
|
|
75
|
-
width: '100%',
|
|
76
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
77
|
-
padding: "var(--ds-space-0, 0px)".concat("!important"),
|
|
78
|
-
//Counter component has its own styles overriding them to match designs
|
|
79
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
80
|
-
color: isSelected ? "".concat("var(--ds-text, ".concat(_colors.B400, ")"), "!important") : "2px solid ".concat("var(--ds-text, ".concat(_colors.N500, ")"), "!important"),
|
|
81
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/design-system/use-tokens-typography -- Ignored via go/DSP-18766
|
|
82
|
-
fontWeight: isSelected ? 700 : 400
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
46
|
var fadedCss = function fadedCss(edge, theme) {
|
|
87
47
|
return (0, _react.css)({
|
|
88
48
|
content: '""',
|
|
@@ -106,8 +66,6 @@ var customTabWrapper = exports.customTabWrapper = function customTabWrapper(isSe
|
|
|
106
66
|
alignItems: 'center',
|
|
107
67
|
justifyContent: 'center',
|
|
108
68
|
minWidth: "".concat(REACTIONS_CONTAINER_WIDTH, "px"),
|
|
109
|
-
minHeight: "".concat(REACTION_CONTAINER_HEIGHT, "px"),
|
|
110
|
-
marginRight: REACTION_RIGHT_MARGIN_TOKEN,
|
|
111
69
|
boxSizing: 'border-box',
|
|
112
70
|
position: 'relative',
|
|
113
71
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
@@ -127,25 +85,7 @@ var customTabWrapper = exports.customTabWrapper = function customTabWrapper(isSe
|
|
|
127
85
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
128
86
|
'&.disabled:after': fadedCss('rightEdge', theme),
|
|
129
87
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
130
|
-
'&.disabled + &.disabled:after': fadedCss('leftEdge', theme)
|
|
131
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
132
|
-
'&:after': isSelected ? {
|
|
133
|
-
content: '""',
|
|
134
|
-
borderBottom: "2px solid ".concat("var(--ds-text, ".concat(_colors.B400, ")")),
|
|
135
|
-
width: "".concat(REACTIONS_CONTAINER_WIDTH, "px"),
|
|
136
|
-
bottom: '0px',
|
|
137
|
-
display: 'block',
|
|
138
|
-
position: 'absolute',
|
|
139
|
-
zIndex: 2
|
|
140
|
-
} : {
|
|
141
|
-
content: '""',
|
|
142
|
-
borderBottom: "2px solid transparent",
|
|
143
|
-
width: "".concat(REACTIONS_CONTAINER_WIDTH, "px"),
|
|
144
|
-
bottom: '0px',
|
|
145
|
-
display: 'block',
|
|
146
|
-
position: 'absolute',
|
|
147
|
-
zIndex: 1
|
|
148
|
-
}
|
|
88
|
+
'&.disabled + &.disabled:after': fadedCss('leftEdge', theme)
|
|
149
89
|
});
|
|
150
90
|
};
|
|
151
91
|
|
|
@@ -209,7 +149,6 @@ var userStyle = exports.userStyle = (0, _react.css)({
|
|
|
209
149
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
210
150
|
var customTabListStyles = exports.customTabListStyles = (0, _react.css)({
|
|
211
151
|
overflow: 'auto',
|
|
212
|
-
scrollBehavior: 'smooth',
|
|
213
152
|
display: 'flex',
|
|
214
153
|
paddingBottom: "var(--ds-space-050, 4px)",
|
|
215
154
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
@@ -24,8 +24,8 @@ var _ufo = require("../../ufo");
|
|
|
24
24
|
var _Reaction = require("../Reaction");
|
|
25
25
|
var _ReactionDialog = require("../ReactionDialog");
|
|
26
26
|
var _ReactionPicker = require("../ReactionPicker");
|
|
27
|
-
var _styles = require("./styles");
|
|
28
27
|
var _ReactionSummary = require("../ReactionSummary/");
|
|
28
|
+
var _styles = require("./styles");
|
|
29
29
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
30
30
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
31
31
|
/**
|
|
@@ -240,7 +240,9 @@ var Reactions = exports.Reactions = /*#__PURE__*/_react.default.memo(function (_
|
|
|
240
240
|
// ufo selected reaction inside the modal dialog
|
|
241
241
|
ufoExperiences.selectedReactionChangeInsideDialog.start();
|
|
242
242
|
handleReactionMouseEnter(emojiId);
|
|
243
|
-
|
|
243
|
+
if (analyticsEvent) {
|
|
244
|
+
onDialogSelectReactionCallback(emojiId, analyticsEvent);
|
|
245
|
+
}
|
|
244
246
|
|
|
245
247
|
// ufo selected reaction inside the modal dialog success
|
|
246
248
|
ufoExperiences.selectedReactionChangeInsideDialog.success({
|
|
@@ -251,6 +253,13 @@ var Reactions = exports.Reactions = /*#__PURE__*/_react.default.memo(function (_
|
|
|
251
253
|
}
|
|
252
254
|
});
|
|
253
255
|
};
|
|
256
|
+
var handlePaginationChange = (0, _react.useCallback)(function (emojiId) {
|
|
257
|
+
getReactionDetails(emojiId);
|
|
258
|
+
setSelectedEmojiId(emojiId);
|
|
259
|
+
},
|
|
260
|
+
// Exclude unstable getReactionDetails to avoid extra re-renders
|
|
261
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
262
|
+
[setSelectedEmojiId]);
|
|
254
263
|
|
|
255
264
|
/**
|
|
256
265
|
* Get the reactions that we want to render are any reactions with a count greater than zero as well as any default emoji not already shown
|
|
@@ -355,7 +364,8 @@ var Reactions = exports.Reactions = /*#__PURE__*/_react.default.memo(function (_
|
|
|
355
364
|
reactions: memorizedReactions,
|
|
356
365
|
emojiProvider: emojiProvider,
|
|
357
366
|
handleCloseReactionsDialog: handleCloseReactionsDialog,
|
|
358
|
-
handleSelectReaction: handleSelectReactionInDialog
|
|
367
|
+
handleSelectReaction: handleSelectReactionInDialog,
|
|
368
|
+
handlePaginationChange: handlePaginationChange
|
|
359
369
|
})))
|
|
360
370
|
);
|
|
361
371
|
});
|
|
@@ -95,10 +95,10 @@ var ExtendedReactionsByShortName = exports.ExtendedReactionsByShortName = new Ma
|
|
|
95
95
|
var TOOLTIP_USERS_LIMIT = exports.TOOLTIP_USERS_LIMIT = 5;
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* Maximum number of reactions that will fit in the horizontal
|
|
98
|
+
* Maximum number of reactions that will fit in the horizontal pagination of
|
|
99
99
|
* reactions dialog
|
|
100
100
|
*/
|
|
101
|
-
var NUMBER_OF_REACTIONS_TO_DISPLAY = exports.NUMBER_OF_REACTIONS_TO_DISPLAY =
|
|
101
|
+
var NUMBER_OF_REACTIONS_TO_DISPLAY = exports.NUMBER_OF_REACTIONS_TO_DISPLAY = 8;
|
|
102
102
|
|
|
103
103
|
// This rate is used in fetching emoji resource
|
|
104
104
|
var SAMPLING_RATE_REACTIONS_RENDERED_EXP = exports.SAMPLING_RATE_REACTIONS_RENDERED_EXP = 50;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
2
2
|
import { UI_EVENT_TYPE, OPERATIONAL_EVENT_TYPE } from '@atlaskit/analytics-gas-types';
|
|
3
3
|
const packageName = "@atlaskit/reactions";
|
|
4
|
-
const packageVersion = "
|
|
4
|
+
const packageVersion = "24.0.0";
|
|
5
5
|
/**
|
|
6
6
|
* TODO: move to utility package?
|
|
7
7
|
* A random sampling function
|
|
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
6
|
import { useEffect, useState, useMemo } from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
9
|
import { jsx } from '@emotion/react';
|
|
10
10
|
import { ResourcedEmoji } from '@atlaskit/emoji/element';
|
|
@@ -19,8 +19,7 @@ export const ReactionView = ({
|
|
|
19
19
|
emojiProvider,
|
|
20
20
|
reaction
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
const [emojiName, setEmojiName] = useState('');
|
|
22
|
+
const [emojiShortName, setEmojiShortName] = useState('');
|
|
24
23
|
useEffect(() => {
|
|
25
24
|
(async () => {
|
|
26
25
|
const provider = await emojiProvider;
|
|
@@ -28,11 +27,11 @@ export const ReactionView = ({
|
|
|
28
27
|
shortName: '',
|
|
29
28
|
id: selectedEmojiId
|
|
30
29
|
});
|
|
31
|
-
if (emoji && emoji.
|
|
32
|
-
|
|
30
|
+
if (emoji !== null && emoji !== void 0 && emoji.shortName) {
|
|
31
|
+
setEmojiShortName(emoji.shortName);
|
|
33
32
|
}
|
|
34
33
|
})();
|
|
35
|
-
}, [emojiProvider, selectedEmojiId]);
|
|
34
|
+
}, [emojiProvider, selectedEmojiId, reaction]);
|
|
36
35
|
const alphabeticalNames = useMemo(() => {
|
|
37
36
|
var _reactionObj$users;
|
|
38
37
|
const reactionObj = reaction;
|
|
@@ -45,15 +44,17 @@ export const ReactionView = ({
|
|
|
45
44
|
css: reactionViewStyle
|
|
46
45
|
}, tabPanelAttributes), jsx(Text, {
|
|
47
46
|
as: "p"
|
|
48
|
-
}, jsx(
|
|
47
|
+
}, jsx(FormattedMessage, _extends({}, messages.peopleWhoReactedSubheading, {
|
|
48
|
+
values: {
|
|
49
|
+
emojiShortName
|
|
50
|
+
}
|
|
51
|
+
})), jsx(ResourcedEmoji, {
|
|
49
52
|
emojiProvider: emojiProvider,
|
|
50
53
|
emojiId: {
|
|
51
54
|
id: selectedEmojiId,
|
|
52
55
|
shortName: ''
|
|
53
56
|
},
|
|
54
|
-
fitToHeight:
|
|
55
|
-
}), intl.formatMessage(messages.emojiName, {
|
|
56
|
-
emojiName
|
|
57
|
+
fitToHeight: 16
|
|
57
58
|
})), alphabeticalNames.length === 0 ?
|
|
58
59
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
59
60
|
jsx("div", {
|
|
@@ -6,12 +6,18 @@ import { useEffect, useState, useRef, useCallback, useMemo } from 'react';
|
|
|
6
6
|
import { useIntl } from 'react-intl-next';
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { jsx } from '@emotion/react';
|
|
9
|
-
import
|
|
9
|
+
import { Flex, xcss } from '@atlaskit/primitives';
|
|
10
|
+
import Button, { IconButton } from '@atlaskit/button/new';
|
|
10
11
|
import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
|
|
12
|
+
import ChevronLeftIcon from '@atlaskit/icon/utility/chevron-left';
|
|
13
|
+
import ChevronRightIcon from '@atlaskit/icon/utility/chevron-right';
|
|
11
14
|
import { NUMBER_OF_REACTIONS_TO_DISPLAY } from '../../shared/constants';
|
|
12
15
|
import { messages } from '../../shared/i18n';
|
|
13
16
|
import { ReactionsList } from './ReactionsList';
|
|
14
|
-
import { containerStyle
|
|
17
|
+
import { containerStyle } from './styles';
|
|
18
|
+
const fullWidthStyle = xcss({
|
|
19
|
+
width: '100%'
|
|
20
|
+
});
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* Test id for the Reactions modal dialog
|
|
@@ -29,8 +35,10 @@ export const ReactionsDialog = ({
|
|
|
29
35
|
handleCloseReactionsDialog = () => {},
|
|
30
36
|
emojiProvider,
|
|
31
37
|
selectedEmojiId,
|
|
32
|
-
handleSelectReaction = () => {}
|
|
38
|
+
handleSelectReaction = () => {},
|
|
39
|
+
handlePaginationChange = () => {}
|
|
33
40
|
}) => {
|
|
41
|
+
var _currentReactions$;
|
|
34
42
|
const [elementToScroll, setElementToScroll] = useState();
|
|
35
43
|
const [reactionsContainerRef, setReactionsContainerRef] = useState(null);
|
|
36
44
|
const reactionElementsRef = useRef();
|
|
@@ -45,15 +53,35 @@ export const ReactionsDialog = ({
|
|
|
45
53
|
const sortedReactions = useMemo(() => {
|
|
46
54
|
return reactions.sort((a, b) => (b === null || b === void 0 ? void 0 : b.count) - (a === null || a === void 0 ? void 0 : a.count));
|
|
47
55
|
}, [reactions]);
|
|
56
|
+
const maxPages = Math.max(1, Math.ceil(reactions.length / NUMBER_OF_REACTIONS_TO_DISPLAY));
|
|
57
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
58
|
+
const currentReactions = useMemo(() => {
|
|
59
|
+
const start = (currentPage - 1) * NUMBER_OF_REACTIONS_TO_DISPLAY;
|
|
60
|
+
const end = start + NUMBER_OF_REACTIONS_TO_DISPLAY;
|
|
61
|
+
return sortedReactions.slice(start, end);
|
|
62
|
+
}, [sortedReactions, currentPage]);
|
|
63
|
+
const handleNextPage = () => {
|
|
64
|
+
setCurrentPage(prevPage => Math.min(prevPage + 1, maxPages));
|
|
65
|
+
};
|
|
66
|
+
const handlePreviousPage = () => {
|
|
67
|
+
setCurrentPage(prevPage => Math.max(prevPage - 1, 1));
|
|
68
|
+
};
|
|
69
|
+
const firstEmojiOnPage = (_currentReactions$ = currentReactions[0]) === null || _currentReactions$ === void 0 ? void 0 : _currentReactions$.emojiId;
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
// trigger the handler with the first emoji when the page changes
|
|
72
|
+
if (firstEmojiOnPage) {
|
|
73
|
+
handlePaginationChange(firstEmojiOnPage);
|
|
74
|
+
}
|
|
75
|
+
}, [currentPage, firstEmojiOnPage, handlePaginationChange]);
|
|
48
76
|
|
|
49
|
-
/* set Reactions Border Width ,
|
|
77
|
+
/* set Reactions Border Width , 8 Number of reactions to display*/
|
|
50
78
|
const reactionsBorderWidth = useMemo(() => {
|
|
51
79
|
return Math.ceil(reactions.length / NUMBER_OF_REACTIONS_TO_DISPLAY) * 100;
|
|
52
80
|
}, [reactions]);
|
|
53
81
|
|
|
54
82
|
/* Callback from IntersectionObserver to set/unset classNames based on visibility to toggle styles*/
|
|
55
83
|
const handleNavigation = useCallback(entries => {
|
|
56
|
-
entries.forEach(
|
|
84
|
+
entries.forEach(entry => {
|
|
57
85
|
var _dataset;
|
|
58
86
|
const element = entry.target;
|
|
59
87
|
const emojiElement = element === null || element === void 0 ? void 0 : element.querySelector('[data-emoji-id]');
|
|
@@ -121,16 +149,32 @@ export const ReactionsDialog = ({
|
|
|
121
149
|
onClose: handleCloseReactionsDialog,
|
|
122
150
|
height: 600,
|
|
123
151
|
testId: RENDER_MODAL_TESTID
|
|
124
|
-
}, jsx(ModalHeader, null, jsx(
|
|
125
|
-
|
|
126
|
-
|
|
152
|
+
}, jsx(ModalHeader, null, jsx(Flex, {
|
|
153
|
+
direction: "row",
|
|
154
|
+
justifyContent: "space-between",
|
|
155
|
+
alignItems: "center",
|
|
156
|
+
xcss: fullWidthStyle
|
|
157
|
+
}, jsx("div", null, jsx(ModalTitle, null, intl.formatMessage(messages.reactionsCount, {
|
|
127
158
|
count: totalReactionsCount
|
|
159
|
+
}))), jsx(Flex, {
|
|
160
|
+
alignItems: "center",
|
|
161
|
+
gap: "space.100"
|
|
162
|
+
}, jsx(IconButton, {
|
|
163
|
+
isDisabled: currentPage === 1,
|
|
164
|
+
onClick: handlePreviousPage,
|
|
165
|
+
icon: ChevronLeftIcon,
|
|
166
|
+
label: intl.formatMessage(messages.leftNavigateLabel)
|
|
167
|
+
}), jsx(IconButton, {
|
|
168
|
+
onClick: handleNextPage,
|
|
169
|
+
isDisabled: currentPage === maxPages,
|
|
170
|
+
icon: ChevronRightIcon,
|
|
171
|
+
label: intl.formatMessage(messages.rightNavigateLabel)
|
|
128
172
|
})))), jsx(ModalBody, null, jsx("div", {
|
|
129
173
|
css: containerStyle(reactionsBorderWidth),
|
|
130
174
|
ref: setRef
|
|
131
175
|
}, jsx(ReactionsList, {
|
|
132
176
|
initialEmojiId: selectedEmojiId,
|
|
133
|
-
reactions:
|
|
177
|
+
reactions: currentReactions,
|
|
134
178
|
emojiProvider: emojiProvider,
|
|
135
179
|
onReactionChanged: handleSelectReaction
|
|
136
180
|
}))), jsx(ModalFooter, null, jsx(Button, {
|