@arcblock/ux 2.10.64 → 2.10.66
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.
- package/lib/ActionButton/index.d.ts +1 -1
- package/lib/Alert/index.d.ts +1 -1
- package/lib/AnimationWaiter/index.d.ts +27 -15
- package/lib/AnimationWaiter/index.js +15 -14
- package/lib/Async/index.d.ts +50 -17
- package/lib/Badge/index.d.ts +1 -1
- package/lib/Badge/index.js +7 -1
- package/lib/BlockletContext/index.d.ts +12 -28
- package/lib/BlockletContext/index.js +3 -21
- package/lib/Button/wrap.d.ts +5 -3
- package/lib/Button/wrap.js +2 -1
- package/lib/ButtonGroup/index.d.ts +12 -2
- package/lib/ButtonGroup/index.js +13 -3
- package/lib/CardSelector/index.d.ts +11 -33
- package/lib/CardSelector/index.js +16 -32
- package/lib/Center/index.d.ts +6 -21
- package/lib/Center/index.js +2 -17
- package/lib/ClickToCopy/copy-button.d.ts +9 -26
- package/lib/ClickToCopy/copy-button.js +5 -17
- package/lib/ClickToCopy/hook.d.ts +11 -5
- package/lib/ClickToCopy/hook.js +3 -3
- package/lib/ClickToCopy/index.d.ts +18 -29
- package/lib/ClickToCopy/index.js +0 -13
- package/lib/CodeBlock/LightBox.d.ts +1 -1
- package/lib/CodeBlock/index.d.ts +7 -26
- package/lib/CodeBlock/index.js +4 -17
- package/lib/Colors/index.d.ts +2 -2
- package/lib/Colors/themes/default.d.ts +54 -61
- package/lib/Colors/themes/temp.d.ts +35 -35
- package/lib/ContactForm/index.d.ts +26 -30
- package/lib/ContactForm/index.js +7 -17
- package/lib/Dialog/confirm.d.ts +3 -3
- package/lib/Dialog/confirm.js +2 -2
- package/lib/Earth/index.d.ts +10 -1
- package/lib/Header/auto-hidden.d.ts +6 -11
- package/lib/Header/auto-hidden.js +0 -5
- package/lib/Header/header.d.ts +20 -51
- package/lib/Header/header.js +10 -42
- package/lib/Header/index.d.ts +2 -2
- package/lib/Header/responsive-header.d.ts +10 -22
- package/lib/Header/responsive-header.js +1 -13
- package/lib/Icon/image.d.ts +8 -36
- package/lib/Icon/image.js +6 -24
- package/lib/Icon/index.d.ts +9 -1
- package/lib/Icon/index.js +6 -25
- package/lib/NavMenu/index.d.ts +1 -1
- package/lib/NavMenu/nav-menu.d.ts +37 -51
- package/lib/NavMenu/nav-menu.js +47 -102
- package/lib/NavMenu/style.d.ts +8 -2
- package/lib/NavMenu/style.js +3 -1
- package/lib/PageScroller/index.d.ts +13 -1
- package/lib/Passport/passport.js +1 -1
- package/lib/PricingTable/index.d.ts +3 -1
- package/lib/RelativeTime/index.d.ts +1 -1
- package/lib/Screenshot/BaseScreenshot/index.js +1 -1
- package/lib/SplitButton/index.d.ts +0 -19
- package/lib/SplitButton/index.js +7 -27
- package/lib/TextCollapse/index.d.ts +10 -1
- package/lib/Theme/index.d.ts +5 -13
- package/lib/Theme/index.js +4 -11
- package/lib/Theme/theme-provider.d.ts +16 -18
- package/lib/Theme/theme.d.ts +37 -11
- package/lib/Theme/theme.js +13 -22
- package/lib/Util/constant.d.ts +31 -31
- package/lib/Util/deprecate.d.ts +7 -5
- package/lib/Util/federated.d.ts +21 -21
- package/lib/Util/federated.js +1 -1
- package/lib/Util/index.d.ts +59 -60
- package/lib/Util/index.js +16 -43
- package/lib/Util/passport.d.ts +6 -6
- package/lib/Util/wallet.d.ts +15 -3
- package/lib/WebWalletSWKeeper/index.js +1 -1
- package/lib/global.d.ts +13 -0
- package/lib/index.d.ts +4 -2
- package/lib/index.js +2 -2
- package/lib/type.d.ts +31 -1
- package/package.json +5 -5
- package/src/AnimationWaiter/index.jsx +15 -14
- package/src/Async/{index.jsx → index.tsx} +13 -4
- package/src/Badge/index.jsx +8 -1
- package/src/BlockletContext/{index.jsx → index.tsx} +17 -22
- package/src/Button/wrap.jsx +2 -1
- package/src/ButtonGroup/index.js +13 -3
- package/src/CardSelector/{index.jsx → index.tsx} +32 -33
- package/src/Center/index.tsx +33 -0
- package/src/ClickToCopy/{copy-button.jsx → copy-button.tsx} +15 -16
- package/src/ClickToCopy/{hook.js → hook.ts} +5 -5
- package/src/ClickToCopy/{index.jsx → index.tsx} +12 -17
- package/src/CodeBlock/{index.jsx → index.tsx} +15 -17
- package/src/ContactForm/{index.jsx → index.tsx} +47 -29
- package/src/Dialog/confirm.jsx +2 -2
- package/src/Header/{auto-hidden.jsx → auto-hidden.tsx} +6 -7
- package/src/Header/{header.jsx → header.tsx} +32 -46
- package/src/Header/{responsive-header.jsx → responsive-header.tsx} +9 -15
- package/src/Icon/{image.jsx → image.tsx} +19 -22
- package/src/Icon/{index.jsx → index.tsx} +22 -24
- package/src/NavMenu/{nav-menu.jsx → nav-menu.tsx} +161 -144
- package/src/NavMenu/{style.js → style.ts} +9 -1
- package/src/Passport/passport.jsx +1 -1
- package/src/Screenshot/BaseScreenshot/index.jsx +1 -1
- package/src/SplitButton/index.tsx +10 -23
- package/src/Theme/{index.js → index.ts} +6 -12
- package/src/Theme/{theme-provider.jsx → theme-provider.tsx} +10 -2
- package/src/Theme/{theme.js → theme.ts} +54 -23
- package/src/Util/{deprecate.jsx → deprecate.tsx} +8 -4
- package/src/Util/{federated.js → federated.ts} +3 -3
- package/src/Util/{index.js → index.ts} +85 -59
- package/src/Util/{passport.js → passport.ts} +2 -2
- package/src/Util/{wallet.js → wallet.ts} +1 -1
- package/src/WebWalletSWKeeper/index.jsx +1 -1
- package/src/global.d.ts +13 -0
- package/src/{index.js → index.ts} +2 -2
- package/src/type.d.ts +31 -1
- package/src/Center/index.jsx +0 -41
- /package/src/CodeBlock/{LightBox.jsx → LightBox.tsx} +0 -0
- /package/src/Colors/{index.js → index.ts} +0 -0
- /package/src/Colors/themes/{default.js → default.ts} +0 -0
- /package/src/Colors/themes/{temp.js → temp.ts} +0 -0
- /package/src/Header/{index.js → index.ts} +0 -0
- /package/src/NavMenu/{index.js → index.ts} +0 -0
- /package/src/Util/{constant.js → constant.ts} +0 -0
package/lib/Util/constant.d.ts
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
export const DEFAULT_TIMEOUT: number;
|
2
|
-
export const DEFAULT_WINDOW_TIMEOUT: number;
|
3
|
-
export const WELLKNOWN_SERVICE_PATH_PREFIX
|
4
|
-
export const AUTH_SERVICE_PREFIX
|
5
|
-
export const SESSION_TOKEN_STORAGE_KEY
|
6
|
-
export const REFRESH_TOKEN_STORAGE_KEY
|
7
|
-
export const RELAY_SOCKET_PREFIX
|
8
|
-
export const API_DID_PREFIX
|
9
|
-
export const DASHBOARD_URL
|
10
|
-
export const PROFILE_URL
|
11
|
-
export const NAVIGATION_URL
|
12
|
-
export const DID_PREFIX
|
13
|
-
export
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
export
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
25
|
-
export const LOGIN_PROVIDER_NAME: {
|
1
|
+
export declare const DEFAULT_TIMEOUT: number;
|
2
|
+
export declare const DEFAULT_WINDOW_TIMEOUT: number;
|
3
|
+
export declare const WELLKNOWN_SERVICE_PATH_PREFIX = "/.well-known/service";
|
4
|
+
export declare const AUTH_SERVICE_PREFIX = "/.well-known/service";
|
5
|
+
export declare const SESSION_TOKEN_STORAGE_KEY = "login_token";
|
6
|
+
export declare const REFRESH_TOKEN_STORAGE_KEY = "refresh_token";
|
7
|
+
export declare const RELAY_SOCKET_PREFIX = "/.well-known/service";
|
8
|
+
export declare const API_DID_PREFIX = "/api/did";
|
9
|
+
export declare const DASHBOARD_URL = "/.well-known/service/admin";
|
10
|
+
export declare const PROFILE_URL = "/.well-known/service/user";
|
11
|
+
export declare const NAVIGATION_URL = "/.well-known/service/admin/navigation";
|
12
|
+
export declare const DID_PREFIX = "did:abt:";
|
13
|
+
export declare const PASSPORT_STATUS: {
|
14
|
+
VALID: string;
|
15
|
+
REVOKED: string;
|
16
|
+
};
|
17
|
+
export declare const LOGIN_PROVIDER: {
|
18
|
+
AUTH0: string;
|
19
|
+
APPLE: string;
|
20
|
+
GITHUB: string;
|
21
|
+
GOOGLE: string;
|
22
|
+
WALLET: string;
|
23
|
+
NFT: string;
|
24
|
+
};
|
25
|
+
export declare const LOGIN_PROVIDER_NAME: {
|
26
26
|
[x: string]: string;
|
27
27
|
};
|
28
|
-
export
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
}
|
28
|
+
export declare const OAUTH_PROVIDER: {
|
29
|
+
auth0: string;
|
30
|
+
apple: string;
|
31
|
+
github: string;
|
32
|
+
google: string;
|
33
|
+
};
|
package/lib/Util/deprecate.d.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
import { ComponentType } from 'react';
|
2
|
+
declare const warn: (name: string, alternative?: string) => void;
|
3
|
+
declare const withDeprecated: <P extends object>(Component: ComponentType<P>, { name, alternative }: {
|
4
|
+
name: string;
|
5
|
+
alternative?: string;
|
6
|
+
}) => (props: P) => import("react/jsx-runtime").JSX.Element;
|
7
|
+
export { warn, withDeprecated };
|
package/lib/Util/federated.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
export function getMaster(blocklet?:
|
2
|
-
export function getConfig(blocklet?:
|
3
|
-
export function getFederatedEnabled(blocklet?:
|
4
|
-
export function getSourceAppPid(blocklet?:
|
5
|
-
export function getFederatedApp(blocklet?:
|
1
|
+
export declare function getMaster(blocklet?: import("../type").Blocklet): any;
|
2
|
+
export declare function getConfig(blocklet?: import("../type").Blocklet): any;
|
3
|
+
export declare function getFederatedEnabled(blocklet?: import("../type").Blocklet): boolean;
|
4
|
+
export declare function getSourceAppPid(blocklet?: import("../type").Blocklet): any;
|
5
|
+
export declare function getFederatedApp(blocklet?: import("../type").Blocklet): {
|
6
6
|
appId: any;
|
7
7
|
appName: any;
|
8
8
|
appDescription: any;
|
@@ -13,22 +13,22 @@ export function getFederatedApp(blocklet?: any): {
|
|
13
13
|
sourceAppPid: any;
|
14
14
|
provider: string;
|
15
15
|
} | null;
|
16
|
-
export function getCurrentApp(blocklet?:
|
17
|
-
appId:
|
18
|
-
appName:
|
19
|
-
appDescription:
|
20
|
-
appLogo:
|
21
|
-
appPid:
|
22
|
-
appUrl:
|
16
|
+
export declare function getCurrentApp(blocklet?: import("../type").Blocklet): {
|
17
|
+
appId: string;
|
18
|
+
appName: string;
|
19
|
+
appDescription: string;
|
20
|
+
appLogo: string;
|
21
|
+
appPid: string;
|
22
|
+
appUrl: string;
|
23
23
|
currentAppUrl: string | undefined;
|
24
|
-
version:
|
24
|
+
version: string;
|
25
25
|
sourceAppPid: null;
|
26
26
|
provider: string;
|
27
27
|
type?: undefined;
|
28
28
|
} | {
|
29
|
-
appId:
|
30
|
-
appName:
|
31
|
-
appDescription:
|
29
|
+
appId: string;
|
30
|
+
appName: string;
|
31
|
+
appDescription: string;
|
32
32
|
appUrl: any;
|
33
33
|
currentAppUrl: string;
|
34
34
|
sourceAppPid: null;
|
@@ -38,7 +38,7 @@ export function getCurrentApp(blocklet?: any): {
|
|
38
38
|
appPid?: undefined;
|
39
39
|
version?: undefined;
|
40
40
|
} | null;
|
41
|
-
export function getApps(blocklet:
|
41
|
+
export declare function getApps(blocklet: Blocklet): ({
|
42
42
|
appId: any;
|
43
43
|
appName: any;
|
44
44
|
appDescription: any;
|
@@ -49,9 +49,9 @@ export function getApps(blocklet: any): ({
|
|
49
49
|
sourceAppPid: any;
|
50
50
|
provider: string;
|
51
51
|
} | {
|
52
|
-
appId:
|
53
|
-
appName:
|
54
|
-
appDescription:
|
52
|
+
appId: string;
|
53
|
+
appName: string;
|
54
|
+
appDescription: string;
|
55
55
|
appUrl: any;
|
56
56
|
currentAppUrl: string;
|
57
57
|
sourceAppPid: null;
|
@@ -61,4 +61,4 @@ export function getApps(blocklet: any): ({
|
|
61
61
|
appPid?: undefined;
|
62
62
|
version?: undefined;
|
63
63
|
})[];
|
64
|
-
export function getBlockletData(appUrl:
|
64
|
+
export declare function getBlockletData(appUrl: string): Promise<any>;
|
package/lib/Util/federated.js
CHANGED
package/lib/Util/index.d.ts
CHANGED
@@ -1,81 +1,80 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
export function
|
17
|
-
export
|
1
|
+
import type { $TSFixMe } from '../type';
|
2
|
+
declare let dateTool: $TSFixMe | null;
|
3
|
+
export declare function parseQuery(str: string): Record<string, string | boolean>;
|
4
|
+
export declare function stringifyQuery(params?: {}): string;
|
5
|
+
export declare function getCookieOptions(expireInDays?: number | {
|
6
|
+
expireInDays: number;
|
7
|
+
path?: string;
|
8
|
+
domain?: string;
|
9
|
+
returnDomain?: boolean;
|
10
|
+
sameSite?: Cookies.CookieAttributes['sameSite'];
|
11
|
+
secure?: boolean;
|
12
|
+
}): import("js-cookie").CookieAttributes;
|
13
|
+
export declare const getColor: (props: $TSFixMe) => any;
|
14
|
+
export declare const getBackground: (props: $TSFixMe) => any;
|
15
|
+
export declare function mergeProps<P extends object>(props: Record<string, any>, component: React.ComponentType<P>, jsonAttrs?: string[]): Record<string, any>;
|
16
|
+
export declare function getCopyright(startYear?: number): string;
|
17
|
+
export declare const getTimezone: () => string;
|
18
|
+
export declare const str2color: (str: string) => string;
|
19
|
+
export declare const formatUptime: (uptime: number) => string;
|
18
20
|
/**
|
19
21
|
* Set the date tool library which support for format() and locale() functions,
|
20
22
|
* moment and dayjs are recommended.
|
21
|
-
* @param {object} the date tool library
|
22
23
|
*/
|
23
|
-
export function setDateTool(tool:
|
24
|
-
export function getDateTool(): any;
|
24
|
+
export declare function setDateTool(tool: typeof dateTool): void;
|
25
|
+
export declare function getDateTool(): any;
|
25
26
|
/**
|
26
27
|
* Format the time string as `ll` format: MMM D, YYYY
|
27
28
|
* Ensure that the setDateTool() function is called first to set the time tool library.
|
28
|
-
* @param {string} date date string
|
29
|
-
* @param {object} option
|
30
|
-
* @param {string} option.locale, default: en
|
31
|
-
* @param {string} option.tz, default: timzone
|
32
29
|
* @returns formatted date string
|
33
30
|
*/
|
34
|
-
export function formatToDate(date: string, { locale, tz }?: {
|
35
|
-
locale
|
36
|
-
tz
|
31
|
+
export declare function formatToDate(date: string, { locale, tz }?: {
|
32
|
+
locale?: string;
|
33
|
+
tz?: string;
|
37
34
|
}): any;
|
38
35
|
/**
|
39
36
|
* Format the time string as `lll` format: MMM D, YYYY h:mm A
|
40
37
|
* Ensure that the setDateTool() function is called first to set the time tool library.
|
41
|
-
* @param {string} date date string
|
42
|
-
* @param {object} option
|
43
|
-
* @param {string} option.locale, default: en
|
44
|
-
* @param {string} option.tz, default: timzone
|
45
38
|
* @returns formatted date string
|
46
39
|
*/
|
47
|
-
export function formatToDatetime(date: string, { locale, tz }?: {
|
48
|
-
locale
|
49
|
-
tz
|
40
|
+
export declare function formatToDatetime(date: string, { locale, tz }?: {
|
41
|
+
locale?: string;
|
42
|
+
tz?: string;
|
50
43
|
}): any;
|
51
|
-
export function detectWalletExtension(): any;
|
52
|
-
export function openWebWallet({ webWalletUrl, action, locale, url, windowFeatures }: {
|
53
|
-
webWalletUrl:
|
54
|
-
action?: string
|
55
|
-
locale?: string
|
56
|
-
url:
|
57
|
-
windowFeatures:
|
44
|
+
export declare function detectWalletExtension(): any;
|
45
|
+
export declare function openWebWallet({ webWalletUrl, action, locale, url, windowFeatures, }: {
|
46
|
+
webWalletUrl: string;
|
47
|
+
action?: string;
|
48
|
+
locale?: string;
|
49
|
+
url: string;
|
50
|
+
windowFeatures: $TSFixMe;
|
58
51
|
}): void;
|
59
|
-
export
|
60
|
-
export
|
61
|
-
export
|
62
|
-
export function str2color(str: any): string;
|
63
|
-
export function formatUptime(uptime: any): string;
|
64
|
-
export function getFontSize(size: any): string;
|
65
|
-
export function isEthereumDid(did: any): boolean;
|
66
|
-
export function appendParams(url: string, params: {
|
52
|
+
export declare const getFontSize: (size: string) => string;
|
53
|
+
export declare const isEthereumDid: (did: string) => boolean;
|
54
|
+
export declare const appendParams: (url: string, params: {
|
67
55
|
imageFilter: "crop" | "resize";
|
68
56
|
w?: number;
|
69
57
|
h?: number;
|
70
58
|
r?: 0 | 90 | 180 | 270;
|
71
|
-
})
|
72
|
-
export
|
73
|
-
export
|
74
|
-
export
|
75
|
-
export
|
76
|
-
export
|
77
|
-
export
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
59
|
+
}) => string;
|
60
|
+
export declare const getUserAvatar: (avatar: string, size?: number) => string;
|
61
|
+
export declare const sleep: (time?: number) => Promise<void>;
|
62
|
+
export declare const isUrl: (str: string) => boolean;
|
63
|
+
export declare const getVisitorId: () => string | null;
|
64
|
+
export declare const setVisitorId: (value: string | null) => void;
|
65
|
+
export declare const getDIDColor: (did: string) => any;
|
66
|
+
type NestedTranslation = {
|
67
|
+
[key: string]: string | NestedTranslation;
|
68
|
+
};
|
69
|
+
type TranslationsObject = {
|
70
|
+
[locale: string]: NestedTranslation;
|
71
|
+
};
|
72
|
+
/**
|
73
|
+
* Retrieves the appropriate translation based on the locale, with fallback options.
|
74
|
+
* @return {string} The translated string based on the locale, with fallback options if necessary.
|
75
|
+
*/
|
76
|
+
export declare const getTranslation: (translations: string | TranslationsObject, locale: string, options?: {
|
77
|
+
fallbackLocale?: string;
|
78
|
+
defaultValue?: string;
|
79
|
+
}) => string;
|
80
|
+
export {};
|
package/lib/Util/index.js
CHANGED
@@ -14,19 +14,12 @@ export function parseQuery(str) {
|
|
14
14
|
export function stringifyQuery(params = {}) {
|
15
15
|
return new URLSearchParams(params).toString();
|
16
16
|
}
|
17
|
-
|
18
|
-
/**
|
19
|
-
* @param {number} opts.expireInDays
|
20
|
-
* @param {string} opts.path
|
21
|
-
* @param {domain} opts.domain
|
22
|
-
* @param {boolean} opts.returnDomain if === false, opts.domain will be skipped
|
23
|
-
*/
|
24
17
|
export function getCookieOptions(expireInDays = 1) {
|
25
|
-
let opts =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
let opts = expireInDays;
|
19
|
+
if (typeof opts === 'number') {
|
20
|
+
opts = {
|
21
|
+
expireInDays: opts
|
22
|
+
};
|
30
23
|
}
|
31
24
|
if (opts.path === undefined) {
|
32
25
|
opts.path = '/';
|
@@ -120,13 +113,13 @@ export const formatUptime = uptime => {
|
|
120
113
|
const hours = Math.floor(total / 3600);
|
121
114
|
const minutes = Math.floor((total - hours * 3600) / 60);
|
122
115
|
const seconds = total % 60;
|
116
|
+
// @ts-expect-error
|
123
117
|
return `${padStart(hours, 2, '0')}:${padStart(minutes, 2, '0')}:${padStart(seconds, 2, '0')}`;
|
124
118
|
};
|
125
119
|
|
126
120
|
/**
|
127
121
|
* Set the date tool library which support for format() and locale() functions,
|
128
122
|
* moment and dayjs are recommended.
|
129
|
-
* @param {object} the date tool library
|
130
123
|
*/
|
131
124
|
export function setDateTool(tool) {
|
132
125
|
dateTool = tool;
|
@@ -137,7 +130,7 @@ export function getDateTool() {
|
|
137
130
|
const createDateFormatter = format => (date, {
|
138
131
|
locale,
|
139
132
|
tz
|
140
|
-
}) => {
|
133
|
+
} = {}) => {
|
141
134
|
if (dateTool === null) {
|
142
135
|
throw new Error('call setDateTool to set the date tool library, such as: setDateTool(dayjs)');
|
143
136
|
}
|
@@ -157,14 +150,10 @@ const createDateFormatter = format => (date, {
|
|
157
150
|
/**
|
158
151
|
* Format the time string as `ll` format: MMM D, YYYY
|
159
152
|
* Ensure that the setDateTool() function is called first to set the time tool library.
|
160
|
-
* @param {string} date date string
|
161
|
-
* @param {object} option
|
162
|
-
* @param {string} option.locale, default: en
|
163
|
-
* @param {string} option.tz, default: timzone
|
164
153
|
* @returns formatted date string
|
165
154
|
*/
|
166
155
|
export function formatToDate(date, {
|
167
|
-
locale,
|
156
|
+
locale = 'en',
|
168
157
|
tz
|
169
158
|
} = {}) {
|
170
159
|
return createDateFormatter('ll')(date, {
|
@@ -176,14 +165,10 @@ export function formatToDate(date, {
|
|
176
165
|
/**
|
177
166
|
* Format the time string as `lll` format: MMM D, YYYY h:mm A
|
178
167
|
* Ensure that the setDateTool() function is called first to set the time tool library.
|
179
|
-
* @param {string} date date string
|
180
|
-
* @param {object} option
|
181
|
-
* @param {string} option.locale, default: en
|
182
|
-
* @param {string} option.tz, default: timzone
|
183
168
|
* @returns formatted date string
|
184
169
|
*/
|
185
170
|
export function formatToDatetime(date, {
|
186
|
-
locale,
|
171
|
+
locale = 'en',
|
187
172
|
tz
|
188
173
|
} = {}) {
|
189
174
|
return createDateFormatter('lll')(date, {
|
@@ -192,6 +177,7 @@ export function formatToDatetime(date, {
|
|
192
177
|
});
|
193
178
|
}
|
194
179
|
export function detectWalletExtension() {
|
180
|
+
// @ts-expect-error Property 'ABT_DEV' does not exist on type 'Window & typeof globalThis'.
|
195
181
|
const extension = window?.ABT_DEV || window.ABT;
|
196
182
|
if (extension && typeof extension.open === 'function') {
|
197
183
|
return extension;
|
@@ -261,13 +247,6 @@ export const isEthereumDid = did => {
|
|
261
247
|
}
|
262
248
|
return true;
|
263
249
|
};
|
264
|
-
|
265
|
-
/**
|
266
|
-
*
|
267
|
-
* @param {string} url 需要处理的 url
|
268
|
-
* @param {{imageFilter: 'crop'|'resize'; w?: number; h?: number; r?: 0|90|180|270}} params
|
269
|
-
* @returns
|
270
|
-
*/
|
271
250
|
export const appendParams = (url, params) => {
|
272
251
|
if (!params) {
|
273
252
|
return url;
|
@@ -276,7 +255,7 @@ export const appendParams = (url, params) => {
|
|
276
255
|
// HACK: 如果 url 中带有域名,则 urlInstance.origin 为 url 中的域名;否则,借用当前页面的 location.origin 作为域名来拼接一个 url
|
277
256
|
const urlInstance = new URL(url, window.location.origin);
|
278
257
|
Object.keys(params).forEach(key => {
|
279
|
-
urlInstance.searchParams.set(key, params[key]);
|
258
|
+
urlInstance.searchParams.set(key, String(params[key]));
|
280
259
|
});
|
281
260
|
// HACK: 如果前后域名一致,代表前面已经借用了 location.origin,这个时候只需要返回 urlInstance.pathname + urlInstance.search 即可
|
282
261
|
if (urlInstance.origin === window.location.origin) {
|
@@ -333,21 +312,15 @@ export const getDIDColor = did => {
|
|
333
312
|
return null;
|
334
313
|
}
|
335
314
|
};
|
336
|
-
|
337
315
|
/**
|
338
316
|
* Retrieves the appropriate translation based on the locale, with fallback options.
|
339
|
-
*
|
340
|
-
* @param {Object|string} translations - The translations object or string to retrieve translation from.
|
341
|
-
* @param {string} locale - The locale to use for retrieving the translation.
|
342
|
-
* @param {Object} options - Additional options for fallbackLocale and defaultValue.
|
343
|
-
* @param {string} [options.fallbackLocale='en'] - The fallback locale to use if the translation for the specified locale is not found.
|
344
|
-
* @param {string} [options.defaultValue='unknown'] - The default value to return if no translation is found.
|
345
317
|
* @return {string} The translated string based on the locale, with fallback options if necessary.
|
346
318
|
*/
|
347
|
-
export const getTranslation = (translations, locale, {
|
348
|
-
|
349
|
-
|
350
|
-
|
319
|
+
export const getTranslation = (translations, locale, options = {}) => {
|
320
|
+
const {
|
321
|
+
fallbackLocale = 'en',
|
322
|
+
defaultValue = 'unknown'
|
323
|
+
} = options;
|
351
324
|
if (typeof translations === 'string') {
|
352
325
|
return translations;
|
353
326
|
}
|
package/lib/Util/passport.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
export
|
1
|
+
export declare const getPassportColor: (preferredColor: string, did: string) => {
|
2
2
|
start: string;
|
3
3
|
end: string;
|
4
4
|
};
|
5
|
-
export
|
6
|
-
export
|
5
|
+
export declare const getTextColor: (background: string) => "#111" | "#EEE";
|
6
|
+
export declare const createPassportSvg: ({ issuer, title, issuerDid, issuerAvatarUrl, ownerDid, ownerAvatarUrl, preferredColor, revoked, isDataUrl, width, height, }: {
|
7
7
|
issuer?: string | undefined;
|
8
8
|
title?: string | undefined;
|
9
9
|
issuerDid?: string | undefined;
|
@@ -15,8 +15,8 @@ export function createPassportSvg({ issuer, title, issuerDid, issuerAvatarUrl, o
|
|
15
15
|
isDataUrl?: boolean | undefined;
|
16
16
|
width?: string | undefined;
|
17
17
|
height?: string | undefined;
|
18
|
-
})
|
19
|
-
export
|
18
|
+
}) => string;
|
19
|
+
export declare const createKycSvg: ({ issuer, title, issuerDid, issuerAvatarUrl, ownerDid, ownerName, ownerAvatarUrl, preferredColor, type, revoked, isDataUrl, width, height, }: {
|
20
20
|
issuer?: string | undefined;
|
21
21
|
title?: string | undefined;
|
22
22
|
issuerDid?: string | undefined;
|
@@ -30,4 +30,4 @@ export function createKycSvg({ issuer, title, issuerDid, issuerAvatarUrl, ownerD
|
|
30
30
|
isDataUrl?: boolean | undefined;
|
31
31
|
width?: string | undefined;
|
32
32
|
height?: string | undefined;
|
33
|
-
})
|
33
|
+
}) => string;
|
package/lib/Util/wallet.d.ts
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
-
export const providerName
|
2
|
-
|
3
|
-
|
1
|
+
export declare const providerName = "wallet_url";
|
2
|
+
/**
|
3
|
+
* 获取 web wallet url, 常用于为 did connect 组件传递 webWalletUrl 参数,
|
4
|
+
* 更明确的说, 这里获取的应该是 **default web wallet url**,
|
5
|
+
* 如果用户使用自定义的 web wallet url, 不应该使用该方法, 应该显式的将自定义的 web wallet url 传递给 did connect 组件
|
6
|
+
* (参考: https://github.com/blocklet/ocap-playground/issues/98)
|
7
|
+
*
|
8
|
+
* 获取优先级:
|
9
|
+
* - localStorage 使用 provider 注册
|
10
|
+
* - window.env.webWalletUrl
|
11
|
+
* - window.blocklet.webWalletUrl
|
12
|
+
* - production web wallet url
|
13
|
+
*/
|
14
|
+
export declare const getWebWalletUrl: () => any;
|
15
|
+
export declare const checkSameProtocol: (webWalletUrl: string) => boolean;
|
@@ -4,8 +4,8 @@ import PropTypes from 'prop-types';
|
|
4
4
|
import useIdle from 'react-use/lib/useIdle';
|
5
5
|
import { useLocalStorageState } from 'ahooks';
|
6
6
|
import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
|
7
|
-
import { detectWalletExtension } from '@arcblock/ux/lib/Util';
|
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;
|
package/lib/global.d.ts
ADDED
package/lib/index.d.ts
CHANGED
@@ -16,15 +16,17 @@ import Footer from './Footer';
|
|
16
16
|
import Icon from './Icon';
|
17
17
|
import LocaleSelector from './Locale/selector';
|
18
18
|
import Logo from './Logo';
|
19
|
-
import Tabs from './Tabs';
|
20
19
|
import RelativeTime from './RelativeTime';
|
21
20
|
import SessionManager from './SessionManager';
|
22
21
|
import Datatable from './Datatable';
|
23
22
|
import Dialog from './Dialog';
|
24
23
|
import DidLogo from './DidLogo';
|
24
|
+
import Tabs from './Tabs';
|
25
25
|
import Tag from './Tag';
|
26
26
|
import TextCollapse from './TextCollapse';
|
27
|
+
import * as Theme from './Theme';
|
27
28
|
import Toast from './Toast';
|
29
|
+
import * as Util from './Util';
|
28
30
|
import Video from './Video';
|
29
31
|
import WebWalletSWKeeper from './WebWalletSWKeeper';
|
30
32
|
import WalletAction from './Wallet/Action';
|
@@ -33,4 +35,4 @@ import WechatPrompt from './WechatPrompt';
|
|
33
35
|
import withTheme from './withTheme';
|
34
36
|
import withTracker from './withTracker';
|
35
37
|
import Img from './Img';
|
36
|
-
export { ActionButton, ActivityIndicator, Address, Alert, AnimationWaiter, Async, Avatar, Badge, Button, ClickToCopy, CodeBlock, ContactForm, CountDown, Earth, Footer, Icon, LocaleSelector, Logo, Tabs, RelativeTime, SessionManager, Datatable, Dialog, DidLogo, Tag, TextCollapse, Theme, Toast, Util, Video, WebWalletSWKeeper, WalletAction, WalletDownload, WechatPrompt, withTheme, withTracker, Img };
|
38
|
+
export { ActionButton, ActivityIndicator, Address, Alert, AnimationWaiter, Async, Avatar, Badge, Button, ClickToCopy, CodeBlock, ContactForm, CountDown, Earth, Footer, Icon, LocaleSelector, Logo, Tabs, RelativeTime, SessionManager, Datatable, Dialog, DidLogo, Tag, TextCollapse, Theme, Toast, Util, Video, WebWalletSWKeeper, WalletAction, WalletDownload, WechatPrompt, withTheme, withTracker, Img, };
|
package/lib/index.js
CHANGED
@@ -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/lib/type.d.ts
CHANGED
@@ -1 +1,31 @@
|
|
1
|
-
|
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
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.10.
|
3
|
+
"version": "2.10.66",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -64,12 +64,12 @@
|
|
64
64
|
"react": ">=18.2.0",
|
65
65
|
"react-router-dom": ">=6.22.3"
|
66
66
|
},
|
67
|
-
"gitHead": "
|
67
|
+
"gitHead": "39618b5825c36e842a8c50af5967a95c19481341",
|
68
68
|
"dependencies": {
|
69
69
|
"@arcblock/did-motif": "^1.1.13",
|
70
|
-
"@arcblock/icons": "^2.10.
|
71
|
-
"@arcblock/nft-display": "^2.10.
|
72
|
-
"@arcblock/react-hooks": "^2.10.
|
70
|
+
"@arcblock/icons": "^2.10.66",
|
71
|
+
"@arcblock/nft-display": "^2.10.66",
|
72
|
+
"@arcblock/react-hooks": "^2.10.66",
|
73
73
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
74
74
|
"@fontsource/inter": "^5.0.16",
|
75
75
|
"@fontsource/ubuntu-mono": "^5.0.18",
|