@atlaskit/emoji 71.0.0 → 71.0.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 +8 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/components/common/Emoji.js +2 -1
- package/dist/cjs/components/common/EmojiActions.compiled.css +8 -0
- package/dist/cjs/components/common/EmojiActions.js +69 -3
- package/dist/cjs/components/common/Popup.js +20 -5
- package/dist/cjs/components/common/ProductivityColorSelector.compiled.css +59 -0
- package/dist/cjs/components/common/ProductivityColorSelector.js +112 -0
- package/dist/cjs/components/common/TonePreviewButton.js +4 -2
- package/dist/cjs/components/i18n.js +10 -0
- package/dist/cjs/components/picker/EmojiPickerComponent.js +51 -36
- package/dist/cjs/components/picker/EmojiPickerList.js +36 -14
- package/dist/cjs/components/picker/VirtualList.js +4 -5
- package/dist/cjs/util/analytics/analytics.js +1 -1
- package/dist/cjs/util/hidden-emojis.js +33 -0
- package/dist/cjs/util/productivity-colors.js +51 -0
- package/dist/es2019/components/common/Emoji.js +2 -1
- package/dist/es2019/components/common/EmojiActions.compiled.css +8 -0
- package/dist/es2019/components/common/EmojiActions.js +67 -3
- package/dist/es2019/components/common/Popup.js +19 -5
- package/dist/es2019/components/common/ProductivityColorSelector.compiled.css +59 -0
- package/dist/es2019/components/common/ProductivityColorSelector.js +98 -0
- package/dist/es2019/components/common/TonePreviewButton.js +3 -2
- package/dist/es2019/components/i18n.js +10 -0
- package/dist/es2019/components/picker/EmojiPickerComponent.js +26 -14
- package/dist/es2019/components/picker/EmojiPickerList.js +32 -14
- package/dist/es2019/components/picker/VirtualList.js +4 -5
- package/dist/es2019/util/analytics/analytics.js +1 -1
- package/dist/es2019/util/hidden-emojis.js +25 -0
- package/dist/es2019/util/productivity-colors.js +37 -0
- package/dist/esm/components/common/Emoji.js +2 -1
- package/dist/esm/components/common/EmojiActions.compiled.css +8 -0
- package/dist/esm/components/common/EmojiActions.js +70 -4
- package/dist/esm/components/common/Popup.js +20 -5
- package/dist/esm/components/common/ProductivityColorSelector.compiled.css +59 -0
- package/dist/esm/components/common/ProductivityColorSelector.js +103 -0
- package/dist/esm/components/common/TonePreviewButton.js +4 -2
- package/dist/esm/components/i18n.js +10 -0
- package/dist/esm/components/picker/EmojiPickerComponent.js +51 -36
- package/dist/esm/components/picker/EmojiPickerList.js +36 -14
- package/dist/esm/components/picker/VirtualList.js +4 -5
- package/dist/esm/util/analytics/analytics.js +1 -1
- package/dist/esm/util/hidden-emojis.js +27 -0
- package/dist/esm/util/productivity-colors.js +45 -0
- package/dist/types/components/common/EmojiActions.d.ts +6 -0
- package/dist/types/components/common/Popup.d.ts +1 -0
- package/dist/types/components/common/ProductivityColorSelector.d.ts +17 -0
- package/dist/types/components/common/TonePreviewButton.d.ts +1 -0
- package/dist/types/components/i18n.d.ts +10 -0
- package/dist/types/components/picker/EmojiPickerList.d.ts +3 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/util/hidden-emojis.d.ts +3 -0
- package/dist/types/util/productivity-colors.d.ts +8 -0
- package/package.json +3 -2
|
@@ -2,6 +2,8 @@ import { useIntl } from 'react-intl';
|
|
|
2
2
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
4
4
|
import { customCategory, defaultEmojiPickerSize, frequentCategory, searchCategory, userCustomTitle, yourUploadsCategory } from '../../util/constants';
|
|
5
|
+
import { filterProductivityEmojisByColor, getProductivityColorPreviewEmojis } from '../../util/productivity-colors';
|
|
6
|
+
import { filterHiddenEmojis } from '../../util/hidden-emojis';
|
|
5
7
|
import { CategoryDescriptionMap, CategoryDescriptionMapNew } from './categories';
|
|
6
8
|
import CategoryTracker from './CategoryTracker';
|
|
7
9
|
import { sizes } from './EmojiPickerSizes';
|
|
@@ -62,7 +64,9 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
62
64
|
onCloseDelete,
|
|
63
65
|
onFileChooserClicked,
|
|
64
66
|
onOpenUpload,
|
|
65
|
-
|
|
67
|
+
onProductivityColorSelected,
|
|
68
|
+
activeCategoryId,
|
|
69
|
+
selectedProductivityColor
|
|
66
70
|
} = props;
|
|
67
71
|
const {
|
|
68
72
|
formatMessage
|
|
@@ -74,6 +78,8 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
74
78
|
const categoryTracker = useMemo(() => new CategoryTracker(), []);
|
|
75
79
|
const [categoriesChanged, setCategoriesChanged] = useState(false);
|
|
76
80
|
const isTeamojiExperimentEnabled = FeatureGates.getExperimentValue(teamojiRefreshExperimentName, 'isEnabled', false);
|
|
81
|
+
const visibleEmojis = useMemo(() => isTeamojiExperimentEnabled ? filterHiddenEmojis(emojis) : emojis, [emojis, isTeamojiExperimentEnabled]);
|
|
82
|
+
const productivityColorPreviewEmojis = useMemo(() => isTeamojiExperimentEnabled ? getProductivityColorPreviewEmojis(visibleEmojis) : {}, [isTeamojiExperimentEnabled, visibleEmojis]);
|
|
77
83
|
const addToCategoryMap = useCallback((categoryToGroupMap, emoji, category) => {
|
|
78
84
|
if (!categoryToGroupMap[category]) {
|
|
79
85
|
const categoryDefinition = isTeamojiExperimentEnabled ? CategoryDescriptionMapNew[category] : CategoryDescriptionMap[category];
|
|
@@ -150,16 +156,23 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
150
156
|
const buildEmojiGroupedByCategory = useCallback((emojis, currentUser) => {
|
|
151
157
|
const categoryToGroupMap = emojis.reduce(groupByCategory(currentUser), {});
|
|
152
158
|
setAllEmojiGroups(Object.keys(categoryToGroupMap).map(key => categoryToGroupMap[key]).map(group => {
|
|
153
|
-
if (
|
|
159
|
+
if (isTeamojiExperimentEnabled && selectedProductivityColor) {
|
|
154
160
|
var _group$subcategories;
|
|
155
|
-
group.emojis.
|
|
161
|
+
group.emojis = filterProductivityEmojisByColor(group.emojis, selectedProductivityColor);
|
|
156
162
|
(_group$subcategories = group.subcategories) === null || _group$subcategories === void 0 ? void 0 : _group$subcategories.forEach(subcategory => {
|
|
163
|
+
subcategory.emojis = filterProductivityEmojisByColor(subcategory.emojis, selectedProductivityColor);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (group.category !== frequentCategory) {
|
|
167
|
+
var _group$subcategories2;
|
|
168
|
+
group.emojis.sort(byOrder);
|
|
169
|
+
(_group$subcategories2 = group.subcategories) === null || _group$subcategories2 === void 0 ? void 0 : _group$subcategories2.forEach(subcategory => {
|
|
157
170
|
subcategory.emojis.sort(byOrder);
|
|
158
171
|
});
|
|
159
172
|
}
|
|
160
173
|
return group;
|
|
161
174
|
}).sort(byOrder));
|
|
162
|
-
}, [groupByCategory]);
|
|
175
|
+
}, [groupByCategory, isTeamojiExperimentEnabled, selectedProductivityColor]);
|
|
163
176
|
const buildEmojiRows = useCallback((items, category, title, emojis, showDelete) => {
|
|
164
177
|
let remainingEmojis = emojis;
|
|
165
178
|
while (remainingEmojis.length > 0) {
|
|
@@ -179,9 +192,9 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
179
192
|
}
|
|
180
193
|
}, [isTeamojiExperimentEnabled, onEmojiActive, onEmojiDelete, onEmojiLeave, onEmojiSelected]);
|
|
181
194
|
const buildVirtualItemFromGroup = useCallback(group => {
|
|
182
|
-
var _group$
|
|
195
|
+
var _group$subcategories3;
|
|
183
196
|
const items = [];
|
|
184
|
-
const hasAtlassianSubcategories = isTeamojiExperimentEnabled && group.category === atlassianCategory && !!((_group$
|
|
197
|
+
const hasAtlassianSubcategories = isTeamojiExperimentEnabled && group.category === atlassianCategory && !!((_group$subcategories3 = group.subcategories) !== null && _group$subcategories3 !== void 0 && _group$subcategories3.length);
|
|
185
198
|
if (!hasAtlassianSubcategories) {
|
|
186
199
|
items.push(new CategoryHeadingItem({
|
|
187
200
|
id: group.category,
|
|
@@ -226,7 +239,7 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
226
239
|
} else {
|
|
227
240
|
if (query) {
|
|
228
241
|
const search = isTeamojiExperimentEnabled ? CategoryDescriptionMapNew.SEARCH : CategoryDescriptionMap.SEARCH;
|
|
229
|
-
if (
|
|
242
|
+
if (visibleEmojis.length === 0 && isTeamojiExperimentEnabled) {
|
|
230
243
|
// Show a "No results" category heading, then a no-results illustration below it
|
|
231
244
|
items.push(new CategoryHeadingItem({
|
|
232
245
|
id: searchCategory,
|
|
@@ -242,7 +255,7 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
242
255
|
items = [...items, ...buildVirtualItemFromGroup({
|
|
243
256
|
category: searchCategory,
|
|
244
257
|
title: search.name,
|
|
245
|
-
emojis,
|
|
258
|
+
emojis: visibleEmojis,
|
|
246
259
|
order: search.order
|
|
247
260
|
})];
|
|
248
261
|
}
|
|
@@ -270,7 +283,7 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
270
283
|
}
|
|
271
284
|
}
|
|
272
285
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
273
|
-
}, [allEmojiGroups, buildVirtualItemFromGroup,
|
|
286
|
+
}, [allEmojiGroups, buildVirtualItemFromGroup, formatMessage, isTeamojiExperimentEnabled, loading, onOpenUpload, query, uploadEnabled, visibleEmojis]);
|
|
274
287
|
const findCategoryToActivate = row => {
|
|
275
288
|
let category = null;
|
|
276
289
|
if (row instanceof CategoryHeadingItem) {
|
|
@@ -364,9 +377,9 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
364
377
|
});
|
|
365
378
|
useEffect(() => {
|
|
366
379
|
if (!query) {
|
|
367
|
-
buildEmojiGroupedByCategory(
|
|
380
|
+
buildEmojiGroupedByCategory(visibleEmojis, currentUser);
|
|
368
381
|
}
|
|
369
|
-
}, [
|
|
382
|
+
}, [visibleEmojis, selectedTone, selectedProductivityColor, loading, query, currentUser, buildEmojiGroupedByCategory]);
|
|
370
383
|
useEffect(() => {
|
|
371
384
|
buildVirtualItems();
|
|
372
385
|
}, [allEmojiGroups, buildVirtualItems]);
|
|
@@ -375,16 +388,17 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
375
388
|
onRowsRendered({
|
|
376
389
|
startIndex: 0
|
|
377
390
|
});
|
|
391
|
+
setCategoriesChanged(false);
|
|
378
392
|
}
|
|
379
393
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
380
394
|
}, [virtualItems, categoriesChanged]);
|
|
381
395
|
const virtualListHeight = useMemo(() => {
|
|
382
|
-
if (query &&
|
|
396
|
+
if (query && visibleEmojis.length === 0 && isTeamojiExperimentEnabled) {
|
|
383
397
|
// No-results state: expand the list height to fit heading + illustration without scrolling
|
|
384
398
|
return sizes.categoryHeadingHeight + sizes.noResultsHeight + emojiPickerHeightOffset(size);
|
|
385
399
|
}
|
|
386
400
|
return isTeamojiExperimentEnabled ? sizes.listHeightNew + emojiPickerHeightOffset(size) : sizes.listHeight + emojiPickerHeightOffset(size);
|
|
387
|
-
}, [size, query,
|
|
401
|
+
}, [size, query, visibleEmojis.length, isTeamojiExperimentEnabled]);
|
|
388
402
|
return /*#__PURE__*/React.createElement(EmojiPickerTabPanel, {
|
|
389
403
|
showSearchResults: !!query
|
|
390
404
|
}, /*#__PURE__*/React.createElement(EmojiActions, {
|
|
@@ -392,6 +406,9 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
392
406
|
onToneSelected: onToneSelected,
|
|
393
407
|
onToneSelectorCancelled: onToneSelectorCancelled,
|
|
394
408
|
toneEmoji: toneEmoji,
|
|
409
|
+
activeCategoryId: isTeamojiExperimentEnabled ? activeCategoryId : undefined,
|
|
410
|
+
productivityColorPreviewEmojis: isTeamojiExperimentEnabled ? productivityColorPreviewEmojis : undefined,
|
|
411
|
+
selectedProductivityColor: isTeamojiExperimentEnabled ? selectedProductivityColor : undefined,
|
|
395
412
|
uploading: uploading,
|
|
396
413
|
uploadEnabled: uploadEnabled,
|
|
397
414
|
emojiToDelete: emojiToDelete,
|
|
@@ -403,9 +420,10 @@ export const EmojiPickerVirtualListInternal = /*#__PURE__*/React.forwardRef((pro
|
|
|
403
420
|
onDeleteEmoji: onDeleteEmoji,
|
|
404
421
|
onFileChooserClicked: onFileChooserClicked,
|
|
405
422
|
onOpenUpload: onOpenUpload,
|
|
423
|
+
onProductivityColorSelected: isTeamojiExperimentEnabled ? onProductivityColorSelected : undefined,
|
|
406
424
|
query: query,
|
|
407
425
|
onChange: onSearch,
|
|
408
|
-
resultsCount:
|
|
426
|
+
resultsCount: visibleEmojis.length
|
|
409
427
|
}), /*#__PURE__*/React.createElement(EmojiPickerListContextProvider, {
|
|
410
428
|
initialEmojisFocus: {
|
|
411
429
|
rowIndex: 1,
|
|
@@ -5,6 +5,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
5
5
|
import React, { useCallback, useImperativeHandle } from 'react';
|
|
6
6
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
8
9
|
import { useEmojiPickerListContext } from '../../hooks/useEmojiPickerListContext';
|
|
9
10
|
import { EMOJIPICKERLIST_KEYBOARD_KEYS_SUPPORTED, EMOJI_LIST_COLUMNS, EMOJI_LIST_PAGE_COUNT, KeyboardNavigationDirection, KeyboardKeys } from '../../util/constants';
|
|
10
11
|
const virtualList = null;
|
|
@@ -55,13 +56,11 @@ export const VirtualList = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
55
56
|
const elemBottom = elementRect.bottom;
|
|
56
57
|
const parentTop = parentRect.top;
|
|
57
58
|
const parentBottom = parentRect.bottom;
|
|
58
|
-
|
|
59
|
-
// Only completely visible elements return true:
|
|
60
|
-
const isVisible = elemTop >= parentTop && elemBottom <= parentBottom;
|
|
59
|
+
const isVisible = FeatureGates.getExperimentValue('platform_teamoji_26_refresh_emoji_picker', 'isEnabled', false) ? elemTop >= parentTop && elemBottom <= parentBottom : elemBottom > parentTop && elemTop < parentBottom;
|
|
61
60
|
return isVisible;
|
|
62
61
|
};
|
|
63
62
|
const getFirstVisibleListElementIndex = useCallback(() => {
|
|
64
|
-
var _parentRef$current, _parentRef$current$fi
|
|
63
|
+
var _parentRef$current, _parentRef$current$fi, _virtualList$;
|
|
65
64
|
const virtualList = rowVirtualizer.getVirtualItems();
|
|
66
65
|
const renderedElements = (_parentRef$current = parentRef.current) === null || _parentRef$current === void 0 ? void 0 : (_parentRef$current$fi = _parentRef$current.firstChild) === null || _parentRef$current$fi === void 0 ? void 0 : _parentRef$current$fi.childNodes;
|
|
67
66
|
if (virtualList.length === 0 || !renderedElements || renderedElements.length === 0) {
|
|
@@ -74,7 +73,7 @@ export const VirtualList = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
74
73
|
var _virtualList$firstVis;
|
|
75
74
|
return ((_virtualList$firstVis = virtualList[firstVisibleIndex]) === null || _virtualList$firstVis === void 0 ? void 0 : _virtualList$firstVis.index) || 0;
|
|
76
75
|
}
|
|
77
|
-
return 0;
|
|
76
|
+
return FeatureGates.getExperimentValue('platform_teamoji_26_refresh_emoji_picker', 'isEnabled', false) ? ((_virtualList$ = virtualList[0]) === null || _virtualList$ === void 0 ? void 0 : _virtualList$.index) || 0 : 0;
|
|
78
77
|
}, [rowVirtualizer]);
|
|
79
78
|
|
|
80
79
|
/**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const hasHiddenTag = tags => {
|
|
2
|
+
var _tags$includes;
|
|
3
|
+
return (_tags$includes = tags === null || tags === void 0 ? void 0 : tags.includes('hidden')) !== null && _tags$includes !== void 0 ? _tags$includes : false;
|
|
4
|
+
};
|
|
5
|
+
const hasHiddenMetadataTag = emoji => {
|
|
6
|
+
const emojiWithMetadata = emoji;
|
|
7
|
+
const {
|
|
8
|
+
metadata
|
|
9
|
+
} = emojiWithMetadata;
|
|
10
|
+
if (typeof metadata === 'string') {
|
|
11
|
+
return metadata === 'hidden';
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(metadata)) {
|
|
14
|
+
return hasHiddenTag(metadata);
|
|
15
|
+
}
|
|
16
|
+
return hasHiddenTag(metadata === null || metadata === void 0 ? void 0 : metadata.tags) || hasHiddenTag(emojiWithMetadata.tags);
|
|
17
|
+
};
|
|
18
|
+
export const isHiddenEmoji = emoji => {
|
|
19
|
+
const emojiWithMetadata = emoji;
|
|
20
|
+
if (emojiWithMetadata.hidden) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return hasHiddenMetadataTag(emoji);
|
|
24
|
+
};
|
|
25
|
+
export const filterHiddenEmojis = emojis => emojis.filter(emoji => !isHiddenEmoji(emoji));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const productivityColors = ['gray', 'magenta', 'purple', 'blue', 'teal', 'green', 'lime', 'yellow', 'orange', 'red'];
|
|
2
|
+
const productivityColorSet = new Set(productivityColors);
|
|
3
|
+
const zeroSquareVariantParent = '0_zero_square_blue';
|
|
4
|
+
export const defaultProductivityColor = 'blue';
|
|
5
|
+
const getProductivityVariant = emoji => {
|
|
6
|
+
if (emoji.type !== 'ATLASSIAN' || !emoji.color || !productivityColorSet.has(emoji.color)) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
color: emoji.color
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const getProductivityColor = emoji => {
|
|
14
|
+
var _getProductivityVaria;
|
|
15
|
+
return (_getProductivityVaria = getProductivityVariant(emoji)) === null || _getProductivityVaria === void 0 ? void 0 : _getProductivityVaria.color;
|
|
16
|
+
};
|
|
17
|
+
export const isProductivityNumberEmoji = emoji => getProductivityColor(emoji) !== undefined;
|
|
18
|
+
export const filterProductivityEmojisByColor = (emojis, selectedColor) => {
|
|
19
|
+
return emojis.filter(emoji => {
|
|
20
|
+
const variant = getProductivityVariant(emoji);
|
|
21
|
+
return !variant || variant.color === selectedColor;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const isZeroSquareProductivityEmoji = emoji => {
|
|
25
|
+
var _emoji$variantChildre, _emoji$keywords, _emoji$variantChildre2;
|
|
26
|
+
return emoji.variantParent === zeroSquareVariantParent || ((_emoji$variantChildre = emoji.variantChildren) === null || _emoji$variantChildre === void 0 ? void 0 : _emoji$variantChildre.some(variantChild => variantChild.includes('0_zero_square_'))) || !!(emoji.variantBase && (_emoji$keywords = emoji.keywords) !== null && _emoji$keywords !== void 0 && _emoji$keywords.includes('0') && (_emoji$variantChildre2 = emoji.variantChildren) !== null && _emoji$variantChildre2 !== void 0 && _emoji$variantChildre2.some(variantChild => variantChild.includes('_square_')));
|
|
27
|
+
};
|
|
28
|
+
export const getProductivityColorPreviewEmojis = emojis => emojis.reduce((previewEmojis, emoji) => {
|
|
29
|
+
const color = getProductivityColor(emoji);
|
|
30
|
+
if (!color) {
|
|
31
|
+
return previewEmojis;
|
|
32
|
+
}
|
|
33
|
+
if (isZeroSquareProductivityEmoji(emoji) || !previewEmojis[color]) {
|
|
34
|
+
previewEmojis[color] = emoji;
|
|
35
|
+
}
|
|
36
|
+
return previewEmojis;
|
|
37
|
+
}, {});
|
|
@@ -332,6 +332,7 @@ export var ImageEmoji = function ImageEmoji(props) {
|
|
|
332
332
|
);
|
|
333
333
|
};
|
|
334
334
|
export var EmojiNodeWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
335
|
+
var _emoji$name;
|
|
335
336
|
var emoji = props.emoji,
|
|
336
337
|
fitToHeight = props.fitToHeight,
|
|
337
338
|
selected = props.selected,
|
|
@@ -356,7 +357,7 @@ export var EmojiNodeWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
356
357
|
other = _objectWithoutProperties(props, _excluded);
|
|
357
358
|
var intl = useContext(IntlContext);
|
|
358
359
|
var ariaLabel = intl && fg('platform_change_emoji_button_label') ? intl.formatMessage(messages.changeEmojiShortnameButtonLabel, {
|
|
359
|
-
shortName: emoji.shortName
|
|
360
|
+
shortName: (_emoji$name = emoji.name) !== null && _emoji$name !== void 0 ? _emoji$name : emoji.shortName
|
|
360
361
|
}) : editorEmoji ? undefined : emoji.shortName;
|
|
361
362
|
return /*#__PURE__*/React.createElement("span", _extends({
|
|
362
363
|
role: editorEmoji ? undefined : shouldBeInteractive ? 'button' : ariaLabel ? 'img' : 'presentation',
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
|
|
2
|
+
._19itia51{border:var(--ds-border-width,1px) solid var(--ds-border,#0b120e24)}
|
|
3
|
+
._2rkofajl{border-radius:var(--ds-radius-small,3px)}
|
|
2
4
|
._n7zl1uh4{border-bottom:var(--ds-border-width-selected,2px) solid var(--ds-border,#0b120e24)}._16jlidpf{flex-grow:0}
|
|
3
5
|
._16jlkb7n{flex-grow:1}
|
|
6
|
+
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
4
7
|
._16qsjgpa{box-shadow:0 1px 1px 0 var(--ds-border,#0b120e24)}
|
|
5
8
|
._18u019bv{margin-left:10px}
|
|
6
9
|
._18u0r5cr{margin-left:var(--ds-space-negative-050,-4px)}
|
|
10
|
+
._19bv12x7{padding-left:var(--ds-space-075,6px)}
|
|
7
11
|
._19bvidpf{padding-left:0}
|
|
8
12
|
._1bahesu3{justify-content:flex-end}
|
|
9
13
|
._1e0c1txw{display:flex}
|
|
@@ -12,10 +16,14 @@
|
|
|
12
16
|
._1wpz1h6o{align-self:center}
|
|
13
17
|
._2hwx1i6y{margin-right:var(--ds-space-negative-025,-2px)}
|
|
14
18
|
._4cvr1h6o{align-items:center}
|
|
19
|
+
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
20
|
+
._ca0q12x7{padding-top:var(--ds-space-075,6px)}
|
|
15
21
|
._ca0q1skh{padding-top:11px}
|
|
16
22
|
._i0dl1wug{flex-basis:auto}
|
|
17
23
|
._i0dlf1ug{flex-basis:0%}
|
|
24
|
+
._n3td12x7{padding-bottom:var(--ds-space-075,6px)}
|
|
18
25
|
._n3td1crf{padding-bottom:9pt}
|
|
19
26
|
._otyr19bv{margin-bottom:10px}
|
|
20
27
|
._p12f3sup{max-width:285px}
|
|
28
|
+
._u5f312x7{padding-right:var(--ds-space-075,6px)}
|
|
21
29
|
._u5f319bv{padding-right:10px}
|
|
@@ -4,13 +4,15 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
4
4
|
import "./EmojiActions.compiled.css";
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
-
import { Fragment, useState, useRef, memo, useLayoutEffect, useCallback } from 'react';
|
|
7
|
+
import { Fragment, useState, useRef, memo, useLayoutEffect, useCallback, useEffect } from 'react';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
|
10
10
|
import EmojiDeletePreview from './EmojiDeletePreview';
|
|
11
11
|
import EmojiUploadPicker from './EmojiUploadPicker';
|
|
12
12
|
import TonePreviewButton from './TonePreviewButton';
|
|
13
13
|
import ToneSelector from './ToneSelector';
|
|
14
|
+
import ProductivityColorSelector, { productivityColorSelectorId } from './ProductivityColorSelector';
|
|
15
|
+
import Popup from './Popup';
|
|
14
16
|
import { EmojiPickerListSearch } from '../picker/EmojiPickerListSearch';
|
|
15
17
|
import { messages } from '../i18n';
|
|
16
18
|
import AkButton from '@atlaskit/button/standard-button';
|
|
@@ -27,6 +29,7 @@ var addCustomEmoji = null;
|
|
|
27
29
|
var addCustomEmojiButton = null;
|
|
28
30
|
var emojiActionsWrapper = null;
|
|
29
31
|
var emojiToneSelectorContainer = null;
|
|
32
|
+
var productivityColorPopup = null;
|
|
30
33
|
var previewFooter = null;
|
|
31
34
|
var previewFooterNew = null;
|
|
32
35
|
export var emojiActionsTestId = 'emoji-actions';
|
|
@@ -68,11 +71,17 @@ export var AddOwnEmoji = function AddOwnEmoji(props) {
|
|
|
68
71
|
})));
|
|
69
72
|
};
|
|
70
73
|
var TonesWrapper = function TonesWrapper(props) {
|
|
71
|
-
var
|
|
74
|
+
var activeCategoryId = props.activeCategoryId,
|
|
75
|
+
onProductivityColorSelected = props.onProductivityColorSelected,
|
|
76
|
+
productivityColorPreviewEmojis = props.productivityColorPreviewEmojis,
|
|
77
|
+
selectedProductivityColor = props.selectedProductivityColor,
|
|
78
|
+
toneEmoji = props.toneEmoji,
|
|
72
79
|
_props$selectedTone = props.selectedTone,
|
|
73
80
|
selectedTone = _props$selectedTone === void 0 ? DEFAULT_TONE : _props$selectedTone,
|
|
74
81
|
intl = props.intl,
|
|
82
|
+
onToneClose = props.onToneClose,
|
|
75
83
|
onToneOpen = props.onToneOpen,
|
|
84
|
+
onToneToggle = props.onToneToggle,
|
|
76
85
|
showToneSelector = props.showToneSelector;
|
|
77
86
|
var formatMessage = intl.formatMessage;
|
|
78
87
|
var tonePreviewButtonRef = useRef(null);
|
|
@@ -99,6 +108,41 @@ var TonesWrapper = function TonesWrapper(props) {
|
|
|
99
108
|
onToneSelected(toneValue);
|
|
100
109
|
setFocusTonePreviewButton(true);
|
|
101
110
|
}, [props]);
|
|
111
|
+
var onProductivityColorSelectedHandler = useCallback(function (color) {
|
|
112
|
+
onProductivityColorSelected === null || onProductivityColorSelected === void 0 || onProductivityColorSelected(color);
|
|
113
|
+
onToneClose();
|
|
114
|
+
setFocusTonePreviewButton(true);
|
|
115
|
+
}, [onProductivityColorSelected, onToneClose]);
|
|
116
|
+
var shouldShowProductivityColorSelector = !!(activeCategoryId === 'ATLASSIAN' && productivityColorPreviewEmojis && selectedProductivityColor && onProductivityColorSelected && FeatureGates.getExperimentValue('platform_teamoji_26_refresh_emoji_picker', 'isEnabled', false));
|
|
117
|
+
if (shouldShowProductivityColorSelector) {
|
|
118
|
+
var previewEmoji = (productivityColorPreviewEmojis === null || productivityColorPreviewEmojis === void 0 ? void 0 : productivityColorPreviewEmojis[selectedProductivityColor]) || Object.values(productivityColorPreviewEmojis || {})[0];
|
|
119
|
+
if (!previewEmoji) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
123
|
+
className: ax(["_16jlkb7n _1o9zkb7n _i0dlf1ug _ca0q1skh _u5f319bv _n3td1crf _19bvidpf _1e0c1txw _1bahesu3"])
|
|
124
|
+
}, showToneSelector && tonePreviewButtonRef.current && /*#__PURE__*/React.createElement(Popup, {
|
|
125
|
+
target: tonePreviewButtonRef.current,
|
|
126
|
+
relativePosition: "below",
|
|
127
|
+
horizontalAlign: "end-to-start",
|
|
128
|
+
offsetY: 4,
|
|
129
|
+
zIndex: 510
|
|
130
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: ax(["_19itia51 _2rkofajl _bfhk1bhr _16qs130s _ca0q12x7 _u5f312x7 _n3td12x7 _19bv12x7"])
|
|
132
|
+
}, /*#__PURE__*/React.createElement(ProductivityColorSelector, {
|
|
133
|
+
colorPreviewEmojis: productivityColorPreviewEmojis,
|
|
134
|
+
selectedColor: selectedProductivityColor,
|
|
135
|
+
onColorSelected: onProductivityColorSelectedHandler
|
|
136
|
+
}))), /*#__PURE__*/React.createElement(TonePreviewButton, {
|
|
137
|
+
ref: tonePreviewButtonRef,
|
|
138
|
+
ariaControls: productivityColorSelectorId,
|
|
139
|
+
ariaExpanded: showToneSelector,
|
|
140
|
+
emoji: previewEmoji,
|
|
141
|
+
selectOnHover: true,
|
|
142
|
+
onSelected: onToneToggle,
|
|
143
|
+
ariaLabelText: formatMessage(messages.emojiSelectColorButtonAriaLabelText)
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
102
146
|
if (!toneEmoji) {
|
|
103
147
|
return null;
|
|
104
148
|
}
|
|
@@ -147,12 +191,19 @@ export var EmojiActions = function EmojiActions(props) {
|
|
|
147
191
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
148
192
|
showToneSelector = _useState4[0],
|
|
149
193
|
setShowToneSelector = _useState4[1];
|
|
194
|
+
var wasProductivityColorSelectorOpen = useRef(false);
|
|
195
|
+
var shouldUseProductivityColorControl = !!(props.activeCategoryId === 'ATLASSIAN' && props.productivityColorPreviewEmojis && props.selectedProductivityColor && props.onProductivityColorSelected && FeatureGates.getExperimentValue('platform_teamoji_26_refresh_emoji_picker', 'isEnabled', false));
|
|
150
196
|
var onToneOpenHandler = useCallback(function () {
|
|
151
197
|
return setShowToneSelector(true);
|
|
152
198
|
}, []);
|
|
153
199
|
var onToneCloseHandler = useCallback(function () {
|
|
154
200
|
return setShowToneSelector(false);
|
|
155
201
|
}, []);
|
|
202
|
+
var onToneToggleHandler = useCallback(function () {
|
|
203
|
+
setShowToneSelector(function (isOpen) {
|
|
204
|
+
return !isOpen;
|
|
205
|
+
});
|
|
206
|
+
}, []);
|
|
156
207
|
var onToneSelectedHandler = useCallback(function (toneValue) {
|
|
157
208
|
setShowToneSelector(false);
|
|
158
209
|
if (onToneSelected) {
|
|
@@ -160,11 +211,24 @@ export var EmojiActions = function EmojiActions(props) {
|
|
|
160
211
|
}
|
|
161
212
|
}, [onToneSelected]);
|
|
162
213
|
var onMouseLeaveHandler = useCallback(function () {
|
|
214
|
+
if (shouldUseProductivityColorControl) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
163
217
|
if (showToneSelector && onToneSelectorCancelled) {
|
|
164
218
|
onToneSelectorCancelled();
|
|
165
219
|
}
|
|
166
220
|
setShowToneSelector(false);
|
|
167
|
-
}, [showToneSelector, onToneSelectorCancelled]);
|
|
221
|
+
}, [shouldUseProductivityColorControl, showToneSelector, onToneSelectorCancelled]);
|
|
222
|
+
useEffect(function () {
|
|
223
|
+
if (shouldUseProductivityColorControl && showToneSelector) {
|
|
224
|
+
wasProductivityColorSelectorOpen.current = true;
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (!shouldUseProductivityColorControl && wasProductivityColorSelectorOpen.current) {
|
|
228
|
+
setShowToneSelector(false);
|
|
229
|
+
wasProductivityColorSelectorOpen.current = false;
|
|
230
|
+
}
|
|
231
|
+
}, [shouldUseProductivityColorControl, showToneSelector]);
|
|
168
232
|
if (uploading) {
|
|
169
233
|
return FeatureGates.getExperimentValue('platform_teamoji_26_refresh_emoji_picker', 'isEnabled', false) ? /*#__PURE__*/React.createElement("div", {
|
|
170
234
|
className: ax(["_16jlidpf _1o9zidpf _i0dl1wug"])
|
|
@@ -210,11 +274,12 @@ export var EmojiActions = function EmojiActions(props) {
|
|
|
210
274
|
onChange: onChange,
|
|
211
275
|
query: query,
|
|
212
276
|
resultsCount: resultsCount,
|
|
213
|
-
isVisible: !showToneSelector
|
|
277
|
+
isVisible: !showToneSelector || shouldUseProductivityColorControl
|
|
214
278
|
}), /*#__PURE__*/React.createElement(TonesWrapper, _extends({}, props, {
|
|
215
279
|
onToneOpen: onToneOpenHandler,
|
|
216
280
|
onToneClose: onToneCloseHandler,
|
|
217
281
|
onToneSelected: onToneSelectedHandler,
|
|
282
|
+
onToneToggle: onToneToggleHandler,
|
|
218
283
|
showToneSelector: showToneSelector
|
|
219
284
|
})))) : /*#__PURE__*/React.createElement("div", {
|
|
220
285
|
"data-testid": emojiActionsTestId,
|
|
@@ -232,6 +297,7 @@ export var EmojiActions = function EmojiActions(props) {
|
|
|
232
297
|
onToneOpen: onToneOpenHandler,
|
|
233
298
|
onToneClose: onToneCloseHandler,
|
|
234
299
|
onToneSelected: onToneSelectedHandler,
|
|
300
|
+
onToneToggle: onToneToggleHandler,
|
|
235
301
|
showToneSelector: showToneSelector
|
|
236
302
|
}))), /*#__PURE__*/React.createElement(AddOwnEmoji, props));
|
|
237
303
|
};
|
|
@@ -11,6 +11,8 @@ var getTargetNode = function getTargetNode(target) {
|
|
|
11
11
|
var Popup = function Popup(props) {
|
|
12
12
|
var _props$relativePositi = props.relativePosition,
|
|
13
13
|
relativePosition = _props$relativePositi === void 0 ? 'auto' : _props$relativePositi,
|
|
14
|
+
_props$horizontalAlig = props.horizontalAlign,
|
|
15
|
+
horizontalAlign = _props$horizontalAlig === void 0 ? 'start' : _props$horizontalAlig,
|
|
14
16
|
_props$offsetX = props.offsetX,
|
|
15
17
|
offsetX = _props$offsetX === void 0 ? 0 : _props$offsetX,
|
|
16
18
|
_props$offsetY = props.offsetY,
|
|
@@ -24,17 +26,27 @@ var Popup = function Popup(props) {
|
|
|
24
26
|
_useState2 = _slicedToArray(_useState, 2),
|
|
25
27
|
debounced = _useState2[0],
|
|
26
28
|
setDebounced = _useState2[1];
|
|
29
|
+
var getLeftPosition = useCallback(function (box) {
|
|
30
|
+
if (horizontalAlign === 'end-to-start') {
|
|
31
|
+
return box.left - 152;
|
|
32
|
+
}
|
|
33
|
+
if (horizontalAlign === 'end') {
|
|
34
|
+
var _popup$current;
|
|
35
|
+
return box.right - (((_popup$current = popup.current) === null || _popup$current === void 0 ? void 0 : _popup$current.offsetWidth) || 0) + (offsetX || 0);
|
|
36
|
+
}
|
|
37
|
+
return box.left + (offsetX || 0);
|
|
38
|
+
}, [horizontalAlign, offsetX]);
|
|
27
39
|
var applyBelowPosition = useCallback(function () {
|
|
28
40
|
var targetNode = getTargetNode(target);
|
|
29
41
|
if (targetNode && popup.current) {
|
|
30
42
|
var box = targetNode.getBoundingClientRect();
|
|
31
43
|
var top = box.bottom + (offsetY || 0);
|
|
32
|
-
var left = box
|
|
44
|
+
var left = getLeftPosition(box);
|
|
33
45
|
popup.current.style.top = "".concat(top, "px");
|
|
34
46
|
popup.current.style.bottom = '';
|
|
35
47
|
popup.current.style.left = "".concat(left, "px");
|
|
36
48
|
}
|
|
37
|
-
}, [
|
|
49
|
+
}, [getLeftPosition, offsetY, target]);
|
|
38
50
|
var applyAbovePosition = useCallback(function () {
|
|
39
51
|
if (typeof window === 'undefined') {
|
|
40
52
|
return;
|
|
@@ -43,12 +55,12 @@ var Popup = function Popup(props) {
|
|
|
43
55
|
if (targetNode && popup.current) {
|
|
44
56
|
var box = targetNode.getBoundingClientRect();
|
|
45
57
|
var bottom = window.innerHeight - box.top + (offsetY || 0);
|
|
46
|
-
var left = box
|
|
58
|
+
var left = getLeftPosition(box);
|
|
47
59
|
popup.current.style.top = '';
|
|
48
60
|
popup.current.style.bottom = "".concat(bottom, "px");
|
|
49
61
|
popup.current.style.left = "".concat(left, "px");
|
|
50
62
|
}
|
|
51
|
-
}, [
|
|
63
|
+
}, [getLeftPosition, offsetY, target]);
|
|
52
64
|
var applyAbsolutePosition = useCallback(function () {
|
|
53
65
|
if (typeof window === 'undefined') {
|
|
54
66
|
return;
|
|
@@ -103,6 +115,9 @@ var Popup = function Popup(props) {
|
|
|
103
115
|
}
|
|
104
116
|
applyAbsolutePosition();
|
|
105
117
|
renderPopup();
|
|
118
|
+
if (horizontalAlign !== 'start') {
|
|
119
|
+
applyAbsolutePosition();
|
|
120
|
+
}
|
|
106
121
|
return function () {
|
|
107
122
|
if (typeof window === 'undefined') {
|
|
108
123
|
return;
|
|
@@ -113,7 +128,7 @@ var Popup = function Popup(props) {
|
|
|
113
128
|
document.body.removeChild(popup.current);
|
|
114
129
|
}
|
|
115
130
|
};
|
|
116
|
-
}, [applyAbsolutePosition, handleResize, renderPopup]);
|
|
131
|
+
}, [applyAbsolutePosition, handleResize, horizontalAlign, renderPopup]);
|
|
117
132
|
return /*#__PURE__*/React.createElement("div", null);
|
|
118
133
|
};
|
|
119
134
|
export default Popup;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
._1355fajl input+span{border-radius:var(--ds-radius-small,3px)}
|
|
3
|
+
._19itidpf{border:0}
|
|
4
|
+
._zulp1b66{gap:var(--ds-space-050,4px)}._1030zwfg input+span{height:2pc}
|
|
5
|
+
._12hvze3t input{margin-right:var(--ds-space-0,0)}
|
|
6
|
+
._12ultlke input{cursor:pointer}
|
|
7
|
+
._13yj1o36 input:focus+span{outline-width:medium}
|
|
8
|
+
._17muzwfg label{height:2pc}
|
|
9
|
+
._18m915vq{overflow-y:hidden}
|
|
10
|
+
._18u0ze3t{margin-left:var(--ds-space-0,0)}
|
|
11
|
+
._19bvidpf{padding-left:0}
|
|
12
|
+
._19pkze3t{margin-top:var(--ds-space-0,0)}
|
|
13
|
+
._1bah1h6o{justify-content:center}
|
|
14
|
+
._1bsbt94y{width:1px}
|
|
15
|
+
._1bsbzwfg{width:2pc}
|
|
16
|
+
._1e0c11p5{display:grid}
|
|
17
|
+
._1e0c1txw{display:flex}
|
|
18
|
+
._1e7sidpf input{opacity:0}
|
|
19
|
+
._1eq11h6o label{align-items:center}
|
|
20
|
+
._1nn0kb7n input{z-index:1}
|
|
21
|
+
._1p1fzwfg label{width:2pc}
|
|
22
|
+
._1pi91y54 input:focus+span{box-shadow:0 0 0 2px var(--ds-border-focused,#4688ec)}
|
|
23
|
+
._1reo15vq{overflow-x:hidden}
|
|
24
|
+
._1rgfze3t input{margin-left:var(--ds-space-0,0)}
|
|
25
|
+
._1rgq13zc input:focus+span{transition-duration:0s,.2s}
|
|
26
|
+
._1ul9idpf{min-width:0}
|
|
27
|
+
._1vzltlke label{cursor:pointer}
|
|
28
|
+
._1wqq1h6o label{justify-content:center}
|
|
29
|
+
._2hwxze3t{margin-right:var(--ds-space-0,0)}
|
|
30
|
+
._2x4gze3t input{margin-top:var(--ds-space-0,0)}
|
|
31
|
+
._2z051y6t{grid-template-rows:repeat(2,2pc)}
|
|
32
|
+
._4cvr1h6o{align-items:center}
|
|
33
|
+
._4t3it94y{height:1px}
|
|
34
|
+
._4t3izwfg{height:2pc}
|
|
35
|
+
._5hv9zwfg input{width:2pc}
|
|
36
|
+
._6rawzwfg input+span{width:2pc}
|
|
37
|
+
._6vsr1h6o input+span{justify-content:center}
|
|
38
|
+
._7kzvidpf input+span{padding-inline-end:0}
|
|
39
|
+
._8qdiidpf input+span{padding-block-start:0}
|
|
40
|
+
._ca0qidpf{padding-top:0}
|
|
41
|
+
._ecyuidpf input+span{padding-block-end:0}
|
|
42
|
+
._ev8ridpf input+span{padding-inline-start:0}
|
|
43
|
+
._hxs6glyw input:focus+span{outline-style:none}
|
|
44
|
+
._khufstnw input{position:absolute}
|
|
45
|
+
._kqswh2mm{position:relative}
|
|
46
|
+
._kqswstnw{position:absolute}
|
|
47
|
+
._n3tdidpf{padding-bottom:0}
|
|
48
|
+
._ngzz1txw input+span{display:flex}
|
|
49
|
+
._o5721q9c{white-space:nowrap}
|
|
50
|
+
._ogtohxbz{clip:rect(0 0 0 0)}
|
|
51
|
+
._otyrze3t{margin-bottom:var(--ds-space-0,0)}
|
|
52
|
+
._pytkzwfg input{height:2pc}
|
|
53
|
+
._smb7plhp input:hover+span{background-color:var(--ds-background-neutral-hovered,#0b120e24)}
|
|
54
|
+
._soq51h6o input+span{align-items:center}
|
|
55
|
+
._szw2w5lj input:checked+span{box-shadow:0 0 0 2px var(--ds-border-selected,#1868db)}
|
|
56
|
+
._tnsm1r31 input:focus+span{outline-color:currentColor}
|
|
57
|
+
._u5f3idpf{padding-right:0}
|
|
58
|
+
._x5bdze3t input{margin-bottom:var(--ds-space-0,0)}
|
|
59
|
+
._yv0e1bbt{grid-template-columns:repeat(5,2pc)}
|