@atlaskit/mention 24.2.18 → 24.3.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 +8 -0
- package/dist/cjs/components/MentionItem/index.js +12 -4
- package/dist/cjs/components/MentionList/index.js +60 -21
- package/dist/cjs/components/MentionPicker/index.js +2 -2
- package/dist/cjs/components/Popup/index.js +81 -23
- package/dist/cjs/components/Scrollable/index.js +14 -1
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/es2019/components/MentionItem/index.js +11 -3
- package/dist/es2019/components/MentionList/index.js +54 -21
- package/dist/es2019/components/MentionPicker/index.js +2 -2
- package/dist/es2019/components/Popup/index.js +77 -21
- package/dist/es2019/components/Scrollable/index.js +14 -1
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/esm/components/MentionItem/index.js +11 -3
- package/dist/esm/components/MentionList/index.js +58 -21
- package/dist/esm/components/MentionPicker/index.js +2 -2
- package/dist/esm/components/Popup/index.js +79 -23
- package/dist/esm/components/Scrollable/index.js +14 -1
- package/dist/esm/util/analytics.js +1 -1
- package/dist/types/components/MentionItem/index.d.ts +2 -0
- package/dist/types/components/MentionList/index.d.ts +3 -0
- package/dist/types/components/MentionPicker/index.d.ts +1 -1
- package/dist/types/components/Popup/index.d.ts +4 -1
- package/dist/types/components/Scrollable/index.d.ts +1 -0
- package/dist/types-ts4.5/components/MentionItem/index.d.ts +2 -0
- package/dist/types-ts4.5/components/MentionList/index.d.ts +3 -0
- package/dist/types-ts4.5/components/MentionPicker/index.d.ts +1 -1
- package/dist/types-ts4.5/components/Popup/index.d.ts +4 -1
- package/dist/types-ts4.5/components/Scrollable/index.d.ts +1 -0
- package/package.json +8 -5
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import ReactDOM from 'react-dom';
|
|
3
|
+
import ReactDOM, { createPortal } from 'react-dom';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
/*
|
|
5
6
|
* Simple implementation of popup while waiting for ak-inline-dialog
|
|
6
7
|
*/
|
|
7
8
|
export default class Popup extends React.PureComponent {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.portalStyles = {
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
top: null,
|
|
14
|
+
bottom: null,
|
|
15
|
+
left: null,
|
|
16
|
+
zIndex: null
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
setPortalStyles(styles) {
|
|
20
|
+
this.portalStyles = {
|
|
21
|
+
...this.portalStyles,
|
|
22
|
+
...styles
|
|
23
|
+
};
|
|
24
|
+
}
|
|
8
25
|
componentDidMount() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
26
|
+
if (!fg('mentions-migrate-react-dom')) {
|
|
27
|
+
this.popup = document.createElement('div');
|
|
28
|
+
document.body.appendChild(this.popup);
|
|
29
|
+
this.popup.style.position = 'absolute';
|
|
30
|
+
}
|
|
12
31
|
this._applyAbsolutePosition();
|
|
13
32
|
this._renderContent();
|
|
14
33
|
}
|
|
@@ -16,9 +35,11 @@ export default class Popup extends React.PureComponent {
|
|
|
16
35
|
this._renderContent();
|
|
17
36
|
}
|
|
18
37
|
componentWillUnmount() {
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
38
|
+
if (!fg('mentions-migrate-react-dom')) {
|
|
39
|
+
if (this.popup) {
|
|
40
|
+
ReactDOM.unmountComponentAtNode(this.popup);
|
|
41
|
+
document.body.removeChild(this.popup);
|
|
42
|
+
}
|
|
22
43
|
}
|
|
23
44
|
}
|
|
24
45
|
_applyBelowPosition() {
|
|
@@ -27,10 +48,18 @@ export default class Popup extends React.PureComponent {
|
|
|
27
48
|
const box = targetNode.getBoundingClientRect();
|
|
28
49
|
const top = box.bottom + (this.props.offsetY || 0);
|
|
29
50
|
const left = box.left + (this.props.offsetX || 0);
|
|
30
|
-
if (
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
52
|
+
this.setPortalStyles({
|
|
53
|
+
top: `${top}px`,
|
|
54
|
+
bottom: '',
|
|
55
|
+
left: `${left}px`
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
if (this.popup) {
|
|
59
|
+
this.popup.style.top = `${top}px`;
|
|
60
|
+
this.popup.style.bottom = '';
|
|
61
|
+
this.popup.style.left = `${left}px`;
|
|
62
|
+
}
|
|
34
63
|
}
|
|
35
64
|
}
|
|
36
65
|
}
|
|
@@ -40,10 +69,18 @@ export default class Popup extends React.PureComponent {
|
|
|
40
69
|
const box = targetNode.getBoundingClientRect();
|
|
41
70
|
const bottom = window.innerHeight - box.top + (this.props.offsetY || 0);
|
|
42
71
|
const left = box.left + (this.props.offsetX || 0);
|
|
43
|
-
if (
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
72
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
73
|
+
this.setPortalStyles({
|
|
74
|
+
top: '',
|
|
75
|
+
bottom: `${bottom}px`,
|
|
76
|
+
left: `${left}px`
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
if (this.popup) {
|
|
80
|
+
this.popup.style.top = '';
|
|
81
|
+
this.popup.style.bottom = `${bottom}px`;
|
|
82
|
+
this.popup.style.left = `${left}px`;
|
|
83
|
+
}
|
|
47
84
|
}
|
|
48
85
|
}
|
|
49
86
|
}
|
|
@@ -64,18 +101,37 @@ export default class Popup extends React.PureComponent {
|
|
|
64
101
|
}
|
|
65
102
|
}
|
|
66
103
|
}
|
|
67
|
-
if (
|
|
68
|
-
this.
|
|
104
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
105
|
+
if (this.props.zIndex) {
|
|
106
|
+
this.setPortalStyles({
|
|
107
|
+
zIndex: this.props.zIndex
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
if (this.props.zIndex && this.popup) {
|
|
112
|
+
this.popup.style.zIndex = `${this.props.zIndex}`;
|
|
113
|
+
}
|
|
69
114
|
}
|
|
70
115
|
}
|
|
71
116
|
_renderContent() {
|
|
72
|
-
if (
|
|
73
|
-
|
|
117
|
+
if (!fg('mentions-migrate-react-dom')) {
|
|
118
|
+
if (this.popup) {
|
|
119
|
+
ReactDOM.render(this.props.children, this.popup);
|
|
120
|
+
}
|
|
74
121
|
}
|
|
75
122
|
}
|
|
76
123
|
render() {
|
|
77
|
-
|
|
78
|
-
|
|
124
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
125
|
+
// https://atlassian.design/components/eslint-plugin-ui-styling-standard/migration-guide#dynamic-styles
|
|
126
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
127
|
+
const content = /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
style: this.portalStyles
|
|
129
|
+
}, this.props.children);
|
|
130
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/createPortal(content, document.body));
|
|
131
|
+
} else {
|
|
132
|
+
// Placeholder element for react to render inplace
|
|
133
|
+
/*#__PURE__*/React.createElement("div", null);
|
|
134
|
+
}
|
|
79
135
|
}
|
|
80
136
|
}
|
|
81
137
|
_defineProperty(Popup, "defaultProps", {
|
|
@@ -5,7 +5,7 @@ import { ScrollableStyle } from './styles';
|
|
|
5
5
|
export default class Scrollable extends React.PureComponent {
|
|
6
6
|
constructor(...args) {
|
|
7
7
|
super(...args);
|
|
8
|
-
//
|
|
8
|
+
// Cleanup when removing mentions-migrate-react-dom
|
|
9
9
|
_defineProperty(this, "reveal", child => {
|
|
10
10
|
if (child && this.scrollableDiv) {
|
|
11
11
|
const childNode = findDOMNode(child);
|
|
@@ -20,6 +20,19 @@ export default class Scrollable extends React.PureComponent {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
_defineProperty(this, "revealRef", ref => {
|
|
24
|
+
if (ref && ref.current && this.scrollableDiv) {
|
|
25
|
+
// Not using Element.scrollIntoView as it scrolls even to top/bottom of view even if
|
|
26
|
+
// already visible
|
|
27
|
+
const scrollableRect = this.scrollableDiv.getBoundingClientRect();
|
|
28
|
+
const elementRect = ref.current.getBoundingClientRect();
|
|
29
|
+
if (elementRect.top < scrollableRect.top) {
|
|
30
|
+
this.scrollableDiv.scrollTop += elementRect.top - scrollableRect.top;
|
|
31
|
+
} else if (elementRect.bottom > scrollableRect.bottom) {
|
|
32
|
+
this.scrollableDiv.scrollTop += elementRect.bottom - scrollableRect.bottom;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
23
36
|
_defineProperty(this, "handleRef", ref => {
|
|
24
37
|
this.scrollableDiv = ref;
|
|
25
38
|
});
|
|
@@ -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 = "
|
|
5
|
+
const packageVersion = "0.0.0-development";
|
|
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) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
@@ -76,7 +77,8 @@ var MentionItem = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
76
77
|
value: function render() {
|
|
77
78
|
var _this$props = this.props,
|
|
78
79
|
mention = _this$props.mention,
|
|
79
|
-
selected = _this$props.selected
|
|
80
|
+
selected = _this$props.selected,
|
|
81
|
+
forwardedRef = _this$props.forwardedRef;
|
|
80
82
|
var id = mention.id,
|
|
81
83
|
highlight = mention.highlight,
|
|
82
84
|
avatarUrl = mention.avatarUrl,
|
|
@@ -102,7 +104,8 @@ var MentionItem = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
102
104
|
"data-testid": "mention-item-".concat(id),
|
|
103
105
|
"data-mention-id": id,
|
|
104
106
|
"data-mention-name": mentionName,
|
|
105
|
-
"data-selected": selected
|
|
107
|
+
"data-selected": selected,
|
|
108
|
+
ref: forwardedRef
|
|
106
109
|
}, /*#__PURE__*/React.createElement(RowStyle, null, /*#__PURE__*/React.createElement(AvatarStyle, {
|
|
107
110
|
restricted: restricted
|
|
108
111
|
}, fg('team-avatar-in-mention-picker') ? /*#__PURE__*/React.createElement(MentionAvatar, {
|
|
@@ -134,4 +137,9 @@ var MentionItem = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
134
137
|
}
|
|
135
138
|
}]);
|
|
136
139
|
}(React.PureComponent);
|
|
137
|
-
export { MentionItem as default };
|
|
140
|
+
export { MentionItem as default };
|
|
141
|
+
export var MentionItemWithRef = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
142
|
+
return /*#__PURE__*/React.createElement(MentionItem, _extends({}, props, {
|
|
143
|
+
forwardedRef: ref
|
|
144
|
+
}));
|
|
145
|
+
});
|
|
@@ -7,9 +7,10 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
7
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
8
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
9
|
import React from 'react';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import debug from '../../util/logger';
|
|
11
12
|
import { actualMouseMove, mouseLocation } from '../../util/mouse';
|
|
12
|
-
import MentionItem from '../MentionItem';
|
|
13
|
+
import MentionItem, { MentionItemWithRef } from '../MentionItem';
|
|
13
14
|
import MentionListError from '../MentionListError';
|
|
14
15
|
import MessagesIntlProvider from '../MessagesIntlProvider';
|
|
15
16
|
import Scrollable from '../Scrollable';
|
|
@@ -102,11 +103,24 @@ var MentionList = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
102
103
|
_defineProperty(_this, "handleScrollableRef", function (ref) {
|
|
103
104
|
_this.scrollable = ref;
|
|
104
105
|
});
|
|
106
|
+
_this.itemsRefs = new Map();
|
|
105
107
|
_this.setDefaultSelectionState();
|
|
106
108
|
return _this;
|
|
107
109
|
}
|
|
108
110
|
_inherits(MentionList, _React$PureComponent);
|
|
109
111
|
return _createClass(MentionList, [{
|
|
112
|
+
key: "createItemRef",
|
|
113
|
+
value: function createItemRef(key) {
|
|
114
|
+
var itemRef = /*#__PURE__*/React.createRef();
|
|
115
|
+
this.itemsRefs.set(key, itemRef);
|
|
116
|
+
return itemRef;
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "getItemRef",
|
|
120
|
+
value: function getItemRef(key) {
|
|
121
|
+
return this.itemsRefs.get(key);
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
110
124
|
key: "UNSAFE_componentWillReceiveProps",
|
|
111
125
|
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
112
126
|
// adjust selection
|
|
@@ -147,9 +161,16 @@ var MentionList = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
147
161
|
value:
|
|
148
162
|
// Internal
|
|
149
163
|
function revealItem(key) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.scrollable
|
|
164
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
165
|
+
var itemRef = this.getItemRef(key);
|
|
166
|
+
if (itemRef && this.scrollable) {
|
|
167
|
+
itemRef && this.scrollable.revealRef(itemRef);
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
var item = this.items[key];
|
|
171
|
+
if (item && this.scrollable) {
|
|
172
|
+
this.scrollable.reveal(item);
|
|
173
|
+
}
|
|
153
174
|
}
|
|
154
175
|
}
|
|
155
176
|
|
|
@@ -173,24 +194,40 @@ var MentionList = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
173
194
|
this.items = {};
|
|
174
195
|
return /*#__PURE__*/React.createElement("div", null, this.props.initialHighlightElement, mentions.map(function (mention, idx) {
|
|
175
196
|
var key = mention.id;
|
|
176
|
-
var
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
197
|
+
var ref = _this2.createItemRef(key);
|
|
198
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
199
|
+
var item = /*#__PURE__*/React.createElement(MentionItemWithRef, {
|
|
200
|
+
mention: mention,
|
|
201
|
+
selected: _this2.isSelectedMention(mention, idx),
|
|
202
|
+
key: key,
|
|
203
|
+
onMouseMove: _this2.selectIndexOnHover
|
|
204
|
+
/* Cannot use onclick, as onblur will close the element, and prevent
|
|
205
|
+
* onClick from firing.
|
|
206
|
+
*/,
|
|
207
|
+
onSelection: _this2.itemSelected,
|
|
208
|
+
ref: ref
|
|
209
|
+
});
|
|
210
|
+
return item;
|
|
211
|
+
} else {
|
|
212
|
+
var _item = /*#__PURE__*/React.createElement(MentionItem, {
|
|
213
|
+
mention: mention,
|
|
214
|
+
selected: _this2.isSelectedMention(mention, idx),
|
|
215
|
+
key: key,
|
|
216
|
+
onMouseMove: _this2.selectIndexOnHover
|
|
217
|
+
/* Cannot use onclick, as onblur will close the element, and prevent
|
|
218
|
+
* onClick from firing.
|
|
219
|
+
*/,
|
|
220
|
+
onSelection: _this2.itemSelected,
|
|
221
|
+
ref: function ref(_ref) {
|
|
222
|
+
if (_ref) {
|
|
223
|
+
_this2.items[key] = _ref;
|
|
224
|
+
} else {
|
|
225
|
+
delete _this2.items[key];
|
|
226
|
+
}
|
|
190
227
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
228
|
+
});
|
|
229
|
+
return _item;
|
|
230
|
+
}
|
|
194
231
|
}));
|
|
195
232
|
}
|
|
196
233
|
return null;
|
|
@@ -6,10 +6,10 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
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
8
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
-
import { Text } from '@atlaskit/primitives/compiled';
|
|
10
|
-
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
11
9
|
import React from 'react';
|
|
12
10
|
import { IntlProvider, injectIntl } from 'react-intl-next';
|
|
11
|
+
import { Text } from '@atlaskit/primitives/compiled';
|
|
12
|
+
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
13
13
|
import { fireAnalyticsMentionTypeaheadEvent } from '../../util/analytics';
|
|
14
14
|
import uniqueId from '../../util/id';
|
|
15
15
|
import debug from '../../util/logger';
|
|
@@ -4,25 +4,44 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
4
4
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
7
9
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
11
|
import React from 'react';
|
|
10
|
-
import ReactDOM from 'react-dom';
|
|
12
|
+
import ReactDOM, { createPortal } from 'react-dom';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
14
|
/*
|
|
12
15
|
* Simple implementation of popup while waiting for ak-inline-dialog
|
|
13
16
|
*/
|
|
14
17
|
var Popup = /*#__PURE__*/function (_React$PureComponent) {
|
|
15
|
-
function Popup() {
|
|
18
|
+
function Popup(props) {
|
|
19
|
+
var _this;
|
|
16
20
|
_classCallCheck(this, Popup);
|
|
17
|
-
|
|
21
|
+
_this = _callSuper(this, Popup, [props]);
|
|
22
|
+
_this.portalStyles = {
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
top: null,
|
|
25
|
+
bottom: null,
|
|
26
|
+
left: null,
|
|
27
|
+
zIndex: null
|
|
28
|
+
};
|
|
29
|
+
return _this;
|
|
18
30
|
}
|
|
19
31
|
_inherits(Popup, _React$PureComponent);
|
|
20
32
|
return _createClass(Popup, [{
|
|
33
|
+
key: "setPortalStyles",
|
|
34
|
+
value: function setPortalStyles(styles) {
|
|
35
|
+
this.portalStyles = _objectSpread(_objectSpread({}, this.portalStyles), styles);
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
21
38
|
key: "componentDidMount",
|
|
22
39
|
value: function componentDidMount() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
if (!fg('mentions-migrate-react-dom')) {
|
|
41
|
+
this.popup = document.createElement('div');
|
|
42
|
+
document.body.appendChild(this.popup);
|
|
43
|
+
this.popup.style.position = 'absolute';
|
|
44
|
+
}
|
|
26
45
|
this._applyAbsolutePosition();
|
|
27
46
|
this._renderContent();
|
|
28
47
|
}
|
|
@@ -34,9 +53,11 @@ var Popup = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
34
53
|
}, {
|
|
35
54
|
key: "componentWillUnmount",
|
|
36
55
|
value: function componentWillUnmount() {
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
56
|
+
if (!fg('mentions-migrate-react-dom')) {
|
|
57
|
+
if (this.popup) {
|
|
58
|
+
ReactDOM.unmountComponentAtNode(this.popup);
|
|
59
|
+
document.body.removeChild(this.popup);
|
|
60
|
+
}
|
|
40
61
|
}
|
|
41
62
|
}
|
|
42
63
|
}, {
|
|
@@ -47,10 +68,18 @@ var Popup = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
47
68
|
var box = targetNode.getBoundingClientRect();
|
|
48
69
|
var top = box.bottom + (this.props.offsetY || 0);
|
|
49
70
|
var left = box.left + (this.props.offsetX || 0);
|
|
50
|
-
if (
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
72
|
+
this.setPortalStyles({
|
|
73
|
+
top: "".concat(top, "px"),
|
|
74
|
+
bottom: '',
|
|
75
|
+
left: "".concat(left, "px")
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
if (this.popup) {
|
|
79
|
+
this.popup.style.top = "".concat(top, "px");
|
|
80
|
+
this.popup.style.bottom = '';
|
|
81
|
+
this.popup.style.left = "".concat(left, "px");
|
|
82
|
+
}
|
|
54
83
|
}
|
|
55
84
|
}
|
|
56
85
|
}
|
|
@@ -62,10 +91,18 @@ var Popup = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
62
91
|
var box = targetNode.getBoundingClientRect();
|
|
63
92
|
var bottom = window.innerHeight - box.top + (this.props.offsetY || 0);
|
|
64
93
|
var left = box.left + (this.props.offsetX || 0);
|
|
65
|
-
if (
|
|
66
|
-
this.
|
|
67
|
-
|
|
68
|
-
|
|
94
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
95
|
+
this.setPortalStyles({
|
|
96
|
+
top: '',
|
|
97
|
+
bottom: "".concat(bottom, "px"),
|
|
98
|
+
left: "".concat(left, "px")
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
if (this.popup) {
|
|
102
|
+
this.popup.style.top = '';
|
|
103
|
+
this.popup.style.bottom = "".concat(bottom, "px");
|
|
104
|
+
this.popup.style.left = "".concat(left, "px");
|
|
105
|
+
}
|
|
69
106
|
}
|
|
70
107
|
}
|
|
71
108
|
}
|
|
@@ -88,22 +125,41 @@ var Popup = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
88
125
|
}
|
|
89
126
|
}
|
|
90
127
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
128
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
129
|
+
if (this.props.zIndex) {
|
|
130
|
+
this.setPortalStyles({
|
|
131
|
+
zIndex: this.props.zIndex
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
if (this.props.zIndex && this.popup) {
|
|
136
|
+
this.popup.style.zIndex = "".concat(this.props.zIndex);
|
|
137
|
+
}
|
|
93
138
|
}
|
|
94
139
|
}
|
|
95
140
|
}, {
|
|
96
141
|
key: "_renderContent",
|
|
97
142
|
value: function _renderContent() {
|
|
98
|
-
if (
|
|
99
|
-
|
|
143
|
+
if (!fg('mentions-migrate-react-dom')) {
|
|
144
|
+
if (this.popup) {
|
|
145
|
+
ReactDOM.render(this.props.children, this.popup);
|
|
146
|
+
}
|
|
100
147
|
}
|
|
101
148
|
}
|
|
102
149
|
}, {
|
|
103
150
|
key: "render",
|
|
104
151
|
value: function render() {
|
|
105
|
-
|
|
106
|
-
|
|
152
|
+
if (fg('mentions-migrate-react-dom')) {
|
|
153
|
+
// https://atlassian.design/components/eslint-plugin-ui-styling-standard/migration-guide#dynamic-styles
|
|
154
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
155
|
+
var content = /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
style: this.portalStyles
|
|
157
|
+
}, this.props.children);
|
|
158
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/createPortal(content, document.body));
|
|
159
|
+
} else {
|
|
160
|
+
// Placeholder element for react to render inplace
|
|
161
|
+
/*#__PURE__*/React.createElement("div", null);
|
|
162
|
+
}
|
|
107
163
|
}
|
|
108
164
|
}]);
|
|
109
165
|
}(React.PureComponent);
|
|
@@ -17,7 +17,7 @@ var Scrollable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
17
17
|
args[_key] = arguments[_key];
|
|
18
18
|
}
|
|
19
19
|
_this = _callSuper(this, Scrollable, [].concat(args));
|
|
20
|
-
//
|
|
20
|
+
// Cleanup when removing mentions-migrate-react-dom
|
|
21
21
|
_defineProperty(_this, "reveal", function (child) {
|
|
22
22
|
if (child && _this.scrollableDiv) {
|
|
23
23
|
var childNode = findDOMNode(child);
|
|
@@ -32,6 +32,19 @@ var Scrollable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
+
_defineProperty(_this, "revealRef", function (ref) {
|
|
36
|
+
if (ref && ref.current && _this.scrollableDiv) {
|
|
37
|
+
// Not using Element.scrollIntoView as it scrolls even to top/bottom of view even if
|
|
38
|
+
// already visible
|
|
39
|
+
var scrollableRect = _this.scrollableDiv.getBoundingClientRect();
|
|
40
|
+
var elementRect = ref.current.getBoundingClientRect();
|
|
41
|
+
if (elementRect.top < scrollableRect.top) {
|
|
42
|
+
_this.scrollableDiv.scrollTop += elementRect.top - scrollableRect.top;
|
|
43
|
+
} else if (elementRect.bottom > scrollableRect.bottom) {
|
|
44
|
+
_this.scrollableDiv.scrollTop += elementRect.bottom - scrollableRect.bottom;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
35
48
|
_defineProperty(_this, "handleRef", function (ref) {
|
|
36
49
|
_this.scrollableDiv = ref;
|
|
37
50
|
});
|
|
@@ -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 = "
|
|
8
|
+
var packageVersion = "0.0.0-development";
|
|
9
9
|
export var SLI_EVENT_TYPE = 'sli';
|
|
10
10
|
export var SMART_EVENT_TYPE = 'smart';
|
|
11
11
|
export var fireAnalyticsMentionTypeaheadEvent = function fireAnalyticsMentionTypeaheadEvent(props) {
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type MentionDescription, type OnMentionEvent } from '../../types';
|
|
3
3
|
export { MENTION_ITEM_HEIGHT } from './styles';
|
|
4
4
|
export interface Props {
|
|
5
|
+
forwardedRef?: React.Ref<HTMLDivElement>;
|
|
5
6
|
mention: MentionDescription;
|
|
6
7
|
onMouseEnter?: OnMentionEvent;
|
|
7
8
|
onMouseMove?: OnMentionEvent;
|
|
@@ -14,3 +15,4 @@ export default class MentionItem extends React.PureComponent<Props, {}> {
|
|
|
14
15
|
private onMentionMenuItemMouseEnter;
|
|
15
16
|
render(): React.JSX.Element;
|
|
16
17
|
}
|
|
18
|
+
export declare const MentionItemWithRef: React.ForwardRefExoticComponent<Omit<Props, "forwardedRef"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -18,7 +18,10 @@ export default class MentionList extends React.PureComponent<Props, State> {
|
|
|
18
18
|
private lastMousePosition;
|
|
19
19
|
private scrollable?;
|
|
20
20
|
private items;
|
|
21
|
+
private itemsRefs;
|
|
21
22
|
constructor(props: Props);
|
|
23
|
+
createItemRef(key: string): React.RefObject<HTMLDivElement>;
|
|
24
|
+
getItemRef(key: string): React.RefObject<HTMLDivElement> | undefined;
|
|
22
25
|
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
23
26
|
componentDidUpdate(): void;
|
|
24
27
|
selectNext: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { type IntlShape } from 'react-intl-next';
|
|
3
|
+
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
4
4
|
import { type MentionProvider } from '../../api/MentionResource';
|
|
5
5
|
import { type PresenceProvider } from '../../api/PresenceResource';
|
|
6
6
|
import { type OnMentionEvent } from '../../types';
|
|
@@ -9,6 +9,9 @@ export interface Props {
|
|
|
9
9
|
}
|
|
10
10
|
export default class Popup extends React.PureComponent<Props, {}> {
|
|
11
11
|
private popup?;
|
|
12
|
+
private portalStyles;
|
|
13
|
+
constructor(props: Props);
|
|
14
|
+
setPortalStyles(styles: Record<string, string | number | null>): void;
|
|
12
15
|
static defaultProps: {
|
|
13
16
|
relativePosition: string;
|
|
14
17
|
offsetX: number;
|
|
@@ -22,5 +25,5 @@ export default class Popup extends React.PureComponent<Props, {}> {
|
|
|
22
25
|
_applyAbovePosition(): void;
|
|
23
26
|
_applyAbsolutePosition(): void;
|
|
24
27
|
_renderContent(): void;
|
|
25
|
-
render(): React.JSX.Element;
|
|
28
|
+
render(): React.JSX.Element | undefined;
|
|
26
29
|
}
|
|
@@ -6,6 +6,7 @@ export interface Props {
|
|
|
6
6
|
export default class Scrollable extends React.PureComponent<Props, {}> {
|
|
7
7
|
private scrollableDiv?;
|
|
8
8
|
reveal: (child: MentionItem) => void;
|
|
9
|
+
revealRef: (ref: React.RefObject<HTMLDivElement>) => void;
|
|
9
10
|
private handleRef;
|
|
10
11
|
render(): React.JSX.Element;
|
|
11
12
|
}
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type MentionDescription, type OnMentionEvent } from '../../types';
|
|
3
3
|
export { MENTION_ITEM_HEIGHT } from './styles';
|
|
4
4
|
export interface Props {
|
|
5
|
+
forwardedRef?: React.Ref<HTMLDivElement>;
|
|
5
6
|
mention: MentionDescription;
|
|
6
7
|
onMouseEnter?: OnMentionEvent;
|
|
7
8
|
onMouseMove?: OnMentionEvent;
|
|
@@ -14,3 +15,4 @@ export default class MentionItem extends React.PureComponent<Props, {}> {
|
|
|
14
15
|
private onMentionMenuItemMouseEnter;
|
|
15
16
|
render(): React.JSX.Element;
|
|
16
17
|
}
|
|
18
|
+
export declare const MentionItemWithRef: React.ForwardRefExoticComponent<Omit<Props, "forwardedRef"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -18,7 +18,10 @@ export default class MentionList extends React.PureComponent<Props, State> {
|
|
|
18
18
|
private lastMousePosition;
|
|
19
19
|
private scrollable?;
|
|
20
20
|
private items;
|
|
21
|
+
private itemsRefs;
|
|
21
22
|
constructor(props: Props);
|
|
23
|
+
createItemRef(key: string): React.RefObject<HTMLDivElement>;
|
|
24
|
+
getItemRef(key: string): React.RefObject<HTMLDivElement> | undefined;
|
|
22
25
|
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
23
26
|
componentDidUpdate(): void;
|
|
24
27
|
selectNext: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { type IntlShape } from 'react-intl-next';
|
|
3
|
+
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
4
4
|
import { type MentionProvider } from '../../api/MentionResource';
|
|
5
5
|
import { type PresenceProvider } from '../../api/PresenceResource';
|
|
6
6
|
import { type OnMentionEvent } from '../../types';
|
|
@@ -9,6 +9,9 @@ export interface Props {
|
|
|
9
9
|
}
|
|
10
10
|
export default class Popup extends React.PureComponent<Props, {}> {
|
|
11
11
|
private popup?;
|
|
12
|
+
private portalStyles;
|
|
13
|
+
constructor(props: Props);
|
|
14
|
+
setPortalStyles(styles: Record<string, string | number | null>): void;
|
|
12
15
|
static defaultProps: {
|
|
13
16
|
relativePosition: string;
|
|
14
17
|
offsetX: number;
|
|
@@ -22,5 +25,5 @@ export default class Popup extends React.PureComponent<Props, {}> {
|
|
|
22
25
|
_applyAbovePosition(): void;
|
|
23
26
|
_applyAbsolutePosition(): void;
|
|
24
27
|
_renderContent(): void;
|
|
25
|
-
render(): React.JSX.Element;
|
|
28
|
+
render(): React.JSX.Element | undefined;
|
|
26
29
|
}
|