@arcblock/ux 2.13.12 → 2.13.13
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/ActivityIndicator/index.js +9 -5
- package/lib/Address/did-address.js +14 -7
- package/lib/BlockletV2/blocklet.js +1 -1
- package/lib/CloseButton/index.js +1 -2
- package/lib/Colors/index.d.ts +1 -3
- package/lib/Colors/index.js +2 -4
- package/lib/Colors/themes/default.d.ts +3 -66
- package/lib/Colors/themes/default.js +4 -74
- package/lib/Colors/themes/did-connect.d.ts +11 -6
- package/lib/Colors/themes/did-connect.js +17 -12
- package/lib/Colors/themes/temp.d.ts +3 -0
- package/lib/Colors/themes/temp.js +3 -0
- package/lib/Config/config-provider.d.ts +4 -5
- package/lib/Config/config-provider.js +7 -26
- package/lib/Config/theme-mode-toggle.js +0 -1
- package/lib/DID/index.js +3 -4
- package/lib/Datatable/CustomToolbar.js +3 -0
- package/lib/Datatable/index.js +105 -71
- package/lib/Footer/index.js +2 -5
- package/lib/Header/header.js +3 -1
- package/lib/Header/responsive-header.js +3 -1
- package/lib/Layout/dashboard/index.js +14 -2
- package/lib/Layout/dashboard/sidebar.js +1 -2
- package/lib/LoadingMask/index.js +4 -3
- package/lib/Locale/selector.js +3 -3
- package/lib/NavMenu/nav-menu.js +14 -9
- package/lib/NavMenu/products.js +3 -1
- package/lib/NavMenu/style.js +7 -3
- package/lib/NavMenu/sub-item-group.js +1 -1
- package/lib/PhoneInput/country-select.js +2 -3
- package/lib/SessionBlocklet/index.js +3 -3
- package/lib/SessionUser/components/did-space.js +14 -28
- package/lib/SessionUser/components/logged-in.js +2 -2
- package/lib/SessionUser/components/quick-login-item.js +13 -11
- package/lib/SessionUser/components/session-user-item.js +5 -6
- package/lib/SessionUser/components/session-user-switch.js +15 -13
- package/lib/SessionUser/components/un-login.js +9 -7
- package/lib/SessionUser/components/user-info.js +9 -8
- package/lib/SessionUser/images/did-spaces.svg +7 -13
- package/lib/Success/index.js +8 -4
- package/lib/Switch/index.js +3 -3
- package/lib/Tabs/index.js +8 -9
- package/lib/Theme/theme-provider.d.ts +5 -1
- package/lib/Theme/theme-provider.js +60 -5
- package/lib/Theme/theme.d.ts +6 -3
- package/lib/Theme/theme.js +55 -19
- package/lib/UserCard/Container/card.js +1 -1
- package/lib/UserCard/Container/dialog.js +1 -1
- package/lib/Util/index.d.ts +8 -0
- package/lib/Util/index.js +23 -1
- package/lib/type.d.ts +5 -1
- package/package.json +7 -6
- package/src/ActivityIndicator/index.jsx +4 -4
- package/src/Address/did-address.tsx +5 -5
- package/src/BlockletV2/blocklet.tsx +1 -1
- package/src/CloseButton/index.tsx +1 -2
- package/src/Colors/index.ts +2 -7
- package/src/Colors/themes/default.ts +4 -50
- package/src/Colors/themes/did-connect.ts +13 -6
- package/src/Colors/themes/temp.ts +3 -0
- package/src/Config/config-provider.tsx +17 -30
- package/src/Config/theme-mode-toggle.tsx +1 -1
- package/src/DID/index.tsx +3 -4
- package/src/Datatable/CustomToolbar.jsx +1 -0
- package/src/Datatable/index.jsx +107 -70
- package/src/Footer/index.tsx +2 -2
- package/src/Header/header.tsx +1 -1
- package/src/Header/responsive-header.tsx +2 -0
- package/src/Layout/dashboard/index.tsx +8 -4
- package/src/Layout/dashboard/sidebar.tsx +1 -2
- package/src/LoadingMask/index.tsx +3 -4
- package/src/Locale/selector.tsx +3 -4
- package/src/NavMenu/nav-menu.tsx +15 -10
- package/src/NavMenu/products.tsx +1 -1
- package/src/NavMenu/style.ts +5 -2
- package/src/NavMenu/sub-item-group.tsx +1 -1
- package/src/PhoneInput/country-select.tsx +2 -3
- package/src/SessionBlocklet/index.tsx +3 -3
- package/src/SessionUser/components/did-space.tsx +14 -10
- package/src/SessionUser/components/logged-in.tsx +2 -2
- package/src/SessionUser/components/quick-login-item.tsx +11 -12
- package/src/SessionUser/components/session-user-item.tsx +3 -6
- package/src/SessionUser/components/session-user-switch.tsx +13 -12
- package/src/SessionUser/components/un-login.tsx +7 -6
- package/src/SessionUser/components/user-info.tsx +7 -8
- package/src/SessionUser/images/did-spaces.svg +7 -13
- package/src/Success/index.tsx +6 -4
- package/src/Switch/index.jsx +3 -3
- package/src/Tabs/index.tsx +8 -9
- package/src/Theme/theme-provider.tsx +73 -2
- package/src/Theme/theme.ts +73 -22
- package/src/UserCard/Container/card.tsx +1 -1
- package/src/UserCard/Container/dialog.tsx +1 -1
- package/src/Util/index.ts +25 -0
- package/src/type.d.ts +5 -1
package/lib/Switch/index.js
CHANGED
@@ -23,7 +23,7 @@ const IOSSwitch = styled(props => /*#__PURE__*/_jsx(MuiSwitch, {
|
|
23
23
|
transform: 'translateX(16px)',
|
24
24
|
color: '#fff',
|
25
25
|
'& + .MuiSwitch-track': {
|
26
|
-
backgroundColor: theme.palette.
|
26
|
+
backgroundColor: theme.palette.primary.main,
|
27
27
|
opacity: 1,
|
28
28
|
border: 0
|
29
29
|
},
|
@@ -32,7 +32,7 @@ const IOSSwitch = styled(props => /*#__PURE__*/_jsx(MuiSwitch, {
|
|
32
32
|
}
|
33
33
|
},
|
34
34
|
'&.Mui-focusVisible .MuiSwitch-thumb': {
|
35
|
-
color:
|
35
|
+
color: theme.palette.primary.main,
|
36
36
|
border: '6px solid #fff'
|
37
37
|
},
|
38
38
|
'&.Mui-disabled .MuiSwitch-thumb': {
|
@@ -49,7 +49,7 @@ const IOSSwitch = styled(props => /*#__PURE__*/_jsx(MuiSwitch, {
|
|
49
49
|
},
|
50
50
|
'& .MuiSwitch-track': {
|
51
51
|
borderRadius: 26 / 2,
|
52
|
-
backgroundColor: theme.palette.
|
52
|
+
backgroundColor: theme.palette.grey[200],
|
53
53
|
opacity: 1,
|
54
54
|
transition: theme.transitions.create(['background-color'], {
|
55
55
|
duration: 500
|
package/lib/Tabs/index.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import { Tabs as MuiTabs, Tab as MuiTab } from '@mui/material';
|
3
|
-
import { temp as colors } from '../Colors';
|
4
3
|
import { styled } from '../Theme';
|
5
4
|
const PREFIX = 'index';
|
6
5
|
const classes = {
|
@@ -42,7 +41,7 @@ function CardTabs({
|
|
42
41
|
},
|
43
42
|
'.MuiTabs-flexContainer': {
|
44
43
|
borderRadius: '100vw',
|
45
|
-
backgroundColor:
|
44
|
+
backgroundColor: 'grey.200',
|
46
45
|
padding: 0.5,
|
47
46
|
display: 'inline-flex',
|
48
47
|
columnGap: 0.25,
|
@@ -55,15 +54,15 @@ function CardTabs({
|
|
55
54
|
minHeight: 'auto',
|
56
55
|
lineHeight: 1,
|
57
56
|
py: 1,
|
58
|
-
color:
|
57
|
+
color: 'text.secondary',
|
59
58
|
fontSize: '13px',
|
60
59
|
fontWeight: 'normal',
|
61
60
|
textTransform: 'capitalize',
|
62
61
|
transition: 'background-color 0.2s ease',
|
63
62
|
'&.Mui-selected, &:hover': {
|
64
63
|
backgroundColor: 'white',
|
65
|
-
borderColor:
|
66
|
-
color:
|
64
|
+
borderColor: 'grey.100',
|
65
|
+
color: 'grey.A700'
|
67
66
|
}
|
68
67
|
},
|
69
68
|
'.MuiTabs-indicator': {
|
@@ -107,7 +106,7 @@ function LineTabs({
|
|
107
106
|
zIndex: -1,
|
108
107
|
width: '100%',
|
109
108
|
height: '1px',
|
110
|
-
backgroundColor:
|
109
|
+
backgroundColor: 'grey.300'
|
111
110
|
}
|
112
111
|
} : {},
|
113
112
|
'.MuiTabs-flexContainer': {
|
@@ -122,18 +121,18 @@ function LineTabs({
|
|
122
121
|
lineHeight: 1,
|
123
122
|
py: 1,
|
124
123
|
px: 0,
|
125
|
-
color:
|
124
|
+
color: 'text.secondary',
|
126
125
|
fontSize: '14px',
|
127
126
|
fontWeight: 500,
|
128
127
|
textTransform: 'capitalize',
|
129
128
|
minWidth: 'auto',
|
130
129
|
'&.Mui-selected, &:hover': {
|
131
|
-
color:
|
130
|
+
color: 'primary.main'
|
132
131
|
}
|
133
132
|
},
|
134
133
|
'.MuiTabs-indicator': {
|
135
134
|
height: '1px',
|
136
|
-
backgroundColor:
|
135
|
+
backgroundColor: 'primary.main'
|
137
136
|
},
|
138
137
|
...rest.sx
|
139
138
|
},
|
@@ -4,21 +4,25 @@ export interface ThemeProviderProps {
|
|
4
4
|
children?: React.ReactNode;
|
5
5
|
theme: Theme;
|
6
6
|
injectFirst?: boolean;
|
7
|
+
/** 指定一个类名,DarkSchemeStyles 只会作用于带有该类的元素及其后代 */
|
8
|
+
darkSchemeClass?: string;
|
7
9
|
}
|
8
10
|
/**
|
9
11
|
* 默认的 theme provider, 可以为 webapp/blocklet 快捷的配置好 mui theme provider
|
10
12
|
*/
|
11
|
-
declare function ThemeProvider({ children, theme, injectFirst }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
13
|
+
declare function ThemeProvider({ children, theme, injectFirst, darkSchemeClass }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
12
14
|
declare namespace ThemeProvider {
|
13
15
|
var propTypes: {
|
14
16
|
children: PropTypes.Requireable<any>;
|
15
17
|
theme: PropTypes.Requireable<any>;
|
16
18
|
injectFirst: PropTypes.Requireable<boolean>;
|
19
|
+
darkSchemeClass: PropTypes.Requireable<string>;
|
17
20
|
};
|
18
21
|
var defaultProps: {
|
19
22
|
children: null;
|
20
23
|
theme: Theme;
|
21
24
|
injectFirst: boolean;
|
25
|
+
darkSchemeClass: string;
|
22
26
|
};
|
23
27
|
}
|
24
28
|
export default ThemeProvider;
|
@@ -1,17 +1,68 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import PropTypes from 'prop-types';
|
3
|
-
import {
|
3
|
+
import { GlobalStyles } from '@mui/material';
|
4
|
+
import { ThemeProvider as MuiThemeProvider, useTheme } from '@mui/material/styles';
|
4
5
|
import StyledEngineProvider from '@mui/material/StyledEngineProvider';
|
5
6
|
import CssBaseline from '@mui/material/CssBaseline';
|
6
7
|
import { createTheme } from './theme';
|
7
8
|
const defaultTheme = createTheme();
|
9
|
+
function DarkSchemeStyles({
|
10
|
+
className
|
11
|
+
}) {
|
12
|
+
const theme = useTheme();
|
13
|
+
if (theme.palette.mode === 'dark') {
|
14
|
+
const trackColor = 'transparent';
|
15
|
+
const thumbColor = theme.palette.grey[300];
|
16
|
+
|
17
|
+
// 处理作用域选择器
|
18
|
+
const prefix = (className || '').trim().split(/\s+/).filter(Boolean).map(c => c.startsWith('.') ? c : `.${c}`).join(' ');
|
19
|
+
const webkitScrollbar = prefix ? `${prefix}::-webkit-scrollbar, ${prefix} *::-webkit-scrollbar` : '*::-webkit-scrollbar';
|
20
|
+
const webkitTrack = prefix ? `${prefix}::-webkit-scrollbar-track, ${prefix} *::-webkit-scrollbar-track` : '*::-webkit-scrollbar-track';
|
21
|
+
const webkitThumb = prefix ? `${prefix}::-webkit-scrollbar-thumb, ${prefix} *::-webkit-scrollbar-thumb` : '*::-webkit-scrollbar-thumb';
|
22
|
+
const firefoxSelector = prefix ? `${prefix}, ${prefix} *` : '*';
|
23
|
+
return /*#__PURE__*/_jsx(GlobalStyles, {
|
24
|
+
styles: {
|
25
|
+
// Chrome, Safari, Edge
|
26
|
+
'@supports selector(::-webkit-scrollbar)': {
|
27
|
+
[webkitScrollbar]: {
|
28
|
+
width: '12px',
|
29
|
+
height: '12px'
|
30
|
+
},
|
31
|
+
[webkitTrack]: {
|
32
|
+
background: trackColor
|
33
|
+
},
|
34
|
+
[webkitThumb]: {
|
35
|
+
background: thumbColor,
|
36
|
+
borderRadius: '6px',
|
37
|
+
border: '2px solid',
|
38
|
+
borderColor: trackColor,
|
39
|
+
backgroundClip: 'padding-box',
|
40
|
+
'&:hover': {
|
41
|
+
background: theme.palette.grey[400],
|
42
|
+
backgroundClip: 'padding-box'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
},
|
46
|
+
// Firefox
|
47
|
+
'@supports not selector(::-webkit-scrollbar)': {
|
48
|
+
[firefoxSelector]: {
|
49
|
+
scrollbarWidth: 'auto',
|
50
|
+
scrollbarColor: `${thumbColor} ${trackColor}`
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
55
|
+
}
|
56
|
+
return null;
|
57
|
+
}
|
8
58
|
/**
|
9
59
|
* 默认的 theme provider, 可以为 webapp/blocklet 快捷的配置好 mui theme provider
|
10
60
|
*/
|
11
61
|
export default function ThemeProvider({
|
12
62
|
children,
|
13
63
|
theme,
|
14
|
-
injectFirst
|
64
|
+
injectFirst,
|
65
|
+
darkSchemeClass
|
15
66
|
}) {
|
16
67
|
return (
|
17
68
|
/*#__PURE__*/
|
@@ -20,7 +71,9 @@ export default function ThemeProvider({
|
|
20
71
|
injectFirst: injectFirst,
|
21
72
|
children: /*#__PURE__*/_jsxs(MuiThemeProvider, {
|
22
73
|
theme: theme,
|
23
|
-
children: [/*#__PURE__*/_jsx(CssBaseline, {}),
|
74
|
+
children: [/*#__PURE__*/_jsx(CssBaseline, {}), /*#__PURE__*/_jsx(DarkSchemeStyles, {
|
75
|
+
className: darkSchemeClass
|
76
|
+
}), children]
|
24
77
|
})
|
25
78
|
})
|
26
79
|
);
|
@@ -28,10 +81,12 @@ export default function ThemeProvider({
|
|
28
81
|
ThemeProvider.propTypes = {
|
29
82
|
children: PropTypes.any,
|
30
83
|
theme: PropTypes.any,
|
31
|
-
injectFirst: PropTypes.bool
|
84
|
+
injectFirst: PropTypes.bool,
|
85
|
+
darkSchemeClass: PropTypes.string
|
32
86
|
};
|
33
87
|
ThemeProvider.defaultProps = {
|
34
88
|
children: null,
|
35
89
|
theme: defaultTheme,
|
36
|
-
injectFirst: true
|
90
|
+
injectFirst: true,
|
91
|
+
darkSchemeClass: ''
|
37
92
|
};
|
package/lib/Theme/theme.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { PaletteMode } from '@mui/material';
|
1
|
+
import type { PaletteMode, Theme } from '@mui/material';
|
2
2
|
import { type ThemeOptions } from '@mui/material/styles';
|
3
3
|
import { deepmerge } from '@mui/utils';
|
4
4
|
import '@fontsource/roboto/latin-400.css';
|
@@ -11,10 +11,13 @@ export declare function collectFontFamilies(obj?: {
|
|
11
11
|
fontFamily?: string;
|
12
12
|
}, fontSet?: Set<string>): Set<string>;
|
13
13
|
export declare function loadFonts(fonts: string[]): Promise<boolean>;
|
14
|
+
export declare function getDefaultThemePrefer(): PaletteMode;
|
14
15
|
export declare function createDefaultThemeOptions(mode?: PaletteMode): ThemeOptions;
|
15
16
|
export interface UserThemeOptions extends ThemeOptions {
|
16
17
|
disableBlockletTheme?: boolean;
|
17
18
|
}
|
18
|
-
export
|
19
|
-
export declare
|
19
|
+
export type ThemeConfig = Pick<Theme, 'palette'>;
|
20
|
+
export declare function lazyThemeConfig(mode: PaletteMode): () => ThemeConfig;
|
21
|
+
export declare const create: (...args: Array<UserThemeOptions | ((config: ThemeConfig) => UserThemeOptions)>) => Theme;
|
22
|
+
export declare const createTheme: (...args: Array<UserThemeOptions | ((config: ThemeConfig) => UserThemeOptions)>) => Theme;
|
20
23
|
export { deepmerge };
|
package/lib/Theme/theme.js
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
|
4
4
|
import { createTheme as _createTheme, responsiveFontSizes } from '@mui/material/styles';
|
5
5
|
import { deepmerge } from '@mui/utils';
|
6
|
+
import pick from 'lodash/pick';
|
6
7
|
import webfontloader from 'webfontloader';
|
7
|
-
import { BLOCKLET_THEME_LIGHT, BLOCKLET_THEME_DARK, DEFAULT_FONTS } from '@blocklet/theme';
|
8
|
-
import { cleanedObj } from '../Util';
|
8
|
+
import { BLOCKLET_THEME_LIGHT, BLOCKLET_THEME_DARK, DEFAULT_FONTS, BLOCKLET_THEME_PREFER_KEY } from '@blocklet/theme';
|
9
|
+
import { cleanedObj, deepmergeAll } from '../Util';
|
9
10
|
|
10
11
|
// 默认只加载最基本的 roboto latin 字体
|
11
12
|
import '@fontsource/roboto/latin-400.css';
|
@@ -61,6 +62,27 @@ export function loadFonts(fonts) {
|
|
61
62
|
});
|
62
63
|
}
|
63
64
|
|
65
|
+
// 获取默认主题偏好
|
66
|
+
export function getDefaultThemePrefer() {
|
67
|
+
const prefer = window.blocklet?.theme?.prefer;
|
68
|
+
if (prefer === 'system') {
|
69
|
+
// 本地缓存
|
70
|
+
const localPrefer = localStorage.getItem(BLOCKLET_THEME_PREFER_KEY);
|
71
|
+
if (localPrefer && (localPrefer === 'light' || localPrefer === 'dark')) {
|
72
|
+
return localPrefer;
|
73
|
+
}
|
74
|
+
|
75
|
+
// 跟随系统
|
76
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
77
|
+
}
|
78
|
+
if (prefer === 'light' || prefer === 'dark') {
|
79
|
+
return prefer;
|
80
|
+
}
|
81
|
+
|
82
|
+
// 未设置偏好
|
83
|
+
return 'light';
|
84
|
+
}
|
85
|
+
|
64
86
|
// 创建默认主题配置
|
65
87
|
export function createDefaultThemeOptions(mode = 'light') {
|
66
88
|
if (mode === 'dark') {
|
@@ -68,26 +90,35 @@ export function createDefaultThemeOptions(mode = 'light') {
|
|
68
90
|
}
|
69
91
|
return BLOCKLET_THEME_LIGHT;
|
70
92
|
}
|
71
|
-
|
93
|
+
|
94
|
+
// 用于获取 Blocklet Theme 配置,便于用户创建自定义主题
|
95
|
+
|
96
|
+
export function lazyThemeConfig(mode) {
|
97
|
+
const fields = ['palette'];
|
98
|
+
let config = null;
|
99
|
+
return () => {
|
100
|
+
if (config) return config;
|
101
|
+
config = deepmerge(pick(createDefaultThemeOptions(mode), fields), pick(window.blocklet?.theme?.[mode] ?? {}, fields));
|
102
|
+
return config;
|
103
|
+
};
|
104
|
+
}
|
105
|
+
|
106
|
+
// 主要处理 overrides
|
72
107
|
const normalizeUserThemeOptions = ({
|
73
|
-
mode = 'light',
|
74
108
|
palette,
|
75
109
|
components,
|
76
110
|
overrides,
|
77
111
|
...rest
|
78
112
|
}) => {
|
79
|
-
|
80
|
-
|
81
|
-
palette: {
|
82
|
-
...palette,
|
83
|
-
mode
|
84
|
-
},
|
113
|
+
const result = {
|
114
|
+
palette,
|
85
115
|
components: {
|
86
116
|
...overrides,
|
87
117
|
...components
|
88
118
|
},
|
89
119
|
...rest
|
90
120
|
};
|
121
|
+
return result;
|
91
122
|
};
|
92
123
|
const defaultUserThemeOptions = {
|
93
124
|
themeName: 'ArcBlock',
|
@@ -118,20 +149,25 @@ const defaultUserThemeOptions = {
|
|
118
149
|
|
119
150
|
// https://material-ui.com/customization/default-theme/
|
120
151
|
export const create = (...args) => {
|
121
|
-
const
|
152
|
+
const defaultPrefer = getDefaultThemePrefer();
|
153
|
+
const getThemeConfig = lazyThemeConfig(defaultPrefer);
|
154
|
+
const userThemeOptions = args.reduce((acc, curr) => deepmerge(acc, normalizeUserThemeOptions(typeof curr === 'function' ? curr(getThemeConfig()) : curr)), normalizeUserThemeOptions(defaultUserThemeOptions));
|
155
|
+
const prefer = userThemeOptions.mode || userThemeOptions.palette?.mode || defaultPrefer;
|
156
|
+
const blockletThemeOptions = window.blocklet?.theme?.[prefer] ?? {};
|
157
|
+
const defaultThemeOptions = createDefaultThemeOptions(prefer);
|
122
158
|
const {
|
123
|
-
mode,
|
124
159
|
disableBlockletTheme
|
125
160
|
} = userThemeOptions;
|
126
|
-
const blockletThemeOptions = window.blocklet?.theme?.[mode] ?? {};
|
127
|
-
const defaultThemeOptions = createDefaultThemeOptions(mode);
|
128
161
|
|
129
162
|
// 合并配置
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
163
|
+
const mergedThemeOptions = deepmergeAll([defaultThemeOptions, !disableBlockletTheme && cleanedObj(blockletThemeOptions), cleanedObj(userThemeOptions),
|
164
|
+
// 确保 mode 跟 prefer 一致
|
165
|
+
{
|
166
|
+
mode: prefer,
|
167
|
+
palette: {
|
168
|
+
mode: prefer
|
169
|
+
}
|
170
|
+
}].filter(Boolean));
|
135
171
|
|
136
172
|
// 创建主题
|
137
173
|
const theme = _createTheme(mergedThemeOptions);
|
package/lib/Util/index.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { type DeepmergeOptions } from '@mui/utils/deepmerge';
|
1
2
|
import type { $TSFixMe, Locale } from '../type';
|
2
3
|
declare let dateTool: $TSFixMe | null;
|
3
4
|
/** 是否常见二段式顶级域名 */
|
@@ -92,4 +93,11 @@ export declare const getTranslation: (translations: TranslationsObject, locale:
|
|
92
93
|
}) => string;
|
93
94
|
export declare const lazyRetry: (fn: () => Promise<any>) => import("react").LazyExoticComponent<import("react").ComponentType<any>>;
|
94
95
|
export declare const cleanedObj: (obj: object) => import("lodash").Dictionary<any>;
|
96
|
+
/**
|
97
|
+
* 依次对数组中的对象进行深度合并
|
98
|
+
* @param objects - 需要合并的对象数组
|
99
|
+
* @param options - deepmerge 的配置选项
|
100
|
+
* @returns 合并后的对象
|
101
|
+
*/
|
102
|
+
export declare function deepmergeAll<T>(objects: T[], options?: DeepmergeOptions): T;
|
95
103
|
export {};
|
package/lib/Util/index.js
CHANGED
@@ -5,6 +5,7 @@ import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
|
|
5
5
|
import isNil from 'lodash/isNil';
|
6
6
|
import omitBy from 'lodash/omitBy';
|
7
7
|
import pRetry from 'p-retry';
|
8
|
+
import deepmerge from '@mui/utils/deepmerge';
|
8
9
|
import { DID_PREFIX, BLOCKLET_SERVICE_PATH_PREFIX } from './constant';
|
9
10
|
let dateTool = null;
|
10
11
|
const IP_V4_REGEX = /^(\d{1,3}\.){3}\d{1,3}(:\d+)?$/;
|
@@ -426,4 +427,25 @@ export const lazyRetry = fn => /*#__PURE__*/lazy(() => pRetry(async () => {
|
|
426
427
|
}));
|
427
428
|
export const cleanedObj = obj => {
|
428
429
|
return omitBy(obj, isNil);
|
429
|
-
};
|
430
|
+
};
|
431
|
+
|
432
|
+
/**
|
433
|
+
* 依次对数组中的对象进行深度合并
|
434
|
+
* @param objects - 需要合并的对象数组
|
435
|
+
* @param options - deepmerge 的配置选项
|
436
|
+
* @returns 合并后的对象
|
437
|
+
*/
|
438
|
+
export function deepmergeAll(objects, options) {
|
439
|
+
if (!Array.isArray(objects)) {
|
440
|
+
throw new Error('First argument should be an array');
|
441
|
+
}
|
442
|
+
if (objects.length === 0) {
|
443
|
+
return {};
|
444
|
+
}
|
445
|
+
if (objects.length === 1) {
|
446
|
+
return objects[0];
|
447
|
+
}
|
448
|
+
return objects.reduce((acc, obj) => {
|
449
|
+
return deepmerge(acc, obj, options);
|
450
|
+
});
|
451
|
+
}
|
package/lib/type.d.ts
CHANGED
@@ -25,7 +25,11 @@ export type Blocklet = {
|
|
25
25
|
version: string;
|
26
26
|
mode: string;
|
27
27
|
tenantMode: 'single' | 'multiple';
|
28
|
-
theme:
|
28
|
+
theme: {
|
29
|
+
prefer?: PaletteMode | 'system';
|
30
|
+
light: Theme;
|
31
|
+
dark: Theme;
|
32
|
+
};
|
29
33
|
navigation: $TSFixMe[];
|
30
34
|
preferences: Record<string, any>;
|
31
35
|
languages: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.13.
|
3
|
+
"version": "2.13.13",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -40,6 +40,7 @@
|
|
40
40
|
"@babel/cli": "^7.19.3",
|
41
41
|
"@babel/core": "^7.19.3",
|
42
42
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
43
|
+
"@babel/plugin-transform-typescript": "^7.24.7",
|
43
44
|
"@babel/preset-env": "^7.19.3",
|
44
45
|
"@babel/preset-react": "^7.18.6",
|
45
46
|
"@babel/preset-typescript": "^7.24.7",
|
@@ -70,14 +71,14 @@
|
|
70
71
|
"react": ">=18.2.0",
|
71
72
|
"react-router-dom": ">=6.22.3"
|
72
73
|
},
|
73
|
-
"gitHead": "
|
74
|
+
"gitHead": "b098f3a884e8b34a1926479507b674d40ea58298",
|
74
75
|
"dependencies": {
|
75
76
|
"@arcblock/did-motif": "^1.1.13",
|
76
|
-
"@arcblock/icons": "^2.13.
|
77
|
-
"@arcblock/nft-display": "^2.13.
|
78
|
-
"@arcblock/react-hooks": "^2.13.
|
77
|
+
"@arcblock/icons": "^2.13.13",
|
78
|
+
"@arcblock/nft-display": "^2.13.13",
|
79
|
+
"@arcblock/react-hooks": "^2.13.13",
|
79
80
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
80
|
-
"@blocklet/theme": "^2.13.
|
81
|
+
"@blocklet/theme": "^2.13.13",
|
81
82
|
"@fontsource/roboto": "~5.1.1",
|
82
83
|
"@fontsource/ubuntu-mono": "^5.0.18",
|
83
84
|
"@iconify-icons/logos": "^1.2.36",
|
@@ -3,8 +3,7 @@ import PropTypes from 'prop-types';
|
|
3
3
|
import { green, blue } from '@mui/material/colors';
|
4
4
|
|
5
5
|
import Logo from '../Logo';
|
6
|
-
import
|
7
|
-
import { styled } from '../Theme';
|
6
|
+
import { styled, useTheme } from '../Theme';
|
8
7
|
|
9
8
|
/**
|
10
9
|
* ActivityIndicator is used when we want to tell the user the request they made on the UI will take time.
|
@@ -21,6 +20,7 @@ import { styled } from '../Theme';
|
|
21
20
|
*/
|
22
21
|
export default function ActivityIndicator({ messages, interval, ...rest }) {
|
23
22
|
const [index, setIndex] = useState(0);
|
23
|
+
const { palette } = useTheme();
|
24
24
|
|
25
25
|
useEffect(() => {
|
26
26
|
const timer = setInterval(() => {
|
@@ -42,7 +42,7 @@ export default function ActivityIndicator({ messages, interval, ...rest }) {
|
|
42
42
|
<Logo style={{ transform: 'scale(0.6)' }} showText={false} />
|
43
43
|
<Orbit size={56} orbitColor={green[500]} atomColor={green[500]} duration={1} />
|
44
44
|
<Orbit size={80} orbitColor={blue[800]} atomColor={blue[800]} duration={1.5} />
|
45
|
-
<Orbit size={100} orbitColor={
|
45
|
+
<Orbit size={100} orbitColor={palette.grey[900]} atomColor={palette.grey[900]} />
|
46
46
|
</div>
|
47
47
|
</div>
|
48
48
|
</Div>
|
@@ -75,7 +75,7 @@ const Div = styled('div')`
|
|
75
75
|
}
|
76
76
|
|
77
77
|
.pm-loader-text {
|
78
|
-
color: ${
|
78
|
+
color: ${({ theme }) => theme.palette.grey[900]};
|
79
79
|
font-size: 14px;
|
80
80
|
text-align: center;
|
81
81
|
position: relative;
|
@@ -116,7 +116,7 @@ const DidAddress = forwardRef<HTMLDidAddressElement, IDidAddressProps>((props, r
|
|
116
116
|
<span className="did-address-copy-wrapper" title={copied ? '' : translations[locale].copy}>
|
117
117
|
{copied ? (
|
118
118
|
<Tooltip title={translations[locale].copied} placement="bottom" arrow open={copied}>
|
119
|
-
<CheckIcon className="did-address-copy"
|
119
|
+
<CheckIcon className="did-address-copy" sx={{ color: 'success.main' }} />
|
120
120
|
</Tooltip>
|
121
121
|
) : (
|
122
122
|
/* title prop 直接加在 icon 上不生效 */
|
@@ -184,7 +184,7 @@ const Root = styled<any>(Box, { shouldForwardProp: (prop) => prop !== 'inline' }
|
|
184
184
|
}
|
185
185
|
|
186
186
|
.did-address-text {
|
187
|
-
color:
|
187
|
+
color: ${({ theme }) => theme.palette.text.secondary};
|
188
188
|
}
|
189
189
|
/* truncate string with ellipsis */
|
190
190
|
.did-address-truncate {
|
@@ -204,16 +204,16 @@ const Root = styled<any>(Box, { shouldForwardProp: (prop) => prop !== 'inline' }
|
|
204
204
|
.did-address-copy {
|
205
205
|
flex: 0 0 auto;
|
206
206
|
font-size: 1em;
|
207
|
-
color:
|
207
|
+
color: ${({ theme }) => theme.palette.text.secondary};
|
208
208
|
cursor: pointer;
|
209
209
|
}
|
210
210
|
|
211
211
|
/* link */
|
212
212
|
a {
|
213
|
-
color:
|
213
|
+
color: ${({ theme }) => theme.palette.text.secondary};
|
214
214
|
}
|
215
215
|
&:hover a {
|
216
|
-
color:
|
216
|
+
color: ${({ theme }) => theme.palette.text.primary};
|
217
217
|
text-decoration: underline;
|
218
218
|
}
|
219
219
|
`;
|
@@ -105,7 +105,7 @@ export default function BlockletStore(props: IBlockletStore) {
|
|
105
105
|
variant="outlined"
|
106
106
|
onClick={handleMainClick}
|
107
107
|
{...rest}
|
108
|
-
sx={{ p: { xs: 2, md: 3 }, borderRadius:
|
108
|
+
sx={{ p: { xs: 2, md: 3 }, borderRadius: 1, ...rest.sx }}>
|
109
109
|
<Stack flex={1} direction="row" gap={1} alignItems="center" overflow="hidden" sx={{ '& > *': { flexShrink: 0 } }}>
|
110
110
|
<Avatar src={cover} did={did} size={48} variant="rounded" style={{ borderRadius: '8px', overflow: 'hidden' }} />
|
111
111
|
<Typography
|
@@ -4,7 +4,6 @@ import { Icon } from '@iconify/react';
|
|
4
4
|
import CloseRoundedIcon from '@iconify-icons/material-symbols/close-rounded';
|
5
5
|
import noop from 'lodash/noop';
|
6
6
|
|
7
|
-
import { temp as colors } from '../Colors';
|
8
7
|
import { mergeSx } from '../Util/style';
|
9
8
|
|
10
9
|
export default function CloseButton({
|
@@ -23,7 +22,7 @@ export default function CloseButton({
|
|
23
22
|
{
|
24
23
|
fontSize: 0,
|
25
24
|
cursor: 'pointer',
|
26
|
-
color:
|
25
|
+
color: 'text.secondary',
|
27
26
|
transition: 'transform 0.25s ease-in-out 0s',
|
28
27
|
transformOrigin: 'center',
|
29
28
|
'&:hover': {
|
package/src/Colors/index.ts
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
// @compatibility
|
5
|
-
const colors = BLOCKLET_THEME_LIGHT.palette as Theme['palette'];
|
6
|
-
|
7
|
-
export default colors;
|
1
|
+
// eslint-disable-next-line no-restricted-exports
|
2
|
+
export { default } from './themes/default';
|
8
3
|
export { default as temp } from './themes/temp';
|
9
4
|
export { default as didConnectColors } from './themes/did-connect';
|
@@ -1,54 +1,8 @@
|
|
1
|
+
import { BLOCKLET_THEME_LIGHT, type Theme } from '@blocklet/theme';
|
2
|
+
|
1
3
|
/**
|
2
|
-
*
|
3
|
-
*
|
4
|
-
* - colors object 结构是在 mui theme#palette object 基础上调整后的结构
|
5
|
-
* - 色值在 mui default theme 基础上将 figma 中常用的 colors 进行覆盖
|
6
|
-
* - 扩展一些常用色值 (如 DID 系列)
|
7
|
-
* - figma: https://www.figma.com/file/1qHyMF137EXOQpSFVByszG/UX-Library?node-id=295%3A1518
|
4
|
+
* @deprecated 请使用 MUI theme 对象替代
|
8
5
|
*/
|
9
|
-
const colors =
|
10
|
-
common: {
|
11
|
-
black: '#000',
|
12
|
-
white: '#fff',
|
13
|
-
},
|
14
|
-
primary: { main: '#3773F2', contrastText: '#fff' }, // override
|
15
|
-
secondary: { main: '#16CED1', contrastText: '#fff' }, // override
|
16
|
-
error: { main: '#F16E6E', contrastText: '#fff' }, // override
|
17
|
-
warning: { main: '#DE9E37', contrastText: '#fff' }, // override
|
18
|
-
info: { main: '#0775F8', contrastText: '#fff' }, // override
|
19
|
-
success: { main: '#34BE74', contrastText: '#fff' }, // override
|
20
|
-
grey: {
|
21
|
-
50: '#fafafa',
|
22
|
-
100: '#f5f5f5',
|
23
|
-
200: '#eeeeee',
|
24
|
-
300: '#e0e0e0',
|
25
|
-
400: '#bdbdbd',
|
26
|
-
500: '#9e9e9e',
|
27
|
-
600: '#757575',
|
28
|
-
700: '#616161',
|
29
|
-
800: '#424242',
|
30
|
-
900: '#212121',
|
31
|
-
A100: '#d5d5d5',
|
32
|
-
A200: '#aaaaaa',
|
33
|
-
A400: '#303030',
|
34
|
-
A700: '#616161',
|
35
|
-
},
|
36
|
-
text: {
|
37
|
-
primary: 'rgba(0, 0, 0, 0.87)',
|
38
|
-
secondary: 'rgba(0, 0, 0, 0.54)',
|
39
|
-
disabled: 'rgba(0, 0, 0, 0.38)',
|
40
|
-
hint: 'rgba(0, 0, 0, 0.38)',
|
41
|
-
},
|
42
|
-
divider: 'rgba(0, 0, 0, 0.12)',
|
43
|
-
background: {
|
44
|
-
default: '#fff',
|
45
|
-
},
|
46
|
-
// 扩展色值, 适用于 did 相关的组件, 如果某些产品整体风格是 did 系列, 可以扩展出一个 did 系列的 theme
|
47
|
-
did: {
|
48
|
-
primary: '#4598FA',
|
49
|
-
secondary: '#49C3AD',
|
50
|
-
},
|
51
|
-
// TODO: 等设计规范稳定后, 考虑扩展 trade 相关的常用颜色 (send/receive/exchange/transfer)
|
52
|
-
};
|
6
|
+
const colors = BLOCKLET_THEME_LIGHT.palette as Theme['palette'];
|
53
7
|
|
54
8
|
export default colors;
|