@arcblock/ux 3.4.15 → 3.5.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 (333) hide show
  1. package/lib/package.json.js +1 -1
  2. package/package.json +10 -7
  3. package/src/ActionButton/ActionButton.stories.jsx +0 -61
  4. package/src/ActionButton/index.jsx +0 -106
  5. package/src/ActivityIndicator/ActivityIndicator.stories.jsx +0 -9
  6. package/src/ActivityIndicator/index.jsx +0 -140
  7. package/src/Address/Address.stories.jsx +0 -38
  8. package/src/Address/compact-text.jsx +0 -76
  9. package/src/Address/did-address.tsx +0 -223
  10. package/src/Address/index.tsx +0 -21
  11. package/src/Address/responsive-did-address.tsx +0 -154
  12. package/src/Alert/Alert.stories.jsx +0 -100
  13. package/src/Alert/index.jsx +0 -130
  14. package/src/AnimationWaiter/AnimationWaiter.stories.jsx +0 -35
  15. package/src/AnimationWaiter/dark-animation.json +0 -1
  16. package/src/AnimationWaiter/default-animation.json +0 -1
  17. package/src/AnimationWaiter/index.jsx +0 -296
  18. package/src/Async/index.tsx +0 -44
  19. package/src/Avatar/Avatar.stories.jsx +0 -11
  20. package/src/Avatar/did-motif.jsx +0 -38
  21. package/src/Avatar/etherscan-blockies.js +0 -81
  22. package/src/Avatar/index.jsx +0 -195
  23. package/src/Badge/Badge.stories.jsx +0 -41
  24. package/src/Badge/index.jsx +0 -101
  25. package/src/Blocklet/Blocklet.stories.jsx +0 -21
  26. package/src/Blocklet/blocklet.jsx +0 -276
  27. package/src/Blocklet/index.js +0 -5
  28. package/src/Blocklet/utils.jsx +0 -58
  29. package/src/BlockletContext/index.tsx +0 -72
  30. package/src/BlockletNFT/BlockletNFT.stories.jsx +0 -21
  31. package/src/BlockletNFT/index.jsx +0 -378
  32. package/src/BlockletV2/Blocklet.stories.jsx +0 -34
  33. package/src/BlockletV2/blocklet.tsx +0 -247
  34. package/src/BlockletV2/components/icon-text.tsx +0 -47
  35. package/src/BlockletV2/components/tooltip-icon.tsx +0 -52
  36. package/src/BlockletV2/index.ts +0 -6
  37. package/src/BlockletV2/utils.js +0 -75
  38. package/src/Button/Button.stories.jsx +0 -24
  39. package/src/Button/index.js +0 -9
  40. package/src/Button/wrap.jsx +0 -126
  41. package/src/ButtonGroup/index.js +0 -16
  42. package/src/CardSelector/index.tsx +0 -136
  43. package/src/Center/Center.stories.jsx +0 -20
  44. package/src/Center/index.tsx +0 -33
  45. package/src/ClickToCopy/ClickToCopy.stories.jsx +0 -24
  46. package/src/ClickToCopy/copy-button.tsx +0 -43
  47. package/src/ClickToCopy/hook.ts +0 -42
  48. package/src/ClickToCopy/index.tsx +0 -96
  49. package/src/CloseButton/index.tsx +0 -37
  50. package/src/CodeBlock/CodeBlock.stories.jsx +0 -22
  51. package/src/CodeBlock/LightBox.tsx +0 -87
  52. package/src/CodeBlock/index.tsx +0 -217
  53. package/src/Colors/Colors.stories.jsx +0 -211
  54. package/src/Colors/index.ts +0 -4
  55. package/src/Colors/themes/default.ts +0 -8
  56. package/src/Colors/themes/did-connect.ts +0 -64
  57. package/src/Colors/themes/temp.ts +0 -52
  58. package/src/Config/Config.stories.jsx +0 -16
  59. package/src/Config/config-provider.tsx +0 -62
  60. package/src/Config/index.ts +0 -2
  61. package/src/Config/theme-mode-toggle.tsx +0 -38
  62. package/src/ContactForm/ContactForm.stories.jsx +0 -32
  63. package/src/ContactForm/index.tsx +0 -264
  64. package/src/CookieConsent/CookieConsent.stories.jsx +0 -33
  65. package/src/CookieConsent/index.tsx +0 -104
  66. package/src/CountDown/CountDown.stories.jsx +0 -15
  67. package/src/CountDown/index.tsx +0 -170
  68. package/src/DID/DID.stories.jsx +0 -37
  69. package/src/DID/index.tsx +0 -393
  70. package/src/DIDConnect/app-icon.tsx +0 -37
  71. package/src/DIDConnect/app-info-item.tsx +0 -93
  72. package/src/DIDConnect/auth-apps/auth-apps-info.tsx +0 -77
  73. package/src/DIDConnect/auth-apps/index.tsx +0 -278
  74. package/src/DIDConnect/auth-apps/switch-role.tsx +0 -47
  75. package/src/DIDConnect/did-connect-container.tsx +0 -326
  76. package/src/DIDConnect/did-connect-footer.tsx +0 -76
  77. package/src/DIDConnect/did-connect-logo.tsx +0 -8
  78. package/src/DIDConnect/icons/did-wallet-logo.tsx +0 -18
  79. package/src/DIDConnect/icons/github-logo.tsx +0 -17
  80. package/src/DIDConnect/index.ts +0 -11
  81. package/src/DIDConnect/landing-page.tsx +0 -218
  82. package/src/DIDConnect/powered-by.tsx +0 -48
  83. package/src/DIDConnect/provider-icon.tsx +0 -62
  84. package/src/DIDConnect/request-storage-access-api-dialog.tsx +0 -304
  85. package/src/DIDConnect/with-container.tsx +0 -323
  86. package/src/DIDConnect/with-ux-theme.tsx +0 -22
  87. package/src/DIDLogo/Logo.stories.jsx +0 -11
  88. package/src/DIDLogo/index.tsx +0 -168
  89. package/src/Datatable/CustomToolbar.jsx +0 -415
  90. package/src/Datatable/Datatable.stories.jsx +0 -92
  91. package/src/Datatable/DatatableContext.jsx +0 -35
  92. package/src/Datatable/TableSearch.jsx +0 -166
  93. package/src/Datatable/index.jsx +0 -652
  94. package/src/Datatable/utils.js +0 -161
  95. package/src/Dialog/Dialog.stories.jsx +0 -21
  96. package/src/Dialog/confirm.jsx +0 -143
  97. package/src/Dialog/dialog.jsx +0 -199
  98. package/src/Dialog/index.js +0 -4
  99. package/src/Dialog/types.d.ts +0 -20
  100. package/src/Dialog/use-confirm.jsx +0 -188
  101. package/src/DriftBot/index.tsx +0 -81
  102. package/src/Earth/Earth.stories.jsx +0 -39
  103. package/src/Earth/countries.json +0 -8057
  104. package/src/Earth/index.tsx +0 -515
  105. package/src/Earth/util.ts +0 -72
  106. package/src/Empty/Empty.stories.jsx +0 -23
  107. package/src/Empty/index.jsx +0 -48
  108. package/src/ErrorBoundary/ErrorBoundary.stories.jsx +0 -13
  109. package/src/ErrorBoundary/fallback.tsx +0 -85
  110. package/src/ErrorBoundary/index.ts +0 -1
  111. package/src/Footer/Footer.stories.jsx +0 -13
  112. package/src/Footer/index.tsx +0 -130
  113. package/src/Header/Header.stories.jsx +0 -30
  114. package/src/Header/addon-button.tsx +0 -41
  115. package/src/Header/auto-hidden.tsx +0 -31
  116. package/src/Header/header-addons.tsx +0 -37
  117. package/src/Header/header.tsx +0 -214
  118. package/src/Header/index.ts +0 -3
  119. package/src/Header/responsive-header.tsx +0 -145
  120. package/src/Icon/Icon.stories.jsx +0 -45
  121. package/src/Icon/image.tsx +0 -53
  122. package/src/Icon/index.tsx +0 -63
  123. package/src/Img/Img.stories.jsx +0 -17
  124. package/src/Img/index.jsx +0 -258
  125. package/src/InfoRow/InfoRow.stories.jsx +0 -14
  126. package/src/InfoRow/index.tsx +0 -91
  127. package/src/Layout/Layout.stories.jsx +0 -24
  128. package/src/Layout/dashboard/external-link.tsx +0 -59
  129. package/src/Layout/dashboard/full-page.tsx +0 -58
  130. package/src/Layout/dashboard/index.tsx +0 -260
  131. package/src/Layout/dashboard/sidebar.tsx +0 -198
  132. package/src/Layout/dashboard-legacy/header.tsx +0 -156
  133. package/src/Layout/dashboard-legacy/index.tsx +0 -127
  134. package/src/Layout/dashboard-legacy/sidebar.tsx +0 -129
  135. package/src/Layout/index.tsx +0 -310
  136. package/src/LoadingMask/index.tsx +0 -108
  137. package/src/Locale/LocaleSelector.stories.jsx +0 -44
  138. package/src/Locale/browser-lang.ts +0 -65
  139. package/src/Locale/context.tsx +0 -162
  140. package/src/Locale/languages.ts +0 -58
  141. package/src/Locale/selector.tsx +0 -174
  142. package/src/Locale/util.ts +0 -38
  143. package/src/Logo/Logo.stories.jsx +0 -23
  144. package/src/Logo/images/logo-dark-text.svg +0 -3
  145. package/src/Logo/images/logo-dark-top.svg +0 -6
  146. package/src/Logo/images/logo-light-text.svg +0 -3
  147. package/src/Logo/images/logo-light-top.svg +0 -6
  148. package/src/Logo/index.tsx +0 -58
  149. package/src/Metric/Metric.stories.jsx +0 -29
  150. package/src/Metric/index.tsx +0 -130
  151. package/src/MuiWrap/index.tsx +0 -10
  152. package/src/NFTDisplay/NFTBroken.svg +0 -34
  153. package/src/NFTDisplay/NFTDisplay.stories.jsx +0 -30
  154. package/src/NFTDisplay/README.md +0 -59
  155. package/src/NFTDisplay/aspect-ratio-container.tsx +0 -36
  156. package/src/NFTDisplay/broken.tsx +0 -51
  157. package/src/NFTDisplay/displayApi.ts +0 -43
  158. package/src/NFTDisplay/index.tsx +0 -393
  159. package/src/NFTDisplay/loading.tsx +0 -16
  160. package/src/NFTDisplay/preview.tsx +0 -84
  161. package/src/NFTDisplay/render-svg.tsx +0 -21
  162. package/src/NFTDisplay/svg-embedder/img.tsx +0 -27
  163. package/src/NFTDisplay/svg-embedder/inline-svg.tsx +0 -36
  164. package/src/NavMenu/NavMenu.stories.jsx +0 -17
  165. package/src/NavMenu/images/OCAP.svg +0 -1
  166. package/src/NavMenu/images/abt-network.svg +0 -1
  167. package/src/NavMenu/images/ai-kit.svg +0 -1
  168. package/src/NavMenu/images/aigne-image-smith.svg +0 -1
  169. package/src/NavMenu/images/aigne.svg +0 -1
  170. package/src/NavMenu/images/aistro.png +0 -0
  171. package/src/NavMenu/images/arcsphere.svg +0 -1
  172. package/src/NavMenu/images/blocklet-framework.svg +0 -1
  173. package/src/NavMenu/images/blocklet-launcher.svg +0 -1
  174. package/src/NavMenu/images/blocklet-server.svg +0 -1
  175. package/src/NavMenu/images/blocklet-store.svg +0 -1
  176. package/src/NavMenu/images/creator-studio.svg +0 -1
  177. package/src/NavMenu/images/did-wallet.svg +0 -1
  178. package/src/NavMenu/images/did.svg +0 -1
  179. package/src/NavMenu/images/nft-studio.svg +0 -1
  180. package/src/NavMenu/images/payment-kit.png +0 -0
  181. package/src/NavMenu/images/vc.svg +0 -1
  182. package/src/NavMenu/images/web3-kit.svg +0 -1
  183. package/src/NavMenu/index.ts +0 -3
  184. package/src/NavMenu/nav-menu-context.tsx +0 -30
  185. package/src/NavMenu/nav-menu.tsx +0 -441
  186. package/src/NavMenu/products.tsx +0 -830
  187. package/src/NavMenu/style.ts +0 -258
  188. package/src/NavMenu/sub-container.tsx +0 -125
  189. package/src/NavMenu/sub-item-group.tsx +0 -42
  190. package/src/OrgTransfer/index.tsx +0 -53
  191. package/src/OrgTransfer/locales.ts +0 -25
  192. package/src/OrgTransfer/selector.tsx +0 -252
  193. package/src/OrgTransfer/type.ts +0 -31
  194. package/src/PageScroller/index.tsx +0 -316
  195. package/src/PageScroller/story/FifthComponent.jsx +0 -7
  196. package/src/PageScroller/story/FirstComponent.jsx +0 -7
  197. package/src/PageScroller/story/FourthComponent.jsx +0 -7
  198. package/src/PageScroller/story/FullPage.jsx +0 -55
  199. package/src/PageScroller/story/PageContain.jsx +0 -59
  200. package/src/PageScroller/story/PageScroller.stories.jsx +0 -18
  201. package/src/PageScroller/story/SecondComponent.jsx +0 -7
  202. package/src/PageScroller/story/ThirdComponent.jsx +0 -7
  203. package/src/PageScroller/story/index.css +0 -115
  204. package/src/PageScroller/usePrevValue.ts +0 -11
  205. package/src/Passport/index.ts +0 -3
  206. package/src/Passport/passport.tsx +0 -118
  207. package/src/PhoneInput/PhoneInput.stories.jsx +0 -12
  208. package/src/PhoneInput/country-select.tsx +0 -148
  209. package/src/PhoneInput/index.tsx +0 -269
  210. package/src/PoweredByArcBlock/index.tsx +0 -27
  211. package/src/PricingTable/PricingPlan.tsx +0 -120
  212. package/src/PricingTable/PricingTable.stories.jsx +0 -38
  213. package/src/PricingTable/index.tsx +0 -59
  214. package/src/QRCode/QRCode.stories.jsx +0 -13
  215. package/src/QRCode/index.tsx +0 -66
  216. package/src/RelativeTime/RelativeTime.stories.jsx +0 -20
  217. package/src/RelativeTime/index.tsx +0 -334
  218. package/src/Result/Result.stories.jsx +0 -61
  219. package/src/Result/common.tsx +0 -119
  220. package/src/Result/index.tsx +0 -30
  221. package/src/Result/result.tsx +0 -65
  222. package/src/Result/translations.ts +0 -57
  223. package/src/Screenshot/BaseScreenshot/index.tsx +0 -73
  224. package/src/Screenshot/BaseScreenshot/shells/Macbook.tsx +0 -38
  225. package/src/Screenshot/BaseScreenshot/shells/Phone.tsx +0 -35
  226. package/src/Screenshot/Screenshot.stories.jsx +0 -44
  227. package/src/Screenshot/devices.css +0 -1366
  228. package/src/Screenshot/index.tsx +0 -300
  229. package/src/SessionBlocklet/index.tsx +0 -178
  230. package/src/SessionManager/SessionManager.stories.jsx +0 -9
  231. package/src/SessionManager/index.tsx +0 -3
  232. package/src/SessionPermission/index.tsx +0 -26
  233. package/src/SessionUser/components/did-space.tsx +0 -68
  234. package/src/SessionUser/components/logged-in.tsx +0 -338
  235. package/src/SessionUser/components/quick-login-item.tsx +0 -132
  236. package/src/SessionUser/components/session-user-item.tsx +0 -93
  237. package/src/SessionUser/components/session-user-switch.tsx +0 -240
  238. package/src/SessionUser/components/un-login.tsx +0 -257
  239. package/src/SessionUser/components/user-info.tsx +0 -201
  240. package/src/SessionUser/index.tsx +0 -68
  241. package/src/SessionUser/libs/translation.ts +0 -30
  242. package/src/SessionUser/libs/utils.ts +0 -39
  243. package/src/SharedBridge/index.tsx +0 -126
  244. package/src/SocialShare/index.tsx +0 -194
  245. package/src/Sparkline/Sparkline.stories.jsx +0 -13
  246. package/src/Sparkline/index.tsx +0 -231
  247. package/src/Spinner/Spinner.stories.jsx +0 -98
  248. package/src/Spinner/index.tsx +0 -20
  249. package/src/SplitButton/SplitButton.stories.jsx +0 -32
  250. package/src/SplitButton/index.tsx +0 -116
  251. package/src/SplitButton/useClickAway.tsx +0 -24
  252. package/src/Success/index.tsx +0 -175
  253. package/src/Switch/Switch.stories.jsx +0 -16
  254. package/src/Switch/index.jsx +0 -79
  255. package/src/Tabs/Tabs.stories.jsx +0 -18
  256. package/src/Tabs/index.tsx +0 -255
  257. package/src/Tag/Tag.stories.jsx +0 -15
  258. package/src/Tag/index.jsx +0 -106
  259. package/src/TextCollapse/TextCollapse.stories.jsx +0 -73
  260. package/src/TextCollapse/index.tsx +0 -85
  261. package/src/Theme/Theme.stories.jsx +0 -11
  262. package/src/Theme/index.ts +0 -21
  263. package/src/Theme/theme-provider.tsx +0 -374
  264. package/src/Theme/theme.ts +0 -229
  265. package/src/Toast/Toast.stories.jsx +0 -28
  266. package/src/Toast/index.tsx +0 -80
  267. package/src/Typography/index.tsx +0 -124
  268. package/src/UserCard/Cards/avatar-only.tsx +0 -27
  269. package/src/UserCard/Cards/basic-info.tsx +0 -43
  270. package/src/UserCard/Cards/index.tsx +0 -16
  271. package/src/UserCard/Cards/social-actions.tsx +0 -196
  272. package/src/UserCard/Container/card.tsx +0 -63
  273. package/src/UserCard/Container/dialog.tsx +0 -37
  274. package/src/UserCard/Content/basic.tsx +0 -330
  275. package/src/UserCard/Content/clock.tsx +0 -82
  276. package/src/UserCard/Content/minimal.tsx +0 -113
  277. package/src/UserCard/Content/shorten-label.tsx +0 -32
  278. package/src/UserCard/Content/tooltip-avatar.tsx +0 -80
  279. package/src/UserCard/UserCard.stories.jsx +0 -19
  280. package/src/UserCard/components.tsx +0 -81
  281. package/src/UserCard/index.tsx +0 -132
  282. package/src/UserCard/types.ts +0 -165
  283. package/src/UserCard/use-follow.tsx +0 -111
  284. package/src/UserCard/utils.ts +0 -155
  285. package/src/Util/WebWalletOpener.stories.jsx +0 -5
  286. package/src/Util/client.ts +0 -4
  287. package/src/Util/constant.ts +0 -70
  288. package/src/Util/deprecate.tsx +0 -29
  289. package/src/Util/federated.ts +0 -125
  290. package/src/Util/iframe.ts +0 -19
  291. package/src/Util/index.ts +0 -760
  292. package/src/Util/logger.ts +0 -44
  293. package/src/Util/passport.ts +0 -127
  294. package/src/Util/security.ts +0 -72
  295. package/src/Util/style.ts +0 -17
  296. package/src/Util/wallet.ts +0 -35
  297. package/src/VerificationCode/index.tsx +0 -83
  298. package/src/Video/Video.stories.jsx +0 -6
  299. package/src/Video/index.tsx +0 -70
  300. package/src/Wallet/Action.stories.jsx +0 -8
  301. package/src/Wallet/Action.tsx +0 -118
  302. package/src/Wallet/Download.stories.jsx +0 -9
  303. package/src/Wallet/Download.tsx +0 -157
  304. package/src/Wallet/Open.tsx +0 -47
  305. package/src/Wallet/OpenInWallet.stories.jsx +0 -5
  306. package/src/Wallet/images/abtwallet.png +0 -0
  307. package/src/Wallet/images/android_download.svg +0 -22
  308. package/src/Wallet/images/app-store.svg +0 -30
  309. package/src/Wallet/images/google-play.svg +0 -69
  310. package/src/WalletOSIcon/index.tsx +0 -47
  311. package/src/WebWalletSWKeeper/index.tsx +0 -117
  312. package/src/WechatPrompt/images/android.png +0 -0
  313. package/src/WechatPrompt/images/ios.png +0 -0
  314. package/src/WechatPrompt/index.tsx +0 -75
  315. package/src/global.d.ts +0 -28
  316. package/src/hooks/use-blocklet-logo.tsx +0 -32
  317. package/src/hooks/use-clock.tsx +0 -62
  318. package/src/hooks/use-location-state.tsx +0 -117
  319. package/src/hooks/use-mobile.tsx +0 -6
  320. package/src/index.ts +0 -79
  321. package/src/type.d.ts +0 -44
  322. package/src/withTheme/index.tsx +0 -72
  323. package/src/withTracker/README.md +0 -37
  324. package/src/withTracker/action/bind-wallet.tsx +0 -17
  325. package/src/withTracker/action/login.tsx +0 -18
  326. package/src/withTracker/action/pay.tsx +0 -14
  327. package/src/withTracker/action/switch-passport.tsx +0 -20
  328. package/src/withTracker/constant/index.tsx +0 -3
  329. package/src/withTracker/env.tsx +0 -1
  330. package/src/withTracker/error_boundary.jsx +0 -34
  331. package/src/withTracker/index.tsx +0 -50
  332. package/src/withTracker/libs/utm.ts +0 -46
  333. package/vite.config.mjs +0 -37
@@ -1,269 +0,0 @@
1
- import { useCallback, useMemo, useState } from 'react';
2
- import { Box, TextField, TextFieldProps, Typography } from '@mui/material';
3
- import { parsePhoneNumber } from 'awesome-phonenumber';
4
- import { defaultCountries, CountryIso2, usePhoneInput, parseCountry } from 'react-international-phone';
5
- import CountrySelect, { CountryDisplayOptions } from './country-select';
6
- import { mergeSx } from '../Util/style';
7
-
8
- export interface PhoneValue {
9
- country: CountryIso2;
10
- phone: string; // 带区号的完整电话号码,如 +86123456789
11
- }
12
-
13
- export interface PhoneInputProps extends Omit<TextFieldProps, 'value' | 'onChange'> {
14
- value?: PhoneValue;
15
- onChange?: (value: PhoneValue) => void;
16
- countryDisplayOptions?: CountryDisplayOptions;
17
- preview?: boolean;
18
- allowDial?: boolean; // 是否允许拨号, 只在 preview 为 true 时有效
19
- }
20
-
21
- export function validatePhoneNumber(phone: string, iso2: CountryIso2, dialCode: string = ''): boolean {
22
- // 如果没有输入电话号码,返回false
23
- if (!phone) return false;
24
-
25
- // 如果去除所有格式化字符后,只剩下区号,则认为只有区号
26
- const cleanedPhone = phone.replace(/[\s\-()]+/g, '');
27
-
28
- const phoneDialCode = dialCode || getDialCodeByCountry(iso2);
29
- // 这表示电话号码只有区号部分
30
- if (getDialCodeWithoutPlus(phoneDialCode) === getDialCodeWithoutPlus(cleanedPhone)) {
31
- return true; // 如果只有区号,则视为有效
32
- }
33
-
34
- // 否则使用validator进行完整校验
35
- const pn = parsePhoneNumber(phone, { regionCode: iso2 });
36
- const cleanedParsedPhone = pn.number?.input.replace(/[\s\-()]+/g, '');
37
- return (
38
- pn.valid && (pn.type === 'mobile' || pn.type === 'fixed-line-or-mobile') && cleanedParsedPhone === pn.number?.e164
39
- );
40
- }
41
-
42
- // 从带区号的电话号码中提取纯号码部分
43
- function extractPhoneWithoutCode(phone: string, dialCode: string): string {
44
- if (!phone) return '';
45
- // 先去除区号
46
- const phoneWithoutCode = phone.replace(new RegExp(`^\\+${dialCode}`), '');
47
- // 去除非数字字符,但保留括号
48
- return phoneWithoutCode;
49
- }
50
-
51
- // 添加区号到纯号码
52
- function addCountryCodeToPhone(phone: string, dialCode: string): string {
53
- if (!phone) return `+${dialCode}`;
54
- return phone.startsWith('+') ? phone : `+${dialCode}${phone}`;
55
- }
56
-
57
- // 获取不带+号的区号
58
- function getDialCodeWithoutPlus(dialCode: string): string {
59
- return dialCode.replace(/^\+/, '');
60
- }
61
-
62
- // 根据ISO2国家代码获取国家信息
63
- function getCountryInfoByIso2<T extends keyof ReturnType<typeof parseCountry>>(
64
- iso2: CountryIso2,
65
- property: T
66
- ): ReturnType<typeof parseCountry>[T] | undefined {
67
- // 查找对应的国家数据
68
- const countryItem = defaultCountries.find((country) => parseCountry(country).iso2 === iso2);
69
-
70
- if (!countryItem) {
71
- return undefined;
72
- }
73
-
74
- // 解析国家信息并返回请求的属性
75
- return parseCountry(countryItem)[property];
76
- }
77
-
78
- // 根据ISO2国家代码获取区号
79
- export function getDialCodeByCountry(iso2: CountryIso2): string {
80
- return getCountryInfoByIso2(iso2, 'dialCode') || '';
81
- }
82
-
83
- // 根据ISO2国家代码获取国家名称
84
- export function getCountryNameByCountry(iso2: CountryIso2): string {
85
- return getCountryInfoByIso2(iso2, 'name') || '';
86
- }
87
-
88
- // 根据手机号识别国家,返回国家的 iso2 码
89
- // 如果手机号带有区号,通过 parsePhoneNumber 识别
90
- // 如果手机号不带区号,通过碰撞识别
91
- export function detectCountryFromPhone(phoneNumber?: string): CountryIso2 | undefined {
92
- try {
93
- if (!phoneNumber) return undefined;
94
-
95
- // 如果已经带了+号,尝试从前缀匹配
96
- if (phoneNumber.startsWith('+')) {
97
- const parsedPhone = parsePhoneNumber(phoneNumber);
98
- if (parsedPhone.valid) {
99
- return parsedPhone.regionCode.toLowerCase() as CountryIso2;
100
- }
101
- for (const country of defaultCountries) {
102
- const parsed = parseCountry(country);
103
- if (phoneNumber.startsWith(`+${parsed.dialCode}`)) {
104
- const phoneWithCode = phoneNumber;
105
- // 验证该号码是否有效
106
- if (validatePhoneNumber(phoneWithCode, parsed.dialCode, parsed.iso2)) {
107
- return parsed.iso2;
108
- }
109
- }
110
- }
111
- } else {
112
- for (const country of defaultCountries) {
113
- const parsed = parseCountry(country);
114
- const phoneWithCode = `+${parsed.dialCode}${phoneNumber}`;
115
- if (validatePhoneNumber(phoneWithCode, parsed.dialCode, parsed.iso2)) {
116
- return parsed.iso2;
117
- }
118
- }
119
- }
120
- return undefined;
121
- } catch {
122
- return undefined;
123
- }
124
- }
125
-
126
- export default function PhoneInput({
127
- value = { country: 'us', phone: '' },
128
- onChange = undefined,
129
- placeholder = 'Enter phone number',
130
- countryDisplayOptions = {},
131
- preview = false,
132
- allowDial = true,
133
- ...props
134
- }: PhoneInputProps) {
135
- // 创建国家代码映射表,避免重复解析
136
- const countryMap = useMemo(() => {
137
- const map = new Map<CountryIso2, ReturnType<typeof parseCountry>>();
138
- defaultCountries.forEach((country) => {
139
- const parsed = parseCountry(country);
140
- map.set(parsed.iso2, parsed);
141
- });
142
- return map;
143
- }, []);
144
-
145
- const [previewValue, setPreviewValue] = useState(value);
146
-
147
- const handleValueChange = useCallback(
148
- (data: PhoneValue) => {
149
- if (!preview && onChange) {
150
- const newValue = {
151
- ...value,
152
- ...data,
153
- };
154
- const countryData = countryMap.get(newValue.country);
155
- if (countryData) {
156
- newValue.phone = addCountryCodeToPhone(newValue.phone, getDialCodeWithoutPlus(countryData.dialCode));
157
- }
158
- onChange(newValue);
159
- }
160
- },
161
- [onChange, preview, value, countryMap]
162
- );
163
-
164
- // 获取当前国家的区号(不带+号)
165
- const currentDialCode = useMemo(() => {
166
- const countryData = countryMap.get(value.country);
167
- return countryData ? getDialCodeWithoutPlus(countryData.dialCode) : '';
168
- }, [value.country, countryMap]);
169
-
170
- // 使用 react-international-phone 的 hook
171
- const { phone, country, handlePhoneValueChange, setCountry } = usePhoneInput({
172
- defaultCountry: value.country,
173
- value: extractPhoneWithoutCode(value.phone, currentDialCode),
174
- countries: defaultCountries,
175
- disableDialCodeAndPrefix: true,
176
- onChange: (data) => {
177
- const newData = {
178
- ...data,
179
- phone:
180
- previewValue.country !== data.country && !data.phone
181
- ? extractPhoneWithoutCode(value.phone, currentDialCode)
182
- : data.phone,
183
- };
184
- setPreviewValue(newData);
185
- handleValueChange(newData);
186
- },
187
- });
188
-
189
- // 从完整电话号码中提取不带区号的部分用于显示,并去除格式化字符
190
- const displayPhone = useMemo(
191
- () => phone || extractPhoneWithoutCode(value.phone, currentDialCode),
192
- [phone, value.phone, currentDialCode]
193
- );
194
-
195
- // 处理国家变更
196
- const onCountryChange = (newCountry: CountryIso2) => {
197
- if (preview) return;
198
- setCountry(newCountry);
199
- };
200
-
201
- // 预览模式
202
- if (preview) {
203
- const phoneWithCode = addCountryCodeToPhone(phone, getDialCodeByCountry(country));
204
- const isValid = phone && validatePhoneNumber(phoneWithCode, country);
205
- const canDial = allowDial && isValid;
206
-
207
- return (
208
- <Box
209
- component={canDial ? 'a' : 'div'}
210
- href={canDial ? `tel:${phone}` : undefined}
211
- {...(canDial
212
- ? {
213
- 'aria-label': `Call ${phone}`,
214
- title: `Call ${phone}`,
215
- rel: 'nofollow',
216
- itemProp: 'telephone',
217
- }
218
- : {})}
219
- sx={{
220
- display: 'flex',
221
- alignItems: 'center',
222
- textDecoration: 'none',
223
- color: 'inherit',
224
- cursor: canDial ? 'pointer' : 'default',
225
-
226
- '&:hover': {
227
- opacity: canDial ? 0.8 : 1,
228
- },
229
- }}>
230
- <CountrySelect value={country} preview={preview} />
231
- <Typography sx={{ ml: 0.5 }}>{displayPhone}</Typography>
232
- </Box>
233
- );
234
- }
235
- // 编辑模式
236
- return (
237
- <Box
238
- sx={{
239
- display: 'flex',
240
- alignItems: 'flex-start',
241
- gap: 0.5,
242
- }}>
243
- <CountrySelect
244
- value={country}
245
- onChange={onCountryChange}
246
- preview={false}
247
- selectCountryProps={countryDisplayOptions}
248
- />
249
- <TextField
250
- {...props}
251
- value={displayPhone}
252
- onChange={handlePhoneValueChange}
253
- placeholder={placeholder}
254
- className="phone-input"
255
- sx={mergeSx(
256
- {
257
- '& .MuiInputBase-input': {
258
- padding: 1,
259
- },
260
- },
261
- props.sx as any // 这里传入的可能是一个数组或一个对象
262
- )}
263
- slotProps={{
264
- input: props.InputProps ?? {},
265
- }}
266
- />
267
- </Box>
268
- );
269
- }
@@ -1,27 +0,0 @@
1
- import type { LinkProps, TypographyProps } from '@mui/material';
2
- import { Link, Typography } from '@mui/material';
3
-
4
- export interface PoweredByArcBlockProps extends TypographyProps {
5
- linkProps?: LinkProps;
6
- showExtra?: boolean;
7
- }
8
-
9
- export default function PoweredByArcBlock({
10
- linkProps = undefined,
11
- showExtra = false,
12
- ...props
13
- }: PoweredByArcBlockProps) {
14
- return (
15
- <Typography {...props}>
16
- Powered by{' '}
17
- <Link href="https://www.arcblock.io" target="_blank" {...linkProps}>
18
- ArcBlock
19
- </Link>
20
- 's{' '}
21
- <Link href="https://www.blocklet.io" target="_blank" {...linkProps}>
22
- Blocklet Technology
23
- </Link>
24
- {showExtra ? ', the decentralized web engine.' : null}
25
- </Typography>
26
- );
27
- }
@@ -1,120 +0,0 @@
1
- import { Card, Button, CardContent, Typography } from '@mui/material';
2
-
3
- import { styled } from '../Theme';
4
-
5
- export interface PricingPlanProps {
6
- plan: {
7
- name: string;
8
- price: string;
9
- featureList: string[];
10
- showButton: boolean;
11
- buttonLink: string;
12
- buttonText: string;
13
- };
14
- }
15
-
16
- function PricingPlan({ plan }: PricingPlanProps) {
17
- return (
18
- <PlanCard $shadow>
19
- <div className="card-header">
20
- <div className="title">{plan.name}</div>
21
- </div>
22
- <CardContent className="card-content">
23
- <div className="plan-content">
24
- <div className="plan-pricing">
25
- <Typography component="h2" variant="h5" className="price-number">
26
- {plan.price}
27
- </Typography>
28
- </div>
29
- <div className="plan-services">
30
- {plan.featureList.map((line) => (
31
- <Typography component="p" variant="body1" align="center" key={line}>
32
- {line}
33
- </Typography>
34
- ))}
35
- </div>
36
- </div>
37
- <div className="plan-actions">
38
- {plan.showButton && (
39
- <Button fullWidth variant="outlined" color="primary" component="a" href={plan.buttonLink}>
40
- {plan.buttonText}
41
- </Button>
42
- )}
43
- </div>
44
- </CardContent>
45
- </PlanCard>
46
- );
47
- }
48
-
49
- export default PricingPlan;
50
-
51
- type PlanCardProps = {
52
- $shadow?: boolean;
53
- };
54
-
55
- const PlanCard = styled(Card)<PlanCardProps>`
56
- height: 500px;
57
- display: flex;
58
- flex-direction: column;
59
- @media (max-width: 320px) {
60
- margin-top: 20px;
61
- }
62
-
63
- && {
64
- ${(props) => (props.$shadow ? '' : 'box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.1)')}
65
- }
66
-
67
- .card-header {
68
- height: 80px;
69
- background-color: #f1fbfb;
70
- display: flex;
71
- flex-flow: column;
72
- align-items: center;
73
- justify-content: center;
74
- .title {
75
- font-size: 18px;
76
- font-weight: 600;
77
- text-align: center;
78
- color: #404040;
79
- margin: 0;
80
- }
81
- }
82
-
83
- .card-content {
84
- display: flex;
85
- flex-direction: column;
86
- justify-content: space-between;
87
- align-items: center;
88
- flex-grow: 1;
89
- }
90
-
91
- .plan-content {
92
- display: flex;
93
- flex-direction: column;
94
- flex-grow: 1;
95
-
96
- .plan-pricing {
97
- display: flex;
98
- justify-content: center;
99
- align-items: baseline;
100
- margin-bottom: 12px;
101
- color: #4e6af6;
102
- text-align: center;
103
- }
104
-
105
- .price-number {
106
- font-size: 30px;
107
- font-weight: 600;
108
- color: #4e6af6;
109
- }
110
-
111
- .plan-services strong {
112
- color: #4e6af6;
113
- font-weight: 500;
114
- }
115
- }
116
-
117
- .plan-actions {
118
- width: 100%;
119
- }
120
- `;
@@ -1,38 +0,0 @@
1
- import PricingTable from '.';
2
-
3
- const plans = [
4
- {
5
- name: 'Developer',
6
- price: '0 ABT',
7
- featureList: ['1. 规则1111', '2. 规则22222', '3. 规则33333'],
8
- showButton: true,
9
- buttonText: 'Contact',
10
- buttonLink: 'https://www.arcblockio.cn/zh/',
11
- },
12
- {
13
- name: 'Free',
14
- price: '0 ABT',
15
- featureList: ['1. 规则1111', '2. 规则22222', '3. 规则33333'],
16
- showButton: true,
17
- buttonText: 'Contact',
18
- buttonLink: 'https://www.arcblockio.cn/zh/',
19
- },
20
- {
21
- name: 'Enterprise Plan',
22
- price: '2000 ABT',
23
- featureList: ['1. 规则1111', '2. 规则22222', '3. 规则33333'],
24
- showButton: true,
25
- buttonText: 'Contact',
26
- buttonLink: 'https://www.arcblockio.cn/zh/',
27
- },
28
- ];
29
-
30
- export default {
31
- title: 'Deprecated/PricingTable',
32
- };
33
-
34
- export function BasicUse() {
35
- return <PricingTable plans={plans} />;
36
- }
37
-
38
- BasicUse.storyName = 'basic use';
@@ -1,59 +0,0 @@
1
- import { Grid } from '@mui/material';
2
-
3
- import PricingPlan, { type PricingPlanProps } from './PricingPlan';
4
- import { styled } from '../Theme';
5
- import { withDeprecated } from '../Util/deprecate';
6
-
7
- export interface PricingTableProps {
8
- plans?: Array<PricingPlanProps['plan']>;
9
- }
10
-
11
- function PricingTable({ plans = [] }: PricingTableProps) {
12
- if (plans && plans.length > 0) {
13
- return (
14
- <Div variant="even">
15
- <Grid
16
- container
17
- spacing={2}
18
- sx={{
19
- justifyContent: 'center',
20
- }}>
21
- {plans.map((x, index) => (
22
- <Grid
23
- className="plan-item"
24
- // eslint-disable-next-line react/no-array-index-key
25
- key={index}
26
- size={{
27
- xs: 12,
28
- sm: 6,
29
- md: 3,
30
- }}>
31
- <PricingPlan plan={x} />
32
- </Grid>
33
- ))}
34
- </Grid>
35
- </Div>
36
- );
37
- }
38
- return null;
39
- }
40
-
41
- export default withDeprecated(PricingTable, { name: 'PricingTable' });
42
-
43
- type DivProps = {
44
- variant: 'even' | 'odd';
45
- };
46
-
47
- const Div = styled('div')<DivProps>`
48
- padding: 100px 0;
49
- text-align: center;
50
- background-color: ${(props) => (props.variant === 'even' ? '#fbfbfb' : '#ffffff')};
51
- @media (max-width: 320px) {
52
- padding: 50px 0;
53
- }
54
- .plan-item {
55
- @media (max-width: 320px) {
56
- margin-bottom: 30px;
57
- }
58
- }
59
- `;
@@ -1,13 +0,0 @@
1
- export { default as Basic } from './demo/basic';
2
- export { default as WithImage } from './demo/with-image';
3
-
4
- export default {
5
- title: 'Data Display/QRCode',
6
- parameters: {
7
- docs: {
8
- description: {
9
- component: 'Used to generate QR codes with a logo and styling.',
10
- },
11
- },
12
- },
13
- };
@@ -1,66 +0,0 @@
1
- import { useRef, useEffect, useMemo, useState } from 'react';
2
- import QRCodeStyling from '@solana/qr-code-styling';
3
- import { Box } from '@mui/material';
4
-
5
- type QRCodeStylingOptions = NonNullable<ConstructorParameters<typeof QRCodeStyling>[0]>;
6
-
7
- const defaults: QRCodeStylingOptions = {
8
- margin: 0,
9
- dotsOptions: {
10
- type: 'dots',
11
- },
12
- cornersSquareOptions: {
13
- type: 'extra-rounded',
14
- },
15
- cornersDotOptions: {
16
- type: 'dot',
17
- },
18
- };
19
-
20
- export interface QRCodeProps {
21
- /** 一般情况下仅使用 data/size/image 即可 */
22
- data: string;
23
- size: number;
24
- image?: string;
25
- /** 覆盖 qr-code-styling 配置 */
26
- config?: QRCodeStylingOptions;
27
- }
28
-
29
- // 该组件用于生成与 android wallet 样式风格相似的 qrcode
30
- // 注意: 依赖的 @solana/qr-code-styling 是一份 fork 版本, 原版本的 margin 配置存在 bug
31
- function QRCode({ data, size, image = undefined, config = {}, ...rest }: QRCodeProps) {
32
- const ref = useRef(null);
33
- const options = useMemo(() => {
34
- return {
35
- ...defaults,
36
- data,
37
- width: size,
38
- height: size,
39
- ...(image && {
40
- image,
41
- imageOptions: {
42
- crossOrigin: 'anonymous',
43
- margin: 0,
44
- },
45
- }),
46
- ...config,
47
- };
48
- }, [data, size, image, config]);
49
-
50
- const [qrCode] = useState(new QRCodeStyling(options));
51
-
52
- useEffect(() => {
53
- if (ref.current) {
54
- qrCode.append(ref.current);
55
- }
56
- }, [qrCode, ref]);
57
-
58
- useEffect(() => {
59
- if (!qrCode) return;
60
- qrCode.update(options);
61
- }, [options, qrCode]);
62
-
63
- return <Box ref={ref} {...rest} />;
64
- }
65
-
66
- export default QRCode;
@@ -1,20 +0,0 @@
1
- export { default as Basic } from './demo/basic';
2
- export { default as WithoutSuffix } from './demo/without-suffix';
3
- export { default as From } from './demo/from';
4
- export { default as To } from './demo/to';
5
- export { default as DisplayAbsoluteTime } from './demo/display-absolute-time';
6
- export { default as CustomTimezoneAmericaLosAngeLes } from './demo/custom-timezone-america-los-ange-les';
7
- export { default as CustomStyle } from './demo/custom-style';
8
- export { default as UTCTimeFormat } from './demo/utc';
9
- export { default as AllTimeFormat } from './demo/all';
10
-
11
- export default {
12
- title: 'Data Display/RelativeTIme',
13
- parameters: {
14
- docs: {
15
- description: {
16
- component: 'Display dates as a human-readable relative time.',
17
- },
18
- },
19
- },
20
- };