@envive-ai/react-hooks 0.2.6-alpha-7 → 0.2.6-alpha-9
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/dist/{AmplitudeOperations-DjqOM3uE.js → AmplitudeOperations-D2r56Ptr.js} +2 -2
- package/dist/{AmplitudeOperations-DbUiR0N_.cjs → AmplitudeOperations-SkndCrhj.cjs} +2 -2
- package/dist/{NewOrgConfig-C_1T1iOt.js → NewOrgConfig-C9aQqGsb.js} +2 -2
- package/dist/{NewOrgConfig-D2Kvqa1z.cjs → NewOrgConfig-CHkHRqHx.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-BxOhr9Da.js → TrackComponentVisibleEvent-BIGvzk4f.js} +2 -2
- package/dist/{TrackComponentVisibleEvent-CDbecFPM.cjs → TrackComponentVisibleEvent-DjZUt7LR.cjs} +2 -2
- package/dist/amplitudeContext-B3DsV6IO.cjs +248 -0
- package/dist/amplitudeContext-S3JYCxr4.js +232 -0
- package/dist/{app-Bs2KxG_8.js → app-BT3g-mDp.js} +5 -5
- package/dist/{app-DSnDDqcW.cjs → app-DxwdFQlv.cjs} +5 -5
- package/dist/application/utils/index.cjs +4 -4
- package/dist/application/utils/index.d.cts +2 -2
- package/dist/application/utils/index.js +4 -4
- package/dist/{atomStore-CfzCqWB9.js → atomStore-BuopbV9k.js} +1 -1
- package/dist/{atomStore-BQVO5haU.cjs → atomStore-CZKe3itM.cjs} +1 -1
- package/dist/atoms/app/index.cjs +9 -9
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/app/index.d.ts +7 -7
- package/dist/atoms/app/index.js +9 -9
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.d.ts +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +10 -10
- package/dist/atoms/chat/index.d.cts +32 -32
- package/dist/atoms/chat/index.d.ts +32 -32
- package/dist/atoms/chat/index.js +10 -10
- package/dist/atoms/globalSearch/index.d.cts +6 -6
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/org/index.cjs +2 -2
- package/dist/atoms/org/index.d.cts +15 -15
- package/dist/atoms/org/index.d.ts +16 -16
- package/dist/atoms/org/index.js +2 -2
- package/dist/atoms/search/index.cjs +3 -3
- package/dist/atoms/search/index.d.cts +15 -15
- package/dist/atoms/search/index.d.ts +14 -14
- package/dist/atoms/search/index.js +3 -3
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/cdnContext-i5iYA8ig.cjs +53 -0
- package/dist/cdnContext-td-gAam0.js +38 -0
- package/dist/{chat-EJbfGWRr.js → chat-ClvJ9xEj.js} +1 -1
- package/dist/{chat-CJ9D8n7g.cjs → chat-DCGriB7h.cjs} +1 -1
- package/dist/{chat-C5afTKUY.js → chat-ZaY3KY-R.js} +3 -3
- package/dist/{chat-CCjM6fS_.cjs → chat-rhEjVfrd.cjs} +3 -3
- package/dist/{common-CuwWqIJ1.cjs → common-DQPvV_S_.cjs} +1 -1
- package/dist/{common-Df2bwzd2.js → common-c_4eX0qn.js} +1 -1
- package/dist/{components-QGCWJ26c.js → components-CDpaMUjK.js} +1 -1
- package/dist/{components-BCfFLf9X.cjs → components-DKwVHIjq.cjs} +1 -1
- package/dist/config/index.cjs +4 -4
- package/dist/config/index.js +4 -4
- package/dist/config/locators/components/chat/index.cjs +1 -1
- package/dist/config/locators/components/chat/index.js +1 -1
- package/dist/config/locators/components/common/index.cjs +1 -1
- package/dist/config/locators/components/common/index.js +1 -1
- package/dist/config/locators/components/index.cjs +1 -1
- package/dist/config/locators/components/index.js +1 -1
- package/dist/config/locators/index.cjs +4 -4
- package/dist/config/locators/index.js +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +12 -12
- package/dist/contexts/amplitudeContext/index.d.cts +1 -1
- package/dist/contexts/amplitudeContext/index.js +12 -12
- package/dist/contexts/cdnContext/index.cjs +2 -2
- package/dist/contexts/cdnContext/index.d.cts +1 -1
- package/dist/contexts/cdnContext/index.d.ts +1 -1
- package/dist/contexts/cdnContext/index.js +2 -2
- package/dist/contexts/enviveConfigContext/index.cjs +2 -2
- package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
- package/dist/contexts/enviveConfigContext/index.js +2 -2
- package/dist/contexts/enviveCssContext/index.cjs +6 -6
- package/dist/contexts/enviveCssContext/index.js +6 -6
- package/dist/contexts/featureFlagContext/index.cjs +2 -2
- package/dist/contexts/featureFlagContext/index.js +2 -2
- package/dist/contexts/graphqlContext/index.cjs +2 -2
- package/dist/contexts/graphqlContext/index.js +2 -2
- package/dist/contexts/localStorageContext/index.d.cts +1 -1
- package/dist/contexts/newOrgConfigContext/index.cjs +5 -5
- package/dist/contexts/newOrgConfigContext/index.js +5 -5
- package/dist/contexts/searchContext/index.cjs +14 -14
- package/dist/contexts/searchContext/index.js +14 -14
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.cts +1 -1
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +2 -2
- package/dist/contexts/systemSettingsContext/index.d.cts +1 -1
- package/dist/contexts/systemSettingsContext/index.d.ts +2 -2
- package/dist/contexts/systemSettingsContext/index.js +2 -2
- package/dist/contexts/userIdentityContext/index.cjs +9 -9
- package/dist/contexts/userIdentityContext/index.js +9 -9
- package/dist/{domObserver-DNeeSh1F.js → domObserver-CVhsCSkS.js} +1 -1
- package/dist/{domObserver-C2oQO8vi.cjs → domObserver-LCBj1xw4.cjs} +1 -1
- package/dist/{enviveConfig-Dp80h9yu.cjs → enviveConfig-CQ_8mT-g.cjs} +1 -1
- package/dist/{enviveConfig-Ciq4ASoV.js → enviveConfig-Cwlp7-Qz.js} +1 -1
- package/dist/{enviveConfigContext-CCjJUmwp.js → enviveConfigContext-BZbGEgOW.js} +2 -2
- package/dist/{enviveConfigContext-DoYP8KSw.cjs → enviveConfigContext-BinpxTCy.cjs} +2 -2
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.js +1 -1
- package/dist/{events-DBin1Z7o.cjs → events-CgFGtanE.cjs} +1 -1
- package/dist/{events-CXiS1aTc.js → events-WOOrnUAx.js} +1 -1
- package/dist/exceptions/index.d.ts +1 -1
- package/dist/{graphqlContext-ChXlE8Ul.cjs → graphqlContext-B8wuRZcp.cjs} +2 -2
- package/dist/{graphqlContext-0cg9fEUw.js → graphqlContext-CpHMbKoX.js} +2 -2
- package/dist/hooks/AmplitudeOperations/index.cjs +13 -13
- package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/index.js +13 -13
- package/dist/hooks/AppDetails/index.cjs +12 -12
- package/dist/hooks/AppDetails/index.d.cts +1 -1
- package/dist/hooks/AppDetails/index.js +12 -12
- package/dist/hooks/BlockBackButton/index.d.cts +1 -1
- package/dist/hooks/CdnOperations/index.cjs +2 -2
- package/dist/hooks/CdnOperations/index.d.ts +1 -1
- package/dist/hooks/CdnOperations/index.js +2 -2
- package/dist/hooks/ChatToggle/index.cjs +13 -13
- package/dist/hooks/ChatToggle/index.d.cts +1 -1
- package/dist/hooks/ChatToggle/index.js +13 -13
- package/dist/hooks/ChatToggleAnalytics/index.cjs +13 -13
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.js +13 -13
- package/dist/hooks/Debounce/index.d.cts +1 -1
- package/dist/hooks/ElementObserver/index.cjs +1 -1
- package/dist/hooks/ElementObserver/index.js +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +3 -3
- package/dist/hooks/GraphQLConfig/index.d.cts +1 -1
- package/dist/hooks/GraphQLConfig/index.js +3 -3
- package/dist/hooks/IdentifyUser/index.cjs +9 -9
- package/dist/hooks/IdentifyUser/index.d.cts +1 -1
- package/dist/hooks/IdentifyUser/index.js +9 -9
- package/dist/hooks/ImageResolver/index.cjs +1 -1
- package/dist/hooks/ImageResolver/index.d.cts +1 -1
- package/dist/hooks/ImageResolver/index.js +1 -1
- package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
- package/dist/hooks/MessageFilter/index.d.cts +1 -1
- package/dist/hooks/MessageScrollObserver/index.d.cts +1 -1
- package/dist/hooks/NewOrgConfig/index.cjs +6 -6
- package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
- package/dist/hooks/NewOrgConfig/index.d.ts +2 -2
- package/dist/hooks/NewOrgConfig/index.js +6 -6
- package/dist/hooks/Search/index.cjs +15 -15
- package/dist/hooks/Search/index.js +15 -15
- package/dist/hooks/SearchOperations/index.cjs +14 -14
- package/dist/hooks/SearchOperations/index.js +14 -14
- package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
- package/dist/hooks/SystemSettingsContext/index.cjs +2 -2
- package/dist/hooks/SystemSettingsContext/index.d.cts +3 -3
- package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
- package/dist/hooks/SystemSettingsContext/index.js +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +13 -13
- package/dist/hooks/TrackComponentVisibleEvent/index.js +13 -13
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +12 -12
- package/dist/hooks/UpdateAnalyticsProps/index.js +12 -12
- package/dist/hooks/utils.cjs +1 -1
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/hooks/utils.js +1 -1
- package/dist/index-CMZcE7pk.d.cts +1 -1
- package/dist/index-ChiZg0yw.d.cts +1 -1
- package/dist/index-CsmO1rDH.d.ts +1 -1
- package/dist/index-DtzPIcQp.d.ts +1 -1
- package/dist/index-bEjLKG_Q.d.ts +1 -1
- package/dist/index-mv7KvWDq.d.ts +1 -1
- package/dist/{locators-C2fWd-74.js → locators-BMQGmGLq.js} +1 -1
- package/dist/{locators-Cx3q6Z_h.cjs → locators-DxYdak1F.cjs} +1 -1
- package/dist/{newOrgConfigAtom-BuQE_zPK.js → newOrgConfigAtom-C8h3w_Ji.js} +1 -1
- package/dist/{newOrgConfigAtom-rrYHmp1b.cjs → newOrgConfigAtom-CDttTiuu.cjs} +1 -1
- package/dist/{newOrgConfigContext-d3RHl430.cjs → newOrgConfigContext-Brsggue9.cjs} +4 -4
- package/dist/{newOrgConfigContext-D-gU5ppl.js → newOrgConfigContext-Dt_W-wlK.js} +4 -4
- package/dist/{org-CIFgIcO4.cjs → org-BNs_maoW.cjs} +1 -1
- package/dist/{org-15F128Ah.js → org-CScQqL4k.js} +1 -1
- package/dist/{search-Ch6LKNh4.cjs → search-CWkDtqQV.cjs} +2 -2
- package/dist/{search--80x6CfL.js → search-OWKKaQQj.js} +2 -2
- package/dist/{searchContext-BkPoTq1o.js → searchContext-B-rEZixl.js} +4 -4
- package/dist/{searchContext-B0qEUoKb.cjs → searchContext-JCUBg-lA.cjs} +4 -4
- package/dist/{shopifyUrlContext-Bw1kAZ2P.cjs → shopifyUrlContext-COc1eDR_.cjs} +2 -2
- package/dist/{shopifyUrlContext-DnJiUmMA.js → shopifyUrlContext-CToAt_98.js} +2 -2
- package/dist/{systemSettingsContext-DPdDfVhj.js → systemSettingsContext-D9iNGz5v.js} +2 -2
- package/dist/{systemSettingsContext-068vQuP2.cjs → systemSettingsContext-DdV7Yte8.cjs} +2 -2
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +1 -1
- package/dist/{types-B8HZYWV3.cjs → types-1iJ_FnQQ.cjs} +1 -1
- package/dist/{types-y3mhxOUA.js → types-D5du68Vp.js} +1 -1
- package/dist/{urlsParser-bb8ciRFg.cjs → urlsParser-Dax4iVNC.cjs} +1 -1
- package/dist/{urlsParser-v_1DKvyf.js → urlsParser-NAp2LwWP.js} +1 -1
- package/dist/{useAppDetails-eP2hBuid.cjs → useAppDetails-D3T6kJY_.cjs} +4 -4
- package/dist/{useAppDetails-BPXln8UE.js → useAppDetails-xPVs6fW7.js} +4 -4
- package/dist/{useGraphQLConfig-v9veUbvJ.cjs → useGraphQLConfig-B1DaVvFx.cjs} +2 -2
- package/dist/{useGraphQLConfig-Btszi6cG.js → useGraphQLConfig-BtPxjtxw.js} +2 -2
- package/dist/{utils-D_nGHczN.js → utils-BZT_oZ3n.js} +1 -1
- package/dist/{utils-SjlIHajO.cjs → utils-D3MjNkd3.cjs} +2 -2
- package/dist/{utils-CWzuvlOR.js → utils-DMwh3QbT.js} +2 -2
- package/dist/{utils-CJk5iwQI.cjs → utils-qtHPLFby.cjs} +1 -1
- package/package.json +1 -1
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +11 -3
- package/src/contexts/cdnContext/cdnContext.tsx +11 -9
- package/dist/amplitudeContext-BWmXliMI.cjs +0 -243
- package/dist/amplitudeContext-BjMlg5RV.js +0 -227
- package/dist/cdnContext-CJ2BNLAD.js +0 -38
- package/dist/cdnContext-lkC-AE6A.cjs +0 -53
- package/dist/src/application/commerce-api.js +0 -408
- package/dist/src/application/logging/logger.js +0 -16
- package/dist/src/application/models/graphql/index.js +0 -3
- package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +0 -13
- package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +0 -13
- package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +0 -10
- package/dist/src/application/models/guards/api/index.js +0 -12
- package/dist/src/application/models/guards/api/isApiFormResponse.js +0 -59
- package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +0 -22
- package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +0 -91
- package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +0 -188
- package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +0 -115
- package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +0 -16
- package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +0 -26
- package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +0 -15
- package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +0 -65
- package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +0 -15
- package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +0 -10
- package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiResponse.js +0 -33
- package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +0 -22
- package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +0 -23
- package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +0 -20
- package/dist/src/application/models/guards/api/isApiSuggestion.js +0 -24
- package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiUserEvent.js +0 -18
- package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +0 -41
- package/dist/src/application/models/guards/isBaseEcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isGA4EcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +0 -4
- package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +0 -1
- package/dist/src/application/models/guards/isVariantInfo.js +0 -28
- package/dist/src/application/models/guards/utils.js +0 -34
- package/dist/src/application/models/index.js +0 -34
- package/dist/src/application/models/utils/snakeToCamelTransformer.js +0 -71
- package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +0 -65
- package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +0 -9
- package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +0 -420
- package/dist/src/application/models/validators/validateGraphQLOrgId.js +0 -6
- package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +0 -9
- package/dist/src/application/models/validators/validateOrgConfigResults.js +0 -44
- package/dist/src/application/models/validators/validateOrganizationConfig.js +0 -34
- package/dist/src/application/models/validators/validateResponse.js +0 -173
- package/dist/src/application/models/validators/validateSuggestion.js +0 -13
- package/dist/src/application/models/validators/validateUserEvent.js +0 -91
- package/dist/src/application/utils/analyticsUtils.js +0 -95
- package/dist/src/application/utils/coreContextToApiContext.js +0 -8
- package/dist/src/application/utils/coreUserEventToApiUserEvent.js +0 -90
- package/dist/src/application/utils/divideArray.js +0 -7
- package/dist/src/application/utils/domObserver.js +0 -85
- package/dist/src/application/utils/elementObserver.js +0 -186
- package/dist/src/application/utils/imageFilter.js +0 -11
- package/dist/src/application/utils/index.js +0 -21
- package/dist/src/application/utils/merchantUtils.js +0 -15
- package/dist/src/application/utils/messageFromFormSubmittedEvent.js +0 -19
- package/dist/src/application/utils/messageFromQueryEvent.js +0 -35
- package/dist/src/application/utils/messageFromResponse.js +0 -123
- package/dist/src/application/utils/messageFromSuggestionEvent.js +0 -27
- package/dist/src/application/utils/mouseEventTypes.js +0 -1
- package/dist/src/application/utils/mutationHelper.js +0 -33
- package/dist/src/application/utils/nextMessageRequestToApiRequest.js +0 -29
- package/dist/src/application/utils/nodeSelector.js +0 -101
- package/dist/src/application/utils/overrides.js +0 -144
- package/dist/src/application/utils/stringUtils.js +0 -47
- package/dist/src/application/utils/supportedEventRequestToApiRequest.js +0 -7
- package/dist/src/application/utils/urlsParser.js +0 -33
- package/dist/src/application/utils/validation.js +0 -5
- package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +0 -4
- package/dist/src/atoms/app/index.js +0 -23
- package/dist/src/atoms/app/variant.js +0 -102
- package/dist/src/atoms/atomStore/atomStore.js +0 -28
- package/dist/src/atoms/atomStore/index.js +0 -1
- package/dist/src/atoms/chat/chatState.js +0 -32
- package/dist/src/atoms/chat/form.js +0 -16
- package/dist/src/atoms/chat/index.js +0 -23
- package/dist/src/atoms/chat/lastMessage.js +0 -10
- package/dist/src/atoms/chat/messageQueue.js +0 -68
- package/dist/src/atoms/chat/performanceMetrics.js +0 -70
- package/dist/src/atoms/chat/renderedWidgetRefs.js +0 -24
- package/dist/src/atoms/chat/replies.js +0 -42
- package/dist/src/atoms/chat/suggestions.js +0 -29
- package/dist/src/atoms/envive/enviveConfig.js +0 -67
- package/dist/src/atoms/globalSearch/globalSearch.js +0 -8
- package/dist/src/atoms/globalSearch/index.js +0 -1
- package/dist/src/atoms/org/customerService.js +0 -6
- package/dist/src/atoms/org/graphqlConfig.js +0 -8
- package/dist/src/atoms/org/index.js +0 -4
- package/dist/src/atoms/org/newOrgConfigAtom.js +0 -2
- package/dist/src/atoms/org/orgAnalyticsConfig.js +0 -8
- package/dist/src/atoms/search/index.js +0 -1
- package/dist/src/atoms/search/productFilters.js +0 -163
- package/dist/src/atoms/search/productRetrievalAPI.js +0 -50
- package/dist/src/atoms/search/productRetrievalAdapter.js +0 -14
- package/dist/src/atoms/search/productSorter.js +0 -13
- package/dist/src/atoms/search/searchAPI.js +0 -140
- package/dist/src/atoms/search/searchServiceAdapter.js +0 -14
- package/dist/src/atoms/search/utils.js +0 -15
- package/dist/src/config/index.js +0 -1
- package/dist/src/config/locators/components/chat/entrypoints.js +0 -10
- package/dist/src/config/locators/components/chat/index.js +0 -21
- package/dist/src/config/locators/components/chat/preview.js +0 -11
- package/dist/src/config/locators/components/chat/variants/index.js +0 -12
- package/dist/src/config/locators/components/common/buttons.js +0 -6
- package/dist/src/config/locators/components/common/cards.js +0 -17
- package/dist/src/config/locators/components/common/index.js +0 -4
- package/dist/src/config/locators/components/common/links.js +0 -1
- package/dist/src/config/locators/components/common/tables.js +0 -1
- package/dist/src/config/locators/components/floating-button.js +0 -2
- package/dist/src/config/locators/components/index.js +0 -3
- package/dist/src/config/locators/components/report-issue.js +0 -13
- package/dist/src/config/locators/components/search/index.js +0 -5
- package/dist/src/config/locators/components/shadow-dom.js +0 -1
- package/dist/src/config/locators/embedded.js +0 -20
- package/dist/src/config/locators/index.js +0 -4
- package/dist/src/contexts/amplitudeContext/amplitudeContext.js +0 -271
- package/dist/src/contexts/amplitudeContext/index.js +0 -1
- package/dist/src/contexts/cdnContext/cdnContext.js +0 -28
- package/dist/src/contexts/cdnContext/index.js +0 -1
- package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +0 -37
- package/dist/src/contexts/enviveConfigContext/index.js +0 -1
- package/dist/src/contexts/enviveCssContext/enviveCssContext.js +0 -31
- package/dist/src/contexts/enviveCssContext/index.js +0 -1
- package/dist/src/contexts/featureFlagContext/featureFlagContext.js +0 -109
- package/dist/src/contexts/featureFlagContext/index.js +0 -1
- package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +0 -47
- package/dist/src/contexts/featureFlagServiceContext/index.js +0 -1
- package/dist/src/contexts/graphqlContext/graphqlContext.js +0 -87
- package/dist/src/contexts/graphqlContext/index.js +0 -1
- package/dist/src/contexts/localStorageContext/index.js +0 -1
- package/dist/src/contexts/localStorageContext/localStorageContext.js +0 -95
- package/dist/src/contexts/newOrgConfigContext/index.js +0 -1
- package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +0 -33
- package/dist/src/contexts/searchContext/index.js +0 -1
- package/dist/src/contexts/searchContext/searchContext.js +0 -131
- package/dist/src/contexts/sessionStorageContext/index.js +0 -1
- package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +0 -43
- package/dist/src/contexts/shopifyUrlContext/index.js +0 -1
- package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +0 -62
- package/dist/src/contexts/systemSettingsContext/index.js +0 -1
- package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +0 -29
- package/dist/src/contexts/userIdentityContext/index.js +0 -1
- package/dist/src/contexts/userIdentityContext/userIdentityContext.js +0 -118
- package/dist/src/events/index.js +0 -51
- package/dist/src/events/registerAnalyticsListeners.js +0 -32
- package/dist/src/exceptions/index.js +0 -2
- package/dist/src/exceptions/sessionExceptions.js +0 -6
- package/dist/src/exceptions/unsupportedProductExceptions.js +0 -6
- package/dist/src/hooks/AmplitudeOperations/index.js +0 -1
- package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +0 -24
- package/dist/src/hooks/AppDetails/index.js +0 -1
- package/dist/src/hooks/AppDetails/useAppDetails.js +0 -26
- package/dist/src/hooks/BlockBackButton/index.js +0 -1
- package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +0 -23
- package/dist/src/hooks/CdnOperations/index.js +0 -1
- package/dist/src/hooks/CdnOperations/useCdnOperations.js +0 -13
- package/dist/src/hooks/ChatToggle/index.js +0 -1
- package/dist/src/hooks/ChatToggle/useChatToggle.js +0 -50
- package/dist/src/hooks/ChatToggleAnalytics/index.js +0 -1
- package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +0 -11
- package/dist/src/hooks/CustomerSupportHandoff/index.js +0 -1
- package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +0 -32
- package/dist/src/hooks/Debounce/index.js +0 -1
- package/dist/src/hooks/Debounce/useDebounce.js +0 -13
- package/dist/src/hooks/ElementObserver/index.js +0 -1
- package/dist/src/hooks/ElementObserver/useElementObserver.js +0 -208
- package/dist/src/hooks/GrabAndScroll/index.js +0 -1
- package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +0 -105
- package/dist/src/hooks/GraphQLConfig/index.js +0 -1
- package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +0 -54
- package/dist/src/hooks/IdentifyUser/index.js +0 -1
- package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +0 -28
- package/dist/src/hooks/ImageResolver/index.js +0 -1
- package/dist/src/hooks/ImageResolver/useImageResolver.js +0 -45
- package/dist/src/hooks/Intersection/index.js +0 -1
- package/dist/src/hooks/Intersection/useIntersection.js +0 -20
- package/dist/src/hooks/IsSmallScreen/index.js +0 -1
- package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +0 -16
- package/dist/src/hooks/LocalStorageOperations/index.js +0 -1
- package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +0 -64
- package/dist/src/hooks/MessageFilter/index.js +0 -1
- package/dist/src/hooks/MessageFilter/useMessageFilter.js +0 -37
- package/dist/src/hooks/MessageScrollObserver/index.js +0 -1
- package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +0 -35
- package/dist/src/hooks/NewOrgConfig/index.js +0 -1
- package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +0 -5
- package/dist/src/hooks/Search/index.js +0 -1
- package/dist/src/hooks/Search/useRecommendedProducts.js +0 -35
- package/dist/src/hooks/Search/useSearch.js +0 -224
- package/dist/src/hooks/Search/useSearchInput.js +0 -192
- package/dist/src/hooks/SearchOperations/index.js +0 -1
- package/dist/src/hooks/SearchOperations/useSearchOperations.js +0 -78
- package/dist/src/hooks/SessionStorageOperations/index.js +0 -1
- package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +0 -20
- package/dist/src/hooks/ShopifyUrlOperations/index.js +0 -1
- package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +0 -34
- package/dist/src/hooks/SnapCalculator/index.js +0 -1
- package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +0 -22
- package/dist/src/hooks/SystemSettingsContext/index.js +0 -1
- package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +0 -9
- package/dist/src/hooks/TrackComponentVisibleEvent/index.js +0 -1
- package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +0 -45
- package/dist/src/hooks/UpdateAnalyticsProps/index.js +0 -1
- package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +0 -43
- package/dist/src/hooks/utils.js +0 -116
- package/dist/src/interceptors/index.js +0 -1
- package/dist/src/interceptors/useMessageInterceptor.js +0 -24
- package/dist/src/types/ApiResponse.js +0 -1
- package/dist/src/types/FilterAttribute.js +0 -3
- package/dist/src/types/Message.js +0 -24
- package/dist/src/types/Suggestion.js +0 -3
- package/dist/src/types/index.js +0 -4
- package/dist/src/util/colorVar.js +0 -3
- package/dist/src/util/configVersion.js +0 -4
- package/dist/src/util/domInsertion.js +0 -16
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
|
-
import { ProductSorting, SpiffyMetricsEventName, SpiffyWidgets, } from "@envive-ai/types";
|
|
4
|
-
import { addSearchFilterAtom, clearSearchFiltersAtom, createFilterOption, filteredSearchProductsAtom, performSearchAtom, removeSearchFilterAtom, searchAtom, searchFiltersAtom, searchParamsAtom, searchProductSortingAtom, searchSelectedFiltersAtom, } from "../../atoms/search";
|
|
5
|
-
import { isFilterOpenAtom } from "../../atoms/globalSearch/globalSearch";
|
|
6
|
-
import { formatFilterDisplayName } from "../../atoms/search/utils";
|
|
7
|
-
import { amplitudeTrackEventAtom } from "../../atoms/amplitude/amplitudeTrackEventAtom";
|
|
8
|
-
import { orgShortNameAtom } from "../../atoms/envive/enviveConfig";
|
|
9
|
-
import { newOrgConfigAtom } from "../../atoms/org/newOrgConfigAtom";
|
|
10
|
-
import { retrievedProductsAtom } from "../../atoms/search/productRetrievalAPI";
|
|
11
|
-
import { useTrackComponentVisibleEvent } from "../TrackComponentVisibleEvent";
|
|
12
|
-
import { getSearchResultsState } from "../utils";
|
|
13
|
-
import { useSearchInput } from "./useSearchInput";
|
|
14
|
-
export const useSearch = () => {
|
|
15
|
-
var _a, _b, _c;
|
|
16
|
-
// Atoms
|
|
17
|
-
const trackEvent = useAtomValue(amplitudeTrackEventAtom);
|
|
18
|
-
const config = useAtomValue(newOrgConfigAtom);
|
|
19
|
-
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
20
|
-
const { data: searchData, loading: isLoadingSearch } = useAtomValue(searchAtom);
|
|
21
|
-
const productList = useAtomValue(filteredSearchProductsAtom);
|
|
22
|
-
const performSearch = useSetAtom(performSearchAtom);
|
|
23
|
-
const [{ query }] = useAtom(searchParamsAtom);
|
|
24
|
-
const [isFilterOpen, setIsFilterOpen] = useAtom(isFilterOpenAtom);
|
|
25
|
-
const [selectedFilterOptions] = useAtom(searchSelectedFiltersAtom);
|
|
26
|
-
const addFilter = useSetAtom(addSearchFilterAtom);
|
|
27
|
-
const removeFilter = useSetAtom(removeSearchFilterAtom);
|
|
28
|
-
const [productSorting, setProductSorting] = useAtom(searchProductSortingAtom);
|
|
29
|
-
const clearFilters = useSetAtom(clearSearchFiltersAtom);
|
|
30
|
-
const searchFilters = useAtomValue(searchFiltersAtom);
|
|
31
|
-
const recommendedProducts = useAtomValue(retrievedProductsAtom);
|
|
32
|
-
// Refs
|
|
33
|
-
const searchResultsRef = useRef(null);
|
|
34
|
-
// Utilities
|
|
35
|
-
const scrollToTop = useCallback(() => {
|
|
36
|
-
const container = searchResultsRef.current;
|
|
37
|
-
if (container) {
|
|
38
|
-
container.scrollTo({ top: 0, behavior: "smooth" });
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
42
|
-
}
|
|
43
|
-
}, []);
|
|
44
|
-
// Search Input Hook
|
|
45
|
-
const searchInput = useSearchInput({
|
|
46
|
-
initialSearchText: query || "",
|
|
47
|
-
searchOrigin: SpiffyWidgets.SearchResults,
|
|
48
|
-
onSearchSubmit: (searchQuery) => {
|
|
49
|
-
performSearch({ query: searchQuery });
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
const { searchText, focusedIndex, focusedOptionId, autocompleteResults, shouldShowAutocomplete, handleSearchInputChange, handleSearchInputFocus, handleSearchInputBlur, handleKeyDown, handleAutocompleteSelect, handleSubmitSearch, setSearchText, } = searchInput;
|
|
53
|
-
const searchResultsState = getSearchResultsState(isLoadingSearch, searchData);
|
|
54
|
-
const dynamicFilters = (searchData === null || searchData === void 0 ? void 0 : searchData.filters) || [];
|
|
55
|
-
// Provide fallback values when config is not yet available
|
|
56
|
-
const safeProductCardConfig = ((_b = (_a = config === null || config === void 0 ? void 0 : config.frontendConfig) === null || _a === void 0 ? void 0 : _a.uiConfigs) === null || _b === void 0 ? void 0 : _b.productCardConfig) || {
|
|
57
|
-
variant: "minimal",
|
|
58
|
-
hoverVariant: "none",
|
|
59
|
-
layoutVariant: "square",
|
|
60
|
-
};
|
|
61
|
-
const safeMerchantShortName = orgShortName || "";
|
|
62
|
-
const availableDynamicFilters = useMemo(() => {
|
|
63
|
-
return dynamicFilters
|
|
64
|
-
.filter((dynamicFilterName) => !selectedFilterOptions.some((option) => option.id === `dynamic:${dynamicFilterName}`))
|
|
65
|
-
.map((dynamicFilterName) => ({
|
|
66
|
-
name: dynamicFilterName,
|
|
67
|
-
displayName: formatFilterDisplayName(dynamicFilterName),
|
|
68
|
-
}));
|
|
69
|
-
}, [dynamicFilters, selectedFilterOptions]);
|
|
70
|
-
const filters = useMemo(() => {
|
|
71
|
-
const sortOptions = [
|
|
72
|
-
{
|
|
73
|
-
filterItemId: String(ProductSorting.FEATURED),
|
|
74
|
-
displayName: "Relevance",
|
|
75
|
-
productCount: 0,
|
|
76
|
-
isSelected: productSorting === ProductSorting.FEATURED,
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
filterItemId: String(ProductSorting.PRICE_ASC),
|
|
80
|
-
displayName: "Price: Low to High",
|
|
81
|
-
productCount: 0,
|
|
82
|
-
isSelected: productSorting === ProductSorting.PRICE_ASC,
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
filterItemId: String(ProductSorting.PRICE_DESC),
|
|
86
|
-
displayName: "Price: High to Low",
|
|
87
|
-
productCount: 0,
|
|
88
|
-
isSelected: productSorting === ProductSorting.PRICE_DESC,
|
|
89
|
-
},
|
|
90
|
-
];
|
|
91
|
-
return [
|
|
92
|
-
{ filterId: "sort", displayName: "SORT", items: sortOptions },
|
|
93
|
-
...searchFilters,
|
|
94
|
-
];
|
|
95
|
-
}, [productSorting, searchFilters]);
|
|
96
|
-
const filterButtonText = useMemo(() => {
|
|
97
|
-
const selectedCount = filters.reduce((acc, filter) => {
|
|
98
|
-
if (filter.filterId === "sort") {
|
|
99
|
-
return acc;
|
|
100
|
-
}
|
|
101
|
-
return acc + filter.items.filter((item) => item.isSelected).length;
|
|
102
|
-
}, 0);
|
|
103
|
-
if (selectedCount === 0) {
|
|
104
|
-
return "Filter & Sort";
|
|
105
|
-
}
|
|
106
|
-
return `Filter & Sort (${selectedCount})`;
|
|
107
|
-
}, [filters]);
|
|
108
|
-
// Callbacks
|
|
109
|
-
const handleToggleDynamicFilter = useCallback(({ filter, dynamicFilterDisplayName, }) => {
|
|
110
|
-
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
111
|
-
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
112
|
-
eventProps: {
|
|
113
|
-
filterType: "Dynamic",
|
|
114
|
-
filterValue: filter,
|
|
115
|
-
queryText: searchText,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
addFilter(createFilterOption("dynamic", filter, dynamicFilterDisplayName));
|
|
119
|
-
scrollToTop();
|
|
120
|
-
}, [addFilter, searchText, scrollToTop, trackEvent]);
|
|
121
|
-
const handleRemoveFilter = useCallback((filter) => {
|
|
122
|
-
removeFilter(filter.id);
|
|
123
|
-
scrollToTop();
|
|
124
|
-
}, [removeFilter, scrollToTop]);
|
|
125
|
-
const handleSelectFilterItem = useCallback(({ filterId, filterItemId, isSelected, displayName, }) => {
|
|
126
|
-
if (filterId === "sort") {
|
|
127
|
-
const newSort = filterItemId;
|
|
128
|
-
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
129
|
-
eventName: SpiffyMetricsEventName.SearchSortClicked,
|
|
130
|
-
eventProps: {
|
|
131
|
-
sortType: newSort,
|
|
132
|
-
queryText: searchText,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
setProductSorting(newSort);
|
|
136
|
-
scrollToTop();
|
|
137
|
-
}
|
|
138
|
-
else if (!isSelected) {
|
|
139
|
-
removeFilter(`${filterId}:${filterItemId}`);
|
|
140
|
-
scrollToTop();
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
144
|
-
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
145
|
-
eventProps: {
|
|
146
|
-
filterType: "Static",
|
|
147
|
-
filterCategory: filterId,
|
|
148
|
-
filterValue: filterItemId,
|
|
149
|
-
queryText: searchText,
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
addFilter(createFilterOption(filterId, filterItemId, displayName));
|
|
153
|
-
scrollToTop();
|
|
154
|
-
}
|
|
155
|
-
}, [
|
|
156
|
-
addFilter,
|
|
157
|
-
removeFilter,
|
|
158
|
-
setProductSorting,
|
|
159
|
-
searchText,
|
|
160
|
-
scrollToTop,
|
|
161
|
-
trackEvent,
|
|
162
|
-
]);
|
|
163
|
-
const handleClearAllFilters = useCallback(() => {
|
|
164
|
-
setProductSorting(ProductSorting.FEATURED);
|
|
165
|
-
clearFilters();
|
|
166
|
-
scrollToTop();
|
|
167
|
-
}, [setProductSorting, clearFilters, scrollToTop]);
|
|
168
|
-
// Side Effects
|
|
169
|
-
useTrackComponentVisibleEvent(SpiffyWidgets.SearchResults, searchResultsRef, {}, SpiffyMetricsEventName.SearchComponentVisible);
|
|
170
|
-
useEffect(() => {
|
|
171
|
-
if (productList.length > 0) {
|
|
172
|
-
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
173
|
-
eventName: SpiffyMetricsEventName.SearchResultsViewed,
|
|
174
|
-
eventProps: {
|
|
175
|
-
queryText: searchText,
|
|
176
|
-
resultsCount: productList.length,
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}, [productList.length, searchText, trackEvent]);
|
|
181
|
-
// This is the single source of truth for the search text triggering a search
|
|
182
|
-
useEffect(() => {
|
|
183
|
-
if (query && query !== searchText) {
|
|
184
|
-
const esq = new URLSearchParams(window.location.search).get("esq");
|
|
185
|
-
setSearchText(query);
|
|
186
|
-
performSearch({ query: esq !== null && esq !== void 0 ? esq : query });
|
|
187
|
-
}
|
|
188
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
189
|
-
}, [performSearch, query, setSearchText]);
|
|
190
|
-
return {
|
|
191
|
-
searchData,
|
|
192
|
-
searchResponseId: (_c = searchData === null || searchData === void 0 ? void 0 : searchData.searchResponseId) !== null && _c !== void 0 ? _c : "",
|
|
193
|
-
merchantShortName: safeMerchantShortName,
|
|
194
|
-
productCardConfig: safeProductCardConfig,
|
|
195
|
-
productList,
|
|
196
|
-
recommendedProducts,
|
|
197
|
-
autocompleteResults,
|
|
198
|
-
searchFilters: filters,
|
|
199
|
-
availableDynamicFilters,
|
|
200
|
-
selectedFilterOptions,
|
|
201
|
-
searchText,
|
|
202
|
-
query: query || "",
|
|
203
|
-
searchResultsState,
|
|
204
|
-
isLoadingSearch,
|
|
205
|
-
isLoadingAutocomplete: false,
|
|
206
|
-
isFilterOpen,
|
|
207
|
-
shouldShowAutocomplete,
|
|
208
|
-
focusedIndex,
|
|
209
|
-
focusedOptionId,
|
|
210
|
-
filterButtonText,
|
|
211
|
-
onSearchInputChange: handleSearchInputChange,
|
|
212
|
-
onSubmitSearch: handleSubmitSearch,
|
|
213
|
-
onAutocompleteSelect: handleAutocompleteSelect,
|
|
214
|
-
onKeyDown: handleKeyDown,
|
|
215
|
-
onSearchInputFocus: handleSearchInputFocus,
|
|
216
|
-
onSearchInputBlur: handleSearchInputBlur,
|
|
217
|
-
onToggleDynamicFilter: handleToggleDynamicFilter,
|
|
218
|
-
onSelectFilterItem: handleSelectFilterItem,
|
|
219
|
-
onRemoveFilter: handleRemoveFilter,
|
|
220
|
-
onClearAllFilters: handleClearAllFilters,
|
|
221
|
-
setIsFilterOpen,
|
|
222
|
-
searchResultsRef,
|
|
223
|
-
};
|
|
224
|
-
};
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback, useRef, useMemo } from "react";
|
|
2
|
-
import { useAtomValue } from "jotai";
|
|
3
|
-
import Fuse from "fuse.js";
|
|
4
|
-
import { SpiffyMetricsEventName, } from "@envive-ai/types";
|
|
5
|
-
import { autocompleteStateAtom } from "src/atoms/globalSearch";
|
|
6
|
-
import { amplitudeTrackEventAtom } from "src/atoms/amplitude/amplitudeTrackEventAtom";
|
|
7
|
-
export const useSearchInput = ({ initialSearchText = "", searchOrigin, onSearchSubmit, }) => {
|
|
8
|
-
const track = useAtomValue(amplitudeTrackEventAtom);
|
|
9
|
-
// State
|
|
10
|
-
const [searchText, setSearchText] = useState(initialSearchText);
|
|
11
|
-
const [hasText, setHasText] = useState(initialSearchText.trim().length > 0);
|
|
12
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
13
|
-
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
14
|
-
const [focusedOptionId, setFocusedOptionId] = useState(undefined);
|
|
15
|
-
const autocompleteState = useAtomValue(autocompleteStateAtom);
|
|
16
|
-
const globalAutocompleteResults = autocompleteState.results;
|
|
17
|
-
const isAutocompleteEnabled = globalAutocompleteResults.length > 0;
|
|
18
|
-
// Refs
|
|
19
|
-
const isSelectingAutocomplete = useRef(false);
|
|
20
|
-
// Computed
|
|
21
|
-
const shouldShowAutocomplete = hasText && isFocused && isAutocompleteEnabled;
|
|
22
|
-
const autocompleteResultsLimit = 5;
|
|
23
|
-
// Configure Fuse.js for fuzzy search with custom scoring
|
|
24
|
-
const fuseOptions = useMemo(() => ({
|
|
25
|
-
includeScore: true,
|
|
26
|
-
includeMatches: true,
|
|
27
|
-
// Fuzzy matching threshold (0.0 = perfect match, 1.0 = match anything)
|
|
28
|
-
threshold: 0.3,
|
|
29
|
-
// Location where match is expected (0 = beginning)
|
|
30
|
-
location: 0,
|
|
31
|
-
// Distance from location where match can be found - smaller for prefix preference
|
|
32
|
-
distance: 4,
|
|
33
|
-
// Minimum character length before fuzzy matching starts
|
|
34
|
-
minMatchCharLength: 1,
|
|
35
|
-
// Keys to search (we're searching strings directly, so no keys needed)
|
|
36
|
-
keys: [],
|
|
37
|
-
// Use extended search for exact matches and prefix matching
|
|
38
|
-
useExtendedSearch: false,
|
|
39
|
-
// Don't ignore location - this helps prioritize matches at the beginning
|
|
40
|
-
ignoreLocation: false,
|
|
41
|
-
}), []);
|
|
42
|
-
const fuse = useMemo(() => {
|
|
43
|
-
if (!globalAutocompleteResults.length)
|
|
44
|
-
return null;
|
|
45
|
-
return new Fuse(globalAutocompleteResults, fuseOptions);
|
|
46
|
-
}, [globalAutocompleteResults, fuseOptions]);
|
|
47
|
-
// Autocomplete fuzzy search using Fuse.js
|
|
48
|
-
const autocompleteResults = useMemo(() => {
|
|
49
|
-
if (!isAutocompleteEnabled || !fuse) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
if (!searchText.trim()) {
|
|
53
|
-
return [];
|
|
54
|
-
}
|
|
55
|
-
const fuseResults = fuse.search(searchText);
|
|
56
|
-
// Use only Fuse.js scoring (results are already sorted by relevance)
|
|
57
|
-
return fuseResults
|
|
58
|
-
.slice(0, autocompleteResultsLimit)
|
|
59
|
-
.map((result) => result.item);
|
|
60
|
-
}, [isAutocompleteEnabled, fuse, searchText, autocompleteResultsLimit]);
|
|
61
|
-
// Handlers
|
|
62
|
-
const handleSearchInputChange = useCallback((newValue) => {
|
|
63
|
-
// If the user is changing text, they must be interacting with the input
|
|
64
|
-
// So we can safely assume they're focused
|
|
65
|
-
if (newValue !== searchText) {
|
|
66
|
-
setIsFocused(true);
|
|
67
|
-
}
|
|
68
|
-
if (newValue.length === 1) {
|
|
69
|
-
track === null || track === void 0 ? void 0 : track({
|
|
70
|
-
eventName: SpiffyMetricsEventName.SearchInputStarted,
|
|
71
|
-
eventProps: {
|
|
72
|
-
searchOrigin,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
setSearchText(newValue);
|
|
77
|
-
setHasText(newValue.trim().length > 0);
|
|
78
|
-
setFocusedIndex(-1);
|
|
79
|
-
setFocusedOptionId(undefined);
|
|
80
|
-
}, [searchOrigin, searchText, track]);
|
|
81
|
-
const handleSearchInputFocus = useCallback(() => {
|
|
82
|
-
setIsFocused(true);
|
|
83
|
-
}, []);
|
|
84
|
-
const handleSearchInputBlur = useCallback(() => {
|
|
85
|
-
setTimeout(() => {
|
|
86
|
-
if (!isSelectingAutocomplete.current) {
|
|
87
|
-
setIsFocused(false);
|
|
88
|
-
setFocusedIndex(-1);
|
|
89
|
-
setFocusedOptionId(undefined);
|
|
90
|
-
}
|
|
91
|
-
}, 150);
|
|
92
|
-
}, []);
|
|
93
|
-
const handleSubmitSearch = useCallback(() => {
|
|
94
|
-
setIsFocused(false);
|
|
95
|
-
if (searchText.trim() && onSearchSubmit) {
|
|
96
|
-
track === null || track === void 0 ? void 0 : track({
|
|
97
|
-
eventName: SpiffyMetricsEventName.SearchQuerySubmitted,
|
|
98
|
-
eventProps: {
|
|
99
|
-
searchOrigin,
|
|
100
|
-
queryText: searchText.trim(),
|
|
101
|
-
},
|
|
102
|
-
alsoSendToGoogleAnalytics: true,
|
|
103
|
-
});
|
|
104
|
-
onSearchSubmit(searchText.trim());
|
|
105
|
-
}
|
|
106
|
-
}, [searchText, onSearchSubmit, searchOrigin, track]);
|
|
107
|
-
const handleAutocompleteSelect = useCallback((suggestion, rankPosition) => {
|
|
108
|
-
isSelectingAutocomplete.current = true;
|
|
109
|
-
setSearchText(suggestion);
|
|
110
|
-
setHasText(suggestion.trim().length > 0);
|
|
111
|
-
setIsFocused(false);
|
|
112
|
-
track === null || track === void 0 ? void 0 : track({
|
|
113
|
-
eventName: SpiffyMetricsEventName.SearchInputStarted,
|
|
114
|
-
eventProps: {
|
|
115
|
-
searchOrigin,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
if (onSearchSubmit) {
|
|
119
|
-
onSearchSubmit(suggestion.trim());
|
|
120
|
-
}
|
|
121
|
-
setTimeout(() => {
|
|
122
|
-
isSelectingAutocomplete.current = false;
|
|
123
|
-
}, 100);
|
|
124
|
-
}, [onSearchSubmit, searchOrigin, track]);
|
|
125
|
-
const handleKeyDown = useCallback((event) => {
|
|
126
|
-
if (event.key === "ArrowDown") {
|
|
127
|
-
event.preventDefault();
|
|
128
|
-
const newIndex = (focusedIndex + 1) % autocompleteResults.length;
|
|
129
|
-
setFocusedIndex(newIndex);
|
|
130
|
-
setFocusedOptionId(`option-${newIndex}`);
|
|
131
|
-
}
|
|
132
|
-
else if (event.key === "ArrowUp") {
|
|
133
|
-
event.preventDefault();
|
|
134
|
-
const newIndex = (focusedIndex - 1 + autocompleteResults.length) %
|
|
135
|
-
autocompleteResults.length;
|
|
136
|
-
setFocusedIndex(newIndex);
|
|
137
|
-
setFocusedOptionId(`option-${newIndex}`);
|
|
138
|
-
}
|
|
139
|
-
else if (event.key === "Enter") {
|
|
140
|
-
if (focusedIndex === -1) {
|
|
141
|
-
event.preventDefault();
|
|
142
|
-
handleSubmitSearch();
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
event.preventDefault();
|
|
146
|
-
const suggestionText = autocompleteResults[focusedIndex];
|
|
147
|
-
handleAutocompleteSelect(suggestionText, focusedIndex);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else if (event.key === "Escape") {
|
|
151
|
-
event.preventDefault();
|
|
152
|
-
setFocusedIndex(-1);
|
|
153
|
-
setFocusedOptionId(undefined);
|
|
154
|
-
}
|
|
155
|
-
}, [
|
|
156
|
-
autocompleteResults,
|
|
157
|
-
focusedIndex,
|
|
158
|
-
handleAutocompleteSelect,
|
|
159
|
-
handleSubmitSearch,
|
|
160
|
-
]);
|
|
161
|
-
const setSearchTextUtility = useCallback((text) => {
|
|
162
|
-
setSearchText(text);
|
|
163
|
-
setHasText(text.trim().length > 0);
|
|
164
|
-
}, []);
|
|
165
|
-
const resetSearch = useCallback(() => {
|
|
166
|
-
setSearchText("");
|
|
167
|
-
setHasText(false);
|
|
168
|
-
setIsFocused(false);
|
|
169
|
-
setFocusedIndex(-1);
|
|
170
|
-
setFocusedOptionId(undefined);
|
|
171
|
-
}, []);
|
|
172
|
-
return {
|
|
173
|
-
// State
|
|
174
|
-
searchText,
|
|
175
|
-
hasText,
|
|
176
|
-
isFocused,
|
|
177
|
-
focusedIndex,
|
|
178
|
-
focusedOptionId,
|
|
179
|
-
autocompleteResults,
|
|
180
|
-
shouldShowAutocomplete,
|
|
181
|
-
// Handlers
|
|
182
|
-
handleSearchInputChange,
|
|
183
|
-
handleSearchInputFocus,
|
|
184
|
-
handleSearchInputBlur,
|
|
185
|
-
handleKeyDown,
|
|
186
|
-
handleAutocompleteSelect,
|
|
187
|
-
handleSubmitSearch,
|
|
188
|
-
// Utilities
|
|
189
|
-
setSearchText: setSearchTextUtility,
|
|
190
|
-
resetSearch,
|
|
191
|
-
};
|
|
192
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useSearchOperations";
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { useSearchService } from 'src/contexts/searchContext';
|
|
3
|
-
export const useProductSearch = () => {
|
|
4
|
-
const { searchProducts, isReady } = useSearchService();
|
|
5
|
-
const [data, setData] = useState();
|
|
6
|
-
const [loading, setLoading] = useState(false);
|
|
7
|
-
const [error, setError] = useState(null);
|
|
8
|
-
const search = useCallback(async (params) => {
|
|
9
|
-
if (!isReady) {
|
|
10
|
-
setError(new Error('Search service not ready - missing dependencies'));
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
setLoading(true);
|
|
14
|
-
setError(null);
|
|
15
|
-
try {
|
|
16
|
-
const result = await searchProducts(params);
|
|
17
|
-
setData(result);
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
setError(err instanceof Error ? err : new Error('Unknown search error'));
|
|
21
|
-
}
|
|
22
|
-
finally {
|
|
23
|
-
setLoading(false);
|
|
24
|
-
}
|
|
25
|
-
}, [searchProducts, isReady]);
|
|
26
|
-
const reset = useCallback(() => {
|
|
27
|
-
setData(undefined);
|
|
28
|
-
setError(null);
|
|
29
|
-
setLoading(false);
|
|
30
|
-
}, []);
|
|
31
|
-
return {
|
|
32
|
-
data,
|
|
33
|
-
loading,
|
|
34
|
-
error,
|
|
35
|
-
search,
|
|
36
|
-
reset,
|
|
37
|
-
isReady,
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export const useSearchWithQuery = (params) => {
|
|
41
|
-
const { searchProducts, isReady } = useSearchService();
|
|
42
|
-
const [data, setData] = useState();
|
|
43
|
-
const [loading, setLoading] = useState(false);
|
|
44
|
-
const [error, setError] = useState(null);
|
|
45
|
-
const executeSearch = useCallback(async (searchParams) => {
|
|
46
|
-
if (!isReady)
|
|
47
|
-
return;
|
|
48
|
-
setLoading(true);
|
|
49
|
-
setError(null);
|
|
50
|
-
try {
|
|
51
|
-
const result = await searchProducts(searchParams);
|
|
52
|
-
setData(result);
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
setError(err instanceof Error ? err : new Error('Unknown search error'));
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
setLoading(false);
|
|
59
|
-
}
|
|
60
|
-
}, [searchProducts, isReady]);
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (params && isReady) {
|
|
63
|
-
executeSearch(params);
|
|
64
|
-
}
|
|
65
|
-
}, [params, isReady, executeSearch]);
|
|
66
|
-
const refetch = useCallback(() => {
|
|
67
|
-
if (params) {
|
|
68
|
-
executeSearch(params);
|
|
69
|
-
}
|
|
70
|
-
}, [params, executeSearch]);
|
|
71
|
-
return {
|
|
72
|
-
data,
|
|
73
|
-
loading,
|
|
74
|
-
error,
|
|
75
|
-
refetch,
|
|
76
|
-
isReady,
|
|
77
|
-
};
|
|
78
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useSessionStorageOperations";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback } from "react";
|
|
2
|
-
import { useSessionStorage } from "src/contexts/sessionStorageContext";
|
|
3
|
-
export const useSessionStorageValue = (key) => {
|
|
4
|
-
const { getItem, setItem } = useSessionStorage();
|
|
5
|
-
const [value, setValue] = useState(() => getItem(key));
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const handleStorageChange = (event) => {
|
|
8
|
-
if (event.key === key) {
|
|
9
|
-
setValue(event.newValue);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
window.addEventListener("storage", handleStorageChange);
|
|
13
|
-
return () => window.removeEventListener("storage", handleStorageChange);
|
|
14
|
-
}, [key, getItem]);
|
|
15
|
-
const updateValue = useCallback((newValue) => {
|
|
16
|
-
setItem(key, newValue);
|
|
17
|
-
setValue(newValue);
|
|
18
|
-
}, [key, setItem]);
|
|
19
|
-
return { value, setValue: updateValue };
|
|
20
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useShopifyUrlOperations";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { useShopifyUrl } from 'src/contexts/shopifyUrlContext/shopifyUrlContext';
|
|
3
|
-
export const useShopifyUrlOperations = () => {
|
|
4
|
-
const { getTrimmedPathName, getPlpOrPdpId, isOnPdpPage, isOnPlpPage, isReady } = useShopifyUrl();
|
|
5
|
-
return {
|
|
6
|
-
getTrimmedPathName,
|
|
7
|
-
getPlpOrPdpId,
|
|
8
|
-
isOnPdpPage,
|
|
9
|
-
isOnPlpPage,
|
|
10
|
-
isReady,
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export const useCurrentPageType = () => {
|
|
14
|
-
const { isOnPdpPage, isOnPlpPage, isReady } = useShopifyUrl();
|
|
15
|
-
const getPageType = useCallback(() => {
|
|
16
|
-
if (!isReady)
|
|
17
|
-
return 'unknown';
|
|
18
|
-
if (isOnPdpPage())
|
|
19
|
-
return 'pdp';
|
|
20
|
-
if (isOnPlpPage())
|
|
21
|
-
return 'plp';
|
|
22
|
-
return 'other';
|
|
23
|
-
}, [isReady, isOnPdpPage, isOnPlpPage]);
|
|
24
|
-
return { getPageType, isReady };
|
|
25
|
-
};
|
|
26
|
-
export const useProductId = (extractor) => {
|
|
27
|
-
const { getPlpOrPdpId, isReady } = useShopifyUrl();
|
|
28
|
-
const productId = useCallback(() => {
|
|
29
|
-
if (!isReady)
|
|
30
|
-
return null;
|
|
31
|
-
return getPlpOrPdpId(extractor);
|
|
32
|
-
}, [isReady, getPlpOrPdpId, extractor]);
|
|
33
|
-
return { productId, isReady };
|
|
34
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useSnapCalculator";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
export const useSnapCalculator = (snaps, maxHeight, unit) => {
|
|
3
|
-
const viewportHeightPx = document.documentElement.clientHeight;
|
|
4
|
-
const swipeviewHeightPx = unit === 'percent' ? Math.floor(viewportHeightPx * (maxHeight / 100)) : maxHeight;
|
|
5
|
-
const snapsToPixels = useMemo(() => snaps === null || snaps === void 0 ? void 0 : snaps.map((snap) => Math.abs((unit === 'percent' ? Math.floor(swipeviewHeightPx * (snap / 100)) : snap) -
|
|
6
|
-
swipeviewHeightPx)), [viewportHeightPx]);
|
|
7
|
-
const getPixelToSnap = (pixels) => {
|
|
8
|
-
const snapIdx = (snapsToPixels === null || snapsToPixels === void 0 ? void 0 : snapsToPixels.indexOf(pixels)) || 0;
|
|
9
|
-
return (snaps === null || snaps === void 0 ? void 0 : snaps[snapIdx]) || 0;
|
|
10
|
-
};
|
|
11
|
-
const getSnapToPixel = (snap) => {
|
|
12
|
-
const snapIdx = (snaps === null || snaps === void 0 ? void 0 : snaps.indexOf(snap)) || 0;
|
|
13
|
-
return (snapsToPixels === null || snapsToPixels === void 0 ? void 0 : snapsToPixels[snapIdx]) || 0;
|
|
14
|
-
};
|
|
15
|
-
return {
|
|
16
|
-
viewportHeightPx,
|
|
17
|
-
snapsToPixels,
|
|
18
|
-
swipeviewHeightPx,
|
|
19
|
-
getPixelToSnap,
|
|
20
|
-
getSnapToPixel,
|
|
21
|
-
};
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useSystemSettingsContext";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { SystemSettingsContext } from "src/contexts/systemSettingsContext";
|
|
3
|
-
export const useSystemSettingsContext = () => {
|
|
4
|
-
const context = useContext(SystemSettingsContext);
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error("useSystemSettingsContext must be used within a SystemSettingsContextProvider");
|
|
7
|
-
}
|
|
8
|
-
return { ...context };
|
|
9
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useTrackComponentVisibleEvent";
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { useIntersection } from 'src/hooks/Intersection/useIntersection';
|
|
3
|
-
import { useAmplitude } from 'src/contexts/amplitudeContext/amplitudeContext';
|
|
4
|
-
import { SpiffyMetricsEventName } from '@envive-ai/types';
|
|
5
|
-
/**
|
|
6
|
-
* Tracks a component and logs an event to Amplitude when the component is visible.
|
|
7
|
-
*
|
|
8
|
-
* @param component - The component to track.
|
|
9
|
-
* @param element - The element to track visibility of.
|
|
10
|
-
* @param eventProps - Additional properties to include with the event.
|
|
11
|
-
* @param eventName - The Amplitude event name to track (defaults to ChatComponentVisible).
|
|
12
|
-
*/
|
|
13
|
-
export const useTrackComponentVisibleEvent = (component, element, eventProps, eventName = SpiffyMetricsEventName.ChatComponentVisible) => {
|
|
14
|
-
const isVisible = useIntersection(element, '0px');
|
|
15
|
-
const hasTrackedEvent = useRef(false);
|
|
16
|
-
const { trackEvent } = useAmplitude();
|
|
17
|
-
const componentProps = (() => {
|
|
18
|
-
if (eventName === SpiffyMetricsEventName.ChatComponentVisible) {
|
|
19
|
-
return {
|
|
20
|
-
chat_component: component,
|
|
21
|
-
...eventProps,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if (eventName === SpiffyMetricsEventName.SearchComponentVisible) {
|
|
25
|
-
return {
|
|
26
|
-
search_component: component,
|
|
27
|
-
...eventProps,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
// Default case for other event types
|
|
31
|
-
return {
|
|
32
|
-
component,
|
|
33
|
-
...eventProps,
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (isVisible && !hasTrackedEvent.current) {
|
|
38
|
-
trackEvent({
|
|
39
|
-
eventName,
|
|
40
|
-
eventProps: componentProps,
|
|
41
|
-
});
|
|
42
|
-
hasTrackedEvent.current = true;
|
|
43
|
-
}
|
|
44
|
-
}, [isVisible, component, eventProps, eventName, componentProps, trackEvent]);
|
|
45
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useUpdateAnalyticsProps";
|