@arcblock/ux 2.13.70 → 3.0.0

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 (668) hide show
  1. package/lib/ActionButton/ActionButton.stories.d.ts +18 -0
  2. package/lib/ActionButton/index.d.ts +2 -2
  3. package/lib/ActionButton/index.js +43 -94
  4. package/lib/ActivityIndicator/ActivityIndicator.stories.d.ts +8 -0
  5. package/lib/ActivityIndicator/index.d.ts +2 -8
  6. package/lib/ActivityIndicator/index.js +41 -114
  7. package/lib/Address/Address.stories.d.ts +16 -0
  8. package/lib/Address/compact-text.d.ts +4 -14
  9. package/lib/Address/compact-text.js +40 -98
  10. package/lib/Address/did-address.d.ts +5 -4
  11. package/lib/Address/did-address.js +94 -151
  12. package/lib/Address/index.d.ts +4 -2
  13. package/lib/Address/index.js +13 -20
  14. package/lib/Address/responsive-did-address.d.ts +5 -4
  15. package/lib/Address/responsive-did-address.js +80 -114
  16. package/lib/Alert/Alert.stories.d.ts +28 -0
  17. package/lib/Alert/index.d.ts +2 -2
  18. package/lib/Alert/index.js +56 -102
  19. package/lib/AnimationWaiter/AnimationWaiter.stories.d.ts +21 -0
  20. package/lib/AnimationWaiter/{dark-animation.json → dark-animation.json.js} +27 -1
  21. package/lib/AnimationWaiter/{default-animation.json → default-animation.json.js} +29 -1
  22. package/lib/AnimationWaiter/index.d.ts +3 -25
  23. package/lib/AnimationWaiter/index.js +107 -198
  24. package/lib/Async/index.d.ts +2 -4
  25. package/lib/Async/index.js +15 -29
  26. package/lib/Avatar/Avatar.stories.d.ts +11 -0
  27. package/lib/Avatar/did-motif.d.ts +5 -15
  28. package/lib/Avatar/did-motif.js +30 -65
  29. package/lib/Avatar/etherscan-blockies.js +42 -75
  30. package/lib/Avatar/index.d.ts +3 -19
  31. package/lib/Avatar/index.js +114 -180
  32. package/lib/Badge/Badge.stories.d.ts +13 -0
  33. package/lib/Badge/index.d.ts +3 -3
  34. package/lib/Badge/index.js +43 -83
  35. package/lib/Blocklet/Blocklet.stories.d.ts +17 -0
  36. package/lib/Blocklet/blocklet.d.ts +2 -28
  37. package/lib/Blocklet/blocklet.js +108 -191
  38. package/lib/Blocklet/index.d.ts +2 -3
  39. package/lib/Blocklet/index.js +7 -4
  40. package/lib/Blocklet/utils.d.ts +1 -1
  41. package/lib/Blocklet/utils.js +10 -10
  42. package/lib/BlockletContext/index.d.ts +3 -3
  43. package/lib/BlockletContext/index.js +32 -57
  44. package/lib/BlockletNFT/BlockletNFT.stories.d.ts +17 -0
  45. package/lib/BlockletNFT/index.d.ts +3 -38
  46. package/lib/BlockletNFT/index.js +123 -245
  47. package/lib/BlockletV2/Blocklet.stories.d.ts +18 -0
  48. package/lib/BlockletV2/blocklet.d.ts +2 -2
  49. package/lib/BlockletV2/blocklet.js +188 -213
  50. package/lib/BlockletV2/components/icon-text.d.ts +2 -2
  51. package/lib/BlockletV2/components/icon-text.js +43 -33
  52. package/lib/BlockletV2/components/tooltip-icon.js +46 -36
  53. package/lib/BlockletV2/index.d.ts +3 -3
  54. package/lib/BlockletV2/index.js +9 -5
  55. package/lib/BlockletV2/utils.d.ts +1 -1
  56. package/lib/BlockletV2/utils.js +13 -25
  57. package/lib/Button/Button.stories.d.ts +19 -0
  58. package/lib/Button/index.d.ts +1 -1
  59. package/lib/Button/index.js +6 -8
  60. package/lib/Button/wrap.d.ts +3 -3
  61. package/lib/Button/wrap.js +48 -131
  62. package/lib/ButtonGroup/index.d.ts +2 -2
  63. package/lib/ButtonGroup/index.js +6 -16
  64. package/lib/CardSelector/index.js +51 -94
  65. package/lib/Center/Center.stories.d.ts +18 -0
  66. package/lib/Center/index.js +15 -18
  67. package/lib/ClickToCopy/ClickToCopy.stories.d.ts +16 -0
  68. package/lib/ClickToCopy/copy-button.d.ts +3 -2
  69. package/lib/ClickToCopy/copy-button.js +19 -58
  70. package/lib/ClickToCopy/hook.d.ts +2 -2
  71. package/lib/ClickToCopy/hook.js +23 -32
  72. package/lib/ClickToCopy/index.d.ts +3 -14
  73. package/lib/ClickToCopy/index.js +23 -75
  74. package/lib/CloseButton/index.d.ts +1 -1
  75. package/lib/CloseButton/index.js +34 -28
  76. package/lib/CodeBlock/CodeBlock.stories.d.ts +20 -0
  77. package/lib/CodeBlock/LightBox.d.ts +4 -4
  78. package/lib/CodeBlock/LightBox.js +5 -4
  79. package/lib/CodeBlock/index.d.ts +1 -2
  80. package/lib/CodeBlock/index.js +96 -127
  81. package/lib/Colors/Colors.stories.d.ts +34 -0
  82. package/lib/Colors/index.js +8 -4
  83. package/lib/Colors/themes/default.d.ts +1 -1
  84. package/lib/Colors/themes/default.js +5 -7
  85. package/lib/Colors/themes/did-connect.js +43 -44
  86. package/lib/Colors/themes/temp.js +38 -39
  87. package/lib/Config/Config.stories.d.ts +14 -0
  88. package/lib/Config/config-provider.d.ts +8 -8
  89. package/lib/Config/config-provider.js +50 -44
  90. package/lib/Config/index.js +7 -2
  91. package/lib/Config/theme-mode-toggle.js +12 -27
  92. package/lib/ContactForm/ContactForm.stories.d.ts +23 -0
  93. package/lib/ContactForm/index.d.ts +2 -1
  94. package/lib/ContactForm/index.js +137 -164
  95. package/lib/CookieConsent/CookieConsent.stories.d.ts +18 -0
  96. package/lib/CookieConsent/index.d.ts +2 -2
  97. package/lib/CookieConsent/index.js +44 -73
  98. package/lib/CountDown/CountDown.stories.d.ts +14 -0
  99. package/lib/CountDown/index.d.ts +2 -2
  100. package/lib/CountDown/index.js +52 -124
  101. package/lib/DID/DID.stories.d.ts +15 -0
  102. package/lib/DID/index.d.ts +3 -1
  103. package/lib/DID/index.js +262 -327
  104. package/lib/DIDConnect/app-icon.js +26 -31
  105. package/lib/DIDConnect/app-info-item.js +76 -82
  106. package/lib/DIDConnect/auth-apps/auth-apps-info.js +71 -63
  107. package/lib/DIDConnect/auth-apps/index.d.ts +2 -2
  108. package/lib/DIDConnect/auth-apps/index.js +184 -183
  109. package/lib/DIDConnect/did-connect-container.js +231 -247
  110. package/lib/DIDConnect/did-connect-footer.js +66 -68
  111. package/lib/DIDConnect/did-connect-logo.js +10 -11
  112. package/lib/DIDConnect/index.js +22 -10
  113. package/lib/DIDConnect/landing-page.d.ts +1 -1
  114. package/lib/DIDConnect/landing-page.js +165 -189
  115. package/lib/DIDConnect/powered-by.js +55 -46
  116. package/lib/DIDConnect/request-storage-access-api-dialog.d.ts +5 -2
  117. package/lib/DIDConnect/request-storage-access-api-dialog.js +230 -292
  118. package/lib/DIDConnect/with-container.js +200 -236
  119. package/lib/DIDConnect/with-ux-theme.js +15 -22
  120. package/lib/Datatable/CustomToolbar.d.ts +1 -15
  121. package/lib/Datatable/CustomToolbar.js +232 -313
  122. package/lib/Datatable/Datatable.stories.d.ts +32 -0
  123. package/lib/Datatable/DatatableContext.js +23 -35
  124. package/lib/Datatable/TableSearch.d.ts +5 -13
  125. package/lib/Datatable/TableSearch.js +81 -113
  126. package/lib/Datatable/index.d.ts +12 -13
  127. package/lib/Datatable/index.js +226 -479
  128. package/lib/Datatable/utils.js +55 -120
  129. package/lib/Dialog/Dialog.stories.d.ts +20 -0
  130. package/lib/Dialog/confirm.d.ts +4 -25
  131. package/lib/Dialog/confirm.js +99 -125
  132. package/lib/Dialog/dialog.d.ts +30 -23
  133. package/lib/Dialog/dialog.js +62 -148
  134. package/lib/Dialog/index.d.ts +3 -3
  135. package/lib/Dialog/index.js +8 -4
  136. package/lib/Dialog/use-confirm.d.ts +3 -3
  137. package/lib/Dialog/use-confirm.js +91 -171
  138. package/lib/DidLogo/Logo.stories.d.ts +8 -0
  139. package/lib/DidLogo/index.js +19 -19
  140. package/lib/DriftBot/index.js +23 -33
  141. package/lib/Earth/Earth.stories.d.ts +18 -0
  142. package/lib/Earth/countries.json.js +13 -0
  143. package/lib/Earth/index.js +234 -334
  144. package/lib/Earth/util.js +36 -45
  145. package/lib/Empty/Empty.stories.d.ts +17 -0
  146. package/lib/Empty/index.d.ts +3 -11
  147. package/lib/Empty/index.js +17 -50
  148. package/lib/ErrorBoundary/ErrorBoundary.stories.d.ts +12 -0
  149. package/lib/ErrorBoundary/fallback.js +54 -71
  150. package/lib/ErrorBoundary/index.js +6 -1
  151. package/lib/Footer/Footer.stories.d.ts +12 -0
  152. package/lib/Footer/index.d.ts +1 -12
  153. package/lib/Footer/index.js +53 -100
  154. package/lib/Header/Header.stories.d.ts +21 -0
  155. package/lib/Header/addon-button.js +24 -31
  156. package/lib/Header/auto-hidden.d.ts +1 -1
  157. package/lib/Header/auto-hidden.js +9 -16
  158. package/lib/Header/header-addons.d.ts +1 -1
  159. package/lib/Header/header-addons.js +40 -37
  160. package/lib/Header/header.d.ts +2 -1
  161. package/lib/Header/header.js +64 -109
  162. package/lib/Header/index.js +8 -3
  163. package/lib/Header/responsive-header.d.ts +1 -1
  164. package/lib/Header/responsive-header.js +74 -112
  165. package/lib/Icon/Icon.stories.d.ts +23 -0
  166. package/lib/Icon/image.d.ts +1 -1
  167. package/lib/Icon/image.js +32 -33
  168. package/lib/Icon/index.d.ts +4 -4
  169. package/lib/Icon/index.js +30 -53
  170. package/lib/Img/Img.stories.d.ts +13 -0
  171. package/lib/Img/index.d.ts +6 -32
  172. package/lib/Img/index.js +126 -204
  173. package/lib/InfoRow/InfoRow.stories.d.ts +14 -0
  174. package/lib/InfoRow/index.js +27 -41
  175. package/lib/Layout/Layout.stories.d.ts +23 -0
  176. package/lib/Layout/dashboard/external-link.d.ts +1 -1
  177. package/lib/Layout/dashboard/external-link.js +23 -44
  178. package/lib/Layout/dashboard/full-page.d.ts +1 -1
  179. package/lib/Layout/dashboard/full-page.js +31 -48
  180. package/lib/Layout/dashboard/index.d.ts +4 -4
  181. package/lib/Layout/dashboard/index.js +134 -211
  182. package/lib/Layout/dashboard/sidebar.js +44 -78
  183. package/lib/Layout/dashboard-legacy/header.d.ts +1 -1
  184. package/lib/Layout/dashboard-legacy/header.js +70 -87
  185. package/lib/Layout/dashboard-legacy/index.d.ts +2 -2
  186. package/lib/Layout/dashboard-legacy/index.js +82 -90
  187. package/lib/Layout/dashboard-legacy/sidebar.d.ts +1 -1
  188. package/lib/Layout/dashboard-legacy/sidebar.js +44 -76
  189. package/lib/Layout/index.d.ts +2 -2
  190. package/lib/Layout/index.js +129 -189
  191. package/lib/LoadingMask/index.js +91 -82
  192. package/lib/Locale/LocaleSelector.stories.d.ts +22 -0
  193. package/lib/Locale/browser-lang.js +23 -52
  194. package/lib/Locale/context.d.ts +3 -3
  195. package/lib/Locale/context.js +71 -123
  196. package/lib/Locale/languages.js +32 -34
  197. package/lib/Locale/selector.d.ts +2 -2
  198. package/lib/Locale/selector.js +104 -139
  199. package/lib/Locale/util.d.ts +1 -1
  200. package/lib/Locale/util.js +9 -24
  201. package/lib/Logo/Logo.stories.d.ts +22 -0
  202. package/lib/Logo/images/logo-dark-text.svg.js +5 -0
  203. package/lib/Logo/images/logo-dark-top.svg.js +5 -0
  204. package/lib/Logo/images/logo-light-text.svg.js +5 -0
  205. package/lib/Logo/images/logo-light-top.svg.js +5 -0
  206. package/lib/Logo/index.d.ts +1 -1
  207. package/lib/Logo/index.js +27 -107
  208. package/lib/Metric/Metric.stories.d.ts +14 -0
  209. package/lib/Metric/index.js +50 -53
  210. package/lib/MuiWrap/index.js +11 -19
  211. package/lib/NFTDisplay/NFTBroken.svg.js +108 -0
  212. package/lib/NFTDisplay/NFTDisplay.stories.d.ts +15 -0
  213. package/lib/NFTDisplay/aspect-ratio-container.js +9 -20
  214. package/lib/NFTDisplay/broken.js +14 -286
  215. package/lib/NFTDisplay/displayApi.d.ts +1 -1
  216. package/lib/NFTDisplay/displayApi.js +17 -44
  217. package/lib/NFTDisplay/index.d.ts +2 -2
  218. package/lib/NFTDisplay/index.js +160 -343
  219. package/lib/NFTDisplay/loading.js +9 -9
  220. package/lib/NFTDisplay/render-svg.js +15 -22
  221. package/lib/NFTDisplay/svg-embedder/img.js +13 -29
  222. package/lib/NFTDisplay/svg-embedder/inline-svg.d.ts +1 -1
  223. package/lib/NFTDisplay/svg-embedder/inline-svg.js +10 -20
  224. package/lib/NavMenu/NavMenu.stories.d.ts +17 -0
  225. package/lib/NavMenu/images/OCAP.svg.js +5 -0
  226. package/lib/NavMenu/images/abt-network.svg.js +7 -0
  227. package/lib/NavMenu/images/ai-kit.svg.js +7 -0
  228. package/lib/NavMenu/images/aigne.svg.js +7 -0
  229. package/lib/NavMenu/images/aistro.svg.js +5 -0
  230. package/lib/NavMenu/images/arcsphere.svg.js +10 -0
  231. package/lib/NavMenu/images/blocklet-framework.svg.js +7 -0
  232. package/lib/NavMenu/images/blocklet-launcher.svg.js +5 -0
  233. package/lib/NavMenu/images/blocklet-server.svg.js +7 -0
  234. package/lib/NavMenu/images/blocklet-store.svg.js +5 -0
  235. package/lib/NavMenu/images/creator-studio.svg.js +7 -0
  236. package/lib/NavMenu/images/did-connect.svg.js +5 -0
  237. package/lib/NavMenu/images/did-name-service.svg.js +5 -0
  238. package/lib/NavMenu/images/did-wallet.svg.js +7 -0
  239. package/lib/NavMenu/images/did.svg.js +5 -0
  240. package/lib/NavMenu/images/nft-studio.svg.js +5 -0
  241. package/lib/NavMenu/images/vc.svg.js +5 -0
  242. package/lib/NavMenu/images/web3-kit.svg.js +7 -0
  243. package/lib/NavMenu/index.js +6 -3
  244. package/lib/NavMenu/nav-menu-context.js +15 -18
  245. package/lib/NavMenu/nav-menu.d.ts +17 -7
  246. package/lib/NavMenu/nav-menu.js +219 -355
  247. package/lib/NavMenu/products.js +264 -1652
  248. package/lib/NavMenu/style.d.ts +5 -5
  249. package/lib/NavMenu/style.js +156 -172
  250. package/lib/NavMenu/sub-container.d.ts +1 -1
  251. package/lib/NavMenu/sub-container.js +63 -104
  252. package/lib/NavMenu/sub-item-group.js +15 -33
  253. package/lib/PageScroller/index.d.ts +1 -1
  254. package/lib/PageScroller/index.js +116 -252
  255. package/lib/PageScroller/story/FifthComponent.js +7 -9
  256. package/lib/PageScroller/story/FirstComponent.js +7 -9
  257. package/lib/PageScroller/story/FourthComponent.js +7 -12
  258. package/lib/PageScroller/story/FullPage.js +52 -45
  259. package/lib/PageScroller/story/PageContain.js +55 -57
  260. package/lib/PageScroller/story/PageScroller.stories.d.ts +13 -0
  261. package/lib/PageScroller/story/SecondComponent.js +7 -9
  262. package/lib/PageScroller/story/ThirdComponent.js +7 -9
  263. package/lib/PageScroller/usePrevValue.js +10 -8
  264. package/lib/Passport/index.d.ts +1 -1
  265. package/lib/Passport/index.js +4 -2
  266. package/lib/Passport/passport.d.ts +1 -1
  267. package/lib/Passport/passport.js +123 -100
  268. package/lib/PhoneInput/PhoneInput.stories.d.ts +12 -0
  269. package/lib/PhoneInput/country-select.d.ts +2 -2
  270. package/lib/PhoneInput/country-select.js +111 -159
  271. package/lib/PhoneInput/index.js +166 -218
  272. package/lib/PoweredByArcBlock/index.d.ts +1 -1
  273. package/lib/PoweredByArcBlock/index.js +16 -22
  274. package/lib/PricingTable/PricingPlan.js +20 -55
  275. package/lib/PricingTable/PricingTable.stories.d.ts +8 -0
  276. package/lib/PricingTable/index.d.ts +1 -1
  277. package/lib/PricingTable/index.js +34 -37
  278. package/lib/QRCode/QRCode.stories.d.ts +13 -0
  279. package/lib/QRCode/index.d.ts +1 -1
  280. package/lib/QRCode/index.js +31 -49
  281. package/lib/RelativeTime/RelativeTime.stories.d.ts +20 -0
  282. package/lib/RelativeTime/index.d.ts +3 -3
  283. package/lib/RelativeTime/index.js +163 -261
  284. package/lib/Result/Result.stories.d.ts +21 -0
  285. package/lib/Result/common.d.ts +2 -2
  286. package/lib/Result/common.js +97 -129
  287. package/lib/Result/index.d.ts +1 -1
  288. package/lib/Result/index.js +21 -22
  289. package/lib/Result/result.js +45 -32
  290. package/lib/Result/translations.d.ts +1 -1
  291. package/lib/Result/translations.js +28 -25
  292. package/lib/Screenshot/BaseScreenshot/index.d.ts +1 -1
  293. package/lib/Screenshot/BaseScreenshot/index.js +23 -44
  294. package/lib/Screenshot/BaseScreenshot/shells/Macbook.js +23 -41
  295. package/lib/Screenshot/BaseScreenshot/shells/Phone.js +24 -26
  296. package/lib/Screenshot/Screenshot.stories.d.ts +13 -0
  297. package/lib/Screenshot/demo/images/bg-01.jpg +0 -0
  298. package/lib/Screenshot/demo/images/bg-02.jpg +0 -0
  299. package/lib/Screenshot/demo/images/bg-03.jpg +0 -0
  300. package/lib/Screenshot/index.d.ts +1 -2
  301. package/lib/Screenshot/index.js +83 -188
  302. package/lib/SessionBlocklet/index.d.ts +2 -2
  303. package/lib/SessionBlocklet/index.js +147 -162
  304. package/lib/SessionManager/SessionManager.stories.d.ts +9 -0
  305. package/lib/SessionManager/index.d.ts +1 -1
  306. package/lib/SessionManager/index.js +4 -2
  307. package/lib/SessionPermission/index.d.ts +1 -0
  308. package/lib/SessionPermission/index.js +12 -20
  309. package/lib/SessionUser/components/did-space.js +65 -117
  310. package/lib/SessionUser/components/logged-in.d.ts +3 -4
  311. package/lib/SessionUser/components/logged-in.js +215 -292
  312. package/lib/SessionUser/components/quick-login-item.js +125 -120
  313. package/lib/SessionUser/components/session-user-item.d.ts +4 -2
  314. package/lib/SessionUser/components/session-user-item.js +85 -89
  315. package/lib/SessionUser/components/session-user-switch.d.ts +1 -1
  316. package/lib/SessionUser/components/session-user-switch.js +187 -187
  317. package/lib/SessionUser/components/un-login.js +196 -222
  318. package/lib/SessionUser/components/user-info.d.ts +1 -1
  319. package/lib/SessionUser/components/user-info.js +163 -150
  320. package/lib/SessionUser/images/did-spaces.svg.js +5 -0
  321. package/lib/SessionUser/index.d.ts +1 -1
  322. package/lib/SessionUser/index.js +27 -30
  323. package/lib/SessionUser/libs/translation.d.ts +1 -1
  324. package/lib/SessionUser/libs/translation.js +25 -24
  325. package/lib/SessionUser/libs/utils.js +33 -23
  326. package/lib/SharedBridge/index.d.ts +6 -5
  327. package/lib/SharedBridge/index.js +76 -93
  328. package/lib/Sparkline/Sparkline.stories.d.ts +12 -0
  329. package/lib/Sparkline/index.js +67 -183
  330. package/lib/Spinner/Spinner.stories.d.ts +18 -0
  331. package/lib/Spinner/index.d.ts +1 -1
  332. package/lib/Spinner/index.js +10 -20
  333. package/lib/SplitButton/SplitButton.stories.d.ts +15 -0
  334. package/lib/SplitButton/index.d.ts +3 -5
  335. package/lib/SplitButton/index.js +39 -83
  336. package/lib/Success/index.js +174 -160
  337. package/lib/Switch/Switch.stories.d.ts +13 -0
  338. package/lib/Switch/index.d.ts +3 -7
  339. package/lib/Switch/index.js +51 -87
  340. package/lib/Tabs/Tabs.stories.d.ts +14 -0
  341. package/lib/Tabs/index.d.ts +2 -2
  342. package/lib/Tabs/index.js +169 -186
  343. package/lib/Tag/Tag.stories.d.ts +13 -0
  344. package/lib/Tag/index.d.ts +7 -4
  345. package/lib/Tag/index.js +40 -88
  346. package/lib/TextCollapse/TextCollapse.stories.d.ts +28 -0
  347. package/lib/TextCollapse/index.js +34 -51
  348. package/lib/Theme/Theme.stories.d.ts +10 -0
  349. package/lib/Theme/index.d.ts +1 -2
  350. package/lib/Theme/index.js +25 -17
  351. package/lib/Theme/theme-provider.d.ts +4 -15
  352. package/lib/Theme/theme-provider.js +111 -232
  353. package/lib/Theme/theme.d.ts +1 -8
  354. package/lib/Theme/theme.js +118 -166
  355. package/lib/Toast/Toast.stories.d.ts +15 -0
  356. package/lib/Toast/index.d.ts +1 -1
  357. package/lib/Toast/index.js +46 -67
  358. package/lib/Typography/index.d.ts +1 -1
  359. package/lib/Typography/index.js +73 -109
  360. package/lib/UserCard/Cards/avatar-only.d.ts +1 -1
  361. package/lib/UserCard/Cards/avatar-only.js +28 -36
  362. package/lib/UserCard/Cards/basic-info.d.ts +1 -2
  363. package/lib/UserCard/Cards/basic-info.js +34 -42
  364. package/lib/UserCard/Cards/index.d.ts +1 -1
  365. package/lib/UserCard/Cards/index.js +13 -21
  366. package/lib/UserCard/Cards/name-only.js +12 -18
  367. package/lib/UserCard/Container/card.d.ts +2 -2
  368. package/lib/UserCard/Container/card.js +34 -41
  369. package/lib/UserCard/Container/dialog.d.ts +1 -1
  370. package/lib/UserCard/Container/dialog.js +27 -27
  371. package/lib/UserCard/Content/basic.d.ts +1 -2
  372. package/lib/UserCard/Content/basic.js +227 -307
  373. package/lib/UserCard/Content/clock.d.ts +2 -0
  374. package/lib/UserCard/Content/clock.js +85 -71
  375. package/lib/UserCard/Content/minimal.d.ts +1 -1
  376. package/lib/UserCard/Content/minimal.js +81 -71
  377. package/lib/UserCard/Content/shorten-label.js +11 -35
  378. package/lib/UserCard/Content/tooltip-avatar.d.ts +1 -1
  379. package/lib/UserCard/Content/tooltip-avatar.js +43 -51
  380. package/lib/UserCard/UserCard.stories.d.ts +18 -0
  381. package/lib/UserCard/components.d.ts +1 -1
  382. package/lib/UserCard/components.js +53 -66
  383. package/lib/UserCard/index.d.ts +1 -2
  384. package/lib/UserCard/index.js +59 -111
  385. package/lib/UserCard/types.d.ts +1 -1
  386. package/lib/UserCard/types.js +10 -37
  387. package/lib/UserCard/utils.js +70 -125
  388. package/lib/Util/WebWalletOpener.stories.d.ts +5 -0
  389. package/lib/Util/constant.js +47 -46
  390. package/lib/Util/deprecate.js +11 -26
  391. package/lib/Util/federated.d.ts +6 -6
  392. package/lib/Util/federated.js +77 -92
  393. package/lib/Util/iframe.js +14 -21
  394. package/lib/Util/index.d.ts +5 -5
  395. package/lib/Util/index.js +278 -479
  396. package/lib/Util/logger.d.ts +1 -1
  397. package/lib/Util/logger.js +17 -25
  398. package/lib/Util/passport.js +72 -87
  399. package/lib/Util/security.js +28 -40
  400. package/lib/Util/style.d.ts +1 -1
  401. package/lib/Util/style.js +4 -14
  402. package/lib/Util/wallet.js +16 -30
  403. package/lib/VerificationCode/index.d.ts +1 -1
  404. package/lib/VerificationCode/index.js +69 -64
  405. package/lib/Video/Video.stories.d.ts +6 -0
  406. package/lib/Video/index.d.ts +1 -9
  407. package/lib/Video/index.js +26 -60
  408. package/lib/Wallet/Action.d.ts +1 -10
  409. package/lib/Wallet/Action.js +37 -65
  410. package/lib/Wallet/Action.stories.d.ts +8 -0
  411. package/lib/Wallet/Download.d.ts +3 -16
  412. package/lib/Wallet/Download.js +41 -440
  413. package/lib/Wallet/Download.stories.d.ts +9 -0
  414. package/lib/Wallet/Open.d.ts +1 -1
  415. package/lib/Wallet/Open.js +27 -27
  416. package/lib/Wallet/OpenInWallet.stories.d.ts +5 -0
  417. package/lib/Wallet/images/android_download.svg.js +5 -0
  418. package/lib/Wallet/images/app-store.svg.js +5 -0
  419. package/lib/Wallet/images/google-play.svg.js +5 -0
  420. package/lib/WalletOSIcon/index.js +15 -73
  421. package/lib/WebWalletSWKeeper/index.js +39 -106
  422. package/lib/WechatPrompt/images/android.png +0 -0
  423. package/lib/WechatPrompt/images/ios.png +0 -0
  424. package/lib/WechatPrompt/index.js +26 -61
  425. package/lib/hooks/use-blocklet-logo.d.ts +2 -2
  426. package/lib/hooks/use-blocklet-logo.js +22 -30
  427. package/lib/hooks/use-clock.d.ts +1 -3
  428. package/lib/hooks/use-clock.js +34 -67
  429. package/lib/hooks/use-location-state.js +55 -79
  430. package/lib/hooks/use-mobile.js +8 -7
  431. package/lib/index.d.ts +35 -35
  432. package/lib/index.js +81 -38
  433. package/lib/ux.css +1 -0
  434. package/lib/withTheme/index.d.ts +1 -3
  435. package/lib/withTheme/index.js +28 -37
  436. package/lib/withTracker/error_boundary.d.ts +1 -1
  437. package/lib/withTracker/error_boundary.js +15 -29
  438. package/lib/withTracker/index.js +21 -48
  439. package/package.json +48 -57
  440. package/src/ActionButton/ActionButton.stories.jsx +61 -0
  441. package/src/ActionButton/index.jsx +30 -14
  442. package/src/ActivityIndicator/ActivityIndicator.stories.jsx +9 -0
  443. package/src/ActivityIndicator/index.jsx +2 -11
  444. package/src/Address/Address.stories.jsx +38 -0
  445. package/src/Address/compact-text.jsx +9 -11
  446. package/src/Address/did-address.tsx +8 -4
  447. package/src/Address/index.tsx +12 -9
  448. package/src/Address/responsive-did-address.tsx +94 -89
  449. package/src/Alert/Alert.stories.jsx +100 -0
  450. package/src/Alert/index.jsx +24 -12
  451. package/src/AnimationWaiter/AnimationWaiter.stories.jsx +35 -0
  452. package/src/AnimationWaiter/index.jsx +10 -23
  453. package/src/Async/index.tsx +2 -2
  454. package/src/Avatar/Avatar.stories.jsx +11 -0
  455. package/src/Avatar/did-motif.jsx +1 -8
  456. package/src/Avatar/index.jsx +36 -13
  457. package/src/Badge/Badge.stories.jsx +41 -0
  458. package/src/Badge/index.jsx +22 -18
  459. package/src/Blocklet/Blocklet.stories.jsx +21 -0
  460. package/src/Blocklet/blocklet.jsx +13 -30
  461. package/src/BlockletContext/index.tsx +2 -2
  462. package/src/BlockletNFT/BlockletNFT.stories.jsx +21 -0
  463. package/src/BlockletNFT/index.jsx +14 -38
  464. package/src/BlockletV2/Blocklet.stories.jsx +34 -0
  465. package/src/BlockletV2/blocklet.tsx +69 -29
  466. package/src/BlockletV2/components/icon-text.tsx +15 -5
  467. package/src/Button/Button.stories.jsx +24 -0
  468. package/src/Button/index.js +1 -1
  469. package/src/Button/wrap.jsx +20 -13
  470. package/src/ButtonGroup/index.js +1 -1
  471. package/src/Center/Center.stories.jsx +20 -0
  472. package/src/ClickToCopy/ClickToCopy.stories.jsx +24 -0
  473. package/src/ClickToCopy/copy-button.tsx +4 -4
  474. package/src/ClickToCopy/index.tsx +28 -12
  475. package/src/CodeBlock/CodeBlock.stories.jsx +22 -0
  476. package/src/CodeBlock/index.tsx +1 -2
  477. package/src/Colors/Colors.stories.jsx +211 -0
  478. package/src/Colors/themes/did-connect.ts +0 -2
  479. package/src/Config/Config.stories.jsx +16 -0
  480. package/src/Config/theme-mode-toggle.tsx +4 -2
  481. package/src/ContactForm/ContactForm.stories.jsx +32 -0
  482. package/src/ContactForm/index.tsx +2 -2
  483. package/src/CookieConsent/CookieConsent.stories.jsx +33 -0
  484. package/src/CookieConsent/index.tsx +1 -1
  485. package/src/CountDown/CountDown.stories.jsx +15 -0
  486. package/src/CountDown/index.tsx +11 -6
  487. package/src/DID/DID.stories.jsx +37 -0
  488. package/src/DID/index.tsx +8 -3
  489. package/src/DIDConnect/app-info-item.tsx +2 -2
  490. package/src/DIDConnect/did-connect-container.tsx +17 -18
  491. package/src/DIDConnect/request-storage-access-api-dialog.tsx +210 -183
  492. package/src/DIDConnect/with-container.tsx +17 -18
  493. package/src/Datatable/CustomToolbar.jsx +32 -34
  494. package/src/Datatable/Datatable.stories.jsx +92 -0
  495. package/src/Datatable/DatatableContext.jsx +2 -2
  496. package/src/Datatable/TableSearch.jsx +10 -12
  497. package/src/Datatable/index.jsx +36 -58
  498. package/src/Datatable/utils.js +7 -7
  499. package/src/Dialog/Dialog.stories.jsx +21 -0
  500. package/src/Dialog/confirm.jsx +11 -21
  501. package/src/Dialog/dialog.jsx +9 -20
  502. package/src/Dialog/use-confirm.jsx +4 -3
  503. package/src/DidLogo/Logo.stories.jsx +8 -0
  504. package/src/DriftBot/index.tsx +4 -6
  505. package/src/Earth/Earth.stories.jsx +39 -0
  506. package/src/Earth/index.tsx +1 -1
  507. package/src/Empty/Empty.stories.jsx +23 -0
  508. package/src/Empty/index.jsx +1 -6
  509. package/src/ErrorBoundary/ErrorBoundary.stories.jsx +13 -0
  510. package/src/ErrorBoundary/fallback.tsx +5 -1
  511. package/src/Footer/Footer.stories.jsx +13 -0
  512. package/src/Footer/index.tsx +10 -18
  513. package/src/Header/Header.stories.jsx +30 -0
  514. package/src/Header/auto-hidden.tsx +1 -1
  515. package/src/Header/header.tsx +21 -4
  516. package/src/Header/responsive-header.tsx +11 -13
  517. package/src/Icon/Icon.stories.jsx +45 -0
  518. package/src/Icon/index.tsx +12 -24
  519. package/src/Img/Img.stories.jsx +17 -0
  520. package/src/Img/index.jsx +14 -30
  521. package/src/InfoRow/InfoRow.stories.jsx +14 -0
  522. package/src/InfoRow/index.tsx +5 -5
  523. package/src/Layout/Layout.stories.jsx +24 -0
  524. package/src/Layout/dashboard/full-page.tsx +4 -4
  525. package/src/Layout/dashboard/index.tsx +24 -21
  526. package/src/Layout/dashboard/sidebar.tsx +1 -1
  527. package/src/Layout/dashboard-legacy/header.tsx +25 -14
  528. package/src/Layout/dashboard-legacy/index.tsx +7 -7
  529. package/src/Layout/dashboard-legacy/sidebar.tsx +1 -3
  530. package/src/Layout/index.tsx +8 -6
  531. package/src/Locale/LocaleSelector.stories.jsx +44 -0
  532. package/src/Locale/context.tsx +2 -2
  533. package/src/Locale/selector.tsx +10 -17
  534. package/src/Logo/Logo.stories.jsx +23 -0
  535. package/src/Metric/Metric.stories.jsx +29 -0
  536. package/src/NFTDisplay/NFTDisplay.stories.jsx +30 -0
  537. package/src/NFTDisplay/broken.tsx +1 -1
  538. package/src/NFTDisplay/displayApi.ts +1 -0
  539. package/src/NFTDisplay/index.tsx +0 -1
  540. package/src/NavMenu/NavMenu.stories.jsx +17 -0
  541. package/src/NavMenu/nav-menu-context.tsx +3 -3
  542. package/src/NavMenu/nav-menu.tsx +138 -125
  543. package/src/NavMenu/products.tsx +7 -1
  544. package/src/NavMenu/style.ts +1 -1
  545. package/src/PageScroller/index.tsx +2 -2
  546. package/src/PageScroller/story/PageScroller.stories.jsx +18 -0
  547. package/src/PageScroller/usePrevValue.ts +1 -1
  548. package/src/PhoneInput/PhoneInput.stories.jsx +12 -0
  549. package/src/PhoneInput/country-select.tsx +107 -103
  550. package/src/PhoneInput/index.tsx +12 -4
  551. package/src/PricingTable/PricingPlan.tsx +1 -4
  552. package/src/PricingTable/PricingTable.stories.jsx +38 -0
  553. package/src/PricingTable/index.tsx +16 -4
  554. package/src/QRCode/QRCode.stories.jsx +13 -0
  555. package/src/RelativeTime/RelativeTime.stories.jsx +20 -0
  556. package/src/RelativeTime/index.tsx +20 -5
  557. package/src/Result/Result.stories.jsx +61 -0
  558. package/src/Result/common.tsx +1 -2
  559. package/src/Result/result.tsx +22 -6
  560. package/src/Screenshot/Screenshot.stories.jsx +44 -0
  561. package/src/Screenshot/index.tsx +33 -15
  562. package/src/SessionManager/SessionManager.stories.jsx +9 -0
  563. package/src/SessionPermission/index.tsx +1 -0
  564. package/src/SessionUser/components/logged-in.tsx +0 -2
  565. package/src/SessionUser/components/quick-login-item.tsx +3 -3
  566. package/src/SessionUser/components/session-user-item.tsx +68 -70
  567. package/src/SessionUser/components/session-user-switch.tsx +9 -1
  568. package/src/SessionUser/components/un-login.tsx +8 -1
  569. package/src/SharedBridge/index.tsx +106 -111
  570. package/src/Sparkline/Sparkline.stories.jsx +13 -0
  571. package/src/Spinner/Spinner.stories.jsx +98 -0
  572. package/src/Spinner/index.tsx +1 -1
  573. package/src/SplitButton/SplitButton.stories.jsx +32 -0
  574. package/src/SplitButton/index.tsx +15 -9
  575. package/src/Switch/Switch.stories.jsx +16 -0
  576. package/src/Switch/index.jsx +2 -6
  577. package/src/Tabs/Tabs.stories.jsx +18 -0
  578. package/src/Tabs/index.tsx +3 -3
  579. package/src/Tag/Tag.stories.jsx +15 -0
  580. package/src/Tag/index.jsx +20 -11
  581. package/src/TextCollapse/TextCollapse.stories.jsx +73 -0
  582. package/src/TextCollapse/index.tsx +1 -1
  583. package/src/Theme/Theme.stories.jsx +10 -0
  584. package/src/Theme/theme-provider.tsx +10 -18
  585. package/src/Theme/theme.ts +7 -2
  586. package/src/Toast/Toast.stories.jsx +28 -0
  587. package/src/Toast/index.tsx +2 -2
  588. package/src/Typography/index.tsx +6 -2
  589. package/src/UserCard/Cards/basic-info.tsx +9 -5
  590. package/src/UserCard/Container/card.tsx +2 -2
  591. package/src/UserCard/Content/basic.tsx +43 -14
  592. package/src/UserCard/Content/clock.tsx +13 -6
  593. package/src/UserCard/Content/minimal.tsx +23 -7
  594. package/src/UserCard/Content/tooltip-avatar.tsx +14 -11
  595. package/src/UserCard/UserCard.stories.jsx +18 -0
  596. package/src/UserCard/components.tsx +6 -3
  597. package/src/UserCard/index.tsx +0 -1
  598. package/src/Util/WebWalletOpener.stories.jsx +5 -0
  599. package/src/Util/index.ts +37 -3
  600. package/src/VerificationCode/index.tsx +16 -14
  601. package/src/Video/Video.stories.jsx +6 -0
  602. package/src/Video/index.tsx +16 -8
  603. package/src/Wallet/Action.stories.jsx +8 -0
  604. package/src/Wallet/Action.tsx +20 -9
  605. package/src/Wallet/Download.stories.jsx +9 -0
  606. package/src/Wallet/Download.tsx +36 -14
  607. package/src/Wallet/Open.tsx +1 -1
  608. package/src/Wallet/OpenInWallet.stories.jsx +5 -0
  609. package/src/WechatPrompt/index.tsx +1 -2
  610. package/src/hooks/use-clock.tsx +2 -1
  611. package/src/withTheme/index.tsx +1 -4
  612. package/vite.config.mjs +34 -0
  613. package/babel.config.es.js +0 -28
  614. package/lib/Dialog/types.d.ts +0 -20
  615. package/lib/Earth/countries.json +0 -8057
  616. package/lib/Header/demo/images/boards.svg +0 -3
  617. package/lib/Header/demo/images/chatbot.svg +0 -3
  618. package/lib/Header/demo/images/gallery.svg +0 -3
  619. package/lib/Logo/images/logo-dark-text.svg +0 -3
  620. package/lib/Logo/images/logo-dark-top.svg +0 -6
  621. package/lib/Logo/images/logo-light-text.svg +0 -3
  622. package/lib/Logo/images/logo-light-top.svg +0 -6
  623. package/lib/NFTDisplay/NFTBroken.svg +0 -34
  624. package/lib/NFTDisplay/README.md +0 -59
  625. package/lib/NFTDisplay/demo/data/asset-state-bad-url.json +0 -7
  626. package/lib/NFTDisplay/demo/data/asset-state-did-space-svg.json +0 -7
  627. package/lib/NFTDisplay/demo/data/asset-state-did-space.json +0 -7
  628. package/lib/NFTDisplay/demo/data/asset-state-display-url.json +0 -7
  629. package/lib/NFTDisplay/demo/data/asset-state-gzipped-svg-1-1.json +0 -10
  630. package/lib/NFTDisplay/demo/data/asset-state-gzipped-svg-374-130.json +0 -10
  631. package/lib/NFTDisplay/demo/data/asset-state-gzipped-svg-with-foreign-object.json +0 -20
  632. package/lib/NFTDisplay/demo/data/asset-state-svg.json +0 -29
  633. package/lib/NFTDisplay/demo/data/asset-state-url.json +0 -10
  634. package/lib/NavMenu/images/OCAP.svg +0 -16
  635. package/lib/NavMenu/images/abt-network.svg +0 -18
  636. package/lib/NavMenu/images/ai-kit.svg +0 -46
  637. package/lib/NavMenu/images/aigne.svg +0 -8
  638. package/lib/NavMenu/images/aistro.svg +0 -14
  639. package/lib/NavMenu/images/arcsphere.svg +0 -13
  640. package/lib/NavMenu/images/blocklet-framework.svg +0 -25
  641. package/lib/NavMenu/images/blocklet-launcher.svg +0 -9
  642. package/lib/NavMenu/images/blocklet-server.svg +0 -19
  643. package/lib/NavMenu/images/blocklet-store.svg +0 -11
  644. package/lib/NavMenu/images/creator-studio.svg +0 -42
  645. package/lib/NavMenu/images/did-connect.svg +0 -26
  646. package/lib/NavMenu/images/did-name-service.svg +0 -3
  647. package/lib/NavMenu/images/did-wallet.svg +0 -33
  648. package/lib/NavMenu/images/did.svg +0 -3
  649. package/lib/NavMenu/images/nft-studio.svg +0 -19
  650. package/lib/NavMenu/images/vc.svg +0 -7
  651. package/lib/NavMenu/images/web3-kit.svg +0 -56
  652. package/lib/PageScroller/story/index.css +0 -115
  653. package/lib/Result/demo/fixtures/result-image-404.svg +0 -1
  654. package/lib/Screenshot/devices.css +0 -1366
  655. package/lib/SessionUser/images/did-spaces.svg +0 -17
  656. package/lib/Wallet/images/android_download.svg +0 -22
  657. package/lib/Wallet/images/app-store.svg +0 -30
  658. package/lib/Wallet/images/google-play.svg +0 -69
  659. package/lib/global.d.ts +0 -28
  660. package/lib/type.d.ts +0 -44
  661. package/lib/withTracker/README.md +0 -37
  662. /package/src/PageScroller/story/{FifthComponent.js → FifthComponent.jsx} +0 -0
  663. /package/src/PageScroller/story/{FirstComponent.js → FirstComponent.jsx} +0 -0
  664. /package/src/PageScroller/story/{FourthComponent.js → FourthComponent.jsx} +0 -0
  665. /package/src/PageScroller/story/{FullPage.js → FullPage.jsx} +0 -0
  666. /package/src/PageScroller/story/{PageContain.js → PageContain.jsx} +0 -0
  667. /package/src/PageScroller/story/{SecondComponent.js → SecondComponent.jsx} +0 -0
  668. /package/src/PageScroller/story/{ThirdComponent.js → ThirdComponent.jsx} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import type { Locale } from '../type';
2
+ import { Locale } from '../type';
3
3
  declare const getLocale: (languages?: {
4
4
  code: string;
5
5
  }[]) => string;
@@ -26,8 +26,8 @@ export interface LocaleContextType {
26
26
  name: string;
27
27
  }[];
28
28
  }
29
- declare const LocaleContext: import("react").Context<LocaleContextType>;
30
- declare const Consumer: import("react").Consumer<LocaleContextType>;
29
+ declare const LocaleContext: import('react').Context<LocaleContextType>;
30
+ declare const Consumer: import('react').Consumer<LocaleContextType>;
31
31
  declare function LocaleProvider({ children, locale, fallbackLocale, translations, onLoadingTranslation, languages, ...rest }: LocaleProviderProps): import("react/jsx-runtime").JSX.Element;
32
32
  declare function useLocaleContext(): LocaleContextType;
33
33
  export { LocaleProvider, Consumer as LocaleConsumer, LocaleContext, useLocaleContext, setLocale, getLocale };
@@ -1,133 +1,81 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /* eslint-disable no-prototype-builtins */
3
- import { createContext, useState, useEffect, useContext, useRef, useCallback } from 'react';
4
- import get from 'lodash/get';
5
- import Cookie from 'js-cookie';
6
- import browserLang from './browser-lang';
7
- import { translate } from './util';
8
- import { getCookieOptions, resolveRootDomain } from '../Util';
9
- const cookieName = 'nf_lang';
10
-
11
- // 跨应用传递多语言选择的方式是在 query string 中添加 locale 参数,LocaleSelector 要高优先级遵守这个参数
12
- const getLocaleFromSearchParams = (languages, url = window.location.href) => {
13
- const locale = new URL(url).searchParams.get('locale');
14
- if (languages.find(x => x.code === locale)) {
15
- return locale;
16
- }
17
- return null;
18
- };
19
- const setLocaleParam = (locale, url = window.location.href) => {
20
- const urlObj = new URL(url);
21
- const hasLocaleParam = urlObj.searchParams.has('locale');
22
- if (hasLocaleParam) {
23
- urlObj.searchParams.set('locale', locale);
24
- window.history.replaceState({}, '', urlObj.href);
25
- }
26
- };
27
- const getLocale = (languages = []) => {
28
- const langParams = {
29
- languages: languages.map(item => item.code),
1
+ import { jsx as v } from "react/jsx-runtime";
2
+ import { createContext as x, use as k, useState as p, useRef as A, useEffect as R, useCallback as b } from "react";
3
+ import j from "lodash/get";
4
+ import f from "js-cookie";
5
+ import S from "./browser-lang.js";
6
+ import { translate as U } from "./util.js";
7
+ import { getCookieOptions as D, resolveRootDomain as E } from "../Util/index.js";
8
+ const l = "nf_lang", F = (e, o = window.location.href) => {
9
+ const t = new URL(o).searchParams.get("locale");
10
+ return e.find((r) => r.code === t) ? t : null;
11
+ }, O = (e, o = window.location.href) => {
12
+ const t = new URL(o);
13
+ t.searchParams.has("locale") && (t.searchParams.set("locale", e), window.history.replaceState({}, "", t.href));
14
+ }, L = (e = []) => {
15
+ var t;
16
+ const o = {
17
+ languages: e.map((r) => r.code),
30
18
  // 取 languages 首个元素的 code 值, 如果不存在则取 'en'
31
- fallback: languages?.[0]?.code || 'en'
19
+ fallback: ((t = e == null ? void 0 : e[0]) == null ? void 0 : t.code) || "en"
32
20
  };
33
- return getLocaleFromSearchParams(languages) || Cookie.get(cookieName) || browserLang(langParams);
34
- };
35
- const setLocale = locale => {
36
- const opts = getCookieOptions();
37
-
38
- // @compatibility 移除历史上使用根域名的旧 cookie
39
- if (!opts.domain) {
40
- const rootDomain = resolveRootDomain();
41
- if (rootDomain) {
42
- Cookie.remove(cookieName, {
43
- path: opts.path || '/',
44
- domain: rootDomain
45
- });
46
- }
21
+ return F(e) || f.get(l) || S(o);
22
+ }, z = (e) => {
23
+ const o = D();
24
+ if (!o.domain) {
25
+ const t = E();
26
+ t && f.remove(l, { path: o.path || "/", domain: t });
47
27
  }
48
- Cookie.set(cookieName, locale, opts);
49
- setLocaleParam(locale);
50
- };
51
- const getLanguages = arg => {
52
- const env = get(window, 'blocklet.languages');
53
- if (Array.isArray(env) && env.length) {
54
- return env;
55
- }
56
- if (Array.isArray(arg) && arg.length) {
57
- return arg;
58
- }
59
- return [{
60
- code: 'en',
61
- name: 'English'
62
- }, {
63
- code: 'zh',
64
- name: '简体中文'
65
- }];
66
- };
67
- // FIXME: @wangshijun revert this before release
68
- const LocaleContext = /*#__PURE__*/createContext(null);
69
- const {
70
- Provider,
71
- Consumer
72
- } = LocaleContext;
73
- function LocaleProvider({
74
- children,
75
- locale,
76
- fallbackLocale,
77
- translations,
78
- onLoadingTranslation,
79
- languages = [],
80
- ...rest
28
+ f.set(l, e, o), O(e);
29
+ }, N = (e) => {
30
+ const o = j(window, "blocklet.languages");
31
+ return Array.isArray(o) && o.length ? o : Array.isArray(e) && e.length ? e : [
32
+ { code: "en", name: "English" },
33
+ { code: "zh", name: "简体中文" }
34
+ ];
35
+ }, d = x(null), { Provider: _, Consumer: M } = d;
36
+ function Q({
37
+ children: e,
38
+ locale: o,
39
+ fallbackLocale: t,
40
+ translations: r,
41
+ onLoadingTranslation: m,
42
+ languages: P = [],
43
+ ...C
81
44
  }) {
82
- const langs = getLanguages(languages);
83
- // eslint-disable-next-line prefer-const
84
- let [currentLocale, setCurrentLocale] = useState(locale || getLocale(langs));
85
- const lastCurrentLocale = useRef(fallbackLocale || '');
86
- const [, setForceUpdate] = useState(0);
87
- const changeLocale = newLocale => {
88
- setCurrentLocale(newLocale);
89
- setLocale(newLocale);
45
+ const a = N(P);
46
+ let [n, w] = p(o || L(a));
47
+ const i = A(t || ""), [, y] = p(0), u = (c) => {
48
+ w(c), z(c);
90
49
  };
91
- useEffect(() => {
92
- const tmpLocale = locale || getLocale(langs);
93
- if (tmpLocale !== currentLocale) {
94
- changeLocale(tmpLocale);
95
- }
96
- // eslint-disable-next-line react-hooks/exhaustive-deps
97
- }, [locale]);
98
-
99
- // handle async loading of translations
100
- if (currentLocale && translations[currentLocale] && typeof translations[currentLocale] === 'function') {
101
- const tmpLocale = currentLocale;
50
+ if (R(() => {
51
+ const c = o || L(a);
52
+ c !== n && u(c);
53
+ }, [o]), n && r[n] && typeof r[n] == "function") {
54
+ const c = n;
102
55
  try {
103
- Promise.resolve(translations[tmpLocale]()).then(res => {
104
- if (res && typeof res === 'object') {
105
- translations[tmpLocale] = res;
106
- setForceUpdate(x => x > 999 ? 0 : x + 1);
107
- }
56
+ Promise.resolve(r[c]()).then((s) => {
57
+ s && typeof s == "object" && (r[c] = s, y((h) => h > 999 ? 0 : h + 1));
108
58
  });
109
- } catch (err) {
110
- console.error(err);
59
+ } catch (s) {
60
+ console.error(s);
111
61
  }
112
- onLoadingTranslation?.(tmpLocale, langs);
113
- currentLocale = lastCurrentLocale.current;
114
- } else {
115
- lastCurrentLocale.current = currentLocale;
116
- }
117
- const t = useCallback((key, data) => translate(translations, key, currentLocale, fallbackLocale, data), [translations, currentLocale, fallbackLocale]);
118
- return /*#__PURE__*/_jsx(Provider, {
119
- value: {
120
- locale: currentLocale,
121
- changeLocale,
122
- t,
123
- languages: langs,
124
- ...rest
125
- },
126
- children: children
127
- });
62
+ m == null || m(c, a), n = i.current;
63
+ } else
64
+ i.current = n;
65
+ const g = b(
66
+ (c, s) => U(r, c, n, t, s),
67
+ [r, n, t]
68
+ );
69
+ return /* @__PURE__ */ v(_, { value: { locale: n, changeLocale: u, t: g, languages: a, ...C }, children: e });
128
70
  }
129
- function useLocaleContext() {
130
- const context = useContext(LocaleContext);
131
- return context;
71
+ function V() {
72
+ return k(d);
132
73
  }
133
- export { LocaleProvider, Consumer as LocaleConsumer, LocaleContext, useLocaleContext, setLocale, getLocale };
74
+ export {
75
+ M as LocaleConsumer,
76
+ d as LocaleContext,
77
+ Q as LocaleProvider,
78
+ L as getLocale,
79
+ z as setLocale,
80
+ V as useLocaleContext
81
+ };
@@ -1,60 +1,58 @@
1
- // from: https://github.com/meikidd/iso-639-1/blob/master/src/data.js
2
- const languages = {
1
+ const e = {
3
2
  ar: {
4
- name: 'Arabic',
5
- nativeName: 'اَلْعَرَبِيَّةُ'
3
+ name: "Arabic",
4
+ nativeName: "اَلْعَرَبِيَّةُ"
6
5
  },
7
6
  de: {
8
- name: 'German',
9
- nativeName: 'Deutsch'
7
+ name: "German",
8
+ nativeName: "Deutsch"
10
9
  },
11
10
  en: {
12
- name: 'English',
13
- nativeName: 'English'
11
+ name: "English",
12
+ nativeName: "English"
14
13
  },
15
14
  es: {
16
- name: 'Spanish',
17
- nativeName: 'Español'
15
+ name: "Spanish",
16
+ nativeName: "Español"
18
17
  },
19
18
  fr: {
20
- name: 'French',
21
- nativeName: 'Français'
19
+ name: "French",
20
+ nativeName: "Français"
22
21
  },
23
22
  it: {
24
- name: 'Italian',
25
- nativeName: 'Italiano'
23
+ name: "Italian",
24
+ nativeName: "Italiano"
26
25
  },
27
26
  ja: {
28
- name: 'Japanese',
29
- nativeName: '日本語'
27
+ name: "Japanese",
28
+ nativeName: "日本語"
30
29
  },
31
30
  ko: {
32
- name: 'Korean',
33
- nativeName: '한국어'
31
+ name: "Korean",
32
+ nativeName: "한국어"
34
33
  },
35
34
  mn: {
36
- name: 'Mongolian',
37
- nativeName: 'Монгол хэл'
35
+ name: "Mongolian",
36
+ nativeName: "Монгол хэл"
38
37
  },
39
38
  pt: {
40
- name: 'Portuguese',
41
- nativeName: 'Português'
39
+ name: "Portuguese",
40
+ nativeName: "Português"
42
41
  },
43
42
  ru: {
44
- name: 'Russian',
45
- nativeName: 'Русский'
43
+ name: "Russian",
44
+ nativeName: "Русский"
46
45
  },
47
46
  zh: {
48
- name: 'Simplified Chinese',
49
- nativeName: '简体中文'
47
+ name: "Simplified Chinese",
48
+ nativeName: "简体中文"
50
49
  },
51
- 'zh-TW': {
52
- name: 'Traditional Chinese',
53
- nativeName: '繁體中文'
50
+ "zh-TW": {
51
+ name: "Traditional Chinese",
52
+ nativeName: "繁體中文"
54
53
  }
54
+ }, n = Object.keys(e).map((a) => ({ code: a, ...e[a] }));
55
+ export {
56
+ n as default,
57
+ e as map
55
58
  };
56
- export default Object.keys(languages).map(code => ({
57
- code,
58
- ...languages[code]
59
- }));
60
- export { languages as map };
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import type { Locale } from '../type';
1
+ import { default as React } from 'react';
2
+ import { Locale } from '../type';
3
3
  export interface LocaleSelectorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
4
4
  showText?: true | false;
5
5
  popperProps?: React.HTMLAttributes<HTMLDivElement>;
@@ -1,147 +1,111 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /* eslint-disable react/jsx-no-bind */
3
- import React, { useState, useContext, useRef, useMemo } from 'react';
4
- import { Button, Typography, IconButton, Popper, MenuItem, MenuList, Box, ClickAwayListener, Paper } from '@mui/material';
5
- import { Icon as IconifyIcon } from '@iconify/react';
6
- import CheckIcon from '@iconify-icons/material-symbols/check';
7
- import LanguageIcon from 'iconify-icons-material-symbols-400/language';
8
- import noop from 'lodash/noop';
9
- import { LocaleContext } from './context';
10
- import { styled, useTheme } from '../Theme';
11
- import { mergeSx } from '../Util/style';
12
- export default function LocaleSelector(props) {
13
- const {
14
- showText = true,
15
- popperProps = {},
16
- popperType = 'click',
17
- icon: Icon,
18
- size = 24,
19
- onChange = noop,
20
- ...rest
21
- } = props;
22
- const {
23
- locale,
24
- changeLocale,
25
- languages
26
- } = useContext(LocaleContext);
27
- const anchorEl = useRef(null);
28
- const [open, setOpen] = useState(false);
29
- const theme = useTheme();
30
- const dark = theme?.palette?.mode === 'dark';
31
- const onSelect = newLocale => {
32
- changeLocale(newLocale);
33
- setOpen(false);
34
- if (typeof props.onChange === 'function') {
35
- props.onChange(newLocale);
36
- }
37
- };
38
- const onClose = e => {
39
- if (anchorEl.current?.contains(e.target)) {
40
- return;
41
- }
42
- setOpen(false);
43
- };
44
- const ButtonComponent = showText ? Button : IconButton;
45
- const handleEventProps = popperType === 'hover' ? {
1
+ import { jsx as n, jsxs as s } from "react/jsx-runtime";
2
+ import { use as z, useRef as L, useState as M, useMemo as N } from "react";
3
+ import { Box as m, Button as w, IconButton as B, Typography as E, Popper as j, Paper as A, ClickAwayListener as R, MenuList as T, MenuItem as P } from "@mui/material";
4
+ import { Icon as h } from "@iconify/react";
5
+ import $ from "@iconify-icons/material-symbols/check";
6
+ import H from "iconify-icons-material-symbols-400/language";
7
+ import { LocaleContext as O } from "./context.js";
8
+ import { styled as W } from "../Theme/index.js";
9
+ import { mergeSx as q } from "../Util/style.js";
10
+ function Z(t) {
11
+ var g;
12
+ const { showText: p = !0, popperProps: r = {}, popperType: d = "click", icon: c, size: f = 24, ...y } = t, { locale: l, changeLocale: I, languages: u } = z(O), a = L(null), [x, o] = M(!1), k = (e) => {
13
+ I(e), o(!1), typeof t.onChange == "function" && t.onChange(e);
14
+ }, C = (e) => {
15
+ var i;
16
+ (i = a.current) != null && i.contains(e.target) || o(!1);
17
+ }, S = p ? w : B, b = d === "hover" ? {
46
18
  onMouseEnter: () => {
47
- setOpen(true);
19
+ o(!0);
48
20
  },
49
21
  onMouseLeave: () => {
50
- setOpen(false);
22
+ o(!1);
51
23
  }
52
24
  } : {
53
25
  onClick: () => {
54
- setOpen(!open);
55
- }
56
- };
57
- const renderIcon = useMemo(() => {
58
- if (Icon) {
59
- return /*#__PURE__*/_jsx(Icon, {});
26
+ o(!x);
60
27
  }
61
- return /*#__PURE__*/_jsx(IconifyIcon, {
62
- icon: LanguageIcon,
63
- fontSize: size,
64
- style: {
65
- transform: 'scale(1.10)'
66
- }
67
- });
68
- }, [Icon, size]);
69
- return /*#__PURE__*/_jsxs(Wrapper, {
70
- ...rest,
71
- ...handleEventProps,
72
- children: [/*#__PURE__*/_jsx(ButtonComponent, {
73
- ref: anchorEl,
74
- className: "trigger",
75
- role: "button",
76
- "aria-label": "Locale selector button",
77
- children: /*#__PURE__*/_jsxs(Box, {
78
- display: "flex",
79
- alignItems: "center",
80
- children: [renderIcon, showText ? /*#__PURE__*/_jsx(Typography, {
81
- component: "strong",
82
- className: "trigger-text",
83
- children: languages.find(x => x.code === locale)?.name
84
- }) : '']
85
- })
86
- }), /*#__PURE__*/_jsx(Popper, {
87
- open: open,
88
- anchorEl: anchorEl.current,
89
- ...popperProps,
90
- // @ts-ignore
91
- sx: mergeSx(
92
- // @ts-ignore
93
- {
94
- zIndex: _theme => _theme.zIndex.tooltip + 10
95
- },
96
- // @ts-ignore
97
- popperProps?.sx),
98
- children: /*#__PURE__*/_jsx(Paper, {
99
- variant: "outlined",
100
- className: "locales",
101
- sx: {
102
- borderRadius: 1
103
- },
104
- children: /*#__PURE__*/_jsx(ClickAwayListener, {
105
- onClickAway: onClose,
106
- children: /*#__PURE__*/_jsx(MenuList, {
107
- children: languages.map(({
108
- code,
109
- name
110
- }) => {
111
- return /*#__PURE__*/_jsxs(MenuItem, {
112
- className: "locale-item",
113
- onClick: () => onSelect(code),
114
- sx: {
115
- fontSize: 16,
116
- fontStyle: 'normal',
117
- fontStretch: 'normal',
118
- lineHeight: 'normal',
119
- letterSpacing: '2px',
120
- textAlign: 'center',
121
- color: 'text.primary',
122
- cursor: 'pointer',
123
- display: 'flex',
124
- padding: '16px',
125
- alignItems: 'center'
126
- },
127
- children: [/*#__PURE__*/_jsx(Box, {
128
- component: IconifyIcon,
129
- icon: CheckIcon,
130
- className: code === locale ? 'check-icon check-icon-visible' : 'check-icon',
28
+ }, v = N(() => c ? /* @__PURE__ */ n(c, {}) : /* @__PURE__ */ n(h, { icon: H, fontSize: f, style: { transform: "scale(1.10)" } }), [c, f]);
29
+ return (
30
+ // @ts-ignore
31
+ /* @__PURE__ */ s(D, { ...y, ...b, children: [
32
+ /* @__PURE__ */ n(S, { ref: a, className: "trigger", role: "button", "aria-label": "Locale selector button", children: /* @__PURE__ */ s(
33
+ m,
34
+ {
35
+ sx: {
36
+ display: "flex",
37
+ alignItems: "center"
38
+ },
39
+ children: [
40
+ v,
41
+ p ? /* @__PURE__ */ n(E, { component: "strong", className: "trigger-text", children: (g = u.find((e) => e.code === l)) == null ? void 0 : g.name }) : ""
42
+ ]
43
+ }
44
+ ) }),
45
+ /* @__PURE__ */ n(
46
+ j,
47
+ {
48
+ open: x,
49
+ anchorEl: a.current,
50
+ ...r,
51
+ sx: q(
52
+ // @ts-ignore
53
+ { zIndex: (e) => e.zIndex.tooltip + 10 },
54
+ // @ts-ignore
55
+ r == null ? void 0 : r.sx
56
+ ),
57
+ children: /* @__PURE__ */ n(
58
+ A,
59
+ {
60
+ variant: "outlined",
61
+ className: "locales",
62
+ sx: {
63
+ borderRadius: 1
64
+ },
65
+ children: /* @__PURE__ */ n(R, { onClickAway: C, children: /* @__PURE__ */ n(T, { children: u.map(({ code: e, name: i }) => /* @__PURE__ */ s(
66
+ P,
67
+ {
68
+ className: "locale-item",
69
+ onClick: () => k(e),
131
70
  sx: {
132
- marginRight: 1,
133
- visibility: code === locale ? 'visible' : 'hidden'
134
- }
135
- }), name]
136
- }, code);
137
- })
138
- })
139
- })
140
- })
141
- })]
142
- });
71
+ fontSize: 16,
72
+ fontStyle: "normal",
73
+ fontStretch: "normal",
74
+ lineHeight: "normal",
75
+ letterSpacing: "2px",
76
+ textAlign: "center",
77
+ color: "text.primary",
78
+ cursor: "pointer",
79
+ display: "flex",
80
+ padding: "16px",
81
+ alignItems: "center"
82
+ },
83
+ children: [
84
+ /* @__PURE__ */ n(
85
+ m,
86
+ {
87
+ component: h,
88
+ icon: $,
89
+ className: e === l ? "check-icon check-icon-visible" : "check-icon",
90
+ sx: {
91
+ marginRight: 1,
92
+ visibility: e === l ? "visible" : "hidden"
93
+ }
94
+ }
95
+ ),
96
+ i
97
+ ]
98
+ },
99
+ e
100
+ )) }) })
101
+ }
102
+ )
103
+ }
104
+ )
105
+ ] })
106
+ );
143
107
  }
144
- const Wrapper = styled(Box)`
108
+ const D = W(m)`
145
109
  display: inline-block;
146
110
 
147
111
  .trigger {
@@ -154,9 +118,10 @@ const Wrapper = styled(Box)`
154
118
  .trigger-text {
155
119
  margin-left: 5px;
156
120
  font-size: 14px;
157
- color: ${({
158
- theme
159
- }) => theme.palette.text.primary};
121
+ color: ${({ theme: t }) => t.palette.text.primary};
160
122
  }
161
123
  }
162
- `;
124
+ `;
125
+ export {
126
+ Z as default
127
+ };
@@ -1,4 +1,4 @@
1
- import type { Locale, Translations } from '../type';
1
+ import { Locale, Translations } from '../type';
2
2
  export declare const replace: (template: string | Function, data: Record<string, any>) => any;
3
3
  export declare const translate: (translations: Translations, key: string, locale: Locale, fallbackLocale?: string, data?: {}) => any;
4
4
  export declare const t: (translations: Translations, key: string, locale: Locale, fallbackLocale?: string, data?: {}) => any;
@@ -1,25 +1,10 @@
1
- import get from 'lodash/get';
2
- /* eslint-disable no-prototype-builtins */
3
- export const replace = (template, data) => {
4
- if (typeof template === 'function') {
5
- return template(data);
6
- }
7
- return template.replace(/{(\w*)}/g, (m, key) => data.hasOwnProperty(key) ? data[key] : '');
1
+ import s from "lodash/get";
2
+ const e = (n, r) => typeof n == "function" ? n(r) : n.replace(/{(\w*)}/g, (t, o) => r.hasOwnProperty(o) ? r[o] : ""), p = (n, r, t, o = "en", f = {}) => {
3
+ const i = n[t], c = s(i, r), u = s(n[o], r);
4
+ return !i || !c ? (console.warn(`Warning: no ${r} translation of ${t}`), o && u ? e(u, f) : r) : typeof n[t] == "function" || n[t].then ? e(u, f) : e(c, f);
5
+ }, w = p;
6
+ export {
7
+ e as replace,
8
+ w as t,
9
+ p as translate
8
10
  };
9
- export const translate = (translations, key, locale, fallbackLocale = 'en', data = {}) => {
10
- const translation = translations[locale];
11
- const translationValue = get(translation, key);
12
- const fallbackValue = get(translations[fallbackLocale], key);
13
- if (!translation || !translationValue) {
14
- console.warn(`Warning: no ${key} translation of ${locale}`);
15
- if (fallbackLocale && fallbackValue) {
16
- return replace(fallbackValue, data);
17
- }
18
- return key;
19
- }
20
- if (typeof translations[locale] === 'function' || translations[locale].then) {
21
- return replace(fallbackValue, data);
22
- }
23
- return replace(translationValue, data);
24
- };
25
- export const t = translate;
@@ -0,0 +1,22 @@
1
+ export { default as DarkMode } from './demo/dark-mode';
2
+ export { default as DarkModeLogoOnly } from './demo/dark-mode-logo-only';
3
+ export { default as DarkModeHorizontal } from './demo/dark-mode-horizontal';
4
+ export { default as WithStyling } from './demo/with-styling';
5
+ export { default as LightMode } from './demo/light-mode';
6
+ export { default as LightModeLogoOnly } from './demo/light-mode-logo-only';
7
+ export { default as LightModeHorizontal } from './demo/light-mode-horizontal';
8
+ declare namespace _default {
9
+ let title: string;
10
+ namespace parameters {
11
+ namespace docs {
12
+ namespace description {
13
+ let component: string;
14
+ }
15
+ }
16
+ namespace design {
17
+ let type: string;
18
+ let url: string;
19
+ }
20
+ }
21
+ }
22
+ export default _default;