@blocklet/ui-react 2.13.70 → 3.0.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 (381) hide show
  1. package/lib/@types/index.js +5 -18
  2. package/lib/BlockletStudio/index.js +75 -89
  3. package/lib/ComponentInstaller/index.js +153 -190
  4. package/lib/ComponentInstaller/installer-item.js +56 -55
  5. package/lib/ComponentInstaller/locales.js +19 -18
  6. package/lib/ComponentInstaller/use-component-installed.js +49 -80
  7. package/lib/ComponentManager/components/add-component.js +68 -89
  8. package/lib/ComponentManager/components/check-component.js +4 -2
  9. package/lib/ComponentManager/components/publish-component.js +48 -57
  10. package/lib/ComponentManager/components/resource-dialog.js +41 -55
  11. package/lib/ComponentManager/index.js +8 -3
  12. package/lib/ComponentManager/libs/locales.js +8 -5
  13. package/lib/Dashboard/index.js +88 -124
  14. package/lib/Footer/brand.js +25 -28
  15. package/lib/Footer/copyright.js +15 -16
  16. package/lib/Footer/index.js +55 -65
  17. package/lib/Footer/internal-footer.js +93 -95
  18. package/lib/Footer/layout/plain.js +26 -24
  19. package/lib/Footer/layout/row.js +16 -20
  20. package/lib/Footer/layout/standard.js +73 -59
  21. package/lib/Footer/links.js +100 -120
  22. package/lib/Footer/social-media.js +28 -33
  23. package/lib/Header/index.js +108 -130
  24. package/lib/Icon/index.js +43 -59
  25. package/lib/Notifications/Snackbar.js +114 -151
  26. package/lib/Notifications/hooks/use-title.js +85 -126
  27. package/lib/Notifications/hooks/use-width.js +10 -9
  28. package/lib/Notifications/utils.js +74 -114
  29. package/lib/UserCenter/components/config-inviter.js +21 -31
  30. package/lib/UserCenter/components/config-profile.js +41 -47
  31. package/lib/UserCenter/components/danger-zone.js +88 -93
  32. package/lib/UserCenter/components/editable-field.js +149 -167
  33. package/lib/UserCenter/components/nft.js +91 -81
  34. package/lib/UserCenter/components/notification.js +206 -195
  35. package/lib/UserCenter/components/passport.js +37 -53
  36. package/lib/UserCenter/components/privacy.js +53 -64
  37. package/lib/UserCenter/components/settings.js +117 -128
  38. package/lib/UserCenter/components/status-dialog/date-picker.js +35 -36
  39. package/lib/UserCenter/components/status-dialog/index.js +132 -144
  40. package/lib/UserCenter/components/status-selector/duration-menu.js +53 -48
  41. package/lib/UserCenter/components/status-selector/index.js +37 -36
  42. package/lib/UserCenter/components/status-selector/menu-item.js +13 -9
  43. package/lib/UserCenter/components/storage/action.js +27 -25
  44. package/lib/UserCenter/components/storage/connected.js +59 -30
  45. package/lib/UserCenter/components/storage/delete.js +32 -39
  46. package/lib/UserCenter/components/storage/disconnect.js +43 -25
  47. package/lib/UserCenter/components/storage/icons/empty-spaces-nft.svg.js +7 -0
  48. package/lib/UserCenter/components/storage/index.js +24 -18
  49. package/lib/UserCenter/components/storage/preview-nft.js +35 -36
  50. package/lib/UserCenter/components/third-party-login/index.js +73 -143
  51. package/lib/UserCenter/components/third-party-login/third-party-item.js +132 -153
  52. package/lib/UserCenter/components/user-center.js +345 -461
  53. package/lib/UserCenter/components/user-info/address.js +120 -100
  54. package/lib/UserCenter/components/user-info/index.js +10 -4
  55. package/lib/UserCenter/components/user-info/link-preview-input.js +148 -159
  56. package/lib/UserCenter/components/user-info/metadata.js +290 -385
  57. package/lib/UserCenter/components/user-info/switch-role.js +24 -18
  58. package/lib/UserCenter/components/user-info/timezone-select.js +37 -45
  59. package/lib/UserCenter/components/user-info/user-basic-info.js +213 -207
  60. package/lib/UserCenter/components/user-info/user-info-item.js +39 -26
  61. package/lib/UserCenter/components/user-info/user-info.js +52 -67
  62. package/lib/UserCenter/components/user-info/user-status.js +111 -154
  63. package/lib/UserCenter/components/user-info/utils.js +96 -93
  64. package/lib/UserCenter/components/webhook-item.js +95 -143
  65. package/lib/UserCenter/index.js +4 -1
  66. package/lib/UserCenter/libs/locales.js +132 -129
  67. package/lib/UserCenter/libs/utils.js +17 -22
  68. package/lib/UserSessions/components/user-session-info.js +30 -26
  69. package/lib/UserSessions/components/user-sessions.js +222 -268
  70. package/lib/UserSessions/index.js +4 -1
  71. package/lib/UserSessions/libs/locales.js +31 -28
  72. package/lib/UserSessions/libs/utils.js +30 -56
  73. package/lib/blocklets.js +75 -156
  74. package/lib/common/domain-warning.js +64 -104
  75. package/lib/common/header-addons.js +59 -80
  76. package/lib/common/link-blocker.js +10 -16
  77. package/lib/common/notification-addon.js +56 -89
  78. package/lib/common/overridable-theme-provider.js +12 -12
  79. package/lib/common/wallet-hidden-topbar.js +11 -13
  80. package/lib/common/ws.js +23 -34
  81. package/lib/contexts/config-user-space.js +34 -43
  82. package/lib/hooks/use-mobile.js +7 -4
  83. package/lib/index.js +25 -10
  84. package/lib/libs/client.js +5 -2
  85. package/lib/libs/constant.js +4 -1
  86. package/lib/libs/spaces.js +11 -11
  87. package/lib/libs/with-hide-when-embed.js +13 -15
  88. package/lib/packages/blocklet-ui-react/build.config.d.ts +2 -0
  89. package/lib/packages/blocklet-ui-react/jest.config.d.ts +8 -0
  90. package/lib/packages/blocklet-ui-react/lib/@types/index.d.ts +3 -0
  91. package/lib/packages/blocklet-ui-react/lib/BlockletStudio/index.d.ts +26 -0
  92. package/lib/packages/blocklet-ui-react/lib/ComponentInstaller/index.d.ts +18 -0
  93. package/lib/packages/blocklet-ui-react/lib/ComponentInstaller/installer-item.d.ts +18 -0
  94. package/lib/packages/blocklet-ui-react/lib/ComponentInstaller/locales.d.ts +28 -0
  95. package/lib/packages/blocklet-ui-react/lib/ComponentInstaller/use-component-installed.d.ts +12 -0
  96. package/lib/packages/blocklet-ui-react/lib/ComponentManager/components/add-component.d.ts +13 -0
  97. package/lib/packages/blocklet-ui-react/lib/ComponentManager/components/check-component.d.ts +2 -0
  98. package/lib/packages/blocklet-ui-react/lib/ComponentManager/components/publish-component.d.ts +7 -0
  99. package/lib/packages/blocklet-ui-react/lib/ComponentManager/components/resource-dialog.d.ts +11 -0
  100. package/lib/packages/blocklet-ui-react/lib/ComponentManager/index.d.ts +4 -0
  101. package/lib/packages/blocklet-ui-react/lib/ComponentManager/libs/locales.d.ts +19 -0
  102. package/lib/packages/blocklet-ui-react/lib/Dashboard/index.d.ts +27 -0
  103. package/lib/packages/blocklet-ui-react/lib/Footer/brand.d.ts +15 -0
  104. package/lib/packages/blocklet-ui-react/lib/Footer/copyright.d.ts +13 -0
  105. package/lib/packages/blocklet-ui-react/lib/Footer/index.d.ts +2 -0
  106. package/lib/packages/blocklet-ui-react/lib/Footer/internal-footer.d.ts +29 -0
  107. package/lib/packages/blocklet-ui-react/lib/Footer/layout/plain.d.ts +19 -0
  108. package/lib/packages/blocklet-ui-react/lib/Footer/layout/row.d.ts +13 -0
  109. package/lib/packages/blocklet-ui-react/lib/Footer/layout/standard.d.ts +21 -0
  110. package/lib/packages/blocklet-ui-react/lib/Footer/links.d.ts +20 -0
  111. package/lib/packages/blocklet-ui-react/lib/Footer/social-media.d.ts +14 -0
  112. package/lib/packages/blocklet-ui-react/lib/Header/index.d.ts +2 -0
  113. package/lib/packages/blocklet-ui-react/lib/Icon/index.d.ts +7 -0
  114. package/lib/packages/blocklet-ui-react/lib/Notifications/Snackbar.d.ts +8 -0
  115. package/lib/packages/blocklet-ui-react/lib/Notifications/hooks/use-title.d.ts +9 -0
  116. package/lib/packages/blocklet-ui-react/lib/Notifications/hooks/use-width.d.ts +2 -0
  117. package/lib/packages/blocklet-ui-react/lib/Notifications/utils.d.ts +10 -0
  118. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/config-inviter.d.ts +4 -0
  119. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/config-profile.d.ts +5 -0
  120. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/danger-zone.d.ts +2 -0
  121. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/editable-field.d.ts +50 -0
  122. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/nft.d.ts +4 -0
  123. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/notification.d.ts +5 -0
  124. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/passport.d.ts +5 -0
  125. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/privacy.d.ts +5 -0
  126. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/settings.d.ts +8 -0
  127. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/status-dialog/date-picker.d.ts +9 -0
  128. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/status-dialog/index.d.ts +9 -0
  129. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/status-selector/duration-menu.d.ts +7 -0
  130. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/status-selector/index.d.ts +8 -0
  131. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/status-selector/menu-item.d.ts +9 -0
  132. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/storage/action.d.ts +7 -0
  133. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/storage/connected.d.ts +4 -0
  134. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/storage/delete.d.ts +5 -0
  135. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/storage/disconnect.d.ts +2 -0
  136. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/storage/icons/empty-spaces-nft.svg.d.ts +3 -0
  137. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/storage/index.d.ts +2 -0
  138. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/storage/preview-nft.d.ts +5 -0
  139. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/third-party-login/index.d.ts +4 -0
  140. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/third-party-login/third-party-item.d.ts +4 -0
  141. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-center.d.ts +15 -0
  142. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/address.d.ts +7 -0
  143. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/index.d.ts +5 -0
  144. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/link-preview-input.d.ts +6 -0
  145. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/metadata.d.ts +7 -0
  146. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/switch-role.d.ts +6 -0
  147. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/timezone-select.d.ts +7 -0
  148. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/user-basic-info.d.ts +12 -0
  149. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/user-info-item.d.ts +6 -0
  150. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/user-info.d.ts +6 -0
  151. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/user-status.d.ts +9 -0
  152. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/user-info/utils.d.ts +33 -0
  153. package/lib/packages/blocklet-ui-react/lib/UserCenter/components/webhook-item.d.ts +10 -0
  154. package/lib/packages/blocklet-ui-react/lib/UserCenter/index.d.ts +2 -0
  155. package/lib/packages/blocklet-ui-react/lib/UserCenter/libs/locales.d.ts +513 -0
  156. package/lib/packages/blocklet-ui-react/lib/UserCenter/libs/utils.d.ts +3 -0
  157. package/lib/packages/blocklet-ui-react/lib/UserSessions/components/user-session-info.d.ts +5 -0
  158. package/lib/packages/blocklet-ui-react/lib/UserSessions/components/user-sessions.d.ts +8 -0
  159. package/lib/packages/blocklet-ui-react/lib/UserSessions/index.d.ts +2 -0
  160. package/lib/packages/blocklet-ui-react/lib/UserSessions/libs/locales.d.ts +88 -0
  161. package/lib/packages/blocklet-ui-react/lib/UserSessions/libs/utils.d.ts +3 -0
  162. package/lib/packages/blocklet-ui-react/lib/blocklets.d.ts +18 -0
  163. package/lib/packages/blocklet-ui-react/lib/common/domain-warning.d.ts +12 -0
  164. package/lib/packages/blocklet-ui-react/lib/common/header-addons.d.ts +19 -0
  165. package/lib/packages/blocklet-ui-react/lib/common/link-blocker.d.ts +4 -0
  166. package/lib/packages/blocklet-ui-react/lib/common/notification-addon.d.ts +10 -0
  167. package/lib/packages/blocklet-ui-react/lib/common/overridable-theme-provider.d.ts +12 -0
  168. package/lib/packages/blocklet-ui-react/lib/common/wallet-hidden-topbar.d.ts +2 -0
  169. package/lib/packages/blocklet-ui-react/lib/common/ws.d.ts +4 -0
  170. package/lib/packages/blocklet-ui-react/lib/contexts/config-user-space.d.ts +7 -0
  171. package/lib/packages/blocklet-ui-react/lib/hooks/use-mobile.d.ts +4 -0
  172. package/lib/packages/blocklet-ui-react/lib/index.d.ts +12 -0
  173. package/lib/packages/blocklet-ui-react/lib/libs/client.d.ts +3 -0
  174. package/lib/packages/blocklet-ui-react/lib/libs/constant.d.ts +2 -0
  175. package/lib/packages/blocklet-ui-react/lib/libs/spaces.d.ts +3 -0
  176. package/lib/packages/blocklet-ui-react/lib/libs/with-hide-when-embed.d.ts +5 -0
  177. package/lib/packages/blocklet-ui-react/lib/types.d.ts +37 -0
  178. package/lib/packages/blocklet-ui-react/lib/utils.d.ts +11 -0
  179. package/lib/{@types → packages/blocklet-ui-react/src/@types}/index.d.ts +3 -3
  180. package/lib/{BlockletStudio → packages/blocklet-ui-react/src/BlockletStudio}/index.d.ts +1 -1
  181. package/lib/packages/blocklet-ui-react/src/ComponentInstaller/ComponentInstaller.stories.d.ts +9 -0
  182. package/lib/packages/blocklet-ui-react/src/ComponentInstaller/demo/basic.d.ts +29 -0
  183. package/lib/packages/blocklet-ui-react/src/ComponentInstaller/demo/mock-optional-components.d.ts +2 -0
  184. package/lib/packages/blocklet-ui-react/src/ComponentInstaller/index.d.ts +18 -0
  185. package/lib/packages/blocklet-ui-react/src/ComponentInstaller/installer-item.d.ts +18 -0
  186. package/lib/{ComponentInstaller → packages/blocklet-ui-react/src/ComponentInstaller}/use-component-installed.d.ts +1 -1
  187. package/lib/{ComponentManager → packages/blocklet-ui-react/src/ComponentManager}/components/add-component.d.ts +2 -2
  188. package/lib/packages/blocklet-ui-react/src/ComponentManager/components/check-component.d.ts +2 -0
  189. package/lib/{ComponentManager → packages/blocklet-ui-react/src/ComponentManager}/components/publish-component.d.ts +2 -2
  190. package/lib/{ComponentManager → packages/blocklet-ui-react/src/ComponentManager}/components/resource-dialog.d.ts +2 -2
  191. package/lib/packages/blocklet-ui-react/src/Dashboard/Dashboard.stories.d.ts +13 -0
  192. package/lib/packages/blocklet-ui-react/src/Dashboard/demo/basic.d.ts +29 -0
  193. package/lib/packages/blocklet-ui-react/src/Dashboard/index.d.ts +30 -0
  194. package/lib/packages/blocklet-ui-react/src/Footer/Footer.stories.d.ts +19 -0
  195. package/lib/packages/blocklet-ui-react/src/Footer/brand.d.ts +15 -0
  196. package/lib/packages/blocklet-ui-react/src/Footer/copyright.d.ts +13 -0
  197. package/lib/packages/blocklet-ui-react/src/Footer/demo/arcblock-site.d.ts +31 -0
  198. package/lib/packages/blocklet-ui-react/src/Footer/demo/brand.d.ts +1 -0
  199. package/lib/packages/blocklet-ui-react/src/Footer/demo/copyright.d.ts +1 -0
  200. package/lib/packages/blocklet-ui-react/src/Footer/demo/footer.d.ts +10 -0
  201. package/lib/packages/blocklet-ui-react/src/Footer/demo/links.d.ts +1 -0
  202. package/lib/packages/blocklet-ui-react/src/Footer/demo/social-media-icons.d.ts +1 -0
  203. package/lib/packages/blocklet-ui-react/src/Footer/index.d.ts +6 -0
  204. package/lib/packages/blocklet-ui-react/src/Footer/internal-footer.d.ts +32 -0
  205. package/lib/packages/blocklet-ui-react/src/Footer/layout/plain.d.ts +22 -0
  206. package/lib/packages/blocklet-ui-react/src/Footer/layout/row.d.ts +13 -0
  207. package/lib/packages/blocklet-ui-react/src/Footer/layout/standard.d.ts +24 -0
  208. package/lib/packages/blocklet-ui-react/src/Footer/links.d.ts +23 -0
  209. package/lib/packages/blocklet-ui-react/src/Footer/social-media.d.ts +14 -0
  210. package/lib/packages/blocklet-ui-react/src/Header/Header.stories.d.ts +26 -0
  211. package/lib/packages/blocklet-ui-react/src/Header/demo/addons-customization.d.ts +11 -0
  212. package/lib/packages/blocklet-ui-react/src/Header/demo/basic.d.ts +1 -0
  213. package/lib/packages/blocklet-ui-react/src/Header/demo/fixtures/index.d.ts +49 -0
  214. package/lib/packages/blocklet-ui-react/src/Header/demo/with-enable-connect-enable-locale.d.ts +1 -0
  215. package/lib/{Header → packages/blocklet-ui-react/src/Header}/index.d.ts +3 -2
  216. package/lib/packages/blocklet-ui-react/src/Icon/Icon.stories.d.ts +12 -0
  217. package/lib/packages/blocklet-ui-react/src/Icon/demo/basic.d.ts +1 -0
  218. package/lib/{Icon → packages/blocklet-ui-react/src/Icon}/index.d.ts +2 -3
  219. package/lib/packages/blocklet-ui-react/src/Notifications/Snackbar.d.ts +16 -0
  220. package/lib/{Notifications → packages/blocklet-ui-react/src/Notifications}/hooks/use-title.d.ts +1 -1
  221. package/lib/{Notifications → packages/blocklet-ui-react/src/Notifications}/utils.d.ts +2 -2
  222. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/config-inviter.d.ts +1 -1
  223. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/config-profile.d.ts +1 -1
  224. package/lib/packages/blocklet-ui-react/src/UserCenter/components/danger-zone.d.ts +1 -0
  225. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/editable-field.d.ts +3 -3
  226. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/nft.d.ts +1 -1
  227. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/notification.d.ts +1 -1
  228. package/lib/packages/blocklet-ui-react/src/UserCenter/components/passport.d.ts +5 -0
  229. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/privacy.d.ts +1 -1
  230. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/settings.d.ts +2 -2
  231. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/status-dialog/date-picker.d.ts +1 -1
  232. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/status-dialog/index.d.ts +1 -1
  233. package/lib/packages/blocklet-ui-react/src/UserCenter/components/status-selector/duration-menu.d.ts +7 -0
  234. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/status-selector/index.d.ts +1 -1
  235. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/status-selector/menu-item.d.ts +4 -4
  236. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/storage/action.d.ts +1 -1
  237. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/storage/connected.d.ts +1 -1
  238. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/storage/delete.d.ts +1 -1
  239. package/lib/packages/blocklet-ui-react/src/UserCenter/components/storage/disconnect.d.ts +2 -0
  240. package/lib/packages/blocklet-ui-react/src/UserCenter/components/storage/index.d.ts +2 -0
  241. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/storage/preview-nft.d.ts +1 -1
  242. package/lib/packages/blocklet-ui-react/src/UserCenter/components/third-party-login/index.d.ts +4 -0
  243. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/third-party-login/third-party-item.d.ts +2 -2
  244. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-center.d.ts +2 -2
  245. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/address.d.ts +2 -2
  246. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/link-preview-input.d.ts +1 -1
  247. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/metadata.d.ts +2 -2
  248. package/lib/packages/blocklet-ui-react/src/UserCenter/components/user-info/switch-role.d.ts +7 -0
  249. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/timezone-select.d.ts +1 -1
  250. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/user-basic-info.d.ts +3 -3
  251. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/user-info-item.d.ts +1 -1
  252. package/lib/packages/blocklet-ui-react/src/UserCenter/components/user-info/user-info.d.ts +6 -0
  253. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/user-status.d.ts +2 -2
  254. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/utils.d.ts +8 -5
  255. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/webhook-item.d.ts +1 -1
  256. package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/libs/utils.d.ts +1 -1
  257. package/lib/{UserSessions → packages/blocklet-ui-react/src/UserSessions}/components/user-session-info.d.ts +1 -1
  258. package/lib/{UserSessions → packages/blocklet-ui-react/src/UserSessions}/components/user-sessions.d.ts +1 -1
  259. package/lib/packages/blocklet-ui-react/src/common/domain-warning.d.ts +12 -0
  260. package/lib/packages/blocklet-ui-react/src/common/header-addons.d.ts +19 -0
  261. package/lib/{common → packages/blocklet-ui-react/src/common}/link-blocker.d.ts +1 -1
  262. package/lib/{common → packages/blocklet-ui-react/src/common}/notification-addon.d.ts +3 -6
  263. package/lib/{common → packages/blocklet-ui-react/src/common}/overridable-theme-provider.d.ts +5 -8
  264. package/lib/{contexts → packages/blocklet-ui-react/src/contexts}/config-user-space.d.ts +3 -3
  265. package/lib/{libs → packages/blocklet-ui-react/src/libs}/with-hide-when-embed.d.ts +1 -1
  266. package/lib/packages/blocklet-ui-react/src/types.d.ts +36 -0
  267. package/lib/packages/blocklet-ui-react/tools/auto-exports.d.ts +1 -0
  268. package/lib/packages/blocklet-ui-react/tools/jest.d.ts +1 -0
  269. package/lib/packages/blocklet-ui-react/vite.config.d.mts +2 -0
  270. package/lib/types.js +39 -39
  271. package/lib/utils.js +61 -175
  272. package/package.json +28 -34
  273. package/src/ComponentInstaller/ComponentInstaller.stories.jsx +16 -0
  274. package/src/ComponentInstaller/index.jsx +11 -27
  275. package/src/ComponentInstaller/installer-item.jsx +1 -5
  276. package/src/ComponentManager/components/add-component.tsx +3 -3
  277. package/src/ComponentManager/components/publish-component.tsx +3 -3
  278. package/src/Dashboard/Dashboard.stories.jsx +20 -0
  279. package/src/Dashboard/index.jsx +16 -27
  280. package/src/Footer/Footer.stories.jsx +32 -0
  281. package/src/Footer/brand.jsx +1 -7
  282. package/src/Footer/copyright.jsx +1 -6
  283. package/src/Footer/index.jsx +1 -6
  284. package/src/Footer/internal-footer.jsx +26 -16
  285. package/src/Footer/layout/row.jsx +2 -7
  286. package/src/Footer/layout/standard.jsx +12 -2
  287. package/src/Footer/links.jsx +2 -7
  288. package/src/Footer/social-media.jsx +1 -5
  289. package/src/Header/Header.stories.jsx +30 -0
  290. package/src/Header/index.tsx +1 -1
  291. package/src/Icon/Icon.stories.jsx +12 -0
  292. package/src/Notifications/Snackbar.tsx +119 -126
  293. package/src/Notifications/hooks/use-title.tsx +5 -2
  294. package/src/Notifications/hooks/use-width.tsx +1 -1
  295. package/src/UserCenter/components/config-profile.tsx +0 -1
  296. package/src/UserCenter/components/danger-zone.tsx +7 -3
  297. package/src/UserCenter/components/editable-field.tsx +45 -44
  298. package/src/UserCenter/components/nft.tsx +21 -9
  299. package/src/UserCenter/components/notification.tsx +22 -6
  300. package/src/UserCenter/components/privacy.tsx +1 -1
  301. package/src/UserCenter/components/settings.tsx +6 -1
  302. package/src/UserCenter/components/status-dialog/date-picker.tsx +10 -7
  303. package/src/UserCenter/components/status-dialog/index.tsx +11 -4
  304. package/src/UserCenter/components/status-selector/duration-menu.tsx +7 -2
  305. package/src/UserCenter/components/status-selector/index.tsx +7 -1
  306. package/src/UserCenter/components/status-selector/menu-item.tsx +1 -2
  307. package/src/UserCenter/components/storage/action.tsx +1 -2
  308. package/src/UserCenter/components/storage/connected.tsx +18 -5
  309. package/src/UserCenter/components/storage/delete.tsx +1 -1
  310. package/src/UserCenter/components/storage/disconnect.tsx +10 -2
  311. package/src/UserCenter/components/storage/index.tsx +6 -1
  312. package/src/UserCenter/components/storage/preview-nft.tsx +1 -1
  313. package/src/UserCenter/components/third-party-login/index.tsx +2 -2
  314. package/src/UserCenter/components/third-party-login/third-party-item.tsx +11 -7
  315. package/src/UserCenter/components/user-center.tsx +10 -5
  316. package/src/UserCenter/components/user-info/address.tsx +12 -6
  317. package/src/UserCenter/components/user-info/link-preview-input.tsx +36 -51
  318. package/src/UserCenter/components/user-info/metadata.tsx +45 -39
  319. package/src/UserCenter/components/user-info/timezone-select.tsx +2 -5
  320. package/src/UserCenter/components/user-info/user-basic-info.tsx +24 -8
  321. package/src/UserCenter/components/user-info/user-info-item.tsx +7 -2
  322. package/src/UserCenter/components/user-info/user-status.tsx +7 -9
  323. package/src/UserCenter/components/user-info/utils.ts +77 -11
  324. package/src/UserCenter/components/webhook-item.tsx +4 -2
  325. package/src/UserSessions/components/user-sessions.tsx +1 -1
  326. package/src/common/domain-warning.jsx +2 -14
  327. package/src/common/header-addons.jsx +8 -11
  328. package/src/common/notification-addon.jsx +1 -7
  329. package/src/common/overridable-theme-provider.jsx +1 -5
  330. package/src/common/ws.js +2 -2
  331. package/src/contexts/config-user-space.tsx +3 -3
  332. package/vite.config.mjs +31 -0
  333. package/lib/@types/shims.d.ts +0 -18
  334. package/lib/ComponentInstaller/index.d.ts +0 -37
  335. package/lib/ComponentInstaller/installer-item.d.ts +0 -21
  336. package/lib/ComponentManager/components/check-component.d.ts +0 -2
  337. package/lib/Dashboard/index.d.ts +0 -44
  338. package/lib/Footer/brand.d.ts +0 -22
  339. package/lib/Footer/copyright.d.ts +0 -18
  340. package/lib/Footer/index.d.ts +0 -6
  341. package/lib/Footer/internal-footer.d.ts +0 -29
  342. package/lib/Footer/layout/plain.d.ts +0 -15
  343. package/lib/Footer/layout/row.d.ts +0 -18
  344. package/lib/Footer/layout/standard.d.ts +0 -17
  345. package/lib/Footer/links.d.ts +0 -23
  346. package/lib/Footer/social-media.d.ts +0 -14
  347. package/lib/Notifications/Snackbar.d.ts +0 -14
  348. package/lib/UserCenter/components/danger-zone.d.ts +0 -1
  349. package/lib/UserCenter/components/passport.d.ts +0 -5
  350. package/lib/UserCenter/components/status-selector/duration-menu.d.ts +0 -7
  351. package/lib/UserCenter/components/storage/disconnect.d.ts +0 -2
  352. package/lib/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
  353. package/lib/UserCenter/components/storage/icons/long-arrow.svg +0 -5
  354. package/lib/UserCenter/components/storage/icons/space-connected.svg +0 -3
  355. package/lib/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
  356. package/lib/UserCenter/components/storage/index.d.ts +0 -2
  357. package/lib/UserCenter/components/third-party-login/index.d.ts +0 -4
  358. package/lib/UserCenter/components/user-info/switch-role.d.ts +0 -7
  359. package/lib/UserCenter/components/user-info/user-info.d.ts +0 -6
  360. package/lib/common/domain-warning.d.ts +0 -17
  361. package/lib/common/header-addons.d.ts +0 -27
  362. package/lib/types.d.ts +0 -2
  363. /package/lib/{ComponentInstaller → packages/blocklet-ui-react/src/ComponentInstaller}/locales.d.ts +0 -0
  364. /package/lib/{ComponentManager → packages/blocklet-ui-react/src/ComponentManager}/index.d.ts +0 -0
  365. /package/lib/{ComponentManager → packages/blocklet-ui-react/src/ComponentManager}/libs/locales.d.ts +0 -0
  366. /package/lib/{Notifications → packages/blocklet-ui-react/src/Notifications}/hooks/use-width.d.ts +0 -0
  367. /package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/components/user-info/index.d.ts +0 -0
  368. /package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/index.d.ts +0 -0
  369. /package/lib/{UserCenter → packages/blocklet-ui-react/src/UserCenter}/libs/locales.d.ts +0 -0
  370. /package/lib/{UserSessions → packages/blocklet-ui-react/src/UserSessions}/index.d.ts +0 -0
  371. /package/lib/{UserSessions → packages/blocklet-ui-react/src/UserSessions}/libs/locales.d.ts +0 -0
  372. /package/lib/{UserSessions → packages/blocklet-ui-react/src/UserSessions}/libs/utils.d.ts +0 -0
  373. /package/lib/{blocklets.d.ts → packages/blocklet-ui-react/src/blocklets.d.ts} +0 -0
  374. /package/lib/{common → packages/blocklet-ui-react/src/common}/wallet-hidden-topbar.d.ts +0 -0
  375. /package/lib/{common → packages/blocklet-ui-react/src/common}/ws.d.ts +0 -0
  376. /package/lib/{hooks → packages/blocklet-ui-react/src/hooks}/use-mobile.d.ts +0 -0
  377. /package/lib/{index.d.ts → packages/blocklet-ui-react/src/index.d.ts} +0 -0
  378. /package/lib/{libs → packages/blocklet-ui-react/src/libs}/client.d.ts +0 -0
  379. /package/lib/{libs → packages/blocklet-ui-react/src/libs}/constant.d.ts +0 -0
  380. /package/lib/{libs → packages/blocklet-ui-react/src/libs}/spaces.d.ts +0 -0
  381. /package/lib/{utils.d.ts → packages/blocklet-ui-react/src/utils.d.ts} +0 -0
@@ -1,37 +1,44 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { useContext } from "react";
3
- import { Box, CircularProgress, Divider, Typography } from "@mui/material";
4
- import { useCreation, useMemoizedFn, useRequest } from "ahooks";
5
- import pWaitFor from "p-wait-for";
6
- import { SessionContext } from "@arcblock/did-connect/lib/Session";
7
- import Tabs from "@arcblock/ux/lib/Tabs";
8
- import Empty from "@arcblock/ux/lib/Empty";
9
- import Button from "@arcblock/ux/lib/Button";
10
- import Result from "@arcblock/ux/lib/Result";
11
- import { useConfirm } from "@arcblock/ux/lib/Dialog";
12
- import { translate } from "@arcblock/ux/lib/Locale/util";
13
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
14
- import { ErrorFallback } from "@arcblock/ux/lib/ErrorBoundary";
15
- import { styled } from "@arcblock/ux/lib/Theme";
16
- import cloneDeep from "lodash/cloneDeep";
17
- import { getQuery, withQuery, joinURL, withoutTrailingSlash } from "ufo";
18
- import { PROFILE_URL } from "@arcblock/ux/lib/Util/constant";
19
- import Footer from "../../Footer/index.js";
20
- import Header from "../../Header/index.js";
21
- import { translations } from "../libs/locales.js";
22
- import { UserBasicInfo } from "./user-info/index.js";
23
- import { formatBlockletInfo, getLink, getLocalizedNavigation } from "../../blocklets.js";
24
- import Passport from "./passport.js";
25
- import Settings from "./settings.js";
26
- import { client } from "../../libs/client.js";
27
- import useMobile from "../../hooks/use-mobile.js";
28
- import { ConfigUserSpaceProvider } from "../../contexts/config-user-space.js";
29
- import DidSpace from "./storage/index.js";
30
- import Nft from "./nft.js";
31
- const nftsLink = joinURL(PROFILE_URL, "/nfts");
32
- const settingsLink = joinURL(PROFILE_URL, "/settings");
33
- const didSpacesLink = joinURL(PROFILE_URL, "/did-spaces");
34
- const Main = styled(Box)(({ theme }) => ({
1
+ import { jsx as i, jsxs as m, Fragment as L } from "react/jsx-runtime";
2
+ import { use as vr } from "react";
3
+ import { Box as s, Typography as br, CircularProgress as yr, Divider as Pr } from "@mui/material";
4
+ import { useMemoizedFn as C, useCreation as f, useRequest as or } from "ahooks";
5
+ import kr from "p-wait-for";
6
+ import { SessionContext as Cr } from "@arcblock/did-connect/lib/Session";
7
+ import Dr from "@arcblock/ux/lib/Tabs";
8
+ import F from "@arcblock/ux/lib/Empty";
9
+ import Mr from "@arcblock/ux/lib/Button";
10
+ import Sr from "@arcblock/ux/lib/Result";
11
+ import { useConfirm as Wr } from "@arcblock/ux/lib/Dialog";
12
+ import { translate as zr } from "@arcblock/ux/lib/Locale/util";
13
+ import { useLocaleContext as Ur } from "@arcblock/ux/lib/Locale/context";
14
+ import { ErrorFallback as Lr } from "@arcblock/ux/lib/ErrorBoundary";
15
+ import { styled as fr } from "@arcblock/ux/lib/Theme";
16
+ import Fr from "lodash/cloneDeep";
17
+ import { joinURL as D, getQuery as Rr, withoutTrailingSlash as nr, withQuery as lr } from "ufo";
18
+ import { PROFILE_URL as M } from "@arcblock/ux/lib/Util/constant";
19
+ import Br from "../../Footer/index.js";
20
+ import ar from "../../Header/index.js";
21
+ import { translations as Ir } from "../libs/locales.js";
22
+ import sr from "./user-info/user-basic-info.js";
23
+ import "@mui/icons-material";
24
+ import "@iconify/react";
25
+ import "@arcblock/ux/lib/DID";
26
+ import "@iconify-icons/material-symbols/schedule-outline-rounded";
27
+ import "@iconify-icons/material-symbols/more-time-rounded";
28
+ import "@iconify-icons/material-symbols/captive-portal-rounded";
29
+ import "@iconify-icons/material-symbols/settings-input-antenna-rounded";
30
+ import "@arcblock/ux/lib/RelativeTime";
31
+ import "@arcblock/ux/lib/UserCard/Content/shorten-label";
32
+ import "./user-info/switch-role.js";
33
+ import { formatBlockletInfo as jr, getLink as R, getLocalizedNavigation as Hr } from "../../blocklets.js";
34
+ import Nr from "./passport.js";
35
+ import _r from "./settings.js";
36
+ import { client as dr } from "../../libs/client.js";
37
+ import Er from "../../hooks/use-mobile.js";
38
+ import { ConfigUserSpaceProvider as Or } from "../../contexts/config-user-space.js";
39
+ import Qr from "./storage/index.js";
40
+ import qr from "./nft.js";
41
+ const B = D(M, "/nfts"), I = D(M, "/settings"), j = D(M, "/did-spaces"), ur = fr(s)(({ theme: v }) => ({
35
42
  flex: 1,
36
43
  boxSizing: "border-box",
37
44
  padding: "0 16px",
@@ -42,14 +49,13 @@ const Main = styled(Box)(({ theme }) => ({
42
49
  alignItems: "stretch",
43
50
  gap: 2.5,
44
51
  flexDirection: "column",
45
- [theme.breakpoints.up("md")]: {
52
+ [v.breakpoints.up("md")]: {
46
53
  flexDirection: "row"
47
54
  }
48
- }));
49
- const ContentWrapper = styled(Box)(({ theme }) => ({
55
+ })), H = fr(s)(({ theme: v }) => ({
50
56
  overflow: "hidden",
51
57
  flex: "revert",
52
- [theme.breakpoints.up("md")]: {
58
+ [v.breakpoints.up("md")]: {
53
59
  flex: 1
54
60
  },
55
61
  "@media (min-width: 850px) and (max-width: 1050px)": {
@@ -58,84 +64,50 @@ const ContentWrapper = styled(Box)(({ theme }) => ({
58
64
  }
59
65
  }
60
66
  }));
61
- export default function UserCenter({
62
- children,
63
- notLoginContent = null,
64
- currentTab,
65
- contentProps = {},
66
- disableAutoRedirect = false,
67
- hideFooter = false,
68
- headerProps = {},
69
- footerProps = {},
70
- userDid = void 0,
71
- stickySidebar = false,
72
- embed = false,
73
- onlyProfile = false
67
+ function Le({
68
+ children: v,
69
+ notLoginContent: N = null,
70
+ currentTab: x,
71
+ contentProps: _ = {},
72
+ disableAutoRedirect: E = !1,
73
+ hideFooter: cr = !1,
74
+ headerProps: pr = {},
75
+ footerProps: mr = {},
76
+ userDid: S = void 0,
77
+ stickySidebar: O = !1,
78
+ embed: Q = !1,
79
+ onlyProfile: b = !1
74
80
  // 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
75
81
  }) {
76
- const { locale } = useLocaleContext();
77
- const isMobile = useMobile({ key: "md" });
78
- const t = useMemoizedFn((key, data = {}) => {
79
- return translate(translations, key, locale, "en", data);
80
- });
81
- const sessionCtx = useContext(SessionContext);
82
- const session = sessionCtx?.session;
83
- const currentDid = useCreation(() => {
84
- if (userDid) {
85
- return userDid;
86
- }
87
- const currentUrl = window.location.href;
88
- const query = getQuery(currentUrl);
89
- if (query?.did) {
90
- if (Array.isArray(query.did)) {
91
- return query.did[0];
92
- }
93
- return query.did;
94
- }
95
- return session?.user?.did;
96
- }, [session?.user?.did, userDid]);
97
- const isMyself = useCreation(() => {
98
- if (session?.user) {
99
- return currentDid === session?.user?.did;
100
- }
101
- return false;
102
- }, [currentDid, session?.user?.did]);
103
- const userState = useRequest(
82
+ var rr, er, tr;
83
+ const { locale: g } = Ur(), d = Er({ key: "md" }), w = C((e, o = {}) => zr(Ir, e, g, "en", o)), W = vr(Cr), r = W == null ? void 0 : W.session, h = f(() => {
84
+ var p;
85
+ if (S)
86
+ return S;
87
+ const e = window.location.href, o = Rr(e);
88
+ return o != null && o.did ? Array.isArray(o.did) ? o.did[0] : o.did : (p = r == null ? void 0 : r.user) == null ? void 0 : p.did;
89
+ }, [(rr = r == null ? void 0 : r.user) == null ? void 0 : rr.did, S]), n = f(() => {
90
+ var e;
91
+ return r != null && r.user ? h === ((e = r == null ? void 0 : r.user) == null ? void 0 : e.did) : !1;
92
+ }, [h, (er = r == null ? void 0 : r.user) == null ? void 0 : er.did]), l = or(
104
93
  // eslint-disable-next-line consistent-return
105
94
  async () => {
106
- await pWaitFor(() => session?.initialized);
107
- if (isMyself) {
108
- return session.user;
109
- }
110
- if (currentDid) {
111
- return client.user.getUserPublicInfo({ did: currentDid });
112
- }
95
+ if (await kr(() => r == null ? void 0 : r.initialized), n)
96
+ return r.user;
97
+ if (h)
98
+ return dr.user.getUserPublicInfo({ did: h });
113
99
  },
114
100
  {
115
- refreshDeps: [currentDid, isMyself, session?.initialized, session?.user]
116
- }
117
- );
118
- const onRefreshUser = useMemoizedFn(() => {
119
- if (isMyself) {
120
- return session.refresh();
101
+ refreshDeps: [h, n, r == null ? void 0 : r.initialized, r == null ? void 0 : r.user]
121
102
  }
122
- return userState.refresh();
123
- });
124
- const privacyState = useRequest(
125
- async () => {
126
- if (userState.data && currentTab) {
127
- const config = await client.user.getUserPrivacyConfig({ did: currentDid });
128
- return config;
129
- }
130
- return null;
131
- },
103
+ ), q = C(() => n ? r.refresh() : l.refresh()), c = or(
104
+ async () => l.data && x ? await dr.user.getUserPrivacyConfig({ did: h }) : null,
132
105
  {
133
- refreshDeps: [currentDid, userState.data, currentTab],
106
+ refreshDeps: [h, l.data, x],
134
107
  loadingDelay: 300
135
108
  }
136
- );
137
- const { confirmHolder } = useConfirm({
138
- fullScreen: isMobile,
109
+ ), { confirmHolder: G } = Wr({
110
+ fullScreen: d,
139
111
  sx: {
140
112
  ".MuiDialog-paper": {
141
113
  borderRadius: 1,
@@ -154,391 +126,300 @@ export default function UserCenter({
154
126
  }
155
127
  }
156
128
  }
157
- });
158
- const formattedBlocklet = useCreation(() => {
159
- const blocklet = cloneDeep(window.blocklet);
129
+ }), P = f(() => {
130
+ const e = Fr(window.blocklet);
160
131
  try {
161
- return formatBlockletInfo(blocklet);
162
- } catch (e) {
163
- console.error("Failed to format blocklet info", e, blocklet);
164
- return blocklet;
132
+ return jr(e);
133
+ } catch (o) {
134
+ return console.error("Failed to format blocklet info", o, e), e;
165
135
  }
166
- }, []);
167
- const defaultTabs = useCreation(() => {
168
- const nftTab = {
169
- label: t("common.nft"),
170
- protected: false,
171
- isPrivate: false,
136
+ }, []), J = f(() => {
137
+ const e = {
138
+ label: w("common.nft"),
139
+ protected: !1,
140
+ isPrivate: !1,
172
141
  // true: 隐私数据,仅自己可见
173
- value: nftsLink,
174
- url: getLink(nftsLink, locale)
142
+ value: B,
143
+ url: R(B, g)
175
144
  };
176
- let tabs = [nftTab];
177
- if (isMyself) {
178
- tabs = [
179
- nftTab,
180
- {
181
- label: t("common.setting"),
182
- protected: true,
183
- isPrivate: true,
184
- value: settingsLink,
185
- url: getLink(settingsLink, locale)
186
- },
187
- {
188
- label: t("storageManagement"),
189
- protected: true,
190
- isPrivate: true,
191
- value: didSpacesLink,
192
- url: getLink(didSpacesLink, locale)
193
- }
194
- ];
195
- }
196
- return tabs;
197
- }, [isMyself, locale]);
198
- const userCenterTabs = useCreation(() => {
199
- const menus = formattedBlocklet?.navigation?.userCenter || [];
200
- const localizedMenus = getLocalizedNavigation(menus, locale) || [];
201
- const allMenus = localizedMenus.concat(defaultTabs);
202
- return allMenus.map((x) => {
203
- const value = x.value ?? x._rawLink ?? x.link ?? x.url;
145
+ let o = [e];
146
+ return n && (o = [
147
+ e,
148
+ {
149
+ label: w("common.setting"),
150
+ protected: !0,
151
+ isPrivate: !0,
152
+ value: I,
153
+ url: R(I, g)
154
+ },
155
+ {
156
+ label: w("storageManagement"),
157
+ protected: !0,
158
+ isPrivate: !0,
159
+ value: j,
160
+ url: R(j, g)
161
+ }
162
+ ]), o;
163
+ }, [n, g]), a = f(() => {
164
+ var y;
165
+ const e = ((y = P == null ? void 0 : P.navigation) == null ? void 0 : y.userCenter) || [];
166
+ return (Hr(e, g) || []).concat(J).map((u) => {
167
+ var k, ir;
168
+ const U = u.value ?? u._rawLink ?? u.link ?? u.url;
204
169
  return {
205
- value,
206
- label: x.title || x.label,
207
- url: x.link || x.url,
208
- protected: privacyState?.data?.[value] ?? false,
209
- isPrivate: x.isPrivate || x.private || (x?._rawLink?.includes("/customer") ?? false)
170
+ value: U,
171
+ label: u.title || u.label,
172
+ url: u.link || u.url,
173
+ protected: ((k = c == null ? void 0 : c.data) == null ? void 0 : k[U]) ?? !1,
174
+ isPrivate: u.isPrivate || u.private || (((ir = u == null ? void 0 : u._rawLink) == null ? void 0 : ir.includes("/customer")) ?? !1)
210
175
  // FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
211
176
  // icon: x.icon,
212
177
  };
213
- }).filter((x) => isMyself || !x.isPrivate);
214
- }, [formattedBlocklet, userState.data, privacyState?.data, locale, defaultTabs, isMyself]);
215
- const currentActiveTab = useCreation(() => {
216
- return userCenterTabs.find((x) => withoutTrailingSlash(x.value) === withoutTrailingSlash(currentTab));
217
- }, [userCenterTabs]);
218
- const handleChangeTab = useMemoizedFn((value) => {
219
- const findTab = userCenterTabs.find((x) => x.value === value);
220
- if (findTab) {
221
- window.location.href = withQuery(findTab.url, {
222
- did: isMyself ? void 0 : currentDid
223
- });
178
+ }).filter((u) => n || !u.isPrivate);
179
+ }, [P, l.data, c == null ? void 0 : c.data, g, J, n]), t = f(() => a.find((e) => nr(e.value) === nr(x)), [a]), hr = C((e) => {
180
+ const o = a.find((p) => p.value === e);
181
+ o && (window.location.href = lr(o.url, {
182
+ did: n ? void 0 : h
183
+ }));
184
+ }), K = f(() => /* @__PURE__ */ i(
185
+ _r,
186
+ {
187
+ user: l.data,
188
+ settings: { userCenterTabs: a },
189
+ onSave: async (e) => e === "privacy" ? (await c.runAsync(), c.data) : (e === "profile" && await r.refresh(), null),
190
+ isMobile: d
224
191
  }
225
- });
226
- const settingContent = useCreation(() => {
227
- return /* @__PURE__ */ jsx(
228
- Settings,
229
- {
230
- user: userState.data,
231
- settings: { userCenterTabs },
232
- onSave: async (type) => {
233
- if (type === "privacy") {
234
- await privacyState.runAsync();
235
- return privacyState.data;
236
- }
237
- if (type === "profile") {
238
- await session.refresh();
239
- }
240
- return null;
241
- },
242
- isMobile
243
- }
244
- );
245
- }, [userState.data, userCenterTabs, privacyState.data, privacyState.runAsync]);
246
- const isSettingTab = useCreation(() => {
247
- return currentActiveTab && currentActiveTab?.value === settingsLink;
248
- }, [currentActiveTab]);
249
- const isNftsTab = useCreation(() => {
250
- return currentActiveTab && currentActiveTab?.value === joinURL(PROFILE_URL, "/profile") || currentActiveTab?.value === nftsLink;
251
- }, [currentActiveTab]);
252
- const isDidSpaceTab = useCreation(() => {
253
- return currentActiveTab && currentActiveTab?.value === didSpacesLink;
254
- }, [currentActiveTab]);
255
- const oauth = session.useOAuth();
256
- const passkey = session.usePasskey();
257
- const handleSwitchPassport = useMemoizedFn(() => {
258
- if (session?.user?.sourceProvider === "passkey") {
259
- passkey.switchPassport(session.user);
260
- } else if (["google", "apple", "email", "github"].includes(session?.user?.sourceProvider ?? "")) {
261
- oauth.switchOAuthPassport(session.user);
262
- } else if (session) {
263
- session.switchPassport();
192
+ ), [l.data, a, c.data, c.runAsync]), V = f(() => t && (t == null ? void 0 : t.value) === I, [t]), X = f(() => t && (t == null ? void 0 : t.value) === D(M, "/profile") || (t == null ? void 0 : t.value) === B, [t]), xr = f(() => t && (t == null ? void 0 : t.value) === j, [t]), gr = r.useOAuth(), wr = r.usePasskey(), Y = C(() => {
193
+ var e, o;
194
+ ((e = r == null ? void 0 : r.user) == null ? void 0 : e.sourceProvider) === "passkey" ? wr.switchPassport(r.user) : ["google", "apple", "email", "github"].includes(((o = r == null ? void 0 : r.user) == null ? void 0 : o.sourceProvider) ?? "") ? gr.switchOAuthPassport(r.user) : r && r.switchPassport();
195
+ }), z = f(() => X ? /* @__PURE__ */ m(
196
+ s,
197
+ {
198
+ sx: {
199
+ display: "flex",
200
+ flexDirection: "column",
201
+ gap: 2.5
202
+ },
203
+ children: [
204
+ n ? /* @__PURE__ */ m(s, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
205
+ /* @__PURE__ */ i(
206
+ br,
207
+ {
208
+ sx: {
209
+ color: "text.primary",
210
+ fontWeight: 600,
211
+ mb: 2.5
212
+ },
213
+ children: w("passport")
214
+ }
215
+ ),
216
+ /* @__PURE__ */ i(Nr, { user: l.data })
217
+ ] }) : null,
218
+ /* @__PURE__ */ i(qr, { user: l.data })
219
+ ]
264
220
  }
265
- });
266
- const renderDefaultTab = useCreation(() => {
267
- if (isNftsTab) {
268
- return /* @__PURE__ */ jsxs(
269
- Box,
270
- {
271
- sx: {
272
- display: "flex",
273
- flexDirection: "column",
274
- gap: 2.5
275
- },
276
- children: [
277
- isMyself ? /* @__PURE__ */ jsxs(Box, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
278
- /* @__PURE__ */ jsx(
279
- Typography,
280
- {
281
- sx: {
282
- color: "text.primary",
283
- fontWeight: 600,
284
- mb: 2.5
285
- },
286
- children: t("passport")
287
- }
288
- ),
289
- /* @__PURE__ */ jsx(Passport, { user: userState.data })
290
- ] }) : null,
291
- /* @__PURE__ */ jsx(Nft, { user: userState.data })
292
- ]
293
- }
294
- );
221
+ ) : V && n ? K : xr && n ? /* @__PURE__ */ i(Or, { children: /* @__PURE__ */ i(Qr, {}) }) : null, [V, X, l, n, O, K]), Z = f(() => /* @__PURE__ */ i(
222
+ s,
223
+ {
224
+ sx: {
225
+ display: {
226
+ xs: n ? "none" : "block",
227
+ md: "block"
228
+ },
229
+ py: 3
230
+ },
231
+ children: /* @__PURE__ */ i(F, { children: w("emptyContent") })
295
232
  }
296
- if (isSettingTab && isMyself) {
297
- return settingContent;
233
+ ), [n, g]), $ = f(() => !c.data || c.loading ? /* @__PURE__ */ i(
234
+ s,
235
+ {
236
+ sx: {
237
+ height: "100%",
238
+ minWidth: "160px",
239
+ minHeight: "160px",
240
+ display: "flex",
241
+ justifyContent: "center",
242
+ alignItems: "center",
243
+ flex: 1
244
+ },
245
+ children: /* @__PURE__ */ i(yr, {})
298
246
  }
299
- if (isDidSpaceTab && isMyself) {
300
- return /* @__PURE__ */ jsx(ConfigUserSpaceProvider, { children: /* @__PURE__ */ jsx(DidSpace, {}) });
247
+ ) : (
248
+ // eslint-disable-next-line react/jsx-no-useless-fragment
249
+ /* @__PURE__ */ i(s, { sx: { flex: 1 }, children: t != null && t.protected && !n ? /* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(F, { children: w("underProtected") }) }) : (
250
+ // eslint-disable-next-line react/jsx-no-useless-fragment
251
+ /* @__PURE__ */ i(L, { children: v ? /* @__PURE__ */ i(s, { ..._, children: v }) : /* @__PURE__ */ i(L, { children: z }) })
252
+ ) })
253
+ ), [c, t, n, v, _, z, g]), T = f(() => {
254
+ var e, o, p, y;
255
+ if (l.loading || r.loading)
256
+ return null;
257
+ if (l.error) {
258
+ if (((o = (e = l.error) == null ? void 0 : e.response) == null ? void 0 : o.status) === 404)
259
+ return /* @__PURE__ */ i(s, { sx: { width: "100%" }, children: /* @__PURE__ */ i(Sr, { status: 404, description: w("noUserFound") }) });
260
+ const k = {
261
+ message: ((y = (p = l.error.response) == null ? void 0 : p.data) == null ? void 0 : y.error) || l.error.message || "error occurred"
262
+ };
263
+ return /* @__PURE__ */ i(s, { sx: { width: "100%" }, children: /* @__PURE__ */ i(Lr, { error: k }) });
301
264
  }
302
- return null;
303
- }, [isSettingTab, isNftsTab, userState, isMyself, stickySidebar, settingContent]);
304
- const emptyContent = useCreation(() => {
305
- return /* @__PURE__ */ jsx(
306
- Box,
265
+ return !h && !l.data ? N || /* @__PURE__ */ i(s, { sx: { width: "100%" }, children: /* @__PURE__ */ m(
266
+ s,
307
267
  {
308
268
  sx: {
309
- display: {
310
- xs: isMyself ? "none" : "block",
311
- md: "block"
312
- },
313
- py: 3
269
+ display: "flex",
270
+ flexDirection: "column",
271
+ justifyContent: "center",
272
+ alignItems: "center",
273
+ gap: 1
314
274
  },
315
- children: /* @__PURE__ */ jsx(Empty, { children: t("emptyContent") })
275
+ children: [
276
+ /* @__PURE__ */ i(F, { children: w("viewAfterLogin") }),
277
+ /* @__PURE__ */ i(Mr, { size: "small", variant: "contained", onClick: () => r.login(), children: w("loginNow") })
278
+ ]
316
279
  }
317
- );
318
- }, [isMyself, locale]);
319
- const tabContent = useCreation(() => {
320
- if (!privacyState.data || privacyState.loading) {
321
- return /* @__PURE__ */ jsx(
322
- Box,
280
+ ) }) : Q ? /* @__PURE__ */ m(H, { children: [
281
+ a.length > 0 && x ? /* @__PURE__ */ i(
282
+ s,
323
283
  {
324
284
  sx: {
285
+ display: d ? "block" : "flex",
325
286
  height: "100%",
326
- minWidth: "160px",
327
- minHeight: "160px",
328
- display: "flex",
329
- justifyContent: "center",
330
- alignItems: "center",
331
- flex: 1
287
+ overflow: "auto",
288
+ padding: "1px"
332
289
  },
333
- children: /* @__PURE__ */ jsx(CircularProgress, {})
290
+ children: $
291
+ }
292
+ ) : null,
293
+ a.length === 0 && Z
294
+ ] }) : b ? /* @__PURE__ */ i(H, { display: "flex", flexDirection: d ? "column" : "row", children: /* @__PURE__ */ i(
295
+ sr,
296
+ {
297
+ isMobile: d,
298
+ order: d ? 1 : "unset",
299
+ isMyself: n,
300
+ switchPassport: Y,
301
+ switchProfile: r.switchProfile,
302
+ user: l.data,
303
+ showFullDid: !1,
304
+ onlyProfile: b,
305
+ refreshProfile: q,
306
+ sx: {
307
+ padding: d ? "16px 0 0 0" : "40px 24px 24px 40px",
308
+ ...d ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
309
+ boxSizing: "content-box"
334
310
  }
335
- );
336
- }
337
- return (
338
- // eslint-disable-next-line react/jsx-no-useless-fragment
339
- /* @__PURE__ */ jsx(Box, { sx: { flex: 1 }, children: currentActiveTab?.protected && !isMyself ? /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Empty, { children: t("underProtected") }) }) : (
340
- // eslint-disable-next-line react/jsx-no-useless-fragment
341
- /* @__PURE__ */ jsx(Fragment, { children: children ? /* @__PURE__ */ jsx(Box, { ...contentProps, children }) : /* @__PURE__ */ jsx(Fragment, { children: renderDefaultTab }) })
342
- ) })
343
- );
344
- }, [privacyState, currentActiveTab, isMyself, children, contentProps, renderDefaultTab, locale]);
345
- const content = useCreation(() => {
346
- if (userState.loading || session.loading) {
347
- return null;
348
- }
349
- if (userState.error) {
350
- const errorStatus = userState.error?.response?.status;
351
- if (errorStatus === 404) {
352
- return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsx(Result, { status: 404, description: t("noUserFound") }) });
353
- }
354
- const errorMessage = userState.error.response?.data?.error || userState.error.message || "error occurred";
355
- const formatError = {
356
- message: errorMessage
357
- };
358
- return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsx(ErrorFallback, { error: formatError }) });
359
- }
360
- if (!currentDid && !userState.data) {
361
- if (notLoginContent) {
362
- return notLoginContent;
363
311
  }
364
- return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsxs(
365
- Box,
312
+ ) }) : /* @__PURE__ */ m(H, { display: "flex", flexDirection: d ? "column" : "row", children: [
313
+ /* @__PURE__ */ m(
314
+ s,
366
315
  {
316
+ className: "user-center-tabs",
367
317
  sx: {
368
- display: "flex",
369
- flexDirection: "column",
370
- justifyContent: "center",
371
- alignItems: "center",
372
- gap: 1
318
+ flex: "1",
319
+ order: d ? 2 : "unset"
373
320
  },
374
321
  children: [
375
- /* @__PURE__ */ jsx(Empty, { children: t("viewAfterLogin") }),
376
- /* @__PURE__ */ jsx(Button, { size: "small", variant: "contained", onClick: () => session.login(), children: t("loginNow") })
377
- ]
378
- }
379
- ) });
380
- }
381
- if (embed) {
382
- return /* @__PURE__ */ jsxs(ContentWrapper, { children: [
383
- userCenterTabs.length > 0 && currentTab ? /* @__PURE__ */ jsx(
384
- Box,
385
- {
386
- sx: {
387
- display: isMobile ? "block" : "flex",
388
- height: "100%",
389
- overflow: "auto",
390
- padding: "1px"
391
- },
392
- children: tabContent
393
- }
394
- ) : null,
395
- userCenterTabs.length === 0 && emptyContent
396
- ] });
397
- }
398
- if (onlyProfile) {
399
- return /* @__PURE__ */ jsx(ContentWrapper, { display: "flex", flexDirection: isMobile ? "column" : "row", children: /* @__PURE__ */ jsx(
400
- UserBasicInfo,
401
- {
402
- isMobile,
403
- order: isMobile ? 1 : "unset",
404
- isMyself,
405
- switchPassport: handleSwitchPassport,
406
- switchProfile: session.switchProfile,
407
- user: userState.data,
408
- showFullDid: false,
409
- onlyProfile,
410
- refreshProfile: onRefreshUser,
411
- sx: {
412
- padding: !isMobile ? "40px 24px 24px 40px" : "16px 0 0 0",
413
- ...!isMobile ? { width: 320, maxWidth: 320, flexShrink: 0 } : {},
414
- boxSizing: "content-box"
415
- }
416
- }
417
- ) });
418
- }
419
- return /* @__PURE__ */ jsxs(ContentWrapper, { display: "flex", flexDirection: isMobile ? "column" : "row", children: [
420
- /* @__PURE__ */ jsxs(Box, { flex: "1", className: "user-center-tabs", order: isMobile ? 2 : "unset", children: [
421
- userCenterTabs.length > 0 && currentTab ? /* @__PURE__ */ jsxs(
422
- Box,
423
- {
424
- display: "flex",
425
- flexDirection: "column",
426
- sx: {
427
- height: "100%",
428
- overflow: "auto",
429
- padding: "1px"
430
- },
431
- children: [
432
- /* @__PURE__ */ jsx(
433
- Tabs,
434
- {
435
- orientation: "horizontal",
436
- variant: "line",
437
- tabs: userCenterTabs,
438
- current: currentActiveTab?.value ?? currentTab,
439
- onChange: handleChangeTab,
440
- sx: {
441
- mb: 2,
442
- ".MuiTabs-flexContainer": {
443
- gap: 3,
444
- ".MuiButtonBase-root": {
445
- padding: isMobile ? "16px 4px" : "40px 4px 32px 4px",
446
- fontSize: 16
447
- },
448
- ".MuiTab-root": {
449
- display: "block",
450
- textAlign: "left",
451
- alignItems: "flex-start",
452
- justifyContent: "flex-start",
453
- fontWeight: 400
454
- }
455
- },
456
- ".MuiTabs-root": {
457
- "&:after": {
458
- content: '""',
459
- display: "block",
460
- width: "100%",
461
- height: "1px",
462
- backgroundColor: "divider"
322
+ a.length > 0 && x ? /* @__PURE__ */ m(
323
+ s,
324
+ {
325
+ sx: {
326
+ display: "flex",
327
+ flexDirection: "column",
328
+ height: "100%",
329
+ overflow: "auto",
330
+ padding: "1px"
331
+ },
332
+ children: [
333
+ /* @__PURE__ */ i(
334
+ Dr,
335
+ {
336
+ orientation: "horizontal",
337
+ variant: "line",
338
+ tabs: a,
339
+ current: (t == null ? void 0 : t.value) ?? x,
340
+ onChange: hr,
341
+ sx: {
342
+ mb: 2,
343
+ ".MuiTabs-flexContainer": {
344
+ gap: 3,
345
+ ".MuiButtonBase-root": {
346
+ padding: d ? "16px 4px" : "40px 4px 32px 4px",
347
+ fontSize: 16
348
+ },
349
+ ".MuiTab-root": {
350
+ display: "block",
351
+ textAlign: "left",
352
+ alignItems: "flex-start",
353
+ justifyContent: "flex-start",
354
+ fontWeight: 400
355
+ }
356
+ },
357
+ ".MuiTabs-root": {
358
+ "&:after": {
359
+ content: '""',
360
+ display: "block",
361
+ width: "100%",
362
+ height: "1px",
363
+ backgroundColor: "divider"
364
+ }
365
+ }
463
366
  }
464
367
  }
465
- }
466
- }
467
- ),
468
- tabContent
469
- ]
470
- }
471
- ) : null,
472
- userCenterTabs.length === 0 && emptyContent
473
- ] }),
474
- !isMobile && /* @__PURE__ */ jsx(Divider, { orientation: "vertical", sx: { ml: 5 } }),
475
- /* @__PURE__ */ jsx(
476
- UserBasicInfo,
368
+ ),
369
+ $
370
+ ]
371
+ }
372
+ ) : null,
373
+ a.length === 0 && Z
374
+ ]
375
+ }
376
+ ),
377
+ !d && /* @__PURE__ */ i(Pr, { orientation: "vertical", sx: { ml: 5 } }),
378
+ /* @__PURE__ */ i(
379
+ sr,
477
380
  {
478
- isMobile,
479
- order: isMobile ? 1 : "unset",
480
- isMyself,
481
- switchPassport: handleSwitchPassport,
482
- switchProfile: session.switchProfile,
483
- user: userState.data,
484
- refreshProfile: onRefreshUser,
485
- showFullDid: false,
381
+ isMobile: d,
382
+ order: d ? 1 : "unset",
383
+ isMyself: n,
384
+ switchPassport: Y,
385
+ switchProfile: r.switchProfile,
386
+ user: l.data,
387
+ refreshProfile: q,
388
+ showFullDid: !1,
486
389
  sx: {
487
- padding: !isMobile ? "40px 24px 24px 40px" : "16px 0 0 0",
488
- ...!isMobile ? { width: 320, maxWidth: 320, flexShrink: 0 } : {},
390
+ padding: d ? "16px 0 0 0" : "40px 24px 24px 40px",
391
+ ...d ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
489
392
  boxSizing: "content-box"
490
393
  }
491
394
  }
492
395
  )
493
396
  ] });
494
397
  }, [
495
- userState,
496
- userCenterTabs,
497
- isMyself,
498
- currentActiveTab,
499
- privacyState,
500
- currentTab,
501
- stickySidebar,
502
- renderDefaultTab
503
- ]);
504
- const isPrivateActive = useCreation(() => {
505
- if (isMyself) {
506
- return false;
507
- }
508
- return currentActiveTab?.isPrivate;
509
- }, [isMyself, currentActiveTab]);
510
- const shouldRedirect = useCreation(() => {
511
- if (onlyProfile) {
512
- return false;
513
- }
514
- const noActiveTabButHasTabs = !disableAutoRedirect && !currentTab && userCenterTabs?.length > 0;
515
- const invalidCurrentTab = !currentActiveTab;
516
- const accessingPrivateTab = isPrivateActive;
517
- return noActiveTabButHasTabs || invalidCurrentTab || accessingPrivateTab;
518
- }, [disableAutoRedirect, currentTab, userCenterTabs, currentActiveTab, isPrivateActive, onlyProfile]);
519
- if (shouldRedirect) {
520
- const firstUserCenterUrl = userCenterTabs[0]?.url;
521
- const firstTab = userCenterTabs.find((x) => x.value === firstUserCenterUrl);
522
- if (firstUserCenterUrl && !firstTab?.isPrivate) {
523
- window.location.replace(
524
- withQuery(firstUserCenterUrl, {
525
- did: isMyself ? void 0 : currentDid
526
- })
527
- );
528
- }
529
- return null;
530
- }
531
- if (embed || onlyProfile) {
532
- return /* @__PURE__ */ jsxs(Fragment, { children: [
533
- /* @__PURE__ */ jsx(Header, { style: { display: "none" } }),
534
- /* @__PURE__ */ jsxs(Main, { children: [
535
- content,
536
- confirmHolder
537
- ] })
538
- ] });
398
+ l,
399
+ a,
400
+ n,
401
+ t,
402
+ c,
403
+ x,
404
+ O,
405
+ z
406
+ ]), A = f(() => n ? !1 : t == null ? void 0 : t.isPrivate, [n, t]);
407
+ if (f(() => b ? !1 : !E && !x && (a == null ? void 0 : a.length) > 0 || !t || A, [E, x, a, t, A, b])) {
408
+ const e = (tr = a[0]) == null ? void 0 : tr.url, o = a.find((p) => p.value === e);
409
+ return e && !(o != null && o.isPrivate) && window.location.replace(
410
+ lr(e, {
411
+ did: n ? void 0 : h
412
+ })
413
+ ), null;
539
414
  }
540
- return /* @__PURE__ */ jsxs(
541
- Box,
415
+ return Q || b ? /* @__PURE__ */ m(L, { children: [
416
+ /* @__PURE__ */ i(ar, { style: { display: "none" } }),
417
+ /* @__PURE__ */ m(ur, { children: [
418
+ T,
419
+ G
420
+ ] })
421
+ ] }) : /* @__PURE__ */ m(
422
+ s,
542
423
  {
543
424
  sx: {
544
425
  minHeight: "100vh",
@@ -546,16 +427,16 @@ export default function UserCenter({
546
427
  flexDirection: "column"
547
428
  },
548
429
  children: [
549
- /* @__PURE__ */ jsx(Header, { bordered: true, ...headerProps, maxWidth: "100%" }),
550
- /* @__PURE__ */ jsxs(Main, { children: [
551
- content,
552
- confirmHolder
430
+ /* @__PURE__ */ i(ar, { bordered: !0, ...pr, maxWidth: "100%" }),
431
+ /* @__PURE__ */ m(ur, { children: [
432
+ T,
433
+ G
553
434
  ] }),
554
- hideFooter ? null : /* @__PURE__ */ jsx(
555
- Footer,
435
+ cr ? null : /* @__PURE__ */ i(
436
+ Br,
556
437
  {
557
- bordered: true,
558
- ...footerProps,
438
+ bordered: !0,
439
+ ...mr,
559
440
  sx: {
560
441
  ".MuiContainer-root": {
561
442
  maxWidth: 1600
@@ -567,3 +448,6 @@ export default function UserCenter({
567
448
  }
568
449
  );
569
450
  }
451
+ export {
452
+ Le as default
453
+ };