@arcblock/ux 2.10.65 → 2.10.66

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. package/lib/ActionButton/index.d.ts +1 -1
  2. package/lib/Alert/index.d.ts +1 -1
  3. package/lib/AnimationWaiter/index.d.ts +27 -15
  4. package/lib/AnimationWaiter/index.js +15 -14
  5. package/lib/Async/index.d.ts +50 -17
  6. package/lib/Badge/index.d.ts +1 -1
  7. package/lib/Badge/index.js +7 -1
  8. package/lib/BlockletContext/index.d.ts +12 -28
  9. package/lib/BlockletContext/index.js +3 -21
  10. package/lib/Button/wrap.d.ts +5 -3
  11. package/lib/Button/wrap.js +2 -1
  12. package/lib/ButtonGroup/index.d.ts +12 -2
  13. package/lib/ButtonGroup/index.js +13 -3
  14. package/lib/CardSelector/index.d.ts +11 -33
  15. package/lib/CardSelector/index.js +16 -32
  16. package/lib/Center/index.d.ts +6 -21
  17. package/lib/Center/index.js +2 -17
  18. package/lib/ClickToCopy/copy-button.d.ts +9 -26
  19. package/lib/ClickToCopy/copy-button.js +5 -17
  20. package/lib/ClickToCopy/hook.d.ts +11 -5
  21. package/lib/ClickToCopy/hook.js +3 -3
  22. package/lib/ClickToCopy/index.d.ts +18 -29
  23. package/lib/ClickToCopy/index.js +0 -13
  24. package/lib/CodeBlock/LightBox.d.ts +1 -1
  25. package/lib/CodeBlock/index.d.ts +7 -26
  26. package/lib/CodeBlock/index.js +4 -17
  27. package/lib/Colors/index.d.ts +2 -2
  28. package/lib/Colors/themes/default.d.ts +54 -61
  29. package/lib/Colors/themes/temp.d.ts +35 -35
  30. package/lib/ContactForm/index.d.ts +26 -30
  31. package/lib/ContactForm/index.js +7 -17
  32. package/lib/Dialog/confirm.d.ts +3 -3
  33. package/lib/Dialog/confirm.js +2 -2
  34. package/lib/Earth/index.d.ts +10 -1
  35. package/lib/Header/auto-hidden.d.ts +6 -11
  36. package/lib/Header/auto-hidden.js +0 -5
  37. package/lib/Header/header.d.ts +20 -51
  38. package/lib/Header/header.js +10 -42
  39. package/lib/Header/index.d.ts +2 -2
  40. package/lib/Header/responsive-header.d.ts +10 -22
  41. package/lib/Header/responsive-header.js +1 -13
  42. package/lib/Icon/image.d.ts +8 -36
  43. package/lib/Icon/image.js +6 -24
  44. package/lib/Icon/index.d.ts +9 -1
  45. package/lib/Icon/index.js +6 -25
  46. package/lib/NavMenu/index.d.ts +1 -1
  47. package/lib/NavMenu/nav-menu.d.ts +37 -51
  48. package/lib/NavMenu/nav-menu.js +47 -102
  49. package/lib/NavMenu/style.d.ts +8 -2
  50. package/lib/NavMenu/style.js +3 -1
  51. package/lib/PageScroller/index.d.ts +13 -1
  52. package/lib/Passport/passport.js +1 -1
  53. package/lib/PricingTable/index.d.ts +3 -1
  54. package/lib/RelativeTime/index.d.ts +1 -1
  55. package/lib/Screenshot/BaseScreenshot/index.js +1 -1
  56. package/lib/SplitButton/index.d.ts +0 -19
  57. package/lib/SplitButton/index.js +7 -27
  58. package/lib/TextCollapse/index.d.ts +10 -1
  59. package/lib/Theme/index.d.ts +5 -13
  60. package/lib/Theme/index.js +4 -11
  61. package/lib/Theme/theme-provider.d.ts +16 -18
  62. package/lib/Theme/theme.d.ts +37 -11
  63. package/lib/Theme/theme.js +13 -22
  64. package/lib/Util/constant.d.ts +31 -31
  65. package/lib/Util/deprecate.d.ts +7 -5
  66. package/lib/Util/federated.d.ts +21 -21
  67. package/lib/Util/federated.js +1 -1
  68. package/lib/Util/index.d.ts +59 -60
  69. package/lib/Util/index.js +16 -43
  70. package/lib/Util/passport.d.ts +6 -6
  71. package/lib/Util/wallet.d.ts +15 -3
  72. package/lib/WebWalletSWKeeper/index.js +1 -1
  73. package/lib/global.d.ts +13 -0
  74. package/lib/index.d.ts +4 -2
  75. package/lib/index.js +2 -2
  76. package/lib/type.d.ts +31 -1
  77. package/package.json +5 -5
  78. package/src/AnimationWaiter/index.jsx +15 -14
  79. package/src/Async/{index.jsx → index.tsx} +13 -4
  80. package/src/Badge/index.jsx +8 -1
  81. package/src/BlockletContext/{index.jsx → index.tsx} +17 -22
  82. package/src/Button/wrap.jsx +2 -1
  83. package/src/ButtonGroup/index.js +13 -3
  84. package/src/CardSelector/{index.jsx → index.tsx} +32 -33
  85. package/src/Center/index.tsx +33 -0
  86. package/src/ClickToCopy/{copy-button.jsx → copy-button.tsx} +15 -16
  87. package/src/ClickToCopy/{hook.js → hook.ts} +5 -5
  88. package/src/ClickToCopy/{index.jsx → index.tsx} +12 -17
  89. package/src/CodeBlock/{index.jsx → index.tsx} +15 -17
  90. package/src/ContactForm/{index.jsx → index.tsx} +47 -29
  91. package/src/Dialog/confirm.jsx +2 -2
  92. package/src/Header/{auto-hidden.jsx → auto-hidden.tsx} +6 -7
  93. package/src/Header/{header.jsx → header.tsx} +32 -46
  94. package/src/Header/{responsive-header.jsx → responsive-header.tsx} +9 -15
  95. package/src/Icon/{image.jsx → image.tsx} +19 -22
  96. package/src/Icon/{index.jsx → index.tsx} +22 -24
  97. package/src/NavMenu/{nav-menu.jsx → nav-menu.tsx} +161 -144
  98. package/src/NavMenu/{style.js → style.ts} +9 -1
  99. package/src/Passport/passport.jsx +1 -1
  100. package/src/Screenshot/BaseScreenshot/index.jsx +1 -1
  101. package/src/SplitButton/index.tsx +10 -23
  102. package/src/Theme/{index.js → index.ts} +6 -12
  103. package/src/Theme/{theme-provider.jsx → theme-provider.tsx} +10 -2
  104. package/src/Theme/{theme.js → theme.ts} +54 -23
  105. package/src/Util/{deprecate.jsx → deprecate.tsx} +8 -4
  106. package/src/Util/{federated.js → federated.ts} +3 -3
  107. package/src/Util/{index.js → index.ts} +85 -59
  108. package/src/Util/{passport.js → passport.ts} +2 -2
  109. package/src/Util/{wallet.js → wallet.ts} +1 -1
  110. package/src/WebWalletSWKeeper/index.jsx +1 -1
  111. package/src/global.d.ts +13 -0
  112. package/src/{index.js → index.ts} +2 -2
  113. package/src/type.d.ts +31 -1
  114. package/src/Center/index.jsx +0 -41
  115. /package/src/CodeBlock/{LightBox.jsx → LightBox.tsx} +0 -0
  116. /package/src/Colors/{index.js → index.ts} +0 -0
  117. /package/src/Colors/themes/{default.js → default.ts} +0 -0
  118. /package/src/Colors/themes/{temp.js → temp.ts} +0 -0
  119. /package/src/Header/{index.js → index.ts} +0 -0
  120. /package/src/NavMenu/{index.js → index.ts} +0 -0
  121. /package/src/Util/{constant.js → constant.ts} +0 -0
@@ -1,6 +1,6 @@
1
- import { useEffect } from 'react';
1
+ import { ComponentType, useEffect } from 'react';
2
2
 
3
- const warn = (name, alternative) => {
3
+ const warn = (name: string, alternative?: string) => {
4
4
  if (process.env.NODE_ENV === 'production') {
5
5
  return;
6
6
  }
@@ -13,11 +13,15 @@ const warn = (name, alternative) => {
13
13
  }
14
14
  };
15
15
 
16
- const withDeprecated = (Component, { name, alternative }) => {
17
- return function Deprecated(props) {
16
+ const withDeprecated = <P extends object>(
17
+ Component: ComponentType<P>,
18
+ { name, alternative }: { name: string; alternative?: string }
19
+ ) => {
20
+ return function Deprecated(props: P) {
18
21
  useEffect(() => {
19
22
  warn(name, alternative);
20
23
  }, []);
24
+
21
25
  return <Component {...props} />;
22
26
  };
23
27
  };
@@ -58,7 +58,7 @@ export function getCurrentApp(blocklet = window.blocklet) {
58
58
  provider: 'wallet',
59
59
  };
60
60
  }
61
- // HACK: 适用于 blockelt-server
61
+ // HACK: 适用于 blocklet-server
62
62
  if (window.env) {
63
63
  // eslint-disable-next-line no-param-reassign
64
64
  blocklet = window.env;
@@ -78,7 +78,7 @@ export function getCurrentApp(blocklet = window.blocklet) {
78
78
  return null;
79
79
  }
80
80
 
81
- export function getApps(blocklet) {
81
+ export function getApps(blocklet: Blocklet) {
82
82
  const appList = [];
83
83
 
84
84
  const masterApp = getFederatedApp(blocklet);
@@ -95,7 +95,7 @@ export function getApps(blocklet) {
95
95
  return appList.reverse();
96
96
  }
97
97
 
98
- export async function getBlockletData(appUrl) {
98
+ export async function getBlockletData(appUrl: string) {
99
99
  try {
100
100
  const url = new URL('__blocklet__.js', appUrl);
101
101
  url.searchParams.set('type', 'json');
@@ -2,16 +2,17 @@
2
2
  import padStart from 'lodash/padStart';
3
3
  import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
4
4
  import { DID_PREFIX, WELLKNOWN_SERVICE_PATH_PREFIX } from './constant';
5
+ import type { $TSFixMe } from '../type';
5
6
 
6
- let dateTool = null;
7
+ let dateTool: $TSFixMe | null = null;
7
8
 
8
- export function parseQuery(str) {
9
+ export function parseQuery(str: string) {
9
10
  return str
10
11
  .replace(/^\?/, '')
11
12
  .split('&')
12
13
  .map((x) => x.split('='))
13
14
  .filter(([key]) => !!key)
14
- .reduce((memo, x) => {
15
+ .reduce<Record<string, string | boolean>>((memo, x) => {
15
16
  const key = x[0];
16
17
  const value = decodeURIComponent(x[1]) || true;
17
18
  memo[key] = value;
@@ -23,16 +24,22 @@ export function stringifyQuery(params = {}) {
23
24
  return new URLSearchParams(params).toString();
24
25
  }
25
26
 
26
- /**
27
- * @param {number} opts.expireInDays
28
- * @param {string} opts.path
29
- * @param {domain} opts.domain
30
- * @param {boolean} opts.returnDomain if === false, opts.domain will be skipped
31
- */
32
- export function getCookieOptions(expireInDays = 1) {
33
- let opts = { expireInDays };
34
- if (typeof expireInDays === 'object') {
35
- opts = expireInDays;
27
+ export function getCookieOptions(
28
+ expireInDays:
29
+ | number
30
+ | {
31
+ expireInDays: number;
32
+ path?: string;
33
+ domain?: string;
34
+ returnDomain?: boolean;
35
+ sameSite?: Cookies.CookieAttributes['sameSite'];
36
+ secure?: boolean;
37
+ } = 1
38
+ ) {
39
+ let opts = expireInDays;
40
+
41
+ if (typeof opts === 'number') {
42
+ opts = { expireInDays: opts };
36
43
  }
37
44
 
38
45
  if (opts.path === undefined) {
@@ -43,7 +50,7 @@ export function getCookieOptions(expireInDays = 1) {
43
50
  opts.expireInDays = 1;
44
51
  }
45
52
 
46
- const options = {
53
+ const options: Cookies.CookieAttributes = {
47
54
  expires: opts.expireInDays,
48
55
  path: opts.path,
49
56
  domain: opts.domain || '',
@@ -61,7 +68,7 @@ export function getCookieOptions(expireInDays = 1) {
61
68
  return options;
62
69
  }
63
70
 
64
- export const getColor = (props) => {
71
+ export const getColor = (props: $TSFixMe) => {
65
72
  if (props.color) {
66
73
  return props.color;
67
74
  }
@@ -73,7 +80,7 @@ export const getColor = (props) => {
73
80
  return props.theme.palette.text.primary;
74
81
  };
75
82
 
76
- export const getBackground = (props) => {
83
+ export const getBackground = (props: $TSFixMe) => {
77
84
  if (props.background) {
78
85
  return props.background;
79
86
  }
@@ -85,11 +92,15 @@ export const getBackground = (props) => {
85
92
  return props.theme.palette.common.white;
86
93
  };
87
94
 
88
- export function mergeProps(props, component, jsonAttrs = []) {
95
+ export function mergeProps<P extends object>(
96
+ props: Record<string, any>,
97
+ component: React.ComponentType<P>,
98
+ jsonAttrs: string[] = []
99
+ ) {
89
100
  const newProps = Object.assign({}, props);
90
101
  Object.keys(component.defaultProps || {}).forEach((x) => {
91
102
  if (typeof newProps[x] === 'string' && newProps[x].indexOf('::prop::') === 0) {
92
- newProps[x] = component.defaultProps[x];
103
+ newProps[x] = component.defaultProps![x as keyof P];
93
104
  }
94
105
  });
95
106
 
@@ -133,7 +144,7 @@ export const getTimezone = () => {
133
144
  return '';
134
145
  };
135
146
 
136
- export const str2color = (str) => {
147
+ export const str2color = (str: string) => {
137
148
  let hash = 0;
138
149
  for (let i = 0; i < str.length; i++) {
139
150
  hash = str.charCodeAt(i) + ((hash << 5) - hash);
@@ -146,20 +157,20 @@ export const str2color = (str) => {
146
157
  return colour;
147
158
  };
148
159
 
149
- export const formatUptime = (uptime) => {
160
+ export const formatUptime = (uptime: number) => {
150
161
  const total = Math.round(uptime / 1000);
151
162
  const hours = Math.floor(total / 3600);
152
163
  const minutes = Math.floor((total - hours * 3600) / 60);
153
164
  const seconds = total % 60;
165
+ // @ts-expect-error
154
166
  return `${padStart(hours, 2, '0')}:${padStart(minutes, 2, '0')}:${padStart(seconds, 2, '0')}`;
155
167
  };
156
168
 
157
169
  /**
158
170
  * Set the date tool library which support for format() and locale() functions,
159
171
  * moment and dayjs are recommended.
160
- * @param {object} the date tool library
161
172
  */
162
- export function setDateTool(tool) {
173
+ export function setDateTool(tool: typeof dateTool) {
163
174
  dateTool = tool;
164
175
  }
165
176
 
@@ -168,8 +179,8 @@ export function getDateTool() {
168
179
  }
169
180
 
170
181
  const createDateFormatter =
171
- (format) =>
172
- (date, { locale, tz }) => {
182
+ (format: string) =>
183
+ (date: string, { locale, tz }: { locale?: string; tz?: string } = {}) => {
173
184
  if (dateTool === null) {
174
185
  throw new Error('call setDateTool to set the date tool library, such as: setDateTool(dayjs)');
175
186
  }
@@ -194,30 +205,23 @@ const createDateFormatter =
194
205
  /**
195
206
  * Format the time string as `ll` format: MMM D, YYYY
196
207
  * Ensure that the setDateTool() function is called first to set the time tool library.
197
- * @param {string} date date string
198
- * @param {object} option
199
- * @param {string} option.locale, default: en
200
- * @param {string} option.tz, default: timzone
201
208
  * @returns formatted date string
202
209
  */
203
- export function formatToDate(date, { locale, tz } = {}) {
210
+ export function formatToDate(date: string, { locale = 'en', tz }: { locale?: string; tz?: string } = {}) {
204
211
  return createDateFormatter('ll')(date, { locale, tz });
205
212
  }
206
213
 
207
214
  /**
208
215
  * Format the time string as `lll` format: MMM D, YYYY h:mm A
209
216
  * Ensure that the setDateTool() function is called first to set the time tool library.
210
- * @param {string} date date string
211
- * @param {object} option
212
- * @param {string} option.locale, default: en
213
- * @param {string} option.tz, default: timzone
214
217
  * @returns formatted date string
215
218
  */
216
- export function formatToDatetime(date, { locale, tz } = {}) {
219
+ export function formatToDatetime(date: string, { locale = 'en', tz }: { locale?: string; tz?: string } = {}) {
217
220
  return createDateFormatter('lll')(date, { locale, tz });
218
221
  }
219
222
 
220
223
  export function detectWalletExtension() {
224
+ // @ts-expect-error Property 'ABT_DEV' does not exist on type 'Window & typeof globalThis'.
221
225
  const extension = window?.ABT_DEV || window.ABT;
222
226
  if (extension && typeof extension.open === 'function') {
223
227
  return extension;
@@ -226,7 +230,19 @@ export function detectWalletExtension() {
226
230
  return null;
227
231
  }
228
232
 
229
- export function openWebWallet({ webWalletUrl, action = 'login', locale = 'en', url, windowFeatures }) {
233
+ export function openWebWallet({
234
+ webWalletUrl,
235
+ action = 'login',
236
+ locale = 'en',
237
+ url,
238
+ windowFeatures,
239
+ }: {
240
+ webWalletUrl: string;
241
+ action?: string;
242
+ locale?: string;
243
+ url: string;
244
+ windowFeatures: $TSFixMe;
245
+ }) {
230
246
  // web wallet extension
231
247
  const extension = detectWalletExtension();
232
248
  if (extension) {
@@ -252,7 +268,7 @@ export function openWebWallet({ webWalletUrl, action = 'login', locale = 'en', u
252
268
  };
253
269
  const windowUrl = `${webWalletUrl}?action=${action}&locale=${locale}&url=${encodeURIComponent(url)}`;
254
270
  const mergedWindowFeatures = Object.assign({}, defaultWindowFeatures, windowFeatures);
255
- const getWindowWidth = (win) => {
271
+ const getWindowWidth = (win: Window) => {
256
272
  return win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth;
257
273
  };
258
274
  // 默认在浏览器右上角弹出窗口
@@ -271,7 +287,7 @@ export function openWebWallet({ webWalletUrl, action = 'login', locale = 'en', u
271
287
  window.open(windowUrl, 'targetWindow', strWindowFeatures);
272
288
  }
273
289
 
274
- export const getFontSize = (size) => {
290
+ export const getFontSize = (size: string) => {
275
291
  // 12px 及以上的 size 有效, 否则返回 inherit
276
292
  if (size && Number(size) >= 12) {
277
293
  return `${Number(size)}px`;
@@ -280,7 +296,7 @@ export const getFontSize = (size) => {
280
296
  };
281
297
 
282
298
  // 参考: asset-chain @arcblock/did
283
- export const isEthereumDid = (did) => {
299
+ export const isEthereumDid = (did: string) => {
284
300
  const address = did.replace(DID_PREFIX, '');
285
301
  // check if it has the basic requirements of an address
286
302
  if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
@@ -289,13 +305,15 @@ export const isEthereumDid = (did) => {
289
305
  return true;
290
306
  };
291
307
 
292
- /**
293
- *
294
- * @param {string} url 需要处理的 url
295
- * @param {{imageFilter: 'crop'|'resize'; w?: number; h?: number; r?: 0|90|180|270}} params
296
- * @returns
297
- */
298
- export const appendParams = (url, params) => {
308
+ export const appendParams = (
309
+ url: string,
310
+ params: {
311
+ imageFilter: 'crop' | 'resize';
312
+ w?: number;
313
+ h?: number;
314
+ r?: 0 | 90 | 180 | 270;
315
+ }
316
+ ) => {
299
317
  if (!params) {
300
318
  return url;
301
319
  }
@@ -303,7 +321,7 @@ export const appendParams = (url, params) => {
303
321
  // HACK: 如果 url 中带有域名,则 urlInstance.origin 为 url 中的域名;否则,借用当前页面的 location.origin 作为域名来拼接一个 url
304
322
  const urlInstance = new URL(url, window.location.origin);
305
323
  Object.keys(params).forEach((key) => {
306
- urlInstance.searchParams.set(key, params[key]);
324
+ urlInstance.searchParams.set(key, String(params[key as keyof typeof params]));
307
325
  });
308
326
  // HACK: 如果前后域名一致,代表前面已经借用了 location.origin,这个时候只需要返回 urlInstance.pathname + urlInstance.search 即可
309
327
  if (urlInstance.origin === window.location.origin) {
@@ -315,7 +333,7 @@ export const appendParams = (url, params) => {
315
333
  }
316
334
  };
317
335
 
318
- export const getUserAvatar = (avatar, size = 48) => {
336
+ export const getUserAvatar = (avatar: string, size = 48) => {
319
337
  if (!avatar) {
320
338
  return avatar;
321
339
  }
@@ -332,14 +350,14 @@ export const getUserAvatar = (avatar, size = 48) => {
332
350
  };
333
351
 
334
352
  export const sleep = (time = 0) => {
335
- return new Promise((resolve) => {
353
+ return new Promise<void>((resolve) => {
336
354
  setTimeout(() => {
337
355
  resolve();
338
356
  }, time);
339
357
  });
340
358
  };
341
359
 
342
- export const isUrl = (str) => {
360
+ export const isUrl = (str: string) => {
343
361
  return /^https?:\/\//.test(str);
344
362
  };
345
363
 
@@ -348,7 +366,7 @@ export const getVisitorId = () => {
348
366
  return localStorage.getItem(visitorIdKey);
349
367
  };
350
368
 
351
- export const setVisitorId = (value) => {
369
+ export const setVisitorId = (value: string | null) => {
352
370
  if (value === null) {
353
371
  localStorage.removeItem(visitorIdKey);
354
372
  } else {
@@ -356,13 +374,13 @@ export const setVisitorId = (value) => {
356
374
  }
357
375
  };
358
376
 
359
- export const getDIDColor = (did) => {
377
+ export const getDIDColor = (did: string) => {
360
378
  if (isEthereumDid(did)) {
361
379
  const index =
362
380
  Uint8Array.from(
363
381
  did
364
382
  .slice(2)
365
- .match(/.{1,2}/g)
383
+ .match(/.{1,2}/g)!
366
384
  .map((pair) => parseInt(pair, 16))
367
385
  )
368
386
  .slice(0, 8)
@@ -378,17 +396,25 @@ export const getDIDColor = (did) => {
378
396
  }
379
397
  };
380
398
 
399
+ type NestedTranslation = {
400
+ [key: string]: string | NestedTranslation;
401
+ };
402
+
403
+ type TranslationsObject = {
404
+ [locale: string]: NestedTranslation;
405
+ };
406
+
381
407
  /**
382
408
  * Retrieves the appropriate translation based on the locale, with fallback options.
383
- *
384
- * @param {Object|string} translations - The translations object or string to retrieve translation from.
385
- * @param {string} locale - The locale to use for retrieving the translation.
386
- * @param {Object} options - Additional options for fallbackLocale and defaultValue.
387
- * @param {string} [options.fallbackLocale='en'] - The fallback locale to use if the translation for the specified locale is not found.
388
- * @param {string} [options.defaultValue='unknown'] - The default value to return if no translation is found.
389
409
  * @return {string} The translated string based on the locale, with fallback options if necessary.
390
410
  */
391
- export const getTranslation = (translations, locale, { fallbackLocale = 'en', defaultValue = 'unknown' } = {}) => {
411
+ export const getTranslation = (
412
+ translations: string | TranslationsObject,
413
+ locale: string,
414
+ options: { fallbackLocale?: string; defaultValue?: string } = {}
415
+ ) => {
416
+ const { fallbackLocale = 'en', defaultValue = 'unknown' } = options;
417
+
392
418
  if (typeof translations === 'string') {
393
419
  return translations;
394
420
  }
@@ -1,6 +1,6 @@
1
1
  import { getNftBGColor, DEFAULT_COLORS, getNftBGColorFromDid, getSvg } from '@arcblock/nft-display';
2
2
 
3
- export const getPassportColor = (preferredColor, did) => {
3
+ export const getPassportColor = (preferredColor: string, did: string) => {
4
4
  let color;
5
5
  if (preferredColor === 'default') {
6
6
  color = DEFAULT_COLORS['app-passport'];
@@ -13,7 +13,7 @@ export const getPassportColor = (preferredColor, did) => {
13
13
  return color;
14
14
  };
15
15
 
16
- export const getTextColor = (background) => {
16
+ export const getTextColor = (background: string) => {
17
17
  const r = parseInt(background.slice(1, 3), 16);
18
18
  const g = parseInt(background.slice(3, 5), 16);
19
19
  const b = parseInt(background.slice(5, 7), 16);
@@ -23,7 +23,7 @@ export const getWebWalletUrl = () => {
23
23
  };
24
24
 
25
25
  // 检查 wallet url protocol 和当前页面地址的 protocol 是否一致
26
- export const checkSameProtocol = (webWalletUrl) => {
26
+ export const checkSameProtocol = (webWalletUrl: string) => {
27
27
  const { protocol } = window.location;
28
28
  let walletProtocol = '';
29
29
  try {
@@ -3,9 +3,9 @@ import PropTypes from 'prop-types';
3
3
  import useIdle from 'react-use/lib/useIdle';
4
4
  import { useLocalStorageState } from 'ahooks';
5
5
  import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
6
- import { detectWalletExtension } from '@arcblock/ux/lib/Util';
7
6
 
8
7
  import { getWebWalletUrl, checkSameProtocol } from '../Util/wallet';
8
+ import { detectWalletExtension } from '../Util';
9
9
 
10
10
  // 默认最大空闲时间: 30min
11
11
  const DEFAULT_MAX_IDLE_TIME = 1000 * 60 * 30;
@@ -0,0 +1,13 @@
1
+ declare module '@arcblock/did-motif';
2
+
3
+ type Blocklet = import('./type').Blocklet;
4
+
5
+ interface Window {
6
+ blocklet?: Blocklet;
7
+ env?: Blocklet;
8
+ }
9
+
10
+ declare module globalThis {
11
+ var blocklet: Blocklet;
12
+ var env: Blocklet;
13
+ }
@@ -24,9 +24,9 @@ import DidLogo from './DidLogo';
24
24
  import Tabs from './Tabs';
25
25
  import Tag from './Tag';
26
26
  import TextCollapse from './TextCollapse';
27
- import Theme from './Theme';
27
+ import * as Theme from './Theme';
28
28
  import Toast from './Toast';
29
- import Util from './Util';
29
+ import * as Util from './Util';
30
30
  import Video from './Video';
31
31
  import WebWalletSWKeeper from './WebWalletSWKeeper';
32
32
  import WalletAction from './Wallet/Action';
package/src/type.d.ts CHANGED
@@ -1 +1,31 @@
1
- declare module '@arcblock/did-motif';
1
+ export type $TSFixMe = any;
2
+
3
+ export type Blocklet = {
4
+ appId: string;
5
+ appIds: string[];
6
+ appPid: string;
7
+ appName: string;
8
+ appDescription: string;
9
+ appLogo: string;
10
+ appLogoRect: string;
11
+ appUrl: string;
12
+ isComponent: boolean;
13
+ prefix: string;
14
+ groupPrefix: string;
15
+ pageGroup: string;
16
+ version: string;
17
+ mode: string;
18
+ tenantMode: 'single' | 'multiple';
19
+ theme: TTheme;
20
+ navigation: TNavigation[];
21
+ preferences: Record<string, any>;
22
+ languages: {
23
+ code: string;
24
+ name: string;
25
+ }[];
26
+ passportColor: string;
27
+ componentMountPoints: TComponent[];
28
+ alsoKnownAs: string[];
29
+ trustedFactories: string[];
30
+ [x: string]: any;
31
+ };
@@ -1,41 +0,0 @@
1
- import PropTypes from 'prop-types';
2
-
3
- import { styled } from '../Theme';
4
-
5
- /**
6
- * @param {Object} props 属性
7
- * @param {*} props.children 子元素
8
- * @param {'screen'|'parent'} [props.relative='screen'] 容器相对尺寸,默认相对屏幕(screen),可设置为父容器(parent)
9
- * @returns react component element
10
- */
11
- export default function Center({ children, relative }) {
12
- let style = {};
13
-
14
- if (relative === 'parent') {
15
- style = {
16
- width: '100%',
17
- height: '100%',
18
- };
19
- }
20
-
21
- return <Div style={style}>{children}</Div>;
22
- }
23
-
24
- const Div = styled('div')`
25
- flex: 1;
26
- width: 100vw;
27
- height: 100vh;
28
-
29
- display: flex;
30
- justify-content: center;
31
- align-items: center;
32
- `;
33
-
34
- Center.propTypes = {
35
- children: PropTypes.any.isRequired,
36
- relative: PropTypes.string,
37
- };
38
-
39
- Center.defaultProps = {
40
- relative: 'screen',
41
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes