@atlaskit/avatar 21.4.4 → 21.4.5
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 +6 -0
- package/dist/cjs/Avatar.js +8 -7
- package/dist/cjs/AvatarImage.js +7 -3
- package/dist/es2019/Avatar.js +8 -7
- package/dist/es2019/AvatarImage.js +7 -3
- package/dist/esm/Avatar.js +8 -7
- package/dist/esm/AvatarImage.js +7 -3
- package/dist/types/Skeleton.d.ts +12 -0
- package/dist/types-ts4.5/Skeleton.d.ts +12 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/avatar
|
|
2
2
|
|
|
3
|
+
## 21.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#67339](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67339) [`33c37b4c2c1e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/33c37b4c2c1e) - [ux] Remove nested images introduced in 21.4.3
|
|
8
|
+
|
|
3
9
|
## 21.4.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cjs/Avatar.js
CHANGED
|
@@ -23,7 +23,7 @@ var _templateObject;
|
|
|
23
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; }
|
|
24
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; }
|
|
25
25
|
var packageName = "@atlaskit/avatar";
|
|
26
|
-
var packageVersion = "21.4.
|
|
26
|
+
var packageVersion = "21.4.5";
|
|
27
27
|
|
|
28
28
|
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
29
29
|
|
|
@@ -141,10 +141,11 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
141
141
|
// if status or presence are nodes this is not added to the label by default
|
|
142
142
|
var defaultLabel = [name, isStatus && !customStatusNode && "(".concat(status, ")"), isPresence && !customPresenceNode && "(".concat(presence, ")")].filter(Boolean).join(' ');
|
|
143
143
|
var isInteractive = onClick || href || isDisabled;
|
|
144
|
+
var containerShouldBeImage = Boolean(!isInteractive && defaultLabel);
|
|
144
145
|
return (0, _react2.jsx)(AvatarContainer, {
|
|
145
146
|
"data-testid": testId,
|
|
146
|
-
role:
|
|
147
|
-
"aria-labelledby":
|
|
147
|
+
role: containerShouldBeImage ? 'img' : undefined,
|
|
148
|
+
"aria-labelledby": containerShouldBeImage ? "".concat(uuid, "-label") : undefined,
|
|
148
149
|
style: {
|
|
149
150
|
display: 'inline-block',
|
|
150
151
|
position: 'relative',
|
|
@@ -167,10 +168,10 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
167
168
|
'aria-label': label || defaultLabel
|
|
168
169
|
}), {}, {
|
|
169
170
|
children: (0, _react2.jsx)(_AvatarImage.default
|
|
170
|
-
// Only pass the name if
|
|
171
|
-
//
|
|
171
|
+
// Only pass in the name if an image is provded and the
|
|
172
|
+
// container is not being used as an `img` role
|
|
172
173
|
, {
|
|
173
|
-
alt: src ? name : undefined,
|
|
174
|
+
alt: !containerShouldBeImage && src ? name : undefined,
|
|
174
175
|
appearance: appearance,
|
|
175
176
|
size: size,
|
|
176
177
|
src: src,
|
|
@@ -190,7 +191,7 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
190
191
|
borderColor: borderColor,
|
|
191
192
|
status: typeof status === 'string' ? status : undefined,
|
|
192
193
|
testId: testId
|
|
193
|
-
}, customStatusNode),
|
|
194
|
+
}, customStatusNode), containerShouldBeImage ? (0, _react2.jsx)("span", {
|
|
194
195
|
id: "".concat(uuid, "-label"),
|
|
195
196
|
hidden: true
|
|
196
197
|
}, defaultLabel) : undefined);
|
package/dist/cjs/AvatarImage.js
CHANGED
|
@@ -59,6 +59,7 @@ var AvatarImage = function AvatarImage(_ref3) {
|
|
|
59
59
|
hasImageErrored = _useState2[0],
|
|
60
60
|
setHasImageErrored = _useState2[1];
|
|
61
61
|
var borderRadius = appearance === 'circle' ? '50%' : "".concat(_constants.AVATAR_RADIUS[size], "px");
|
|
62
|
+
var isHidden = !alt ? true : undefined;
|
|
62
63
|
|
|
63
64
|
// If src changes, reset state
|
|
64
65
|
(0, _react.useEffect)(function () {
|
|
@@ -71,12 +72,14 @@ var AvatarImage = function AvatarImage(_ref3) {
|
|
|
71
72
|
label: alt,
|
|
72
73
|
primaryColor: ICON_BACKGROUND,
|
|
73
74
|
secondaryColor: ICON_COLOR,
|
|
74
|
-
testId: testId && "".concat(testId, "--person")
|
|
75
|
+
testId: testId && "".concat(testId, "--person"),
|
|
76
|
+
"aria-hidden": isHidden
|
|
75
77
|
}) : (0, _react2.jsx)(_ship.default, {
|
|
76
78
|
label: alt,
|
|
77
79
|
primaryColor: ICON_BACKGROUND,
|
|
78
80
|
secondaryColor: ICON_COLOR,
|
|
79
|
-
testId: testId && "".concat(testId, "--ship")
|
|
81
|
+
testId: testId && "".concat(testId, "--ship"),
|
|
82
|
+
"aria-hidden": isHidden
|
|
80
83
|
}));
|
|
81
84
|
}
|
|
82
85
|
return (0, _react2.jsx)("img", {
|
|
@@ -89,7 +92,8 @@ var AvatarImage = function AvatarImage(_ref3) {
|
|
|
89
92
|
},
|
|
90
93
|
onError: function onError() {
|
|
91
94
|
return setHasImageErrored(true);
|
|
92
|
-
}
|
|
95
|
+
},
|
|
96
|
+
"aria-hidden": isHidden
|
|
93
97
|
});
|
|
94
98
|
};
|
|
95
99
|
var _default = exports.default = AvatarImage;
|
package/dist/es2019/Avatar.js
CHANGED
|
@@ -11,7 +11,7 @@ import { PresenceWrapper } from './Presence';
|
|
|
11
11
|
import { StatusWrapper } from './Status';
|
|
12
12
|
import { getButtonProps, getCustomElement, getLinkProps } from './utilities';
|
|
13
13
|
const packageName = "@atlaskit/avatar";
|
|
14
|
-
const packageVersion = "21.4.
|
|
14
|
+
const packageVersion = "21.4.5";
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
17
17
|
|
|
@@ -217,10 +217,11 @@ const Avatar = /*#__PURE__*/forwardRef(({
|
|
|
217
217
|
// if status or presence are nodes this is not added to the label by default
|
|
218
218
|
const defaultLabel = [name, isStatus && !customStatusNode && `(${status})`, isPresence && !customPresenceNode && `(${presence})`].filter(Boolean).join(' ');
|
|
219
219
|
const isInteractive = onClick || href || isDisabled;
|
|
220
|
+
const containerShouldBeImage = Boolean(!isInteractive && defaultLabel);
|
|
220
221
|
return jsx(AvatarContainer, {
|
|
221
222
|
"data-testid": testId,
|
|
222
|
-
role:
|
|
223
|
-
"aria-labelledby":
|
|
223
|
+
role: containerShouldBeImage ? 'img' : undefined,
|
|
224
|
+
"aria-labelledby": containerShouldBeImage ? `${uuid}-label` : undefined,
|
|
224
225
|
style: {
|
|
225
226
|
display: 'inline-block',
|
|
226
227
|
position: 'relative',
|
|
@@ -246,10 +247,10 @@ const Avatar = /*#__PURE__*/forwardRef(({
|
|
|
246
247
|
'aria-label': label || defaultLabel
|
|
247
248
|
}),
|
|
248
249
|
children: jsx(AvatarImage
|
|
249
|
-
// Only pass the name if
|
|
250
|
-
//
|
|
250
|
+
// Only pass in the name if an image is provded and the
|
|
251
|
+
// container is not being used as an `img` role
|
|
251
252
|
, {
|
|
252
|
-
alt: src ? name : undefined,
|
|
253
|
+
alt: !containerShouldBeImage && src ? name : undefined,
|
|
253
254
|
appearance: appearance,
|
|
254
255
|
size: size,
|
|
255
256
|
src: src,
|
|
@@ -269,7 +270,7 @@ const Avatar = /*#__PURE__*/forwardRef(({
|
|
|
269
270
|
borderColor: borderColor,
|
|
270
271
|
status: typeof status === 'string' ? status : undefined,
|
|
271
272
|
testId: testId
|
|
272
|
-
}, customStatusNode),
|
|
273
|
+
}, customStatusNode), containerShouldBeImage ? jsx("span", {
|
|
273
274
|
id: `${uuid}-label`,
|
|
274
275
|
hidden: true
|
|
275
276
|
}, defaultLabel) : undefined);
|
|
@@ -47,6 +47,7 @@ const AvatarImage = ({
|
|
|
47
47
|
}) => {
|
|
48
48
|
const [hasImageErrored, setHasImageErrored] = useState(false);
|
|
49
49
|
const borderRadius = appearance === 'circle' ? '50%' : `${AVATAR_RADIUS[size]}px`;
|
|
50
|
+
const isHidden = !alt ? true : undefined;
|
|
50
51
|
|
|
51
52
|
// If src changes, reset state
|
|
52
53
|
useEffect(() => {
|
|
@@ -59,12 +60,14 @@ const AvatarImage = ({
|
|
|
59
60
|
label: alt,
|
|
60
61
|
primaryColor: ICON_BACKGROUND,
|
|
61
62
|
secondaryColor: ICON_COLOR,
|
|
62
|
-
testId: testId && `${testId}--person
|
|
63
|
+
testId: testId && `${testId}--person`,
|
|
64
|
+
"aria-hidden": isHidden
|
|
63
65
|
}) : jsx(ShipIcon, {
|
|
64
66
|
label: alt,
|
|
65
67
|
primaryColor: ICON_BACKGROUND,
|
|
66
68
|
secondaryColor: ICON_COLOR,
|
|
67
|
-
testId: testId && `${testId}--ship
|
|
69
|
+
testId: testId && `${testId}--ship`,
|
|
70
|
+
"aria-hidden": isHidden
|
|
68
71
|
}));
|
|
69
72
|
}
|
|
70
73
|
return jsx("img", {
|
|
@@ -75,7 +78,8 @@ const AvatarImage = ({
|
|
|
75
78
|
style: {
|
|
76
79
|
borderRadius: borderRadius
|
|
77
80
|
},
|
|
78
|
-
onError: () => setHasImageErrored(true)
|
|
81
|
+
onError: () => setHasImageErrored(true),
|
|
82
|
+
"aria-hidden": isHidden
|
|
79
83
|
});
|
|
80
84
|
};
|
|
81
85
|
export default AvatarImage;
|
package/dist/esm/Avatar.js
CHANGED
|
@@ -16,7 +16,7 @@ import { PresenceWrapper } from './Presence';
|
|
|
16
16
|
import { StatusWrapper } from './Status';
|
|
17
17
|
import { getButtonProps, getCustomElement, getLinkProps } from './utilities';
|
|
18
18
|
var packageName = "@atlaskit/avatar";
|
|
19
|
-
var packageVersion = "21.4.
|
|
19
|
+
var packageVersion = "21.4.5";
|
|
20
20
|
|
|
21
21
|
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
22
22
|
|
|
@@ -134,10 +134,11 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
134
134
|
// if status or presence are nodes this is not added to the label by default
|
|
135
135
|
var defaultLabel = [name, isStatus && !customStatusNode && "(".concat(status, ")"), isPresence && !customPresenceNode && "(".concat(presence, ")")].filter(Boolean).join(' ');
|
|
136
136
|
var isInteractive = onClick || href || isDisabled;
|
|
137
|
+
var containerShouldBeImage = Boolean(!isInteractive && defaultLabel);
|
|
137
138
|
return jsx(AvatarContainer, {
|
|
138
139
|
"data-testid": testId,
|
|
139
|
-
role:
|
|
140
|
-
"aria-labelledby":
|
|
140
|
+
role: containerShouldBeImage ? 'img' : undefined,
|
|
141
|
+
"aria-labelledby": containerShouldBeImage ? "".concat(uuid, "-label") : undefined,
|
|
141
142
|
style: {
|
|
142
143
|
display: 'inline-block',
|
|
143
144
|
position: 'relative',
|
|
@@ -160,10 +161,10 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
160
161
|
'aria-label': label || defaultLabel
|
|
161
162
|
}), {}, {
|
|
162
163
|
children: jsx(AvatarImage
|
|
163
|
-
// Only pass the name if
|
|
164
|
-
//
|
|
164
|
+
// Only pass in the name if an image is provded and the
|
|
165
|
+
// container is not being used as an `img` role
|
|
165
166
|
, {
|
|
166
|
-
alt: src ? name : undefined,
|
|
167
|
+
alt: !containerShouldBeImage && src ? name : undefined,
|
|
167
168
|
appearance: appearance,
|
|
168
169
|
size: size,
|
|
169
170
|
src: src,
|
|
@@ -183,7 +184,7 @@ var Avatar = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
183
184
|
borderColor: borderColor,
|
|
184
185
|
status: typeof status === 'string' ? status : undefined,
|
|
185
186
|
testId: testId
|
|
186
|
-
}, customStatusNode),
|
|
187
|
+
}, customStatusNode), containerShouldBeImage ? jsx("span", {
|
|
187
188
|
id: "".concat(uuid, "-label"),
|
|
188
189
|
hidden: true
|
|
189
190
|
}, defaultLabel) : undefined);
|
package/dist/esm/AvatarImage.js
CHANGED
|
@@ -54,6 +54,7 @@ var AvatarImage = function AvatarImage(_ref3) {
|
|
|
54
54
|
hasImageErrored = _useState2[0],
|
|
55
55
|
setHasImageErrored = _useState2[1];
|
|
56
56
|
var borderRadius = appearance === 'circle' ? '50%' : "".concat(AVATAR_RADIUS[size], "px");
|
|
57
|
+
var isHidden = !alt ? true : undefined;
|
|
57
58
|
|
|
58
59
|
// If src changes, reset state
|
|
59
60
|
useEffect(function () {
|
|
@@ -66,12 +67,14 @@ var AvatarImage = function AvatarImage(_ref3) {
|
|
|
66
67
|
label: alt,
|
|
67
68
|
primaryColor: ICON_BACKGROUND,
|
|
68
69
|
secondaryColor: ICON_COLOR,
|
|
69
|
-
testId: testId && "".concat(testId, "--person")
|
|
70
|
+
testId: testId && "".concat(testId, "--person"),
|
|
71
|
+
"aria-hidden": isHidden
|
|
70
72
|
}) : jsx(ShipIcon, {
|
|
71
73
|
label: alt,
|
|
72
74
|
primaryColor: ICON_BACKGROUND,
|
|
73
75
|
secondaryColor: ICON_COLOR,
|
|
74
|
-
testId: testId && "".concat(testId, "--ship")
|
|
76
|
+
testId: testId && "".concat(testId, "--ship"),
|
|
77
|
+
"aria-hidden": isHidden
|
|
75
78
|
}));
|
|
76
79
|
}
|
|
77
80
|
return jsx("img", {
|
|
@@ -84,7 +87,8 @@ var AvatarImage = function AvatarImage(_ref3) {
|
|
|
84
87
|
},
|
|
85
88
|
onError: function onError() {
|
|
86
89
|
return setHasImageErrored(true);
|
|
87
|
-
}
|
|
90
|
+
},
|
|
91
|
+
"aria-hidden": isHidden
|
|
88
92
|
});
|
|
89
93
|
};
|
|
90
94
|
export default AvatarImage;
|
package/dist/types/Skeleton.d.ts
CHANGED
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { AppearanceType, SizeType } from './types';
|
|
4
4
|
export interface SkeletonProps {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates the shape of the avatar skeleton. Most avatars are circular, but square avatars can be used for container objects.
|
|
7
|
+
*/
|
|
5
8
|
appearance?: AppearanceType;
|
|
9
|
+
/**
|
|
10
|
+
* Color of the skeleton. By default, it will inherit the current text color.
|
|
11
|
+
*/
|
|
6
12
|
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Defines the size of the avatar skeleton.
|
|
15
|
+
*/
|
|
7
16
|
size?: SizeType;
|
|
17
|
+
/**
|
|
18
|
+
* Defines the opacity of the avatar skeleton. Use `weight="normal"` for the default opacity, or `weight="strong"` for a bolder opacity.
|
|
19
|
+
*/
|
|
8
20
|
weight?: 'normal' | 'strong';
|
|
9
21
|
}
|
|
10
22
|
/**
|
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { AppearanceType, SizeType } from './types';
|
|
4
4
|
export interface SkeletonProps {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates the shape of the avatar skeleton. Most avatars are circular, but square avatars can be used for container objects.
|
|
7
|
+
*/
|
|
5
8
|
appearance?: AppearanceType;
|
|
9
|
+
/**
|
|
10
|
+
* Color of the skeleton. By default, it will inherit the current text color.
|
|
11
|
+
*/
|
|
6
12
|
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Defines the size of the avatar skeleton.
|
|
15
|
+
*/
|
|
7
16
|
size?: SizeType;
|
|
17
|
+
/**
|
|
18
|
+
* Defines the opacity of the avatar skeleton. Use `weight="normal"` for the default opacity, or `weight="strong"` for a bolder opacity.
|
|
19
|
+
*/
|
|
8
20
|
weight?: 'normal' | 'strong';
|
|
9
21
|
}
|
|
10
22
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/avatar",
|
|
3
|
-
"version": "21.4.
|
|
3
|
+
"version": "21.4.5",
|
|
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,7 +46,7 @@
|
|
|
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.
|
|
49
|
+
"@atlaskit/tokens": "^1.34.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@emotion/react": "^11.7.1",
|
|
52
52
|
"@emotion/serialize": "^1.1.0",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"@testing-library/react": "^12.1.5",
|
|
68
68
|
"@types/jscodeshift": "^0.11.0",
|
|
69
69
|
"color-contrast-checker": "^1.5.0",
|
|
70
|
+
"jest-in-case": "^1.0.2",
|
|
70
71
|
"jscodeshift": "^0.13.0",
|
|
71
72
|
"react-dom": "^16.8.0",
|
|
72
73
|
"typescript": "~4.9.5",
|