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
|
@@ -5,6 +5,7 @@ import { cx } from 'shipstyles';
|
|
|
5
5
|
import { ClassNames } from '../../DomUtils/classNames';
|
|
6
6
|
import { focusFirstVisibleEmoji } from '../../DomUtils/keyboardNavigation';
|
|
7
7
|
import {
|
|
8
|
+
allUnifiedFromEmojiElement,
|
|
8
9
|
buttonFromTarget,
|
|
9
10
|
elementHeight,
|
|
10
11
|
emojiTrueOffsetTop,
|
|
@@ -20,16 +21,21 @@ import {
|
|
|
20
21
|
emojiUnified,
|
|
21
22
|
emojiVariations,
|
|
22
23
|
} from '../../dataUtils/emojiUtils';
|
|
24
|
+
import { useIsEmojiDisallowed } from '../../hooks/useDisallowedEmojis';
|
|
25
|
+
import { useDefaultAppearance } from '../../primitives/appearance';
|
|
26
|
+
import { EmojiStyle } from '../../types/exposedTypes';
|
|
23
27
|
import {
|
|
24
28
|
useAnchoredEmojiRef,
|
|
25
29
|
useBodyRef,
|
|
26
30
|
useSetAnchoredEmojiRef,
|
|
27
31
|
useVariationPickerRef,
|
|
28
32
|
} from '../context/ElementRefContext';
|
|
29
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
useEmojiVariationPickerState,
|
|
35
|
+
useRequestNativeProbe,
|
|
36
|
+
} from '../context/PickerContext';
|
|
30
37
|
import { ClickableEmoji } from '../emoji/Emoji';
|
|
31
|
-
|
|
32
|
-
import SVGTriangle from './svg/triangle.svg';
|
|
38
|
+
import { TRIANGLE_ICON as SVGTriangle } from '../icons/svgIcons';
|
|
33
39
|
|
|
34
40
|
enum Direction {
|
|
35
41
|
Up,
|
|
@@ -38,10 +44,12 @@ enum Direction {
|
|
|
38
44
|
|
|
39
45
|
// eslint-disable-next-line complexity
|
|
40
46
|
export function EmojiVariationPicker() {
|
|
47
|
+
const appearance = useDefaultAppearance();
|
|
41
48
|
const AnchoredEmojiRef = useAnchoredEmojiRef();
|
|
42
49
|
const VariationPickerRef = useVariationPickerRef();
|
|
43
50
|
const [emoji] = useEmojiVariationPickerState();
|
|
44
51
|
const emojiStyle = useEmojiStyleConfig();
|
|
52
|
+
const isEmojiDisallowed = useIsEmojiDisallowed();
|
|
45
53
|
|
|
46
54
|
const { getTop, getMenuDirection } =
|
|
47
55
|
useVariationPickerTop(VariationPickerRef);
|
|
@@ -54,6 +62,11 @@ export function EmojiVariationPicker() {
|
|
|
54
62
|
const visible = Boolean(
|
|
55
63
|
emoji &&
|
|
56
64
|
button &&
|
|
65
|
+
(emojiStyle !== EmojiStyle.NATIVE ||
|
|
66
|
+
!isEmojiDisallowed(
|
|
67
|
+
emoji,
|
|
68
|
+
allUnifiedFromEmojiElement(button).unified ?? undefined,
|
|
69
|
+
)) &&
|
|
57
70
|
emojiHasVariations(emoji) &&
|
|
58
71
|
button.classList.contains(ClassNames.emojiHasVariations),
|
|
59
72
|
);
|
|
@@ -66,6 +79,14 @@ export function EmojiVariationPicker() {
|
|
|
66
79
|
focusFirstVisibleEmoji(VariationPickerRef.current);
|
|
67
80
|
}, [VariationPickerRef, visible, AnchoredEmojiRef]);
|
|
68
81
|
|
|
82
|
+
// Tones are checked when the menu opens, not for every grid cell.
|
|
83
|
+
const requestNativeProbe = useRequestNativeProbe();
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (visible && emoji) {
|
|
86
|
+
requestNativeProbe([emojiUnified(emoji)].concat(emojiVariations(emoji)));
|
|
87
|
+
}
|
|
88
|
+
}, [requestNativeProbe, visible, emoji]);
|
|
89
|
+
|
|
69
90
|
let top, pointerStyle;
|
|
70
91
|
|
|
71
92
|
if (!visible && AnchoredEmojiRef.current) {
|
|
@@ -78,17 +99,19 @@ export function EmojiVariationPicker() {
|
|
|
78
99
|
return (
|
|
79
100
|
<div
|
|
80
101
|
ref={VariationPickerRef}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
getMenuDirection() === Direction.Down && styles.pointingUp,
|
|
84
|
-
visible && styles.visible,
|
|
85
|
-
)}
|
|
102
|
+
data-epr-part="variation-picker"
|
|
103
|
+
className={variationClassName(appearance, visible, getMenuDirection())}
|
|
86
104
|
style={{ top }}
|
|
87
105
|
>
|
|
88
106
|
{visible && emoji
|
|
89
107
|
? [emojiUnified(emoji)]
|
|
90
108
|
.concat(emojiVariations(emoji))
|
|
91
109
|
.slice(0, 6)
|
|
110
|
+
.filter(
|
|
111
|
+
(unified) =>
|
|
112
|
+
emojiStyle !== EmojiStyle.NATIVE ||
|
|
113
|
+
!isEmojiDisallowed(emoji, unified),
|
|
114
|
+
)
|
|
92
115
|
.map((unified) => (
|
|
93
116
|
<ClickableEmoji
|
|
94
117
|
key={unified}
|
|
@@ -100,12 +123,30 @@ export function EmojiVariationPicker() {
|
|
|
100
123
|
/>
|
|
101
124
|
))
|
|
102
125
|
: null}
|
|
103
|
-
|
|
126
|
+
{appearance && (
|
|
127
|
+
<div className={cx(styles.pointer)} style={pointerStyle} />
|
|
128
|
+
)}
|
|
104
129
|
</div>
|
|
105
130
|
);
|
|
106
131
|
}
|
|
107
132
|
|
|
108
|
-
function
|
|
133
|
+
function variationClassName(
|
|
134
|
+
appearance: boolean,
|
|
135
|
+
visible: boolean,
|
|
136
|
+
direction: Direction,
|
|
137
|
+
) {
|
|
138
|
+
return cx(
|
|
139
|
+
styles.geometry,
|
|
140
|
+
appearance && styles.variationPicker,
|
|
141
|
+
appearance && direction === Direction.Down && styles.pointingUp,
|
|
142
|
+
visible && styles.visibleGeometry,
|
|
143
|
+
appearance && visible && styles.visible,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function usePointerStyle(
|
|
148
|
+
VariationPickerRef: React.RefObject<HTMLElement | null>,
|
|
149
|
+
) {
|
|
109
150
|
const AnchoredEmojiRef = useAnchoredEmojiRef();
|
|
110
151
|
return function getPointerStyle() {
|
|
111
152
|
const style: React.CSSProperties = {};
|
|
@@ -131,7 +172,7 @@ function usePointerStyle(VariationPickerRef: React.RefObject<HTMLElement>) {
|
|
|
131
172
|
}
|
|
132
173
|
|
|
133
174
|
function useVariationPickerTop(
|
|
134
|
-
VariationPickerRef: React.RefObject<HTMLElement>,
|
|
175
|
+
VariationPickerRef: React.RefObject<HTMLElement | null>,
|
|
135
176
|
) {
|
|
136
177
|
const AnchoredEmojiRef = useAnchoredEmojiRef();
|
|
137
178
|
const BodyRef = useBodyRef();
|
|
@@ -176,60 +217,66 @@ function useVariationPickerTop(
|
|
|
176
217
|
}
|
|
177
218
|
}
|
|
178
219
|
|
|
179
|
-
const styles =
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
220
|
+
const styles = /* @__PURE__ */ (() =>
|
|
221
|
+
stylesheet.create({
|
|
222
|
+
geometry: {
|
|
223
|
+
'.': ClassNames.variationPicker,
|
|
224
|
+
position: 'absolute',
|
|
225
|
+
right: '15px',
|
|
226
|
+
left: '15px',
|
|
227
|
+
padding: '5px',
|
|
228
|
+
display: 'flex',
|
|
229
|
+
alignItems: 'center',
|
|
230
|
+
justifyContent: 'space-around',
|
|
231
|
+
opacity: '0',
|
|
232
|
+
visibility: 'hidden',
|
|
233
|
+
pointerEvents: 'none',
|
|
234
|
+
top: '-100%',
|
|
235
|
+
height: 'var(--epr-emoji-variation-picker-height)',
|
|
236
|
+
zIndex: 'var(--epr-skin-variation-picker-z-index)',
|
|
237
|
+
},
|
|
238
|
+
variationPicker: {
|
|
239
|
+
'.': ClassNames.variationPicker,
|
|
240
|
+
boxShadow: '0px 2px 5px rgba(0, 0, 0, 0.2)',
|
|
241
|
+
borderRadius: '3px',
|
|
242
|
+
border: '1px solid var(--epr-picker-border-color)',
|
|
243
|
+
background: 'var(--epr-emoji-variation-picker-bg-color)',
|
|
244
|
+
transform: 'scale(0.9)',
|
|
245
|
+
transition: 'transform 0.1s ease-out, opacity 0.2s ease-out',
|
|
246
|
+
},
|
|
247
|
+
visibleGeometry: {
|
|
248
|
+
opacity: '1',
|
|
249
|
+
visibility: 'visible',
|
|
250
|
+
pointerEvents: 'all',
|
|
251
|
+
},
|
|
252
|
+
visible: {
|
|
253
|
+
transform: 'scale(1)',
|
|
254
|
+
},
|
|
255
|
+
pointingUp: {
|
|
256
|
+
'.': 'pointing-up',
|
|
257
|
+
transformOrigin: 'center 0%',
|
|
258
|
+
transform: 'scale(0.9)',
|
|
259
|
+
},
|
|
260
|
+
'.pointing-up': {
|
|
261
|
+
pointer: {
|
|
262
|
+
top: '0',
|
|
263
|
+
transform: 'rotate(180deg) translateY(100%) translateX(18px)',
|
|
264
|
+
},
|
|
265
|
+
},
|
|
214
266
|
pointer: {
|
|
215
|
-
|
|
216
|
-
|
|
267
|
+
'.': 'epr-emoji-pointer',
|
|
268
|
+
content: '',
|
|
269
|
+
position: 'absolute',
|
|
270
|
+
width: '25px',
|
|
271
|
+
height: '15px',
|
|
272
|
+
backgroundRepeat: 'no-repeat',
|
|
273
|
+
backgroundPosition: '0 0',
|
|
274
|
+
backgroundSize: '50px 15px',
|
|
275
|
+
top: '100%',
|
|
276
|
+
transform: 'translateX(-18px)',
|
|
277
|
+
backgroundImage: `url("${SVGTriangle}")`,
|
|
217
278
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
position: 'absolute',
|
|
223
|
-
width: '25px',
|
|
224
|
-
height: '15px',
|
|
225
|
-
backgroundRepeat: 'no-repeat',
|
|
226
|
-
backgroundPosition: '0 0',
|
|
227
|
-
backgroundSize: '50px 15px',
|
|
228
|
-
top: '100%',
|
|
229
|
-
transform: 'translateX(-18px)',
|
|
230
|
-
backgroundImage: `url(${SVGTriangle})`,
|
|
231
|
-
},
|
|
232
|
-
...darkMode('pointer', {
|
|
233
|
-
backgroundPosition: '-25px 0',
|
|
234
|
-
}),
|
|
235
|
-
});
|
|
279
|
+
...darkMode('pointer', {
|
|
280
|
+
backgroundPosition: '-25px 0',
|
|
281
|
+
}),
|
|
282
|
+
}))();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
+
import { elementBorderBoxHeight } from '../../DomUtils/selectors';
|
|
3
4
|
import {
|
|
4
5
|
categoryFromCategoryConfig,
|
|
5
6
|
customGroupFromCategoryConfig,
|
|
@@ -31,7 +32,12 @@ export function MeasureEmoji() {
|
|
|
31
32
|
|
|
32
33
|
useIsomorphicLayoutEffect(() => {
|
|
33
34
|
if (ref.current) {
|
|
34
|
-
|
|
35
|
+
// Measure the button itself: the wrapper collapses to zero height
|
|
36
|
+
// because its only child is absolutely positioned, which would
|
|
37
|
+
// report 0 forever and keep this measurer mounted (navigation
|
|
38
|
+
// invalidation and stray-node costs on every render).
|
|
39
|
+
const button = ref.current.querySelector('button');
|
|
40
|
+
setEmojiSize(elementBorderBoxHeight(button) || ref.current.clientHeight);
|
|
35
41
|
}
|
|
36
42
|
});
|
|
37
43
|
|
|
@@ -53,7 +59,7 @@ export function MeasureEmoji() {
|
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
return (
|
|
56
|
-
<div ref={ref}>
|
|
62
|
+
<div ref={ref} aria-hidden="true">
|
|
57
63
|
<ClickableEmoji
|
|
58
64
|
emoji={dummyEmoji}
|
|
59
65
|
unified={unified}
|
|
@@ -62,6 +68,7 @@ export function MeasureEmoji() {
|
|
|
62
68
|
lazyLoad={lazyLoadEmojis}
|
|
63
69
|
showVariations={false}
|
|
64
70
|
hidden={false}
|
|
71
|
+
tabIndex={-1}
|
|
65
72
|
style={{
|
|
66
73
|
opacity: 0,
|
|
67
74
|
pointerEvents: 'none',
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { DataEmoji } from '../../dataUtils/DataTypes';
|
|
4
|
+
import { emojiNames, emojiHasVariations } from '../../dataUtils/emojiUtils';
|
|
5
|
+
import { parseNativeEmoji } from '../../dataUtils/parseNativeEmoji';
|
|
6
|
+
import { isCustomEmoji } from '../../typeRefinements/typeRefinements';
|
|
7
|
+
import { EmojiStyle, EmojiStyleValue } from '../../types/exposedTypes';
|
|
8
|
+
|
|
9
|
+
/** The emoji a custom `Emoji` cell renders. */
|
|
10
|
+
export type ListEmoji = {
|
|
11
|
+
/** True while hovered or keyboard-focused. */
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
/** Unified code including the active skin tone, e.g. `1f44d-1f3fd`. */
|
|
14
|
+
unified: string;
|
|
15
|
+
names: string[];
|
|
16
|
+
/** Native emoji text (custom emojis: their id). */
|
|
17
|
+
emoji: string;
|
|
18
|
+
isCustom: boolean;
|
|
19
|
+
/** Active image style URL, or undefined for standard native emojis. */
|
|
20
|
+
imageUrl?: string;
|
|
21
|
+
/** Whether a long press opens skin tone variations. */
|
|
22
|
+
hasVariations: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Props for a custom emoji cell. Spread everything except `emoji` onto a
|
|
27
|
+
* `<button>`: the library-owned attributes (type, class, position style,
|
|
28
|
+
* tabIndex, aria-label, data-epr-*) carry selection, keyboard navigation,
|
|
29
|
+
* virtualization and accessibility. `children` is the default glyph/image;
|
|
30
|
+
* render it or your own content.
|
|
31
|
+
*/
|
|
32
|
+
export type EmojiRenderProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
33
|
+
emoji: ListEmoji;
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Props for a custom category header. Spread everything except `category`
|
|
39
|
+
* onto the header element; it stays sticky and measured.
|
|
40
|
+
*/
|
|
41
|
+
export type CategoryHeaderRenderProps = React.HTMLAttributes<HTMLElement> & {
|
|
42
|
+
category: { id: string; name: string };
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type ListComponents = {
|
|
47
|
+
Emoji?: React.ComponentType<EmojiRenderProps>;
|
|
48
|
+
CategoryHeader?: React.ComponentType<CategoryHeaderRenderProps>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const NO_COMPONENTS: ListComponents = {};
|
|
52
|
+
|
|
53
|
+
export const ListComponentsContext =
|
|
54
|
+
/* @__PURE__ */ React.createContext<ListComponents>(NO_COMPONENTS);
|
|
55
|
+
|
|
56
|
+
export function useListComponents(): ListComponents {
|
|
57
|
+
return React.useContext(ListComponentsContext);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function emojiRenderInfo(
|
|
61
|
+
emoji: DataEmoji,
|
|
62
|
+
unified: string,
|
|
63
|
+
emojiStyle: EmojiStyleValue,
|
|
64
|
+
getEmojiUrl: (unified: string, style: EmojiStyleValue) => string,
|
|
65
|
+
): Omit<ListEmoji, 'isActive'> {
|
|
66
|
+
const isCustom = isCustomEmoji(emoji);
|
|
67
|
+
return {
|
|
68
|
+
unified,
|
|
69
|
+
names: emojiNames(emoji),
|
|
70
|
+
emoji: isCustom ? unified : parseNativeEmoji(unified),
|
|
71
|
+
isCustom,
|
|
72
|
+
imageUrl: isCustom
|
|
73
|
+
? emoji.imgUrl
|
|
74
|
+
: emojiStyle === EmojiStyle.NATIVE
|
|
75
|
+
? undefined
|
|
76
|
+
: getEmojiUrl(unified, emojiStyle),
|
|
77
|
+
hasVariations: emojiHasVariations(emoji),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -8,37 +8,43 @@ export function ElementRefContextProvider({
|
|
|
8
8
|
}: {
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
}) {
|
|
11
|
-
const
|
|
12
|
-
const AnchoredEmojiRef = React.useRef<HTMLElement>(null);
|
|
13
|
-
const BodyRef = React.useRef<HTMLDivElement>(null);
|
|
14
|
-
const EmojiListRef = React.useRef<HTMLUListElement>(null);
|
|
15
|
-
const SearchInputRef = React.useRef<HTMLInputElement>(null);
|
|
16
|
-
const SkinTonePickerRef = React.useRef<HTMLDivElement>(null);
|
|
17
|
-
const CategoryNavigationRef = React.useRef<HTMLDivElement>(null);
|
|
18
|
-
const VariationPickerRef = React.useRef<HTMLDivElement>(null);
|
|
19
|
-
const ReactionsRef = React.useRef<HTMLUListElement>(null);
|
|
20
|
-
|
|
11
|
+
const [refs] = React.useState(createElementRefs);
|
|
21
12
|
return (
|
|
22
|
-
<ElementRefContext.Provider
|
|
23
|
-
value={{
|
|
24
|
-
AnchoredEmojiRef,
|
|
25
|
-
BodyRef,
|
|
26
|
-
EmojiListRef,
|
|
27
|
-
CategoryNavigationRef,
|
|
28
|
-
PickerMainRef,
|
|
29
|
-
SearchInputRef,
|
|
30
|
-
SkinTonePickerRef,
|
|
31
|
-
VariationPickerRef,
|
|
32
|
-
ReactionsRef,
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
13
|
+
<ElementRefContext.Provider value={refs}>
|
|
35
14
|
{children}
|
|
36
15
|
</ElementRefContext.Provider>
|
|
37
16
|
);
|
|
38
17
|
}
|
|
39
18
|
|
|
40
19
|
export type ElementRef<E extends HTMLElement = HTMLElement> =
|
|
41
|
-
React.MutableRefObject<E | null
|
|
20
|
+
React.MutableRefObject<E | null> & {
|
|
21
|
+
subscribe?: (listener: () => void) => () => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Observe attachment without rerendering ref consumers. Root services follow
|
|
25
|
+
// conditional parts, native element replacements and remounts.
|
|
26
|
+
function createElementRef<E extends HTMLElement>(): ElementRef<E> {
|
|
27
|
+
let current: E | null = null;
|
|
28
|
+
const listeners = new Set<() => void>();
|
|
29
|
+
const ref = {} as ElementRef<E>;
|
|
30
|
+
Object.defineProperty(ref, 'current', {
|
|
31
|
+
configurable: false,
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: () => current,
|
|
34
|
+
set: (element: E | null) => {
|
|
35
|
+
if (element === current) return;
|
|
36
|
+
current = element;
|
|
37
|
+
listeners.forEach((listener) => listener());
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
ref.subscribe = (listener: () => void) => {
|
|
41
|
+
listeners.add(listener);
|
|
42
|
+
return () => {
|
|
43
|
+
listeners.delete(listener);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
return ref;
|
|
47
|
+
}
|
|
42
48
|
|
|
43
49
|
type ElementRefs = {
|
|
44
50
|
PickerMainRef: ElementRef;
|
|
@@ -52,17 +58,22 @@ type ElementRefs = {
|
|
|
52
58
|
ReactionsRef: ElementRef<HTMLUListElement>;
|
|
53
59
|
};
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
function createElementRefs(): ElementRefs {
|
|
62
|
+
return {
|
|
63
|
+
PickerMainRef: createElementRef(),
|
|
64
|
+
AnchoredEmojiRef: createElementRef(),
|
|
65
|
+
BodyRef: createElementRef<HTMLDivElement>(),
|
|
66
|
+
EmojiListRef: createElementRef<HTMLUListElement>(),
|
|
67
|
+
SearchInputRef: createElementRef<HTMLInputElement>(),
|
|
68
|
+
SkinTonePickerRef: createElementRef<HTMLDivElement>(),
|
|
69
|
+
CategoryNavigationRef: createElementRef<HTMLDivElement>(),
|
|
70
|
+
VariationPickerRef: createElementRef<HTMLDivElement>(),
|
|
71
|
+
ReactionsRef: createElementRef<HTMLUListElement>(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const ElementRefContext =
|
|
76
|
+
/* @__PURE__ */ React.createContext<ElementRefs>(createElementRefs());
|
|
66
77
|
|
|
67
78
|
function useElementRef() {
|
|
68
79
|
return React.useContext(ElementRefContext);
|
|
@@ -14,59 +14,74 @@ type Props = PickerConfig &
|
|
|
14
14
|
}>;
|
|
15
15
|
|
|
16
16
|
const ConfigContext =
|
|
17
|
-
React.createContext<PickerConfigInternal>(basePickerConfig());
|
|
17
|
+
/* @__PURE__ */ React.createContext<PickerConfigInternal>(basePickerConfig());
|
|
18
|
+
|
|
19
|
+
type SearchSlice = {
|
|
20
|
+
searchValue: string | undefined;
|
|
21
|
+
defaultSearchValue: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const SearchConfigContext = /* @__PURE__ */ React.createContext<SearchSlice>({
|
|
25
|
+
searchValue: undefined,
|
|
26
|
+
defaultSearchValue: undefined,
|
|
27
|
+
});
|
|
18
28
|
|
|
19
29
|
export function PickerConfigProvider({ children, ...config }: Props) {
|
|
20
30
|
const mergedConfig = useSetConfig(config);
|
|
31
|
+
// Hot per-keystroke values bypass the merged config: their identity
|
|
32
|
+
// changes only when the values change, so typing never rebuilds or
|
|
33
|
+
// rebroadcasts the merged configuration.
|
|
34
|
+
const searchSlice = React.useMemo<SearchSlice>(
|
|
35
|
+
() => ({
|
|
36
|
+
searchValue: config.searchValue,
|
|
37
|
+
defaultSearchValue: config.defaultSearchValue,
|
|
38
|
+
}),
|
|
39
|
+
[config.searchValue, config.defaultSearchValue],
|
|
40
|
+
);
|
|
21
41
|
|
|
22
42
|
return (
|
|
23
43
|
<ConfigContext.Provider value={mergedConfig}>
|
|
24
|
-
{
|
|
44
|
+
<SearchConfigContext.Provider value={searchSlice}>
|
|
45
|
+
{children}
|
|
46
|
+
</SearchConfigContext.Provider>
|
|
25
47
|
</ConfigContext.Provider>
|
|
26
48
|
);
|
|
27
49
|
}
|
|
28
50
|
|
|
51
|
+
export function useSearchSliceConfig(): SearchSlice {
|
|
52
|
+
return React.useContext(SearchConfigContext);
|
|
53
|
+
}
|
|
54
|
+
|
|
29
55
|
export function useSetConfig(config: PickerConfig) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
const cache = React.useRef<{
|
|
57
|
+
inputs: PickerConfig;
|
|
58
|
+
merged: PickerConfigInternal;
|
|
59
|
+
} | null>(null);
|
|
33
60
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// length; compareConfig above still gates no-op updates so inline
|
|
44
|
-
// literals don't loop.
|
|
45
|
-
config.categories,
|
|
46
|
-
config.customEmojis,
|
|
47
|
-
config.open,
|
|
48
|
-
config.emojiVersion,
|
|
49
|
-
config.reactionsDefaultOpen,
|
|
50
|
-
config.searchPlaceHolder,
|
|
51
|
-
config.searchPlaceholder,
|
|
52
|
-
config.searchClearButtonLabel,
|
|
53
|
-
config.defaultSkinTone,
|
|
54
|
-
config.skinTonesDisabled,
|
|
55
|
-
config.autoFocusSearch,
|
|
56
|
-
config.emojiStyle,
|
|
57
|
-
config.theme,
|
|
58
|
-
config.suggestedEmojisMode,
|
|
59
|
-
config.lazyLoadEmojis,
|
|
60
|
-
config.className,
|
|
61
|
-
config.height,
|
|
62
|
-
config.width,
|
|
63
|
-
config.searchDisabled,
|
|
64
|
-
config.skinTonePickerLocation,
|
|
65
|
-
config.allowExpandReactions,
|
|
66
|
-
config.emojiData,
|
|
67
|
-
]);
|
|
61
|
+
// The search slice travels separately (see above); the merged config
|
|
62
|
+
// must not rebuild when only it changes.
|
|
63
|
+
const {
|
|
64
|
+
searchValue: _searchValue,
|
|
65
|
+
defaultSearchValue: _defaultSearchValue,
|
|
66
|
+
...mainInputs
|
|
67
|
+
} = config;
|
|
68
|
+
void _searchValue;
|
|
69
|
+
void _defaultSearchValue;
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
// Derived during render with a content comparison, not settled in a
|
|
72
|
+
// trailing effect: consumers observe prop changes in the same commit,
|
|
73
|
+
// with no extra render pass and no cycle of lag. The derivation is
|
|
74
|
+
// idempotent (same inputs always rebuild identically), so a discarded
|
|
75
|
+
// concurrent render simply recomputes on the next pass. Inline
|
|
76
|
+
// literals with equal contents still reuse the cached merge via the
|
|
77
|
+
// structural comparison, as before.
|
|
78
|
+
const cached = cache.current;
|
|
79
|
+
if (!cached || !compareConfig(cached.inputs, mainInputs)) {
|
|
80
|
+
const merged = mergeConfig(mainInputs);
|
|
81
|
+
cache.current = { inputs: mainInputs, merged };
|
|
82
|
+
return merged;
|
|
83
|
+
}
|
|
84
|
+
return cached.merged;
|
|
70
85
|
}
|
|
71
86
|
|
|
72
87
|
export function usePickerConfig() {
|