UNPKG

@metamask/snaps-sdk

Version:

A library containing the core functionality for building MetaMask Snaps

32 lines 1.28 kB
import { assign, boolean, object, optional, string } from "@metamask/superstruct"; import { literal } from "../../internals/index.mjs"; import { createBuilder } from "../builder.mjs"; import { LiteralStruct, NodeType } from "../nodes.mjs"; export const TextStruct = assign(LiteralStruct, object({ type: literal(NodeType.Text), value: string(), markdown: optional(boolean()), })); /** * Create a {@link Text} node. * * @param args - The node arguments. This can be either a string * and a boolean, or an object with a `value` property * and an optional `markdown` property. * @param args.value - The text content of the node. * @param args.markdown - An optional flag to enable or disable markdown. This * is enabled by default. * @returns The text node as object. * @deprecated Snaps component functions are deprecated, in favor of the new JSX * components. This function will be removed in a future release. * @example * const node = text({ value: 'Hello, world!' }); * const node = text('Hello, world!'); * const node = text({ value: 'Hello, world!', markdown: false }); * const node = text('Hello, world!', false); */ export const text = createBuilder(NodeType.Text, TextStruct, [ 'value', 'markdown', ]); //# sourceMappingURL=text.mjs.map