@envive-ai/react-hooks 0.2.6-alpha → 0.2.6-alpha-2

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.
Files changed (408) hide show
  1. package/dist/{AmplitudeOperations-zFjk1Mkm.js → AmplitudeOperations-C3i2q2Bn.js} +2 -2
  2. package/dist/{AmplitudeOperations-CDe6oRn4.cjs → AmplitudeOperations-DcuLn1Zk.cjs} +2 -2
  3. package/dist/{NewOrgConfig-ChNJ3ZtC.js → NewOrgConfig-BtvujFC8.js} +2 -2
  4. package/dist/{NewOrgConfig-KHz61ikr.cjs → NewOrgConfig-CHt7Xg4t.cjs} +2 -2
  5. package/dist/{TrackComponentVisibleEvent-f8ahqV1g.js → TrackComponentVisibleEvent-Be7wfXXY.js} +3 -3
  6. package/dist/{TrackComponentVisibleEvent-uEzgBXb9.cjs → TrackComponentVisibleEvent-KUihr_y4.cjs} +3 -3
  7. package/dist/{api-1-73JxnF.js → api-D4HaU2Gf.js} +3 -3
  8. package/dist/{api-ZNG6wObS.cjs → api-D4Xoibs9.cjs} +3 -3
  9. package/dist/application/models/graphql/index.cjs +1 -1
  10. package/dist/application/models/graphql/index.js +1 -1
  11. package/dist/application/models/guards/api/index.cjs +3 -3
  12. package/dist/application/models/guards/api/index.js +3 -3
  13. package/dist/application/models/guards/utils.cjs +1 -1
  14. package/dist/application/models/guards/utils.js +1 -1
  15. package/dist/application/models/index.cjs +6 -6
  16. package/dist/application/models/index.js +6 -6
  17. package/dist/application/utils/index.cjs +17 -17
  18. package/dist/application/utils/index.d.cts +1 -1
  19. package/dist/application/utils/index.d.ts +2 -2
  20. package/dist/application/utils/index.js +17 -17
  21. package/dist/{atomStore-DAQvNPkh.js → atomStore-BuopbV9k.js} +1 -1
  22. package/dist/{atomStore-DD9g7Zw2.cjs → atomStore-CZKe3itM.cjs} +1 -1
  23. package/dist/atoms/app/index.cjs +17 -17
  24. package/dist/atoms/app/index.d.cts +7 -7
  25. package/dist/atoms/app/index.d.ts +6 -6
  26. package/dist/atoms/app/index.js +17 -17
  27. package/dist/atoms/atomStore/index.cjs +1 -1
  28. package/dist/atoms/atomStore/index.js +1 -1
  29. package/dist/atoms/chat/index.cjs +19 -19
  30. package/dist/atoms/chat/index.d.cts +32 -32
  31. package/dist/atoms/chat/index.d.ts +32 -32
  32. package/dist/atoms/chat/index.js +19 -19
  33. package/dist/atoms/globalSearch/index.cjs +1 -1
  34. package/dist/atoms/globalSearch/index.d.cts +6 -6
  35. package/dist/atoms/globalSearch/index.d.ts +6 -6
  36. package/dist/atoms/globalSearch/index.js +1 -1
  37. package/dist/atoms/org/index.cjs +2 -2
  38. package/dist/atoms/org/index.d.cts +16 -16
  39. package/dist/atoms/org/index.d.ts +16 -16
  40. package/dist/atoms/org/index.js +2 -2
  41. package/dist/atoms/search/index.cjs +6 -6
  42. package/dist/atoms/search/index.d.cts +15 -15
  43. package/dist/atoms/search/index.d.ts +14 -14
  44. package/dist/atoms/search/index.js +6 -6
  45. package/dist/atoms/search/utils.cjs +1 -1
  46. package/dist/atoms/search/utils.js +1 -1
  47. package/dist/{cdnContext-DT6J5nCw.js → cdnContext-B2-NiEiW.js} +2 -2
  48. package/dist/{cdnContext-BLNiW2HT.cjs → cdnContext-CdhppNeT.cjs} +2 -2
  49. package/dist/{chat-C0cgfkL8.js → chat-C9KdnT5V.js} +7 -7
  50. package/dist/{chat-DULmjtx1.cjs → chat-bImNRcnQ.cjs} +7 -7
  51. package/dist/{chatState-BrSfXIV4.cjs → chatState-DqWSgmjC.cjs} +3 -3
  52. package/dist/{chatState-Cn8JGAlH.js → chatState-DxG0t4fK.js} +3 -3
  53. package/dist/contexts/amplitudeContext/index.cjs +17 -17
  54. package/dist/contexts/amplitudeContext/index.js +17 -17
  55. package/dist/contexts/cdnContext/index.cjs +4 -4
  56. package/dist/contexts/cdnContext/index.d.cts +1 -1
  57. package/dist/contexts/cdnContext/index.js +4 -4
  58. package/dist/contexts/enviveConfigContext/index.cjs +4 -4
  59. package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
  60. package/dist/contexts/enviveConfigContext/index.js +4 -4
  61. package/dist/contexts/enviveCssContext/index.cjs +14 -14
  62. package/dist/contexts/enviveCssContext/index.js +14 -14
  63. package/dist/contexts/featureFlagContext/index.cjs +5 -5
  64. package/dist/contexts/featureFlagContext/index.js +5 -5
  65. package/dist/contexts/featureFlagServiceContext/index.cjs +4 -4
  66. package/dist/contexts/featureFlagServiceContext/index.js +4 -4
  67. package/dist/contexts/graphqlContext/index.cjs +8 -8
  68. package/dist/contexts/graphqlContext/index.js +8 -8
  69. package/dist/contexts/localStorageContext/index.cjs +3 -3
  70. package/dist/contexts/localStorageContext/index.js +3 -3
  71. package/dist/contexts/newOrgConfigContext/index.cjs +13 -13
  72. package/dist/contexts/newOrgConfigContext/index.d.cts +1 -1
  73. package/dist/contexts/newOrgConfigContext/index.js +13 -13
  74. package/dist/contexts/searchContext/index.cjs +22 -22
  75. package/dist/contexts/searchContext/index.js +22 -22
  76. package/dist/contexts/sessionStorageContext/index.cjs +2 -2
  77. package/dist/contexts/sessionStorageContext/index.js +2 -2
  78. package/dist/contexts/systemSettingsContext/index.cjs +4 -4
  79. package/dist/contexts/systemSettingsContext/index.js +4 -4
  80. package/dist/contexts/userIdentityContext/index.cjs +17 -17
  81. package/dist/contexts/userIdentityContext/index.js +17 -17
  82. package/dist/{dist-BZX_Mgfn.cjs → dist-B7BErEyV.cjs} +1 -1
  83. package/dist/{dist-CIM4YRqp.js → dist-CtkINi1R.js} +1 -1
  84. package/dist/{domObserver-DKcas6tl.js → domObserver-B19-69gW.js} +1 -1
  85. package/dist/{domObserver-Do6RAJdf.cjs → domObserver-CwieVNgj.cjs} +1 -1
  86. package/dist/{enviveConfig-DrvYlCYG.js → enviveConfig-Be2kZE7j.js} +3 -3
  87. package/dist/{enviveConfig-DaotBKMS.cjs → enviveConfig-u50Rpz-G.cjs} +3 -3
  88. package/dist/{enviveConfigContext-BCnzgk4M.js → enviveConfigContext-1oiQuocd.js} +3 -3
  89. package/dist/{enviveConfigContext--89ejDs5.cjs → enviveConfigContext-kQfHEGdJ.cjs} +3 -3
  90. package/dist/exceptions/index.cjs +1 -1
  91. package/dist/exceptions/index.js +1 -1
  92. package/dist/{exceptions-BiSWJEl2.cjs → exceptions-BjDgLzGi.cjs} +1 -1
  93. package/dist/{exceptions-DSv0ZaH0.js → exceptions-CUGY31Ua.js} +1 -1
  94. package/dist/{featureFlagServiceContext-DpdlcjNb.js → featureFlagServiceContext-CPsygiHO.js} +3 -3
  95. package/dist/{featureFlagServiceContext-BztKnBPk.cjs → featureFlagServiceContext-pPneufeB.cjs} +3 -3
  96. package/dist/{globalSearch-nmrfGLOn.js → globalSearch-B_v9qfCT.js} +1 -1
  97. package/dist/{globalSearch-Cpc8egsM.cjs → globalSearch-OiF96VLG.cjs} +1 -1
  98. package/dist/{graphql-CWNkUHFV.js → graphql-CvAHWmel.js} +1 -1
  99. package/dist/{graphql-DT-H-lta.cjs → graphql-JaGqsToc.cjs} +1 -1
  100. package/dist/{graphqlContext-CWulFxxC.js → graphqlContext-BuXJ5DiW.js} +5 -5
  101. package/dist/{graphqlContext-B181y-sa.cjs → graphqlContext-CU7NIJo7.cjs} +5 -5
  102. package/dist/hooks/AmplitudeOperations/index.cjs +18 -18
  103. package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
  104. package/dist/hooks/AmplitudeOperations/index.js +18 -18
  105. package/dist/hooks/AppDetails/index.cjs +20 -20
  106. package/dist/hooks/AppDetails/index.d.cts +1 -1
  107. package/dist/hooks/AppDetails/index.js +20 -20
  108. package/dist/hooks/CdnOperations/index.cjs +4 -4
  109. package/dist/hooks/CdnOperations/index.d.cts +1 -1
  110. package/dist/hooks/CdnOperations/index.js +4 -4
  111. package/dist/hooks/ChatToggle/index.cjs +19 -19
  112. package/dist/hooks/ChatToggle/index.js +19 -19
  113. package/dist/hooks/ChatToggleAnalytics/index.cjs +19 -19
  114. package/dist/hooks/ChatToggleAnalytics/index.js +19 -19
  115. package/dist/hooks/CustomerSupportHandoff/index.cjs +1 -1
  116. package/dist/hooks/CustomerSupportHandoff/index.js +1 -1
  117. package/dist/hooks/ElementObserver/index.cjs +1 -1
  118. package/dist/hooks/ElementObserver/index.js +1 -1
  119. package/dist/hooks/GraphQLConfig/index.cjs +9 -9
  120. package/dist/hooks/GraphQLConfig/index.js +9 -9
  121. package/dist/hooks/IdentifyUser/index.cjs +17 -17
  122. package/dist/hooks/IdentifyUser/index.js +17 -17
  123. package/dist/hooks/ImageResolver/index.cjs +3 -3
  124. package/dist/hooks/ImageResolver/index.js +3 -3
  125. package/dist/hooks/LocalStorageOperations/index.cjs +3 -3
  126. package/dist/hooks/LocalStorageOperations/index.js +3 -3
  127. package/dist/hooks/MessageFilter/index.cjs +1 -1
  128. package/dist/hooks/MessageFilter/index.js +1 -1
  129. package/dist/hooks/NewOrgConfig/index.cjs +14 -14
  130. package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
  131. package/dist/hooks/NewOrgConfig/index.d.ts +2 -2
  132. package/dist/hooks/NewOrgConfig/index.js +14 -14
  133. package/dist/hooks/Search/index.cjs +31 -31
  134. package/dist/hooks/Search/index.js +31 -31
  135. package/dist/hooks/SearchOperations/index.cjs +22 -22
  136. package/dist/hooks/SearchOperations/index.js +22 -22
  137. package/dist/hooks/SessionStorageOperations/index.cjs +2 -2
  138. package/dist/hooks/SessionStorageOperations/index.js +2 -2
  139. package/dist/hooks/ShopifyUrlOperations/index.d.cts +2 -2
  140. package/dist/hooks/ShopifyUrlOperations/index.d.ts +2 -2
  141. package/dist/hooks/SystemSettingsContext/index.cjs +4 -4
  142. package/dist/hooks/SystemSettingsContext/index.d.cts +3 -3
  143. package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
  144. package/dist/hooks/SystemSettingsContext/index.js +4 -4
  145. package/dist/hooks/TrackComponentVisibleEvent/index.cjs +18 -18
  146. package/dist/hooks/TrackComponentVisibleEvent/index.js +18 -18
  147. package/dist/hooks/UpdateAnalyticsProps/index.cjs +17 -17
  148. package/dist/hooks/UpdateAnalyticsProps/index.js +17 -17
  149. package/dist/index-B4cSHxVN.d.ts +1 -1
  150. package/dist/index-Dzv6WwSZ.d.ts +1 -1
  151. package/dist/interceptors/index.cjs +1 -1
  152. package/dist/interceptors/index.js +1 -1
  153. package/dist/{localStorageContext-DbWl7Row.cjs → localStorageContext-Bb2b_3ue.cjs} +3 -3
  154. package/dist/{localStorageContext-DSpmlfyr.js → localStorageContext-D2uXKahw.js} +3 -3
  155. package/dist/{logger-DCs3_11o.js → logger-BMVdhQOV.js} +1 -1
  156. package/dist/{logger-BF6iGSVd.cjs → logger-BqHq67zN.cjs} +1 -1
  157. package/dist/{models-DEJUuKYQ.js → models-DmsMlaHT.js} +5 -5
  158. package/dist/{models-158fyHt9.cjs → models-wh2gh_Qz.cjs} +5 -5
  159. package/dist/{newOrgConfigAtom-BuQE_zPK.js → newOrgConfigAtom-Dsk0fJNR.js} +1 -1
  160. package/dist/{newOrgConfigAtom-rrYHmp1b.cjs → newOrgConfigAtom-hs5A1pbZ.cjs} +1 -1
  161. package/dist/{newOrgConfigContext-C0LzIRJ7.js → newOrgConfigContext-DPUxIF2G.js} +5 -5
  162. package/dist/{newOrgConfigContext-BVrzYatq.cjs → newOrgConfigContext-lw85mMS-.cjs} +5 -5
  163. package/dist/nodeSelector-Cj-Xl1LP.d.cts +1 -1
  164. package/dist/{org-CVjyv-gv.cjs → org-C2kLSSe9.cjs} +1 -1
  165. package/dist/{org-Ct9Vjv1J.js → org-CIczyLRP.js} +1 -1
  166. package/dist/{search-DLHzcbfP.js → search-BzXoTgRx.js} +5 -5
  167. package/dist/{search-C0TAcTeY.cjs → search-D1cU29CV.cjs} +5 -5
  168. package/dist/{searchContext-Dmtue5QO.js → searchContext-C8DpjnqD.js} +7 -7
  169. package/dist/{searchContext-l_23fiuP.cjs → searchContext-R_XuFzYe.cjs} +7 -7
  170. package/dist/{searchServiceAdapter-B0h7psvh.js → searchServiceAdapter-CKc7UXKi.js} +1 -1
  171. package/dist/{searchServiceAdapter-BclWy4fE.cjs → searchServiceAdapter-pROGm3Rf.cjs} +1 -1
  172. package/dist/{sessionStorageContext-BOyr7mIM.cjs → sessionStorageContext-ByaTsDUC.cjs} +2 -2
  173. package/dist/{sessionStorageContext-ClXN9eX4.js → sessionStorageContext-DKE97oMv.js} +2 -2
  174. package/dist/{systemSettingsContext-CksCdpiU.js → systemSettingsContext-B-FZ8UAg.js} +2 -2
  175. package/dist/{systemSettingsContext-Cb5kczBD.cjs → systemSettingsContext-J1sny8W8.cjs} +2 -2
  176. package/dist/types/index.cjs +1 -1
  177. package/dist/types/index.js +1 -1
  178. package/dist/{types-18QXD2rd.cjs → types-1iJ_FnQQ.cjs} +1 -1
  179. package/dist/{types-DQC1pHqD.js → types-D5du68Vp.js} +1 -1
  180. package/dist/{useAppDetails-BJFRSYbI.js → useAppDetails-BtK9ZZJs.js} +4 -4
  181. package/dist/{useAppDetails-Czn-5FzP.cjs → useAppDetails-Bw2jJ39H.cjs} +4 -4
  182. package/dist/{useGraphQLConfig-BEtX5pDM.cjs → useGraphQLConfig-Dc8h2yyN.cjs} +2 -2
  183. package/dist/{useGraphQLConfig-Dkcrz1YL.js → useGraphQLConfig-DuLB3tdv.js} +2 -2
  184. package/dist/{utils-CEKzBcN2.js → utils-B1LVzQYK.js} +1 -1
  185. package/dist/{utils-CqVRbvfN.cjs → utils-BivlGkeU.cjs} +1 -1
  186. package/dist/{utils-DQhbbAnt.js → utils-CExht7Uj.js} +1 -1
  187. package/dist/{utils-CsMbZmRw.cjs → utils-CiJLDPjY.cjs} +1 -1
  188. package/dist/{utils-CPvqOk0g.cjs → utils-DqNhRm2b.cjs} +14 -14
  189. package/dist/{utils-N47VsL9W.js → utils-IogJwDB9.js} +13 -13
  190. package/package.json +1 -1
  191. package/dist/src/application/commerce-api.js +0 -406
  192. package/dist/src/application/logging/logger.js +0 -16
  193. package/dist/src/application/models/graphql/index.js +0 -3
  194. package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +0 -13
  195. package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +0 -13
  196. package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +0 -10
  197. package/dist/src/application/models/guards/api/index.js +0 -12
  198. package/dist/src/application/models/guards/api/isApiFormResponse.js +0 -59
  199. package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +0 -22
  200. package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +0 -91
  201. package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +0 -188
  202. package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +0 -115
  203. package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +0 -16
  204. package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +0 -26
  205. package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +0 -15
  206. package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +0 -65
  207. package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +0 -15
  208. package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +0 -10
  209. package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +0 -4
  210. package/dist/src/application/models/guards/api/isApiResponse.js +0 -33
  211. package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +0 -22
  212. package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +0 -23
  213. package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +0 -20
  214. package/dist/src/application/models/guards/api/isApiSuggestion.js +0 -24
  215. package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +0 -4
  216. package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +0 -4
  217. package/dist/src/application/models/guards/api/isApiUserEvent.js +0 -18
  218. package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +0 -41
  219. package/dist/src/application/models/guards/isBaseEcommerceEvent.js +0 -14
  220. package/dist/src/application/models/guards/isGA4EcommerceEvent.js +0 -14
  221. package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +0 -14
  222. package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +0 -4
  223. package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +0 -1
  224. package/dist/src/application/models/guards/isVariantInfo.js +0 -28
  225. package/dist/src/application/models/guards/utils.js +0 -34
  226. package/dist/src/application/models/index.js +0 -34
  227. package/dist/src/application/models/utils/snakeToCamelTransformer.js +0 -71
  228. package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +0 -65
  229. package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +0 -9
  230. package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +0 -420
  231. package/dist/src/application/models/validators/validateGraphQLOrgId.js +0 -6
  232. package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +0 -9
  233. package/dist/src/application/models/validators/validateOrgConfigResults.js +0 -44
  234. package/dist/src/application/models/validators/validateOrganizationConfig.js +0 -34
  235. package/dist/src/application/models/validators/validateResponse.js +0 -173
  236. package/dist/src/application/models/validators/validateSuggestion.js +0 -13
  237. package/dist/src/application/models/validators/validateUserEvent.js +0 -91
  238. package/dist/src/application/utils/analyticsUtils.js +0 -94
  239. package/dist/src/application/utils/coreContextToApiContext.js +0 -8
  240. package/dist/src/application/utils/coreUserEventToApiUserEvent.js +0 -90
  241. package/dist/src/application/utils/divideArray.js +0 -7
  242. package/dist/src/application/utils/domObserver.js +0 -85
  243. package/dist/src/application/utils/elementObserver.js +0 -186
  244. package/dist/src/application/utils/imageFilter.js +0 -11
  245. package/dist/src/application/utils/index.js +0 -21
  246. package/dist/src/application/utils/merchantUtils.js +0 -15
  247. package/dist/src/application/utils/messageFromFormSubmittedEvent.js +0 -19
  248. package/dist/src/application/utils/messageFromQueryEvent.js +0 -35
  249. package/dist/src/application/utils/messageFromResponse.js +0 -123
  250. package/dist/src/application/utils/messageFromSuggestionEvent.js +0 -27
  251. package/dist/src/application/utils/mouseEventTypes.js +0 -1
  252. package/dist/src/application/utils/mutationHelper.js +0 -33
  253. package/dist/src/application/utils/nextMessageRequestToApiRequest.js +0 -29
  254. package/dist/src/application/utils/nodeSelector.js +0 -101
  255. package/dist/src/application/utils/overrides.js +0 -144
  256. package/dist/src/application/utils/stringUtils.js +0 -47
  257. package/dist/src/application/utils/supportedEventRequestToApiRequest.js +0 -7
  258. package/dist/src/application/utils/urlsParser.js +0 -33
  259. package/dist/src/application/utils/validation.js +0 -5
  260. package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +0 -4
  261. package/dist/src/atoms/app/index.js +0 -23
  262. package/dist/src/atoms/app/variant.js +0 -102
  263. package/dist/src/atoms/atomStore/atomStore.js +0 -28
  264. package/dist/src/atoms/atomStore/index.js +0 -1
  265. package/dist/src/atoms/chat/chatState.js +0 -33
  266. package/dist/src/atoms/chat/form.js +0 -16
  267. package/dist/src/atoms/chat/index.js +0 -23
  268. package/dist/src/atoms/chat/lastMessage.js +0 -10
  269. package/dist/src/atoms/chat/messageQueue.js +0 -68
  270. package/dist/src/atoms/chat/performanceMetrics.js +0 -70
  271. package/dist/src/atoms/chat/renderedWidgetRefs.js +0 -24
  272. package/dist/src/atoms/chat/replies.js +0 -43
  273. package/dist/src/atoms/chat/suggestions.js +0 -29
  274. package/dist/src/atoms/envive/enviveConfig.js +0 -67
  275. package/dist/src/atoms/globalSearch/globalSearch.js +0 -8
  276. package/dist/src/atoms/globalSearch/index.js +0 -1
  277. package/dist/src/atoms/org/customerService.js +0 -6
  278. package/dist/src/atoms/org/graphqlConfig.js +0 -8
  279. package/dist/src/atoms/org/index.js +0 -4
  280. package/dist/src/atoms/org/newOrgConfigAtom.js +0 -2
  281. package/dist/src/atoms/org/orgAnalyticsConfig.js +0 -8
  282. package/dist/src/atoms/search/index.js +0 -1
  283. package/dist/src/atoms/search/productFilters.js +0 -163
  284. package/dist/src/atoms/search/productRetrievalAPI.js +0 -50
  285. package/dist/src/atoms/search/productRetrievalAdapter.js +0 -14
  286. package/dist/src/atoms/search/productSorter.js +0 -13
  287. package/dist/src/atoms/search/searchAPI.js +0 -140
  288. package/dist/src/atoms/search/searchServiceAdapter.js +0 -14
  289. package/dist/src/atoms/search/utils.js +0 -15
  290. package/dist/src/config/index.js +0 -1
  291. package/dist/src/config/locators/components/chat/entrypoints.js +0 -10
  292. package/dist/src/config/locators/components/chat/index.js +0 -21
  293. package/dist/src/config/locators/components/chat/preview.js +0 -11
  294. package/dist/src/config/locators/components/chat/variants/index.js +0 -12
  295. package/dist/src/config/locators/components/common/buttons.js +0 -6
  296. package/dist/src/config/locators/components/common/cards.js +0 -17
  297. package/dist/src/config/locators/components/common/index.js +0 -4
  298. package/dist/src/config/locators/components/common/links.js +0 -1
  299. package/dist/src/config/locators/components/common/tables.js +0 -1
  300. package/dist/src/config/locators/components/floating-button.js +0 -2
  301. package/dist/src/config/locators/components/index.js +0 -3
  302. package/dist/src/config/locators/components/report-issue.js +0 -13
  303. package/dist/src/config/locators/components/search/index.js +0 -5
  304. package/dist/src/config/locators/components/shadow-dom.js +0 -1
  305. package/dist/src/config/locators/embedded.js +0 -20
  306. package/dist/src/config/locators/index.js +0 -4
  307. package/dist/src/contexts/amplitudeContext/amplitudeContext.js +0 -292
  308. package/dist/src/contexts/amplitudeContext/index.js +0 -1
  309. package/dist/src/contexts/cdnContext/cdnContext.js +0 -28
  310. package/dist/src/contexts/cdnContext/index.js +0 -1
  311. package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +0 -37
  312. package/dist/src/contexts/enviveConfigContext/index.js +0 -1
  313. package/dist/src/contexts/enviveCssContext/enviveCssContext.js +0 -31
  314. package/dist/src/contexts/enviveCssContext/index.js +0 -1
  315. package/dist/src/contexts/featureFlagContext/featureFlagContext.js +0 -109
  316. package/dist/src/contexts/featureFlagContext/index.js +0 -1
  317. package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +0 -47
  318. package/dist/src/contexts/featureFlagServiceContext/index.js +0 -1
  319. package/dist/src/contexts/graphqlContext/graphqlContext.js +0 -87
  320. package/dist/src/contexts/graphqlContext/index.js +0 -1
  321. package/dist/src/contexts/localStorageContext/index.js +0 -1
  322. package/dist/src/contexts/localStorageContext/localStorageContext.js +0 -95
  323. package/dist/src/contexts/newOrgConfigContext/index.js +0 -1
  324. package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +0 -33
  325. package/dist/src/contexts/searchContext/index.js +0 -1
  326. package/dist/src/contexts/searchContext/searchContext.js +0 -131
  327. package/dist/src/contexts/sessionStorageContext/index.js +0 -1
  328. package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +0 -43
  329. package/dist/src/contexts/shopifyUrlContext/index.js +0 -1
  330. package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +0 -62
  331. package/dist/src/contexts/systemSettingsContext/index.js +0 -1
  332. package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +0 -29
  333. package/dist/src/contexts/userIdentityContext/index.js +0 -1
  334. package/dist/src/contexts/userIdentityContext/userIdentityContext.js +0 -118
  335. package/dist/src/events/index.js +0 -51
  336. package/dist/src/events/registerAnalyticsListeners.js +0 -32
  337. package/dist/src/exceptions/index.js +0 -2
  338. package/dist/src/exceptions/sessionExceptions.js +0 -6
  339. package/dist/src/exceptions/unsupportedProductExceptions.js +0 -6
  340. package/dist/src/hooks/AmplitudeOperations/index.js +0 -1
  341. package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +0 -24
  342. package/dist/src/hooks/AppDetails/index.js +0 -1
  343. package/dist/src/hooks/AppDetails/useAppDetails.js +0 -26
  344. package/dist/src/hooks/BlockBackButton/index.js +0 -1
  345. package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +0 -23
  346. package/dist/src/hooks/CdnOperations/index.js +0 -1
  347. package/dist/src/hooks/CdnOperations/useCdnOperations.js +0 -13
  348. package/dist/src/hooks/ChatToggle/index.js +0 -1
  349. package/dist/src/hooks/ChatToggle/useChatToggle.js +0 -50
  350. package/dist/src/hooks/ChatToggleAnalytics/index.js +0 -1
  351. package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +0 -11
  352. package/dist/src/hooks/CustomerSupportHandoff/index.js +0 -1
  353. package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +0 -32
  354. package/dist/src/hooks/Debounce/index.js +0 -1
  355. package/dist/src/hooks/Debounce/useDebounce.js +0 -13
  356. package/dist/src/hooks/ElementObserver/index.js +0 -1
  357. package/dist/src/hooks/ElementObserver/useElementObserver.js +0 -208
  358. package/dist/src/hooks/GrabAndScroll/index.js +0 -1
  359. package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +0 -105
  360. package/dist/src/hooks/GraphQLConfig/index.js +0 -1
  361. package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +0 -54
  362. package/dist/src/hooks/IdentifyUser/index.js +0 -1
  363. package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +0 -28
  364. package/dist/src/hooks/ImageResolver/index.js +0 -1
  365. package/dist/src/hooks/ImageResolver/useImageResolver.js +0 -45
  366. package/dist/src/hooks/Intersection/index.js +0 -1
  367. package/dist/src/hooks/Intersection/useIntersection.js +0 -20
  368. package/dist/src/hooks/IsSmallScreen/index.js +0 -1
  369. package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +0 -16
  370. package/dist/src/hooks/LocalStorageOperations/index.js +0 -1
  371. package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +0 -64
  372. package/dist/src/hooks/MessageFilter/index.js +0 -1
  373. package/dist/src/hooks/MessageFilter/useMessageFilter.js +0 -37
  374. package/dist/src/hooks/MessageScrollObserver/index.js +0 -1
  375. package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +0 -35
  376. package/dist/src/hooks/NewOrgConfig/index.js +0 -1
  377. package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +0 -5
  378. package/dist/src/hooks/Search/index.js +0 -1
  379. package/dist/src/hooks/Search/useRecommendedProducts.js +0 -35
  380. package/dist/src/hooks/Search/useSearch.js +0 -224
  381. package/dist/src/hooks/Search/useSearchInput.js +0 -183
  382. package/dist/src/hooks/SearchOperations/index.js +0 -1
  383. package/dist/src/hooks/SearchOperations/useSearchOperations.js +0 -78
  384. package/dist/src/hooks/SessionStorageOperations/index.js +0 -1
  385. package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +0 -20
  386. package/dist/src/hooks/ShopifyUrlOperations/index.js +0 -1
  387. package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +0 -34
  388. package/dist/src/hooks/SnapCalculator/index.js +0 -1
  389. package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +0 -22
  390. package/dist/src/hooks/SystemSettingsContext/index.js +0 -1
  391. package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +0 -9
  392. package/dist/src/hooks/TrackComponentVisibleEvent/index.js +0 -1
  393. package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +0 -45
  394. package/dist/src/hooks/UpdateAnalyticsProps/index.js +0 -1
  395. package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +0 -43
  396. package/dist/src/hooks/utils.js +0 -116
  397. package/dist/src/interceptors/index.js +0 -1
  398. package/dist/src/interceptors/useMessageInterceptor.js +0 -24
  399. package/dist/src/types/ApiResponse.js +0 -1
  400. package/dist/src/types/FilterAttribute.js +0 -3
  401. package/dist/src/types/Message.js +0 -24
  402. package/dist/src/types/Suggestion.js +0 -3
  403. package/dist/src/types/index.js +0 -4
  404. package/dist/src/util/colorVar.js +0 -3
  405. package/dist/src/util/configVersion.js +0 -4
  406. package/dist/src/util/domInsertion.js +0 -16
  407. /package/dist/{featureFlagServiceContext-bI7ZLz4r.js → featureFlagServiceContext-CbUOAw5l.js} +0 -0
  408. /package/dist/{featureFlagServiceContext-B4ash4vz.cjs → featureFlagServiceContext-DSo2brno.cjs} +0 -0
@@ -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 { useAmplitude } from "../../contexts/amplitudeContext/amplitudeContext";
8
- import { orgShortNameAtom } from "../../atoms/envive/enviveConfig";
9
- import { useNewOrgConfig } from "../NewOrgConfig";
10
- import { useTrackComponentVisibleEvent } from "../TrackComponentVisibleEvent";
11
- import { getSearchResultsState } from "../utils";
12
- import { useRecommendedProducts } from "./useRecommendedProducts";
13
- import { useSearchInput } from "./useSearchInput";
14
- export const useSearch = () => {
15
- var _a, _b, _c;
16
- // Atoms
17
- const { trackEvent } = useAmplitude();
18
- const config = useNewOrgConfig();
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 = useRecommendedProducts();
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({
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({
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({
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({
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,183 +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 { useAmplitudeTracking } from "../AmplitudeOperations";
6
- import { autocompleteStateAtom } from "src/atoms/globalSearch";
7
- export const useSearchInput = ({ initialSearchText = "", searchOrigin, onSearchSubmit, }) => {
8
- const { track } = useAmplitudeTracking();
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(SpiffyMetricsEventName.SearchInputStarted, {
70
- searchOrigin,
71
- });
72
- }
73
- setSearchText(newValue);
74
- setHasText(newValue.trim().length > 0);
75
- setFocusedIndex(-1);
76
- setFocusedOptionId(undefined);
77
- }, [searchOrigin, searchText, track]);
78
- const handleSearchInputFocus = useCallback(() => {
79
- setIsFocused(true);
80
- }, []);
81
- const handleSearchInputBlur = useCallback(() => {
82
- setTimeout(() => {
83
- if (!isSelectingAutocomplete.current) {
84
- setIsFocused(false);
85
- setFocusedIndex(-1);
86
- setFocusedOptionId(undefined);
87
- }
88
- }, 150);
89
- }, []);
90
- const handleSubmitSearch = useCallback(() => {
91
- setIsFocused(false);
92
- if (searchText.trim() && onSearchSubmit) {
93
- track(SpiffyMetricsEventName.SearchQuerySubmitted, {
94
- searchOrigin,
95
- queryText: searchText.trim(),
96
- });
97
- onSearchSubmit(searchText.trim());
98
- }
99
- }, [searchText, onSearchSubmit, searchOrigin, track]);
100
- const handleAutocompleteSelect = useCallback((suggestion, rankPosition) => {
101
- isSelectingAutocomplete.current = true;
102
- setSearchText(suggestion);
103
- setHasText(suggestion.trim().length > 0);
104
- setIsFocused(false);
105
- track(SpiffyMetricsEventName.SearchQuerySubmitted, {
106
- searchOrigin,
107
- queryText: suggestion.trim(),
108
- });
109
- if (onSearchSubmit) {
110
- onSearchSubmit(suggestion.trim());
111
- }
112
- setTimeout(() => {
113
- isSelectingAutocomplete.current = false;
114
- }, 100);
115
- }, [onSearchSubmit, searchOrigin, track]);
116
- const handleKeyDown = useCallback((event) => {
117
- if (event.key === "ArrowDown") {
118
- event.preventDefault();
119
- const newIndex = (focusedIndex + 1) % autocompleteResults.length;
120
- setFocusedIndex(newIndex);
121
- setFocusedOptionId(`option-${newIndex}`);
122
- }
123
- else if (event.key === "ArrowUp") {
124
- event.preventDefault();
125
- const newIndex = (focusedIndex - 1 + autocompleteResults.length) %
126
- autocompleteResults.length;
127
- setFocusedIndex(newIndex);
128
- setFocusedOptionId(`option-${newIndex}`);
129
- }
130
- else if (event.key === "Enter") {
131
- if (focusedIndex === -1) {
132
- event.preventDefault();
133
- handleSubmitSearch();
134
- }
135
- else {
136
- event.preventDefault();
137
- const suggestionText = autocompleteResults[focusedIndex];
138
- handleAutocompleteSelect(suggestionText, focusedIndex);
139
- }
140
- }
141
- else if (event.key === "Escape") {
142
- event.preventDefault();
143
- setFocusedIndex(-1);
144
- setFocusedOptionId(undefined);
145
- }
146
- }, [
147
- autocompleteResults,
148
- focusedIndex,
149
- handleAutocompleteSelect,
150
- handleSubmitSearch,
151
- ]);
152
- const setSearchTextUtility = useCallback((text) => {
153
- setSearchText(text);
154
- setHasText(text.trim().length > 0);
155
- }, []);
156
- const resetSearch = useCallback(() => {
157
- setSearchText("");
158
- setHasText(false);
159
- setIsFocused(false);
160
- setFocusedIndex(-1);
161
- setFocusedOptionId(undefined);
162
- }, []);
163
- return {
164
- // State
165
- searchText,
166
- hasText,
167
- isFocused,
168
- focusedIndex,
169
- focusedOptionId,
170
- autocompleteResults,
171
- shouldShowAutocomplete,
172
- // Handlers
173
- handleSearchInputChange,
174
- handleSearchInputFocus,
175
- handleSearchInputBlur,
176
- handleKeyDown,
177
- handleAutocompleteSelect,
178
- handleSubmitSearch,
179
- // Utilities
180
- setSearchText: setSearchTextUtility,
181
- resetSearch,
182
- };
183
- };
@@ -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";