@arcblock/ux 3.4.14 → 3.5.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 (335) hide show
  1. package/lib/Util/constant.d.ts +6 -0
  2. package/lib/Util/constant.js +25 -16
  3. package/lib/package.json.js +1 -1
  4. package/package.json +12 -9
  5. package/src/ActionButton/ActionButton.stories.jsx +0 -61
  6. package/src/ActionButton/index.jsx +0 -106
  7. package/src/ActivityIndicator/ActivityIndicator.stories.jsx +0 -9
  8. package/src/ActivityIndicator/index.jsx +0 -140
  9. package/src/Address/Address.stories.jsx +0 -38
  10. package/src/Address/compact-text.jsx +0 -76
  11. package/src/Address/did-address.tsx +0 -223
  12. package/src/Address/index.tsx +0 -21
  13. package/src/Address/responsive-did-address.tsx +0 -154
  14. package/src/Alert/Alert.stories.jsx +0 -100
  15. package/src/Alert/index.jsx +0 -130
  16. package/src/AnimationWaiter/AnimationWaiter.stories.jsx +0 -35
  17. package/src/AnimationWaiter/dark-animation.json +0 -1
  18. package/src/AnimationWaiter/default-animation.json +0 -1
  19. package/src/AnimationWaiter/index.jsx +0 -296
  20. package/src/Async/index.tsx +0 -44
  21. package/src/Avatar/Avatar.stories.jsx +0 -11
  22. package/src/Avatar/did-motif.jsx +0 -38
  23. package/src/Avatar/etherscan-blockies.js +0 -81
  24. package/src/Avatar/index.jsx +0 -195
  25. package/src/Badge/Badge.stories.jsx +0 -41
  26. package/src/Badge/index.jsx +0 -101
  27. package/src/Blocklet/Blocklet.stories.jsx +0 -21
  28. package/src/Blocklet/blocklet.jsx +0 -276
  29. package/src/Blocklet/index.js +0 -5
  30. package/src/Blocklet/utils.jsx +0 -58
  31. package/src/BlockletContext/index.tsx +0 -72
  32. package/src/BlockletNFT/BlockletNFT.stories.jsx +0 -21
  33. package/src/BlockletNFT/index.jsx +0 -378
  34. package/src/BlockletV2/Blocklet.stories.jsx +0 -34
  35. package/src/BlockletV2/blocklet.tsx +0 -247
  36. package/src/BlockletV2/components/icon-text.tsx +0 -47
  37. package/src/BlockletV2/components/tooltip-icon.tsx +0 -52
  38. package/src/BlockletV2/index.ts +0 -6
  39. package/src/BlockletV2/utils.js +0 -75
  40. package/src/Button/Button.stories.jsx +0 -24
  41. package/src/Button/index.js +0 -9
  42. package/src/Button/wrap.jsx +0 -126
  43. package/src/ButtonGroup/index.js +0 -16
  44. package/src/CardSelector/index.tsx +0 -136
  45. package/src/Center/Center.stories.jsx +0 -20
  46. package/src/Center/index.tsx +0 -33
  47. package/src/ClickToCopy/ClickToCopy.stories.jsx +0 -24
  48. package/src/ClickToCopy/copy-button.tsx +0 -43
  49. package/src/ClickToCopy/hook.ts +0 -42
  50. package/src/ClickToCopy/index.tsx +0 -96
  51. package/src/CloseButton/index.tsx +0 -37
  52. package/src/CodeBlock/CodeBlock.stories.jsx +0 -22
  53. package/src/CodeBlock/LightBox.tsx +0 -87
  54. package/src/CodeBlock/index.tsx +0 -217
  55. package/src/Colors/Colors.stories.jsx +0 -211
  56. package/src/Colors/index.ts +0 -4
  57. package/src/Colors/themes/default.ts +0 -8
  58. package/src/Colors/themes/did-connect.ts +0 -64
  59. package/src/Colors/themes/temp.ts +0 -52
  60. package/src/Config/Config.stories.jsx +0 -16
  61. package/src/Config/config-provider.tsx +0 -62
  62. package/src/Config/index.ts +0 -2
  63. package/src/Config/theme-mode-toggle.tsx +0 -38
  64. package/src/ContactForm/ContactForm.stories.jsx +0 -32
  65. package/src/ContactForm/index.tsx +0 -264
  66. package/src/CookieConsent/CookieConsent.stories.jsx +0 -33
  67. package/src/CookieConsent/index.tsx +0 -104
  68. package/src/CountDown/CountDown.stories.jsx +0 -15
  69. package/src/CountDown/index.tsx +0 -170
  70. package/src/DID/DID.stories.jsx +0 -37
  71. package/src/DID/index.tsx +0 -393
  72. package/src/DIDConnect/app-icon.tsx +0 -37
  73. package/src/DIDConnect/app-info-item.tsx +0 -93
  74. package/src/DIDConnect/auth-apps/auth-apps-info.tsx +0 -77
  75. package/src/DIDConnect/auth-apps/index.tsx +0 -278
  76. package/src/DIDConnect/auth-apps/switch-role.tsx +0 -47
  77. package/src/DIDConnect/did-connect-container.tsx +0 -326
  78. package/src/DIDConnect/did-connect-footer.tsx +0 -76
  79. package/src/DIDConnect/did-connect-logo.tsx +0 -8
  80. package/src/DIDConnect/icons/did-wallet-logo.tsx +0 -18
  81. package/src/DIDConnect/icons/github-logo.tsx +0 -17
  82. package/src/DIDConnect/index.ts +0 -11
  83. package/src/DIDConnect/landing-page.tsx +0 -218
  84. package/src/DIDConnect/powered-by.tsx +0 -48
  85. package/src/DIDConnect/provider-icon.tsx +0 -62
  86. package/src/DIDConnect/request-storage-access-api-dialog.tsx +0 -304
  87. package/src/DIDConnect/with-container.tsx +0 -323
  88. package/src/DIDConnect/with-ux-theme.tsx +0 -22
  89. package/src/DIDLogo/Logo.stories.jsx +0 -11
  90. package/src/DIDLogo/index.tsx +0 -168
  91. package/src/Datatable/CustomToolbar.jsx +0 -415
  92. package/src/Datatable/Datatable.stories.jsx +0 -92
  93. package/src/Datatable/DatatableContext.jsx +0 -35
  94. package/src/Datatable/TableSearch.jsx +0 -166
  95. package/src/Datatable/index.jsx +0 -652
  96. package/src/Datatable/utils.js +0 -161
  97. package/src/Dialog/Dialog.stories.jsx +0 -21
  98. package/src/Dialog/confirm.jsx +0 -143
  99. package/src/Dialog/dialog.jsx +0 -199
  100. package/src/Dialog/index.js +0 -4
  101. package/src/Dialog/types.d.ts +0 -20
  102. package/src/Dialog/use-confirm.jsx +0 -188
  103. package/src/DriftBot/index.tsx +0 -81
  104. package/src/Earth/Earth.stories.jsx +0 -39
  105. package/src/Earth/countries.json +0 -8057
  106. package/src/Earth/index.tsx +0 -515
  107. package/src/Earth/util.ts +0 -72
  108. package/src/Empty/Empty.stories.jsx +0 -23
  109. package/src/Empty/index.jsx +0 -48
  110. package/src/ErrorBoundary/ErrorBoundary.stories.jsx +0 -13
  111. package/src/ErrorBoundary/fallback.tsx +0 -85
  112. package/src/ErrorBoundary/index.ts +0 -1
  113. package/src/Footer/Footer.stories.jsx +0 -13
  114. package/src/Footer/index.tsx +0 -130
  115. package/src/Header/Header.stories.jsx +0 -30
  116. package/src/Header/addon-button.tsx +0 -41
  117. package/src/Header/auto-hidden.tsx +0 -31
  118. package/src/Header/header-addons.tsx +0 -37
  119. package/src/Header/header.tsx +0 -214
  120. package/src/Header/index.ts +0 -3
  121. package/src/Header/responsive-header.tsx +0 -145
  122. package/src/Icon/Icon.stories.jsx +0 -45
  123. package/src/Icon/image.tsx +0 -53
  124. package/src/Icon/index.tsx +0 -63
  125. package/src/Img/Img.stories.jsx +0 -17
  126. package/src/Img/index.jsx +0 -258
  127. package/src/InfoRow/InfoRow.stories.jsx +0 -14
  128. package/src/InfoRow/index.tsx +0 -91
  129. package/src/Layout/Layout.stories.jsx +0 -24
  130. package/src/Layout/dashboard/external-link.tsx +0 -59
  131. package/src/Layout/dashboard/full-page.tsx +0 -58
  132. package/src/Layout/dashboard/index.tsx +0 -260
  133. package/src/Layout/dashboard/sidebar.tsx +0 -198
  134. package/src/Layout/dashboard-legacy/header.tsx +0 -156
  135. package/src/Layout/dashboard-legacy/index.tsx +0 -127
  136. package/src/Layout/dashboard-legacy/sidebar.tsx +0 -129
  137. package/src/Layout/index.tsx +0 -310
  138. package/src/LoadingMask/index.tsx +0 -108
  139. package/src/Locale/LocaleSelector.stories.jsx +0 -44
  140. package/src/Locale/browser-lang.ts +0 -65
  141. package/src/Locale/context.tsx +0 -162
  142. package/src/Locale/languages.ts +0 -58
  143. package/src/Locale/selector.tsx +0 -174
  144. package/src/Locale/util.ts +0 -38
  145. package/src/Logo/Logo.stories.jsx +0 -23
  146. package/src/Logo/images/logo-dark-text.svg +0 -3
  147. package/src/Logo/images/logo-dark-top.svg +0 -6
  148. package/src/Logo/images/logo-light-text.svg +0 -3
  149. package/src/Logo/images/logo-light-top.svg +0 -6
  150. package/src/Logo/index.tsx +0 -58
  151. package/src/Metric/Metric.stories.jsx +0 -29
  152. package/src/Metric/index.tsx +0 -130
  153. package/src/MuiWrap/index.tsx +0 -10
  154. package/src/NFTDisplay/NFTBroken.svg +0 -34
  155. package/src/NFTDisplay/NFTDisplay.stories.jsx +0 -30
  156. package/src/NFTDisplay/README.md +0 -59
  157. package/src/NFTDisplay/aspect-ratio-container.tsx +0 -36
  158. package/src/NFTDisplay/broken.tsx +0 -51
  159. package/src/NFTDisplay/displayApi.ts +0 -43
  160. package/src/NFTDisplay/index.tsx +0 -393
  161. package/src/NFTDisplay/loading.tsx +0 -16
  162. package/src/NFTDisplay/preview.tsx +0 -84
  163. package/src/NFTDisplay/render-svg.tsx +0 -21
  164. package/src/NFTDisplay/svg-embedder/img.tsx +0 -27
  165. package/src/NFTDisplay/svg-embedder/inline-svg.tsx +0 -36
  166. package/src/NavMenu/NavMenu.stories.jsx +0 -17
  167. package/src/NavMenu/images/OCAP.svg +0 -1
  168. package/src/NavMenu/images/abt-network.svg +0 -1
  169. package/src/NavMenu/images/ai-kit.svg +0 -1
  170. package/src/NavMenu/images/aigne-image-smith.svg +0 -1
  171. package/src/NavMenu/images/aigne.svg +0 -1
  172. package/src/NavMenu/images/aistro.png +0 -0
  173. package/src/NavMenu/images/arcsphere.svg +0 -1
  174. package/src/NavMenu/images/blocklet-framework.svg +0 -1
  175. package/src/NavMenu/images/blocklet-launcher.svg +0 -1
  176. package/src/NavMenu/images/blocklet-server.svg +0 -1
  177. package/src/NavMenu/images/blocklet-store.svg +0 -1
  178. package/src/NavMenu/images/creator-studio.svg +0 -1
  179. package/src/NavMenu/images/did-wallet.svg +0 -1
  180. package/src/NavMenu/images/did.svg +0 -1
  181. package/src/NavMenu/images/nft-studio.svg +0 -1
  182. package/src/NavMenu/images/payment-kit.png +0 -0
  183. package/src/NavMenu/images/vc.svg +0 -1
  184. package/src/NavMenu/images/web3-kit.svg +0 -1
  185. package/src/NavMenu/index.ts +0 -3
  186. package/src/NavMenu/nav-menu-context.tsx +0 -30
  187. package/src/NavMenu/nav-menu.tsx +0 -441
  188. package/src/NavMenu/products.tsx +0 -830
  189. package/src/NavMenu/style.ts +0 -258
  190. package/src/NavMenu/sub-container.tsx +0 -125
  191. package/src/NavMenu/sub-item-group.tsx +0 -42
  192. package/src/OrgTransfer/index.tsx +0 -53
  193. package/src/OrgTransfer/locales.ts +0 -25
  194. package/src/OrgTransfer/selector.tsx +0 -252
  195. package/src/OrgTransfer/type.ts +0 -31
  196. package/src/PageScroller/index.tsx +0 -316
  197. package/src/PageScroller/story/FifthComponent.jsx +0 -7
  198. package/src/PageScroller/story/FirstComponent.jsx +0 -7
  199. package/src/PageScroller/story/FourthComponent.jsx +0 -7
  200. package/src/PageScroller/story/FullPage.jsx +0 -55
  201. package/src/PageScroller/story/PageContain.jsx +0 -59
  202. package/src/PageScroller/story/PageScroller.stories.jsx +0 -18
  203. package/src/PageScroller/story/SecondComponent.jsx +0 -7
  204. package/src/PageScroller/story/ThirdComponent.jsx +0 -7
  205. package/src/PageScroller/story/index.css +0 -115
  206. package/src/PageScroller/usePrevValue.ts +0 -11
  207. package/src/Passport/index.ts +0 -3
  208. package/src/Passport/passport.tsx +0 -118
  209. package/src/PhoneInput/PhoneInput.stories.jsx +0 -12
  210. package/src/PhoneInput/country-select.tsx +0 -148
  211. package/src/PhoneInput/index.tsx +0 -269
  212. package/src/PoweredByArcBlock/index.tsx +0 -27
  213. package/src/PricingTable/PricingPlan.tsx +0 -120
  214. package/src/PricingTable/PricingTable.stories.jsx +0 -38
  215. package/src/PricingTable/index.tsx +0 -59
  216. package/src/QRCode/QRCode.stories.jsx +0 -13
  217. package/src/QRCode/index.tsx +0 -66
  218. package/src/RelativeTime/RelativeTime.stories.jsx +0 -20
  219. package/src/RelativeTime/index.tsx +0 -334
  220. package/src/Result/Result.stories.jsx +0 -61
  221. package/src/Result/common.tsx +0 -119
  222. package/src/Result/index.tsx +0 -30
  223. package/src/Result/result.tsx +0 -65
  224. package/src/Result/translations.ts +0 -57
  225. package/src/Screenshot/BaseScreenshot/index.tsx +0 -73
  226. package/src/Screenshot/BaseScreenshot/shells/Macbook.tsx +0 -38
  227. package/src/Screenshot/BaseScreenshot/shells/Phone.tsx +0 -35
  228. package/src/Screenshot/Screenshot.stories.jsx +0 -44
  229. package/src/Screenshot/devices.css +0 -1366
  230. package/src/Screenshot/index.tsx +0 -300
  231. package/src/SessionBlocklet/index.tsx +0 -178
  232. package/src/SessionManager/SessionManager.stories.jsx +0 -9
  233. package/src/SessionManager/index.tsx +0 -3
  234. package/src/SessionPermission/index.tsx +0 -26
  235. package/src/SessionUser/components/did-space.tsx +0 -68
  236. package/src/SessionUser/components/logged-in.tsx +0 -338
  237. package/src/SessionUser/components/quick-login-item.tsx +0 -132
  238. package/src/SessionUser/components/session-user-item.tsx +0 -93
  239. package/src/SessionUser/components/session-user-switch.tsx +0 -240
  240. package/src/SessionUser/components/un-login.tsx +0 -257
  241. package/src/SessionUser/components/user-info.tsx +0 -201
  242. package/src/SessionUser/index.tsx +0 -68
  243. package/src/SessionUser/libs/translation.ts +0 -30
  244. package/src/SessionUser/libs/utils.ts +0 -39
  245. package/src/SharedBridge/index.tsx +0 -126
  246. package/src/SocialShare/index.tsx +0 -194
  247. package/src/Sparkline/Sparkline.stories.jsx +0 -13
  248. package/src/Sparkline/index.tsx +0 -231
  249. package/src/Spinner/Spinner.stories.jsx +0 -98
  250. package/src/Spinner/index.tsx +0 -20
  251. package/src/SplitButton/SplitButton.stories.jsx +0 -32
  252. package/src/SplitButton/index.tsx +0 -116
  253. package/src/SplitButton/useClickAway.tsx +0 -24
  254. package/src/Success/index.tsx +0 -175
  255. package/src/Switch/Switch.stories.jsx +0 -16
  256. package/src/Switch/index.jsx +0 -79
  257. package/src/Tabs/Tabs.stories.jsx +0 -18
  258. package/src/Tabs/index.tsx +0 -255
  259. package/src/Tag/Tag.stories.jsx +0 -15
  260. package/src/Tag/index.jsx +0 -106
  261. package/src/TextCollapse/TextCollapse.stories.jsx +0 -73
  262. package/src/TextCollapse/index.tsx +0 -85
  263. package/src/Theme/Theme.stories.jsx +0 -11
  264. package/src/Theme/index.ts +0 -21
  265. package/src/Theme/theme-provider.tsx +0 -374
  266. package/src/Theme/theme.ts +0 -229
  267. package/src/Toast/Toast.stories.jsx +0 -28
  268. package/src/Toast/index.tsx +0 -80
  269. package/src/Typography/index.tsx +0 -124
  270. package/src/UserCard/Cards/avatar-only.tsx +0 -27
  271. package/src/UserCard/Cards/basic-info.tsx +0 -43
  272. package/src/UserCard/Cards/index.tsx +0 -16
  273. package/src/UserCard/Cards/social-actions.tsx +0 -196
  274. package/src/UserCard/Container/card.tsx +0 -63
  275. package/src/UserCard/Container/dialog.tsx +0 -37
  276. package/src/UserCard/Content/basic.tsx +0 -330
  277. package/src/UserCard/Content/clock.tsx +0 -82
  278. package/src/UserCard/Content/minimal.tsx +0 -113
  279. package/src/UserCard/Content/shorten-label.tsx +0 -32
  280. package/src/UserCard/Content/tooltip-avatar.tsx +0 -80
  281. package/src/UserCard/UserCard.stories.jsx +0 -19
  282. package/src/UserCard/components.tsx +0 -81
  283. package/src/UserCard/index.tsx +0 -132
  284. package/src/UserCard/types.ts +0 -165
  285. package/src/UserCard/use-follow.tsx +0 -111
  286. package/src/UserCard/utils.ts +0 -155
  287. package/src/Util/WebWalletOpener.stories.jsx +0 -5
  288. package/src/Util/client.ts +0 -4
  289. package/src/Util/constant.ts +0 -60
  290. package/src/Util/deprecate.tsx +0 -29
  291. package/src/Util/federated.ts +0 -125
  292. package/src/Util/iframe.ts +0 -19
  293. package/src/Util/index.ts +0 -760
  294. package/src/Util/logger.ts +0 -44
  295. package/src/Util/passport.ts +0 -127
  296. package/src/Util/security.ts +0 -72
  297. package/src/Util/style.ts +0 -17
  298. package/src/Util/wallet.ts +0 -35
  299. package/src/VerificationCode/index.tsx +0 -83
  300. package/src/Video/Video.stories.jsx +0 -6
  301. package/src/Video/index.tsx +0 -70
  302. package/src/Wallet/Action.stories.jsx +0 -8
  303. package/src/Wallet/Action.tsx +0 -118
  304. package/src/Wallet/Download.stories.jsx +0 -9
  305. package/src/Wallet/Download.tsx +0 -157
  306. package/src/Wallet/Open.tsx +0 -47
  307. package/src/Wallet/OpenInWallet.stories.jsx +0 -5
  308. package/src/Wallet/images/abtwallet.png +0 -0
  309. package/src/Wallet/images/android_download.svg +0 -22
  310. package/src/Wallet/images/app-store.svg +0 -30
  311. package/src/Wallet/images/google-play.svg +0 -69
  312. package/src/WalletOSIcon/index.tsx +0 -47
  313. package/src/WebWalletSWKeeper/index.tsx +0 -117
  314. package/src/WechatPrompt/images/android.png +0 -0
  315. package/src/WechatPrompt/images/ios.png +0 -0
  316. package/src/WechatPrompt/index.tsx +0 -75
  317. package/src/global.d.ts +0 -28
  318. package/src/hooks/use-blocklet-logo.tsx +0 -32
  319. package/src/hooks/use-clock.tsx +0 -62
  320. package/src/hooks/use-location-state.tsx +0 -117
  321. package/src/hooks/use-mobile.tsx +0 -6
  322. package/src/index.ts +0 -79
  323. package/src/type.d.ts +0 -44
  324. package/src/withTheme/index.tsx +0 -72
  325. package/src/withTracker/README.md +0 -37
  326. package/src/withTracker/action/bind-wallet.tsx +0 -17
  327. package/src/withTracker/action/login.tsx +0 -18
  328. package/src/withTracker/action/pay.tsx +0 -14
  329. package/src/withTracker/action/switch-passport.tsx +0 -20
  330. package/src/withTracker/constant/index.tsx +0 -3
  331. package/src/withTracker/env.tsx +0 -1
  332. package/src/withTracker/error_boundary.jsx +0 -34
  333. package/src/withTracker/index.tsx +0 -50
  334. package/src/withTracker/libs/utm.ts +0 -46
  335. package/vite.config.mjs +0 -37
@@ -1,44 +0,0 @@
1
- /* eslint-disable import/prefer-default-export */
2
- import debug from 'debug';
3
-
4
- export const createDebug = debug;
5
-
6
- let debugInitialized = false;
7
-
8
- const initializeDebug = () => {
9
- if (debugInitialized) {
10
- return;
11
- }
12
- debugInitialized = true;
13
-
14
- if (window.blocklet?.ENABLE_DEBUG_TMP === 'false') {
15
- debug.disable();
16
- } else if (window.blocklet?.ENABLE_DEBUG_TMP) {
17
- debug.enable(window.blocklet?.ENABLE_DEBUG_TMP);
18
- }
19
- };
20
-
21
- export const createLogger = (namespace: string) => {
22
- initializeDebug();
23
-
24
- return new Proxy(window.console, {
25
- get(target, prop: keyof Console) {
26
- return (...args: any[]) => {
27
- try {
28
- if (['log', 'debug', 'info', 'warn', 'error'].includes(prop)) {
29
- // @ts-ignore
30
- return target[prop](namespace, ...args);
31
- }
32
- if (target[prop] instanceof Function) {
33
- // @ts-ignore
34
- return target[prop](...args);
35
- }
36
- return target[prop];
37
- } catch (err) {
38
- console.error(`Logger error in ${namespace}:`, err);
39
- return undefined;
40
- }
41
- };
42
- },
43
- });
44
- };
@@ -1,127 +0,0 @@
1
- import { getNftBGColor, DEFAULT_COLORS, getNftBGColorFromDid, getSvg } from '@arcblock/nft-display';
2
-
3
- export const getPassportColor = (preferredColor: string, did: string) => {
4
- let color;
5
- if (preferredColor === 'default') {
6
- color = DEFAULT_COLORS['app-passport'];
7
- } else if (preferredColor === 'auto') {
8
- color = getNftBGColorFromDid(did);
9
- } else {
10
- color = getNftBGColor(preferredColor);
11
- }
12
-
13
- return color;
14
- };
15
-
16
- export const getTextColor = (background: string) => {
17
- const r = parseInt(background.slice(1, 3), 16);
18
- const g = parseInt(background.slice(3, 5), 16);
19
- const b = parseInt(background.slice(5, 7), 16);
20
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
21
- return luminance > 0.5 ? '#111' : '#EEE';
22
- };
23
-
24
- export const createPassportSvg = ({
25
- issuer = '',
26
- title = '',
27
- issuerDid = '',
28
- issuerAvatarUrl = '',
29
- ownerDid = '',
30
- ownerAvatarUrl = '',
31
- preferredColor = 'default',
32
- revoked = false,
33
- isDataUrl = false,
34
- width = '100%',
35
- height = '100%',
36
- }) => {
37
- const color = getPassportColor(preferredColor, issuerDid);
38
-
39
- const svgXML = getSvg({
40
- width,
41
- height,
42
-
43
- tag: revoked ? 'revoked' : '',
44
- tagVariant: revoked ? 'error' : 'info',
45
-
46
- color,
47
-
48
- did: ownerDid,
49
- variant: 'app-passport',
50
- verifiable: true,
51
-
52
- issuer: {
53
- name: issuer,
54
- icon: issuerAvatarUrl,
55
- },
56
-
57
- header: {
58
- name: title,
59
- icon: ownerAvatarUrl,
60
- },
61
-
62
- // FIXME: @wangshijun this should be dynamic
63
- extra: {
64
- key: 'Exp',
65
- value: '2123-01-01',
66
- },
67
- });
68
-
69
- if (isDataUrl) {
70
- return `data:image/svg+xml;utf8,${encodeURIComponent(svgXML)}`;
71
- }
72
-
73
- return svgXML;
74
- };
75
-
76
- export const createKycSvg = ({
77
- issuer = '',
78
- title = '',
79
- issuerDid = '',
80
- issuerAvatarUrl = '',
81
- ownerDid = '',
82
- ownerName = '',
83
- ownerAvatarUrl = '',
84
- preferredColor = 'default',
85
- type = 'email',
86
- revoked = false,
87
- isDataUrl = false,
88
- width = '100%',
89
- height = '100%',
90
- }) => {
91
- const color = getPassportColor(preferredColor, issuerDid);
92
-
93
- const svgXML = getSvg({
94
- width,
95
- height,
96
-
97
- tag: revoked ? 'revoked' : '',
98
- tagVariant: revoked ? 'error' : 'info',
99
-
100
- color,
101
-
102
- did: ownerDid,
103
- variant: 'app-kyc',
104
- verifiable: true,
105
-
106
- issuer: {
107
- name: issuer,
108
- icon: issuerAvatarUrl,
109
- },
110
-
111
- header: {
112
- name: ownerName,
113
- icon: ownerAvatarUrl,
114
- },
115
-
116
- extra: {
117
- key: type,
118
- value: title,
119
- },
120
- });
121
-
122
- if (isDataUrl) {
123
- return `data:image/svg+xml;utf8,${encodeURIComponent(svgXML)}`;
124
- }
125
-
126
- return svgXML;
127
- };
@@ -1,72 +0,0 @@
1
- /* eslint-disable import/prefer-default-export */
2
-
3
- type GetSafeUrlOptions = {
4
- returnRaw?: boolean;
5
- throwOnError?: Boolean;
6
- // 为 null 时代表不检查 protocol
7
- allowProtocols?: Array<string> | null;
8
- // 为 null 时代表不检查 host
9
- allowDomains?: Array<string> | null;
10
- };
11
-
12
- class CustomError extends Error {}
13
-
14
- export function getSafeUrl(
15
- // 只允许 / 开头, ./ 开头和带有 protocol 的 URL
16
- url: string,
17
- {
18
- throwOnError = true,
19
- returnRaw = false,
20
- // 根据 URL 的规范,protocol 以 : 结尾
21
- allowProtocols = ['https:', 'http:'],
22
- // host 中可能会携带端口号,需要使用 hostname 来获取干净的域名
23
- allowDomains = undefined,
24
- }: GetSafeUrlOptions = {}
25
- ) {
26
- if (allowDomains === undefined) {
27
- // eslint-disable-next-line no-param-reassign
28
- allowDomains = window.blocklet?.domainAliases || [];
29
- (allowDomains as unknown as Array<String>).push(window.location.href);
30
- }
31
- try {
32
- let base;
33
- if (url.startsWith('/')) {
34
- base = window.location.origin;
35
- } else if (url.startsWith('./')) {
36
- base = window.location.href;
37
- }
38
-
39
- const urlInstance = new URL(url, base);
40
- const allowHostName = allowDomains
41
- ? (allowDomains as Array<string>).map((host) => {
42
- try {
43
- return new URL(host).hostname;
44
- } catch {
45
- // HACK: 如果传入的 allowDomains 不包含协议,则尝试为它添加协议头
46
- return new URL(`https://${host}`).hostname;
47
- }
48
- })
49
- : (allowDomains as unknown as null);
50
-
51
- if (allowProtocols !== null && !allowProtocols.includes(urlInstance.protocol)) {
52
- console.error(`Invalid protocol: ${urlInstance.protocol}`);
53
- if (throwOnError) throw new CustomError(`Invalid protocol: ${urlInstance.protocol}`);
54
- return null;
55
- }
56
- if (allowHostName !== null && !allowHostName.includes(urlInstance.hostname)) {
57
- console.error(`Invalid host: ${urlInstance.hostname}`);
58
- if (throwOnError) throw new CustomError(`Invalid host: ${urlInstance.hostname}`);
59
- return null;
60
- }
61
-
62
- return returnRaw ? url : urlInstance.href;
63
- } catch (error) {
64
- if (error instanceof CustomError) {
65
- if (throwOnError) throw error;
66
- return null;
67
- }
68
- console.error(`Failed to convert url: ${url}`);
69
- if (throwOnError) throw new Error(`Failed to convert url: ${url}`);
70
- return null;
71
- }
72
- }
package/src/Util/style.ts DELETED
@@ -1,17 +0,0 @@
1
- /* eslint-disable import/prefer-default-export */
2
- import type { SxProps } from '@mui/material';
3
-
4
- export const mergeSx = (...sxList: Array<SxProps | undefined | null>) => {
5
- const mergedSx = sxList.reduce((acc, sx) => {
6
- if (!sx) {
7
- return acc;
8
- }
9
-
10
- if (Array.isArray(sx)) {
11
- return acc.concat(sx);
12
- }
13
-
14
- return acc.concat([sx]);
15
- }, [] as SxProps[]);
16
- return mergedSx as SxProps;
17
- };
@@ -1,35 +0,0 @@
1
- /* eslint-disable import/prefer-default-export */
2
- export const providerName = 'wallet_url';
3
-
4
- /**
5
- * 获取 web wallet url, 常用于为 did connect 组件传递 webWalletUrl 参数,
6
- * 更明确的说, 这里获取的应该是 **default web wallet url**,
7
- * 如果用户使用自定义的 web wallet url, 不应该使用该方法, 应该显式的将自定义的 web wallet url 传递给 did connect 组件
8
- * (参考: https://github.com/blocklet/ocap-playground/issues/98)
9
- *
10
- * 获取优先级:
11
- * - localStorage 使用 provider 注册
12
- * - window.env.webWalletUrl
13
- * - window.blocklet.webWalletUrl
14
- * - production web wallet url
15
- */
16
- export const getWebWalletUrl = () => {
17
- return (
18
- window.localStorage.getItem(providerName) ||
19
- window.env?.webWalletUrl ||
20
- window.blocklet?.webWalletUrl ||
21
- 'https://web.abtwallet.io/'
22
- );
23
- };
24
-
25
- // 检查 wallet url protocol 和当前页面地址的 protocol 是否一致
26
- export const checkSameProtocol = (webWalletUrl: string) => {
27
- const { protocol } = window.location;
28
- let walletProtocol = '';
29
- try {
30
- walletProtocol = new URL(webWalletUrl).protocol;
31
- } catch (error) {
32
- walletProtocol = '';
33
- }
34
- return protocol === walletProtocol;
35
- };
@@ -1,83 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { Box, TextField } from '@mui/material';
3
- import type { SxProps } from '@mui/material';
4
- import trim from 'lodash/trim';
5
- import noop from 'lodash/noop';
6
- import { mergeSx } from '../Util/style';
7
-
8
- export const VERIFY_CODE_LENGTH = 6;
9
-
10
- export default function VerificationCode({
11
- length = VERIFY_CODE_LENGTH,
12
- code,
13
- onChange = noop,
14
- onComplete = noop,
15
- sx = {},
16
- }: {
17
- length?: number;
18
- code: string;
19
- onChange?: (_code: string) => void;
20
- onComplete?: (_code: string) => void;
21
- sx?: SxProps;
22
- }) {
23
- useEffect(() => {
24
- if (code.length === length) {
25
- onComplete?.(code);
26
- }
27
- // eslint-disable-next-line react-hooks/exhaustive-deps
28
- }, [code, length]);
29
- return (
30
- <Box
31
- sx={mergeSx(
32
- {
33
- width: '100%',
34
- maxWidth: 360,
35
- display: 'flex',
36
- justifyContent: 'space-between',
37
- gap: 1.5,
38
- },
39
- sx
40
- )}>
41
- {[...Array(length)].map((_, index) => (
42
- <TextField
43
- id={`code-input-${index}`}
44
- // eslint-disable-next-line react/no-array-index-key
45
- key={`code-input-${index}`}
46
- value={trim(code[index]) || ''}
47
- type="number"
48
- onChange={(e) => {
49
- const newCode = code.split('');
50
- newCode[index] = e.target.value;
51
- onChange?.(newCode.join(''));
52
- if (e.target.value && index < 5) {
53
- document.getElementById(`code-input-${index + 1}`)?.focus();
54
- }
55
- }}
56
- onKeyDown={(e) => {
57
- if (e.key === 'Backspace' && !trim(code[index]) && index > 0) {
58
- document.getElementById(`code-input-${index - 1}`)?.focus();
59
- }
60
- }}
61
- required
62
- autoComplete="off"
63
- slotProps={{
64
- htmlInput: {
65
- maxLength: 1,
66
- sx: {
67
- textAlign: 'center',
68
- fontSize: '1.5rem',
69
- '&::-webkit-inner-spin-button, &::-webkit-outer-spin-button': {
70
- WebkitAppearance: 'none',
71
- margin: 0,
72
- },
73
- },
74
- autoComplete: 'off',
75
- pattern: '[0-9]',
76
- inputMode: 'numeric',
77
- },
78
- }}
79
- />
80
- ))}
81
- </Box>
82
- );
83
- }
@@ -1,6 +0,0 @@
1
- export { default as Youtube } from './demo/youtube';
2
- export { default as Tentent } from './demo/tentent';
3
-
4
- export default {
5
- title: 'Data Display/Video',
6
- };
@@ -1,70 +0,0 @@
1
- import { useState } from 'react';
2
- import Player from 'react-player';
3
- import { CircularProgress } from '@mui/material';
4
- import isUndefined from 'lodash/isUndefined';
5
-
6
- import { mergeProps } from '../Util';
7
- import { styled } from '../Theme';
8
-
9
- export interface VideoProps {
10
- url: string;
11
- width?: string | number;
12
- height?: string | number;
13
- style?: React.CSSProperties;
14
- }
15
-
16
- export default function Video(rawProps: VideoProps) {
17
- const props = Object.assign({}, rawProps);
18
- // eslint-disable-next-line react/prop-types
19
- if (isUndefined(props.width)) {
20
- props.width = 640;
21
- }
22
- // eslint-disable-next-line react/prop-types
23
- if (isUndefined(props.height)) {
24
- props.height = 400;
25
- }
26
- // eslint-disable-next-line react/prop-types
27
- if (isUndefined(props.style)) {
28
- props.style = {};
29
- }
30
- const newProps = mergeProps(props, Video, ['style']);
31
- const { url, width, height, style } = newProps;
32
- const [loaded, setLoaded] = useState(false);
33
-
34
- const styles = Object.assign({ border: 'none' }, style, {
35
- width,
36
- height,
37
- visibility: loaded ? 'visible' : 'hidden',
38
- });
39
-
40
- if (url.indexOf('v.qq.com') > 0) {
41
- return (
42
- <Placeholder style={{ width, height }}>
43
- <iframe title={url} style={styles} src={url} onLoad={() => setLoaded(true)} allowFullScreen />
44
- {!loaded && <CircularProgress className="loading-indicator" color="primary" />}
45
- </Placeholder>
46
- );
47
- }
48
-
49
- return (
50
- <Placeholder style={{ width, height }}>
51
- <Player style={styles} {...newProps} onReady={() => setLoaded(true)} />
52
- {!loaded && <CircularProgress className="loading-indicator" color="primary" />}
53
- </Placeholder>
54
- );
55
- }
56
-
57
- const Placeholder = styled('div')`
58
- background-color: #222222;
59
- display: flex;
60
- justify-content: center;
61
- align-items: center;
62
- position: relative;
63
-
64
- .loading-indicator {
65
- position: absolute;
66
- top: 45%;
67
- left: 47%;
68
- z-index: 2;
69
- }
70
- `;
@@ -1,8 +0,0 @@
1
- export { default as DifferentSizes } from './demo/action-different-sizes';
2
- export { default as DifferentAction } from './demo/action-different-action';
3
- export { default as TextLayout } from './demo/action-text-layout';
4
- export { default as CustomizeStyle } from './demo/action-customize-style';
5
-
6
- export default {
7
- title: 'ArcBlock/Wallet/Action',
8
- };
@@ -1,118 +0,0 @@
1
- import { Typography } from '@mui/material';
2
- import isUndefined from 'lodash/isUndefined';
3
-
4
- import logo from './images/abtwallet.png';
5
- import { mergeProps } from '../Util';
6
- import colors from '../Colors';
7
- import Button from '../Button';
8
- import { styled } from '../Theme';
9
-
10
- export interface WalletActionProps {
11
- action?: string;
12
- size?: 'xlarge' | 'large' | 'medium' | 'small';
13
- textLayout?: 'vertical' | 'horizontal';
14
- style?: React.CSSProperties;
15
- }
16
-
17
- export default function WalletAction(rawProps: WalletActionProps) {
18
- const props = Object.assign({}, rawProps);
19
- // eslint-disable-next-line react/prop-types
20
- if (isUndefined(props.action)) {
21
- props.action = 'Login';
22
- }
23
- // eslint-disable-next-line react/prop-types
24
- if (isUndefined(props.textLayout)) {
25
- props.textLayout = 'vertical';
26
- }
27
- // eslint-disable-next-line react/prop-types
28
- if (isUndefined(props.size)) {
29
- props.size = 'medium';
30
- }
31
- // eslint-disable-next-line react/prop-types
32
- if (isUndefined(props.style)) {
33
- props.style = {};
34
- }
35
- const newProps = mergeProps(props, WalletAction, ['style']);
36
- const { action, size, textLayout, style = {}, ...rest } = newProps;
37
- const styles = Object.assign({}, style, { border: 'none', padding: 0 });
38
-
39
- return (
40
- <Button style={styles} {...rest} variant="outlined">
41
- <Content size={size} color={styles.color}>
42
- <img src={logo} className="wallet-action__logo" alt="DID Wallet" />
43
- {textLayout === 'vertical' && (
44
- <Typography className="wallet-action__text" component="div">
45
- <span className="wallet-action__action">{action} with</span>
46
- <span className="wallet-action__title">DID Wallet</span>
47
- </Typography>
48
- )}
49
- {textLayout === 'horizontal' && (
50
- <span className="wallet-action__title" style={{ padding: 8 }}>
51
- {action} with DID Wallet
52
- </span>
53
- )}
54
- </Content>
55
- </Button>
56
- );
57
- }
58
-
59
- const sizes = {
60
- logo: {
61
- small: 32,
62
- medium: 44,
63
- large: 56,
64
- xlarge: 88,
65
- },
66
- font: {
67
- small: 9,
68
- medium: 11,
69
- large: 13,
70
- xlarge: 18,
71
- },
72
- };
73
-
74
- type ContentProps = {
75
- size: NonNullable<WalletActionProps['size']>;
76
- color: string;
77
- };
78
-
79
- const Content = styled('div')<ContentProps>`
80
- display: flex;
81
- justify-content: center;
82
- align-items: center;
83
-
84
- &:hover {
85
- opacity: 0.9;
86
- }
87
-
88
- .wallet-action__logo {
89
- width: auto;
90
- height: auto;
91
- max-width: ${(props) => sizes.logo[props.size]}px;
92
- margin-left: 5px;
93
- }
94
-
95
- .wallet-action__text {
96
- padding: 8px;
97
- display: flex;
98
- height: 100%;
99
- flex-direction: column;
100
- justify-content: space-between;
101
- align-items: flex-start;
102
- }
103
-
104
- .wallet-action__action {
105
- font-size: ${(props) => sizes.font[props.size]}px;
106
- text-transform: capitalize;
107
- margin-bottom: 1px;
108
- color: ${(props) => props.color || colors.primary.main};
109
- letter-spacing: 1px;
110
- }
111
-
112
- .wallet-action__title {
113
- font-size: ${(props) => sizes.font[props.size] * 1.5}px;
114
- text-transform: capitalize;
115
- color: ${(props) => props.color || colors.primary.main};
116
- letter-spacing: 1px;
117
- }
118
- `;
@@ -1,9 +0,0 @@
1
- export { default as VerticalLayout } from './demo/download-vertical-layout';
2
- export { default as CustomTitle } from './demo/download-custom-title';
3
- export { default as HorizontalLayout1 } from './demo/download-horizontal-layout1';
4
- export { default as HorizontalLayout2 } from './demo/download-horizontal-layout2';
5
- export { default as HorizontalLayout3 } from './demo/download-horizontal-layout3';
6
-
7
- export default {
8
- title: 'ArcBlock/Wallet/Download',
9
- };