@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 +1,4 @@
1
- export { default as UserSessions } from "./components/user-sessions.js";
1
+ import { default as o } from "./components/user-sessions.js";
2
+ export {
3
+ o as UserSessions
4
+ };
@@ -1,32 +1,32 @@
1
- export const translations = {
1
+ const o = {
2
2
  zh: {
3
- confirm: "\u786E\u8BA4",
4
- cancel: "\u53D6\u6D88",
5
- visitorId: "\u8BBE\u5907\u6807\u8BC6",
6
- deviceType: "\u8BBE\u5907\u7C7B\u578B",
7
- platform: "\u64CD\u4F5C\u7CFB\u7EDF",
8
- walletOS: "\u94B1\u5305\u7C7B\u578B",
9
- role: "\u89D2\u8272",
10
- fullname: "\u59D3\u540D",
11
- email: "\u90AE\u7BB1",
12
- avatar: "\u5934\u50CF",
13
- user: "\u7528\u6237",
14
- createdAt: "\u9996\u6B21\u6D3B\u52A8\u65F6\u95F4",
15
- updatedAt: "\u6700\u8FD1\u6D3B\u52A8\u65F6\u95F4",
16
- lastLoginIp: "\u6700\u8FD1\u6D3B\u52A8\u5730\u5740",
17
- actions: "\u64CD\u4F5C",
18
- logoutAll: "\u6CE8\u9500\u6240\u6709{type}\u4F1A\u8BDD",
19
- logoutAllTips: "\u4E0D\u4F1A\u6CE8\u9500\u5F53\u524D\u4F1A\u8BDD",
20
- logout: "\u6CE8\u9500",
21
- currentSession: "\u5F53\u524D\u4F1A\u8BDD",
22
- unknown: "\u672A\u77E5",
23
- expired: "\u5DF2\u8FC7\u671F",
24
- remove: "\u5220\u9664",
25
- logoutThisSession: "\u6CE8\u9500\u6307\u5B9A\u4F1A\u8BDD",
26
- logoutThisSessionConfirm: "\u786E\u5B9A\u8981\u6CE8\u9500\u6B64\u4F1A\u8BDD\u5417?",
27
- logoutAllSession: "\u6CE8\u9500\u6240\u6709{type}\u4F1A\u8BDD",
28
- logoutAllSessionConfirm: "\u786E\u5B9A\u8981\u6CE8\u9500\u6240\u6709{type}\u4F1A\u8BDD\u5417?",
29
- online: "\u6D3B\u8DC3"
3
+ confirm: "确认",
4
+ cancel: "取消",
5
+ visitorId: "设备标识",
6
+ deviceType: "设备类型",
7
+ platform: "操作系统",
8
+ walletOS: "钱包类型",
9
+ role: "角色",
10
+ fullname: "姓名",
11
+ email: "邮箱",
12
+ avatar: "头像",
13
+ user: "用户",
14
+ createdAt: "首次活动时间",
15
+ updatedAt: "最近活动时间",
16
+ lastLoginIp: "最近活动地址",
17
+ actions: "操作",
18
+ logoutAll: "注销所有{type}会话",
19
+ logoutAllTips: "不会注销当前会话",
20
+ logout: "注销",
21
+ currentSession: "当前会话",
22
+ unknown: "未知",
23
+ expired: "已过期",
24
+ remove: "删除",
25
+ logoutThisSession: "注销指定会话",
26
+ logoutThisSessionConfirm: "确定要注销此会话吗?",
27
+ logoutAllSession: "注销所有{type}会话",
28
+ logoutAllSessionConfirm: "确定要注销所有{type}会话吗?",
29
+ online: "活跃"
30
30
  },
31
31
  en: {
32
32
  confirm: "Confirm",
@@ -58,3 +58,6 @@ export const translations = {
58
58
  online: "Active"
59
59
  }
60
60
  };
61
+ export {
62
+ o as translations
63
+ };
@@ -1,73 +1,47 @@
1
- const RESERVED_IP = "Reserved IP";
2
- const IP_REGION_CACHE = "ip-region-cache";
3
- async function getIpRegionFromIpApi(ip) {
4
- const url = `https://ipapi.co/${ip}/json/`;
5
- const result = await fetch(url);
6
- const data = await result.json();
7
- let region = "";
8
- if (data.error) {
9
- if (data.reserved) {
10
- region = RESERVED_IP;
11
- }
12
- } else {
13
- region = [data.country_name, data.region, data.city].filter(Boolean).join("/");
14
- }
15
- return region;
1
+ const a = "Reserved IP", r = "ip-region-cache";
2
+ async function c(t) {
3
+ const o = `https://ipapi.co/${t}/json/`, e = await (await fetch(o)).json();
4
+ let i = "";
5
+ return e.error ? e.reserved && (i = a) : i = [e.country_name, e.region, e.city].filter(Boolean).join("/"), i;
16
6
  }
17
- async function getIpRegionFromIpSb(ip) {
18
- const url = `https://api.ip.sb/geoip/${ip}`;
19
- const result = await fetch(url);
20
- const data = await result.json();
21
- let region = "";
22
- if (data.error) {
23
- if (data.reserved) {
24
- region = RESERVED_IP;
25
- }
26
- } else {
27
- region = [data.country, data.region, data.city].filter(Boolean).join("/");
28
- }
29
- return region;
7
+ async function s(t) {
8
+ const o = `https://api.ip.sb/geoip/${t}`, e = await (await fetch(o)).json();
9
+ let i = "";
10
+ return e.error ? e.reserved && (i = a) : i = [e.country, e.region, e.city].filter(Boolean).join("/"), i;
30
11
  }
31
- export async function ip2Region(ip) {
32
- let region = "";
33
- let ipRegionCache = {};
12
+ async function l(t) {
13
+ let o = "", n = {};
34
14
  try {
35
- const tmpCache = localStorage.getItem(IP_REGION_CACHE);
36
- if (tmpCache) {
37
- ipRegionCache = JSON.parse(tmpCache);
38
- }
15
+ const e = localStorage.getItem(r);
16
+ e && (n = JSON.parse(e));
39
17
  } catch {
40
- ipRegionCache = {};
18
+ n = {};
41
19
  }
42
- if (ipRegionCache[ip]) {
43
- region = ipRegionCache[ip];
44
- } else {
20
+ if (n[t])
21
+ o = n[t];
22
+ else {
45
23
  try {
46
- region = await getIpRegionFromIpSb(ip);
24
+ o = await s(t);
47
25
  } catch {
48
26
  console.warn("Fail to get ip region from ip.sb");
49
27
  }
50
- if (!region) {
28
+ if (!o)
51
29
  try {
52
- region = await getIpRegionFromIpApi(ip);
30
+ o = await c(t);
53
31
  } catch {
54
32
  console.warn("Fail to get ip region from ip-api.co");
55
33
  }
56
- }
57
34
  }
58
- if (region) {
59
- const ipList = Object.keys(ipRegionCache);
60
- if (ipList.length > 100) {
61
- delete ipRegionCache[ipList[0]];
62
- }
63
- if (ipRegionCache[ip]) {
64
- delete ipRegionCache[ip];
65
- }
66
- ipRegionCache[ip] = region;
67
- localStorage.setItem(IP_REGION_CACHE, JSON.stringify(ipRegionCache));
35
+ if (o) {
36
+ const e = Object.keys(n);
37
+ e.length > 100 && delete n[e[0]], n[t] && delete n[t], n[t] = o, localStorage.setItem(r, JSON.stringify(n));
68
38
  }
69
- return region;
39
+ return o;
70
40
  }
71
- export async function batchIp2Region(ips) {
72
- return Promise.all(ips.map((ip) => ip2Region(ip)));
41
+ async function g(t) {
42
+ return Promise.all(t.map((o) => l(o)));
73
43
  }
44
+ export {
45
+ g as batchIp2Region,
46
+ l as ip2Region
47
+ };
package/lib/blocklets.js CHANGED
@@ -1,103 +1,52 @@
1
- import { mapRecursive, filterRecursive, isUrl } from './utils.js';
2
-
3
- export const publicPath = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || '/';
4
-
5
- /**
6
- * 格式化 theme (目前仅考虑 background)
7
- */
8
- export const formatTheme = (theme) => {
9
- const formatted = { ...theme };
10
- const background = theme?.background;
11
- if (typeof background === 'string') {
12
- formatted.background = { header: background, footer: background, default: background };
13
- } else if (background && typeof background === 'object') {
14
- formatted.background = {
15
- header: background.header || background.default,
16
- footer: background.footer || background.default,
17
- default: background.default,
18
- };
19
- }
20
- return formatted;
21
- };
22
-
23
- export const getLink = (link, locale = 'en') => {
24
- if (typeof link === 'string') {
25
- // http[s] 开头的 url
26
- if (isUrl(link)) {
27
- const url = new URL(link);
28
- url.searchParams.set('locale', locale);
29
- return url.href;
1
+ import { mapRecursive as a, filterRecursive as l, isUrl as d } from "./utils.js";
2
+ var c, u;
3
+ const w = ((c = window == null ? void 0 : window.blocklet) == null ? void 0 : c.groupPrefix) || ((u = window == null ? void 0 : window.blocklet) == null ? void 0 : u.prefix) || "/", h = (r) => {
4
+ const o = { ...r }, s = r == null ? void 0 : r.background;
5
+ return typeof s == "string" ? o.background = { header: s, footer: s, default: s } : s && typeof s == "object" && (o.background = {
6
+ header: s.header || s.default,
7
+ footer: s.footer || s.default,
8
+ default: s.default
9
+ }), o;
10
+ }, i = (r, o = "en") => {
11
+ if (typeof r == "string") {
12
+ if (d(r)) {
13
+ const e = new URL(r);
14
+ return e.searchParams.set("locale", o), e.href;
30
15
  }
31
- const url = new URL(link, window.location.origin);
32
- url.searchParams.set('locale', locale);
33
- return url.pathname + url.search;
34
- }
35
- if (typeof link === 'object') {
36
- return link[locale] || link?.en || link?.zh;
37
- }
38
- return link;
39
- };
40
-
41
- /**
42
- * 获取指定 locale 对应的 navigation 数据, 仅考虑 zh/en
43
- */
44
- export const getLocalizedNavigation = (navigation, locale = 'en') => {
45
- if (!navigation?.length) {
46
- return navigation;
16
+ const s = new URL(r, window.location.origin);
17
+ return s.searchParams.set("locale", o), s.pathname + s.search;
47
18
  }
48
- const trans = (text, _locale) => {
49
- if (text && typeof text === 'object') {
50
- return text[_locale] || text?.en || text?.zh;
51
- }
52
-
53
- return text;
54
- };
55
-
56
- return mapRecursive(
57
- navigation,
58
- (item) => {
19
+ return typeof r == "object" ? r[o] || (r == null ? void 0 : r.en) || (r == null ? void 0 : r.zh) : r;
20
+ }, L = (r, o = "en") => {
21
+ if (!(r != null && r.length))
22
+ return r;
23
+ const s = (e, t) => e && typeof e == "object" ? e[t] || (e == null ? void 0 : e.en) || (e == null ? void 0 : e.zh) : e;
24
+ return a(
25
+ r,
26
+ (e) => {
27
+ var t;
59
28
  return {
60
- ...item,
61
- title: trans(item.title, locale),
62
- description: trans(item.description, locale),
29
+ ...e,
30
+ title: s(e.title, o),
31
+ description: s(e.description, o),
63
32
  // 仅对叶结点进行处理
64
- link: !item.items?.length ? getLink(item.link, locale) : item.link,
65
- _rawLink: item.link,
33
+ link: (t = e.items) != null && t.length ? e.link : i(e.link, o),
34
+ _rawLink: e.link
66
35
  };
67
36
  },
68
- 'items'
69
- );
70
- };
71
-
72
- /**
73
- * 格式化 navigation
74
- *
75
- * - role 统一为数组形式
76
- */
77
- export const formatNavigation = (navigation) => {
78
- return mapRecursive(
79
- navigation,
80
- (item) => {
81
- if (item.role) {
82
- return {
83
- ...item,
84
- role: Array.isArray(item.role) ? item.role : [item.role],
85
- };
86
- }
87
- return item;
88
- },
89
- 'items'
37
+ "items"
90
38
  );
91
- };
92
-
93
- export const parseNavigation = (navigation) => {
94
- if (!navigation?.length) {
39
+ }, p = (r) => a(
40
+ r,
41
+ (o) => o.role ? {
42
+ ...o,
43
+ role: Array.isArray(o.role) ? o.role : [o.role]
44
+ } : o,
45
+ "items"
46
+ ), g = (r) => {
47
+ if (!(r != null && r.length))
95
48
  return null;
96
- }
97
-
98
- const formattedNav = formatNavigation(navigation);
99
-
100
- const sections = {
49
+ const o = p(r), s = {
101
50
  header: [],
102
51
  footer: [],
103
52
  // 对应 footer social media
@@ -108,70 +57,40 @@ export const parseNavigation = (navigation) => {
108
57
  dashboard: [],
109
58
  // session manager menus
110
59
  sessionManager: [],
111
- userCenter: [],
60
+ userCenter: []
112
61
  };
113
-
114
- // 对 navigation 顶层元素按 section 分组
115
- formattedNav.forEach((item) => {
116
- // item#section 为空时, 表示只存在于 header
117
- if (!item.section) {
118
- sections.header.push(item);
119
- // item 出现在指定几个 section 中 (array)
120
- } else if (Array.isArray(item.section)) {
121
- item.section.forEach((sectionKey) => {
122
- sections[sectionKey]?.push(item);
123
- });
124
- // item 出现在指定的一个 section 中 (string)
125
- } else if (typeof item.section === 'string') {
126
- sections[item.section]?.push(item);
127
- }
128
- });
129
-
130
- return sections;
131
- };
132
-
133
- /**
134
- * 格式化 blocklet info 数据
135
- */
136
- export const formatBlockletInfo = (blockletInfo) => {
137
- if (!blockletInfo) {
62
+ return o.forEach((e) => {
63
+ var t;
64
+ e.section ? Array.isArray(e.section) ? e.section.forEach((n) => {
65
+ var f;
66
+ (f = s[n]) == null || f.push(e);
67
+ }) : typeof e.section == "string" && ((t = s[e.section]) == null || t.push(e)) : s.header.push(e);
68
+ }), s;
69
+ }, N = (r) => {
70
+ if (!r)
138
71
  return null;
139
- }
140
- const formatted = { ...blockletInfo };
141
- // theme
142
- formatted.theme = formatTheme(formatted.theme);
143
- // navigation
144
- formatted.navigation = parseNavigation(filterValidNavItems(formatted.navigation));
145
- return formatted;
146
- };
147
-
148
- /**
149
- * 过滤掉无效结点 ( link 且子元素为空)
150
- */
151
- export const filterValidNavItems = (navigation = []) => {
152
- return filterRecursive(navigation, (item, context) => !!item.link || context.filteredChildren?.length, 'items');
153
- };
154
-
155
- /**
156
- * 根据 role 筛选 nav, 规则:
157
- * - 如果是枝结点, 必须至少存在一个符合条件的子结点
158
- * - role 未定义, 符合条件
159
- * - role 定义且包括当前的 userRole, 符合条件
160
- *
161
- * @param {object[]} nav 导航菜单数据
162
- * @param {string} userRole 当前用户 role
163
- * @returns 符合 role 权限的导航菜单数据
164
- */
165
- export const filterNavByRole = (nav, userRole) => {
166
- return filterRecursive(
167
- nav,
168
- (item, context) => {
169
- const isRoleMatched = !item.role || (userRole && (item.role.includes(userRole) || item.role.includes('guest')));
170
- if (!context.isLeaf) {
171
- return isRoleMatched && context.filteredChildren?.length;
172
- }
173
- return isRoleMatched;
174
- },
175
- 'items'
176
- );
72
+ const o = { ...r };
73
+ return o.theme = h(o.theme), o.navigation = g(b(o.navigation)), o;
74
+ }, b = (r = []) => l(r, (o, s) => {
75
+ var e;
76
+ return !!o.link || ((e = s.filteredChildren) == null ? void 0 : e.length);
77
+ }, "items"), R = (r, o) => l(
78
+ r,
79
+ (s, e) => {
80
+ var n;
81
+ const t = !s.role || o && (s.role.includes(o) || s.role.includes("guest"));
82
+ return e.isLeaf ? t : t && ((n = e.filteredChildren) == null ? void 0 : n.length);
83
+ },
84
+ "items"
85
+ );
86
+ export {
87
+ R as filterNavByRole,
88
+ b as filterValidNavItems,
89
+ N as formatBlockletInfo,
90
+ p as formatNavigation,
91
+ h as formatTheme,
92
+ i as getLink,
93
+ L as getLocalizedNavigation,
94
+ g as parseNavigation,
95
+ w as publicPath
177
96
  };
@@ -1,24 +1,12 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useMemo, useState, useCallback } from "react";
3
- import PropTypes from "prop-types";
4
- import Box from "@mui/material/Box";
5
- import Typography from "@mui/material/Typography";
6
- import Button from "@mui/material/Button";
7
- import Dialog from "@mui/material/Dialog";
8
- import DialogActions from "@mui/material/DialogActions";
9
- import DialogContent from "@mui/material/DialogContent";
10
- import { useMemoizedFn } from "ahooks";
11
- import { translate } from "@arcblock/ux/lib/Locale/util";
12
- import { joinURL } from "ufo";
13
- import useMobile from "../hooks/use-mobile.js";
14
- const isAdmin = ["admin", "owner"];
15
- const isIpEcho = (hostname) => {
16
- return hostname.endsWith(".ip.abtnet.io");
17
- };
18
- const isDidDomain = (hostname) => {
19
- return hostname.endsWith(".did.abtnet.io");
20
- };
21
- const translations = {
1
+ import { jsxs as l, jsx as t } from "react/jsx-runtime";
2
+ import { useState as S, useMemo as p, useCallback as u } from "react";
3
+ import f from "prop-types";
4
+ import { Dialog as T, DialogContent as A, Typography as m, Box as C, DialogActions as W, Button as w } from "@mui/material";
5
+ import { useMemoizedFn as v } from "ahooks";
6
+ import { translate as M } from "@arcblock/ux/lib/Locale/util";
7
+ import { joinURL as O } from "ufo";
8
+ import j from "../hooks/use-mobile.js";
9
+ const z = ["admin", "owner"], I = (i) => i.endsWith(".ip.abtnet.io"), E = (i) => i.endsWith(".did.abtnet.io"), H = {
22
10
  en: {
23
11
  guest: {
24
12
  title: "Notice: You are using a temporary domain",
@@ -38,124 +26,96 @@ const translations = {
38
26
  },
39
27
  zh: {
40
28
  guest: {
41
- title: "\u6E29\u99A8\u63D0\u793A\uFF1A\u5F53\u524D\u4F7F\u7528\u7684\u662F\u4E34\u65F6\u57DF\u540D",
42
- description: "\u60A8\u6B63\u5728\u901A\u8FC7\u4E34\u65F6\u57DF\u540D\u8BBF\u95EE\u672C\u7AD9\u70B9\u3002\u4E3A\u4E86\u83B7\u5F97\u66F4\u597D\u7684\u8BBF\u95EE\u4F53\u9A8C\uFF0C\u8BF7\u8054\u7CFB\u7AD9\u70B9\u7BA1\u7406\u5458\u914D\u7F6E\u81EA\u5B9A\u4E49\u57DF\u540D\u3002\u4F7F\u7528\u81EA\u5B9A\u4E49\u57DF\u540D\u4E0D\u4EC5\u8BBF\u95EE\u66F4\u4FBF\u6377\uFF0C\u8FD8\u80FD\u786E\u4FDD\u60A8\u7684\u8BBF\u95EE\u66F4\u52A0\u5B89\u5168\u3002"
29
+ title: "温馨提示:当前使用的是临时域名",
30
+ description: "您正在通过临时域名访问本站点。为了获得更好的访问体验,请联系站点管理员配置自定义域名。使用自定义域名不仅访问更便捷,还能确保您的访问更加安全。"
43
31
  },
44
32
  owner: {
45
- title: "\u63D0\u5347\u7F51\u7AD9\u5B89\u5168\u6027\u4E0E\u4E13\u4E1A\u5EA6",
46
- description: "\u5C0A\u656C\u7684\u7BA1\u7406\u5458\uFF0C\u6211\u4EEC\u5EFA\u8BAE\u60A8\u5C3D\u5FEB\u914D\u7F6E\u81EA\u5B9A\u4E49\u57DF\u540D\uFF0C\u8FD9\u6837\u53EF\u4EE5\uFF1A",
47
- benefits1: "\u81EA\u52A8\u83B7\u53D6 HTTPS \u8BC1\u4E66\uFF0C\u786E\u4FDD\u6570\u636E\u4F20\u8F93\u5B89\u5168",
48
- benefits2: "\u6253\u9020\u4E13\u5C5E\u54C1\u724C\u5F62\u8C61\uFF0C\u63D0\u5347\u7F51\u7AD9\u53EF\u4FE1\u5EA6",
49
- benefits3: "\u83B7\u5F97\u66F4\u7B80\u77ED\u3001\u6613\u8BB0\u7684\u8BBF\u95EE\u5730\u5740",
50
- benefits4: "\u4E3A\u8BBF\u5BA2\u63D0\u4F9B\u66F4\u4E13\u4E1A\u7684\u8BBF\u95EE\u4F53\u9A8C",
51
- benefits5: "\u53EA\u9700\u51E0\u5206\u949F\u5373\u53EF\u5B8C\u6210\u57DF\u540D\u914D\u7F6E\uFF0C\u5168\u9762\u63D0\u5347\u60A8\u7684\u7F51\u7AD9\u54C1\u8D28\uFF01"
33
+ title: "提升网站安全性与专业度",
34
+ description: "尊敬的管理员,我们建议您尽快配置自定义域名,这样可以:",
35
+ benefits1: "自动获取 HTTPS 证书,确保数据传输安全",
36
+ benefits2: "打造专属品牌形象,提升网站可信度",
37
+ benefits3: "获得更简短、易记的访问地址",
38
+ benefits4: "为访客提供更专业的访问体验",
39
+ benefits5: "只需几分钟即可完成域名配置,全面提升您的网站品质!"
52
40
  },
53
- skip: "\u7A0D\u540E\u63D0\u9192",
54
- bindDomain: "\u914D\u7F6E\u57DF\u540D"
41
+ skip: "稍后提醒",
42
+ bindDomain: "配置域名"
55
43
  }
56
- };
57
- const ONE_MONTH = 1e3 * 60 * 60 * 24 * 30;
58
- const DASHBOARD_DOMAIN = ".well-known/service/admin/domains";
59
- export default function DomainWarning({ locale, session }) {
60
- const user = session?.user;
61
- const isMobile = useMobile();
62
- const [open, setOpen] = useState(() => {
63
- const skip = window.localStorage.getItem("domain-warning-skip");
64
- if (!skip)
65
- return true;
66
- const now = +/* @__PURE__ */ new Date();
67
- const skipTime = +new Date(skip);
68
- return now - skipTime > ONE_MONTH;
69
- });
70
- const t = useMemoizedFn((key, data = {}) => {
71
- return translate(translations, key, locale, "en", data);
72
- });
73
- const host = useMemo(() => {
44
+ }, N = 1e3 * 60 * 60 * 24 * 30, h = ".well-known/service/admin/domains";
45
+ function P({ locale: i = "en", session: s = {} }) {
46
+ const o = s == null ? void 0 : s.user, b = j(), [g, a] = S(() => {
47
+ const e = window.localStorage.getItem("domain-warning-skip");
48
+ if (!e) return !0;
49
+ const c = +/* @__PURE__ */ new Date(), y = +new Date(e);
50
+ return c - y > N;
51
+ }), n = v((e, c = {}) => M(H, e, i, "en", c)), d = p(() => {
74
52
  try {
75
- const { hostname } = new URL(window.location.href);
76
- return hostname;
77
- } catch (error) {
53
+ const { hostname: e } = new URL(window.location.href);
54
+ return e;
55
+ } catch {
78
56
  return "";
79
57
  }
80
- }, []);
81
- const benefits = useMemo(
58
+ }, []), x = p(
82
59
  () => [
83
- t("owner.benefits1"),
84
- t("owner.benefits2"),
85
- t("owner.benefits3"),
86
- t("owner.benefits4"),
87
- t("owner.benefits5")
60
+ n("owner.benefits1"),
61
+ n("owner.benefits2"),
62
+ n("owner.benefits3"),
63
+ n("owner.benefits4"),
64
+ n("owner.benefits5")
88
65
  ],
89
- [t]
90
- );
91
- const handleSkip = useCallback(() => {
92
- window.localStorage.setItem("domain-warning-skip", (/* @__PURE__ */ new Date()).toISOString());
93
- setOpen(false);
94
- }, []);
95
- const handleDomainConfig = useCallback(() => {
96
- const adminUrl = joinURL(window.location.origin, DASHBOARD_DOMAIN);
97
- if (adminUrl.startsWith("http")) {
98
- window.open(adminUrl, "_blank");
99
- }
100
- setOpen(false);
101
- }, []);
102
- const isOwner = user?.role && isAdmin.includes(user.role);
103
- if (window.location.href.includes(DASHBOARD_DOMAIN)) {
104
- return null;
105
- }
106
- if (isMobile) {
107
- return null;
108
- }
109
- if (!isIpEcho(host) && !isDidDomain(host)) {
110
- return null;
111
- }
112
- return /* @__PURE__ */ jsxs(Dialog, { open, disableEscapeKeyDown: true, fullWidth: true, maxWidth: "sm", onClose: () => setOpen(false), children: [
113
- /* @__PURE__ */ jsxs(DialogContent, { sx: { padding: "20px !important" }, children: [
114
- /* @__PURE__ */ jsx(
115
- Typography,
66
+ [n]
67
+ ), D = u(() => {
68
+ window.localStorage.setItem("domain-warning-skip", (/* @__PURE__ */ new Date()).toISOString()), a(!1);
69
+ }, []), k = u(() => {
70
+ const e = O(window.location.origin, h);
71
+ e.startsWith("http") && window.open(e, "_blank"), a(!1);
72
+ }, []), r = (o == null ? void 0 : o.role) && z.includes(o.role);
73
+ return window.location.href.includes(h) || b || !I(d) && !E(d) ? null : /* @__PURE__ */ l(T, { open: g, disableEscapeKeyDown: !0, fullWidth: !0, maxWidth: "sm", onClose: () => a(!1), children: [
74
+ /* @__PURE__ */ l(A, { sx: { padding: "20px !important" }, children: [
75
+ /* @__PURE__ */ t(
76
+ m,
116
77
  {
117
78
  sx: {
118
79
  fontSize: "20px",
119
80
  fontWeight: "500"
120
81
  },
121
- children: isOwner ? t("owner.title") : t("guest.title")
82
+ children: n(r ? "owner.title" : "guest.title")
122
83
  }
123
84
  ),
124
- /* @__PURE__ */ jsx(
125
- Typography,
85
+ /* @__PURE__ */ t(
86
+ m,
126
87
  {
127
88
  sx: {
128
89
  marginTop: "20px",
129
90
  fontSize: "14px",
130
91
  color: "#9397A1"
131
92
  },
132
- children: isOwner ? t("owner.description") : t("guest.description")
93
+ children: n(r ? "owner.description" : "guest.description")
133
94
  }
134
95
  ),
135
- isOwner && /* @__PURE__ */ jsx(Box, { component: "ul", children: benefits.map((benefit) => /* @__PURE__ */ jsx(
136
- Typography,
96
+ r && /* @__PURE__ */ t(C, { component: "ul", children: x.map((e) => /* @__PURE__ */ t(
97
+ m,
137
98
  {
138
99
  component: "li",
139
100
  sx: {
140
101
  fontSize: "14px",
141
102
  color: "#9397A1"
142
103
  },
143
- children: benefit
104
+ children: e
144
105
  },
145
- benefit
106
+ e
146
107
  )) })
147
108
  ] }),
148
- /* @__PURE__ */ jsxs(DialogActions, { sx: { px: "12px !important" }, children: [
149
- /* @__PURE__ */ jsx(Button, { onClick: handleSkip, children: t("skip") }),
150
- isOwner && /* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleDomainConfig, children: t("bindDomain") })
109
+ /* @__PURE__ */ l(W, { sx: { px: "12px !important" }, children: [
110
+ /* @__PURE__ */ t(w, { onClick: D, children: n("skip") }),
111
+ r && /* @__PURE__ */ t(w, { variant: "contained", onClick: k, children: n("bindDomain") })
151
112
  ] })
152
113
  ] });
153
114
  }
154
- DomainWarning.propTypes = {
155
- locale: PropTypes.string,
156
- session: PropTypes.object
115
+ P.propTypes = {
116
+ locale: f.string,
117
+ session: f.object
157
118
  };
158
- DomainWarning.defaultProps = {
159
- locale: "en",
160
- session: {}
119
+ export {
120
+ P as default
161
121
  };