@metamask/snaps-sdk 2.1.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -2
- package/dist/index.js +805 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +810 -0
- package/dist/index.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +17 -14
- package/dist/cjs/error-wrappers.js +0 -80
- package/dist/cjs/error-wrappers.js.map +0 -1
- package/dist/cjs/errors.js +0 -162
- package/dist/cjs/errors.js.map +0 -1
- package/dist/cjs/images.js +0 -54
- package/dist/cjs/images.js.map +0 -1
- package/dist/cjs/index.js +0 -68
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/internals/error-wrappers.js +0 -39
- package/dist/cjs/internals/error-wrappers.js.map +0 -1
- package/dist/cjs/internals/errors.js +0 -59
- package/dist/cjs/internals/errors.js.map +0 -1
- package/dist/cjs/internals/helpers.js +0 -6
- package/dist/cjs/internals/helpers.js.map +0 -1
- package/dist/cjs/internals/index.js +0 -24
- package/dist/cjs/internals/index.js.map +0 -1
- package/dist/cjs/internals/structs.js +0 -43
- package/dist/cjs/internals/structs.js.map +0 -1
- package/dist/cjs/internals/svg.js +0 -49
- package/dist/cjs/internals/svg.js.map +0 -1
- package/dist/cjs/types/caip.js +0 -10
- package/dist/cjs/types/caip.js.map +0 -1
- package/dist/cjs/types/global.js +0 -6
- package/dist/cjs/types/global.js.map +0 -1
- package/dist/cjs/types/handlers/cronjob.js +0 -6
- package/dist/cjs/types/handlers/cronjob.js.map +0 -1
- package/dist/cjs/types/handlers/home-page.js +0 -6
- package/dist/cjs/types/handlers/home-page.js.map +0 -1
- package/dist/cjs/types/handlers/index.js +0 -28
- package/dist/cjs/types/handlers/index.js.map +0 -1
- package/dist/cjs/types/handlers/keyring.js +0 -6
- package/dist/cjs/types/handlers/keyring.js.map +0 -1
- package/dist/cjs/types/handlers/lifecycle.js +0 -6
- package/dist/cjs/types/handlers/lifecycle.js.map +0 -1
- package/dist/cjs/types/handlers/name-lookup.js +0 -6
- package/dist/cjs/types/handlers/name-lookup.js.map +0 -1
- package/dist/cjs/types/handlers/rpc-request.js +0 -6
- package/dist/cjs/types/handlers/rpc-request.js.map +0 -1
- package/dist/cjs/types/handlers/signature.js +0 -6
- package/dist/cjs/types/handlers/signature.js.map +0 -1
- package/dist/cjs/types/handlers/transaction.js +0 -16
- package/dist/cjs/types/handlers/transaction.js.map +0 -1
- package/dist/cjs/types/handlers/user-input.js +0 -51
- package/dist/cjs/types/handlers/user-input.js.map +0 -1
- package/dist/cjs/types/index.js +0 -29
- package/dist/cjs/types/index.js.map +0 -1
- package/dist/cjs/types/interface.js +0 -26
- package/dist/cjs/types/interface.js.map +0 -1
- package/dist/cjs/types/methods/create-interface.js +0 -6
- package/dist/cjs/types/methods/create-interface.js.map +0 -1
- package/dist/cjs/types/methods/dialog.js +0 -18
- package/dist/cjs/types/methods/dialog.js.map +0 -1
- package/dist/cjs/types/methods/get-bip32-entropy.js +0 -6
- package/dist/cjs/types/methods/get-bip32-entropy.js.map +0 -1
- package/dist/cjs/types/methods/get-bip32-public-key.js +0 -6
- package/dist/cjs/types/methods/get-bip32-public-key.js.map +0 -1
- package/dist/cjs/types/methods/get-bip44-entropy.js +0 -6
- package/dist/cjs/types/methods/get-bip44-entropy.js.map +0 -1
- package/dist/cjs/types/methods/get-client-status.js +0 -10
- package/dist/cjs/types/methods/get-client-status.js.map +0 -1
- package/dist/cjs/types/methods/get-entropy.js +0 -6
- package/dist/cjs/types/methods/get-entropy.js.map +0 -1
- package/dist/cjs/types/methods/get-file.js +0 -18
- package/dist/cjs/types/methods/get-file.js.map +0 -1
- package/dist/cjs/types/methods/get-interface-state.js +0 -6
- package/dist/cjs/types/methods/get-interface-state.js.map +0 -1
- package/dist/cjs/types/methods/get-locale.js +0 -10
- package/dist/cjs/types/methods/get-locale.js.map +0 -1
- package/dist/cjs/types/methods/get-snaps.js +0 -6
- package/dist/cjs/types/methods/get-snaps.js.map +0 -1
- package/dist/cjs/types/methods/index.js +0 -38
- package/dist/cjs/types/methods/index.js.map +0 -1
- package/dist/cjs/types/methods/invoke-keyring.js +0 -6
- package/dist/cjs/types/methods/invoke-keyring.js.map +0 -1
- package/dist/cjs/types/methods/invoke-snap.js +0 -6
- package/dist/cjs/types/methods/invoke-snap.js.map +0 -1
- package/dist/cjs/types/methods/manage-accounts.js +0 -6
- package/dist/cjs/types/methods/manage-accounts.js.map +0 -1
- package/dist/cjs/types/methods/manage-state.js +0 -18
- package/dist/cjs/types/methods/manage-state.js.map +0 -1
- package/dist/cjs/types/methods/methods.js +0 -6
- package/dist/cjs/types/methods/methods.js.map +0 -1
- package/dist/cjs/types/methods/notify.js +0 -17
- package/dist/cjs/types/methods/notify.js.map +0 -1
- package/dist/cjs/types/methods/request-snaps.js +0 -6
- package/dist/cjs/types/methods/request-snaps.js.map +0 -1
- package/dist/cjs/types/methods/update-interface.js +0 -6
- package/dist/cjs/types/methods/update-interface.js.map +0 -1
- package/dist/cjs/types/permissions.js +0 -6
- package/dist/cjs/types/permissions.js.map +0 -1
- package/dist/cjs/types/provider.js +0 -6
- package/dist/cjs/types/provider.js.map +0 -1
- package/dist/cjs/types/snap.js +0 -6
- package/dist/cjs/types/snap.js.map +0 -1
- package/dist/cjs/ui/builder.js +0 -44
- package/dist/cjs/ui/builder.js.map +0 -1
- package/dist/cjs/ui/component.js +0 -29
- package/dist/cjs/ui/component.js.map +0 -1
- package/dist/cjs/ui/components/address.js +0 -30
- package/dist/cjs/ui/components/address.js.map +0 -1
- package/dist/cjs/ui/components/button.js +0 -59
- package/dist/cjs/ui/components/button.js.map +0 -1
- package/dist/cjs/ui/components/copyable.js +0 -32
- package/dist/cjs/ui/components/copyable.js.map +0 -1
- package/dist/cjs/ui/components/divider.js +0 -27
- package/dist/cjs/ui/components/divider.js.map +0 -1
- package/dist/cjs/ui/components/form.js +0 -41
- package/dist/cjs/ui/components/form.js.map +0 -1
- package/dist/cjs/ui/components/heading.js +0 -30
- package/dist/cjs/ui/components/heading.js.map +0 -1
- package/dist/cjs/ui/components/image.js +0 -42
- package/dist/cjs/ui/components/image.js.map +0 -1
- package/dist/cjs/ui/components/index.js +0 -54
- package/dist/cjs/ui/components/index.js.map +0 -1
- package/dist/cjs/ui/components/input.js +0 -52
- package/dist/cjs/ui/components/input.js.map +0 -1
- package/dist/cjs/ui/components/panel.js +0 -65
- package/dist/cjs/ui/components/panel.js.map +0 -1
- package/dist/cjs/ui/components/row.js +0 -57
- package/dist/cjs/ui/components/row.js.map +0 -1
- package/dist/cjs/ui/components/spinner.js +0 -27
- package/dist/cjs/ui/components/spinner.js.map +0 -1
- package/dist/cjs/ui/components/text.js +0 -32
- package/dist/cjs/ui/components/text.js.map +0 -1
- package/dist/cjs/ui/index.js +0 -28
- package/dist/cjs/ui/index.js.map +0 -1
- package/dist/cjs/ui/nodes.js +0 -46
- package/dist/cjs/ui/nodes.js.map +0 -1
- package/dist/esm/error-wrappers.js +0 -128
- package/dist/esm/error-wrappers.js.map +0 -1
- package/dist/esm/errors.js +0 -155
- package/dist/esm/errors.js.map +0 -1
- package/dist/esm/images.js +0 -84
- package/dist/esm/images.js.map +0 -1
- package/dist/esm/index.js +0 -10
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/internals/error-wrappers.js +0 -39
- package/dist/esm/internals/error-wrappers.js.map +0 -1
- package/dist/esm/internals/errors.js +0 -58
- package/dist/esm/internals/errors.js.map +0 -1
- package/dist/esm/internals/helpers.js +0 -3
- package/dist/esm/internals/helpers.js.map +0 -1
- package/dist/esm/internals/index.js +0 -7
- package/dist/esm/internals/index.js.map +0 -1
- package/dist/esm/internals/structs.js +0 -59
- package/dist/esm/internals/structs.js.map +0 -1
- package/dist/esm/internals/svg.js +0 -41
- package/dist/esm/internals/svg.js.map +0 -1
- package/dist/esm/types/caip.js +0 -7
- package/dist/esm/types/caip.js.map +0 -1
- package/dist/esm/types/global.js +0 -3
- package/dist/esm/types/global.js.map +0 -1
- package/dist/esm/types/handlers/cronjob.js +0 -3
- package/dist/esm/types/handlers/cronjob.js.map +0 -1
- package/dist/esm/types/handlers/home-page.js +0 -3
- package/dist/esm/types/handlers/home-page.js.map +0 -1
- package/dist/esm/types/handlers/index.js +0 -11
- package/dist/esm/types/handlers/index.js.map +0 -1
- package/dist/esm/types/handlers/keyring.js +0 -3
- package/dist/esm/types/handlers/keyring.js.map +0 -1
- package/dist/esm/types/handlers/lifecycle.js +0 -3
- package/dist/esm/types/handlers/lifecycle.js.map +0 -1
- package/dist/esm/types/handlers/name-lookup.js +0 -3
- package/dist/esm/types/handlers/name-lookup.js.map +0 -1
- package/dist/esm/types/handlers/rpc-request.js +0 -3
- package/dist/esm/types/handlers/rpc-request.js.map +0 -1
- package/dist/esm/types/handlers/signature.js +0 -3
- package/dist/esm/types/handlers/signature.js.map +0 -1
- package/dist/esm/types/handlers/transaction.js +0 -6
- package/dist/esm/types/handlers/transaction.js.map +0 -1
- package/dist/esm/types/handlers/user-input.js +0 -24
- package/dist/esm/types/handlers/user-input.js.map +0 -1
- package/dist/esm/types/index.js +0 -12
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/interface.js +0 -12
- package/dist/esm/types/interface.js.map +0 -1
- package/dist/esm/types/methods/create-interface.js +0 -3
- package/dist/esm/types/methods/create-interface.js.map +0 -1
- package/dist/esm/types/methods/dialog.js +0 -8
- package/dist/esm/types/methods/dialog.js.map +0 -1
- package/dist/esm/types/methods/get-bip32-entropy.js +0 -3
- package/dist/esm/types/methods/get-bip32-entropy.js.map +0 -1
- package/dist/esm/types/methods/get-bip32-public-key.js +0 -3
- package/dist/esm/types/methods/get-bip32-public-key.js.map +0 -1
- package/dist/esm/types/methods/get-bip44-entropy.js +0 -3
- package/dist/esm/types/methods/get-bip44-entropy.js.map +0 -1
- package/dist/esm/types/methods/get-client-status.js +0 -7
- package/dist/esm/types/methods/get-client-status.js.map +0 -1
- package/dist/esm/types/methods/get-entropy.js +0 -3
- package/dist/esm/types/methods/get-entropy.js.map +0 -1
- package/dist/esm/types/methods/get-file.js +0 -8
- package/dist/esm/types/methods/get-file.js.map +0 -1
- package/dist/esm/types/methods/get-interface-state.js +0 -3
- package/dist/esm/types/methods/get-interface-state.js.map +0 -1
- package/dist/esm/types/methods/get-locale.js +0 -7
- package/dist/esm/types/methods/get-locale.js.map +0 -1
- package/dist/esm/types/methods/get-snaps.js +0 -3
- package/dist/esm/types/methods/get-snaps.js.map +0 -1
- package/dist/esm/types/methods/index.js +0 -21
- package/dist/esm/types/methods/index.js.map +0 -1
- package/dist/esm/types/methods/invoke-keyring.js +0 -3
- package/dist/esm/types/methods/invoke-keyring.js.map +0 -1
- package/dist/esm/types/methods/invoke-snap.js +0 -3
- package/dist/esm/types/methods/invoke-snap.js.map +0 -1
- package/dist/esm/types/methods/manage-accounts.js +0 -3
- package/dist/esm/types/methods/manage-accounts.js.map +0 -1
- package/dist/esm/types/methods/manage-state.js +0 -8
- package/dist/esm/types/methods/manage-state.js.map +0 -1
- package/dist/esm/types/methods/methods.js +0 -3
- package/dist/esm/types/methods/methods.js.map +0 -1
- package/dist/esm/types/methods/notify.js +0 -7
- package/dist/esm/types/methods/notify.js.map +0 -1
- package/dist/esm/types/methods/request-snaps.js +0 -3
- package/dist/esm/types/methods/request-snaps.js.map +0 -1
- package/dist/esm/types/methods/update-interface.js +0 -3
- package/dist/esm/types/methods/update-interface.js.map +0 -1
- package/dist/esm/types/permissions.js +0 -3
- package/dist/esm/types/permissions.js.map +0 -1
- package/dist/esm/types/provider.js +0 -3
- package/dist/esm/types/provider.js.map +0 -1
- package/dist/esm/types/snap.js +0 -3
- package/dist/esm/types/snap.js.map +0 -1
- package/dist/esm/ui/builder.js +0 -50
- package/dist/esm/ui/builder.js.map +0 -1
- package/dist/esm/ui/component.js +0 -23
- package/dist/esm/ui/component.js.map +0 -1
- package/dist/esm/ui/components/address.js +0 -22
- package/dist/esm/ui/components/address.js.map +0 -1
- package/dist/esm/ui/components/button.js +0 -50
- package/dist/esm/ui/components/button.js.map +0 -1
- package/dist/esm/ui/components/copyable.js +0 -27
- package/dist/esm/ui/components/copyable.js.map +0 -1
- package/dist/esm/ui/components/divider.js +0 -15
- package/dist/esm/ui/components/divider.js.map +0 -1
- package/dist/esm/ui/components/form.js +0 -39
- package/dist/esm/ui/components/form.js.map +0 -1
- package/dist/esm/ui/components/heading.js +0 -22
- package/dist/esm/ui/components/heading.js.map +0 -1
- package/dist/esm/ui/components/image.js +0 -37
- package/dist/esm/ui/components/image.js.map +0 -1
- package/dist/esm/ui/components/index.js +0 -14
- package/dist/esm/ui/components/index.js.map +0 -1
- package/dist/esm/ui/components/input.js +0 -47
- package/dist/esm/ui/components/input.js.map +0 -1
- package/dist/esm/ui/components/panel.js +0 -66
- package/dist/esm/ui/components/panel.js.map +0 -1
- package/dist/esm/ui/components/row.js +0 -50
- package/dist/esm/ui/components/row.js.map +0 -1
- package/dist/esm/ui/components/spinner.js +0 -15
- package/dist/esm/ui/components/spinner.js.map +0 -1
- package/dist/esm/ui/components/text.js +0 -29
- package/dist/esm/ui/components/text.js.map +0 -1
- package/dist/esm/ui/index.js +0 -5
- package/dist/esm/ui/index.js.map +0 -1
- package/dist/esm/ui/nodes.js +0 -29
- package/dist/esm/ui/nodes.js.map +0 -1
package/dist/cjs/ui/builder.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createBuilder", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return createBuilder;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _utils = require("@metamask/utils");
|
|
12
|
-
function createBuilder(type, struct, keys = []) {
|
|
13
|
-
return (...args)=>{
|
|
14
|
-
// Node passed as a single object.
|
|
15
|
-
if (args.length === 1 && (0, _utils.isPlainObject)(args[0])) {
|
|
16
|
-
const node = {
|
|
17
|
-
...args[0],
|
|
18
|
-
type
|
|
19
|
-
};
|
|
20
|
-
// The user could be passing invalid values to the builder, so we need to
|
|
21
|
-
// validate them as per the component's struct.
|
|
22
|
-
(0, _utils.assertStruct)(node, struct, `Invalid ${type} component`);
|
|
23
|
-
return node;
|
|
24
|
-
}
|
|
25
|
-
// Node passed as an array of arguments.
|
|
26
|
-
const node = keys.reduce((partialNode, key, index)=>{
|
|
27
|
-
if (args[index] !== undefined) {
|
|
28
|
-
return {
|
|
29
|
-
...partialNode,
|
|
30
|
-
[key]: args[index]
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return partialNode;
|
|
34
|
-
}, {
|
|
35
|
-
type
|
|
36
|
-
});
|
|
37
|
-
// The user could be passing invalid values to the builder, so we need to
|
|
38
|
-
// validate them as per the component's struct.
|
|
39
|
-
(0, _utils.assertStruct)(node, struct, `Invalid ${type} component`);
|
|
40
|
-
return node;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/builder.ts"],"sourcesContent":["import { assertStruct, isPlainObject } from '@metamask/utils';\nimport type { Struct } from 'superstruct';\n\nimport type { Component } from './components';\nimport type { NodeType } from './nodes';\n\n/**\n * A function that builds a {@link Component}. This infers the proper args type\n * from the given node.\n *\n * @internal\n */\ntype NodeBuilder<Node extends Component, Keys extends (keyof Node)[]> = Omit<\n Node,\n 'type'\n> extends Record<string, never>\n ? (...args: []) => Node\n : (...args: [Omit<Node, 'type'>] | NodeArrayType<Node, Keys>) => Node;\n\n/**\n * Map from an array of node keys to the corresponding array type.\n *\n * @example\n * type Node = { type: 'node'; a: string; b: number; c: boolean };\n * type Keys = ['a', 'b', 'c'];\n *\n * type NodeArray = NodeArrayType<Node, Keys>; // [string, number, boolean]\n * @internal\n */\ntype NodeArrayType<Node extends Component, Keys extends (keyof Node)[]> = {\n [Key in keyof Keys]: Node[Keys[Key]];\n};\n\n/**\n * A function that returns a function to \"build\" a {@link Component}. It infers\n * the type of the component from the given struct, and performs validation on\n * the created component.\n *\n * The returned function can handle the node arguments in two ways:\n * 1. As a single object, with the keys corresponding to the node's properties,\n * excluding the `type` property.\n * 2. As an array of arguments, with the order corresponding to the given keys.\n *\n * @param type - The type of the component to build.\n * @param struct - The struct to use to validate the component.\n * @param keys - The keys of the component to use as arguments to the builder.\n * The order of the keys determines the order of the arguments.\n * @returns A function that builds a component of the given type.\n * @internal\n */\nexport function createBuilder<\n Node extends Component,\n Keys extends (keyof Node)[] = [],\n>(\n type: NodeType,\n struct: Struct<Node>,\n keys: Keys = [] as unknown as Keys,\n): NodeBuilder<Node, Keys> {\n return (...args: [Omit<Node, 'type'>] | NodeArrayType<Node, Keys> | []) => {\n // Node passed as a single object.\n if (args.length === 1 && isPlainObject(args[0])) {\n const node = { ...args[0], type };\n\n // The user could be passing invalid values to the builder, so we need to\n // validate them as per the component's struct.\n assertStruct(node, struct, `Invalid ${type} component`);\n return node;\n }\n\n // Node passed as an array of arguments.\n const node = keys.reduce<Partial<Component>>(\n (partialNode, key, index) => {\n if (args[index] !== undefined) {\n return {\n ...partialNode,\n [key]: args[index],\n };\n }\n\n return partialNode;\n },\n { type },\n );\n\n // The user could be passing invalid values to the builder, so we need to\n // validate them as per the component's struct.\n assertStruct(node, struct, `Invalid ${type} component`);\n return node;\n };\n}\n"],"names":["createBuilder","type","struct","keys","args","length","isPlainObject","node","assertStruct","reduce","partialNode","key","index","undefined"],"mappings":";;;;+BAkDgBA;;;eAAAA;;;uBAlD4B;AAkDrC,SAASA,cAIdC,IAAc,EACdC,MAAoB,EACpBC,OAAa,EAAE,AAAmB;IAElC,OAAO,CAAC,GAAGC;QACT,kCAAkC;QAClC,IAAIA,KAAKC,MAAM,KAAK,KAAKC,IAAAA,oBAAa,EAACF,IAAI,CAAC,EAAE,GAAG;YAC/C,MAAMG,OAAO;gBAAE,GAAGH,IAAI,CAAC,EAAE;gBAAEH;YAAK;YAEhC,yEAAyE;YACzE,+CAA+C;YAC/CO,IAAAA,mBAAY,EAACD,MAAML,QAAQ,CAAC,QAAQ,EAAED,KAAK,UAAU,CAAC;YACtD,OAAOM;QACT;QAEA,wCAAwC;QACxC,MAAMA,OAAOJ,KAAKM,MAAM,CACtB,CAACC,aAAaC,KAAKC;YACjB,IAAIR,IAAI,CAACQ,MAAM,KAAKC,WAAW;gBAC7B,OAAO;oBACL,GAAGH,WAAW;oBACd,CAACC,IAAI,EAAEP,IAAI,CAACQ,MAAM;gBACpB;YACF;YAEA,OAAOF;QACT,GACA;YAAET;QAAK;QAGT,yEAAyE;QACzE,+CAA+C;QAC/CO,IAAAA,mBAAY,EAACD,MAAML,QAAQ,CAAC,QAAQ,EAAED,KAAK,UAAU,CAAC;QACtD,OAAOM;IACT;AACF"}
|
package/dist/cjs/ui/component.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
isComponent: function() {
|
|
13
|
-
return isComponent;
|
|
14
|
-
},
|
|
15
|
-
assertIsComponent: function() {
|
|
16
|
-
return assertIsComponent;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _utils = require("@metamask/utils");
|
|
20
|
-
const _superstruct = require("superstruct");
|
|
21
|
-
const _components = require("./components");
|
|
22
|
-
function isComponent(value) {
|
|
23
|
-
return (0, _superstruct.is)(value, _components.ComponentStruct);
|
|
24
|
-
}
|
|
25
|
-
function assertIsComponent(value) {
|
|
26
|
-
(0, _utils.assertStruct)(value, _components.ComponentStruct, 'Invalid component');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/component.ts"],"sourcesContent":["import { assertStruct } from '@metamask/utils';\nimport { is } from 'superstruct';\n\nimport { ComponentStruct } from './components';\nimport type { Component } from './components';\n\n/**\n * Check if the given value is a {@link Component}. This performs recursive\n * validation of the component's children (if any).\n *\n * @param value - The value to check.\n * @returns `true` if the value is a {@link Component}, `false` otherwise.\n */\nexport function isComponent(value: unknown): value is Component {\n return is(value, ComponentStruct);\n}\n\n/**\n * Assert that the given value is a {@link Component}. This performs recursive\n * validation of the component's children (if any).\n *\n * @param value - The value to check.\n * @throws If the value is not a {@link Component}.\n */\nexport function assertIsComponent(value: unknown): asserts value is Component {\n assertStruct(value, ComponentStruct, 'Invalid component');\n}\n"],"names":["isComponent","assertIsComponent","value","is","ComponentStruct","assertStruct"],"mappings":";;;;;;;;;;;IAagBA,WAAW;eAAXA;;IAWAC,iBAAiB;eAAjBA;;;uBAxBa;6BACV;4BAEa;AAUzB,SAASD,YAAYE,KAAc;IACxC,OAAOC,IAAAA,eAAE,EAACD,OAAOE,2BAAe;AAClC;AASO,SAASH,kBAAkBC,KAAc;IAC9CG,IAAAA,mBAAY,EAACH,OAAOE,2BAAe,EAAE;AACvC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
AddressStruct: function() {
|
|
13
|
-
return AddressStruct;
|
|
14
|
-
},
|
|
15
|
-
address: function() {
|
|
16
|
-
return address;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _superstruct = require("superstruct");
|
|
20
|
-
const _builder = require("../builder");
|
|
21
|
-
const _nodes = require("../nodes");
|
|
22
|
-
const AddressStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
23
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Address),
|
|
24
|
-
value: (0, _superstruct.pattern)((0, _superstruct.string)(), /0x[a-fA-F0-9]{40}/u)
|
|
25
|
-
}));
|
|
26
|
-
const address = (0, _builder.createBuilder)(_nodes.NodeType.Address, AddressStruct, [
|
|
27
|
-
'value'
|
|
28
|
-
]);
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=address.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/address.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, pattern, string } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const AddressStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Address),\n value: pattern(string(), /0x[a-fA-F0-9]{40}/u),\n }),\n);\n\n/**\n * A address node, that renders an EVM-like address and its icon.\n *\n * @property type - The type of the node. Must be the string `address`.\n * @property value - The address in hexadecimal, including 0x.\n */\nexport type Address = Infer<typeof AddressStruct>;\n\n/**\n * Create an {@link Address} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The address to be rendered.\n * @returns The address node as an object.\n * @example\n * const node = address({ value: '0x4bbeeb066ed09b7aed07bf39eee0460dfa261520' });\n * const node = address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520');\n */\nexport const address = createBuilder(NodeType.Address, AddressStruct, [\n 'value',\n]);\n"],"names":["AddressStruct","address","assign","LiteralStruct","object","type","literal","NodeType","Address","value","pattern","string","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IA2BAC,OAAO;eAAPA;;;6BAhC4C;yBAE3B;uBACU;AAEjC,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;IAC9BC,OAAOC,IAAAA,oBAAO,EAACC,IAAAA,mBAAM,KAAI;AAC3B;AAsBK,MAAMV,UAAUW,IAAAA,sBAAa,EAACL,eAAQ,CAACC,OAAO,EAAER,eAAe;IACpE;CACD"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
ButtonVariant: function() {
|
|
13
|
-
return ButtonVariant;
|
|
14
|
-
},
|
|
15
|
-
ButtonType: function() {
|
|
16
|
-
return ButtonType;
|
|
17
|
-
},
|
|
18
|
-
ButtonStruct: function() {
|
|
19
|
-
return ButtonStruct;
|
|
20
|
-
},
|
|
21
|
-
button: function() {
|
|
22
|
-
return button;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _superstruct = require("superstruct");
|
|
26
|
-
const _internals = require("../../internals");
|
|
27
|
-
const _builder = require("../builder");
|
|
28
|
-
const _nodes = require("../nodes");
|
|
29
|
-
var ButtonVariant;
|
|
30
|
-
(function(ButtonVariant) {
|
|
31
|
-
ButtonVariant["Primary"] = 'primary';
|
|
32
|
-
ButtonVariant["Secondary"] = 'secondary';
|
|
33
|
-
})(ButtonVariant || (ButtonVariant = {}));
|
|
34
|
-
var ButtonType;
|
|
35
|
-
(function(ButtonType) {
|
|
36
|
-
ButtonType["Button"] = 'button';
|
|
37
|
-
ButtonType["Submit"] = 'submit';
|
|
38
|
-
})(ButtonType || (ButtonType = {}));
|
|
39
|
-
const ButtonStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
40
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Button),
|
|
41
|
-
value: (0, _superstruct.string)(),
|
|
42
|
-
variant: (0, _superstruct.optional)((0, _superstruct.union)([
|
|
43
|
-
(0, _internals.enumValue)(ButtonVariant.Primary),
|
|
44
|
-
(0, _internals.enumValue)(ButtonVariant.Secondary)
|
|
45
|
-
])),
|
|
46
|
-
buttonType: (0, _superstruct.optional)((0, _superstruct.union)([
|
|
47
|
-
(0, _internals.enumValue)(ButtonType.Button),
|
|
48
|
-
(0, _internals.enumValue)(ButtonType.Submit)
|
|
49
|
-
])),
|
|
50
|
-
name: (0, _superstruct.optional)((0, _superstruct.string)())
|
|
51
|
-
}));
|
|
52
|
-
const button = (0, _builder.createBuilder)(_nodes.NodeType.Button, ButtonStruct, [
|
|
53
|
-
'value',
|
|
54
|
-
'buttonType',
|
|
55
|
-
'name',
|
|
56
|
-
'variant'
|
|
57
|
-
]);
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/button.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, optional, string, union } from 'superstruct';\n\nimport { enumValue } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport enum ButtonVariant {\n Primary = 'primary',\n Secondary = 'secondary',\n}\n\nexport enum ButtonType {\n Button = 'button',\n Submit = 'submit',\n}\n\nexport const ButtonStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Button),\n value: string(),\n variant: optional(\n union([\n enumValue(ButtonVariant.Primary),\n enumValue(ButtonVariant.Secondary),\n ]),\n ),\n buttonType: optional(\n union([enumValue(ButtonType.Button), enumValue(ButtonType.Submit)]),\n ),\n name: optional(string()),\n }),\n);\n\n/**\n * A button node, that renders either a primary or a secondary button.\n *\n * @property type - The type of the node, must be the string 'button'.\n * @property variant - The style variant of the node, must be either 'primary' or 'secondary'.\n * @property value - The text content of the node as plain text.\n * @property buttonType - The type of the button, must be either 'button' or 'submit'.\n * @property name - An optional name to identify the button.\n */\nexport type Button = Infer<typeof ButtonStruct>;\n\n/**\n * Create a {@link Button} node.\n *\n * @param args - The node arguments. This can be either a string, or an object\n * with a `value` property. A set of optional properties can be passed.\n * @param args.variant - The optional variant of the button.\n * @param args.value - The text content of the node.\n * @param args.name - The optional name of the button.\n * @returns The text node as object.\n * @example\n * ```typescript\n * const node = button({ variant: 'primary', text: 'Hello, world!', name: 'myButton' });\n * const node = button('Hello, world!', 'button', 'myButton', 'primary');\n * const node = button('Hello, world!');\n * ```\n */\nexport const button = createBuilder(NodeType.Button, ButtonStruct, [\n 'value',\n 'buttonType',\n 'name',\n 'variant',\n]);\n"],"names":["ButtonStruct","button","ButtonVariant","Primary","Secondary","ButtonType","Button","Submit","assign","LiteralStruct","object","type","literal","NodeType","value","string","variant","optional","union","enumValue","buttonType","name","createBuilder"],"mappings":";;;;;;;;;;;;;;;;;IAiBaA,YAAY;eAAZA;;IA6CAC,MAAM;eAANA;;;6BA7DoD;2BAEvC;yBACI;uBACU;IAEjC;UAAKC,aAAa;IAAbA,cACVC,aAAU;IADAD,cAEVE,eAAY;GAFFF,kBAAAA;IAKL;UAAKG,UAAU;IAAVA,WACVC,YAAS;IADCD,WAEVE,YAAS;GAFCF,eAAAA;AAKL,MAAML,eAAeQ,IAAAA,mBAAM,EAChCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACP,MAAM;IAC7BQ,OAAOC,IAAAA,mBAAM;IACbC,SAASC,IAAAA,qBAAQ,EACfC,IAAAA,kBAAK,EAAC;QACJC,IAAAA,oBAAS,EAACjB,cAAcC,OAAO;QAC/BgB,IAAAA,oBAAS,EAACjB,cAAcE,SAAS;KAClC;IAEHgB,YAAYH,IAAAA,qBAAQ,EAClBC,IAAAA,kBAAK,EAAC;QAACC,IAAAA,oBAAS,EAACd,WAAWC,MAAM;QAAGa,IAAAA,oBAAS,EAACd,WAAWE,MAAM;KAAE;IAEpEc,MAAMJ,IAAAA,qBAAQ,EAACF,IAAAA,mBAAM;AACvB;AA8BK,MAAMd,SAASqB,IAAAA,sBAAa,EAACT,eAAQ,CAACP,MAAM,EAAEN,cAAc;IACjE;IACA;IACA;IACA;CACD"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
CopyableStruct: function() {
|
|
13
|
-
return CopyableStruct;
|
|
14
|
-
},
|
|
15
|
-
copyable: function() {
|
|
16
|
-
return copyable;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _superstruct = require("superstruct");
|
|
20
|
-
const _builder = require("../builder");
|
|
21
|
-
const _nodes = require("../nodes");
|
|
22
|
-
const CopyableStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
23
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Copyable),
|
|
24
|
-
value: (0, _superstruct.string)(),
|
|
25
|
-
sensitive: (0, _superstruct.optional)((0, _superstruct.boolean)())
|
|
26
|
-
}));
|
|
27
|
-
const copyable = (0, _builder.createBuilder)(_nodes.NodeType.Copyable, CopyableStruct, [
|
|
28
|
-
'value',
|
|
29
|
-
'sensitive'
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=copyable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/copyable.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n assign,\n boolean,\n literal,\n object,\n optional,\n string,\n} from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const CopyableStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Copyable),\n value: string(),\n sensitive: optional(boolean()),\n }),\n);\n\n/**\n * Text that can be copied to the clipboard. It can optionally be marked as\n * sensitive, in which case it will only be displayed to the user after clicking\n * on the component.\n *\n * @property type - The type of the node. Must be the string `copyable`.\n * @property value - The text to be copied.\n * @property sensitive - Whether the value is sensitive or not. Sensitive values\n * are only displayed to the user after clicking on the component. Defaults to\n * false.\n */\nexport type Copyable = Infer<typeof CopyableStruct>;\n\n/**\n * Create a {@link Copyable} component.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `text` property.\n * @param args.value - The text to be copied.\n * @param args.sensitive - Whether the value is sensitive or not. Sensitive\n * values are only displayed to the user after clicking on the component.\n * Defaults to false.\n * @returns A {@link Copyable} component.\n * @example\n * const node = copyable('Hello, world!');\n * const node = copyable({ value: 'Hello, world!' });\n */\nexport const copyable = createBuilder(NodeType.Copyable, CopyableStruct, [\n 'value',\n 'sensitive',\n]);\n"],"names":["CopyableStruct","copyable","assign","LiteralStruct","object","type","literal","NodeType","Copyable","value","string","sensitive","optional","boolean","createBuilder"],"mappings":";;;;;;;;;;;IAaaA,cAAc;eAAdA;;IAoCAC,QAAQ;eAARA;;;6BAzCN;yBAEuB;uBACU;AAEjC,MAAMD,iBAAiBE,IAAAA,mBAAM,EAClCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,QAAQ;IAC/BC,OAAOC,IAAAA,mBAAM;IACbC,WAAWC,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO;AAC7B;AA8BK,MAAMZ,WAAWa,IAAAA,sBAAa,EAACP,eAAQ,CAACC,QAAQ,EAAER,gBAAgB;IACvE;IACA;CACD"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
DividerStruct: function() {
|
|
13
|
-
return DividerStruct;
|
|
14
|
-
},
|
|
15
|
-
divider: function() {
|
|
16
|
-
return divider;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _superstruct = require("superstruct");
|
|
20
|
-
const _builder = require("../builder");
|
|
21
|
-
const _nodes = require("../nodes");
|
|
22
|
-
const DividerStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
23
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Divider)
|
|
24
|
-
}));
|
|
25
|
-
const divider = (0, _builder.createBuilder)(_nodes.NodeType.Divider, DividerStruct);
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=divider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/divider.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\n\nexport const DividerStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Divider),\n }),\n);\n\n/**\n * A divider node, that renders a line between other nodes.\n */\nexport type Divider = Infer<typeof DividerStruct>;\n\n/**\n * Create a {@link Divider} node.\n *\n * @returns The divider node as object.\n * @example\n * const node = divider();\n */\nexport const divider = createBuilder(NodeType.Divider, DividerStruct);\n"],"names":["DividerStruct","divider","assign","NodeStruct","object","type","literal","NodeType","Divider","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IAmBAC,OAAO;eAAPA;;;6BAxB2B;yBAEV;uBACO;AAE9B,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;AAChC;AAeK,MAAMP,UAAUQ,IAAAA,sBAAa,EAACF,eAAQ,CAACC,OAAO,EAAER"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
FormComponentStruct: function() {
|
|
13
|
-
return FormComponentStruct;
|
|
14
|
-
},
|
|
15
|
-
FormStruct: function() {
|
|
16
|
-
return FormStruct;
|
|
17
|
-
},
|
|
18
|
-
form: function() {
|
|
19
|
-
return form;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _superstruct = require("superstruct");
|
|
23
|
-
const _builder = require("../builder");
|
|
24
|
-
const _nodes = require("../nodes");
|
|
25
|
-
const _button = require("./button");
|
|
26
|
-
const _input = require("./input");
|
|
27
|
-
const FormComponentStruct = (0, _superstruct.union)([
|
|
28
|
-
_input.InputStruct,
|
|
29
|
-
_button.ButtonStruct
|
|
30
|
-
]);
|
|
31
|
-
const FormStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
32
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Form),
|
|
33
|
-
children: (0, _superstruct.array)(FormComponentStruct),
|
|
34
|
-
name: (0, _superstruct.string)()
|
|
35
|
-
}));
|
|
36
|
-
const form = (0, _builder.createBuilder)(_nodes.NodeType.Form, FormStruct, [
|
|
37
|
-
'name',
|
|
38
|
-
'children'
|
|
39
|
-
]);
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=form.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/form.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { array, assign, literal, object, string, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { ButtonStruct } from './button';\nimport { InputStruct } from './input';\n\nexport const FormComponentStruct = union([InputStruct, ButtonStruct]);\n\n/**\n * The subset of nodes allowed as children in the {@link Form} node.\n */\nexport type FormComponent = Infer<typeof FormComponentStruct>;\n\nexport const FormStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Form),\n children: array(FormComponentStruct),\n name: string(),\n }),\n);\n\n/**\n * A form node that takes children {@link FormComponent} nodes and renders a form.\n *\n * @property type - The type of the node. Must be the string `form`.\n * @property children - The children of the node. Only {@link FormComponent} nodes are allowed.\n * @property name - The form name used to identify it.\n */\nexport type Form = Infer<typeof FormStruct>;\n\n/**\n * Create a {@link Form} node.\n *\n * @param args - The node arguments. This can be either an array of children and a string, or\n * an object with a `name` and `children` property.\n * @param args.name - The form name used to identify it.\n * @param args.children - The child nodes of the form. This can be any valid\n * {@link FormComponent}.\n * @returns The form node as object.\n * @example\n * const node = form({\n * name: 'myForm',\n * children: [\n * input({ name: 'myInput' }),\n * button({ value: 'Hello, world!' }),\n * ],\n * });\n *\n * const node = form('myForm', [input('myInput'), button('Hello, world!')]);\n */\nexport const form = createBuilder(NodeType.Form, FormStruct, [\n 'name',\n 'children',\n]);\n"],"names":["FormComponentStruct","FormStruct","form","union","InputStruct","ButtonStruct","assign","NodeStruct","object","type","literal","NodeType","Form","children","array","name","string","createBuilder"],"mappings":";;;;;;;;;;;IAQaA,mBAAmB;eAAnBA;;IAOAC,UAAU;eAAVA;;IAsCAC,IAAI;eAAJA;;;6BApDiD;yBAEhC;uBACO;wBACR;uBACD;AAErB,MAAMF,sBAAsBG,IAAAA,kBAAK,EAAC;IAACC,kBAAW;IAAEC,oBAAY;CAAC;AAO7D,MAAMJ,aAAaK,IAAAA,mBAAM,EAC9BC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,IAAI;IAC3BC,UAAUC,IAAAA,kBAAK,EAACd;IAChBe,MAAMC,IAAAA,mBAAM;AACd;AAgCK,MAAMd,OAAOe,IAAAA,sBAAa,EAACN,eAAQ,CAACC,IAAI,EAAEX,YAAY;IAC3D;IACA;CACD"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
HeadingStruct: function() {
|
|
13
|
-
return HeadingStruct;
|
|
14
|
-
},
|
|
15
|
-
heading: function() {
|
|
16
|
-
return heading;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _superstruct = require("superstruct");
|
|
20
|
-
const _builder = require("../builder");
|
|
21
|
-
const _nodes = require("../nodes");
|
|
22
|
-
const HeadingStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
23
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Heading),
|
|
24
|
-
value: (0, _superstruct.string)()
|
|
25
|
-
}));
|
|
26
|
-
const heading = (0, _builder.createBuilder)(_nodes.NodeType.Heading, HeadingStruct, [
|
|
27
|
-
'value'
|
|
28
|
-
]);
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=heading.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/heading.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, string } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const HeadingStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Heading),\n value: string(),\n }),\n);\n\n/**\n * A heading node, that renders the text as a heading. The level of the heading\n * is determined by the depth of the heading in the document.\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 */\nexport type Heading = Infer<typeof HeadingStruct>;\n\n/**\n * Create a {@link Heading} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The heading text.\n * @returns The heading node as object.\n * @example\n * const node = heading({ value: 'Hello, world!' });\n * const node = heading('Hello, world!');\n */\nexport const heading = createBuilder(NodeType.Heading, HeadingStruct, [\n 'value',\n]);\n"],"names":["HeadingStruct","heading","assign","LiteralStruct","object","type","literal","NodeType","Heading","value","string","createBuilder"],"mappings":";;;;;;;;;;;IAMaA,aAAa;eAAbA;;IA6BAC,OAAO;eAAPA;;;6BAlCmC;yBAElB;uBACU;AAEjC,MAAMD,gBAAgBE,IAAAA,mBAAM,EACjCC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,OAAO;IAC9BC,OAAOC,IAAAA,mBAAM;AACf;AAwBK,MAAMT,UAAUU,IAAAA,sBAAa,EAACJ,eAAQ,CAACC,OAAO,EAAER,eAAe;IACpE;CACD"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
svg: function() {
|
|
13
|
-
return svg;
|
|
14
|
-
},
|
|
15
|
-
ImageStruct: function() {
|
|
16
|
-
return ImageStruct;
|
|
17
|
-
},
|
|
18
|
-
image: function() {
|
|
19
|
-
return image;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _superstruct = require("superstruct");
|
|
23
|
-
const _internals = require("../../internals");
|
|
24
|
-
const _builder = require("../builder");
|
|
25
|
-
const _nodes = require("../nodes");
|
|
26
|
-
function svg() {
|
|
27
|
-
return (0, _superstruct.refine)((0, _superstruct.string)(), 'SVG', (value)=>{
|
|
28
|
-
if (!(0, _internals.isSvg)(value)) {
|
|
29
|
-
return 'Value is not a valid SVG.';
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const ImageStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
35
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Image),
|
|
36
|
-
value: svg()
|
|
37
|
-
}));
|
|
38
|
-
const image = (0, _builder.createBuilder)(_nodes.NodeType.Image, ImageStruct, [
|
|
39
|
-
'value'
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=image.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/image.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, refine, string } from 'superstruct';\n\nimport { isSvg } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\n\n/**\n * Get a Struct that validates a string as a valid SVG.\n *\n * @returns A Struct that validates a string as a valid SVG.\n * @internal\n */\nexport function svg() {\n return refine(string(), 'SVG', (value) => {\n if (!isSvg(value)) {\n return 'Value is not a valid SVG.';\n }\n\n return true;\n });\n}\n\nexport const ImageStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Image),\n value: svg(),\n }),\n);\n\n/**\n * An image node, that renders an SVG image.\n *\n * @property type - The type of the node. Must be the string `image`.\n * @property value - The SVG image to be rendered.\n */\nexport type Image = Infer<typeof ImageStruct>;\n\n/**\n * Create an {@link Image} node.\n *\n * @param args - The node arguments. This can either be a string, or an object\n * with the `value` property.\n * @param args.value - The SVG image to be rendered. Must be a valid SVG string.\n * @returns The image node as object. Other image formats are supported by\n * embedding them as data URLs in the SVG.\n * @example\n * const node = image({ value: '<svg />' });\n * const node = image('<svg />');\n */\nexport const image = createBuilder(NodeType.Image, ImageStruct, ['value']);\n"],"names":["svg","ImageStruct","image","refine","string","value","isSvg","assign","NodeStruct","object","type","literal","NodeType","Image","createBuilder"],"mappings":";;;;;;;;;;;IAagBA,GAAG;eAAHA;;IAUHC,WAAW;eAAXA;;IA4BAC,KAAK;eAALA;;;6BAlD2C;2BAElC;yBACQ;uBACO;AAQ9B,SAASF;IACd,OAAOG,IAAAA,mBAAM,EAACC,IAAAA,mBAAM,KAAI,OAAO,CAACC;QAC9B,IAAI,CAACC,IAAAA,gBAAK,EAACD,QAAQ;YACjB,OAAO;QACT;QAEA,OAAO;IACT;AACF;AAEO,MAAMJ,cAAcM,IAAAA,mBAAM,EAC/BC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;IAC5BR,OAAOL;AACT;AAuBK,MAAME,QAAQY,IAAAA,sBAAa,EAACF,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAAC;CAAQ"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
image: function() {
|
|
13
|
-
return _image.image;
|
|
14
|
-
},
|
|
15
|
-
ImageStruct: function() {
|
|
16
|
-
return _image.ImageStruct;
|
|
17
|
-
},
|
|
18
|
-
ComponentStruct: function() {
|
|
19
|
-
return _panel.ComponentStruct;
|
|
20
|
-
},
|
|
21
|
-
panel: function() {
|
|
22
|
-
return _panel.panel;
|
|
23
|
-
},
|
|
24
|
-
PanelStruct: function() {
|
|
25
|
-
return _panel.PanelStruct;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
_export_star(require("./address"), exports);
|
|
29
|
-
_export_star(require("./copyable"), exports);
|
|
30
|
-
_export_star(require("./divider"), exports);
|
|
31
|
-
_export_star(require("./heading"), exports);
|
|
32
|
-
const _image = require("./image");
|
|
33
|
-
const _panel = require("./panel");
|
|
34
|
-
_export_star(require("./spinner"), exports);
|
|
35
|
-
_export_star(require("./text"), exports);
|
|
36
|
-
_export_star(require("./row"), exports);
|
|
37
|
-
_export_star(require("./button"), exports);
|
|
38
|
-
_export_star(require("./input"), exports);
|
|
39
|
-
_export_star(require("./form"), exports);
|
|
40
|
-
function _export_star(from, to) {
|
|
41
|
-
Object.keys(from).forEach(function(k) {
|
|
42
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
43
|
-
Object.defineProperty(to, k, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function() {
|
|
46
|
-
return from[k];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return from;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/index.ts"],"sourcesContent":["export * from './address';\nexport * from './copyable';\nexport * from './divider';\nexport * from './heading';\nexport type { Image } from './image';\nexport { image, ImageStruct } from './image';\nexport type { Component, Panel } from './panel';\nexport { ComponentStruct, panel, PanelStruct } from './panel';\nexport * from './spinner';\nexport * from './text';\nexport * from './row';\nexport * from './button';\nexport * from './input';\nexport * from './form';\n"],"names":["image","ImageStruct","ComponentStruct","panel","PanelStruct"],"mappings":";;;;;;;;;;;IAKSA,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;IAElBC,eAAe;eAAfA,sBAAe;;IAAEC,KAAK;eAALA,YAAK;;IAAEC,WAAW;eAAXA,kBAAW;;;qBAP9B;qBACA;qBACA;qBACA;uBAEqB;uBAEiB;qBACtC;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
InputType: function() {
|
|
13
|
-
return InputType;
|
|
14
|
-
},
|
|
15
|
-
InputStruct: function() {
|
|
16
|
-
return InputStruct;
|
|
17
|
-
},
|
|
18
|
-
input: function() {
|
|
19
|
-
return input;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _superstruct = require("superstruct");
|
|
23
|
-
const _internals = require("../../internals");
|
|
24
|
-
const _builder = require("../builder");
|
|
25
|
-
const _nodes = require("../nodes");
|
|
26
|
-
var InputType;
|
|
27
|
-
(function(InputType) {
|
|
28
|
-
InputType[/* eslint-disable @typescript-eslint/no-shadow */ "Text"] = 'text';
|
|
29
|
-
InputType["Number"] = 'number';
|
|
30
|
-
InputType[/* eslint-enable @typescript-eslint/no-shadow */ "Password"] = 'password';
|
|
31
|
-
})(InputType || (InputType = {}));
|
|
32
|
-
const InputStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
|
|
33
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Input),
|
|
34
|
-
value: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
35
|
-
name: (0, _superstruct.string)(),
|
|
36
|
-
inputType: (0, _superstruct.optional)((0, _superstruct.union)([
|
|
37
|
-
(0, _internals.enumValue)(InputType.Text),
|
|
38
|
-
(0, _internals.enumValue)(InputType.Password),
|
|
39
|
-
(0, _internals.enumValue)(InputType.Number)
|
|
40
|
-
])),
|
|
41
|
-
placeholder: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
42
|
-
label: (0, _superstruct.optional)((0, _superstruct.string)())
|
|
43
|
-
}));
|
|
44
|
-
const input = (0, _builder.createBuilder)(_nodes.NodeType.Input, InputStruct, [
|
|
45
|
-
'name',
|
|
46
|
-
'inputType',
|
|
47
|
-
'placeholder',
|
|
48
|
-
'value',
|
|
49
|
-
'label'
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=input.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/input.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, optional, string, union } from 'superstruct';\n\nimport { enumValue } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\n/**\n * This replicates the available input types from the metamask extension.\n * https://github.com/MetaMask/metamask-extension/develop/ui/components/component-library/input/input.constants.js\n */\nexport enum InputType {\n /* eslint-disable @typescript-eslint/no-shadow */\n Text = 'text',\n Number = 'number',\n /* eslint-enable @typescript-eslint/no-shadow */\n Password = 'password',\n}\n\nexport const InputStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Input),\n value: optional(string()),\n name: string(),\n inputType: optional(\n union([\n enumValue(InputType.Text),\n enumValue(InputType.Password),\n enumValue(InputType.Number),\n ]),\n ),\n placeholder: optional(string()),\n label: optional(string()),\n }),\n);\n\n/**\n * An input node, that renders an input.\n *\n * @property type - The type of the node, must be the string 'input'.\n * @property name - The name for the input.\n * @property value - The value of the input.\n * @property inputType - An optional type, either `text`, `password` or `number`.\n * @property placeholder - An optional input placeholder.\n * @property label - An optional input label.\n */\nexport type Input = Infer<typeof InputStruct>;\n\n/**\n * Create a {@link Input} node.\n *\n * @param args - The node arguments. This can either be a name and an optional variant, value and placeholder or an object\n * with the properties: `inputType`, `value`, `variant`, `placeholder` and `name`.\n * @param args.name - The name for the input.\n * @param args.value - The value of the input.\n * @param args.inputType - An optional type, either `text`, `password` or `number`.\n * @param args.placeholder - An optional input placeholder.\n * @param args.label - An optional input label.\n * @returns The input node as an object.\n * @example\n * const node = input('myInput');\n * const node = input('myInput', InputType.Text, 'my placeholder', 'myValue', 'myLabel');\n * const node = input({ name: 'myInput' });\n * const node = input({name: 'myInput', value: 'myValue', inputType: InputType.Password, placeholder: 'placeholder'})\n */\nexport const input = createBuilder(NodeType.Input, InputStruct, [\n 'name',\n 'inputType',\n 'placeholder',\n 'value',\n 'label',\n]);\n"],"names":["InputStruct","input","InputType","Text","Number","Password","assign","LiteralStruct","object","type","literal","NodeType","Input","value","optional","string","name","inputType","union","enumValue","placeholder","label","createBuilder"],"mappings":";;;;;;;;;;;;;;IAmBaA,WAAW;eAAXA;;IA+CAC,KAAK;eAALA;;;6BAjEoD;2BAEvC;yBACI;uBACU;IAMjC;UAAKC,SAAS;IAATA,UACV,+CAA+C,GAC/CC,UAAO;IAFGD,UAGVE,YAAS;IAHCF,UAIV,8CAA8C,GAC9CG,cAAW;GALDH,cAAAA;AAQL,MAAMF,cAAcM,IAAAA,mBAAM,EAC/BC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;IAC5BC,OAAOC,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;IACtBC,MAAMD,IAAAA,mBAAM;IACZE,WAAWH,IAAAA,qBAAQ,EACjBI,IAAAA,kBAAK,EAAC;QACJC,IAAAA,oBAAS,EAACjB,UAAUC,IAAI;QACxBgB,IAAAA,oBAAS,EAACjB,UAAUG,QAAQ;QAC5Bc,IAAAA,oBAAS,EAACjB,UAAUE,MAAM;KAC3B;IAEHgB,aAAaN,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;IAC5BM,OAAOP,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;AACxB;AAgCK,MAAMd,QAAQqB,IAAAA,sBAAa,EAACX,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAC9D;IACA;IACA;IACA;IACA;CACD"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
ParentStruct: function() {
|
|
13
|
-
return ParentStruct;
|
|
14
|
-
},
|
|
15
|
-
PanelStruct: function() {
|
|
16
|
-
return PanelStruct;
|
|
17
|
-
},
|
|
18
|
-
panel: function() {
|
|
19
|
-
return panel;
|
|
20
|
-
},
|
|
21
|
-
ComponentStruct: function() {
|
|
22
|
-
return ComponentStruct;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _superstruct = require("superstruct");
|
|
26
|
-
const _builder = require("../builder");
|
|
27
|
-
const _nodes = require("../nodes");
|
|
28
|
-
const _address = require("./address");
|
|
29
|
-
const _button = require("./button");
|
|
30
|
-
const _copyable = require("./copyable");
|
|
31
|
-
const _divider = require("./divider");
|
|
32
|
-
const _form = require("./form");
|
|
33
|
-
const _heading = require("./heading");
|
|
34
|
-
const _image = require("./image");
|
|
35
|
-
const _input = require("./input");
|
|
36
|
-
const _row = require("./row");
|
|
37
|
-
const _spinner = require("./spinner");
|
|
38
|
-
const _text = require("./text");
|
|
39
|
-
const ParentStruct = (0, _superstruct.assign)(_nodes.NodeStruct, (0, _superstruct.object)({
|
|
40
|
-
// This node references itself indirectly, so we need to use `lazy()`.
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
42
|
-
children: (0, _superstruct.array)((0, _superstruct.lazy)(()=>ComponentStruct))
|
|
43
|
-
}));
|
|
44
|
-
const PanelStruct = (0, _superstruct.assign)(ParentStruct, (0, _superstruct.object)({
|
|
45
|
-
type: (0, _superstruct.literal)(_nodes.NodeType.Panel)
|
|
46
|
-
}));
|
|
47
|
-
const panel = (0, _builder.createBuilder)(_nodes.NodeType.Panel, PanelStruct, [
|
|
48
|
-
'children'
|
|
49
|
-
]);
|
|
50
|
-
const ComponentStruct = (0, _superstruct.union)([
|
|
51
|
-
_copyable.CopyableStruct,
|
|
52
|
-
_divider.DividerStruct,
|
|
53
|
-
_heading.HeadingStruct,
|
|
54
|
-
_image.ImageStruct,
|
|
55
|
-
PanelStruct,
|
|
56
|
-
_spinner.SpinnerStruct,
|
|
57
|
-
_text.TextStruct,
|
|
58
|
-
_row.RowStruct,
|
|
59
|
-
_address.AddressStruct,
|
|
60
|
-
_input.InputStruct,
|
|
61
|
-
_form.FormStruct,
|
|
62
|
-
_button.ButtonStruct
|
|
63
|
-
]);
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=panel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/panel.ts"],"sourcesContent":["import type { Infer, Struct } from 'superstruct';\nimport { array, assign, lazy, literal, object, union } from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { NodeStruct, NodeType } from '../nodes';\nimport { AddressStruct } from './address';\nimport { ButtonStruct } from './button';\nimport { CopyableStruct } from './copyable';\nimport { DividerStruct } from './divider';\nimport { FormStruct } from './form';\nimport { HeadingStruct } from './heading';\nimport { ImageStruct } from './image';\nimport { InputStruct } from './input';\nimport { RowStruct } from './row';\nimport { SpinnerStruct } from './spinner';\nimport { TextStruct } from './text';\n\n/**\n * @internal\n */\nexport const ParentStruct = assign(\n NodeStruct,\n object({\n // This node references itself indirectly, so we need to use `lazy()`.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n children: array(lazy(() => ComponentStruct)),\n }),\n);\n\n/**\n * A node which supports child nodes. This is used for nodes that render their\n * children, such as {@link Panel}.\n *\n * @property type - The type of the node.\n * @property children - The children of the node\n * @internal\n */\nexport type Parent = Infer<typeof ParentStruct>;\n\n/**\n * @internal\n */\nexport const PanelStruct: Struct<Panel> = assign(\n ParentStruct,\n object({\n type: literal(NodeType.Panel),\n }),\n);\n\n/**\n * A panel node, which renders its children.\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 */\n// This node references itself indirectly, so it cannot be inferred.\nexport type Panel = {\n type: NodeType.Panel;\n children: Component[];\n};\n\n/**\n * Create a {@link Panel} node.\n *\n * @param args - The node arguments. This can be either an array of children, or\n * an object with a `children` property.\n * @param args.children - The child nodes of the panel. This can be any valid\n * {@link Component}.\n * @returns The panel node as object.\n * @example\n * const node = panel({\n * children: [\n * heading({ text: 'Hello, world!' }),\n * text({ text: 'This is a panel.' }),\n * ],\n * });\n *\n * const node = panel([\n * heading('Hello, world!'),\n * text('This is a panel.'),\n * ]);\n */\nexport const panel = createBuilder(NodeType.Panel, PanelStruct, ['children']);\n\n// This is defined separately from `Component` to avoid circular dependencies.\nexport const ComponentStruct = union([\n CopyableStruct,\n DividerStruct,\n HeadingStruct,\n ImageStruct,\n PanelStruct,\n SpinnerStruct,\n TextStruct,\n RowStruct,\n AddressStruct,\n InputStruct,\n FormStruct,\n ButtonStruct,\n]);\n\n/**\n * All supported component types.\n */\nexport type Component = Infer<typeof ComponentStruct>;\n"],"names":["ParentStruct","PanelStruct","panel","ComponentStruct","assign","NodeStruct","object","children","array","lazy","type","literal","NodeType","Panel","createBuilder","union","CopyableStruct","DividerStruct","HeadingStruct","ImageStruct","SpinnerStruct","TextStruct","RowStruct","AddressStruct","InputStruct","FormStruct","ButtonStruct"],"mappings":";;;;;;;;;;;IAoBaA,YAAY;eAAZA;;IAsBAC,WAAW;eAAXA;;IAyCAC,KAAK;eAALA;;IAGAC,eAAe;eAAfA;;;6BArF+C;yBAE9B;uBACO;yBACP;wBACD;0BACE;yBACD;sBACH;yBACG;uBACF;uBACA;qBACF;yBACI;sBACH;AAKpB,MAAMH,eAAeI,IAAAA,mBAAM,EAChCC,iBAAU,EACVC,IAAAA,mBAAM,EAAC;IACL,sEAAsE;IACtE,mEAAmE;IACnEC,UAAUC,IAAAA,kBAAK,EAACC,IAAAA,iBAAI,EAAC,IAAMN;AAC7B;AAgBK,MAAMF,cAA6BG,IAAAA,mBAAM,EAC9CJ,cACAM,IAAAA,mBAAM,EAAC;IACLI,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,KAAK;AAC9B;AAqCK,MAAMX,QAAQY,IAAAA,sBAAa,EAACF,eAAQ,CAACC,KAAK,EAAEZ,aAAa;IAAC;CAAW;AAGrE,MAAME,kBAAkBY,IAAAA,kBAAK,EAAC;IACnCC,wBAAc;IACdC,sBAAa;IACbC,sBAAa;IACbC,kBAAW;IACXlB;IACAmB,sBAAa;IACbC,gBAAU;IACVC,cAAS;IACTC,sBAAa;IACbC,kBAAW;IACXC,gBAAU;IACVC,oBAAY;CACb"}
|