@metamask/snaps-sdk 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/dist/index.js +147 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -5
- package/dist/index.mjs.map +1 -1
- package/dist/jsx/index.js +327 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +325 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/jsx-dev-runtime.js +217 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx/jsx-dev-runtime.mjs +215 -0
- package/dist/jsx/jsx-dev-runtime.mjs.map +1 -0
- package/dist/jsx/jsx-runtime.js +45 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx/jsx-runtime.mjs +24 -0
- package/dist/jsx/jsx-runtime.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/internals/index.d.ts +1 -0
- package/dist/types/internals/jsx.d.ts +31 -0
- package/dist/types/jsx/component.d.ts +66 -0
- package/dist/types/jsx/components/Address.d.ts +28 -0
- package/dist/types/jsx/components/Box.d.ts +27 -0
- package/dist/types/jsx/components/Copyable.d.ts +32 -0
- package/dist/types/jsx/components/Divider.d.ts +17 -0
- package/dist/types/jsx/components/Heading.d.ts +26 -0
- package/dist/types/jsx/components/Image.d.ts +36 -0
- package/dist/types/jsx/components/Link.d.ts +35 -0
- package/dist/types/jsx/components/Row.d.ts +41 -0
- package/dist/types/jsx/components/Spinner.d.ts +17 -0
- package/dist/types/jsx/components/Text.d.ts +33 -0
- package/dist/types/jsx/components/form/Button.d.ts +37 -0
- package/dist/types/jsx/components/form/Field.d.ts +34 -0
- package/dist/types/jsx/components/form/Form.d.ts +39 -0
- package/dist/types/jsx/components/form/Input.d.ts +37 -0
- package/dist/types/jsx/components/form/index.d.ts +9 -0
- package/dist/types/jsx/components/formatting/Bold.d.ts +32 -0
- package/dist/types/jsx/components/formatting/Italic.d.ts +34 -0
- package/dist/types/jsx/components/formatting/index.d.ts +5 -0
- package/dist/types/jsx/components/index.d.ts +28 -0
- package/dist/types/jsx/index.d.ts +5 -0
- package/dist/types/jsx/jsx-dev-runtime.d.ts +17 -0
- package/dist/types/jsx/jsx-runtime.d.ts +35 -0
- package/dist/types/jsx/validation.d.ts +110 -0
- package/dist/types/types/handlers/home-page.d.ts +2 -2
- package/dist/types/types/handlers/transaction.d.ts +2 -2
- package/dist/types/types/interface.d.ts +72 -0
- package/dist/types/types/methods/create-interface.d.ts +2 -2
- package/dist/types/types/methods/dialog.d.ts +4 -4
- package/dist/types/types/methods/update-interface.d.ts +2 -2
- package/dist/types/types/permissions.d.ts +2 -1
- package/dist/types/ui/components/address.d.ts +2 -0
- package/dist/types/ui/components/button.d.ts +2 -0
- package/dist/types/ui/components/copyable.d.ts +2 -0
- package/dist/types/ui/components/divider.d.ts +2 -0
- package/dist/types/ui/components/form.d.ts +9 -7
- package/dist/types/ui/components/heading.d.ts +2 -0
- package/dist/types/ui/components/image.d.ts +2 -0
- package/dist/types/ui/components/input.d.ts +5 -3
- package/dist/types/ui/components/panel.d.ts +88 -86
- package/dist/types/ui/components/row.d.ts +2 -0
- package/dist/types/ui/components/spinner.d.ts +2 -0
- package/dist/types/ui/components/text.d.ts +2 -0
- package/dist/types/ui/index.d.ts +0 -1
- package/dist/types/ui/nodes.d.ts +0 -5
- package/jsx-dev-runtime.d.ts +1 -0
- package/jsx-dev-runtime.js +5 -0
- package/jsx-runtime.d.ts +1 -0
- package/jsx-runtime.js +5 -0
- package/jsx.d.ts +1 -0
- package/jsx.js +5 -0
- package/package.json +27 -6
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Json } from '@metamask/utils';
|
|
2
|
+
/**
|
|
3
|
+
* A key, which can be a string or a number.
|
|
4
|
+
*/
|
|
5
|
+
export declare type Key = string | number;
|
|
6
|
+
/**
|
|
7
|
+
* A JSON object.
|
|
8
|
+
*/
|
|
9
|
+
export declare type JsonObject = Record<string, Json>;
|
|
10
|
+
/**
|
|
11
|
+
* A generic JSX element.
|
|
12
|
+
*
|
|
13
|
+
* @property type - The type of the element.
|
|
14
|
+
* @property props - The props of the element.
|
|
15
|
+
* @property key - The key of the element.
|
|
16
|
+
*/
|
|
17
|
+
export declare type GenericSnapElement = {
|
|
18
|
+
type: string;
|
|
19
|
+
props: JsonObject;
|
|
20
|
+
key: Key | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A JSX element.
|
|
24
|
+
*
|
|
25
|
+
* @property type - The type of the element.
|
|
26
|
+
* @property props - The props of the element.
|
|
27
|
+
* @property key - The key of the element.
|
|
28
|
+
*/
|
|
29
|
+
export declare type SnapElement<Props extends JsonObject = Record<string, never>, Type extends string = string> = {
|
|
30
|
+
type: Type;
|
|
31
|
+
props: Props;
|
|
32
|
+
key: Key | null;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A type that can be a single value or an array of values.
|
|
36
|
+
*
|
|
37
|
+
* @template Type - The type that can be an array.
|
|
38
|
+
* @example
|
|
39
|
+
* type MaybeArrayString = MaybeArray<string>;
|
|
40
|
+
* const maybeArrayString: MaybeArrayString = 'hello';
|
|
41
|
+
* const maybeArrayStringArray: MaybeArrayString = ['hello', 'world'];
|
|
42
|
+
*/
|
|
43
|
+
export declare type MaybeArray<Type> = Type | Type[];
|
|
44
|
+
/**
|
|
45
|
+
* A JSX node, which can be an element, a string, null, or an array of nodes.
|
|
46
|
+
*/
|
|
47
|
+
export declare type SnapNode = MaybeArray<GenericSnapElement | string | null>;
|
|
48
|
+
/**
|
|
49
|
+
* A JSX string element, which can be a string or an array of strings.
|
|
50
|
+
*/
|
|
51
|
+
export declare type StringElement = MaybeArray<string>;
|
|
52
|
+
/**
|
|
53
|
+
* A JSX component.
|
|
54
|
+
*/
|
|
55
|
+
export declare type SnapComponent<Props extends JsonObject = Record<string, never>, Type extends string = string> = (props: Props & {
|
|
56
|
+
key?: Key | null;
|
|
57
|
+
}) => SnapElement<Props, Type>;
|
|
58
|
+
/**
|
|
59
|
+
* Create a Snap component from a type. This is a helper function that creates a
|
|
60
|
+
* Snap component function.
|
|
61
|
+
*
|
|
62
|
+
* @param type - The type of the component.
|
|
63
|
+
* @returns A function that creates a Snap element.
|
|
64
|
+
* @see SnapComponent
|
|
65
|
+
*/
|
|
66
|
+
export declare function createSnapComponent<Props extends JsonObject = Record<string, never>, Type extends string = string>(type: Type): SnapComponent<Props, Type>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props of the {@link Address} component.
|
|
3
|
+
*
|
|
4
|
+
* @property address - The (Ethereum) address to display. This should be a
|
|
5
|
+
* valid Ethereum address, starting with `0x`.
|
|
6
|
+
*/
|
|
7
|
+
export declare type AddressProps = {
|
|
8
|
+
address: `0x${string}`;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* An address component, which is used to display an Ethereum address.
|
|
12
|
+
*
|
|
13
|
+
* This component does not accept any children.
|
|
14
|
+
*
|
|
15
|
+
* @param props - The props of the component.
|
|
16
|
+
* @param props.address - The (Ethereum) address to display. This should be a
|
|
17
|
+
* valid Ethereum address, starting with `0x`.
|
|
18
|
+
* @returns An address element.
|
|
19
|
+
* @example
|
|
20
|
+
* <Address address="0x1234567890123456789012345678901234567890" />
|
|
21
|
+
*/
|
|
22
|
+
export declare const Address: import("../component").SnapComponent<AddressProps, "Address">;
|
|
23
|
+
/**
|
|
24
|
+
* An address element.
|
|
25
|
+
*
|
|
26
|
+
* @see Address
|
|
27
|
+
*/
|
|
28
|
+
export declare type AddressElement = ReturnType<typeof Address>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { GenericSnapElement, MaybeArray } from '../component';
|
|
2
|
+
/**
|
|
3
|
+
* The props of the {@link Box} component.
|
|
4
|
+
*
|
|
5
|
+
* @property children - The children of the box.
|
|
6
|
+
*/
|
|
7
|
+
export declare type BoxProps = {
|
|
8
|
+
children: MaybeArray<GenericSnapElement | null>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A box component, which is used to group multiple components together.
|
|
12
|
+
*
|
|
13
|
+
* @param props - The props of the component.
|
|
14
|
+
* @param props.children - The children of the box.
|
|
15
|
+
* @returns A box element.
|
|
16
|
+
* @example
|
|
17
|
+
* <Box>
|
|
18
|
+
* <Text>Hello world!</Text>
|
|
19
|
+
* </Box>
|
|
20
|
+
*/
|
|
21
|
+
export declare const Box: import("../component").SnapComponent<BoxProps, "Box">;
|
|
22
|
+
/**
|
|
23
|
+
* A box element.
|
|
24
|
+
*
|
|
25
|
+
* @see Box
|
|
26
|
+
*/
|
|
27
|
+
export declare type BoxElement = ReturnType<typeof Box>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props of the {@link Copyable} component.
|
|
3
|
+
*
|
|
4
|
+
* @property value - The value to copy when the user clicks on the copyable
|
|
5
|
+
* element.
|
|
6
|
+
* @property sensitive - Whether the value is sensitive. If `true`, the value
|
|
7
|
+
* will be hidden when the user is not interacting with the copyable element.
|
|
8
|
+
*/
|
|
9
|
+
export declare type CopyableProps = {
|
|
10
|
+
value: string;
|
|
11
|
+
sensitive?: boolean | undefined;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A copyable component, which is used to display text that can be copied by the
|
|
15
|
+
* user.
|
|
16
|
+
*
|
|
17
|
+
* @param props - The props of the component.
|
|
18
|
+
* @param props.value - The value to copy when the user clicks on the copyable
|
|
19
|
+
* element.
|
|
20
|
+
* @param props.sensitive - Whether the value is sensitive. If `true`, the value
|
|
21
|
+
* will be hidden when the user is not interacting with the copyable element.
|
|
22
|
+
* @example
|
|
23
|
+
* <Copyable value="0x1234567890123456789012345678901234567890" />
|
|
24
|
+
* <Copyable value="0x1234567890123456789012345678901234567890" sensitive />
|
|
25
|
+
*/
|
|
26
|
+
export declare const Copyable: import("../component").SnapComponent<CopyableProps, "Copyable">;
|
|
27
|
+
/**
|
|
28
|
+
* A copyable element.
|
|
29
|
+
*
|
|
30
|
+
* @see Copyable
|
|
31
|
+
*/
|
|
32
|
+
export declare type CopyableElement = ReturnType<typeof Copyable>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A divider component, which is used to create a horizontal line between
|
|
3
|
+
* elements.
|
|
4
|
+
*
|
|
5
|
+
* This component does not have any props.
|
|
6
|
+
*
|
|
7
|
+
* @returns A divider element.
|
|
8
|
+
* @example
|
|
9
|
+
* <Divider />
|
|
10
|
+
*/
|
|
11
|
+
export declare const Divider: import("../component").SnapComponent<Record<string, never>, "Divider">;
|
|
12
|
+
/**
|
|
13
|
+
* A divider element.
|
|
14
|
+
*
|
|
15
|
+
* @see Divider
|
|
16
|
+
*/
|
|
17
|
+
export declare type DividerElement = ReturnType<typeof Divider>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StringElement } from '../component';
|
|
2
|
+
/**
|
|
3
|
+
* The props of the {@link Heading} component.
|
|
4
|
+
*
|
|
5
|
+
* @property children - The text to display in the heading.
|
|
6
|
+
*/
|
|
7
|
+
declare type HeadingProps = {
|
|
8
|
+
children: StringElement;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A heading component, which is used to display heading text.
|
|
12
|
+
*
|
|
13
|
+
* @param props - The props of the component.
|
|
14
|
+
* @param props.children - The text to display in the heading.
|
|
15
|
+
* @returns A heading element.
|
|
16
|
+
* @example
|
|
17
|
+
* <Heading>Hello world!</Heading>
|
|
18
|
+
*/
|
|
19
|
+
export declare const Heading: import("../component").SnapComponent<HeadingProps, "Heading">;
|
|
20
|
+
/**
|
|
21
|
+
* A heading element.
|
|
22
|
+
*
|
|
23
|
+
* @see Heading
|
|
24
|
+
*/
|
|
25
|
+
export declare type HeadingElement = ReturnType<typeof Heading>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props of the {@link Image} component.
|
|
3
|
+
*
|
|
4
|
+
* @property src - The SVG image to display. This should be an SVG string, and
|
|
5
|
+
* other formats such as PNG and JPEG are not supported directly. You can use
|
|
6
|
+
* the `data:` URL scheme to embed images inside the SVG.
|
|
7
|
+
* @property alt - The alternative text of the image, which describes the image
|
|
8
|
+
* for users who cannot see it.
|
|
9
|
+
*/
|
|
10
|
+
declare type ImageProps = {
|
|
11
|
+
src: string;
|
|
12
|
+
alt?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* An image component, which is used to display an image.
|
|
16
|
+
*
|
|
17
|
+
* This component does not accept any children.
|
|
18
|
+
*
|
|
19
|
+
* @param props - The props of the component.
|
|
20
|
+
* @param props.src - The URL of the image to display. This should be an SVG
|
|
21
|
+
* string, and other formats such as PNG and JPEG are not supported directly.
|
|
22
|
+
* You can use the `data:` URL scheme to embed images inside the SVG.
|
|
23
|
+
* @param props.alt - The alternative text of the image, which describes the
|
|
24
|
+
* image for users who cannot see it.
|
|
25
|
+
* @returns An image element.
|
|
26
|
+
* @example
|
|
27
|
+
* <Image src="<svg>...</svg>" alt="An example image" />
|
|
28
|
+
*/
|
|
29
|
+
export declare const Image: import("../component").SnapComponent<ImageProps, "Image">;
|
|
30
|
+
/**
|
|
31
|
+
* An image element.
|
|
32
|
+
*
|
|
33
|
+
* @see Image
|
|
34
|
+
*/
|
|
35
|
+
export declare type ImageElement = ReturnType<typeof Image>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MaybeArray } from '../component';
|
|
2
|
+
import type { StandardFormattingElement } from './formatting';
|
|
3
|
+
/**
|
|
4
|
+
* The children of the {@link Link} component.
|
|
5
|
+
*/
|
|
6
|
+
export declare type LinkChildren = MaybeArray<string | StandardFormattingElement | null>;
|
|
7
|
+
/**
|
|
8
|
+
* The props of the {@link Link} component.
|
|
9
|
+
*
|
|
10
|
+
* @property children - The text to display in the link.
|
|
11
|
+
* @property href - The URL to link to. This must be an `https` or `mailto` URL.
|
|
12
|
+
* `http` is not allowed.
|
|
13
|
+
*/
|
|
14
|
+
export declare type LinkProps = {
|
|
15
|
+
children: LinkChildren;
|
|
16
|
+
href: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A link component, which is used to display a hyperlink.
|
|
20
|
+
*
|
|
21
|
+
* @param props - The props of the component.
|
|
22
|
+
* @param props.children - The text to display in the link.
|
|
23
|
+
* @param props.href - The URL to link to. This must be an `https` or `mailto`
|
|
24
|
+
* URL. `http` is not allowed.
|
|
25
|
+
* @returns A link element.
|
|
26
|
+
* @example
|
|
27
|
+
* <Link href="https://example.com">Click here</Link>
|
|
28
|
+
*/
|
|
29
|
+
export declare const Link: import("../component").SnapComponent<LinkProps, "Link">;
|
|
30
|
+
/**
|
|
31
|
+
* A link element.
|
|
32
|
+
*
|
|
33
|
+
* @see Link
|
|
34
|
+
*/
|
|
35
|
+
export declare type LinkElement = ReturnType<typeof Link>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AddressElement } from './Address';
|
|
2
|
+
import type { ImageElement } from './Image';
|
|
3
|
+
import type { TextElement } from './Text';
|
|
4
|
+
/**
|
|
5
|
+
* The children of a {@link Row} component.
|
|
6
|
+
*/
|
|
7
|
+
export declare type RowChildren = AddressElement | ImageElement | TextElement;
|
|
8
|
+
/**
|
|
9
|
+
* The props of the {@link Row} component.
|
|
10
|
+
*
|
|
11
|
+
* @property label - The label of the row.
|
|
12
|
+
* @property children - The content of the row. This can be an address, an
|
|
13
|
+
* image, or text.
|
|
14
|
+
* @property variant - The variant of the row.
|
|
15
|
+
*/
|
|
16
|
+
export declare type RowProps = {
|
|
17
|
+
label: string;
|
|
18
|
+
children: RowChildren;
|
|
19
|
+
variant?: 'default' | 'warning' | 'error';
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A row component, which is used to display a row of information.
|
|
23
|
+
*
|
|
24
|
+
* @param props - The props of the component.
|
|
25
|
+
* @param props.label - The label of the row.
|
|
26
|
+
* @param props.children - The content of the row. This can be an address, an
|
|
27
|
+
* image, or text.
|
|
28
|
+
* @param props.variant - The variant of the row.
|
|
29
|
+
* @returns A row element.
|
|
30
|
+
* @example
|
|
31
|
+
* <Row label="From" variant="warning">
|
|
32
|
+
* <Address address="0x1234567890123456789012345678901234567890" />
|
|
33
|
+
* </Row>
|
|
34
|
+
*/
|
|
35
|
+
export declare const Row: import("../component").SnapComponent<RowProps, "Row">;
|
|
36
|
+
/**
|
|
37
|
+
* A row element.
|
|
38
|
+
*
|
|
39
|
+
* @see Row
|
|
40
|
+
*/
|
|
41
|
+
export declare type RowElement = ReturnType<typeof Row>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A spinner component, which is used to display a spinner, indicating that some
|
|
3
|
+
* operation is in progress.
|
|
4
|
+
*
|
|
5
|
+
* This component does not accept any props.
|
|
6
|
+
*
|
|
7
|
+
* @returns A spinner element.
|
|
8
|
+
* @example
|
|
9
|
+
* <Spinner />
|
|
10
|
+
*/
|
|
11
|
+
export declare const Spinner: import("../component").SnapComponent<Record<string, never>, "Spinner">;
|
|
12
|
+
/**
|
|
13
|
+
* A spinner element.
|
|
14
|
+
*
|
|
15
|
+
* @see Spinner
|
|
16
|
+
*/
|
|
17
|
+
export declare type SpinnerElement = ReturnType<typeof Spinner>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MaybeArray } from '../component';
|
|
2
|
+
import type { StandardFormattingElement } from './formatting';
|
|
3
|
+
import type { LinkElement } from './Link';
|
|
4
|
+
/**
|
|
5
|
+
* The children of the {@link Text} component.
|
|
6
|
+
*/
|
|
7
|
+
export declare type TextChildren = MaybeArray<string | StandardFormattingElement | LinkElement | null>;
|
|
8
|
+
/**
|
|
9
|
+
* The props of the {@link Text} component.
|
|
10
|
+
*
|
|
11
|
+
* @property children - The text to display.
|
|
12
|
+
*/
|
|
13
|
+
export declare type TextProps = {
|
|
14
|
+
children: TextChildren;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A text component, which is used to display text.
|
|
18
|
+
*
|
|
19
|
+
* @param props - The props of the component.
|
|
20
|
+
* @param props.children - The text to display.
|
|
21
|
+
* @returns A text element.
|
|
22
|
+
* @example
|
|
23
|
+
* <Text>
|
|
24
|
+
* Hello <Bold>world</Bold>!
|
|
25
|
+
* </Text>
|
|
26
|
+
*/
|
|
27
|
+
export declare const Text: import("../component").SnapComponent<TextProps, "Text">;
|
|
28
|
+
/**
|
|
29
|
+
* A text element.
|
|
30
|
+
*
|
|
31
|
+
* @see Text
|
|
32
|
+
*/
|
|
33
|
+
export declare type TextElement = ReturnType<typeof Text>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { StringElement } from '../../component';
|
|
2
|
+
/**
|
|
3
|
+
* The props of the {@link Button} component.
|
|
4
|
+
*
|
|
5
|
+
* @property children - The text to display on the button.
|
|
6
|
+
* @property name - The name of the button. This is used to identify the button
|
|
7
|
+
* in the event handler.
|
|
8
|
+
* @property type - The type of the button, i.e., `'button'` or `'submit'`.
|
|
9
|
+
* Defaults to `'button'`.
|
|
10
|
+
* @property variant - The variant of the button, i.e., `'primary'` or
|
|
11
|
+
* `'destructive'`. Defaults to `'primary'`.
|
|
12
|
+
* @property disabled - Whether the button is disabled. Defaults to `false`.
|
|
13
|
+
*/
|
|
14
|
+
export declare type ButtonProps = {
|
|
15
|
+
children: StringElement;
|
|
16
|
+
name?: string | undefined;
|
|
17
|
+
type?: 'button' | 'submit' | undefined;
|
|
18
|
+
variant?: 'primary' | 'destructive' | undefined;
|
|
19
|
+
disabled?: boolean | undefined;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A button component, which is used to create a clickable button.
|
|
23
|
+
*
|
|
24
|
+
* @param props - The props of the component.
|
|
25
|
+
* @param props.children - The text to display on the button. This should be a
|
|
26
|
+
* string or an array of strings.
|
|
27
|
+
* @returns A button element.
|
|
28
|
+
* @example
|
|
29
|
+
* <Button name="my-button">Click me</Button>
|
|
30
|
+
*/
|
|
31
|
+
export declare const Button: import("../../component").SnapComponent<ButtonProps, "Button">;
|
|
32
|
+
/**
|
|
33
|
+
* A button element.
|
|
34
|
+
*
|
|
35
|
+
* @see Button
|
|
36
|
+
*/
|
|
37
|
+
export declare type ButtonElement = ReturnType<typeof Button>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { InputElement } from './Input';
|
|
2
|
+
/**
|
|
3
|
+
* The props of the {@link Field} component.
|
|
4
|
+
*
|
|
5
|
+
* @property label - The label of the field.
|
|
6
|
+
* @property error - The error message of the field.
|
|
7
|
+
* @property children - The input field and the submit button.
|
|
8
|
+
*/
|
|
9
|
+
export declare type FieldProps = {
|
|
10
|
+
label?: string | undefined;
|
|
11
|
+
error?: string | undefined;
|
|
12
|
+
children: InputElement;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A field component, which is used to create a form field. This component can
|
|
16
|
+
* only be used as a child of the {@link Form} component.
|
|
17
|
+
*
|
|
18
|
+
* @param props - The props of the component.
|
|
19
|
+
* @param props.label - The label of the field.
|
|
20
|
+
* @param props.error - The error message of the field.
|
|
21
|
+
* @param props.children - The input field and the submit button.
|
|
22
|
+
* @returns A field element.
|
|
23
|
+
* @example
|
|
24
|
+
* <Field label="Username">
|
|
25
|
+
* <Input name="username" type="text" />
|
|
26
|
+
* </Field>
|
|
27
|
+
*/
|
|
28
|
+
export declare const Field: import("../../component").SnapComponent<FieldProps, "Field">;
|
|
29
|
+
/**
|
|
30
|
+
* A field element.
|
|
31
|
+
*
|
|
32
|
+
* @see Field
|
|
33
|
+
*/
|
|
34
|
+
export declare type FieldElement = ReturnType<typeof Field>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MaybeArray } from '../../component';
|
|
2
|
+
import type { ButtonElement } from './Button';
|
|
3
|
+
import type { FieldElement } from './Field';
|
|
4
|
+
/**
|
|
5
|
+
* The props of the {@link Form} component.
|
|
6
|
+
*
|
|
7
|
+
* @property children - The form fields. See {@link Field}.
|
|
8
|
+
* @property name - The name of the form. This is used to identify the form in
|
|
9
|
+
* the event handler.
|
|
10
|
+
*/
|
|
11
|
+
declare type FormProps = {
|
|
12
|
+
children: MaybeArray<FieldElement | ButtonElement>;
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A form component, which is used to create a form.
|
|
17
|
+
*
|
|
18
|
+
* @param props - The props of the component.
|
|
19
|
+
* @param props.children - The form fields. This should be a single field or an
|
|
20
|
+
* array of fields.
|
|
21
|
+
* @param props.name - The name of the form. This is used to identify the form
|
|
22
|
+
* in the event handler.
|
|
23
|
+
* @returns A form element.
|
|
24
|
+
* @example
|
|
25
|
+
* <Form name="my-form">
|
|
26
|
+
* <Field label="Username">
|
|
27
|
+
* <Input name="username" type="text" />
|
|
28
|
+
* </Field>
|
|
29
|
+
* <Button type="submit">Submit</Button>
|
|
30
|
+
* </Form>
|
|
31
|
+
*/
|
|
32
|
+
export declare const Form: import("../../component").SnapComponent<FormProps, "Form">;
|
|
33
|
+
/**
|
|
34
|
+
* A form element.
|
|
35
|
+
*
|
|
36
|
+
* @see Form
|
|
37
|
+
*/
|
|
38
|
+
export declare type FormElement = ReturnType<typeof Form>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props of the {@link Input} component.
|
|
3
|
+
*
|
|
4
|
+
* @property name - The name of the input field. This is used to identify the
|
|
5
|
+
* input field in the form data.
|
|
6
|
+
* @property type - The type of the input field. Defaults to `text`.
|
|
7
|
+
* @property value - The value of the input field.
|
|
8
|
+
* @property placeholder - The placeholder text of the input field.
|
|
9
|
+
*/
|
|
10
|
+
declare type InputProps = {
|
|
11
|
+
name: string;
|
|
12
|
+
type?: 'text' | 'password' | 'number' | undefined;
|
|
13
|
+
value?: string | undefined;
|
|
14
|
+
placeholder?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* An input component, which is used to create an input field. This component
|
|
18
|
+
* can only be used as a child of the {@link Field} component.
|
|
19
|
+
*
|
|
20
|
+
* @param props - The props of the component.
|
|
21
|
+
* @param props.name - The name of the input field. This is used to identify the
|
|
22
|
+
* input field in the form data.
|
|
23
|
+
* @param props.type - The type of the input field.
|
|
24
|
+
* @param props.value - The value of the input field.
|
|
25
|
+
* @param props.placeholder - The placeholder text of the input field.
|
|
26
|
+
* @returns An input element.
|
|
27
|
+
* @example
|
|
28
|
+
* <Input name="username" type="text" />
|
|
29
|
+
*/
|
|
30
|
+
export declare const Input: import("../../component").SnapComponent<InputProps, "Input">;
|
|
31
|
+
/**
|
|
32
|
+
* An input element.
|
|
33
|
+
*
|
|
34
|
+
* @see Input
|
|
35
|
+
*/
|
|
36
|
+
export declare type InputElement = ReturnType<typeof Input>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ButtonElement } from './Button';
|
|
2
|
+
import type { FieldElement } from './Field';
|
|
3
|
+
import type { FormElement } from './Form';
|
|
4
|
+
import type { InputElement } from './Input';
|
|
5
|
+
export * from './Button';
|
|
6
|
+
export * from './Field';
|
|
7
|
+
export * from './Form';
|
|
8
|
+
export * from './Input';
|
|
9
|
+
export declare type StandardFormElement = ButtonElement | FormElement | FieldElement | InputElement;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { JsonObject, MaybeArray, SnapElement } from '../../component';
|
|
2
|
+
/**
|
|
3
|
+
* The children of the {@link Bold} component.
|
|
4
|
+
*/
|
|
5
|
+
export declare type BoldChildren = MaybeArray<string | SnapElement<JsonObject, 'Italic'> | null>;
|
|
6
|
+
/**
|
|
7
|
+
* The props of the {@link Bold} component.
|
|
8
|
+
*
|
|
9
|
+
* @property children - The text to display in bold.
|
|
10
|
+
*/
|
|
11
|
+
export declare type BoldProps = {
|
|
12
|
+
children: BoldChildren;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A bold component, which is used to display text in bold. This component can
|
|
16
|
+
* only be used as a child of the {@link Text} component.
|
|
17
|
+
*
|
|
18
|
+
* @param props - The props of the component.
|
|
19
|
+
* @param props.children - The text to display in bold.
|
|
20
|
+
* @returns A bold element.
|
|
21
|
+
* @example
|
|
22
|
+
* <Text>
|
|
23
|
+
* Hello <Bold>world</Bold>!
|
|
24
|
+
* </Text>
|
|
25
|
+
*/
|
|
26
|
+
export declare const Bold: import("../../component").SnapComponent<BoldProps, "Bold">;
|
|
27
|
+
/**
|
|
28
|
+
* A bold element.
|
|
29
|
+
*
|
|
30
|
+
* @see Bold
|
|
31
|
+
*/
|
|
32
|
+
export declare type BoldElement = ReturnType<typeof Bold>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { JsonObject, MaybeArray, SnapElement } from '../../component';
|
|
2
|
+
/**
|
|
3
|
+
* The children of the {@link Italic} component.
|
|
4
|
+
*/
|
|
5
|
+
export declare type ItalicChildren = MaybeArray<string | SnapElement<JsonObject, 'Bold'> | null>;
|
|
6
|
+
/**
|
|
7
|
+
* The props of the {@link Italic} component.
|
|
8
|
+
*
|
|
9
|
+
* @property children - The text to display in italic. This should be a string
|
|
10
|
+
* or an array of strings.
|
|
11
|
+
*/
|
|
12
|
+
export declare type ItalicProps = {
|
|
13
|
+
children: ItalicChildren;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* An italic component, which is used to display text in italic. This componen
|
|
17
|
+
* can only be used as a child of the {@link Text} component.
|
|
18
|
+
*
|
|
19
|
+
* @param props - The props of the component.
|
|
20
|
+
* @param props.children - The text to display in italic. This should be a
|
|
21
|
+
* string or an array of strings.
|
|
22
|
+
* @returns An italic element.
|
|
23
|
+
* @example
|
|
24
|
+
* <Text>
|
|
25
|
+
* Hello <Italic>world</Italic>!
|
|
26
|
+
* </Text>
|
|
27
|
+
*/
|
|
28
|
+
export declare const Italic: import("../../component").SnapComponent<ItalicProps, "Italic">;
|
|
29
|
+
/**
|
|
30
|
+
* An italic element.
|
|
31
|
+
*
|
|
32
|
+
* @see Italic
|
|
33
|
+
*/
|
|
34
|
+
export declare type ItalicElement = ReturnType<typeof Italic>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AddressElement } from './Address';
|
|
2
|
+
import type { BoxElement } from './Box';
|
|
3
|
+
import type { CopyableElement } from './Copyable';
|
|
4
|
+
import type { DividerElement } from './Divider';
|
|
5
|
+
import type { StandardFormElement } from './form';
|
|
6
|
+
import type { StandardFormattingElement } from './formatting';
|
|
7
|
+
import type { HeadingElement } from './Heading';
|
|
8
|
+
import type { ImageElement } from './Image';
|
|
9
|
+
import type { LinkElement } from './Link';
|
|
10
|
+
import type { RowElement } from './Row';
|
|
11
|
+
import type { SpinnerElement } from './Spinner';
|
|
12
|
+
import type { TextElement } from './Text';
|
|
13
|
+
export * from './form';
|
|
14
|
+
export * from './formatting';
|
|
15
|
+
export * from './Address';
|
|
16
|
+
export * from './Box';
|
|
17
|
+
export * from './Copyable';
|
|
18
|
+
export * from './Divider';
|
|
19
|
+
export * from './Heading';
|
|
20
|
+
export * from './Image';
|
|
21
|
+
export * from './Link';
|
|
22
|
+
export * from './Row';
|
|
23
|
+
export * from './Spinner';
|
|
24
|
+
export * from './Text';
|
|
25
|
+
/**
|
|
26
|
+
* A built-in JSX element, which can be used in a Snap user interface.
|
|
27
|
+
*/
|
|
28
|
+
export declare type JSXElement = StandardFormElement | StandardFormattingElement | AddressElement | BoxElement | CopyableElement | DividerElement | HeadingElement | ImageElement | LinkElement | RowElement | SpinnerElement | TextElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JsonObject, Key, SnapComponent } from './component';
|
|
2
|
+
/**
|
|
3
|
+
* The JSX runtime for Snaps SDK components. This function is used to render
|
|
4
|
+
* Snap components into a format that can be used by the Snaps.
|
|
5
|
+
*
|
|
6
|
+
* This is the "development" version of the runtime, which includes additional
|
|
7
|
+
* validation, which is otherwise handled by MetaMask. To use this runtime,
|
|
8
|
+
* specify `@metamask/snaps-sdk` as import source for JSX, and use
|
|
9
|
+
* `react-jsxdev` as the pragma.
|
|
10
|
+
*
|
|
11
|
+
* @param component - The component to render.
|
|
12
|
+
* @param props - The props to pass to the component.
|
|
13
|
+
* @param key - The key of the component.
|
|
14
|
+
* @returns The rendered component.
|
|
15
|
+
* @see https://www.typescriptlang.org/tsconfig/#jsx
|
|
16
|
+
*/
|
|
17
|
+
export declare function jsxDEV<Props extends JsonObject>(component: SnapComponent<Props>, props: Props, key: Key | null): unknown | null;
|