@web3auth/modal 10.0.0-beta.0 → 10.0.0-beta.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.
Files changed (256) hide show
  1. package/dist/lib.cjs/node_modules/style-inject/dist/style-inject.es.js +1 -1
  2. package/dist/lib.cjs/packages/modal/src/modalManager.js +186 -132
  3. package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +2 -2
  4. package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +26 -26
  5. package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3Auth.js +2 -2
  6. package/dist/lib.cjs/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +60 -0
  7. package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.js +47 -22
  8. package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.type.js +8 -0
  9. package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonSocial/ButtonSocial.js +53 -0
  10. package/dist/lib.cjs/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +68 -0
  11. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +202 -0
  12. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +62 -0
  13. package/dist/lib.cjs/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +28 -30
  14. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +49 -0
  15. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +140 -0
  16. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +93 -0
  17. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.js +55 -0
  18. package/dist/lib.cjs/packages/modal/src/ui/components/Embed/Embed.js +70 -0
  19. package/dist/lib.cjs/packages/modal/src/ui/components/Footer/Footer.js +53 -0
  20. package/dist/lib.cjs/packages/modal/src/ui/components/Image/Image.js +89 -0
  21. package/dist/lib.cjs/packages/modal/src/ui/components/Loader/Loader.js +151 -0
  22. package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +489 -0
  23. package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +116 -0
  24. package/dist/lib.cjs/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +117 -0
  25. package/dist/lib.cjs/packages/modal/src/ui/components/LoginHint/LoginHint.js +52 -0
  26. package/dist/lib.cjs/packages/modal/src/ui/components/Modal/Modal.js +87 -0
  27. package/dist/lib.cjs/packages/modal/src/ui/components/Otp/Otp.js +190 -0
  28. package/dist/lib.cjs/packages/modal/src/ui/components/PulseLoader/PulseLoader.js +18 -0
  29. package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +452 -0
  30. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +156 -0
  31. package/dist/lib.cjs/packages/modal/src/ui/components/Toast/Toast.js +70 -0
  32. package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +229 -0
  33. package/dist/lib.cjs/packages/modal/src/ui/config.js +12 -1
  34. package/dist/lib.cjs/packages/modal/src/ui/constants.js +18 -0
  35. package/dist/lib.cjs/packages/modal/src/ui/context/RootContext.js +20 -0
  36. package/dist/lib.cjs/packages/modal/src/ui/context/ThemeContext.js +2 -2
  37. package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +8 -0
  38. package/dist/lib.cjs/packages/modal/src/ui/handlers/AbstractHandler.js +117 -0
  39. package/dist/lib.cjs/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +54 -0
  40. package/dist/lib.cjs/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +57 -0
  41. package/dist/lib.cjs/packages/modal/src/ui/handlers/factory.js +19 -0
  42. package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +37 -2
  43. package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +37 -2
  44. package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +37 -2
  45. package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +37 -2
  46. package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +37 -2
  47. package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +37 -2
  48. package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +37 -2
  49. package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +37 -2
  50. package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +37 -2
  51. package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +37 -2
  52. package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +7 -10
  53. package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +69 -44
  54. package/dist/lib.cjs/packages/modal/src/ui/utils.js +107 -1
  55. package/dist/lib.cjs/types/modalManager.d.ts +4 -1
  56. package/dist/lib.cjs/types/ui/components/BottomSheet/BottomSheet.d.ts +7 -0
  57. package/dist/lib.cjs/types/ui/components/BottomSheet/BottomSheet.type.d.ts +7 -0
  58. package/dist/lib.cjs/types/ui/components/BottomSheet/index.d.ts +2 -0
  59. package/dist/lib.cjs/types/ui/components/Button/Button.d.ts +2 -15
  60. package/dist/lib.cjs/types/ui/components/Button/Button.type.d.ts +12 -0
  61. package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/ButtonSocial.d.ts +3 -0
  62. package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/ButtonSocial.type.d.ts +14 -0
  63. package/dist/lib.cjs/types/ui/components/Button/ButtonSocial/index.d.ts +2 -0
  64. package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/ButtonWallet.d.ts +3 -0
  65. package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/ButtonWallet.type.d.ts +13 -0
  66. package/dist/lib.cjs/types/ui/components/Button/ButtonWallet/index.d.ts +2 -0
  67. package/dist/lib.cjs/types/ui/components/Button/index.d.ts +1 -0
  68. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.d.ts +3 -0
  69. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.type.d.ts +24 -0
  70. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.d.ts +3 -0
  71. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.type.d.ts +13 -0
  72. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainFilter/index.d.ts +2 -0
  73. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.d.ts +3 -0
  74. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.type.d.ts +10 -0
  75. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/index.d.ts +2 -0
  76. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.d.ts +3 -0
  77. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.type.d.ts +6 -0
  78. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletHeader/index.d.ts +2 -0
  79. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.d.ts +3 -0
  80. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.type.d.ts +19 -0
  81. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletList/index.d.ts +2 -0
  82. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.d.ts +3 -0
  83. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.type.d.ts +9 -0
  84. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletQrCode/index.d.ts +2 -0
  85. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.d.ts +3 -0
  86. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.type.d.ts +9 -0
  87. package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWalletSearch/index.d.ts +2 -0
  88. package/dist/lib.cjs/types/ui/components/ConnectWallet/index.d.ts +2 -0
  89. package/dist/lib.cjs/types/ui/components/Embed/Embed.d.ts +8 -0
  90. package/dist/lib.cjs/types/ui/components/Embed/Embed.type.d.ts +12 -0
  91. package/dist/lib.cjs/types/ui/components/Embed/index.d.ts +2 -0
  92. package/dist/lib.cjs/types/ui/components/Footer/Footer.d.ts +7 -0
  93. package/dist/lib.cjs/types/ui/components/Footer/Footer.type.d.ts +4 -0
  94. package/dist/lib.cjs/types/ui/components/Footer/index.d.ts +2 -0
  95. package/dist/lib.cjs/types/ui/components/Image/Image.d.ts +7 -0
  96. package/dist/lib.cjs/types/ui/components/{Image.d.ts → Image/Image.type.d.ts} +2 -1
  97. package/dist/lib.cjs/types/ui/components/Image/index.d.ts +2 -0
  98. package/dist/lib.cjs/types/ui/components/Loader/Loader.d.ts +8 -0
  99. package/dist/lib.cjs/types/ui/components/Loader/Loader.type.d.ts +12 -0
  100. package/dist/lib.cjs/types/ui/components/Loader/index.d.ts +2 -0
  101. package/dist/lib.cjs/types/ui/components/Login/Login.d.ts +3 -0
  102. package/dist/lib.cjs/types/ui/components/Login/Login.type.d.ts +29 -0
  103. package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.d.ts +8 -0
  104. package/dist/lib.cjs/types/ui/components/Login/LoginOtp/LoginOtp.type.d.ts +10 -0
  105. package/dist/lib.cjs/types/ui/components/Login/LoginOtp/index.d.ts +2 -0
  106. package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/LoginPasswordLess.d.ts +3 -0
  107. package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/LoginPasswordLess.type.d.ts +13 -0
  108. package/dist/lib.cjs/types/ui/components/Login/LoginPasswordLess/index.d.ts +2 -0
  109. package/dist/lib.cjs/types/ui/components/Login/index.d.ts +2 -0
  110. package/dist/lib.cjs/types/ui/components/LoginHint/LoginHint.d.ts +3 -0
  111. package/dist/lib.cjs/types/ui/components/LoginHint/LoginHint.type.d.ts +6 -0
  112. package/dist/lib.cjs/types/ui/components/LoginHint/index.d.ts +2 -0
  113. package/dist/lib.cjs/types/ui/components/Modal/Modal.d.ts +8 -0
  114. package/dist/lib.cjs/types/ui/components/Modal/Modal.type.d.ts +14 -0
  115. package/dist/lib.cjs/types/ui/components/Modal/index.d.ts +2 -0
  116. package/dist/lib.cjs/types/ui/components/Otp/Otp.d.ts +3 -0
  117. package/dist/lib.cjs/types/ui/components/Otp/Otp.type.d.ts +22 -0
  118. package/dist/lib.cjs/types/ui/components/Otp/index.d.ts +2 -0
  119. package/dist/lib.cjs/types/ui/components/PulseLoader/PulseLoader.d.ts +2 -0
  120. package/dist/lib.cjs/types/ui/components/PulseLoader/index.d.ts +1 -0
  121. package/dist/lib.cjs/types/ui/components/Root/Root.d.ts +3 -0
  122. package/dist/lib.cjs/types/ui/components/Root/Root.type.d.ts +27 -0
  123. package/dist/lib.cjs/types/ui/components/Root/index.d.ts +2 -0
  124. package/dist/lib.cjs/types/ui/components/SocialLoginList/SocialLoginList.d.ts +3 -0
  125. package/dist/lib.cjs/types/ui/components/SocialLoginList/SocialLoginList.type.d.ts +11 -0
  126. package/dist/lib.cjs/types/ui/components/SocialLoginList/index.d.ts +2 -0
  127. package/dist/lib.cjs/types/ui/components/Toast/Toast.d.ts +2 -0
  128. package/dist/lib.cjs/types/ui/components/Toast/index.d.ts +1 -0
  129. package/dist/lib.cjs/types/ui/components/Widget/Widget.d.ts +3 -0
  130. package/dist/lib.cjs/types/ui/components/{Modal.d.ts → Widget/Widget.type.d.ts} +4 -5
  131. package/dist/lib.cjs/types/ui/components/Widget/index.d.ts +1 -0
  132. package/dist/lib.cjs/types/ui/config.d.ts +4 -1
  133. package/dist/lib.cjs/types/ui/constants.d.ts +13 -0
  134. package/dist/lib.cjs/types/ui/context/RootContext.d.ts +18 -0
  135. package/dist/lib.cjs/types/ui/handlers/AbstractHandler.d.ts +20 -0
  136. package/dist/lib.cjs/types/ui/handlers/EmailPasswordlessHandler.d.ts +8 -0
  137. package/dist/lib.cjs/types/ui/handlers/SmsPasswordlessHandler.d.ts +9 -0
  138. package/dist/lib.cjs/types/ui/handlers/factory.d.ts +5 -0
  139. package/dist/lib.cjs/types/ui/interfaces.d.ts +115 -14
  140. package/dist/lib.cjs/types/ui/loginModal.d.ts +9 -7
  141. package/dist/lib.cjs/types/ui/utils.d.ts +17 -2
  142. package/dist/lib.esm/node_modules/style-inject/dist/style-inject.es.js +1 -1
  143. package/dist/lib.esm/packages/modal/src/modalManager.js +191 -138
  144. package/dist/lib.esm/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +58 -0
  145. package/dist/lib.esm/packages/modal/src/ui/components/Button/Button.js +48 -24
  146. package/dist/lib.esm/packages/modal/src/ui/components/Button/Button.type.js +6 -0
  147. package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonSocial/ButtonSocial.js +51 -0
  148. package/dist/lib.esm/packages/modal/src/ui/components/Button/ButtonWallet/ButtonWallet.js +66 -0
  149. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +200 -0
  150. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +60 -0
  151. package/dist/lib.esm/packages/modal/src/ui/components/{ExternalWallet/ExternalWalletChainNamespace.js → ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js} +28 -31
  152. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletHeader/ConnectWalletHeader.js +47 -0
  153. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.js +138 -0
  154. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +91 -0
  155. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletSearch/ConnectWalletSearch.js +56 -0
  156. package/dist/lib.esm/packages/modal/src/ui/components/Embed/Embed.js +68 -0
  157. package/dist/lib.esm/packages/modal/src/ui/components/Footer/Footer.js +51 -0
  158. package/dist/lib.esm/packages/modal/src/ui/components/Image/Image.js +87 -0
  159. package/dist/lib.esm/packages/modal/src/ui/components/Loader/Loader.js +152 -0
  160. package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +489 -0
  161. package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginOtp/LoginOtp.js +115 -0
  162. package/dist/lib.esm/packages/modal/src/ui/components/Login/LoginPasswordLess/LoginPasswordLess.js +115 -0
  163. package/dist/lib.esm/packages/modal/src/ui/components/LoginHint/LoginHint.js +50 -0
  164. package/dist/lib.esm/packages/modal/src/ui/components/Modal/Modal.js +85 -0
  165. package/dist/lib.esm/packages/modal/src/ui/components/Otp/Otp.js +188 -0
  166. package/dist/lib.esm/packages/modal/src/ui/components/PulseLoader/PulseLoader.js +16 -0
  167. package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +462 -0
  168. package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginList/SocialLoginList.js +154 -0
  169. package/dist/lib.esm/packages/modal/src/ui/components/Toast/Toast.js +68 -0
  170. package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +231 -0
  171. package/dist/lib.esm/packages/modal/src/ui/config.js +10 -3
  172. package/dist/lib.esm/packages/modal/src/ui/constants.js +13 -0
  173. package/dist/lib.esm/packages/modal/src/ui/context/RootContext.js +18 -0
  174. package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +6 -0
  175. package/dist/lib.esm/packages/modal/src/ui/handlers/AbstractHandler.js +115 -0
  176. package/dist/lib.esm/packages/modal/src/ui/handlers/EmailPasswordlessHandler.js +52 -0
  177. package/dist/lib.esm/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +55 -0
  178. package/dist/lib.esm/packages/modal/src/ui/handlers/factory.js +17 -0
  179. package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +37 -3
  180. package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +37 -3
  181. package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +37 -3
  182. package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +37 -3
  183. package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +37 -3
  184. package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +37 -3
  185. package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +37 -3
  186. package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +37 -3
  187. package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +37 -3
  188. package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +37 -3
  189. package/dist/lib.esm/packages/modal/src/ui/interfaces.js +8 -9
  190. package/dist/lib.esm/packages/modal/src/ui/loginModal.js +70 -45
  191. package/dist/lib.esm/packages/modal/src/ui/utils.js +105 -3
  192. package/dist/modal.umd.min.js +1 -1
  193. package/dist/modal.umd.min.js.LICENSE.txt +8 -8
  194. package/package.json +14 -11
  195. package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-dark.svg.js +0 -7
  196. package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-light.svg.js +0 -7
  197. package/dist/lib.cjs/packages/modal/src/ui/assets/x-dark.svg.js +0 -7
  198. package/dist/lib.cjs/packages/modal/src/ui/assets/x-light.svg.js +0 -7
  199. package/dist/lib.cjs/packages/modal/src/ui/components/AdapterLoader.js +0 -108
  200. package/dist/lib.cjs/packages/modal/src/ui/components/Button/styles.css.js +0 -8
  201. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +0 -44
  202. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +0 -67
  203. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +0 -43
  204. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +0 -46
  205. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +0 -167
  206. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +0 -279
  207. package/dist/lib.cjs/packages/modal/src/ui/components/Footer.js +0 -20
  208. package/dist/lib.cjs/packages/modal/src/ui/components/Header.js +0 -81
  209. package/dist/lib.cjs/packages/modal/src/ui/components/Icon.js +0 -73
  210. package/dist/lib.cjs/packages/modal/src/ui/components/Image.js +0 -51
  211. package/dist/lib.cjs/packages/modal/src/ui/components/Loader.js +0 -59
  212. package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +0 -278
  213. package/dist/lib.cjs/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +0 -30
  214. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +0 -150
  215. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +0 -153
  216. package/dist/lib.cjs/packages/modal/src/ui/components/WalletConnect.js +0 -84
  217. package/dist/lib.cjs/packages/modal/src/ui/css/web3auth.css.js +0 -8
  218. package/dist/lib.cjs/types/ui/components/AdapterLoader.d.ts +0 -11
  219. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletButton.d.ts +0 -7
  220. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletChainNamespace.d.ts +0 -9
  221. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletConnect.d.ts +0 -9
  222. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletDetails.d.ts +0 -10
  223. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletHeader.d.ts +0 -8
  224. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletInstall.d.ts +0 -8
  225. package/dist/lib.cjs/types/ui/components/ExternalWallets.d.ts +0 -15
  226. package/dist/lib.cjs/types/ui/components/Footer.d.ts +0 -1
  227. package/dist/lib.cjs/types/ui/components/Header.d.ts +0 -8
  228. package/dist/lib.cjs/types/ui/components/Icon.d.ts +0 -9
  229. package/dist/lib.cjs/types/ui/components/Loader.d.ts +0 -10
  230. package/dist/lib.cjs/types/ui/components/SelfCustodyViaWeb3Auth.d.ts +0 -1
  231. package/dist/lib.cjs/types/ui/components/SocialLoginPasswordless.d.ts +0 -14
  232. package/dist/lib.cjs/types/ui/components/SocialLogins.d.ts +0 -10
  233. package/dist/lib.cjs/types/ui/components/WalletConnect.d.ts +0 -8
  234. package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-dark.svg.js +0 -5
  235. package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-light.svg.js +0 -5
  236. package/dist/lib.esm/packages/modal/src/ui/assets/x-dark.svg.js +0 -5
  237. package/dist/lib.esm/packages/modal/src/ui/assets/x-light.svg.js +0 -5
  238. package/dist/lib.esm/packages/modal/src/ui/components/AdapterLoader.js +0 -106
  239. package/dist/lib.esm/packages/modal/src/ui/components/Button/styles.css.js +0 -6
  240. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +0 -42
  241. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +0 -65
  242. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +0 -44
  243. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +0 -44
  244. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +0 -165
  245. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +0 -281
  246. package/dist/lib.esm/packages/modal/src/ui/components/Footer.js +0 -18
  247. package/dist/lib.esm/packages/modal/src/ui/components/Header.js +0 -79
  248. package/dist/lib.esm/packages/modal/src/ui/components/Icon.js +0 -71
  249. package/dist/lib.esm/packages/modal/src/ui/components/Image.js +0 -49
  250. package/dist/lib.esm/packages/modal/src/ui/components/Loader.js +0 -57
  251. package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +0 -277
  252. package/dist/lib.esm/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +0 -28
  253. package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +0 -148
  254. package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +0 -152
  255. package/dist/lib.esm/packages/modal/src/ui/components/WalletConnect.js +0 -82
  256. package/dist/lib.esm/packages/modal/src/ui/css/web3auth.css.js +0 -6
@@ -0,0 +1,489 @@
1
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
+ import HCaptcha from '@hcaptcha/react-hcaptcha';
3
+ import { AUTH_CONNECTION } from '@web3auth/auth';
4
+ import { WALLET_CONNECTORS, log, WalletLoginError } from '@web3auth/no-modal';
5
+ import { useContext, useState, useRef, useEffect, useMemo } from 'react';
6
+ import { useTranslation } from 'react-i18next';
7
+ import { capitalizeFirstLetter, CAPTCHA_SITE_KEY } from '../../config.js';
8
+ import { DEFAULT_LOGO_DARK, DEFAULT_LOGO_LIGHT } from '../../constants.js';
9
+ import { RootContext } from '../../context/RootContext.js';
10
+ import { createPasswordlessHandler } from '../../handlers/factory.js';
11
+ import i18nInstance from '../../localeImport.js';
12
+ import { cn, getIcons, getUserCountry, validatePhoneNumber } from '../../utils.js';
13
+ import Image from '../Image/Image.js';
14
+ import SocialLoginList from '../SocialLoginList/SocialLoginList.js';
15
+ import LoginOtp from './LoginOtp/LoginOtp.js';
16
+ import LoginPasswordLess from './LoginPasswordLess/LoginPasswordLess.js';
17
+ import { jsx, jsxs } from 'react/jsx-runtime';
18
+
19
+ const restrictedLoginMethods = [AUTH_CONNECTION.SMS_PASSWORDLESS, AUTH_CONNECTION.EMAIL_PASSWORDLESS, AUTH_CONNECTION.AUTHENTICATOR, AUTH_CONNECTION.PASSKEYS, AUTH_CONNECTION.TELEGRAM, AUTH_CONNECTION.CUSTOM];
20
+ function Login(props) {
21
+ // TODO: add appName, isEmailPrimary, isExternalPrimary
22
+ const {
23
+ web3authClientId,
24
+ web3authNetwork,
25
+ appLogo,
26
+ isModalVisible,
27
+ handleSocialLoginHeight,
28
+ socialLoginsConfig,
29
+ installedExternalWalletConfig,
30
+ isDark,
31
+ handleSocialLoginClick,
32
+ totalExternalWallets,
33
+ isEmailPasswordLessLoginVisible,
34
+ isSmsPasswordLessLoginVisible,
35
+ handleExternalWalletBtnClick,
36
+ handleExternalWalletClick,
37
+ areSocialLoginsVisible,
38
+ showPasswordLessInput,
39
+ showExternalWalletButton,
40
+ showExternalWalletCount,
41
+ showInstalledExternalWallets,
42
+ logoAlignment = "center",
43
+ buttonRadius = "pill",
44
+ enableMainSocialLoginButton = false
45
+ } = props;
46
+ const [t] = useTranslation(undefined, {
47
+ i18n: i18nInstance
48
+ });
49
+ const {
50
+ bodyState,
51
+ setBodyState
52
+ } = useContext(RootContext);
53
+ const [countryCode, setCountryCode] = useState("");
54
+ const [passwordlessErrorMessage, setPasswordlessErrorMessage] = useState("");
55
+ const [otpErrorMessage, setOtpErrorMessage] = useState("");
56
+ const [expand, setExpand] = useState(false);
57
+ const [canShowMore, setCanShowMore] = useState(false);
58
+ const [visibleRow, setVisibleRow] = useState([]);
59
+ const [otherRow, setOtherRow] = useState([]);
60
+ const [isPasswordLessCtaClicked, setIsPasswordLessCtaClicked] = useState(false);
61
+ const [showOtpFlow, setShowOtpFlow] = useState(false);
62
+ const [authConnection, setAuthConnection] = useState(undefined);
63
+ const [passwordlessHandler, setPasswordlessHandler] = useState(undefined);
64
+ const [isPasswordLessLoading, setIsPasswordLessLoading] = useState(false);
65
+ const [otpLoading, setOtpLoading] = useState(false);
66
+ const [showCaptcha, setShowCaptcha] = useState(false);
67
+ const [captchaError, setCaptchaError] = useState("");
68
+ const captchaRef = useRef(null);
69
+ const handleExpand = () => {
70
+ setExpand(prev => !prev);
71
+ setIsPasswordLessCtaClicked(false);
72
+ handleSocialLoginHeight();
73
+ };
74
+ useEffect(() => {
75
+ const maxOptions = Object.keys(socialLoginsConfig.loginMethods).filter(loginMethodKey => {
76
+ return socialLoginsConfig.loginMethods[loginMethodKey].showOnModal;
77
+ });
78
+ const visibleRows = [];
79
+ const otherRows = [];
80
+ const loginOptions = Object.keys(socialLoginsConfig.loginMethods).filter(method => {
81
+ return !socialLoginsConfig.loginMethods[method].showOnModal === false && !restrictedLoginMethods.includes(method);
82
+ });
83
+ loginOptions.forEach((method, index) => {
84
+ var _socialLoginsConfig$u;
85
+ const connectorConfig = socialLoginsConfig.loginMethods[method];
86
+ const name = capitalizeFirstLetter(connectorConfig.name || method);
87
+ // const orderIndex = socialLoginsConfig.loginMethodsOrder.indexOf(method) + 1;
88
+ const order = index + 1;
89
+ const isMainOption = order === 1 && enableMainSocialLoginButton;
90
+ const isPrimaryBtn = (socialLoginsConfig === null || socialLoginsConfig === void 0 || (_socialLoginsConfig$u = socialLoginsConfig.uiConfig) === null || _socialLoginsConfig$u === void 0 ? void 0 : _socialLoginsConfig$u.primaryButton) === "socialLogin" && order === 1;
91
+ const loginOptionLength = loginOptions.length;
92
+ const moreThanFour = loginOptionLength >= 4;
93
+ const lengthCheck = moreThanFour ? order > 0 && order <= loginOptionLength : order > 0 && order < 4;
94
+ if (lengthCheck) {
95
+ visibleRows.push({
96
+ method,
97
+ isDark,
98
+ isPrimaryBtn,
99
+ name,
100
+ connector: socialLoginsConfig.connector,
101
+ loginParams: {
102
+ authConnection: connectorConfig.authConnection || method,
103
+ authConnectionId: connectorConfig.authConnectionId,
104
+ groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
105
+ extraLoginOptions: connectorConfig.extraLoginOptions,
106
+ name,
107
+ login_hint: ""
108
+ },
109
+ order,
110
+ isMainOption
111
+ });
112
+ }
113
+ otherRows.push({
114
+ method,
115
+ isDark,
116
+ isPrimaryBtn,
117
+ name: name === "Twitter" ? "X" : name,
118
+ connector: socialLoginsConfig.connector,
119
+ loginParams: {
120
+ authConnection: method,
121
+ authConnectionId: connectorConfig.authConnectionId,
122
+ groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
123
+ extraLoginOptions: connectorConfig.extraLoginOptions,
124
+ name,
125
+ login_hint: ""
126
+ },
127
+ order,
128
+ isMainOption
129
+ });
130
+ });
131
+ setVisibleRow(visibleRows);
132
+ setOtherRow(otherRows);
133
+ setCanShowMore(maxOptions.length > 4); // Update the state based on the condition
134
+ }, [socialLoginsConfig, isDark, enableMainSocialLoginButton, buttonRadius]);
135
+ const handleCustomLogin = async (authConnection, loginHint) => {
136
+ try {
137
+ const handler = createPasswordlessHandler(authConnection, {
138
+ loginHint,
139
+ web3authClientId,
140
+ network: web3authNetwork,
141
+ uiConfig: socialLoginsConfig.uiConfig,
142
+ authConnection
143
+ });
144
+ let token = "";
145
+ if (authConnection === AUTH_CONNECTION.SMS_PASSWORDLESS) {
146
+ var _captchaRef$current;
147
+ const res = await ((_captchaRef$current = captchaRef.current) === null || _captchaRef$current === void 0 ? void 0 : _captchaRef$current.execute({
148
+ async: true
149
+ }));
150
+ if (!res) {
151
+ throw WalletLoginError.connectionError("Captcha token is required");
152
+ }
153
+ token = res.response;
154
+ }
155
+ const result = await handler.sendVerificationCode({
156
+ captchaToken: token
157
+ });
158
+ if (result !== null && result !== void 0 && result.error) {
159
+ setPasswordlessErrorMessage(t(result.error));
160
+ return;
161
+ }
162
+ setAuthConnection(authConnection);
163
+ setShowOtpFlow(true);
164
+ setPasswordlessHandler(handler);
165
+ } catch (error) {
166
+ log.error(error);
167
+ } finally {
168
+ setIsPasswordLessLoading(false);
169
+ }
170
+ };
171
+ const handleFormSubmit = async loginHint => {
172
+ setIsPasswordLessLoading(true);
173
+ if (isEmailPasswordLessLoginVisible) {
174
+ const isEmailValid = loginHint.match(/^([\w.%+-]+)@([\w-]+\.)+([\w]{2,})$/i);
175
+ if (isEmailValid) {
176
+ const connectorConfig = socialLoginsConfig.loginMethods[AUTH_CONNECTION.EMAIL_PASSWORDLESS];
177
+ if (connectorConfig.isDefault) {
178
+ return handleSocialLoginClick({
179
+ connector: socialLoginsConfig.connector || "",
180
+ loginParams: {
181
+ authConnection: AUTH_CONNECTION.EMAIL_PASSWORDLESS,
182
+ authConnectionId: connectorConfig.authConnectionId,
183
+ groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
184
+ extraLoginOptions: connectorConfig.extraLoginOptions,
185
+ login_hint: loginHint,
186
+ name: "Email"
187
+ }
188
+ });
189
+ } else {
190
+ return handleCustomLogin(AUTH_CONNECTION.EMAIL_PASSWORDLESS, loginHint);
191
+ }
192
+ }
193
+ }
194
+ if (isSmsPasswordLessLoginVisible) {
195
+ const number = loginHint.startsWith("+") ? loginHint : `${countryCode}${loginHint}`;
196
+ const result = await validatePhoneNumber(number);
197
+ if (result) {
198
+ const finalLoginHint = typeof result === "string" ? result : number;
199
+ const connectorConfig = socialLoginsConfig.loginMethods[AUTH_CONNECTION.SMS_PASSWORDLESS];
200
+ if (connectorConfig.isDefault) {
201
+ return handleSocialLoginClick({
202
+ connector: socialLoginsConfig.connector || "",
203
+ loginParams: {
204
+ authConnection: AUTH_CONNECTION.SMS_PASSWORDLESS,
205
+ authConnectionId: connectorConfig.authConnectionId,
206
+ groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
207
+ extraLoginOptions: connectorConfig.extraLoginOptions,
208
+ login_hint: finalLoginHint,
209
+ name: "Mobile"
210
+ }
211
+ });
212
+ } else {
213
+ return handleCustomLogin(AUTH_CONNECTION.SMS_PASSWORDLESS, finalLoginHint);
214
+ }
215
+ }
216
+ }
217
+ setPasswordlessErrorMessage(invalidInputErrorMessage);
218
+ setIsPasswordLessLoading(false);
219
+ return undefined;
220
+ };
221
+ const title = useMemo(() => {
222
+ if (isEmailPasswordLessLoginVisible && isSmsPasswordLessLoginVisible) return t("modal.social.passwordless-title");
223
+ if (isEmailPasswordLessLoginVisible) return t("modal.social.email");
224
+ return t("modal.social.phone");
225
+ }, [isEmailPasswordLessLoginVisible, isSmsPasswordLessLoginVisible, t]);
226
+ const placeholder = useMemo(() => {
227
+ if (isEmailPasswordLessLoginVisible && isSmsPasswordLessLoginVisible) return "+(00)123456/name@example.com";
228
+ if (isEmailPasswordLessLoginVisible) return "name@example.com";
229
+ return "+(00)123456";
230
+ }, [isEmailPasswordLessLoginVisible, isSmsPasswordLessLoginVisible]);
231
+ const invalidInputErrorMessage = useMemo(() => {
232
+ if (isEmailPasswordLessLoginVisible && isSmsPasswordLessLoginVisible) return t("modal.errors-invalid-number-email");
233
+ if (isEmailPasswordLessLoginVisible) return t("modal.errors-invalid-email");
234
+ return t("modal.errors-invalid-number");
235
+ }, [isEmailPasswordLessLoginVisible, isSmsPasswordLessLoginVisible, t]);
236
+ useEffect(() => {
237
+ const getLocation = async () => {
238
+ const result = await getUserCountry();
239
+ if (result && result.dialCode) {
240
+ setCountryCode(result.dialCode);
241
+ }
242
+ };
243
+ if (isSmsPasswordLessLoginVisible) getLocation();
244
+ }, [isSmsPasswordLessLoginVisible]);
245
+ const handleConnectWallet = e => {
246
+ setIsPasswordLessCtaClicked(false);
247
+ e.preventDefault();
248
+ if (handleExternalWalletBtnClick) handleExternalWalletBtnClick(true);
249
+ };
250
+ const handleOtpComplete = async otp => {
251
+ setOtpLoading(true);
252
+ if (otpErrorMessage) setOtpErrorMessage("");
253
+ try {
254
+ var _result$data;
255
+ const connectorConfig = socialLoginsConfig.loginMethods[authConnection];
256
+ const result = await (passwordlessHandler === null || passwordlessHandler === void 0 ? void 0 : passwordlessHandler.verifyCode(otp));
257
+ if (result !== null && result !== void 0 && result.error) {
258
+ setOtpErrorMessage(t(result.error));
259
+ return;
260
+ }
261
+ if (result !== null && result !== void 0 && (_result$data = result.data) !== null && _result$data !== void 0 && _result$data.id_token) {
262
+ var _result$data2;
263
+ return handleSocialLoginClick({
264
+ connector: socialLoginsConfig.connector || "",
265
+ loginParams: {
266
+ authConnection: authConnection,
267
+ authConnectionId: connectorConfig.authConnectionId,
268
+ groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
269
+ extraLoginOptions: _objectSpread(_objectSpread({}, connectorConfig.extraLoginOptions), {}, {
270
+ id_token: (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id_token
271
+ }),
272
+ login_hint: passwordlessHandler.passwordlessParams.loginHint,
273
+ name: passwordlessHandler.name
274
+ }
275
+ });
276
+ }
277
+ } catch (error) {
278
+ log.error(error);
279
+ } finally {
280
+ setOtpLoading(false);
281
+ }
282
+ };
283
+ const handleInstalledWalletClick = wallet => {
284
+ var _wallet$chainNamespac;
285
+ // when having multiple namespaces, ask user to select one
286
+ if (((_wallet$chainNamespac = wallet.chainNamespaces) === null || _wallet$chainNamespac === void 0 ? void 0 : _wallet$chainNamespac.length) > 1) {
287
+ setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
288
+ showMultiChainSelector: true,
289
+ walletDetails: wallet
290
+ }));
291
+ } else {
292
+ handleExternalWalletClick({
293
+ connector: wallet.name
294
+ });
295
+ }
296
+ };
297
+ const installedExternalWallets = useMemo(() => {
298
+ if (showInstalledExternalWallets) return installedExternalWalletConfig;
299
+ // always show MetaMask
300
+ return installedExternalWalletConfig.filter(wallet => wallet.name === WALLET_CONNECTORS.METAMASK);
301
+ }, [installedExternalWalletConfig, showInstalledExternalWallets]);
302
+ if (showOtpFlow) {
303
+ return /*#__PURE__*/jsx(LoginOtp, {
304
+ otpLoading: otpLoading,
305
+ loginHint: passwordlessHandler === null || passwordlessHandler === void 0 ? void 0 : passwordlessHandler.passwordlessParams.loginHint,
306
+ setShowOtpFlow: setShowOtpFlow,
307
+ authConnection: authConnection,
308
+ handleOtpComplete: handleOtpComplete,
309
+ errorMessage: otpErrorMessage
310
+ });
311
+ }
312
+ const socialLoginSection = (otherRow = []) => {
313
+ return /*#__PURE__*/jsx(SocialLoginList, {
314
+ otherRow: otherRow,
315
+ isDark: isDark,
316
+ visibleRow: visibleRow,
317
+ canShowMore: canShowMore,
318
+ handleSocialLoginClick: handleSocialLoginClick,
319
+ socialLoginsConfig: socialLoginsConfig,
320
+ handleExpandSocialLogins: handleExpand,
321
+ buttonRadius: buttonRadius
322
+ }, "social-login-section");
323
+ };
324
+ const passwordlessLoginSection = () => {
325
+ return /*#__PURE__*/jsx(LoginPasswordLess, {
326
+ isModalVisible: isModalVisible,
327
+ isPasswordLessCtaClicked: isPasswordLessCtaClicked,
328
+ setIsPasswordLessCtaClicked: setIsPasswordLessCtaClicked,
329
+ title: title,
330
+ placeholder: placeholder,
331
+ handleFormSubmit: handleFormSubmit,
332
+ errorMessage: passwordlessErrorMessage,
333
+ isDark: isDark,
334
+ buttonRadius: buttonRadius,
335
+ isPasswordLessLoading: isPasswordLessLoading
336
+ }, "passwordless-section");
337
+ };
338
+ const externalWalletSection = () => {
339
+ return /*#__PURE__*/jsxs("div", {
340
+ className: cn("w3a--flex w3a--w-full w3a--flex-col w3a--items-start w3a--justify-start w3a--gap-y-2"),
341
+ children: [installedExternalWallets.length > 0 && installedExternalWallets.map(wallet => /*#__PURE__*/jsxs("button", {
342
+ type: "button",
343
+ className: cn("w3a--btn !w3a--justify-between w3a-external-wallet-btn", {
344
+ "w3a--rounded-full": buttonRadius === "pill",
345
+ "w3a--rounded-lg": buttonRadius === "rounded",
346
+ "w3a--rounded-none": buttonRadius === "square"
347
+ }),
348
+ onClick: () => handleInstalledWalletClick(wallet),
349
+ children: [/*#__PURE__*/jsx("p", {
350
+ className: "w3a--text-base w3a--font-normal w3a--text-app-gray-700 dark:w3a--text-app-white",
351
+ children: wallet.displayName
352
+ }), /*#__PURE__*/jsxs("div", {
353
+ className: "w3a--flex w3a--items-center w3a--gap-x-2",
354
+ children: [wallet.hasInjectedWallet && /*#__PURE__*/jsx("span", {
355
+ className: "w3a--inline-flex w3a--items-center w3a--rounded-md w3a--bg-app-primary-100 w3a--px-2 w3a--py-1 w3a--text-xs w3a--font-medium w3a--text-app-primary-800 dark:w3a--border dark:w3a--border-app-primary-400 dark:w3a--bg-transparent dark:w3a--text-app-primary-400",
356
+ children: t("modal.external.installed")
357
+ }), /*#__PURE__*/jsx("figure", {
358
+ className: wallet.icon ? "w3a--size-5" : "w3a--size-5 w3a--rounded-full w3a--bg-app-gray-300",
359
+ children: /*#__PURE__*/jsx(Image, {
360
+ imageData: wallet.icon,
361
+ imageId: `login-${wallet.name}`,
362
+ hoverImageId: `login-${wallet.name}`,
363
+ fallbackImageId: "wallet",
364
+ height: "24",
365
+ width: "24",
366
+ isButton: true,
367
+ extension: wallet.imgExtension || "webp"
368
+ })
369
+ })]
370
+ })]
371
+ }, wallet.name)), totalExternalWallets > 3 && /*#__PURE__*/jsxs("button", {
372
+ type: "button",
373
+ className: cn("w3a--btn !w3a--justify-between w3a-external-wallet-btn", {
374
+ "w3a--rounded-full": buttonRadius === "pill",
375
+ "w3a--rounded-lg": buttonRadius === "rounded",
376
+ "w3a--rounded-none": buttonRadius === "square"
377
+ }),
378
+ onClick: handleConnectWallet,
379
+ children: [/*#__PURE__*/jsx("p", {
380
+ className: "w3a--text-app-gray-900 dark:w3a--text-app-white",
381
+ children: t("modal.external.all-wallets")
382
+ }), showExternalWalletCount && totalExternalWallets > 0 && /*#__PURE__*/jsx("div", {
383
+ id: "external-wallet-count",
384
+ className: "w3a--w-auto w3a--rounded-full w3a--bg-app-primary-100 w3a--px-2.5 w3a--py-0.5 w3a--text-xs w3a--font-medium w3a--text-app-primary-800 dark:w3a--border dark:w3a--border-app-primary-500 dark:w3a--bg-transparent dark:w3a--text-app-primary-500",
385
+ children: totalExternalWallets - 1
386
+ }), /*#__PURE__*/jsx("img", {
387
+ id: "external-wallet-arrow",
388
+ className: "w3a--icon-animation",
389
+ src: getIcons(isDark ? "chevron-right-dark" : "chevron-right-light"),
390
+ alt: "arrow"
391
+ })]
392
+ })]
393
+ }, "external-wallets-section");
394
+ };
395
+ const delimiter = index => {
396
+ return /*#__PURE__*/jsxs("div", {
397
+ className: "w3a--flex w3a--w-full w3a--items-center w3a--gap-x-2",
398
+ children: [/*#__PURE__*/jsx("div", {
399
+ className: "w3a--h-px w3a--w-full w3a--bg-app-gray-200 dark:w3a--bg-app-gray-500"
400
+ }), /*#__PURE__*/jsx("p", {
401
+ className: "w3a--text-xs w3a--font-normal w3a--uppercase w3a--text-app-gray-400 dark:w3a--text-app-gray-400",
402
+ children: "or"
403
+ }), /*#__PURE__*/jsx("div", {
404
+ className: "w3a--h-px w3a--w-full w3a--bg-app-gray-200 dark:w3a--bg-app-gray-500"
405
+ })]
406
+ }, `section-delimiter-${index}`);
407
+ };
408
+ const defaultView = () => {
409
+ var _socialLoginsConfig$u2;
410
+ const sectionMap = {
411
+ social: socialLoginSection,
412
+ passwordless: passwordlessLoginSection,
413
+ externalWallets: externalWalletSection
414
+ };
415
+ const sectionVisibility = {
416
+ social: areSocialLoginsVisible,
417
+ passwordless: showPasswordLessInput,
418
+ externalWallets: showExternalWalletButton
419
+ };
420
+ const signInMethods = ((_socialLoginsConfig$u2 = socialLoginsConfig.uiConfig) === null || _socialLoginsConfig$u2 === void 0 ? void 0 : _socialLoginsConfig$u2.signInMethods) || ["social", "passwordless", "externalWallets"];
421
+
422
+ // add missing signInMethods in case uiConfig.signInMethods is not set correctly
423
+ Object.entries(sectionVisibility).forEach(([method, visibility]) => {
424
+ if (visibility && !signInMethods.includes(method)) {
425
+ signInMethods.push(method);
426
+ }
427
+ });
428
+ const sections = signInMethods.map(method => sectionVisibility[method] && sectionMap[method]()).filter(Boolean);
429
+
430
+ // add delimiter between external wallets and other sections
431
+ if (sections.length === 3) {
432
+ const externalWalletIndex = signInMethods.findIndex(section => section === "externalWallets");
433
+ if (externalWalletIndex === 0) {
434
+ // add after it
435
+ sections.splice(1, 0, delimiter(1));
436
+ } else if (externalWalletIndex === 1) {
437
+ // add before it
438
+ sections.splice(1, 0, delimiter(1));
439
+ // add after it
440
+ sections.splice(3, 0, delimiter(2));
441
+ } else if (externalWalletIndex === 2) {
442
+ // add before it
443
+ sections.splice(2, 0, delimiter(1));
444
+ }
445
+ } else if (sections.length === 2) {
446
+ if (sectionVisibility["externalWallets"]) {
447
+ sections.splice(1, 0, delimiter(1));
448
+ }
449
+ }
450
+ return sections;
451
+ };
452
+ const expandedView = () => socialLoginSection(otherRow);
453
+ const headerLogo = [DEFAULT_LOGO_DARK, DEFAULT_LOGO_LIGHT].includes(appLogo) ? "" : appLogo;
454
+ return /*#__PURE__*/jsxs("div", {
455
+ className: "w3a--flex w3a--flex-col w3a--items-center w3a--gap-y-4 w3a--p-2",
456
+ children: [/*#__PURE__*/jsxs("div", {
457
+ className: cn("w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2 w3a--pt-6", logoAlignment === "center" ? "" : "w3a--w-full"),
458
+ children: [/*#__PURE__*/jsx("figure", {
459
+ className: cn("w3a--mx-auto w3a--h-12 w3a--w-[200px]", logoAlignment === "center" ? "w3a--flex w3a--justify-center w3a--items-center" : "w3a--ml-0"),
460
+ children: /*#__PURE__*/jsx("img", {
461
+ src: headerLogo || getIcons(isDark ? "logo-dark" : "logo-light"),
462
+ alt: "Logo",
463
+ className: "w3a--object-contain"
464
+ })
465
+ }), /*#__PURE__*/jsx("p", {
466
+ className: cn("w3a--text-lg w3a--font-semibold w3a--text-app-gray-900 dark:w3a--text-app-white", logoAlignment === "center" ? "w3a--text-center" : "w3a--text-left w3a--w-full w3a--ml-4"),
467
+ children: t("modal.social.sign-in")
468
+ })]
469
+ }), /*#__PURE__*/jsx(HCaptcha, {
470
+ ref: captchaRef,
471
+ sitekey: CAPTCHA_SITE_KEY,
472
+ size: "invisible",
473
+ languageOverride: socialLoginsConfig.uiConfig.defaultLanguage,
474
+ theme: socialLoginsConfig.uiConfig.theme,
475
+ onOpen: () => setShowCaptcha(true),
476
+ onClose: () => setShowCaptcha(false),
477
+ onError: () => setCaptchaError("passwordless.captcha-default-error"),
478
+ onChalExpired: () => setCaptchaError("passwordless.captcha-default-error")
479
+ }), captchaError && showCaptcha && /*#__PURE__*/jsx("p", {
480
+ className: "-w3a--mt-2 w3a--w-full w3a--pl-6 w3a--text-start w3a--text-xs w3a--font-normal w3a--text-app-red-500 dark:w3a--text-app-red-400",
481
+ children: t(captchaError)
482
+ }), !showCaptcha && /*#__PURE__*/jsxs("div", {
483
+ className: "w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
484
+ children: [!expand && defaultView(), expand && expandedView()]
485
+ })]
486
+ });
487
+ }
488
+
489
+ export { Login as default };
@@ -0,0 +1,115 @@
1
+ import { AUTH_CONNECTION } from '@web3auth/auth';
2
+ import { useMemo } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import i18nInstance from '../../../localeImport.js';
5
+ import { getIcons } from '../../../utils.js';
6
+ import OtpInput$1 from '../../Otp/Otp.js';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
+
9
+ /**
10
+ * OtpInput component
11
+ * @param props - OtpInputProps
12
+ * @returns OtpInput component
13
+ */
14
+ function OtpInput(props) {
15
+ const {
16
+ setShowOtpFlow,
17
+ handleOtpComplete,
18
+ authConnection,
19
+ loginHint = "",
20
+ errorMessage,
21
+ otpLoading
22
+ } = props;
23
+ const isMobileOtp = useMemo(() => authConnection === AUTH_CONNECTION.SMS_PASSWORDLESS, [authConnection]);
24
+ const [t] = useTranslation(undefined, {
25
+ i18n: i18nInstance
26
+ });
27
+ const parsedLoginHint = useMemo(() => {
28
+ if (authConnection === AUTH_CONNECTION.EMAIL_PASSWORDLESS) return loginHint;
29
+ const [countryCode, number] = loginHint.includes("-") ? loginHint.split("-") : ["", loginHint];
30
+ const masked = `${number}`.slice(-Math.floor(number.length / 2)).padStart(`${number}`.length, "*");
31
+ return `${countryCode} ${masked}`;
32
+ }, [loginHint, authConnection]);
33
+ return /*#__PURE__*/jsxs(Fragment, {
34
+ children: [/*#__PURE__*/jsx("div", {
35
+ className: "w3a--mr-auto w3a--flex w3a--w-full w3a--items-start w3a--justify-start",
36
+ children: /*#__PURE__*/jsx("button", {
37
+ type: "button",
38
+ className: "w3a--z-20 w3a--flex w3a--size-5 w3a--cursor-pointer w3a--items-center w3a--justify-center w3a--rounded-full",
39
+ onClick: () => setShowOtpFlow(false),
40
+ children: /*#__PURE__*/jsx("svg", {
41
+ xmlns: "http://www.w3.org/2000/svg",
42
+ fill: "none",
43
+ viewBox: "0 0 20 20",
44
+ className: "w3a--text-app-gray-900 dark:w3a--text-app-white",
45
+ children: /*#__PURE__*/jsx("path", {
46
+ fill: "currentColor",
47
+ fillRule: "evenodd",
48
+ d: "M9.707 16.707a1 1 0 0 1-1.414 0l-6-6a1 1 0 0 1 0-1.414l6-6a1 1 0 0 1 1.414 1.414L5.414 9H17a1 1 0 1 1 0 2H5.414l4.293 4.293a1 1 0 0 1 0 1.414",
49
+ clipRule: "evenodd"
50
+ })
51
+ })
52
+ })
53
+ }), /*#__PURE__*/jsxs("div", {
54
+ className: "-w3a--mt-10 w3a--flex w3a--size-full w3a--flex-1 w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4",
55
+ children: [/*#__PURE__*/jsx("img", {
56
+ src: getIcons(isMobileOtp ? "sms-otp-light" : "email-otp-light"),
57
+ alt: "otp",
58
+ className: "w3a--size-auto"
59
+ }), /*#__PURE__*/jsxs("div", {
60
+ className: "-w3a--mt-6 w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
61
+ children: [/*#__PURE__*/jsx("p", {
62
+ className: "w3a--text-lg w3a--font-bold w3a--text-app-gray-900 dark:w3a--text-app-white",
63
+ children: isMobileOtp ? t("modal.otp.mobile-title") : t("modal.otp.email-title")
64
+ }), /*#__PURE__*/jsxs("div", {
65
+ className: "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-1",
66
+ children: [/*#__PURE__*/jsx("p", {
67
+ className: "w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
68
+ children: isMobileOtp ? t("modal.otp.mobile-subtext") : t("modal.otp.email-subtext")
69
+ }), /*#__PURE__*/jsx("p", {
70
+ className: "w3a--text-sm w3a--font-normal w3a--text-app-gray-500 dark:w3a--text-app-gray-300",
71
+ children: isMobileOtp ? parsedLoginHint : t("modal.otp.email-subtext-example", {
72
+ email: parsedLoginHint
73
+ })
74
+ })]
75
+ })]
76
+ }), /*#__PURE__*/jsx(OtpInput$1, {
77
+ length: 6,
78
+ onComplete: handleOtpComplete,
79
+ error: Boolean(errorMessage),
80
+ helperText: errorMessage,
81
+ loading: otpLoading,
82
+ disabled: otpLoading
83
+ })]
84
+ })]
85
+ });
86
+ }
87
+
88
+ /**
89
+ * LoginOtp component
90
+ * @param props - LoginOtpProps
91
+ * @returns LoginOtp component
92
+ */
93
+ function LoginOtp(props) {
94
+ const {
95
+ otpLoading,
96
+ setShowOtpFlow,
97
+ handleOtpComplete,
98
+ authConnection,
99
+ loginHint,
100
+ errorMessage
101
+ } = props;
102
+ return /*#__PURE__*/jsx("div", {
103
+ className: "w3a--flex w3a--size-full w3a--flex-1 w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4",
104
+ children: /*#__PURE__*/jsx(OtpInput, {
105
+ errorMessage: errorMessage,
106
+ setShowOtpFlow: setShowOtpFlow,
107
+ handleOtpComplete: handleOtpComplete,
108
+ authConnection: authConnection,
109
+ loginHint: loginHint,
110
+ otpLoading: otpLoading
111
+ })
112
+ });
113
+ }
114
+
115
+ export { LoginOtp as default };