@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
51 lines • 2.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.row = exports.RowStruct = exports.RowVariant = void 0;
const superstruct_1 = require("@metamask/superstruct");
const address_1 = require("./address.cjs");
const image_1 = require("./image.cjs");
const text_1 = require("./text.cjs");
const internals_1 = require("../../internals/index.cjs");
const builder_1 = require("../builder.cjs");
const nodes_1 = require("../nodes.cjs");
var RowVariant;
(function (RowVariant) {
RowVariant["Default"] = "default";
RowVariant["Critical"] = "critical";
RowVariant["Warning"] = "warning";
})(RowVariant || (exports.RowVariant = RowVariant = {}));
// A subset of components made available to the row
const RowComponentStruct = (0, superstruct_1.union)([image_1.ImageStruct, text_1.TextStruct, address_1.AddressStruct]);
exports.RowStruct = (0, superstruct_1.assign)(nodes_1.LiteralStruct, (0, superstruct_1.object)({
type: (0, internals_1.literal)(nodes_1.NodeType.Row),
variant: (0, superstruct_1.optional)((0, superstruct_1.union)([
(0, internals_1.enumValue)(RowVariant.Default),
(0, internals_1.enumValue)(RowVariant.Critical),
(0, internals_1.enumValue)(RowVariant.Warning),
])),
label: (0, superstruct_1.string)(),
value: RowComponentStruct,
}));
/**
* Create a {@link Row} node.
*
* @param args - The node arguments. This can either be a string, a component and an optional variant or an object
* with the properties: `label`, `value` and `variant`.
* @param args.label - The label for the row.
* @param args.value - Another component, is currently limited to `image`, `text` and `address`.
* @param args.variant - An optional variant, either `default`, `warning` or `critical`.
* @returns The row node as an 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 = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520') });
* const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), variant: RowVariant.Warning });
* const node = row('Address', address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'));
* const node = row('Address', address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), RowVariant.Warning);
*/
exports.row = (0, builder_1.createBuilder)(nodes_1.NodeType.Row, exports.RowStruct, [
'label',
'value',
'variant',
]);
//# sourceMappingURL=row.cjs.map