@atlaskit/avatar 22.0.0 → 23.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/cjs/avatar-content.js +217 -0
- package/dist/cjs/avatar.js +55 -103
- package/dist/cjs/context.js +31 -1
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/{avatar-image.js → internal/avatar-image.js} +1 -1
- package/dist/cjs/{icon-wrapper.js → internal/icon-wrapper.js} +1 -1
- package/dist/cjs/presence.js +1 -1
- package/dist/cjs/status.js +1 -1
- package/dist/es2019/avatar-content.js +213 -0
- package/dist/es2019/avatar.js +38 -169
- package/dist/es2019/context.js +29 -1
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/{avatar-image.js → internal/avatar-image.js} +1 -1
- package/dist/es2019/{icon-wrapper.js → internal/icon-wrapper.js} +1 -1
- package/dist/es2019/presence.js +1 -1
- package/dist/es2019/status.js +1 -1
- package/dist/esm/avatar-content.js +209 -0
- package/dist/esm/avatar.js +58 -103
- package/dist/esm/context.js +30 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/{avatar-image.js → internal/avatar-image.js} +1 -1
- package/dist/esm/{icon-wrapper.js → internal/icon-wrapper.js} +1 -1
- package/dist/esm/presence.js +1 -1
- package/dist/esm/status.js +1 -1
- package/dist/types/avatar-content.d.ts +21 -0
- package/dist/types/avatar.d.ts +2 -15
- package/dist/types/context.d.ts +33 -2
- package/dist/types/index.d.ts +2 -1
- package/dist/types/{avatar-image.d.ts → internal/avatar-image.d.ts} +1 -1
- package/dist/types/utilities.d.ts +1 -1
- package/dist/types-ts4.5/avatar-content.d.ts +21 -0
- package/dist/types-ts4.5/avatar.d.ts +2 -15
- package/dist/types-ts4.5/context.d.ts +33 -2
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/{avatar-image.d.ts → internal/avatar-image.d.ts} +1 -1
- package/dist/types-ts4.5/utilities.d.ts +1 -1
- package/package.json +3 -3
- /package/dist/types/{icon-wrapper.d.ts → internal/icon-wrapper.d.ts} +0 -0
- /package/dist/types-ts4.5/{icon-wrapper.d.ts → internal/icon-wrapper.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# @atlaskit/avatar
|
|
2
2
|
|
|
3
|
+
## 23.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#117222](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117222)
|
|
8
|
+
[`a80e8994489e7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a80e8994489e7) -
|
|
9
|
+
Removes the option to provide a function to the `children` prop to create a custom avatar. A new
|
|
10
|
+
`AvatarContent` sub-component is now available, which similarly enables custom content to be
|
|
11
|
+
provided for the avatar. This change is in preparation for the migration from `@emotion/react` to
|
|
12
|
+
Compiled CSS-in-JS.
|
|
13
|
+
|
|
14
|
+
Example usage before and after:
|
|
15
|
+
|
|
16
|
+
### Before
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
import Avatar from '@atlaskit/avatar';
|
|
20
|
+
|
|
21
|
+
<Avatar>
|
|
22
|
+
{(props) => (
|
|
23
|
+
<span {...props}>
|
|
24
|
+
Custom content
|
|
25
|
+
</span>
|
|
26
|
+
)}
|
|
27
|
+
<Avatar>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### After
|
|
31
|
+
|
|
32
|
+
```jsx
|
|
33
|
+
import Avatar, { AvatarContent } from '@atlaskit/avatar';
|
|
34
|
+
|
|
35
|
+
<Avatar>
|
|
36
|
+
<AvatarContent>
|
|
37
|
+
Custom content
|
|
38
|
+
</AvatarContent>
|
|
39
|
+
<Avatar>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies
|
|
45
|
+
|
|
3
46
|
## 22.0.0
|
|
4
47
|
|
|
5
48
|
### Major Changes
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AvatarContent = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _react2 = require("@emotion/react");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
14
|
+
var _context = require("./context");
|
|
15
|
+
/**
|
|
16
|
+
* @jsxRuntime classic
|
|
17
|
+
* @jsx jsx
|
|
18
|
+
* @jsxFrag
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
var boxShadowCssVar = '--avatar-box-shadow';
|
|
22
|
+
var bgColorCssVar = '--avatar-bg-color';
|
|
23
|
+
var styles = {
|
|
24
|
+
root: (0, _react2.css)({
|
|
25
|
+
display: 'flex',
|
|
26
|
+
boxSizing: 'content-box',
|
|
27
|
+
position: 'static',
|
|
28
|
+
alignItems: 'stretch',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
backgroundColor: "var(".concat(bgColorCssVar, ")"),
|
|
32
|
+
border: 'none',
|
|
33
|
+
boxShadow: "var(".concat(boxShadowCssVar, ")"),
|
|
34
|
+
cursor: 'inherit',
|
|
35
|
+
marginBlockEnd: "var(--ds-space-025, 2px)",
|
|
36
|
+
marginBlockStart: "var(--ds-space-025, 2px)",
|
|
37
|
+
marginInlineEnd: "var(--ds-space-025, 2px)",
|
|
38
|
+
marginInlineStart: "var(--ds-space-025, 2px)",
|
|
39
|
+
outline: 'none',
|
|
40
|
+
overflow: 'hidden',
|
|
41
|
+
paddingBlockEnd: "var(--ds-space-0, 0px)",
|
|
42
|
+
paddingBlockStart: "var(--ds-space-0, 0px)",
|
|
43
|
+
paddingInlineEnd: "var(--ds-space-0, 0px)",
|
|
44
|
+
paddingInlineStart: "var(--ds-space-0, 0px)",
|
|
45
|
+
transform: 'translateZ(0)',
|
|
46
|
+
transition: 'transform 200ms, opacity 200ms',
|
|
47
|
+
'&::after': {
|
|
48
|
+
width: '100%',
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
inset: "var(--ds-space-0, 0px)",
|
|
51
|
+
backgroundColor: 'transparent',
|
|
52
|
+
content: "' '",
|
|
53
|
+
opacity: 0,
|
|
54
|
+
pointerEvents: 'none',
|
|
55
|
+
transition: 'opacity 200ms'
|
|
56
|
+
},
|
|
57
|
+
'&:focus-visible': {
|
|
58
|
+
boxShadow: 'none',
|
|
59
|
+
outlineColor: "var(--ds-border-focused, #2684FF)",
|
|
60
|
+
outlineOffset: "var(--ds-border-width-outline, 2px)",
|
|
61
|
+
outlineStyle: 'solid',
|
|
62
|
+
outlineWidth: "var(--ds-border-width-outline, 2px)"
|
|
63
|
+
},
|
|
64
|
+
'@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
|
|
65
|
+
'&:focus-visible': {
|
|
66
|
+
outlineWidth: "var(--ds-border-width, 1px)"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
circle: (0, _react2.css)({
|
|
71
|
+
borderRadius: "var(--ds-border-radius-circle, 50%)",
|
|
72
|
+
'&::after': {
|
|
73
|
+
borderRadius: "var(--ds-border-radius-circle, 50%)"
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
positionRelative: (0, _react2.css)({
|
|
77
|
+
position: 'relative'
|
|
78
|
+
}),
|
|
79
|
+
interactive: (0, _react2.css)({
|
|
80
|
+
cursor: 'pointer',
|
|
81
|
+
'&:hover': {
|
|
82
|
+
'&::after': {
|
|
83
|
+
backgroundColor: "var(--ds-interaction-hovered, ".concat(_colors.N70A, ")"),
|
|
84
|
+
opacity: 1
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
'&:active': {
|
|
88
|
+
transform: "scale(0.9)",
|
|
89
|
+
'&::after': {
|
|
90
|
+
backgroundColor: "var(--ds-interaction-pressed, ".concat(_colors.N70A, ")"),
|
|
91
|
+
opacity: 1
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
'@media screen and (forced-colors: active)': {
|
|
95
|
+
'&:focus-visible': {
|
|
96
|
+
outlineWidth: 1
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}),
|
|
100
|
+
disabled: (0, _react2.css)({
|
|
101
|
+
cursor: 'not-allowed',
|
|
102
|
+
'&::after': {
|
|
103
|
+
backgroundColor: "var(--ds-surface, ".concat(_colors.N0, ")"),
|
|
104
|
+
opacity: "var(--ds-opacity-disabled, 0.7)"
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
var widthHeightMap = {
|
|
109
|
+
xsmall: (0, _react2.css)({
|
|
110
|
+
width: '16px',
|
|
111
|
+
height: '16px'
|
|
112
|
+
}),
|
|
113
|
+
small: (0, _react2.css)({
|
|
114
|
+
width: '24px',
|
|
115
|
+
height: '24px'
|
|
116
|
+
}),
|
|
117
|
+
medium: (0, _react2.css)({
|
|
118
|
+
width: '32px',
|
|
119
|
+
height: '32px'
|
|
120
|
+
}),
|
|
121
|
+
large: (0, _react2.css)({
|
|
122
|
+
width: '40px',
|
|
123
|
+
height: '40px'
|
|
124
|
+
}),
|
|
125
|
+
xlarge: (0, _react2.css)({
|
|
126
|
+
width: '96px',
|
|
127
|
+
height: '96px'
|
|
128
|
+
}),
|
|
129
|
+
xxlarge: (0, _react2.css)({
|
|
130
|
+
width: '128px',
|
|
131
|
+
height: '128px'
|
|
132
|
+
})
|
|
133
|
+
};
|
|
134
|
+
var borderRadiusMap = {
|
|
135
|
+
xsmall: (0, _react2.css)({
|
|
136
|
+
borderRadius: '2px',
|
|
137
|
+
'&::after': {
|
|
138
|
+
borderRadius: '2px'
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
small: (0, _react2.css)({
|
|
142
|
+
borderRadius: '2px',
|
|
143
|
+
'&::after': {
|
|
144
|
+
borderRadius: '2px'
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
medium: (0, _react2.css)({
|
|
148
|
+
borderRadius: '3px',
|
|
149
|
+
'&::after': {
|
|
150
|
+
borderRadius: '3px'
|
|
151
|
+
}
|
|
152
|
+
}),
|
|
153
|
+
large: (0, _react2.css)({
|
|
154
|
+
borderRadius: '3px',
|
|
155
|
+
'&::after': {
|
|
156
|
+
borderRadius: '3px'
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
xlarge: (0, _react2.css)({
|
|
160
|
+
borderRadius: '6px',
|
|
161
|
+
'&::after': {
|
|
162
|
+
borderRadius: '6px'
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
xxlarge: (0, _react2.css)({
|
|
166
|
+
borderRadius: '12px',
|
|
167
|
+
'&::after': {
|
|
168
|
+
borderRadius: '12px'
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* __Avatar content__
|
|
174
|
+
*
|
|
175
|
+
* Avatar content renders the avatar content. It can be composed with the Avatar component
|
|
176
|
+
* to create a custom avatar.
|
|
177
|
+
*
|
|
178
|
+
* - [Examples](https://atlassian.design/components/avatar/examples)
|
|
179
|
+
* - [Code](https://atlassian.design/components/avatar/code)
|
|
180
|
+
* - [Usage](https://atlassian.design/components/avatar/usage)
|
|
181
|
+
*/
|
|
182
|
+
var AvatarContent = exports.AvatarContent = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
183
|
+
var children = _ref.children;
|
|
184
|
+
(0, _context.useEnsureIsInsideAvatar)();
|
|
185
|
+
var _useAvatarContent = (0, _context.useAvatarContent)(),
|
|
186
|
+
Container = _useAvatarContent.as,
|
|
187
|
+
appearance = _useAvatarContent.appearance,
|
|
188
|
+
avatarImage = _useAvatarContent.avatarImage,
|
|
189
|
+
_useAvatarContent$bor = _useAvatarContent.borderColor,
|
|
190
|
+
borderColor = _useAvatarContent$bor === void 0 ? (0, _platformFeatureFlags.fg)('platform-component-visual-refresh') ? "var(--ds-surface, #FFFFFF)" : "var(--ds-surface-overlay, ".concat(_colors.N0, ")") : _useAvatarContent$bor,
|
|
191
|
+
href = _useAvatarContent.href,
|
|
192
|
+
isDisabled = _useAvatarContent.isDisabled,
|
|
193
|
+
label = _useAvatarContent.label,
|
|
194
|
+
onClick = _useAvatarContent.onClick,
|
|
195
|
+
contextRef = _useAvatarContent.ref,
|
|
196
|
+
tabIndex = _useAvatarContent.tabIndex,
|
|
197
|
+
target = _useAvatarContent.target,
|
|
198
|
+
testId = _useAvatarContent.testId,
|
|
199
|
+
size = _useAvatarContent.size,
|
|
200
|
+
stackIndex = _useAvatarContent.stackIndex;
|
|
201
|
+
var isInteractive = Boolean(onClick || href || isDisabled);
|
|
202
|
+
return (0, _react2.jsx)(Container, (0, _extends2.default)({
|
|
203
|
+
css: [styles.root, borderRadiusMap[size], appearance === 'circle' && styles.circle, widthHeightMap[size], stackIndex !== undefined && styles.positionRelative, isInteractive && !isDisabled && styles.interactive, isDisabled && styles.disabled],
|
|
204
|
+
style: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, bgColorCssVar, borderColor), boxShadowCssVar, "0 0 0 2px ".concat(borderColor)),
|
|
205
|
+
ref: ref || contextRef,
|
|
206
|
+
"aria-label": isInteractive ? label : undefined,
|
|
207
|
+
onClick: onClick,
|
|
208
|
+
tabIndex: tabIndex,
|
|
209
|
+
"data-testid": testId,
|
|
210
|
+
disabled: isDisabled,
|
|
211
|
+
type: Container === 'button' ? 'button' : undefined
|
|
212
|
+
}, href && {
|
|
213
|
+
href: href,
|
|
214
|
+
target: target,
|
|
215
|
+
rel: target === '_blank' ? 'noopener noreferrer' : undefined
|
|
216
|
+
}), children || avatarImage);
|
|
217
|
+
});
|
package/dist/cjs/avatar.js
CHANGED
|
@@ -6,53 +6,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
10
9
|
var _react = require("react");
|
|
11
10
|
var _react2 = require("@emotion/react");
|
|
12
11
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
13
12
|
var _useId = require("@atlaskit/ds-lib/use-id");
|
|
14
|
-
var
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
17
|
-
var _avatarImage = _interopRequireDefault(require("./avatar-image"));
|
|
18
|
-
var _constants = require("./constants");
|
|
13
|
+
var _avatarContent = require("./avatar-content");
|
|
19
14
|
var _context = require("./context");
|
|
15
|
+
var _avatarImage = _interopRequireDefault(require("./internal/avatar-image"));
|
|
20
16
|
var _presence = require("./presence");
|
|
21
17
|
var _status = require("./status");
|
|
22
18
|
var _utilities = require("./utilities");
|
|
23
|
-
var
|
|
24
|
-
/**
|
|
19
|
+
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; }
|
|
20
|
+
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
21
|
* @jsxRuntime classic
|
|
26
22
|
* @jsx jsx
|
|
27
|
-
*/
|
|
28
|
-
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; }
|
|
29
|
-
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; }
|
|
23
|
+
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
30
24
|
var packageName = "@atlaskit/avatar";
|
|
31
|
-
var packageVersion = "
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
};
|
|
25
|
+
var packageVersion = "23.0.0";
|
|
26
|
+
var containerStyles = (0, _react2.css)({
|
|
27
|
+
display: 'inline-block',
|
|
28
|
+
position: 'relative',
|
|
29
|
+
outline: 0
|
|
30
|
+
});
|
|
39
31
|
|
|
40
32
|
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
41
33
|
|
|
42
|
-
var getStyles = function getStyles(css, _ref) {
|
|
43
|
-
var size = _ref.size,
|
|
44
|
-
radius = _ref.radius,
|
|
45
|
-
appearance = _ref.appearance,
|
|
46
|
-
_ref$borderColor = _ref.borderColor,
|
|
47
|
-
borderColor = _ref$borderColor === void 0 ? (0, _platformFeatureFlags.fg)('platform-component-visual-refresh') ? "var(--ds-surface, #FFFFFF)" : "var(--ds-surface-overlay, ".concat(_colors.N0, ")") : _ref$borderColor,
|
|
48
|
-
stackIndex = _ref.stackIndex,
|
|
49
|
-
isInteractive = _ref.isInteractive,
|
|
50
|
-
isDisabled = _ref.isDisabled;
|
|
51
|
-
return (//eslint-disable-next-line @repo/internal/react/no-css-string-literals
|
|
52
|
-
css(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\t\theight: ", "px;\n\t\twidth: ", "px;\n\t\talign-items: stretch;\n\t\tbackground-color: ", ";\n\t\tborder-radius: ", ";\n\t\tbox-sizing: content-box;\n\t\tcursor: inherit;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tjustify-content: center;\n\t\toutline: none;\n\t\toverflow: hidden;\n\t\tposition: static;\n\t\ttransform: translateZ(0);\n\t\ttransition:\n\t\t\ttransform 200ms,\n\t\t\topacity 200ms;\n\t\tbox-shadow: 0 0 0 ", "px ", ";\n\t\tborder: none;\n\t\tmargin: ", ";\n\t\tpadding: ", ";\n\n\t\t&::-moz-focus-inner {\n\t\t\tborder: 0;\n\t\t\tmargin: ", ";\n\t\t\tpadding: ", ";\n\t\t}\n\n\t\t&::after {\n\t\t\tbackground-color: transparent;\n\t\t\tinset: 0px;\n\n\t\t\t/* Added border-radius style to fix hover issue in safari */\n\t\t\tborder-radius: ", ";\n\t\t\tcontent: ' ';\n\t\t\topacity: 0;\n\t\t\tpointer-events: none;\n\t\t\tposition: absolute;\n\t\t\ttransition: opacity 200ms;\n\t\t\twidth: 100%;\n\t\t}\n\n\t\t:focus-visible {\n\t\t\tbox-shadow: none;\n\t\t}\n\n\t\t", "\n\n\t\t", "\n\n ", "\n\t"])), size, size, borderColor, appearance === 'circle' ? '50%' : "".concat(radius, "px"), _constants.BORDER_WIDTH, borderColor, "var(--ds-space-025, 2px)", "var(--ds-space-0, 0px)", "var(--ds-space-0, 0px)", "var(--ds-space-0, 0px)", appearance === 'circle' ? '50%' : "".concat(radius, "px"), stackIndex && "position: relative;", isInteractive && "\n cursor: pointer;\n\n :hover {\n &::after {\n background-color: ".concat("var(--ds-interaction-hovered, ".concat(_colors.N70A, ")"), ";\n opacity: 1;\n }\n }\n\n :active {\n &::after {\n background-color: ", "var(--ds-interaction-pressed, ".concat(_colors.N70A, ")"), ";\n opacity: 1;\n }\n }\n\n :active {\n transform: scale(", _constants.ACTIVE_SCALE_FACTOR, ");\n }\n\n @media screen and (forced-colors: active) {\n &:focus-visible {\n outline: 1px solid\n }\n }\n "), isDisabled && "\n cursor: not-allowed;\n\n &::after {\n opacity: ".concat("var(--ds-opacity-disabled, 0.7)", ";\n pointer-events: none;\n background-color: ", "var(--ds-surface, ".concat(_colors.N0, ")"), ";\n }\n "))
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
34
|
/**
|
|
57
35
|
* __Avatar__
|
|
58
36
|
*
|
|
@@ -62,31 +40,30 @@ var getStyles = function getStyles(css, _ref) {
|
|
|
62
40
|
* - [Code](https://atlassian.design/components/avatar/code)
|
|
63
41
|
* - [Usage](https://atlassian.design/components/avatar/usage)
|
|
64
42
|
*/
|
|
65
|
-
var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
AvatarContainer = _ref2$as === void 0 ? 'div' : _ref2$as;
|
|
43
|
+
var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
44
|
+
var analyticsContext = _ref.analyticsContext,
|
|
45
|
+
_ref$appearance = _ref.appearance,
|
|
46
|
+
appearance = _ref$appearance === void 0 ? 'circle' : _ref$appearance,
|
|
47
|
+
label = _ref.label,
|
|
48
|
+
borderColor = _ref.borderColor,
|
|
49
|
+
children = _ref.children,
|
|
50
|
+
href = _ref.href,
|
|
51
|
+
isDisabled = _ref.isDisabled,
|
|
52
|
+
name = _ref.name,
|
|
53
|
+
onClick = _ref.onClick,
|
|
54
|
+
presence = _ref.presence,
|
|
55
|
+
sizeProp = _ref.size,
|
|
56
|
+
src = _ref.src,
|
|
57
|
+
stackIndex = _ref.stackIndex,
|
|
58
|
+
status = _ref.status,
|
|
59
|
+
target = _ref.target,
|
|
60
|
+
testId = _ref.testId,
|
|
61
|
+
_ref$as = _ref.as,
|
|
62
|
+
AvatarContainer = _ref$as === void 0 ? 'div' : _ref$as;
|
|
86
63
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
87
64
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
88
65
|
var context = (0, _context.useAvatarContext)();
|
|
89
|
-
var size =
|
|
66
|
+
var size = sizeProp || (context === null || context === void 0 ? void 0 : context.size) || 'medium';
|
|
90
67
|
var customPresenceNode = /*#__PURE__*/(0, _react.isValidElement)(presence) ? presence : null;
|
|
91
68
|
var customStatusNode = /*#__PURE__*/(0, _react.isValidElement)(status) ? status : null;
|
|
92
69
|
var isValidIconSize = size !== 'xxlarge' && size !== 'xsmall';
|
|
@@ -129,18 +106,6 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
129
106
|
}
|
|
130
107
|
onClick(event, analyticsEvent);
|
|
131
108
|
}, [createAnalyticsEvent, isDisabled, onClick]);
|
|
132
|
-
var componentProps = function componentProps() {
|
|
133
|
-
if (isDisabled) {
|
|
134
|
-
return {
|
|
135
|
-
disabled: true
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// return only relevant props for either anchor or button elements
|
|
140
|
-
return _objectSpread(_objectSpread({}, href && (0, _utilities.getLinkProps)(href, target)), onClick && !href ? (0, _utilities.getButtonProps)(onClickHandler) : {
|
|
141
|
-
onClick: onClick
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
109
|
var isPresence = isValidIconSize && presence && !status;
|
|
145
110
|
var isStatus = isValidIconSize && status;
|
|
146
111
|
|
|
@@ -149,52 +114,39 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
149
114
|
var defaultLabel = [name, isStatus && !customStatusNode && "(".concat(status, ")"), isPresence && !customPresenceNode && "(".concat(presence, ")")].filter(Boolean).join(' ');
|
|
150
115
|
var isInteractive = onClick || href || isDisabled;
|
|
151
116
|
var containerShouldBeImage = Boolean(!isInteractive && defaultLabel);
|
|
152
|
-
return (0, _react2.jsx)(
|
|
117
|
+
return (0, _react2.jsx)(_context.EnsureIsInsideAvatarContext.Provider, {
|
|
118
|
+
value: true
|
|
119
|
+
}, (0, _react2.jsx)(AvatarContainer, {
|
|
153
120
|
"data-testid": testId,
|
|
154
121
|
role: containerShouldBeImage ? 'img' : undefined,
|
|
155
122
|
"aria-labelledby": containerShouldBeImage ? labelId : undefined,
|
|
123
|
+
css: containerStyles,
|
|
156
124
|
style: {
|
|
157
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
158
|
-
display: 'inline-block',
|
|
159
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
160
|
-
position: 'relative',
|
|
161
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
162
|
-
outline: 0,
|
|
163
125
|
zIndex: stackIndex
|
|
164
126
|
}
|
|
165
|
-
}, (0, _react2.jsx)(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
children: (0, _react2.jsx)(_avatarImage.default
|
|
181
|
-
// Only pass in the name if an image is provided and the
|
|
182
|
-
// container is not being used as an `img` role
|
|
183
|
-
, {
|
|
127
|
+
}, (0, _react2.jsx)(_context.AvatarContentContext.Provider, {
|
|
128
|
+
value: {
|
|
129
|
+
as: (0, _utilities.getCustomElement)(isDisabled, href, onClick),
|
|
130
|
+
appearance: appearance,
|
|
131
|
+
borderColor: borderColor,
|
|
132
|
+
href: href,
|
|
133
|
+
isDisabled: isDisabled,
|
|
134
|
+
label: label || defaultLabel,
|
|
135
|
+
onClick: isInteractive ? onClickHandler : undefined,
|
|
136
|
+
ref: ref,
|
|
137
|
+
size: size,
|
|
138
|
+
stackIndex: stackIndex,
|
|
139
|
+
target: target,
|
|
140
|
+
testId: testId ? "".concat(testId, "--inner") : undefined,
|
|
141
|
+
avatarImage: (0, _react2.jsx)(_avatarImage.default, {
|
|
184
142
|
alt: !containerShouldBeImage && src ? name : undefined,
|
|
143
|
+
src: src,
|
|
185
144
|
appearance: appearance,
|
|
186
145
|
size: size,
|
|
187
|
-
src: src,
|
|
188
146
|
testId: testId
|
|
189
|
-
})
|
|
190
|
-
ref: ref
|
|
191
|
-
});
|
|
192
|
-
if (children) {
|
|
193
|
-
return children(props);
|
|
147
|
+
})
|
|
194
148
|
}
|
|
195
|
-
|
|
196
|
-
return element === 'a' || element === 'button' ? (0, _react2.jsx)(_focusRing.default, null, /*#__PURE__*/(0, _react.createElement)(element, props)) : ( /*#__PURE__*/(0, _react.createElement)(element, props));
|
|
197
|
-
}), isPresence && (0, _react2.jsx)(_presence.PresenceWrapper, {
|
|
149
|
+
}, children || (0, _react2.jsx)(_avatarContent.AvatarContent, null)), isPresence && (0, _react2.jsx)(_presence.PresenceWrapper, {
|
|
198
150
|
appearance: appearance,
|
|
199
151
|
size: size,
|
|
200
152
|
presence: typeof presence === 'string' ? presence : undefined,
|
|
@@ -209,7 +161,7 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
209
161
|
"data-testid": testId && "".concat(testId, "--label"),
|
|
210
162
|
id: labelId,
|
|
211
163
|
hidden: true
|
|
212
|
-
}, defaultLabel) : undefined);
|
|
164
|
+
}, defaultLabel) : undefined));
|
|
213
165
|
});
|
|
214
166
|
Avatar.displayName = 'Avatar';
|
|
215
167
|
var _default = exports.default = Avatar;
|
package/dist/cjs/context.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useAvatarContext = exports.AvatarContext = void 0;
|
|
6
|
+
exports.useEnsureIsInsideAvatar = exports.useAvatarContext = exports.useAvatarContent = exports.EnsureIsInsideAvatarContext = exports.AvatarContext = exports.AvatarContentContext = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
/**
|
|
9
9
|
* __Avatar context__
|
|
@@ -21,4 +21,34 @@ var _react = require("react");
|
|
|
21
21
|
var AvatarContext = exports.AvatarContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
22
22
|
var useAvatarContext = exports.useAvatarContext = function useAvatarContext() {
|
|
23
23
|
return (0, _react.useContext)(AvatarContext);
|
|
24
|
+
};
|
|
25
|
+
var defaultAvatarContentProps = {
|
|
26
|
+
as: 'span',
|
|
27
|
+
appearance: 'circle',
|
|
28
|
+
avatarImage: null,
|
|
29
|
+
ref: null,
|
|
30
|
+
size: 'medium'
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* __Avatar content context__
|
|
35
|
+
*
|
|
36
|
+
* This context provides the props for the AvatarContent component, enabling
|
|
37
|
+
* consumers to compose the AvatarContent with the Avatar component.
|
|
38
|
+
*/
|
|
39
|
+
var AvatarContentContext = exports.AvatarContentContext = /*#__PURE__*/(0, _react.createContext)(defaultAvatarContentProps);
|
|
40
|
+
var useAvatarContent = exports.useAvatarContent = function useAvatarContent() {
|
|
41
|
+
return (0, _react.useContext)(AvatarContentContext);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Used to ensure Avatar sub-components are used within a Avatar component,
|
|
46
|
+
* and provide a useful error message if not.
|
|
47
|
+
*/
|
|
48
|
+
var EnsureIsInsideAvatarContext = exports.EnsureIsInsideAvatarContext = /*#__PURE__*/(0, _react.createContext)(false);
|
|
49
|
+
var useEnsureIsInsideAvatar = exports.useEnsureIsInsideAvatar = function useEnsureIsInsideAvatar() {
|
|
50
|
+
var context = (0, _react.useContext)(EnsureIsInsideAvatarContext);
|
|
51
|
+
if (!context) {
|
|
52
|
+
throw new Error('Avatar sub-components must be used within a Avatar component.');
|
|
53
|
+
}
|
|
24
54
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -22,6 +22,12 @@ Object.defineProperty(exports, "AVATAR_SIZES", {
|
|
|
22
22
|
return _constants.AVATAR_SIZES;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
Object.defineProperty(exports, "AvatarContent", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _avatarContent.AvatarContent;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
25
31
|
Object.defineProperty(exports, "AvatarContext", {
|
|
26
32
|
enumerable: true,
|
|
27
33
|
get: function get() {
|
|
@@ -71,6 +77,7 @@ Object.defineProperty(exports, "useAvatarContext", {
|
|
|
71
77
|
}
|
|
72
78
|
});
|
|
73
79
|
var _avatar = _interopRequireDefault(require("./avatar"));
|
|
80
|
+
var _avatarContent = require("./avatar-content");
|
|
74
81
|
var _avatarItem = _interopRequireDefault(require("./avatar-item"));
|
|
75
82
|
var _presence = _interopRequireDefault(require("./presence"));
|
|
76
83
|
var _status = _interopRequireDefault(require("./status"));
|
|
@@ -15,7 +15,7 @@ var _person2 = _interopRequireDefault(require("@atlaskit/icon/core/person"));
|
|
|
15
15
|
var _release = _interopRequireDefault(require("@atlaskit/icon/core/release"));
|
|
16
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
17
|
var _colors = require("@atlaskit/theme/colors");
|
|
18
|
-
var _constants = require("
|
|
18
|
+
var _constants = require("../constants");
|
|
19
19
|
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; }
|
|
20
20
|
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; } /**
|
|
21
21
|
* @jsxRuntime classic
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
var _colors = require("@atlaskit/theme/colors");
|
|
9
|
-
var _constants = require("
|
|
9
|
+
var _constants = require("../constants");
|
|
10
10
|
/**
|
|
11
11
|
* @jsxRuntime classic
|
|
12
12
|
* @jsx jsx
|
package/dist/cjs/presence.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.default = exports.PresenceWrapper = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
11
11
|
var _constants = require("./constants");
|
|
12
|
-
var _iconWrapper = _interopRequireDefault(require("./icon-wrapper"));
|
|
12
|
+
var _iconWrapper = _interopRequireDefault(require("./internal/icon-wrapper"));
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
15
|
var BusyIndicator = /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("circle", {
|
package/dist/cjs/status.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.default = exports.StatusWrapper = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
11
11
|
var _constants = require("./constants");
|
|
12
|
-
var _iconWrapper = _interopRequireDefault(require("./icon-wrapper"));
|
|
12
|
+
var _iconWrapper = _interopRequireDefault(require("./internal/icon-wrapper"));
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
15
|
var ApprovedIndicator = /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("circle", {
|