UNPKG

@metamask/snaps-sdk

Version:

A library containing the core functionality for building MetaMask Snaps

52 lines 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.button = exports.ButtonStruct = exports.ButtonType = exports.ButtonVariant = 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"); var ButtonVariant; (function (ButtonVariant) { ButtonVariant["Primary"] = "primary"; ButtonVariant["Secondary"] = "secondary"; })(ButtonVariant || (exports.ButtonVariant = ButtonVariant = {})); var ButtonType; (function (ButtonType) { ButtonType["Button"] = "button"; ButtonType["Submit"] = "submit"; })(ButtonType || (exports.ButtonType = ButtonType = {})); exports.ButtonStruct = (0, superstruct_1.assign)(nodes_1.LiteralStruct, (0, superstruct_1.object)({ type: (0, internals_1.literal)(nodes_1.NodeType.Button), value: (0, superstruct_1.string)(), variant: (0, superstruct_1.optional)((0, superstruct_1.union)([ (0, internals_1.enumValue)(ButtonVariant.Primary), (0, internals_1.enumValue)(ButtonVariant.Secondary), ])), buttonType: (0, superstruct_1.optional)((0, superstruct_1.union)([(0, internals_1.enumValue)(ButtonType.Button), (0, internals_1.enumValue)(ButtonType.Submit)])), name: (0, superstruct_1.optional)((0, superstruct_1.string)()), })); /** * Create a {@link Button} node. * * @param args - The node arguments. This can be either a string, or an object * with a `value` property. A set of optional properties can be passed. * @param args.variant - The optional variant of the button. * @param args.value - The text content of the node. * @param args.name - The optional name of the button. * @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 * ```typescript * const node = button({ variant: 'primary', text: 'Hello, world!', name: 'myButton' }); * const node = button('Hello, world!', 'button', 'myButton', 'primary'); * const node = button('Hello, world!'); * ``` */ exports.button = (0, builder_1.createBuilder)(nodes_1.NodeType.Button, exports.ButtonStruct, [ 'value', 'buttonType', 'name', 'variant', ]); //# sourceMappingURL=button.cjs.map