@arcblock/ux 2.5.46 → 2.5.48

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.
@@ -29,7 +29,30 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
29
29
 
30
30
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
31
31
 
32
+ /**
33
+ * Action button component
34
+ * @typedef {{
35
+ * href: string;
36
+ * children?: import('react').ReactNode;
37
+ * gradient?: string;
38
+ * color?: string;
39
+ * icon?: string;
40
+ * border?: string;
41
+ * text?: string;
42
+ * theme?: string;
43
+ * variant?: string;
44
+ * size?: string;
45
+ * width?: string;
46
+ * }} ActionButtonProps
47
+ */
48
+
49
+ /**
50
+ * Action button component
51
+ * @param {ActionButtonProps} props
52
+ * @returns {JSX.Element}
53
+ */
32
54
  function ActionButton(props) {
55
+ /** @type {ActionButtonProps & {}} */
33
56
  const newProps = (0, _Util.mergeProps)(props, ActionButton);
34
57
 
35
58
  const {
@@ -44,6 +67,8 @@ function ActionButton(props) {
44
67
  text
45
68
  } = newProps,
46
69
  rest = _objectWithoutProperties(newProps, _excluded);
70
+ /** @type {import('react').CSSProperties} */
71
+
47
72
 
48
73
  const styles = {};
49
74
 
@@ -40,6 +40,16 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
40
40
 
41
41
  /**
42
42
  * ActivityIndicator is used when we want to tell the user the request they made on the UI will take time.
43
+ * @typedef {{
44
+ * interval?: number;
45
+ * messages: string[];
46
+ * } & import('react').ComponentPropsWithoutRef<"div"> } ActivityIndicatorProps
47
+ */
48
+
49
+ /**
50
+ * @description ActivityIndicator is used when we want to tell the user the request they made on the UI will take time.
51
+ * @param {ActivityIndicatorProps} props
52
+ * @returns {JSX.Element}
43
53
  */
44
54
  function ActivityIndicator(_ref) {
45
55
  let {
@@ -67,8 +67,25 @@ const types = {
67
67
  backgroundColor: '#EEEEEE'
68
68
  }
69
69
  };
70
+ /**
71
+ * Alert notification component
72
+ * @typedef {{
73
+ * type?: 'error' | 'warning' | 'success' | 'tip';
74
+ * children: any;
75
+ * className?: string;
76
+ * style?: object | string;
77
+ * variant?: 'border' | 'icon';
78
+ * } & import('react').ComponentPropsWithoutRef<"div"> } AlertProps
79
+ */
80
+
81
+ /**
82
+ * Alert notification component
83
+ * @param {AlertProps} props
84
+ * @returns {JSX.Element}
85
+ */
70
86
 
71
87
  function Alert(props) {
88
+ /** @type {AlertProps} */
72
89
  const newProps = (0, _Util.mergeProps)(props, Alert, ['style']);
73
90
 
74
91
  const {
@@ -86,6 +103,8 @@ function Alert(props) {
86
103
  backgroundColor,
87
104
  borderColor
88
105
  } = types[type] || types.success;
106
+ /** @type {import('react').CSSProperties} */
107
+
89
108
  const styles = Object.assign({
90
109
  color: _colors.blueGrey[500],
91
110
  backgroundColor: variant === 'border' ? backgroundColor : 'transparent',
@@ -54,7 +54,26 @@ const isEthereumDid = did => {
54
54
  }
55
55
 
56
56
  return true;
57
- }; // 参考: https://github.com/blocklet/block-explorer/issues/478#issuecomment-1038954976
57
+ };
58
+ /**
59
+ * Avatar component
60
+ * @typedef {{
61
+ * did: string;
62
+ * size?: number;
63
+ * variant?: 'circle' | 'rounded' | 'default';
64
+ * animation?: boolean;
65
+ * shape?: '' | 'rectangle' | 'square' | 'hexagon' | 'circle';
66
+ * src?: string;
67
+ * responsive?: boolean;
68
+ * }} AvatarProps
69
+ */
70
+
71
+ /**
72
+ * Avatar component
73
+ * @see 参考: https://github.com/blocklet/block-explorer/issues/478#issuecomment-1038954976
74
+ * @param {AvatarProps} props
75
+ * @returns {JSX.Element}
76
+ */
58
77
 
59
78
 
60
79
  function Avatar(props) {
@@ -134,13 +153,15 @@ Avatar.propTypes = {
134
153
  // animation 仅对 did motif 有效
135
154
  animation: _propTypes.default.bool,
136
155
  // shape 仅对 did motif 有效, 明确指定 motif shape, 而非由 did role type 自动推断 shape
137
- shape: _propTypes.default.oneOf(['', 'rectangle', 'square', 'hexagon', 'circle'])
156
+ shape: _propTypes.default.oneOf(['', 'rectangle', 'square', 'hexagon', 'circle']),
157
+ responsive: _propTypes.default.bool
138
158
  };
139
159
  Avatar.defaultProps = {
140
160
  size: 36,
141
161
  variant: 'default',
142
162
  animation: false,
143
- shape: ''
163
+ shape: '',
164
+ responsive: false
144
165
  };
145
166
  const BlockyIconContainer = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n width: ", "px;\n height: ", "px;\n .blocky-icon-inner {\n box-sizing: border-box;\n display: flex;\n justify-content: center;\n align-items: center;\n width: ", "px;\n height: ", "px;\n border-radius: ", "px;\n background: #ddd;\n }\n"])), props => props.$size, props => props.$size, props => props.$size, props => props.$size * 0.7, props => Math.min(10, Math.floor(0.1 * props.$size + 2)));
146
167
  const StyledImg = (0, _Theme.styled)(_Img.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &.avatar-img--rounded {\n border-radius: 4px;\n overflow: hidden;\n }\n &.avatar-img--circle {\n border-radius: 100%;\n overflow: hidden;\n }\n"])));
@@ -61,6 +61,22 @@ const types = {
61
61
  backgroundColor: _Colors.default.grey[900]
62
62
  }
63
63
  };
64
+ /**
65
+ * Badge component to display notification badge
66
+ * @typedef {{
67
+ * children: import('react').ReactNode;
68
+ * content?: string;
69
+ * type?: 'error' | 'warning' | 'success' | 'primary' | 'reverse';
70
+ * className?: string;
71
+ * style?: object | string;
72
+ * } & import('@mui/material').TypographyProps } BadgeProps
73
+ */
74
+
75
+ /**
76
+ * Badge notification component
77
+ * @param {BadgeProps} props
78
+ * @returns {JSX.Element}
79
+ */
64
80
 
65
81
  function Badge(props) {
66
82
  const newProps = (0, _Util.mergeProps)(props, Badge, ['style']);
@@ -46,6 +46,29 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
46
46
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
47
47
 
48
48
  const Div = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.arcblock-blocklet {\n padding: ", " ", " 0\n ", ";\n }\n .arcblock-blocklet__content {\n cursor: pointer;\n display: flex;\n ", " {\n align-items: center;\n }\n }\n .arcblock-blocklet__cover {\n width: 64px;\n height: 64px;\n margin-right: ", ";\n overflow: hidden;\n border-radius: 12px;\n /* see: https://stackoverflow.com/questions/49066011/overflow-hidden-with-border-radius-not-working-on-safari */\n transform: translateZ(0);\n ", " {\n width: 80px;\n height: 80px;\n margin-bottom: 12px;\n }\n }\n .arcblock-blocklet__button--hover {\n &:not(.Mui-disabled) {\n position: relative;\n z-index: 1;\n &::before {\n content: '';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n transition: opacity 0.3s;\n }\n &:hover::before {\n opacity: 0;\n }\n &::after {\n content: '';\n position: absolute;\n height: 100%;\n width: 100%;\n background-color: ", ";\n transform: scale(0.1);\n opacity: 0;\n z-index: -1;\n transition: transform 0.3s, opacity 0.3s, background-color 0.3s;\n }\n &:hover::after {\n opacity: 1;\n transform-origin: center;\n transform: scale(1);\n }\n }\n\n &:not(.Mui-disabled) {\n background-color: transparent !important;\n color: ", ";\n }\n &:not(.Mui-disabled) {\n &:hover {\n color: ", ";\n }\n }\n }\n .arcblock-blocklet__info {\n flex: 1;\n overflow: hidden;\n border-bottom: 1px solid ", ";\n padding-bottom: ", ";\n }\n .arcblock-blocklet__text {\n height: 57px;\n overflow: hidden;\n }\n /* \u8BBE\u7F6E\u591A\u884C\u6587\u672C\u6EA2\u51FA\u663E\u793A\u7701\u7565\u53F7 \u517C\u5BB9fireFox\u3001safari */\n .arcblock-blocklet__title {\n margin: 0;\n font-size: 16px;\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .arcblock-blocklet__describe {\n margin-top: ", ";\n color: ", ";\n font-size: 14px;\n font-weight: 500;\n line-height: 17px;\n max-height: 34px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n word-break: break-word;\n }\n .arcblock-blocklet__version {\n color: ", ";\n font-size: 12px;\n }\n"])), props => props.theme.spacing(2), props => props.theme.spacing(2), props => props.theme.spacing(2), props => props.theme.breakpoints.up('sm'), props => props.theme.spacing(2), props => props.theme.breakpoints.up('sm'), props => props.theme.palette.primary.main, props => props.theme.palette.primary.main, props => props.theme.palette.common.white, props => props.theme.palette.divider, props => props.theme.spacing(2), props => props.theme.spacing(0.5), props => props.theme.palette.grey[600], props => props.theme.palette.grey[600]);
49
+ /**
50
+ * BlockletStore component
51
+ * @typedef {{
52
+ * title?: string | JSX.Element;
53
+ * did?: string;
54
+ * description?: string | JSX.Element;
55
+ * cover?: string;
56
+ * version?: string;
57
+ * buttonText?: string;
58
+ * buttonDisabled?: boolean;
59
+ * buttonLoading?: boolean;
60
+ * button?: JSX.Element;
61
+ * onButtonClick?: Function;
62
+ * onMainClick?: Function;
63
+ * className?: string;
64
+ * } & import('react').ComponentPropsWithoutRef<"div"> } BlockletStoreProps
65
+ */
66
+
67
+ /**
68
+ * BlockletStore component
69
+ * @param {BlockletStoreProps} props
70
+ * @returns {JSX.Element}
71
+ */
49
72
 
50
73
  function BlockletStore(_ref) {
51
74
  let {
@@ -86,6 +86,33 @@ function BlockletIcon(_ref) {
86
86
  BlockletIcon.propTypes = {
87
87
  name: _propTypes.default.string.isRequired
88
88
  };
89
+ /**
90
+ * BlockletNFT 组件
91
+ * @typedef {{
92
+ * title: string;
93
+ * description?: string;
94
+ * cover?: string;
95
+ * did?: string;
96
+ * isStickyButton?: boolean;
97
+ * buttonText?: string;
98
+ * buttonDisabled?: boolean;
99
+ * buttonLoading?: boolean;
100
+ * button?: JSX.Element;
101
+ * addons?: Array<any>;
102
+ * size?: 'xs' | 'sm' | 'md' | 'auto';
103
+ * onButtonClick?: Function;
104
+ * onMainClick?: Function;
105
+ * onTagClick?: Function;
106
+ * className?: string;
107
+ * scaleClickZone?: number;
108
+ * } & import('react').ComponentPropsWithoutRef<"div"> } BlockletNFTProps
109
+ */
110
+
111
+ /**
112
+ * BlockletNFT 组件
113
+ * @param {BlockletNFTProps} props
114
+ * @returns {JSX.Element}
115
+ */
89
116
 
90
117
  function BlockletNFT(_ref2) {
91
118
  let {
@@ -27,7 +27,25 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
27
27
 
28
28
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
29
 
30
+ /**
31
+ @typedef {Object} ConfirmProps
32
+ @property {boolean} open
33
+ @property {React.ReactNode} title
34
+ @property {React.ReactNode} children
35
+ @property {() => void | Promise<void>} onConfirm
36
+ @property {() => void | Promise<void>} onCancel
37
+ @property {boolean} [showCancelButton=true]
38
+ @property {{text: string, props?: import('../Button/wrap').ButtonProps}} [confirmButton={text: 'Confirm'}]
39
+ @property {{text: string, props?: import('../Button/wrap').ButtonProps}} [cancelButton={text: 'Cancel'}]
40
+ @property {import('@mui/material').PaperProps} [PaperProps={}]
41
+ */
30
42
  // 注意排在 {...rest} 之后的 props 优先级更高
43
+
44
+ /**
45
+ *
46
+ * @param {ConfirmProps} props
47
+ * @returns {import('react').ReactComponentElement}
48
+ */
31
49
  function Confirm(_ref) {
32
50
  let {
33
51
  title,
@@ -41,6 +41,26 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
41
41
 
42
42
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
43
43
 
44
+ /**
45
+ @typedef {import('@mui/material').PaperProps & {
46
+ minWidth: number | string,
47
+ minHeight: number | string,
48
+ }} PaperStyle
49
+ */
50
+
51
+ /**
52
+ @typedef {Object} DialogProps
53
+ @property {React.ReactNode} children - The content of the dialog.
54
+ @property {React.ReactNode} [title] - The title of the dialog.
55
+ @property {React.ReactNode} [prepend] - Content to be displayed before the dialog title.
56
+ @property {React.ReactNode} [toolbar] - Content to be displayed in the top toolbar of the dialog.
57
+ @property {React.ReactNode} [actions] - Content to be displayed in the bottom actions toolbar of the dialog.
58
+ @property {boolean} [showCloseButton=true] - Whether or not to show the close button.
59
+ @property {'left'|'center'|'right'} [actionsPosition='right'] - The position of the actions toolbar.
60
+ @property {PaperStyle} [PaperProps] - Props to be passed down to the dialog paper.
61
+ @property {(event: React.SyntheticEvent, reason: string) => void} [onClose] - Callback function fired when the dialog is closed.
62
+ */
63
+
44
64
  /**
45
65
  * Dialog
46
66
  *
@@ -48,6 +68,12 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
48
68
  * 注意: 当设置明确的 width 时, 可能需要同时设置 maxWidth=false (mui dialog 默认 maxWidth=sm, 设置的 width 可能受限)
49
69
  * - 添加默认最小尺寸 (300x300), 在需要 先展示 loading 再展示异步数据 的时候避免 loading 阶段窗口过小
50
70
  */
71
+
72
+ /**
73
+ * @description
74
+ * @param {DialogProps} props
75
+ * @return {React.ReactComponentElement}
76
+ */
51
77
  function Dialog(_ref) {
52
78
  let {
53
79
  children,
@@ -142,7 +168,13 @@ Dialog.defaultProps = {
142
168
  actionsPosition: 'right',
143
169
  PaperProps: {}
144
170
  };
171
+ /**
172
+ * @type {import('@emotion/styled').StyledComponent<import('@mui/material').DialogProps, {}, { ref?: React.Ref<any> | undefined;}>}
173
+ */
174
+
145
175
  const StyledMuiDialog = (0, _Theme.styled)(_Dialog.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .MuiDialog-paper {\n ", ";\n }\n .MuiDialogContent-root {\n padding: 16px 24px;\n }\n .MuiDialogActions-root {\n padding: 8px 24px 16px 24px;\n }\n .MuiDialogActions-root.ux-dialog_actions--left {\n justify-content: flex-start;\n }\n .MuiDialogActions-root.ux-dialog_actions--right {\n justify-content: flex-end;\n }\n .MuiDialogActions-root.ux-dialog_actions--center {\n justify-content: center;\n }\n"])), props => props.fullScreen ? 'border-radius: 0;' : '');
176
+ /** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
177
+
146
178
  const Header = (0, _Theme.styled)('div')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 16px 24px;\n .ux-dialog_left {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n min-width: 0;\n }\n .ux-dialog_right {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n }\n .ux-dialog_toolbar {\n display: flex;\n align-items: center;\n }\n .ux-dialog_title {\n margin: 0;\n font-size: 18px;\n font-weight: 500;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .ux-dialog_closeButton {\n /* \u4F7F closeButton \u4E0E content \u5DE6/\u53F3\u5BF9\u9F50 */\n ", "\n }\n"])), props => props.isMobile ? 'margin-left: -12px;' : 'margin-right: -12px;');
147
179
  var _default = Dialog;
148
180
  exports.default = _default;
@@ -32,6 +32,20 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
32
32
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
33
33
 
34
34
  const Wrapper = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: 100%;\n min-height: 100px;\n color: #999;\n .empty-icon {\n margin: 10px 0;\n }\n"])));
35
+ /**
36
+ * Empty component to display empty state
37
+ * @typedef {{
38
+ * color?: string;
39
+ * size?: number;
40
+ * children?: import('react').ReactNode;
41
+ * } & import('react').ComponentPropsWithoutRef<"div"> } EmptyProps
42
+ */
43
+
44
+ /**
45
+ * Empty state component
46
+ * @param {EmptyProps} props
47
+ * @returns {JSX.Element}
48
+ */
35
49
 
36
50
  function Empty(_ref) {
37
51
  let {
package/lib/Img/index.js CHANGED
@@ -35,10 +35,34 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
35
35
 
36
36
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
37
37
 
38
+ /**
39
+ * @typedef {Object} ImgExProps
40
+ * @property {string} src - required
41
+ * @property {string} [alt]
42
+ * @property {string} [size='cover']
43
+ * @property {string} [position='top center']
44
+ * @property {object} [style]
45
+ * @property {number} [ratio=1]
46
+ * @property {string} [repeat='no-repeat']
47
+ * @property {number} [width]
48
+ * @property {number} [height]
49
+ * @property {boolean} [lazy=true]
50
+ * @property {string} [placeholder]
51
+ * @property {string} [fallback]
52
+ * @property {string} [className='']
53
+ * @property {function} [onError=() => {}]
54
+ * @property {function} [onSuccess=() => {}]
55
+ */
56
+
57
+ /**
58
+ * @typedef {ImgExProps & import('react').ComponentPropsWithoutRef<"div">} ImgProps
59
+ */
38
60
  const PREFIX = 'Img';
39
61
  const classes = {
40
62
  root: "".concat(PREFIX, "-root")
41
63
  };
64
+ /** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
65
+
42
66
  const Root = (0, _Theme.styled)('div')(() => ({
43
67
  ["& .".concat(classes.root)]: {
44
68
  position: 'relative',
@@ -72,6 +96,11 @@ const Root = (0, _Theme.styled)('div')(() => ({
72
96
  }
73
97
  }
74
98
  }));
99
+ /**
100
+ *
101
+ * @param {ImgProps} props
102
+ * @returns {React.ReactComponentElement}
103
+ */
75
104
 
76
105
  function Img(_ref) {
77
106
  let {
@@ -124,6 +153,9 @@ function Img(_ref) {
124
153
  paddingTop: "".concat(actualRatio, "%")
125
154
  }), // eslint-disable-next-line react-hooks/exhaustive-deps
126
155
  [actualSrc, position, size, imgState]);
156
+ /**
157
+ * @type {CSSStyleDeclaration}
158
+ */
127
159
 
128
160
  const outerStyle = _objectSpread(_objectSpread({}, style), {}, {
129
161
  display: 'inline-block',
package/lib/Logo/index.js CHANGED
@@ -107,6 +107,21 @@ DarkText.defaultProps = {
107
107
  height: "18",
108
108
  viewBox: "0 0 99 18"
109
109
  };
110
+ /**
111
+ @typedef {import('react').HTMLAttributes<HTMLSpanElement> & {
112
+ mode?: 'light' | 'dark',
113
+ layout?: 'vertical' | 'horizontal',
114
+ showText?: boolean,
115
+ showLogo?: boolean,
116
+ }} LogoProps
117
+ */
118
+
119
+ /**
120
+ * @description
121
+ * @export
122
+ * @param {LogoProps} props
123
+ * @return {React.ReactComponentElement}
124
+ */
110
125
 
111
126
  function Logo(_ref) {
112
127
  let {
@@ -142,4 +157,6 @@ Logo.defaultProps = {
142
157
  showText: true,
143
158
  showLogo: true
144
159
  };
160
+ /** @type {import('@emotion/styled').StyledComponent<HTMLSpanElement, {}, { ref?: React.Ref<any> | undefined;}>} */
161
+
145
162
  const Container = (0, _Theme.styled)('span')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n flex-direction: ", ";\n justify-content: center;\n align-items: center;\n\n .logo-text {\n ", "\n ", ";\n }\n"])), props => props.layout === 'horizontal' ? 'row' : 'column', props => props.layout === 'vertical' ? 'margin-top: 8px;' : '', props => props.layout === 'vertical' ? '' : 'margin-left: 8px;');
@@ -480,7 +480,8 @@ SessionManager.propTypes = {
480
480
  switchDid: _propTypes.default.func.isRequired,
481
481
  switchProfile: _propTypes.default.func.isRequired,
482
482
  switchPassport: _propTypes.default.func.isRequired,
483
- bindWallet: _propTypes.default.func.isRequired
483
+ bindWallet: _propTypes.default.func.isRequired,
484
+ refresh: _propTypes.default.func.isRequired
484
485
  }).isRequired,
485
486
  locale: _propTypes.default.string,
486
487
  showText: _propTypes.default.bool,
@@ -47,8 +47,23 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
47
47
 
48
48
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
49
49
 
50
+ /**
51
+ * SplitButton 组件 Props
52
+ * @typedef {{
53
+ * size?: 'small' | 'medium' | 'large';
54
+ * color?: 'primary' | 'secondary' | 'inherit';
55
+ * menu?: Array<import('@mui/material').MenuItem> | import('@mui/material').MenuItem>;
56
+ * children?: JSX.Element | (() => JSX.Element);
57
+ * variant?: 'outlined' | 'contained';
58
+ * onClick?: () => void;
59
+ * menuButtonProps?: import('@mui/material').ButtonProps;
60
+ * } & import('@mui/material').ButtonGroupProps } SplitButtonProps
61
+ */
62
+
50
63
  /**
51
64
  * SplitButton allows the user to execute a default action which is bound to a Button or to choose a predefined action from a drop-down list.
65
+ * @param {SplitButtonProps} props
66
+ * @returns {JSX.Element}
52
67
  */
53
68
  function SplitButton(_ref) {
54
69
  let {
@@ -83,7 +98,7 @@ function SplitButton(_ref) {
83
98
 
84
99
 
85
100
  const handleItemClick = e => {
86
- if (e.target.classList.contains('MuiMenuItem-root')) {
101
+ if (e.target.closest('.MuiMenuItem-root')) {
87
102
  setOpen(false);
88
103
  }
89
104
  };
@@ -143,6 +158,10 @@ SplitButton.defaultProps = {
143
158
  onClick: () => {},
144
159
  menuButtonProps: {}
145
160
  };
161
+ /**
162
+ * @type {import('@mui/material').MenuItem}
163
+ */
164
+
146
165
  SplitButton.Item = _MenuItem.default;
147
166
  const StyledButtonGroup = (0, _Theme.styled)(_ButtonGroup.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n > .MuiButtonBase-root:last-of-type {\n min-width: 2em;\n padding-left: 0;\n padding-right: 0;\n }\n"])));
148
167
  const StyledPopper = (0, _Theme.styled)(_Popper.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n z-index: ", ";\n .MuiList-root {\n padding: 4px 0;\n }\n .MuiListItem-root {\n padding-top: 4px;\n padding-bottom: 4px;\n }\n"])), props => props.theme.zIndex.tooltip);
@@ -84,8 +84,18 @@ const IOSSwitch = (0, _Theme.styled)(props => /*#__PURE__*/(0, _jsxRuntime.jsx)(
84
84
  };
85
85
  });
86
86
  /**
87
- * 抽取 blocklet server 中使用的 iOS 风格的 Switch, 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
87
+ * Switch 组件 Props
88
+ * @typedef {{
89
+ * labelProps?: import('@mui/material').FormControlLabelProps;
90
+ * } & import('@mui/material').SwitchProps } SwitchProps
91
+ */
92
+
93
+ /**
94
+ * 抽取 blocklet server 中使用的 iOS 风格的 Switch,
95
+ * 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
88
96
  * 兼容 mui Switch props, 使用 labelProps 控制 FormControlLabel
97
+ * @param {SwitchProps} props
98
+ * @returns {JSX.Element}
89
99
  */
90
100
 
91
101
  function Switch(_ref2) {
@@ -24,12 +24,22 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
24
24
 
25
25
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
26
 
27
+ /**
28
+ * @type {import('notistack').ProviderContext['enqueueSnackbar']}
29
+ */
27
30
  const noop = () => {};
28
31
 
29
32
  let _success = noop;
30
33
  let _error = noop;
31
34
  let _warning = noop;
32
35
  let _info = noop;
36
+ /**
37
+ * @description
38
+ * @param {(message: import('notistack').SnackbarMessage, options?: import('notistack').OptionsObject) => import('notistack').SnackbarKey} enqueueSnackbar
39
+ * @param {import('notistack').ProviderContext['enqueueSnackbar']} enqueueSnackbar
40
+ * @param {import('notistack').VariantType} variant
41
+ * @returns {import('notistack').ProviderContext['enqueueSnackbar']}
42
+ */
33
43
 
34
44
  const genFn = (enqueueSnackbar, variant) => (message, opts) => {
35
45
  enqueueSnackbar(message, _objectSpread({
@@ -83,17 +93,60 @@ function Toast() {
83
93
  }
84
94
 
85
95
  var _default = {
86
- success: function success() {
87
- return _success(...arguments);
96
+ /**
97
+ *
98
+ * @param {import('notistack').SnackbarMessage} message
99
+ * @param {import('notistack').OptionsObject} options
100
+ * @returns {import('notistack').SnackbarKey}
101
+ */
102
+ success: function success(message, options) {
103
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
104
+ args[_key - 2] = arguments[_key];
105
+ }
106
+
107
+ return _success(message, options, ...args);
88
108
  },
89
- error: function error() {
90
- return _error(...arguments);
109
+
110
+ /**
111
+ *
112
+ * @param {import('notistack').SnackbarMessage} message
113
+ * @param {import('notistack').OptionsObject} options
114
+ * @returns {import('notistack').SnackbarKey}
115
+ */
116
+ error: function error(message, options) {
117
+ for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
118
+ args[_key2 - 2] = arguments[_key2];
119
+ }
120
+
121
+ return _error(message, options, ...args);
91
122
  },
92
- warning: function warning() {
93
- return _warning(...arguments);
123
+
124
+ /**
125
+ *
126
+ * @param {import('notistack').SnackbarMessage} message
127
+ * @param {import('notistack').OptionsObject} options
128
+ * @returns {import('notistack').SnackbarKey}
129
+ */
130
+ warning: function warning(message, options) {
131
+ for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
132
+ args[_key3 - 2] = arguments[_key3];
133
+ }
134
+
135
+ return _warning(message, options, ...args);
94
136
  },
95
- info: function info() {
96
- return _info(...arguments);
137
+
138
+ /**
139
+ *
140
+ * @param {import('notistack').SnackbarMessage} message
141
+ * @param {import('notistack').OptionsObject} options
142
+ * @returns {import('notistack').SnackbarKey}
143
+ */
144
+ info: function info(message, options) {
145
+ for (var _len4 = arguments.length, args = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
146
+ args[_key4 - 2] = arguments[_key4];
147
+ }
148
+
149
+ return _info(message, options, ...args);
97
150
  }
98
151
  };
99
152
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.5.46",
3
+ "version": "2.5.48",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -45,11 +45,11 @@
45
45
  "peerDependencies": {
46
46
  "react": ">=18.1.0"
47
47
  },
48
- "gitHead": "6c4af406becbfe36208b41d76acaa7dc97528cc0",
48
+ "gitHead": "79c5d91c07cd0d7c76286b9865d902a27acc163f",
49
49
  "dependencies": {
50
50
  "@arcblock/did-motif": "^1.1.10",
51
- "@arcblock/icons": "^2.5.46",
52
- "@arcblock/react-hooks": "^2.5.46",
51
+ "@arcblock/icons": "^2.5.48",
52
+ "@arcblock/react-hooks": "^2.5.48",
53
53
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
54
54
  "@emotion/react": "^11.10.4",
55
55
  "@emotion/styled": "^11.10.4",
@@ -4,9 +4,34 @@ import Button from '../Button';
4
4
  import { mergeProps } from '../Util';
5
5
  import { withDeprecated } from '../Util/deprecate';
6
6
 
7
+ /**
8
+ * Action button component
9
+ * @typedef {{
10
+ * href: string;
11
+ * children?: import('react').ReactNode;
12
+ * gradient?: string;
13
+ * color?: string;
14
+ * icon?: string;
15
+ * border?: string;
16
+ * text?: string;
17
+ * theme?: string;
18
+ * variant?: string;
19
+ * size?: string;
20
+ * width?: string;
21
+ * }} ActionButtonProps
22
+ */
23
+
24
+ /**
25
+ * Action button component
26
+ * @param {ActionButtonProps} props
27
+ * @returns {JSX.Element}
28
+ */
7
29
  function ActionButton(props) {
30
+ /** @type {ActionButtonProps & {}} */
8
31
  const newProps = mergeProps(props, ActionButton);
9
32
  const { href, icon, size, color, theme, variant, gradient, children, text, ...rest } = newProps;
33
+
34
+ /** @type {import('react').CSSProperties} */
10
35
  const styles = {};
11
36
  if (gradient) {
12
37
  styles.backgroundImage = gradient;
@@ -8,6 +8,16 @@ import { styled } from '../Theme';
8
8
 
9
9
  /**
10
10
  * ActivityIndicator is used when we want to tell the user the request they made on the UI will take time.
11
+ * @typedef {{
12
+ * interval?: number;
13
+ * messages: string[];
14
+ * } & import('react').ComponentPropsWithoutRef<"div"> } ActivityIndicatorProps
15
+ */
16
+
17
+ /**
18
+ * @description ActivityIndicator is used when we want to tell the user the request they made on the UI will take time.
19
+ * @param {ActivityIndicatorProps} props
20
+ * @returns {JSX.Element}
11
21
  */
12
22
  export default function ActivityIndicator({ messages, interval, ...rest }) {
13
23
  const [index, setIndex] = useState(0);
@@ -35,10 +35,29 @@ const types = {
35
35
  },
36
36
  };
37
37
 
38
+ /**
39
+ * Alert notification component
40
+ * @typedef {{
41
+ * type?: 'error' | 'warning' | 'success' | 'tip';
42
+ * children: any;
43
+ * className?: string;
44
+ * style?: object | string;
45
+ * variant?: 'border' | 'icon';
46
+ * } & import('react').ComponentPropsWithoutRef<"div"> } AlertProps
47
+ */
48
+
49
+ /**
50
+ * Alert notification component
51
+ * @param {AlertProps} props
52
+ * @returns {JSX.Element}
53
+ */
38
54
  function Alert(props) {
55
+ /** @type {AlertProps} */
39
56
  const newProps = mergeProps(props, Alert, ['style']);
40
57
  const { type, children, style, className, variant, ...rest } = newProps;
41
58
  const { icon, color, backgroundColor, borderColor } = types[type] || types.success;
59
+
60
+ /** @type {import('react').CSSProperties} */
42
61
  const styles = Object.assign(
43
62
  {
44
63
  color: blueGrey[500],
@@ -20,7 +20,25 @@ const isEthereumDid = (did) => {
20
20
  return true;
21
21
  };
22
22
 
23
- // 参考: https://github.com/blocklet/block-explorer/issues/478#issuecomment-1038954976
23
+ /**
24
+ * Avatar component
25
+ * @typedef {{
26
+ * did: string;
27
+ * size?: number;
28
+ * variant?: 'circle' | 'rounded' | 'default';
29
+ * animation?: boolean;
30
+ * shape?: '' | 'rectangle' | 'square' | 'hexagon' | 'circle';
31
+ * src?: string;
32
+ * responsive?: boolean;
33
+ * }} AvatarProps
34
+ */
35
+
36
+ /**
37
+ * Avatar component
38
+ * @see 参考: https://github.com/blocklet/block-explorer/issues/478#issuecomment-1038954976
39
+ * @param {AvatarProps} props
40
+ * @returns {JSX.Element}
41
+ */
24
42
  function Avatar(props) {
25
43
  const [imgError, setImgError] = useState(false);
26
44
  const newProps = mergeProps(props, Avatar, []);
@@ -89,6 +107,7 @@ Avatar.propTypes = {
89
107
  animation: PropTypes.bool,
90
108
  // shape 仅对 did motif 有效, 明确指定 motif shape, 而非由 did role type 自动推断 shape
91
109
  shape: PropTypes.oneOf(['', 'rectangle', 'square', 'hexagon', 'circle']),
110
+ responsive: PropTypes.bool,
92
111
  };
93
112
 
94
113
  Avatar.defaultProps = {
@@ -96,6 +115,7 @@ Avatar.defaultProps = {
96
115
  variant: 'default',
97
116
  animation: false,
98
117
  shape: '',
118
+ responsive: false,
99
119
  };
100
120
 
101
121
  const BlockyIconContainer = styled('div')`
@@ -30,6 +30,22 @@ const types = {
30
30
  },
31
31
  };
32
32
 
33
+ /**
34
+ * Badge component to display notification badge
35
+ * @typedef {{
36
+ * children: import('react').ReactNode;
37
+ * content?: string;
38
+ * type?: 'error' | 'warning' | 'success' | 'primary' | 'reverse';
39
+ * className?: string;
40
+ * style?: object | string;
41
+ * } & import('@mui/material').TypographyProps } BadgeProps
42
+ */
43
+
44
+ /**
45
+ * Badge notification component
46
+ * @param {BadgeProps} props
47
+ * @returns {JSX.Element}
48
+ */
33
49
  function Badge(props) {
34
50
  const newProps = mergeProps(props, Badge, ['style']);
35
51
  const { type, content, children, style, className, forwardedRef, ...rest } = newProps;
@@ -119,6 +119,30 @@ const Div = styled('div')`
119
119
  font-size: 12px;
120
120
  }
121
121
  `;
122
+
123
+ /**
124
+ * BlockletStore component
125
+ * @typedef {{
126
+ * title?: string | JSX.Element;
127
+ * did?: string;
128
+ * description?: string | JSX.Element;
129
+ * cover?: string;
130
+ * version?: string;
131
+ * buttonText?: string;
132
+ * buttonDisabled?: boolean;
133
+ * buttonLoading?: boolean;
134
+ * button?: JSX.Element;
135
+ * onButtonClick?: Function;
136
+ * onMainClick?: Function;
137
+ * className?: string;
138
+ * } & import('react').ComponentPropsWithoutRef<"div"> } BlockletStoreProps
139
+ */
140
+
141
+ /**
142
+ * BlockletStore component
143
+ * @param {BlockletStoreProps} props
144
+ * @returns {JSX.Element}
145
+ */
122
146
  export default function BlockletStore({
123
147
  title,
124
148
  did,
@@ -198,6 +198,33 @@ BlockletIcon.propTypes = {
198
198
  name: PropTypes.string.isRequired,
199
199
  };
200
200
 
201
+ /**
202
+ * BlockletNFT 组件
203
+ * @typedef {{
204
+ * title: string;
205
+ * description?: string;
206
+ * cover?: string;
207
+ * did?: string;
208
+ * isStickyButton?: boolean;
209
+ * buttonText?: string;
210
+ * buttonDisabled?: boolean;
211
+ * buttonLoading?: boolean;
212
+ * button?: JSX.Element;
213
+ * addons?: Array<any>;
214
+ * size?: 'xs' | 'sm' | 'md' | 'auto';
215
+ * onButtonClick?: Function;
216
+ * onMainClick?: Function;
217
+ * onTagClick?: Function;
218
+ * className?: string;
219
+ * scaleClickZone?: number;
220
+ * } & import('react').ComponentPropsWithoutRef<"div"> } BlockletNFTProps
221
+ */
222
+
223
+ /**
224
+ * BlockletNFT 组件
225
+ * @param {BlockletNFTProps} props
226
+ * @returns {JSX.Element}
227
+ */
201
228
  export default function BlockletNFT({
202
229
  title,
203
230
  did,
@@ -2,7 +2,25 @@ import PropTypes from 'prop-types';
2
2
  import Button from '../Button';
3
3
  import Dialog from './dialog';
4
4
 
5
+ /**
6
+ @typedef {Object} ConfirmProps
7
+ @property {boolean} open
8
+ @property {React.ReactNode} title
9
+ @property {React.ReactNode} children
10
+ @property {() => void | Promise<void>} onConfirm
11
+ @property {() => void | Promise<void>} onCancel
12
+ @property {boolean} [showCancelButton=true]
13
+ @property {{text: string, props?: import('../Button/wrap').ButtonProps}} [confirmButton={text: 'Confirm'}]
14
+ @property {{text: string, props?: import('../Button/wrap').ButtonProps}} [cancelButton={text: 'Cancel'}]
15
+ @property {import('@mui/material').PaperProps} [PaperProps={}]
16
+ */
17
+
5
18
  // 注意排在 {...rest} 之后的 props 优先级更高
19
+ /**
20
+ *
21
+ * @param {ConfirmProps} props
22
+ * @returns {import('react').ReactComponentElement}
23
+ */
6
24
  export default function Confirm({
7
25
  title,
8
26
  children,
@@ -8,6 +8,26 @@ import CloseIcon from '@mui/icons-material/Close';
8
8
 
9
9
  import { styled, useTheme } from '../Theme';
10
10
 
11
+ /**
12
+ @typedef {import('@mui/material').PaperProps & {
13
+ minWidth: number | string,
14
+ minHeight: number | string,
15
+ }} PaperStyle
16
+ */
17
+
18
+ /**
19
+ @typedef {Object} DialogProps
20
+ @property {React.ReactNode} children - The content of the dialog.
21
+ @property {React.ReactNode} [title] - The title of the dialog.
22
+ @property {React.ReactNode} [prepend] - Content to be displayed before the dialog title.
23
+ @property {React.ReactNode} [toolbar] - Content to be displayed in the top toolbar of the dialog.
24
+ @property {React.ReactNode} [actions] - Content to be displayed in the bottom actions toolbar of the dialog.
25
+ @property {boolean} [showCloseButton=true] - Whether or not to show the close button.
26
+ @property {'left'|'center'|'right'} [actionsPosition='right'] - The position of the actions toolbar.
27
+ @property {PaperStyle} [PaperProps] - Props to be passed down to the dialog paper.
28
+ @property {(event: React.SyntheticEvent, reason: string) => void} [onClose] - Callback function fired when the dialog is closed.
29
+ */
30
+
11
31
  /**
12
32
  * Dialog
13
33
  *
@@ -15,6 +35,11 @@ import { styled, useTheme } from '../Theme';
15
35
  * 注意: 当设置明确的 width 时, 可能需要同时设置 maxWidth=false (mui dialog 默认 maxWidth=sm, 设置的 width 可能受限)
16
36
  * - 添加默认最小尺寸 (300x300), 在需要 先展示 loading 再展示异步数据 的时候避免 loading 阶段窗口过小
17
37
  */
38
+ /**
39
+ * @description
40
+ * @param {DialogProps} props
41
+ * @return {React.ReactComponentElement}
42
+ */
18
43
  function Dialog({ children, title, prepend, toolbar, actions, showCloseButton, actionsPosition, PaperProps, ...rest }) {
19
44
  const theme = useTheme();
20
45
  // 不管是否是 mobile 设备, 只要屏宽 < sm, dialog 就处于 mobile 模式
@@ -86,7 +111,9 @@ Dialog.defaultProps = {
86
111
  actionsPosition: 'right',
87
112
  PaperProps: {},
88
113
  };
89
-
114
+ /**
115
+ * @type {import('@emotion/styled').StyledComponent<import('@mui/material').DialogProps, {}, { ref?: React.Ref<any> | undefined;}>}
116
+ */
90
117
  const StyledMuiDialog = styled(MuiDialog)`
91
118
  .MuiDialog-paper {
92
119
  ${(props) => (props.fullScreen ? 'border-radius: 0;' : '')};
@@ -108,6 +135,7 @@ const StyledMuiDialog = styled(MuiDialog)`
108
135
  }
109
136
  `;
110
137
 
138
+ /** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
111
139
  const Header = styled('div')`
112
140
  display: flex;
113
141
  justify-content: space-between;
@@ -15,6 +15,20 @@ const Wrapper = styled('div')`
15
15
  }
16
16
  `;
17
17
 
18
+ /**
19
+ * Empty component to display empty state
20
+ * @typedef {{
21
+ * color?: string;
22
+ * size?: number;
23
+ * children?: import('react').ReactNode;
24
+ * } & import('react').ComponentPropsWithoutRef<"div"> } EmptyProps
25
+ */
26
+
27
+ /**
28
+ * Empty state component
29
+ * @param {EmptyProps} props
30
+ * @returns {JSX.Element}
31
+ */
18
32
  function Empty({ color, size, children, ...rest }) {
19
33
  return (
20
34
  <Wrapper {...rest}>
package/src/Img/index.js CHANGED
@@ -6,12 +6,36 @@ import Alert from 'mdi-material-ui/Alert';
6
6
  import ImageIcon from 'mdi-material-ui/Image';
7
7
  import { styled } from '../Theme';
8
8
 
9
+ /**
10
+ * @typedef {Object} ImgExProps
11
+ * @property {string} src - required
12
+ * @property {string} [alt]
13
+ * @property {string} [size='cover']
14
+ * @property {string} [position='top center']
15
+ * @property {object} [style]
16
+ * @property {number} [ratio=1]
17
+ * @property {string} [repeat='no-repeat']
18
+ * @property {number} [width]
19
+ * @property {number} [height]
20
+ * @property {boolean} [lazy=true]
21
+ * @property {string} [placeholder]
22
+ * @property {string} [fallback]
23
+ * @property {string} [className='']
24
+ * @property {function} [onError=() => {}]
25
+ * @property {function} [onSuccess=() => {}]
26
+ */
27
+
28
+ /**
29
+ * @typedef {ImgExProps & import('react').ComponentPropsWithoutRef<"div">} ImgProps
30
+ */
31
+
9
32
  const PREFIX = 'Img';
10
33
 
11
34
  const classes = {
12
35
  root: `${PREFIX}-root`,
13
36
  };
14
37
 
38
+ /** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
15
39
  const Root = styled('div')(() => ({
16
40
  [`& .${classes.root}`]: {
17
41
  position: 'relative',
@@ -46,6 +70,11 @@ const Root = styled('div')(() => ({
46
70
  },
47
71
  }));
48
72
 
73
+ /**
74
+ *
75
+ * @param {ImgProps} props
76
+ * @returns {React.ReactComponentElement}
77
+ */
49
78
  function Img({
50
79
  lazy,
51
80
  width,
@@ -97,6 +126,9 @@ function Img({
97
126
  [actualSrc, position, size, imgState]
98
127
  );
99
128
 
129
+ /**
130
+ * @type {CSSStyleDeclaration}
131
+ */
100
132
  const outerStyle = {
101
133
  ...style,
102
134
  display: 'inline-block',
package/src/Logo/index.js CHANGED
@@ -7,6 +7,21 @@ import { ReactComponent as LightText } from './images/logo-light-text.svg';
7
7
  import { ReactComponent as DarkLogo } from './images/logo-dark-top.svg';
8
8
  import { ReactComponent as DarkText } from './images/logo-dark-text.svg';
9
9
 
10
+ /**
11
+ @typedef {import('react').HTMLAttributes<HTMLSpanElement> & {
12
+ mode?: 'light' | 'dark',
13
+ layout?: 'vertical' | 'horizontal',
14
+ showText?: boolean,
15
+ showLogo?: boolean,
16
+ }} LogoProps
17
+ */
18
+
19
+ /**
20
+ * @description
21
+ * @export
22
+ * @param {LogoProps} props
23
+ * @return {React.ReactComponentElement}
24
+ */
10
25
  export default function Logo({ showText, showLogo, mode, layout, ...rest }) {
11
26
  const logo = mode === 'light' ? <LightLogo /> : <DarkLogo />;
12
27
  const text = mode === 'light' ? <LightText className="logo-text" /> : <DarkText className="logo-text" />;
@@ -33,6 +48,7 @@ Logo.defaultProps = {
33
48
  showLogo: true,
34
49
  };
35
50
 
51
+ /** @type {import('@emotion/styled').StyledComponent<HTMLSpanElement, {}, { ref?: React.Ref<any> | undefined;}>} */
36
52
  const Container = styled('span')`
37
53
  display: inline-flex;
38
54
  flex-direction: ${(props) => (props.layout === 'horizontal' ? 'row' : 'column')};
@@ -391,6 +391,7 @@ SessionManager.propTypes = {
391
391
  switchProfile: PropTypes.func.isRequired,
392
392
  switchPassport: PropTypes.func.isRequired,
393
393
  bindWallet: PropTypes.func.isRequired,
394
+ refresh: PropTypes.func.isRequired,
394
395
  }).isRequired,
395
396
  locale: PropTypes.string,
396
397
  showText: PropTypes.bool,
@@ -11,8 +11,23 @@ import Button from '@mui/material/Button';
11
11
 
12
12
  import { styled } from '../Theme';
13
13
 
14
+ /**
15
+ * SplitButton 组件 Props
16
+ * @typedef {{
17
+ * size?: 'small' | 'medium' | 'large';
18
+ * color?: 'primary' | 'secondary' | 'inherit';
19
+ * menu?: Array<import('@mui/material').MenuItem> | import('@mui/material').MenuItem>;
20
+ * children?: JSX.Element | (() => JSX.Element);
21
+ * variant?: 'outlined' | 'contained';
22
+ * onClick?: () => void;
23
+ * menuButtonProps?: import('@mui/material').ButtonProps;
24
+ * } & import('@mui/material').ButtonGroupProps } SplitButtonProps
25
+ */
26
+
14
27
  /**
15
28
  * SplitButton allows the user to execute a default action which is bound to a Button or to choose a predefined action from a drop-down list.
29
+ * @param {SplitButtonProps} props
30
+ * @returns {JSX.Element}
16
31
  */
17
32
  export default function SplitButton({ size, color, menu, children, variant, onClick, menuButtonProps, ...rest }) {
18
33
  const [open, setOpen] = useState(false);
@@ -34,7 +49,7 @@ export default function SplitButton({ size, color, menu, children, variant, onCl
34
49
 
35
50
  // 点击 item 后收起下拉菜单, 如果想要点击 action 后不收起下拉菜单, 可以在 item#onClick 时调用 e.stopPropagation()
36
51
  const handleItemClick = (e) => {
37
- if (e.target.classList.contains('MuiMenuItem-root')) {
52
+ if (e.target.closest('.MuiMenuItem-root')) {
38
53
  setOpen(false);
39
54
  }
40
55
  };
@@ -84,7 +99,9 @@ SplitButton.defaultProps = {
84
99
  onClick: () => {},
85
100
  menuButtonProps: {},
86
101
  };
87
-
102
+ /**
103
+ * @type {import('@mui/material').MenuItem}
104
+ */
88
105
  SplitButton.Item = MenuItem;
89
106
 
90
107
  const StyledButtonGroup = styled(ButtonGroup)`
@@ -53,8 +53,18 @@ const IOSSwitch = styled((props) => <MuiSwitch focusVisibleClassName=".Mui-focus
53
53
  );
54
54
 
55
55
  /**
56
- * 抽取 blocklet server 中使用的 iOS 风格的 Switch, 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
56
+ * Switch 组件 Props
57
+ * @typedef {{
58
+ * labelProps?: import('@mui/material').FormControlLabelProps;
59
+ * } & import('@mui/material').SwitchProps } SwitchProps
60
+ */
61
+
62
+ /**
63
+ * 抽取 blocklet server 中使用的 iOS 风格的 Switch,
64
+ * 该组件把 FormControlLabel 和 MuiSwitch 组合在一起,
57
65
  * 兼容 mui Switch props, 使用 labelProps 控制 FormControlLabel
66
+ * @param {SwitchProps} props
67
+ * @returns {JSX.Element}
58
68
  */
59
69
  function Switch({ labelProps, ...rest }) {
60
70
  if (labelProps) {
@@ -3,13 +3,22 @@ import { SnackbarProvider, useSnackbar } from 'notistack';
3
3
  import IconButton from '@mui/material/IconButton';
4
4
  import CloseIcon from '@mui/icons-material/Close';
5
5
 
6
+ /**
7
+ * @type {import('notistack').ProviderContext['enqueueSnackbar']}
8
+ */
6
9
  const noop = () => {};
7
10
 
8
11
  let success = noop;
9
12
  let error = noop;
10
13
  let warning = noop;
11
14
  let info = noop;
12
-
15
+ /**
16
+ * @description
17
+ * @param {(message: import('notistack').SnackbarMessage, options?: import('notistack').OptionsObject) => import('notistack').SnackbarKey} enqueueSnackbar
18
+ * @param {import('notistack').ProviderContext['enqueueSnackbar']} enqueueSnackbar
19
+ * @param {import('notistack').VariantType} variant
20
+ * @returns {import('notistack').ProviderContext['enqueueSnackbar']}
21
+ */
13
22
  const genFn = (enqueueSnackbar, variant) => (message, opts) => {
14
23
  enqueueSnackbar(message, {
15
24
  autoHideDuration: 3000,
@@ -58,8 +67,35 @@ function Toast() {
58
67
  export { ToastProvider };
59
68
 
60
69
  export default {
61
- success: (...args) => success(...args),
62
- error: (...args) => error(...args),
63
- warning: (...args) => warning(...args),
64
- info: (...args) => info(...args),
70
+ /**
71
+ *
72
+ * @param {import('notistack').SnackbarMessage} message
73
+ * @param {import('notistack').OptionsObject} options
74
+ * @returns {import('notistack').SnackbarKey}
75
+ */
76
+ success: (message, options, ...args) => success(message, options, ...args),
77
+
78
+ /**
79
+ *
80
+ * @param {import('notistack').SnackbarMessage} message
81
+ * @param {import('notistack').OptionsObject} options
82
+ * @returns {import('notistack').SnackbarKey}
83
+ */
84
+ error: (message, options, ...args) => error(message, options, ...args),
85
+
86
+ /**
87
+ *
88
+ * @param {import('notistack').SnackbarMessage} message
89
+ * @param {import('notistack').OptionsObject} options
90
+ * @returns {import('notistack').SnackbarKey}
91
+ */
92
+ warning: (message, options, ...args) => warning(message, options, ...args),
93
+
94
+ /**
95
+ *
96
+ * @param {import('notistack').SnackbarMessage} message
97
+ * @param {import('notistack').OptionsObject} options
98
+ * @returns {import('notistack').SnackbarKey}
99
+ */
100
+ info: (message, options, ...args) => info(message, options, ...args),
65
101
  };