@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
72 lines • 2.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ComponentStruct = exports.panel = exports.PanelStruct = exports.ParentStruct = void 0;
const superstruct_1 = require("@metamask/superstruct");
const address_1 = require("./address.cjs");
const button_1 = require("./button.cjs");
const copyable_1 = require("./copyable.cjs");
const divider_1 = require("./divider.cjs");
const form_1 = require("./form.cjs");
const heading_1 = require("./heading.cjs");
const image_1 = require("./image.cjs");
const input_1 = require("./input.cjs");
const row_1 = require("./row.cjs");
const spinner_1 = require("./spinner.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");
/**
* @internal
*/
exports.ParentStruct = (0, superstruct_1.assign)(nodes_1.NodeStruct, (0, superstruct_1.object)({
// This node references itself indirectly, so we need to use `lazy()`.
// eslint-disable-next-line @typescript-eslint/no-use-before-define
children: (0, superstruct_1.array)((0, superstruct_1.lazy)(() => exports.ComponentStruct)),
}));
/**
* @internal
*/
exports.PanelStruct = (0, superstruct_1.assign)(exports.ParentStruct, (0, superstruct_1.object)({
type: (0, internals_1.literal)(nodes_1.NodeType.Panel),
}));
/**
* Create a {@link Panel} node.
*
* @param args - The node arguments. This can be either an array of children, or
* an object with a `children` property.
* @param args.children - The child nodes of the panel. This can be any valid
* {@link Component}.
* @returns The panel 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 = panel({
* children: [
* heading({ text: 'Hello, world!' }),
* text({ text: 'This is a panel.' }),
* ],
* });
*
* const node = panel([
* heading('Hello, world!'),
* text('This is a panel.'),
* ]);
*/
exports.panel = (0, builder_1.createBuilder)(nodes_1.NodeType.Panel, exports.PanelStruct, ['children']);
// This is defined separately from `Component` to avoid circular dependencies.
exports.ComponentStruct = (0, internals_1.typedUnion)([
copyable_1.CopyableStruct,
divider_1.DividerStruct,
heading_1.HeadingStruct,
image_1.ImageStruct,
exports.PanelStruct,
spinner_1.SpinnerStruct,
text_1.TextStruct,
row_1.RowStruct,
address_1.AddressStruct,
input_1.InputStruct,
form_1.FormStruct,
button_1.ButtonStruct,
]);
//# sourceMappingURL=panel.cjs.map