@metamask/snaps-sdk 1.4.0 → 2.1.0

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/dist/cjs/errors.js +8 -3
  3. package/dist/cjs/errors.js.map +1 -1
  4. package/dist/cjs/index.js +6 -0
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/internals/error-wrappers.js +15 -1
  7. package/dist/cjs/internals/error-wrappers.js.map +1 -1
  8. package/dist/cjs/internals/index.js +1 -0
  9. package/dist/cjs/internals/index.js.map +1 -1
  10. package/dist/cjs/internals/svg.js +49 -0
  11. package/dist/cjs/internals/svg.js.map +1 -0
  12. package/dist/cjs/types/handlers/index.js +1 -0
  13. package/dist/cjs/types/handlers/index.js.map +1 -1
  14. package/dist/cjs/types/handlers/transaction.js.map +1 -1
  15. package/dist/cjs/types/handlers/user-input.js +51 -0
  16. package/dist/cjs/types/handlers/user-input.js.map +1 -0
  17. package/dist/cjs/types/index.js +1 -0
  18. package/dist/cjs/types/index.js.map +1 -1
  19. package/dist/cjs/types/interface.js +26 -0
  20. package/dist/cjs/types/interface.js.map +1 -0
  21. package/dist/cjs/types/methods/create-interface.js +6 -0
  22. package/dist/cjs/types/methods/create-interface.js.map +1 -0
  23. package/dist/cjs/types/methods/dialog.js.map +1 -1
  24. package/dist/cjs/types/methods/get-interface-state.js +6 -0
  25. package/dist/cjs/types/methods/get-interface-state.js.map +1 -0
  26. package/dist/cjs/types/methods/index.js +3 -0
  27. package/dist/cjs/types/methods/index.js.map +1 -1
  28. package/dist/cjs/types/methods/update-interface.js +6 -0
  29. package/dist/cjs/types/methods/update-interface.js.map +1 -0
  30. package/dist/cjs/ui/components/button.js +59 -0
  31. package/dist/cjs/ui/components/button.js.map +1 -0
  32. package/dist/cjs/ui/components/form.js +41 -0
  33. package/dist/cjs/ui/components/form.js.map +1 -0
  34. package/dist/cjs/ui/components/image.js +2 -7
  35. package/dist/cjs/ui/components/image.js.map +1 -1
  36. package/dist/cjs/ui/components/index.js +3 -0
  37. package/dist/cjs/ui/components/index.js.map +1 -1
  38. package/dist/cjs/ui/components/input.js +52 -0
  39. package/dist/cjs/ui/components/input.js.map +1 -0
  40. package/dist/cjs/ui/components/panel.js +7 -1
  41. package/dist/cjs/ui/components/panel.js.map +1 -1
  42. package/dist/cjs/ui/nodes.js +3 -0
  43. package/dist/cjs/ui/nodes.js.map +1 -1
  44. package/dist/esm/errors.js +8 -3
  45. package/dist/esm/errors.js.map +1 -1
  46. package/dist/esm/index.js +1 -1
  47. package/dist/esm/index.js.map +1 -1
  48. package/dist/esm/internals/error-wrappers.js +15 -1
  49. package/dist/esm/internals/error-wrappers.js.map +1 -1
  50. package/dist/esm/internals/index.js +1 -0
  51. package/dist/esm/internals/index.js.map +1 -1
  52. package/dist/esm/internals/svg.js +41 -0
  53. package/dist/esm/internals/svg.js.map +1 -0
  54. package/dist/esm/types/handlers/home-page.js.map +1 -1
  55. package/dist/esm/types/handlers/index.js +1 -0
  56. package/dist/esm/types/handlers/index.js.map +1 -1
  57. package/dist/esm/types/handlers/name-lookup.js.map +1 -1
  58. package/dist/esm/types/handlers/signature.js.map +1 -1
  59. package/dist/esm/types/handlers/transaction.js.map +1 -1
  60. package/dist/esm/types/handlers/user-input.js +24 -0
  61. package/dist/esm/types/handlers/user-input.js.map +1 -0
  62. package/dist/esm/types/index.js +1 -0
  63. package/dist/esm/types/index.js.map +1 -1
  64. package/dist/esm/types/interface.js +12 -0
  65. package/dist/esm/types/interface.js.map +1 -0
  66. package/dist/esm/types/methods/create-interface.js +3 -0
  67. package/dist/esm/types/methods/create-interface.js.map +1 -0
  68. package/dist/esm/types/methods/dialog.js.map +1 -1
  69. package/dist/esm/types/methods/get-interface-state.js +3 -0
  70. package/dist/esm/types/methods/get-interface-state.js.map +1 -0
  71. package/dist/esm/types/methods/index.js +3 -0
  72. package/dist/esm/types/methods/index.js.map +1 -1
  73. package/dist/esm/types/methods/methods.js.map +1 -1
  74. package/dist/esm/types/methods/update-interface.js +3 -0
  75. package/dist/esm/types/methods/update-interface.js.map +1 -0
  76. package/dist/esm/types/permissions.js.map +1 -1
  77. package/dist/esm/ui/components/button.js +50 -0
  78. package/dist/esm/ui/components/button.js.map +1 -0
  79. package/dist/esm/ui/components/form.js +39 -0
  80. package/dist/esm/ui/components/form.js.map +1 -0
  81. package/dist/esm/ui/components/image.js +1 -1
  82. package/dist/esm/ui/components/image.js.map +1 -1
  83. package/dist/esm/ui/components/index.js +3 -0
  84. package/dist/esm/ui/components/index.js.map +1 -1
  85. package/dist/esm/ui/components/input.js +47 -0
  86. package/dist/esm/ui/components/input.js.map +1 -0
  87. package/dist/esm/ui/components/panel.js +7 -1
  88. package/dist/esm/ui/components/panel.js.map +1 -1
  89. package/dist/esm/ui/nodes.js +3 -0
  90. package/dist/esm/ui/nodes.js.map +1 -1
  91. package/dist/types/error-wrappers.d.ts +464 -48
  92. package/dist/types/errors.d.ts +2 -4
  93. package/dist/types/index.d.ts +1 -1
  94. package/dist/types/internals/error-wrappers.d.ts +29 -3
  95. package/dist/types/internals/index.d.ts +1 -0
  96. package/dist/types/internals/svg.d.ts +14 -0
  97. package/dist/types/types/handlers/home-page.d.ts +3 -0
  98. package/dist/types/types/handlers/index.d.ts +1 -0
  99. package/dist/types/types/handlers/name-lookup.d.ts +31 -10
  100. package/dist/types/types/handlers/signature.d.ts +4 -0
  101. package/dist/types/types/handlers/transaction.d.ts +4 -0
  102. package/dist/types/types/handlers/user-input.d.ts +64 -0
  103. package/dist/types/types/index.d.ts +1 -0
  104. package/dist/types/types/interface.d.ts +10 -0
  105. package/dist/types/types/methods/create-interface.d.ts +13 -0
  106. package/dist/types/types/methods/dialog.d.ts +14 -0
  107. package/dist/types/types/methods/get-interface-state.d.ts +13 -0
  108. package/dist/types/types/methods/index.d.ts +3 -0
  109. package/dist/types/types/methods/methods.d.ts +6 -0
  110. package/dist/types/types/methods/update-interface.d.ts +15 -0
  111. package/dist/types/types/permissions.d.ts +39 -20
  112. package/dist/types/ui/components/button.d.ts +62 -0
  113. package/dist/types/ui/components/form.d.ts +144 -0
  114. package/dist/types/ui/components/index.d.ts +3 -0
  115. package/dist/types/ui/components/input.d.ts +69 -0
  116. package/dist/types/ui/components/panel.d.ts +150 -0
  117. package/dist/types/ui/nodes.d.ts +4 -1
  118. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/permissions.ts"],"sourcesContent":["import type { JsonRpcRequest } from '@metamask/utils';\n\nimport type { ChainId } from './caip';\n\nexport type EmptyObject = Record<string, never>;\n\nexport type Cronjob = {\n expression: string;\n request: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>;\n};\n\nexport type Bip32Entropy = {\n curve: 'secp256k1' | 'ed25519';\n path: string[];\n};\n\nexport type Bip44Entropy = {\n coinType: number;\n};\n\nexport type RequestedSnap = {\n version?: string;\n};\n\nexport type InitialPermissions = {\n 'endowment:cronjob'?: {\n jobs: Cronjob[];\n };\n 'endowment:keyring'?: {\n allowedOrigins?: string[];\n };\n 'endowment:name-lookup'?: ChainId[];\n 'endowment:network-access'?: EmptyObject;\n 'endowment:rpc'?: {\n dapps?: boolean;\n snaps?: boolean;\n allowedOrigins?: string[];\n };\n 'endowment:signature-insight'?: {\n allowSignatureOrigin?: boolean;\n };\n 'endowment:transaction-insight'?: {\n allowTransactionOrigin?: boolean;\n };\n 'endowment:webassembly'?: EmptyObject;\n\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_confirm?: EmptyObject;\n snap_dialog?: EmptyObject;\n snap_getBip32Entropy?: Bip32Entropy[];\n snap_getBip32PublicKey?: Bip32Entropy[];\n snap_getBip44Entropy?: Bip44Entropy[];\n snap_getEntropy?: EmptyObject;\n snap_manageAccounts?: EmptyObject;\n snap_manageState?: EmptyObject;\n snap_notify?: EmptyObject;\n wallet_snap?: Record<string, RequestedSnap>;\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n"],"names":[],"mappings":"AAAA,WA0DE"}
1
+ {"version":3,"sources":["../../../src/types/permissions.ts"],"sourcesContent":["import type { JsonRpcRequest } from '@metamask/utils';\n\nimport type { ChainId } from './caip';\n\nexport type EmptyObject = Record<string, never>;\n\nexport type Cronjob = {\n expression: string;\n request: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>;\n};\n\nexport type Bip32Entropy = {\n curve: 'secp256k1' | 'ed25519';\n path: string[];\n};\n\nexport type Bip44Entropy = {\n coinType: number;\n};\n\nexport type RequestedSnap = {\n version?: string;\n};\n\nexport type InitialPermissions = Partial<{\n 'endowment:cronjob': {\n jobs: Cronjob[];\n maxRequestTime?: number;\n };\n 'endowment:ethereum-provider': EmptyObject;\n 'endowment:keyring': {\n allowedOrigins?: string[];\n maxRequestTime?: number;\n };\n 'endowment:lifecycle-hooks'?: {\n maxRequestTime?: number;\n };\n 'endowment:name-lookup': {\n chains?: ChainId[];\n matchers?: { tlds?: string[]; schemes?: string[] };\n maxRequestTime?: number;\n };\n 'endowment:network-access': EmptyObject;\n 'endowment:page-home'?: {\n maxRequestTime?: number;\n };\n 'endowment:rpc': {\n dapps?: boolean;\n snaps?: boolean;\n allowedOrigins?: string[];\n maxRequestTime?: number;\n };\n 'endowment:signature-insight': {\n allowSignatureOrigin?: boolean;\n maxRequestTime?: number;\n };\n 'endowment:transaction-insight': {\n allowTransactionOrigin?: boolean;\n maxRequestTime?: number;\n };\n 'endowment:webassembly': EmptyObject;\n\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_dialog: EmptyObject;\n snap_getBip32Entropy: Bip32Entropy[];\n snap_getBip32PublicKey: Bip32Entropy[];\n snap_getBip44Entropy: Bip44Entropy[];\n snap_getEntropy: EmptyObject;\n snap_getLocale: EmptyObject;\n snap_manageAccounts: EmptyObject;\n snap_manageState: EmptyObject;\n snap_notify: EmptyObject;\n wallet_snap: Record<string, RequestedSnap>;\n /* eslint-enable @typescript-eslint/naming-convention */\n}>;\n"],"names":[],"mappings":"AAAA,WA0EG"}
@@ -0,0 +1,50 @@
1
+ import { assign, literal, object, optional, string, union } from 'superstruct';
2
+ import { enumValue } from '../../internals';
3
+ import { createBuilder } from '../builder';
4
+ import { LiteralStruct, NodeType } from '../nodes';
5
+ export var ButtonVariant;
6
+ (function(ButtonVariant) {
7
+ ButtonVariant["Primary"] = 'primary';
8
+ ButtonVariant["Secondary"] = 'secondary';
9
+ })(ButtonVariant || (ButtonVariant = {}));
10
+ export var ButtonType;
11
+ (function(ButtonType) {
12
+ ButtonType["Button"] = 'button';
13
+ ButtonType["Submit"] = 'submit';
14
+ })(ButtonType || (ButtonType = {}));
15
+ export const ButtonStruct = assign(LiteralStruct, object({
16
+ type: literal(NodeType.Button),
17
+ value: string(),
18
+ variant: optional(union([
19
+ enumValue(ButtonVariant.Primary),
20
+ enumValue(ButtonVariant.Secondary)
21
+ ])),
22
+ buttonType: optional(union([
23
+ enumValue(ButtonType.Button),
24
+ enumValue(ButtonType.Submit)
25
+ ])),
26
+ name: optional(string())
27
+ }));
28
+ /**
29
+ * Create a {@link Button} node.
30
+ *
31
+ * @param args - The node arguments. This can be either a string, or an object
32
+ * with a `value` property. A set of optional properties can be passed.
33
+ * @param args.variant - The optional variant of the button.
34
+ * @param args.value - The text content of the node.
35
+ * @param args.name - The optional name of the button.
36
+ * @returns The text node as object.
37
+ * @example
38
+ * ```typescript
39
+ * const node = button({ variant: 'primary', text: 'Hello, world!', name: 'myButton' });
40
+ * const node = button('Hello, world!', 'button', 'myButton', 'primary');
41
+ * const node = button('Hello, world!');
42
+ * ```
43
+ */ export const button = createBuilder(NodeType.Button, ButtonStruct, [
44
+ 'value',
45
+ 'buttonType',
46
+ 'name',
47
+ 'variant'
48
+ ]);
49
+
50
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
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":["assign","literal","object","optional","string","union","enumValue","createBuilder","LiteralStruct","NodeType","ButtonVariant","Primary","Secondary","ButtonType","Button","Submit","ButtonStruct","type","value","variant","buttonType","name","button"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE/E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,WAAW;WAE5C;UAAKC,aAAa;IAAbA,cACVC,aAAU;IADAD,cAEVE,eAAY;GAFFF,kBAAAA;WAKL;UAAKG,UAAU;IAAVA,WACVC,YAAS;IADCD,WAEVE,YAAS;GAFCF,eAAAA;AAKZ,OAAO,MAAMG,eAAehB,OAC1BQ,eACAN,OAAO;IACLe,MAAMhB,QAAQQ,SAASK,MAAM;IAC7BI,OAAOd;IACPe,SAAShB,SACPE,MAAM;QACJC,UAAUI,cAAcC,OAAO;QAC/BL,UAAUI,cAAcE,SAAS;KAClC;IAEHQ,YAAYjB,SACVE,MAAM;QAACC,UAAUO,WAAWC,MAAM;QAAGR,UAAUO,WAAWE,MAAM;KAAE;IAEpEM,MAAMlB,SAASC;AACjB,IACA;AAaF;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMkB,SAASf,cAAcE,SAASK,MAAM,EAAEE,cAAc;IACjE;IACA;IACA;IACA;CACD,EAAE"}
@@ -0,0 +1,39 @@
1
+ import { array, assign, literal, object, string, union } from 'superstruct';
2
+ import { createBuilder } from '../builder';
3
+ import { NodeStruct, NodeType } from '../nodes';
4
+ import { ButtonStruct } from './button';
5
+ import { InputStruct } from './input';
6
+ export const FormComponentStruct = union([
7
+ InputStruct,
8
+ ButtonStruct
9
+ ]);
10
+ export const FormStruct = assign(NodeStruct, object({
11
+ type: literal(NodeType.Form),
12
+ children: array(FormComponentStruct),
13
+ name: string()
14
+ }));
15
+ /**
16
+ * Create a {@link Form} node.
17
+ *
18
+ * @param args - The node arguments. This can be either an array of children and a string, or
19
+ * an object with a `name` and `children` property.
20
+ * @param args.name - The form name used to identify it.
21
+ * @param args.children - The child nodes of the form. This can be any valid
22
+ * {@link FormComponent}.
23
+ * @returns The form node as object.
24
+ * @example
25
+ * const node = form({
26
+ * name: 'myForm',
27
+ * children: [
28
+ * input({ name: 'myInput' }),
29
+ * button({ value: 'Hello, world!' }),
30
+ * ],
31
+ * });
32
+ *
33
+ * const node = form('myForm', [input('myInput'), button('Hello, world!')]);
34
+ */ export const form = createBuilder(NodeType.Form, FormStruct, [
35
+ 'name',
36
+ 'children'
37
+ ]);
38
+
39
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
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":["array","assign","literal","object","string","union","createBuilder","NodeStruct","NodeType","ButtonStruct","InputStruct","FormComponentStruct","FormStruct","type","Form","children","name","form"],"mappings":"AACA,SAASA,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE5E,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAChD,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,WAAW,QAAQ,UAAU;AAEtC,OAAO,MAAMC,sBAAsBN,MAAM;IAACK;IAAaD;CAAa,EAAE;AAOtE,OAAO,MAAMG,aAAaX,OACxBM,YACAJ,OAAO;IACLU,MAAMX,QAAQM,SAASM,IAAI;IAC3BC,UAAUf,MAAMW;IAChBK,MAAMZ;AACR,IACA;AAWF;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMa,OAAOX,cAAcE,SAASM,IAAI,EAAEF,YAAY;IAC3D;IACA;CACD,EAAE"}
@@ -1,5 +1,5 @@
1
- import isSvg from 'is-svg';
2
1
  import { assign, literal, object, refine, string } from 'superstruct';
2
+ import { isSvg } from '../../internals';
3
3
  import { createBuilder } from '../builder';
4
4
  import { NodeStruct, NodeType } from '../nodes';
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/components/image.ts"],"sourcesContent":["import isSvg from 'is-svg';\nimport type { Infer } from 'superstruct';\nimport { assign, literal, object, refine, string } from 'superstruct';\n\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":["isSvg","assign","literal","object","refine","string","createBuilder","NodeStruct","NodeType","svg","value","ImageStruct","type","Image","image"],"mappings":"AAAA,OAAOA,WAAW,SAAS;AAE3B,SAASC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,MAAM,QAAQ,cAAc;AAEtE,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAEhD;;;;;CAKC,GACD,OAAO,SAASC;IACd,OAAOL,OAAOC,UAAU,OAAO,CAACK;QAC9B,IAAI,CAACV,MAAMU,QAAQ;YACjB,OAAO;QACT;QAEA,OAAO;IACT;AACF;AAEA,OAAO,MAAMC,cAAcV,OACzBM,YACAJ,OAAO;IACLS,MAAMV,QAAQM,SAASK,KAAK;IAC5BH,OAAOD;AACT,IACA;AAUF;;;;;;;;;;;CAWC,GACD,OAAO,MAAMK,QAAQR,cAAcE,SAASK,KAAK,EAAEF,aAAa;IAAC;CAAQ,EAAE"}
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":["assign","literal","object","refine","string","isSvg","createBuilder","NodeStruct","NodeType","svg","value","ImageStruct","type","Image","image"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,MAAM,QAAQ,cAAc;AAEtE,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAEhD;;;;;CAKC,GACD,OAAO,SAASC;IACd,OAAON,OAAOC,UAAU,OAAO,CAACM;QAC9B,IAAI,CAACL,MAAMK,QAAQ;YACjB,OAAO;QACT;QAEA,OAAO;IACT;AACF;AAEA,OAAO,MAAMC,cAAcX,OACzBO,YACAL,OAAO;IACLU,MAAMX,QAAQO,SAASK,KAAK;IAC5BH,OAAOD;AACT,IACA;AAUF;;;;;;;;;;;CAWC,GACD,OAAO,MAAMK,QAAQR,cAAcE,SAASK,KAAK,EAAEF,aAAa;IAAC;CAAQ,EAAE"}
@@ -7,5 +7,8 @@ export { ComponentStruct, panel, PanelStruct } from './panel';
7
7
  export * from './spinner';
8
8
  export * from './text';
9
9
  export * from './row';
10
+ export * from './button';
11
+ export * from './input';
12
+ export * from './form';
10
13
 
11
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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';\n"],"names":["image","ImageStruct","ComponentStruct","panel","PanelStruct"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAE1B,SAASA,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAE7C,SAASC,eAAe,EAAEC,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAC9D,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,QAAQ"}
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":"AAAA,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAE1B,SAASA,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAE7C,SAASC,eAAe,EAAEC,KAAK,EAAEC,WAAW,QAAQ,UAAU;AAC9D,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,SAAS"}
@@ -0,0 +1,47 @@
1
+ import { assign, literal, object, optional, string, union } from 'superstruct';
2
+ import { enumValue } from '../../internals';
3
+ import { createBuilder } from '../builder';
4
+ import { LiteralStruct, NodeType } from '../nodes';
5
+ export var InputType;
6
+ (function(InputType) {
7
+ InputType[/* eslint-disable @typescript-eslint/no-shadow */ "Text"] = 'text';
8
+ InputType["Number"] = 'number';
9
+ InputType[/* eslint-enable @typescript-eslint/no-shadow */ "Password"] = 'password';
10
+ })(InputType || (InputType = {}));
11
+ export const InputStruct = assign(LiteralStruct, object({
12
+ type: literal(NodeType.Input),
13
+ value: optional(string()),
14
+ name: string(),
15
+ inputType: optional(union([
16
+ enumValue(InputType.Text),
17
+ enumValue(InputType.Password),
18
+ enumValue(InputType.Number)
19
+ ])),
20
+ placeholder: optional(string()),
21
+ label: optional(string())
22
+ }));
23
+ /**
24
+ * Create a {@link Input} node.
25
+ *
26
+ * @param args - The node arguments. This can either be a name and an optional variant, value and placeholder or an object
27
+ * with the properties: `inputType`, `value`, `variant`, `placeholder` and `name`.
28
+ * @param args.name - The name for the input.
29
+ * @param args.value - The value of the input.
30
+ * @param args.inputType - An optional type, either `text`, `password` or `number`.
31
+ * @param args.placeholder - An optional input placeholder.
32
+ * @param args.label - An optional input label.
33
+ * @returns The input node as an object.
34
+ * @example
35
+ * const node = input('myInput');
36
+ * const node = input('myInput', InputType.Text, 'my placeholder', 'myValue', 'myLabel');
37
+ * const node = input({ name: 'myInput' });
38
+ * const node = input({name: 'myInput', value: 'myValue', inputType: InputType.Password, placeholder: 'placeholder'})
39
+ */ export const input = createBuilder(NodeType.Input, InputStruct, [
40
+ 'name',
41
+ 'inputType',
42
+ 'placeholder',
43
+ 'value',
44
+ 'label'
45
+ ]);
46
+
47
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
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":["assign","literal","object","optional","string","union","enumValue","createBuilder","LiteralStruct","NodeType","InputType","Text","Number","Password","InputStruct","type","Input","value","name","inputType","placeholder","label","input"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE/E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,WAAW;WAM5C;UAAKC,SAAS;IAATA,UACV,+CAA+C,GAC/CC,UAAO;IAFGD,UAGVE,YAAS;IAHCF,UAIV,8CAA8C,GAC9CG,cAAW;GALDH,cAAAA;AAQZ,OAAO,MAAMI,cAAcd,OACzBQ,eACAN,OAAO;IACLa,MAAMd,QAAQQ,SAASO,KAAK;IAC5BC,OAAOd,SAASC;IAChBc,MAAMd;IACNe,WAAWhB,SACTE,MAAM;QACJC,UAAUI,UAAUC,IAAI;QACxBL,UAAUI,UAAUG,QAAQ;QAC5BP,UAAUI,UAAUE,MAAM;KAC3B;IAEHQ,aAAajB,SAASC;IACtBiB,OAAOlB,SAASC;AAClB,IACA;AAcF;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMkB,QAAQf,cAAcE,SAASO,KAAK,EAAEF,aAAa;IAC9D;IACA;IACA;IACA;IACA;CACD,EAAE"}
@@ -2,10 +2,13 @@ import { array, assign, lazy, literal, object, union } from 'superstruct';
2
2
  import { createBuilder } from '../builder';
3
3
  import { NodeStruct, NodeType } from '../nodes';
4
4
  import { AddressStruct } from './address';
5
+ import { ButtonStruct } from './button';
5
6
  import { CopyableStruct } from './copyable';
6
7
  import { DividerStruct } from './divider';
8
+ import { FormStruct } from './form';
7
9
  import { HeadingStruct } from './heading';
8
10
  import { ImageStruct } from './image';
11
+ import { InputStruct } from './input';
9
12
  import { RowStruct } from './row';
10
13
  import { SpinnerStruct } from './spinner';
11
14
  import { TextStruct } from './text';
@@ -54,7 +57,10 @@ export const ComponentStruct = union([
54
57
  SpinnerStruct,
55
58
  TextStruct,
56
59
  RowStruct,
57
- AddressStruct
60
+ AddressStruct,
61
+ InputStruct,
62
+ FormStruct,
63
+ ButtonStruct
58
64
  ]);
59
65
 
60
66
  //# sourceMappingURL=panel.js.map
@@ -1 +1 @@
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 { CopyableStruct } from './copyable';\nimport { DividerStruct } from './divider';\nimport { HeadingStruct } from './heading';\nimport { ImageStruct } from './image';\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]);\n\n/**\n * All supported component types.\n */\nexport type Component = Infer<typeof ComponentStruct>;\n"],"names":["array","assign","lazy","literal","object","union","createBuilder","NodeStruct","NodeType","AddressStruct","CopyableStruct","DividerStruct","HeadingStruct","ImageStruct","RowStruct","SpinnerStruct","TextStruct","ParentStruct","children","ComponentStruct","PanelStruct","type","Panel","panel"],"mappings":"AACA,SAASA,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE1E,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAChD,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,UAAU,QAAQ,SAAS;AAEpC;;CAEC,GACD,OAAO,MAAMC,eAAehB,OAC1BM,YACAH,OAAO;IACL,sEAAsE;IACtE,mEAAmE;IACnEc,UAAUlB,MAAME,KAAK,IAAMiB;AAC7B,IACA;AAYF;;CAEC,GACD,OAAO,MAAMC,cAA6BnB,OACxCgB,cACAb,OAAO;IACLiB,MAAMlB,QAAQK,SAASc,KAAK;AAC9B,IACA;AAeF;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,MAAMC,QAAQjB,cAAcE,SAASc,KAAK,EAAEF,aAAa;IAAC;CAAW,EAAE;AAE9E,8EAA8E;AAC9E,OAAO,MAAMD,kBAAkBd,MAAM;IACnCK;IACAC;IACAC;IACAC;IACAO;IACAL;IACAC;IACAF;IACAL;CACD,EAAE"}
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":["array","assign","lazy","literal","object","union","createBuilder","NodeStruct","NodeType","AddressStruct","ButtonStruct","CopyableStruct","DividerStruct","FormStruct","HeadingStruct","ImageStruct","InputStruct","RowStruct","SpinnerStruct","TextStruct","ParentStruct","children","ComponentStruct","PanelStruct","type","Panel","panel"],"mappings":"AACA,SAASA,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,QAAQ,cAAc;AAE1E,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAChD,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,UAAU,QAAQ,SAAS;AAEpC;;CAEC,GACD,OAAO,MAAMC,eAAenB,OAC1BM,YACAH,OAAO;IACL,sEAAsE;IACtE,mEAAmE;IACnEiB,UAAUrB,MAAME,KAAK,IAAMoB;AAC7B,IACA;AAYF;;CAEC,GACD,OAAO,MAAMC,cAA6BtB,OACxCmB,cACAhB,OAAO;IACLoB,MAAMrB,QAAQK,SAASiB,KAAK;AAC9B,IACA;AAeF;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,MAAMC,QAAQpB,cAAcE,SAASiB,KAAK,EAAEF,aAAa;IAAC;CAAW,EAAE;AAE9E,8EAA8E;AAC9E,OAAO,MAAMD,kBAAkBjB,MAAM;IACnCM;IACAC;IACAE;IACAC;IACAQ;IACAL;IACAC;IACAF;IACAR;IACAO;IACAH;IACAH;CACD,EAAE"}
@@ -11,6 +11,9 @@ export var NodeType;
11
11
  NodeType["Image"] = 'image';
12
12
  NodeType["Row"] = 'row';
13
13
  NodeType["Address"] = 'address';
14
+ NodeType["Button"] = 'button';
15
+ NodeType["Input"] = 'input';
16
+ NodeType["Form"] = 'form';
14
17
  })(NodeType || (NodeType = {}));
15
18
  /**
16
19
  * @internal
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ui/nodes.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, object, string, unknown } from 'superstruct';\n\n/**\n * The supported node types. This is based on SIP-7.\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-7\n */\nexport enum NodeType {\n Copyable = 'copyable',\n Divider = 'divider',\n Heading = 'heading',\n Panel = 'panel',\n Spinner = 'spinner',\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Text = 'text',\n Image = 'image',\n Row = 'row',\n Address = 'address',\n}\n\n/**\n * @internal\n */\nexport const NodeStruct = object({\n type: string(),\n});\n\n/**\n * The base node type. All nodes extend this type.\n *\n * @property type - The type of the node. See {@link NodeType} for the supported\n * node types.\n * @internal\n */\nexport type Node = Infer<typeof NodeStruct>;\n\n/**\n * @internal\n */\nexport const LiteralStruct = assign(\n NodeStruct,\n object({\n value: unknown(),\n }),\n);\n\n/**\n * A node with a value. This is used for nodes that render a value, such as\n * {@link Text}.\n *\n * @property type - The type of the node.\n * @property value - The value of the node. The type of the value depends on the\n * node type.\n * @internal\n */\nexport type Literal = Infer<typeof LiteralStruct>;\n"],"names":["assign","object","string","unknown","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","Row","Address","NodeStruct","type","LiteralStruct","value"],"mappings":"AACA,SAASA,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,QAAQ,cAAc;WAOvD;UAAKC,QAAQ;IAARA,SACVC,cAAW;IADDD,SAEVE,aAAU;IAFAF,SAGVG,aAAU;IAHAH,SAIVI,WAAQ;IAJEJ,SAKVK,aAAU;IALAL,SAMV,wDAAwD;IACxDM,UAAO;IAPGN,SAQVO,WAAQ;IAREP,SASVQ,SAAM;IATIR,SAUVS,aAAU;GAVAT,aAAAA;AAaZ;;CAEC,GACD,OAAO,MAAMU,aAAab,OAAO;IAC/Bc,MAAMb;AACR,GAAG;AAWH;;CAEC,GACD,OAAO,MAAMc,gBAAgBhB,OAC3Bc,YACAb,OAAO;IACLgB,OAAOd;AACT,IACA"}
1
+ {"version":3,"sources":["../../../src/ui/nodes.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, object, string, unknown } from 'superstruct';\n\n/**\n * The supported node types. This is based on SIP-7.\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-7\n */\nexport enum NodeType {\n Copyable = 'copyable',\n Divider = 'divider',\n Heading = 'heading',\n Panel = 'panel',\n Spinner = 'spinner',\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Text = 'text',\n Image = 'image',\n Row = 'row',\n Address = 'address',\n Button = 'button',\n Input = 'input',\n Form = 'form',\n}\n\n/**\n * @internal\n */\nexport const NodeStruct = object({\n type: string(),\n});\n\n/**\n * The base node type. All nodes extend this type.\n *\n * @property type - The type of the node. See {@link NodeType} for the supported\n * node types.\n * @internal\n */\nexport type Node = Infer<typeof NodeStruct>;\n\n/**\n * @internal\n */\nexport const LiteralStruct = assign(\n NodeStruct,\n object({\n value: unknown(),\n }),\n);\n\n/**\n * A node with a value. This is used for nodes that render a value, such as\n * {@link Text}.\n *\n * @property type - The type of the node.\n * @property value - The value of the node. The type of the value depends on the\n * node type.\n * @internal\n */\nexport type Literal = Infer<typeof LiteralStruct>;\n"],"names":["assign","object","string","unknown","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","Row","Address","Button","Input","Form","NodeStruct","type","LiteralStruct","value"],"mappings":"AACA,SAASA,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,QAAQ,cAAc;WAOvD;UAAKC,QAAQ;IAARA,SACVC,cAAW;IADDD,SAEVE,aAAU;IAFAF,SAGVG,aAAU;IAHAH,SAIVI,WAAQ;IAJEJ,SAKVK,aAAU;IALAL,SAMV,wDAAwD;IACxDM,UAAO;IAPGN,SAQVO,WAAQ;IAREP,SASVQ,SAAM;IATIR,SAUVS,aAAU;IAVAT,SAWVU,YAAS;IAXCV,SAYVW,WAAQ;IAZEX,SAaVY,UAAO;GAbGZ,aAAAA;AAgBZ;;CAEC,GACD,OAAO,MAAMa,aAAahB,OAAO;IAC/BiB,MAAMhB;AACR,GAAG;AAWH;;CAEC,GACD,OAAO,MAAMiB,gBAAgBnB,OAC3BiB,YACAhB,OAAO;IACLmB,OAAOjB;AACT,IACA"}