@getpara/react-sdk 1.2.0 → 1.3.1-dev.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 (205) hide show
  1. package/dist/cli/cli.mjs +43 -0
  2. package/dist/index.js +6428 -5
  3. package/dist/index.js.br +0 -0
  4. package/dist/index.js.gz +0 -0
  5. package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
  6. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
  7. package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
  8. package/dist/modal/components/Controls/Selects.d.ts +1 -1
  9. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
  10. package/dist/modal/components/Footer/Footer.d.ts +1 -1
  11. package/dist/modal/components/WalletCard/WalletCard.d.ts +2 -2
  12. package/dist/modal/components/common.d.ts +2 -2
  13. package/dist/modal/index.d.ts +0 -1
  14. package/dist/modal/stores/index.d.ts +0 -1
  15. package/dist/modal/stores/modal/useModalStore.d.ts +6 -3
  16. package/dist/modal/types/modalProps.d.ts +1 -27
  17. package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
  18. package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
  19. package/dist/modal/utils/openPopup.d.ts +1 -1
  20. package/dist/provider/ParaProvider.d.ts +3 -1
  21. package/dist/provider/actions/checkIfUserExists.d.ts +2 -7
  22. package/dist/provider/actions/createUser.d.ts +2 -10
  23. package/dist/provider/actions/getAccount.d.ts +9 -6
  24. package/dist/provider/actions/getWallet.d.ts +1 -1
  25. package/dist/provider/actions/logout.d.ts +4 -1
  26. package/dist/provider/actions/waitForLoginAndSetup.d.ts +1 -1
  27. package/dist/provider/components/CosmosWalletWrapper.d.ts +12 -0
  28. package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
  29. package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
  30. package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
  31. package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
  32. package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
  33. package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
  34. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +10 -0
  35. package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
  36. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +6 -0
  37. package/dist/provider/hooks/mutations/useLogout.d.ts +3 -2
  38. package/dist/provider/hooks/queries/useAccount.d.ts +4 -3
  39. package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
  40. package/dist/provider/hooks/utils/useClient.d.ts +1 -1
  41. package/dist/provider/hooks/utils/useWalletState.d.ts +2 -2
  42. package/dist/provider/index.d.ts +1 -0
  43. package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
  44. package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
  45. package/dist/{modal/providers/ExternalWalletContext.d.ts → provider/providers/ExternalWalletProvider.d.ts} +20 -29
  46. package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
  47. package/dist/provider/stores/getters.d.ts +3 -3
  48. package/dist/provider/stores/setters.d.ts +1 -0
  49. package/dist/provider/stores/slices/config.d.ts +3 -0
  50. package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
  51. package/dist/provider/stores/slices/index.d.ts +1 -0
  52. package/dist/provider/stores/types.d.ts +43 -1
  53. package/dist/provider/types/externalWalletProviders.d.ts +12 -0
  54. package/dist/provider/types/provider.d.ts +115 -16
  55. package/dist/provider/types/utils.d.ts +1 -0
  56. package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
  57. package/package.json +33 -9
  58. package/dist/modal/ParaModal.js +0 -281
  59. package/dist/modal/components/Account/Account.js +0 -60
  60. package/dist/modal/components/AddFunds/AddFunds.js +0 -147
  61. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -65
  62. package/dist/modal/components/AddFunds/AddFundsDone.js +0 -26
  63. package/dist/modal/components/AddFunds/MoonPayEmbed.js +0 -2
  64. package/dist/modal/components/AddFunds/index.js +0 -3
  65. package/dist/modal/components/AuthInput/AuthInput.js +0 -221
  66. package/dist/modal/components/AuthInput/countryCodes.js +0 -40
  67. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -23
  68. package/dist/modal/components/AuthInput/phoneMasks.js +0 -247
  69. package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -21
  70. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -89
  71. package/dist/modal/components/AuthOptions/AuthOptions.js +0 -28
  72. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -7
  73. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -5
  74. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -7
  75. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -18
  76. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -17
  77. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -131
  78. package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -26
  79. package/dist/modal/components/Body/Body.js +0 -232
  80. package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -77
  81. package/dist/modal/components/ChainSwitch/config.js +0 -11
  82. package/dist/modal/components/Controls/Controls.js +0 -54
  83. package/dist/modal/components/Controls/Selects.js +0 -159
  84. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -116
  85. package/dist/modal/components/ExternalWalletStep/config.js +0 -11
  86. package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -142
  87. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -7
  88. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -119
  89. package/dist/modal/components/Footer/Footer.js +0 -71
  90. package/dist/modal/components/Header/Header.js +0 -24
  91. package/dist/modal/components/Header/hooks/useStepTitle.js +0 -42
  92. package/dist/modal/components/Hero/Hero.js +0 -119
  93. package/dist/modal/components/IFrameStep/IFrameStep.js +0 -41
  94. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -19
  95. package/dist/modal/components/ModalContent/ModalContent.js +0 -282
  96. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
  97. package/dist/modal/components/OAuth/OAuth.js +0 -125
  98. package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -133
  99. package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -10
  100. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -72
  101. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -67
  102. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -105
  103. package/dist/modal/components/StripeComponents/StripeComponents.js +0 -78
  104. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -8
  105. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -135
  106. package/dist/modal/components/Waiting/Waiting.js +0 -6
  107. package/dist/modal/components/WalletCard/PartnerIcon.js +0 -29
  108. package/dist/modal/components/WalletCard/WalletCard.js +0 -93
  109. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -50
  110. package/dist/modal/components/common.js +0 -67
  111. package/dist/modal/components/index.js +0 -1
  112. package/dist/modal/constants/constants.js +0 -93
  113. package/dist/modal/constants/defaults.js +0 -5
  114. package/dist/modal/constants/oAuthLogos.js +0 -18
  115. package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
  116. package/dist/modal/hooks/useActiveWallet.js +0 -11
  117. package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
  118. package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -46
  119. package/dist/modal/hooks/useGoBack.js +0 -34
  120. package/dist/modal/index.js +0 -9
  121. package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -29
  122. package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -18
  123. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -33
  124. package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -22
  125. package/dist/modal/providers/ExternalWalletContext.js +0 -253
  126. package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -21
  127. package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -12
  128. package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
  129. package/dist/modal/stores/externalWalletProvider/actions.js +0 -5
  130. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -20
  131. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -13
  132. package/dist/modal/stores/index.js +0 -3
  133. package/dist/modal/stores/modal/actions.js +0 -64
  134. package/dist/modal/stores/modal/useModalStore.js +0 -41
  135. package/dist/modal/stores/para/actions.d.ts +0 -3
  136. package/dist/modal/stores/para/actions.js +0 -5
  137. package/dist/modal/stores/para/useParaStore.d.ts +0 -10
  138. package/dist/modal/stores/para/useParaStore.js +0 -3
  139. package/dist/modal/stores/theme/actions.d.ts +0 -3
  140. package/dist/modal/stores/theme/actions.js +0 -24
  141. package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
  142. package/dist/modal/stores/theme/useThemeStore.js +0 -14
  143. package/dist/modal/stores/userInfo/actions.js +0 -34
  144. package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -9
  145. package/dist/modal/types/commonTypes.js +0 -1
  146. package/dist/modal/types/externalWallets.js +0 -21
  147. package/dist/modal/types/modalProps.js +0 -7
  148. package/dist/modal/utils/authLayoutHelpers.js +0 -2
  149. package/dist/modal/utils/getMailtoLink.js +0 -5
  150. package/dist/modal/utils/getTileButtonFlex.js +0 -15
  151. package/dist/modal/utils/isPasskeySupported.js +0 -10
  152. package/dist/modal/utils/openPopup.js +0 -55
  153. package/dist/modal/utils/routeMobileExternalWallet.js +0 -35
  154. package/dist/modal/utils/steps.js +0 -215
  155. package/dist/modal/utils/stringFormatters.js +0 -12
  156. package/dist/modal/utils/validateOnRampConfig.js +0 -26
  157. package/dist/provider/ParaProvider.js +0 -17
  158. package/dist/provider/actions/checkIfUserExists.js +0 -26
  159. package/dist/provider/actions/createUser.js +0 -30
  160. package/dist/provider/actions/getAccount.js +0 -24
  161. package/dist/provider/actions/getWallet.js +0 -16
  162. package/dist/provider/actions/initiateLogin.js +0 -23
  163. package/dist/provider/actions/keepSessionAlive.js +0 -23
  164. package/dist/provider/actions/logout.js +0 -20
  165. package/dist/provider/actions/signMessage.js +0 -23
  166. package/dist/provider/actions/signTransaction.js +0 -23
  167. package/dist/provider/actions/waitForAccountCreation.js +0 -24
  168. package/dist/provider/actions/waitForLoginAndSetup.js +0 -27
  169. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -24
  170. package/dist/provider/hooks/index.js +0 -3
  171. package/dist/provider/hooks/mutations/index.js +0 -10
  172. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
  173. package/dist/provider/hooks/mutations/useCreateUser.js +0 -23
  174. package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
  175. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -23
  176. package/dist/provider/hooks/mutations/useLogout.js +0 -33
  177. package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
  178. package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
  179. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
  180. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
  181. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
  182. package/dist/provider/hooks/queries/index.js +0 -2
  183. package/dist/provider/hooks/queries/useAccount.js +0 -23
  184. package/dist/provider/hooks/queries/useWallet.js +0 -24
  185. package/dist/provider/hooks/utils/index.js +0 -3
  186. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -79
  187. package/dist/provider/hooks/utils/useClient.js +0 -8
  188. package/dist/provider/hooks/utils/useEventListeners.js +0 -87
  189. package/dist/provider/hooks/utils/useInternalClient.js +0 -9
  190. package/dist/provider/hooks/utils/useModal.js +0 -15
  191. package/dist/provider/hooks/utils/useWalletState.js +0 -33
  192. package/dist/provider/index.js +0 -3
  193. package/dist/provider/stores/getters.js +0 -5
  194. package/dist/provider/stores/slices/client.js +0 -4
  195. package/dist/provider/stores/slices/index.js +0 -3
  196. package/dist/provider/stores/slices/modal.js +0 -4
  197. package/dist/provider/stores/slices/wallet.js +0 -6
  198. package/dist/provider/stores/types.js +0 -1
  199. package/dist/provider/stores/useStore.js +0 -14
  200. package/dist/provider/types/provider.js +0 -1
  201. package/dist/provider/types/query.js +0 -1
  202. package/dist/provider/types/utils.js +0 -1
  203. package/dist/provider/utils/renameMutations.js +0 -19
  204. /package/dist/{modal/css → css}/modal.css +0 -0
  205. /package/dist/{modal/public → public}/Inter-VariableFont_slnt,wght.ttf +0 -0
@@ -1,247 +0,0 @@
1
- export const defaultPhoneMask = '#################';
2
- export const phoneMasks = {
3
- AF: '### ### ####',
4
- AX: '## ### ####',
5
- AL: '(###) ### ###',
6
- DZ: '(###) ### ###',
7
- AS: '(###) ###-####',
8
- AD: '### ###',
9
- AO: '(###) ### ###',
10
- AI: '(###) ###-####',
11
- AG: '(###) ###-####',
12
- AR: '(###) ###-####',
13
- AM: '## ### ###',
14
- AW: '### ####',
15
- AU: '# #### ####',
16
- AT: '(###) ### ####',
17
- AZ: '(###) ### ## ##',
18
- BS: '(###) ###-####',
19
- BH: '#### ####',
20
- BD: '# ### ###',
21
- BB: '(###) ###-####',
22
- BY: '(##) ###-##-##',
23
- BE: '(###) ### ###',
24
- BZ: '###-####',
25
- BJ: '##-##-####',
26
- BM: '(###) ###-####',
27
- BT: '# ### ###',
28
- BO: '# ### ####',
29
- BA: '## ###-###',
30
- BW: '## ### ###',
31
- BR: '(##) ####-####',
32
- IO: '### ####',
33
- BN: '### ####',
34
- BG: '(###) ### ###',
35
- BF: '## ## ####',
36
- BI: '## ## ####',
37
- KH: '## ### ###',
38
- CM: '#### ####',
39
- CA: '(###) ###-####',
40
- CV: '(###) ## ##',
41
- KY: '(###) ###-####',
42
- CF: '## ## ####',
43
- TD: '## ## ## ##',
44
- CL: '# #### ####',
45
- CN: '(###) #### ####',
46
- CX: '# ## ## ##',
47
- CC: '# ## ## ##',
48
- CO: '(###) ### ####',
49
- KM: '## ## ## ##',
50
- CG: '## ### ####',
51
- CK: '## ###',
52
- CR: '#### ####',
53
- HR: '## #### ###',
54
- CU: '# ### ####',
55
- CY: '## ### ###',
56
- CZ: '### ### ###',
57
- CD: '### ### ###',
58
- DK: '## ## ## ##',
59
- DJ: '## ## ## ##',
60
- DM: '(###) ###-####',
61
- DO: '(###) ###-####',
62
- EC: '## ### ####',
63
- EG: '# #### ####',
64
- SV: '#### ####',
65
- GQ: '## ### ####',
66
- ER: '# ### ###',
67
- EE: '#### ####',
68
- SZ: '#### ####',
69
- ET: '## ### ####',
70
- FK: '#####',
71
- FO: '######',
72
- FJ: '### ####',
73
- FI: '## ### ####',
74
- FR: '## ## ## ## ##',
75
- GF: '### ## ## ##',
76
- PF: '## ## ##',
77
- GA: '# ## ## ##',
78
- GM: '### ####',
79
- GE: '(###) ## ## ##',
80
- DE: '(###) ### ####',
81
- GH: '## ### ####',
82
- GI: '### #####',
83
- GR: '(###) ### ####',
84
- GL: '## ## ##',
85
- GD: '(###) ###-####',
86
- GP: '### ## ## ##',
87
- GU: '(###) ###-####',
88
- GT: '# ### ####',
89
- GG: '(####) ### ###',
90
- GN: '## ### ###',
91
- GW: '# #######',
92
- GY: '### ####',
93
- HT: '## ## ####',
94
- VA: '### ####',
95
- HN: '####-####',
96
- HK: '#### ####',
97
- HU: '(##) ### ####',
98
- IS: '### ####',
99
- IN: '####### ###',
100
- ID: '(###) ###-####',
101
- IR: '(###) ### ####',
102
- IQ: '(###) ### ####',
103
- IE: '(###) ### ###',
104
- IM: '(####) ### ###',
105
- IL: '#-###-####',
106
- IT: '(###) #### ###',
107
- CI: '## ## ## ##',
108
- JM: '(###) ###-####',
109
- JP: '(###) ###-####',
110
- JE: '(####) ### ###',
111
- JO: '# #### ####',
112
- KZ: '(###) ###-##-##',
113
- KE: '### ######',
114
- KI: '## ###',
115
- KP: '###-###-####',
116
- KR: '(###) ####-####',
117
- XK: '## ### ###',
118
- KW: '#### ####',
119
- KG: '(###) ###-###',
120
- LA: '## ## ####',
121
- LV: '## ### ###',
122
- LB: '## ### ###',
123
- LS: '# ### ####',
124
- LR: '## ### ###',
125
- LY: '##-#######',
126
- LI: '(###) ###-####',
127
- LT: '(###) ## ###',
128
- LU: '### ### ###',
129
- MO: '#### ####',
130
- MG: '## ## ### ##',
131
- MW: '# #### ####',
132
- MY: '(###) ###-###',
133
- MV: '###-####',
134
- ML: '## ## ####',
135
- MT: '#### ####',
136
- MH: '###-####',
137
- MQ: '### ## ## ##',
138
- MR: '## ## ####',
139
- MU: '### ####',
140
- YT: '### ## ## ##',
141
- MX: '(###) ###-####',
142
- FM: '### ####',
143
- MD: '#### ####',
144
- MC: '(###) ###-###',
145
- MN: '## ## ####',
146
- ME: '## ### ###',
147
- MS: '(###) ###-####',
148
- MA: '#-####-####',
149
- MZ: '## ### ####',
150
- MM: '# ### ####',
151
- NA: '## ### ####',
152
- NR: '### ####',
153
- NP: '#-######',
154
- NL: '## ### ####',
155
- NC: '##.##.##',
156
- NZ: '## ### ###',
157
- NI: '#### ####',
158
- NE: '## ## ## ##',
159
- NG: '## ### ####',
160
- NU: '####',
161
- NF: '### ###',
162
- MK: '## ### ###',
163
- MP: '(###) ###-####',
164
- NO: '### ## ###',
165
- OM: '#### ####',
166
- PK: '(###) #######',
167
- PW: '### ####',
168
- PS: '## ### ####',
169
- PA: '####-####',
170
- PG: '(###) ## ###',
171
- PY: '## ### ####',
172
- PE: '(###) ### ###',
173
- PH: '(###) ###-####',
174
- PN: '### ####',
175
- PL: '### ### ###',
176
- PT: '## ### ####',
177
- PR: '(###) ###-####',
178
- QA: '#### ####',
179
- RE: '##### ####',
180
- RO: '## ### ####',
181
- RU: '(###) ###-##-##',
182
- RW: '(###) ### ###',
183
- BL: '### ## ## ##',
184
- SH: '####',
185
- KN: '(###) ###-####',
186
- LC: '(###) ###-####',
187
- MF: '### ## ## ##',
188
- PM: '## ## ##',
189
- VC: '(###) ###-####',
190
- WS: '####',
191
- SM: '(####) ######',
192
- ST: '## ####',
193
- SA: '# ### ####',
194
- SN: '## ### ####',
195
- RS: '## ### ####',
196
- SC: '# ### ###',
197
- SL: '## ######',
198
- SG: '#### ####',
199
- SX: '(###) ###-####',
200
- SK: '(###) ### ###',
201
- SI: '## ### ###',
202
- SB: '### ####',
203
- SO: '# ### ###',
204
- ZA: '## ### ####',
205
- GS: '####',
206
- SS: '# ### ####',
207
- ES: '### ### ###',
208
- LK: '## ### ####',
209
- SD: '## ### ####',
210
- SR: '###-####',
211
- SJ: '### ## ###',
212
- SE: '## ### ####',
213
- CH: '## ### ####',
214
- SY: '## #### ###',
215
- TW: '#### ####',
216
- TJ: '## ### ####',
217
- TZ: '## ### ####',
218
- TH: '# #### ####',
219
- TL: '#### ####',
220
- TG: '## ## ## ##',
221
- TK: '####',
222
- TO: '####',
223
- TT: '(###) ###-####',
224
- TN: '## ### ###',
225
- TR: '(###) ### ####',
226
- TM: '# ### ###',
227
- TC: '(###) ###-####',
228
- TV: '####',
229
- UG: '## ### ####',
230
- UA: '## ### ####',
231
- AE: '# ### ####',
232
- GB: '#### ### ###',
233
- US: '(###) ###-####',
234
- UM: '(###) ###-####',
235
- UY: '# ### ## ##',
236
- UZ: '## ### ####',
237
- VU: '## ####',
238
- VE: '###-###-####',
239
- VN: '## #### ###',
240
- VG: '(###) ###-####',
241
- VI: '(###) ###-####',
242
- WF: '## ####',
243
- EH: '###-###-###',
244
- YE: '# ### ###',
245
- ZM: '## ### ####',
246
- ZW: '# #######',
247
- };
@@ -1,21 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import styled from 'styled-components';
3
- import { useThemeStore } from '../../stores/theme/useThemeStore.js';
4
- import { AuthMainStepContent } from './AuthMainStepContent.js';
5
- import { CenteredText } from '../common.js';
6
- export const AuthMainStep = ({ oAuthMethods, disableEmailLogin, disablePhoneLogin }) => {
7
- const logo = useThemeStore(state => state.getLogo());
8
- const appName = useThemeStore(state => state.appName);
9
- const authLayout = useThemeStore(state => state.authLayout);
10
- const embeddedModal = useThemeStore(state => state.embeddedModal);
11
- const firstLayoutType = authLayout[0].split(':')[0];
12
- const heading = firstLayoutType === 'AUTH' ? 'Sign Up or Login' : 'Connect Wallet';
13
- return (_jsxs(_Fragment, { children: [logo && _jsx(Logo, { src: logo, alt: `${appName ? `${appName} -` : ''}logo` }), !embeddedModal && (_jsx(CenteredText, { variant: logo ? 'bodyM' : 'headingS', weight: "semiBold", children: heading })), _jsx(AuthMainStepContent, { disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin, oAuthMethods: oAuthMethods })] }));
14
- };
15
- const Logo = styled.img `
16
- height: 100px;
17
- max-width: 260px;
18
- object-fit: contain;
19
- box-sizing: content-box;
20
- align-self: center;
21
- `;
@@ -1,89 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Fragment, useMemo } from 'react';
3
- import { CpslButton, CpslDivider, CpslIconGroup } from '@getpara/react-components';
4
- import styled from 'styled-components';
5
- import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
6
- import { ExternalWallets } from '../ExternalWallets/ExternalWallets.js';
7
- import { useModalStore, useThemeStore } from '../../stores/index.js';
8
- import { ModalStep } from '../../utils/steps.js';
9
- import { AuthLayout } from '../../types/modalProps.js';
10
- import { brandedOAuthLogos, oAuthLogos } from '../../constants/oAuthLogos.js';
11
- import { AuthOptions } from '../AuthOptions/AuthOptions.js';
12
- export const AuthMainStepContent = ({ oAuthMethods, disableEmailLogin, disablePhoneLogin }) => {
13
- const { wallets } = useExternalWallets();
14
- const authLayout = useThemeStore(state => state.authLayout);
15
- const setStep = useModalStore(state => state.setStep);
16
- const oAuthLogoVariant = useThemeStore(state => state.oAuthLogoVariant);
17
- const isDark = useThemeStore(state => state.isDark);
18
- const useBrandedLogos = oAuthLogoVariant === 'default';
19
- const useDarkLogos = useBrandedLogos ? isDark : oAuthLogoVariant !== 'dark';
20
- const handleCondensedAuthClick = () => {
21
- setStep(ModalStep.AUTH_MORE);
22
- };
23
- const handleCondensedExternalClick = () => {
24
- setStep(ModalStep.EX_WALLET_MORE);
25
- };
26
- const Content = useMemo(() => {
27
- const methods = [];
28
- authLayout.forEach(layout => {
29
- switch (layout) {
30
- case AuthLayout.AUTH_FULL: {
31
- methods.push([
32
- _jsx(AuthOptions, { oAuthMethods: oAuthMethods, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin }, "authFull"),
33
- layout,
34
- ]);
35
- break;
36
- }
37
- case AuthLayout.AUTH_CONDENSED: {
38
- const icons = [];
39
- oAuthMethods === null || oAuthMethods === void 0 ? void 0 : oAuthMethods.forEach(method => icons.push(useBrandedLogos ? brandedOAuthLogos[method] : oAuthLogos[method]));
40
- methods.push([
41
- _jsxs(CondensedButton, { onClick: handleCondensedAuthClick, variant: "tertiary", fullWidth: true, children: [_jsx(IconGroupSpacer, { slot: "start", icons: [], "$isDark": useDarkLogos }), "Sign Up or Login", _jsx(StyledIconGroup, { slot: "end", icons: icons.splice(0, 3), "$isDark": useDarkLogos })] }, "authCondensed"),
42
- layout,
43
- ]);
44
- break;
45
- }
46
- case AuthLayout.EXTERNAL_FULL: {
47
- if (!!wallets.length) {
48
- methods.push([_jsx(ExternalWallets, {}, "externalWallets"), layout]);
49
- }
50
- break;
51
- }
52
- case AuthLayout.EXTERNAL_CONDENSED: {
53
- const icons = [];
54
- wallets === null || wallets === void 0 ? void 0 : wallets.forEach(wallet => icons.push(wallet.iconUrl));
55
- methods.push([
56
- _jsxs(CondensedButton, { onClick: handleCondensedExternalClick, variant: "tertiary", fullWidth: true, children: [_jsx(IconGroupSpacer, { slot: "start", icons: [], "$isDark": useDarkLogos }), "Connect Wallet", _jsx(StyledIconGroup, { slot: "end", icons: icons.splice(0, 3), "$isDark": useDarkLogos })] }, "authCondensed"),
57
- layout,
58
- ]);
59
- break;
60
- }
61
- default: {
62
- break;
63
- }
64
- }
65
- });
66
- return (_jsx(_Fragment, { children: methods.map(([reactNode, key], index) => (_jsxs(Fragment, { children: [reactNode, methods.length > 1 && index < methods.length - 1 && _jsx(CpslDivider, { children: "or" }, "or")] }, key))) }));
67
- }, [oAuthMethods, disableEmailLogin, disablePhoneLogin, wallets, authLayout]);
68
- return _jsx(Container, { "data-testid": "main-auth-step-content", children: Content });
69
- };
70
- const Container = styled.div `
71
- display: flex;
72
- flex-direction: column;
73
- gap: 8px;
74
- `;
75
- const StyledIconGroup = styled(CpslIconGroup) `
76
- --icon-item-color: ${({ $isDark }) => ($isDark ? 'white' : 'black')};
77
- flex: 1;
78
- justify-content: flex-end;
79
- `;
80
- const IconGroupSpacer = styled(StyledIconGroup) `
81
- visibility: hidden;
82
- `;
83
- const CondensedButton = styled(CpslButton) `
84
- --button-justify-content: space-between;
85
-
86
- &::part(button-native) {
87
- max-height: 50px;
88
- }
89
- `;
@@ -1,28 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import styled from 'styled-components';
4
- import { OAuth } from '../OAuth/OAuth.js';
5
- import { AuthInput } from '../AuthInput/AuthInput.js';
6
- import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
7
- import { useModalStore } from '../../stores/index.js';
8
- import { ModalStep } from '../../utils/steps.js';
9
- export const AuthOptions = ({ oAuthMethods, disableEmailLogin, disablePhoneLogin }) => {
10
- const { wallets } = useExternalWallets();
11
- const showAllOAuth = useModalStore(state => state.step === ModalStep.AUTH_MORE);
12
- const Content = useMemo(() => {
13
- const Methods = [];
14
- if (!!(oAuthMethods === null || oAuthMethods === void 0 ? void 0 : oAuthMethods.length)) {
15
- Methods.push(_jsx(OAuth, { methods: oAuthMethods }, "oAuth"));
16
- }
17
- if (!disableEmailLogin || !disablePhoneLogin) {
18
- Methods.push(_jsx(AuthInput, { disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin }, "input"));
19
- }
20
- return _jsx(_Fragment, { children: Methods });
21
- }, [showAllOAuth, oAuthMethods, disableEmailLogin, disablePhoneLogin, wallets]);
22
- return _jsx(Container, { children: Content });
23
- };
24
- const Container = styled.div `
25
- display: flex;
26
- flex-direction: column;
27
- gap: 8px;
28
- `;
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useModalStore } from '../../stores/index.js';
3
- import { Waiting } from '../Waiting/Waiting.js';
4
- export const AwaitingBiometricsStep = () => {
5
- const isLogin = useModalStore(state => state.isLogin());
6
- return (_jsx(Waiting, { heading: isLogin ? 'Waiting for Passkey' : 'Creating Passkey', subheading: "Follow the prompts presented by your browser." }));
7
- };
@@ -1,5 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Waiting } from '../Waiting/Waiting.js';
3
- export const AwaitingOAuthStep = () => {
4
- return _jsx(Waiting, { heading: "Complete Login", subheading: "Follow the prompts presented by your browser." });
5
- };
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useModalStore } from '../../stores/index.js';
3
- import { Waiting } from '../Waiting/Waiting.js';
4
- export const AwaitingPasswordStep = () => {
5
- const isLogin = useModalStore(state => state.isLogin());
6
- return (_jsx(Waiting, { heading: isLogin ? 'Waiting for Password' : 'Creating Password', subheading: "Follow the prompts presented by your browser." }));
7
- };
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CpslIcon, CpslInfoBox, CpslText } from '@getpara/react-components';
3
- import { InfoBoxContent, InfoBoxHeader, StepContainer } from '../common.js';
4
- import { useEffect, useRef, useState } from 'react';
5
- import { Waiting } from '../Waiting/Waiting.js';
6
- import { useThemeStore } from '../../stores/index.js';
7
- export const AwaitingWalletCreationStep = () => {
8
- const hideWallets = useThemeStore(state => state.hideWallets);
9
- const [showInfoBox, setShowInfoBox] = useState(false);
10
- const showInfoBoxTimeout = useRef();
11
- useEffect(() => {
12
- showInfoBoxTimeout.current = window.setTimeout(() => {
13
- setShowInfoBox(true);
14
- }, 4000);
15
- return () => clearTimeout(showInfoBoxTimeout.current);
16
- }, []);
17
- return (_jsxs(StepContainer, { "$wide": true, children: [_jsx(Waiting, { heading: hideWallets ? 'Creating Your Account' : 'Creating Your Wallet', subheading: "This should only take a couple of seconds." }), showInfoBox && (_jsx(CpslInfoBox, { children: _jsxs(InfoBoxContent, { children: [_jsxs(InfoBoxHeader, { children: [_jsx(CpslIcon, { icon: "clock" }), _jsx(CpslText, { weight: "medium", children: "Hang on" })] }), _jsxs(CpslText, { variant: "bodyS", weight: "medium", color: "secondary", children: ["Creating your ", hideWallets ? 'account' : 'wallet', " is taking a little longer than expected, but we're working on it!"] })] }) }))] }));
18
- };
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { CpslButton, CpslDivider, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from '@getpara/react-components';
3
- import { useModalStore, useUserInfoStore } from '../../stores/index.js';
4
- import { InnerStepContainer, StepContainer, Heading, QRContainer } from '../common.js';
5
- import { isPasskeySupported } from '../../utils/isPasskeySupported.js';
6
- import { useCopyToClipboard, UserIdentifier } from '@getpara/react-common';
7
- export const BiometricCreationStep = ({ handlePasswordClick, handlePasskeyClick, }) => {
8
- const webAuthURLForCreate = useModalStore(state => state.webAuthURLForCreate);
9
- const iFrameUrl = useModalStore(state => state.iFrameUrl);
10
- const authInfo = useUserInfoStore(state => state.getAuthInfo());
11
- const [isCopied, copy] = useCopyToClipboard();
12
- const handleCopy = () => {
13
- copy(webAuthURLForCreate);
14
- };
15
- const isBoth = !!webAuthURLForCreate && !!iFrameUrl;
16
- return (_jsxs(StepContainer, { "$wide": true, children: [_jsxs(InnerStepContainer, { children: [_jsx(Heading, { variant: "headingS", weight: "bold", children: isBoth ? 'Secure Your Account' : 'Create Passkey' }), _jsx(UserIdentifier, Object.assign({}, authInfo)), _jsx(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: isBoth ? 'Choose a password or set up a passkey' : 'Your Passkey keeps your account safe.' })] }), _jsxs(InnerStepContainer, { children: [isPasskeySupported() ? (_jsxs(CpslButton, { fullWidth: true, onClick: handlePasskeyClick, children: [_jsx(CpslIcon, { slot: "start", icon: "key" }), isBoth ? 'Create Passkey' : 'Create'] })) : (_jsxs(_Fragment, { children: [_jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device" }), _jsx(QRContainer, { children: !webAuthURLForCreate ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: webAuthURLForCreate }) }), _jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [_jsx(CpslIcon, { slot: "start", icon: isCopied ? 'check' : 'copy' }), isCopied ? 'Copied' : 'Copy Link'] })] })), isBoth && (_jsxs(_Fragment, { children: [_jsx(CpslDivider, { children: "or" }), _jsxs(CpslButton, { fullWidth: true, onClick: handlePasswordClick, children: [_jsx(CpslIcon, { slot: "start", icon: "passcode" }), "Choose Password"] })] }))] })] }));
17
- };
@@ -1,131 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
- import { CpslButton, CpslDivider, CpslIcon } from '@getpara/react-components';
12
- import { useEffect, useMemo, useState } from 'react';
13
- import { useModalStore, useUserInfoStore } from '../../stores/index.js';
14
- import { ModalStep } from '../../utils/steps.js';
15
- import { Heading, StepContainer, InnerStepContainer } from '../common.js';
16
- import { openPopup } from '../../utils/openPopup.js';
17
- import styled from 'styled-components';
18
- import { AuthMethod, getPublicKeyHex } from '@getpara/web-sdk';
19
- import { isPasskeySupported } from '../../utils/isPasskeySupported.js';
20
- import { formatBiometricHints, KnownDevices, UserIdentifier } from '@getpara/react-common';
21
- import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
22
- export const BiometricLoginStep = () => {
23
- const popupWindow = useModalStore(state => state.popupWindow);
24
- const supportedAuthMethods = useModalStore(state => state.supportedAuthMethods);
25
- const passwordUrlForLogin = useModalStore(state => state.passwordUrlForLogin);
26
- const webAuthURLForLogin = useModalStore(state => state.webAuthURLForLogin);
27
- const setStep = useModalStore(state => state.setStep);
28
- const setPopupWindow = useModalStore(state => state.setPopupWindow);
29
- const biometricLocationHints = useModalStore(state => state.biometricLocationHints);
30
- const para = useInternalClient();
31
- const authInfo = useUserInfoStore(state => state.getAuthInfo());
32
- const setWebAuthURLForLogin = useModalStore(state => state.setWebAuthURLForLogin);
33
- const setPasswordUrlForLogin = useModalStore(state => state.setPasswordUrlForLogin);
34
- const passkeysSupported = isPasskeySupported();
35
- const formattedHints = useMemo(() => formatBiometricHints(biometricLocationHints), [biometricLocationHints]);
36
- const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
37
- const [webAuthURLForKnownDeviceLogin, setWebAuthURLForKnownDeviceLogin] = useState();
38
- useEffect(() => {
39
- function setLinks() {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- if (!(supportedAuthMethods === null || supportedAuthMethods === void 0 ? void 0 : supportedAuthMethods.size) && para.getUserId()) {
42
- const fetchedSupportedAuthMethods = yield para.supportedAuthMethods({ userId: para.getUserId() });
43
- if (fetchedSupportedAuthMethods === null || fetchedSupportedAuthMethods === void 0 ? void 0 : fetchedSupportedAuthMethods.size) {
44
- setSupportedAuthMethods(fetchedSupportedAuthMethods);
45
- }
46
- return;
47
- }
48
- if (!para.isEmail && !para.isPhone && !para.isFarcaster && !para.isTelegram) {
49
- return;
50
- }
51
- if (!para.loginEncryptionKeyPair) {
52
- return;
53
- }
54
- const authType = para.isEmail ? 'email' : para.isPhone ? 'phone' : para.isFarcaster ? 'farcaster' : 'telegram';
55
- const res = yield para.touchSession();
56
- const webAuthUrlForLogin = (supportedAuthMethods === null || supportedAuthMethods === void 0 ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSKEY)
57
- ? yield para.getWebAuthURLForLogin({
58
- sessionId: res.data.sessionId,
59
- loginEncryptionPublicKey: getPublicKeyHex(para.loginEncryptionKeyPair),
60
- partnerId: res.data.partnerId,
61
- authType,
62
- displayName: authInfo.displayName,
63
- pfpUrl: authInfo.pfpUrl,
64
- })
65
- : undefined;
66
- const _webAuthURLForKnownDeviceLogin = (supportedAuthMethods === null || supportedAuthMethods === void 0 ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSKEY)
67
- ? yield para.getWebAuthURLForLogin({
68
- sessionId: res.data.sessionId,
69
- loginEncryptionPublicKey: getPublicKeyHex(para.loginEncryptionKeyPair),
70
- partnerId: res.data.partnerId,
71
- newDeviceSessionId: res.data.sessionLookupId,
72
- newDeviceEncryptionKey: getPublicKeyHex(para.loginEncryptionKeyPair),
73
- authType,
74
- displayName: authInfo.displayName,
75
- pfpUrl: authInfo.pfpUrl,
76
- })
77
- : undefined;
78
- const passwordAuthUrlForLogin = (supportedAuthMethods === null || supportedAuthMethods === void 0 ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSWORD)
79
- ? yield para.getPasswordURLForLogin({
80
- sessionId: res.data.sessionId,
81
- loginEncryptionPublicKey: getPublicKeyHex(para.loginEncryptionKeyPair),
82
- partnerId: res.data.partnerId,
83
- authType,
84
- displayName: authInfo.displayName,
85
- pfpUrl: authInfo.pfpUrl,
86
- })
87
- : undefined;
88
- const shortWebAuthLoginLink = webAuthUrlForLogin ? yield para.shortenLoginLink(webAuthUrlForLogin) : undefined;
89
- const shortWebAuthForKnownDeviceLoginLink = _webAuthURLForKnownDeviceLogin
90
- ? yield para.shortenLoginLink(_webAuthURLForKnownDeviceLogin)
91
- : undefined;
92
- setWebAuthURLForKnownDeviceLogin(shortWebAuthForKnownDeviceLoginLink);
93
- setWebAuthURLForLogin(shortWebAuthLoginLink);
94
- setPasswordUrlForLogin(passwordAuthUrlForLogin);
95
- });
96
- }
97
- setLinks();
98
- }, [supportedAuthMethods, para]);
99
- const handlePasskeyClick = () => {
100
- if (!!popupWindow) {
101
- return;
102
- }
103
- const loginWindow = openPopup(webAuthURLForLogin, 'ParaPasskey', 'LOGIN_PASSKEY');
104
- setPopupWindow(loginWindow);
105
- setStep(ModalStep.AWAITING_BIOMETRIC_LOGIN);
106
- };
107
- const handlePasswordClick = () => {
108
- const loginWindow = openPopup(passwordUrlForLogin, 'ParaPassword', 'LOGIN_PASSWORD');
109
- setPopupWindow(loginWindow);
110
- setStep(ModalStep.AWAITING_PASSWORD_LOGIN);
111
- };
112
- function shouldShowWelcomeBack() {
113
- return (!(biometricLocationHints === null || biometricLocationHints === void 0 ? void 0 : biometricLocationHints.length) ||
114
- (passkeysSupported && formattedHints.isOnKnownDevice) ||
115
- ((supportedAuthMethods === null || supportedAuthMethods === void 0 ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSWORD)));
116
- }
117
- return (_jsxs(StepContainer, { "$wide": true, children: [_jsxs(InnerStepContainer, { children: [shouldShowWelcomeBack() && (_jsx(Heading, { variant: "headingS", weight: "bold", children: "Welcome back," })), _jsx(UserIdentifier, Object.assign({}, authInfo))] }), _jsxs(MainContainer, { children: [(supportedAuthMethods === null || supportedAuthMethods === void 0 ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSWORD) && passwordUrlForLogin && (_jsx(PasswordOnly, { handlePasswordClick: handlePasswordClick })), (supportedAuthMethods === null || supportedAuthMethods === void 0 ? void 0 : supportedAuthMethods.has) &&
118
- supportedAuthMethods.has(AuthMethod.PASSKEY) &&
119
- webAuthURLForLogin &&
120
- webAuthURLForKnownDeviceLogin && (_jsx(BiometricOnly, { handlePasskeyClick: handlePasskeyClick, formattedHints: formattedHints, shortLoginLink: webAuthURLForKnownDeviceLogin, passkeysSupported: passkeysSupported, biometricLocationHints: biometricLocationHints }))] })] }));
121
- };
122
- const PasswordOnly = ({ handlePasswordClick }) => {
123
- return (_jsx(CpslButton, { fullWidth: true, onClick: handlePasswordClick, children: "Login" }));
124
- };
125
- const BiometricOnly = ({ handlePasskeyClick, formattedHints, shortLoginLink, passkeysSupported, biometricLocationHints = [], }) => {
126
- const [hasHints, isOnKnownDevice] = [biometricLocationHints.length > 0, formattedHints.isOnKnownDevice];
127
- return (_jsxs(_Fragment, { children: [((hasHints && !isOnKnownDevice) || !passkeysSupported) && (_jsx(KnownDevices, { hints: formattedHints, link: shortLoginLink })), passkeysSupported && (_jsxs(_Fragment, { children: [hasHints && !isOnKnownDevice && _jsx(CpslDivider, { children: "or" }), _jsx(CpslButton, { fullWidth: true, onClick: handlePasskeyClick, children: !hasHints || isOnKnownDevice ? (_jsxs(_Fragment, { children: [_jsx(CpslIcon, { slot: "start", icon: "key" }), "Login with passkey"] })) : ('Continue anyway') })] }))] }));
128
- };
129
- const MainContainer = styled(InnerStepContainer) `
130
- gap: 16px;
131
- `;
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { motion } from 'framer-motion';
3
- import { useEffect, useRef, useState } from 'react';
4
- import styled from 'styled-components';
5
- export const AnimatedHeightWrapper = ({ children, className }) => {
6
- const containerRef = useRef(null);
7
- const [height, setHeight] = useState('auto');
8
- useEffect(() => {
9
- if (containerRef.current) {
10
- const resizeObserver = new ResizeObserver(entries => {
11
- // We only have one entry, so we can use entries[0].
12
- const observedHeight = entries[0].contentRect.height;
13
- setHeight(observedHeight);
14
- });
15
- resizeObserver.observe(containerRef.current);
16
- return () => {
17
- // Cleanup the observer when the component is unmounted
18
- resizeObserver.disconnect();
19
- };
20
- }
21
- }, []);
22
- return (_jsx(Container, { className: className, style: { height }, animate: { height }, transition: { duration: 0.2 }, children: _jsx("div", { ref: containerRef, children: children }) }));
23
- };
24
- const Container = styled(motion.div) `
25
- overflow: hidden;
26
- `;