@atlaskit/emoji 72.5.18 → 73.0.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/api/EmojiResource.js +0 -28
  3. package/dist/cjs/api/EmojiUtils.js +1 -8
  4. package/dist/cjs/api/denormaliseEmojiServiceResponse.js +2 -2
  5. package/dist/cjs/api/denormaliseSkinEmoji.js +2 -2
  6. package/dist/cjs/components/common/CachingMediaEmoji.js +1 -2
  7. package/dist/cjs/components/common/Emoji.js +4 -17
  8. package/dist/cjs/components/common/EmojiPreviewComponent.js +1 -4
  9. package/dist/cjs/components/common/EmojiRadioButton.js +1 -4
  10. package/dist/cjs/components/common/ResourcedEmojiComponent.js +4 -39
  11. package/dist/cjs/components/common/TonePreviewButton.js +2 -6
  12. package/dist/cjs/components/picker/EmojiPickerEmojiRow.js +0 -3
  13. package/dist/cjs/util/analytics/createEvent.js +1 -1
  14. package/dist/cjs/util/type-helpers.js +0 -7
  15. package/dist/es2019/api/EmojiResource.js +0 -28
  16. package/dist/es2019/api/EmojiUtils.js +1 -5
  17. package/dist/es2019/api/denormaliseEmojiServiceResponse.js +2 -2
  18. package/dist/es2019/api/denormaliseSkinEmoji.js +2 -2
  19. package/dist/es2019/components/common/CachingMediaEmoji.js +1 -2
  20. package/dist/es2019/components/common/Emoji.js +3 -16
  21. package/dist/es2019/components/common/EmojiPreviewComponent.js +1 -4
  22. package/dist/es2019/components/common/EmojiRadioButton.js +1 -4
  23. package/dist/es2019/components/common/ResourcedEmojiComponent.js +4 -38
  24. package/dist/es2019/components/common/TonePreviewButton.js +2 -6
  25. package/dist/es2019/components/picker/EmojiPickerEmojiRow.js +0 -3
  26. package/dist/es2019/util/analytics/createEvent.js +1 -1
  27. package/dist/es2019/util/type-helpers.js +0 -4
  28. package/dist/esm/api/EmojiResource.js +0 -28
  29. package/dist/esm/api/EmojiUtils.js +1 -5
  30. package/dist/esm/api/denormaliseEmojiServiceResponse.js +2 -2
  31. package/dist/esm/api/denormaliseSkinEmoji.js +2 -2
  32. package/dist/esm/components/common/CachingMediaEmoji.js +1 -2
  33. package/dist/esm/components/common/Emoji.js +4 -17
  34. package/dist/esm/components/common/EmojiPreviewComponent.js +1 -4
  35. package/dist/esm/components/common/EmojiRadioButton.js +1 -4
  36. package/dist/esm/components/common/ResourcedEmojiComponent.js +5 -40
  37. package/dist/esm/components/common/TonePreviewButton.js +2 -6
  38. package/dist/esm/components/picker/EmojiPickerEmojiRow.js +0 -3
  39. package/dist/esm/util/analytics/createEvent.js +1 -1
  40. package/dist/esm/util/type-helpers.js +0 -4
  41. package/dist/types/api/EmojiResource.d.ts +0 -6
  42. package/dist/types/api/EmojiUtils.d.ts +0 -4
  43. package/dist/types/components/common/Emoji.d.ts +1 -7
  44. package/dist/types/components/common/ResourcedEmojiComponent.d.ts +1 -6
  45. package/dist/types/types.d.ts +1 -15
  46. package/dist/types/util/type-helpers.d.ts +0 -4
  47. package/package.json +5 -5
  48. package/dist/cjs/api/denormaliseStandardRepresentation.js +0 -17
  49. package/dist/cjs/components/common/UnicodeEmoji.js +0 -137
  50. package/dist/cjs/util/emojiIdToEmoji.js +0 -119
  51. package/dist/cjs/util/is-unicode-representation.js +0 -9
  52. package/dist/cjs/util/renderUnicodeEmojiToImagePath.js +0 -56
  53. package/dist/es2019/api/denormaliseStandardRepresentation.js +0 -11
  54. package/dist/es2019/components/common/UnicodeEmoji.js +0 -125
  55. package/dist/es2019/util/emojiIdToEmoji.js +0 -93
  56. package/dist/es2019/util/is-unicode-representation.js +0 -1
  57. package/dist/es2019/util/renderUnicodeEmojiToImagePath.js +0 -24
  58. package/dist/esm/api/denormaliseStandardRepresentation.js +0 -11
  59. package/dist/esm/components/common/UnicodeEmoji.js +0 -128
  60. package/dist/esm/util/emojiIdToEmoji.js +0 -113
  61. package/dist/esm/util/is-unicode-representation.js +0 -3
  62. package/dist/esm/util/renderUnicodeEmojiToImagePath.js +0 -49
  63. package/dist/types/api/denormaliseStandardRepresentation.d.ts +0 -2
  64. package/dist/types/components/common/UnicodeEmoji.d.ts +0 -6
  65. package/dist/types/util/emojiIdToEmoji.d.ts +0 -16
  66. package/dist/types/util/is-unicode-representation.d.ts +0 -2
  67. package/dist/types/util/renderUnicodeEmojiToImagePath.d.ts +0 -1
  68. package/emoji-id-to-emoji/package.json +0 -10
  69. package/unicode-emoji-image/package.json +0 -10
@@ -120,12 +120,6 @@ export declare class EmojiResource extends AbstractResource<string, EmojiSearchR
120
120
  findByShortName(shortName: string, emojiProviderLookupOrder?: EmojiProviderLookupOrder): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
121
121
  findByEmojiId(emojiId: EmojiId, emojiProviderLookupOrder?: EmojiProviderLookupOrder): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
122
122
  findById(id: string): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
123
- /**
124
- * Synchronously reads the emoji type from the local cache for the given emojiId.
125
- * Returns `undefined` when the emoji is not in the cache or no repository is initialised.
126
- * This is a pure cache read — no network requests are made.
127
- */
128
- getCachedEmojiType(emojiId: EmojiId): string | undefined;
129
123
  findInCategory(categoryId: CategoryId): Promise<EmojiDescription[]>;
130
124
  getAsciiMap(): Promise<Map<string, EmojiDescription>>;
131
125
  getFrequentlyUsed(options?: SearchOptions): Promise<EmojiDescription[]>;
@@ -54,7 +54,3 @@ export { shouldUseAltRepresentation } from './shouldUseAltRepresentation';
54
54
  * @deprecated Use `import { calculateScale } from '@atlaskit/emoji/emoji-utils'` instead.
55
55
  */
56
56
  export { calculateScale } from './calculateScale';
57
- /**
58
- * @deprecated Use `import { denormaliseStandardRepresentation } from '@atlaskit/emoji/emoji-utils'` instead.
59
- */
60
- export { denormaliseStandardRepresentation } from './denormaliseStandardRepresentation';
@@ -69,11 +69,6 @@ export interface Props extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onMo
69
69
  * Keyboard selection still keeps focus on the emoji for grid navigation.
70
70
  */
71
71
  preventFocusOnMouseDown?: boolean;
72
- /**
73
- * Renders unicode emoji through an image representation when a fixed height is supplied.
74
- * Defaults to `true`.
75
- */
76
- renderUnicodeEmojiAsImage?: boolean;
77
72
  /**
78
73
  * Show the emoji as selected
79
74
  */
@@ -98,9 +93,8 @@ export interface Props extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onMo
98
93
  */
99
94
  showTooltip?: boolean;
100
95
  }
101
- export declare const unicodeEmojiCanvasSize: any;
102
96
  interface EmojiNodeWrapperProps extends Props {
103
- type: 'sprite' | 'image' | 'unicode';
97
+ type: 'sprite' | 'image';
104
98
  }
105
99
  export declare const EmojiNodeWrapper: React.ForwardRefExoticComponent<EmojiNodeWrapperProps & {
106
100
  children?: React.ReactNode | undefined;
@@ -65,11 +65,6 @@ export interface BaseResourcedEmojiProps {
65
65
  * allows custom styling to the placeholder component while the emoji is loading.
66
66
  */
67
67
  placeholderXcss?: StrictXCSSProp<'backgroundColor', never>;
68
- /**
69
- * Renders unicode emoji through an image representation when a fixed height is supplied.
70
- * Defaults to `true`.
71
- */
72
- renderUnicodeEmojiAsImage?: boolean;
73
68
  /**
74
69
  * Allows to show the tooltip.
75
70
  * Defaults to `false`.
@@ -90,5 +85,5 @@ export interface Props extends BaseResourcedEmojiProps {
90
85
  */
91
86
  onEmojiLoadSuccess?: EmojiLoadSuccessCallback;
92
87
  }
93
- export declare const ResourcedEmojiComponent: ({ emojiProvider, emojiId, emojiProviderLookupOrder, showTooltip, customFallback, fitToHeight, ignoreWrapper, optimistic, optimisticImageURL, editorEmoji, renderUnicodeEmojiAsImage, pageTitleEmoji, placeholderXcss, onEmojiLoadSuccess, onEmojiLoadFail, }: Props) => React.JSX.Element;
88
+ export declare const ResourcedEmojiComponent: ({ emojiProvider, emojiId, emojiProviderLookupOrder, showTooltip, customFallback, fitToHeight, ignoreWrapper, optimistic, optimisticImageURL, editorEmoji, pageTitleEmoji, placeholderXcss, onEmojiLoadSuccess, onEmojiLoadFail, }: Props) => React.JSX.Element;
94
89
  export default ResourcedEmojiComponent;
@@ -65,17 +65,6 @@ export interface EmojiProvider extends Provider<string, EmojiSearchResult, any,
65
65
  * Returns a map matching ascii representations to their corresponding EmojiDescription.
66
66
  */
67
67
  getAsciiMap(): Promise<Map<string, EmojiDescription>>;
68
- /**
69
- * Synchronously reads the emoji type (e.g. 'STANDARD', 'SITE', 'ATLASSIAN') from the
70
- * local cache for the given emojiId, without making any network requests.
71
- *
72
- * Returns `undefined` when the emoji is not yet in the cache or no repository has been
73
- * initialised. This is an optional method — callers must fall back gracefully when it is
74
- * absent (e.g. in mock or legacy providers).
75
- *
76
- * Optional.
77
- */
78
- getCachedEmojiType?(emojiId: EmojiId): string | undefined;
79
68
  /**
80
69
  * Returns the logged user passed by the Product
81
70
  */
@@ -218,10 +207,7 @@ export interface ImageRepresentation extends EmojiImageRepresentation {
218
207
  export interface MediaApiRepresentation extends EmojiImageRepresentation {
219
208
  mediaPath: string;
220
209
  }
221
- export interface UnicodeRepresentation {
222
- unicodeEmoji: string;
223
- }
224
- export type EmojiRepresentation = SpriteRepresentation | ImageRepresentation | MediaApiRepresentation | UnicodeRepresentation | undefined;
210
+ export type EmojiRepresentation = SpriteRepresentation | ImageRepresentation | MediaApiRepresentation | undefined;
225
211
  export interface EmojiDescription extends EmojiId {
226
212
  altRepresentation?: EmojiRepresentation;
227
213
  ascii?: string[];
@@ -14,10 +14,6 @@ export { isImageRepresentation } from './is-image-representation';
14
14
  * @deprecated Use `import { isMediaRepresentation } from '@atlaskit/emoji/type-helpers'` instead.
15
15
  */
16
16
  export { isMediaRepresentation } from './is-media-representation';
17
- /**
18
- * @deprecated Use `import { isUnicodeRepresentation } from '@atlaskit/emoji/type-helpers'` instead.
19
- */
20
- export { isUnicodeRepresentation } from './is-unicode-representation';
21
17
  /**
22
18
  * @deprecated Use `import { isPromise } from '@atlaskit/emoji/type-helpers'` instead.
23
19
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/emoji",
3
- "version": "72.5.18",
3
+ "version": "73.0.0",
4
4
  "description": "Fabric emoji React components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -44,18 +44,18 @@
44
44
  "@atlaskit/icon-lab": "^7.11.0",
45
45
  "@atlaskit/image": "^5.2.0",
46
46
  "@atlaskit/logo": "^23.3.0",
47
- "@atlaskit/media-client": "^39.1.0",
47
+ "@atlaskit/media-client": "^39.2.0",
48
48
  "@atlaskit/media-client-react": "^7.0.0",
49
49
  "@atlaskit/platform-feature-experiments": "^0.3.0",
50
50
  "@atlaskit/platform-feature-flags": "^2.2.0",
51
51
  "@atlaskit/pragmatic-drag-and-drop": "^4.0.0",
52
- "@atlaskit/primitives": "^22.5.0",
52
+ "@atlaskit/primitives": "^22.6.0",
53
53
  "@atlaskit/radio": "^10.2.0",
54
54
  "@atlaskit/spinner": "^20.4.0",
55
55
  "@atlaskit/textfield": "^10.2.0",
56
56
  "@atlaskit/theme": "^28.2.0",
57
- "@atlaskit/tmp-editor-statsig": "^239.0.0",
58
- "@atlaskit/tokens": "^20.5.0",
57
+ "@atlaskit/tmp-editor-statsig": "^240.0.0",
58
+ "@atlaskit/tokens": "^20.6.0",
59
59
  "@atlaskit/tooltip": "^24.4.0",
60
60
  "@atlaskit/ufo": "^2.0.0",
61
61
  "@atlaskit/util-service-support": "^7.4.0",
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.denormaliseStandardRepresentation = void 0;
7
- var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
8
- var _types = require("../types");
9
- var _emojiIdToEmoji = require("../util/emojiIdToEmoji");
10
- var _denormaliseServiceRepresentation = require("./denormaliseServiceRepresentation");
11
- var denormaliseStandardRepresentation = exports.denormaliseStandardRepresentation = function denormaliseStandardRepresentation(emoji, meta) {
12
- var unicodeEmoji = (0, _emojiIdToEmoji.emojiIdToEmoji)(emoji.id);
13
- var useUnicodeRepresentation = !!(emoji.id && emoji.type === _types.ProviderTypes.STANDARD && unicodeEmoji && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_use_unicode_emojis', 'isEnabled', true));
14
- return useUnicodeRepresentation ? {
15
- unicodeEmoji: unicodeEmoji
16
- } : (0, _denormaliseServiceRepresentation.denormaliseServiceRepresentation)(emoji.representation, meta);
17
- };
@@ -1,137 +0,0 @@
1
- /* UnicodeEmoji.tsx generated by @compiled/babel-plugin v3.0.2 */
2
- "use strict";
3
-
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
9
- exports.UnicodeEmoji = void 0;
10
- var _runtime = require("@compiled/react/runtime");
11
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
14
- var _react = _interopRequireWildcard(require("react"));
15
- var _constants = require("../../util/constants");
16
- var _isSsr = require("../../util/is-ssr");
17
- var _renderUnicodeEmojiToImagePath = require("../../util/renderUnicodeEmojiToImagePath");
18
- var _Emoji = require("./Emoji");
19
- var _EmojiPlaceholder = _interopRequireDefault(require("./EmojiPlaceholder"));
20
- var _ImageEmoji = require("./ImageEmoji");
21
- var _styles = require("./styles");
22
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
23
- 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; }
24
- 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) { (0, _defineProperty2.default)(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; }
25
- var useUnicodeEmojiImage = function useUnicodeEmojiImage(unicodeEmoji) {
26
- var _useState = (0, _react.useState)({
27
- status: 'loading'
28
- }),
29
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
30
- state = _useState2[0],
31
- setState = _useState2[1];
32
- (0, _react.useEffect)(function () {
33
- var cancelled = false;
34
- var imagePathToRevoke;
35
- setState({
36
- status: 'loading',
37
- unicodeEmoji: unicodeEmoji
38
- });
39
- void (0, _renderUnicodeEmojiToImagePath.renderUnicodeEmojiToImagePath)(unicodeEmoji).then(function (imagePath) {
40
- if (cancelled) {
41
- if (imagePath) {
42
- URL.revokeObjectURL(imagePath);
43
- }
44
- return;
45
- }
46
- imagePathToRevoke = imagePath;
47
- setState(imagePath ? {
48
- status: 'ready',
49
- unicodeEmoji: unicodeEmoji,
50
- imagePath: imagePath
51
- } : {
52
- status: 'failed',
53
- unicodeEmoji: unicodeEmoji
54
- });
55
- }).catch(function () {
56
- if (!cancelled) {
57
- setState({
58
- status: 'failed',
59
- unicodeEmoji: unicodeEmoji
60
- });
61
- }
62
- });
63
- return function () {
64
- cancelled = true;
65
- if (imagePathToRevoke) {
66
- URL.revokeObjectURL(imagePathToRevoke);
67
- }
68
- };
69
- }, [unicodeEmoji]);
70
- return state;
71
- };
72
- var UnicodeEmojiImage = function UnicodeEmojiImage(props) {
73
- var emoji = props.emoji,
74
- fitToHeight = props.fitToHeight,
75
- showTooltip = props.showTooltip;
76
- var emojiText = emoji.representation.unicodeEmoji;
77
- var unicodeEmojiImage = useUnicodeEmojiImage(emojiText);
78
- var hasCurrentEmojiImage = unicodeEmojiImage.unicodeEmoji === emojiText;
79
- if ((0, _isSsr.isSSR)() || !hasCurrentEmojiImage || unicodeEmojiImage.status === 'loading') {
80
- return /*#__PURE__*/_react.default.createElement(_EmojiPlaceholder.default, {
81
- shortName: emoji.shortName,
82
- showTooltip: showTooltip,
83
- size: fitToHeight,
84
- loading: true
85
- });
86
- }
87
- if (unicodeEmojiImage.status === 'ready') {
88
- return /*#__PURE__*/_react.default.createElement(_ImageEmoji.ImageEmoji, (0, _extends2.default)({}, props, {
89
- emoji: _objectSpread(_objectSpread({}, emoji), {}, {
90
- altRepresentation: undefined,
91
- representation: {
92
- imagePath: unicodeEmojiImage.imagePath,
93
- width: _Emoji.unicodeEmojiCanvasSize,
94
- height: _Emoji.unicodeEmojiCanvasSize
95
- }
96
- })
97
- }));
98
- }
99
- return /*#__PURE__*/_react.default.createElement(_EmojiPlaceholder.default, {
100
- shortName: emoji.shortName,
101
- showTooltip: showTooltip,
102
- size: fitToHeight
103
- });
104
- };
105
- var UnicodeEmoji = exports.UnicodeEmoji = function UnicodeEmoji(props) {
106
- var emoji = props.emoji,
107
- selected = props.selected,
108
- selectOnHover = props.selectOnHover,
109
- className = props.className,
110
- fitToHeight = props.fitToHeight,
111
- _props$renderUnicodeE = props.renderUnicodeEmojiAsImage,
112
- renderUnicodeEmojiAsImage = _props$renderUnicodeE === void 0 ? true : _props$renderUnicodeE;
113
- if (renderUnicodeEmojiAsImage) {
114
- return /*#__PURE__*/_react.default.createElement(UnicodeEmojiImage, props);
115
- }
116
- var classes = "".concat(_styles.emojiNodeStyles, " ").concat(selected ? _styles.commonSelectedStyles : '', " ").concat(selectOnHover ? _styles.selectOnHoverStyles : '', " ").concat(className ? className : '');
117
- var emojiText = emoji.representation.unicodeEmoji;
118
- var defaultSize = "".concat(fitToHeight !== null && fitToHeight !== void 0 ? fitToHeight : _constants.defaultEmojiHeight, "px");
119
- var emojiSize = "var(--emoji-common-unicode-size, ".concat(defaultSize, ")");
120
- var style = {
121
- display: 'inline-flex',
122
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
123
- fontSize: emojiSize,
124
- alignItems: 'center',
125
- aspectRatio: '1/1'
126
- };
127
- return (
128
- /*#__PURE__*/
129
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
130
- _react.default.createElement(_Emoji.EmojiNodeWrapper, (0, _extends2.default)({}, props, {
131
- type: "unicode",
132
- className: classes
133
- }), /*#__PURE__*/_react.default.createElement("span", {
134
- style: style
135
- }, emojiText))
136
- );
137
- };
@@ -1,119 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.emojiIdToEmoji = emojiIdToEmoji;
7
- var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
8
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
9
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
- var KEYCAP_COMBINING = 0x20e3;
12
- var VARIATION_SELECTOR_16 = 0xfe0f;
13
- var VARIATION_SELECTOR_15 = 0xfe0e;
14
- var EMOJI_MODIFIER_START = 0x1f3fb;
15
- var EMOJI_MODIFIER_END = 0x1f3ff;
16
- var REGIONAL_INDICATOR_START = 0x1f1e6;
17
- var REGIONAL_INDICATOR_END = 0x1f1ff;
18
- var FLAG_BASES = new Set([0x1f38c, 0x1f3c1, 0x1f3f3, 0x1f3f4, 0x1f6a9]);
19
-
20
- // Emoji variation bases from Unicode 14.0 emoji-variation-sequences.txt.
21
- // These are the code points with a defined U+FE0F emoji-style variant.
22
- var EMOJI_VARIATION_BASES = new Set([0x0023, 0x002a, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x00a9, 0x00ae, 0x203c, 0x2049, 0x2122, 0x2139, 0x2194, 0x2195, 0x2196, 0x2197, 0x2198, 0x2199, 0x21a9, 0x21aa, 0x2328, 0x23cf, 0x23ed, 0x23ee, 0x23ef, 0x23f1, 0x23f2, 0x23f8, 0x23f9, 0x23fa, 0x24c2, 0x25aa, 0x25ab, 0x25b6, 0x25c0, 0x25fb, 0x25fc, 0x2600, 0x2601, 0x2602, 0x2603, 0x2604, 0x260e, 0x2611, 0x2618, 0x261d, 0x2620, 0x2622, 0x2623, 0x2626, 0x262a, 0x262e, 0x262f, 0x2638, 0x2639, 0x263a, 0x2640, 0x2642, 0x265f, 0x2660, 0x2663, 0x2665, 0x2666, 0x2668, 0x267b, 0x267e, 0x2692, 0x2694, 0x2695, 0x2696, 0x2697, 0x2699, 0x269b, 0x269c, 0x26a0, 0x26a7, 0x26b0, 0x26b1, 0x26c8, 0x26cf, 0x26d1, 0x26d3, 0x26e9, 0x26f0, 0x26f1, 0x26f4, 0x26f7, 0x26f8, 0x26f9, 0x2702, 0x2708, 0x2709, 0x270c, 0x270d, 0x270f, 0x2712, 0x2714, 0x2716, 0x271d, 0x2721, 0x2733, 0x2734, 0x2744, 0x2747, 0x2763, 0x2764, 0x27a1, 0x2934, 0x2935, 0x2b05, 0x2b06, 0x2b07, 0x3030, 0x303d, 0x3297, 0x3299, 0x1f170, 0x1f171, 0x1f17e, 0x1f17f, 0x1f202, 0x1f237, 0x1f321, 0x1f324, 0x1f325, 0x1f326, 0x1f327, 0x1f328, 0x1f329, 0x1f32a, 0x1f32b, 0x1f32c, 0x1f336, 0x1f37d, 0x1f396, 0x1f397, 0x1f399, 0x1f39a, 0x1f39b, 0x1f39e, 0x1f39f, 0x1f3cb, 0x1f3cc, 0x1f3cd, 0x1f3ce, 0x1f3d4, 0x1f3d5, 0x1f3d6, 0x1f3d7, 0x1f3d8, 0x1f3d9, 0x1f3da, 0x1f3db, 0x1f3dc, 0x1f3dd, 0x1f3de, 0x1f3df, 0x1f3f3, 0x1f3f5, 0x1f3f7, 0x1f43f, 0x1f441, 0x1f4fd, 0x1f549, 0x1f54a, 0x1f56f, 0x1f570, 0x1f573, 0x1f574, 0x1f575, 0x1f576, 0x1f577, 0x1f578, 0x1f579, 0x1f587, 0x1f58a, 0x1f58b, 0x1f58c, 0x1f58d, 0x1f590, 0x1f5a5, 0x1f5a8, 0x1f5b1, 0x1f5b2, 0x1f5bc, 0x1f5c2, 0x1f5c3, 0x1f5c4, 0x1f5d1, 0x1f5d2, 0x1f5d3, 0x1f5dc, 0x1f5dd, 0x1f5de, 0x1f5e1, 0x1f5e3, 0x1f5e8, 0x1f5ef, 0x1f5f3, 0x1f5fa, 0x1f6cb, 0x1f6cd, 0x1f6ce, 0x1f6cf, 0x1f6e0, 0x1f6e1, 0x1f6e2, 0x1f6e3, 0x1f6e4, 0x1f6e5, 0x1f6e9, 0x1f6f0, 0x1f6f3, 0x231a, 0x231b, 0x23e9, 0x23ea, 0x23f3, 0x25fd, 0x25fe, 0x2614, 0x2615, 0x2648, 0x2649, 0x264a, 0x264b, 0x264c, 0x264d, 0x264e, 0x264f, 0x2650, 0x2651, 0x2652, 0x2653, 0x267f, 0x2693, 0x26a1, 0x26aa, 0x26ab, 0x26bd, 0x26be, 0x26c4, 0x26c5, 0x26d4, 0x26ea, 0x26f2, 0x26f3, 0x26f5, 0x26fa, 0x26fd, 0x2753, 0x2757, 0x2b1b, 0x2b1c, 0x2b50, 0x2b55, 0x1f004, 0x1f21a, 0x1f22f, 0x1f30d, 0x1f30e, 0x1f30f, 0x1f315, 0x1f31c, 0x1f378, 0x1f393, 0x1f3a7, 0x1f3ac, 0x1f3ad, 0x1f3ae, 0x1f3c2, 0x1f3c4, 0x1f3c6, 0x1f3ca, 0x1f3e0, 0x1f3ed, 0x1f408, 0x1f415, 0x1f41f, 0x1f426, 0x1f442, 0x1f446, 0x1f447, 0x1f448, 0x1f449, 0x1f44d, 0x1f44e, 0x1f453, 0x1f46a, 0x1f47d, 0x1f4a3, 0x1f4b0, 0x1f4b3, 0x1f4bb, 0x1f4bf, 0x1f4cb, 0x1f4da, 0x1f4df, 0x1f4e4, 0x1f4e5, 0x1f4e6, 0x1f4ea, 0x1f4eb, 0x1f4ec, 0x1f4ed, 0x1f4f7, 0x1f4f9, 0x1f4fa, 0x1f4fb, 0x1f508, 0x1f50d, 0x1f512, 0x1f513, 0x1f550, 0x1f551, 0x1f552, 0x1f553, 0x1f554, 0x1f555, 0x1f556, 0x1f557, 0x1f558, 0x1f559, 0x1f55a, 0x1f55b, 0x1f55c, 0x1f55d, 0x1f55e, 0x1f55f, 0x1f560, 0x1f561, 0x1f562, 0x1f563, 0x1f564, 0x1f565, 0x1f566, 0x1f567, 0x1f610, 0x1f687, 0x1f68d, 0x1f691, 0x1f694, 0x1f698, 0x1f6ad, 0x1f6b2, 0x1f6b9, 0x1f6ba, 0x1f6bc]);
23
- var isEmojiModifier = function isEmojiModifier(codePoint) {
24
- return typeof codePoint === 'number' && codePoint >= EMOJI_MODIFIER_START && codePoint <= EMOJI_MODIFIER_END;
25
- };
26
- var shouldAddEmojiPresentationSelector = function shouldAddEmojiPresentationSelector(codePoint, nextCodePoint) {
27
- return EMOJI_VARIATION_BASES.has(codePoint) && nextCodePoint !== VARIATION_SELECTOR_16 && nextCodePoint !== VARIATION_SELECTOR_15 && nextCodePoint !== KEYCAP_COMBINING && !isEmojiModifier(nextCodePoint);
28
- };
29
- var isRegionalIndicator = function isRegionalIndicator(codePoint) {
30
- return codePoint >= REGIONAL_INDICATOR_START && codePoint <= REGIONAL_INDICATOR_END;
31
- };
32
- var isStandaloneRegionalIndicator = function isStandaloneRegionalIndicator(codePoints) {
33
- return codePoints.length === 1 && isRegionalIndicator(codePoints[0]);
34
- };
35
- var parseEmojiIdCodePoints = function parseEmojiIdCodePoints(id) {
36
- var segments = id.split('-');
37
- var codePoints = [];
38
- var _iterator = _createForOfIteratorHelper(segments),
39
- _step;
40
- try {
41
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
42
- var segment = _step.value;
43
- if (!/^[0-9a-fA-F]+$/.test(segment)) {
44
- return undefined;
45
- }
46
- var cp = parseInt(segment, 16);
47
- // Valid Unicode scalar values: U+0000–U+10FFFF, excluding surrogates.
48
- if (isNaN(cp) || cp < 0 || cp > 0x10ffff || cp >= 0xd800 && cp <= 0xdfff) {
49
- return undefined;
50
- }
51
- codePoints.push(cp);
52
- }
53
- } catch (err) {
54
- _iterator.e(err);
55
- } finally {
56
- _iterator.f();
57
- }
58
- return codePoints.length ? codePoints : undefined;
59
- };
60
- var isFlagEmoji = function isFlagEmoji(codePoints) {
61
- if (codePoints.length === 2 && codePoints.every(isRegionalIndicator)) {
62
- return true;
63
- }
64
- return FLAG_BASES.has(codePoints[0]);
65
- };
66
-
67
- /**
68
- * Converts an emoji ID (a hyphen-separated string of hex Unicode code points,
69
- * e.g. `"1f44d"`, `"1f44d-1f3fb"`, `"1f468-200d-1f469-200d-1f467"`) into its
70
- * corresponding Unicode string.
71
- *
72
- * Special handling:
73
- * - Keycap sequences: U+20E3 (COMBINING ENCLOSING KEYCAP) must be preceded by
74
- * U+FE0F (VARIATION SELECTOR-16) to form a well-defined keycap emoji.
75
- * - Emoji variation bases are followed by U+FE0F to force emoji presentation.
76
- * - Flags and standalone regional indicators return `undefined` so callers use
77
- * Twemoji instead of native emoji.
78
- *
79
- * @returns The Unicode string for the emoji, or `undefined` if the input is
80
- * invalid (empty string, non-hex segments, or out-of-range code points).
81
- */
82
- function emojiIdToEmoji(id) {
83
- if (!(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_use_unicode_emojis', 'isEnabled', true)) {
84
- return undefined;
85
- }
86
- if (!id) {
87
- return undefined;
88
- }
89
- var codePoints = parseEmojiIdCodePoints(id);
90
- if (!codePoints) {
91
- return undefined;
92
- }
93
- if (isStandaloneRegionalIndicator(codePoints) || isFlagEmoji(codePoints)) {
94
- return undefined;
95
- }
96
- var processedCodePoints = [];
97
- for (var i = 0; i < codePoints.length; i++) {
98
- var cp = codePoints[i];
99
- var next = codePoints[i + 1];
100
- processedCodePoints.push(cp);
101
-
102
- // Insert U+FE0F before U+20E3 if not already present.
103
- // Keycap sequences: digit/# /* followed by U+20E3 need U+FE0F between them.
104
- if (next === KEYCAP_COMBINING && cp !== VARIATION_SELECTOR_16) {
105
- processedCodePoints.push(VARIATION_SELECTOR_16);
106
- }
107
-
108
- // Emoji variation bases need U+FE0F immediately after the base code point,
109
- // including when the base appears inside a ZWJ sequence.
110
- if (shouldAddEmojiPresentationSelector(cp, next)) {
111
- processedCodePoints.push(VARIATION_SELECTOR_16);
112
- }
113
- }
114
- try {
115
- return String.fromCodePoint.apply(String, processedCodePoints);
116
- } catch (_unused) {
117
- return undefined;
118
- }
119
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isUnicodeRepresentation = void 0;
7
- var isUnicodeRepresentation = exports.isUnicodeRepresentation = function isUnicodeRepresentation(rep) {
8
- return !!(rep && rep.unicodeEmoji);
9
- };
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.renderUnicodeEmojiToImagePath = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _isSsr = require("./is-ssr");
11
- var unicodeEmojiCanvasSize = 128;
12
- var unicodeEmojiCanvasFontSize = 124;
13
- var unicodeEmojiCanvasTopPadding = 8;
14
- var renderUnicodeEmojiToImagePath = exports.renderUnicodeEmojiToImagePath = /*#__PURE__*/function () {
15
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(unicodeEmoji) {
16
- var OffscreenCanvasCtor, canvas, context, blob;
17
- return _regenerator.default.wrap(function (_context) {
18
- while (1) switch (_context.prev = _context.next) {
19
- case 0:
20
- OffscreenCanvasCtor = globalThis['OffscreenCanvas'];
21
- if (!((0, _isSsr.isSSR)() || !OffscreenCanvasCtor || typeof URL === 'undefined')) {
22
- _context.next = 1;
23
- break;
24
- }
25
- return _context.abrupt("return", undefined);
26
- case 1:
27
- canvas = new OffscreenCanvasCtor(unicodeEmojiCanvasSize, unicodeEmojiCanvasSize);
28
- context = canvas.getContext('2d');
29
- if (context) {
30
- _context.next = 2;
31
- break;
32
- }
33
- return _context.abrupt("return", undefined);
34
- case 2:
35
- context.clearRect(0, 0, unicodeEmojiCanvasSize, unicodeEmojiCanvasSize);
36
- context.textAlign = 'center';
37
- context.textBaseline = 'middle';
38
- context.font = "".concat(unicodeEmojiCanvasFontSize, "px sans-serif");
39
- context.fillText(unicodeEmoji, unicodeEmojiCanvasSize / 2, unicodeEmojiCanvasSize / 2 + unicodeEmojiCanvasTopPadding);
40
- _context.next = 3;
41
- return canvas.convertToBlob({
42
- type: 'image/png'
43
- });
44
- case 3:
45
- blob = _context.sent;
46
- return _context.abrupt("return", URL.createObjectURL(blob));
47
- case 4:
48
- case "end":
49
- return _context.stop();
50
- }
51
- }, _callee);
52
- }));
53
- return function renderUnicodeEmojiToImagePath(_x) {
54
- return _ref.apply(this, arguments);
55
- };
56
- }();
@@ -1,11 +0,0 @@
1
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
2
- import { ProviderTypes } from '../types';
3
- import { emojiIdToEmoji } from '../util/emojiIdToEmoji';
4
- import { denormaliseServiceRepresentation } from './denormaliseServiceRepresentation';
5
- export const denormaliseStandardRepresentation = (emoji, meta) => {
6
- const unicodeEmoji = emojiIdToEmoji(emoji.id);
7
- const useUnicodeRepresentation = !!(emoji.id && emoji.type === ProviderTypes.STANDARD && unicodeEmoji && expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true));
8
- return useUnicodeRepresentation ? {
9
- unicodeEmoji
10
- } : denormaliseServiceRepresentation(emoji.representation, meta);
11
- };
@@ -1,125 +0,0 @@
1
- /* UnicodeEmoji.tsx generated by @compiled/babel-plugin v3.0.2 */
2
- import _extends from "@babel/runtime/helpers/extends";
3
- import { ax, ix } from "@compiled/react/runtime";
4
- import React, { useEffect, useState } from 'react';
5
- import { defaultEmojiHeight } from '../../util/constants';
6
- import { isSSR } from '../../util/is-ssr';
7
- import { renderUnicodeEmojiToImagePath } from '../../util/renderUnicodeEmojiToImagePath';
8
- import { EmojiNodeWrapper, unicodeEmojiCanvasSize } from './Emoji';
9
- import EmojiPlaceholder from './EmojiPlaceholder';
10
- import { ImageEmoji } from './ImageEmoji';
11
- import { emojiNodeStyles, commonSelectedStyles, selectOnHoverStyles } from './styles';
12
- const useUnicodeEmojiImage = unicodeEmoji => {
13
- const [state, setState] = useState({
14
- status: 'loading'
15
- });
16
- useEffect(() => {
17
- let cancelled = false;
18
- let imagePathToRevoke;
19
- setState({
20
- status: 'loading',
21
- unicodeEmoji
22
- });
23
- void renderUnicodeEmojiToImagePath(unicodeEmoji).then(imagePath => {
24
- if (cancelled) {
25
- if (imagePath) {
26
- URL.revokeObjectURL(imagePath);
27
- }
28
- return;
29
- }
30
- imagePathToRevoke = imagePath;
31
- setState(imagePath ? {
32
- status: 'ready',
33
- unicodeEmoji,
34
- imagePath
35
- } : {
36
- status: 'failed',
37
- unicodeEmoji
38
- });
39
- }).catch(() => {
40
- if (!cancelled) {
41
- setState({
42
- status: 'failed',
43
- unicodeEmoji
44
- });
45
- }
46
- });
47
- return () => {
48
- cancelled = true;
49
- if (imagePathToRevoke) {
50
- URL.revokeObjectURL(imagePathToRevoke);
51
- }
52
- };
53
- }, [unicodeEmoji]);
54
- return state;
55
- };
56
- const UnicodeEmojiImage = props => {
57
- const {
58
- emoji,
59
- fitToHeight,
60
- showTooltip
61
- } = props;
62
- const emojiText = emoji.representation.unicodeEmoji;
63
- const unicodeEmojiImage = useUnicodeEmojiImage(emojiText);
64
- const hasCurrentEmojiImage = unicodeEmojiImage.unicodeEmoji === emojiText;
65
- if (isSSR() || !hasCurrentEmojiImage || unicodeEmojiImage.status === 'loading') {
66
- return /*#__PURE__*/React.createElement(EmojiPlaceholder, {
67
- shortName: emoji.shortName,
68
- showTooltip: showTooltip,
69
- size: fitToHeight,
70
- loading: true
71
- });
72
- }
73
- if (unicodeEmojiImage.status === 'ready') {
74
- return /*#__PURE__*/React.createElement(ImageEmoji, _extends({}, props, {
75
- emoji: {
76
- ...emoji,
77
- altRepresentation: undefined,
78
- representation: {
79
- imagePath: unicodeEmojiImage.imagePath,
80
- width: unicodeEmojiCanvasSize,
81
- height: unicodeEmojiCanvasSize
82
- }
83
- }
84
- }));
85
- }
86
- return /*#__PURE__*/React.createElement(EmojiPlaceholder, {
87
- shortName: emoji.shortName,
88
- showTooltip: showTooltip,
89
- size: fitToHeight
90
- });
91
- };
92
- export const UnicodeEmoji = props => {
93
- const {
94
- emoji,
95
- selected,
96
- selectOnHover,
97
- className,
98
- fitToHeight,
99
- renderUnicodeEmojiAsImage = true
100
- } = props;
101
- if (renderUnicodeEmojiAsImage) {
102
- return /*#__PURE__*/React.createElement(UnicodeEmojiImage, props);
103
- }
104
- const classes = `${emojiNodeStyles} ${selected ? commonSelectedStyles : ''} ${selectOnHover ? selectOnHoverStyles : ''} ${className ? className : ''}`;
105
- const emojiText = emoji.representation.unicodeEmoji;
106
- const defaultSize = `${fitToHeight !== null && fitToHeight !== void 0 ? fitToHeight : defaultEmojiHeight}px`;
107
- const emojiSize = `var(--emoji-common-unicode-size, ${defaultSize})`;
108
- const style = {
109
- display: 'inline-flex',
110
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
111
- fontSize: emojiSize,
112
- alignItems: 'center',
113
- aspectRatio: '1/1'
114
- };
115
- return (
116
- /*#__PURE__*/
117
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
118
- React.createElement(EmojiNodeWrapper, _extends({}, props, {
119
- type: "unicode",
120
- className: classes
121
- }), /*#__PURE__*/React.createElement("span", {
122
- style: style
123
- }, emojiText))
124
- );
125
- };