@metamask/snaps-sdk 2.0.0 → 3.0.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.
- package/CHANGELOG.md +17 -1
- package/dist/index.js +883 -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/dist/types/error-wrappers.d.ts +464 -48
- package/dist/types/errors.d.ts +2 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internals/error-wrappers.d.ts +29 -3
- package/dist/types/internals/index.d.ts +1 -0
- package/dist/types/internals/svg.d.ts +14 -0
- package/package.json +19 -16
- package/dist/cjs/error-wrappers.js +0 -80
- package/dist/cjs/error-wrappers.js.map +0 -1
- package/dist/cjs/errors.js +0 -157
- 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 -62
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/internals/error-wrappers.js +0 -25
- 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 -23
- 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/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 -47
- 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 -150
- 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 -25
- 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 -6
- 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/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
|
@@ -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":["assign","literal","object","createBuilder","NodeStruct","NodeType","DividerStruct","type","Divider","divider"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,QAAQ,cAAc;AAEtD,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAEhD,OAAO,MAAMC,gBAAgBN,OAC3BI,YACAF,OAAO;IACLK,MAAMN,QAAQI,SAASG,OAAO;AAChC,IACA;AAOF;;;;;;CAMC,GACD,OAAO,MAAMC,UAAUN,cAAcE,SAASG,OAAO,EAAEF,eAAe"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
|
@@ -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":["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,22 +0,0 @@
|
|
|
1
|
-
import { assign, literal, object, string } from 'superstruct';
|
|
2
|
-
import { createBuilder } from '../builder';
|
|
3
|
-
import { LiteralStruct, NodeType } from '../nodes';
|
|
4
|
-
export const HeadingStruct = assign(LiteralStruct, object({
|
|
5
|
-
type: literal(NodeType.Heading),
|
|
6
|
-
value: string()
|
|
7
|
-
}));
|
|
8
|
-
/**
|
|
9
|
-
* Create a {@link Heading} node.
|
|
10
|
-
*
|
|
11
|
-
* @param args - The node arguments. This can either be a string, or an object
|
|
12
|
-
* with the `value` property.
|
|
13
|
-
* @param args.value - The heading text.
|
|
14
|
-
* @returns The heading node as object.
|
|
15
|
-
* @example
|
|
16
|
-
* const node = heading({ value: 'Hello, world!' });
|
|
17
|
-
* const node = heading('Hello, world!');
|
|
18
|
-
*/ export const heading = createBuilder(NodeType.Heading, HeadingStruct, [
|
|
19
|
-
'value'
|
|
20
|
-
]);
|
|
21
|
-
|
|
22
|
-
//# 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":["assign","literal","object","string","createBuilder","LiteralStruct","NodeType","HeadingStruct","type","Heading","value","heading"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,QAAQ,cAAc;AAE9D,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,WAAW;AAEnD,OAAO,MAAMC,gBAAgBP,OAC3BK,eACAH,OAAO;IACLM,MAAMP,QAAQK,SAASG,OAAO;IAC9BC,OAAOP;AACT,IACA;AAYF;;;;;;;;;;CAUC,GACD,OAAO,MAAMQ,UAAUP,cAAcE,SAASG,OAAO,EAAEF,eAAe;IACpE;CACD,EAAE"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import isSvg from 'is-svg';
|
|
2
|
-
import { assign, literal, object, refine, string } from 'superstruct';
|
|
3
|
-
import { createBuilder } from '../builder';
|
|
4
|
-
import { NodeStruct, NodeType } from '../nodes';
|
|
5
|
-
/**
|
|
6
|
-
* Get a Struct that validates a string as a valid SVG.
|
|
7
|
-
*
|
|
8
|
-
* @returns A Struct that validates a string as a valid SVG.
|
|
9
|
-
* @internal
|
|
10
|
-
*/ export function svg() {
|
|
11
|
-
return refine(string(), 'SVG', (value)=>{
|
|
12
|
-
if (!isSvg(value)) {
|
|
13
|
-
return 'Value is not a valid SVG.';
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
export const ImageStruct = assign(NodeStruct, object({
|
|
19
|
-
type: literal(NodeType.Image),
|
|
20
|
-
value: svg()
|
|
21
|
-
}));
|
|
22
|
-
/**
|
|
23
|
-
* Create an {@link Image} node.
|
|
24
|
-
*
|
|
25
|
-
* @param args - The node arguments. This can either be a string, or an object
|
|
26
|
-
* with the `value` property.
|
|
27
|
-
* @param args.value - The SVG image to be rendered. Must be a valid SVG string.
|
|
28
|
-
* @returns The image node as object. Other image formats are supported by
|
|
29
|
-
* embedding them as data URLs in the SVG.
|
|
30
|
-
* @example
|
|
31
|
-
* const node = image({ value: '<svg />' });
|
|
32
|
-
* const node = image('<svg />');
|
|
33
|
-
*/ export const image = createBuilder(NodeType.Image, ImageStruct, [
|
|
34
|
-
'value'
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=image.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,14 +0,0 @@
|
|
|
1
|
-
export * from './address';
|
|
2
|
-
export * from './copyable';
|
|
3
|
-
export * from './divider';
|
|
4
|
-
export * from './heading';
|
|
5
|
-
export { image, ImageStruct } from './image';
|
|
6
|
-
export { ComponentStruct, panel, PanelStruct } from './panel';
|
|
7
|
-
export * from './spinner';
|
|
8
|
-
export * from './text';
|
|
9
|
-
export * from './row';
|
|
10
|
-
export * from './button';
|
|
11
|
-
export * from './input';
|
|
12
|
-
export * from './form';
|
|
13
|
-
|
|
14
|
-
//# 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":"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"}
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
|
@@ -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":["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"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { array, assign, lazy, literal, object, union } from 'superstruct';
|
|
2
|
-
import { createBuilder } from '../builder';
|
|
3
|
-
import { NodeStruct, NodeType } from '../nodes';
|
|
4
|
-
import { AddressStruct } from './address';
|
|
5
|
-
import { ButtonStruct } from './button';
|
|
6
|
-
import { CopyableStruct } from './copyable';
|
|
7
|
-
import { DividerStruct } from './divider';
|
|
8
|
-
import { FormStruct } from './form';
|
|
9
|
-
import { HeadingStruct } from './heading';
|
|
10
|
-
import { ImageStruct } from './image';
|
|
11
|
-
import { InputStruct } from './input';
|
|
12
|
-
import { RowStruct } from './row';
|
|
13
|
-
import { SpinnerStruct } from './spinner';
|
|
14
|
-
import { TextStruct } from './text';
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/ export const ParentStruct = assign(NodeStruct, object({
|
|
18
|
-
// This node references itself indirectly, so we need to use `lazy()`.
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
20
|
-
children: array(lazy(()=>ComponentStruct))
|
|
21
|
-
}));
|
|
22
|
-
/**
|
|
23
|
-
* @internal
|
|
24
|
-
*/ export const PanelStruct = assign(ParentStruct, object({
|
|
25
|
-
type: literal(NodeType.Panel)
|
|
26
|
-
}));
|
|
27
|
-
/**
|
|
28
|
-
* Create a {@link Panel} node.
|
|
29
|
-
*
|
|
30
|
-
* @param args - The node arguments. This can be either an array of children, or
|
|
31
|
-
* an object with a `children` property.
|
|
32
|
-
* @param args.children - The child nodes of the panel. This can be any valid
|
|
33
|
-
* {@link Component}.
|
|
34
|
-
* @returns The panel node as object.
|
|
35
|
-
* @example
|
|
36
|
-
* const node = panel({
|
|
37
|
-
* children: [
|
|
38
|
-
* heading({ text: 'Hello, world!' }),
|
|
39
|
-
* text({ text: 'This is a panel.' }),
|
|
40
|
-
* ],
|
|
41
|
-
* });
|
|
42
|
-
*
|
|
43
|
-
* const node = panel([
|
|
44
|
-
* heading('Hello, world!'),
|
|
45
|
-
* text('This is a panel.'),
|
|
46
|
-
* ]);
|
|
47
|
-
*/ export const panel = createBuilder(NodeType.Panel, PanelStruct, [
|
|
48
|
-
'children'
|
|
49
|
-
]);
|
|
50
|
-
// This is defined separately from `Component` to avoid circular dependencies.
|
|
51
|
-
export const ComponentStruct = union([
|
|
52
|
-
CopyableStruct,
|
|
53
|
-
DividerStruct,
|
|
54
|
-
HeadingStruct,
|
|
55
|
-
ImageStruct,
|
|
56
|
-
PanelStruct,
|
|
57
|
-
SpinnerStruct,
|
|
58
|
-
TextStruct,
|
|
59
|
-
RowStruct,
|
|
60
|
-
AddressStruct,
|
|
61
|
-
InputStruct,
|
|
62
|
-
FormStruct,
|
|
63
|
-
ButtonStruct
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
//# 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":["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"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { assign, literal, object, string, optional, union } from 'superstruct';
|
|
2
|
-
import { enumValue } from '../../internals';
|
|
3
|
-
import { createBuilder } from '../builder';
|
|
4
|
-
import { LiteralStruct, NodeType } from '../nodes';
|
|
5
|
-
import { AddressStruct } from './address';
|
|
6
|
-
import { ImageStruct } from './image';
|
|
7
|
-
import { TextStruct } from './text';
|
|
8
|
-
export var RowVariant;
|
|
9
|
-
(function(RowVariant) {
|
|
10
|
-
RowVariant["Default"] = 'default';
|
|
11
|
-
RowVariant["Critical"] = 'critical';
|
|
12
|
-
RowVariant["Warning"] = 'warning';
|
|
13
|
-
})(RowVariant || (RowVariant = {}));
|
|
14
|
-
// A subset of components made available to the row
|
|
15
|
-
const RowComponentStruct = union([
|
|
16
|
-
ImageStruct,
|
|
17
|
-
TextStruct,
|
|
18
|
-
AddressStruct
|
|
19
|
-
]);
|
|
20
|
-
export const RowStruct = assign(LiteralStruct, object({
|
|
21
|
-
type: literal(NodeType.Row),
|
|
22
|
-
variant: optional(union([
|
|
23
|
-
enumValue(RowVariant.Default),
|
|
24
|
-
enumValue(RowVariant.Critical),
|
|
25
|
-
enumValue(RowVariant.Warning)
|
|
26
|
-
])),
|
|
27
|
-
label: string(),
|
|
28
|
-
value: RowComponentStruct
|
|
29
|
-
}));
|
|
30
|
-
/**
|
|
31
|
-
* Create a {@link Row} node.
|
|
32
|
-
*
|
|
33
|
-
* @param args - The node arguments. This can either be a string, a component and an optional variant or an object
|
|
34
|
-
* with the properties: `label`, `value` and `variant`.
|
|
35
|
-
* @param args.label - The label for the row.
|
|
36
|
-
* @param args.value - Another component, is currently limited to `image`, `text` and `address`.
|
|
37
|
-
* @param args.variant - An optional variant, either `default`, `warning` or `critical`.
|
|
38
|
-
* @returns The row node as an object.
|
|
39
|
-
* @example
|
|
40
|
-
* const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520') });
|
|
41
|
-
* const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), variant: RowVariant.Warning });
|
|
42
|
-
* const node = row('Address', address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'));
|
|
43
|
-
* const node = row('Address', address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), RowVariant.Warning);
|
|
44
|
-
*/ export const row = createBuilder(NodeType.Row, RowStruct, [
|
|
45
|
-
'label',
|
|
46
|
-
'value',
|
|
47
|
-
'variant'
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=row.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/row.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, literal, object, string, optional, union } from 'superstruct';\n\nimport { enumValue } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\nimport { AddressStruct } from './address';\nimport { ImageStruct } from './image';\nimport { TextStruct } from './text';\n\nexport enum RowVariant {\n Default = 'default',\n Critical = 'critical',\n Warning = 'warning',\n}\n\n// A subset of components made available to the row\nconst RowComponentStruct = union([ImageStruct, TextStruct, AddressStruct]);\n\nexport const RowStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Row),\n variant: optional(\n union([\n enumValue(RowVariant.Default),\n enumValue(RowVariant.Critical),\n enumValue(RowVariant.Warning),\n ]),\n ),\n label: string(),\n value: RowComponentStruct,\n }),\n);\n\n/**\n * A row node, that renders a row with a label and a value.\n *\n * @property type - The type of the node. Must be the string `row`.\n * @property label - The label for the row.\n * @property value - A sub component to be rendered\n * on one side of the row.\n * @property variant - Optional variant for styling.\n */\nexport type Row = Infer<typeof RowStruct>;\n\n/**\n * Create a {@link Row} node.\n *\n * @param args - The node arguments. This can either be a string, a component and an optional variant or an object\n * with the properties: `label`, `value` and `variant`.\n * @param args.label - The label for the row.\n * @param args.value - Another component, is currently limited to `image`, `text` and `address`.\n * @param args.variant - An optional variant, either `default`, `warning` or `critical`.\n * @returns The row node as an object.\n * @example\n * const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520') });\n * const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), variant: RowVariant.Warning });\n * const node = row('Address', address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'));\n * const node = row('Address', address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), RowVariant.Warning);\n */\nexport const row = createBuilder(NodeType.Row, RowStruct, [\n 'label',\n 'value',\n 'variant',\n]);\n"],"names":["assign","literal","object","string","optional","union","enumValue","createBuilder","LiteralStruct","NodeType","AddressStruct","ImageStruct","TextStruct","RowVariant","Default","Critical","Warning","RowComponentStruct","RowStruct","type","Row","variant","label","value","row"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,QAAQ,cAAc;AAE/E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,WAAW;AACnD,SAASC,aAAa,QAAQ,YAAY;AAC1C,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,UAAU,QAAQ,SAAS;WAE7B;UAAKC,UAAU;IAAVA,WACVC,aAAU;IADAD,WAEVE,cAAW;IAFDF,WAGVG,aAAU;GAHAH,eAAAA;AAMZ,mDAAmD;AACnD,MAAMI,qBAAqBZ,MAAM;IAACM;IAAaC;IAAYF;CAAc;AAEzE,OAAO,MAAMQ,YAAYlB,OACvBQ,eACAN,OAAO;IACLiB,MAAMlB,QAAQQ,SAASW,GAAG;IAC1BC,SAASjB,SACPC,MAAM;QACJC,UAAUO,WAAWC,OAAO;QAC5BR,UAAUO,WAAWE,QAAQ;QAC7BT,UAAUO,WAAWG,OAAO;KAC7B;IAEHM,OAAOnB;IACPoB,OAAON;AACT,IACA;AAaF;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMO,MAAMjB,cAAcE,SAASW,GAAG,EAAEF,WAAW;IACxD;IACA;IACA;CACD,EAAE"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { assign, literal, object } from 'superstruct';
|
|
2
|
-
import { createBuilder } from '../builder';
|
|
3
|
-
import { NodeStruct, NodeType } from '../nodes';
|
|
4
|
-
export const SpinnerStruct = assign(NodeStruct, object({
|
|
5
|
-
type: literal(NodeType.Spinner)
|
|
6
|
-
}));
|
|
7
|
-
/**
|
|
8
|
-
* Create a {@link Spinner} node.
|
|
9
|
-
*
|
|
10
|
-
* @returns The spinner node as object.
|
|
11
|
-
* @example
|
|
12
|
-
* const node = spinner();
|
|
13
|
-
*/ export const spinner = createBuilder(NodeType.Spinner, SpinnerStruct);
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=spinner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/spinner.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 SpinnerStruct = assign(\n NodeStruct,\n object({\n type: literal(NodeType.Spinner),\n }),\n);\n\n/**\n * A spinner node, that renders a spinner, either as a full-screen overlay, or\n * inline when nested inside a {@link Panel}.\n */\nexport type Spinner = Infer<typeof SpinnerStruct>;\n\n/**\n * Create a {@link Spinner} node.\n *\n * @returns The spinner node as object.\n * @example\n * const node = spinner();\n */\nexport const spinner = createBuilder(NodeType.Spinner, SpinnerStruct);\n"],"names":["assign","literal","object","createBuilder","NodeStruct","NodeType","SpinnerStruct","type","Spinner","spinner"],"mappings":"AACA,SAASA,MAAM,EAAEC,OAAO,EAAEC,MAAM,QAAQ,cAAc;AAEtD,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAEhD,OAAO,MAAMC,gBAAgBN,OAC3BI,YACAF,OAAO;IACLK,MAAMN,QAAQI,SAASG,OAAO;AAChC,IACA;AAQF;;;;;;CAMC,GACD,OAAO,MAAMC,UAAUN,cAAcE,SAASG,OAAO,EAAEF,eAAe"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { assign, boolean, literal, object, optional, string } from 'superstruct';
|
|
2
|
-
import { createBuilder } from '../builder';
|
|
3
|
-
import { LiteralStruct, NodeType } from '../nodes';
|
|
4
|
-
export const TextStruct = assign(LiteralStruct, object({
|
|
5
|
-
type: literal(NodeType.Text),
|
|
6
|
-
value: string(),
|
|
7
|
-
markdown: optional(boolean())
|
|
8
|
-
}));
|
|
9
|
-
/**
|
|
10
|
-
* Create a {@link Text} node.
|
|
11
|
-
*
|
|
12
|
-
* @param args - The node arguments. This can be either a string
|
|
13
|
-
* and a boolean, or an object with a `value` property
|
|
14
|
-
* and an optional `markdown` property.
|
|
15
|
-
* @param args.value - The text content of the node.
|
|
16
|
-
* @param args.markdown - An optional flag to enable or disable markdown. This
|
|
17
|
-
* is enabled by default.
|
|
18
|
-
* @returns The text node as object.
|
|
19
|
-
* @example
|
|
20
|
-
* const node = text({ value: 'Hello, world!' });
|
|
21
|
-
* const node = text('Hello, world!');
|
|
22
|
-
* const node = text({ value: 'Hello, world!', markdown: false });
|
|
23
|
-
* const node = text('Hello, world!', false);
|
|
24
|
-
*/ export const text = createBuilder(NodeType.Text, TextStruct, [
|
|
25
|
-
'value',
|
|
26
|
-
'markdown'
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=text.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ui/components/text.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 TextStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Text),\n value: string(),\n markdown: optional(boolean()),\n }),\n);\n\n/**\n * A text node, that renders the text as one or more paragraphs.\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 * @property markdown - A flag to enable/disable markdown, if nothing is specified\n * markdown will be enabled.\n */\nexport type Text = Infer<typeof TextStruct>;\n\n/**\n * Create a {@link Text} node.\n *\n * @param args - The node arguments. This can be either a string\n * and a boolean, or an object with a `value` property\n * and an optional `markdown` property.\n * @param args.value - The text content of the node.\n * @param args.markdown - An optional flag to enable or disable markdown. This\n * is enabled by default.\n * @returns The text node as object.\n * @example\n * const node = text({ value: 'Hello, world!' });\n * const node = text('Hello, world!');\n * const node = text({ value: 'Hello, world!', markdown: false });\n * const node = text('Hello, world!', false);\n */\nexport const text = createBuilder(NodeType.Text, TextStruct, [\n 'value',\n 'markdown',\n]);\n"],"names":["assign","boolean","literal","object","optional","string","createBuilder","LiteralStruct","NodeType","TextStruct","type","Text","value","markdown","text"],"mappings":"AACA,SACEA,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,MAAM,QACD,cAAc;AAErB,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,WAAW;AAEnD,OAAO,MAAMC,aAAaT,OACxBO,eACAJ,OAAO;IACLO,MAAMR,QAAQM,SAASG,IAAI;IAC3BC,OAAOP;IACPQ,UAAUT,SAASH;AACrB,IACA;AAaF;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMa,OAAOR,cAAcE,SAASG,IAAI,EAAEF,YAAY;IAC3D;IACA;CACD,EAAE"}
|
package/dist/esm/ui/index.js
DELETED
package/dist/esm/ui/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/index.ts"],"sourcesContent":["export * from './components';\nexport * from './component';\nexport { NodeType } from './nodes';\n"],"names":["NodeType"],"mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,SAASA,QAAQ,QAAQ,UAAU"}
|
package/dist/esm/ui/nodes.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { assign, object, string, unknown } from 'superstruct';
|
|
2
|
-
export var NodeType;
|
|
3
|
-
(function(NodeType) {
|
|
4
|
-
NodeType["Copyable"] = 'copyable';
|
|
5
|
-
NodeType["Divider"] = 'divider';
|
|
6
|
-
NodeType["Heading"] = 'heading';
|
|
7
|
-
NodeType["Panel"] = 'panel';
|
|
8
|
-
NodeType["Spinner"] = 'spinner';
|
|
9
|
-
NodeType[// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
10
|
-
"Text"] = 'text';
|
|
11
|
-
NodeType["Image"] = 'image';
|
|
12
|
-
NodeType["Row"] = 'row';
|
|
13
|
-
NodeType["Address"] = 'address';
|
|
14
|
-
NodeType["Button"] = 'button';
|
|
15
|
-
NodeType["Input"] = 'input';
|
|
16
|
-
NodeType["Form"] = 'form';
|
|
17
|
-
})(NodeType || (NodeType = {}));
|
|
18
|
-
/**
|
|
19
|
-
* @internal
|
|
20
|
-
*/ export const NodeStruct = object({
|
|
21
|
-
type: string()
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/ export const LiteralStruct = assign(NodeStruct, object({
|
|
26
|
-
value: unknown()
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=nodes.js.map
|
package/dist/esm/ui/nodes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|