@arcblock/ux 2.10.30 → 2.10.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  presets: [
3
+ '@babel/preset-typescript',
3
4
  ['@babel/preset-env', { modules: false, targets: 'chrome 114' }],
4
5
  ['@babel/preset-react', { useBuiltIns: true, runtime: 'automatic' }],
5
6
  ],
@@ -9,5 +10,5 @@ module.exports = {
9
10
  '@babel/plugin-proposal-class-properties',
10
11
  './tools/sticky-react-runtime',
11
12
  ],
12
- ignore: ['src/**/*.stories.js', 'src/**/demo'],
13
+ ignore: ['src/**/*.stories.js', 'src/**/demo', 'src/**/*.d.ts'],
13
14
  };
@@ -0,0 +1,18 @@
1
+ declare const _default: (props: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default _default;
3
+ /**
4
+ * Action button component
5
+ */
6
+ export type ActionButtonProps = {
7
+ href: string;
8
+ children?: import("react").ReactNode;
9
+ gradient?: string;
10
+ color?: string;
11
+ icon?: string;
12
+ border?: string;
13
+ text?: string;
14
+ theme?: string;
15
+ variant?: string;
16
+ size?: string;
17
+ width?: string;
18
+ };
@@ -1,4 +1,4 @@
1
- declare const _default: (props: any) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
1
+ declare const _default: (props: any) => import("react/jsx-runtime").JSX.Element;
2
2
  export default _default;
3
3
  /**
4
4
  * Alert notification component
@@ -6,7 +6,7 @@ declare function DIDMotif({ did, size, animation, shape, responsive, ...rest }:
6
6
  animation: any;
7
7
  shape: any;
8
8
  responsive: any;
9
- }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
10
  declare namespace DIDMotif {
11
11
  namespace propTypes {
12
12
  let did: PropTypes.Validator<string>;
@@ -22,7 +22,7 @@ declare namespace DIDMotif {
22
22
  export { animation_1 as animation };
23
23
  let responsive_1: boolean;
24
24
  export { responsive_1 as responsive };
25
- let shape_1: any;
25
+ let shape_1: null;
26
26
  export { shape_1 as shape };
27
27
  }
28
28
  }
@@ -1,4 +1,4 @@
1
- declare const _default: (props: any) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
1
+ declare const _default: (props: any) => import("react/jsx-runtime").JSX.Element;
2
2
  export default _default;
3
3
  /**
4
4
  * Badge component to display notification badge
@@ -23,9 +23,9 @@
23
23
  declare function BlockletStore({ title, did, description, cover, version, button, buttonText, buttonDisabled, buttonLoading, onButtonClick, onMainClick, className, ...rest }: BlockletStoreProps): JSX.Element;
24
24
  declare namespace BlockletStore {
25
25
  namespace propTypes {
26
- let title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
26
+ let title: PropTypes.Requireable<string>;
27
27
  let did: PropTypes.Requireable<string>;
28
- let description: PropTypes.Requireable<PropTypes.ReactNodeLike>;
28
+ let description: PropTypes.Requireable<string>;
29
29
  let cover: PropTypes.Requireable<string>;
30
30
  let buttonText: PropTypes.Requireable<string>;
31
31
  let buttonDisabled: PropTypes.Requireable<boolean>;
@@ -41,9 +41,9 @@ declare namespace BlockletStore {
41
41
  export { title_1 as title };
42
42
  let description_1: string;
43
43
  export { description_1 as description };
44
- let cover_1: any;
44
+ let cover_1: null;
45
45
  export { cover_1 as cover };
46
- let did_1: any;
46
+ let did_1: null;
47
47
  export { did_1 as did };
48
48
  let buttonText_1: string;
49
49
  export { buttonText_1 as buttonText };
@@ -51,15 +51,15 @@ declare namespace BlockletStore {
51
51
  export { buttonDisabled_1 as buttonDisabled };
52
52
  let buttonLoading_1: boolean;
53
53
  export { buttonLoading_1 as buttonLoading };
54
- let button_1: any;
54
+ let button_1: null;
55
55
  export { button_1 as button };
56
- let version_1: any;
56
+ let version_1: null;
57
57
  export { version_1 as version };
58
- let onButtonClick_1: any;
58
+ let onButtonClick_1: null;
59
59
  export { onButtonClick_1 as onButtonClick };
60
- let onMainClick_1: any;
60
+ let onMainClick_1: null;
61
61
  export { onMainClick_1 as onMainClick };
62
- let className_1: any;
62
+ let className_1: null;
63
63
  export { className_1 as className };
64
64
  }
65
65
  }
@@ -0,0 +1,102 @@
1
+ /**
2
+ * BlockletNFT 组件
3
+ * @typedef {{
4
+ * title: string;
5
+ * description?: string;
6
+ * cover?: string;
7
+ * did?: string;
8
+ * isStickyButton?: boolean;
9
+ * buttonText?: string;
10
+ * buttonDisabled?: boolean;
11
+ * buttonLoading?: boolean;
12
+ * button?: JSX.Element;
13
+ * addons?: Array<any>;
14
+ * size?: 'xs' | 'sm' | 'md' | 'auto';
15
+ * onButtonClick?: Function;
16
+ * onMainClick?: Function;
17
+ * onTagClick?: Function;
18
+ * className?: string;
19
+ * scaleClickZone?: number;
20
+ * } & import('react').ComponentPropsWithoutRef<"div"> } BlockletNFTProps
21
+ */
22
+ /**
23
+ * BlockletNFT 组件
24
+ * @param {BlockletNFTProps} props
25
+ * @returns {JSX.Element}
26
+ */
27
+ declare function BlockletNFT({ title, did, description, cover, size, addons, button, buttonText, buttonDisabled, buttonLoading, isStickyButton, onButtonClick, onMainClick, onTagClick, className, scaleClickZone, ...rest }: BlockletNFTProps): JSX.Element;
28
+ declare namespace BlockletNFT {
29
+ namespace propTypes {
30
+ let title: PropTypes.Validator<string>;
31
+ let did: PropTypes.Requireable<string>;
32
+ let isStickyButton: PropTypes.Requireable<boolean>;
33
+ let description: PropTypes.Requireable<string>;
34
+ let cover: PropTypes.Requireable<string>;
35
+ let buttonText: PropTypes.Requireable<string>;
36
+ let buttonDisabled: PropTypes.Requireable<boolean>;
37
+ let buttonLoading: PropTypes.Requireable<boolean>;
38
+ let button: PropTypes.Requireable<PropTypes.ReactElementLike>;
39
+ let addons: PropTypes.Requireable<(object | null | undefined)[]>;
40
+ let size: PropTypes.Requireable<string>;
41
+ let onButtonClick: PropTypes.Requireable<(...args: any[]) => any>;
42
+ let onMainClick: PropTypes.Requireable<(...args: any[]) => any>;
43
+ let onTagClick: PropTypes.Requireable<(...args: any[]) => any>;
44
+ let className: PropTypes.Requireable<string>;
45
+ let scaleClickZone: PropTypes.Requireable<number>;
46
+ }
47
+ namespace defaultProps {
48
+ let description_1: null;
49
+ export { description_1 as description };
50
+ let cover_1: null;
51
+ export { cover_1 as cover };
52
+ let did_1: null;
53
+ export { did_1 as did };
54
+ let isStickyButton_1: boolean;
55
+ export { isStickyButton_1 as isStickyButton };
56
+ let buttonText_1: string;
57
+ export { buttonText_1 as buttonText };
58
+ let buttonDisabled_1: boolean;
59
+ export { buttonDisabled_1 as buttonDisabled };
60
+ let buttonLoading_1: boolean;
61
+ export { buttonLoading_1 as buttonLoading };
62
+ let button_1: null;
63
+ export { button_1 as button };
64
+ let size_1: string;
65
+ export { size_1 as size };
66
+ let addons_1: never[];
67
+ export { addons_1 as addons };
68
+ let onButtonClick_1: null;
69
+ export { onButtonClick_1 as onButtonClick };
70
+ let onMainClick_1: null;
71
+ export { onMainClick_1 as onMainClick };
72
+ let onTagClick_1: null;
73
+ export { onTagClick_1 as onTagClick };
74
+ let className_1: null;
75
+ export { className_1 as className };
76
+ let scaleClickZone_1: number;
77
+ export { scaleClickZone_1 as scaleClickZone };
78
+ }
79
+ }
80
+ export default BlockletNFT;
81
+ /**
82
+ * BlockletNFT 组件
83
+ */
84
+ export type BlockletNFTProps = {
85
+ title: string;
86
+ description?: string;
87
+ cover?: string;
88
+ did?: string;
89
+ isStickyButton?: boolean;
90
+ buttonText?: string;
91
+ buttonDisabled?: boolean;
92
+ buttonLoading?: boolean;
93
+ button?: JSX.Element;
94
+ addons?: Array<any>;
95
+ size?: "xs" | "sm" | "md" | "auto";
96
+ onButtonClick?: Function;
97
+ onMainClick?: Function;
98
+ onTagClick?: Function;
99
+ className?: string;
100
+ scaleClickZone?: number;
101
+ } & import("react").ComponentPropsWithoutRef<"div">;
102
+ import PropTypes from 'prop-types';
@@ -1,4 +1,4 @@
1
- declare function CustomToolbar(props: any): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
1
+ declare function CustomToolbar(props: any): import("react/jsx-runtime").JSX.Element;
2
2
  declare namespace CustomToolbar {
3
3
  namespace propTypes {
4
4
  let data: PropTypes.Requireable<any[]>;
@@ -19,17 +19,17 @@ declare namespace CustomToolbar {
19
19
  let tableRef: PropTypes.Validator<(...args: any[]) => any>;
20
20
  }
21
21
  namespace defaultProps {
22
- let data_1: any[];
22
+ let data_1: never[];
23
23
  export { data_1 as data };
24
24
  let components_1: {};
25
25
  export { components_1 as components };
26
- let filterList_1: any[];
26
+ let filterList_1: never[];
27
27
  export { filterList_1 as filterList };
28
- let filterData_1: any[];
28
+ let filterData_1: never[];
29
29
  export { filterData_1 as filterData };
30
30
  let title_1: string;
31
31
  export { title_1 as title };
32
- let searchText_1: any;
32
+ let searchText_1: null;
33
33
  export { searchText_1 as searchText };
34
34
  }
35
35
  }
@@ -1,4 +1,4 @@
1
1
  export function DatatableProvider({ children }: {
2
2
  children: any;
3
- }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
3
+ }): import("react/jsx-runtime").JSX.Element;
4
4
  export function useDatatableContext(): {};
@@ -5,7 +5,7 @@ declare function TableSearch({ search, options, searchText, searchTextUpdate, se
5
5
  searchTextUpdate: any;
6
6
  searchClose: any;
7
7
  onSearchOpen: any;
8
- }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
9
  declare namespace TableSearch {
10
10
  namespace propTypes {
11
11
  let search: PropTypes.Requireable<string>;
@@ -13,15 +13,8 @@ export type DataTableCustomButton = {
13
13
  };
14
14
  export type DataTableColumn = {
15
15
  name: string;
16
- label: string;
17
16
  width?: number;
18
17
  align?: "left" | "center" | "right";
19
- options?: {
20
- filter?: boolean;
21
- sort?: boolean;
22
- customBodyRender?: (value: any) => import("react").ReactElement;
23
- customBodyRenderLite?: (index: number) => import("react").ReactElement;
24
- } & import("mui-datatables").MUIDataTableColumnOptions;
25
18
  } & import("mui-datatables").MUIDataTableColumnDef;
26
19
  export type DataTableState = Pick<import("mui-datatables").MUIDataTableState, "count" | "page" | "rowsPerPage" | "searchText" | "sortOrder" | "filterList">;
27
20
  export type ModifiedMUIDataTableProps = {
@@ -25,15 +25,8 @@ import { styled } from '../Theme';
25
25
  /**
26
26
  * @typedef {{
27
27
  * name: string,
28
- * label: string,
29
28
  * width?: number,
30
29
  * align?: 'left' | 'center' | 'right',
31
- * options?: {
32
- * filter?: boolean,
33
- * sort?: boolean,
34
- * customBodyRender?: (value: any) => import('react').ReactElement,
35
- * customBodyRenderLite?: (index: number) => import('react').ReactElement
36
- * } & import('mui-datatables').MUIDataTableColumnOptions
37
30
  * } & import('mui-datatables').MUIDataTableColumnDef} DataTableColumn
38
31
  */
39
32
 
@@ -28,23 +28,22 @@ export type UxDialogProps = {
28
28
  /**
29
29
  * - Whether or not to show the close button.
30
30
  */
31
- showCloseButton?: boolean;
31
+ showCloseButton?: boolean | undefined;
32
32
  /**
33
33
  * - The position of the actions toolbar.
34
34
  */
35
- actionsPosition?: "left" | "center" | "right";
35
+ actionsPosition?: "left" | "right" | "center" | undefined;
36
36
  /**
37
37
  * - Props to be passed down to the dialog paper.
38
38
  */
39
- PaperProps?: PaperStyle;
39
+ PaperProps?: PaperStyle | undefined;
40
40
  slotProps?: {
41
41
  content: object;
42
- content: object;
43
- };
42
+ } | undefined;
44
43
  /**
45
44
  * - Callback function fired when the dialog is closed.
46
45
  */
47
- onClose?: (event: React.SyntheticEvent, reason: string) => void;
46
+ onClose?: ((event: React.SyntheticEvent, reason: string) => void) | undefined;
48
47
  };
49
48
  export type DialogProps = Omit<MuiDialogProps, "title" | "children" | "onClose" | "PaperProps" | "slotProps"> & UxDialogProps;
50
49
  /**
@@ -102,11 +101,11 @@ declare namespace Dialog {
102
101
  namespace defaultProps {
103
102
  let title_1: string;
104
103
  export { title_1 as title };
105
- let prepend_1: any;
104
+ let prepend_1: null;
106
105
  export { prepend_1 as prepend };
107
- let toolbar_1: any;
106
+ let toolbar_1: null;
108
107
  export { toolbar_1 as toolbar };
109
- let actions_1: any;
108
+ let actions_1: null;
110
109
  export { actions_1 as actions };
111
110
  let showCloseButton_1: boolean;
112
111
  export { showCloseButton_1 as showCloseButton };
@@ -116,7 +115,7 @@ declare namespace Dialog {
116
115
  export { PaperProps_1 as PaperProps };
117
116
  let slotProps_1: {};
118
117
  export { slotProps_1 as slotProps };
119
- let onClose_1: any;
118
+ let onClose_1: undefined;
120
119
  export { onClose_1 as onClose };
121
120
  }
122
121
  }
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
2
 
3
- export type OpenConfirmProps = {
3
+ export interface OpenConfirmProps {
4
4
  title: ReactNode;
5
5
  content: ReactNode;
6
6
  onConfirm?: (close: () => void) => void;
@@ -8,7 +8,7 @@ export type OpenConfirmProps = {
8
8
  showCancelButton?: boolean;
9
9
  confirmButtonText?: string;
10
10
  cancelButtonText?: string;
11
- };
11
+ }
12
12
 
13
13
  export type UpdateConfirmProps = Partial<Pick<OpenConfirmProps, 'title' | 'content'>>;
14
14
 
@@ -1,5 +1,5 @@
1
1
  export default function useConfirm(props?: {}): {
2
- confirmHolder: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
2
+ confirmHolder: import("react/jsx-runtime").JSX.Element;
3
3
  confirmApi: {
4
4
  open: import("./types").OpenConfirm;
5
5
  close: import("./types").CloseConfirm;
@@ -32,7 +32,7 @@ declare namespace Empty {
32
32
  export { color_1 as color };
33
33
  let size_1: number;
34
34
  export { size_1 as size };
35
- let children_1: any;
35
+ let children_1: null;
36
36
  export { children_1 as children };
37
37
  }
38
38
  }
@@ -1,2 +1,2 @@
1
- declare const _default: (props: any) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
1
+ declare const _default: (props: any) => import("react/jsx-runtime").JSX.Element;
2
2
  export default _default;
@@ -4,20 +4,20 @@ export type ImgExProps = {
4
4
  * - required
5
5
  */
6
6
  src: string;
7
- alt?: string;
8
- size?: string;
9
- position?: string;
10
- style?: object;
11
- ratio?: number;
12
- repeat?: string;
13
- width?: number;
14
- height?: number;
15
- lazy?: boolean;
16
- placeholder?: string;
17
- fallback?: string;
18
- className?: string;
19
- onError?: Function;
20
- onSuccess?: Function;
7
+ alt?: string | undefined;
8
+ size?: string | undefined;
9
+ position?: string | undefined;
10
+ style?: object | undefined;
11
+ ratio?: number | undefined;
12
+ repeat?: string | undefined;
13
+ width?: number | undefined;
14
+ height?: number | undefined;
15
+ lazy?: boolean | undefined;
16
+ placeholder?: string | undefined;
17
+ fallback?: string | undefined;
18
+ className?: string | undefined;
19
+ onError?: Function | undefined;
20
+ onSuccess?: Function | undefined;
21
21
  };
22
22
  export type ImgProps = ImgExProps & import("react").ComponentPropsWithoutRef<"div">;
23
23
  /**
@@ -45,7 +45,7 @@ declare namespace Img {
45
45
  let onSuccess: PropTypes.Requireable<(...args: any[]) => any>;
46
46
  }
47
47
  namespace defaultProps {
48
- let alt_1: any;
48
+ let alt_1: null;
49
49
  export { alt_1 as alt };
50
50
  let size_1: string;
51
51
  export { size_1 as size };
@@ -53,19 +53,19 @@ declare namespace Img {
53
53
  export { position_1 as position };
54
54
  let repeat_1: string;
55
55
  export { repeat_1 as repeat };
56
- let style_1: any;
56
+ let style_1: null;
57
57
  export { style_1 as style };
58
58
  let ratio_1: number;
59
59
  export { ratio_1 as ratio };
60
- let width_1: any;
60
+ let width_1: null;
61
61
  export { width_1 as width };
62
- let height_1: any;
62
+ let height_1: null;
63
63
  export { height_1 as height };
64
64
  let lazy_1: boolean;
65
65
  export { lazy_1 as lazy };
66
- let placeholder_1: any;
66
+ let placeholder_1: null;
67
67
  export { placeholder_1 as placeholder };
68
- let fallback_1: any;
68
+ let fallback_1: null;
69
69
  export { fallback_1 as fallback };
70
70
  let className_1: string;
71
71
  export { className_1 as className };
@@ -12,7 +12,7 @@
12
12
  * @param {LogoProps} props
13
13
  * @return {React.ReactComponentElement}
14
14
  */
15
- declare function Logo({ showText, showLogo, mode, layout, ...rest }: LogoProps): React.ReactComponentElement<any, Pick<any, string | number | symbol>>;
15
+ declare function Logo({ showText, showLogo, mode, layout, ...rest }: LogoProps): import("react").ReactComponentElement<any, Pick<any, string | number | symbol>>;
16
16
  declare namespace Logo {
17
17
  namespace propTypes {
18
18
  let mode: PropTypes.Requireable<string>;
@@ -38,5 +38,4 @@ export type LogoProps = import("react").HTMLAttributes<HTMLSpanElement> & {
38
38
  showText?: boolean;
39
39
  showLogo?: boolean;
40
40
  };
41
- import React from "react";
42
41
  import PropTypes from 'prop-types';
@@ -0,0 +1,7 @@
1
+ import { BoxProps, TypographyProps } from '@mui/material';
2
+ export declare function TBox<C extends React.ElementType>({ component, ...rest }: BoxProps<C, {
3
+ component: C;
4
+ }>): import("react/jsx-runtime").JSX.Element;
5
+ export declare function TTypography<C extends React.ElementType>({ component, ...rest }: TypographyProps<C, {
6
+ component: C;
7
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box, Typography } from '@mui/material';
3
+ export function TBox({
4
+ component,
5
+ ...rest
6
+ }) {
7
+ return /*#__PURE__*/_jsx(Box, {
8
+ component: component,
9
+ ...rest
10
+ });
11
+ }
12
+ export function TTypography({
13
+ component,
14
+ ...rest
15
+ }) {
16
+ return /*#__PURE__*/_jsx(Typography, {
17
+ component: component,
18
+ ...rest
19
+ });
20
+ }
@@ -30,13 +30,15 @@ export default function Passport({
30
30
  ,
31
31
  dangerouslySetInnerHTML: {
32
32
  __html: createPassportSvg({
33
- title: passport.title || passport.name,
33
+ title: passport.scope === 'passport' ? passport.title : passport.name,
34
34
  issuer: passport.issuer && passport.issuer.name,
35
35
  issuerDid: passport.issuer && passport.issuer.id,
36
36
  ownerName: user.fullName,
37
37
  ownerDid: user.did,
38
38
  ownerAvatarUrl: user.avatar,
39
39
  revoked: passport.revoked,
40
+ scope: passport.scope,
41
+ role: passport.role,
40
42
  preferredColor: color,
41
43
  width
42
44
  })
@@ -0,0 +1,33 @@
1
+ import PropTypes from 'prop-types';
2
+ import MenuItem, { MenuItemProps } from '@mui/material/MenuItem';
3
+ import { ButtonGroupProps } from '@mui/material/ButtonGroup';
4
+ import { ButtonProps } from '@mui/material/Button';
5
+ export interface SplitButtonProps extends Omit<ButtonGroupProps, 'children'> {
6
+ menu?: React.ReactElement<MenuItemProps, typeof MenuItem> | React.ReactElement<MenuItemProps, typeof MenuItem>[] | MenuItemProps[];
7
+ children?: JSX.Element | (() => JSX.Element);
8
+ onClick?: () => void;
9
+ menuButtonProps?: ButtonProps;
10
+ }
11
+ declare function SplitButton(props: SplitButtonProps): import("react/jsx-runtime").JSX.Element;
12
+ declare namespace SplitButton {
13
+ var propTypes: {
14
+ size: PropTypes.Requireable<string>;
15
+ color: PropTypes.Requireable<string>;
16
+ menu: PropTypes.Requireable<NonNullable<any[] | PropTypes.ReactNodeLike>>;
17
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
18
+ variant: PropTypes.Requireable<string>;
19
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
20
+ menuButtonProps: PropTypes.Requireable<object>;
21
+ };
22
+ var defaultProps: {
23
+ size: string;
24
+ color: string;
25
+ menu: never[];
26
+ children: null;
27
+ variant: string;
28
+ onClick: (...args: any[]) => void;
29
+ menuButtonProps: {};
30
+ };
31
+ var Item: import("@mui/material").ExtendButtonBase<import("@mui/material/MenuItem").MenuItemTypeMap<{}, "li">>;
32
+ }
33
+ export default SplitButton;
@@ -11,25 +11,6 @@ import ButtonGroup from '@mui/material/ButtonGroup';
11
11
  import Button from '@mui/material/Button';
12
12
  import noop from 'lodash/noop';
13
13
  import { styled } from '../Theme';
14
-
15
- /**
16
- * @typedef {import('@mui/material').MenuItem} MenuItem
17
- * @typedef {import('@mui/material').MenuItemProps} MenuItemProps
18
- * SplitButton 组件 Props
19
- * @typedef {{
20
- * menu?: React.ReactElement<MenuItemProps, MenuItem>[] | React.ReactElement<MenuItemProps, MenuItem>;
21
- * children?: JSX.Element | (() => JSX.Element);
22
- * onClick?: () => void;
23
- * menuButtonProps?: import('@mui/material').ButtonProps;
24
- * } & import('@mui/material').ButtonGroupProps } SplitButtonProps
25
- */
26
-
27
- /**
28
- * @description 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
- * @export
30
- * @param {SplitButtonProps} props
31
- * @return {JSX.Element}
32
- */
33
14
  export default function SplitButton(props) {
34
15
  const {
35
16
  size,
@@ -46,8 +27,7 @@ export default function SplitButton(props) {
46
27
  const menuItems = Array.isArray(menu) ? menu.map((item, index) => /*#__PURE__*/isValidElement(item) ? item : /*#__PURE__*/_createElement(MenuItem, {
47
28
  ...item,
48
29
  key: index
49
- })) // eslint-disable-line react/no-array-index-key
50
- : menu;
30
+ })) : menu;
51
31
  const onToggle = () => {
52
32
  setOpen(prevOpen => !prevOpen);
53
33
  };
@@ -118,10 +98,6 @@ SplitButton.defaultProps = {
118
98
  onClick: noop,
119
99
  menuButtonProps: {}
120
100
  };
121
-
122
- /**
123
- * @type {MenuItem}
124
- */
125
101
  SplitButton.Item = MenuItem;
126
102
  const StyledButtonGroup = styled(ButtonGroup)`
127
103
  > .MuiButtonBase-root:last-of-type {
@@ -24,7 +24,7 @@ declare namespace Switch {
24
24
  let labelProps: PropTypes.Requireable<object>;
25
25
  }
26
26
  namespace defaultProps {
27
- let labelProps_1: any;
27
+ let labelProps_1: null;
28
28
  export { labelProps_1 as labelProps };
29
29
  }
30
30
  }
@@ -5,7 +5,7 @@ declare function ThemeProvider({ children, theme, injectFirst }: {
5
5
  children: any;
6
6
  theme: any;
7
7
  injectFirst: any;
8
- }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
9
  declare namespace ThemeProvider {
10
10
  namespace propTypes {
11
11
  let children: PropTypes.Requireable<any>;
@@ -13,7 +13,7 @@ declare namespace ThemeProvider {
13
13
  let injectFirst: PropTypes.Requireable<boolean>;
14
14
  }
15
15
  namespace defaultProps {
16
- let children_1: any;
16
+ let children_1: null;
17
17
  export { children_1 as children };
18
18
  export { defaultTheme as theme };
19
19
  let injectFirst_1: boolean;
@@ -8,4 +8,4 @@ export default _default;
8
8
  export type EnqueueSnackbarFunc = (message: import("notistack").SnackbarMessage, options?: import("notistack").OptionsObject, ...args: any[]) => import("notistack").SnackbarKey;
9
9
  export function ToastProvider({ children }: {
10
10
  children: any;
11
- }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
11
+ }): import("react/jsx-runtime").JSX.Element;
@@ -2,4 +2,4 @@ export function warn(name: any, alternative: any): void;
2
2
  export function withDeprecated(Component: any, { name, alternative }: {
3
3
  name: any;
4
4
  alternative: any;
5
- }): (props: any) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
5
+ }): (props: any) => import("react/jsx-runtime").JSX.Element;
@@ -51,8 +51,8 @@ export function formatToDatetime(date: string, { locale, tz }?: {
51
51
  export function detectWalletExtension(): any;
52
52
  export function openWebWallet({ webWalletUrl, action, locale, url, windowFeatures }: {
53
53
  webWalletUrl: any;
54
- action?: string;
55
- locale?: string;
54
+ action?: string | undefined;
55
+ locale?: string | undefined;
56
56
  url: any;
57
57
  windowFeatures: any;
58
58
  }): void;
@@ -72,10 +72,10 @@ export function appendParams(url: string, params: {
72
72
  export function getUserAvatar(avatar: any, size?: number): any;
73
73
  export function sleep(time?: number): Promise<any>;
74
74
  export function isUrl(str: any): boolean;
75
- export function getVisitorId(): string;
75
+ export function getVisitorId(): string | null;
76
76
  export function setVisitorId(value: any): void;
77
77
  export function getDIDColor(did: any): any;
78
- export function getTranslation(translations: any | string, locale: string, { fallbackLocale, defaultValue }?: {
79
- fallbackLocale?: string;
80
- defaultValue?: string;
78
+ export function getTranslation(translations: Object | string, locale: string, { fallbackLocale, defaultValue }?: {
79
+ fallbackLocale?: string | undefined;
80
+ defaultValue?: string | undefined;
81
81
  }): string;
@@ -23,7 +23,6 @@ export const createPassportSvg = ({
23
23
  issuerDid = '',
24
24
  issuerAvatarUrl = '',
25
25
  ownerDid = '',
26
- ownerName = '',
27
26
  ownerAvatarUrl = '',
28
27
  preferredColor = 'default',
29
28
  revoked = false,
@@ -39,7 +38,7 @@ export const createPassportSvg = ({
39
38
  tagVariant: revoked ? 'error' : 'info',
40
39
  color,
41
40
  did: ownerDid,
42
- variant: 'app-passport' || ownerName,
41
+ variant: 'app-passport',
43
42
  verifiable: true,
44
43
  issuer: {
45
44
  name: issuer,
@@ -59,4 +58,47 @@ export const createPassportSvg = ({
59
58
  return `data:image/svg+xml;utf8,${encodeURIComponent(svgXML)}`;
60
59
  }
61
60
  return svgXML;
61
+ };
62
+ export const createKycSvg = ({
63
+ issuer = '',
64
+ title = '',
65
+ issuerDid = '',
66
+ issuerAvatarUrl = '',
67
+ ownerDid = '',
68
+ ownerName = '',
69
+ ownerAvatarUrl = '',
70
+ preferredColor = 'default',
71
+ type = 'email',
72
+ revoked = false,
73
+ isDataUrl = false,
74
+ width = '100%',
75
+ height = '100%'
76
+ }) => {
77
+ const color = getPassportColor(preferredColor, issuerDid);
78
+ const svgXML = getSvg({
79
+ width,
80
+ height,
81
+ tag: revoked ? 'revoked' : '',
82
+ tagVariant: revoked ? 'error' : 'info',
83
+ color,
84
+ did: ownerDid,
85
+ variant: 'app-kyc',
86
+ verifiable: true,
87
+ issuer: {
88
+ name: issuer,
89
+ icon: issuerAvatarUrl
90
+ },
91
+ header: {
92
+ name: ownerName,
93
+ icon: ownerAvatarUrl
94
+ },
95
+ extra: {
96
+ key: type,
97
+ value: title
98
+ }
99
+ });
100
+ if (isDataUrl) {
101
+ return `data:image/svg+xml;utf8,${encodeURIComponent(svgXML)}`;
102
+ }
103
+ return svgXML;
62
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.10.30",
3
+ "version": "2.10.32",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -17,13 +17,13 @@
17
17
  "url": "git+https://github.com/ArcBlock/ux.git"
18
18
  },
19
19
  "scripts": {
20
- "lint": "eslint src tests --ext js --ext jsx",
20
+ "lint": "eslint src tests --ext js --ext jsx && tsc --noEmit --emitDeclarationOnly false",
21
21
  "lint:fix": "npm run lint -- --fix",
22
- "build": "npm run build:clean && npm run build:lib && npm run build:types",
22
+ "build": "npm run build:clean && npm run build:babel && npm run build:types",
23
23
  "build:clean": "rm -rf lib",
24
- "build:lib": "babel --config-file ./babel.config.es.js src --out-dir lib --copy-files --no-copy-ignored",
25
- "build:types": "tsc",
26
- "watch": "babel --config-file ./babel.config.es.js src --out-dir lib -w --copy-files --no-copy-ignored",
24
+ "build:babel": "babel --config-file ./babel.config.es.js src --out-dir lib --extensions \".js,.jsx,.ts,.tsx\" --copy-files --no-copy-ignored",
25
+ "build:types": "tsc && copyfiles -u 1 'src/**/*.d.ts' lib/",
26
+ "watch": "babel --config-file ./babel.config.es.js src --out-dir lib -w --extensions \".js,.jsx,.ts,.tsx\" --copy-files --no-copy-ignored",
27
27
  "precommit": "CI=1 npm run lint",
28
28
  "prepush": "CI=1 npm run lint",
29
29
  "prepublish": "npm run build",
@@ -42,8 +42,10 @@
42
42
  "@babel/plugin-proposal-class-properties": "^7.18.6",
43
43
  "@babel/preset-env": "^7.19.3",
44
44
  "@babel/preset-react": "^7.18.6",
45
+ "@babel/preset-typescript": "^7.24.7",
45
46
  "@types/react": "^18.3.4",
46
47
  "babel-plugin-inline-react-svg": "^1.1.2",
48
+ "copyfiles": "^2.4.1",
47
49
  "eslint-plugin-react-hooks": "^4.6.0",
48
50
  "glob": "^10.3.3",
49
51
  "jest": "^28.1.3",
@@ -59,12 +61,12 @@
59
61
  "react": ">=18.2.0",
60
62
  "react-router-dom": ">=6.22.3"
61
63
  },
62
- "gitHead": "fc513c9d7b90fecd65844cc562b41f3c5dd5f398",
64
+ "gitHead": "0da245771d21b08f036d4c8f872b61995538c411",
63
65
  "dependencies": {
64
66
  "@arcblock/did-motif": "^1.1.13",
65
- "@arcblock/icons": "^2.10.30",
66
- "@arcblock/nft-display": "^2.10.30",
67
- "@arcblock/react-hooks": "^2.10.30",
67
+ "@arcblock/icons": "^2.10.32",
68
+ "@arcblock/nft-display": "^2.10.32",
69
+ "@arcblock/react-hooks": "^2.10.32",
68
70
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
69
71
  "@fontsource/inter": "^5.0.16",
70
72
  "@fontsource/ubuntu-mono": "^5.0.18",
@@ -24,15 +24,8 @@ import { styled } from '../Theme';
24
24
  /**
25
25
  * @typedef {{
26
26
  * name: string,
27
- * label: string,
28
27
  * width?: number,
29
28
  * align?: 'left' | 'center' | 'right',
30
- * options?: {
31
- * filter?: boolean,
32
- * sort?: boolean,
33
- * customBodyRender?: (value: any) => import('react').ReactElement,
34
- * customBodyRenderLite?: (index: number) => import('react').ReactElement
35
- * } & import('mui-datatables').MUIDataTableColumnOptions
36
29
  * } & import('mui-datatables').MUIDataTableColumnDef} DataTableColumn
37
30
  */
38
31
 
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
2
 
3
- export type OpenConfirmProps = {
3
+ export interface OpenConfirmProps {
4
4
  title: ReactNode;
5
5
  content: ReactNode;
6
6
  onConfirm?: (close: () => void) => void;
@@ -8,7 +8,7 @@ export type OpenConfirmProps = {
8
8
  showCancelButton?: boolean;
9
9
  confirmButtonText?: string;
10
10
  cancelButtonText?: string;
11
- };
11
+ }
12
12
 
13
13
  export type UpdateConfirmProps = Partial<Pick<OpenConfirmProps, 'title' | 'content'>>;
14
14
 
@@ -0,0 +1,9 @@
1
+ import { Box, BoxProps, Typography, TypographyProps } from '@mui/material';
2
+
3
+ export function TBox<C extends React.ElementType>({ component, ...rest }: BoxProps<C, { component: C }>) {
4
+ return <Box component={component} {...rest} />;
5
+ }
6
+
7
+ export function TTypography<C extends React.ElementType>({ component, ...rest }: TypographyProps<C, { component: C }>) {
8
+ return <Typography component={component} {...rest} />;
9
+ }
@@ -19,13 +19,15 @@ export default function Passport({ passport, user, color, width, icon, children,
19
19
  // eslint-disable-next-line react/no-danger
20
20
  dangerouslySetInnerHTML={{
21
21
  __html: createPassportSvg({
22
- title: passport.title || passport.name,
22
+ title: passport.scope === 'passport' ? passport.title : passport.name,
23
23
  issuer: passport.issuer && passport.issuer.name,
24
24
  issuerDid: passport.issuer && passport.issuer.id,
25
25
  ownerName: user.fullName,
26
26
  ownerDid: user.did,
27
27
  ownerAvatarUrl: user.avatar,
28
28
  revoked: passport.revoked,
29
+ scope: passport.scope,
30
+ role: passport.role,
29
31
  preferredColor: color,
30
32
  width,
31
33
  }),
@@ -5,54 +5,46 @@ import Popper from '@mui/material/Popper';
5
5
  import Paper from '@mui/material/Paper';
6
6
  import ClickAwayListener from '@mui/material/ClickAwayListener';
7
7
  import MenuList from '@mui/material/MenuList';
8
- import MenuItem from '@mui/material/MenuItem';
9
- import ButtonGroup from '@mui/material/ButtonGroup';
10
- import Button from '@mui/material/Button';
8
+ import MenuItem, { MenuItemProps } from '@mui/material/MenuItem';
9
+ import ButtonGroup, { ButtonGroupProps } from '@mui/material/ButtonGroup';
10
+ import Button, { ButtonProps } from '@mui/material/Button';
11
11
  import noop from 'lodash/noop';
12
12
 
13
13
  import { styled } from '../Theme';
14
14
 
15
- /**
16
- * @typedef {import('@mui/material').MenuItem} MenuItem
17
- * @typedef {import('@mui/material').MenuItemProps} MenuItemProps
18
- * SplitButton 组件 Props
19
- * @typedef {{
20
- * menu?: React.ReactElement<MenuItemProps, MenuItem>[] | React.ReactElement<MenuItemProps, MenuItem>;
21
- * children?: JSX.Element | (() => JSX.Element);
22
- * onClick?: () => void;
23
- * menuButtonProps?: import('@mui/material').ButtonProps;
24
- * } & import('@mui/material').ButtonGroupProps } SplitButtonProps
25
- */
15
+ export interface SplitButtonProps extends Omit<ButtonGroupProps, 'children'> {
16
+ menu?:
17
+ | React.ReactElement<MenuItemProps, typeof MenuItem>
18
+ | React.ReactElement<MenuItemProps, typeof MenuItem>[]
19
+ | MenuItemProps[];
20
+ children?: JSX.Element | (() => JSX.Element);
21
+ onClick?: () => void;
22
+ menuButtonProps?: ButtonProps;
23
+ }
26
24
 
27
- /**
28
- * @description 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
- * @export
30
- * @param {SplitButtonProps} props
31
- * @return {JSX.Element}
32
- */
33
- export default function SplitButton(props) {
25
+ export default function SplitButton(props: SplitButtonProps) {
34
26
  const { size, color, menu, children, variant, onClick, menuButtonProps, ...rest } = props;
35
27
 
36
28
  const [open, setOpen] = useState(false);
37
- const anchorRef = useRef(null);
29
+ const anchorRef = useRef<HTMLDivElement | null>(null);
38
30
  const menuItems = Array.isArray(menu)
39
- ? menu.map((item, index) => (isValidElement(item) ? item : <MenuItem {...item} key={index} />)) // eslint-disable-line react/no-array-index-key
31
+ ? menu.map((item, index) => (isValidElement(item) ? item : <MenuItem {...item} key={index} />))
40
32
  : menu;
41
33
 
42
34
  const onToggle = () => {
43
35
  setOpen((prevOpen) => !prevOpen);
44
36
  };
45
37
 
46
- const handleClose = (e) => {
47
- if (anchorRef.current && anchorRef.current.contains(e.target)) {
38
+ const handleClose = (e: MouseEvent | TouchEvent) => {
39
+ if (anchorRef.current && anchorRef.current.contains(e.target as HTMLElement)) {
48
40
  return;
49
41
  }
50
42
  setOpen(false);
51
43
  };
52
44
 
53
45
  // 点击 item 后收起下拉菜单, 如果想要点击 action 后不收起下拉菜单, 可以在 item#onClick 时调用 e.stopPropagation()
54
- const handleItemClick = (e) => {
55
- if (e.target.closest('.MuiMenuItem-root')) {
46
+ const handleItemClick: React.MouseEventHandler<HTMLUListElement> = (e) => {
47
+ if ((e.target as HTMLElement).closest('.MuiMenuItem-root')) {
56
48
  setOpen(false);
57
49
  }
58
50
  };
@@ -103,9 +95,6 @@ SplitButton.defaultProps = {
103
95
  menuButtonProps: {},
104
96
  };
105
97
 
106
- /**
107
- * @type {MenuItem}
108
- */
109
98
  SplitButton.Item = MenuItem;
110
99
 
111
100
  const StyledButtonGroup = styled(ButtonGroup)`
@@ -27,7 +27,6 @@ export const createPassportSvg = ({
27
27
  issuerDid = '',
28
28
  issuerAvatarUrl = '',
29
29
  ownerDid = '',
30
- ownerName = '',
31
30
  ownerAvatarUrl = '',
32
31
  preferredColor = 'default',
33
32
  revoked = false,
@@ -47,7 +46,7 @@ export const createPassportSvg = ({
47
46
  color,
48
47
 
49
48
  did: ownerDid,
50
- variant: 'app-passport' || ownerName,
49
+ variant: 'app-passport',
51
50
  verifiable: true,
52
51
 
53
52
  issuer: {
@@ -73,3 +72,56 @@ export const createPassportSvg = ({
73
72
 
74
73
  return svgXML;
75
74
  };
75
+
76
+ export const createKycSvg = ({
77
+ issuer = '',
78
+ title = '',
79
+ issuerDid = '',
80
+ issuerAvatarUrl = '',
81
+ ownerDid = '',
82
+ ownerName = '',
83
+ ownerAvatarUrl = '',
84
+ preferredColor = 'default',
85
+ type = 'email',
86
+ revoked = false,
87
+ isDataUrl = false,
88
+ width = '100%',
89
+ height = '100%',
90
+ }) => {
91
+ const color = getPassportColor(preferredColor, issuerDid);
92
+
93
+ const svgXML = getSvg({
94
+ width,
95
+ height,
96
+
97
+ tag: revoked ? 'revoked' : '',
98
+ tagVariant: revoked ? 'error' : 'info',
99
+
100
+ color,
101
+
102
+ did: ownerDid,
103
+ variant: 'app-kyc',
104
+ verifiable: true,
105
+
106
+ issuer: {
107
+ name: issuer,
108
+ icon: issuerAvatarUrl,
109
+ },
110
+
111
+ header: {
112
+ name: ownerName,
113
+ icon: ownerAvatarUrl,
114
+ },
115
+
116
+ extra: {
117
+ key: type,
118
+ value: title,
119
+ },
120
+ });
121
+
122
+ if (isDataUrl) {
123
+ return `data:image/svg+xml;utf8,${encodeURIComponent(svgXML)}`;
124
+ }
125
+
126
+ return svgXML;
127
+ };