@atlaskit/avatar 22.0.0 → 24.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/cjs/avatar-content.js +217 -0
  3. package/dist/cjs/avatar-item.js +115 -98
  4. package/dist/cjs/avatar.js +55 -103
  5. package/dist/cjs/context.js +31 -1
  6. package/dist/cjs/index.js +7 -0
  7. package/dist/cjs/{avatar-image.js → internal/avatar-image.js} +1 -1
  8. package/dist/cjs/{icon-wrapper.js → internal/icon-wrapper.js} +1 -1
  9. package/dist/cjs/presence.js +1 -1
  10. package/dist/cjs/status.js +1 -1
  11. package/dist/es2019/avatar-content.js +213 -0
  12. package/dist/es2019/avatar-item.js +107 -130
  13. package/dist/es2019/avatar.js +38 -169
  14. package/dist/es2019/context.js +29 -1
  15. package/dist/es2019/index.js +1 -0
  16. package/dist/es2019/{avatar-image.js → internal/avatar-image.js} +1 -1
  17. package/dist/es2019/{icon-wrapper.js → internal/icon-wrapper.js} +1 -1
  18. package/dist/es2019/presence.js +1 -1
  19. package/dist/es2019/status.js +1 -1
  20. package/dist/esm/avatar-content.js +209 -0
  21. package/dist/esm/avatar-item.js +117 -102
  22. package/dist/esm/avatar.js +58 -103
  23. package/dist/esm/context.js +30 -0
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/{avatar-image.js → internal/avatar-image.js} +1 -1
  26. package/dist/esm/{icon-wrapper.js → internal/icon-wrapper.js} +1 -1
  27. package/dist/esm/presence.js +1 -1
  28. package/dist/esm/status.js +1 -1
  29. package/dist/types/avatar-content.d.ts +21 -0
  30. package/dist/types/avatar-item.d.ts +1 -19
  31. package/dist/types/avatar.d.ts +2 -15
  32. package/dist/types/context.d.ts +33 -2
  33. package/dist/types/entry-points/avatar-item.d.ts +1 -1
  34. package/dist/types/index.d.ts +3 -2
  35. package/dist/types/{avatar-image.d.ts → internal/avatar-image.d.ts} +1 -1
  36. package/dist/types/utilities.d.ts +1 -1
  37. package/dist/types-ts4.5/avatar-content.d.ts +21 -0
  38. package/dist/types-ts4.5/avatar-item.d.ts +1 -19
  39. package/dist/types-ts4.5/avatar.d.ts +2 -15
  40. package/dist/types-ts4.5/context.d.ts +33 -2
  41. package/dist/types-ts4.5/entry-points/avatar-item.d.ts +1 -1
  42. package/dist/types-ts4.5/index.d.ts +3 -2
  43. package/dist/types-ts4.5/{avatar-image.d.ts → internal/avatar-image.d.ts} +1 -1
  44. package/dist/types-ts4.5/utilities.d.ts +1 -1
  45. package/package.json +6 -6
  46. /package/dist/types/{icon-wrapper.d.ts → internal/icon-wrapper.d.ts} +0 -0
  47. /package/dist/types-ts4.5/{icon-wrapper.d.ts → internal/icon-wrapper.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @atlaskit/avatar
2
2
 
3
+ ## 24.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#119746](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/119746)
8
+ [`42617a5e15cd2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/42617a5e15cd2) -
9
+ Removes the `children` prop from `AvatarItem`, along with the `CustomAvatarItemProps` type.
10
+ Limiting the amount of customization that can be applied. This change is in preparation for the
11
+ migration from `@emotion/react` to Compiled CSS-in-JS.
12
+
13
+ ## 23.0.0
14
+
15
+ ### Major Changes
16
+
17
+ - [#117222](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117222)
18
+ [`a80e8994489e7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a80e8994489e7) -
19
+ Removes the option to provide a function to the `children` prop to create a custom avatar. A new
20
+ `AvatarContent` sub-component is now available, which similarly enables custom content to be
21
+ provided for the avatar. This change is in preparation for the migration from `@emotion/react` to
22
+ Compiled CSS-in-JS.
23
+
24
+ Example usage before and after:
25
+
26
+ ### Before
27
+
28
+ ```jsx
29
+ import Avatar from '@atlaskit/avatar';
30
+
31
+ <Avatar>
32
+ {(props) => (
33
+ <span {...props}>
34
+ Custom content
35
+ </span>
36
+ )}
37
+ <Avatar>
38
+ ```
39
+
40
+ ### After
41
+
42
+ ```jsx
43
+ import Avatar, { AvatarContent } from '@atlaskit/avatar';
44
+
45
+ <Avatar>
46
+ <AvatarContent>
47
+ Custom content
48
+ </AvatarContent>
49
+ <Avatar>
50
+ ```
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies
55
+
3
56
  ## 22.0.0
4
57
 
5
58
  ### 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
+ });
@@ -5,55 +5,92 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
10
10
  var _react = require("react");
11
11
  var _react2 = require("@emotion/react");
12
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
13
  var _primitives = require("@atlaskit/primitives");
14
14
  var _colors = require("@atlaskit/theme/colors");
15
- var _constants = require("@atlaskit/theme/constants");
16
- var _constants2 = require("./constants");
17
15
  var _utilities = require("./utilities");
18
- var _templateObject;
19
16
  /**
20
17
  * @jsxRuntime classic
21
18
  * @jsx jsx
22
19
  */
23
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
24
- 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; }
25
- 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; }
26
- var avatarItemStyles = (0, _react2.css)({
27
- minWidth: 0,
28
- maxWidth: '100%',
29
- flex: '1 1 100%',
30
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
31
- lineHeight: '1.4',
32
- paddingInlineStart: "var(--ds-space-100, 8px)"
33
- });
34
- var secondaryTextOldStyles = (0, _react2.css)({
35
- color: "var(--ds-text-subtlest, #626F86)",
36
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
37
- fontSize: '0.85em'
38
- });
39
- var baseTextStyles = (0, _react2.css)({
40
- display: 'block',
41
- color: "var(--ds-text, #172B4D)"
42
- });
43
- var truncationStyles = (0, _react2.css)({
44
- overflowX: 'hidden',
45
- textOverflow: 'ellipsis',
46
- whiteSpace: 'nowrap'
47
- });
48
- var getStyles = function getStyles(css, _ref) {
49
- var backgroundColor = _ref.backgroundColor,
50
- isInteractive = _ref.isInteractive,
51
- isDisabled = _ref.isDisabled;
52
- return (// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage, @repo/internal/react/no-css-string-literals
53
- css(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\t\talign-items: center;\n\t\tbackground-color: ", ";\n\t\tborder-radius: ", "px;\n\t\tborder: ", "px solid transparent;\n\t\tbox-sizing: border-box;\n\t\tcolor: inherit;\n\t\tdisplay: flex;\n\t\tfont-size: inherit;\n\t\tfont-style: normal;\n\t\tfont-weight: ", ";\n\t\tline-height: 1;\n\t\toutline: none;\n\t\tmargin: ", ";\n\t\tpadding: ", ";\n\t\ttext-align: left;\n\t\ttext-decoration: none;\n\t\twidth: 100%;\n\n\t\t", "\n\n\t\t", "\n\t"])), backgroundColor, (0, _constants.borderRadius)(), _constants2.BORDER_WIDTH, "var(--ds-font-weight-regular, 400)", "var(--ds-space-0, 0px)", "var(--ds-space-050, 4px)", isInteractive && "\n :hover {\n background-color: ".concat("var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N30, ")"), ";\n cursor: pointer;\n text-decoration: none;\n }\n\n :focus {\n outline: none;\n border-color: ", "var(--ds-border-focused, ".concat(_colors.B200, ")"), ";\n }\n\n :active {\n background-color: ", "var(--ds-background-neutral-subtle-pressed, ".concat(_colors.B50, ")"), ";\n }\n "), isDisabled && "\n cursor: not-allowed;\n opacity: ".concat("var(--ds-opacity-disabled, 0.5)", ";\n pointer-events: none;\n "))
54
- );
55
- };
56
20
 
21
+ var bgColorCssVar = '--avatar-item-bg-color';
22
+ var styles = {
23
+ root: (0, _react2.css)({
24
+ display: 'flex',
25
+ boxSizing: 'border-box',
26
+ width: '100%',
27
+ alignItems: 'center',
28
+ backgroundColor: "var(".concat(bgColorCssVar, ")"),
29
+ borderColor: 'transparent',
30
+ borderRadius: '3px',
31
+ borderStyle: 'solid',
32
+ borderWidth: "var(--ds-border-width-outline, 2px)",
33
+ color: 'inherit',
34
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
35
+ fontSize: 'inherit',
36
+ fontStyle: 'normal',
37
+ fontWeight: "var(--ds-font-weight-regular, 400)",
38
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
39
+ lineHeight: '1',
40
+ marginBlockEnd: "var(--ds-space-0, 0px)",
41
+ marginBlockStart: "var(--ds-space-0, 0px)",
42
+ marginInlineEnd: "var(--ds-space-0, 0px)",
43
+ marginInlineStart: "var(--ds-space-0, 0px)",
44
+ outline: 'none',
45
+ paddingBlockEnd: "var(--ds-space-050, 4px)",
46
+ paddingBlockStart: "var(--ds-space-050, 4px)",
47
+ paddingInlineEnd: "var(--ds-space-050, 4px)",
48
+ paddingInlineStart: "var(--ds-space-050, 4px)",
49
+ textAlign: 'left',
50
+ textDecoration: 'none'
51
+ }),
52
+ rootDisabled: (0, _react2.css)({
53
+ cursor: 'not-allowed',
54
+ opacity: "var(--ds-opacity-disabled, 0.5)",
55
+ pointerEvents: 'none'
56
+ }),
57
+ rootInteractive: (0, _react2.css)({
58
+ '&:hover': {
59
+ backgroundColor: "var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N30, ")"),
60
+ cursor: 'pointer',
61
+ textDecoration: 'none'
62
+ },
63
+ '&:focus': {
64
+ borderColor: "var(--ds-border-focused, ".concat(_colors.B200, ")"),
65
+ outline: 'none'
66
+ },
67
+ '&:active': {
68
+ backgroundColor: "var(--ds-background-neutral-subtle-pressed, ".concat(_colors.B50, ")")
69
+ }
70
+ }),
71
+ avatarItem: (0, _react2.css)({
72
+ minWidth: 0,
73
+ maxWidth: '100%',
74
+ flex: '1 1 100%',
75
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
76
+ lineHeight: '1.4',
77
+ paddingInlineStart: "var(--ds-space-100, 8px)"
78
+ }),
79
+ baseText: (0, _react2.css)({
80
+ display: 'block',
81
+ color: "var(--ds-text, #172B4D)"
82
+ }),
83
+ truncation: (0, _react2.css)({
84
+ overflowX: 'hidden',
85
+ textOverflow: 'ellipsis',
86
+ whiteSpace: 'nowrap'
87
+ }),
88
+ secondaryTextLegacy: (0, _react2.css)({
89
+ color: "var(--ds-text-subtlest, #626F86)",
90
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
91
+ fontSize: '0.85em'
92
+ })
93
+ };
57
94
  /**
58
95
  * __Avatar item__
59
96
  *
@@ -62,67 +99,47 @@ var getStyles = function getStyles(css, _ref) {
62
99
  * - [Examples](https://atlassian.design/components/avatar/avatar-item/examples)
63
100
  * - [Code](https://atlassian.design/components/avatar/avatar-item/code)
64
101
  */
65
- var AvatarItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
66
- var avatar = _ref2.avatar,
67
- _ref2$backgroundColor = _ref2.backgroundColor,
68
- backgroundColor = _ref2$backgroundColor === void 0 ? 'transparent' : _ref2$backgroundColor,
69
- children = _ref2.children,
70
- isTruncationDisabled = _ref2.isTruncationDisabled,
71
- href = _ref2.href,
72
- isDisabled = _ref2.isDisabled,
73
- onClick = _ref2.onClick,
74
- primaryText = _ref2.primaryText,
75
- secondaryText = _ref2.secondaryText,
76
- target = _ref2.target,
77
- testId = _ref2.testId,
78
- label = _ref2.label;
79
- var getTestId = function getTestId(testId, children) {
80
- return !children ? {
81
- 'data-testid': "".concat(testId, "--itemInner")
82
- } : {
83
- testId: "".concat(testId, "--itemInner")
84
- };
85
- };
86
- var componentProps = function componentProps() {
87
- if (isDisabled) {
88
- return {
89
- disabled: true
90
- };
91
- }
92
-
93
- // return only relevant props for either anchor or button elements
94
- return _objectSpread(_objectSpread({}, href && (0, _utilities.getLinkProps)(href, target)), onClick && !href ? (0, _utilities.getButtonProps)(onClick) : {
95
- onClick: onClick
96
- });
97
- };
98
- return (0, _react2.jsx)(_react2.ClassNames, null, function (_ref3) {
99
- var css = _ref3.css;
100
- var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
101
- ref: ref,
102
- className: getStyles(css, {
103
- backgroundColor: backgroundColor,
104
- isInteractive: Boolean(onClick || href),
105
- isDisabled: isDisabled
106
- })
107
- }, componentProps()), testId && getTestId(testId, children)), (onClick || href) && {
108
- 'aria-label': label
109
- }), {}, {
110
- children: (0, _react2.jsx)(_react.Fragment, null, avatar, (0, _react2.jsx)("div", {
111
- css: avatarItemStyles
112
- }, (0, _platformFeatureFlags.fg)('platform.design-system-team.avatar-item-font-size_830x6') ? (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_primitives.Text, {
113
- maxLines: isTruncationDisabled ? undefined : 1
114
- }, primaryText), (0, _react2.jsx)(_primitives.Text, {
115
- color: "color.text.subtlest",
116
- maxLines: isTruncationDisabled ? undefined : 1,
117
- size: "UNSAFE_small"
118
- }, secondaryText)) : (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)("span", {
119
- css: [baseTextStyles, !isTruncationDisabled && truncationStyles]
120
- }, primaryText), (0, _react2.jsx)("span", {
121
- css: [baseTextStyles, secondaryTextOldStyles, !isTruncationDisabled && truncationStyles]
122
- }, secondaryText))))
123
- });
124
- return children ? children(props) : /*#__PURE__*/(0, _react.createElement)((0, _utilities.getCustomElement)(isDisabled, href, onClick), props);
125
- });
102
+ var AvatarItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
103
+ var avatar = _ref.avatar,
104
+ _ref$backgroundColor = _ref.backgroundColor,
105
+ backgroundColor = _ref$backgroundColor === void 0 ? 'transparent' : _ref$backgroundColor,
106
+ isTruncationDisabled = _ref.isTruncationDisabled,
107
+ href = _ref.href,
108
+ isDisabled = _ref.isDisabled,
109
+ onClick = _ref.onClick,
110
+ primaryText = _ref.primaryText,
111
+ secondaryText = _ref.secondaryText,
112
+ target = _ref.target,
113
+ testId = _ref.testId,
114
+ label = _ref.label;
115
+ var Container = (0, _utilities.getCustomElement)(isDisabled, href, onClick);
116
+ var isInteractive = Boolean(onClick || href);
117
+ return (0, _react2.jsx)(Container, (0, _extends2.default)({
118
+ css: [styles.root, isInteractive && styles.rootInteractive, isDisabled && styles.rootDisabled],
119
+ style: (0, _defineProperty2.default)({}, bgColorCssVar, backgroundColor),
120
+ ref: ref,
121
+ "aria-label": isInteractive ? label : undefined,
122
+ onClick: onClick,
123
+ disabled: isDisabled,
124
+ "data-testid": testId ? "".concat(testId, "--itemInner") : undefined,
125
+ type: Container === 'button' ? 'button' : undefined
126
+ }, href && {
127
+ href: href,
128
+ target: target,
129
+ rel: target === '_blank' ? 'noopener noreferrer' : undefined
130
+ }), avatar, (0, _react2.jsx)("div", {
131
+ css: styles.avatarItem
132
+ }, (0, _platformFeatureFlags.fg)('platform.design-system-team.avatar-item-font-size_830x6') ? (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_primitives.Text, {
133
+ maxLines: isTruncationDisabled ? undefined : 1
134
+ }, primaryText), (0, _react2.jsx)(_primitives.Text, {
135
+ color: "color.text.subtlest",
136
+ maxLines: isTruncationDisabled ? undefined : 1,
137
+ size: "UNSAFE_small"
138
+ }, secondaryText)) : (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)("span", {
139
+ css: [styles.baseText, !isTruncationDisabled && styles.truncation]
140
+ }, primaryText), (0, _react2.jsx)("span", {
141
+ css: [styles.baseText, styles.secondaryTextLegacy, !isTruncationDisabled && styles.truncation]
142
+ }, secondaryText))));
126
143
  });
127
144
  AvatarItem.displayName = 'AvatarItem';
128
145
  var _default = exports.default = AvatarItem;