@atlaskit/avatar 21.3.6 → 21.3.8

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,17 @@
1
1
  # @atlaskit/avatar
2
2
 
3
+ ## 21.3.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7a3cbead067`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7a3cbead067) - Default content for label
8
+
9
+ ## 21.3.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [`4ae083a7e66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ae083a7e66) - Use `@af/accessibility-testing` for default jest-axe config and jest-axe import in accessibility testing.
14
+
3
15
  ## 21.3.6
4
16
 
5
17
  ### Patch Changes
@@ -22,7 +22,7 @@ var _templateObject;
22
22
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
23
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
24
  var packageName = "@atlaskit/avatar";
25
- var packageVersion = "21.3.6";
25
+ var packageVersion = "21.3.8";
26
26
 
27
27
  // eslint-disable-next-line @repo/internal/react/consistent-types-definitions
28
28
 
@@ -130,6 +130,17 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
130
130
  onClick: onClick
131
131
  });
132
132
  };
133
+ var isPresence = isValidIconSize && presence && !status;
134
+ var isStatus = isValidIconSize && status;
135
+
136
+ // add presence or status to the label by default if presence and status are passed as a string
137
+ // if status or presence are nodes this is not added to the label by default
138
+ var generateDefaultLabel = function generateDefaultLabel() {
139
+ if (!name && !status && !presence) {
140
+ return;
141
+ }
142
+ return "".concat(name || '', " ").concat(isStatus && !customStatusNode ? "(".concat(status, ")") : '', " ").concat(isPresence && !customPresenceNode ? "(".concat(presence, ")") : '');
143
+ };
133
144
  return (0, _react2.jsx)("div", {
134
145
  "data-testid": testId,
135
146
  style: {
@@ -151,7 +162,7 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
151
162
  isDisabled: isDisabled
152
163
  })
153
164
  }, componentProps()), testId && getTestId(testId, children)), (onClick || href) && {
154
- 'aria-label': label
165
+ 'aria-label': label || generateDefaultLabel()
155
166
  }), {}, {
156
167
  children: (0, _react2.jsx)(_AvatarImage.default, {
157
168
  alt: name,
@@ -163,12 +174,12 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
163
174
  ref: ref
164
175
  });
165
176
  return children ? children(props) : /*#__PURE__*/(0, _react.createElement)((0, _utilities.getCustomElement)(isDisabled, href, onClick), props);
166
- }), isValidIconSize && presence && !status && (0, _react2.jsx)(_Presence.PresenceWrapper, {
177
+ }), isPresence && (0, _react2.jsx)(_Presence.PresenceWrapper, {
167
178
  appearance: appearance,
168
179
  size: size,
169
180
  presence: typeof presence === 'string' ? presence : undefined,
170
181
  testId: testId
171
- }, customPresenceNode), isValidIconSize && status && (0, _react2.jsx)(_Status.StatusWrapper, {
182
+ }, customPresenceNode), isStatus && (0, _react2.jsx)(_Status.StatusWrapper, {
172
183
  appearance: appearance,
173
184
  size: size,
174
185
  borderColor: borderColor,
@@ -30,7 +30,7 @@ var nestedAvatarStyles = Object.entries(_constants.AVATAR_SIZES).reduce(function
30
30
  key = _ref2[0],
31
31
  size = _ref2[1];
32
32
  return _objectSpread(_objectSpread({}, styles), {}, (0, _defineProperty2.default)({}, key, (0, _react2.css)({
33
- // eslint-disable-next-line @repo/internal/styles/no-nested-styles
33
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
34
34
  '& svg': {
35
35
  width: "".concat(size, "px"),
36
36
  height: "".concat(size, "px")
@@ -10,7 +10,7 @@ import { PresenceWrapper } from './Presence';
10
10
  import { StatusWrapper } from './Status';
11
11
  import { getButtonProps, getCustomElement, getLinkProps } from './utilities';
12
12
  const packageName = "@atlaskit/avatar";
13
- const packageVersion = "21.3.6";
13
+ const packageVersion = "21.3.8";
14
14
 
15
15
  // eslint-disable-next-line @repo/internal/react/consistent-types-definitions
16
16
 
@@ -207,6 +207,17 @@ const Avatar = /*#__PURE__*/forwardRef(({
207
207
  })
208
208
  };
209
209
  };
210
+ const isPresence = isValidIconSize && presence && !status;
211
+ const isStatus = isValidIconSize && status;
212
+
213
+ // add presence or status to the label by default if presence and status are passed as a string
214
+ // if status or presence are nodes this is not added to the label by default
215
+ const generateDefaultLabel = () => {
216
+ if (!name && !status && !presence) {
217
+ return;
218
+ }
219
+ return `${name || ''} ${isStatus && !customStatusNode ? `(${status})` : ''} ${isPresence && !customPresenceNode ? `(${presence})` : ''}`;
220
+ };
210
221
  return jsx("div", {
211
222
  "data-testid": testId,
212
223
  style: {
@@ -231,7 +242,7 @@ const Avatar = /*#__PURE__*/forwardRef(({
231
242
  ...componentProps(),
232
243
  ...(testId && getTestId(testId, children)),
233
244
  ...((onClick || href) && {
234
- 'aria-label': label
245
+ 'aria-label': label || generateDefaultLabel()
235
246
  }),
236
247
  children: jsx(AvatarImage, {
237
248
  alt: name,
@@ -243,12 +254,12 @@ const Avatar = /*#__PURE__*/forwardRef(({
243
254
  ref
244
255
  };
245
256
  return children ? children(props) : /*#__PURE__*/createElement(getCustomElement(isDisabled, href, onClick), props);
246
- }), isValidIconSize && presence && !status && jsx(PresenceWrapper, {
257
+ }), isPresence && jsx(PresenceWrapper, {
247
258
  appearance: appearance,
248
259
  size: size,
249
260
  presence: typeof presence === 'string' ? presence : undefined,
250
261
  testId: testId
251
- }, customPresenceNode), isValidIconSize && status && jsx(StatusWrapper, {
262
+ }, customPresenceNode), isStatus && jsx(StatusWrapper, {
252
263
  appearance: appearance,
253
264
  size: size,
254
265
  borderColor: borderColor,
@@ -18,7 +18,7 @@ const nestedAvatarStyles = Object.entries(AVATAR_SIZES).reduce((styles, [key, si
18
18
  return {
19
19
  ...styles,
20
20
  [key]: css({
21
- // eslint-disable-next-line @repo/internal/styles/no-nested-styles
21
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
22
22
  '& svg': {
23
23
  width: `${size}px`,
24
24
  height: `${size}px`
@@ -15,7 +15,7 @@ import { PresenceWrapper } from './Presence';
15
15
  import { StatusWrapper } from './Status';
16
16
  import { getButtonProps, getCustomElement, getLinkProps } from './utilities';
17
17
  var packageName = "@atlaskit/avatar";
18
- var packageVersion = "21.3.6";
18
+ var packageVersion = "21.3.8";
19
19
 
20
20
  // eslint-disable-next-line @repo/internal/react/consistent-types-definitions
21
21
 
@@ -123,6 +123,17 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
123
123
  onClick: onClick
124
124
  });
125
125
  };
126
+ var isPresence = isValidIconSize && presence && !status;
127
+ var isStatus = isValidIconSize && status;
128
+
129
+ // add presence or status to the label by default if presence and status are passed as a string
130
+ // if status or presence are nodes this is not added to the label by default
131
+ var generateDefaultLabel = function generateDefaultLabel() {
132
+ if (!name && !status && !presence) {
133
+ return;
134
+ }
135
+ return "".concat(name || '', " ").concat(isStatus && !customStatusNode ? "(".concat(status, ")") : '', " ").concat(isPresence && !customPresenceNode ? "(".concat(presence, ")") : '');
136
+ };
126
137
  return jsx("div", {
127
138
  "data-testid": testId,
128
139
  style: {
@@ -144,7 +155,7 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
144
155
  isDisabled: isDisabled
145
156
  })
146
157
  }, componentProps()), testId && getTestId(testId, children)), (onClick || href) && {
147
- 'aria-label': label
158
+ 'aria-label': label || generateDefaultLabel()
148
159
  }), {}, {
149
160
  children: jsx(AvatarImage, {
150
161
  alt: name,
@@ -156,12 +167,12 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
156
167
  ref: ref
157
168
  });
158
169
  return children ? children(props) : /*#__PURE__*/createElement(getCustomElement(isDisabled, href, onClick), props);
159
- }), isValidIconSize && presence && !status && jsx(PresenceWrapper, {
170
+ }), isPresence && jsx(PresenceWrapper, {
160
171
  appearance: appearance,
161
172
  size: size,
162
173
  presence: typeof presence === 'string' ? presence : undefined,
163
174
  testId: testId
164
- }, customPresenceNode), isValidIconSize && status && jsx(StatusWrapper, {
175
+ }, customPresenceNode), isStatus && jsx(StatusWrapper, {
165
176
  appearance: appearance,
166
177
  size: size,
167
178
  borderColor: borderColor,
@@ -23,7 +23,7 @@ var nestedAvatarStyles = Object.entries(AVATAR_SIZES).reduce(function (styles, _
23
23
  key = _ref2[0],
24
24
  size = _ref2[1];
25
25
  return _objectSpread(_objectSpread({}, styles), {}, _defineProperty({}, key, css({
26
- // eslint-disable-next-line @repo/internal/styles/no-nested-styles
26
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
27
27
  '& svg': {
28
28
  width: "".concat(size, "px"),
29
29
  height: "".concat(size, "px")
@@ -22,9 +22,9 @@ export interface AvatarPropTypes {
22
22
  */
23
23
  appearance?: AppearanceType;
24
24
  /**
25
- * Used to provide better content to screen readers when using presence/status. Rather
26
- * than a screen reader speaking "online, approved, John Smith", passing in a label
27
- * allows a custom message like "John Smith (approved and online)".
25
+ * Used to provide custom content to screen readers.
26
+ * Status or presence is not added to the label by default if it passed as nodes.
27
+ * If status or presence is passed as a string, the default content format is "John Smith (online)".
28
28
  */
29
29
  label?: string;
30
30
  /**
@@ -22,9 +22,9 @@ export interface AvatarPropTypes {
22
22
  */
23
23
  appearance?: AppearanceType;
24
24
  /**
25
- * Used to provide better content to screen readers when using presence/status. Rather
26
- * than a screen reader speaking "online, approved, John Smith", passing in a label
27
- * allows a custom message like "John Smith (approved and online)".
25
+ * Used to provide custom content to screen readers.
26
+ * Status or presence is not added to the label by default if it passed as nodes.
27
+ * If status or presence is passed as a string, the default content format is "John Smith (online)".
28
28
  */
29
29
  label?: string;
30
30
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/avatar",
3
- "version": "21.3.6",
3
+ "version": "21.3.8",
4
4
  "description": "An avatar is a visual representation of a user or entity.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/analytics-next": "^9.1.0",
44
44
  "@atlaskit/icon": "^21.12.0",
45
45
  "@atlaskit/theme": "^12.5.0",
46
- "@atlaskit/tokens": "^1.11.0",
46
+ "@atlaskit/tokens": "^1.14.0",
47
47
  "@babel/runtime": "^7.0.0",
48
48
  "@emotion/react": "^11.7.1",
49
49
  "@emotion/serialize": "^1.1.0"
@@ -52,11 +52,10 @@
52
52
  "react": "^16.8.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@atlaskit/button": "^16.8.0",
56
- "@atlaskit/docs": "*",
55
+ "@af/accessibility-testing": "*",
56
+ "@af/visual-regression": "*",
57
57
  "@atlaskit/ds-lib": "^2.2.0",
58
58
  "@atlaskit/icon": "^21.12.0",
59
- "@atlaskit/section-message": "^6.4.0",
60
59
  "@atlaskit/ssr": "*",
61
60
  "@atlaskit/tooltip": "^17.8.0",
62
61
  "@atlaskit/visual-regression": "*",
@@ -65,7 +64,6 @@
65
64
  "@testing-library/react": "^12.1.5",
66
65
  "@types/jscodeshift": "^0.11.0",
67
66
  "color-contrast-checker": "^1.5.0",
68
- "jest-axe": "^4.0.0",
69
67
  "jscodeshift": "^0.13.0",
70
68
  "react-dom": "^16.8.0",
71
69
  "typescript": "~4.9.5",
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/avatar",
3
- "version": "21.3.6",
4
- "sideEffects": false
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/avatar",
3
- "version": "21.3.6",
4
- "sideEffects": false
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/avatar",
3
- "version": "21.3.6",
4
- "sideEffects": false
5
- }