@atlaskit/mention 27.15.2 → 27.17.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 +18 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/_constants.js +3 -2
- package/dist/cjs/components/Mention/PrimitiveMention.js +7 -4
- package/dist/cjs/components/Mention/ResourcedMention.js +4 -0
- package/dist/cjs/components/Mention/index.compiled.css +17 -0
- package/dist/cjs/components/Mention/index.js +65 -7
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/es2019/_constants.js +2 -1
- package/dist/es2019/components/Mention/PrimitiveMention.js +24 -19
- package/dist/es2019/components/Mention/ResourcedMention.js +4 -0
- package/dist/es2019/components/Mention/index.compiled.css +17 -0
- package/dist/es2019/components/Mention/index.js +53 -3
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/esm/_constants.js +2 -1
- package/dist/esm/components/Mention/PrimitiveMention.js +7 -4
- package/dist/esm/components/Mention/ResourcedMention.js +4 -0
- package/dist/esm/components/Mention/index.compiled.css +17 -0
- package/dist/esm/components/Mention/index.js +57 -5
- package/dist/esm/util/analytics.js +1 -1
- package/dist/types/_constants.d.ts +1 -0
- package/dist/types/components/Mention/PrimitiveMention.d.ts +1 -0
- package/dist/types/components/Mention/ResourcedMention.d.ts +4 -0
- package/dist/types/components/Mention/index.d.ts +19 -2
- package/dist/types/types.d.ts +7 -0
- package/package.json +3 -2
- package/mention.docs.tsx +0 -72
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/mention
|
|
2
2
|
|
|
3
|
+
## 27.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`6997a74055219`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6997a74055219) -
|
|
8
|
+
Add profile card on hover in the mentions typeahead for agent mentions
|
|
9
|
+
|
|
10
|
+
## 27.16.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`13e86ff9f1588`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/13e86ff9f1588) -
|
|
15
|
+
[ux] Display avatars for mention nodes.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 27.15.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/dist/cjs/_constants.js
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ELEMENTS_CHANNEL = void 0;
|
|
7
|
-
var ELEMENTS_CHANNEL = exports.ELEMENTS_CHANNEL = 'fabric-elements';
|
|
6
|
+
exports.UNKNOWN_USER_ID = exports.ELEMENTS_CHANNEL = void 0;
|
|
7
|
+
var ELEMENTS_CHANNEL = exports.ELEMENTS_CHANNEL = 'fabric-elements';
|
|
8
|
+
var UNKNOWN_USER_ID = exports.UNKNOWN_USER_ID = '_|unknown|_';
|
|
@@ -12,7 +12,7 @@ var _react = require("@emotion/react");
|
|
|
12
12
|
var _react2 = require("react");
|
|
13
13
|
var _mentionStyle = require("./mention-style");
|
|
14
14
|
var _templateObject;
|
|
15
|
-
var _excluded = ["mentionType"];
|
|
15
|
+
var _excluded = ["isAvatarVisible", "mentionType"];
|
|
16
16
|
/* eslint-disable @atlaskit/design-system/no-html-button */
|
|
17
17
|
/**
|
|
18
18
|
* @jsxRuntime classic
|
|
@@ -24,13 +24,16 @@ var getStyle = function getStyle(_ref, property) {
|
|
|
24
24
|
return _mentionStyle.mentionStyle[mentionType][property];
|
|
25
25
|
};
|
|
26
26
|
var PrimitiveMention = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref2, ref) {
|
|
27
|
-
var
|
|
27
|
+
var _ref2$isAvatarVisible = _ref2.isAvatarVisible,
|
|
28
|
+
isAvatarVisible = _ref2$isAvatarVisible === void 0 ? false : _ref2$isAvatarVisible,
|
|
29
|
+
mentionType = _ref2.mentionType,
|
|
28
30
|
other = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
29
31
|
return (0, _react.jsx)("span", (0, _extends2.default)({
|
|
30
|
-
ref: ref
|
|
32
|
+
ref: ref,
|
|
33
|
+
"data-avatar-visible": isAvatarVisible || undefined
|
|
31
34
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
32
35
|
,
|
|
33
|
-
css: (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\t\t\t\tdisplay: inline;\n\t\t\t\tborder: ", " solid ", ";\n\t\t\t\tbackground: ", ";\n\t\t\t\tcolor: ", ";\n\t\t\t\tborder-radius: 20px;\n\t\t\t\tcursor: pointer;\n\t\t\t\tpadding: 0 0.3em 2px 0.23em;\n\t\t\t\tline-height: 1.714;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tfont-weight: ", ";\n\t\t\t\tword-break: break-word;\n\t\t\t\t&:hover {\n\t\t\t\t\tbackground: ", ";\n\t\t\t\t}\n\t\t\t\t&:active {\n\t\t\t\t\tbackground: ", ";\n\t\t\t\t}\n\t\t\t"])), "var(--ds-border-width, 1px)", getStyle({
|
|
36
|
+
css: (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\t\t\t\t\tdisplay: inline;\n\t\t\t\t\tborder: ", " solid ", ";\n\t\t\t\t\tbackground: ", ";\n\t\t\t\t\tcolor: ", ";\n\t\t\t\t\tborder-radius: 20px;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t\tpadding: 0 0.3em 2px 0.23em;\n\t\t\t\t\tline-height: 1.714;\n\t\t\t\t\tfont-size: 1em;\n\t\t\t\t\tfont-weight: ", ";\n\t\t\t\t\tword-break: break-word;\n\t\t\t\t\t&[data-avatar-visible='true'] {\n\t\t\t\t\t\tpadding: 1px 0.3em 1px 0.23em;\n\t\t\t\t\t}\n\t\t\t\t\t&:hover {\n\t\t\t\t\t\tbackground: ", ";\n\t\t\t\t\t}\n\t\t\t\t\t&:active {\n\t\t\t\t\t\tbackground: ", ";\n\t\t\t\t\t}\n\t\t\t\t"])), "var(--ds-border-width, 1px)", getStyle({
|
|
34
37
|
mentionType: mentionType
|
|
35
38
|
}, 'borderColor'), getStyle({
|
|
36
39
|
mentionType: mentionType
|
|
@@ -123,10 +123,14 @@ var ResourcedMention = exports.default = /*#__PURE__*/function (_React$PureCompo
|
|
|
123
123
|
isDisabled: props.isDisabled,
|
|
124
124
|
disabledTooltip: props.disabledTooltip,
|
|
125
125
|
accessLevel: props.accessLevel,
|
|
126
|
+
appType: props.appType,
|
|
127
|
+
avatarUrl: props.avatarUrl,
|
|
128
|
+
isAvatarImagePreShaped: props.isAvatarImagePreShaped,
|
|
126
129
|
localId: props.localId,
|
|
127
130
|
onClick: props.onClick,
|
|
128
131
|
onMouseEnter: props.onMouseEnter,
|
|
129
132
|
onMouseLeave: props.onMouseLeave,
|
|
133
|
+
renderAvatarSlot: props.renderAvatarSlot,
|
|
130
134
|
ssrPlaceholderId: props.ssrPlaceholderId
|
|
131
135
|
});
|
|
132
136
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
._2rko1rr0{border-radius:var(--ds-radius-full,9999px)}
|
|
2
|
+
._2rkoidpf{border-radius:0}._12l21b66{margin-inline-end:var(--ds-space-050,4px)}
|
|
3
|
+
._18m915vq{overflow-y:hidden}
|
|
4
|
+
._1bah1h6o{justify-content:center}
|
|
5
|
+
._1bsb1osq{width:100%}
|
|
6
|
+
._1bsb7vkz{width:1pc}
|
|
7
|
+
._1e0c116y{display:inline-flex}
|
|
8
|
+
._1e0c1ule{display:block}
|
|
9
|
+
._1o9zidpf{flex-shrink:0}
|
|
10
|
+
._1reo15vq{overflow-x:hidden}
|
|
11
|
+
._4cvr1h6o{align-items:center}
|
|
12
|
+
._4t3i1osq{height:100%}
|
|
13
|
+
._4t3i7vkz{height:1pc}
|
|
14
|
+
._5ral1dfr{object-fit:cover}
|
|
15
|
+
._mkrz1l17{clip-path:polygon(25% 6.7%,75% 6.7%,100% 50%,75% 93.3%,25% 93.3%,0 50%)}
|
|
16
|
+
._s7n410e5{vertical-align:-.125em}
|
|
17
|
+
._s7n41q9y{vertical-align:baseline}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
1
2
|
"use strict";
|
|
2
3
|
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
|
-
exports.
|
|
8
|
+
exports.MentionInternal = exports.ANALYTICS_HOVER_DELAY = void 0;
|
|
9
|
+
Object.defineProperty(exports, "UNKNOWN_USER_ID", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return _constants.UNKNOWN_USER_ID;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
exports.default = void 0;
|
|
16
|
+
require("./index.compiled.css");
|
|
17
|
+
var _runtime = require("@compiled/react/runtime");
|
|
8
18
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
19
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
20
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -18,6 +28,7 @@ var _MessagesIntlProvider = _interopRequireDefault(require("../MessagesIntlProvi
|
|
|
18
28
|
var _PrimitiveMention = _interopRequireDefault(require("./PrimitiveMention"));
|
|
19
29
|
var _NoAccessTooltip = _interopRequireDefault(require("../NoAccessTooltip"));
|
|
20
30
|
var _DisabledMentionTooltip = _interopRequireDefault(require("../DisabledMentionTooltip"));
|
|
31
|
+
var _constants = require("../../_constants");
|
|
21
32
|
var _types = require("../../types");
|
|
22
33
|
var _analytics = require("../../util/analytics");
|
|
23
34
|
var _withAnalyticsEvents = _interopRequireDefault(require("@atlaskit/analytics-next/withAnalyticsEvents"));
|
|
@@ -29,12 +40,23 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
29
40
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
30
41
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable @atlaskit/design-system/no-deprecated-imports, @typescript-eslint/ban-types -- Preserve existing mention implementation while focus-ring usage is reviewed separately. */
|
|
31
42
|
var ANALYTICS_HOVER_DELAY = exports.ANALYTICS_HOVER_DELAY = 1000;
|
|
32
|
-
var
|
|
43
|
+
var avatarStyles = null;
|
|
44
|
+
var avatarFallbackStyles = null;
|
|
45
|
+
var avatarImageStyles = null;
|
|
46
|
+
var agentAvatarStyles = null;
|
|
33
47
|
var MentionInternal = exports.MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
|
|
34
48
|
function MentionInternal(props) {
|
|
35
49
|
var _this;
|
|
36
50
|
(0, _classCallCheck2.default)(this, MentionInternal);
|
|
37
51
|
_this = _callSuper(this, MentionInternal, [props]);
|
|
52
|
+
(0, _defineProperty2.default)(_this, "state", {
|
|
53
|
+
hasAvatarError: false
|
|
54
|
+
});
|
|
55
|
+
(0, _defineProperty2.default)(_this, "handleAvatarError", function () {
|
|
56
|
+
_this.setState({
|
|
57
|
+
hasAvatarError: true
|
|
58
|
+
});
|
|
59
|
+
});
|
|
38
60
|
(0, _defineProperty2.default)(_this, "handleOnClick", function (e) {
|
|
39
61
|
var _this$props = _this.props,
|
|
40
62
|
id = _this$props.id,
|
|
@@ -127,17 +149,26 @@ var MentionInternal = exports.MentionInternal = /*#__PURE__*/function (_React$Pu
|
|
|
127
149
|
}, {
|
|
128
150
|
key: "render",
|
|
129
151
|
value: function render() {
|
|
130
|
-
var
|
|
152
|
+
var handleAvatarError = this.handleAvatarError,
|
|
153
|
+
handleOnClick = this.handleOnClick,
|
|
131
154
|
handleOnMouseEnter = this.handleOnMouseEnter,
|
|
132
155
|
handleOnMouseLeave = this.handleOnMouseLeave,
|
|
133
156
|
props = this.props;
|
|
134
|
-
var
|
|
157
|
+
var appType = props.appType,
|
|
158
|
+
avatarUrl = props.avatarUrl,
|
|
159
|
+
text = props.text,
|
|
135
160
|
id = props.id,
|
|
136
161
|
accessLevel = props.accessLevel,
|
|
137
162
|
localId = props.localId,
|
|
138
|
-
disabledTooltip = props.disabledTooltip
|
|
163
|
+
disabledTooltip = props.disabledTooltip,
|
|
164
|
+
isAvatarImagePreShaped = props.isAvatarImagePreShaped,
|
|
165
|
+
renderAvatarSlot = props.renderAvatarSlot;
|
|
139
166
|
var mentionType = this.getMentionType();
|
|
140
|
-
var failedMention = text === "@".concat(UNKNOWN_USER_ID);
|
|
167
|
+
var failedMention = text === "@".concat(_constants.UNKNOWN_USER_ID);
|
|
168
|
+
var showAvatarSlot = Boolean(renderAvatarSlot) && !failedMention;
|
|
169
|
+
var visibleText = showAvatarSlot && text.startsWith('@') ? text.slice(1) : text;
|
|
170
|
+
var shouldApplyAgentShape = appType === 'agent' && !isAvatarImagePreShaped;
|
|
171
|
+
var shouldRenderAvatar = avatarUrl && !this.state.hasAvatarError;
|
|
141
172
|
var showRestrictedTooltip = mentionType === _types.MentionType.RESTRICTED;
|
|
142
173
|
var showDisabledTooltip = mentionType === _types.MentionType.DISABLED && !!disabledTooltip;
|
|
143
174
|
|
|
@@ -154,6 +185,7 @@ var MentionInternal = exports.MentionInternal = /*#__PURE__*/function (_React$Pu
|
|
|
154
185
|
'aria-label': "".concat(text || '@...', " \u2014 ").concat(disabledTooltip)
|
|
155
186
|
} : {}) : {};
|
|
156
187
|
var mentionComponent = /*#__PURE__*/_react.default.createElement(_focusRing.default, null, /*#__PURE__*/_react.default.createElement(_PrimitiveMention.default, (0, _extends2.default)({
|
|
188
|
+
isAvatarVisible: showAvatarSlot,
|
|
157
189
|
mentionType: mentionType,
|
|
158
190
|
onClick: handleOnClick,
|
|
159
191
|
onMouseEnter: handleOnMouseEnter,
|
|
@@ -162,7 +194,22 @@ var MentionInternal = exports.MentionInternal = /*#__PURE__*/function (_React$Pu
|
|
|
162
194
|
"data-testid": "mention-".concat(id),
|
|
163
195
|
"data-mention-type": mentionType,
|
|
164
196
|
"data-mention-tooltip": showRestrictedTooltip || showDisabledTooltip
|
|
165
|
-
}, disabledA11yProps), failedMention ? this.renderUnknownUserError(id) :
|
|
197
|
+
}, disabledA11yProps), failedMention ? this.renderUnknownUserError(id) : showAvatarSlot ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
198
|
+
"aria-hidden": "true",
|
|
199
|
+
"data-testid": "mention-avatar-slot",
|
|
200
|
+
className: (0, _runtime.ax)(["_1reo15vq _18m915vq _2rko1rr0 _1e0c116y _1bsb7vkz _4t3i7vkz _4cvr1h6o _1bah1h6o _1o9zidpf _12l21b66 _s7n410e5", shouldApplyAgentShape && "_2rkoidpf _mkrz1l17", this.state.hasAvatarError && "_s7n41q9y"])
|
|
201
|
+
}, shouldRenderAvatar ? /*#__PURE__*/_react.default.createElement("img", {
|
|
202
|
+
alt: "",
|
|
203
|
+
decoding: "async",
|
|
204
|
+
draggable: false,
|
|
205
|
+
height: 16,
|
|
206
|
+
loading: "lazy",
|
|
207
|
+
onError: handleAvatarError,
|
|
208
|
+
src: avatarUrl,
|
|
209
|
+
"data-testid": "mention-avatar",
|
|
210
|
+
width: 16,
|
|
211
|
+
className: (0, _runtime.ax)(["_1e0c1ule _1bsb1osq _4t3i1osq _5ral1dfr"])
|
|
212
|
+
}) : this.state.hasAvatarError ? '@' : null), /*#__PURE__*/_react.default.createElement("span", null, visibleText || '...')) : text || '@...'));
|
|
166
213
|
var ssrPlaceholderProp = props.ssrPlaceholderId ? {
|
|
167
214
|
'data-ssr-placeholder': props.ssrPlaceholderId
|
|
168
215
|
} : {};
|
|
@@ -193,6 +240,17 @@ var MentionInternal = exports.MentionInternal = /*#__PURE__*/function (_React$Pu
|
|
|
193
240
|
spellCheck: false
|
|
194
241
|
}, ssrPlaceholderProp), /*#__PURE__*/_react.default.createElement(_MessagesIntlProvider.default, null, wrappedMention)));
|
|
195
242
|
}
|
|
243
|
+
}], [{
|
|
244
|
+
key: "getDerivedStateFromProps",
|
|
245
|
+
value: function getDerivedStateFromProps(props, state) {
|
|
246
|
+
if (props.avatarUrl !== state.avatarUrl) {
|
|
247
|
+
return {
|
|
248
|
+
avatarUrl: props.avatarUrl,
|
|
249
|
+
hasAvatarError: false
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
196
254
|
}]);
|
|
197
255
|
}(_react.default.PureComponent);
|
|
198
256
|
var MentionWithAnalytics = (0, _withAnalyticsEvents.default)({
|
|
@@ -12,7 +12,7 @@ var _types = require("../types");
|
|
|
12
12
|
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; }
|
|
13
13
|
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; }
|
|
14
14
|
var packageName = "@atlaskit/mention";
|
|
15
|
-
var packageVersion = "27.
|
|
15
|
+
var packageVersion = "27.16.0";
|
|
16
16
|
var SLI_EVENT_TYPE = exports.SLI_EVENT_TYPE = 'sli';
|
|
17
17
|
var SMART_EVENT_TYPE = exports.SMART_EVENT_TYPE = 'smart';
|
|
18
18
|
var fireAnalyticsMentionTypeaheadEvent = exports.fireAnalyticsMentionTypeaheadEvent = function fireAnalyticsMentionTypeaheadEvent(props) {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const ELEMENTS_CHANNEL = 'fabric-elements';
|
|
1
|
+
export const ELEMENTS_CHANNEL = 'fabric-elements';
|
|
2
|
+
export const UNKNOWN_USER_ID = '_|unknown|_';
|
|
@@ -12,42 +12,47 @@ const getStyle = ({
|
|
|
12
12
|
mentionType
|
|
13
13
|
}, property) => mentionStyle[mentionType][property];
|
|
14
14
|
const PrimitiveMention = /*#__PURE__*/forwardRef(({
|
|
15
|
+
isAvatarVisible = false,
|
|
15
16
|
mentionType,
|
|
16
17
|
...other
|
|
17
18
|
}, ref) => {
|
|
18
19
|
return jsx("span", _extends({
|
|
19
|
-
ref: ref
|
|
20
|
+
ref: ref,
|
|
21
|
+
"data-avatar-visible": isAvatarVisible || undefined
|
|
20
22
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
21
23
|
,
|
|
22
24
|
css: css`
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
display: inline;
|
|
26
|
+
border: ${"var(--ds-border-width, 1px)"} solid ${getStyle({
|
|
25
27
|
mentionType
|
|
26
28
|
}, 'borderColor')};
|
|
27
|
-
|
|
29
|
+
background: ${getStyle({
|
|
28
30
|
mentionType
|
|
29
31
|
}, 'background')};
|
|
30
|
-
|
|
32
|
+
color: ${getStyle({
|
|
31
33
|
mentionType
|
|
32
34
|
}, 'text')};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
border-radius: 20px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
padding: 0 0.3em 2px 0.23em;
|
|
38
|
+
line-height: 1.714;
|
|
39
|
+
font-size: 1em;
|
|
40
|
+
font-weight: ${"var(--ds-font-weight-regular, 400)"};
|
|
41
|
+
word-break: break-word;
|
|
42
|
+
&[data-avatar-visible='true'] {
|
|
43
|
+
padding: 1px 0.3em 1px 0.23em;
|
|
44
|
+
}
|
|
45
|
+
&:hover {
|
|
46
|
+
background: ${getStyle({
|
|
42
47
|
mentionType
|
|
43
48
|
}, 'hoveredBackground')};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
}
|
|
50
|
+
&:active {
|
|
51
|
+
background: ${getStyle({
|
|
47
52
|
mentionType
|
|
48
53
|
}, 'pressedBackground')};
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
}
|
|
55
|
+
`
|
|
51
56
|
}, other));
|
|
52
57
|
});
|
|
53
58
|
export default PrimitiveMention;
|
|
@@ -97,10 +97,14 @@ export default class ResourcedMention extends React.PureComponent {
|
|
|
97
97
|
isDisabled: props.isDisabled,
|
|
98
98
|
disabledTooltip: props.disabledTooltip,
|
|
99
99
|
accessLevel: props.accessLevel,
|
|
100
|
+
appType: props.appType,
|
|
101
|
+
avatarUrl: props.avatarUrl,
|
|
102
|
+
isAvatarImagePreShaped: props.isAvatarImagePreShaped,
|
|
100
103
|
localId: props.localId,
|
|
101
104
|
onClick: props.onClick,
|
|
102
105
|
onMouseEnter: props.onMouseEnter,
|
|
103
106
|
onMouseLeave: props.onMouseLeave,
|
|
107
|
+
renderAvatarSlot: props.renderAvatarSlot,
|
|
104
108
|
ssrPlaceholderId: props.ssrPlaceholderId
|
|
105
109
|
});
|
|
106
110
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
._2rko1rr0{border-radius:var(--ds-radius-full,9999px)}
|
|
2
|
+
._2rkoidpf{border-radius:0}._12l21b66{margin-inline-end:var(--ds-space-050,4px)}
|
|
3
|
+
._18m915vq{overflow-y:hidden}
|
|
4
|
+
._1bah1h6o{justify-content:center}
|
|
5
|
+
._1bsb1osq{width:100%}
|
|
6
|
+
._1bsb7vkz{width:1pc}
|
|
7
|
+
._1e0c116y{display:inline-flex}
|
|
8
|
+
._1e0c1ule{display:block}
|
|
9
|
+
._1o9zidpf{flex-shrink:0}
|
|
10
|
+
._1reo15vq{overflow-x:hidden}
|
|
11
|
+
._4cvr1h6o{align-items:center}
|
|
12
|
+
._4t3i1osq{height:100%}
|
|
13
|
+
._4t3i7vkz{height:1pc}
|
|
14
|
+
._5ral1dfr{object-fit:cover}
|
|
15
|
+
._mkrz1l17{clip-path:polygon(25% 6.7%,75% 6.7%,100% 50%,75% 93.3%,25% 93.3%,0 50%)}
|
|
16
|
+
._s7n410e5{vertical-align:-.125em}
|
|
17
|
+
._s7n41q9y{vertical-align:baseline}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import "./index.compiled.css";
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
3
6
|
/* eslint-disable @atlaskit/design-system/no-deprecated-imports, @typescript-eslint/ban-types -- Preserve existing mention implementation while focus-ring usage is reviewed separately. */
|
|
4
7
|
import React from 'react';
|
|
5
8
|
import FocusRing from '@atlaskit/focus-ring';
|
|
@@ -7,6 +10,7 @@ import MessagesIntlProvider from '../MessagesIntlProvider';
|
|
|
7
10
|
import PrimitiveMention from './PrimitiveMention';
|
|
8
11
|
import AsyncNoAccessTooltip from '../NoAccessTooltip';
|
|
9
12
|
import AsyncDisabledMentionTooltip from '../DisabledMentionTooltip';
|
|
13
|
+
import { UNKNOWN_USER_ID } from '../../_constants';
|
|
10
14
|
import { isRestricted, MentionType } from '../../types';
|
|
11
15
|
import { fireAnalyticsMentionEvent } from '../../util/analytics';
|
|
12
16
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
@@ -14,10 +18,22 @@ import { UFOExperienceState } from '@atlaskit/ufo';
|
|
|
14
18
|
import { UnknownUserError } from '../../util/i18n';
|
|
15
19
|
import { UfoErrorBoundary, mentionRenderedUfoExperience } from './ufoExperiences';
|
|
16
20
|
export const ANALYTICS_HOVER_DELAY = 1000;
|
|
17
|
-
export
|
|
21
|
+
export { UNKNOWN_USER_ID } from '../../_constants';
|
|
22
|
+
const avatarStyles = null;
|
|
23
|
+
const avatarFallbackStyles = null;
|
|
24
|
+
const avatarImageStyles = null;
|
|
25
|
+
const agentAvatarStyles = null;
|
|
18
26
|
export class MentionInternal extends React.PureComponent {
|
|
19
27
|
constructor(props) {
|
|
20
28
|
super(props);
|
|
29
|
+
_defineProperty(this, "state", {
|
|
30
|
+
hasAvatarError: false
|
|
31
|
+
});
|
|
32
|
+
_defineProperty(this, "handleAvatarError", () => {
|
|
33
|
+
this.setState({
|
|
34
|
+
hasAvatarError: true
|
|
35
|
+
});
|
|
36
|
+
});
|
|
21
37
|
_defineProperty(this, "handleOnClick", e => {
|
|
22
38
|
const {
|
|
23
39
|
id,
|
|
@@ -85,6 +101,15 @@ export class MentionInternal extends React.PureComponent {
|
|
|
85
101
|
componentDidMount() {
|
|
86
102
|
mentionRenderedUfoExperience.getInstance(this.props.id).success();
|
|
87
103
|
}
|
|
104
|
+
static getDerivedStateFromProps(props, state) {
|
|
105
|
+
if (props.avatarUrl !== state.avatarUrl) {
|
|
106
|
+
return {
|
|
107
|
+
avatarUrl: props.avatarUrl,
|
|
108
|
+
hasAvatarError: false
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
88
113
|
componentWillUnmount() {
|
|
89
114
|
if (this.hoverTimeout) {
|
|
90
115
|
clearTimeout(this.hoverTimeout);
|
|
@@ -103,20 +128,29 @@ export class MentionInternal extends React.PureComponent {
|
|
|
103
128
|
}
|
|
104
129
|
render() {
|
|
105
130
|
const {
|
|
131
|
+
handleAvatarError,
|
|
106
132
|
handleOnClick,
|
|
107
133
|
handleOnMouseEnter,
|
|
108
134
|
handleOnMouseLeave,
|
|
109
135
|
props
|
|
110
136
|
} = this;
|
|
111
137
|
const {
|
|
138
|
+
appType,
|
|
139
|
+
avatarUrl,
|
|
112
140
|
text,
|
|
113
141
|
id,
|
|
114
142
|
accessLevel,
|
|
115
143
|
localId,
|
|
116
|
-
disabledTooltip
|
|
144
|
+
disabledTooltip,
|
|
145
|
+
isAvatarImagePreShaped,
|
|
146
|
+
renderAvatarSlot
|
|
117
147
|
} = props;
|
|
118
148
|
const mentionType = this.getMentionType();
|
|
119
149
|
const failedMention = text === `@${UNKNOWN_USER_ID}`;
|
|
150
|
+
const showAvatarSlot = Boolean(renderAvatarSlot) && !failedMention;
|
|
151
|
+
const visibleText = showAvatarSlot && text.startsWith('@') ? text.slice(1) : text;
|
|
152
|
+
const shouldApplyAgentShape = appType === 'agent' && !isAvatarImagePreShaped;
|
|
153
|
+
const shouldRenderAvatar = avatarUrl && !this.state.hasAvatarError;
|
|
120
154
|
const showRestrictedTooltip = mentionType === MentionType.RESTRICTED;
|
|
121
155
|
const showDisabledTooltip = mentionType === MentionType.DISABLED && !!disabledTooltip;
|
|
122
156
|
|
|
@@ -134,6 +168,7 @@ export class MentionInternal extends React.PureComponent {
|
|
|
134
168
|
} : {})
|
|
135
169
|
} : {};
|
|
136
170
|
const mentionComponent = /*#__PURE__*/React.createElement(FocusRing, null, /*#__PURE__*/React.createElement(PrimitiveMention, _extends({
|
|
171
|
+
isAvatarVisible: showAvatarSlot,
|
|
137
172
|
mentionType: mentionType,
|
|
138
173
|
onClick: handleOnClick,
|
|
139
174
|
onMouseEnter: handleOnMouseEnter,
|
|
@@ -142,7 +177,22 @@ export class MentionInternal extends React.PureComponent {
|
|
|
142
177
|
"data-testid": `mention-${id}`,
|
|
143
178
|
"data-mention-type": mentionType,
|
|
144
179
|
"data-mention-tooltip": showRestrictedTooltip || showDisabledTooltip
|
|
145
|
-
}, disabledA11yProps), failedMention ? this.renderUnknownUserError(id) :
|
|
180
|
+
}, disabledA11yProps), failedMention ? this.renderUnknownUserError(id) : showAvatarSlot ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
181
|
+
"aria-hidden": "true",
|
|
182
|
+
"data-testid": "mention-avatar-slot",
|
|
183
|
+
className: ax(["_1reo15vq _18m915vq _2rko1rr0 _1e0c116y _1bsb7vkz _4t3i7vkz _4cvr1h6o _1bah1h6o _1o9zidpf _12l21b66 _s7n410e5", shouldApplyAgentShape && "_2rkoidpf _mkrz1l17", this.state.hasAvatarError && "_s7n41q9y"])
|
|
184
|
+
}, shouldRenderAvatar ? /*#__PURE__*/React.createElement("img", {
|
|
185
|
+
alt: "",
|
|
186
|
+
decoding: "async",
|
|
187
|
+
draggable: false,
|
|
188
|
+
height: 16,
|
|
189
|
+
loading: "lazy",
|
|
190
|
+
onError: handleAvatarError,
|
|
191
|
+
src: avatarUrl,
|
|
192
|
+
"data-testid": "mention-avatar",
|
|
193
|
+
width: 16,
|
|
194
|
+
className: ax(["_1e0c1ule _1bsb1osq _4t3i1osq _5ral1dfr"])
|
|
195
|
+
}) : this.state.hasAvatarError ? '@' : null), /*#__PURE__*/React.createElement("span", null, visibleText || '...')) : text || '@...'));
|
|
146
196
|
const ssrPlaceholderProp = props.ssrPlaceholderId ? {
|
|
147
197
|
'data-ssr-placeholder': props.ssrPlaceholderId
|
|
148
198
|
} : {};
|
|
@@ -2,7 +2,7 @@ import { OPERATIONAL_EVENT_TYPE, UI_EVENT_TYPE } from '@atlaskit/analytics-gas-t
|
|
|
2
2
|
import { ELEMENTS_CHANNEL } from '../_constants';
|
|
3
3
|
import { ComponentNames, isSpecialMentionText } from '../types';
|
|
4
4
|
const packageName = "@atlaskit/mention";
|
|
5
|
-
const packageVersion = "27.
|
|
5
|
+
const packageVersion = "27.16.0";
|
|
6
6
|
export const SLI_EVENT_TYPE = 'sli';
|
|
7
7
|
export const SMART_EVENT_TYPE = 'smart';
|
|
8
8
|
export const fireAnalyticsMentionTypeaheadEvent = props => (action, duration, userIds = [], query) => {
|
package/dist/esm/_constants.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export var ELEMENTS_CHANNEL = 'fabric-elements';
|
|
1
|
+
export var ELEMENTS_CHANNEL = 'fabric-elements';
|
|
2
|
+
export var UNKNOWN_USER_ID = '_|unknown|_';
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
var _templateObject;
|
|
5
|
-
var _excluded = ["mentionType"];
|
|
5
|
+
var _excluded = ["isAvatarVisible", "mentionType"];
|
|
6
6
|
/* eslint-disable @atlaskit/design-system/no-html-button */
|
|
7
7
|
/**
|
|
8
8
|
* @jsxRuntime classic
|
|
@@ -17,13 +17,16 @@ var getStyle = function getStyle(_ref, property) {
|
|
|
17
17
|
return mentionStyle[mentionType][property];
|
|
18
18
|
};
|
|
19
19
|
var PrimitiveMention = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
20
|
-
var
|
|
20
|
+
var _ref2$isAvatarVisible = _ref2.isAvatarVisible,
|
|
21
|
+
isAvatarVisible = _ref2$isAvatarVisible === void 0 ? false : _ref2$isAvatarVisible,
|
|
22
|
+
mentionType = _ref2.mentionType,
|
|
21
23
|
other = _objectWithoutProperties(_ref2, _excluded);
|
|
22
24
|
return jsx("span", _extends({
|
|
23
|
-
ref: ref
|
|
25
|
+
ref: ref,
|
|
26
|
+
"data-avatar-visible": isAvatarVisible || undefined
|
|
24
27
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
25
28
|
,
|
|
26
|
-
css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t\t\t\tdisplay: inline;\n\t\t\t\tborder: ", " solid ", ";\n\t\t\t\tbackground: ", ";\n\t\t\t\tcolor: ", ";\n\t\t\t\tborder-radius: 20px;\n\t\t\t\tcursor: pointer;\n\t\t\t\tpadding: 0 0.3em 2px 0.23em;\n\t\t\t\tline-height: 1.714;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tfont-weight: ", ";\n\t\t\t\tword-break: break-word;\n\t\t\t\t&:hover {\n\t\t\t\t\tbackground: ", ";\n\t\t\t\t}\n\t\t\t\t&:active {\n\t\t\t\t\tbackground: ", ";\n\t\t\t\t}\n\t\t\t"])), "var(--ds-border-width, 1px)", getStyle({
|
|
29
|
+
css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t\t\t\t\tdisplay: inline;\n\t\t\t\t\tborder: ", " solid ", ";\n\t\t\t\t\tbackground: ", ";\n\t\t\t\t\tcolor: ", ";\n\t\t\t\t\tborder-radius: 20px;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t\tpadding: 0 0.3em 2px 0.23em;\n\t\t\t\t\tline-height: 1.714;\n\t\t\t\t\tfont-size: 1em;\n\t\t\t\t\tfont-weight: ", ";\n\t\t\t\t\tword-break: break-word;\n\t\t\t\t\t&[data-avatar-visible='true'] {\n\t\t\t\t\t\tpadding: 1px 0.3em 1px 0.23em;\n\t\t\t\t\t}\n\t\t\t\t\t&:hover {\n\t\t\t\t\t\tbackground: ", ";\n\t\t\t\t\t}\n\t\t\t\t\t&:active {\n\t\t\t\t\t\tbackground: ", ";\n\t\t\t\t\t}\n\t\t\t\t"])), "var(--ds-border-width, 1px)", getStyle({
|
|
27
30
|
mentionType: mentionType
|
|
28
31
|
}, 'borderColor'), getStyle({
|
|
29
32
|
mentionType: mentionType
|
|
@@ -114,10 +114,14 @@ var ResourcedMention = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
114
114
|
isDisabled: props.isDisabled,
|
|
115
115
|
disabledTooltip: props.disabledTooltip,
|
|
116
116
|
accessLevel: props.accessLevel,
|
|
117
|
+
appType: props.appType,
|
|
118
|
+
avatarUrl: props.avatarUrl,
|
|
119
|
+
isAvatarImagePreShaped: props.isAvatarImagePreShaped,
|
|
117
120
|
localId: props.localId,
|
|
118
121
|
onClick: props.onClick,
|
|
119
122
|
onMouseEnter: props.onMouseEnter,
|
|
120
123
|
onMouseLeave: props.onMouseLeave,
|
|
124
|
+
renderAvatarSlot: props.renderAvatarSlot,
|
|
121
125
|
ssrPlaceholderId: props.ssrPlaceholderId
|
|
122
126
|
});
|
|
123
127
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
._2rko1rr0{border-radius:var(--ds-radius-full,9999px)}
|
|
2
|
+
._2rkoidpf{border-radius:0}._12l21b66{margin-inline-end:var(--ds-space-050,4px)}
|
|
3
|
+
._18m915vq{overflow-y:hidden}
|
|
4
|
+
._1bah1h6o{justify-content:center}
|
|
5
|
+
._1bsb1osq{width:100%}
|
|
6
|
+
._1bsb7vkz{width:1pc}
|
|
7
|
+
._1e0c116y{display:inline-flex}
|
|
8
|
+
._1e0c1ule{display:block}
|
|
9
|
+
._1o9zidpf{flex-shrink:0}
|
|
10
|
+
._1reo15vq{overflow-x:hidden}
|
|
11
|
+
._4cvr1h6o{align-items:center}
|
|
12
|
+
._4t3i1osq{height:100%}
|
|
13
|
+
._4t3i7vkz{height:1pc}
|
|
14
|
+
._5ral1dfr{object-fit:cover}
|
|
15
|
+
._mkrz1l17{clip-path:polygon(25% 6.7%,75% 6.7%,100% 50%,75% 93.3%,25% 93.3%,0 50%)}
|
|
16
|
+
._s7n410e5{vertical-align:-.125em}
|
|
17
|
+
._s7n41q9y{vertical-align:baseline}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
@@ -5,6 +6,8 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
7
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
import "./index.compiled.css";
|
|
10
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
8
11
|
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; }
|
|
9
12
|
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) { _defineProperty(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; }
|
|
10
13
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
@@ -16,6 +19,7 @@ import MessagesIntlProvider from '../MessagesIntlProvider';
|
|
|
16
19
|
import PrimitiveMention from './PrimitiveMention';
|
|
17
20
|
import AsyncNoAccessTooltip from '../NoAccessTooltip';
|
|
18
21
|
import AsyncDisabledMentionTooltip from '../DisabledMentionTooltip';
|
|
22
|
+
import { UNKNOWN_USER_ID } from '../../_constants';
|
|
19
23
|
import { isRestricted, MentionType } from '../../types';
|
|
20
24
|
import { fireAnalyticsMentionEvent } from '../../util/analytics';
|
|
21
25
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
@@ -23,12 +27,24 @@ import { UFOExperienceState } from '@atlaskit/ufo';
|
|
|
23
27
|
import { UnknownUserError } from '../../util/i18n';
|
|
24
28
|
import { UfoErrorBoundary, mentionRenderedUfoExperience } from './ufoExperiences';
|
|
25
29
|
export var ANALYTICS_HOVER_DELAY = 1000;
|
|
26
|
-
export
|
|
30
|
+
export { UNKNOWN_USER_ID } from '../../_constants';
|
|
31
|
+
var avatarStyles = null;
|
|
32
|
+
var avatarFallbackStyles = null;
|
|
33
|
+
var avatarImageStyles = null;
|
|
34
|
+
var agentAvatarStyles = null;
|
|
27
35
|
export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
|
|
28
36
|
function MentionInternal(props) {
|
|
29
37
|
var _this;
|
|
30
38
|
_classCallCheck(this, MentionInternal);
|
|
31
39
|
_this = _callSuper(this, MentionInternal, [props]);
|
|
40
|
+
_defineProperty(_this, "state", {
|
|
41
|
+
hasAvatarError: false
|
|
42
|
+
});
|
|
43
|
+
_defineProperty(_this, "handleAvatarError", function () {
|
|
44
|
+
_this.setState({
|
|
45
|
+
hasAvatarError: true
|
|
46
|
+
});
|
|
47
|
+
});
|
|
32
48
|
_defineProperty(_this, "handleOnClick", function (e) {
|
|
33
49
|
var _this$props = _this.props,
|
|
34
50
|
id = _this$props.id,
|
|
@@ -121,17 +137,26 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
121
137
|
}, {
|
|
122
138
|
key: "render",
|
|
123
139
|
value: function render() {
|
|
124
|
-
var
|
|
140
|
+
var handleAvatarError = this.handleAvatarError,
|
|
141
|
+
handleOnClick = this.handleOnClick,
|
|
125
142
|
handleOnMouseEnter = this.handleOnMouseEnter,
|
|
126
143
|
handleOnMouseLeave = this.handleOnMouseLeave,
|
|
127
144
|
props = this.props;
|
|
128
|
-
var
|
|
145
|
+
var appType = props.appType,
|
|
146
|
+
avatarUrl = props.avatarUrl,
|
|
147
|
+
text = props.text,
|
|
129
148
|
id = props.id,
|
|
130
149
|
accessLevel = props.accessLevel,
|
|
131
150
|
localId = props.localId,
|
|
132
|
-
disabledTooltip = props.disabledTooltip
|
|
151
|
+
disabledTooltip = props.disabledTooltip,
|
|
152
|
+
isAvatarImagePreShaped = props.isAvatarImagePreShaped,
|
|
153
|
+
renderAvatarSlot = props.renderAvatarSlot;
|
|
133
154
|
var mentionType = this.getMentionType();
|
|
134
155
|
var failedMention = text === "@".concat(UNKNOWN_USER_ID);
|
|
156
|
+
var showAvatarSlot = Boolean(renderAvatarSlot) && !failedMention;
|
|
157
|
+
var visibleText = showAvatarSlot && text.startsWith('@') ? text.slice(1) : text;
|
|
158
|
+
var shouldApplyAgentShape = appType === 'agent' && !isAvatarImagePreShaped;
|
|
159
|
+
var shouldRenderAvatar = avatarUrl && !this.state.hasAvatarError;
|
|
135
160
|
var showRestrictedTooltip = mentionType === MentionType.RESTRICTED;
|
|
136
161
|
var showDisabledTooltip = mentionType === MentionType.DISABLED && !!disabledTooltip;
|
|
137
162
|
|
|
@@ -148,6 +173,7 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
148
173
|
'aria-label': "".concat(text || '@...', " \u2014 ").concat(disabledTooltip)
|
|
149
174
|
} : {}) : {};
|
|
150
175
|
var mentionComponent = /*#__PURE__*/React.createElement(FocusRing, null, /*#__PURE__*/React.createElement(PrimitiveMention, _extends({
|
|
176
|
+
isAvatarVisible: showAvatarSlot,
|
|
151
177
|
mentionType: mentionType,
|
|
152
178
|
onClick: handleOnClick,
|
|
153
179
|
onMouseEnter: handleOnMouseEnter,
|
|
@@ -156,7 +182,22 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
156
182
|
"data-testid": "mention-".concat(id),
|
|
157
183
|
"data-mention-type": mentionType,
|
|
158
184
|
"data-mention-tooltip": showRestrictedTooltip || showDisabledTooltip
|
|
159
|
-
}, disabledA11yProps), failedMention ? this.renderUnknownUserError(id) :
|
|
185
|
+
}, disabledA11yProps), failedMention ? this.renderUnknownUserError(id) : showAvatarSlot ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
186
|
+
"aria-hidden": "true",
|
|
187
|
+
"data-testid": "mention-avatar-slot",
|
|
188
|
+
className: ax(["_1reo15vq _18m915vq _2rko1rr0 _1e0c116y _1bsb7vkz _4t3i7vkz _4cvr1h6o _1bah1h6o _1o9zidpf _12l21b66 _s7n410e5", shouldApplyAgentShape && "_2rkoidpf _mkrz1l17", this.state.hasAvatarError && "_s7n41q9y"])
|
|
189
|
+
}, shouldRenderAvatar ? /*#__PURE__*/React.createElement("img", {
|
|
190
|
+
alt: "",
|
|
191
|
+
decoding: "async",
|
|
192
|
+
draggable: false,
|
|
193
|
+
height: 16,
|
|
194
|
+
loading: "lazy",
|
|
195
|
+
onError: handleAvatarError,
|
|
196
|
+
src: avatarUrl,
|
|
197
|
+
"data-testid": "mention-avatar",
|
|
198
|
+
width: 16,
|
|
199
|
+
className: ax(["_1e0c1ule _1bsb1osq _4t3i1osq _5ral1dfr"])
|
|
200
|
+
}) : this.state.hasAvatarError ? '@' : null), /*#__PURE__*/React.createElement("span", null, visibleText || '...')) : text || '@...'));
|
|
160
201
|
var ssrPlaceholderProp = props.ssrPlaceholderId ? {
|
|
161
202
|
'data-ssr-placeholder': props.ssrPlaceholderId
|
|
162
203
|
} : {};
|
|
@@ -187,6 +228,17 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
187
228
|
spellCheck: false
|
|
188
229
|
}, ssrPlaceholderProp), /*#__PURE__*/React.createElement(MessagesIntlProvider, null, wrappedMention)));
|
|
189
230
|
}
|
|
231
|
+
}], [{
|
|
232
|
+
key: "getDerivedStateFromProps",
|
|
233
|
+
value: function getDerivedStateFromProps(props, state) {
|
|
234
|
+
if (props.avatarUrl !== state.avatarUrl) {
|
|
235
|
+
return {
|
|
236
|
+
avatarUrl: props.avatarUrl,
|
|
237
|
+
hasAvatarError: false
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
190
242
|
}]);
|
|
191
243
|
}(React.PureComponent);
|
|
192
244
|
var MentionWithAnalytics = withAnalyticsEvents({
|
|
@@ -5,7 +5,7 @@ import { OPERATIONAL_EVENT_TYPE, UI_EVENT_TYPE } from '@atlaskit/analytics-gas-t
|
|
|
5
5
|
import { ELEMENTS_CHANNEL } from '../_constants';
|
|
6
6
|
import { ComponentNames, isSpecialMentionText } from '../types';
|
|
7
7
|
var packageName = "@atlaskit/mention";
|
|
8
|
-
var packageVersion = "27.
|
|
8
|
+
var packageVersion = "27.16.0";
|
|
9
9
|
export var SLI_EVENT_TYPE = 'sli';
|
|
10
10
|
export var SMART_EVENT_TYPE = 'smart';
|
|
11
11
|
export var fireAnalyticsMentionTypeaheadEvent = function fireAnalyticsMentionTypeaheadEvent(props) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ForwardRefExoticComponent, type HTMLAttributes, type RefAttributes } from 'react';
|
|
2
2
|
import type { MentionType } from '../../types';
|
|
3
3
|
export interface PrimitiveMentionProps extends HTMLAttributes<HTMLSpanElement> {
|
|
4
|
+
isAvatarVisible?: boolean;
|
|
4
5
|
mentionType: MentionType;
|
|
5
6
|
}
|
|
6
7
|
declare const PrimitiveMention: ForwardRefExoticComponent<PrimitiveMentionProps & RefAttributes<HTMLSpanElement>>;
|
|
@@ -3,14 +3,18 @@ import { type MentionProvider } from '../../api/MentionResource';
|
|
|
3
3
|
import { type MentionEventHandler } from '../../types';
|
|
4
4
|
export interface Props {
|
|
5
5
|
accessLevel?: string;
|
|
6
|
+
appType?: string | null;
|
|
7
|
+
avatarUrl?: string;
|
|
6
8
|
disabledTooltip?: string;
|
|
7
9
|
id: string;
|
|
10
|
+
isAvatarImagePreShaped?: boolean;
|
|
8
11
|
isDisabled?: boolean;
|
|
9
12
|
localId?: string;
|
|
10
13
|
mentionProvider?: Promise<MentionProvider>;
|
|
11
14
|
onClick?: MentionEventHandler;
|
|
12
15
|
onMouseEnter?: MentionEventHandler;
|
|
13
16
|
onMouseLeave?: MentionEventHandler;
|
|
17
|
+
renderAvatarSlot?: boolean;
|
|
14
18
|
ssrPlaceholderId?: string;
|
|
15
19
|
text: string;
|
|
16
20
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
* @jsxFrag React.Fragment
|
|
5
|
+
*/
|
|
1
6
|
import React from 'react';
|
|
2
7
|
import { type MentionEventHandler } from '../../types';
|
|
3
8
|
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
4
9
|
export declare const ANALYTICS_HOVER_DELAY = 1000;
|
|
5
|
-
export
|
|
10
|
+
export { UNKNOWN_USER_ID } from '../../_constants';
|
|
6
11
|
export type OwnProps = {
|
|
7
12
|
accessLevel?: string;
|
|
13
|
+
appType?: string | null;
|
|
14
|
+
avatarUrl?: string;
|
|
8
15
|
/**
|
|
9
16
|
* Tooltip text shown on hover when the chip is disabled. Ignored when
|
|
10
17
|
* `isDisabled` is false. When omitted, no tooltip is rendered even if
|
|
@@ -12,6 +19,7 @@ export type OwnProps = {
|
|
|
12
19
|
*/
|
|
13
20
|
disabledTooltip?: string;
|
|
14
21
|
id: string;
|
|
22
|
+
isAvatarImagePreShaped?: boolean;
|
|
15
23
|
/**
|
|
16
24
|
* When true, the mention chip is rendered in its disabled visual state
|
|
17
25
|
* (`MentionType.DISABLED`) and click handlers are not invoked. Takes
|
|
@@ -24,14 +32,23 @@ export type OwnProps = {
|
|
|
24
32
|
onHover?: () => void;
|
|
25
33
|
onMouseEnter?: MentionEventHandler;
|
|
26
34
|
onMouseLeave?: MentionEventHandler;
|
|
35
|
+
/** Whether the upstream integration has enabled the avatar treatment for this mention. */
|
|
36
|
+
renderAvatarSlot?: boolean;
|
|
27
37
|
ssrPlaceholderId?: string;
|
|
28
38
|
text: string;
|
|
29
39
|
};
|
|
30
40
|
export type Props = OwnProps & WithAnalyticsEventsProps;
|
|
31
|
-
|
|
41
|
+
type State = {
|
|
42
|
+
avatarUrl?: string;
|
|
43
|
+
hasAvatarError: boolean;
|
|
44
|
+
};
|
|
45
|
+
export declare class MentionInternal extends React.PureComponent<Props, State> {
|
|
32
46
|
private hoverTimeout?;
|
|
47
|
+
state: State;
|
|
33
48
|
constructor(props: Props);
|
|
34
49
|
componentDidMount(): void;
|
|
50
|
+
static getDerivedStateFromProps(props: Props, state: State): Partial<State> | null;
|
|
51
|
+
private handleAvatarError;
|
|
35
52
|
private handleOnClick;
|
|
36
53
|
private handleOnMouseEnter;
|
|
37
54
|
private handleOnMouseLeave;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { type SyntheticEvent } from 'react';
|
|
2
2
|
import { type ServiceConfig } from '@atlaskit/util-service-support/types';
|
|
3
|
+
export interface MentionNodeData {
|
|
4
|
+
appType?: string | null;
|
|
5
|
+
avatarUrl?: string;
|
|
6
|
+
/** The image already contains its intended user/agent shape and must not be clipped again. */
|
|
7
|
+
isAvatarImagePreShaped?: boolean;
|
|
8
|
+
}
|
|
3
9
|
export interface MentionNameResolver {
|
|
4
10
|
cacheName(id: string, name: string): void;
|
|
5
11
|
lookupName(id: string): Promise<MentionNameDetails> | MentionNameDetails;
|
|
@@ -212,6 +218,7 @@ export interface RealMentionDescription {
|
|
|
212
218
|
appType?: string | null;
|
|
213
219
|
avatarUrl?: string;
|
|
214
220
|
context?: MentionDescContext;
|
|
221
|
+
description?: string;
|
|
215
222
|
highlight?: Highlight;
|
|
216
223
|
id: string;
|
|
217
224
|
inContext?: boolean;
|
package/package.json
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"@atlaskit/analytics-gas-types": "^6.0.0",
|
|
31
31
|
"@atlaskit/analytics-next": "^12.3.0",
|
|
32
32
|
"@atlaskit/avatar": "^27.0.0",
|
|
33
|
+
"@atlaskit/css": "^1.0.0",
|
|
33
34
|
"@atlaskit/focus-ring": "^5.0.0",
|
|
34
35
|
"@atlaskit/heading": "^7.0.0",
|
|
35
36
|
"@atlaskit/icon": "^37.3.0",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"@atlaskit/skeleton": "^4.2.0",
|
|
42
43
|
"@atlaskit/tag": "^15.4.0",
|
|
43
44
|
"@atlaskit/teams-avatar": "^4.1.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^147.
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^147.1.0",
|
|
45
46
|
"@atlaskit/tokens": "^16.7.0",
|
|
46
47
|
"@atlaskit/tooltip": "^24.0.0",
|
|
47
48
|
"@atlaskit/ufo": "^1.0.0",
|
|
@@ -125,5 +126,5 @@
|
|
|
125
126
|
}
|
|
126
127
|
},
|
|
127
128
|
"types": "dist/types/index.d.ts",
|
|
128
|
-
"version": "27.
|
|
129
|
+
"version": "27.17.0"
|
|
129
130
|
}
|
package/mention.docs.tsx
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured MCP docs for `@atlaskit/mention`.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import path from 'path';
|
|
6
|
-
|
|
7
|
-
import type { StructuredContentSource } from '@atlassian/structured-docs-types/types';
|
|
8
|
-
|
|
9
|
-
import packageJson from './package.json';
|
|
10
|
-
|
|
11
|
-
const packagePath = path.resolve(__dirname);
|
|
12
|
-
|
|
13
|
-
const documentation: StructuredContentSource = {
|
|
14
|
-
package: {
|
|
15
|
-
package: '@atlaskit/mention',
|
|
16
|
-
packagePath,
|
|
17
|
-
packageJson,
|
|
18
|
-
overview:
|
|
19
|
-
'React components for displaying user and team mentions. It includes support for mention items, lists, and pickers with integration for profile cards and presence.',
|
|
20
|
-
},
|
|
21
|
-
components: [
|
|
22
|
-
{
|
|
23
|
-
name: 'Mention',
|
|
24
|
-
description: 'A component for displaying a single mention.',
|
|
25
|
-
status: 'general-availability',
|
|
26
|
-
import: {
|
|
27
|
-
name: 'Mention',
|
|
28
|
-
package: '@atlaskit/mention',
|
|
29
|
-
type: 'named',
|
|
30
|
-
packagePath,
|
|
31
|
-
packageJson,
|
|
32
|
-
},
|
|
33
|
-
usageGuidelines: ['Use `Mention` to render a mention for a user or team.'],
|
|
34
|
-
keywords: ['mention', 'user', 'team'],
|
|
35
|
-
categories: ['elements'],
|
|
36
|
-
examples: [
|
|
37
|
-
{
|
|
38
|
-
name: 'Simple mention',
|
|
39
|
-
description: 'Basic usage of the Mention component.',
|
|
40
|
-
source: path.resolve(packagePath, './examples/07-simple-mention.tsx'),
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: 'MentionPicker',
|
|
46
|
-
description: 'A component that provides a searchable picker for mentions.',
|
|
47
|
-
status: 'general-availability',
|
|
48
|
-
import: {
|
|
49
|
-
name: 'MentionPicker',
|
|
50
|
-
package: '@atlaskit/mention',
|
|
51
|
-
type: 'named',
|
|
52
|
-
packagePath,
|
|
53
|
-
packageJson,
|
|
54
|
-
},
|
|
55
|
-
usageGuidelines: [
|
|
56
|
-
'Use `MentionPicker` to allow users to select a user or team to mention.',
|
|
57
|
-
'Requires a `MentionResource` to fetch and manage mention data.',
|
|
58
|
-
],
|
|
59
|
-
keywords: ['mention', 'picker', 'select'],
|
|
60
|
-
categories: ['elements'],
|
|
61
|
-
examples: [
|
|
62
|
-
{
|
|
63
|
-
name: 'Mention list picker',
|
|
64
|
-
description: 'Basic usage of MentionPicker.',
|
|
65
|
-
source: path.resolve(packagePath, './examples/05-mention-list-picker.tsx'),
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default documentation;
|