@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,515 +0,0 @@
1
- /* eslint-disable consistent-return */
2
- import { useReducer, useRef, useEffect } from 'react';
3
- import useSpring from 'react-use/lib/useSpring';
4
- import * as d3 from 'd3-geo';
5
- import * as topojson from 'topojson-client';
6
- import versor from 'versor';
7
-
8
- import json from './countries.json';
9
- import util from './util';
10
- import type { Vec2, Vec3, Quaternion, Angles, Rotation } from './util';
11
- import { withDeprecated } from '../Util/deprecate';
12
- import { styled } from '../Theme';
13
-
14
- const geoJson = topojson.feature(json, json.objects.ne_110m_admin_0_countries);
15
- const themes = {
16
- light: {
17
- ocean: '#EDF4F4',
18
- graticule: '#EDF4F4',
19
- land: '#CCEAEA',
20
- activeLand: '#AFD3D3',
21
- border: '#AFD3D3',
22
- marker: '#4E6AF6',
23
- activeMarker: '#4E6AF6',
24
- },
25
- dark: {
26
- ocean: '#09233B',
27
- graticule: '#09233B',
28
- land: '#0D2344',
29
- activeLand: '#173159',
30
- border: '#89DDD9',
31
- marker: '#ffffff',
32
- activeMarker: '#FFD159',
33
- },
34
- };
35
-
36
- type State = {
37
- rotation: Angles;
38
- isDragging: boolean;
39
- animateDuration: number;
40
- mousePosition: [number, number] | null;
41
- tooltipIndex: number;
42
- };
43
-
44
- type Action = {
45
- type: string;
46
- payload: Record<string, any>;
47
- };
48
-
49
- function stateReducer(state: State, action: Action) {
50
- switch (action.type) {
51
- case 'dragEnd':
52
- return { ...state, isDragging: false };
53
- case 'dragStart':
54
- return {
55
- ...state,
56
- isDragging: true,
57
- animationDuration: 1,
58
- mousePosition: action.payload.mousePosition,
59
- };
60
- case 'tooltip':
61
- case 'rotate':
62
- return Object.assign({}, state, action.payload);
63
- default:
64
- return state;
65
- }
66
- }
67
-
68
- export type Marker = {
69
- id: string;
70
- title: string;
71
- description: string;
72
- country: string;
73
- latitude: number;
74
- longitude: number;
75
- };
76
-
77
- export type Colors = {
78
- ocean: string;
79
- graticule: string;
80
- land: string;
81
- activeLand: string;
82
- border: string;
83
- marker: string;
84
- activeMarker: string;
85
- };
86
-
87
- export interface EarthProps {
88
- theme?: 'light' | 'dark';
89
- width?: number;
90
- height?: number;
91
- enableRotation?: false | true;
92
- rotationSpeed?: number;
93
- activeMarkerId?: string;
94
- markers?: Marker[];
95
- colors?: Partial<Colors>;
96
- }
97
-
98
- function Earth({
99
- theme = 'dark',
100
- width = 1200,
101
- height = 600,
102
- enableRotation = false,
103
- rotationSpeed = 5,
104
- activeMarkerId = undefined,
105
- markers = [],
106
- colors: _colors = {},
107
- }: EarthProps) {
108
- const colors: Colors = Object.assign(_colors, themes[theme]);
109
- const [state, dispatch] = useReducer(stateReducer, {
110
- rotation: [0, 0, 0],
111
- isDragging: false,
112
- animateDuration: 1,
113
- mousePosition: null,
114
- tooltipIndex: -1,
115
- });
116
-
117
- const svgRef = useRef<SVGSVGElement>(null);
118
-
119
- // variables used to track drag and rotate
120
- const dragRef = useRef<{
121
- v0?: Vec3;
122
- r0?: Rotation;
123
- q0?: Quaternion;
124
- }>({});
125
-
126
- // variables used to track start and end position when there is active marker
127
- const rotateRef = useRef<{
128
- p1: Vec2 | null;
129
- p2: Vec2;
130
- r1: Rotation | null;
131
- r2: Rotation;
132
- step: number;
133
- markerId: string | null;
134
- iv: ((t: number) => Angles) | null;
135
- }>({
136
- p1: null,
137
- p2: [0, 0],
138
- r1: null,
139
- r2: [0, 0, 0],
140
- step: 0,
141
- markerId: null,
142
- iv: null,
143
- });
144
-
145
- // console.log('renderGlobe', state, dragRef.current, rotateRef.current, geoJson);
146
- const t = useSpring(state.animateDuration, 170, 26);
147
-
148
- const isValid =
149
- activeMarkerId && rotateRef.current.markerId !== activeMarkerId && markers.some((x) => x.id === activeMarkerId);
150
-
151
- // Setup path for globe
152
- const projection = d3
153
- .geoOrthographic()
154
- .fitExtent(
155
- [
156
- [30, 30],
157
- [width - 30, height - 30],
158
- ],
159
- geoJson
160
- )
161
- .rotate(
162
- t <= 1 || state.isDragging || !activeMarkerId ? state.rotation : rotateRef.current.iv!(t / state.animateDuration)
163
- );
164
-
165
- const pathGenerator = d3.geoPath().projection(projection).pointRadius(2);
166
-
167
- useEffect(() => {
168
- // Rotate to active marker
169
- if (isValid) {
170
- // eslint-disable-next-line prefer-const
171
- let { p1, p2, r1, r2, markerId } = rotateRef.current;
172
- // We should only start new animation if the marker has changed
173
- if (markerId !== activeMarkerId && !state.isDragging) {
174
- const marker = markers.find((x) => x.id === activeMarkerId)!;
175
- p1 = p2;
176
- p2 = [marker.longitude, marker.latitude];
177
- r1 = r2;
178
- r2 = [-p2[0], 20 - p2[1], projection.rotate()[2]];
179
- const iv = util.interpolateAngles(r1, r2);
180
-
181
- Object.assign(rotateRef.current, {
182
- p1,
183
- p2,
184
- r1,
185
- r2,
186
- iv,
187
- markerId: activeMarkerId,
188
- });
189
- const duration = state.animateDuration * 2;
190
-
191
- dispatch({
192
- type: 'rotate',
193
- payload: {
194
- animateDuration: duration > 1e3 ? 2 : duration,
195
- },
196
- });
197
- }
198
-
199
- // Enable auto rotation
200
- } else if (enableRotation) {
201
- const handler = window.requestAnimationFrame(() => {
202
- const newRotation = [state.rotation[0] + 2 / rotationSpeed, state.rotation[1], state.rotation[2]];
203
- dispatch({ type: 'rotate', payload: { rotation: newRotation } });
204
- });
205
-
206
- return function cleanup() {
207
- window.cancelAnimationFrame(handler);
208
- };
209
- }
210
- });
211
-
212
- const getMousePosition = (event: MouseEvent) => {
213
- const node = svgRef.current!;
214
- const rect = node?.getBoundingClientRect();
215
- const mousePosition = [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
216
-
217
- return mousePosition;
218
- };
219
-
220
- const onDragStart = (event: React.MouseEvent<SVGSVGElement>) => {
221
- const mousePosition = getMousePosition(event as unknown as MouseEvent);
222
-
223
- if (!mousePosition[0]) {
224
- return;
225
- }
226
-
227
- dragRef.current.v0 = versor.cartesian(projection.invert(mousePosition));
228
- dragRef.current.r0 = projection.rotate();
229
- dragRef.current.q0 = versor(dragRef.current.r0);
230
-
231
- dispatch({ type: 'dragStart', payload: { mousePosition } });
232
- };
233
-
234
- const onDrag = (event: React.MouseEvent<SVGSVGElement>) => {
235
- if (state.isDragging === false) {
236
- return;
237
- }
238
-
239
- const mousePosition = getMousePosition(event as unknown as MouseEvent);
240
- const { r0, v0, q0 } = dragRef.current;
241
-
242
- const v1 = versor.cartesian(projection.rotate(r0).invert(mousePosition));
243
- const q1 = versor.multiply(q0, versor.delta(v0, v1));
244
- const r1 = versor.rotation(q1);
245
-
246
- dispatch({ type: 'rotate', payload: { rotation: r1, mousePosition } });
247
- };
248
-
249
- const onDragEnd = () => {
250
- setTimeout(() => {
251
- dispatch({ type: 'dragEnd', payload: {} });
252
- }, 200);
253
- };
254
-
255
- const onShowTooltip = (event: MouseEvent, i: number) =>
256
- dispatch({
257
- type: 'tooltip',
258
- payload: { tooltipIndex: i, mousePosition: getMousePosition(event) },
259
- });
260
-
261
- const onHideTooltip = () => dispatch({ type: 'tooltip', payload: { tooltipIndex: -1, mousePosition: null } });
262
-
263
- const renderMarkers = () =>
264
- markers.map((x, i) => {
265
- const areaCoords = [x.longitude, x.latitude];
266
- const distance = d3.geoDistance(areaCoords, projection.invert([width / 2, height / 2]));
267
- const sphereCoords = projection(areaCoords);
268
- const isActive = activeMarkerId === x.id;
269
- // eslint-disable-next-line no-nested-ternary
270
- const fill = distance > 1.57 ? 'none' : isActive ? colors.activeMarker : colors.marker;
271
- const radius = isActive ? 9 : 6;
272
- return (
273
- <g
274
- key={x.id}
275
- className={`marker ${isActive ? 'marker--active' : ''}`}
276
- onFocus={(event) => onShowTooltip(event as unknown as MouseEvent, i)}
277
- onBlur={onHideTooltip}
278
- onMouseOver={(event) => onShowTooltip(event as unknown as MouseEvent, i)}
279
- onMouseOut={onHideTooltip}>
280
- <circle
281
- key="marker-inner"
282
- className="marker__inner"
283
- r={radius}
284
- cx={sphereCoords[0]}
285
- cy={sphereCoords[1]}
286
- fill={fill}
287
- style={{ fillOpacity: isActive ? 1 : 0.5 }}
288
- />
289
- <circle
290
- key="marker-outer"
291
- className="marker__outer"
292
- r={radius * 2}
293
- cx={sphereCoords[0]}
294
- cy={sphereCoords[1]}
295
- fill={fill}
296
- style={{
297
- animationDuration: isActive ? '800ms' : '1600ms',
298
- animationDelay: `${i * 0.2}s`,
299
- transformOrigin: `${sphereCoords[0]}px ${sphereCoords[1]}px`,
300
- }}
301
- />
302
- </g>
303
- );
304
- });
305
-
306
- const renderTooltip = () => {
307
- if (state.tooltipIndex >= 0) {
308
- const marker = markers[state.tooltipIndex];
309
- return (
310
- <Tooltip style={{ left: state.mousePosition?.[0] ?? 0, top: state.mousePosition?.[1] ?? 0 }}>
311
- <p className="title">{marker.title}</p>
312
- <p className="description">{marker.description}</p>
313
- <p className="description">ID: {marker.id}</p>
314
- </Tooltip>
315
- );
316
- }
317
- };
318
-
319
- let activeCountry = null;
320
- if (activeMarkerId && markers.some((x) => x.id === activeMarkerId)) {
321
- const activeMarker = markers.find((x) => x.id === activeMarkerId);
322
- activeCountry = geoJson.features.findIndex(
323
- (x: any) => x.properties && x.properties.name && x.properties.name === activeMarker!.country
324
- );
325
- }
326
-
327
- return (
328
- <Container width={width} height={height} $theme={theme} colors={colors} onMouseLeave={onDragEnd}>
329
- {renderTooltip()}
330
- <svg
331
- className="earth"
332
- width={width}
333
- height={height}
334
- onMouseDown={onDragStart}
335
- onMouseMove={onDrag}
336
- onMouseUp={onDragEnd}
337
- ref={svgRef}>
338
- <rect className="frame" width={width} height={height} />
339
- <circle cx={width / 2} cy={height / 2} r={projection.scale()} className="globe" filter="url(#glow)" />
340
- <path className="graticule" d={pathGenerator(d3.geoGraticule().step([10, 10])())} />
341
- <g className="features">
342
- {geoJson.features.map((x: any, i: number) => (
343
- <path
344
- key={x.properties.name}
345
- className={`country ${activeCountry === i ? 'country--active' : ''}`}
346
- d={pathGenerator(x)}
347
- />
348
- ))}
349
- </g>
350
- <g className="markers">{renderMarkers()}</g>
351
- {state.isDragging && state.mousePosition && (
352
- <path
353
- className="point point-mouse"
354
- d={pathGenerator({
355
- type: 'Point',
356
- coordinates: projection.invert(state.mousePosition),
357
- })}
358
- />
359
- )}
360
- </svg>
361
- <svg className="defs">
362
- <defs>
363
- <linearGradient id="gradBlue" x1="0%" y1="0%" x2="100%" y2="0%">
364
- <stop offset="0%" style={{ stopColor: '#005C99', stopOpacity: 1 }} />
365
- <stop offset="100%" style={{ stopColor: '#0099FF', stopOpacity: 1 }} />
366
- </linearGradient>
367
- <filter id="glow">
368
- <feColorMatrix
369
- type="matrix"
370
- values="0 0 0 0 0
371
- 0 0 0 0.9 0
372
- 0 0 0 0.9 0
373
- 0 0 0 1 0"
374
- />
375
- <feGaussianBlur stdDeviation="5.5" result="coloredBlur" />
376
- <feMerge>
377
- <feMergeNode in="coloredBlur" />
378
- <feMergeNode in="SourceGraphic" />
379
- </feMerge>
380
- </filter>
381
- </defs>
382
- </svg>
383
- </Container>
384
- );
385
- }
386
-
387
- export default withDeprecated(Earth, { name: 'Earth' });
388
-
389
- type ContainerProps = {
390
- $theme: 'light' | 'dark';
391
- width: number;
392
- height: number;
393
- colors: Colors;
394
- };
395
-
396
- const Container = styled('div')<ContainerProps>`
397
- background-color: ${(props) => (props.$theme === 'light' ? '#f7f7f7' : '#222')};
398
- width: ${(props) => props.width}px;
399
- height: ${(props) => props.height}px;
400
- position: relative;
401
- animation-name: zoomIn;
402
- animation-duration: 1s;
403
- animation-iteration-count: 1;
404
- animation-timing-function: ease;
405
- user-select: none;
406
-
407
- .defs {
408
- height: 0;
409
- width: 0;
410
- }
411
-
412
- .frame {
413
- fill: none;
414
- pointer-events: all;
415
- }
416
-
417
- .country {
418
- fill: ${(props) => props.colors.land};
419
- stroke: ${(props) => props.colors.border};
420
- stroke-width: 0.5px;
421
- transition: fill 300ms ease;
422
-
423
- &:hover {
424
- fill: ${(props) => props.colors.activeLand};
425
- }
426
- }
427
-
428
- .country--active {
429
- fill: ${(props) => props.colors.activeLand};
430
- }
431
-
432
- .globe {
433
- fill: ${(props) => props.colors.ocean};
434
- stroke: rgba(255, 255, 255, 0.5);
435
- stroke-width: 0.25px;
436
- }
437
-
438
- .graticule {
439
- fill: none;
440
- stroke: ${(props) => props.colors.graticule};
441
- }
442
-
443
- .star {
444
- fill: #fff;
445
- stroke: rgba(255, 255, 255, 0.5);
446
- stroke-width: 0.25px;
447
- }
448
-
449
- .marker {
450
- .marker__outer {
451
- fill-opacity: 0;
452
- animation: scaleIn 2s infinite ease-in-out;
453
- }
454
- }
455
-
456
- @keyframes zoomIn {
457
- from {
458
- opacity: 0;
459
- transform: scale3d(0.1, 0.1, 0.1);
460
- }
461
-
462
- 50% {
463
- opacity: 1;
464
- }
465
- }
466
-
467
- @keyframes scaleIn {
468
- from {
469
- fill-opacity: 0.3;
470
- transform: scale3d(0.5, 0.5, 0.5);
471
- }
472
- to {
473
- fill-opacity: 0;
474
- transform: scale3d(1.5, 1.5, 1.5);
475
- }
476
- }
477
- `;
478
-
479
- const Tooltip = styled('div')`
480
- position: absolute;
481
- width: auto;
482
- min-width: 90px;
483
- max-width: 320px;
484
- padding: 8px 12px;
485
- font-size: 14px;
486
- background-color: #4a4a4a;
487
- border-radius: 2px;
488
- animation-name: fadeIn;
489
- animation-duration: 250ms;
490
- animation-iteration-count: 1;
491
- animation-timing-function: ease;
492
-
493
- .title,
494
- .description {
495
- margin: 0;
496
- font-size: 16px;
497
- color: #fff;
498
- }
499
-
500
- .description {
501
- margin-top: ${(props) => props.theme.spacing(1)}px;
502
- color: #fff;
503
- font-size: 12px;
504
- }
505
-
506
- @keyframes fadeIn {
507
- from {
508
- opacity: 0;
509
- }
510
-
511
- to {
512
- opacity: 1;
513
- }
514
- }
515
- `;
package/src/Earth/util.ts DELETED
@@ -1,72 +0,0 @@
1
- /* eslint-disable */
2
- // Code from: https://observablehq.com/@d3/world-tour
3
- export type Vec3 = [number, number, number];
4
- export type Vec2 = [number, number];
5
- export type Quaternion = [number, number, number, number];
6
- export type Rotation = Vec3;
7
- export type Angles = Vec3;
8
-
9
- export default class Util {
10
- static fromAngles([l, p, g]: Angles) {
11
- l *= Math.PI / 360;
12
- p *= Math.PI / 360;
13
- g *= Math.PI / 360;
14
- const sl = Math.sin(l);
15
- const cl = Math.cos(l);
16
- const sp = Math.sin(p);
17
- const cp = Math.cos(p);
18
- const sg = Math.sin(g);
19
- const cg = Math.cos(g);
20
- return [
21
- cl * cp * cg + sl * sp * sg,
22
- sl * cp * cg - cl * sp * sg,
23
- cl * sp * cg + sl * cp * sg,
24
- cl * cp * sg - sl * sp * cg,
25
- ] as Quaternion;
26
- }
27
-
28
- static toAngles([a, b, c, d]: Quaternion) {
29
- return [
30
- (Math.atan2(2 * (a * b + c * d), 1 - 2 * (b * b + c * c)) * 180) / Math.PI,
31
- (Math.asin(Math.max(-1, Math.min(1, 2 * (a * c - d * b)))) * 180) / Math.PI,
32
- (Math.atan2(2 * (a * d + b * c), 1 - 2 * (c * c + d * d)) * 180) / Math.PI,
33
- ];
34
- }
35
-
36
- static interpolateAngles(a: [number, number, number], b: [number, number, number]) {
37
- const i = Util.interpolate(Util.fromAngles(a), Util.fromAngles(b));
38
- return (t: number) => Util.toAngles(i(t));
39
- }
40
-
41
- static interpolateLinear([a1, b1, c1, d1]: Quaternion, [a2, b2, c2, d2]: Quaternion) {
42
- (a2 -= a1), (b2 -= b1), (c2 -= c1), (d2 -= d1);
43
- const x = new Array(4);
44
-
45
- return (t: number) => {
46
- const l = Math.hypot((x[0] = a1 + a2 * t), (x[1] = b1 + b2 * t), (x[2] = c1 + c2 * t), (x[3] = d1 + d2 * t));
47
- (x[0] /= l), (x[1] /= l), (x[2] /= l), (x[3] /= l);
48
-
49
- return x as Quaternion;
50
- };
51
- }
52
-
53
- static interpolate([a1, b1, c1, d1]: Quaternion, [a2, b2, c2, d2]: Quaternion) {
54
- let dot = a1 * a2 + b1 * b2 + c1 * c2 + d1 * d2;
55
- if (dot < 0) (a2 = -a2), (b2 = -b2), (c2 = -c2), (d2 = -d2), (dot = -dot);
56
- if (dot > 0.9995) return Util.interpolateLinear([a1, b1, c1, d1], [a2, b2, c2, d2]);
57
- const theta0 = Math.acos(Math.max(-1, Math.min(1, dot)));
58
- const x = new Array(4);
59
- const l = Math.hypot((a2 -= a1 * dot), (b2 -= b1 * dot), (c2 -= c1 * dot), (d2 -= d1 * dot));
60
- (a2 /= l), (b2 /= l), (c2 /= l), (d2 /= l);
61
- return (t: number) => {
62
- const theta = theta0 * t;
63
- const s = Math.sin(theta);
64
- const c = Math.cos(theta);
65
- x[0] = a1 * c + a2 * s;
66
- x[1] = b1 * c + b2 * s;
67
- x[2] = c1 * c + c2 * s;
68
- x[3] = d1 * c + d2 * s;
69
- return x as Quaternion;
70
- };
71
- }
72
- }
@@ -1,23 +0,0 @@
1
- import Empty from './index';
2
-
3
- import Basic from './demo/basic';
4
- import CustomMessage from './demo/custom-message';
5
- import ComplexMessage from './demo/complex-message';
6
-
7
- export default {
8
- title: 'Data Display/Empty',
9
- component: Empty,
10
- parameters: {
11
- docs: {
12
- description: {
13
- component: 'Empty provides a generic "Empty Content" placeholder.',
14
- },
15
- },
16
- },
17
- };
18
-
19
- Basic.parameters = {
20
- layout: 'fullscreen',
21
- };
22
-
23
- export { Basic, CustomMessage, ComplexMessage };
@@ -1,48 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import { Box } from '@mui/material';
3
- import EmptyIcon from '@arcblock/icons/lib/EmptyIcon';
4
- import { styled } from '../Theme';
5
-
6
- const Wrapper = styled(Box)`
7
- display: flex;
8
- justify-content: center;
9
- align-items: center;
10
- flex-direction: column;
11
- height: 100%;
12
- min-height: 100px;
13
- color: #999;
14
- .empty-icon {
15
- margin: 10px 0;
16
- }
17
- `;
18
-
19
- /**
20
- * Empty component to display empty state
21
- * @typedef {{
22
- * color?: string;
23
- * size?: number;
24
- * children?: import('react').ReactNode;
25
- * } & import('react').ComponentPropsWithoutRef<"div"> } EmptyProps
26
- */
27
-
28
- /**
29
- * Empty state component
30
- * @param {EmptyProps} props
31
- * @returns {JSX.Element}
32
- */
33
- function Empty({ color = 'inherit', size = 36, children = null, ...rest }) {
34
- return (
35
- <Wrapper {...rest}>
36
- <EmptyIcon style={{ width: size, height: size, color }} className="empty-icon" />
37
- <Box className="empty-content">{children}</Box>
38
- </Wrapper>
39
- );
40
- }
41
-
42
- Empty.propTypes = {
43
- color: PropTypes.string,
44
- size: PropTypes.number,
45
- children: PropTypes.any,
46
- };
47
-
48
- export default Empty;
@@ -1,13 +0,0 @@
1
- export { default as ErrorFallback } from './demo/error-fallback';
2
-
3
- export default {
4
- title: 'Basic/ErrorBoundary',
5
-
6
- parameters: {
7
- docs: {
8
- description: {
9
- component: 'ErrorFallback provides a generic error fallback UI',
10
- },
11
- },
12
- },
13
- };