@atlaskit/emoji 67.0.4 → 67.0.6
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 +12 -0
- package/dist/cjs/admin.js +0 -2
- package/dist/cjs/api/EmojiLoader.js +1 -8
- package/dist/cjs/api/EmojiRepository.js +16 -80
- package/dist/cjs/api/EmojiRepositoryRegex.js +2 -0
- package/dist/cjs/api/EmojiResource.js +20 -170
- package/dist/cjs/api/EmojiUtils.js +27 -67
- package/dist/cjs/api/internal/Comparators.js +8 -62
- package/dist/cjs/api/internal/UsageFrequencyTracker.js +4 -34
- package/dist/cjs/api/media/MediaEmojiCache.js +8 -58
- package/dist/cjs/api/media/MediaImageLoader.js +4 -28
- package/dist/cjs/api/media/SiteEmojiResource.js +14 -55
- package/dist/cjs/api/media/TokenManager.js +4 -18
- package/dist/cjs/components/common/CachingEmoji.js +18 -52
- package/dist/cjs/components/common/DeleteButton.js +0 -10
- package/dist/cjs/components/common/Emoji.js +44 -102
- package/dist/cjs/components/common/EmojiActions.js +25 -61
- package/dist/cjs/components/common/EmojiButton.js +5 -18
- package/dist/cjs/components/common/EmojiDeletePreview.js +7 -38
- package/dist/cjs/components/common/EmojiErrorMessage.js +3 -9
- package/dist/cjs/components/common/EmojiPlaceholder.js +7 -16
- package/dist/cjs/components/common/EmojiPreviewComponent.js +1 -6
- package/dist/cjs/components/common/EmojiUploadPicker.js +31 -86
- package/dist/cjs/components/common/EmojiUploadPreview.js +7 -36
- package/dist/cjs/components/common/FileChooser.js +5 -18
- package/dist/cjs/components/common/LoadingEmojiComponent.js +5 -24
- package/dist/cjs/components/common/Popup.js +16 -44
- package/dist/cjs/components/common/RecordSelectionDefault.js +0 -7
- package/dist/cjs/components/common/ResourcedEmoji.js +0 -15
- package/dist/cjs/components/common/ResourcedEmojiComponent.js +29 -69
- package/dist/cjs/components/common/RetryableButton.js +4 -19
- package/dist/cjs/components/common/Scrollable.js +6 -36
- package/dist/cjs/components/common/ToneSelector.js +3 -24
- package/dist/cjs/components/common/UfoErrorBoundary.js +1 -19
- package/dist/cjs/components/common/UploadEmoji.js +2 -13
- package/dist/cjs/components/common/internal-types.js +0 -1
- package/dist/cjs/components/common/setSkinToneAriaLabelText.js +0 -6
- package/dist/cjs/components/common/styles.js +9 -17
- package/dist/cjs/components/hooks.js +0 -2
- package/dist/cjs/components/i18n.js +0 -2
- package/dist/cjs/components/picker/CategorySelector.js +4 -50
- package/dist/cjs/components/picker/CategoryTracker.js +3 -14
- package/dist/cjs/components/picker/EmojiPicker.js +3 -42
- package/dist/cjs/components/picker/EmojiPickerCategoryHeading.js +2 -10
- package/dist/cjs/components/picker/EmojiPickerComponent.js +59 -140
- package/dist/cjs/components/picker/EmojiPickerEmojiRow.js +7 -14
- package/dist/cjs/components/picker/EmojiPickerFooter.js +1 -8
- package/dist/cjs/components/picker/EmojiPickerList.js +32 -83
- package/dist/cjs/components/picker/EmojiPickerListSearch.js +11 -48
- package/dist/cjs/components/picker/EmojiPickerSizes.js +1 -2
- package/dist/cjs/components/picker/EmojiPickerVirtualItems.js +1 -38
- package/dist/cjs/components/picker/VirtualList.js +11 -41
- package/dist/cjs/components/picker/categories.js +0 -14
- package/dist/cjs/components/picker/styles.js +15 -20
- package/dist/cjs/components/picker/utils.js +0 -4
- package/dist/cjs/components/typeahead/EmojiTypeAhead.js +10 -45
- package/dist/cjs/components/typeahead/EmojiTypeAheadComponent.js +11 -74
- package/dist/cjs/components/typeahead/EmojiTypeAheadItem.js +7 -37
- package/dist/cjs/components/typeahead/EmojiTypeAheadList.js +10 -63
- package/dist/cjs/components/typeahead/styles.js +2 -4
- package/dist/cjs/components/uploader/EmojiUploadComponent.js +6 -42
- package/dist/cjs/components/uploader/EmojiUploader.js +3 -31
- package/dist/cjs/components/uploader/styles.js +3 -4
- package/dist/cjs/context/EmojiCommonProvider.js +0 -6
- package/dist/cjs/context/EmojiContext.js +0 -2
- package/dist/cjs/context/EmojiContextProvider.js +1 -17
- package/dist/cjs/element.js +0 -4
- package/dist/cjs/hooks/useEmoji.js +5 -20
- package/dist/cjs/hooks/useEmojiContext.js +0 -4
- package/dist/cjs/hooks/usePrevious.js +0 -2
- package/dist/cjs/i18n/cs.js +0 -1
- package/dist/cjs/i18n/da.js +0 -1
- package/dist/cjs/i18n/de.js +0 -1
- package/dist/cjs/i18n/en.js +0 -1
- package/dist/cjs/i18n/en_GB.js +0 -1
- package/dist/cjs/i18n/en_ZZ.js +0 -1
- package/dist/cjs/i18n/es.js +0 -1
- package/dist/cjs/i18n/et.js +0 -1
- package/dist/cjs/i18n/fi.js +0 -1
- package/dist/cjs/i18n/fr.js +0 -1
- package/dist/cjs/i18n/hu.js +0 -1
- package/dist/cjs/i18n/index.js +0 -30
- package/dist/cjs/i18n/it.js +0 -1
- package/dist/cjs/i18n/ja.js +0 -1
- package/dist/cjs/i18n/ko.js +0 -1
- package/dist/cjs/i18n/nb.js +0 -1
- package/dist/cjs/i18n/nl.js +0 -1
- package/dist/cjs/i18n/pl.js +0 -1
- package/dist/cjs/i18n/pt_BR.js +0 -1
- package/dist/cjs/i18n/pt_PT.js +0 -1
- package/dist/cjs/i18n/ru.js +0 -1
- package/dist/cjs/i18n/sk.js +0 -1
- package/dist/cjs/i18n/sv.js +0 -1
- package/dist/cjs/i18n/th.js +0 -1
- package/dist/cjs/i18n/tr.js +0 -1
- package/dist/cjs/i18n/uk.js +0 -1
- package/dist/cjs/i18n/vi.js +0 -1
- package/dist/cjs/i18n/zh.js +0 -1
- package/dist/cjs/i18n/zh_TW.js +0 -1
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/picker.js +0 -2
- package/dist/cjs/resource.js +0 -5
- package/dist/cjs/typeahead.js +0 -3
- package/dist/cjs/types.js +0 -17
- package/dist/cjs/util/DuplicateLimitedQueue.js +13 -31
- package/dist/cjs/util/StoredDuplicateLimitedQueue.js +4 -26
- package/dist/cjs/util/analytics/analytics.js +14 -97
- package/dist/cjs/util/analytics/index.js +0 -4
- package/dist/cjs/util/analytics/samplingUfo.js +3 -59
- package/dist/cjs/util/analytics/ufoExperiences.js +0 -12
- package/dist/cjs/util/analytics/useSampledUFOComponentExperience.js +3 -10
- package/dist/cjs/util/constants.js +5 -5
- package/dist/cjs/util/filters.js +0 -4
- package/dist/cjs/util/image.js +3 -18
- package/dist/cjs/util/logger.js +0 -6
- package/dist/cjs/util/mouse.js +3 -6
- package/dist/cjs/util/shared-styles.js +0 -4
- package/dist/cjs/util/storage-available.js +10 -8
- package/dist/cjs/util/type-helpers.js +2 -57
- package/dist/cjs/util/useInView.js +0 -6
- package/dist/cjs/utils.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/api/EmojiLoader.js +2 -4
- package/dist/es2019/api/EmojiRepository.js +15 -82
- package/dist/es2019/api/EmojiRepositoryRegex.js +2 -0
- package/dist/es2019/api/EmojiResource.js +21 -114
- package/dist/es2019/api/EmojiUtils.js +11 -18
- package/dist/es2019/api/internal/Comparators.js +12 -48
- package/dist/es2019/api/internal/UsageFrequencyTracker.js +7 -24
- package/dist/es2019/api/media/MediaEmojiCache.js +9 -52
- package/dist/es2019/api/media/MediaImageLoader.js +2 -16
- package/dist/es2019/api/media/SiteEmojiResource.js +11 -31
- package/dist/es2019/api/media/TokenManager.js +4 -14
- package/dist/es2019/components/common/CachingEmoji.js +5 -12
- package/dist/es2019/components/common/DeleteButton.js +2 -3
- package/dist/es2019/components/common/Emoji.js +19 -47
- package/dist/es2019/components/common/EmojiActions.js +3 -16
- package/dist/es2019/components/common/EmojiButton.js +0 -5
- package/dist/es2019/components/common/EmojiDeletePreview.js +0 -11
- package/dist/es2019/components/common/EmojiErrorMessage.js +1 -2
- package/dist/es2019/components/common/EmojiPlaceholder.js +0 -5
- package/dist/es2019/components/common/EmojiPreviewComponent.js +1 -0
- package/dist/es2019/components/common/EmojiUploadPicker.js +2 -25
- package/dist/es2019/components/common/EmojiUploadPreview.js +0 -6
- package/dist/es2019/components/common/FileChooser.js +0 -6
- package/dist/es2019/components/common/LoadingEmojiComponent.js +2 -14
- package/dist/es2019/components/common/Popup.js +4 -22
- package/dist/es2019/components/common/RecordSelectionDefault.js +1 -1
- package/dist/es2019/components/common/ResourcedEmoji.js +1 -6
- package/dist/es2019/components/common/ResourcedEmojiComponent.js +2 -13
- package/dist/es2019/components/common/RetryableButton.js +1 -8
- package/dist/es2019/components/common/Scrollable.js +2 -12
- package/dist/es2019/components/common/ToneSelector.js +2 -8
- package/dist/es2019/components/common/UfoErrorBoundary.js +0 -2
- package/dist/es2019/components/common/UploadEmoji.js +2 -3
- package/dist/es2019/components/common/internal-types.js +0 -1
- package/dist/es2019/components/common/styles.js +12 -8
- package/dist/es2019/components/picker/CategorySelector.js +0 -22
- package/dist/es2019/components/picker/CategoryTracker.js +3 -13
- package/dist/es2019/components/picker/EmojiPicker.js +3 -17
- package/dist/es2019/components/picker/EmojiPickerCategoryHeading.js +2 -3
- package/dist/es2019/components/picker/EmojiPickerComponent.js +10 -43
- package/dist/es2019/components/picker/EmojiPickerEmojiRow.js +0 -2
- package/dist/es2019/components/picker/EmojiPickerFooter.js +0 -2
- package/dist/es2019/components/picker/EmojiPickerList.js +10 -45
- package/dist/es2019/components/picker/EmojiPickerListSearch.js +2 -19
- package/dist/es2019/components/picker/EmojiPickerSizes.js +1 -0
- package/dist/es2019/components/picker/EmojiPickerVirtualItems.js +1 -8
- package/dist/es2019/components/picker/VirtualList.js +3 -24
- package/dist/es2019/components/picker/styles.js +22 -10
- package/dist/es2019/components/picker/utils.js +0 -1
- package/dist/es2019/components/typeahead/EmojiTypeAhead.js +4 -21
- package/dist/es2019/components/typeahead/EmojiTypeAheadComponent.js +0 -42
- package/dist/es2019/components/typeahead/EmojiTypeAheadItem.js +0 -7
- package/dist/es2019/components/typeahead/EmojiTypeAheadList.js +4 -45
- package/dist/es2019/components/typeahead/styles.js +2 -1
- package/dist/es2019/components/uploader/EmojiUploadComponent.js +2 -15
- package/dist/es2019/components/uploader/EmojiUploader.js +2 -10
- package/dist/es2019/components/uploader/styles.js +5 -2
- package/dist/es2019/context/EmojiCommonProvider.js +0 -2
- package/dist/es2019/context/EmojiContextProvider.js +0 -1
- package/dist/es2019/hooks/useEmoji.js +2 -6
- package/dist/es2019/hooks/useEmojiContext.js +1 -1
- package/dist/es2019/index.js +12 -6
- package/dist/es2019/types.js +1 -11
- package/dist/es2019/util/DuplicateLimitedQueue.js +13 -35
- package/dist/es2019/util/StoredDuplicateLimitedQueue.js +5 -12
- package/dist/es2019/util/analytics/analytics.js +7 -23
- package/dist/es2019/util/analytics/samplingUfo.js +6 -32
- package/dist/es2019/util/analytics/ufoExperiences.js +0 -3
- package/dist/es2019/util/analytics/useSampledUFOComponentExperience.js +3 -7
- package/dist/es2019/util/constants.js +5 -4
- package/dist/es2019/util/filters.js +0 -3
- package/dist/es2019/util/image.js +3 -8
- package/dist/es2019/util/mouse.js +3 -3
- package/dist/es2019/util/storage-available.js +10 -7
- package/dist/es2019/util/type-helpers.js +6 -9
- package/dist/es2019/util/useInView.js +0 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/api/EmojiLoader.js +2 -6
- package/dist/esm/api/EmojiRepository.js +16 -71
- package/dist/esm/api/EmojiRepositoryRegex.js +2 -0
- package/dist/esm/api/EmojiResource.js +20 -158
- package/dist/esm/api/EmojiUtils.js +27 -47
- package/dist/esm/api/internal/Comparators.js +12 -53
- package/dist/esm/api/internal/UsageFrequencyTracker.js +5 -29
- package/dist/esm/api/media/MediaEmojiCache.js +9 -55
- package/dist/esm/api/media/MediaImageLoader.js +4 -27
- package/dist/esm/api/media/SiteEmojiResource.js +14 -43
- package/dist/esm/api/media/TokenManager.js +6 -16
- package/dist/esm/components/common/CachingEmoji.js +18 -30
- package/dist/esm/components/common/DeleteButton.js +2 -3
- package/dist/esm/components/common/Emoji.js +44 -78
- package/dist/esm/components/common/EmojiActions.js +25 -40
- package/dist/esm/components/common/EmojiButton.js +4 -9
- package/dist/esm/components/common/EmojiDeletePreview.js +7 -24
- package/dist/esm/components/common/EmojiErrorMessage.js +3 -4
- package/dist/esm/components/common/EmojiPlaceholder.js +6 -11
- package/dist/esm/components/common/EmojiPreviewComponent.js +1 -0
- package/dist/esm/components/common/EmojiUploadPicker.js +30 -64
- package/dist/esm/components/common/EmojiUploadPreview.js +7 -19
- package/dist/esm/components/common/FileChooser.js +5 -11
- package/dist/esm/components/common/LoadingEmojiComponent.js +4 -20
- package/dist/esm/components/common/Popup.js +16 -36
- package/dist/esm/components/common/RecordSelectionDefault.js +1 -1
- package/dist/esm/components/common/ResourcedEmoji.js +1 -6
- package/dist/esm/components/common/ResourcedEmojiComponent.js +29 -51
- package/dist/esm/components/common/RetryableButton.js +4 -11
- package/dist/esm/components/common/Scrollable.js +6 -29
- package/dist/esm/components/common/ToneSelector.js +3 -13
- package/dist/esm/components/common/UfoErrorBoundary.js +1 -13
- package/dist/esm/components/common/UploadEmoji.js +2 -3
- package/dist/esm/components/common/internal-types.js +0 -1
- package/dist/esm/components/common/setSkinToneAriaLabelText.js +0 -2
- package/dist/esm/components/common/styles.js +12 -9
- package/dist/esm/components/picker/CategorySelector.js +4 -32
- package/dist/esm/components/picker/CategoryTracker.js +3 -13
- package/dist/esm/components/picker/EmojiPicker.js +5 -27
- package/dist/esm/components/picker/EmojiPickerCategoryHeading.js +4 -5
- package/dist/esm/components/picker/EmojiPickerComponent.js +60 -114
- package/dist/esm/components/picker/EmojiPickerEmojiRow.js +6 -8
- package/dist/esm/components/picker/EmojiPickerFooter.js +0 -2
- package/dist/esm/components/picker/EmojiPickerList.js +32 -77
- package/dist/esm/components/picker/EmojiPickerListSearch.js +11 -35
- package/dist/esm/components/picker/EmojiPickerSizes.js +1 -0
- package/dist/esm/components/picker/EmojiPickerVirtualItems.js +2 -26
- package/dist/esm/components/picker/VirtualList.js +11 -28
- package/dist/esm/components/picker/styles.js +22 -11
- package/dist/esm/components/picker/utils.js +0 -1
- package/dist/esm/components/typeahead/EmojiTypeAhead.js +11 -39
- package/dist/esm/components/typeahead/EmojiTypeAheadComponent.js +11 -65
- package/dist/esm/components/typeahead/EmojiTypeAheadItem.js +7 -24
- package/dist/esm/components/typeahead/EmojiTypeAheadList.js +10 -53
- package/dist/esm/components/typeahead/styles.js +2 -1
- package/dist/esm/components/uploader/EmojiUploadComponent.js +5 -25
- package/dist/esm/components/uploader/EmojiUploader.js +4 -22
- package/dist/esm/components/uploader/styles.js +5 -2
- package/dist/esm/context/EmojiCommonProvider.js +0 -2
- package/dist/esm/context/EmojiContextProvider.js +1 -6
- package/dist/esm/hooks/useEmoji.js +5 -13
- package/dist/esm/hooks/useEmojiContext.js +1 -1
- package/dist/esm/index.js +12 -6
- package/dist/esm/types.js +1 -11
- package/dist/esm/util/DuplicateLimitedQueue.js +13 -29
- package/dist/esm/util/StoredDuplicateLimitedQueue.js +5 -22
- package/dist/esm/util/analytics/analytics.js +14 -50
- package/dist/esm/util/analytics/samplingUfo.js +3 -51
- package/dist/esm/util/analytics/ufoExperiences.js +0 -3
- package/dist/esm/util/analytics/useSampledUFOComponentExperience.js +3 -7
- package/dist/esm/util/constants.js +5 -4
- package/dist/esm/util/filters.js +0 -3
- package/dist/esm/util/image.js +3 -8
- package/dist/esm/util/logger.js +0 -2
- package/dist/esm/util/mouse.js +3 -3
- package/dist/esm/util/storage-available.js +10 -7
- package/dist/esm/util/type-helpers.js +2 -12
- package/dist/esm/util/useInView.js +0 -2
- package/dist/esm/version.json +1 -1
- package/package.json +6 -4
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* The options used to configure a newly constructed queue.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* A queue which will limit the number of duplicates of type T that it holds. When the duplicate limit is
|
|
10
8
|
* reached the earliest inserted duplicate (the "original") is removed to make room for the new insertion.
|
|
@@ -22,74 +20,70 @@ var DuplicateLimitedQueue = /*#__PURE__*/function () {
|
|
|
22
20
|
*/
|
|
23
21
|
function DuplicateLimitedQueue(options) {
|
|
24
22
|
_classCallCheck(this, DuplicateLimitedQueue);
|
|
25
|
-
|
|
26
23
|
if (options.maxDuplicates < 1) {
|
|
27
24
|
throw new RangeError('The maxDuplicates option must be at least 1');
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
if (options.minUniqueItems < 1) {
|
|
31
27
|
throw new RangeError('The minUniqueItems option must be at least 1');
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
this.maximumSize = options.maxDuplicates * options.minUniqueItems;
|
|
35
30
|
this.perItemSize = options.maxDuplicates;
|
|
36
31
|
this.createEmptyState();
|
|
37
32
|
}
|
|
33
|
+
|
|
38
34
|
/**
|
|
39
35
|
* @param item the item to add to the queue.
|
|
40
36
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
37
|
_createClass(DuplicateLimitedQueue, [{
|
|
44
38
|
key: "enqueue",
|
|
45
39
|
value: function enqueue(item) {
|
|
46
|
-
this.enqueueWithoutOrdering(item);
|
|
47
|
-
// so do the ordering work on each enqueue.
|
|
40
|
+
this.enqueueWithoutOrdering(item);
|
|
48
41
|
|
|
42
|
+
// enqueues are less time sensitive (and may happen less frequently) than queries against the queue
|
|
43
|
+
// so do the ordering work on each enqueue.
|
|
49
44
|
this.itemsOrderedByFrequency = this.orderItemsByFrequency();
|
|
50
45
|
}
|
|
46
|
+
|
|
51
47
|
/**
|
|
52
48
|
* Return the items in the queue, ordered by how often they are duplicated. The items with the
|
|
53
49
|
* most duplicates come first in the returned Array.
|
|
54
50
|
*
|
|
55
51
|
* If there are no items in the queue then an empty Array will be returned.
|
|
56
52
|
*/
|
|
57
|
-
|
|
58
53
|
}, {
|
|
59
54
|
key: "getItemsOrderedByDuplicateCount",
|
|
60
55
|
value: function getItemsOrderedByDuplicateCount() {
|
|
61
56
|
return this.itemsOrderedByFrequency;
|
|
62
57
|
}
|
|
58
|
+
|
|
63
59
|
/**
|
|
64
60
|
* Exposed for storybook/testing purposes only. Clear the contents of the queue.
|
|
65
61
|
*/
|
|
66
|
-
|
|
67
62
|
}, {
|
|
68
63
|
key: "clear",
|
|
69
64
|
value: function clear() {
|
|
70
65
|
this.createEmptyState();
|
|
71
66
|
}
|
|
67
|
+
|
|
72
68
|
/**
|
|
73
69
|
* A more efficient mechanism for adding multiple items. Ordering is only performed once all
|
|
74
70
|
* the items have been added.
|
|
75
71
|
*
|
|
76
72
|
* @param items the items to be enqueued, which happens in their presented order.
|
|
77
73
|
*/
|
|
78
|
-
|
|
79
74
|
}, {
|
|
80
75
|
key: "bulkEnqueue",
|
|
81
76
|
value: function bulkEnqueue(items) {
|
|
82
77
|
var _this = this;
|
|
83
|
-
|
|
84
78
|
items.map(function (item) {
|
|
85
79
|
return _this.enqueueWithoutOrdering(item);
|
|
86
80
|
});
|
|
87
81
|
this.itemsOrderedByFrequency = this.orderItemsByFrequency();
|
|
88
82
|
}
|
|
83
|
+
|
|
89
84
|
/**
|
|
90
85
|
* Return the items currently stored in the queue.
|
|
91
86
|
*/
|
|
92
|
-
|
|
93
87
|
}, {
|
|
94
88
|
key: "getItems",
|
|
95
89
|
value: function getItems() {
|
|
@@ -102,18 +96,17 @@ var DuplicateLimitedQueue = /*#__PURE__*/function () {
|
|
|
102
96
|
this.itemCountMap = new Map();
|
|
103
97
|
this.itemsOrderedByFrequency = new Array();
|
|
104
98
|
}
|
|
99
|
+
|
|
105
100
|
/**
|
|
106
101
|
* Enqueue the supplied item, keeping consistency with the limits configured. However no ordering is
|
|
107
102
|
* performed by this enqueuing. You must trigger that manually if required.
|
|
108
103
|
*
|
|
109
104
|
* @param item the item to be queued
|
|
110
105
|
*/
|
|
111
|
-
|
|
112
106
|
}, {
|
|
113
107
|
key: "enqueueWithoutOrdering",
|
|
114
108
|
value: function enqueueWithoutOrdering(item) {
|
|
115
109
|
var count = this.itemCountMap.get(item);
|
|
116
|
-
|
|
117
110
|
if (count && count >= this.perItemSize) {
|
|
118
111
|
// find the first item with that key in the array and remove it
|
|
119
112
|
this.removeFirstOccurrence(item);
|
|
@@ -122,13 +115,12 @@ var DuplicateLimitedQueue = /*#__PURE__*/function () {
|
|
|
122
115
|
this.remove();
|
|
123
116
|
}
|
|
124
117
|
}
|
|
125
|
-
|
|
126
118
|
this.add(item);
|
|
127
119
|
}
|
|
120
|
+
|
|
128
121
|
/**
|
|
129
122
|
* Get an array of items from the queue ordered by how often they are duplicated in the queue.
|
|
130
123
|
*/
|
|
131
|
-
|
|
132
124
|
}, {
|
|
133
125
|
key: "orderItemsByFrequency",
|
|
134
126
|
value: function orderItemsByFrequency() {
|
|
@@ -143,10 +135,8 @@ var DuplicateLimitedQueue = /*#__PURE__*/function () {
|
|
|
143
135
|
key: "decrementCount",
|
|
144
136
|
value: function decrementCount(item) {
|
|
145
137
|
var count = this.itemCountMap.get(item);
|
|
146
|
-
|
|
147
138
|
if (count) {
|
|
148
139
|
count--;
|
|
149
|
-
|
|
150
140
|
if (count > 0) {
|
|
151
141
|
this.itemCountMap.set(item, count);
|
|
152
142
|
} else {
|
|
@@ -154,49 +144,45 @@ var DuplicateLimitedQueue = /*#__PURE__*/function () {
|
|
|
154
144
|
}
|
|
155
145
|
}
|
|
156
146
|
}
|
|
147
|
+
|
|
157
148
|
/**
|
|
158
149
|
* Walk the list of items and remove the first occurrence of the matching item.
|
|
159
150
|
*
|
|
160
151
|
* @param item the item to be removed.
|
|
161
152
|
*/
|
|
162
|
-
|
|
163
153
|
}, {
|
|
164
154
|
key: "removeFirstOccurrence",
|
|
165
155
|
value: function removeFirstOccurrence(item) {
|
|
166
156
|
var index = this.items.indexOf(item);
|
|
167
|
-
|
|
168
157
|
if (index !== -1) {
|
|
169
158
|
this.items.splice(index, 1);
|
|
170
159
|
this.decrementCount(item);
|
|
171
160
|
}
|
|
172
161
|
}
|
|
162
|
+
|
|
173
163
|
/**
|
|
174
164
|
* Remove the first item from the queue and update the itemCountMap accordingly.
|
|
175
165
|
* @return the item add the front of the queue or undefined if the queue is empty
|
|
176
166
|
*/
|
|
177
|
-
|
|
178
167
|
}, {
|
|
179
168
|
key: "remove",
|
|
180
169
|
value: function remove() {
|
|
181
170
|
var removed = this.items.shift();
|
|
182
|
-
|
|
183
171
|
if (removed !== undefined) {
|
|
184
172
|
this.decrementCount(removed);
|
|
185
173
|
}
|
|
186
|
-
|
|
187
174
|
return removed;
|
|
188
175
|
}
|
|
176
|
+
|
|
189
177
|
/**
|
|
190
178
|
* Add the supplied item to the end of the queue and update the itemCountMap accordingly.
|
|
191
179
|
* @param item the item to be added to the queue
|
|
192
180
|
*/
|
|
193
|
-
|
|
194
181
|
}, {
|
|
195
182
|
key: "add",
|
|
196
183
|
value: function add(item) {
|
|
197
184
|
this.items.push(item);
|
|
198
185
|
var count = this.itemCountMap.get(item);
|
|
199
|
-
|
|
200
186
|
if (count) {
|
|
201
187
|
this.itemCountMap.set(item, count + 1);
|
|
202
188
|
} else {
|
|
@@ -204,8 +190,6 @@ var DuplicateLimitedQueue = /*#__PURE__*/function () {
|
|
|
204
190
|
}
|
|
205
191
|
}
|
|
206
192
|
}]);
|
|
207
|
-
|
|
208
193
|
return DuplicateLimitedQueue;
|
|
209
194
|
}();
|
|
210
|
-
|
|
211
195
|
export { DuplicateLimitedQueue as default };
|
|
@@ -5,75 +5,62 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
8
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
9
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
|
|
13
10
|
import DuplicateLimitedQueue from './DuplicateLimitedQueue';
|
|
14
11
|
import debug from './logger';
|
|
12
|
+
|
|
15
13
|
/**
|
|
16
14
|
* The options used to configure a newly constructed queue.
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
16
|
/**
|
|
20
17
|
* An extension to the DuplicateLimitedQueue that will initialise its contents from the
|
|
21
18
|
* supplied Storage and will also update the storage for every new item enqueued.
|
|
22
19
|
*/
|
|
23
20
|
var StoredDuplicateLimitedQueue = /*#__PURE__*/function (_DuplicateLimitedQueu) {
|
|
24
21
|
_inherits(StoredDuplicateLimitedQueue, _DuplicateLimitedQueu);
|
|
25
|
-
|
|
26
22
|
var _super = _createSuper(StoredDuplicateLimitedQueue);
|
|
27
|
-
|
|
28
23
|
function StoredDuplicateLimitedQueue(options) {
|
|
29
24
|
var _this;
|
|
30
|
-
|
|
31
25
|
_classCallCheck(this, StoredDuplicateLimitedQueue);
|
|
32
|
-
|
|
33
26
|
_this = _super.call(this, options);
|
|
34
27
|
_this.storage = options.storage;
|
|
35
28
|
_this.prefixedStorageKey = "".concat(options.storagePrefix, ".").concat(StoredDuplicateLimitedQueue.storageKey);
|
|
36
|
-
|
|
37
29
|
_this.load();
|
|
38
|
-
|
|
39
30
|
return _this;
|
|
40
31
|
}
|
|
32
|
+
|
|
41
33
|
/**
|
|
42
34
|
* Enqueue the supplied item and also persist the new contents of the queue to storage.
|
|
43
35
|
*
|
|
44
36
|
* @param item the item to be enqueued
|
|
45
37
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
38
|
_createClass(StoredDuplicateLimitedQueue, [{
|
|
49
39
|
key: "enqueue",
|
|
50
40
|
value: function enqueue(item) {
|
|
51
41
|
_get(_getPrototypeOf(StoredDuplicateLimitedQueue.prototype), "enqueue", this).call(this, item);
|
|
52
|
-
|
|
53
42
|
this.save();
|
|
54
43
|
}
|
|
44
|
+
|
|
55
45
|
/**
|
|
56
46
|
* Exposed for storybook/testing purposes only. Clear the contents of the queue, and localStorage.
|
|
57
47
|
*/
|
|
58
|
-
|
|
59
48
|
}, {
|
|
60
49
|
key: "clear",
|
|
61
50
|
value: function clear() {
|
|
62
51
|
_get(_getPrototypeOf(StoredDuplicateLimitedQueue.prototype), "clear", this).call(this);
|
|
63
|
-
|
|
64
52
|
this.storage.removeItem(this.prefixedStorageKey);
|
|
65
53
|
}
|
|
54
|
+
|
|
66
55
|
/**
|
|
67
56
|
* Initialise the queue contents from the configured Storage. If there is no data found in
|
|
68
57
|
* storage then the queue will have no items added. Likewise, a failure to read or parse stored
|
|
69
58
|
* data will be swallowed and no items are added to the queue.
|
|
70
59
|
*/
|
|
71
|
-
|
|
72
60
|
}, {
|
|
73
61
|
key: "load",
|
|
74
62
|
value: function load() {
|
|
75
63
|
var itemsJson = this.storage.getItem(this.prefixedStorageKey);
|
|
76
|
-
|
|
77
64
|
if (itemsJson) {
|
|
78
65
|
try {
|
|
79
66
|
var items = JSON.parse(itemsJson);
|
|
@@ -83,17 +70,16 @@ var StoredDuplicateLimitedQueue = /*#__PURE__*/function (_DuplicateLimitedQueu)
|
|
|
83
70
|
}
|
|
84
71
|
}
|
|
85
72
|
}
|
|
73
|
+
|
|
86
74
|
/**
|
|
87
75
|
* Save the current items in the queue, overwriting any previously stored queue.
|
|
88
76
|
* Any failure in saving will be silently ignored with the likely outcome that any previous
|
|
89
77
|
* saved items will remain unchanged in storage.
|
|
90
78
|
*/
|
|
91
|
-
|
|
92
79
|
}, {
|
|
93
80
|
key: "save",
|
|
94
81
|
value: function save() {
|
|
95
82
|
var itemsJson = JSON.stringify(this.getItems());
|
|
96
|
-
|
|
97
83
|
try {
|
|
98
84
|
this.storage.setItem(this.prefixedStorageKey, itemsJson);
|
|
99
85
|
} catch (e) {
|
|
@@ -101,10 +87,7 @@ var StoredDuplicateLimitedQueue = /*#__PURE__*/function (_DuplicateLimitedQueu)
|
|
|
101
87
|
}
|
|
102
88
|
}
|
|
103
89
|
}]);
|
|
104
|
-
|
|
105
90
|
return StoredDuplicateLimitedQueue;
|
|
106
91
|
}(DuplicateLimitedQueue);
|
|
107
|
-
|
|
108
92
|
_defineProperty(StoredDuplicateLimitedQueue, "storageKey", 'lastUsed');
|
|
109
|
-
|
|
110
93
|
export { StoredDuplicateLimitedQueue as default };
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
-
|
|
9
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
|
|
11
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
|
|
13
4
|
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
14
5
|
import { name as packageName, version as packageVersion } from '../../version.json';
|
|
15
6
|
export var createAndFireEventInElementsChannel = createAndFireEvent('fabric-elements');
|
|
16
|
-
|
|
17
7
|
var createEvent = function createEvent(eventType, action, actionSubject, actionSubjectId) {
|
|
18
8
|
var attributes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
19
9
|
return {
|
|
@@ -27,7 +17,6 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
27
17
|
}, attributes)
|
|
28
18
|
};
|
|
29
19
|
};
|
|
30
|
-
|
|
31
20
|
export var recordSucceeded = function recordSucceeded(source) {
|
|
32
21
|
return createEvent('operational', 'succeeded', 'recordEmojiSelection', undefined, {
|
|
33
22
|
source: source
|
|
@@ -38,13 +27,11 @@ export var recordFailed = function recordFailed(source) {
|
|
|
38
27
|
source: source
|
|
39
28
|
});
|
|
40
29
|
};
|
|
41
|
-
|
|
42
30
|
var emojiPickerEvent = function emojiPickerEvent(action) {
|
|
43
31
|
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
44
32
|
var actionSubjectId = arguments.length > 2 ? arguments[2] : undefined;
|
|
45
33
|
return createEvent('ui', action, 'emojiPicker', actionSubjectId, attributes);
|
|
46
34
|
};
|
|
47
|
-
|
|
48
35
|
export var openedPickerEvent = function openedPickerEvent() {
|
|
49
36
|
return emojiPickerEvent('opened');
|
|
50
37
|
};
|
|
@@ -67,37 +54,23 @@ var skinTones = [{
|
|
|
67
54
|
id: '-1f3ff',
|
|
68
55
|
skinToneModifier: 'dark'
|
|
69
56
|
}];
|
|
70
|
-
|
|
71
57
|
var getSkinTone = function getSkinTone(emojiId) {
|
|
72
58
|
if (!emojiId) {
|
|
73
59
|
return {};
|
|
74
60
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (emojiId.indexOf(id) !== -1) {
|
|
86
|
-
return {
|
|
87
|
-
skinToneModifier: skinToneModifier,
|
|
88
|
-
baseEmojiId: emojiId.replace(id, '')
|
|
89
|
-
};
|
|
90
|
-
}
|
|
61
|
+
for (var _i = 0, _skinTones = skinTones; _i < _skinTones.length; _i++) {
|
|
62
|
+
var _skinTones$_i = _skinTones[_i],
|
|
63
|
+
id = _skinTones$_i.id,
|
|
64
|
+
skinToneModifier = _skinTones$_i.skinToneModifier;
|
|
65
|
+
if (emojiId.indexOf(id) !== -1) {
|
|
66
|
+
return {
|
|
67
|
+
skinToneModifier: skinToneModifier,
|
|
68
|
+
baseEmojiId: emojiId.replace(id, '')
|
|
69
|
+
};
|
|
91
70
|
}
|
|
92
|
-
} catch (err) {
|
|
93
|
-
_iterator.e(err);
|
|
94
|
-
} finally {
|
|
95
|
-
_iterator.f();
|
|
96
71
|
}
|
|
97
|
-
|
|
98
72
|
return {};
|
|
99
73
|
};
|
|
100
|
-
|
|
101
74
|
export var pickerClickedEvent = function pickerClickedEvent(attributes) {
|
|
102
75
|
return emojiPickerEvent('clicked', _objectSpread(_objectSpread({}, getSkinTone(attributes.emojiId)), attributes), 'emoji');
|
|
103
76
|
};
|
|
@@ -107,12 +80,10 @@ export var categoryClickedEvent = function categoryClickedEvent(attributes) {
|
|
|
107
80
|
export var pickerSearchedEvent = function pickerSearchedEvent(attributes) {
|
|
108
81
|
return emojiPickerEvent('searched', attributes, 'query');
|
|
109
82
|
};
|
|
110
|
-
|
|
111
83
|
var skintoneSelectorEvent = function skintoneSelectorEvent(action) {
|
|
112
84
|
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
113
85
|
return createEvent('ui', action, 'emojiSkintoneSelector', undefined, attributes);
|
|
114
86
|
};
|
|
115
|
-
|
|
116
87
|
export var toneSelectedEvent = function toneSelectedEvent(attributes) {
|
|
117
88
|
return skintoneSelectorEvent('clicked', attributes);
|
|
118
89
|
};
|
|
@@ -122,11 +93,9 @@ export var toneSelectorOpenedEvent = function toneSelectorOpenedEvent(attributes
|
|
|
122
93
|
export var toneSelectorClosedEvent = function toneSelectorClosedEvent() {
|
|
123
94
|
return skintoneSelectorEvent('cancelled');
|
|
124
95
|
};
|
|
125
|
-
|
|
126
96
|
var emojiUploaderEvent = function emojiUploaderEvent(action, actionSubjectId, attributes) {
|
|
127
97
|
return createEvent('ui', action, 'emojiUploader', actionSubjectId, attributes);
|
|
128
98
|
};
|
|
129
|
-
|
|
130
99
|
export var uploadBeginButton = function uploadBeginButton() {
|
|
131
100
|
return emojiUploaderEvent('clicked', 'addButton');
|
|
132
101
|
};
|
|
@@ -154,7 +123,6 @@ export var deleteCancelEvent = function deleteCancelEvent(attributes) {
|
|
|
154
123
|
export var selectedFileEvent = function selectedFileEvent() {
|
|
155
124
|
return createEvent('ui', 'clicked', 'emojiUploader', 'selectFile');
|
|
156
125
|
};
|
|
157
|
-
|
|
158
126
|
var extractCommonAttributes = function extractCommonAttributes(query, emojiList) {
|
|
159
127
|
return {
|
|
160
128
|
queryLength: query ? query.length : 0,
|
|
@@ -164,13 +132,11 @@ var extractCommonAttributes = function extractCommonAttributes(query, emojiList)
|
|
|
164
132
|
}).filter(Boolean).slice(0, 20) : []
|
|
165
133
|
};
|
|
166
134
|
};
|
|
167
|
-
|
|
168
135
|
export var typeaheadCancelledEvent = function typeaheadCancelledEvent(duration, query, emojiList) {
|
|
169
136
|
return createEvent('ui', 'cancelled', 'emojiTypeahead', undefined, _objectSpread({
|
|
170
137
|
duration: duration
|
|
171
138
|
}, extractCommonAttributes(query, emojiList)));
|
|
172
139
|
};
|
|
173
|
-
|
|
174
140
|
var getPosition = function getPosition(emojiList, selectedEmoji) {
|
|
175
141
|
if (emojiList) {
|
|
176
142
|
var index = emojiList.findIndex(function (emoji) {
|
|
@@ -178,10 +144,8 @@ var getPosition = function getPosition(emojiList, selectedEmoji) {
|
|
|
178
144
|
});
|
|
179
145
|
return index === -1 ? undefined : index;
|
|
180
146
|
}
|
|
181
|
-
|
|
182
147
|
return;
|
|
183
148
|
};
|
|
184
|
-
|
|
185
149
|
export var typeaheadSelectedEvent = function typeaheadSelectedEvent(pressed, duration, emoji, emojiList, query, exactMatch) {
|
|
186
150
|
return createEvent('ui', pressed ? 'pressed' : 'clicked', 'emojiTypeahead', undefined, _objectSpread(_objectSpread(_objectSpread({
|
|
187
151
|
duration: duration,
|
|
@@ -195,31 +159,32 @@ export var typeaheadRenderedEvent = function typeaheadRenderedEvent(duration, qu
|
|
|
195
159
|
return createEvent('operational', 'rendered', 'emojiTypeahead', undefined, _objectSpread({
|
|
196
160
|
duration: duration
|
|
197
161
|
}, extractCommonAttributes(query, emojiList)));
|
|
198
|
-
};
|
|
162
|
+
};
|
|
199
163
|
|
|
164
|
+
// it's used in editor typeahead to fire success record analytics
|
|
200
165
|
export var recordSelectionSucceededSli = function recordSelectionSucceededSli(options) {
|
|
201
166
|
return function () {
|
|
202
167
|
if (options && options.createAnalyticsEvent) {
|
|
203
168
|
createAndFireEvent('editor')(recordSucceeded('typeahead'))(options.createAnalyticsEvent);
|
|
204
169
|
}
|
|
205
170
|
};
|
|
206
|
-
};
|
|
171
|
+
};
|
|
207
172
|
|
|
173
|
+
// it's used in editor typeahead to fire failure record analytics
|
|
208
174
|
export var recordSelectionFailedSli = function recordSelectionFailedSli(options) {
|
|
209
175
|
return function (err) {
|
|
210
176
|
if (options && options.createAnalyticsEvent) {
|
|
211
177
|
createAndFireEvent('editor')(recordFailed('typeahead'))(options.createAnalyticsEvent);
|
|
212
178
|
}
|
|
213
|
-
|
|
214
179
|
return Promise.reject(err);
|
|
215
180
|
};
|
|
216
181
|
};
|
|
182
|
+
|
|
217
183
|
/**
|
|
218
184
|
* Used for store failure metadata for analytics
|
|
219
185
|
* @param error The error could be a service error with {code, reason} or an Error
|
|
220
186
|
* @returns any
|
|
221
187
|
*/
|
|
222
|
-
|
|
223
188
|
export var extractErrorInfo = function extractErrorInfo(error) {
|
|
224
189
|
if (error instanceof Error) {
|
|
225
190
|
return {
|
|
@@ -227,6 +192,5 @@ export var extractErrorInfo = function extractErrorInfo(error) {
|
|
|
227
192
|
message: error.message
|
|
228
193
|
};
|
|
229
194
|
}
|
|
230
|
-
|
|
231
195
|
return error;
|
|
232
196
|
};
|