@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,230 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import { IntlProvider, injectIntl } from 'react-intl';
|
|
11
|
-
import { Text } from '@atlaskit/primitives/compiled';
|
|
12
|
-
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
13
|
-
import { fireAnalyticsMentionTypeaheadEvent } from '../../util/analytics';
|
|
14
|
-
import uniqueId from '../../util/id';
|
|
15
|
-
import debug from '../../util/logger';
|
|
16
|
-
import Popup from '../Popup';
|
|
17
|
-
import ResourcedMentionList from '../ResourcedMentionList';
|
|
18
|
-
import { MentionPickerInfoStyle, MentionPickerStyle } from './styles';
|
|
19
|
-
/**
|
|
20
|
-
* @class MentionPicker
|
|
21
|
-
*/
|
|
22
|
-
export var MentionPicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
23
|
-
function MentionPicker(props) {
|
|
24
|
-
var _this;
|
|
25
|
-
_classCallCheck(this, MentionPicker);
|
|
26
|
-
_this = _callSuper(this, MentionPicker, [props]);
|
|
27
|
-
_defineProperty(_this, "selectNext", function () {
|
|
28
|
-
if (_this.mentionListRef) {
|
|
29
|
-
_this.mentionListRef.selectNext();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
_defineProperty(_this, "selectPrevious", function () {
|
|
33
|
-
if (_this.mentionListRef) {
|
|
34
|
-
_this.mentionListRef.selectPrevious();
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
_defineProperty(_this, "selectIndex", function (index, callback) {
|
|
38
|
-
if (_this.mentionListRef) {
|
|
39
|
-
_this.mentionListRef.selectIndex(index, callback);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
_defineProperty(_this, "selectId", function (id, callback) {
|
|
43
|
-
if (_this.mentionListRef) {
|
|
44
|
-
_this.mentionListRef.selectId(id, callback);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
_defineProperty(_this, "chooseCurrentSelection", function () {
|
|
48
|
-
if (_this.mentionListRef) {
|
|
49
|
-
_this.mentionListRef.chooseCurrentSelection();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
_defineProperty(_this, "mentionsCount", function () {
|
|
53
|
-
if (_this.mentionListRef) {
|
|
54
|
-
return _this.mentionListRef.mentionsCount();
|
|
55
|
-
}
|
|
56
|
-
return 0;
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* Called after the 'visible' state is changed to decide whether the onOpen or onClose
|
|
60
|
-
* handlers should be called.
|
|
61
|
-
*
|
|
62
|
-
* It should be noted that the visible state of the component is not considered in
|
|
63
|
-
* this function. Instead the old state and new state should be passed as parameters.
|
|
64
|
-
*/
|
|
65
|
-
_defineProperty(_this, "onFilterVisibilityChange", function (oldVisibility, newVisibility) {
|
|
66
|
-
if (oldVisibility !== newVisibility) {
|
|
67
|
-
if (newVisibility) {
|
|
68
|
-
if (_this.props.onOpen) {
|
|
69
|
-
_this.props.onOpen();
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
if (_this.props.onClose) {
|
|
73
|
-
_this.props.onClose();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
// internal, used for callbacks
|
|
79
|
-
_defineProperty(_this, "filterChange", function (mentions, query, stats) {
|
|
80
|
-
debug('ak-mention-picker.filterChange', mentions.length);
|
|
81
|
-
var wasVisible = _this.state.visible;
|
|
82
|
-
var visible = mentions.length > 0;
|
|
83
|
-
_this.setState({
|
|
84
|
-
visible: visible
|
|
85
|
-
});
|
|
86
|
-
_this.onFilterVisibilityChange(wasVisible, visible);
|
|
87
|
-
fireAnalyticsMentionTypeaheadEvent(_this.props)('rendered', stats && stats.duration, mentions.map(function (mention) {
|
|
88
|
-
return mention.id;
|
|
89
|
-
}), query);
|
|
90
|
-
});
|
|
91
|
-
_defineProperty(_this, "filterError", function (error) {
|
|
92
|
-
debug('ak-mention-picker.filterError', error);
|
|
93
|
-
var wasVisible = _this.state.visible;
|
|
94
|
-
_this.setState({
|
|
95
|
-
visible: true,
|
|
96
|
-
info: undefined
|
|
97
|
-
});
|
|
98
|
-
_this.onFilterVisibilityChange(wasVisible, true);
|
|
99
|
-
});
|
|
100
|
-
_defineProperty(_this, "filterInfo", function (info) {
|
|
101
|
-
debug('ak-mention-picker.filterInfo', info);
|
|
102
|
-
_this.setState({
|
|
103
|
-
info: info
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
_defineProperty(_this, "handleMentionListRef", function (ref) {
|
|
107
|
-
_this.mentionListRef = ref;
|
|
108
|
-
});
|
|
109
|
-
_this.subscriberKey = uniqueId('ak-mention-picker');
|
|
110
|
-
_this.state = {
|
|
111
|
-
visible: false
|
|
112
|
-
};
|
|
113
|
-
_this.applyPropChanges({}, props);
|
|
114
|
-
return _this;
|
|
115
|
-
}
|
|
116
|
-
_inherits(MentionPicker, _React$PureComponent);
|
|
117
|
-
return _createClass(MentionPicker, [{
|
|
118
|
-
key: "componentDidMount",
|
|
119
|
-
value: function componentDidMount() {
|
|
120
|
-
this.subscribeResourceProvider(this.props.resourceProvider);
|
|
121
|
-
}
|
|
122
|
-
}, {
|
|
123
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
124
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
125
|
-
this.applyPropChanges(this.props, nextProps);
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "componentWillUnmount",
|
|
129
|
-
value: function componentWillUnmount() {
|
|
130
|
-
this.unsubscribeResourceProvider(this.props.resourceProvider);
|
|
131
|
-
}
|
|
132
|
-
}, {
|
|
133
|
-
key: "applyPropChanges",
|
|
134
|
-
value:
|
|
135
|
-
// Internal
|
|
136
|
-
function applyPropChanges(prevProps, nextProps) {
|
|
137
|
-
var oldResourceProvider = prevProps.resourceProvider;
|
|
138
|
-
var newResourceProvider = nextProps.resourceProvider;
|
|
139
|
-
var resourceProviderChanged = oldResourceProvider !== newResourceProvider;
|
|
1
|
+
/* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
|
|
140
2
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.subscribeResourceProvider(newResourceProvider);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, {
|
|
148
|
-
key: "subscribeResourceProvider",
|
|
149
|
-
value: function subscribeResourceProvider(resourceProvider) {
|
|
150
|
-
if (resourceProvider) {
|
|
151
|
-
resourceProvider.subscribe(this.subscriberKey, this.filterChange, this.filterError, this.filterInfo, undefined);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}, {
|
|
155
|
-
key: "unsubscribeResourceProvider",
|
|
156
|
-
value: function unsubscribeResourceProvider(resourceProvider) {
|
|
157
|
-
if (resourceProvider) {
|
|
158
|
-
resourceProvider.unsubscribe(this.subscriberKey);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}, {
|
|
162
|
-
key: "render",
|
|
163
|
-
value: function render() {
|
|
164
|
-
var _this$props = this.props,
|
|
165
|
-
resourceProvider = _this$props.resourceProvider,
|
|
166
|
-
presenceProvider = _this$props.presenceProvider,
|
|
167
|
-
onSelection = _this$props.onSelection,
|
|
168
|
-
query = _this$props.query,
|
|
169
|
-
target = _this$props.target,
|
|
170
|
-
position = _this$props.position,
|
|
171
|
-
zIndex = _this$props.zIndex,
|
|
172
|
-
offsetX = _this$props.offsetX,
|
|
173
|
-
offsetY = _this$props.offsetY,
|
|
174
|
-
intl = _this$props.intl;
|
|
175
|
-
var _this$state = this.state,
|
|
176
|
-
visible = _this$state.visible,
|
|
177
|
-
info = _this$state.info;
|
|
178
|
-
var resourceMentionList = /*#__PURE__*/React.createElement(ResourcedMentionList, {
|
|
179
|
-
resourceProvider: resourceProvider,
|
|
180
|
-
presenceProvider: presenceProvider,
|
|
181
|
-
onSelection: onSelection,
|
|
182
|
-
query: query,
|
|
183
|
-
ref: this.handleMentionListRef
|
|
184
|
-
});
|
|
185
|
-
var infoContent = info && !visible ? /*#__PURE__*/React.createElement(MentionPickerInfoStyle, null, /*#__PURE__*/React.createElement(Text, {
|
|
186
|
-
as: "p"
|
|
187
|
-
}, info)) : null;
|
|
188
|
-
var content;
|
|
189
|
-
if (position) {
|
|
190
|
-
debug('target, position', target, position);
|
|
191
|
-
if (target) {
|
|
192
|
-
content = /*#__PURE__*/React.createElement(Popup, {
|
|
193
|
-
target: target,
|
|
194
|
-
relativePosition: position,
|
|
195
|
-
zIndex: zIndex,
|
|
196
|
-
offsetX: offsetX,
|
|
197
|
-
offsetY: offsetY
|
|
198
|
-
}, /*#__PURE__*/React.createElement(IntlProvider, {
|
|
199
|
-
locale: (intl === null || intl === void 0 ? void 0 : intl.locale) || 'en'
|
|
200
|
-
}, /*#__PURE__*/React.createElement("div", null, resourceMentionList, infoContent)));
|
|
201
|
-
} else {
|
|
202
|
-
// don't show if we have a position, but no target yet
|
|
203
|
-
content = null;
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
content = /*#__PURE__*/React.createElement("div", null, resourceMentionList, infoContent);
|
|
207
|
-
}
|
|
208
|
-
return (
|
|
209
|
-
/*#__PURE__*/
|
|
210
|
-
/* old classnames are essential for Confluence tests */
|
|
211
|
-
React.createElement(MentionPickerStyle
|
|
212
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
213
|
-
, {
|
|
214
|
-
className: "ak-mention-picker",
|
|
215
|
-
visible: visible || info
|
|
216
|
-
}, content)
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
}]);
|
|
220
|
-
}(React.PureComponent);
|
|
221
|
-
_defineProperty(MentionPicker, "defaultProps", {
|
|
222
|
-
onSelection: function onSelection() {},
|
|
223
|
-
onOpen: function onOpen() {},
|
|
224
|
-
onClose: function onClose() {}
|
|
225
|
-
});
|
|
3
|
+
import { injectIntl } from 'react-intl';
|
|
4
|
+
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
5
|
+
import { MentionPicker } from './MentionPicker';
|
|
226
6
|
var MentionPickerWithIntl = injectIntl(MentionPicker, {
|
|
227
7
|
forwardRef: true
|
|
228
8
|
});
|
|
229
9
|
export var MentionPickerWithAnalytics = withAnalyticsEvents({})(MentionPickerWithIntl);
|
|
230
|
-
|
|
10
|
+
|
|
11
|
+
// Merges with the `const` above so that `MentionPickerWithAnalytics` is usable in a type
|
|
12
|
+
// position as the component instance type (e.g. for refs). Both halves of a declaration
|
|
13
|
+
// merge must live in the same module, so this alias cannot be split out.
|
|
14
|
+
|
|
15
|
+
export default MentionPickerWithAnalytics;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `import { MentionPicker } from '@atlaskit/mention/mention-picker'` instead.
|
|
19
|
+
*/
|
|
20
|
+
export { MentionPicker } from './MentionPicker';
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { IntlProvider, useIntl } from 'react-intl';
|
|
5
|
-
import { getMessagesForLocale } from '../../util/
|
|
5
|
+
import { getMessagesForLocale } from '../../util/get-messages-for-locale';
|
|
6
6
|
var EMPTY = {};
|
|
7
7
|
var useI18n = function useI18n(locale) {
|
|
8
8
|
var _React$useState = React.useState(EMPTY),
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { SLI_EVENT_TYPE } from '../../util/analytics';
|
|
13
|
+
import { fireSliAnalyticsEvent } from '../../util/fire-sli-analytics-event';
|
|
14
|
+
import uniqueId from '../../util/id';
|
|
15
|
+
import debug from '../../util/logger';
|
|
16
|
+
import MentionList from '../MentionList';
|
|
17
|
+
function applyPresence(mentions, presences) {
|
|
18
|
+
var updatedMentions = [];
|
|
19
|
+
for (var i = 0; i < mentions.length; i++) {
|
|
20
|
+
// Shallow copy
|
|
21
|
+
var mention = _objectSpread({}, mentions[i]);
|
|
22
|
+
var presence = presences[mention.id];
|
|
23
|
+
if (presence) {
|
|
24
|
+
mention.presence = presence;
|
|
25
|
+
}
|
|
26
|
+
updatedMentions.push(mention);
|
|
27
|
+
}
|
|
28
|
+
return updatedMentions;
|
|
29
|
+
}
|
|
30
|
+
function extractPresences(mentions) {
|
|
31
|
+
var presences = {};
|
|
32
|
+
for (var i = 0; i < mentions.length; i++) {
|
|
33
|
+
var mention = mentions[i];
|
|
34
|
+
if (mention.presence) {
|
|
35
|
+
presences[mention.id] = mention.presence;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return presences;
|
|
39
|
+
}
|
|
40
|
+
export var ResourcedMentionListWithoutAnalytics = /*#__PURE__*/function (_React$PureComponent) {
|
|
41
|
+
function ResourcedMentionListWithoutAnalytics(props) {
|
|
42
|
+
var _this;
|
|
43
|
+
_classCallCheck(this, ResourcedMentionListWithoutAnalytics);
|
|
44
|
+
_this = _callSuper(this, ResourcedMentionListWithoutAnalytics, [props]);
|
|
45
|
+
// API
|
|
46
|
+
_defineProperty(_this, "selectNext", function () {
|
|
47
|
+
if (_this.mentionListRef) {
|
|
48
|
+
_this.mentionListRef.selectNext();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
_defineProperty(_this, "selectPrevious", function () {
|
|
52
|
+
if (_this.mentionListRef) {
|
|
53
|
+
_this.mentionListRef.selectPrevious();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
_defineProperty(_this, "selectIndex", function (index, callback) {
|
|
57
|
+
if (_this.mentionListRef) {
|
|
58
|
+
_this.mentionListRef.selectIndex(index, callback);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
_defineProperty(_this, "selectId", function (id, callback) {
|
|
62
|
+
if (_this.mentionListRef) {
|
|
63
|
+
_this.mentionListRef.selectId(id, callback);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
_defineProperty(_this, "chooseCurrentSelection", function () {
|
|
67
|
+
if (_this.mentionListRef) {
|
|
68
|
+
_this.mentionListRef.chooseCurrentSelection();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
_defineProperty(_this, "mentionsCount", function () {
|
|
72
|
+
if (_this.mentionListRef) {
|
|
73
|
+
return _this.mentionListRef.mentionsCount();
|
|
74
|
+
}
|
|
75
|
+
return 0;
|
|
76
|
+
});
|
|
77
|
+
// internal, used for callbacks
|
|
78
|
+
_defineProperty(_this, "filterChange", function (mentions) {
|
|
79
|
+
// Retain known presence
|
|
80
|
+
var currentPresences = extractPresences(_this.state.mentions);
|
|
81
|
+
_this.setState({
|
|
82
|
+
resourceError: undefined,
|
|
83
|
+
mentions: applyPresence(mentions, currentPresences)
|
|
84
|
+
});
|
|
85
|
+
_this.refreshPresences(mentions);
|
|
86
|
+
});
|
|
87
|
+
_defineProperty(_this, "sendAnalytics", function (event, actionSubject, action) {
|
|
88
|
+
if (event === SLI_EVENT_TYPE) {
|
|
89
|
+
fireSliAnalyticsEvent(_this.props)(actionSubject, action);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
_defineProperty(_this, "filterError", function (error) {
|
|
93
|
+
debug('ak-resourced-mentions-list._filterError', error);
|
|
94
|
+
_this.setState({
|
|
95
|
+
resourceError: error
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
_defineProperty(_this, "presenceUpdate", function (presences) {
|
|
99
|
+
_this.setState({
|
|
100
|
+
mentions: applyPresence(_this.state.mentions, presences)
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
_defineProperty(_this, "notifySelection", function (mention) {
|
|
104
|
+
_this.props.resourceProvider.recordMentionSelection(mention);
|
|
105
|
+
if (_this.props.onSelection) {
|
|
106
|
+
_this.props.onSelection(mention);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
_defineProperty(_this, "handleMentionListRef", function (ref) {
|
|
110
|
+
_this.mentionListRef = ref;
|
|
111
|
+
});
|
|
112
|
+
_this.subscriberKey = uniqueId('ak-resourced-mention-list');
|
|
113
|
+
_this.state = {
|
|
114
|
+
resourceError: undefined,
|
|
115
|
+
mentions: []
|
|
116
|
+
};
|
|
117
|
+
_this.applyPropChanges({}, props);
|
|
118
|
+
return _this;
|
|
119
|
+
}
|
|
120
|
+
_inherits(ResourcedMentionListWithoutAnalytics, _React$PureComponent);
|
|
121
|
+
return _createClass(ResourcedMentionListWithoutAnalytics, [{
|
|
122
|
+
key: "componentDidMount",
|
|
123
|
+
value: function componentDidMount() {
|
|
124
|
+
this.subscribeMentionProvider(this.props.resourceProvider);
|
|
125
|
+
this.subscribePresenceProvider(this.props.presenceProvider);
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
129
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
130
|
+
this.applyPropChanges(this.props, nextProps);
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "componentWillUnmount",
|
|
134
|
+
value: function componentWillUnmount() {
|
|
135
|
+
this.unsubscribeMentionProvider(this.props.resourceProvider);
|
|
136
|
+
this.unsubscribePresenceProvider(this.props.presenceProvider);
|
|
137
|
+
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "subscribeMentionProvider",
|
|
140
|
+
value:
|
|
141
|
+
// internal
|
|
142
|
+
function subscribeMentionProvider(mentionProvider) {
|
|
143
|
+
if (mentionProvider) {
|
|
144
|
+
mentionProvider.subscribe(this.subscriberKey, this.filterChange, this.filterError, undefined, undefined, this.sendAnalytics);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "subscribePresenceProvider",
|
|
149
|
+
value: function subscribePresenceProvider(presenceProvider) {
|
|
150
|
+
if (presenceProvider) {
|
|
151
|
+
presenceProvider.subscribe(this.subscriberKey, this.presenceUpdate);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
key: "unsubscribeMentionProvider",
|
|
156
|
+
value: function unsubscribeMentionProvider(mentionProvider) {
|
|
157
|
+
if (mentionProvider) {
|
|
158
|
+
mentionProvider.unsubscribe(this.subscriberKey);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "unsubscribePresenceProvider",
|
|
163
|
+
value: function unsubscribePresenceProvider(presenceProvider) {
|
|
164
|
+
if (presenceProvider) {
|
|
165
|
+
presenceProvider.unsubscribe(this.subscriberKey);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "applyPropChanges",
|
|
170
|
+
value: function applyPropChanges(prevProps, nextProps) {
|
|
171
|
+
var oldResourceProvider = prevProps.resourceProvider;
|
|
172
|
+
var oldPresenceProvider = prevProps.presenceProvider;
|
|
173
|
+
var oldQuery = prevProps.query;
|
|
174
|
+
var newResourceProvider = nextProps.resourceProvider;
|
|
175
|
+
var newPresenceProvider = nextProps.presenceProvider;
|
|
176
|
+
var newQuery = nextProps.query;
|
|
177
|
+
var resourceProviderChanged = oldResourceProvider !== newResourceProvider;
|
|
178
|
+
var queryChanged = oldQuery !== newQuery;
|
|
179
|
+
var canFilter = !!(typeof newQuery === 'string' && newResourceProvider);
|
|
180
|
+
var shouldFilter = canFilter && (queryChanged || resourceProviderChanged);
|
|
181
|
+
|
|
182
|
+
// resource provider
|
|
183
|
+
if (resourceProviderChanged) {
|
|
184
|
+
this.unsubscribeMentionProvider(oldResourceProvider);
|
|
185
|
+
this.subscribeMentionProvider(newResourceProvider);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// presence provider
|
|
189
|
+
if (oldPresenceProvider !== newPresenceProvider) {
|
|
190
|
+
this.unsubscribePresenceProvider(oldPresenceProvider);
|
|
191
|
+
this.subscribePresenceProvider(newPresenceProvider);
|
|
192
|
+
}
|
|
193
|
+
if (shouldFilter) {
|
|
194
|
+
newResourceProvider.filter(newQuery);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "refreshPresences",
|
|
199
|
+
value: function refreshPresences(mentions) {
|
|
200
|
+
if (this.props.presenceProvider) {
|
|
201
|
+
var ids = mentions.map(function (mention) {
|
|
202
|
+
return mention.id;
|
|
203
|
+
});
|
|
204
|
+
this.props.presenceProvider.refreshPresence(ids);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "render",
|
|
209
|
+
value: function render() {
|
|
210
|
+
var _this$state = this.state,
|
|
211
|
+
mentions = _this$state.mentions,
|
|
212
|
+
resourceError = _this$state.resourceError;
|
|
213
|
+
return /*#__PURE__*/React.createElement(MentionList, {
|
|
214
|
+
mentions: mentions,
|
|
215
|
+
resourceError: resourceError,
|
|
216
|
+
onSelection: this.notifySelection,
|
|
217
|
+
ref: this.handleMentionListRef
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}]);
|
|
221
|
+
}(React.PureComponent);
|