UNPKG

@metamask/snaps-sdk

Version:

A library containing the core functionality for building MetaMask Snaps

352 lines 18.7 kB
import type { Struct } from "@metamask/superstruct"; import type { GenericSnapElement, Key, SnapElement, SnapsChildren, StringElement } from "./component.cjs"; import type { AssetSelectorElement, SkeletonElement, AddressElement, AddressInputElement, BoldElement, BoxElement, ButtonElement, CheckboxElement, CardElement, CopyableElement, DividerElement, DropdownElement, OptionElement, RadioElement, RadioGroupElement, FieldElement, FormElement, HeadingElement, ImageElement, InputElement, ItalicElement, JSXElement, LinkElement, RowElement, SpinnerElement, StandardFormattingElement, TextElement, TooltipElement, ValueElement, FileInputElement, ContainerElement, FooterElement, IconElement, SectionElement, SelectorElement, SelectorOptionElement, BannerElement } from "./components/index.cjs"; import type { Describe } from "../internals/index.cjs"; /** * A struct for the {@link Key} type. */ export declare const KeyStruct: Describe<Key>; /** * A struct for the {@link StringElement} type. */ export declare const StringElementStruct: Describe<StringElement>; /** * A struct for the {@link GenericSnapElement} type. */ export declare const ElementStruct: Describe<GenericSnapElement>; /** * Shared struct used to validate border radius values used by various Snaps components. */ export declare const BorderRadiusStruct: Struct<"none" | "medium" | "full", null>; /** * A struct for the {@link ImageElement} type. */ export declare const ImageStruct: Describe<ImageElement>; /** * A struct for the {@link IconElement} type. */ export declare const IconStruct: Describe<IconElement>; /** * A struct for the {@link ButtonElement} type. */ export declare const ButtonStruct: Describe<ButtonElement>; /** * A struct for the {@link CheckboxElement} type. */ export declare const CheckboxStruct: Describe<CheckboxElement>; /** * A struct for the generic input element props. */ export declare const GenericInputPropsStruct: Struct<{ name: string; value?: string | undefined; placeholder?: string | undefined; disabled?: boolean | undefined; }, { name: Struct<string, null>; value: Struct<string | undefined, null>; placeholder: Struct<string | undefined, null>; disabled: Struct<boolean | undefined, null>; }>; /** * A struct for the text type input props. */ export declare const TextInputPropsStruct: Struct<{ name: string; type: "text"; value?: string | undefined; placeholder?: string | undefined; disabled?: boolean | undefined; }, { type: Struct<"text", null>; value: Struct<string | undefined, null>; name: Struct<string, null>; placeholder: Struct<string | undefined, null>; disabled: Struct<boolean | undefined, null>; }>; /** * A struct for the password type input props. */ export declare const PasswordInputPropsStruct: Struct<{ name: string; type: "password"; value?: string | undefined; placeholder?: string | undefined; disabled?: boolean | undefined; }, { type: Struct<"password", null>; value: Struct<string | undefined, null>; name: Struct<string, null>; placeholder: Struct<string | undefined, null>; disabled: Struct<boolean | undefined, null>; }>; /** * A struct for the number type input props. */ export declare const NumberInputPropsStruct: Struct<{ name: string; type: "number"; value?: string | undefined; placeholder?: string | undefined; disabled?: boolean | undefined; min?: number | undefined; max?: number | undefined; step?: number | undefined; }, { type: Struct<"number", null>; min: Struct<number | undefined, null>; max: Struct<number | undefined, null>; step: Struct<number | undefined, null>; value: Struct<string | undefined, null>; name: Struct<string, null>; placeholder: Struct<string | undefined, null>; disabled: Struct<boolean | undefined, null>; }>; /** * A struct for the {@link InputElement} type. */ export declare const InputStruct: Describe<InputElement>; /** * A struct for the {@link AddressInputElement} type. */ export declare const AddressInputStruct: Describe<AddressInputElement>; /** * A struct for the {@link OptionElement} type. */ export declare const OptionStruct: Describe<OptionElement>; /** * A struct for the {@link DropdownElement} type. */ export declare const DropdownStruct: Describe<DropdownElement>; /** * A struct for the {@link AddressElement} type. */ export declare const AddressStruct: Describe<AddressElement>; /** * A struct for the {@link CardElement} type. */ export declare const CardStruct: Describe<CardElement>; /** * A struct for the {@link SelectorOptionElement} type. */ export declare const SelectorOptionStruct: Describe<SelectorOptionElement>; /** * A struct for the {@link SelectorElement} type. */ export declare const SelectorStruct: Describe<SelectorElement>; /** * A struct for the {@link AssetSelectorElement} type. */ export declare const AssetSelectorStruct: Describe<AssetSelectorElement>; /** * A struct for the {@link RadioElement} type. */ export declare const RadioStruct: Describe<RadioElement>; /** * A struct for the {@link RadioGroupElement} type. */ export declare const RadioGroupStruct: Describe<RadioGroupElement>; /** * A struct for the {@link FileInputElement} type. */ export declare const FileInputStruct: Describe<FileInputElement>; /** * A union of the allowed children of the Field component. * This is mainly used in the simulator for validation purposes. */ export declare const FieldChildUnionStruct: Struct<SnapElement<import("./components/index.cjs").AssetSelectorProps, "AssetSelector"> | SnapElement<import("./components/index.cjs").AddressInputProps, "AddressInput"> | SnapElement<import("./components/index.cjs").IconProps, "Icon"> | SnapElement<{ src: string; alt?: string | undefined; borderRadius?: import("./components/index.cjs").BorderRadius; }, "Image"> | SnapElement<import("./components/index.cjs").ButtonProps, "Button"> | SnapElement<import("./components/index.cjs").CheckboxProps, "Checkbox"> | SnapElement<import("./components/index.cjs").FormProps, "Form"> | SnapElement<import("./components/index.cjs").InputProps, "Input"> | SnapElement<import("./components/index.cjs").DropdownProps, "Dropdown"> | SnapElement<{ name: string; value?: string | undefined; children: SnapsChildren<SnapElement<{ value: string; children: string; disabled?: boolean | undefined; }, "Radio">>; disabled?: boolean | undefined; }, "RadioGroup"> | SnapElement<import("./components/index.cjs").FileInputProps, "FileInput"> | SnapElement<import("./components/index.cjs").AddressProps, "Address"> | SnapElement<import("./components/index.cjs").CardProps, "Card"> | SnapElement<import("./components/index.cjs").SelectorProps, "Selector"> | SnapElement<import("./components/index.cjs").FieldProps, "Field"> | SnapElement<import("./components/index.cjs").BoldProps, "Bold"> | SnapElement<import("./components/index.cjs").ItalicProps, "Italic"> | SnapElement<import("./components/index.cjs").AvatarProps, "Avatar"> | SnapElement<import("./components/index.cjs").BoxProps, "Box"> | SnapElement<import("./components/index.cjs").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<import("./components/index.cjs").LinkProps, "Link"> | SnapElement<import("./components/index.cjs").SkeletonProps, "Skeleton"> | SnapElement<import("./components/index.cjs").TextProps, "Text"> | SnapElement<{ children: StringElement; size?: "md" | "sm" | "lg" | undefined; }, "Heading"> | SnapElement<import("./components/index.cjs").RowProps, "Row"> | SnapElement<import("./components/index.cjs").SectionProps, "Section"> | SnapElement<Record<string, never>, "Spinner"> | SnapElement<import("./components/index.cjs").TooltipProps, "Tooltip"> | SnapElement<import("./components/index.cjs").BannerProps, "Banner">, null>; /** * A struct for the {@link FieldElement} type. */ export declare const FieldStruct: Describe<FieldElement>; /** * A struct for the {@link BoldElement} type. */ export declare const BoldStruct: Describe<BoldElement>; /** * A struct for the {@link ItalicElement} type. */ export declare const ItalicStruct: Describe<ItalicElement>; export declare const FormattingStruct: Describe<StandardFormattingElement>; /** * A struct for the {@link AvatarElement} type. */ export declare const AvatarStruct: Struct<SnapElement<import("./components/index.cjs").AvatarProps, "Avatar">, null>; export declare const BoxChildrenStruct: Struct<SnapsChildren<GenericSnapElement>, null>; /** * A struct for the {@link BoxElement} type. */ export declare const BoxStruct: Describe<BoxElement>; /** * A subset of JSX elements that are allowed as children of the Form component. */ export declare const FormChildStruct: Struct<SnapsChildren<GenericSnapElement>, null>; /** * A struct for the {@link FormElement} type. */ export declare const FormStruct: Describe<FormElement>; /** * A struct for the {@link SectionElement} type. */ export declare const SectionStruct: Describe<SectionElement>; /** * A subset of JSX elements that are allowed as children of the Footer component. * This set should include a single button or a tuple of two buttons. */ export declare const FooterChildStruct: Struct<SnapElement<import("./components/index.cjs").ButtonProps, "Button"> | [SnapElement<import("./components/index.cjs").ButtonProps, "Button">, SnapElement<import("./components/index.cjs").ButtonProps, "Button">], null>; /** * A struct for the {@link FooterElement} type. */ export declare const FooterStruct: Describe<FooterElement>; /** * A struct for the {@link CopyableElement} type. */ export declare const CopyableStruct: Describe<CopyableElement>; /** * A struct for the {@link DividerElement} type. */ export declare const DividerStruct: Describe<DividerElement>; /** * A struct for the {@link HeadingElement} type. */ export declare const HeadingStruct: Describe<HeadingElement>; /** * A struct for the {@link LinkElement} type. */ export declare const LinkStruct: Describe<LinkElement>; /** * A struct for the {@link SkeletonElement} type. */ export declare const SkeletonStruct: Describe<SkeletonElement>; /** * A struct for the {@link TextElement} type. */ export declare const TextStruct: Describe<TextElement>; /** * A struct for the {@link ValueElement} type. */ export declare const ValueStruct: Describe<ValueElement>; /** * A subset of JSX elements that are allowed as children of the Tooltip component. * This set should include all text components and the Image. */ export declare const TooltipChildStruct: Struct<boolean | SnapElement<import("./components/index.cjs").IconProps, "Icon"> | SnapElement<{ src: string; alt?: string | undefined; borderRadius?: import("./components/index.cjs").BorderRadius; }, "Image"> | SnapElement<import("./components/index.cjs").BoldProps, "Bold"> | SnapElement<import("./components/index.cjs").ItalicProps, "Italic"> | SnapElement<import("./components/index.cjs").LinkProps, "Link"> | SnapElement<import("./components/index.cjs").TextProps, "Text">, null>; /** * A subset of JSX elements that are allowed as content of the Tooltip component. * This set should include all text components. */ export declare const TooltipContentStruct: Struct<string | SnapElement<import("./components/index.cjs").IconProps, "Icon"> | SnapElement<import("./components/index.cjs").BoldProps, "Bold"> | SnapElement<import("./components/index.cjs").ItalicProps, "Italic"> | SnapElement<import("./components/index.cjs").LinkProps, "Link"> | SnapElement<import("./components/index.cjs").TextProps, "Text">, null>; /** * A struct for the {@link TooltipElement} type. */ export declare const TooltipStruct: Describe<TooltipElement>; /** * A struct for the {@link BannerElement} type. */ export declare const BannerStruct: Describe<BannerElement>; /** * A struct for the {@link RowElement} type. */ export declare const RowStruct: Describe<RowElement>; /** * A struct for the {@link SpinnerElement} type. */ export declare const SpinnerStruct: Describe<SpinnerElement>; /** * A subset of JSX elements that are allowed as children of the Box component. * This set includes all components, except components that need to be nested in * another component (e.g., Field must be contained in a Form). */ export declare const BoxChildStruct: Struct<SnapElement<import("./components/index.cjs").AssetSelectorProps, "AssetSelector"> | SnapElement<import("./components/index.cjs").AddressInputProps, "AddressInput"> | SnapElement<import("./components/index.cjs").IconProps, "Icon"> | SnapElement<{ src: string; alt?: string | undefined; borderRadius?: import("./components/index.cjs").BorderRadius; }, "Image"> | SnapElement<import("./components/index.cjs").ButtonProps, "Button"> | SnapElement<import("./components/index.cjs").CheckboxProps, "Checkbox"> | SnapElement<import("./components/index.cjs").FormProps, "Form"> | SnapElement<import("./components/index.cjs").InputProps, "Input"> | SnapElement<import("./components/index.cjs").DropdownProps, "Dropdown"> | SnapElement<{ name: string; value?: string | undefined; children: SnapsChildren<SnapElement<{ value: string; children: string; disabled?: boolean | undefined; }, "Radio">>; disabled?: boolean | undefined; }, "RadioGroup"> | SnapElement<import("./components/index.cjs").FileInputProps, "FileInput"> | SnapElement<import("./components/index.cjs").AddressProps, "Address"> | SnapElement<import("./components/index.cjs").CardProps, "Card"> | SnapElement<import("./components/index.cjs").SelectorProps, "Selector"> | SnapElement<import("./components/index.cjs").FieldProps, "Field"> | SnapElement<import("./components/index.cjs").BoldProps, "Bold"> | SnapElement<import("./components/index.cjs").ItalicProps, "Italic"> | SnapElement<import("./components/index.cjs").AvatarProps, "Avatar"> | SnapElement<import("./components/index.cjs").BoxProps, "Box"> | SnapElement<import("./components/index.cjs").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<import("./components/index.cjs").LinkProps, "Link"> | SnapElement<import("./components/index.cjs").SkeletonProps, "Skeleton"> | SnapElement<import("./components/index.cjs").TextProps, "Text"> | SnapElement<{ children: StringElement; size?: "md" | "sm" | "lg" | undefined; }, "Heading"> | SnapElement<import("./components/index.cjs").RowProps, "Row"> | SnapElement<import("./components/index.cjs").SectionProps, "Section"> | SnapElement<Record<string, never>, "Spinner"> | SnapElement<import("./components/index.cjs").TooltipProps, "Tooltip"> | SnapElement<import("./components/index.cjs").BannerProps, "Banner">, null>; /** * A struct for the {@link ContainerElement} type. */ export declare const ContainerStruct: Describe<ContainerElement>; /** * For now, the allowed JSX elements at the root are the same as the allowed * children of the Box component. */ export declare const RootJSXElementStruct: Struct<SnapElement<import("./components/index.cjs").AssetSelectorProps, "AssetSelector"> | SnapElement<import("./components/index.cjs").AddressInputProps, "AddressInput"> | SnapElement<import("./components/index.cjs").IconProps, "Icon"> | SnapElement<{ src: string; alt?: string | undefined; borderRadius?: import("./components/index.cjs").BorderRadius; }, "Image"> | SnapElement<import("./components/index.cjs").ButtonProps, "Button"> | SnapElement<import("./components/index.cjs").CheckboxProps, "Checkbox"> | SnapElement<import("./components/index.cjs").FormProps, "Form"> | SnapElement<import("./components/index.cjs").InputProps, "Input"> | SnapElement<import("./components/index.cjs").DropdownProps, "Dropdown"> | SnapElement<{ name: string; value?: string | undefined; children: SnapsChildren<SnapElement<{ value: string; children: string; disabled?: boolean | undefined; }, "Radio">>; disabled?: boolean | undefined; }, "RadioGroup"> | SnapElement<import("./components/index.cjs").FileInputProps, "FileInput"> | SnapElement<import("./components/index.cjs").AddressProps, "Address"> | SnapElement<import("./components/index.cjs").CardProps, "Card"> | SnapElement<import("./components/index.cjs").SelectorProps, "Selector"> | SnapElement<import("./components/index.cjs").FieldProps, "Field"> | SnapElement<import("./components/index.cjs").BoldProps, "Bold"> | SnapElement<import("./components/index.cjs").ItalicProps, "Italic"> | SnapElement<import("./components/index.cjs").AvatarProps, "Avatar"> | SnapElement<import("./components/index.cjs").BoxProps, "Box"> | SnapElement<import("./components/index.cjs").ContainerProps, "Container"> | SnapElement<import("./components/index.cjs").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<import("./components/index.cjs").LinkProps, "Link"> | SnapElement<import("./components/index.cjs").SkeletonProps, "Skeleton"> | SnapElement<import("./components/index.cjs").TextProps, "Text"> | SnapElement<{ children: StringElement; size?: "md" | "sm" | "lg" | undefined; }, "Heading"> | SnapElement<import("./components/index.cjs").RowProps, "Row"> | SnapElement<import("./components/index.cjs").SectionProps, "Section"> | SnapElement<Record<string, never>, "Spinner"> | SnapElement<import("./components/index.cjs").TooltipProps, "Tooltip"> | SnapElement<import("./components/index.cjs").BannerProps, "Banner">, null>; /** * A struct for the {@link JSXElement} type. */ export declare const JSXElementStruct: Describe<JSXElement>; /** * Check if a value is a JSX element. * * @param value - The value to check. * @returns True if the value is a JSX element, false otherwise. */ export declare function isJSXElement(value: unknown): value is JSXElement; /** * Check if a value is a JSX element, without validating all of its contents. * This is useful when you want to validate the structure of a value, but not * all the children. * * This should only be used when you are sure that the value is safe to use, * i.e., after using {@link isJSXElement}. * * @param value - The value to check. * @returns True if the value is a JSX element, false otherwise. */ export declare function isJSXElementUnsafe(value: unknown): value is JSXElement; /** * Assert that a value is a JSX element. * * @param value - The value to check. * @throws If the value is not a JSX element. */ export declare function assertJSXElement(value: unknown): asserts value is JSXElement; //# sourceMappingURL=validation.d.cts.map