@atlaskit/reactions 24.0.1 → 24.1.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/reactions
2
2
 
3
+ ## 24.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#106745](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/106745)
8
+ [`d3fc0dc988c34`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d3fc0dc988c34) -
9
+ [ux] UI updates to improve spacing and text appearance. Business logic updates on when to render
10
+ dialog entrypoint
11
+
3
12
  ## 24.0.1
4
13
 
5
14
  ### 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 = "24.0.1";
14
+ var packageVersion = "24.1.0";
15
15
  /**
16
16
  * TODO: move to utility package?
17
17
  * A random sampling function
@@ -7,12 +7,15 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.ReactionsDialog = exports.RENDER_MODAL_TESTID = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
11
  var _react = require("react");
11
12
  var _reactIntlNext = require("react-intl-next");
12
13
  var _react2 = require("@emotion/react");
13
14
  var _primitives = require("@atlaskit/primitives");
14
15
  var _new = _interopRequireWildcard(require("@atlaskit/button/new"));
16
+ var _heading = _interopRequireDefault(require("@atlaskit/heading"));
15
17
  var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
18
+ var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
16
19
  var _chevronLeft = _interopRequireDefault(require("@atlaskit/icon/utility/chevron-left"));
17
20
  var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/utility/chevron-right"));
18
21
  var _constants = require("../../shared/constants");
@@ -29,7 +32,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
29
32
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
30
33
 
31
34
  var fullWidthStyle = (0, _primitives.xcss)({
32
- width: '100%'
35
+ width: '100%',
36
+ padding: 'space.300',
37
+ paddingBlockEnd: 'space.400'
33
38
  });
34
39
 
35
40
  /**
@@ -43,18 +48,69 @@ var getDimensions = function getDimensions(container) {
43
48
  scrollLeft: container === null || container === void 0 ? void 0 : container.scrollLeft
44
49
  };
45
50
  };
46
- var ReactionsDialog = exports.ReactionsDialog = function ReactionsDialog(_ref) {
51
+ var ReactionsDialogModalHeader = function ReactionsDialogModalHeader(_ref) {
52
+ var totalReactionsCount = _ref.totalReactionsCount,
53
+ handlePreviousPage = _ref.handlePreviousPage,
54
+ handleNextPage = _ref.handleNextPage,
55
+ currentPage = _ref.currentPage,
56
+ maxPages = _ref.maxPages;
57
+ var _useModal = (0, _modalDialog.useModal)(),
58
+ titleId = _useModal.titleId;
59
+ var intl = (0, _reactIntlNext.useIntl)();
60
+ var isSinglePage = maxPages === 1;
61
+ var isOnFirstPage = currentPage === 1;
62
+ var isOnLastPage = currentPage === maxPages;
63
+ return (0, _react2.jsx)(_primitives.Flex, {
64
+ direction: "row",
65
+ justifyContent: "space-between",
66
+ alignItems: "center",
67
+ xcss: fullWidthStyle
68
+ }, (0, _react2.jsx)(_heading.default, {
69
+ size: "medium",
70
+ id: titleId
71
+ }, intl.formatMessage(_i18n.messages.reactionsCount, {
72
+ count: totalReactionsCount
73
+ })), !isSinglePage && (0, _react2.jsx)(_primitives.Flex, {
74
+ alignItems: "center",
75
+ gap: "space.100"
76
+ }, (0, _react2.jsx)(_tooltip.default, {
77
+ content: intl.formatMessage(_i18n.messages.leftNavigateLabel),
78
+ canAppear: function canAppear() {
79
+ return !isOnFirstPage;
80
+ }
81
+ }, function (tooltipProps) {
82
+ return (0, _react2.jsx)(_new.IconButton, (0, _extends2.default)({}, tooltipProps, {
83
+ isDisabled: isOnFirstPage,
84
+ onClick: handlePreviousPage,
85
+ icon: _chevronLeft.default,
86
+ label: intl.formatMessage(_i18n.messages.leftNavigateLabel)
87
+ }));
88
+ }), (0, _react2.jsx)(_tooltip.default, {
89
+ content: intl.formatMessage(_i18n.messages.rightNavigateLabel),
90
+ canAppear: function canAppear() {
91
+ return !isOnLastPage;
92
+ }
93
+ }, function (tooltipProps) {
94
+ return (0, _react2.jsx)(_new.IconButton, (0, _extends2.default)({}, tooltipProps, {
95
+ onClick: handleNextPage,
96
+ isDisabled: isOnLastPage,
97
+ icon: _chevronRight.default,
98
+ label: intl.formatMessage(_i18n.messages.rightNavigateLabel)
99
+ }));
100
+ })));
101
+ };
102
+ var ReactionsDialog = exports.ReactionsDialog = function ReactionsDialog(_ref2) {
47
103
  var _currentReactions$;
48
- var _ref$reactions = _ref.reactions,
49
- reactions = _ref$reactions === void 0 ? [] : _ref$reactions,
50
- _ref$handleCloseReact = _ref.handleCloseReactionsDialog,
51
- handleCloseReactionsDialog = _ref$handleCloseReact === void 0 ? function () {} : _ref$handleCloseReact,
52
- emojiProvider = _ref.emojiProvider,
53
- selectedEmojiId = _ref.selectedEmojiId,
54
- _ref$handleSelectReac = _ref.handleSelectReaction,
55
- handleSelectReaction = _ref$handleSelectReac === void 0 ? function () {} : _ref$handleSelectReac,
56
- _ref$handlePagination = _ref.handlePaginationChange,
57
- handlePaginationChange = _ref$handlePagination === void 0 ? function () {} : _ref$handlePagination;
104
+ var _ref2$reactions = _ref2.reactions,
105
+ reactions = _ref2$reactions === void 0 ? [] : _ref2$reactions,
106
+ _ref2$handleCloseReac = _ref2.handleCloseReactionsDialog,
107
+ handleCloseReactionsDialog = _ref2$handleCloseReac === void 0 ? function () {} : _ref2$handleCloseReac,
108
+ emojiProvider = _ref2.emojiProvider,
109
+ selectedEmojiId = _ref2.selectedEmojiId,
110
+ _ref2$handleSelectRea = _ref2.handleSelectReaction,
111
+ handleSelectReaction = _ref2$handleSelectRea === void 0 ? function () {} : _ref2$handleSelectRea,
112
+ _ref2$handlePaginatio = _ref2.handlePaginationChange,
113
+ handlePaginationChange = _ref2$handlePaginatio === void 0 ? function () {} : _ref2$handlePaginatio;
58
114
  var _useState = (0, _react.useState)(),
59
115
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
60
116
  elementToScroll = _useState2[0],
@@ -179,27 +235,16 @@ var ReactionsDialog = exports.ReactionsDialog = function ReactionsDialog(_ref) {
179
235
  onClose: handleCloseReactionsDialog,
180
236
  height: 600,
181
237
  testId: RENDER_MODAL_TESTID
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, {
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)
202
- })))), (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)("div", {
238
+ // eslint-disable-next-line jsx-a11y/no-autofocus
239
+ ,
240
+ autoFocus: false
241
+ }, (0, _react2.jsx)(ReactionsDialogModalHeader, {
242
+ totalReactionsCount: totalReactionsCount,
243
+ maxPages: maxPages,
244
+ handlePreviousPage: handlePreviousPage,
245
+ handleNextPage: handleNextPage,
246
+ currentPage: currentPage
247
+ }), (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)("div", {
203
248
  css: (0, _styles.containerStyle)(reactionsBorderWidth),
204
249
  ref: setRef
205
250
  }, (0, _react2.jsx)(_ReactionsList.ReactionsList, {
@@ -208,8 +253,7 @@ var ReactionsDialog = exports.ReactionsDialog = function ReactionsDialog(_ref) {
208
253
  emojiProvider: emojiProvider,
209
254
  onReactionChanged: handleSelectReaction
210
255
  }))), (0, _react2.jsx)(_modalDialog.ModalFooter, null, (0, _react2.jsx)(_new.default, {
211
- appearance: "primary",
212
- onClick: handleCloseReactionsDialog,
213
- autoFocus: true
256
+ appearance: "subtle",
257
+ onClick: handleCloseReactionsDialog
214
258
  }, intl.formatMessage(_i18n.messages.closeReactionsDialog))));
215
259
  };
@@ -110,7 +110,6 @@ var reactionViewStyle = exports.reactionViewStyle = (0, _react.css)({
110
110
  p: {
111
111
  margin: 0,
112
112
  color: "".concat("var(--ds-text, ".concat(_colors.N800, ")")),
113
- textTransform: 'capitalize',
114
113
  font: "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
115
114
  fontWeight: "var(--ds-font-weight-semibold, 600)",
116
115
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
@@ -293,6 +293,11 @@ var Reactions = exports.Reactions = /*#__PURE__*/_react.default.memo(function (_
293
293
  return reactions.concat(items);
294
294
  }, [quickReactionEmojis, reactions, hideDefaultReactions]);
295
295
  var shouldShowSummaryView = summaryViewEnabled && memorizedReactions.length >= summaryViewThreshold && reactions.length > 0;
296
+
297
+ // criteria to show Reactions Dialog
298
+ var hasEmojiWithFivePlusReactions = reactions.some(function (reaction) {
299
+ return reaction.count >= 5;
300
+ });
296
301
  return (
297
302
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
298
303
  (0, _react2.jsx)("div", {
@@ -345,7 +350,7 @@ var Reactions = exports.Reactions = /*#__PURE__*/_react.default.memo(function (_
345
350
  showOpaqueBackground: showOpaqueBackground,
346
351
  showAddReactionText: showAddReactionText,
347
352
  subtleReactionsSummaryAndPicker: subtleReactionsSummaryAndPicker
348
- }), allowUserDialog && reactions.length > 0 && (0, _react2.jsx)(_tooltip.default, {
353
+ }), allowUserDialog && hasEmojiWithFivePlusReactions && (0, _react2.jsx)(_tooltip.default, {
349
354
  content: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _i18n.messages.seeWhoReactedTooltip),
350
355
  hideTooltipOnClick: true
351
356
  }, (0, _react2.jsx)(_standardButton.default
@@ -53,7 +53,7 @@ var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
53
53
  },
54
54
  reactionsCount: {
55
55
  id: 'reactions.dialog.reactions.count',
56
- defaultMessage: "{count, plural,\n one {# reaction}\n other {# reactions}\n }",
56
+ defaultMessage: "{count, plural,\n one {# total reaction}\n other {# total reactions}\n }",
57
57
  description: 'The count of Reactions displayed in Reactions Dialog'
58
58
  },
59
59
  leftNavigateLabel: {
@@ -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 = "24.0.1";
4
+ const packageVersion = "24.1.0";
5
5
  /**
6
6
  * TODO: move to utility package?
7
7
  * A random sampling function
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  /**
2
3
  * @jsxRuntime classic
3
4
  * @jsx jsx
@@ -8,7 +9,9 @@ import { useIntl } from 'react-intl-next';
8
9
  import { jsx } from '@emotion/react';
9
10
  import { Flex, xcss } from '@atlaskit/primitives';
10
11
  import Button, { IconButton } from '@atlaskit/button/new';
11
- import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
12
+ import Heading from '@atlaskit/heading';
13
+ import Modal, { ModalBody, ModalFooter, useModal } from '@atlaskit/modal-dialog';
14
+ import Tooltip from '@atlaskit/tooltip';
12
15
  import ChevronLeftIcon from '@atlaskit/icon/utility/chevron-left';
13
16
  import ChevronRightIcon from '@atlaskit/icon/utility/chevron-right';
14
17
  import { NUMBER_OF_REACTIONS_TO_DISPLAY } from '../../shared/constants';
@@ -16,7 +19,9 @@ import { messages } from '../../shared/i18n';
16
19
  import { ReactionsList } from './ReactionsList';
17
20
  import { containerStyle } from './styles';
18
21
  const fullWidthStyle = xcss({
19
- width: '100%'
22
+ width: '100%',
23
+ padding: 'space.300',
24
+ paddingBlockEnd: 'space.400'
20
25
  });
21
26
 
22
27
  /**
@@ -30,6 +35,51 @@ const getDimensions = container => {
30
35
  scrollLeft: container === null || container === void 0 ? void 0 : container.scrollLeft
31
36
  };
32
37
  };
38
+ const ReactionsDialogModalHeader = ({
39
+ totalReactionsCount,
40
+ handlePreviousPage,
41
+ handleNextPage,
42
+ currentPage,
43
+ maxPages
44
+ }) => {
45
+ const {
46
+ titleId
47
+ } = useModal();
48
+ const intl = useIntl();
49
+ const isSinglePage = maxPages === 1;
50
+ const isOnFirstPage = currentPage === 1;
51
+ const isOnLastPage = currentPage === maxPages;
52
+ return jsx(Flex, {
53
+ direction: "row",
54
+ justifyContent: "space-between",
55
+ alignItems: "center",
56
+ xcss: fullWidthStyle
57
+ }, jsx(Heading, {
58
+ size: "medium",
59
+ id: titleId
60
+ }, intl.formatMessage(messages.reactionsCount, {
61
+ count: totalReactionsCount
62
+ })), !isSinglePage && jsx(Flex, {
63
+ alignItems: "center",
64
+ gap: "space.100"
65
+ }, jsx(Tooltip, {
66
+ content: intl.formatMessage(messages.leftNavigateLabel),
67
+ canAppear: () => !isOnFirstPage
68
+ }, tooltipProps => jsx(IconButton, _extends({}, tooltipProps, {
69
+ isDisabled: isOnFirstPage,
70
+ onClick: handlePreviousPage,
71
+ icon: ChevronLeftIcon,
72
+ label: intl.formatMessage(messages.leftNavigateLabel)
73
+ }))), jsx(Tooltip, {
74
+ content: intl.formatMessage(messages.rightNavigateLabel),
75
+ canAppear: () => !isOnLastPage
76
+ }, tooltipProps => jsx(IconButton, _extends({}, tooltipProps, {
77
+ onClick: handleNextPage,
78
+ isDisabled: isOnLastPage,
79
+ icon: ChevronRightIcon,
80
+ label: intl.formatMessage(messages.rightNavigateLabel)
81
+ })))));
82
+ };
33
83
  export const ReactionsDialog = ({
34
84
  reactions = [],
35
85
  handleCloseReactionsDialog = () => {},
@@ -149,27 +199,16 @@ export const ReactionsDialog = ({
149
199
  onClose: handleCloseReactionsDialog,
150
200
  height: 600,
151
201
  testId: RENDER_MODAL_TESTID
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, {
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)
172
- })))), jsx(ModalBody, null, jsx("div", {
202
+ // eslint-disable-next-line jsx-a11y/no-autofocus
203
+ ,
204
+ autoFocus: false
205
+ }, jsx(ReactionsDialogModalHeader, {
206
+ totalReactionsCount: totalReactionsCount,
207
+ maxPages: maxPages,
208
+ handlePreviousPage: handlePreviousPage,
209
+ handleNextPage: handleNextPage,
210
+ currentPage: currentPage
211
+ }), jsx(ModalBody, null, jsx("div", {
173
212
  css: containerStyle(reactionsBorderWidth),
174
213
  ref: setRef
175
214
  }, jsx(ReactionsList, {
@@ -178,8 +217,7 @@ export const ReactionsDialog = ({
178
217
  emojiProvider: emojiProvider,
179
218
  onReactionChanged: handleSelectReaction
180
219
  }))), jsx(ModalFooter, null, jsx(Button, {
181
- appearance: "primary",
182
- onClick: handleCloseReactionsDialog,
183
- autoFocus: true
220
+ appearance: "subtle",
221
+ onClick: handleCloseReactionsDialog
184
222
  }, intl.formatMessage(messages.closeReactionsDialog))));
185
223
  };
@@ -97,7 +97,6 @@ export const reactionViewStyle = css({
97
97
  p: {
98
98
  margin: 0,
99
99
  color: `${`var(--ds-text, ${N800})`}`,
100
- textTransform: 'capitalize',
101
100
  font: "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
102
101
  fontWeight: "var(--ds-font-weight-semibold, 600)",
103
102
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
@@ -258,6 +258,9 @@ export const Reactions = /*#__PURE__*/React.memo(({
258
258
  return reactions.concat(items);
259
259
  }, [quickReactionEmojis, reactions, hideDefaultReactions]);
260
260
  const shouldShowSummaryView = summaryViewEnabled && memorizedReactions.length >= summaryViewThreshold && reactions.length > 0;
261
+
262
+ // criteria to show Reactions Dialog
263
+ const hasEmojiWithFivePlusReactions = reactions.some(reaction => reaction.count >= 5);
261
264
  return (
262
265
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
263
266
  jsx("div", {
@@ -308,7 +311,7 @@ export const Reactions = /*#__PURE__*/React.memo(({
308
311
  showOpaqueBackground: showOpaqueBackground,
309
312
  showAddReactionText: showAddReactionText,
310
313
  subtleReactionsSummaryAndPicker: subtleReactionsSummaryAndPicker
311
- }), allowUserDialog && reactions.length > 0 && jsx(Tooltip, {
314
+ }), allowUserDialog && hasEmojiWithFivePlusReactions && jsx(Tooltip, {
312
315
  content: jsx(FormattedMessage, messages.seeWhoReactedTooltip),
313
316
  hideTooltipOnClick: true
314
317
  }, jsx(Button
@@ -48,8 +48,8 @@ export const messages = defineMessages({
48
48
  reactionsCount: {
49
49
  id: 'reactions.dialog.reactions.count',
50
50
  defaultMessage: `{count, plural,
51
- one {# reaction}
52
- other {# reactions}
51
+ one {# total reaction}
52
+ other {# total reactions}
53
53
  }`,
54
54
  description: 'The count of Reactions displayed in Reactions Dialog'
55
55
  },
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { createAndFireEvent } from '@atlaskit/analytics-next';
5
5
  import { UI_EVENT_TYPE, OPERATIONAL_EVENT_TYPE } from '@atlaskit/analytics-gas-types';
6
6
  var packageName = "@atlaskit/reactions";
7
- var packageVersion = "24.0.1";
7
+ var packageVersion = "24.1.0";
8
8
  /**
9
9
  * TODO: move to utility package?
10
10
  * A random sampling function
@@ -1,4 +1,5 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _extends from "@babel/runtime/helpers/extends";
2
3
  /**
3
4
  * @jsxRuntime classic
4
5
  * @jsx jsx
@@ -9,7 +10,9 @@ import { useIntl } from 'react-intl-next';
9
10
  import { jsx } from '@emotion/react';
10
11
  import { Flex, xcss } from '@atlaskit/primitives';
11
12
  import Button, { IconButton } from '@atlaskit/button/new';
12
- import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
13
+ import Heading from '@atlaskit/heading';
14
+ import Modal, { ModalBody, ModalFooter, useModal } from '@atlaskit/modal-dialog';
15
+ import Tooltip from '@atlaskit/tooltip';
13
16
  import ChevronLeftIcon from '@atlaskit/icon/utility/chevron-left';
14
17
  import ChevronRightIcon from '@atlaskit/icon/utility/chevron-right';
15
18
  import { NUMBER_OF_REACTIONS_TO_DISPLAY } from '../../shared/constants';
@@ -17,7 +20,9 @@ import { messages } from '../../shared/i18n';
17
20
  import { ReactionsList } from './ReactionsList';
18
21
  import { containerStyle } from './styles';
19
22
  var fullWidthStyle = xcss({
20
- width: '100%'
23
+ width: '100%',
24
+ padding: 'space.300',
25
+ paddingBlockEnd: 'space.400'
21
26
  });
22
27
 
23
28
  /**
@@ -31,18 +36,69 @@ var getDimensions = function getDimensions(container) {
31
36
  scrollLeft: container === null || container === void 0 ? void 0 : container.scrollLeft
32
37
  };
33
38
  };
34
- export var ReactionsDialog = function ReactionsDialog(_ref) {
39
+ var ReactionsDialogModalHeader = function ReactionsDialogModalHeader(_ref) {
40
+ var totalReactionsCount = _ref.totalReactionsCount,
41
+ handlePreviousPage = _ref.handlePreviousPage,
42
+ handleNextPage = _ref.handleNextPage,
43
+ currentPage = _ref.currentPage,
44
+ maxPages = _ref.maxPages;
45
+ var _useModal = useModal(),
46
+ titleId = _useModal.titleId;
47
+ var intl = useIntl();
48
+ var isSinglePage = maxPages === 1;
49
+ var isOnFirstPage = currentPage === 1;
50
+ var isOnLastPage = currentPage === maxPages;
51
+ return jsx(Flex, {
52
+ direction: "row",
53
+ justifyContent: "space-between",
54
+ alignItems: "center",
55
+ xcss: fullWidthStyle
56
+ }, jsx(Heading, {
57
+ size: "medium",
58
+ id: titleId
59
+ }, intl.formatMessage(messages.reactionsCount, {
60
+ count: totalReactionsCount
61
+ })), !isSinglePage && jsx(Flex, {
62
+ alignItems: "center",
63
+ gap: "space.100"
64
+ }, jsx(Tooltip, {
65
+ content: intl.formatMessage(messages.leftNavigateLabel),
66
+ canAppear: function canAppear() {
67
+ return !isOnFirstPage;
68
+ }
69
+ }, function (tooltipProps) {
70
+ return jsx(IconButton, _extends({}, tooltipProps, {
71
+ isDisabled: isOnFirstPage,
72
+ onClick: handlePreviousPage,
73
+ icon: ChevronLeftIcon,
74
+ label: intl.formatMessage(messages.leftNavigateLabel)
75
+ }));
76
+ }), jsx(Tooltip, {
77
+ content: intl.formatMessage(messages.rightNavigateLabel),
78
+ canAppear: function canAppear() {
79
+ return !isOnLastPage;
80
+ }
81
+ }, function (tooltipProps) {
82
+ return jsx(IconButton, _extends({}, tooltipProps, {
83
+ onClick: handleNextPage,
84
+ isDisabled: isOnLastPage,
85
+ icon: ChevronRightIcon,
86
+ label: intl.formatMessage(messages.rightNavigateLabel)
87
+ }));
88
+ })));
89
+ };
90
+ export var ReactionsDialog = function ReactionsDialog(_ref2) {
35
91
  var _currentReactions$;
36
- var _ref$reactions = _ref.reactions,
37
- reactions = _ref$reactions === void 0 ? [] : _ref$reactions,
38
- _ref$handleCloseReact = _ref.handleCloseReactionsDialog,
39
- handleCloseReactionsDialog = _ref$handleCloseReact === void 0 ? function () {} : _ref$handleCloseReact,
40
- emojiProvider = _ref.emojiProvider,
41
- selectedEmojiId = _ref.selectedEmojiId,
42
- _ref$handleSelectReac = _ref.handleSelectReaction,
43
- handleSelectReaction = _ref$handleSelectReac === void 0 ? function () {} : _ref$handleSelectReac,
44
- _ref$handlePagination = _ref.handlePaginationChange,
45
- handlePaginationChange = _ref$handlePagination === void 0 ? function () {} : _ref$handlePagination;
92
+ var _ref2$reactions = _ref2.reactions,
93
+ reactions = _ref2$reactions === void 0 ? [] : _ref2$reactions,
94
+ _ref2$handleCloseReac = _ref2.handleCloseReactionsDialog,
95
+ handleCloseReactionsDialog = _ref2$handleCloseReac === void 0 ? function () {} : _ref2$handleCloseReac,
96
+ emojiProvider = _ref2.emojiProvider,
97
+ selectedEmojiId = _ref2.selectedEmojiId,
98
+ _ref2$handleSelectRea = _ref2.handleSelectReaction,
99
+ handleSelectReaction = _ref2$handleSelectRea === void 0 ? function () {} : _ref2$handleSelectRea,
100
+ _ref2$handlePaginatio = _ref2.handlePaginationChange,
101
+ handlePaginationChange = _ref2$handlePaginatio === void 0 ? function () {} : _ref2$handlePaginatio;
46
102
  var _useState = useState(),
47
103
  _useState2 = _slicedToArray(_useState, 2),
48
104
  elementToScroll = _useState2[0],
@@ -167,27 +223,16 @@ export var ReactionsDialog = function ReactionsDialog(_ref) {
167
223
  onClose: handleCloseReactionsDialog,
168
224
  height: 600,
169
225
  testId: RENDER_MODAL_TESTID
170
- }, jsx(ModalHeader, null, jsx(Flex, {
171
- direction: "row",
172
- justifyContent: "space-between",
173
- alignItems: "center",
174
- xcss: fullWidthStyle
175
- }, jsx("div", null, jsx(ModalTitle, null, intl.formatMessage(messages.reactionsCount, {
176
- count: totalReactionsCount
177
- }))), jsx(Flex, {
178
- alignItems: "center",
179
- gap: "space.100"
180
- }, jsx(IconButton, {
181
- isDisabled: currentPage === 1,
182
- onClick: handlePreviousPage,
183
- icon: ChevronLeftIcon,
184
- label: intl.formatMessage(messages.leftNavigateLabel)
185
- }), jsx(IconButton, {
186
- onClick: handleNextPage,
187
- isDisabled: currentPage === maxPages,
188
- icon: ChevronRightIcon,
189
- label: intl.formatMessage(messages.rightNavigateLabel)
190
- })))), jsx(ModalBody, null, jsx("div", {
226
+ // eslint-disable-next-line jsx-a11y/no-autofocus
227
+ ,
228
+ autoFocus: false
229
+ }, jsx(ReactionsDialogModalHeader, {
230
+ totalReactionsCount: totalReactionsCount,
231
+ maxPages: maxPages,
232
+ handlePreviousPage: handlePreviousPage,
233
+ handleNextPage: handleNextPage,
234
+ currentPage: currentPage
235
+ }), jsx(ModalBody, null, jsx("div", {
191
236
  css: containerStyle(reactionsBorderWidth),
192
237
  ref: setRef
193
238
  }, jsx(ReactionsList, {
@@ -196,8 +241,7 @@ export var ReactionsDialog = function ReactionsDialog(_ref) {
196
241
  emojiProvider: emojiProvider,
197
242
  onReactionChanged: handleSelectReaction
198
243
  }))), jsx(ModalFooter, null, jsx(Button, {
199
- appearance: "primary",
200
- onClick: handleCloseReactionsDialog,
201
- autoFocus: true
244
+ appearance: "subtle",
245
+ onClick: handleCloseReactionsDialog
202
246
  }, intl.formatMessage(messages.closeReactionsDialog))));
203
247
  };
@@ -103,7 +103,6 @@ export var reactionViewStyle = css({
103
103
  p: {
104
104
  margin: 0,
105
105
  color: "".concat("var(--ds-text, ".concat(N800, ")")),
106
- textTransform: 'capitalize',
107
106
  font: "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
108
107
  fontWeight: "var(--ds-font-weight-semibold, 600)",
109
108
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
@@ -280,6 +280,11 @@ export var Reactions = /*#__PURE__*/React.memo(function (_ref) {
280
280
  return reactions.concat(items);
281
281
  }, [quickReactionEmojis, reactions, hideDefaultReactions]);
282
282
  var shouldShowSummaryView = summaryViewEnabled && memorizedReactions.length >= summaryViewThreshold && reactions.length > 0;
283
+
284
+ // criteria to show Reactions Dialog
285
+ var hasEmojiWithFivePlusReactions = reactions.some(function (reaction) {
286
+ return reaction.count >= 5;
287
+ });
283
288
  return (
284
289
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
285
290
  jsx("div", {
@@ -332,7 +337,7 @@ export var Reactions = /*#__PURE__*/React.memo(function (_ref) {
332
337
  showOpaqueBackground: showOpaqueBackground,
333
338
  showAddReactionText: showAddReactionText,
334
339
  subtleReactionsSummaryAndPicker: subtleReactionsSummaryAndPicker
335
- }), allowUserDialog && reactions.length > 0 && jsx(Tooltip, {
340
+ }), allowUserDialog && hasEmojiWithFivePlusReactions && jsx(Tooltip, {
336
341
  content: jsx(FormattedMessage, messages.seeWhoReactedTooltip),
337
342
  hideTooltipOnClick: true
338
343
  }, jsx(Button
@@ -47,7 +47,7 @@ export var messages = defineMessages({
47
47
  },
48
48
  reactionsCount: {
49
49
  id: 'reactions.dialog.reactions.count',
50
- defaultMessage: "{count, plural,\n one {# reaction}\n other {# reactions}\n }",
50
+ defaultMessage: "{count, plural,\n one {# total reaction}\n other {# total reactions}\n }",
51
51
  description: 'The count of Reactions displayed in Reactions Dialog'
52
52
  },
53
53
  leftNavigateLabel: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/reactions",
3
- "version": "24.0.1",
3
+ "version": "24.1.0",
4
4
  "description": "Reactions component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"