@envive-ai/react-hooks 0.2.6-alpha.13 → 0.2.7-arthur-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{NewOrgConfig-DJm6_abA.cjs → NewOrgConfig-Bo1seKr6.cjs} +2 -2
- package/dist/{NewOrgConfig-BfbTlFg1.js → NewOrgConfig-yptI2imS.js} +2 -2
- package/dist/{SystemSettingsContext-BbTKNBvJ.js → SystemSettingsContext-BY1BFgAQ.js} +2 -2
- package/dist/{SystemSettingsContext-6ZHzQkCE.cjs → SystemSettingsContext-EDpRMMt2.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-BJgNOypY.js → TrackComponentVisibleEvent-CXhKOwKQ.js} +3 -3
- package/dist/{TrackComponentVisibleEvent-BRC2FTp-.cjs → TrackComponentVisibleEvent-CgxCqrIt.cjs} +7 -7
- package/dist/amplitudeContext-C8tT74Mi.cjs +286 -0
- package/dist/{amplitudeContext-B73xamNe.d.cts → amplitudeContext-CCVyp5RU.d.cts} +1 -1
- package/dist/amplitudeContext-DCk6Va-j.js +264 -0
- package/dist/{amplitudeContext-CZUzMXHl.d.ts → amplitudeContext-DcRur97Z.d.ts} +1 -1
- package/dist/app-BbPSHefQ.cjs +156 -0
- package/dist/app-CflxT_xI.js +110 -0
- package/dist/application/models/graphql/index.cjs +3 -2
- package/dist/application/models/graphql/index.d.cts +2 -2
- package/dist/application/models/graphql/index.d.ts +2 -2
- package/dist/application/models/graphql/index.js +2 -2
- package/dist/application/models/guards/api/index.d.cts +2 -1
- package/dist/application/models/guards/api/index.d.ts +3 -2
- package/dist/application/models/guards/utils.d.cts +1 -1
- package/dist/application/models/guards/utils.d.ts +1 -1
- package/dist/application/models/index.cjs +3 -3
- package/dist/application/models/index.d.cts +11 -10
- package/dist/application/models/index.d.ts +12 -11
- package/dist/application/models/index.js +2 -2
- package/dist/application/models/utilityTypes/index.d.ts +1 -1
- package/dist/application/models/variantInfo/index.d.cts +1 -1
- package/dist/application/models/variantInfo/index.d.ts +1 -1
- package/dist/application/utils/index.cjs +8 -6
- package/dist/application/utils/index.d.cts +14 -13
- package/dist/application/utils/index.d.ts +17 -16
- package/dist/application/utils/index.js +8 -6
- package/dist/{atomStore-DNji91Im.cjs → atomStore-CmZbgQHc.cjs} +1 -1
- package/dist/{atomStore-DXTVqiKc.js → atomStore-DEcDhiLp.js} +1 -1
- package/dist/atoms/app/index.cjs +9 -14
- package/dist/atoms/app/index.d.cts +19 -18
- package/dist/atoms/app/index.d.ts +20 -19
- package/dist/atoms/app/index.js +4 -9
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +9 -8
- package/dist/atoms/chat/index.d.cts +39 -38
- package/dist/atoms/chat/index.d.ts +40 -39
- package/dist/atoms/chat/index.js +9 -8
- package/dist/atoms/globalSearch/index.cjs +1 -2
- package/dist/atoms/globalSearch/index.d.cts +5 -5
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/globalSearch/index.js +1 -2
- package/dist/atoms/org/index.cjs +8 -7
- package/dist/atoms/org/index.d.cts +30 -29
- package/dist/atoms/org/index.d.ts +31 -30
- package/dist/atoms/org/index.js +4 -3
- package/dist/atoms/search/index.cjs +16 -15
- package/dist/atoms/search/index.d.cts +13 -12
- package/dist/atoms/search/index.d.ts +14 -13
- package/dist/atoms/search/index.js +16 -15
- package/dist/atoms/search/types.cjs +1 -1
- package/dist/atoms/search/types.d.cts +4 -2
- package/dist/atoms/search/types.d.ts +4 -2
- package/dist/atoms/search/types.js +1 -1
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/{cdnContext-DOSIofl8.cjs → cdnContext-CaDyQ_5p.cjs} +1 -1
- package/dist/{cdnContext-CEGBVVBU.js → cdnContext-CtrIlAqX.js} +1 -1
- package/dist/{chat-DH70QqJp.js → chat-BjhQCyW_.js} +8 -7
- package/dist/{chat-CqPuT9_V.cjs → chat-BkPax29G.cjs} +16 -9
- package/dist/{chatElementDisplayLocation-DWmfNX_u.d.cts → chatElementDisplayLocation-B7vr33eG.d.cts} +1 -1
- package/dist/{chatElementDisplayLocation-CpgV2wR1.d.ts → chatElementDisplayLocation-D4XF0UfI.d.ts} +1 -1
- package/dist/{chatSearch-C7Y-hb-6.js → chatSearch-BsYlFvpv.js} +7 -7
- package/dist/{chatSearch-DLV4BUGA.cjs → chatSearch-C3N3iIxu.cjs} +7 -7
- package/dist/{chatState-CcFtSqJT.cjs → chatState-CJ52Ag_7.cjs} +5 -5
- package/dist/{chatState-DKnNHmwe.js → chatState-CXA1vF16.js} +3 -3
- package/dist/commerce-api-DA1QGGMK.cjs +319 -0
- package/dist/commerce-api-rgj30eEp.js +312 -0
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/locators/components/chat/index.d.cts +1 -1
- package/dist/config/locators/components/chat/index.d.ts +1 -1
- package/dist/config/locators/components/common/index.d.cts +1 -1
- package/dist/config/locators/components/common/index.d.ts +1 -1
- package/dist/config/locators/components/index.d.cts +1 -1
- package/dist/config/locators/components/index.d.ts +1 -1
- package/dist/config/locators/index.d.cts +4 -4
- package/dist/config/locators/index.d.ts +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +10 -9
- package/dist/contexts/amplitudeContext/index.d.cts +1 -1
- package/dist/contexts/amplitudeContext/index.d.ts +1 -1
- package/dist/contexts/amplitudeContext/index.js +7 -6
- package/dist/contexts/cdnContext/index.cjs +1 -1
- package/dist/contexts/cdnContext/index.js +1 -1
- package/dist/contexts/chatContext/index.cjs +32 -27
- package/dist/contexts/chatContext/index.d.cts +2 -2
- package/dist/contexts/chatContext/index.d.ts +4 -4
- package/dist/contexts/chatContext/index.js +22 -17
- package/dist/contexts/enviveConfigContext/index.d.cts +3 -3
- package/dist/contexts/enviveConfigContext/index.d.ts +3 -3
- package/dist/contexts/enviveCssContext/index.cjs +7 -7
- package/dist/contexts/enviveCssContext/index.js +7 -7
- package/dist/contexts/featureFlagContext/index.cjs +1 -1
- package/dist/contexts/featureFlagContext/index.d.cts +3 -3
- package/dist/contexts/featureFlagContext/index.d.ts +3 -3
- package/dist/contexts/featureFlagContext/index.js +1 -1
- package/dist/contexts/featureFlagServiceContext/index.d.cts +4 -4
- package/dist/contexts/featureFlagServiceContext/index.d.ts +4 -4
- package/dist/contexts/graphqlContext/index.cjs +3 -3
- package/dist/contexts/graphqlContext/index.d.cts +13 -12
- package/dist/contexts/graphqlContext/index.d.ts +14 -13
- package/dist/contexts/graphqlContext/index.js +3 -3
- package/dist/contexts/newOrgConfigContext/index.cjs +6 -6
- package/dist/contexts/newOrgConfigContext/index.d.cts +14 -13
- package/dist/contexts/newOrgConfigContext/index.d.ts +15 -14
- package/dist/contexts/newOrgConfigContext/index.js +6 -6
- package/dist/contexts/searchContext/index.cjs +10 -13
- package/dist/contexts/searchContext/index.d.cts +1 -1
- package/dist/contexts/searchContext/index.d.ts +2 -2
- package/dist/contexts/searchContext/index.js +10 -13
- package/dist/contexts/sessionStorageContext/index.cjs +1 -1
- package/dist/contexts/sessionStorageContext/index.js +1 -1
- package/dist/contexts/shopifyUrlContext/index.cjs +1 -1
- package/dist/contexts/shopifyUrlContext/index.d.cts +3 -3
- package/dist/contexts/shopifyUrlContext/index.d.ts +3 -3
- package/dist/contexts/shopifyUrlContext/index.js +1 -1
- package/dist/contexts/systemSettingsContext/index.cjs +1 -1
- package/dist/contexts/systemSettingsContext/index.d.cts +14 -13
- package/dist/contexts/systemSettingsContext/index.d.ts +15 -14
- package/dist/contexts/systemSettingsContext/index.js +1 -1
- package/dist/contexts/types.d.cts +3 -3
- package/dist/contexts/types.d.ts +3 -3
- package/dist/contexts/userIdentityContext/index.cjs +14 -8
- package/dist/contexts/userIdentityContext/index.d.cts +1 -1
- package/dist/contexts/userIdentityContext/index.d.ts +1 -1
- package/dist/contexts/userIdentityContext/index.js +12 -6
- package/dist/{domObserver-Bqf3ooj8.cjs → domObserver-COKvTfZV.cjs} +1 -1
- package/dist/{domObserver-v9ODTyfT.js → domObserver-DEiUh0qg.js} +1 -1
- package/dist/{featureFlagServiceContext-V0J-69ty.d.ts → featureFlagServiceContext-CpxlOkI9.d.ts} +2 -2
- package/dist/{featureFlagServiceContext-Be_LUbFf.d.cts → featureFlagServiceContext-p5UBwPM3.d.cts} +2 -2
- package/dist/frontendConfig-Cawh5iqv.d.ts +859 -0
- package/dist/frontendConfig-iZipB5FG.d.cts +859 -0
- package/dist/{globalSearch-FBk2epe8.cjs → globalSearch-BOG3wmck.cjs} +1 -1
- package/dist/{globalSearch-Ccxq8hNF.js → globalSearch-BQEX-2Ml.js} +1 -1
- package/dist/graphql-CkxgqsXP.js +48 -0
- package/dist/graphql-i3dtpVTl.cjs +71 -0
- package/dist/graphqlConfig-BnfE0ql5.cjs +39 -0
- package/dist/graphqlConfig-CZGjJ8hP.js +14 -0
- package/dist/{graphqlContext-D67VEQg3.d.cts → graphqlContext-BeyKU1Dr.d.cts} +2 -2
- package/dist/{graphqlContext-BQA6gnpH.d.ts → graphqlContext-CXQl0hq2.d.ts} +3 -3
- package/dist/{graphqlContext-W0cZNBf1.cjs → graphqlContext-DP8T3-Kd.cjs} +4 -4
- package/dist/{graphqlContext-Ci5GRAdH.js → graphqlContext-czH0kIZg.js} +3 -3
- package/dist/hooks/AmplitudeOperations/index.cjs +8 -8
- package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/index.d.ts +1 -1
- package/dist/hooks/AmplitudeOperations/index.js +8 -8
- package/dist/hooks/AppDetails/index.cjs +7 -12
- package/dist/hooks/AppDetails/index.d.cts +12 -11
- package/dist/hooks/AppDetails/index.d.ts +13 -12
- package/dist/hooks/AppDetails/index.js +7 -12
- package/dist/hooks/CdnOperations/index.cjs +1 -1
- package/dist/hooks/CdnOperations/index.js +1 -1
- package/dist/hooks/ChatToggle/index.cjs +13 -12
- package/dist/hooks/ChatToggle/index.d.cts +1 -1
- package/dist/hooks/ChatToggle/index.d.ts +1 -1
- package/dist/hooks/ChatToggle/index.js +10 -9
- package/dist/hooks/ChatToggleAnalytics/index.cjs +9 -9
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.js +9 -9
- package/dist/hooks/Debounce/index.cjs +20 -2
- package/dist/hooks/Debounce/index.js +18 -2
- package/dist/hooks/ElementObserver/index.cjs +1 -1
- package/dist/hooks/ElementObserver/index.d.cts +1 -1
- package/dist/hooks/ElementObserver/index.d.ts +1 -1
- package/dist/hooks/ElementObserver/index.js +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/index.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +4 -4
- package/dist/hooks/GraphQLConfig/index.d.cts +13 -12
- package/dist/hooks/GraphQLConfig/index.d.ts +14 -13
- package/dist/hooks/GraphQLConfig/index.js +4 -4
- package/dist/hooks/IdentifyUser/index.cjs +14 -8
- package/dist/hooks/IdentifyUser/index.js +13 -7
- package/dist/hooks/ImageResolver/index.cjs +2 -2
- package/dist/hooks/ImageResolver/index.js +2 -2
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/MessageFilter/index.cjs +2 -2
- package/dist/hooks/MessageFilter/index.d.cts +12 -11
- package/dist/hooks/MessageFilter/index.d.ts +13 -12
- package/dist/hooks/MessageFilter/index.js +2 -2
- package/dist/hooks/NewOrgConfig/index.cjs +7 -7
- package/dist/hooks/NewOrgConfig/index.d.cts +14 -13
- package/dist/hooks/NewOrgConfig/index.d.ts +15 -14
- package/dist/hooks/NewOrgConfig/index.js +7 -7
- package/dist/hooks/Search/index.cjs +1469 -159
- package/dist/hooks/Search/index.d.cts +21 -17
- package/dist/hooks/Search/index.d.ts +22 -18
- package/dist/hooks/Search/index.js +1464 -154
- package/dist/hooks/SearchOperations/index.cjs +11 -14
- package/dist/hooks/SearchOperations/index.d.cts +1 -1
- package/dist/hooks/SearchOperations/index.d.ts +2 -2
- package/dist/hooks/SearchOperations/index.js +11 -14
- package/dist/hooks/SessionStorageOperations/index.cjs +1 -1
- package/dist/hooks/SessionStorageOperations/index.js +1 -1
- package/dist/hooks/ShopifyUrlOperations/index.cjs +1 -1
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +5 -5
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +5 -5
- package/dist/hooks/ShopifyUrlOperations/index.js +1 -1
- package/dist/hooks/SystemSettingsContext/index.cjs +2 -2
- package/dist/hooks/SystemSettingsContext/index.d.cts +14 -13
- package/dist/hooks/SystemSettingsContext/index.d.ts +15 -14
- package/dist/hooks/SystemSettingsContext/index.js +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +8 -8
- package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.js +8 -8
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +11 -11
- package/dist/hooks/UpdateAnalyticsProps/index.js +6 -6
- package/dist/hooks/utils.d.cts +12 -11
- package/dist/hooks/utils.d.ts +13 -12
- package/dist/{index-BeYfyZ6k.d.ts → index--9_c4tze.d.ts} +1 -1
- package/dist/index-BEpDGqnz.d.cts +41 -0
- package/dist/{index-xHVrsrbz.d.ts → index-BKvFVPUX.d.ts} +1 -1
- package/dist/{index-DJTrxIFJ.d.ts → index-BNHIIgYk.d.ts} +1 -1
- package/dist/{index-BeGt0Aw3.d.cts → index-BSd8767K.d.cts} +5 -5
- package/dist/index-BUDrAxnl.d.ts +673 -0
- package/dist/{index-DzbkQtaK.d.cts → index-CCboEuTO.d.cts} +1 -1
- package/dist/{index-FQjyuD3D.d.cts → index-COXkY78t.d.cts} +1 -1
- package/dist/{index-xhBQ1HBx.d.ts → index-CUO68KG3.d.ts} +34 -34
- package/dist/{index-DazMsEy_.d.ts → index-D7htGSQC.d.ts} +1 -1
- package/dist/index-DM_5fh8c.d.ts +101 -0
- package/dist/index-DU7uw0ba.d.cts +101 -0
- package/dist/{index-Da1s8h5C.d.cts → index-DZtnHhlr.d.cts} +1 -1
- package/dist/{index-h809JLbL.d.ts → index-Dtw-hJdt.d.ts} +1 -1
- package/dist/{index-Dfwnna1j.d.ts → index-Dxpscrvz.d.ts} +1 -1
- package/dist/index-Dy3TTIOm.d.cts +673 -0
- package/dist/index-ErVcwUnR.d.ts +41 -0
- package/dist/{index-Cyq5HiC0.d.cts → index-OkKEOL6H.d.cts} +1 -1
- package/dist/{index-9NE86em3.d.cts → index-hAqp0oYb.d.cts} +1 -1
- package/dist/interceptors/index.d.cts +13 -12
- package/dist/interceptors/index.d.ts +14 -13
- package/dist/interceptors/types.d.cts +12 -11
- package/dist/interceptors/types.d.ts +13 -12
- package/dist/models-CWOgrLCm.js +1284 -0
- package/dist/models-DqdLOi2I.cjs +1519 -0
- package/dist/{newOrgConfigAtom-DxILMn2I.cjs → newOrgConfigAtom-CPA6Gp6n.cjs} +1 -1
- package/dist/{newOrgConfigAtom-sqve6LZU.js → newOrgConfigAtom-DEUj6H-p.js} +1 -1
- package/dist/{newOrgConfigContext-Cl4H9c3q.cjs → newOrgConfigContext-Bet9CgKP.cjs} +3 -3
- package/dist/{newOrgConfigContext-DQiuf8nd.js → newOrgConfigContext-Bi_dBNe5.js} +3 -3
- package/dist/{newOrgConfigContext-5Bw7RwT-.d.cts → newOrgConfigContext-CJI3tsVV.d.cts} +2 -2
- package/dist/{newOrgConfigContext-CS8IA5Eg.d.ts → newOrgConfigContext-I2qceBB4.d.ts} +2 -2
- package/dist/{nodeSelector-BiCDowlK.d.ts → nodeSelector-B5NfnUHv.d.ts} +1 -1
- package/dist/{nodeSelector-B3bPtEjX.d.cts → nodeSelector-vKB44CDB.d.cts} +1 -1
- package/dist/{org-DlAesvQ_.cjs → org-B_cWn2bt.cjs} +1 -1
- package/dist/{org-vi0njpBh.js → org-h32_LSEb.js} +1 -1
- package/dist/orgAnalyticsConfig-Bm23fw4s.cjs +39 -0
- package/dist/orgAnalyticsConfig-CpBmga08.js +14 -0
- package/dist/responseGenerics-D9bS-Dd6.d.ts +148 -0
- package/dist/{index-CCa4tZuO.d.ts → responseGenerics-DWLV09cQ.d.cts} +4 -40
- package/dist/{search-y-ioX5Mz.d.cts → search-6RrxBXD6.d.cts} +1 -1
- package/dist/{search-CXXslzAO.cjs → search-Csh2n66W.cjs} +5 -5
- package/dist/{search-DBSMrXWv.js → search-DkiqkogN.js} +5 -5
- package/dist/{search-1NQLQD9d.d.ts → search-DrJiCT7d.d.ts} +2 -2
- package/dist/{search-filter-types-BxaNSLs_.d.cts → search-filter-types-BItKtezf.d.cts} +1 -1
- package/dist/{search-filter-types-DPgeG8FS.d.ts → search-filter-types-CGFhksO3.d.ts} +1 -1
- package/dist/{searchContext-mvwUJncR.js → searchContext-BmgoAFMF.js} +4 -4
- package/dist/{searchContext-DXW6xvXv.cjs → searchContext-DksJfC1s.cjs} +6 -6
- package/dist/{searchServiceAdapter-DEv1tTn0.cjs → searchServiceAdapter-BGlvoZFE.cjs} +1 -1
- package/dist/{searchServiceAdapter-WyCU55NV.js → searchServiceAdapter-Db6jEcJs.js} +1 -1
- package/dist/{sessionStorageContext-1Ks_d4Z0.cjs → sessionStorageContext-B6FsNKjj.cjs} +1 -1
- package/dist/{sessionStorageContext-CDcl7NVl.js → sessionStorageContext-CLYCm83p.js} +1 -1
- package/dist/{shopifyUrlContext-CejRZfj7.js → shopifyUrlContext-C-PkSgNC.js} +1 -1
- package/dist/{shopifyUrlContext-lnHoAOEf.cjs → shopifyUrlContext-ZOcARiMR.cjs} +1 -1
- package/dist/{spiffyWidgets-B1uc84_g.d.ts → spiffyWidgets-CR6F7FRE.d.ts} +1 -1
- package/dist/{spiffyWidgets-BuS00VaQ.d.cts → spiffyWidgets-eNbU1gMc.d.cts} +1 -1
- package/dist/{systemSettingsContext-CVUxEcsU.js → systemSettingsContext-DF0jSq9m.js} +1 -1
- package/dist/{systemSettingsContext-B0Kyq7nA.cjs → systemSettingsContext-dmE1v6w8.cjs} +1 -1
- package/dist/{test-types-y6kp-tiw.d.ts → test-types-BEml_bm3.d.ts} +1 -1
- package/dist/{test-types-ThQiO_cc.d.cts → test-types-Dsu8RJZu.d.cts} +1 -1
- package/dist/types/index.cjs +1 -16
- package/dist/types/index.d.cts +3 -17
- package/dist/types/index.d.ts +3 -17
- package/dist/types/index.js +2 -16
- package/dist/{types-Db5Eux6K.d.ts → types-4LQ7LUCk.d.ts} +2 -2
- package/dist/types-BegmH0S1.d.ts +60 -0
- package/dist/types-BuvXXGxE.cjs +48 -0
- package/dist/types-CtUb63bt.js +1 -1
- package/dist/{types-zQGBI-Yo.d.cts → types-DFsSqmWx.d.cts} +2 -2
- package/dist/types-DWorwfS-.d.cts +60 -0
- package/dist/types-DXnG1tV0.js +30 -0
- package/dist/types-UUvB6h05.cjs +1 -1
- package/dist/types.d.cts +4 -23
- package/dist/types.d.ts +4 -23
- package/dist/unsupportedProductExceptions-DGENUnEA.cjs +32 -0
- package/dist/unsupportedProductExceptions-uQuuelOs.js +20 -0
- package/dist/{useAmplitudeOperations-jqa7K9dH.cjs → useAmplitudeOperations-Bo6YNbTV.cjs} +3 -3
- package/dist/{useAmplitudeOperations-DYs1h8a_.js → useAmplitudeOperations-zIRSqmMW.js} +2 -2
- package/dist/{useAppDetails-BRUqZEyt.js → useAppDetails-B584gkCs.js} +3 -3
- package/dist/{useAppDetails-C71k0brz.cjs → useAppDetails-DczgqeLG.cjs} +6 -6
- package/dist/{useGraphQLConfig-5VwS9Q_Z.js → useGraphQLConfig-7UxACM4n.js} +2 -2
- package/dist/{useGraphQLConfig-Cj26_J9I.cjs → useGraphQLConfig-D_rF2Sun.cjs} +2 -2
- package/dist/{useIntersection-Cncgxdmy.js → useIntersection-CZSEBUbv.js} +1 -1
- package/dist/{useIntersection-m4PEpvG7.cjs → useIntersection-DSDREfj6.cjs} +1 -1
- package/dist/userIdentityContext-BqbNu7xu.cjs +132 -0
- package/dist/userIdentityContext-BxFH9FNQ.js +115 -0
- package/dist/{userIdentityContext-BVODeTlN.d.ts → userIdentityContext-C6kApbuk.d.ts} +1 -1
- package/dist/{userIdentityContext-D2oFVFzo.d.cts → userIdentityContext-kU1PIo8K.d.cts} +1 -1
- package/dist/{utils-DpneNSJf.d.ts → utils-BRkGP1eb.d.ts} +1 -1
- package/dist/utils-C1ErYSoW.js +606 -0
- package/dist/{utils-BxPPugeP.d.cts → utils-CBD4g2Nc.d.cts} +4 -4
- package/dist/{utils-2SWrJ12w.cjs → utils-CvLmSsUj.cjs} +1 -1
- package/dist/{utils-CqBxIpEV.js → utils-D82gfbgU.js} +1 -1
- package/dist/{utils-B3x_9JTY.d.cts → utils-DCrwX6FT.d.cts} +1 -1
- package/dist/{utils-Covisryh.d.ts → utils-QKFAbPT6.d.ts} +4 -4
- package/dist/utils-mqfncrhI.cjs +715 -0
- package/package.json +18 -13
- package/src/application/commerce-api.ts +2 -0
- package/src/application/models/graphql/index.ts +1 -0
- package/src/application/utils/__tests__/divideArrays.test.ts +12 -13
- package/src/atoms/app/index.ts +1 -2
- package/src/atoms/search/productRetrievalAPI.ts +70 -0
- package/src/atoms/search/productRetrievalAdapter.ts +25 -0
- package/src/atoms/search/types.ts +13 -0
- package/src/contexts/enviveConfigContext/__tests__/enviveConfigContext.test.tsx +411 -0
- package/src/contexts/graphqlContext/__tests__/graphqlContext.test.tsx +790 -0
- package/src/contexts/localStorageContext/__tests__/localStorageContext.test.tsx +775 -0
- package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +495 -0
- package/src/contexts/searchContext/__tests__/searchContext.test.tsx +806 -0
- package/src/contexts/systemSettingsContext/__tests__/systemSettingsContext.test.tsx +506 -0
- package/src/contexts/types.ts +16 -14
- package/src/contexts/userIdentityContext/__tests__/userIdentityContext.test.tsx +663 -0
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +6 -0
- package/src/hooks/Search/useRecommendedProducts.ts +48 -0
- package/src/hooks/Search/useSearch.tsx +89 -182
- package/src/hooks/Search/useSearchInput.ts +263 -0
- package/src/types/FilterAttribute.ts +35 -0
- package/src/types/index.ts +0 -1
- package/src/types.ts +0 -16
- package/dist/frontendConfig-CeWhVevA.d.ts +0 -857
- package/dist/frontendConfig-OWWJmuPc.d.cts +0 -857
- package/dist/graphql-3PxNRFOc.js +0 -36
- package/dist/graphql-DGYfelZp.cjs +0 -53
- package/dist/graphqlConfig-GHZ1UgCw.cjs +0 -73
- package/dist/graphqlConfig-mDg6J44N.js +0 -24
- package/dist/hooks/FloatingButtonVisibility/index.cjs +0 -73
- package/dist/hooks/FloatingButtonVisibility/index.d.cts +0 -7
- package/dist/hooks/FloatingButtonVisibility/index.d.ts +0 -7
- package/dist/hooks/FloatingButtonVisibility/index.js +0 -69
- package/dist/hooks/LastInteraction/index.cjs +0 -34
- package/dist/hooks/LastInteraction/index.d.cts +0 -17
- package/dist/hooks/LastInteraction/index.d.ts +0 -17
- package/dist/hooks/LastInteraction/index.js +0 -32
- package/dist/index-Bmub8e38.d.cts +0 -98
- package/dist/index-CiWEYzXl.d.cts +0 -184
- package/dist/index-D4c-port.d.ts +0 -676
- package/dist/index-O33GSSRr.d.cts +0 -676
- package/dist/index-bjMvkcBF.d.ts +0 -98
- package/dist/models-D-4db7XW.cjs +0 -1537
- package/dist/models-c86hYW-F.js +0 -1296
- package/dist/types-BCz-hOvv.d.ts +0 -51
- package/dist/types-CKMMb_gX.d.cts +0 -51
- package/dist/types-CS0Hrzja.js +0 -30
- package/dist/types-CxObxLKs.cjs +0 -48
- package/dist/useDebounce-DZ8Cgiwc.cjs +0 -26
- package/dist/useDebounce-v9cezyjn.js +0 -19
- package/dist/utils-CLGXsOwE.cjs +0 -1591
- package/dist/utils-jYtD3hmA.js +0 -1385
- package/src/hooks/FloatingButtonVisibility/index.ts +0 -1
- package/src/hooks/FloatingButtonVisibility/useFloatingButtonVisibility.ts +0 -99
- package/src/hooks/LastInteraction/index.ts +0 -1
- package/src/hooks/LastInteraction/useLastInteraction.ts +0 -42
- package/src/types/floatingbuttonoverrides-types.ts +0 -10
- /package/dist/{AmplitudeOperations-ni7wVevx.js → AmplitudeOperations-ChZWcSsc.js} +0 -0
- /package/dist/{AmplitudeOperations-DxQnurSG.cjs → AmplitudeOperations-JggIc1zD.cjs} +0 -0
- /package/dist/{globalSearch-BpGfkuXz.js → amplitudeContext-BItT9HmT.js} +0 -0
- /package/dist/{globalSearch-B9DRBxSM.cjs → amplitudeContext-DPtyVv3Q.cjs} +0 -0
- /package/dist/{index-CgAfoNpB.d.ts → index-A0HvA68Y.d.cts} +0 -0
- /package/dist/{index-RcVcRKH7.d.cts → index-DNVvRcKu.d.ts} +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useAtomValue, useSetAtom } from "jotai";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { useFeatureFlagService } from "src/contexts/featureFlagServiceContext/featureFlagServiceContext";
|
|
4
|
+
import {
|
|
5
|
+
retrievedProductsAtom,
|
|
6
|
+
performProductRetrievalAtom,
|
|
7
|
+
productRetrievalAtom,
|
|
8
|
+
} from "src/atoms/search/productRetrievalAPI";
|
|
9
|
+
import { useNewOrgConfig } from "../NewOrgConfig";
|
|
10
|
+
import { SearchResponseProductAttributes } from "src/application/models/api/response";
|
|
11
|
+
import { FeatureGates } from "src/application/models";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A hook to get recommended products.
|
|
15
|
+
* It checks the `IsRecommendedProductsEnabled` feature gate and triggers fetching if needed.
|
|
16
|
+
* If the gate is enabled, it returns the list of recommended products.
|
|
17
|
+
* If the gate is disabled, it returns an empty array.
|
|
18
|
+
*
|
|
19
|
+
* @returns The list of recommended products or an empty array.
|
|
20
|
+
*/
|
|
21
|
+
export const useRecommendedProducts =
|
|
22
|
+
(): SearchResponseProductAttributes["attributes"][] => {
|
|
23
|
+
const { featureFlagService } = useFeatureFlagService();
|
|
24
|
+
const isEnabled = featureFlagService?.isFeatureGateEnabled(
|
|
25
|
+
FeatureGates.IsRecommendedProductsEnabled
|
|
26
|
+
);
|
|
27
|
+
const recommendedProducts = useAtomValue(retrievedProductsAtom);
|
|
28
|
+
const performProductRetrieval = useSetAtom(performProductRetrievalAtom);
|
|
29
|
+
const { lastProductIds } = useAtomValue(productRetrievalAtom);
|
|
30
|
+
const orgUIConfig = useNewOrgConfig();
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const recommendedProductIds = orgUIConfig.frontendConfig?.uiConfigs?.searchConfig
|
|
34
|
+
? orgUIConfig.frontendConfig?.uiConfigs?.searchConfig.recommendedProducts
|
|
35
|
+
: [];
|
|
36
|
+
// Fetch only if the feature is enabled, there are IDs to fetch, and we haven't already fetched them.
|
|
37
|
+
if (
|
|
38
|
+
isEnabled &&
|
|
39
|
+
recommendedProductIds &&
|
|
40
|
+
recommendedProductIds.length > 0 &&
|
|
41
|
+
!lastProductIds
|
|
42
|
+
) {
|
|
43
|
+
performProductRetrieval({ productIds: recommendedProductIds });
|
|
44
|
+
}
|
|
45
|
+
}, [isEnabled, performProductRetrieval, lastProductIds, orgUIConfig]);
|
|
46
|
+
|
|
47
|
+
return isEnabled ? recommendedProducts : [];
|
|
48
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef
|
|
3
|
-
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
|
|
4
4
|
import {
|
|
5
5
|
addSearchFilterAtom,
|
|
6
6
|
clearSearchFiltersAtom,
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
SelectedFilterOption,
|
|
17
17
|
} from "src/atoms/search";
|
|
18
18
|
import {
|
|
19
|
-
autocompleteStateAtom,
|
|
20
19
|
isFilterOpenAtom,
|
|
21
20
|
} from "src/atoms/globalSearch/globalSearch";
|
|
22
21
|
import { formatFilterDisplayName } from "src/atoms/search/utils";
|
|
@@ -27,7 +26,6 @@ import {
|
|
|
27
26
|
} from "src/contexts/amplitudeContext/amplitudeContext";
|
|
28
27
|
import { SpiffyWidgets } from "src/application/models/spiffyWidgets";
|
|
29
28
|
import { ProductCardConfig } from "src/contexts/types";
|
|
30
|
-
import Logger from "src/application/logging/logger";
|
|
31
29
|
import { SearchResult } from "src/application/models/api/search";
|
|
32
30
|
import { SearchResponseProduct } from "@spiffy-ai/commerce-api-client";
|
|
33
31
|
import {
|
|
@@ -36,8 +34,14 @@ import {
|
|
|
36
34
|
} from "src/types/search-filter-types";
|
|
37
35
|
import { getSearchResultsState, SearchResultsState } from "../utils";
|
|
38
36
|
import { orgShortNameAtom } from "src/atoms/envive/enviveConfig";
|
|
39
|
-
import { useNewOrgConfig } from "../NewOrgConfig";
|
|
40
37
|
import { useTrackComponentVisibleEvent } from "../TrackComponentVisibleEvent";
|
|
38
|
+
import { amplitudeTrackEventAtom } from "src/atoms/amplitude/amplitudeTrackEventAtom";
|
|
39
|
+
import { newOrgConfigAtom } from "src/atoms/org";
|
|
40
|
+
import { retrievedProductsAtom } from "src/atoms/search/productRetrievalAPI";
|
|
41
|
+
import { useSearchInput } from "./useSearchInput";
|
|
42
|
+
import { SearchResponseProductAttributes } from "src/application/models";
|
|
43
|
+
import { useNewOrgConfig } from "../NewOrgConfig";
|
|
44
|
+
import { useRecommendedProducts } from "./useRecommendedProducts";
|
|
41
45
|
|
|
42
46
|
export interface SearchResultsHocProps {
|
|
43
47
|
// Data
|
|
@@ -50,14 +54,15 @@ export interface SearchResultsHocProps {
|
|
|
50
54
|
searchFilters: SearchFilterDatum[];
|
|
51
55
|
availableDynamicFilters: { name: string; displayName: string }[];
|
|
52
56
|
selectedFilterOptions: SelectedFilterOption[];
|
|
57
|
+
recommendedProducts: SearchResponseProductAttributes['attributes'][];
|
|
53
58
|
|
|
54
59
|
// State
|
|
55
60
|
searchText: string;
|
|
61
|
+
query: string;
|
|
56
62
|
searchResultsState: SearchResultsState;
|
|
57
|
-
isLoadingAutocomplete: boolean;
|
|
58
63
|
isLoadingSearch: boolean;
|
|
59
64
|
isFilterOpen: boolean;
|
|
60
|
-
|
|
65
|
+
shouldShowAutocomplete: boolean;
|
|
61
66
|
focusedIndex: number;
|
|
62
67
|
focusedOptionId: string | undefined;
|
|
63
68
|
|
|
@@ -69,13 +74,9 @@ export interface SearchResultsHocProps {
|
|
|
69
74
|
onSubmitSearch: () => void;
|
|
70
75
|
onAutocompleteSelect: (suggestion: string) => void;
|
|
71
76
|
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}: {
|
|
76
|
-
filter: string;
|
|
77
|
-
dynamicFilterDisplayName: string;
|
|
78
|
-
}) => void;
|
|
77
|
+
onSearchInputFocus: () => void;
|
|
78
|
+
onSearchInputBlur: () => void;
|
|
79
|
+
onToggleDynamicFilter: ({ filter, dynamicFilterDisplayName }: { filter: string; dynamicFilterDisplayName: string }) => void;
|
|
79
80
|
onSelectFilterItem: SelectFilterItem;
|
|
80
81
|
onRemoveFilter: (filter: SelectedFilterOption) => void;
|
|
81
82
|
onClearAllFilters: () => void;
|
|
@@ -93,10 +94,6 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
93
94
|
useAtomValue(searchAtom);
|
|
94
95
|
const productList = useAtomValue(filteredSearchProductsAtom);
|
|
95
96
|
const performSearch = useSetAtom(performSearchAtom);
|
|
96
|
-
const [
|
|
97
|
-
{ results: autocompleteResults, isLoading: isLoadingAutocomplete },
|
|
98
|
-
setAutocompleteState,
|
|
99
|
-
] = useAtom(autocompleteStateAtom);
|
|
100
97
|
const [{ query }] = useAtom(searchParamsAtom);
|
|
101
98
|
const [isFilterOpen, setIsFilterOpen] = useAtom(isFilterOpenAtom);
|
|
102
99
|
const [selectedFilterOptions] = useAtom(searchSelectedFiltersAtom);
|
|
@@ -105,20 +102,44 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
105
102
|
const [productSorting, setProductSorting] = useAtom(searchProductSortingAtom);
|
|
106
103
|
const clearFilters = useSetAtom(clearSearchFiltersAtom);
|
|
107
104
|
const searchFilters = useAtomValue(searchFiltersAtom);
|
|
108
|
-
|
|
109
|
-
// State
|
|
110
|
-
const [isDirty, setIsDirty] = useState(true);
|
|
111
|
-
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
112
|
-
const [focusedOptionId, setFocusedOptionId] = useState<string | undefined>(
|
|
113
|
-
undefined
|
|
114
|
-
);
|
|
115
|
-
const [searchText, setSearchText] = useState(query || "");
|
|
105
|
+
const recommendedProducts = useRecommendedProducts();
|
|
116
106
|
|
|
117
107
|
// Refs
|
|
118
108
|
const searchResultsRef = useRef<HTMLDivElement>(null);
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
const
|
|
109
|
+
|
|
110
|
+
// Utilities
|
|
111
|
+
const scrollToTop = useCallback(() => {
|
|
112
|
+
const container = searchResultsRef.current;
|
|
113
|
+
if (container) {
|
|
114
|
+
container.scrollTo({ top: 0, behavior: 'smooth' });
|
|
115
|
+
} else {
|
|
116
|
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
117
|
+
}
|
|
118
|
+
}, []);
|
|
119
|
+
|
|
120
|
+
// Search Input Hook
|
|
121
|
+
const searchInput = useSearchInput({
|
|
122
|
+
initialSearchText: query || '',
|
|
123
|
+
searchOrigin: SpiffyWidgets.SearchResults,
|
|
124
|
+
onSearchSubmit: (searchQuery) => {
|
|
125
|
+
performSearch({ query: searchQuery });
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const {
|
|
130
|
+
searchText,
|
|
131
|
+
focusedIndex,
|
|
132
|
+
focusedOptionId,
|
|
133
|
+
autocompleteResults,
|
|
134
|
+
shouldShowAutocomplete,
|
|
135
|
+
handleSearchInputChange,
|
|
136
|
+
handleSearchInputFocus,
|
|
137
|
+
handleSearchInputBlur,
|
|
138
|
+
handleKeyDown,
|
|
139
|
+
handleAutocompleteSelect,
|
|
140
|
+
handleSubmitSearch,
|
|
141
|
+
setSearchText,
|
|
142
|
+
} = searchInput;
|
|
122
143
|
const searchResultsState = getSearchResultsState(isLoadingSearch, searchData);
|
|
123
144
|
|
|
124
145
|
const dynamicFilters = searchData?.filters || [];
|
|
@@ -136,9 +157,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
136
157
|
return dynamicFilters
|
|
137
158
|
.filter(
|
|
138
159
|
(dynamicFilterName) =>
|
|
139
|
-
!selectedFilterOptions.some(
|
|
140
|
-
(option) => option.id === `dynamic:${dynamicFilterName}`
|
|
141
|
-
)
|
|
160
|
+
!selectedFilterOptions.some((option) => option.id === `dynamic:${dynamicFilterName}`),
|
|
142
161
|
)
|
|
143
162
|
.map((dynamicFilterName) => ({
|
|
144
163
|
name: dynamicFilterName,
|
|
@@ -150,39 +169,36 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
150
169
|
const sortOptions = [
|
|
151
170
|
{
|
|
152
171
|
filterItemId: String(ProductSorting.FEATURED),
|
|
153
|
-
displayName:
|
|
172
|
+
displayName: 'Relevance',
|
|
154
173
|
productCount: 0,
|
|
155
174
|
isSelected: productSorting === ProductSorting.FEATURED,
|
|
156
175
|
},
|
|
157
176
|
{
|
|
158
177
|
filterItemId: String(ProductSorting.PRICE_ASC),
|
|
159
|
-
displayName:
|
|
178
|
+
displayName: 'Price: Low to High',
|
|
160
179
|
productCount: 0,
|
|
161
180
|
isSelected: productSorting === ProductSorting.PRICE_ASC,
|
|
162
181
|
},
|
|
163
182
|
{
|
|
164
183
|
filterItemId: String(ProductSorting.PRICE_DESC),
|
|
165
|
-
displayName:
|
|
184
|
+
displayName: 'Price: High to Low',
|
|
166
185
|
productCount: 0,
|
|
167
186
|
isSelected: productSorting === ProductSorting.PRICE_DESC,
|
|
168
187
|
},
|
|
169
188
|
];
|
|
170
189
|
|
|
171
|
-
return [
|
|
172
|
-
{ filterId: "sort", displayName: "SORT", items: sortOptions },
|
|
173
|
-
...searchFilters,
|
|
174
|
-
] as SearchFilterDatum[];
|
|
190
|
+
return [{ filterId: 'sort', displayName: 'SORT', items: sortOptions }, ...searchFilters] as SearchFilterDatum[];
|
|
175
191
|
}, [productSorting, searchFilters]);
|
|
176
192
|
|
|
177
193
|
const filterButtonText = useMemo(() => {
|
|
178
194
|
const selectedCount = filters.reduce((acc: number, filter) => {
|
|
179
|
-
if (filter.filterId ===
|
|
195
|
+
if (filter.filterId === 'sort') {
|
|
180
196
|
return acc;
|
|
181
197
|
}
|
|
182
198
|
return acc + filter.items.filter((item) => item.isSelected).length;
|
|
183
199
|
}, 0);
|
|
184
200
|
if (selectedCount === 0) {
|
|
185
|
-
return
|
|
201
|
+
return 'Filter & Sort';
|
|
186
202
|
}
|
|
187
203
|
return `Filter & Sort (${selectedCount})`;
|
|
188
204
|
}, [filters]);
|
|
@@ -190,110 +206,31 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
190
206
|
// Callbacks
|
|
191
207
|
const { trackEvent } = useAmplitude();
|
|
192
208
|
|
|
209
|
+
|
|
193
210
|
const handleToggleDynamicFilter = useCallback(
|
|
194
|
-
({
|
|
195
|
-
filter,
|
|
196
|
-
dynamicFilterDisplayName,
|
|
197
|
-
}: {
|
|
198
|
-
filter: string;
|
|
199
|
-
dynamicFilterDisplayName: string;
|
|
200
|
-
}) => {
|
|
211
|
+
({ filter, dynamicFilterDisplayName }: { filter: string; dynamicFilterDisplayName: string }) => {
|
|
201
212
|
trackEvent({
|
|
202
213
|
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
203
214
|
eventProps: {
|
|
204
|
-
filterType:
|
|
215
|
+
filterType: 'Dynamic',
|
|
205
216
|
filterValue: filter,
|
|
206
217
|
queryText: searchText,
|
|
207
218
|
},
|
|
208
219
|
});
|
|
209
|
-
addFilter(
|
|
210
|
-
|
|
211
|
-
);
|
|
220
|
+
addFilter(createFilterOption('dynamic', filter, dynamicFilterDisplayName));
|
|
221
|
+
scrollToTop();
|
|
212
222
|
},
|
|
213
|
-
[addFilter, searchText,
|
|
223
|
+
[addFilter, searchText, scrollToTop],
|
|
214
224
|
);
|
|
215
225
|
|
|
216
226
|
const handleRemoveFilter = useCallback(
|
|
217
227
|
(filter: SelectedFilterOption) => {
|
|
218
228
|
removeFilter(filter.id);
|
|
229
|
+
scrollToTop();
|
|
219
230
|
},
|
|
220
|
-
[removeFilter]
|
|
231
|
+
[removeFilter, scrollToTop],
|
|
221
232
|
);
|
|
222
233
|
|
|
223
|
-
const handleSubmitSearch = useCallback(async () => {
|
|
224
|
-
if (searchText.trim()) {
|
|
225
|
-
trackEvent({
|
|
226
|
-
eventName: SpiffyMetricsEventName.SearchQuerySubmitted,
|
|
227
|
-
eventProps: {
|
|
228
|
-
searchOrigin: SpiffyWidgets.SearchResults,
|
|
229
|
-
queryText: searchText.trim(),
|
|
230
|
-
},
|
|
231
|
-
alsoSendToGoogleAnalytics: true,
|
|
232
|
-
});
|
|
233
|
-
const url = new URL(window.location.href);
|
|
234
|
-
url.searchParams.set("esq", searchText.trim());
|
|
235
|
-
window.history.pushState({}, "", url);
|
|
236
|
-
performSearch({ query: searchText.trim() });
|
|
237
|
-
}
|
|
238
|
-
}, [performSearch, searchText, trackEvent]);
|
|
239
|
-
|
|
240
|
-
const handleAutocompleteSelect = useCallback(
|
|
241
|
-
(suggestion: string) => {
|
|
242
|
-
setSearchText(suggestion);
|
|
243
|
-
handleSubmitSearch();
|
|
244
|
-
},
|
|
245
|
-
[handleSubmitSearch, setSearchText]
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
const handleKeyDown = useCallback(
|
|
249
|
-
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
250
|
-
if (event.key === "ArrowDown") {
|
|
251
|
-
event.preventDefault();
|
|
252
|
-
const newIndex = (focusedIndex + 1) % autocompleteResults.length;
|
|
253
|
-
setFocusedIndex(newIndex);
|
|
254
|
-
setFocusedOptionId(`option-${newIndex}`);
|
|
255
|
-
} else if (event.key === "ArrowUp") {
|
|
256
|
-
event.preventDefault();
|
|
257
|
-
const newIndex =
|
|
258
|
-
(focusedIndex - 1 + autocompleteResults.length) %
|
|
259
|
-
autocompleteResults.length;
|
|
260
|
-
setFocusedIndex(newIndex);
|
|
261
|
-
setFocusedOptionId(`option-${newIndex}`);
|
|
262
|
-
} else if (event.key === "Enter") {
|
|
263
|
-
if (focusedIndex === -1) {
|
|
264
|
-
event.preventDefault();
|
|
265
|
-
handleSubmitSearch();
|
|
266
|
-
} else {
|
|
267
|
-
event.preventDefault();
|
|
268
|
-
const suggestionText = autocompleteResults[focusedIndex];
|
|
269
|
-
handleAutocompleteSelect(suggestionText);
|
|
270
|
-
}
|
|
271
|
-
} else if (event.key === "Escape") {
|
|
272
|
-
event.preventDefault();
|
|
273
|
-
setFocusedIndex(-1);
|
|
274
|
-
setFocusedOptionId(undefined);
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
[
|
|
278
|
-
autocompleteResults,
|
|
279
|
-
focusedIndex,
|
|
280
|
-
handleAutocompleteSelect,
|
|
281
|
-
handleSubmitSearch,
|
|
282
|
-
]
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
const handleSearchInputChange = (newValue: string) => {
|
|
286
|
-
if (newValue.length === 1) {
|
|
287
|
-
trackEvent({
|
|
288
|
-
eventName: SpiffyMetricsEventName.SearchInputStarted,
|
|
289
|
-
eventProps: {
|
|
290
|
-
searchOrigin: SpiffyWidgets.SearchResults,
|
|
291
|
-
},
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
setSearchText(newValue);
|
|
295
|
-
setIsDirty(true);
|
|
296
|
-
};
|
|
297
234
|
|
|
298
235
|
const handleSelectFilterItem: SelectFilterItem = useCallback(
|
|
299
236
|
({
|
|
@@ -307,7 +244,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
307
244
|
isSelected: boolean;
|
|
308
245
|
displayName: string;
|
|
309
246
|
}) => {
|
|
310
|
-
if (filterId ===
|
|
247
|
+
if (filterId === 'sort') {
|
|
311
248
|
const newSort = filterItemId as ProductSorting;
|
|
312
249
|
trackEvent({
|
|
313
250
|
eventName: SpiffyMetricsEventName.SearchSortClicked,
|
|
@@ -317,39 +254,44 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
317
254
|
},
|
|
318
255
|
});
|
|
319
256
|
setProductSorting(newSort);
|
|
257
|
+
scrollToTop();
|
|
320
258
|
} else if (!isSelected) {
|
|
321
259
|
removeFilter(`${filterId}:${filterItemId}`);
|
|
260
|
+
scrollToTop();
|
|
322
261
|
} else {
|
|
323
262
|
trackEvent({
|
|
324
263
|
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
325
264
|
eventProps: {
|
|
326
|
-
filterType:
|
|
265
|
+
filterType: 'Static',
|
|
327
266
|
filterCategory: filterId,
|
|
328
267
|
filterValue: filterItemId,
|
|
329
268
|
queryText: searchText,
|
|
330
269
|
},
|
|
331
270
|
});
|
|
332
271
|
addFilter(createFilterOption(filterId, filterItemId, displayName));
|
|
272
|
+
scrollToTop();
|
|
333
273
|
}
|
|
334
274
|
},
|
|
335
|
-
[addFilter, removeFilter, setProductSorting, searchText,
|
|
275
|
+
[addFilter, removeFilter, setProductSorting, searchText, scrollToTop],
|
|
336
276
|
);
|
|
337
277
|
|
|
278
|
+
|
|
338
279
|
const handleClearAllFilters = useCallback(() => {
|
|
339
280
|
setProductSorting(ProductSorting.FEATURED);
|
|
340
281
|
clearFilters();
|
|
341
|
-
|
|
282
|
+
scrollToTop();
|
|
283
|
+
}, [setProductSorting, clearFilters, scrollToTop]);
|
|
342
284
|
|
|
343
285
|
// Side Effects
|
|
344
286
|
useTrackComponentVisibleEvent(
|
|
345
287
|
SpiffyWidgets.SearchResults,
|
|
346
288
|
searchResultsRef,
|
|
347
289
|
{},
|
|
348
|
-
SpiffyMetricsEventName.SearchComponentVisible
|
|
290
|
+
SpiffyMetricsEventName.SearchComponentVisible,
|
|
349
291
|
);
|
|
350
292
|
|
|
351
293
|
useEffect(() => {
|
|
352
|
-
if (
|
|
294
|
+
if (searchResultsState === SearchResultsState.Results || searchResultsState === SearchResultsState.NoResults) {
|
|
353
295
|
trackEvent({
|
|
354
296
|
eventName: SpiffyMetricsEventName.SearchResultsViewed,
|
|
355
297
|
eventProps: {
|
|
@@ -358,72 +300,35 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
358
300
|
},
|
|
359
301
|
});
|
|
360
302
|
}
|
|
361
|
-
}, [productList.length,
|
|
303
|
+
}, [productList.length, searchResultsState]);
|
|
362
304
|
|
|
305
|
+
// This is the single source of truth for the search text triggering a search
|
|
363
306
|
useEffect(() => {
|
|
364
307
|
if (query && query !== searchText) {
|
|
308
|
+
const esq = new URLSearchParams(window.location.search).get('esq');
|
|
365
309
|
setSearchText(query);
|
|
310
|
+
performSearch({ query: esq ?? query });
|
|
366
311
|
}
|
|
367
|
-
|
|
368
|
-
}, [query]);
|
|
369
|
-
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
const esq = new URLSearchParams(window.location.search).get("esq");
|
|
372
|
-
if (esq) {
|
|
373
|
-
setSearchText(esq);
|
|
374
|
-
performSearch({ query: esq });
|
|
375
|
-
}
|
|
376
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
377
|
-
}, [performSearch]);
|
|
378
|
-
|
|
379
|
-
const fetchAutocompleteSuggestions = (_query: string) => {
|
|
380
|
-
// TODO: implement autocomplete suggestions
|
|
381
|
-
return Promise.resolve([]);
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
useEffect(() => {
|
|
385
|
-
if (fetchAutocompleteSuggestions === undefined) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
if (!isDirty || debouncedSearchText.length <= 2) {
|
|
390
|
-
setAutocompleteState({ results: [], isLoading: false });
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
setAutocompleteState((prev) => ({ ...prev, isLoading: true }));
|
|
395
|
-
|
|
396
|
-
const fetchData = async () => {
|
|
397
|
-
try {
|
|
398
|
-
const results = await fetchAutocompleteSuggestions?.(
|
|
399
|
-
debouncedSearchText
|
|
400
|
-
);
|
|
401
|
-
setAutocompleteState({ results: results ?? [], isLoading: false });
|
|
402
|
-
} catch (error) {
|
|
403
|
-
Logger.logError("Failed to fetch autocomplete suggestions:", error);
|
|
404
|
-
setAutocompleteState({ results: [], isLoading: false });
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
fetchData();
|
|
409
|
-
}, [debouncedSearchText, isDirty, setAutocompleteState]);
|
|
312
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
313
|
+
}, [performSearch, query, setSearchText]);
|
|
410
314
|
|
|
411
315
|
return {
|
|
412
316
|
searchData,
|
|
413
|
-
searchResponseId: searchData?.searchResponseId ??
|
|
317
|
+
searchResponseId: searchData?.searchResponseId ?? '',
|
|
414
318
|
merchantShortName: safeMerchantShortName,
|
|
415
319
|
productCardConfig: safeProductCardConfig,
|
|
416
320
|
productList,
|
|
321
|
+
recommendedProducts,
|
|
417
322
|
autocompleteResults,
|
|
418
323
|
searchFilters: filters,
|
|
419
324
|
availableDynamicFilters,
|
|
420
325
|
selectedFilterOptions,
|
|
421
326
|
searchText,
|
|
327
|
+
query: query || '',
|
|
422
328
|
searchResultsState,
|
|
423
|
-
isLoadingAutocomplete,
|
|
424
329
|
isLoadingSearch,
|
|
425
330
|
isFilterOpen,
|
|
426
|
-
|
|
331
|
+
shouldShowAutocomplete,
|
|
427
332
|
focusedIndex,
|
|
428
333
|
focusedOptionId,
|
|
429
334
|
filterButtonText,
|
|
@@ -431,6 +336,8 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
431
336
|
onSubmitSearch: handleSubmitSearch,
|
|
432
337
|
onAutocompleteSelect: handleAutocompleteSelect,
|
|
433
338
|
onKeyDown: handleKeyDown,
|
|
339
|
+
onSearchInputFocus: handleSearchInputFocus,
|
|
340
|
+
onSearchInputBlur: handleSearchInputBlur,
|
|
434
341
|
onToggleDynamicFilter: handleToggleDynamicFilter,
|
|
435
342
|
onSelectFilterItem: handleSelectFilterItem,
|
|
436
343
|
onRemoveFilter: handleRemoveFilter,
|
|
@@ -438,4 +345,4 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
438
345
|
setIsFilterOpen,
|
|
439
346
|
searchResultsRef,
|
|
440
347
|
};
|
|
441
|
-
};
|
|
348
|
+
};
|