emoji-picker-react 4.22.3 → 5.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/README.md +331 -49
- package/dist/DomUtils/categoryNameFromDom.d.ts +1 -1
- package/dist/DomUtils/classNames.d.ts +23 -23
- package/dist/DomUtils/detectEmojyPartiallyBelowFold.d.ts +2 -2
- package/dist/DomUtils/elementPositionInRow.d.ts +5 -5
- package/dist/DomUtils/eventBelongsToPicker.d.ts +2 -0
- package/dist/DomUtils/focusElement.d.ts +5 -5
- package/dist/DomUtils/getActiveElement.d.ts +2 -2
- package/dist/DomUtils/isJsdom.d.ts +1 -0
- package/dist/DomUtils/isRtl.d.ts +1 -0
- package/dist/DomUtils/keyboardNavigation.d.ts +15 -8
- package/dist/DomUtils/scrollTo.d.ts +4 -5
- package/dist/DomUtils/selectors.d.ts +31 -35
- package/dist/EmojiPickerReact.d.ts +5 -5
- package/dist/Stylesheet/DedupedStyle.d.ts +13 -0
- package/dist/Stylesheet/stylesheet.d.ts +40 -37
- package/dist/components/ErrorBoundary.d.ts +15 -15
- package/dist/components/Layout/Absolute.d.ts +8 -8
- package/dist/components/Layout/Flex.d.ts +13 -13
- package/dist/components/Layout/Relative.d.ts +8 -8
- package/dist/components/Layout/Space.d.ts +7 -7
- package/dist/components/Reactions/BtnPlus.d.ts +2 -2
- package/dist/components/Reactions/DEFAULT_REACTIONS.d.ts +1 -1
- package/dist/components/Reactions/Reactions.d.ts +3 -2
- package/dist/components/atoms/Button.d.ts +11 -6
- package/dist/components/body/EmojiCategory.d.ts +13 -12
- package/dist/components/body/EmojiList.d.ts +7 -4
- package/dist/components/body/EmojiVariationPicker.d.ts +2 -2
- package/dist/components/body/MeasureEmoji.d.ts +2 -2
- package/dist/components/body/listComponents.d.ts +47 -0
- package/dist/components/context/ElementRefContext.d.ts +18 -16
- package/dist/components/context/PickerConfigContext.d.ts +14 -9
- package/dist/components/context/PickerContext.d.ts +57 -25
- package/dist/components/context/PickerDataContext.d.ts +23 -17
- package/dist/components/emoji/BaseEmojiProps.d.ts +14 -13
- package/dist/components/emoji/ClickableEmojiButton.d.ts +23 -15
- package/dist/components/emoji/Emoji.d.ts +18 -15
- package/dist/components/emoji/EmojiImg.d.ts +11 -11
- package/dist/components/emoji/ExportedEmoji.d.ts +11 -11
- package/dist/components/emoji/NativeEmoji.d.ts +6 -6
- package/dist/components/emoji/ViewOnlyEmoji.d.ts +3 -3
- package/dist/components/emoji/emojiStyles.d.ts +6 -1
- package/dist/components/footer/Preview.d.ts +7 -7
- package/dist/components/header/Header.d.ts +2 -2
- package/dist/components/header/Search/BtnClearSearch.d.ts +2 -2
- package/dist/components/header/Search/IcnSearch.d.ts +2 -2
- package/dist/components/header/Search/Search.d.ts +11 -3
- package/dist/components/header/SkinTonePicker/BtnSkinToneVariation.d.ts +12 -12
- package/dist/components/header/SkinTonePicker/SkinTonePicker.d.ts +11 -11
- package/dist/components/icons/svgIcons.d.ts +4 -0
- package/dist/components/main/PickerMainBehaviors.d.ts +4 -0
- package/dist/components/main/defaultAppearance.d.ts +12 -0
- package/dist/components/main/labelHeight.d.ts +1 -0
- package/dist/components/navigation/CategoryButton.d.ts +12 -12
- package/dist/components/navigation/CategoryNavIcon.d.ts +4 -4
- package/dist/components/navigation/CategoryNavigation.d.ts +19 -2
- package/dist/config/categoryConfig.d.ts +34 -34
- package/dist/config/cdnUrls.d.ts +2 -2
- package/dist/config/compareConfig.d.ts +10 -2
- package/dist/config/config.d.ts +166 -64
- package/dist/config/customEmojiConfig.d.ts +14 -14
- package/dist/config/defaultPickerConfiguration.d.ts +10 -0
- package/dist/config/mutableConfig.d.ts +32 -10
- package/dist/config/useConfig.d.ts +48 -36
- package/dist/data/defaultEmojiData.d.ts +9 -0
- package/dist/data/defaultEmojiData.js +40 -0
- package/dist/data/emojis-bn.d.mts +39 -0
- package/dist/data/emojis-bn.d.ts +38 -2
- package/dist/data/emojis-bn.js +25 -2
- package/dist/data/emojis-bn.mjs +2 -0
- package/dist/data/emojis-da.d.mts +39 -0
- package/dist/data/emojis-da.d.ts +38 -2
- package/dist/data/emojis-da.js +25 -2
- package/dist/data/emojis-da.mjs +2 -0
- package/dist/data/emojis-de.d.mts +39 -0
- package/dist/data/emojis-de.d.ts +38 -2
- package/dist/data/emojis-de.js +25 -2
- package/dist/data/emojis-de.mjs +2 -0
- package/dist/data/emojis-en-gb.d.mts +39 -0
- package/dist/data/emojis-en-gb.d.ts +38 -2
- package/dist/data/emojis-en-gb.js +25 -2
- package/dist/data/emojis-en-gb.mjs +2 -0
- package/dist/data/emojis-en.d.mts +39 -0
- package/dist/data/emojis-en.d.ts +38 -2
- package/dist/data/emojis-en.js +25 -2
- package/dist/data/emojis-en.mjs +2 -0
- package/dist/data/emojis-es-mx.d.mts +39 -0
- package/dist/data/emojis-es-mx.d.ts +38 -2
- package/dist/data/emojis-es-mx.js +25 -2
- package/dist/data/emojis-es-mx.mjs +2 -0
- package/dist/data/emojis-es.d.mts +39 -0
- package/dist/data/emojis-es.d.ts +38 -2
- package/dist/data/emojis-es.js +25 -2
- package/dist/data/emojis-es.mjs +2 -0
- package/dist/data/emojis-et.d.mts +39 -0
- package/dist/data/emojis-et.d.ts +38 -2
- package/dist/data/emojis-et.js +25 -2
- package/dist/data/emojis-et.mjs +2 -0
- package/dist/data/emojis-fi.d.mts +39 -0
- package/dist/data/emojis-fi.d.ts +38 -2
- package/dist/data/emojis-fi.js +25 -2
- package/dist/data/emojis-fi.mjs +2 -0
- package/dist/data/emojis-fr.d.mts +39 -0
- package/dist/data/emojis-fr.d.ts +38 -2
- package/dist/data/emojis-fr.js +25 -2
- package/dist/data/emojis-fr.mjs +2 -0
- package/dist/data/emojis-hi.d.mts +39 -0
- package/dist/data/emojis-hi.d.ts +38 -2
- package/dist/data/emojis-hi.js +25 -2
- package/dist/data/emojis-hi.mjs +2 -0
- package/dist/data/emojis-hu.d.mts +39 -0
- package/dist/data/emojis-hu.d.ts +38 -2
- package/dist/data/emojis-hu.js +25 -2
- package/dist/data/emojis-hu.mjs +2 -0
- package/dist/data/emojis-it.d.mts +39 -0
- package/dist/data/emojis-it.d.ts +38 -2
- package/dist/data/emojis-it.js +25 -2
- package/dist/data/emojis-it.mjs +2 -0
- package/dist/data/emojis-ja.d.mts +39 -0
- package/dist/data/emojis-ja.d.ts +38 -2
- package/dist/data/emojis-ja.js +25 -2
- package/dist/data/emojis-ja.mjs +2 -0
- package/dist/data/emojis-ko.d.mts +39 -0
- package/dist/data/emojis-ko.d.ts +38 -2
- package/dist/data/emojis-ko.js +25 -2
- package/dist/data/emojis-ko.mjs +2 -0
- package/dist/data/emojis-lt.d.mts +39 -0
- package/dist/data/emojis-lt.d.ts +38 -2
- package/dist/data/emojis-lt.js +25 -2
- package/dist/data/emojis-lt.mjs +2 -0
- package/dist/data/emojis-ms.d.mts +39 -0
- package/dist/data/emojis-ms.d.ts +38 -2
- package/dist/data/emojis-ms.js +25 -2
- package/dist/data/emojis-ms.mjs +2 -0
- package/dist/data/emojis-nb.d.mts +39 -0
- package/dist/data/emojis-nb.d.ts +38 -2
- package/dist/data/emojis-nb.js +25 -2
- package/dist/data/emojis-nb.mjs +2 -0
- package/dist/data/emojis-nl.d.mts +39 -0
- package/dist/data/emojis-nl.d.ts +38 -2
- package/dist/data/emojis-nl.js +25 -2
- package/dist/data/emojis-nl.mjs +2 -0
- package/dist/data/emojis-pl.d.mts +39 -0
- package/dist/data/emojis-pl.d.ts +38 -2
- package/dist/data/emojis-pl.js +25 -2
- package/dist/data/emojis-pl.mjs +2 -0
- package/dist/data/emojis-pt.d.mts +39 -0
- package/dist/data/emojis-pt.d.ts +38 -2
- package/dist/data/emojis-pt.js +25 -2
- package/dist/data/emojis-pt.mjs +2 -0
- package/dist/data/emojis-ru.d.mts +39 -0
- package/dist/data/emojis-ru.d.ts +38 -2
- package/dist/data/emojis-ru.js +25 -2
- package/dist/data/emojis-ru.mjs +2 -0
- package/dist/data/emojis-sv.d.mts +39 -0
- package/dist/data/emojis-sv.d.ts +38 -2
- package/dist/data/emojis-sv.js +25 -2
- package/dist/data/emojis-sv.mjs +2 -0
- package/dist/data/emojis-th.d.mts +39 -0
- package/dist/data/emojis-th.d.ts +38 -2
- package/dist/data/emojis-th.js +25 -2
- package/dist/data/emojis-th.mjs +2 -0
- package/dist/data/emojis-uk.d.mts +39 -0
- package/dist/data/emojis-uk.d.ts +38 -2
- package/dist/data/emojis-uk.js +25 -2
- package/dist/data/emojis-uk.mjs +2 -0
- package/dist/data/emojis-vi.d.mts +39 -0
- package/dist/data/emojis-vi.d.ts +38 -2
- package/dist/data/emojis-vi.js +25 -2
- package/dist/data/emojis-vi.mjs +2 -0
- package/dist/data/emojis-zh-hant.d.mts +39 -0
- package/dist/data/emojis-zh-hant.d.ts +38 -2
- package/dist/data/emojis-zh-hant.js +25 -2
- package/dist/data/emojis-zh-hant.mjs +2 -0
- package/dist/data/emojis-zh.d.mts +39 -0
- package/dist/data/emojis-zh.d.ts +38 -2
- package/dist/data/emojis-zh.js +25 -2
- package/dist/data/emojis-zh.mjs +2 -0
- package/dist/data/index.js +1 -0
- package/dist/data/registerDefaultEmojiData.d.ts +1 -0
- package/dist/data/registerDefaultEmojiData.js +3 -0
- package/dist/data/skinToneVariations.js +2 -2
- package/dist/data/skinToneVariations.ts +8 -7
- package/dist/data-core/pickerData.d.ts +12 -0
- package/dist/data-core/prepare.d.ts +23 -0
- package/dist/data-core/search.d.ts +13 -0
- package/dist/data-core/types.d.ts +23 -0
- package/dist/data.d.mts +72 -0
- package/dist/data.d.ts +72 -0
- package/dist/dataUtils/DataTypes.d.ts +23 -19
- package/dist/dataUtils/emojiSelectors.d.ts +15 -16
- package/dist/dataUtils/emojiUtils.d.ts +1 -12
- package/dist/dataUtils/nativeEmojiSequenceSupport.d.ts +10 -0
- package/dist/dataUtils/nativeEmojiSupport.d.ts +40 -0
- package/dist/dataUtils/parseNativeEmoji.d.ts +1 -1
- package/dist/dataUtils/suggested.d.ts +11 -11
- package/dist/dataUtils/suggestedEmojis.d.ts +7 -0
- package/dist/esm/chunks/chunk-7ZGTUZFB.mjs +8025 -0
- package/dist/esm/chunks/chunk-ACXAQEKG.mjs +149 -0
- package/dist/esm/chunks/chunk-F2KS7DCA.mjs +6735 -0
- package/dist/esm/chunks/chunk-L5W4PFRJ.mjs +14 -0
- package/dist/esm/chunks/chunk-LO4TPPLH.mjs +33 -0
- package/dist/esm/chunks/emojis-6L3GRBAP.mjs +7 -0
- package/dist/esm/data.mjs +11 -0
- package/dist/esm/index.mjs +279 -0
- package/dist/esm/primitives/index.mjs +8 -0
- package/dist/hooks/preloadEmoji.d.ts +5 -9
- package/dist/hooks/useActiveCategoryScrollDetection.d.ts +11 -11
- package/dist/hooks/useCategoryHeight.d.ts +7 -5
- package/dist/hooks/useCloseAllOpenToggles.d.ts +2 -2
- package/dist/hooks/useDataIdentityStabilityWarning.d.ts +13 -0
- package/dist/hooks/useDebouncedState.d.ts +1 -1
- package/dist/hooks/useDisallowMouseMove.d.ts +4 -4
- package/dist/hooks/useDisallowedEmojis.d.ts +2 -3
- package/dist/hooks/useEmojiPreviewEvents.d.ts +3 -3
- package/dist/hooks/useEmojiVirtualization.d.ts +22 -17
- package/dist/hooks/useFilter.d.ts +10 -16
- package/dist/hooks/useFocus.d.ts +3 -3
- package/dist/hooks/useInitialLoad.d.ts +2 -2
- package/dist/hooks/useIsEmojiHidden.d.ts +8 -8
- package/dist/hooks/useIsMounted.d.ts +1 -1
- package/dist/hooks/useIsSearchMode.d.ts +1 -1
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/hooks/useKeyboardNavigation.d.ts +3 -1
- package/dist/hooks/useMouseDownHandlers.d.ts +8 -4
- package/dist/hooks/useOnFocus.d.ts +1 -1
- package/dist/hooks/useOnScroll.d.ts +2 -2
- package/dist/hooks/useReactionsFocus.d.ts +1 -0
- package/dist/hooks/useRegisterRegion.d.ts +24 -0
- package/dist/hooks/useResolvedEmojiData.d.ts +37 -0
- package/dist/hooks/useScrollCategoryIntoView.d.ts +1 -1
- package/dist/hooks/useSearchController.d.ts +17 -0
- package/dist/hooks/useSearchResults.d.ts +8 -0
- package/dist/hooks/useSetVariationPicker.d.ts +2 -2
- package/dist/hooks/useShouldHideCustomEmojis.d.ts +1 -1
- package/dist/hooks/useShouldShowSkinTonePicker.d.ts +4 -4
- package/dist/index.d.mts +376 -0
- package/dist/index.d.ts +376 -9
- package/dist/index.js +2 -8
- package/dist/primitives/CategoryNav.d.ts +4 -0
- package/dist/primitives/Empty.d.ts +6 -0
- package/dist/primitives/List.d.ts +4 -0
- package/dist/primitives/LoadError.d.ts +8 -0
- package/dist/primitives/Loading.d.ts +4 -0
- package/dist/primitives/Panel.d.ts +3 -0
- package/dist/primitives/Preview.d.ts +3 -0
- package/dist/primitives/Reactions.d.ts +2 -0
- package/dist/primitives/Root.d.ts +26 -0
- package/dist/primitives/Search.d.ts +5 -0
- package/dist/primitives/SearchInput.d.ts +3 -0
- package/dist/primitives/SkinTone.d.ts +4 -0
- package/dist/primitives/Viewport.d.ts +19 -0
- package/dist/primitives/appearance.d.ts +3 -0
- package/dist/primitives/components.d.ts +27 -0
- package/dist/primitives/hooks.d.ts +48 -0
- package/dist/primitives/index.d.mts +561 -0
- package/dist/primitives/index.d.ts +561 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/nativeProps.d.ts +15 -0
- package/dist/primitives/scope.d.ts +13 -0
- package/dist/primitives/structuralStyles.d.ts +16 -0
- package/dist/primitives/tokens.d.ts +18 -0
- package/dist/primitives/types.d.ts +85 -0
- package/dist/state/activeEmojiStore.d.ts +7 -0
- package/dist/state/navigationRegistry.d.ts +61 -0
- package/dist/state/regionTraversal.d.ts +20 -0
- package/dist/typeRefinements/typeRefinements.d.ts +6 -6
- package/dist/types/exposedTypes.d.ts +16 -6
- package/dist/types/exposedTypes.js +5 -0
- package/dist/virtualization/virtualizationHelpers.d.ts +22 -18
- package/llms-full.txt +3683 -0
- package/llms.txt +66 -480
- package/package.json +180 -66
- package/src/DomUtils/categoryNameFromDom.ts +1 -1
- package/src/DomUtils/classNames.ts +1 -4
- package/src/DomUtils/elementPositionInRow.ts +28 -6
- package/src/DomUtils/eventBelongsToPicker.ts +17 -0
- package/src/DomUtils/getActiveElement.ts +7 -1
- package/src/DomUtils/isJsdom.ts +12 -0
- package/src/DomUtils/isRtl.ts +5 -0
- package/src/DomUtils/keyboardNavigation.ts +164 -144
- package/src/DomUtils/scrollTo.ts +20 -18
- package/src/DomUtils/selectors.ts +30 -127
- package/src/EmojiPickerReact.tsx +155 -48
- package/src/Stylesheet/DedupedStyle.tsx +80 -0
- package/src/Stylesheet/stylesheet.tsx +128 -59
- package/src/components/Layout/Flex.tsx +12 -11
- package/src/components/Reactions/BtnPlus.tsx +61 -51
- package/src/components/Reactions/Reactions.tsx +113 -55
- package/src/components/atoms/Button.tsx +18 -15
- package/src/components/body/EmojiCategory.tsx +77 -40
- package/src/components/body/EmojiList.tsx +107 -44
- package/src/components/body/EmojiVariationPicker.tsx +113 -66
- package/src/components/body/MeasureEmoji.tsx +9 -2
- package/src/components/body/listComponents.tsx +79 -0
- package/src/components/context/ElementRefContext.tsx +46 -35
- package/src/components/context/PickerConfigContext.tsx +55 -40
- package/src/components/context/PickerContext.tsx +567 -92
- package/src/components/context/PickerDataContext.tsx +114 -99
- package/src/components/emoji/BaseEmojiProps.ts +5 -4
- package/src/components/emoji/ClickableEmojiButton.tsx +148 -63
- package/src/components/emoji/Emoji.tsx +24 -2
- package/src/components/emoji/EmojiImg.tsx +13 -12
- package/src/components/emoji/ExportedEmoji.tsx +5 -4
- package/src/components/emoji/NativeEmoji.tsx +19 -16
- package/src/components/emoji/ViewOnlyEmoji.tsx +55 -30
- package/src/components/emoji/emojiStyles.ts +12 -11
- package/src/components/footer/Preview.tsx +86 -91
- package/src/components/header/Header.tsx +21 -6
- package/src/components/header/Search/BtnClearSearch.tsx +69 -55
- package/src/components/header/Search/IcnSearch.tsx +21 -21
- package/src/components/header/Search/Search.tsx +79 -137
- package/src/components/header/SkinTonePicker/BtnSkinToneVariation.tsx +99 -62
- package/src/components/header/SkinTonePicker/SkinTonePicker.tsx +84 -46
- package/src/components/icons/svgIcons.ts +17 -0
- package/src/components/main/PickerMainBehaviors.tsx +163 -0
- package/src/components/main/defaultAppearance.tsx +189 -0
- package/src/components/main/labelHeight.ts +5 -0
- package/src/components/navigation/CategoryButton.tsx +83 -57
- package/src/components/navigation/CategoryNavIcon.tsx +73 -194
- package/src/components/navigation/CategoryNavigation.tsx +118 -46
- package/src/config/categoryConfig.ts +7 -3
- package/src/config/cdnUrls.ts +11 -21
- package/src/config/compareConfig.ts +128 -30
- package/src/config/config.ts +228 -24
- package/src/config/defaultPickerConfiguration.ts +7 -0
- package/src/config/mutableConfig.ts +44 -20
- package/src/config/useConfig.ts +130 -37
- package/src/data/defaultEmojiData.ts +49 -0
- package/src/data/registerDefaultEmojiData.ts +8 -0
- package/src/data/skinToneVariations.ts +8 -7
- package/src/data-core/pickerData.ts +171 -0
- package/src/data-core/prepare.ts +163 -0
- package/src/data-core/search.ts +122 -0
- package/src/data-core/types.ts +36 -0
- package/src/data.ts +10 -0
- package/src/dataUtils/DataTypes.ts +4 -0
- package/src/dataUtils/emojiSelectors.ts +59 -63
- package/src/dataUtils/emojiUtils.ts +17 -74
- package/src/dataUtils/nativeEmojiSequenceSupport.ts +116 -0
- package/src/dataUtils/nativeEmojiSupport.ts +160 -0
- package/src/dataUtils/parseNativeEmoji.ts +3 -4
- package/src/dataUtils/suggested.ts +8 -4
- package/src/dataUtils/suggestedEmojis.ts +92 -0
- package/src/env.d.ts +4 -0
- package/src/hooks/preloadEmoji.ts +2 -47
- package/src/hooks/useActiveCategoryScrollDetection.ts +28 -16
- package/src/hooks/useCategoryHeight.ts +116 -10
- package/src/hooks/useDataIdentityStabilityWarning.ts +86 -0
- package/src/hooks/useDebouncedState.ts +13 -1
- package/src/hooks/useDisallowedEmojis.ts +31 -42
- package/src/hooks/useEmojiPreviewEvents.ts +43 -10
- package/src/hooks/useEmojiVirtualization.tsx +112 -52
- package/src/hooks/useFilter.ts +92 -132
- package/src/hooks/useFocus.ts +14 -24
- package/src/hooks/useIsEmojiHidden.ts +22 -14
- package/src/hooks/useKeyboardNavigation.ts +412 -432
- package/src/hooks/useMouseDownHandlers.ts +91 -16
- package/src/hooks/useOnFocus.ts +12 -3
- package/src/hooks/useOnScroll.ts +18 -2
- package/src/hooks/useReactionsFocus.ts +118 -0
- package/src/hooks/useRegisterRegion.ts +92 -0
- package/src/hooks/useResolvedEmojiData.ts +200 -0
- package/src/hooks/useScrollCategoryIntoView.ts +74 -12
- package/src/hooks/useSearchController.ts +369 -0
- package/src/hooks/useSearchResults.ts +51 -0
- package/src/hooks/useSetVariationPicker.ts +4 -1
- package/src/index.tsx +67 -5
- package/src/primitives/CategoryNav.tsx +40 -0
- package/src/primitives/Empty.tsx +68 -0
- package/src/primitives/List.tsx +61 -0
- package/src/primitives/LoadError.tsx +38 -0
- package/src/primitives/Loading.tsx +60 -0
- package/src/primitives/Panel.tsx +47 -0
- package/src/primitives/Preview.tsx +38 -0
- package/src/primitives/Reactions.tsx +2 -0
- package/src/primitives/Root.tsx +398 -0
- package/src/primitives/Search.tsx +41 -0
- package/src/primitives/SearchInput.tsx +110 -0
- package/src/primitives/SkinTone.tsx +76 -0
- package/src/primitives/Viewport.tsx +204 -0
- package/src/primitives/appearance.tsx +7 -0
- package/src/primitives/components.tsx +30 -0
- package/src/primitives/hooks.ts +165 -0
- package/src/primitives/index.ts +94 -0
- package/src/primitives/nativeProps.ts +90 -0
- package/src/primitives/scope.tsx +109 -0
- package/src/primitives/structuralStyles.tsx +136 -0
- package/src/primitives/tokens.ts +150 -0
- package/src/primitives/types.ts +192 -0
- package/src/state/activeEmojiStore.ts +39 -0
- package/src/state/navigationRegistry.ts +209 -0
- package/src/state/regionTraversal.ts +116 -0
- package/src/svg.d.ts +2 -2
- package/src/types/exposedTypes.ts +28 -1
- package/src/virtualization/virtualizationHelpers.ts +29 -8
- package/dist/components/body/Body.d.ts +0 -2
- package/dist/components/main/PickerMain.d.ts +0 -7
- package/dist/dataUtils/alphaNumericEmojiIndex.d.ts +0 -5
- package/dist/emoji-picker-react.cjs.development.js +0 -31413
- package/dist/emoji-picker-react.cjs.development.js.map +0 -1
- package/dist/emoji-picker-react.cjs.production.min.js +0 -2
- package/dist/emoji-picker-react.cjs.production.min.js.map +0 -1
- package/dist/emoji-picker-react.esm.js +0 -31411
- package/dist/emoji-picker-react.esm.js.map +0 -1
- package/dist/hooks/useHideEmojisByUniocode.d.ts +0 -1
- package/src/components/body/Body.tsx +0 -43
- package/src/components/main/PickerMain.tsx +0 -249
- package/src/dataUtils/alphaNumericEmojiIndex.ts +0 -21
package/src/hooks/useFilter.ts
CHANGED
|
@@ -1,148 +1,123 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
1
3
|
import { scrollTo } from '../DomUtils/scrollTo';
|
|
2
|
-
import {
|
|
3
|
-
usePickerMainRef,
|
|
4
|
-
useSearchInputRef,
|
|
5
|
-
} from '../components/context/ElementRefContext';
|
|
4
|
+
import { usePickerMainRef } from '../components/context/ElementRefContext';
|
|
6
5
|
import {
|
|
7
6
|
FilterState,
|
|
7
|
+
useFilterQueryOrderRef,
|
|
8
8
|
useFilterRef,
|
|
9
|
+
useNavigationRegistry,
|
|
9
10
|
useSearchTermState,
|
|
10
11
|
} from '../components/context/PickerContext';
|
|
11
|
-
import {
|
|
12
|
+
import { usePickerDataContext } from '../components/context/PickerDataContext';
|
|
13
|
+
import { normalizeQuery } from '../data-core/prepare';
|
|
12
14
|
import { DataEmoji } from '../dataUtils/DataTypes';
|
|
13
15
|
import { emojiNames } from '../dataUtils/emojiUtils';
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Bound on cached per-query filter dicts per Root. Dicts are cheaply
|
|
19
|
+
* rebuilt from the shared memoized core, so a long typing session keeps
|
|
20
|
+
* only a recent window instead of growing without bound.
|
|
21
|
+
*/
|
|
22
|
+
const MAX_FILTER_QUERIES = 50;
|
|
16
23
|
|
|
17
24
|
function useSetFilterRef() {
|
|
18
25
|
const filterRef = useFilterRef();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function useClearSearch() {
|
|
32
|
-
const applySearch = useApplySearch();
|
|
33
|
-
const SearchInputRef = useSearchInputRef();
|
|
34
|
-
const focusSearchInput = useFocusSearchInput();
|
|
35
|
-
|
|
36
|
-
return function clearSearch() {
|
|
37
|
-
if (SearchInputRef.current) {
|
|
38
|
-
SearchInputRef.current.value = '';
|
|
26
|
+
const orderRef = useFilterQueryOrderRef();
|
|
27
|
+
|
|
28
|
+
return function setFilter(nextValue: string, dict: FilterDict): void {
|
|
29
|
+
// Copy-on-write into a fresh object: the ref never aliases shared
|
|
30
|
+
// snapshot state, and spread defines own properties (no prototype
|
|
31
|
+
// mutation for adversarial queries such as "__proto__").
|
|
32
|
+
const next: FilterState = { ...filterRef.current, [nextValue]: dict };
|
|
33
|
+
const order = orderRef.current;
|
|
34
|
+
if (!order.includes(nextValue)) {
|
|
35
|
+
order.push(nextValue);
|
|
39
36
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function useAppendSearch() {
|
|
47
|
-
const SearchInputRef = useSearchInputRef();
|
|
48
|
-
const applySearch = useApplySearch();
|
|
49
|
-
|
|
50
|
-
return function appendSearch(str: string) {
|
|
51
|
-
if (SearchInputRef.current) {
|
|
52
|
-
SearchInputRef.current.value = `${SearchInputRef.current.value}${str}`;
|
|
53
|
-
applySearch(getNormalizedSearchTerm(SearchInputRef.current.value));
|
|
54
|
-
} else {
|
|
55
|
-
applySearch(getNormalizedSearchTerm(str));
|
|
37
|
+
while (order.length > MAX_FILTER_QUERIES) {
|
|
38
|
+
const oldest = order.shift() as string;
|
|
39
|
+
delete next[oldest];
|
|
56
40
|
}
|
|
41
|
+
filterRef.current = next;
|
|
57
42
|
};
|
|
58
43
|
}
|
|
59
44
|
|
|
60
45
|
export function useFilter() {
|
|
61
|
-
const SearchInputRef = useSearchInputRef();
|
|
62
46
|
const filterRef = useFilterRef();
|
|
63
47
|
const setFilterRef = useSetFilterRef();
|
|
64
48
|
const applySearch = useApplySearch();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
filterRef.current,
|
|
69
|
-
searchTerm,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
onChange,
|
|
74
|
-
searchTerm,
|
|
75
|
-
SearchInputRef,
|
|
76
|
-
statusSearchResults,
|
|
77
|
-
};
|
|
49
|
+
const { queryFilterDict } = usePickerDataContext();
|
|
50
|
+
// Managed SearchInput owns announcements; this hook only applies filters.
|
|
51
|
+
return { onChange };
|
|
78
52
|
|
|
79
53
|
function onChange(inputValue: string) {
|
|
80
54
|
const filter = filterRef.current;
|
|
81
55
|
|
|
82
|
-
|
|
56
|
+
// Normalized derived query: the visible/callback value
|
|
57
|
+
// stays raw, filtering folds case and trims surrounding whitespace.
|
|
58
|
+
// Matching itself runs in the single shared prepared core.
|
|
59
|
+
const nextValue = normalizeQuery(inputValue);
|
|
83
60
|
|
|
84
|
-
if (
|
|
61
|
+
if (!nextValue) {
|
|
85
62
|
return applySearch(nextValue);
|
|
86
63
|
}
|
|
87
|
-
|
|
88
|
-
const longestMatch = findLongestMatch(nextValue, filter);
|
|
89
|
-
|
|
90
|
-
if (!longestMatch) {
|
|
91
|
-
// Can we even get here?
|
|
92
|
-
// If so, we need to search among all emojis
|
|
64
|
+
if (hasOwnQuery(filter, nextValue)) {
|
|
93
65
|
return applySearch(nextValue);
|
|
94
66
|
}
|
|
95
67
|
|
|
96
|
-
setFilterRef((
|
|
97
|
-
Object.assign(current, {
|
|
98
|
-
[nextValue]: filterEmojiObjectByKeyword(longestMatch, nextValue),
|
|
99
|
-
}),
|
|
100
|
-
);
|
|
68
|
+
setFilterRef(nextValue, queryFilterDict(nextValue));
|
|
101
69
|
applySearch(nextValue);
|
|
102
70
|
}
|
|
103
71
|
}
|
|
104
72
|
|
|
73
|
+
function hasOwnQuery(filter: FilterState, query: string): boolean {
|
|
74
|
+
return Object.prototype.hasOwnProperty.call(filter, query);
|
|
75
|
+
}
|
|
76
|
+
|
|
105
77
|
function useApplySearch() {
|
|
106
78
|
const [, setSearchTerm] = useSearchTermState();
|
|
107
79
|
const PickerMainRef = usePickerMainRef();
|
|
80
|
+
const registry = useNavigationRegistry();
|
|
81
|
+
// A search frame pending at unmount must not schedule post-unmount
|
|
82
|
+
// debounce work (the debounced state also clears its own timer, so
|
|
83
|
+
// both stages of the pipeline die with the Root).
|
|
84
|
+
const mountedRef = React.useRef(true);
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
mountedRef.current = true;
|
|
87
|
+
return () => {
|
|
88
|
+
mountedRef.current = false;
|
|
89
|
+
};
|
|
90
|
+
}, []);
|
|
108
91
|
|
|
109
92
|
return function applySearch(searchTerm: string) {
|
|
93
|
+
// A new accepted filter obsoletes pending grid materialize/focus work.
|
|
94
|
+
registry.invalidate();
|
|
95
|
+
// The scroll back to the top lands after the debounce; navigation in
|
|
96
|
+
// the meantime (e.g. a category tab clicked right after clearing the
|
|
97
|
+
// search) supersedes it instead of being yanked back to the top.
|
|
98
|
+
const token = registry.currentGeneration();
|
|
110
99
|
requestAnimationFrame(() => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
if (!mountedRef.current) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
setSearchTerm(searchTerm).then(() => {
|
|
104
|
+
if (registry.isCurrent(token)) {
|
|
105
|
+
scrollTo(PickerMainRef.current, 0, () => registry.isCurrent(token));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
116
108
|
});
|
|
117
109
|
};
|
|
118
110
|
}
|
|
119
111
|
|
|
120
|
-
export function filterEmojiObjectByKeyword(
|
|
121
|
-
emojis: FilterDict,
|
|
122
|
-
keyword: string,
|
|
123
|
-
): FilterDict {
|
|
124
|
-
const filtered: FilterDict = {};
|
|
125
|
-
|
|
126
|
-
for (const unified in emojis) {
|
|
127
|
-
const emoji = emojis[unified];
|
|
128
|
-
|
|
129
|
-
if (hasMatch(emoji, keyword)) {
|
|
130
|
-
filtered[unified] = emoji;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return filtered;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function hasMatch(emoji: DataEmoji, keyword: string): boolean {
|
|
138
|
-
return emojiNames(emoji).some((name) => name.includes(keyword));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
112
|
export function useIsEmojiFiltered(): (unified: string) => boolean {
|
|
142
113
|
const { current: filter } = useFilterRef();
|
|
143
114
|
const [searchTerm] = useSearchTermState();
|
|
144
115
|
|
|
145
|
-
return (
|
|
116
|
+
return React.useCallback(
|
|
117
|
+
(unified: string) =>
|
|
118
|
+
isEmojiFilteredBySearchTerm(unified, filter, searchTerm),
|
|
119
|
+
[filter, searchTerm],
|
|
120
|
+
);
|
|
146
121
|
}
|
|
147
122
|
|
|
148
123
|
export function isEmojiFilteredBySearchTerm(
|
|
@@ -159,45 +134,30 @@ export function isEmojiFilteredBySearchTerm(
|
|
|
159
134
|
|
|
160
135
|
export type FilterDict = Record<string, DataEmoji>;
|
|
161
136
|
|
|
137
|
+
export function filterEmojiObjectByKeyword(
|
|
138
|
+
emojis: FilterDict,
|
|
139
|
+
keyword: string,
|
|
140
|
+
): FilterDict {
|
|
141
|
+
const filtered: FilterDict = {};
|
|
142
|
+
Object.keys(emojis).forEach((unified) => {
|
|
143
|
+
const emoji = emojis[unified];
|
|
144
|
+
if (
|
|
145
|
+
emojiNames(emoji).some((name) => name.toLowerCase().includes(keyword))
|
|
146
|
+
) {
|
|
147
|
+
filtered[unified] = emoji;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return filtered;
|
|
151
|
+
}
|
|
152
|
+
|
|
162
153
|
export function findLongestMatch(
|
|
163
154
|
keyword: string,
|
|
164
155
|
dict: Record<string, FilterDict> | null,
|
|
165
156
|
): FilterDict | null {
|
|
166
|
-
if (!dict)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (dict[keyword]) {
|
|
171
|
-
return dict[keyword];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const longestMatchingKey = Object.keys(dict)
|
|
175
|
-
.sort((a, b) => b.length - a.length)
|
|
157
|
+
if (!dict) return null;
|
|
158
|
+
if (dict[keyword]) return dict[keyword];
|
|
159
|
+
const longest = Object.keys(dict)
|
|
160
|
+
.sort((left, right) => right.length - left.length)
|
|
176
161
|
.find((key) => keyword.includes(key));
|
|
177
|
-
|
|
178
|
-
if (longestMatchingKey) {
|
|
179
|
-
return dict[longestMatchingKey];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export function getNormalizedSearchTerm(str: string): string {
|
|
186
|
-
if (!str || typeof str !== 'string') {
|
|
187
|
-
return '';
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return str.trim().toLowerCase();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function getStatusSearchResults(
|
|
194
|
-
filterState: FilterState,
|
|
195
|
-
searchTerm: string,
|
|
196
|
-
): string {
|
|
197
|
-
if (!filterState?.[searchTerm]) return '';
|
|
198
|
-
|
|
199
|
-
const searchResultsCount =
|
|
200
|
-
Object.entries(filterState?.[searchTerm])?.length || 0;
|
|
201
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
202
|
-
return useSearchResultsConfig(searchResultsCount);
|
|
162
|
+
return longest ? dict[longest] : null;
|
|
203
163
|
}
|
package/src/hooks/useFocus.ts
CHANGED
|
@@ -1,40 +1,30 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
|
|
3
|
-
import { focusElement
|
|
3
|
+
import { focusElement } from '../DomUtils/focusElement';
|
|
4
|
+
import { NullableElement } from '../DomUtils/selectors';
|
|
4
5
|
import {
|
|
6
|
+
ElementRef,
|
|
5
7
|
useCategoryNavigationRef,
|
|
6
8
|
useSearchInputRef,
|
|
7
9
|
useSkinTonePickerRef,
|
|
8
10
|
} from '../components/context/ElementRefContext';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
const SearchInputRef = useSearchInputRef();
|
|
12
|
-
|
|
12
|
+
function useFocusRef(ref: ElementRef, child = false) {
|
|
13
13
|
return useCallback(() => {
|
|
14
|
-
focusElement(
|
|
15
|
-
|
|
14
|
+
focusElement(
|
|
15
|
+
(child ? ref.current?.firstElementChild : ref.current) as NullableElement,
|
|
16
|
+
);
|
|
17
|
+
}, [ref, child]);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
export function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return useCallback(() => {
|
|
22
|
-
if (!SkinTonePickerRef.current) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
20
|
+
export function useFocusSearchInput() {
|
|
21
|
+
return useFocusRef(useSearchInputRef());
|
|
22
|
+
}
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
export function useFocusSkinTonePicker() {
|
|
25
|
+
return useFocusRef(useSkinTonePickerRef(), true);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
export function useFocusCategoryNavigation() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return useCallback(() => {
|
|
34
|
-
if (!CategoryNavigationRef.current) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
focusFirstElementChild(CategoryNavigationRef.current);
|
|
39
|
-
}, [CategoryNavigationRef]);
|
|
29
|
+
return useFocusRef(useCategoryNavigationRef(), true);
|
|
40
30
|
}
|
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useActiveSkinToneState,
|
|
5
|
+
useEmojisThatFailedToLoadState,
|
|
6
|
+
} from '../components/context/PickerContext';
|
|
2
7
|
import { DataEmoji } from '../dataUtils/DataTypes';
|
|
3
|
-
import { emojiUnified } from '../dataUtils/emojiUtils';
|
|
8
|
+
import { emojiUnified, emojiCanonicalUnified } from '../dataUtils/emojiUtils';
|
|
4
9
|
|
|
5
10
|
import { useIsEmojiFiltered } from './useFilter';
|
|
6
11
|
|
|
7
12
|
export function useIsEmojiHidden(): (emoji: DataEmoji) => IsHiddenReturn {
|
|
8
|
-
const [
|
|
13
|
+
const [activeSkinTone] = useActiveSkinToneState();
|
|
14
|
+
// The tuple changes when its Root-local Set is mutated by an image error.
|
|
15
|
+
const failures = useEmojisThatFailedToLoadState();
|
|
9
16
|
const isEmojiFiltered = useIsEmojiFiltered();
|
|
10
17
|
|
|
11
|
-
return (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const filteredOut = isEmojiFiltered(unified);
|
|
18
|
+
return useCallback(
|
|
19
|
+
(emoji: DataEmoji): IsHiddenReturn => {
|
|
20
|
+
const failedToLoad = failures[0].has(emojiUnified(emoji, activeSkinTone));
|
|
21
|
+
const filteredOut = isEmojiFiltered(emojiCanonicalUnified(emoji));
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
return {
|
|
24
|
+
failedToLoad,
|
|
25
|
+
filteredOut,
|
|
26
|
+
hidden: failedToLoad || filteredOut,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
[activeSkinTone, failures, isEmojiFiltered],
|
|
30
|
+
);
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
type IsHiddenReturn = {
|