@atlaskit/emoji 65.0.0 → 65.2.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 +36 -0
- package/dist/cjs/components/common/CachingEmoji.js +84 -151
- package/dist/cjs/components/common/Emoji.js +2 -2
- package/dist/cjs/components/common/EmojiActions.js +129 -175
- package/dist/cjs/components/common/EmojiErrorMessage.js +23 -59
- package/dist/cjs/components/common/EmojiPreviewComponent.js +1 -0
- package/dist/cjs/components/common/EmojiUploadPicker.js +235 -293
- package/dist/cjs/components/common/FileChooser.js +34 -71
- package/dist/cjs/components/common/Popup.js +105 -154
- package/dist/cjs/components/common/ResourcedEmojiComponent.js +10 -5
- package/dist/cjs/components/common/RetryableButton.js +43 -64
- package/dist/cjs/components/common/ToneSelector.js +50 -89
- package/dist/cjs/components/common/styles.js +14 -16
- package/dist/cjs/components/hooks.js +16 -0
- package/dist/cjs/components/picker/EmojiPickerCategoryHeading.js +16 -48
- package/dist/cjs/components/picker/EmojiPickerComponent.js +496 -508
- package/dist/cjs/components/picker/EmojiPickerEmojiRow.js +33 -60
- package/dist/cjs/components/picker/EmojiPickerFooter.js +13 -46
- package/dist/cjs/components/picker/styles.js +16 -13
- package/dist/cjs/components/uploader/EmojiUploadComponent.js +124 -109
- package/dist/cjs/hooks/useEmojiContext.js +16 -0
- package/dist/cjs/hooks/usePrevious.js +16 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/util/constants.js +3 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/common/CachingEmoji.js +65 -112
- package/dist/es2019/components/common/Emoji.js +2 -2
- package/dist/es2019/components/common/EmojiActions.js +124 -150
- package/dist/es2019/components/common/EmojiErrorMessage.js +22 -26
- package/dist/es2019/components/common/EmojiPreviewComponent.js +1 -0
- package/dist/es2019/components/common/EmojiUploadPicker.js +190 -253
- package/dist/es2019/components/common/FileChooser.js +37 -40
- package/dist/es2019/components/common/Popup.js +89 -109
- package/dist/es2019/components/common/ResourcedEmojiComponent.js +5 -4
- package/dist/es2019/components/common/RetryableButton.js +43 -34
- package/dist/es2019/components/common/ToneSelector.js +46 -59
- package/dist/es2019/components/common/styles.js +9 -9
- package/dist/es2019/components/hooks.js +8 -0
- package/dist/es2019/components/picker/EmojiPickerCategoryHeading.js +13 -17
- package/dist/es2019/components/picker/EmojiPickerComponent.js +417 -497
- package/dist/es2019/components/picker/EmojiPickerEmojiRow.js +32 -35
- package/dist/es2019/components/picker/EmojiPickerFooter.js +11 -19
- package/dist/es2019/components/picker/styles.js +16 -14
- package/dist/es2019/components/uploader/EmojiUploadComponent.js +81 -91
- package/dist/es2019/hooks/useEmojiContext.js +3 -0
- package/dist/es2019/hooks/usePrevious.js +8 -0
- package/dist/es2019/index.js +4 -1
- package/dist/es2019/util/constants.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/common/CachingEmoji.js +86 -156
- package/dist/esm/components/common/Emoji.js +2 -2
- package/dist/esm/components/common/EmojiActions.js +129 -176
- package/dist/esm/components/common/EmojiErrorMessage.js +21 -56
- package/dist/esm/components/common/EmojiPreviewComponent.js +1 -0
- package/dist/esm/components/common/EmojiUploadPicker.js +233 -299
- package/dist/esm/components/common/FileChooser.js +34 -70
- package/dist/esm/components/common/Popup.js +104 -155
- package/dist/esm/components/common/ResourcedEmojiComponent.js +8 -4
- package/dist/esm/components/common/RetryableButton.js +40 -60
- package/dist/esm/components/common/ToneSelector.js +50 -87
- package/dist/esm/components/common/styles.js +10 -10
- package/dist/esm/components/hooks.js +8 -0
- package/dist/esm/components/picker/EmojiPickerCategoryHeading.js +14 -43
- package/dist/esm/components/picker/EmojiPickerComponent.js +486 -526
- package/dist/esm/components/picker/EmojiPickerEmojiRow.js +31 -59
- package/dist/esm/components/picker/EmojiPickerFooter.js +14 -47
- package/dist/esm/components/picker/styles.js +16 -14
- package/dist/esm/components/uploader/EmojiUploadComponent.js +119 -113
- package/dist/esm/hooks/useEmojiContext.js +5 -0
- package/dist/esm/hooks/usePrevious.js +8 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/util/constants.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/api/EmojiResource.d.ts +2 -3
- package/dist/types/components/common/CachingEmoji.d.ts +3 -13
- package/dist/types/components/common/Emoji.d.ts +1 -2
- package/dist/types/components/common/EmojiActions.d.ts +6 -17
- package/dist/types/components/common/EmojiErrorMessage.d.ts +3 -6
- package/dist/types/components/common/EmojiPreviewComponent.d.ts +2 -2
- package/dist/types/components/common/EmojiUploadPicker.d.ts +3 -27
- package/dist/types/components/common/FileChooser.d.ts +3 -5
- package/dist/types/components/common/LoadingEmojiComponent.d.ts +3 -0
- package/dist/types/components/common/Popup.d.ts +3 -20
- package/dist/types/components/common/ResourcedEmojiComponent.d.ts +23 -11
- package/dist/types/components/common/RetryableButton.d.ts +3 -7
- package/dist/types/components/common/ToneSelector.d.ts +4 -10
- package/dist/types/components/common/setSkinToneAriaLabelText.d.ts +1 -1
- package/dist/types/components/common/styles.d.ts +1 -3
- package/dist/types/components/hooks.d.ts +1 -0
- package/dist/types/components/picker/CategorySelector.d.ts +1 -1
- package/dist/types/components/picker/EmojiPicker.d.ts +12 -3
- package/dist/types/components/picker/EmojiPickerCategoryHeading.d.ts +3 -4
- package/dist/types/components/picker/EmojiPickerComponent.d.ts +14 -76
- package/dist/types/components/picker/EmojiPickerEmojiRow.d.ts +3 -4
- package/dist/types/components/picker/EmojiPickerFooter.d.ts +3 -5
- package/dist/types/components/picker/styles.d.ts +1 -1
- package/dist/types/components/typeahead/EmojiTypeAheadComponent.d.ts +18 -0
- package/dist/types/components/uploader/EmojiUploadComponent.d.ts +3 -17
- package/dist/types/components/uploader/EmojiUploader.d.ts +5 -7
- package/dist/types/hooks/useEmojiContext.d.ts +1 -0
- package/dist/types/hooks/usePrevious.d.ts +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/types.d.ts +2 -1
- package/dist/types/util/constants.d.ts +1 -0
- package/docs/0-intro.tsx +35 -27
- package/docs/1-resourced-emoji.tsx +74 -0
- package/docs/2-emoji-picker.tsx +56 -0
- package/docs/3-typeahead.tsx +20 -0
- package/docs/4-emoji-provider.tsx +98 -0
- package/local-config-example.ts +3 -1
- package/package.json +19 -6
- package/dist/cjs/components/common/EmojiPreview.js +0 -194
- package/dist/es2019/components/common/EmojiPreview.js +0 -152
- package/dist/esm/components/common/EmojiPreview.js +0 -170
- package/dist/types/components/common/EmojiPreview.d.ts +0 -31
|
@@ -1,77 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { PureComponent } from 'react';
|
|
1
|
+
import React, { useRef } from 'react';
|
|
15
2
|
import AkButton from '@atlaskit/button/custom-theme-button';
|
|
16
3
|
|
|
17
|
-
var FileChooser =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
var FileChooser = function FileChooser(props) {
|
|
5
|
+
var accept = props.accept,
|
|
6
|
+
ariaDescribedBy = props.ariaDescribedBy,
|
|
7
|
+
isDisabled = props.isDisabled,
|
|
8
|
+
label = props.label,
|
|
9
|
+
onChange = props.onChange,
|
|
10
|
+
onClick = props.onClick;
|
|
11
|
+
var filePickerRef = useRef(null);
|
|
12
|
+
|
|
13
|
+
var handleOnChooseFile = function handleOnChooseFile() {
|
|
14
|
+
if (!filePickerRef.current) {
|
|
15
|
+
return;
|
|
29
16
|
}
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_defineProperty(_assertThisInitialized(_this), "onChooseFile", function () {
|
|
34
|
-
if (_this.props.onClick) {
|
|
35
|
-
_this.props.onClick();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var chooseFile = _this.refs['chooseFile'];
|
|
39
|
-
|
|
40
|
-
if (chooseFile) {
|
|
41
|
-
chooseFile.click();
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return _this;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
_createClass(FileChooser, [{
|
|
49
|
-
key: "render",
|
|
50
|
-
value: function render() {
|
|
51
|
-
var _this$props = this.props,
|
|
52
|
-
accept = _this$props.accept,
|
|
53
|
-
ariaDescribedBy = _this$props.ariaDescribedBy,
|
|
54
|
-
isDisabled = _this$props.isDisabled,
|
|
55
|
-
label = _this$props.label,
|
|
56
|
-
onChange = _this$props.onChange;
|
|
57
|
-
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(AkButton, {
|
|
58
|
-
onClick: this.onChooseFile,
|
|
59
|
-
isDisabled: isDisabled,
|
|
60
|
-
"aria-describedby": ariaDescribedBy
|
|
61
|
-
}, label), /*#__PURE__*/React.createElement("input", {
|
|
62
|
-
className: "emojiUploadFileInput",
|
|
63
|
-
ref: "chooseFile",
|
|
64
|
-
onChange: onChange,
|
|
65
|
-
type: "file",
|
|
66
|
-
accept: accept,
|
|
67
|
-
style: {
|
|
68
|
-
display: 'none'
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
18
|
+
if (onClick) {
|
|
19
|
+
onClick();
|
|
71
20
|
}
|
|
72
|
-
}]);
|
|
73
21
|
|
|
74
|
-
|
|
75
|
-
}
|
|
22
|
+
filePickerRef.current.click();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(AkButton, {
|
|
26
|
+
onClick: handleOnChooseFile,
|
|
27
|
+
isDisabled: isDisabled,
|
|
28
|
+
"aria-describedby": ariaDescribedBy
|
|
29
|
+
}, label), /*#__PURE__*/React.createElement("input", {
|
|
30
|
+
className: "emojiUploadFileInput",
|
|
31
|
+
ref: filePickerRef,
|
|
32
|
+
onChange: onChange,
|
|
33
|
+
type: "file",
|
|
34
|
+
accept: accept,
|
|
35
|
+
style: {
|
|
36
|
+
display: 'none'
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
76
40
|
|
|
77
|
-
export
|
|
41
|
+
export default FileChooser;
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { PureComponent } from 'react';
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
15
3
|
import ReactDOM from 'react-dom';
|
|
16
4
|
|
|
17
5
|
var getTargetNode = function getTargetNode(target) {
|
|
@@ -23,168 +11,129 @@ var getTargetNode = function getTargetNode(target) {
|
|
|
23
11
|
return target;
|
|
24
12
|
};
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
14
|
+
var Popup = function Popup(props) {
|
|
15
|
+
var _props$relativePositi = props.relativePosition,
|
|
16
|
+
relativePosition = _props$relativePositi === void 0 ? 'auto' : _props$relativePositi,
|
|
17
|
+
_props$offsetX = props.offsetX,
|
|
18
|
+
offsetX = _props$offsetX === void 0 ? 0 : _props$offsetX,
|
|
19
|
+
_props$offsetY = props.offsetY,
|
|
20
|
+
offsetY = _props$offsetY === void 0 ? 0 : _props$offsetY,
|
|
21
|
+
_props$zIndex = props.zIndex,
|
|
22
|
+
zIndex = _props$zIndex === void 0 ? 9 : _props$zIndex,
|
|
23
|
+
target = props.target,
|
|
24
|
+
children = props.children;
|
|
25
|
+
var popup = useRef();
|
|
26
|
+
|
|
27
|
+
var _useState = useState(null),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
debounced = _useState2[0],
|
|
30
|
+
setDebounced = _useState2[1];
|
|
31
|
+
|
|
32
|
+
var applyBelowPosition = useCallback(function () {
|
|
33
|
+
var targetNode = getTargetNode(target);
|
|
34
|
+
|
|
35
|
+
if (targetNode && popup.current) {
|
|
36
|
+
var box = targetNode.getBoundingClientRect();
|
|
37
|
+
var top = box.bottom + (offsetY || 0);
|
|
38
|
+
var left = box.left + (offsetX || 0);
|
|
39
|
+
popup.current.style.top = "".concat(top, "px");
|
|
40
|
+
popup.current.style.bottom = '';
|
|
41
|
+
popup.current.style.left = "".concat(left, "px");
|
|
42
|
+
}
|
|
43
|
+
}, [offsetX, offsetY, target]);
|
|
44
|
+
var applyAbovePosition = useCallback(function () {
|
|
45
|
+
if (typeof window === 'undefined') {
|
|
46
|
+
return;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "debounced", null);
|
|
46
|
-
|
|
47
|
-
_defineProperty(_assertThisInitialized(_this), "handleResize", function () {
|
|
48
|
-
if (_this.debounced) {
|
|
49
|
-
clearTimeout(_this.debounced);
|
|
50
|
-
_this.debounced = null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (typeof window === 'undefined') {
|
|
54
|
-
return;
|
|
55
|
-
} // Timeout set to 30ms as to not throttle IE11
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
_this.debounced = window.setTimeout(function () {
|
|
59
|
-
_this.applyAbsolutePosition();
|
|
49
|
+
var targetNode = getTargetNode(target);
|
|
60
50
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
if (targetNode && popup.current) {
|
|
52
|
+
var box = targetNode.getBoundingClientRect();
|
|
53
|
+
var bottom = window.innerHeight - box.top + (offsetY || 0);
|
|
54
|
+
var left = box.left + (offsetX || 0);
|
|
55
|
+
popup.current.style.top = '';
|
|
56
|
+
popup.current.style.bottom = "".concat(bottom, "px");
|
|
57
|
+
popup.current.style.left = "".concat(left, "px");
|
|
58
|
+
}
|
|
59
|
+
}, [offsetX, offsetY, target]);
|
|
60
|
+
var applyAbsolutePosition = useCallback(function () {
|
|
61
|
+
if (typeof window === 'undefined') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if (relativePosition === 'above') {
|
|
66
|
+
applyAbovePosition();
|
|
67
|
+
} else if (relativePosition === 'below') {
|
|
68
|
+
applyBelowPosition();
|
|
69
|
+
} else {
|
|
70
|
+
var targetNode = getTargetNode(target);
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.popup = document.createElement('div');
|
|
72
|
-
document.body.appendChild(this.popup);
|
|
73
|
-
this.popup.style.position = 'absolute';
|
|
72
|
+
if (targetNode) {
|
|
73
|
+
var box = targetNode.getBoundingClientRect();
|
|
74
|
+
var viewPortHeight = window.innerHeight;
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
if (box.top < viewPortHeight / 2) {
|
|
77
|
+
applyBelowPosition();
|
|
78
|
+
} else {
|
|
79
|
+
applyAbovePosition();
|
|
80
|
+
}
|
|
77
81
|
}
|
|
82
|
+
}
|
|
78
83
|
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
if (zIndex && popup.current) {
|
|
85
|
+
popup.current.style.zIndex = "".concat(zIndex);
|
|
81
86
|
}
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
}, [applyAbovePosition, applyBelowPosition, relativePosition, target, zIndex]);
|
|
88
|
+
var handleResize = useCallback(function () {
|
|
89
|
+
if (debounced) {
|
|
90
|
+
clearTimeout(debounced);
|
|
91
|
+
setDebounced(null);
|
|
87
92
|
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "componentWillUnmount",
|
|
90
|
-
value: function componentWillUnmount() {
|
|
91
|
-
if (typeof window === 'undefined') {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
window.removeEventListener('resize', this.handleResize);
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
} // Internal
|
|
94
|
+
if (typeof window === 'undefined') {
|
|
95
|
+
return;
|
|
96
|
+
} // Timeout set to 30ms as to not throttle IE11
|
|
102
97
|
|
|
103
|
-
}, {
|
|
104
|
-
key: "applyBelowPosition",
|
|
105
|
-
value: function applyBelowPosition() {
|
|
106
|
-
var targetNode = getTargetNode(this.props.target);
|
|
107
98
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
99
|
+
var debounceId = window.setTimeout(function () {
|
|
100
|
+
applyAbsolutePosition();
|
|
101
|
+
setDebounced(null);
|
|
102
|
+
}, 30);
|
|
103
|
+
setDebounced(debounceId);
|
|
104
|
+
}, [applyAbsolutePosition, debounced]);
|
|
105
|
+
var renderPopup = useCallback(function () {
|
|
106
|
+
if (!popup.current) {
|
|
107
|
+
return;
|
|
116
108
|
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "applyAbovePosition",
|
|
119
|
-
value: function applyAbovePosition() {
|
|
120
|
-
if (typeof window === 'undefined') {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
109
|
|
|
124
|
-
|
|
110
|
+
ReactDOM.render(children, popup.current);
|
|
111
|
+
}, [children]);
|
|
112
|
+
useEffect(function () {
|
|
113
|
+
popup.current = document.createElement('div');
|
|
114
|
+
document.body.appendChild(popup.current);
|
|
115
|
+
popup.current.style.position = 'absolute';
|
|
125
116
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var bottom = window.innerHeight - box.top + (this.props.offsetY || 0);
|
|
129
|
-
var left = box.left + (this.props.offsetX || 0);
|
|
130
|
-
this.popup.style.top = '';
|
|
131
|
-
this.popup.style.bottom = "".concat(bottom, "px");
|
|
132
|
-
this.popup.style.left = "".concat(left, "px");
|
|
133
|
-
}
|
|
117
|
+
if (typeof window !== 'undefined') {
|
|
118
|
+
window.addEventListener('resize', handleResize);
|
|
134
119
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
120
|
+
|
|
121
|
+
applyAbsolutePosition();
|
|
122
|
+
renderPopup();
|
|
123
|
+
return function () {
|
|
138
124
|
if (typeof window === 'undefined') {
|
|
139
125
|
return;
|
|
140
126
|
}
|
|
141
127
|
|
|
142
|
-
|
|
143
|
-
this.applyAbovePosition();
|
|
144
|
-
} else if (this.props.relativePosition === 'below') {
|
|
145
|
-
this.applyBelowPosition();
|
|
146
|
-
} else {
|
|
147
|
-
var targetNode = getTargetNode(this.props.target);
|
|
148
|
-
|
|
149
|
-
if (targetNode) {
|
|
150
|
-
var box = targetNode.getBoundingClientRect();
|
|
151
|
-
var viewPortHeight = window.innerHeight;
|
|
152
|
-
|
|
153
|
-
if (box.top < viewPortHeight / 2) {
|
|
154
|
-
this.applyBelowPosition();
|
|
155
|
-
} else {
|
|
156
|
-
this.applyAbovePosition();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
128
|
+
window.removeEventListener('resize', handleResize);
|
|
160
129
|
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
}, {
|
|
166
|
-
key: "renderContent",
|
|
167
|
-
value: function renderContent() {
|
|
168
|
-
if (this.popup) {
|
|
169
|
-
ReactDOM.render(this.props.children, this.popup);
|
|
130
|
+
if (popup.current) {
|
|
131
|
+
ReactDOM.unmountComponentAtNode(popup.current);
|
|
132
|
+
document.body.removeChild(popup.current);
|
|
170
133
|
}
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
// inline placeholder element for react to render inplace
|
|
176
|
-
return /*#__PURE__*/React.createElement("div", null);
|
|
177
|
-
}
|
|
178
|
-
}]);
|
|
179
|
-
|
|
180
|
-
return Popup;
|
|
181
|
-
}(PureComponent);
|
|
182
|
-
|
|
183
|
-
_defineProperty(Popup, "defaultProps", {
|
|
184
|
-
relativePosition: 'auto',
|
|
185
|
-
offsetX: 0,
|
|
186
|
-
offsetY: 0,
|
|
187
|
-
zIndex: 0
|
|
188
|
-
});
|
|
134
|
+
};
|
|
135
|
+
}, [applyAbsolutePosition, handleResize, renderPopup]);
|
|
136
|
+
return /*#__PURE__*/React.createElement("div", null);
|
|
137
|
+
};
|
|
189
138
|
|
|
190
|
-
export
|
|
139
|
+
export default Popup;
|
|
@@ -21,13 +21,16 @@ var ResourcedEmojiComponentRenderStatesEnum;
|
|
|
21
21
|
export var ResourcedEmojiComponent = function ResourcedEmojiComponent(_ref) {
|
|
22
22
|
var emojiProvider = _ref.emojiProvider,
|
|
23
23
|
emojiId = _ref.emojiId,
|
|
24
|
-
showTooltip = _ref.showTooltip,
|
|
25
|
-
|
|
24
|
+
_ref$showTooltip = _ref.showTooltip,
|
|
25
|
+
showTooltip = _ref$showTooltip === void 0 ? false : _ref$showTooltip,
|
|
26
|
+
_ref$customFallback = _ref.customFallback,
|
|
27
|
+
customFallback = _ref$customFallback === void 0 ? undefined : _ref$customFallback,
|
|
26
28
|
_ref$fitToHeight = _ref.fitToHeight,
|
|
27
29
|
fitToHeight = _ref$fitToHeight === void 0 ? defaultEmojiHeight : _ref$fitToHeight,
|
|
28
30
|
_ref$optimistic = _ref.optimistic,
|
|
29
31
|
optimistic = _ref$optimistic === void 0 ? false : _ref$optimistic,
|
|
30
|
-
|
|
32
|
+
_ref$optimisticImageU = _ref.optimisticImageURL,
|
|
33
|
+
optimisticImageURL = _ref$optimisticImageU === void 0 ? undefined : _ref$optimisticImageU;
|
|
31
34
|
var shortName = emojiId.shortName,
|
|
32
35
|
id = emojiId.id,
|
|
33
36
|
fallback = emojiId.fallback;
|
|
@@ -179,4 +182,5 @@ export var ResourcedEmojiComponent = function ResourcedEmojiComponent(_ref) {
|
|
|
179
182
|
showTooltip: showTooltip,
|
|
180
183
|
fitToHeight: fitToHeight
|
|
181
184
|
})));
|
|
182
|
-
};
|
|
185
|
+
};
|
|
186
|
+
export default ResourcedEmojiComponent;
|
|
@@ -1,72 +1,52 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
|
|
9
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
1
|
/** @jsx jsx */
|
|
12
2
|
import { jsx } from '@emotion/core';
|
|
13
3
|
import AkButton from '@atlaskit/button/custom-theme-button';
|
|
14
4
|
import Spinner from '@atlaskit/spinner';
|
|
15
|
-
import { Component } from 'react';
|
|
16
5
|
import { FormattedMessage } from 'react-intl-next';
|
|
17
6
|
import { messages } from '../i18n';
|
|
18
7
|
import { buttonSpinner, uploadEmojiButton, uploadRetryButton } from './styles';
|
|
19
8
|
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
var LoadingSpinner = function LoadingSpinner() {
|
|
10
|
+
return jsx("span", {
|
|
11
|
+
css: buttonSpinner
|
|
12
|
+
}, jsx(Spinner, null));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var RetryButton = function RetryButton(props) {
|
|
16
|
+
var onSubmit = props.onSubmit;
|
|
17
|
+
return jsx(FormattedMessage, messages.retryLabel, function (retryLabel) {
|
|
18
|
+
return jsx(AkButton, {
|
|
19
|
+
css: uploadRetryButton,
|
|
20
|
+
appearance: "warning",
|
|
21
|
+
onClick: onSubmit
|
|
22
|
+
}, retryLabel);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var UploadButton = function UploadButton(props) {
|
|
27
|
+
var appearance = props.appearance,
|
|
28
|
+
onSubmit = props.onSubmit,
|
|
29
|
+
label = props.label;
|
|
30
|
+
return jsx(AkButton, {
|
|
31
|
+
css: uploadEmojiButton,
|
|
32
|
+
appearance: appearance,
|
|
33
|
+
onClick: onSubmit
|
|
34
|
+
}, label);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var RetryableButton = function RetryableButton(props) {
|
|
38
|
+
var loading = props.loading,
|
|
39
|
+
error = props.error;
|
|
40
|
+
|
|
41
|
+
if (loading) {
|
|
42
|
+
return jsx(LoadingSpinner, null);
|
|
29
43
|
}
|
|
30
44
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return jsx("span", {
|
|
35
|
-
css: buttonSpinner
|
|
36
|
-
}, jsx(Spinner, null));
|
|
37
|
-
}
|
|
38
|
-
}, {
|
|
39
|
-
key: "renderRetry",
|
|
40
|
-
value: function renderRetry() {
|
|
41
|
-
var _this$props = this.props,
|
|
42
|
-
loading = _this$props.loading,
|
|
43
|
-
onSubmit = _this$props.onSubmit;
|
|
44
|
-
return loading ? this.renderLoading() : jsx(FormattedMessage, messages.retryLabel, function (retryLabel) {
|
|
45
|
-
return jsx(AkButton, {
|
|
46
|
-
css: uploadRetryButton,
|
|
47
|
-
appearance: "warning",
|
|
48
|
-
onClick: onSubmit
|
|
49
|
-
}, retryLabel);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "render",
|
|
54
|
-
value: function render() {
|
|
55
|
-
var _this$props2 = this.props,
|
|
56
|
-
loading = _this$props2.loading,
|
|
57
|
-
error = _this$props2.error,
|
|
58
|
-
appearance = _this$props2.appearance,
|
|
59
|
-
onSubmit = _this$props2.onSubmit,
|
|
60
|
-
label = _this$props2.label;
|
|
61
|
-
return error ? this.renderRetry() : loading ? this.renderLoading() : jsx(AkButton, {
|
|
62
|
-
css: uploadEmojiButton,
|
|
63
|
-
appearance: appearance,
|
|
64
|
-
onClick: onSubmit
|
|
65
|
-
}, label);
|
|
66
|
-
}
|
|
67
|
-
}]);
|
|
45
|
+
if (error) {
|
|
46
|
+
return jsx(RetryButton, props);
|
|
47
|
+
}
|
|
68
48
|
|
|
69
|
-
return
|
|
70
|
-
}
|
|
49
|
+
return jsx(UploadButton, props);
|
|
50
|
+
};
|
|
71
51
|
|
|
72
|
-
export
|
|
52
|
+
export default RetryableButton;
|