emoji-picker-react 4.22.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +331 -49
- package/dist/DomUtils/categoryNameFromDom.d.ts +1 -1
- package/dist/DomUtils/classNames.d.ts +24 -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 +7 -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-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-46BUDQLE.mjs +228 -0
- package/dist/esm/chunks/chunk-7ZGTUZFB.mjs +16 -0
- package/dist/esm/chunks/chunk-FQIJ4HBW.mjs +25 -0
- package/dist/esm/chunks/chunk-KQPOIRSC.mjs +9305 -0
- package/dist/esm/chunks/chunk-LO4TPPLH.mjs +43 -0
- package/dist/esm/chunks/emojis-6L3GRBAP.mjs +9 -0
- package/dist/esm/data.mjs +18 -0
- package/dist/esm/index.mjs +389 -0
- package/dist/esm/primitives/index.mjs +67 -0
- package/dist/hooks/preloadEmoji.d.ts +9 -9
- package/dist/hooks/useActiveCategoryScrollDetection.d.ts +11 -11
- package/dist/hooks/useCategoryHeight.d.ts +6 -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 +21 -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 +20 -18
- package/llms-full.txt +3680 -0
- package/llms.txt +66 -480
- package/package.json +180 -66
- package/src/DomUtils/categoryNameFromDom.ts +1 -1
- package/src/DomUtils/classNames.ts +1 -0
- package/src/DomUtils/elementPositionInRow.ts +26 -4
- 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 +105 -149
- package/src/DomUtils/scrollTo.ts +18 -16
- package/src/DomUtils/selectors.ts +20 -111
- 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 +55 -23
- 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 +110 -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 +77 -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 +188 -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-core/pickerData.ts +173 -0
- package/src/data-core/prepare.ts +178 -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 +58 -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/suggested.ts +8 -4
- package/src/dataUtils/suggestedEmojis.ts +92 -0
- package/src/env.d.ts +4 -0
- package/src/hooks/preloadEmoji.ts +3 -3
- package/src/hooks/useActiveCategoryScrollDetection.ts +10 -1
- package/src/hooks/useCategoryHeight.ts +82 -8
- package/src/hooks/useDataIdentityStabilityWarning.ts +86 -0
- package/src/hooks/useDebouncedState.ts +13 -1
- package/src/hooks/useDisallowedEmojis.ts +26 -42
- package/src/hooks/useEmojiPreviewEvents.ts +43 -10
- package/src/hooks/useEmojiVirtualization.tsx +38 -4
- package/src/hooks/useFilter.ts +85 -127
- package/src/hooks/useFocus.ts +14 -24
- package/src/hooks/useIsEmojiHidden.ts +10 -6
- package/src/hooks/useKeyboardNavigation.ts +322 -429
- 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 +133 -0
- package/src/primitives/tokens.ts +149 -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 +20 -6
- 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
|
@@ -4,47 +4,145 @@ import { UserCategoryConfig } from './categoryConfig';
|
|
|
4
4
|
import { PickerConfig } from './config';
|
|
5
5
|
import { CustomEmoji } from './customEmojiConfig';
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// Callbacks are read through the mutable config ref, so a new function
|
|
8
|
+
// identity must never rebuild configuration or rerender the memoized tree.
|
|
9
|
+
const CALLBACK_KEYS: ReadonlySet<string> = new Set([
|
|
10
|
+
'onEmojiClick',
|
|
11
|
+
'onReactionClick',
|
|
12
|
+
'onSkinToneChange',
|
|
13
|
+
'onSearchChange',
|
|
14
|
+
'onReactionsModeChange',
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Content equality over every config key. Iterating the union of keys
|
|
19
|
+
* (rather than a hand-maintained list) means a prop added later is
|
|
20
|
+
* compared by default instead of being silently ignored after mount —
|
|
21
|
+
* which is how `reactions`, `previewConfig`, `hiddenEmojis`,
|
|
22
|
+
* `allowExpandReactions`, `categoryIcons`, `getEmojiUrl` and `nonce`
|
|
23
|
+
* updates used to be dropped.
|
|
24
|
+
*/
|
|
8
25
|
export function compareConfig(prev: PickerConfig, next: PickerConfig) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
26
|
+
const prevRecord = prev as Record<string, unknown>;
|
|
27
|
+
const nextRecord = next as Record<string, unknown>;
|
|
28
|
+
const keys = Object.keys(prevRecord).concat(
|
|
29
|
+
Object.keys(nextRecord).filter((key) => !(key in prevRecord)),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
for (const key of keys) {
|
|
33
|
+
if (CALLBACK_KEYS.has(key)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (!configValueEqual(key, prevRecord[key], nextRecord[key])) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type ValueComparator = (prev: unknown, next: unknown) => boolean;
|
|
44
|
+
|
|
45
|
+
const identityOnly: ValueComparator = () => false;
|
|
46
|
+
|
|
47
|
+
// Keys with dedicated structural comparisons. `emojiData` and `style` are
|
|
48
|
+
// identity-only: datasets are large (identity is the contract, see
|
|
49
|
+
// useDataIdentityStabilityWarning) and style objects feed the DOM.
|
|
50
|
+
const KEY_COMPARATORS: Record<string, ValueComparator> = {
|
|
51
|
+
customEmojis: (prev, next) =>
|
|
52
|
+
customEmojisEqual(
|
|
53
|
+
(prev as CustomEmoji[] | undefined) ?? [],
|
|
54
|
+
(next as CustomEmoji[] | undefined) ?? [],
|
|
55
|
+
),
|
|
56
|
+
categories: (prev, next) =>
|
|
57
|
+
categoriesEqual(
|
|
58
|
+
prev as UserCategoryConfig | undefined,
|
|
59
|
+
next as UserCategoryConfig | undefined,
|
|
60
|
+
),
|
|
61
|
+
suggestedEmojis: (prev, next) =>
|
|
62
|
+
suggestedEmojisEqual(
|
|
63
|
+
prev as string[] | undefined,
|
|
64
|
+
next as string[] | undefined,
|
|
65
|
+
),
|
|
66
|
+
emojiData: identityOnly,
|
|
67
|
+
style: identityOnly,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
function configValueEqual(key: string, prev: unknown, next: unknown): boolean {
|
|
71
|
+
if (prev === next) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
const comparator = KEY_COMPARATORS[key];
|
|
75
|
+
if (comparator) {
|
|
76
|
+
return comparator(prev, next);
|
|
77
|
+
}
|
|
78
|
+
return genericValueEqual(prev, next);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function genericValueEqual(prev: unknown, next: unknown): boolean {
|
|
82
|
+
if (Array.isArray(prev) && Array.isArray(next)) {
|
|
83
|
+
return shallowArrayEqual(prev, next);
|
|
84
|
+
}
|
|
85
|
+
if (isPlainObject(prev) && isPlainObject(next)) {
|
|
86
|
+
return shallowObjectEqual(prev, next);
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function shallowArrayEqual(prev: unknown[], next: unknown[]): boolean {
|
|
11
92
|
return (
|
|
12
|
-
prev.
|
|
13
|
-
prev.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
93
|
+
prev.length === next.length &&
|
|
94
|
+
prev.every((entry, index) => entry === next[index])
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
99
|
+
if (value === null || typeof value !== 'object') {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const proto = Object.getPrototypeOf(value);
|
|
103
|
+
return proto === Object.prototype || proto === null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function shallowObjectEqual(
|
|
107
|
+
prev: Record<string, unknown>,
|
|
108
|
+
next: Record<string, unknown>,
|
|
109
|
+
): boolean {
|
|
110
|
+
const prevKeys = Object.keys(prev);
|
|
111
|
+
if (prevKeys.length !== Object.keys(next).length) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return prevKeys.every(
|
|
115
|
+
(key) =>
|
|
116
|
+
Object.prototype.hasOwnProperty.call(next, key) &&
|
|
117
|
+
prev[key] === next[key],
|
|
35
118
|
);
|
|
36
119
|
}
|
|
37
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Element-wise equality for caller-defined suggestions. Compared by value
|
|
123
|
+
* (not identity) so inline literals with equal contents don't rebuild the
|
|
124
|
+
* merged configuration on every parent render.
|
|
125
|
+
*/
|
|
126
|
+
function suggestedEmojisEqual(
|
|
127
|
+
prev: string[] | undefined,
|
|
128
|
+
next: string[] | undefined,
|
|
129
|
+
): boolean {
|
|
130
|
+
if (prev === next) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
if (!prev || !next || prev.length !== next.length) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return prev.every((entry, index) => entry === next[index]);
|
|
137
|
+
}
|
|
138
|
+
|
|
38
139
|
/**
|
|
39
140
|
* Structural content equality for custom emojis. Length alone misses
|
|
40
141
|
* regroups and swaps, which would leave merged categories, search, and
|
|
41
142
|
* sections stale. Fields are compared element-wise (never serialized
|
|
42
143
|
* with delimiters) so user-controlled values cannot collide.
|
|
43
144
|
*/
|
|
44
|
-
function customEmojisEqual(
|
|
45
|
-
prev: CustomEmoji[],
|
|
46
|
-
next: CustomEmoji[],
|
|
47
|
-
): boolean {
|
|
145
|
+
function customEmojisEqual(prev: CustomEmoji[], next: CustomEmoji[]): boolean {
|
|
48
146
|
if (prev.length !== next.length) {
|
|
49
147
|
return false;
|
|
50
148
|
}
|
package/src/config/config.ts
CHANGED
|
@@ -3,19 +3,25 @@ import * as React from 'react';
|
|
|
3
3
|
import { DEFAULT_REACTIONS } from '../components/Reactions/DEFAULT_REACTIONS';
|
|
4
4
|
import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps';
|
|
5
5
|
import { emojiUrlByUnified } from '../dataUtils/emojiUtils';
|
|
6
|
+
import type { EmojiDataInput } from '../hooks/useResolvedEmojiData';
|
|
6
7
|
import {
|
|
7
8
|
CategoryIcons,
|
|
8
9
|
EmojiClickData,
|
|
9
10
|
EmojiData,
|
|
10
11
|
EmojiStyle,
|
|
12
|
+
EmojiStyleValue,
|
|
11
13
|
SkinTonePickerLocation,
|
|
12
14
|
SkinTones,
|
|
15
|
+
SkinTonesValue,
|
|
13
16
|
SuggestionMode,
|
|
17
|
+
SuggestionModeValue,
|
|
14
18
|
Theme,
|
|
19
|
+
ThemeValue,
|
|
15
20
|
} from '../types/exposedTypes';
|
|
16
21
|
|
|
17
22
|
import {
|
|
18
23
|
CategoriesConfig,
|
|
24
|
+
UserCategoryConfig,
|
|
19
25
|
baseCategoriesConfig,
|
|
20
26
|
mergeCategoriesConfig,
|
|
21
27
|
} from './categoryConfig';
|
|
@@ -24,6 +30,9 @@ import { CustomEmoji } from './customEmojiConfig';
|
|
|
24
30
|
const KNOWN_FAILING_EMOJIS = ['2640-fe0f', '2642-fe0f', '2695-fe0f'];
|
|
25
31
|
|
|
26
32
|
export const DEFAULT_SEARCH_PLACEHOLDER = 'Search';
|
|
33
|
+
export const DEFAULT_PICKER_WIDTH = 350;
|
|
34
|
+
export const DEFAULT_PICKER_HEIGHT = 450;
|
|
35
|
+
export const DEFAULT_SEARCH_INPUT_LABEL = 'Type to search for an emoji';
|
|
27
36
|
export const DEFAULT_SEARCH_CLEAR_BUTTON_LABEL = 'Clear';
|
|
28
37
|
export const SEARCH_RESULTS_NO_RESULTS_FOUND = 'No results found';
|
|
29
38
|
export const SEARCH_RESULTS_SUFFIX =
|
|
@@ -33,13 +42,78 @@ export const SEARCH_RESULTS_ONE_RESULT_FOUND =
|
|
|
33
42
|
export const SEARCH_RESULTS_MULTIPLE_RESULTS_FOUND =
|
|
34
43
|
'%n results' + SEARCH_RESULTS_SUFFIX;
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Every user-facing string the picker renders or announces. All keys are
|
|
47
|
+
* optional on the `labels` prop; anything omitted keeps its English
|
|
48
|
+
* default. Category names come from `categories` / localized `emojiData`,
|
|
49
|
+
* and the preview caption from `previewConfig.defaultCaption`.
|
|
50
|
+
*/
|
|
51
|
+
export type PickerLabels = {
|
|
52
|
+
searchPlaceholder: string;
|
|
53
|
+
/** Accessible name of the search input. */
|
|
54
|
+
searchLabel: string;
|
|
55
|
+
searchClear: string;
|
|
56
|
+
/** Live-region announcement and visible empty state. */
|
|
57
|
+
searchResultsNone: string;
|
|
58
|
+
searchResultsOne: string;
|
|
59
|
+
/** `%n` is replaced with the result count. */
|
|
60
|
+
searchResultsMany: string;
|
|
61
|
+
categoryNavigation: string;
|
|
62
|
+
reactions: string;
|
|
63
|
+
expandReactions: string;
|
|
64
|
+
/** Shown by the Loading part while the dataset loads. */
|
|
65
|
+
loading: string;
|
|
66
|
+
loadingError: string;
|
|
67
|
+
retryLoading: string;
|
|
68
|
+
skinToneNeutral: string;
|
|
69
|
+
skinToneLight: string;
|
|
70
|
+
skinToneMediumLight: string;
|
|
71
|
+
skinToneMedium: string;
|
|
72
|
+
skinToneMediumDark: string;
|
|
73
|
+
skinToneDark: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// English defaults, identical to the v4 strings so existing queries and
|
|
77
|
+
// snapshots keep matching.
|
|
78
|
+
export const DEFAULT_LABELS: PickerLabels = {
|
|
79
|
+
searchPlaceholder: DEFAULT_SEARCH_PLACEHOLDER,
|
|
80
|
+
searchLabel: DEFAULT_SEARCH_INPUT_LABEL,
|
|
81
|
+
searchClear: DEFAULT_SEARCH_CLEAR_BUTTON_LABEL,
|
|
82
|
+
searchResultsNone: SEARCH_RESULTS_NO_RESULTS_FOUND,
|
|
83
|
+
searchResultsOne: SEARCH_RESULTS_ONE_RESULT_FOUND,
|
|
84
|
+
searchResultsMany: SEARCH_RESULTS_MULTIPLE_RESULTS_FOUND,
|
|
85
|
+
categoryNavigation: 'Category navigation',
|
|
86
|
+
reactions: 'Reactions',
|
|
87
|
+
expandReactions: 'Show all Emojis',
|
|
88
|
+
loading: 'Loading…',
|
|
89
|
+
loadingError: 'Could not load emojis.',
|
|
90
|
+
retryLoading: 'Try again',
|
|
91
|
+
skinToneNeutral: 'Skin tone NEUTRAL',
|
|
92
|
+
skinToneLight: 'Skin tone LIGHT',
|
|
93
|
+
skinToneMediumLight: 'Skin tone MEDIUM_LIGHT',
|
|
94
|
+
skinToneMedium: 'Skin tone MEDIUM',
|
|
95
|
+
skinToneMediumDark: 'Skin tone MEDIUM_DARK',
|
|
96
|
+
skinToneDark: 'Skin tone DARK',
|
|
97
|
+
};
|
|
40
98
|
|
|
41
|
-
|
|
42
|
-
|
|
99
|
+
type ResolvedUserConfig = Omit<PickerConfig, 'emojiData'> & {
|
|
100
|
+
emojiData?: EmojiData;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
function withResolvedEmojiData(config: PickerConfig): ResolvedUserConfig {
|
|
104
|
+
return (
|
|
105
|
+
typeof config.emojiData === 'function'
|
|
106
|
+
? { ...config, emojiData: undefined }
|
|
107
|
+
: config
|
|
108
|
+
) as ResolvedUserConfig;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Localized mood caption from emojiData is the default; an explicit
|
|
112
|
+
// previewConfig.defaultCaption still wins.
|
|
113
|
+
function mergePreviewConfig(
|
|
114
|
+
base: PreviewConfig,
|
|
115
|
+
userConfig: ResolvedUserConfig,
|
|
116
|
+
): PreviewConfig {
|
|
43
117
|
const localizedMood = (
|
|
44
118
|
userConfig.emojiData?.categories as Record<
|
|
45
119
|
string,
|
|
@@ -47,16 +121,44 @@ export function mergeConfig(
|
|
|
47
121
|
>
|
|
48
122
|
)?.preview_mood?.name;
|
|
49
123
|
|
|
50
|
-
|
|
51
|
-
...base
|
|
52
|
-
// Localized mood is default, but user can override
|
|
124
|
+
return {
|
|
125
|
+
...base,
|
|
53
126
|
...(localizedMood && !userConfig.previewConfig?.defaultCaption
|
|
54
127
|
? { defaultCaption: localizedMood }
|
|
55
128
|
: {}),
|
|
56
129
|
...(userConfig.previewConfig ?? {}),
|
|
57
130
|
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The default style is native, but a caller-supplied image URL resolver is
|
|
135
|
+
* an explicit request for images: without an explicit `emojiStyle` it keeps
|
|
136
|
+
* v4's image default (Apple), so the resolver is actually used.
|
|
137
|
+
*/
|
|
138
|
+
export function resolveEmojiStyle(
|
|
139
|
+
emojiStyle: EmojiStyleValue | undefined,
|
|
140
|
+
customImageSource: unknown,
|
|
141
|
+
): EmojiStyleValue {
|
|
142
|
+
if (emojiStyle !== undefined) {
|
|
143
|
+
return emojiStyle;
|
|
144
|
+
}
|
|
145
|
+
return customImageSource ? EmojiStyle.APPLE : EmojiStyle.NATIVE;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function mergeConfig(
|
|
149
|
+
rawUserConfig: PickerConfig = {},
|
|
150
|
+
): PickerConfigInternal {
|
|
151
|
+
const base = basePickerConfig();
|
|
152
|
+
// Root resolves loaders before configuration is merged; a loader that
|
|
153
|
+
// reaches this point (direct internal use) is treated as "not loaded".
|
|
154
|
+
const userConfig = withResolvedEmojiData(rawUserConfig);
|
|
155
|
+
const previewConfig = mergePreviewConfig(base.previewConfig, userConfig);
|
|
58
156
|
|
|
59
|
-
const config = Object.assign(base, userConfig);
|
|
157
|
+
const config = Object.assign(base, userConfig) as PickerConfigInternal;
|
|
158
|
+
config.emojiStyle = resolveEmojiStyle(
|
|
159
|
+
userConfig.emojiStyle,
|
|
160
|
+
userConfig.getEmojiUrl,
|
|
161
|
+
);
|
|
60
162
|
|
|
61
163
|
const categories = mergeCategoriesConfig(
|
|
62
164
|
userConfig.categories,
|
|
@@ -67,13 +169,23 @@ export function mergeConfig(
|
|
|
67
169
|
userConfig.customEmojis,
|
|
68
170
|
);
|
|
69
171
|
|
|
172
|
+
// Dataset ids are lowercase; accept the uppercase spelling consumers
|
|
173
|
+
// copy from docs and tools (and stray whitespace), like `reactions` and
|
|
174
|
+
// `suggestedEmojis` already do.
|
|
70
175
|
config.hiddenEmojis.forEach((emoji) => {
|
|
71
|
-
|
|
176
|
+
const id = String(emoji).trim().toLowerCase();
|
|
177
|
+
if (id) config.unicodeToHide.add(id);
|
|
72
178
|
});
|
|
73
179
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
180
|
+
// The built-in tone control needs a host region: without Search a
|
|
181
|
+
// search-located control moves to the preview, and without the preview
|
|
182
|
+
// a preview-located control moves to Search. With neither region it is
|
|
183
|
+
// off (NONE), the same as the explicit placement.
|
|
184
|
+
const skinTonePickerLocation = resolveSkinTonePickerLocation(
|
|
185
|
+
config.skinTonePickerLocation,
|
|
186
|
+
config.searchDisabled,
|
|
187
|
+
previewConfig.showPreview,
|
|
188
|
+
);
|
|
77
189
|
|
|
78
190
|
return {
|
|
79
191
|
...config,
|
|
@@ -83,6 +195,24 @@ export function mergeConfig(
|
|
|
83
195
|
};
|
|
84
196
|
}
|
|
85
197
|
|
|
198
|
+
export function resolveSkinTonePickerLocation(
|
|
199
|
+
location: SkinTonePickerLocation,
|
|
200
|
+
searchDisabled: boolean,
|
|
201
|
+
showPreview: boolean,
|
|
202
|
+
): SkinTonePickerLocation {
|
|
203
|
+
if (location === SkinTonePickerLocation.SEARCH && searchDisabled) {
|
|
204
|
+
return showPreview
|
|
205
|
+
? SkinTonePickerLocation.PREVIEW
|
|
206
|
+
: SkinTonePickerLocation.NONE;
|
|
207
|
+
}
|
|
208
|
+
if (location === SkinTonePickerLocation.PREVIEW && !showPreview) {
|
|
209
|
+
return searchDisabled
|
|
210
|
+
? SkinTonePickerLocation.NONE
|
|
211
|
+
: SkinTonePickerLocation.SEARCH;
|
|
212
|
+
}
|
|
213
|
+
return location;
|
|
214
|
+
}
|
|
215
|
+
|
|
86
216
|
export function basePickerConfig(): PickerConfigInternal {
|
|
87
217
|
return {
|
|
88
218
|
autoFocusSearch: true,
|
|
@@ -90,10 +220,10 @@ export function basePickerConfig(): PickerConfigInternal {
|
|
|
90
220
|
className: '',
|
|
91
221
|
customEmojis: [],
|
|
92
222
|
defaultSkinTone: SkinTones.NEUTRAL,
|
|
93
|
-
emojiStyle: EmojiStyle.
|
|
223
|
+
emojiStyle: EmojiStyle.NATIVE,
|
|
94
224
|
emojiVersion: null,
|
|
95
225
|
getEmojiUrl: emojiUrlByUnified,
|
|
96
|
-
height:
|
|
226
|
+
height: DEFAULT_PICKER_HEIGHT,
|
|
97
227
|
lazyLoadEmojis: false,
|
|
98
228
|
previewConfig: {
|
|
99
229
|
...basePreviewConfig,
|
|
@@ -108,7 +238,7 @@ export function basePickerConfig(): PickerConfigInternal {
|
|
|
108
238
|
suggestedEmojisMode: SuggestionMode.FREQUENT,
|
|
109
239
|
theme: Theme.LIGHT,
|
|
110
240
|
unicodeToHide: new Set<string>(KNOWN_FAILING_EMOJIS),
|
|
111
|
-
width:
|
|
241
|
+
width: DEFAULT_PICKER_WIDTH,
|
|
112
242
|
reactionsDefaultOpen: false,
|
|
113
243
|
reactions: DEFAULT_REACTIONS,
|
|
114
244
|
open: true,
|
|
@@ -117,6 +247,16 @@ export function basePickerConfig(): PickerConfigInternal {
|
|
|
117
247
|
emojiData: undefined,
|
|
118
248
|
categoryIcons: {},
|
|
119
249
|
nonce: undefined,
|
|
250
|
+
searchValue: undefined,
|
|
251
|
+
defaultSearchValue: undefined,
|
|
252
|
+
onSearchChange: undefined,
|
|
253
|
+
searchLabel: undefined,
|
|
254
|
+
suggestedEmojis: undefined,
|
|
255
|
+
onReactionsModeChange: undefined,
|
|
256
|
+
labels: undefined,
|
|
257
|
+
skinTone: undefined,
|
|
258
|
+
cssLayer: undefined,
|
|
259
|
+
columns: undefined,
|
|
120
260
|
};
|
|
121
261
|
}
|
|
122
262
|
|
|
@@ -125,13 +265,13 @@ export type PickerConfigInternal = {
|
|
|
125
265
|
searchPlaceHolder: string;
|
|
126
266
|
searchPlaceholder: string;
|
|
127
267
|
searchClearButtonLabel: string;
|
|
128
|
-
defaultSkinTone:
|
|
268
|
+
defaultSkinTone: SkinTonesValue;
|
|
129
269
|
skinTonesDisabled: boolean;
|
|
130
270
|
autoFocusSearch: boolean;
|
|
131
|
-
emojiStyle:
|
|
271
|
+
emojiStyle: EmojiStyleValue;
|
|
132
272
|
categories: CategoriesConfig;
|
|
133
|
-
theme:
|
|
134
|
-
suggestedEmojisMode:
|
|
273
|
+
theme: ThemeValue;
|
|
274
|
+
suggestedEmojisMode: SuggestionModeValue;
|
|
135
275
|
lazyLoadEmojis: boolean;
|
|
136
276
|
previewConfig: PreviewConfig;
|
|
137
277
|
className: string;
|
|
@@ -151,6 +291,48 @@ export type PickerConfigInternal = {
|
|
|
151
291
|
emojiData?: EmojiData;
|
|
152
292
|
categoryIcons: CategoryIcons;
|
|
153
293
|
nonce?: string;
|
|
294
|
+
/**
|
|
295
|
+
* Controlled search value (raw user text). When present, it is the
|
|
296
|
+
* accepted visible source of truth; user edits emit `onSearchChange`
|
|
297
|
+
* proposals instead of committing locally.
|
|
298
|
+
*/
|
|
299
|
+
searchValue?: string;
|
|
300
|
+
/** Uncontrolled initial search value, read once per mounted lifetime. */
|
|
301
|
+
defaultSearchValue?: string;
|
|
302
|
+
/** Emitted synchronously with each committed (uncontrolled) or proposed (controlled) user edit. */
|
|
303
|
+
onSearchChange?: (value: string) => void;
|
|
304
|
+
/** Accessible label for the search input. Defaults to English. */
|
|
305
|
+
searchLabel?: string;
|
|
306
|
+
/**
|
|
307
|
+
* Caller-defined Suggested category contents/order (unified or custom
|
|
308
|
+
* IDs). While present, `suggestedEmojisMode` is ignored for contents.
|
|
309
|
+
*/
|
|
310
|
+
suggestedEmojis?: string[];
|
|
311
|
+
/** Observes compact-reactions vs full-picker transitions. */
|
|
312
|
+
onReactionsModeChange?: (reactionsOpen: boolean) => void;
|
|
313
|
+
/**
|
|
314
|
+
* Localized user-facing strings. Takes precedence over the individual
|
|
315
|
+
* `searchPlaceholder` / `searchLabel` / `searchClearButtonLabel` props.
|
|
316
|
+
*/
|
|
317
|
+
labels?: Partial<PickerLabels>;
|
|
318
|
+
/**
|
|
319
|
+
* Controlled active skin tone. Pair with `onSkinToneChange`; while
|
|
320
|
+
* present, `defaultSkinTone` is ignored.
|
|
321
|
+
*/
|
|
322
|
+
skinTone?: SkinTonesValue;
|
|
323
|
+
/**
|
|
324
|
+
* Emit the picker's CSS inside this cascade layer (e.g. "epr"), for
|
|
325
|
+
* layered CSS frameworks such as Tailwind v4 whose utilities cannot
|
|
326
|
+
* beat unlayered CSS. Declare the layer first in your CSS:
|
|
327
|
+
* `@layer epr, theme, base, components, utilities;`. Default: unlayered.
|
|
328
|
+
*/
|
|
329
|
+
cssLayer?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Emojis per row. The picker then sizes its width to fit those columns
|
|
332
|
+
* unless you set a width; a narrower container shows fewer columns.
|
|
333
|
+
* Default: as many as the width fits.
|
|
334
|
+
*/
|
|
335
|
+
columns?: number;
|
|
154
336
|
};
|
|
155
337
|
|
|
156
338
|
export type PreviewConfig = {
|
|
@@ -170,7 +352,22 @@ type ConfigExternal = {
|
|
|
170
352
|
onEmojiClick: MouseDownEvent;
|
|
171
353
|
onReactionClick: MouseDownEvent;
|
|
172
354
|
onSkinToneChange: OnSkinToneChange;
|
|
173
|
-
|
|
355
|
+
/**
|
|
356
|
+
* User-supplied allowlist/order/merge input. Bare `Categories` members
|
|
357
|
+
* are accepted alongside full configs (as in v4 usage and this repo's
|
|
358
|
+
* own tests); the merged internal representation stays `CategoriesConfig`.
|
|
359
|
+
*/
|
|
360
|
+
categories: UserCategoryConfig;
|
|
361
|
+
/**
|
|
362
|
+
* Dataset: an object (synchronous, SSR-safe), or a loader such as
|
|
363
|
+
* `() => import('emoji-picker-react/data/emojis-fr')` to code-split it.
|
|
364
|
+
* Omitted: the bundled English dataset.
|
|
365
|
+
*/
|
|
366
|
+
emojiData: EmojiDataInput;
|
|
367
|
+
} & Omit<
|
|
368
|
+
PickerConfigInternal,
|
|
369
|
+
'previewConfig' | 'unicodeToHide' | 'categories' | 'emojiData'
|
|
370
|
+
>;
|
|
174
371
|
|
|
175
372
|
export type PickerConfig = Partial<ConfigExternal>;
|
|
176
373
|
|
|
@@ -181,8 +378,15 @@ export type MouseDownEvent = (
|
|
|
181
378
|
event: MouseEvent,
|
|
182
379
|
api?: OnEmojiClickApi,
|
|
183
380
|
) => void;
|
|
184
|
-
export type OnSkinToneChange = (
|
|
381
|
+
export type OnSkinToneChange = (skinTone: SkinTones) => void;
|
|
382
|
+
|
|
383
|
+
/** The `onEmojiClick` / `onReactionClick` callback signature. */
|
|
384
|
+
export type EmojiClickHandler = MouseDownEvent;
|
|
385
|
+
/** The `onSkinToneChange` callback signature. */
|
|
386
|
+
export type SkinToneChangeHandler = OnSkinToneChange;
|
|
185
387
|
|
|
186
|
-
|
|
388
|
+
/** Third argument of `onEmojiClick` / `onReactionClick`. */
|
|
389
|
+
export type OnEmojiClickApi = {
|
|
390
|
+
/** Return to the compact reactions bar (no-op when reactions are off). */
|
|
187
391
|
collapseToReactions: () => void;
|
|
188
392
|
};
|
|
@@ -6,38 +6,62 @@ export type MutableConfig = {
|
|
|
6
6
|
onEmojiClick?: MouseDownEvent;
|
|
7
7
|
onReactionClick?: MouseDownEvent;
|
|
8
8
|
onSkinToneChange?: OnSkinToneChange;
|
|
9
|
+
onSearchChange?: (value: string) => void;
|
|
10
|
+
onReactionsModeChange?: (reactionsOpen: boolean) => void;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Sentinel default: marks the absence of a provider. Root adopts the
|
|
15
|
+
* wrapper-provided ref across the default picker memo boundary and
|
|
16
|
+
* owns one otherwise (including nested bare Roots). Callbacks stay fresh
|
|
17
|
+
* without depending on the memoized default tree rerendering.
|
|
18
|
+
*/
|
|
19
|
+
export const NO_MUTABLE_PROVIDER = {} as React.MutableRefObject<MutableConfig>;
|
|
20
|
+
|
|
21
|
+
export const MutableConfigContext = /* @__PURE__ */ React.createContext({
|
|
22
|
+
ref: NO_MUTABLE_PROVIDER,
|
|
23
|
+
inheritToRoot: false,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export function MutableConfigProvider({
|
|
27
|
+
value,
|
|
28
|
+
inheritToRoot = false,
|
|
29
|
+
children,
|
|
30
|
+
}: {
|
|
31
|
+
value: React.MutableRefObject<MutableConfig>;
|
|
32
|
+
inheritToRoot?: boolean;
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
}) {
|
|
35
|
+
const context = React.useMemo(
|
|
36
|
+
() => ({ ref: value, inheritToRoot }),
|
|
37
|
+
[value, inheritToRoot],
|
|
38
|
+
);
|
|
39
|
+
return React.createElement(
|
|
40
|
+
MutableConfigContext.Provider,
|
|
41
|
+
{ value: context },
|
|
42
|
+
children,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
14
45
|
|
|
15
46
|
export function useMutableConfig(): React.MutableRefObject<MutableConfig> {
|
|
16
47
|
const mutableConfig = React.useContext(MutableConfigContext);
|
|
17
|
-
return mutableConfig;
|
|
48
|
+
return mutableConfig.ref;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Only the default wrapper crosses its own memo boundary into Root. */
|
|
52
|
+
export function useInheritedMutableConfig(): React.MutableRefObject<MutableConfig> {
|
|
53
|
+
const value = React.useContext(MutableConfigContext);
|
|
54
|
+
return value.inheritToRoot ? value.ref : NO_MUTABLE_PROVIDER;
|
|
18
55
|
}
|
|
19
56
|
|
|
20
57
|
export function useDefineMutableConfig(
|
|
21
58
|
config: MutableConfig,
|
|
22
59
|
): React.MutableRefObject<MutableConfig> {
|
|
23
|
-
const MutableConfigRef = React.useRef<MutableConfig>(
|
|
24
|
-
onEmojiClick: config.onEmojiClick || emptyFunc,
|
|
25
|
-
onReactionClick: config.onReactionClick || config.onEmojiClick,
|
|
26
|
-
onSkinToneChange: config.onSkinToneChange || emptyFunc,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
React.useEffect(() => {
|
|
30
|
-
MutableConfigRef.current.onEmojiClick = config.onEmojiClick || emptyFunc;
|
|
31
|
-
MutableConfigRef.current.onReactionClick =
|
|
32
|
-
config.onReactionClick || config.onEmojiClick;
|
|
33
|
-
}, [config.onEmojiClick, config.onReactionClick]);
|
|
60
|
+
const MutableConfigRef = React.useRef<MutableConfig>(config);
|
|
34
61
|
|
|
35
62
|
React.useEffect(() => {
|
|
36
|
-
MutableConfigRef.current
|
|
37
|
-
|
|
38
|
-
}, [config.onSkinToneChange]);
|
|
63
|
+
Object.assign(MutableConfigRef.current, config);
|
|
64
|
+
});
|
|
39
65
|
|
|
40
66
|
return MutableConfigRef;
|
|
41
67
|
}
|
|
42
|
-
|
|
43
|
-
function emptyFunc() {}
|