@atlaskit/avatar 21.4.2 → 21.4.3

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,11 @@
1
1
  # @atlaskit/avatar
2
2
 
3
+ ## 21.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#63807](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63807) [`538c46e739b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/538c46e739b6) - [ux] Add accessible name to non-interactive avatars.
8
+
3
9
  ## 21.4.2
4
10
 
5
11
  ### Patch Changes
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
10
10
  var _react = require("react");
11
11
  var _react2 = require("@emotion/react");
12
+ var _reactUid = require("react-uid");
12
13
  var _analyticsNext = require("@atlaskit/analytics-next");
13
14
  var _colors = require("@atlaskit/theme/colors");
14
15
  var _AvatarImage = _interopRequireDefault(require("./AvatarImage"));
@@ -22,7 +23,7 @@ var _templateObject;
22
23
  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; }
23
24
  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; }
24
25
  var packageName = "@atlaskit/avatar";
25
- var packageVersion = "21.4.2";
26
+ var packageVersion = "21.4.3";
26
27
 
27
28
  // eslint-disable-next-line @repo/internal/react/consistent-types-definitions
28
29
 
@@ -76,6 +77,7 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
76
77
  var customStatusNode = /*#__PURE__*/(0, _react.isValidElement)(status) ? status : null;
77
78
  var isValidIconSize = size !== 'xxlarge' && size !== 'xsmall';
78
79
  var lastAnalytics = (0, _react.useRef)(analyticsContext);
80
+ var uuid = (0, _reactUid.useUIDSeed)()('avatar');
79
81
  (0, _react.useEffect)(function () {
80
82
  lastAnalytics.current = analyticsContext;
81
83
  }, [analyticsContext]);
@@ -137,14 +139,12 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
137
139
 
138
140
  // add presence or status to the label by default if presence and status are passed as a string
139
141
  // if status or presence are nodes this is not added to the label by default
140
- var generateDefaultLabel = function generateDefaultLabel() {
141
- if (!name && !status && !presence) {
142
- return;
143
- }
144
- return "".concat(name || '', " ").concat(isStatus && !customStatusNode ? "(".concat(status, ")") : '', " ").concat(isPresence && !customPresenceNode ? "(".concat(presence, ")") : '');
145
- };
142
+ var defaultLabel = "".concat(name || '', " ").concat(isStatus && !customStatusNode ? "(".concat(status, ")") : '', " ").concat(isPresence && !customPresenceNode ? "(".concat(presence, ")") : '').trim();
143
+ var isInteractive = onClick || href || isDisabled;
146
144
  return (0, _react2.jsx)(AvatarContainer, {
147
145
  "data-testid": testId,
146
+ role: isInteractive || !defaultLabel ? undefined : 'img',
147
+ "aria-labelledby": isInteractive || !defaultLabel ? undefined : "".concat(uuid, "-label"),
148
148
  style: {
149
149
  display: 'inline-block',
150
150
  position: 'relative',
@@ -163,11 +163,14 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
163
163
  isInteractive: Boolean(href || onClick) && !isDisabled,
164
164
  isDisabled: isDisabled
165
165
  })
166
- }, componentProps()), testId && getTestId(testId, children)), (onClick || href) && {
167
- 'aria-label': label || generateDefaultLabel()
166
+ }, componentProps()), testId && getTestId(testId, children)), isInteractive && {
167
+ 'aria-label': label || defaultLabel
168
168
  }), {}, {
169
- children: (0, _react2.jsx)(_AvatarImage.default, {
170
- alt: name,
169
+ children: (0, _react2.jsx)(_AvatarImage.default
170
+ // Only pass the name if there is an image provided. We want the
171
+ // icons to be presentational if they don't show anything important.
172
+ , {
173
+ alt: src ? name : undefined,
171
174
  appearance: appearance,
172
175
  size: size,
173
176
  src: src,
@@ -187,7 +190,10 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
187
190
  borderColor: borderColor,
188
191
  status: typeof status === 'string' ? status : undefined,
189
192
  testId: testId
190
- }, customStatusNode));
193
+ }, customStatusNode), !isInteractive && defaultLabel ? (0, _react2.jsx)("span", {
194
+ id: "".concat(uuid, "-label"),
195
+ hidden: true
196
+ }, defaultLabel) : undefined);
191
197
  });
192
198
  Avatar.displayName = 'Avatar';
193
199
  var _default = exports.default = Avatar;
@@ -22,10 +22,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
22
22
  var avatarItemStyles = (0, _react2.css)({
23
23
  minWidth: 0,
24
24
  maxWidth: '100%',
25
- paddingLeft: "var(--ds-space-100, 8px)",
26
25
  flex: '1 1 100%',
27
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
28
- lineHeight: '1.4'
26
+ lineHeight: '1.4',
27
+ paddingInlineStart: "var(--ds-space-100, 8px)"
29
28
  });
30
29
  var getStyles = function getStyles(css, _ref) {
31
30
  var backgroundColor = _ref.backgroundColor,
@@ -29,12 +29,10 @@ var iconWrapperStyles = (0, _react.css)({
29
29
  var IconWrapper = function IconWrapper(_ref) {
30
30
  var _ref$bgColor = _ref.bgColor,
31
31
  bgColor = _ref$bgColor === void 0 ? "var(--ds-surface-overlay, ".concat(_colors.N0, ")") : _ref$bgColor,
32
- children = _ref.children,
33
- label = _ref.label;
32
+ children = _ref.children;
34
33
  return (0, _react.jsx)("span", {
35
- "aria-label": label || undefined,
36
34
  css: iconWrapperStyles,
37
- role: label ? 'img' : 'presentation',
35
+ role: "presentation",
38
36
  style: {
39
37
  border: "".concat(_constants.BORDER_WIDTH, "px solid ").concat(bgColor),
40
38
  backgroundColor: bgColor
@@ -67,16 +67,14 @@ var AvatarPresence = function AvatarPresence(_ref) {
67
67
  children = _ref.children,
68
68
  presence = _ref.presence;
69
69
  return /*#__PURE__*/_react.default.createElement(_IconWrapper.default, {
70
- bgColor: borderColor,
71
- label: typeof presence === 'string' ? presence : undefined
70
+ bgColor: borderColor
72
71
  }, presence ? /*#__PURE__*/_react.default.createElement("svg", {
73
- "aria-hidden": "true",
74
72
  height: "100%",
75
73
  version: "1.1",
76
74
  viewBox: "0 0 8 8",
77
75
  width: "100%",
78
76
  xmlns: "http://www.w3.org/2000/svg"
79
- }, getPresence(presence)) : children);
77
+ }, /*#__PURE__*/_react.default.createElement("title", null, "(".concat(presence, ")")), getPresence(presence)) : children);
80
78
  };
81
79
  var _default = exports.default = AvatarPresence;
82
80
  /**
@@ -93,7 +91,6 @@ var PresenceWrapper = exports.PresenceWrapper = function PresenceWrapper(_ref2)
93
91
  testId = _ref2.testId;
94
92
  var position = appearance === 'square' ? -4 : _constants.ICON_OFFSET[size];
95
93
  return /*#__PURE__*/_react.default.createElement("span", {
96
- "aria-hidden": "true",
97
94
  "data-testid": testId && "".concat(testId, "--presence"),
98
95
  style: {
99
96
  pointerEvents: 'none',
@@ -65,16 +65,14 @@ var AvatarStatus = function AvatarStatus(_ref) {
65
65
  children = _ref.children,
66
66
  status = _ref.status;
67
67
  return /*#__PURE__*/_react.default.createElement(_IconWrapper.default, {
68
- bgColor: borderColor,
69
- label: typeof status === 'string' ? status : undefined
68
+ bgColor: borderColor
70
69
  }, status ? /*#__PURE__*/_react.default.createElement("svg", {
71
- "aria-hidden": "true",
72
70
  height: "100%",
73
71
  version: "1.1",
74
72
  viewBox: "0 0 8 8",
75
73
  width: "100%",
76
74
  xmlns: "http://www.w3.org/2000/svg"
77
- }, getStatus(status)) : children);
75
+ }, /*#__PURE__*/_react.default.createElement("title", null, "(".concat(status, ")")), getStatus(status)) : children);
78
76
  };
79
77
  var _default = exports.default = AvatarStatus;
80
78
  /**
@@ -91,7 +89,6 @@ var StatusWrapper = exports.StatusWrapper = function StatusWrapper(_ref2) {
91
89
  testId = _ref2.testId;
92
90
  var position = appearance === 'square' ? 0 : _constants.ICON_OFFSET[size];
93
91
  return /*#__PURE__*/_react.default.createElement("span", {
94
- "aria-hidden": "true",
95
92
  "data-testid": testId && "".concat(testId, "--status"),
96
93
  style: {
97
94
  position: 'absolute',
@@ -2,6 +2,7 @@
2
2
  // eslint-disable-next-line @repo/internal/fs/filename-pattern-match
3
3
  import { createElement, forwardRef, isValidElement, useCallback, useEffect, useRef } from 'react';
4
4
  import { ClassNames, jsx } from '@emotion/react';
5
+ import { useUIDSeed } from 'react-uid';
5
6
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
6
7
  import { B300, N0, N70A } from '@atlaskit/theme/colors';
7
8
  import AvatarImage from './AvatarImage';
@@ -10,7 +11,7 @@ import { PresenceWrapper } from './Presence';
10
11
  import { StatusWrapper } from './Status';
11
12
  import { getButtonProps, getCustomElement, getLinkProps } from './utilities';
12
13
  const packageName = "@atlaskit/avatar";
13
- const packageVersion = "21.4.2";
14
+ const packageVersion = "21.4.3";
14
15
 
15
16
  // eslint-disable-next-line @repo/internal/react/consistent-types-definitions
16
17
 
@@ -150,6 +151,7 @@ const Avatar = /*#__PURE__*/forwardRef(({
150
151
  const customStatusNode = /*#__PURE__*/isValidElement(status) ? status : null;
151
152
  const isValidIconSize = size !== 'xxlarge' && size !== 'xsmall';
152
153
  const lastAnalytics = useRef(analyticsContext);
154
+ const uuid = useUIDSeed()('avatar');
153
155
  useEffect(() => {
154
156
  lastAnalytics.current = analyticsContext;
155
157
  }, [analyticsContext]);
@@ -213,14 +215,12 @@ const Avatar = /*#__PURE__*/forwardRef(({
213
215
 
214
216
  // add presence or status to the label by default if presence and status are passed as a string
215
217
  // if status or presence are nodes this is not added to the label by default
216
- const generateDefaultLabel = () => {
217
- if (!name && !status && !presence) {
218
- return;
219
- }
220
- return `${name || ''} ${isStatus && !customStatusNode ? `(${status})` : ''} ${isPresence && !customPresenceNode ? `(${presence})` : ''}`;
221
- };
218
+ const defaultLabel = `${name || ''} ${isStatus && !customStatusNode ? `(${status})` : ''} ${isPresence && !customPresenceNode ? `(${presence})` : ''}`.trim();
219
+ const isInteractive = onClick || href || isDisabled;
222
220
  return jsx(AvatarContainer, {
223
221
  "data-testid": testId,
222
+ role: isInteractive || !defaultLabel ? undefined : 'img',
223
+ "aria-labelledby": isInteractive || !defaultLabel ? undefined : `${uuid}-label`,
224
224
  style: {
225
225
  display: 'inline-block',
226
226
  position: 'relative',
@@ -242,11 +242,14 @@ const Avatar = /*#__PURE__*/forwardRef(({
242
242
  }),
243
243
  ...componentProps(),
244
244
  ...(testId && getTestId(testId, children)),
245
- ...((onClick || href) && {
246
- 'aria-label': label || generateDefaultLabel()
245
+ ...(isInteractive && {
246
+ 'aria-label': label || defaultLabel
247
247
  }),
248
- children: jsx(AvatarImage, {
249
- alt: name,
248
+ children: jsx(AvatarImage
249
+ // Only pass the name if there is an image provided. We want the
250
+ // icons to be presentational if they don't show anything important.
251
+ , {
252
+ alt: src ? name : undefined,
250
253
  appearance: appearance,
251
254
  size: size,
252
255
  src: src,
@@ -266,7 +269,10 @@ const Avatar = /*#__PURE__*/forwardRef(({
266
269
  borderColor: borderColor,
267
270
  status: typeof status === 'string' ? status : undefined,
268
271
  testId: testId
269
- }, customStatusNode));
272
+ }, customStatusNode), !isInteractive && defaultLabel ? jsx("span", {
273
+ id: `${uuid}-label`,
274
+ hidden: true
275
+ }, defaultLabel) : undefined);
270
276
  });
271
277
  Avatar.displayName = 'Avatar';
272
278
  export default Avatar;
@@ -10,10 +10,9 @@ import { getButtonProps, getCustomElement, getLinkProps } from './utilities';
10
10
  const avatarItemStyles = css({
11
11
  minWidth: 0,
12
12
  maxWidth: '100%',
13
- paddingLeft: "var(--ds-space-100, 8px)",
14
13
  flex: '1 1 100%',
15
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
16
- lineHeight: '1.4'
14
+ lineHeight: '1.4',
15
+ paddingInlineStart: "var(--ds-space-100, 8px)"
17
16
  });
18
17
  const getStyles = (css, {
19
18
  backgroundColor,
@@ -22,12 +22,10 @@ const iconWrapperStyles = css({
22
22
  */
23
23
  const IconWrapper = ({
24
24
  bgColor = `var(--ds-surface-overlay, ${N0})`,
25
- children,
26
- label
25
+ children
27
26
  }) => jsx("span", {
28
- "aria-label": label || undefined,
29
27
  css: iconWrapperStyles,
30
- role: label ? 'img' : 'presentation',
28
+ role: "presentation",
31
29
  style: {
32
30
  border: `${BORDER_WIDTH}px solid ${bgColor}`,
33
31
  backgroundColor: bgColor
@@ -56,16 +56,14 @@ const AvatarPresence = ({
56
56
  children,
57
57
  presence
58
58
  }) => /*#__PURE__*/React.createElement(IconWrapper, {
59
- bgColor: borderColor,
60
- label: typeof presence === 'string' ? presence : undefined
59
+ bgColor: borderColor
61
60
  }, presence ? /*#__PURE__*/React.createElement("svg", {
62
- "aria-hidden": "true",
63
61
  height: "100%",
64
62
  version: "1.1",
65
63
  viewBox: "0 0 8 8",
66
64
  width: "100%",
67
65
  xmlns: "http://www.w3.org/2000/svg"
68
- }, getPresence(presence)) : children);
66
+ }, /*#__PURE__*/React.createElement("title", null, `(${presence})`), getPresence(presence)) : children);
69
67
  export default AvatarPresence;
70
68
  /**
71
69
  * __Presence wrapper__
@@ -82,7 +80,6 @@ export const PresenceWrapper = ({
82
80
  }) => {
83
81
  const position = appearance === 'square' ? -4 : ICON_OFFSET[size];
84
82
  return /*#__PURE__*/React.createElement("span", {
85
- "aria-hidden": "true",
86
83
  "data-testid": testId && `${testId}--presence`,
87
84
  style: {
88
85
  pointerEvents: 'none',
@@ -54,16 +54,14 @@ const AvatarStatus = ({
54
54
  children,
55
55
  status
56
56
  }) => /*#__PURE__*/React.createElement(IconWrapper, {
57
- bgColor: borderColor,
58
- label: typeof status === 'string' ? status : undefined
57
+ bgColor: borderColor
59
58
  }, status ? /*#__PURE__*/React.createElement("svg", {
60
- "aria-hidden": "true",
61
59
  height: "100%",
62
60
  version: "1.1",
63
61
  viewBox: "0 0 8 8",
64
62
  width: "100%",
65
63
  xmlns: "http://www.w3.org/2000/svg"
66
- }, getStatus(status)) : children);
64
+ }, /*#__PURE__*/React.createElement("title", null, `(${status})`), getStatus(status)) : children);
67
65
  export default AvatarStatus;
68
66
  /**
69
67
  * Status wrapper**
@@ -80,7 +78,6 @@ export const StatusWrapper = ({
80
78
  }) => {
81
79
  const position = appearance === 'square' ? 0 : ICON_OFFSET[size];
82
80
  return /*#__PURE__*/React.createElement("span", {
83
- "aria-hidden": "true",
84
81
  "data-testid": testId && `${testId}--status`,
85
82
  style: {
86
83
  position: 'absolute',
@@ -7,6 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  // eslint-disable-next-line @repo/internal/fs/filename-pattern-match
8
8
  import { createElement, forwardRef, isValidElement, useCallback, useEffect, useRef } from 'react';
9
9
  import { ClassNames, jsx } from '@emotion/react';
10
+ import { useUIDSeed } from 'react-uid';
10
11
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
11
12
  import { B300, N0, N70A } from '@atlaskit/theme/colors';
12
13
  import AvatarImage from './AvatarImage';
@@ -15,7 +16,7 @@ import { PresenceWrapper } from './Presence';
15
16
  import { StatusWrapper } from './Status';
16
17
  import { getButtonProps, getCustomElement, getLinkProps } from './utilities';
17
18
  var packageName = "@atlaskit/avatar";
18
- var packageVersion = "21.4.2";
19
+ var packageVersion = "21.4.3";
19
20
 
20
21
  // eslint-disable-next-line @repo/internal/react/consistent-types-definitions
21
22
 
@@ -69,6 +70,7 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
69
70
  var customStatusNode = /*#__PURE__*/isValidElement(status) ? status : null;
70
71
  var isValidIconSize = size !== 'xxlarge' && size !== 'xsmall';
71
72
  var lastAnalytics = useRef(analyticsContext);
73
+ var uuid = useUIDSeed()('avatar');
72
74
  useEffect(function () {
73
75
  lastAnalytics.current = analyticsContext;
74
76
  }, [analyticsContext]);
@@ -130,14 +132,12 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
130
132
 
131
133
  // add presence or status to the label by default if presence and status are passed as a string
132
134
  // if status or presence are nodes this is not added to the label by default
133
- var generateDefaultLabel = function generateDefaultLabel() {
134
- if (!name && !status && !presence) {
135
- return;
136
- }
137
- return "".concat(name || '', " ").concat(isStatus && !customStatusNode ? "(".concat(status, ")") : '', " ").concat(isPresence && !customPresenceNode ? "(".concat(presence, ")") : '');
138
- };
135
+ var defaultLabel = "".concat(name || '', " ").concat(isStatus && !customStatusNode ? "(".concat(status, ")") : '', " ").concat(isPresence && !customPresenceNode ? "(".concat(presence, ")") : '').trim();
136
+ var isInteractive = onClick || href || isDisabled;
139
137
  return jsx(AvatarContainer, {
140
138
  "data-testid": testId,
139
+ role: isInteractive || !defaultLabel ? undefined : 'img',
140
+ "aria-labelledby": isInteractive || !defaultLabel ? undefined : "".concat(uuid, "-label"),
141
141
  style: {
142
142
  display: 'inline-block',
143
143
  position: 'relative',
@@ -156,11 +156,14 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
156
156
  isInteractive: Boolean(href || onClick) && !isDisabled,
157
157
  isDisabled: isDisabled
158
158
  })
159
- }, componentProps()), testId && getTestId(testId, children)), (onClick || href) && {
160
- 'aria-label': label || generateDefaultLabel()
159
+ }, componentProps()), testId && getTestId(testId, children)), isInteractive && {
160
+ 'aria-label': label || defaultLabel
161
161
  }), {}, {
162
- children: jsx(AvatarImage, {
163
- alt: name,
162
+ children: jsx(AvatarImage
163
+ // Only pass the name if there is an image provided. We want the
164
+ // icons to be presentational if they don't show anything important.
165
+ , {
166
+ alt: src ? name : undefined,
164
167
  appearance: appearance,
165
168
  size: size,
166
169
  src: src,
@@ -180,7 +183,10 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
180
183
  borderColor: borderColor,
181
184
  status: typeof status === 'string' ? status : undefined,
182
185
  testId: testId
183
- }, customStatusNode));
186
+ }, customStatusNode), !isInteractive && defaultLabel ? jsx("span", {
187
+ id: "".concat(uuid, "-label"),
188
+ hidden: true
189
+ }, defaultLabel) : undefined);
184
190
  });
185
191
  Avatar.displayName = 'Avatar';
186
192
  export default Avatar;
@@ -15,10 +15,9 @@ import { getButtonProps, getCustomElement, getLinkProps } from './utilities';
15
15
  var avatarItemStyles = css({
16
16
  minWidth: 0,
17
17
  maxWidth: '100%',
18
- paddingLeft: "var(--ds-space-100, 8px)",
19
18
  flex: '1 1 100%',
20
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
21
- lineHeight: '1.4'
19
+ lineHeight: '1.4',
20
+ paddingInlineStart: "var(--ds-space-100, 8px)"
22
21
  });
23
22
  var getStyles = function getStyles(css, _ref) {
24
23
  var backgroundColor = _ref.backgroundColor,
@@ -23,12 +23,10 @@ var iconWrapperStyles = css({
23
23
  var IconWrapper = function IconWrapper(_ref) {
24
24
  var _ref$bgColor = _ref.bgColor,
25
25
  bgColor = _ref$bgColor === void 0 ? "var(--ds-surface-overlay, ".concat(N0, ")") : _ref$bgColor,
26
- children = _ref.children,
27
- label = _ref.label;
26
+ children = _ref.children;
28
27
  return jsx("span", {
29
- "aria-label": label || undefined,
30
28
  css: iconWrapperStyles,
31
- role: label ? 'img' : 'presentation',
29
+ role: "presentation",
32
30
  style: {
33
31
  border: "".concat(BORDER_WIDTH, "px solid ").concat(bgColor),
34
32
  backgroundColor: bgColor
@@ -56,16 +56,14 @@ var AvatarPresence = function AvatarPresence(_ref) {
56
56
  children = _ref.children,
57
57
  presence = _ref.presence;
58
58
  return /*#__PURE__*/React.createElement(IconWrapper, {
59
- bgColor: borderColor,
60
- label: typeof presence === 'string' ? presence : undefined
59
+ bgColor: borderColor
61
60
  }, presence ? /*#__PURE__*/React.createElement("svg", {
62
- "aria-hidden": "true",
63
61
  height: "100%",
64
62
  version: "1.1",
65
63
  viewBox: "0 0 8 8",
66
64
  width: "100%",
67
65
  xmlns: "http://www.w3.org/2000/svg"
68
- }, getPresence(presence)) : children);
66
+ }, /*#__PURE__*/React.createElement("title", null, "(".concat(presence, ")")), getPresence(presence)) : children);
69
67
  };
70
68
  export default AvatarPresence;
71
69
  /**
@@ -82,7 +80,6 @@ export var PresenceWrapper = function PresenceWrapper(_ref2) {
82
80
  testId = _ref2.testId;
83
81
  var position = appearance === 'square' ? -4 : ICON_OFFSET[size];
84
82
  return /*#__PURE__*/React.createElement("span", {
85
- "aria-hidden": "true",
86
83
  "data-testid": testId && "".concat(testId, "--presence"),
87
84
  style: {
88
85
  pointerEvents: 'none',
@@ -54,16 +54,14 @@ var AvatarStatus = function AvatarStatus(_ref) {
54
54
  children = _ref.children,
55
55
  status = _ref.status;
56
56
  return /*#__PURE__*/React.createElement(IconWrapper, {
57
- bgColor: borderColor,
58
- label: typeof status === 'string' ? status : undefined
57
+ bgColor: borderColor
59
58
  }, status ? /*#__PURE__*/React.createElement("svg", {
60
- "aria-hidden": "true",
61
59
  height: "100%",
62
60
  version: "1.1",
63
61
  viewBox: "0 0 8 8",
64
62
  width: "100%",
65
63
  xmlns: "http://www.w3.org/2000/svg"
66
- }, getStatus(status)) : children);
64
+ }, /*#__PURE__*/React.createElement("title", null, "(".concat(status, ")")), getStatus(status)) : children);
67
65
  };
68
66
  export default AvatarStatus;
69
67
  /**
@@ -80,7 +78,6 @@ export var StatusWrapper = function StatusWrapper(_ref2) {
80
78
  testId = _ref2.testId;
81
79
  var position = appearance === 'square' ? 0 : ICON_OFFSET[size];
82
80
  return /*#__PURE__*/React.createElement("span", {
83
- "aria-hidden": "true",
84
81
  "data-testid": testId && "".concat(testId, "--status"),
85
82
  style: {
86
83
  position: 'absolute',
@@ -39,7 +39,7 @@ export interface AvatarItemProps {
39
39
  */
40
40
  href?: string;
41
41
  /**
42
- * Disable the item from being interactive
42
+ * Disable the item from being interactive.
43
43
  */
44
44
  isDisabled?: boolean;
45
45
  /**
@@ -63,7 +63,7 @@ export interface AvatarItemProps {
63
63
  */
64
64
  isTruncationDisabled?: boolean;
65
65
  /**
66
- * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
66
+ * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
67
67
  */
68
68
  testId?: string;
69
69
  }
@@ -39,7 +39,7 @@ export interface AvatarItemProps {
39
39
  */
40
40
  href?: string;
41
41
  /**
42
- * Disable the item from being interactive
42
+ * Disable the item from being interactive.
43
43
  */
44
44
  isDisabled?: boolean;
45
45
  /**
@@ -63,7 +63,7 @@ export interface AvatarItemProps {
63
63
  */
64
64
  isTruncationDisabled?: boolean;
65
65
  /**
66
- * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
66
+ * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
67
67
  */
68
68
  testId?: string;
69
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/avatar",
3
- "version": "21.4.2",
3
+ "version": "21.4.3",
4
4
  "description": "An avatar is a visual representation of a user or entity.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -46,10 +46,11 @@
46
46
  "@atlaskit/analytics-next": "^9.1.0",
47
47
  "@atlaskit/icon": "^22.0.0",
48
48
  "@atlaskit/theme": "^12.6.0",
49
- "@atlaskit/tokens": "^1.28.0",
49
+ "@atlaskit/tokens": "^1.33.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1",
52
- "@emotion/serialize": "^1.1.0"
52
+ "@emotion/serialize": "^1.1.0",
53
+ "react-uid": "^2.2.0"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "react": "^16.8.0"
@@ -59,7 +60,7 @@
59
60
  "@af/visual-regression": "*",
60
61
  "@atlaskit/ds-lib": "^2.2.0",
61
62
  "@atlaskit/ssr": "*",
62
- "@atlaskit/tooltip": "^18.0.0",
63
+ "@atlaskit/tooltip": "^18.1.0",
63
64
  "@atlaskit/visual-regression": "*",
64
65
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
65
66
  "@emotion/styled": "^11.0.0",
@@ -1,171 +0,0 @@
1
- ## API Report File for "@atlaskit/avatar"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- /// <reference types="react" />
8
-
9
- import { FC } from 'react';
10
- import { ForwardRefExoticComponent } from 'react';
11
- import { MouseEventHandler } from 'react';
12
- import { ReactNode } from 'react';
13
- import { Ref } from 'react';
14
- import { RefAttributes } from 'react';
15
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
16
-
17
- // @public (undocumented)
18
- export const ACTIVE_SCALE_FACTOR = 0.9;
19
-
20
- // @public (undocumented)
21
- export type AppearanceType = 'circle' | 'square';
22
-
23
- // @public
24
- const Avatar: ForwardRefExoticComponent<AvatarPropTypes & RefAttributes<HTMLElement>>;
25
- export default Avatar;
26
-
27
- // @public (undocumented)
28
- export const AVATAR_RADIUS: AvatarSizeMap;
29
-
30
- // @public (undocumented)
31
- export const AVATAR_SIZES: AvatarSizeMap;
32
-
33
- // @public (undocumented)
34
- export type AvatarClickEventHandler = (event: React.MouseEvent, analyticsEvent?: UIAnalyticsEvent) => void;
35
-
36
- // @public
37
- export const AvatarItem: ForwardRefExoticComponent<AvatarItemProps & RefAttributes<HTMLElement>>;
38
-
39
- // @public (undocumented)
40
- export interface AvatarItemProps {
41
- avatar: ReactNode;
42
- backgroundColor?: string;
43
- children?: (props: CustomAvatarItemProps) => ReactNode;
44
- href?: string;
45
- isDisabled?: boolean;
46
- isTruncationDisabled?: boolean;
47
- label?: string;
48
- onClick?: AvatarClickEventHandler;
49
- primaryText?: ReactNode;
50
- secondaryText?: ReactNode;
51
- target?: '_blank' | '_parent' | '_self' | '_top';
52
- testId?: string;
53
- }
54
-
55
- // @public (undocumented)
56
- export interface AvatarPropTypes {
57
- analyticsContext?: Record<string, any>;
58
- appearance?: AppearanceType;
59
- as?: React.ComponentType<React.AllHTMLAttributes<HTMLElement>> | keyof JSX.IntrinsicElements;
60
- borderColor?: string;
61
- children?: (props: CustomAvatarProps) => ReactNode;
62
- href?: string;
63
- isDisabled?: boolean;
64
- label?: string;
65
- name?: string;
66
- onClick?: AvatarClickEventHandler;
67
- presence?: (string & {}) | Omit<ReactNode, string> | PresenceType | null;
68
- size?: SizeType;
69
- src?: string;
70
- stackIndex?: number;
71
- status?: (string & {}) | Omit<ReactNode, string> | StatusType | null;
72
- tabIndex?: number;
73
- target?: '_blank' | '_parent' | '_self' | '_top';
74
- testId?: string;
75
- }
76
-
77
- // @public (undocumented)
78
- type AvatarSizeMap = Record<SizeType, number>;
79
-
80
- // @public (undocumented)
81
- export const BORDER_WIDTH = 2;
82
-
83
- // @public (undocumented)
84
- export interface CustomAvatarItemProps {
85
- // (undocumented)
86
- 'aria-disabled'?: 'false' | 'true' | boolean | undefined;
87
- 'aria-label'?: string;
88
- // (undocumented)
89
- children: ReactNode;
90
- // (undocumented)
91
- className?: string;
92
- // (undocumented)
93
- href?: string;
94
- // (undocumented)
95
- onClick?: MouseEventHandler;
96
- // (undocumented)
97
- ref: Ref<HTMLElement>;
98
- // (undocumented)
99
- testId?: string;
100
- }
101
-
102
- // @public (undocumented)
103
- export interface CustomAvatarProps {
104
- 'aria-label'?: string;
105
- // (undocumented)
106
- children: ReactNode;
107
- // (undocumented)
108
- className?: string;
109
- // (undocumented)
110
- href?: string;
111
- // (undocumented)
112
- onClick?: MouseEventHandler;
113
- // (undocumented)
114
- ref: Ref<HTMLElement>;
115
- // (undocumented)
116
- tabIndex?: number;
117
- // (undocumented)
118
- testId?: string;
119
- }
120
-
121
- // @public (undocumented)
122
- export type IndicatorSizeType = 'large' | 'medium' | 'small' | 'xlarge';
123
-
124
- // @public
125
- export const Presence: FC<PresenceProps>;
126
-
127
- // @public (undocumented)
128
- export interface PresenceProps {
129
- borderColor?: string;
130
- children?: ReactNode;
131
- presence?: PresenceType;
132
- testId?: string;
133
- }
134
-
135
- // @public (undocumented)
136
- export type PresenceType = 'busy' | 'focus' | 'offline' | 'online';
137
-
138
- // @public (undocumented)
139
- export type SizeType = 'large' | 'medium' | 'small' | 'xlarge' | 'xsmall' | 'xxlarge';
140
-
141
- // @public
142
- export const Skeleton: FC<SkeletonProps>;
143
-
144
- // @public (undocumented)
145
- export interface SkeletonProps {
146
- // (undocumented)
147
- appearance?: AppearanceType;
148
- // (undocumented)
149
- color?: string;
150
- // (undocumented)
151
- size?: SizeType;
152
- // (undocumented)
153
- weight?: 'normal' | 'strong';
154
- }
155
-
156
- // @public
157
- export const Status: FC<StatusProps>;
158
-
159
- // @public (undocumented)
160
- export interface StatusProps {
161
- borderColor?: string;
162
- children?: ReactNode;
163
- status?: StatusType;
164
- }
165
-
166
- // @public (undocumented)
167
- export type StatusType = 'approved' | 'declined' | 'locked';
168
-
169
- // (No @packageDocumentation comment for this package)
170
-
171
- ```