UNPKG

@metamask/snaps-sdk

Version:

A library containing the core functionality for building MetaMask Snaps

1 lines 2.31 kB
{"version":3,"file":"text.cjs","sourceRoot":"","sources":["../../../src/ui/components/text.ts"],"names":[],"mappings":";;;AACA,uDAM+B;AAE/B,yDAA0C;AAC1C,4CAA2C;AAC3C,wCAAmD;AAEtC,QAAA,UAAU,GAAG,IAAA,oBAAM,EAC9B,qBAAa,EACb,IAAA,oBAAM,EAAC;IACL,IAAI,EAAE,IAAA,mBAAO,EAAC,gBAAQ,CAAC,IAAI,CAAC;IAC5B,KAAK,EAAE,IAAA,oBAAM,GAAE;IACf,QAAQ,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;CAC9B,CAAC,CACH,CAAC;AAaF;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,IAAI,GAAG,IAAA,uBAAa,EAAC,gBAAQ,CAAC,IAAI,EAAE,kBAAU,EAAE;IAC3D,OAAO;IACP,UAAU;CACX,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n assign,\n boolean,\n object,\n optional,\n string,\n} from '@metamask/superstruct';\n\nimport { literal } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const TextStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Text),\n value: string(),\n markdown: optional(boolean()),\n }),\n);\n\n/**\n * A text node, that renders the text as one or more paragraphs.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n * @property markdown - A flag to enable/disable markdown, if nothing is specified\n * markdown will be enabled.\n */\nexport type Text = Infer<typeof TextStruct>;\n\n/**\n * Create a {@link Text} node.\n *\n * @param args - The node arguments. This can be either a string\n * and a boolean, or an object with a `value` property\n * and an optional `markdown` property.\n * @param args.value - The text content of the node.\n * @param args.markdown - An optional flag to enable or disable markdown. This\n * is enabled by default.\n * @returns The text node as object.\n * @deprecated Snaps component functions are deprecated, in favor of the new JSX\n * components. This function will be removed in a future release.\n * @example\n * const node = text({ value: 'Hello, world!' });\n * const node = text('Hello, world!');\n * const node = text({ value: 'Hello, world!', markdown: false });\n * const node = text('Hello, world!', false);\n */\nexport const text = createBuilder(NodeType.Text, TextStruct, [\n 'value',\n 'markdown',\n]);\n"]}