@atlaskit/profilecard 19.10.0 → 19.11.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/profilecard
2
2
 
3
+ ## 19.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#73706](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/73706) [`3a5408573683`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3a5408573683) - Fix bug causing profilecard to disappear early in some circumstances
8
+
9
+ ## 19.11.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#72021](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72021) [`bfb147303ac8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bfb147303ac8) - Pass fullName props to ProfileCardTrigger, and update aria-label message
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 19.10.0
4
20
 
5
21
  ### Minor Changes
@@ -57,7 +57,7 @@ var addHeaders = exports.addHeaders = function addHeaders(headers) {
57
57
  headers.append('X-ExperimentalApi', 'teams-beta');
58
58
  headers.append('X-ExperimentalApi', 'team-members-beta');
59
59
  headers.append('atl-client-name', "@atlaskit/profilecard");
60
- headers.append('atl-client-version', "19.10.0");
60
+ headers.append('atl-client-version', "19.11.1");
61
61
  return headers;
62
62
  };
63
63
  function getTeamFromAGG(_x, _x2, _x3) {
@@ -154,12 +154,6 @@ var Actions = function Actions(_ref) {
154
154
  action.callback.apply(action, [event].concat((0, _toConsumableArray2.default)(args)));
155
155
  }
156
156
  }, [fireAnalyticsWithDuration]);
157
- var buttonRef = (0, _react.useRef)(null);
158
- (0, _react.useEffect)(function () {
159
- if (actions.length > 0 && buttonRef.current && isTriggeredUsingKeyboard) {
160
- buttonRef.current.focus();
161
- }
162
- }, [isTriggeredUsingKeyboard, actions.length]);
163
157
  if (!actions || actions.length === 0) {
164
158
  return null;
165
159
  }
@@ -182,7 +176,7 @@ var Actions = function Actions(_ref) {
182
176
  return onActionClick(action, args, event, index);
183
177
  },
184
178
  href: action.link,
185
- ref: index === 0 ? buttonRef : undefined
179
+ autoFocus: index === 0 && isTriggeredUsingKeyboard
186
180
  }, action.label, isKudos && /*#__PURE__*/_react.default.createElement(_Card.AnimationWrapper, null, /*#__PURE__*/_react.default.createElement(_Card.KudosBlobAnimation, null))));
187
181
  if (isKudos) {
188
182
  return /*#__PURE__*/_react.default.createElement(_Card.AnimatedKudosButton, {
@@ -14,11 +14,13 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
14
14
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
15
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
16
16
  var _react = _interopRequireWildcard(require("react"));
17
+ var _reactIntlNext = require("react-intl-next");
17
18
  var _analyticsNext = require("@atlaskit/analytics-next");
18
19
  var _giveKudos = require("@atlaskit/give-kudos");
19
20
  var _popup = _interopRequireDefault(require("@atlaskit/popup"));
20
21
  var _constants = require("@atlaskit/theme/constants");
21
22
  var _filterActions = _interopRequireDefault(require("../../internal/filterActions"));
23
+ var _getLabelMessage = _interopRequireDefault(require("../../internal/getLabelMessage"));
22
24
  var _Card = require("../../styled/Card");
23
25
  var _analytics = require("../../util/analytics");
24
26
  var _config = require("../../util/config");
@@ -44,70 +46,67 @@ function ProfilecardTriggerNext(_ref) {
44
46
  addFlag = _ref.addFlag,
45
47
  onReportingLinesClick = _ref.onReportingLinesClick,
46
48
  ariaLabel = _ref.ariaLabel,
47
- ariaLabelledBy = _ref.ariaLabelledBy;
49
+ ariaLabelledBy = _ref.ariaLabelledBy,
50
+ prepopulatedData = _ref.prepopulatedData;
48
51
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
49
52
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
53
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
54
+ formatMessage = _useIntl.formatMessage;
50
55
  var _useState = (0, _react.useState)(false),
51
56
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
52
57
  isMounted = _useState2[0],
53
58
  setIsMounted = _useState2[1];
54
59
  var showDelay = trigger === 'click' ? 0 : _config.DELAY_MS_SHOW;
55
60
  var hideDelay = trigger === 'click' ? 0 : _config.DELAY_MS_HIDE;
56
- var _useState3 = (0, _react.useState)(0),
61
+ var showTimer = (0, _react.useRef)(0);
62
+ var hideTimer = (0, _react.useRef)(0);
63
+ var _useState3 = (0, _react.useState)(false),
57
64
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
58
- showTimer = _useState4[0],
59
- setShowTimer = _useState4[1];
60
- var _useState5 = (0, _react.useState)(0),
65
+ visible = _useState4[0],
66
+ setVisible = _useState4[1];
67
+ var _useState5 = (0, _react.useState)(undefined),
61
68
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
62
- hideTimer = _useState6[0],
63
- setHideTimer = _useState6[1];
69
+ isLoading = _useState6[0],
70
+ setIsLoading = _useState6[1];
64
71
  var _useState7 = (0, _react.useState)(false),
65
72
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
66
- visible = _useState8[0],
67
- setVisible = _useState8[1];
68
- var _useState9 = (0, _react.useState)(undefined),
73
+ hasError = _useState8[0],
74
+ setHasError = _useState8[1];
75
+ var _useState9 = (0, _react.useState)(null),
69
76
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
70
- isLoading = _useState10[0],
71
- setIsLoading = _useState10[1];
72
- var _useState11 = (0, _react.useState)(false),
77
+ error = _useState10[0],
78
+ setError = _useState10[1];
79
+ var _useState11 = (0, _react.useState)(null),
73
80
  _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
74
- hasError = _useState12[0],
75
- setHasError = _useState12[1];
76
- var _useState13 = (0, _react.useState)(null),
81
+ data = _useState12[0],
82
+ setData = _useState12[1];
83
+ var _useState13 = (0, _react.useState)(undefined),
77
84
  _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
78
- error = _useState14[0],
79
- setError = _useState14[1];
80
- var _useState15 = (0, _react.useState)(null),
85
+ reportingLinesData = _useState14[0],
86
+ setReportingLinesData = _useState14[1];
87
+ var _useState15 = (0, _react.useState)(false),
81
88
  _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
82
- data = _useState16[0],
83
- setData = _useState16[1];
89
+ shouldShowGiveKudos = _useState16[0],
90
+ setShouldShowGiveKudos = _useState16[1];
84
91
  var _useState17 = (0, _react.useState)(undefined),
85
92
  _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
86
- reportingLinesData = _useState18[0],
87
- setReportingLinesData = _useState18[1];
93
+ teamCentralBaseUrl = _useState18[0],
94
+ setTeamCentralBaseUrl = _useState18[1];
88
95
  var _useState19 = (0, _react.useState)(false),
89
96
  _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
90
- shouldShowGiveKudos = _useState20[0],
91
- setShouldShowGiveKudos = _useState20[1];
92
- var _useState21 = (0, _react.useState)(undefined),
97
+ kudosDrawerOpen = _useState20[0],
98
+ setKudosDrawerOpen = _useState20[1];
99
+ var _useState21 = (0, _react.useState)(false),
93
100
  _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
94
- teamCentralBaseUrl = _useState22[0],
95
- setTeamCentralBaseUrl = _useState22[1];
96
- var _useState23 = (0, _react.useState)(false),
97
- _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
98
- kudosDrawerOpen = _useState24[0],
99
- setKudosDrawerOpen = _useState24[1];
100
- var _useState25 = (0, _react.useState)(false),
101
- _useState26 = (0, _slicedToArray2.default)(_useState25, 2),
102
- isTriggeredUsingKeyboard = _useState26[0],
103
- setTriggeredUsingKeyboard = _useState26[1];
101
+ isTriggeredUsingKeyboard = _useState22[0],
102
+ setTriggeredUsingKeyboard = _useState22[1];
104
103
  var triggerRef = (0, _react.useRef)(null);
105
104
  (0, _react.useEffect)(function () {
106
105
  setIsMounted(true);
107
106
  return function () {
108
107
  setIsMounted(false);
109
- clearTimeout(showTimer);
110
- clearTimeout(hideTimer);
108
+ clearTimeout(showTimer.current);
109
+ clearTimeout(hideTimer.current);
111
110
  };
112
111
  // eslint-disable-next-line react-hooks/exhaustive-deps
113
112
  }, []);
@@ -129,17 +128,16 @@ function ProfilecardTriggerNext(_ref) {
129
128
  (0, _analytics.fireEvent)(createAnalyticsEvent, payload);
130
129
  }, [createAnalyticsEvent, isMounted]);
131
130
  var hideProfilecard = (0, _react.useCallback)(function () {
132
- clearTimeout(showTimer);
133
- clearTimeout(hideTimer);
131
+ clearTimeout(showTimer.current);
132
+ clearTimeout(hideTimer.current);
134
133
  if (!isTriggeredUsingKeyboard) {
135
- setHideTimer(window.setTimeout(function () {
134
+ hideTimer.current = window.setTimeout(function () {
136
135
  setVisible(false);
137
- }, hideDelay));
136
+ }, hideDelay);
138
137
  }
139
- setTriggeredUsingKeyboard(false);
140
- }, [hideDelay, hideTimer, showTimer, isTriggeredUsingKeyboard]);
138
+ }, [hideDelay, isTriggeredUsingKeyboard]);
141
139
  var handleKeyboardClose = (0, _react.useCallback)(function (event) {
142
- if (event.key !== 'Escape') {
140
+ if (event.key && event.key !== 'Escape') {
143
141
  return;
144
142
  }
145
143
  if (triggerRef.current) {
@@ -202,15 +200,15 @@ function ProfilecardTriggerNext(_ref) {
202
200
  }, _callee, null, [[7, 15]]);
203
201
  })), [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
204
202
  var showProfilecard = (0, _react.useCallback)(function () {
205
- clearTimeout(hideTimer);
206
- clearTimeout(showTimer);
207
- setShowTimer(window.setTimeout(function () {
203
+ clearTimeout(hideTimer.current);
204
+ clearTimeout(showTimer.current);
205
+ showTimer.current = window.setTimeout(function () {
208
206
  if (!visible) {
209
207
  void clientFetchProfile();
210
208
  setVisible(true);
211
209
  }
212
- }, showDelay));
213
- }, [hideTimer, showDelay, showTimer, visible, clientFetchProfile]);
210
+ }, showDelay);
211
+ }, [showDelay, visible, clientFetchProfile]);
214
212
  var onClick = (0, _react.useCallback)(function (event) {
215
213
  // If the user clicks on the trigger then we don't want that click event to
216
214
  // propagate out to parent containers. For example when clicking a mention
@@ -271,6 +269,7 @@ function ProfilecardTriggerNext(_ref) {
271
269
  }, [hideProfilecard, onFocus, onMouseEnter, trigger]);
272
270
  var profilecardProps = _objectSpread(_objectSpread({
273
271
  userId: userId,
272
+ fullName: prepopulatedData === null || prepopulatedData === void 0 ? void 0 : prepopulatedData.fullName,
274
273
  isCurrentUser: data === null || data === void 0 ? void 0 : data.isCurrentUser,
275
274
  clientFetchProfile: clientFetchProfile
276
275
  }, data), {}, {
@@ -290,9 +289,9 @@ function ProfilecardTriggerNext(_ref) {
290
289
  },
291
290
  placement: position,
292
291
  content: function content() {
293
- return showLoading ? /*#__PURE__*/_react.default.createElement(LoadingView, {
292
+ return /*#__PURE__*/_react.default.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/_react.default.createElement(LoadingView, {
294
293
  fireAnalytics: fireAnalytics
295
- }) : /*#__PURE__*/_react.default.createElement("div", wrapperProps, visible && /*#__PURE__*/_react.default.createElement(_react.Suspense, {
294
+ }) : visible && /*#__PURE__*/_react.default.createElement(_react.Suspense, {
296
295
  fallback: null
297
296
  }, /*#__PURE__*/_react.default.createElement(_lazyProfileCard.ProfileCardLazy, (0, _extends2.default)({}, profilecardProps, {
298
297
  actions: filterActions(),
@@ -315,7 +314,7 @@ function ProfilecardTriggerNext(_ref) {
315
314
  "data-testid": testId,
316
315
  role: "button",
317
316
  tabIndex: 0,
318
- "aria-label": ariaLabel,
317
+ "aria-label": (0, _getLabelMessage.default)(ariaLabel, profilecardProps.fullName, formatMessage),
319
318
  "aria-labelledby": ariaLabelledBy
320
319
  }), children);
321
320
  },
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactIntlNext = require("react-intl-next");
8
+ var getLabelMessage = function getLabelMessage(ariaLabelProp, fullName, formatMessage) {
9
+ if (ariaLabelProp) {
10
+ return ariaLabelProp;
11
+ }
12
+ return fullName ? formatMessage(messages.label, {
13
+ fullName: fullName
14
+ }) : formatMessage(messages.fallbackLabel);
15
+ };
16
+ var messages = (0, _reactIntlNext.defineMessages)({
17
+ fallbackLabel: {
18
+ id: 'profilecard.user.trigger.fallback-aria-label',
19
+ defaultMessage: 'More information about this user',
20
+ description: 'Label for profile card trigger when we do not have user name'
21
+ },
22
+ label: {
23
+ id: 'profilecard.user.trigger.aria-label',
24
+ defaultMessage: 'More information about {fullName}',
25
+ description: 'Label for profile card trigger'
26
+ }
27
+ });
28
+ var _default = exports.default = getLabelMessage;
@@ -44,7 +44,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
44
44
  actionSubjectId: actionSubjectId,
45
45
  attributes: _objectSpread(_objectSpread({
46
46
  packageName: "@atlaskit/profilecard",
47
- packageVersion: "19.10.0"
47
+ packageVersion: "19.11.1"
48
48
  }, attributes), {}, {
49
49
  firedAt: Math.round((0, _performance.getPageTime)())
50
50
  })
@@ -67,7 +67,7 @@ export const addHeaders = headers => {
67
67
  headers.append('X-ExperimentalApi', 'teams-beta');
68
68
  headers.append('X-ExperimentalApi', 'team-members-beta');
69
69
  headers.append('atl-client-name', "@atlaskit/profilecard");
70
- headers.append('atl-client-version', "19.10.0");
70
+ headers.append('atl-client-version', "19.11.1");
71
71
  return headers;
72
72
  };
73
73
  export async function getTeamFromAGG(url, teamId, siteId) {
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
3
  import { FormattedMessage } from 'react-intl-next';
4
4
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
5
5
  import Avatar from '@atlaskit/avatar';
@@ -140,12 +140,6 @@ const Actions = ({
140
140
  action.callback(event, ...args);
141
141
  }
142
142
  }, [fireAnalyticsWithDuration]);
143
- const buttonRef = useRef(null);
144
- useEffect(() => {
145
- if (actions.length > 0 && buttonRef.current && isTriggeredUsingKeyboard) {
146
- buttonRef.current.focus();
147
- }
148
- }, [isTriggeredUsingKeyboard, actions.length]);
149
143
  if (!actions || actions.length === 0) {
150
144
  return null;
151
145
  }
@@ -163,7 +157,7 @@ const Actions = ({
163
157
  key: action.id || index,
164
158
  onClick: (event, ...args) => onActionClick(action, args, event, index),
165
159
  href: action.link,
166
- ref: index === 0 ? buttonRef : undefined
160
+ autoFocus: index === 0 && isTriggeredUsingKeyboard
167
161
  }, action.label, isKudos && /*#__PURE__*/React.createElement(AnimationWrapper, null, /*#__PURE__*/React.createElement(KudosBlobAnimation, null))));
168
162
  if (isKudos) {
169
163
  return /*#__PURE__*/React.createElement(AnimatedKudosButton, {
@@ -1,10 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
+ import { useIntl } from 'react-intl-next';
3
4
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
5
  import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
5
6
  import Popup from '@atlaskit/popup';
6
7
  import { layers } from '@atlaskit/theme/constants';
7
8
  import filterActionsInner from '../../internal/filterActions';
9
+ import getLabelMessage from '../../internal/getLabelMessage';
8
10
  import { CardWrapper } from '../../styled/Card';
9
11
  import { cardTriggered, fireEvent } from '../../util/analytics';
10
12
  import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
@@ -22,16 +24,20 @@ export default function ProfilecardTriggerNext({
22
24
  addFlag,
23
25
  onReportingLinesClick,
24
26
  ariaLabel,
25
- ariaLabelledBy
27
+ ariaLabelledBy,
28
+ prepopulatedData
26
29
  }) {
27
30
  const {
28
31
  createAnalyticsEvent
29
32
  } = useAnalyticsEvents();
33
+ const {
34
+ formatMessage
35
+ } = useIntl();
30
36
  const [isMounted, setIsMounted] = useState(false);
31
37
  const showDelay = trigger === 'click' ? 0 : DELAY_MS_SHOW;
32
38
  const hideDelay = trigger === 'click' ? 0 : DELAY_MS_HIDE;
33
- const [showTimer, setShowTimer] = useState(0);
34
- const [hideTimer, setHideTimer] = useState(0);
39
+ const showTimer = useRef(0);
40
+ const hideTimer = useRef(0);
35
41
  const [visible, setVisible] = useState(false);
36
42
  const [isLoading, setIsLoading] = useState(undefined);
37
43
  const [hasError, setHasError] = useState(false);
@@ -47,8 +53,8 @@ export default function ProfilecardTriggerNext({
47
53
  setIsMounted(true);
48
54
  return () => {
49
55
  setIsMounted(false);
50
- clearTimeout(showTimer);
51
- clearTimeout(hideTimer);
56
+ clearTimeout(showTimer.current);
57
+ clearTimeout(hideTimer.current);
52
58
  };
53
59
  // eslint-disable-next-line react-hooks/exhaustive-deps
54
60
  }, []);
@@ -70,17 +76,16 @@ export default function ProfilecardTriggerNext({
70
76
  fireEvent(createAnalyticsEvent, payload);
71
77
  }, [createAnalyticsEvent, isMounted]);
72
78
  const hideProfilecard = useCallback(() => {
73
- clearTimeout(showTimer);
74
- clearTimeout(hideTimer);
79
+ clearTimeout(showTimer.current);
80
+ clearTimeout(hideTimer.current);
75
81
  if (!isTriggeredUsingKeyboard) {
76
- setHideTimer(window.setTimeout(() => {
82
+ hideTimer.current = window.setTimeout(() => {
77
83
  setVisible(false);
78
- }, hideDelay));
84
+ }, hideDelay);
79
85
  }
80
- setTriggeredUsingKeyboard(false);
81
- }, [hideDelay, hideTimer, showTimer, isTriggeredUsingKeyboard]);
86
+ }, [hideDelay, isTriggeredUsingKeyboard]);
82
87
  const handleKeyboardClose = useCallback(event => {
83
- if (event.key !== 'Escape') {
88
+ if (event.key && event.key !== 'Escape') {
84
89
  return;
85
90
  }
86
91
  if (triggerRef.current) {
@@ -126,15 +131,15 @@ export default function ProfilecardTriggerNext({
126
131
  }
127
132
  }, [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
128
133
  const showProfilecard = useCallback(() => {
129
- clearTimeout(hideTimer);
130
- clearTimeout(showTimer);
131
- setShowTimer(window.setTimeout(() => {
134
+ clearTimeout(hideTimer.current);
135
+ clearTimeout(showTimer.current);
136
+ showTimer.current = window.setTimeout(() => {
132
137
  if (!visible) {
133
138
  void clientFetchProfile();
134
139
  setVisible(true);
135
140
  }
136
- }, showDelay));
137
- }, [hideTimer, showDelay, showTimer, visible, clientFetchProfile]);
141
+ }, showDelay);
142
+ }, [showDelay, visible, clientFetchProfile]);
138
143
  const onClick = useCallback(event => {
139
144
  // If the user clicks on the trigger then we don't want that click event to
140
145
  // propagate out to parent containers. For example when clicking a mention
@@ -191,6 +196,7 @@ export default function ProfilecardTriggerNext({
191
196
  } : {}, [hideProfilecard, onFocus, onMouseEnter, trigger]);
192
197
  const profilecardProps = {
193
198
  userId: userId,
199
+ fullName: prepopulatedData === null || prepopulatedData === void 0 ? void 0 : prepopulatedData.fullName,
194
200
  isCurrentUser: data === null || data === void 0 ? void 0 : data.isCurrentUser,
195
201
  clientFetchProfile: clientFetchProfile,
196
202
  ...data,
@@ -209,9 +215,9 @@ export default function ProfilecardTriggerNext({
209
215
  handleKeyboardClose(event);
210
216
  },
211
217
  placement: position,
212
- content: () => showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
218
+ content: () => /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
213
219
  fireAnalytics: fireAnalytics
214
- }) : /*#__PURE__*/React.createElement("div", wrapperProps, visible && /*#__PURE__*/React.createElement(Suspense, {
220
+ }) : visible && /*#__PURE__*/React.createElement(Suspense, {
215
221
  fallback: null
216
222
  }, /*#__PURE__*/React.createElement(ProfileCardLazy, _extends({}, profilecardProps, {
217
223
  actions: filterActions(),
@@ -235,7 +241,7 @@ export default function ProfilecardTriggerNext({
235
241
  "data-testid": testId,
236
242
  role: "button",
237
243
  tabIndex: 0,
238
- "aria-label": ariaLabel,
244
+ "aria-label": getLabelMessage(ariaLabel, profilecardProps.fullName, formatMessage),
239
245
  "aria-labelledby": ariaLabelledBy
240
246
  }), children);
241
247
  },
@@ -0,0 +1,22 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ const getLabelMessage = (ariaLabelProp, fullName, formatMessage) => {
3
+ if (ariaLabelProp) {
4
+ return ariaLabelProp;
5
+ }
6
+ return fullName ? formatMessage(messages.label, {
7
+ fullName
8
+ }) : formatMessage(messages.fallbackLabel);
9
+ };
10
+ const messages = defineMessages({
11
+ fallbackLabel: {
12
+ id: 'profilecard.user.trigger.fallback-aria-label',
13
+ defaultMessage: 'More information about this user',
14
+ description: 'Label for profile card trigger when we do not have user name'
15
+ },
16
+ label: {
17
+ id: 'profilecard.user.trigger.aria-label',
18
+ defaultMessage: 'More information about {fullName}',
19
+ description: 'Label for profile card trigger'
20
+ }
21
+ });
22
+ export default getLabelMessage;
@@ -31,7 +31,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
31
31
  actionSubjectId,
32
32
  attributes: {
33
33
  packageName: "@atlaskit/profilecard",
34
- packageVersion: "19.10.0",
34
+ packageVersion: "19.11.1",
35
35
  ...attributes,
36
36
  firedAt: Math.round(getPageTime())
37
37
  }
@@ -48,7 +48,7 @@ export var addHeaders = function addHeaders(headers) {
48
48
  headers.append('X-ExperimentalApi', 'teams-beta');
49
49
  headers.append('X-ExperimentalApi', 'team-members-beta');
50
50
  headers.append('atl-client-name', "@atlaskit/profilecard");
51
- headers.append('atl-client-version', "19.10.0");
51
+ headers.append('atl-client-version', "19.11.1");
52
52
  return headers;
53
53
  };
54
54
  export function getTeamFromAGG(_x, _x2, _x3) {
@@ -1,7 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
5
5
  import { FormattedMessage } from 'react-intl-next';
6
6
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
7
  import Avatar from '@atlaskit/avatar';
@@ -144,12 +144,6 @@ var Actions = function Actions(_ref) {
144
144
  action.callback.apply(action, [event].concat(_toConsumableArray(args)));
145
145
  }
146
146
  }, [fireAnalyticsWithDuration]);
147
- var buttonRef = useRef(null);
148
- useEffect(function () {
149
- if (actions.length > 0 && buttonRef.current && isTriggeredUsingKeyboard) {
150
- buttonRef.current.focus();
151
- }
152
- }, [isTriggeredUsingKeyboard, actions.length]);
153
147
  if (!actions || actions.length === 0) {
154
148
  return null;
155
149
  }
@@ -172,7 +166,7 @@ var Actions = function Actions(_ref) {
172
166
  return onActionClick(action, args, event, index);
173
167
  },
174
168
  href: action.link,
175
- ref: index === 0 ? buttonRef : undefined
169
+ autoFocus: index === 0 && isTriggeredUsingKeyboard
176
170
  }, action.label, isKudos && /*#__PURE__*/React.createElement(AnimationWrapper, null, /*#__PURE__*/React.createElement(KudosBlobAnimation, null))));
177
171
  if (isKudos) {
178
172
  return /*#__PURE__*/React.createElement(AnimatedKudosButton, {
@@ -9,11 +9,13 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
9
9
  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) { _defineProperty(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; }
10
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
11
11
  import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
12
+ import { useIntl } from 'react-intl-next';
12
13
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
13
14
  import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
14
15
  import Popup from '@atlaskit/popup';
15
16
  import { layers } from '@atlaskit/theme/constants';
16
17
  import filterActionsInner from '../../internal/filterActions';
18
+ import getLabelMessage from '../../internal/getLabelMessage';
17
19
  import { CardWrapper } from '../../styled/Card';
18
20
  import { cardTriggered, fireEvent } from '../../util/analytics';
19
21
  import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
@@ -34,70 +36,67 @@ export default function ProfilecardTriggerNext(_ref) {
34
36
  addFlag = _ref.addFlag,
35
37
  onReportingLinesClick = _ref.onReportingLinesClick,
36
38
  ariaLabel = _ref.ariaLabel,
37
- ariaLabelledBy = _ref.ariaLabelledBy;
39
+ ariaLabelledBy = _ref.ariaLabelledBy,
40
+ prepopulatedData = _ref.prepopulatedData;
38
41
  var _useAnalyticsEvents = useAnalyticsEvents(),
39
42
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
43
+ var _useIntl = useIntl(),
44
+ formatMessage = _useIntl.formatMessage;
40
45
  var _useState = useState(false),
41
46
  _useState2 = _slicedToArray(_useState, 2),
42
47
  isMounted = _useState2[0],
43
48
  setIsMounted = _useState2[1];
44
49
  var showDelay = trigger === 'click' ? 0 : DELAY_MS_SHOW;
45
50
  var hideDelay = trigger === 'click' ? 0 : DELAY_MS_HIDE;
46
- var _useState3 = useState(0),
51
+ var showTimer = useRef(0);
52
+ var hideTimer = useRef(0);
53
+ var _useState3 = useState(false),
47
54
  _useState4 = _slicedToArray(_useState3, 2),
48
- showTimer = _useState4[0],
49
- setShowTimer = _useState4[1];
50
- var _useState5 = useState(0),
55
+ visible = _useState4[0],
56
+ setVisible = _useState4[1];
57
+ var _useState5 = useState(undefined),
51
58
  _useState6 = _slicedToArray(_useState5, 2),
52
- hideTimer = _useState6[0],
53
- setHideTimer = _useState6[1];
59
+ isLoading = _useState6[0],
60
+ setIsLoading = _useState6[1];
54
61
  var _useState7 = useState(false),
55
62
  _useState8 = _slicedToArray(_useState7, 2),
56
- visible = _useState8[0],
57
- setVisible = _useState8[1];
58
- var _useState9 = useState(undefined),
63
+ hasError = _useState8[0],
64
+ setHasError = _useState8[1];
65
+ var _useState9 = useState(null),
59
66
  _useState10 = _slicedToArray(_useState9, 2),
60
- isLoading = _useState10[0],
61
- setIsLoading = _useState10[1];
62
- var _useState11 = useState(false),
67
+ error = _useState10[0],
68
+ setError = _useState10[1];
69
+ var _useState11 = useState(null),
63
70
  _useState12 = _slicedToArray(_useState11, 2),
64
- hasError = _useState12[0],
65
- setHasError = _useState12[1];
66
- var _useState13 = useState(null),
71
+ data = _useState12[0],
72
+ setData = _useState12[1];
73
+ var _useState13 = useState(undefined),
67
74
  _useState14 = _slicedToArray(_useState13, 2),
68
- error = _useState14[0],
69
- setError = _useState14[1];
70
- var _useState15 = useState(null),
75
+ reportingLinesData = _useState14[0],
76
+ setReportingLinesData = _useState14[1];
77
+ var _useState15 = useState(false),
71
78
  _useState16 = _slicedToArray(_useState15, 2),
72
- data = _useState16[0],
73
- setData = _useState16[1];
79
+ shouldShowGiveKudos = _useState16[0],
80
+ setShouldShowGiveKudos = _useState16[1];
74
81
  var _useState17 = useState(undefined),
75
82
  _useState18 = _slicedToArray(_useState17, 2),
76
- reportingLinesData = _useState18[0],
77
- setReportingLinesData = _useState18[1];
83
+ teamCentralBaseUrl = _useState18[0],
84
+ setTeamCentralBaseUrl = _useState18[1];
78
85
  var _useState19 = useState(false),
79
86
  _useState20 = _slicedToArray(_useState19, 2),
80
- shouldShowGiveKudos = _useState20[0],
81
- setShouldShowGiveKudos = _useState20[1];
82
- var _useState21 = useState(undefined),
87
+ kudosDrawerOpen = _useState20[0],
88
+ setKudosDrawerOpen = _useState20[1];
89
+ var _useState21 = useState(false),
83
90
  _useState22 = _slicedToArray(_useState21, 2),
84
- teamCentralBaseUrl = _useState22[0],
85
- setTeamCentralBaseUrl = _useState22[1];
86
- var _useState23 = useState(false),
87
- _useState24 = _slicedToArray(_useState23, 2),
88
- kudosDrawerOpen = _useState24[0],
89
- setKudosDrawerOpen = _useState24[1];
90
- var _useState25 = useState(false),
91
- _useState26 = _slicedToArray(_useState25, 2),
92
- isTriggeredUsingKeyboard = _useState26[0],
93
- setTriggeredUsingKeyboard = _useState26[1];
91
+ isTriggeredUsingKeyboard = _useState22[0],
92
+ setTriggeredUsingKeyboard = _useState22[1];
94
93
  var triggerRef = useRef(null);
95
94
  useEffect(function () {
96
95
  setIsMounted(true);
97
96
  return function () {
98
97
  setIsMounted(false);
99
- clearTimeout(showTimer);
100
- clearTimeout(hideTimer);
98
+ clearTimeout(showTimer.current);
99
+ clearTimeout(hideTimer.current);
101
100
  };
102
101
  // eslint-disable-next-line react-hooks/exhaustive-deps
103
102
  }, []);
@@ -119,17 +118,16 @@ export default function ProfilecardTriggerNext(_ref) {
119
118
  fireEvent(createAnalyticsEvent, payload);
120
119
  }, [createAnalyticsEvent, isMounted]);
121
120
  var hideProfilecard = useCallback(function () {
122
- clearTimeout(showTimer);
123
- clearTimeout(hideTimer);
121
+ clearTimeout(showTimer.current);
122
+ clearTimeout(hideTimer.current);
124
123
  if (!isTriggeredUsingKeyboard) {
125
- setHideTimer(window.setTimeout(function () {
124
+ hideTimer.current = window.setTimeout(function () {
126
125
  setVisible(false);
127
- }, hideDelay));
126
+ }, hideDelay);
128
127
  }
129
- setTriggeredUsingKeyboard(false);
130
- }, [hideDelay, hideTimer, showTimer, isTriggeredUsingKeyboard]);
128
+ }, [hideDelay, isTriggeredUsingKeyboard]);
131
129
  var handleKeyboardClose = useCallback(function (event) {
132
- if (event.key !== 'Escape') {
130
+ if (event.key && event.key !== 'Escape') {
133
131
  return;
134
132
  }
135
133
  if (triggerRef.current) {
@@ -192,15 +190,15 @@ export default function ProfilecardTriggerNext(_ref) {
192
190
  }, _callee, null, [[7, 15]]);
193
191
  })), [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
194
192
  var showProfilecard = useCallback(function () {
195
- clearTimeout(hideTimer);
196
- clearTimeout(showTimer);
197
- setShowTimer(window.setTimeout(function () {
193
+ clearTimeout(hideTimer.current);
194
+ clearTimeout(showTimer.current);
195
+ showTimer.current = window.setTimeout(function () {
198
196
  if (!visible) {
199
197
  void clientFetchProfile();
200
198
  setVisible(true);
201
199
  }
202
- }, showDelay));
203
- }, [hideTimer, showDelay, showTimer, visible, clientFetchProfile]);
200
+ }, showDelay);
201
+ }, [showDelay, visible, clientFetchProfile]);
204
202
  var onClick = useCallback(function (event) {
205
203
  // If the user clicks on the trigger then we don't want that click event to
206
204
  // propagate out to parent containers. For example when clicking a mention
@@ -261,6 +259,7 @@ export default function ProfilecardTriggerNext(_ref) {
261
259
  }, [hideProfilecard, onFocus, onMouseEnter, trigger]);
262
260
  var profilecardProps = _objectSpread(_objectSpread({
263
261
  userId: userId,
262
+ fullName: prepopulatedData === null || prepopulatedData === void 0 ? void 0 : prepopulatedData.fullName,
264
263
  isCurrentUser: data === null || data === void 0 ? void 0 : data.isCurrentUser,
265
264
  clientFetchProfile: clientFetchProfile
266
265
  }, data), {}, {
@@ -280,9 +279,9 @@ export default function ProfilecardTriggerNext(_ref) {
280
279
  },
281
280
  placement: position,
282
281
  content: function content() {
283
- return showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
282
+ return /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
284
283
  fireAnalytics: fireAnalytics
285
- }) : /*#__PURE__*/React.createElement("div", wrapperProps, visible && /*#__PURE__*/React.createElement(Suspense, {
284
+ }) : visible && /*#__PURE__*/React.createElement(Suspense, {
286
285
  fallback: null
287
286
  }, /*#__PURE__*/React.createElement(ProfileCardLazy, _extends({}, profilecardProps, {
288
287
  actions: filterActions(),
@@ -305,7 +304,7 @@ export default function ProfilecardTriggerNext(_ref) {
305
304
  "data-testid": testId,
306
305
  role: "button",
307
306
  tabIndex: 0,
308
- "aria-label": ariaLabel,
307
+ "aria-label": getLabelMessage(ariaLabel, profilecardProps.fullName, formatMessage),
309
308
  "aria-labelledby": ariaLabelledBy
310
309
  }), children);
311
310
  },
@@ -0,0 +1,22 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ var getLabelMessage = function getLabelMessage(ariaLabelProp, fullName, formatMessage) {
3
+ if (ariaLabelProp) {
4
+ return ariaLabelProp;
5
+ }
6
+ return fullName ? formatMessage(messages.label, {
7
+ fullName: fullName
8
+ }) : formatMessage(messages.fallbackLabel);
9
+ };
10
+ var messages = defineMessages({
11
+ fallbackLabel: {
12
+ id: 'profilecard.user.trigger.fallback-aria-label',
13
+ defaultMessage: 'More information about this user',
14
+ description: 'Label for profile card trigger when we do not have user name'
15
+ },
16
+ label: {
17
+ id: 'profilecard.user.trigger.aria-label',
18
+ defaultMessage: 'More information about {fullName}',
19
+ description: 'Label for profile card trigger'
20
+ }
21
+ });
22
+ export default getLabelMessage;
@@ -38,7 +38,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
38
38
  actionSubjectId: actionSubjectId,
39
39
  attributes: _objectSpread(_objectSpread({
40
40
  packageName: "@atlaskit/profilecard",
41
- packageVersion: "19.10.0"
41
+ packageVersion: "19.11.1"
42
42
  }, attributes), {}, {
43
43
  firedAt: Math.round(getPageTime())
44
44
  })
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { ProfileCardTriggerProps } from '../../types';
3
- export default function ProfilecardTriggerNext({ trigger, userId, cloudId, resourceClient, actions, position, children, testId, addFlag, onReportingLinesClick, ariaLabel, ariaLabelledBy, }: ProfileCardTriggerProps): JSX.Element;
3
+ export default function ProfilecardTriggerNext({ trigger, userId, cloudId, resourceClient, actions, position, children, testId, addFlag, onReportingLinesClick, ariaLabel, ariaLabelledBy, prepopulatedData, }: ProfileCardTriggerProps): JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { MessageDescriptor } from 'react-intl-next';
2
+ declare const getLabelMessage: (ariaLabelProp: string | undefined, fullName: string | undefined, formatMessage: (message: MessageDescriptor, values?: Record<string, string>) => string) => string;
3
+ export default getLabelMessage;
@@ -115,6 +115,7 @@ export interface ProfileCardTriggerProps {
115
115
  addFlag?: (flag: any) => void;
116
116
  ariaLabel?: string;
117
117
  ariaLabelledBy?: string;
118
+ prepopulatedData?: PrepopulatedData;
118
119
  }
119
120
  export interface ProfileCardTriggerState {
120
121
  visible?: boolean;
@@ -362,3 +363,7 @@ export interface ClientOverrides {
362
363
  teamClient?: TeamProfileCardClient;
363
364
  teamCentralClient?: TeamCentralCardClient;
364
365
  }
366
+ /** This interface represents the data that is prepopulated in the profile card. **/
367
+ export interface PrepopulatedData {
368
+ fullName?: string;
369
+ }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { ProfileCardTriggerProps } from '../../types';
3
- export default function ProfilecardTriggerNext({ trigger, userId, cloudId, resourceClient, actions, position, children, testId, addFlag, onReportingLinesClick, ariaLabel, ariaLabelledBy, }: ProfileCardTriggerProps): JSX.Element;
3
+ export default function ProfilecardTriggerNext({ trigger, userId, cloudId, resourceClient, actions, position, children, testId, addFlag, onReportingLinesClick, ariaLabel, ariaLabelledBy, prepopulatedData, }: ProfileCardTriggerProps): JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { MessageDescriptor } from 'react-intl-next';
2
+ declare const getLabelMessage: (ariaLabelProp: string | undefined, fullName: string | undefined, formatMessage: (message: MessageDescriptor, values?: Record<string, string>) => string) => string;
3
+ export default getLabelMessage;
@@ -115,6 +115,7 @@ export interface ProfileCardTriggerProps {
115
115
  addFlag?: (flag: any) => void;
116
116
  ariaLabel?: string;
117
117
  ariaLabelledBy?: string;
118
+ prepopulatedData?: PrepopulatedData;
118
119
  }
119
120
  export interface ProfileCardTriggerState {
120
121
  visible?: boolean;
@@ -362,3 +363,7 @@ export interface ClientOverrides {
362
363
  teamClient?: TeamProfileCardClient;
363
364
  teamCentralClient?: TeamCentralCardClient;
364
365
  }
366
+ /** This interface represents the data that is prepopulated in the profile card. **/
367
+ export interface PrepopulatedData {
368
+ fullName?: string;
369
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "19.10.0",
3
+ "version": "19.11.1",
4
4
  "description": "A React component to display a card with user information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -55,9 +55,9 @@
55
55
  "@atlaskit/analytics-next": "^9.2.0",
56
56
  "@atlaskit/avatar": "^21.4.0",
57
57
  "@atlaskit/avatar-group": "^9.5.0",
58
- "@atlaskit/button": "^17.3.0",
58
+ "@atlaskit/button": "^17.4.0",
59
59
  "@atlaskit/dropdown-menu": "^12.5.0",
60
- "@atlaskit/empty-state": "^7.6.0",
60
+ "@atlaskit/empty-state": "^7.7.0",
61
61
  "@atlaskit/focus-ring": "^1.3.4",
62
62
  "@atlaskit/give-kudos": "^2.1.0",
63
63
  "@atlaskit/icon": "^22.0.0",
@@ -67,7 +67,7 @@
67
67
  "@atlaskit/popup": "^1.12.0",
68
68
  "@atlaskit/spinner": "^16.0.0",
69
69
  "@atlaskit/theme": "^12.6.0",
70
- "@atlaskit/tokens": "^1.36.0",
70
+ "@atlaskit/tokens": "^1.37.0",
71
71
  "@atlaskit/tooltip": "^18.1.0",
72
72
  "@babel/runtime": "^7.0.0",
73
73
  "@emotion/react": "^11.7.1",