@arcblock/ux 2.10.65 → 2.10.67
Sign up to get free protection for your applications and to get access to all the features.
- 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/NavMenu/nav-menu.js
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
|
3
|
-
import
|
2
|
+
/* eslint-disable no-unused-vars */
|
3
|
+
import { Children, cloneElement, useEffect, createContext, useContext, useRef, forwardRef, useLayoutEffect, isValidElement } from 'react';
|
4
4
|
import clsx from 'clsx';
|
5
5
|
import { MoreHoriz as MoreHorizIcon, ExpandMore as ExpandMoreIcon, Menu as MenuIcon } from '@mui/icons-material';
|
6
6
|
import { useCreation, useMemoizedFn, useReactive, useSize, useThrottleFn } from 'ahooks';
|
7
7
|
import { HorizontalStyle, InlineStyle } from './style';
|
8
|
-
const NavMenuContext = /*#__PURE__*/createContext();
|
8
|
+
const NavMenuContext = /*#__PURE__*/createContext(null);
|
9
9
|
|
10
10
|
// 过滤 children 中的 Item/Sub, 忽略其它类型的 element
|
11
11
|
function filterItems(children) {
|
12
12
|
if (children) {
|
13
13
|
// eslint-disable-next-line no-use-before-define
|
14
|
-
return Children.toArray(children).filter(child =>
|
14
|
+
return Children.toArray(children).filter(child => {
|
15
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
return child.type === Item || child.type === Sub;
|
19
|
+
});
|
15
20
|
}
|
16
21
|
return null;
|
17
22
|
}
|
@@ -19,23 +24,22 @@ function useUniqueId(id) {
|
|
19
24
|
const _id = useRef(id || `navmenu-item-id-${Math.random().toString(36).slice(2)}`);
|
20
25
|
return _id.current;
|
21
26
|
}
|
22
|
-
|
23
27
|
/**
|
24
28
|
* NavMenu, 导航组件, 可用于 header/footer/sidebar
|
25
29
|
*/
|
26
30
|
function NavMenu({
|
27
|
-
items,
|
28
|
-
mode,
|
29
|
-
children,
|
30
|
-
activeId,
|
31
|
-
textColor,
|
32
|
-
activeTextColor,
|
33
|
-
bgColor,
|
31
|
+
items = [],
|
32
|
+
mode = 'horizontal',
|
33
|
+
children: _childs = null,
|
34
|
+
activeId = null,
|
35
|
+
textColor = '#9397a1',
|
36
|
+
activeTextColor = '#25292f',
|
37
|
+
bgColor = '#fff',
|
34
38
|
onSelected,
|
35
39
|
...rest
|
36
40
|
}) {
|
37
41
|
// eslint-disable-next-line no-param-reassign
|
38
|
-
children = filterItems(
|
42
|
+
const children = filterItems(_childs);
|
39
43
|
if (!items?.length && !children?.length) {
|
40
44
|
throw new Error("One of 'items' or 'children' is required by NavMenu component.");
|
41
45
|
}
|
@@ -63,9 +67,9 @@ function NavMenu({
|
|
63
67
|
close
|
64
68
|
};
|
65
69
|
}, [currentState.activeId, currentState.hiddenItemCount, currentState.openedIds, mode, activate, open, close]);
|
66
|
-
const navMenuRef = useRef();
|
70
|
+
const navMenuRef = useRef(null);
|
67
71
|
const itemRefs = useRef([]);
|
68
|
-
const moreIconRef = useRef();
|
72
|
+
const moreIconRef = useRef(null);
|
69
73
|
const isAllItemsHidden = currentState.hiddenItemCount === itemRefs.current?.length;
|
70
74
|
const style = isAllItemsHidden ? {
|
71
75
|
marginLeft: '0px'
|
@@ -175,7 +179,7 @@ function NavMenu({
|
|
175
179
|
children: /*#__PURE__*/_jsxs("ul", {
|
176
180
|
className: "navmenu-root",
|
177
181
|
ref: navMenuRef,
|
178
|
-
children: [items ? items.map((item, index) => renderItem(item, index, true)) : renderChildrenWithRef(children), currentState.hiddenItemCount > 0 && /*#__PURE__*/_jsx(Sub, {
|
182
|
+
children: [items ? items.map((item, index) => renderItem(item, index, true)) : renderChildrenWithRef(children || []), currentState.hiddenItemCount > 0 && /*#__PURE__*/_jsx(Sub, {
|
179
183
|
expandIcon: false,
|
180
184
|
icon: icon,
|
181
185
|
label: "",
|
@@ -187,57 +191,31 @@ function NavMenu({
|
|
187
191
|
})
|
188
192
|
});
|
189
193
|
}
|
190
|
-
NavMenu.propTypes = {
|
191
|
-
items: PropTypes.array,
|
192
|
-
// 默认水平方向布局,
|
193
|
-
// inline 模式: 垂直布局, 且通过 click 事件来收缩/伸展子菜单, 适用于移动端
|
194
|
-
mode: PropTypes.oneOf(['horizontal', 'vertical', 'inline']),
|
195
|
-
children: PropTypes.array,
|
196
|
-
activeId: PropTypes.string,
|
197
|
-
textColor: PropTypes.string,
|
198
|
-
activeTextColor: PropTypes.string,
|
199
|
-
bgColor: PropTypes.string,
|
200
|
-
onSelected: PropTypes.func
|
201
|
-
};
|
202
|
-
NavMenu.defaultProps = {
|
203
|
-
items: null,
|
204
|
-
mode: 'horizontal',
|
205
|
-
children: null,
|
206
|
-
activeId: null,
|
207
|
-
textColor: '#9397a1',
|
208
|
-
activeTextColor: '#25292f',
|
209
|
-
bgColor: '#fff',
|
210
|
-
onSelected: null
|
211
|
-
};
|
212
|
-
|
213
|
-
/**
|
214
|
-
* Item
|
215
|
-
*/
|
216
194
|
const Item = /*#__PURE__*/forwardRef(({
|
217
|
-
id: _id,
|
218
|
-
icon,
|
219
|
-
label,
|
220
|
-
active,
|
221
|
-
onClick,
|
195
|
+
id: _id = '',
|
196
|
+
icon = null,
|
197
|
+
label = '',
|
198
|
+
active = false,
|
199
|
+
onClick = null,
|
222
200
|
...rest
|
223
201
|
}, ref) => {
|
224
202
|
const id = useUniqueId(_id);
|
225
203
|
const {
|
226
204
|
activeId,
|
227
205
|
activate
|
228
|
-
} = useContext(NavMenuContext);
|
206
|
+
} = useContext(NavMenuContext) || {};
|
229
207
|
const classes = clsx('navmenu-item', {
|
230
208
|
'navmenu-item--active': activeId === id
|
231
209
|
}, rest.className);
|
232
210
|
useEffect(() => {
|
233
211
|
if (active) {
|
234
|
-
activate(id);
|
212
|
+
activate?.(id);
|
235
213
|
}
|
236
214
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
237
215
|
}, [active]);
|
238
216
|
const handleClick = () => {
|
239
217
|
onClick?.();
|
240
|
-
activate(id);
|
218
|
+
activate?.(id);
|
241
219
|
};
|
242
220
|
return (
|
243
221
|
/*#__PURE__*/
|
@@ -257,30 +235,18 @@ const Item = /*#__PURE__*/forwardRef(({
|
|
257
235
|
})
|
258
236
|
);
|
259
237
|
});
|
260
|
-
Item.propTypes = {
|
261
|
-
id: PropTypes.string,
|
262
|
-
icon: PropTypes.element,
|
263
|
-
label: PropTypes.node,
|
264
|
-
active: PropTypes.bool,
|
265
|
-
onClick: PropTypes.func
|
266
|
-
};
|
267
|
-
Item.defaultProps = {
|
268
|
-
id: null,
|
269
|
-
icon: null,
|
270
|
-
label: '',
|
271
|
-
active: false,
|
272
|
-
onClick: null
|
273
|
-
};
|
274
|
-
|
275
|
-
/**
|
276
|
-
* Sub
|
277
|
-
*/
|
278
238
|
const Sub = /*#__PURE__*/forwardRef(({
|
279
|
-
id: _id,
|
280
|
-
icon,
|
281
|
-
label,
|
239
|
+
id: _id = '',
|
240
|
+
icon = null,
|
241
|
+
label = null,
|
282
242
|
children,
|
283
|
-
expandIcon
|
243
|
+
expandIcon = ({
|
244
|
+
isOpen
|
245
|
+
}) => /*#__PURE__*/_jsx(ExpandMoreIcon, {
|
246
|
+
style: {
|
247
|
+
transform: `rotate(${isOpen ? 180 : 0}deg)`
|
248
|
+
}
|
249
|
+
}),
|
284
250
|
...rest
|
285
251
|
}, ref) => {
|
286
252
|
const id = useUniqueId(_id);
|
@@ -289,8 +255,8 @@ const Sub = /*#__PURE__*/forwardRef(({
|
|
289
255
|
open,
|
290
256
|
close,
|
291
257
|
mode
|
292
|
-
} = useContext(NavMenuContext);
|
293
|
-
const isOpen = openedIds
|
258
|
+
} = useContext(NavMenuContext) || {};
|
259
|
+
const isOpen = openedIds?.includes(id) ?? false;
|
294
260
|
const classes = clsx('navmenu-sub', {
|
295
261
|
'navmenu-sub--opened': isOpen
|
296
262
|
}, rest.className);
|
@@ -298,15 +264,15 @@ const Sub = /*#__PURE__*/forwardRef(({
|
|
298
264
|
// inline mode 时使用 click 事件控制收缩/伸展子菜单
|
299
265
|
const props = isInlineMode ? {
|
300
266
|
onClick: () => {
|
301
|
-
if (openedIds
|
302
|
-
close(id);
|
267
|
+
if (openedIds?.includes(id)) {
|
268
|
+
close?.(id);
|
303
269
|
} else {
|
304
|
-
open(id);
|
270
|
+
open?.(id);
|
305
271
|
}
|
306
272
|
}
|
307
273
|
} : {
|
308
|
-
onMouseEnter: () => open(id),
|
309
|
-
onMouseLeave: () => close(id)
|
274
|
+
onMouseEnter: () => open?.(id),
|
275
|
+
onMouseLeave: () => close?.(id)
|
310
276
|
};
|
311
277
|
// inline mode, 避免点击子菜单项时触发父菜单的 open/close
|
312
278
|
const containerProps = isInlineMode ? {
|
@@ -325,9 +291,9 @@ const Sub = /*#__PURE__*/forwardRef(({
|
|
325
291
|
children: label
|
326
292
|
}), expandIcon && /*#__PURE__*/_jsx("span", {
|
327
293
|
className: "navmenu-sub-expand-icon",
|
328
|
-
children: expandIcon
|
294
|
+
children: typeof expandIcon === 'function' ? expandIcon({
|
329
295
|
isOpen
|
330
|
-
})
|
296
|
+
}) : expandIcon
|
331
297
|
}), /*#__PURE__*/_jsx("div", {
|
332
298
|
className: "navmenu-sub-container",
|
333
299
|
...containerProps,
|
@@ -338,27 +304,6 @@ const Sub = /*#__PURE__*/forwardRef(({
|
|
338
304
|
})]
|
339
305
|
});
|
340
306
|
});
|
341
|
-
Sub.propTypes = {
|
342
|
-
id: PropTypes.string,
|
343
|
-
icon: PropTypes.element,
|
344
|
-
label: PropTypes.node.isRequired,
|
345
|
-
children: PropTypes.array.isRequired,
|
346
|
-
expandIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
347
|
-
};
|
348
|
-
Sub.defaultProps = {
|
349
|
-
id: null,
|
350
|
-
icon: null,
|
351
|
-
// eslint-disable-next-line react/prop-types
|
352
|
-
expandIcon: ({
|
353
|
-
isOpen
|
354
|
-
}) => {
|
355
|
-
return /*#__PURE__*/_jsx(ExpandMoreIcon, {
|
356
|
-
style: {
|
357
|
-
transform: `rotate(${isOpen ? 180 : 0}deg)`
|
358
|
-
}
|
359
|
-
});
|
360
|
-
}
|
361
|
-
};
|
362
307
|
NavMenu.Item = Item;
|
363
308
|
NavMenu.Sub = Sub;
|
364
309
|
export default NavMenu;
|
package/lib/NavMenu/style.d.ts
CHANGED
@@ -1,2 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
type NavMenuBaseProps = {
|
2
|
+
$bgColor: string;
|
3
|
+
$textColor: string;
|
4
|
+
$activeTextColor: string;
|
5
|
+
};
|
6
|
+
export declare const HorizontalStyle: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & NavMenuBaseProps & import("react").ClassAttributes<HTMLElement> & import("react").HTMLAttributes<HTMLElement>, {}, {}>;
|
7
|
+
export declare const InlineStyle: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & NavMenuBaseProps & import("react").ClassAttributes<HTMLElement> & import("react").HTMLAttributes<HTMLElement>, {}, {}>;
|
8
|
+
export {};
|
package/lib/NavMenu/style.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { styled } from '../Theme';
|
2
|
-
const NavMenuBase = styled('nav'
|
2
|
+
const NavMenuBase = styled('nav', {
|
3
|
+
shouldForwardProp: prop => prop !== '$bgColor' && prop !== '$textColor' && prop !== '$activeTextColor'
|
4
|
+
})`
|
3
5
|
background-color: ${props => props.$bgColor};
|
4
6
|
font-size: 16px;
|
5
7
|
// width: 100%;
|
@@ -1,2 +1,14 @@
|
|
1
|
-
declare const _default: (props:
|
1
|
+
declare const _default: (props: {
|
2
|
+
animationTimer: any;
|
3
|
+
blockScrollDown: any;
|
4
|
+
blockScrollUp: any;
|
5
|
+
children: any;
|
6
|
+
height: any;
|
7
|
+
width: any;
|
8
|
+
customPageNumber: any;
|
9
|
+
onScrollUnavailable: any;
|
10
|
+
onChange: any;
|
11
|
+
renderAllPagesOnFirstRender: any;
|
12
|
+
transitionTimingFunction: any;
|
13
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
2
14
|
export default _default;
|
package/lib/Passport/passport.js
CHANGED
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import upperFirst from 'lodash/upperFirst';
|
4
4
|
import { Box } from '@mui/material';
|
5
|
-
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
6
5
|
import RevokeIcon from '@arcblock/icons/lib/RevokeIcon';
|
7
6
|
import NFTDisplay from '../NFTDisplay';
|
7
|
+
import { useLocaleContext } from '../Locale/context';
|
8
8
|
export default function Passport({
|
9
9
|
passport,
|
10
10
|
user,
|
@@ -8,7 +8,7 @@ declare function RelativeTime({ value, locale, withoutSuffix, from, to, type, tz
|
|
8
8
|
type: any;
|
9
9
|
tz: any;
|
10
10
|
relativeRange: any;
|
11
|
-
}): import("react/jsx-runtime").JSX.Element
|
11
|
+
}): "-" | import("react/jsx-runtime").JSX.Element;
|
12
12
|
declare namespace RelativeTime {
|
13
13
|
namespace propTypes {
|
14
14
|
let value: PropTypes.Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import { styled } from '@arcblock/ux/lib/Theme';
|
3
2
|
import PropTypes from 'prop-types';
|
4
3
|
import phone from './shells/Phone';
|
5
4
|
import macbook from './shells/Macbook';
|
5
|
+
import { styled } from '../../Theme';
|
6
6
|
const map = {
|
7
7
|
phone,
|
8
8
|
macbook
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
2
|
import MenuItem, { MenuItemProps } from '@mui/material/MenuItem';
|
4
3
|
import { ButtonGroupProps } from '@mui/material/ButtonGroup';
|
5
4
|
import { ButtonProps } from '@mui/material/Button';
|
@@ -11,24 +10,6 @@ export interface SplitButtonProps extends Omit<ButtonGroupProps, 'children'> {
|
|
11
10
|
}
|
12
11
|
declare function SplitButton(props: SplitButtonProps): import("react/jsx-runtime").JSX.Element;
|
13
12
|
declare namespace SplitButton {
|
14
|
-
var propTypes: {
|
15
|
-
size: PropTypes.Requireable<string>;
|
16
|
-
color: PropTypes.Requireable<string>;
|
17
|
-
menu: PropTypes.Requireable<NonNullable<any[] | PropTypes.ReactNodeLike>>;
|
18
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
19
|
-
variant: PropTypes.Requireable<string>;
|
20
|
-
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
21
|
-
menuButtonProps: PropTypes.Requireable<object>;
|
22
|
-
};
|
23
|
-
var defaultProps: {
|
24
|
-
size: string;
|
25
|
-
color: string;
|
26
|
-
menu: never[];
|
27
|
-
children: null;
|
28
|
-
variant: string;
|
29
|
-
onClick: (...args: any[]) => void;
|
30
|
-
menuButtonProps: {};
|
31
|
-
};
|
32
13
|
var Item: import("@mui/material").ExtendButtonBase<import("@mui/material/MenuItem").MenuItemTypeMap<{}, "li">>;
|
33
14
|
}
|
34
15
|
export default SplitButton;
|
package/lib/SplitButton/index.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
2
|
import React, { useState, useRef, isValidElement, createElement as _createElement } from 'react';
|
3
|
-
import PropTypes from 'prop-types';
|
4
3
|
import ExpandMore from '@mui/icons-material/ExpandMore';
|
5
4
|
import Popper from '@mui/material/Popper';
|
6
5
|
import Paper from '@mui/material/Paper';
|
@@ -13,13 +12,13 @@ import noop from 'lodash/noop';
|
|
13
12
|
import { styled } from '../Theme';
|
14
13
|
export default function SplitButton(props) {
|
15
14
|
const {
|
16
|
-
size,
|
17
|
-
color,
|
18
|
-
menu,
|
19
|
-
children,
|
20
|
-
variant,
|
21
|
-
onClick,
|
22
|
-
menuButtonProps,
|
15
|
+
size = 'medium',
|
16
|
+
color = 'primary',
|
17
|
+
menu = [],
|
18
|
+
children = null,
|
19
|
+
variant = 'contained',
|
20
|
+
onClick = noop,
|
21
|
+
menuButtonProps = {},
|
23
22
|
...rest
|
24
23
|
} = props;
|
25
24
|
const [open, setOpen] = useState(false);
|
@@ -79,25 +78,6 @@ export default function SplitButton(props) {
|
|
79
78
|
})]
|
80
79
|
});
|
81
80
|
}
|
82
|
-
SplitButton.propTypes = {
|
83
|
-
size: PropTypes.string,
|
84
|
-
color: PropTypes.string,
|
85
|
-
menu: PropTypes.oneOfType([PropTypes.node, PropTypes.array]),
|
86
|
-
// 也可以是用于渲染主按钮的 function
|
87
|
-
children: PropTypes.node,
|
88
|
-
variant: PropTypes.oneOf(['outlined', 'contained']),
|
89
|
-
onClick: PropTypes.func,
|
90
|
-
menuButtonProps: PropTypes.object
|
91
|
-
};
|
92
|
-
SplitButton.defaultProps = {
|
93
|
-
size: 'medium',
|
94
|
-
color: 'primary',
|
95
|
-
menu: [],
|
96
|
-
children: null,
|
97
|
-
variant: 'contained',
|
98
|
-
onClick: noop,
|
99
|
-
menuButtonProps: {}
|
100
|
-
};
|
101
81
|
SplitButton.Item = MenuItem;
|
102
82
|
const StyledButtonGroup = styled(ButtonGroup)`
|
103
83
|
> .MuiButtonBase-root:last-of-type {
|
@@ -1,2 +1,11 @@
|
|
1
|
-
declare const _default: (props:
|
1
|
+
declare const _default: (props: {
|
2
|
+
[x: string]: any;
|
3
|
+
children: any;
|
4
|
+
startChars: any;
|
5
|
+
endChars: any;
|
6
|
+
scaleFactor: any;
|
7
|
+
maxWidth: any;
|
8
|
+
style: any;
|
9
|
+
fontType: any;
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
2
11
|
export default _default;
|
package/lib/Theme/index.d.ts
CHANGED
@@ -1,14 +1,6 @@
|
|
1
|
-
|
2
|
-
export { default as ThemeProvider } from "./theme-provider";
|
3
|
-
export { useTheme };
|
4
|
-
/**
|
5
|
-
* @typedef {import('@mui/material/styles').Theme} Theme
|
6
|
-
* @typedef {import('@mui/material/styles').CreateMUIStyled<Theme>} Styled
|
7
|
-
*/
|
8
|
-
/**
|
9
|
-
* @type {Styled}
|
10
|
-
*/
|
11
|
-
export const styled: Styled;
|
12
|
-
export type Theme = import("@mui/material/styles").Theme;
|
13
|
-
export type Styled = import("@mui/material/styles").CreateMUIStyled<Theme>;
|
1
|
+
import { CreateMUIStyled, Theme } from '@mui/material';
|
14
2
|
import { useTheme } from '@mui/material/styles';
|
3
|
+
export * from './theme';
|
4
|
+
export { default as ThemeProvider } from './theme-provider';
|
5
|
+
export { useTheme };
|
6
|
+
export declare const styled: CreateMUIStyled<Theme>;
|
package/lib/Theme/index.js
CHANGED
@@ -1,22 +1,15 @@
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
2
|
+
|
1
3
|
import { styled as muiStyled, useTheme } from '@mui/material/styles';
|
2
4
|
export * from './theme';
|
3
5
|
export { default as ThemeProvider } from './theme-provider';
|
4
6
|
export { useTheme };
|
5
7
|
const isTransientProp = prop => prop.startsWith('$');
|
6
|
-
|
7
|
-
/**
|
8
|
-
* @typedef {import('@mui/material/styles').Theme} Theme
|
9
|
-
* @typedef {import('@mui/material/styles').CreateMUIStyled<Theme>} Styled
|
10
|
-
*/
|
11
|
-
|
12
|
-
/**
|
13
|
-
* @type {Styled}
|
14
|
-
*/
|
15
|
-
export const styled = (component, options = {}) => {
|
8
|
+
export const styled = (component, options) => {
|
16
9
|
return muiStyled(component, {
|
17
10
|
...options,
|
18
11
|
shouldForwardProp: prop => {
|
19
|
-
if (options
|
12
|
+
if (options?.shouldForwardProp) {
|
20
13
|
return options.shouldForwardProp(prop) && !isTransientProp(prop);
|
21
14
|
}
|
22
15
|
return !isTransientProp(prop);
|
@@ -1,25 +1,23 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import { Theme } from '@mui/material/styles';
|
1
3
|
/**
|
2
4
|
* 默认的 theme provider, 可以为 webapp/blocklet 快捷的配置好 mui theme provider
|
3
5
|
*/
|
4
|
-
declare function ThemeProvider({ children, theme, injectFirst }: {
|
5
|
-
children:
|
6
|
-
theme:
|
7
|
-
injectFirst:
|
6
|
+
declare function ThemeProvider({ children, theme, injectFirst, }: {
|
7
|
+
children: React.ReactNode;
|
8
|
+
theme: Theme;
|
9
|
+
injectFirst: boolean;
|
8
10
|
}): import("react/jsx-runtime").JSX.Element;
|
9
11
|
declare namespace ThemeProvider {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
export { injectFirst_1 as injectFirst };
|
21
|
-
}
|
12
|
+
var propTypes: {
|
13
|
+
children: PropTypes.Requireable<any>;
|
14
|
+
theme: PropTypes.Requireable<any>;
|
15
|
+
injectFirst: PropTypes.Requireable<boolean>;
|
16
|
+
};
|
17
|
+
var defaultProps: {
|
18
|
+
children: null;
|
19
|
+
theme: Theme;
|
20
|
+
injectFirst: boolean;
|
21
|
+
};
|
22
22
|
}
|
23
23
|
export default ThemeProvider;
|
24
|
-
import PropTypes from 'prop-types';
|
25
|
-
declare const defaultTheme: import("@mui/material/styles").Theme;
|
package/lib/Theme/theme.d.ts
CHANGED
@@ -1,17 +1,43 @@
|
|
1
|
-
|
1
|
+
import { Components, type Theme, type ThemeOptions } from '@mui/material/styles';
|
2
|
+
import { Typography, TypographyOptions } from '@mui/material/styles/createTypography';
|
3
|
+
import '@fontsource/inter/latin-300.css';
|
4
|
+
import '@fontsource/inter/latin-400.css';
|
5
|
+
import '@fontsource/inter/latin-500.css';
|
6
|
+
import '@fontsource/inter/latin-700.css';
|
7
|
+
import '@fontsource/inter/latin-ext-300.css';
|
8
|
+
import '@fontsource/inter/latin-ext-400.css';
|
9
|
+
import '@fontsource/inter/latin-ext-500.css';
|
10
|
+
import '@fontsource/inter/latin-ext-700.css';
|
11
|
+
declare module '@mui/material/styles/createTheme' {
|
12
|
+
interface Theme {
|
13
|
+
mode?: string;
|
14
|
+
themeName?: string;
|
15
|
+
pageWidth?: string;
|
16
|
+
colors?: Record<string, string>;
|
17
|
+
typography: Typography & {
|
18
|
+
useNextVariants: boolean;
|
19
|
+
color: Record<string, string>;
|
20
|
+
button: {
|
21
|
+
fontWeight?: number;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
}
|
25
|
+
interface ThemeOptions {
|
26
|
+
mode?: string;
|
27
|
+
themeName?: string;
|
28
|
+
pageWidth?: string;
|
29
|
+
colors?: Record<string, string>;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
export declare const create: ({ mode, pageWidth, typography, overrides, palette, components, ...rest }?: {
|
2
33
|
mode?: string;
|
3
34
|
pageWidth?: string;
|
4
|
-
|
5
|
-
typography?: TypographyVariantsOptions;
|
35
|
+
typography?: TypographyOptions;
|
6
36
|
overrides?: Components<Omit<Theme, "components">>;
|
7
|
-
})
|
8
|
-
export
|
37
|
+
} & ThemeOptions) => Theme;
|
38
|
+
export declare const createTheme: ({ mode, pageWidth, typography, overrides, palette, components, ...rest }?: {
|
9
39
|
mode?: string;
|
10
40
|
pageWidth?: string;
|
11
|
-
|
12
|
-
typography?: TypographyVariantsOptions;
|
41
|
+
typography?: TypographyOptions;
|
13
42
|
overrides?: Components<Omit<Theme, "components">>;
|
14
|
-
})
|
15
|
-
export type Theme = import("@mui/material/styles").Theme;
|
16
|
-
export type TypographyVariantsOptions = import("@mui/material/styles").TypographyVariantsOptions;
|
17
|
-
export type Components = import("@mui/material/styles").Components;
|
43
|
+
} & ThemeOptions) => Theme;
|
package/lib/Theme/theme.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
2
|
+
/* eslint-disable no-shadow */
|
1
3
|
// https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
|
2
4
|
import { createTheme as _createTheme, responsiveFontSizes } from '@mui/material/styles';
|
3
5
|
// 为了避免加载全量的字体导致打包后体积太大,目前只选择了 latin 语系的字体
|
@@ -11,11 +13,7 @@ import '@fontsource/inter/latin-ext-500.css';
|
|
11
13
|
import '@fontsource/inter/latin-ext-700.css';
|
12
14
|
import colors from '../Colors';
|
13
15
|
|
14
|
-
|
15
|
-
* @typedef {import('@mui/material/styles').Theme} Theme
|
16
|
-
* @typedef {import('@mui/material/styles').TypographyVariantsOptions} TypographyVariantsOptions
|
17
|
-
* @typedef {import('@mui/material/styles').Components} Components
|
18
|
-
*/
|
16
|
+
// 扩展 Theme 和 ThemeOptions 接口
|
19
17
|
|
20
18
|
const muiDarkTheme = _createTheme({
|
21
19
|
palette: {
|
@@ -24,24 +22,15 @@ const muiDarkTheme = _createTheme({
|
|
24
22
|
});
|
25
23
|
|
26
24
|
// https://material-ui.com/customization/default-theme/
|
27
|
-
/**
|
28
|
-
* @description
|
29
|
-
* @export
|
30
|
-
* @param {{
|
31
|
-
* mode?: string,
|
32
|
-
* pageWidth?: string,
|
33
|
-
* palette?: import('@mui/material/styles').PaletteOptions,
|
34
|
-
* typography?: TypographyVariantsOptions,
|
35
|
-
* overrides?: Components<Omit<Theme, 'components'>>,
|
36
|
-
* }} options
|
37
|
-
* @return {Theme}
|
38
|
-
*/
|
39
25
|
export const create = ({
|
40
26
|
mode = 'light',
|
41
27
|
pageWidth = 'md',
|
42
|
-
palette,
|
43
28
|
typography,
|
44
|
-
|
29
|
+
/** @deprecated 使用 components 替代 */
|
30
|
+
overrides,
|
31
|
+
// original theme options
|
32
|
+
palette,
|
33
|
+
components,
|
45
34
|
...rest
|
46
35
|
} = {}) => {
|
47
36
|
// palette 考虑 light & dark mode, dark mode 需要持续完善
|
@@ -124,11 +113,13 @@ export const create = ({
|
|
124
113
|
}
|
125
114
|
}
|
126
115
|
},
|
127
|
-
...overrides
|
116
|
+
...overrides,
|
117
|
+
...components
|
128
118
|
},
|
129
119
|
pageWidth,
|
130
|
-
|
131
|
-
|
120
|
+
/**
|
121
|
+
* @deprecated 应使用 theme.palette 中的颜色
|
122
|
+
*/
|
132
123
|
colors: {
|
133
124
|
white: '#FFFFFF',
|
134
125
|
dark: '#4A707C',
|