@atlaskit/mention 27.17.1 → 27.18.1
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 +40 -0
- package/dist/cjs/api/AbstractMentionResource.js +111 -0
- package/dist/cjs/api/AbstractPresenceResource.js +41 -0
- package/dist/cjs/api/AbstractResource.js +48 -0
- package/dist/cjs/api/Callback.js +5 -0
- package/dist/cjs/api/DefaultMentionNameResolver.js +178 -0
- package/dist/cjs/api/DefaultPresenceCache.js +159 -0
- package/dist/cjs/api/DefaultPresenceParser.js +91 -0
- package/dist/cjs/api/HttpError.js +16 -0
- package/dist/cjs/api/MentionNameResolver.js +13 -201
- package/dist/cjs/api/MentionResource.js +52 -157
- package/dist/cjs/api/PresenceResource.js +39 -263
- package/dist/cjs/api/Queue.js +5 -0
- package/dist/cjs/api/isResolvingMentionProvider.js +9 -0
- package/dist/cjs/api/mergeNameResolverQueues.js +36 -0
- package/dist/cjs/components/Mention/MentionInternal.js +247 -0
- package/dist/cjs/components/Mention/ResourcedMention.js +5 -4
- package/dist/cjs/components/Mention/index.js +29 -243
- package/dist/cjs/components/MentionAvatar/index.js +5 -4
- package/dist/cjs/components/MentionItem/index.js +18 -12
- package/dist/cjs/components/MentionList/index.js +4 -3
- package/dist/cjs/components/MentionPicker/MentionPicker.js +231 -0
- package/dist/cjs/components/MentionPicker/index.js +18 -225
- package/dist/cjs/components/MessagesIntlProvider/index.js +2 -2
- package/dist/cjs/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +228 -0
- package/dist/cjs/components/ResourcedMentionList/index.js +14 -223
- package/dist/cjs/index.js +17 -15
- package/dist/cjs/is-agent-mention.js +12 -0
- package/dist/cjs/is-app-mention.js +10 -0
- package/dist/cjs/is-promise.js +9 -0
- package/dist/cjs/is-restricted.js +10 -0
- package/dist/cjs/is-special-mention-text.js +9 -0
- package/dist/cjs/is-special-mention.js +10 -0
- package/dist/cjs/is-team-mention.js +10 -0
- package/dist/cjs/resource.js +15 -12
- package/dist/cjs/team-resource.js +9 -9
- package/dist/cjs/typeahead.js +4 -0
- package/dist/cjs/types.js +71 -30
- package/dist/cjs/util/actual-mouse-move.js +14 -0
- package/dist/cjs/util/analytics.js +91 -107
- package/dist/cjs/util/build-sli-payload.js +27 -0
- package/dist/cjs/util/fire-analytics-mention-event.js +32 -0
- package/dist/cjs/util/fire-analytics-mention-hydration-event.js +33 -0
- package/dist/cjs/util/fire-analytics-mention-typeahead-event.js +34 -0
- package/dist/cjs/util/fire-analytics.js +18 -0
- package/dist/cjs/util/fire-sli-analytics-event.js +16 -0
- package/dist/cjs/util/get-messages-for-locale.js +233 -0
- package/dist/cjs/util/i18n.js +9 -254
- package/dist/cjs/util/left-click.js +9 -0
- package/dist/cjs/util/mouse-location.js +12 -0
- package/dist/cjs/util/mouse.js +1 -26
- package/dist/cjs/util/package-name.js +7 -0
- package/dist/cjs/util/package-version.js +7 -0
- package/dist/cjs/util/prop-formatter.js +25 -0
- package/dist/es2019/api/AbstractMentionResource.js +73 -0
- package/dist/es2019/api/AbstractPresenceResource.js +17 -0
- package/dist/es2019/api/AbstractResource.js +33 -0
- package/dist/es2019/api/Callback.js +1 -0
- package/dist/es2019/api/DefaultMentionNameResolver.js +152 -0
- package/dist/es2019/api/DefaultPresenceCache.js +111 -0
- package/dist/es2019/api/DefaultPresenceParser.js +58 -0
- package/dist/es2019/api/HttpError.js +8 -0
- package/dist/es2019/api/MentionNameResolver.js +13 -176
- package/dist/es2019/api/MentionResource.js +28 -122
- package/dist/es2019/api/PresenceResource.js +19 -185
- package/dist/es2019/api/Queue.js +1 -0
- package/dist/es2019/api/isResolvingMentionProvider.js +1 -0
- package/dist/es2019/api/mergeNameResolverQueues.js +25 -0
- package/dist/es2019/components/Mention/MentionInternal.js +225 -0
- package/dist/es2019/components/Mention/ResourcedMention.js +4 -3
- package/dist/es2019/components/Mention/index.js +19 -223
- package/dist/es2019/components/MentionAvatar/index.js +3 -2
- package/dist/es2019/components/MentionItem/index.js +14 -8
- package/dist/es2019/components/MentionList/index.js +2 -1
- package/dist/es2019/components/MentionPicker/MentionPicker.js +198 -0
- package/dist/es2019/components/MentionPicker/index.js +15 -198
- package/dist/es2019/components/MessagesIntlProvider/index.js +1 -1
- package/dist/es2019/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +187 -0
- package/dist/es2019/components/ResourcedMentionList/index.js +9 -187
- package/dist/es2019/element.js +5 -0
- package/dist/es2019/index.js +13 -9
- package/dist/es2019/is-agent-mention.js +6 -0
- package/dist/es2019/is-app-mention.js +4 -0
- package/dist/es2019/is-promise.js +1 -0
- package/dist/es2019/is-restricted.js +4 -0
- package/dist/es2019/is-special-mention-text.js +3 -0
- package/dist/es2019/is-special-mention.js +4 -0
- package/dist/es2019/is-team-mention.js +4 -0
- package/dist/es2019/item.js +5 -0
- package/dist/es2019/resource.js +15 -5
- package/dist/es2019/team-resource.js +10 -4
- package/dist/es2019/typeahead.js +5 -0
- package/dist/es2019/types.js +30 -21
- package/dist/es2019/util/actual-mouse-move.js +8 -0
- package/dist/es2019/util/analytics.js +35 -91
- package/dist/es2019/util/build-sli-payload.js +18 -0
- package/dist/es2019/util/fire-analytics-mention-event.js +24 -0
- package/dist/es2019/util/fire-analytics-mention-hydration-event.js +25 -0
- package/dist/es2019/util/fire-analytics-mention-typeahead-event.js +24 -0
- package/dist/es2019/util/fire-analytics.js +10 -0
- package/dist/es2019/util/fire-sli-analytics-event.js +8 -0
- package/dist/es2019/util/get-messages-for-locale.js +145 -0
- package/dist/es2019/util/i18n.js +2 -165
- package/dist/es2019/util/left-click.js +3 -0
- package/dist/es2019/util/mouse-location.js +6 -0
- package/dist/es2019/util/mouse.js +0 -18
- package/dist/es2019/util/package-name.js +1 -0
- package/dist/es2019/util/package-version.js +1 -0
- package/dist/es2019/util/prop-formatter.js +18 -0
- package/dist/esm/api/AbstractMentionResource.js +104 -0
- package/dist/esm/api/AbstractPresenceResource.js +34 -0
- package/dist/esm/api/AbstractResource.js +41 -0
- package/dist/esm/api/Callback.js +1 -0
- package/dist/esm/api/DefaultMentionNameResolver.js +171 -0
- package/dist/esm/api/DefaultPresenceCache.js +152 -0
- package/dist/esm/api/DefaultPresenceParser.js +84 -0
- package/dist/esm/api/HttpError.js +9 -0
- package/dist/esm/api/MentionNameResolver.js +13 -198
- package/dist/esm/api/MentionResource.js +30 -154
- package/dist/esm/api/PresenceResource.js +22 -256
- package/dist/esm/api/Queue.js +1 -0
- package/dist/esm/api/isResolvingMentionProvider.js +3 -0
- package/dist/esm/api/mergeNameResolverQueues.js +29 -0
- package/dist/esm/components/Mention/MentionInternal.js +242 -0
- package/dist/esm/components/Mention/ResourcedMention.js +4 -3
- package/dist/esm/components/Mention/index.js +19 -240
- package/dist/esm/components/MentionAvatar/index.js +3 -2
- package/dist/esm/components/MentionItem/index.js +14 -8
- package/dist/esm/components/MentionList/index.js +2 -1
- package/dist/esm/components/MentionPicker/MentionPicker.js +225 -0
- package/dist/esm/components/MentionPicker/index.js +15 -225
- package/dist/esm/components/MessagesIntlProvider/index.js +1 -1
- package/dist/esm/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.js +221 -0
- package/dist/esm/components/ResourcedMentionList/index.js +9 -221
- package/dist/esm/element.js +5 -0
- package/dist/esm/index.js +13 -9
- package/dist/esm/is-agent-mention.js +6 -0
- package/dist/esm/is-app-mention.js +4 -0
- package/dist/esm/is-promise.js +3 -0
- package/dist/esm/is-restricted.js +4 -0
- package/dist/esm/is-special-mention-text.js +3 -0
- package/dist/esm/is-special-mention.js +4 -0
- package/dist/esm/is-team-mention.js +4 -0
- package/dist/esm/item.js +5 -0
- package/dist/esm/resource.js +15 -5
- package/dist/esm/team-resource.js +10 -4
- package/dist/esm/typeahead.js +5 -0
- package/dist/esm/types.js +30 -23
- package/dist/esm/util/actual-mouse-move.js +8 -0
- package/dist/esm/util/analytics.js +35 -105
- package/dist/esm/util/build-sli-payload.js +20 -0
- package/dist/esm/util/fire-analytics-mention-event.js +26 -0
- package/dist/esm/util/fire-analytics-mention-hydration-event.js +27 -0
- package/dist/esm/util/fire-analytics-mention-typeahead-event.js +28 -0
- package/dist/esm/util/fire-analytics.js +12 -0
- package/dist/esm/util/fire-sli-analytics-event.js +10 -0
- package/dist/esm/util/get-messages-for-locale.js +163 -0
- package/dist/esm/util/i18n.js +2 -183
- package/dist/esm/util/left-click.js +3 -0
- package/dist/esm/util/mouse-location.js +6 -0
- package/dist/esm/util/mouse.js +0 -18
- package/dist/esm/util/package-name.js +1 -0
- package/dist/esm/util/package-version.js +1 -0
- package/dist/esm/util/prop-formatter.js +18 -0
- package/dist/types/api/AbstractMentionResource.d.ts +15 -0
- package/dist/types/api/AbstractPresenceResource.d.ts +6 -0
- package/dist/types/api/AbstractResource.d.ts +11 -0
- package/dist/types/api/Callback.d.ts +4 -0
- package/dist/types/api/DefaultMentionNameResolver.d.ts +27 -0
- package/dist/types/api/DefaultPresenceCache.d.ts +57 -0
- package/dist/types/api/DefaultPresenceParser.d.ts +8 -0
- package/dist/types/api/HttpError.d.ts +7 -0
- package/dist/types/api/MentionNameResolver.d.ts +14 -35
- package/dist/types/api/MentionResource.d.ts +18 -33
- package/dist/types/api/PresenceResource.d.ts +15 -69
- package/dist/types/api/Queue.d.ts +2 -0
- package/dist/types/api/isResolvingMentionProvider.d.ts +2 -0
- package/dist/types/api/mergeNameResolverQueues.d.ts +6 -0
- package/dist/types/components/Mention/MentionInternal.d.ts +27 -0
- package/dist/types/components/Mention/ResourcedMention.d.ts +1 -1
- package/dist/types/components/Mention/index.d.ts +9 -20
- package/dist/types/components/MentionAvatar/index.d.ts +1 -1
- package/dist/types/components/MentionItem/index.d.ts +4 -1
- package/dist/types/components/MentionPicker/MentionPicker.d.ts +46 -0
- package/dist/types/components/MentionPicker/index.d.ts +5 -42
- package/dist/types/components/ResourcedMentionList/ResourcedMentionListWithoutAnalytics.d.ts +30 -0
- package/dist/types/components/ResourcedMentionList/index.d.ts +5 -27
- package/dist/types/element.d.ts +3 -0
- package/dist/types/index.d.ts +15 -10
- package/dist/types/is-agent-mention.d.ts +2 -0
- package/dist/types/is-app-mention.d.ts +2 -0
- package/dist/types/is-promise.d.ts +1 -0
- package/dist/types/is-restricted.d.ts +1 -0
- package/dist/types/is-special-mention-text.d.ts +1 -0
- package/dist/types/is-special-mention.d.ts +2 -0
- package/dist/types/is-team-mention.d.ts +2 -0
- package/dist/types/item.d.ts +3 -0
- package/dist/types/resource.d.ts +15 -6
- package/dist/types/team-resource.d.ts +10 -4
- package/dist/types/typeahead.d.ts +3 -0
- package/dist/types/types.d.ts +28 -8
- package/dist/types/util/actual-mouse-move.d.ts +2 -0
- package/dist/types/util/analytics.d.ts +33 -10
- package/dist/types/util/build-sli-payload.d.ts +4 -0
- package/dist/types/util/fire-analytics-mention-event.d.ts +1 -0
- package/dist/types/util/fire-analytics-mention-hydration-event.d.ts +1 -0
- package/dist/types/util/fire-analytics-mention-typeahead-event.d.ts +1 -0
- package/dist/types/util/fire-analytics.d.ts +1 -0
- package/dist/types/util/fire-sli-analytics-event.d.ts +1 -0
- package/dist/types/util/get-messages-for-locale.d.ts +11 -0
- package/dist/types/util/i18n.d.ts +0 -15
- package/dist/types/util/left-click.d.ts +2 -0
- package/dist/types/util/mouse-location.d.ts +3 -0
- package/dist/types/util/mouse.d.ts +0 -4
- package/dist/types/util/package-name.d.ts +1 -0
- package/dist/types/util/package-version.d.ts +1 -0
- package/dist/types/util/prop-formatter.d.ts +5 -0
- package/package.json +2 -2
- package/dist/cjs/i18n/index.js +0 -216
- package/dist/es2019/i18n/index.js +0 -37
- package/dist/esm/i18n/index.js +0 -37
- package/dist/types/i18n/index.d.ts +0 -37
- /package/dist/cjs/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
- /package/dist/es2019/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
- /package/dist/esm/components/Mention/{index.compiled.css → MentionInternal.compiled.css} +0 -0
|
@@ -1,229 +1,20 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
* @jsxFrag React.Fragment
|
|
6
|
+
*/
|
|
6
7
|
/* eslint-disable @atlaskit/design-system/no-deprecated-imports, @typescript-eslint/ban-types -- Preserve existing mention implementation while focus-ring usage is reviewed separately. */
|
|
7
|
-
|
|
8
|
-
import FocusRing from '@atlaskit/focus-ring';
|
|
9
|
-
import MessagesIntlProvider from '../MessagesIntlProvider';
|
|
10
|
-
import PrimitiveMention from './PrimitiveMention';
|
|
11
|
-
import AsyncNoAccessTooltip from '../NoAccessTooltip';
|
|
12
|
-
import AsyncDisabledMentionTooltip from '../DisabledMentionTooltip';
|
|
13
|
-
import { UNKNOWN_USER_ID } from '../../_constants';
|
|
14
|
-
import { isRestricted, MentionType } from '../../types';
|
|
15
|
-
import { fireAnalyticsMentionEvent } from '../../util/analytics';
|
|
8
|
+
|
|
16
9
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { UfoErrorBoundary, mentionRenderedUfoExperience } from './ufoExperiences';
|
|
10
|
+
import { fireAnalyticsMentionEvent } from '../../util/fire-analytics-mention-event';
|
|
11
|
+
import { MentionInternal } from './MentionInternal';
|
|
20
12
|
export const ANALYTICS_HOVER_DELAY = 1000;
|
|
21
|
-
export { UNKNOWN_USER_ID } from '../../_constants';
|
|
22
|
-
const avatarStyles = null;
|
|
23
|
-
const avatarFallbackStyles = null;
|
|
24
|
-
const avatarImageStyles = null;
|
|
25
|
-
const agentAvatarStyles = null;
|
|
26
|
-
export class MentionInternal extends React.PureComponent {
|
|
27
|
-
constructor(props) {
|
|
28
|
-
super(props);
|
|
29
|
-
_defineProperty(this, "state", {
|
|
30
|
-
hasAvatarError: false
|
|
31
|
-
});
|
|
32
|
-
_defineProperty(this, "handleAvatarError", () => {
|
|
33
|
-
this.setState({
|
|
34
|
-
hasAvatarError: true
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
_defineProperty(this, "handleOnClick", e => {
|
|
38
|
-
const {
|
|
39
|
-
id,
|
|
40
|
-
text,
|
|
41
|
-
onClick,
|
|
42
|
-
isDisabled
|
|
43
|
-
} = this.props;
|
|
44
|
-
if (isDisabled) {
|
|
45
|
-
// Disabled chips do not invoke their click handler.
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (onClick) {
|
|
49
|
-
onClick(id, text, e);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
_defineProperty(this, "handleOnMouseEnter", e => {
|
|
53
|
-
const {
|
|
54
|
-
id,
|
|
55
|
-
text,
|
|
56
|
-
onMouseEnter,
|
|
57
|
-
onHover
|
|
58
|
-
} = this.props;
|
|
59
|
-
if (onMouseEnter) {
|
|
60
|
-
onMouseEnter(id, text, e);
|
|
61
|
-
}
|
|
62
|
-
this.hoverTimeout = window.setTimeout(() => {
|
|
63
|
-
if (onHover) {
|
|
64
|
-
onHover();
|
|
65
|
-
}
|
|
66
|
-
this.hoverTimeout = undefined;
|
|
67
|
-
}, ANALYTICS_HOVER_DELAY);
|
|
68
|
-
});
|
|
69
|
-
_defineProperty(this, "handleOnMouseLeave", e => {
|
|
70
|
-
const {
|
|
71
|
-
id,
|
|
72
|
-
text,
|
|
73
|
-
onMouseLeave
|
|
74
|
-
} = this.props;
|
|
75
|
-
if (onMouseLeave) {
|
|
76
|
-
onMouseLeave(id, text, e);
|
|
77
|
-
}
|
|
78
|
-
if (this.hoverTimeout) {
|
|
79
|
-
clearTimeout(this.hoverTimeout);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
_defineProperty(this, "getMentionType", () => {
|
|
83
|
-
const {
|
|
84
|
-
accessLevel,
|
|
85
|
-
isHighlighted,
|
|
86
|
-
isDisabled
|
|
87
|
-
} = this.props;
|
|
88
|
-
if (isDisabled) {
|
|
89
|
-
return MentionType.DISABLED;
|
|
90
|
-
}
|
|
91
|
-
if (isHighlighted) {
|
|
92
|
-
return MentionType.SELF;
|
|
93
|
-
}
|
|
94
|
-
if (isRestricted(accessLevel)) {
|
|
95
|
-
return MentionType.RESTRICTED;
|
|
96
|
-
}
|
|
97
|
-
return MentionType.DEFAULT;
|
|
98
|
-
});
|
|
99
|
-
mentionRenderedUfoExperience.getInstance(props.id).start();
|
|
100
|
-
}
|
|
101
|
-
componentDidMount() {
|
|
102
|
-
mentionRenderedUfoExperience.getInstance(this.props.id).success();
|
|
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
|
-
}
|
|
113
|
-
componentWillUnmount() {
|
|
114
|
-
if (this.hoverTimeout) {
|
|
115
|
-
clearTimeout(this.hoverTimeout);
|
|
116
|
-
}
|
|
117
|
-
const ufoInstance = mentionRenderedUfoExperience.getInstance(this.props.id);
|
|
118
|
-
if ([UFOExperienceState['STARTED'], UFOExperienceState['IN_PROGRESS']].includes(ufoInstance.state)) {
|
|
119
|
-
ufoInstance.abort();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
renderUnknownUserError(id) {
|
|
123
|
-
return /*#__PURE__*/React.createElement(UnknownUserError, {
|
|
124
|
-
values: {
|
|
125
|
-
userId: id.slice(-5)
|
|
126
|
-
}
|
|
127
|
-
}, message => /*#__PURE__*/React.createElement(React.Fragment, null, `@${message}`));
|
|
128
|
-
}
|
|
129
|
-
render() {
|
|
130
|
-
const {
|
|
131
|
-
handleAvatarError,
|
|
132
|
-
handleOnClick,
|
|
133
|
-
handleOnMouseEnter,
|
|
134
|
-
handleOnMouseLeave,
|
|
135
|
-
props
|
|
136
|
-
} = this;
|
|
137
|
-
const {
|
|
138
|
-
appType,
|
|
139
|
-
avatarUrl,
|
|
140
|
-
text,
|
|
141
|
-
id,
|
|
142
|
-
accessLevel,
|
|
143
|
-
localId,
|
|
144
|
-
disabledTooltip,
|
|
145
|
-
isAvatarImagePreShaped,
|
|
146
|
-
renderAvatarSlot
|
|
147
|
-
} = props;
|
|
148
|
-
const mentionType = this.getMentionType();
|
|
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;
|
|
154
|
-
const showRestrictedTooltip = mentionType === MentionType.RESTRICTED;
|
|
155
|
-
const showDisabledTooltip = mentionType === MentionType.DISABLED && !!disabledTooltip;
|
|
156
13
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// `aria-describedby`.
|
|
162
|
-
const isDisabledChip = mentionType === MentionType.DISABLED;
|
|
163
|
-
const disabledA11yProps = isDisabledChip ? {
|
|
164
|
-
'aria-disabled': true,
|
|
165
|
-
tabIndex: 0,
|
|
166
|
-
...(disabledTooltip ? {
|
|
167
|
-
'aria-label': `${text || '@...'} — ${disabledTooltip}`
|
|
168
|
-
} : {})
|
|
169
|
-
} : {};
|
|
170
|
-
const mentionComponent = /*#__PURE__*/React.createElement(FocusRing, null, /*#__PURE__*/React.createElement(PrimitiveMention, _extends({
|
|
171
|
-
isAvatarVisible: showAvatarSlot,
|
|
172
|
-
mentionType: mentionType,
|
|
173
|
-
onClick: handleOnClick,
|
|
174
|
-
onMouseEnter: handleOnMouseEnter,
|
|
175
|
-
onMouseLeave: handleOnMouseLeave,
|
|
176
|
-
spellCheck: false,
|
|
177
|
-
"data-testid": `mention-${id}`,
|
|
178
|
-
"data-mention-type": mentionType,
|
|
179
|
-
"data-mention-tooltip": showRestrictedTooltip || showDisabledTooltip
|
|
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 || '@...'));
|
|
196
|
-
const ssrPlaceholderProp = props.ssrPlaceholderId ? {
|
|
197
|
-
'data-ssr-placeholder': props.ssrPlaceholderId
|
|
198
|
-
} : {};
|
|
199
|
-
const wrappedMention = (() => {
|
|
200
|
-
if (showRestrictedTooltip) {
|
|
201
|
-
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
202
|
-
fallback: mentionComponent
|
|
203
|
-
}, /*#__PURE__*/React.createElement(AsyncNoAccessTooltip, {
|
|
204
|
-
name: text
|
|
205
|
-
}, mentionComponent));
|
|
206
|
-
}
|
|
207
|
-
if (showDisabledTooltip) {
|
|
208
|
-
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
209
|
-
fallback: mentionComponent
|
|
210
|
-
}, /*#__PURE__*/React.createElement(AsyncDisabledMentionTooltip, {
|
|
211
|
-
tooltip: disabledTooltip
|
|
212
|
-
}, mentionComponent));
|
|
213
|
-
}
|
|
214
|
-
return mentionComponent;
|
|
215
|
-
})();
|
|
216
|
-
return /*#__PURE__*/React.createElement(UfoErrorBoundary, {
|
|
217
|
-
id: id
|
|
218
|
-
}, /*#__PURE__*/React.createElement("span", _extends({
|
|
219
|
-
id: localId,
|
|
220
|
-
"data-mention-id": id,
|
|
221
|
-
"data-local-id": localId,
|
|
222
|
-
"data-access-level": accessLevel,
|
|
223
|
-
spellCheck: false
|
|
224
|
-
}, ssrPlaceholderProp), /*#__PURE__*/React.createElement(MessagesIntlProvider, null, wrappedMention)));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use `import { UNKNOWN_USER_ID } from '@atlaskit/mention/constants'` instead.
|
|
16
|
+
*/
|
|
17
|
+
export { UNKNOWN_USER_ID } from '../../_constants';
|
|
227
18
|
const MentionWithAnalytics = withAnalyticsEvents({
|
|
228
19
|
onClick: (createEvent, props) => {
|
|
229
20
|
const {
|
|
@@ -245,4 +36,9 @@ const MentionWithAnalytics = withAnalyticsEvents({
|
|
|
245
36
|
}
|
|
246
37
|
})(MentionInternal);
|
|
247
38
|
const Mention = MentionWithAnalytics;
|
|
248
|
-
export default Mention;
|
|
39
|
+
export default Mention;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use `import { MentionInternal } from '@atlaskit/mention/mention'` instead.
|
|
43
|
+
*/
|
|
44
|
+
export { MentionInternal } from './MentionInternal';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Avatar, { getAppearanceForAppType } from '@atlaskit/avatar';
|
|
3
|
-
import TeamAvatar from '@atlaskit/teams-avatar/teams-avatar';
|
|
4
3
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
-
import
|
|
5
|
+
import TeamAvatar from '@atlaskit/teams-avatar/teams-avatar';
|
|
6
|
+
import { isAppMention } from '../../is-app-mention';
|
|
7
|
+
import { isTeamMention } from '../../is-team-mention';
|
|
7
8
|
export const MentionAvatar = ({
|
|
8
9
|
mention,
|
|
9
10
|
selected
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
/* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import EditorPanelIcon from '@atlaskit/icon/core/status-information';
|
|
3
6
|
import Lozenge from '@atlaskit/lozenge';
|
|
4
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
8
|
import Tag from '@atlaskit/tag';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import EditorPanelIcon from '@atlaskit/icon/core/status-information';
|
|
8
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
-
import { isAgentMention
|
|
10
|
+
import { isAgentMention } from '../../is-agent-mention';
|
|
11
|
+
import { isRestricted } from '../../is-restricted';
|
|
10
12
|
import { NoAccessLabel } from '../../util/i18n';
|
|
11
|
-
import { leftClick } from '../../util/
|
|
12
|
-
import AsyncNoAccessTooltip from '../NoAccessTooltip';
|
|
13
|
+
import { leftClick } from '../../util/left-click';
|
|
13
14
|
import AsyncLockCircleIcon from '../LockCircleIcon';
|
|
14
|
-
import {
|
|
15
|
-
import { renderHighlight } from './MentionHighlightHelpers';
|
|
15
|
+
import { MentionAvatar } from '../MentionAvatar';
|
|
16
16
|
import MentionDescriptionByline from '../MentionDescriptionByline';
|
|
17
17
|
import MessagesIntlProvider from '../MessagesIntlProvider';
|
|
18
|
-
import
|
|
18
|
+
import AsyncNoAccessTooltip from '../NoAccessTooltip';
|
|
19
|
+
import { renderHighlight } from './MentionHighlightHelpers';
|
|
20
|
+
import { AccessSectionStyle, AvatarStyle, FullNameStyle, InfoSectionStyle, MentionItemStyle, NameSectionStyle, RowStyle as RowStyleLegacy, RowStyleNext, TimeStyle } from './styles';
|
|
19
21
|
|
|
20
22
|
// Lazy-loaded so `@atlaskit/skeleton` (only needed for the loading
|
|
21
23
|
// placeholder) doesn't enter the bundle for every `@atlaskit/mention`
|
|
22
24
|
// consumer — only when an `isPlaceholder` mention is actually rendered.
|
|
23
25
|
const MentionItemPlaceholder = /*#__PURE__*/React.lazy(() => import( /* webpackChunkName: "@atlaskit-internal_mention-item-placeholder" */'./MentionItemPlaceholder'));
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use `import { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from '@atlaskit/mention/mention-item/styles'` instead.
|
|
29
|
+
*/
|
|
24
30
|
export { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from './styles';
|
|
25
31
|
const lozengeAppearanceToTagColor = {
|
|
26
32
|
default: 'standard',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { actualMouseMove } from '../../util/actual-mouse-move';
|
|
3
4
|
import debug from '../../util/logger';
|
|
4
|
-
import {
|
|
5
|
+
import { mouseLocation } from '../../util/mouse-location';
|
|
5
6
|
import { MentionItemWithRef } from '../MentionItem';
|
|
6
7
|
import MentionListError from '../MentionListError';
|
|
7
8
|
import MessagesIntlProvider from '../MessagesIntlProvider';
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { IntlProvider } from 'react-intl';
|
|
4
|
+
import { Text } from '@atlaskit/primitives/compiled';
|
|
5
|
+
import { fireAnalyticsMentionTypeaheadEvent } from '../../util/fire-analytics-mention-typeahead-event';
|
|
6
|
+
import uniqueId from '../../util/id';
|
|
7
|
+
import debug from '../../util/logger';
|
|
8
|
+
import Popup from '../Popup';
|
|
9
|
+
import ResourcedMentionList from '../ResourcedMentionList';
|
|
10
|
+
import { MentionPickerInfoStyle, MentionPickerStyle } from './styles';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @class MentionPicker
|
|
14
|
+
*/
|
|
15
|
+
export class MentionPicker extends React.PureComponent {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
_defineProperty(this, "selectNext", () => {
|
|
19
|
+
if (this.mentionListRef) {
|
|
20
|
+
this.mentionListRef.selectNext();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
_defineProperty(this, "selectPrevious", () => {
|
|
24
|
+
if (this.mentionListRef) {
|
|
25
|
+
this.mentionListRef.selectPrevious();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(this, "selectIndex", (index, callback) => {
|
|
29
|
+
if (this.mentionListRef) {
|
|
30
|
+
this.mentionListRef.selectIndex(index, callback);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
_defineProperty(this, "selectId", (id, callback) => {
|
|
34
|
+
if (this.mentionListRef) {
|
|
35
|
+
this.mentionListRef.selectId(id, callback);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
_defineProperty(this, "chooseCurrentSelection", () => {
|
|
39
|
+
if (this.mentionListRef) {
|
|
40
|
+
this.mentionListRef.chooseCurrentSelection();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
_defineProperty(this, "mentionsCount", () => {
|
|
44
|
+
if (this.mentionListRef) {
|
|
45
|
+
return this.mentionListRef.mentionsCount();
|
|
46
|
+
}
|
|
47
|
+
return 0;
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Called after the 'visible' state is changed to decide whether the onOpen or onClose
|
|
51
|
+
* handlers should be called.
|
|
52
|
+
*
|
|
53
|
+
* It should be noted that the visible state of the component is not considered in
|
|
54
|
+
* this function. Instead the old state and new state should be passed as parameters.
|
|
55
|
+
*/
|
|
56
|
+
_defineProperty(this, "onFilterVisibilityChange", (oldVisibility, newVisibility) => {
|
|
57
|
+
if (oldVisibility !== newVisibility) {
|
|
58
|
+
if (newVisibility) {
|
|
59
|
+
if (this.props.onOpen) {
|
|
60
|
+
this.props.onOpen();
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
if (this.props.onClose) {
|
|
64
|
+
this.props.onClose();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// internal, used for callbacks
|
|
70
|
+
_defineProperty(this, "filterChange", (mentions, query, stats) => {
|
|
71
|
+
debug('ak-mention-picker.filterChange', mentions.length);
|
|
72
|
+
const wasVisible = this.state.visible;
|
|
73
|
+
const visible = mentions.length > 0;
|
|
74
|
+
this.setState({
|
|
75
|
+
visible
|
|
76
|
+
});
|
|
77
|
+
this.onFilterVisibilityChange(wasVisible, visible);
|
|
78
|
+
fireAnalyticsMentionTypeaheadEvent(this.props)('rendered', stats && stats.duration, mentions.map(mention => mention.id), query);
|
|
79
|
+
});
|
|
80
|
+
_defineProperty(this, "filterError", error => {
|
|
81
|
+
debug('ak-mention-picker.filterError', error);
|
|
82
|
+
const wasVisible = this.state.visible;
|
|
83
|
+
this.setState({
|
|
84
|
+
visible: true,
|
|
85
|
+
info: undefined
|
|
86
|
+
});
|
|
87
|
+
this.onFilterVisibilityChange(wasVisible, true);
|
|
88
|
+
});
|
|
89
|
+
_defineProperty(this, "filterInfo", info => {
|
|
90
|
+
debug('ak-mention-picker.filterInfo', info);
|
|
91
|
+
this.setState({
|
|
92
|
+
info
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
_defineProperty(this, "handleMentionListRef", ref => {
|
|
96
|
+
this.mentionListRef = ref;
|
|
97
|
+
});
|
|
98
|
+
this.subscriberKey = uniqueId('ak-mention-picker');
|
|
99
|
+
this.state = {
|
|
100
|
+
visible: false
|
|
101
|
+
};
|
|
102
|
+
this.applyPropChanges({}, props);
|
|
103
|
+
}
|
|
104
|
+
componentDidMount() {
|
|
105
|
+
this.subscribeResourceProvider(this.props.resourceProvider);
|
|
106
|
+
}
|
|
107
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
108
|
+
this.applyPropChanges(this.props, nextProps);
|
|
109
|
+
}
|
|
110
|
+
componentWillUnmount() {
|
|
111
|
+
this.unsubscribeResourceProvider(this.props.resourceProvider);
|
|
112
|
+
}
|
|
113
|
+
// Internal
|
|
114
|
+
applyPropChanges(prevProps, nextProps) {
|
|
115
|
+
const oldResourceProvider = prevProps.resourceProvider;
|
|
116
|
+
const newResourceProvider = nextProps.resourceProvider;
|
|
117
|
+
const resourceProviderChanged = oldResourceProvider !== newResourceProvider;
|
|
118
|
+
|
|
119
|
+
// resource provider
|
|
120
|
+
if (resourceProviderChanged) {
|
|
121
|
+
this.unsubscribeResourceProvider(oldResourceProvider);
|
|
122
|
+
this.subscribeResourceProvider(newResourceProvider);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
subscribeResourceProvider(resourceProvider) {
|
|
126
|
+
if (resourceProvider) {
|
|
127
|
+
resourceProvider.subscribe(this.subscriberKey, this.filterChange, this.filterError, this.filterInfo, undefined);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
unsubscribeResourceProvider(resourceProvider) {
|
|
131
|
+
if (resourceProvider) {
|
|
132
|
+
resourceProvider.unsubscribe(this.subscriberKey);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
render() {
|
|
136
|
+
const {
|
|
137
|
+
resourceProvider,
|
|
138
|
+
presenceProvider,
|
|
139
|
+
onSelection,
|
|
140
|
+
query,
|
|
141
|
+
target,
|
|
142
|
+
position,
|
|
143
|
+
zIndex,
|
|
144
|
+
offsetX,
|
|
145
|
+
offsetY,
|
|
146
|
+
intl
|
|
147
|
+
} = this.props;
|
|
148
|
+
const {
|
|
149
|
+
visible,
|
|
150
|
+
info
|
|
151
|
+
} = this.state;
|
|
152
|
+
const resourceMentionList = /*#__PURE__*/React.createElement(ResourcedMentionList, {
|
|
153
|
+
resourceProvider: resourceProvider,
|
|
154
|
+
presenceProvider: presenceProvider,
|
|
155
|
+
onSelection: onSelection,
|
|
156
|
+
query: query,
|
|
157
|
+
ref: this.handleMentionListRef
|
|
158
|
+
});
|
|
159
|
+
const infoContent = info && !visible ? /*#__PURE__*/React.createElement(MentionPickerInfoStyle, null, /*#__PURE__*/React.createElement(Text, {
|
|
160
|
+
as: "p"
|
|
161
|
+
}, info)) : null;
|
|
162
|
+
let content;
|
|
163
|
+
if (position) {
|
|
164
|
+
debug('target, position', target, position);
|
|
165
|
+
if (target) {
|
|
166
|
+
content = /*#__PURE__*/React.createElement(Popup, {
|
|
167
|
+
target: target,
|
|
168
|
+
relativePosition: position,
|
|
169
|
+
zIndex: zIndex,
|
|
170
|
+
offsetX: offsetX,
|
|
171
|
+
offsetY: offsetY
|
|
172
|
+
}, /*#__PURE__*/React.createElement(IntlProvider, {
|
|
173
|
+
locale: (intl === null || intl === void 0 ? void 0 : intl.locale) || 'en'
|
|
174
|
+
}, /*#__PURE__*/React.createElement("div", null, resourceMentionList, infoContent)));
|
|
175
|
+
} else {
|
|
176
|
+
// don't show if we have a position, but no target yet
|
|
177
|
+
content = null;
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
content = /*#__PURE__*/React.createElement("div", null, resourceMentionList, infoContent);
|
|
181
|
+
}
|
|
182
|
+
return (
|
|
183
|
+
/*#__PURE__*/
|
|
184
|
+
/* old classnames are essential for Confluence tests */
|
|
185
|
+
React.createElement(MentionPickerStyle
|
|
186
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
187
|
+
, {
|
|
188
|
+
className: "ak-mention-picker",
|
|
189
|
+
visible: visible || info
|
|
190
|
+
}, content)
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
_defineProperty(MentionPicker, "defaultProps", {
|
|
195
|
+
onSelection: () => {},
|
|
196
|
+
onOpen: () => {},
|
|
197
|
+
onClose: () => {}
|
|
198
|
+
});
|