@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
47 lines • 1.49 kB
JavaScript
import { array, assign, lazy, object } from "@metamask/superstruct";
import { AddressStruct } from "./address.mjs";
import { ButtonStruct } from "./button.mjs";
import { CopyableStruct } from "./copyable.mjs";
import { DividerStruct } from "./divider.mjs";
import { FormStruct } from "./form.mjs";
import { HeadingStruct } from "./heading.mjs";
import { ImageStruct } from "./image.mjs";
import { InputStruct } from "./input.mjs";
import { RowStruct } from "./row.mjs";
import { SpinnerStruct } from "./spinner.mjs";
import { TextStruct } from "./text.mjs";
import { typedUnion, literal } from "../../internals/index.mjs";
import { NodeStruct, NodeType } from "../nodes.mjs";
/**
* @internal
*/
export const ParentStruct = assign(NodeStruct, object({
// This node references itself indirectly, so we need to use `lazy()`.
children: array(lazy(
/* istanbul ignore next */
() =>
// eslint-disable-next-line @typescript-eslint/no-use-before-define
ComponentStruct)),
}));
/**
* @internal
*/
export const PanelStruct = assign(ParentStruct, object({
type: literal(NodeType.Panel),
}));
// This is defined separately from `Component` to avoid circular dependencies.
export const ComponentStruct = typedUnion([
CopyableStruct,
DividerStruct,
HeadingStruct,
ImageStruct,
PanelStruct,
SpinnerStruct,
TextStruct,
RowStruct,
AddressStruct,
InputStruct,
FormStruct,
ButtonStruct,
]);
//# sourceMappingURL=panel.mjs.map