@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,161 +0,0 @@
1
- import find from 'lodash/find';
2
-
3
- function escapeDangerousCSVCharacters(data) {
4
- if (typeof data === 'string') {
5
- // Places single quote before the appearance of dangerous characters if they
6
- // are the first in the data string.
7
- // eslint-disable-next-line no-useless-escape
8
- return data.replace(/^\+|^\-|^\=|^\@/g, "'$&");
9
- }
10
-
11
- return data;
12
- }
13
-
14
- function buildCSV(columns, data, options) {
15
- const replaceDoubleQuoteInString = (columnData) =>
16
- typeof columnData === 'string' ? columnData.replace(/"/g, '""') : columnData;
17
-
18
- // eslint-disable-next-line no-shadow
19
- const buildHead = (tmpColumns) => {
20
- return `${tmpColumns
21
- .reduce(
22
- (soFar, column) =>
23
- column.download
24
- ? `${soFar}"${escapeDangerousCSVCharacters(replaceDoubleQuoteInString(column.label || column.name))}"${
25
- options.downloadOptions.separator
26
- }`
27
- : soFar,
28
- ''
29
- )
30
- .slice(0, -1)}\r\n`;
31
- };
32
-
33
- const CSVHead = buildHead(columns);
34
-
35
- // eslint-disable-next-line no-shadow
36
- const buildBody = (tmpData) => {
37
- if (!tmpData.length) return '';
38
- return tmpData
39
- .reduce(
40
- (soFar, row) =>
41
- `${soFar}"${row.data
42
- .filter((_, index) => columns[index].download)
43
- .map((columnData) => escapeDangerousCSVCharacters(replaceDoubleQuoteInString(columnData)))
44
- .join(`"${options.downloadOptions.separator}"`)}"\r\n`,
45
- ''
46
- )
47
- .trim();
48
- };
49
- const CSVBody = buildBody(data);
50
-
51
- const csv = options.onDownload
52
- ? options.onDownload(buildHead, buildBody, columns, data)
53
- : `${CSVHead}${CSVBody}`.trim();
54
-
55
- return csv;
56
- }
57
-
58
- function downloadCSV(csv, filename) {
59
- const blob = new Blob([csv], { type: 'text/csv' });
60
-
61
- /* taken from react-csv */
62
- if (navigator && navigator.msSaveOrOpenBlob) {
63
- navigator.msSaveOrOpenBlob(blob, filename);
64
- } else {
65
- const dataURI = `data:text/csv;charset=utf-8,${csv}`;
66
-
67
- const URL = window.URL || window.webkitURL;
68
- const downloadURI = typeof URL.createObjectURL === 'undefined' ? dataURI : URL.createObjectURL(blob);
69
-
70
- const link = document.createElement('a');
71
- link.setAttribute('href', downloadURI);
72
- link.setAttribute('download', filename);
73
- document.body.appendChild(link);
74
- link.click();
75
- document.body.removeChild(link);
76
- }
77
- }
78
-
79
- // eslint-disable-next-line no-shadow
80
- function createCSVDownload(columns, data, options, tmpDownloadCSV) {
81
- const csv = buildCSV(columns, data, options);
82
-
83
- if (options.onDownload && csv === false) {
84
- return;
85
- }
86
-
87
- tmpDownloadCSV(csv, options.downloadOptions.filename);
88
- }
89
-
90
- export function handleCSVDownload(props) {
91
- const { data, displayData, columns, options, columnOrder } = props;
92
- let dataToDownload = [];
93
- let columnsToDownload = [];
94
- let columnOrderCopy = Array.isArray(columnOrder) ? columnOrder.slice(0) : [];
95
-
96
- if (columnOrderCopy.length === 0) {
97
- columnOrderCopy = columns.map((item, idx) => idx);
98
- }
99
-
100
- data.forEach((row) => {
101
- const newRow = { index: row.index, data: [] };
102
- columnOrderCopy.forEach((idx) => {
103
- newRow.data.push(row.data[idx]);
104
- });
105
- dataToDownload.push(newRow);
106
- });
107
-
108
- columnOrderCopy.forEach((idx) => {
109
- columnsToDownload.push(columns[idx]);
110
- });
111
-
112
- if (options.downloadOptions && options.downloadOptions.filterOptions) {
113
- // check rows first:
114
- if (options.downloadOptions.filterOptions.useDisplayedRowsOnly) {
115
- const filteredDataToDownload = displayData.map((row, index) => {
116
- let i = -1;
117
-
118
- // Help to preserve sort order in custom render columns
119
- row.index = index;
120
-
121
- return {
122
- data: row.data.map((column) => {
123
- i += 1;
124
-
125
- // if we have a custom render, which will appear as a react element, we must grab the actual value from data
126
- // that matches the dataIndex and column
127
- // TODO: Create a utility function for checking whether or not something is a react object
128
- let val =
129
- typeof column === 'object' && column !== null && !Array.isArray(column)
130
- ? find(data, (d) => d.index === row.dataIndex).data[i]
131
- : column;
132
- val = typeof val === 'function' ? find(data, (d) => d.index === row.dataIndex).data[i] : val;
133
- return val;
134
- }),
135
- };
136
- });
137
-
138
- dataToDownload = [];
139
- filteredDataToDownload.forEach((row) => {
140
- const newRow = { index: row.index, data: [] };
141
- columnOrderCopy.forEach((idx) => {
142
- newRow.data.push(row.data[idx]);
143
- });
144
- dataToDownload.push(newRow);
145
- });
146
- }
147
-
148
- // now, check columns:
149
- if (options.downloadOptions.filterOptions.useDisplayedColumnsOnly) {
150
- columnsToDownload = columnsToDownload.filter((_) => _.display === 'true');
151
-
152
- dataToDownload = dataToDownload.map((row) => {
153
- row.data = row.data.filter((_, index) => columns[columnOrderCopy[index]].display === 'true');
154
- return row;
155
- });
156
- }
157
- }
158
- createCSVDownload(columnsToDownload, dataToDownload, options, downloadCSV);
159
- }
160
-
161
- export default { handleCSVDownload };
@@ -1,21 +0,0 @@
1
- export { default as Basic } from './demo/basic';
2
- export { default as WithShortContent } from './demo/with-short-content';
3
- export { default as CustomSize } from './demo/custom-size';
4
- export { default as CustomActionsPosition } from './demo/custom-actions-position';
5
- export { default as HeaderContentActionsStyleOverrides } from './demo/header-content-actions-style-overrides';
6
- export { default as ConfirmDefault } from './demo/confirm-default';
7
- export { default as ConfirmButtonCustomization } from './demo/confirm-button-customization';
8
- export { default as ConfirmWithoutCancelButton } from './demo/confirm-without-cancel-button';
9
- export { default as ConfirmComplexDescription } from './demo/confirm-complex-description';
10
-
11
- export default {
12
- title: 'Feedback/Dialog',
13
-
14
- parameters: {
15
- docs: {
16
- description: {
17
- component: 'An easy-to-use dialog component based on MUI Dialog.',
18
- },
19
- },
20
- },
21
- };
@@ -1,143 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import { useMemoizedFn } from 'ahooks';
3
-
4
- import Button from '../Button';
5
- import Dialog from './dialog';
6
-
7
- /**
8
- * @typedef {import('../Button/wrap').ButtonProps} ButtonProps
9
- * @typedef {import('@mui/material').PaperProps} PaperProps
10
- * @typedef {{
11
- * title: React.ReactNode,
12
- * open: boolean,
13
- * onConfirm: Function,
14
- * onCancel: Function,
15
- * children?: React.ReactNode,
16
- * showCancelButton?: true | false,
17
- * showCloseButton?: true | false,
18
- * showConfirmButton?: true | false,
19
- * fullScreen?: false | true,
20
- * confirmButton?: {text: React.ReactNode, props?: ButtonProps}
21
- * cancelButton?: {text: React.ReactNode, props?: ButtonProps}
22
- * PaperProps?: PaperProps
23
- * }} ConfirmProps
24
- */
25
-
26
- // 注意排在 {...rest} 之后的 props 优先级更高
27
- /**
28
- *
29
- * @param {ConfirmProps} props
30
- * @returns {import('react').ReactComponentElement}
31
- */
32
- export default function Confirm({
33
- title,
34
- children,
35
- onConfirm,
36
- onCancel,
37
- showCloseButton = true,
38
- showCancelButton = true,
39
- showConfirmButton = true,
40
- fullScreen = false,
41
- confirmButton = {
42
- text: 'Confirm',
43
- },
44
- cancelButton = {
45
- text: 'Cancel',
46
- },
47
- PaperProps = {},
48
- ...rest
49
- }) {
50
- // 去除 dialog 默认的 300 最小高度
51
- PaperProps.style = Object.assign(
52
- {
53
- minHeight: 0,
54
- },
55
- PaperProps.style
56
- );
57
-
58
- const handleClose = useMemoizedFn((e, reason) => {
59
- if (['backdropClick', 'escapeKeyDown'].includes(reason)) {
60
- return;
61
- }
62
- e.stopPropagation();
63
- onCancel(e, reason);
64
- });
65
-
66
- return (
67
- <Dialog
68
- title={title}
69
- PaperProps={PaperProps}
70
- {...rest}
71
- onClose={handleClose}
72
- showCloseButton={showCloseButton}
73
- fullScreen={fullScreen}
74
- slotProps={{
75
- header: {
76
- sx: {
77
- '.ux-dialog_title': {
78
- lineHeight: 1,
79
- },
80
- },
81
- },
82
- content: {
83
- sx: {
84
- paddingTop: '0!important',
85
- border: 'none!important',
86
- },
87
- },
88
- }}
89
- actions={
90
- showCancelButton || showConfirmButton ? (
91
- <>
92
- {showCancelButton && (
93
- <Button
94
- onClick={(e) => {
95
- e.stopPropagation();
96
- onCancel(e, 'closeButton');
97
- }}
98
- color="primary"
99
- {...cancelButton.props}>
100
- {cancelButton.text}
101
- </Button>
102
- )}
103
- {showConfirmButton && (
104
- <Button
105
- onClick={(e) => {
106
- e.stopPropagation();
107
- onConfirm(e);
108
- }}
109
- color="primary"
110
- autoFocus
111
- {...confirmButton.props}>
112
- {confirmButton.text}
113
- </Button>
114
- )}
115
- </>
116
- ) : null
117
- }>
118
- {children}
119
- </Dialog>
120
- );
121
- }
122
-
123
- Confirm.propTypes = {
124
- title: PropTypes.node.isRequired,
125
- open: PropTypes.bool.isRequired,
126
- onConfirm: PropTypes.func.isRequired,
127
- onCancel: PropTypes.func.isRequired,
128
- children: PropTypes.node.isRequired,
129
- showCancelButton: PropTypes.bool,
130
- showConfirmButton: PropTypes.bool,
131
- showCloseButton: PropTypes.bool,
132
- fullScreen: PropTypes.bool,
133
- // 可以传入 {text: ..., props: ...}
134
- confirmButton: PropTypes.shape({
135
- text: PropTypes.node.isRequired,
136
- props: PropTypes.object,
137
- }),
138
- cancelButton: PropTypes.shape({
139
- text: PropTypes.node.isRequired,
140
- props: PropTypes.object,
141
- }),
142
- PaperProps: PropTypes.object,
143
- };
@@ -1,199 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import { Close as CloseIcon } from '@mui/icons-material';
3
- import {
4
- Typography,
5
- Dialog as MuiDialog,
6
- DialogContent as MuiDialogContent,
7
- DialogActions,
8
- IconButton,
9
- useMediaQuery,
10
- Box,
11
- } from '@mui/material';
12
-
13
- import { styled, useTheme } from '../Theme';
14
-
15
- /**
16
- * @typedef {import('@mui/material').DialogProps} MuiDialogProps
17
- * @typedef {import('@mui/material').PaperProps & {
18
- * minWidth?: number | string,
19
- * minHeight?: number | string,
20
- * }} PaperStyle
21
- */
22
-
23
- /**
24
- @typedef {Object} UxDialogProps
25
- @property {React.ReactNode} children - The content of the dialog.
26
- @property {React.ReactNode} [title] - The title of the dialog.
27
- @property {React.ReactNode} [prepend] - Content to be displayed before the dialog title.
28
- @property {React.ReactNode} [toolbar] - Content to be displayed in the top toolbar of the dialog.
29
- @property {React.ReactNode} [actions] - Content to be displayed in the bottom actions toolbar of the dialog.
30
- @property {boolean} [showCloseButton=true] - Whether or not to show the close button.
31
- @property {'left'|'center'|'right'} [actionsPosition='right'] - The position of the actions toolbar.
32
- @property {PaperStyle} [PaperProps] - Props to be passed down to the dialog paper.
33
- @property {{content: object, content: object}} [slotProps]
34
- @property {(event: React.SyntheticEvent, reason: string) => void} [onClose] - Callback function fired when the dialog is closed.
35
- */
36
-
37
- /**
38
- * @typedef {Omit<MuiDialogProps, 'title' | 'children' | 'onClose' | 'PaperProps' | 'slotProps'> & UxDialogProps} DialogProps
39
- */
40
-
41
- /**
42
- * Dialog
43
- *
44
- * - 固定尺寸或特殊的尺寸控制需求, 可使用 PaperProps.style (不再提供 width/height 等 props)
45
- * 注意: 当设置明确的 width 时, 可能需要同时设置 maxWidth=false (mui dialog 默认 maxWidth=sm, 设置的 width 可能受限)
46
- * - 添加默认最小尺寸 (300x300), 在需要 先展示 loading 再展示异步数据 的时候避免 loading 阶段窗口过小
47
- */
48
- /**
49
- * @description
50
- * @param {DialogProps} props
51
- * @return {React.ReactComponentElement<any, DialogProps>}
52
- */
53
- function Dialog({
54
- children,
55
- title = '',
56
- prepend = null,
57
- toolbar = null,
58
- actions = null,
59
- showCloseButton = true,
60
- actionsPosition = 'right',
61
- PaperProps = {},
62
- slotProps = {},
63
- ...rest
64
- }) {
65
- const theme = useTheme();
66
- // 不管是否是 mobile 设备, 只要屏宽 < sm, dialog 就处于 mobile 模式
67
- const isMobile = useMediaQuery(theme.breakpoints.down('md'));
68
- const showHeader = title || showCloseButton || toolbar;
69
- const handleOnClose = (e, reason) => {
70
- // escapeKeyDown/backdropClick
71
- const { onClose } = rest;
72
- if (onClose) {
73
- onClose(e, reason);
74
- }
75
- };
76
- // 添加默认最小尺寸 (300x300)
77
- PaperProps.style = Object.assign(
78
- {
79
- minWidth: 300,
80
- minHeight: 300,
81
- },
82
- PaperProps.style
83
- );
84
-
85
- const closeButton = (
86
- <IconButton className="ux-dialog_closeButton" onClick={(e) => handleOnClose(e, 'closeButton')}>
87
- <CloseIcon />
88
- </IconButton>
89
- );
90
-
91
- return (
92
- <StyledMuiDialog fullScreen={isMobile} onClose={handleOnClose} PaperProps={PaperProps} {...rest}>
93
- {showHeader && (
94
- <Header {...slotProps.header} className="ux-dialog_header" isMobile={isMobile}>
95
- <div className="ux-dialog_left">
96
- {showCloseButton && isMobile && closeButton}
97
- {prepend && <div className="ux-dialog_prepend">{prepend}</div>}
98
- {title && (
99
- <Typography variant="h6" className="ux-dialog_title">
100
- {title}
101
- </Typography>
102
- )}
103
- </div>
104
-
105
- <div className="ux-dialog_right">
106
- <div className="ux-dialog_toolbar">{toolbar}</div>
107
- {showCloseButton && !isMobile && closeButton}
108
- </div>
109
- </Header>
110
- )}
111
- <MuiDialogContent {...slotProps.content}>{children}</MuiDialogContent>
112
- {actions && <DialogActions className={`ux-dialog_actions--${actionsPosition}`}>{actions}</DialogActions>}
113
- </StyledMuiDialog>
114
- );
115
- }
116
-
117
- Dialog.propTypes = {
118
- children: PropTypes.node.isRequired,
119
- title: PropTypes.node,
120
- // 在 title 之前追加内容, 比如返回按钮
121
- prepend: PropTypes.node,
122
- // 顶部工具栏, 在 close button 另一侧
123
- toolbar: PropTypes.node,
124
- actions: PropTypes.node,
125
- showCloseButton: PropTypes.bool,
126
- actionsPosition: PropTypes.oneOf(['left', 'center', 'right']),
127
- PaperProps: PropTypes.object,
128
- slotProps: PropTypes.shape({
129
- content: PropTypes.object,
130
- header: PropTypes.object,
131
- }),
132
- onClose: PropTypes.func,
133
- };
134
-
135
- /**
136
- * @type {import('@emotion/styled').StyledComponent<import('@mui/material').DialogProps, {}, { ref?: React.Ref<any> | undefined;}>}
137
- */
138
- const StyledMuiDialog = styled(MuiDialog)`
139
- .MuiDialog-paper {
140
- ${(props) => (props.fullScreen ? 'border-radius: 0;' : '')};
141
- }
142
- .MuiDialogContent-root {
143
- padding: 16px 24px;
144
- }
145
- .MuiDialogActions-root {
146
- padding: 8px 24px 16px 24px;
147
- }
148
- .MuiDialogActions-root.ux-dialog_actions--left {
149
- justify-content: flex-start;
150
- }
151
- .MuiDialogActions-root.ux-dialog_actions--right {
152
- justify-content: flex-end;
153
- }
154
- .MuiDialogActions-root.ux-dialog_actions--center {
155
- justify-content: center;
156
- }
157
- `;
158
-
159
- /** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
160
- const Header = styled(Box, { shouldForwardProp: (prop) => prop !== 'isMobile' })`
161
- display: flex;
162
- justify-content: space-between;
163
- align-items: center;
164
- padding: 16px 24px;
165
- .ux-dialog_left {
166
- display: flex;
167
- justify-content: flex-start;
168
- align-items: center;
169
- min-width: 0;
170
- }
171
- .ux-dialog_right {
172
- display: flex;
173
- justify-content: flex-end;
174
- align-items: center;
175
- }
176
- .ux-dialog_toolbar {
177
- display: flex;
178
- align-items: center;
179
- }
180
- .ux-dialog_title {
181
- margin: 0;
182
- font-size: 18px;
183
- font-weight: 500;
184
- white-space: nowrap;
185
- overflow: hidden;
186
- text-overflow: ellipsis;
187
- }
188
- .ux-dialog_closeButton {
189
- /* 使 closeButton 与 content 左/右对齐 */
190
- ${(props) => (props.isMobile ? 'margin-left: -12px;' : 'margin-right: -12px;')}
191
- transition: transform 0.3s;
192
- transform: rotate(0deg);
193
- &:hover {
194
- transform: rotate(90deg);
195
- }
196
- }
197
- `;
198
-
199
- export default Dialog;
@@ -1,4 +0,0 @@
1
- // eslint-disable-next-line no-restricted-exports
2
- export { default } from './dialog';
3
- export { default as Confirm } from './confirm';
4
- export { default as useConfirm } from './use-confirm';
@@ -1,20 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { ButtonProps } from '@mui/material';
3
-
4
- export interface OpenConfirmProps {
5
- title: ReactNode;
6
- content: ReactNode;
7
- onConfirm?: (close: () => void) => void;
8
- onCancel?: () => void;
9
- showCancelButton?: true | false;
10
- confirmButtonText?: string;
11
- cancelButtonText?: string;
12
- confirmButtonProps?: ButtonProps;
13
- cancelButtonProps?: ButtonProps;
14
- }
15
-
16
- export type UpdateConfirmProps = Partial<Pick<OpenConfirmProps, 'title' | 'content'>>;
17
-
18
- export type OpenConfirm = (params: OpenConfirmProps) => void;
19
- export type CloseConfirm = () => void;
20
- export type UpdateConfirm = (params: UpdateConfirmProps) => void;