@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,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { PureComponent } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
2
|
import ReactDOM from 'react-dom';
|
|
5
3
|
|
|
6
4
|
const getTargetNode = target => {
|
|
@@ -12,140 +10,122 @@ const getTargetNode = target => {
|
|
|
12
10
|
return target;
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (typeof window === 'undefined') {
|
|
31
|
-
return;
|
|
32
|
-
} // Timeout set to 30ms as to not throttle IE11
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.debounced = window.setTimeout(() => {
|
|
36
|
-
this.applyAbsolutePosition();
|
|
37
|
-
this.debounced = null;
|
|
38
|
-
}, 30);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
componentDidMount() {
|
|
43
|
-
this.popup = document.createElement('div');
|
|
44
|
-
document.body.appendChild(this.popup);
|
|
45
|
-
this.popup.style.position = 'absolute';
|
|
46
|
-
|
|
47
|
-
if (typeof window !== 'undefined') {
|
|
48
|
-
window.addEventListener('resize', this.handleResize);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.applyAbsolutePosition();
|
|
52
|
-
this.renderContent();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
componentDidUpdate() {
|
|
56
|
-
this.applyAbsolutePosition();
|
|
57
|
-
this.renderContent();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
componentWillUnmount() {
|
|
61
|
-
if (typeof window === 'undefined') {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
window.removeEventListener('resize', this.handleResize);
|
|
66
|
-
|
|
67
|
-
if (this.popup) {
|
|
68
|
-
ReactDOM.unmountComponentAtNode(this.popup);
|
|
69
|
-
document.body.removeChild(this.popup);
|
|
70
|
-
}
|
|
71
|
-
} // Internal
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
applyBelowPosition() {
|
|
75
|
-
const targetNode = getTargetNode(this.props.target);
|
|
76
|
-
|
|
77
|
-
if (targetNode && this.popup) {
|
|
13
|
+
const Popup = props => {
|
|
14
|
+
const {
|
|
15
|
+
relativePosition = 'auto',
|
|
16
|
+
offsetX = 0,
|
|
17
|
+
offsetY = 0,
|
|
18
|
+
zIndex = 9,
|
|
19
|
+
target,
|
|
20
|
+
children
|
|
21
|
+
} = props;
|
|
22
|
+
const popup = useRef();
|
|
23
|
+
const [debounced, setDebounced] = useState(null);
|
|
24
|
+
const applyBelowPosition = useCallback(() => {
|
|
25
|
+
const targetNode = getTargetNode(target);
|
|
26
|
+
|
|
27
|
+
if (targetNode && popup.current) {
|
|
78
28
|
const box = targetNode.getBoundingClientRect();
|
|
79
|
-
const top = box.bottom + (
|
|
80
|
-
const left = box.left + (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
29
|
+
const top = box.bottom + (offsetY || 0);
|
|
30
|
+
const left = box.left + (offsetX || 0);
|
|
31
|
+
popup.current.style.top = `${top}px`;
|
|
32
|
+
popup.current.style.bottom = '';
|
|
33
|
+
popup.current.style.left = `${left}px`;
|
|
84
34
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
applyAbovePosition() {
|
|
35
|
+
}, [offsetX, offsetY, target]);
|
|
36
|
+
const applyAbovePosition = useCallback(() => {
|
|
88
37
|
if (typeof window === 'undefined') {
|
|
89
38
|
return;
|
|
90
39
|
}
|
|
91
40
|
|
|
92
|
-
const targetNode = getTargetNode(
|
|
41
|
+
const targetNode = getTargetNode(target);
|
|
93
42
|
|
|
94
|
-
if (targetNode &&
|
|
43
|
+
if (targetNode && popup.current) {
|
|
95
44
|
const box = targetNode.getBoundingClientRect();
|
|
96
|
-
const bottom = window.innerHeight - box.top + (
|
|
97
|
-
const left = box.left + (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
45
|
+
const bottom = window.innerHeight - box.top + (offsetY || 0);
|
|
46
|
+
const left = box.left + (offsetX || 0);
|
|
47
|
+
popup.current.style.top = '';
|
|
48
|
+
popup.current.style.bottom = `${bottom}px`;
|
|
49
|
+
popup.current.style.left = `${left}px`;
|
|
101
50
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
applyAbsolutePosition() {
|
|
51
|
+
}, [offsetX, offsetY, target]);
|
|
52
|
+
const applyAbsolutePosition = useCallback(() => {
|
|
105
53
|
if (typeof window === 'undefined') {
|
|
106
54
|
return;
|
|
107
55
|
}
|
|
108
56
|
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
} else if (
|
|
112
|
-
|
|
57
|
+
if (relativePosition === 'above') {
|
|
58
|
+
applyAbovePosition();
|
|
59
|
+
} else if (relativePosition === 'below') {
|
|
60
|
+
applyBelowPosition();
|
|
113
61
|
} else {
|
|
114
|
-
const targetNode = getTargetNode(
|
|
62
|
+
const targetNode = getTargetNode(target);
|
|
115
63
|
|
|
116
64
|
if (targetNode) {
|
|
117
65
|
const box = targetNode.getBoundingClientRect();
|
|
118
66
|
const viewPortHeight = window.innerHeight;
|
|
119
67
|
|
|
120
68
|
if (box.top < viewPortHeight / 2) {
|
|
121
|
-
|
|
69
|
+
applyBelowPosition();
|
|
122
70
|
} else {
|
|
123
|
-
|
|
71
|
+
applyAbovePosition();
|
|
124
72
|
}
|
|
125
73
|
}
|
|
126
74
|
}
|
|
127
75
|
|
|
128
|
-
if (
|
|
129
|
-
|
|
76
|
+
if (zIndex && popup.current) {
|
|
77
|
+
popup.current.style.zIndex = `${zIndex}`;
|
|
78
|
+
}
|
|
79
|
+
}, [applyAbovePosition, applyBelowPosition, relativePosition, target, zIndex]);
|
|
80
|
+
const handleResize = useCallback(() => {
|
|
81
|
+
if (debounced) {
|
|
82
|
+
clearTimeout(debounced);
|
|
83
|
+
setDebounced(null);
|
|
130
84
|
}
|
|
131
|
-
}
|
|
132
85
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
86
|
+
if (typeof window === 'undefined') {
|
|
87
|
+
return;
|
|
88
|
+
} // Timeout set to 30ms as to not throttle IE11
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
const debounceId = window.setTimeout(() => {
|
|
92
|
+
applyAbsolutePosition();
|
|
93
|
+
setDebounced(null);
|
|
94
|
+
}, 30);
|
|
95
|
+
setDebounced(debounceId);
|
|
96
|
+
}, [applyAbsolutePosition, debounced]);
|
|
97
|
+
const renderPopup = useCallback(() => {
|
|
98
|
+
if (!popup.current) {
|
|
99
|
+
return;
|
|
136
100
|
}
|
|
137
|
-
}
|
|
138
101
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
102
|
+
ReactDOM.render(children, popup.current);
|
|
103
|
+
}, [children]);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
popup.current = document.createElement('div');
|
|
106
|
+
document.body.appendChild(popup.current);
|
|
107
|
+
popup.current.style.position = 'absolute';
|
|
143
108
|
|
|
144
|
-
|
|
109
|
+
if (typeof window !== 'undefined') {
|
|
110
|
+
window.addEventListener('resize', handleResize);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
applyAbsolutePosition();
|
|
114
|
+
renderPopup();
|
|
115
|
+
return () => {
|
|
116
|
+
if (typeof window === 'undefined') {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
window.removeEventListener('resize', handleResize);
|
|
121
|
+
|
|
122
|
+
if (popup.current) {
|
|
123
|
+
ReactDOM.unmountComponentAtNode(popup.current);
|
|
124
|
+
document.body.removeChild(popup.current);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}, [applyAbsolutePosition, handleResize, renderPopup]);
|
|
128
|
+
return /*#__PURE__*/React.createElement("div", null);
|
|
129
|
+
};
|
|
145
130
|
|
|
146
|
-
|
|
147
|
-
relativePosition: 'auto',
|
|
148
|
-
offsetX: 0,
|
|
149
|
-
offsetY: 0,
|
|
150
|
-
zIndex: 0
|
|
151
|
-
});
|
|
131
|
+
export default Popup;
|
|
@@ -20,11 +20,11 @@ var ResourcedEmojiComponentRenderStatesEnum;
|
|
|
20
20
|
export const ResourcedEmojiComponent = ({
|
|
21
21
|
emojiProvider,
|
|
22
22
|
emojiId,
|
|
23
|
-
showTooltip,
|
|
24
|
-
customFallback,
|
|
23
|
+
showTooltip = false,
|
|
24
|
+
customFallback = undefined,
|
|
25
25
|
fitToHeight = defaultEmojiHeight,
|
|
26
26
|
optimistic = false,
|
|
27
|
-
optimisticImageURL
|
|
27
|
+
optimisticImageURL = undefined
|
|
28
28
|
}) => {
|
|
29
29
|
const {
|
|
30
30
|
shortName,
|
|
@@ -170,4 +170,5 @@ export const ResourcedEmojiComponent = ({
|
|
|
170
170
|
showTooltip: showTooltip,
|
|
171
171
|
fitToHeight: fitToHeight
|
|
172
172
|
})));
|
|
173
|
-
};
|
|
173
|
+
};
|
|
174
|
+
export default ResourcedEmojiComponent;
|
|
@@ -2,46 +2,55 @@
|
|
|
2
2
|
import { jsx } from '@emotion/core';
|
|
3
3
|
import AkButton from '@atlaskit/button/custom-theme-button';
|
|
4
4
|
import Spinner from '@atlaskit/spinner';
|
|
5
|
-
import { Component } from 'react';
|
|
6
5
|
import { FormattedMessage } from 'react-intl-next';
|
|
7
6
|
import { messages } from '../i18n';
|
|
8
7
|
import { buttonSpinner, uploadEmojiButton, uploadRetryButton } from './styles';
|
|
9
|
-
export default class RetryableButton extends Component {
|
|
10
|
-
constructor(props) {
|
|
11
|
-
super(props);
|
|
12
|
-
}
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const LoadingSpinner = () => {
|
|
10
|
+
return jsx("span", {
|
|
11
|
+
css: buttonSpinner
|
|
12
|
+
}, jsx(Spinner, null));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const RetryButton = props => {
|
|
16
|
+
const {
|
|
17
|
+
onSubmit
|
|
18
|
+
} = props;
|
|
19
|
+
return jsx(FormattedMessage, messages.retryLabel, retryLabel => jsx(AkButton, {
|
|
20
|
+
css: uploadRetryButton,
|
|
21
|
+
appearance: "warning",
|
|
22
|
+
onClick: onSubmit
|
|
23
|
+
}, retryLabel));
|
|
24
|
+
};
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const UploadButton = props => {
|
|
27
|
+
const {
|
|
28
|
+
appearance,
|
|
29
|
+
onSubmit,
|
|
30
|
+
label
|
|
31
|
+
} = props;
|
|
32
|
+
return jsx(AkButton, {
|
|
33
|
+
css: uploadEmojiButton,
|
|
34
|
+
appearance: appearance,
|
|
35
|
+
onClick: onSubmit
|
|
36
|
+
}, label);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const RetryableButton = props => {
|
|
40
|
+
const {
|
|
41
|
+
loading,
|
|
42
|
+
error
|
|
43
|
+
} = props;
|
|
44
|
+
|
|
45
|
+
if (loading) {
|
|
46
|
+
return jsx(LoadingSpinner, null);
|
|
30
47
|
}
|
|
31
48
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
loading,
|
|
35
|
-
error,
|
|
36
|
-
appearance,
|
|
37
|
-
onSubmit,
|
|
38
|
-
label
|
|
39
|
-
} = this.props;
|
|
40
|
-
return error ? this.renderRetry() : loading ? this.renderLoading() : jsx(AkButton, {
|
|
41
|
-
css: uploadEmojiButton,
|
|
42
|
-
appearance: appearance,
|
|
43
|
-
onClick: onSubmit
|
|
44
|
-
}, label);
|
|
49
|
+
if (error) {
|
|
50
|
+
return jsx(RetryButton, props);
|
|
45
51
|
}
|
|
46
52
|
|
|
47
|
-
|
|
53
|
+
return jsx(UploadButton, props);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default RetryableButton;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { createRef, PureComponent } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
3
2
|
import EmojiButton from './EmojiButton';
|
|
4
3
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
4
|
import { createAndFireEventInElementsChannel, toneSelectedEvent, toneSelectorOpenedEvent } from '../../util/analytics';
|
|
@@ -13,70 +12,58 @@ const extractAllTones = emoji => {
|
|
|
13
12
|
return [emoji];
|
|
14
13
|
};
|
|
15
14
|
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} = this.props;
|
|
15
|
+
export const ToneSelectorInternal = props => {
|
|
16
|
+
const {
|
|
17
|
+
createAnalyticsEvent,
|
|
18
|
+
emoji,
|
|
19
|
+
previewEmojiId,
|
|
20
|
+
onToneSelected
|
|
21
|
+
} = props;
|
|
22
|
+
const isMounted = useRef(false);
|
|
23
|
+
const firstToneButtonRef = useRef(null);
|
|
24
|
+
const emojiToneCollection = useMemo(() => {
|
|
25
|
+
return extractAllTones(emoji).map((tone, index) => ({ ...tone,
|
|
26
|
+
focused: tone.id !== previewEmojiId,
|
|
27
|
+
label: setSkinToneAriaLabelText(tone.name),
|
|
28
|
+
toneId: index
|
|
29
|
+
}));
|
|
30
|
+
}, [emoji, previewEmojiId]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (firstToneButtonRef.current) {
|
|
33
|
+
firstToneButtonRef.current.focus();
|
|
34
|
+
}
|
|
35
|
+
}, [firstToneButtonRef]);
|
|
38
36
|
|
|
37
|
+
const fireAnalyticsEvent = event => {
|
|
39
38
|
if (createAnalyticsEvent) {
|
|
40
39
|
createAndFireEventInElementsChannel(event)(createAnalyticsEvent);
|
|
41
40
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
componentDidMount() {
|
|
45
|
-
var _this$firstToneButton, _this$firstToneButton2;
|
|
41
|
+
};
|
|
46
42
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
render() {
|
|
55
|
-
const {
|
|
56
|
-
emoji,
|
|
57
|
-
previewEmojiId
|
|
58
|
-
} = this.props;
|
|
59
|
-
const toneEmojis = extractAllTones(emoji);
|
|
60
|
-
let isRefAlreadySet = false;
|
|
61
|
-
return /*#__PURE__*/React.createElement("div", null, toneEmojis.map((tone, i) => {
|
|
62
|
-
const shouldSetRef = !isRefAlreadySet && tone.id !== previewEmojiId;
|
|
63
|
-
|
|
64
|
-
if (shouldSetRef) {
|
|
65
|
-
isRefAlreadySet = true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return /*#__PURE__*/React.createElement(EmojiButton, {
|
|
69
|
-
ref: shouldSetRef ? this.firstToneButtonRef : null,
|
|
70
|
-
shouldHideButton: tone.id === previewEmojiId,
|
|
71
|
-
ariaLabelText: setSkinToneAriaLabelText(tone.name),
|
|
72
|
-
key: `${tone.id}`,
|
|
73
|
-
onSelected: () => this.onToneSelectedHandler(i),
|
|
74
|
-
emoji: tone,
|
|
75
|
-
selectOnHover: true
|
|
76
|
-
});
|
|
43
|
+
const onToneSelectedHandler = toneValue => () => {
|
|
44
|
+
onToneSelected(toneValue);
|
|
45
|
+
const toneList = ['default', 'light', 'mediumLight', 'medium', 'mediumDark', 'dark'];
|
|
46
|
+
fireAnalyticsEvent(toneSelectedEvent({
|
|
47
|
+
skinToneModifier: toneList[toneValue]
|
|
77
48
|
}));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (!isMounted.current) {
|
|
52
|
+
fireAnalyticsEvent(toneSelectorOpenedEvent({}));
|
|
78
53
|
}
|
|
79
54
|
|
|
80
|
-
|
|
55
|
+
isMounted.current = true;
|
|
56
|
+
return /*#__PURE__*/React.createElement("div", null, emojiToneCollection.map(tone => {
|
|
57
|
+
return /*#__PURE__*/React.createElement(EmojiButton, {
|
|
58
|
+
ref: tone.focused ? firstToneButtonRef : null,
|
|
59
|
+
shouldHideButton: tone.id === previewEmojiId,
|
|
60
|
+
ariaLabelText: tone.label,
|
|
61
|
+
key: `${tone.id}`,
|
|
62
|
+
onSelected: onToneSelectedHandler(tone.toneId),
|
|
63
|
+
emoji: tone,
|
|
64
|
+
selectOnHover: true
|
|
65
|
+
});
|
|
66
|
+
}));
|
|
67
|
+
};
|
|
81
68
|
const ToneSelector = withAnalyticsEvents()(ToneSelectorInternal);
|
|
82
69
|
export default ToneSelector;
|
|
@@ -28,7 +28,7 @@ export const emojiToneSelectorContainer = css({
|
|
|
28
28
|
flex: 1,
|
|
29
29
|
display: 'flex',
|
|
30
30
|
justifyContent: 'flex-end',
|
|
31
|
-
padding: '
|
|
31
|
+
padding: '10px 10px 11px 0'
|
|
32
32
|
});
|
|
33
33
|
export const emojiStyles = css({
|
|
34
34
|
borderRadius: `${borderRadius()}px`,
|
|
@@ -127,8 +127,6 @@ export const hiddenToneButton = css({
|
|
|
127
127
|
display: 'none'
|
|
128
128
|
}); // Emoji Preview
|
|
129
129
|
|
|
130
|
-
export const buttons = 'emoji-common-buttons';
|
|
131
|
-
export const toneSelectorContainer = 'emoji-common-tone-selector-container';
|
|
132
130
|
export const emojiPickerAddEmoji = 'emoji-picker-add-emoji';
|
|
133
131
|
export const previewText = css({
|
|
134
132
|
display: 'flex',
|
|
@@ -172,7 +170,9 @@ export const preview = css({
|
|
|
172
170
|
display: 'flex',
|
|
173
171
|
flexDirection: 'row',
|
|
174
172
|
flexWrap: 'nowrap',
|
|
175
|
-
padding: '10px'
|
|
173
|
+
padding: '10px',
|
|
174
|
+
height: '32px',
|
|
175
|
+
alignItems: 'center'
|
|
176
176
|
});
|
|
177
177
|
export const previewImg = css({
|
|
178
178
|
display: 'inline-block',
|
|
@@ -194,11 +194,6 @@ export const previewImg = css({
|
|
|
194
194
|
padding: 0,
|
|
195
195
|
display: 'block'
|
|
196
196
|
}
|
|
197
|
-
});
|
|
198
|
-
export const emojiPreview = css({
|
|
199
|
-
display: 'flex',
|
|
200
|
-
height: '50px',
|
|
201
|
-
boxSizing: 'border-box'
|
|
202
197
|
}); // Scrollable
|
|
203
198
|
|
|
204
199
|
export const emojiScrollable = css({
|
|
@@ -380,4 +375,9 @@ export const cancelButton = css({
|
|
|
380
375
|
export const buttonSpinner = css({
|
|
381
376
|
marginRight: '10px',
|
|
382
377
|
marginLeft: '10px'
|
|
378
|
+
});
|
|
379
|
+
export const emojiActionsWrapper = css({
|
|
380
|
+
display: 'flex',
|
|
381
|
+
justifyContent: 'flex-end',
|
|
382
|
+
alignItems: 'center'
|
|
383
383
|
});
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/core';
|
|
3
|
-
import { PureComponent } from 'react';
|
|
4
3
|
import { FormattedMessage } from 'react-intl-next';
|
|
5
4
|
import { isMessagesKey } from '../../util/type-helpers';
|
|
6
5
|
import { messages } from '../i18n';
|
|
7
6
|
import { emojiCategoryTitle } from './styles';
|
|
8
|
-
export default class EmojiPickerCategoryHeading extends PureComponent {
|
|
9
|
-
render() {
|
|
10
|
-
const {
|
|
11
|
-
id,
|
|
12
|
-
title,
|
|
13
|
-
className
|
|
14
|
-
} = this.props;
|
|
15
|
-
return jsx("div", {
|
|
16
|
-
id: id,
|
|
17
|
-
"data-category-id": id,
|
|
18
|
-
className: className
|
|
19
|
-
}, jsx("div", {
|
|
20
|
-
css: emojiCategoryTitle
|
|
21
|
-
}, isMessagesKey(title) ? jsx(FormattedMessage, messages[title]) : title));
|
|
22
|
-
}
|
|
23
7
|
|
|
24
|
-
|
|
8
|
+
const EmojiPickerCategoryHeading = ({
|
|
9
|
+
id,
|
|
10
|
+
title,
|
|
11
|
+
className
|
|
12
|
+
}) => jsx("div", {
|
|
13
|
+
id: id,
|
|
14
|
+
"data-category-id": id,
|
|
15
|
+
className: className
|
|
16
|
+
}, jsx("div", {
|
|
17
|
+
css: emojiCategoryTitle
|
|
18
|
+
}, isMessagesKey(title) ? jsx(FormattedMessage, messages[title]) : title));
|
|
19
|
+
|
|
20
|
+
export default EmojiPickerCategoryHeading;
|