@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
35 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.text = exports.TextStruct = void 0;
const superstruct_1 = require("@metamask/superstruct");
const internals_1 = require("../../internals/index.cjs");
const builder_1 = require("../builder.cjs");
const nodes_1 = require("../nodes.cjs");
exports.TextStruct = (0, superstruct_1.assign)(nodes_1.LiteralStruct, (0, superstruct_1.object)({
type: (0, internals_1.literal)(nodes_1.NodeType.Text),
value: (0, superstruct_1.string)(),
markdown: (0, superstruct_1.optional)((0, superstruct_1.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);
*/
exports.text = (0, builder_1.createBuilder)(nodes_1.NodeType.Text, exports.TextStruct, [
'value',
'markdown',
]);
//# sourceMappingURL=text.cjs.map