@metamask/snaps-sdk 5.0.0 → 6.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 +13 -1
- package/dist/index.js +99 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -49
- package/dist/index.mjs.map +1 -1
- package/dist/jsx/index.js +125 -73
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +125 -73
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +74 -37
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.mjs +74 -37
- package/dist/jsx/jsx-dev-runtime.mjs.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/internals/jsx.d.ts +1 -1
- package/dist/types/jsx/component.d.ts +6 -9
- package/dist/types/jsx/components/Box.d.ts +4 -4
- package/dist/types/jsx/components/Link.d.ts +2 -2
- package/dist/types/jsx/components/Row.d.ts +1 -1
- package/dist/types/jsx/components/Text.d.ts +7 -2
- package/dist/types/jsx/components/Tooltip.d.ts +38 -0
- package/dist/types/jsx/components/form/Checkbox.d.ts +35 -0
- package/dist/types/jsx/components/form/Dropdown.d.ts +4 -5
- package/dist/types/jsx/components/form/Field.d.ts +7 -1
- package/dist/types/jsx/components/form/FileInput.d.ts +47 -0
- package/dist/types/jsx/components/form/Form.d.ts +4 -7
- package/dist/types/jsx/components/form/Input.d.ts +1 -2
- package/dist/types/jsx/components/form/index.d.ts +5 -1
- package/dist/types/jsx/components/formatting/Bold.d.ts +2 -2
- package/dist/types/jsx/components/formatting/Italic.d.ts +2 -2
- package/dist/types/jsx/components/index.d.ts +3 -1
- package/dist/types/jsx/validation.d.ts +34 -39
- package/dist/types/types/handlers/user-input.d.ts +126 -11
- package/dist/types/types/interface.d.ts +29 -21
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [6.0.0]
|
|
10
|
+
### Added
|
|
11
|
+
- **BREAKING:** Add `FileInput` component ([#2469](https://github.com/MetaMask/snaps/pull/2469), [#2504](https://github.com/MetaMask/snaps/pull/2504))
|
|
12
|
+
- `FormSubmitEvent` may now contain values of type `File`.
|
|
13
|
+
- **BREAKING:** Add `Checkbox` component ([#2501](https://github.com/MetaMask/snaps/pull/2501))
|
|
14
|
+
- `FormSubmitEvent` and `InputChangeEvent` may now contain values of type `boolean`.
|
|
15
|
+
- Add `alignment` prop to `Text` ([#2489](https://github.com/MetaMask/snaps/pull/2489))
|
|
16
|
+
- Add `Tooltip` component ([#2490](https://github.com/MetaMask/snaps/pull/2490))
|
|
17
|
+
- Support additional components inside forms ([#2497](https://github.com/MetaMask/snaps/pull/2497))
|
|
18
|
+
- Support conditional children in most JSX components ([#2506](https://github.com/MetaMask/snaps/pull/2506))
|
|
19
|
+
|
|
9
20
|
## [5.0.0]
|
|
10
21
|
### Added
|
|
11
22
|
- Allow row tooltips ([#2483](https://github.com/MetaMask/snaps/pull/2483))
|
|
@@ -170,7 +181,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
170
181
|
### Added
|
|
171
182
|
- Initial release of this package.
|
|
172
183
|
|
|
173
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@
|
|
184
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@6.0.0...HEAD
|
|
185
|
+
[6.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@5.0.0...@metamask/snaps-sdk@6.0.0
|
|
174
186
|
[5.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.4.2...@metamask/snaps-sdk@5.0.0
|
|
175
187
|
[4.4.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.4.1...@metamask/snaps-sdk@4.4.2
|
|
176
188
|
[4.4.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@4.4.0...@metamask/snaps-sdk@4.4.1
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,8 @@ __export(src_exports, {
|
|
|
51
51
|
DialogType: () => DialogType,
|
|
52
52
|
DisconnectedError: () => DisconnectedError,
|
|
53
53
|
DividerStruct: () => DividerStruct,
|
|
54
|
+
FileStruct: () => FileStruct,
|
|
55
|
+
FileUploadEventStruct: () => FileUploadEventStruct,
|
|
54
56
|
FormComponentStruct: () => FormComponentStruct,
|
|
55
57
|
FormStateStruct: () => FormStateStruct,
|
|
56
58
|
FormStruct: () => FormStruct,
|
|
@@ -84,6 +86,7 @@ __export(src_exports, {
|
|
|
84
86
|
SeverityLevel: () => SeverityLevel,
|
|
85
87
|
SnapError: () => SnapError,
|
|
86
88
|
SpinnerStruct: () => SpinnerStruct,
|
|
89
|
+
StateStruct: () => StateStruct,
|
|
87
90
|
TextStruct: () => TextStruct,
|
|
88
91
|
TransactionRejected: () => TransactionRejected,
|
|
89
92
|
UnauthorizedError: () => UnauthorizedError,
|
|
@@ -721,6 +724,7 @@ var UserInputEventType = /* @__PURE__ */ ((UserInputEventType2) => {
|
|
|
721
724
|
UserInputEventType2["ButtonClickEvent"] = "ButtonClickEvent";
|
|
722
725
|
UserInputEventType2["FormSubmitEvent"] = "FormSubmitEvent";
|
|
723
726
|
UserInputEventType2["InputChangeEvent"] = "InputChangeEvent";
|
|
727
|
+
UserInputEventType2["FileUploadEvent"] = "FileUploadEvent";
|
|
724
728
|
return UserInputEventType2;
|
|
725
729
|
})(UserInputEventType || {});
|
|
726
730
|
var GenericEventStruct = (0, import_superstruct17.object)({
|
|
@@ -734,11 +738,17 @@ var ButtonClickEventStruct = (0, import_superstruct17.assign)(
|
|
|
734
738
|
name: (0, import_superstruct17.optional)((0, import_superstruct17.string)())
|
|
735
739
|
})
|
|
736
740
|
);
|
|
741
|
+
var FileStruct = (0, import_superstruct17.object)({
|
|
742
|
+
name: (0, import_superstruct17.string)(),
|
|
743
|
+
size: (0, import_superstruct17.number)(),
|
|
744
|
+
contentType: (0, import_superstruct17.string)(),
|
|
745
|
+
contents: (0, import_superstruct17.string)()
|
|
746
|
+
});
|
|
737
747
|
var FormSubmitEventStruct = (0, import_superstruct17.assign)(
|
|
738
748
|
GenericEventStruct,
|
|
739
749
|
(0, import_superstruct17.object)({
|
|
740
750
|
type: (0, import_superstruct17.literal)("FormSubmitEvent" /* FormSubmitEvent */),
|
|
741
|
-
value: (0, import_superstruct17.record)((0, import_superstruct17.string)(), (0, import_superstruct17.nullable)((0, import_superstruct17.string)())),
|
|
751
|
+
value: (0, import_superstruct17.record)((0, import_superstruct17.string)(), (0, import_superstruct17.nullable)((0, import_superstruct17.union)([(0, import_superstruct17.string)(), FileStruct, (0, import_superstruct17.boolean)()]))),
|
|
742
752
|
name: (0, import_superstruct17.string)()
|
|
743
753
|
})
|
|
744
754
|
);
|
|
@@ -747,13 +757,22 @@ var InputChangeEventStruct = (0, import_superstruct17.assign)(
|
|
|
747
757
|
(0, import_superstruct17.object)({
|
|
748
758
|
type: (0, import_superstruct17.literal)("InputChangeEvent" /* InputChangeEvent */),
|
|
749
759
|
name: (0, import_superstruct17.string)(),
|
|
750
|
-
value: (0, import_superstruct17.string)()
|
|
760
|
+
value: (0, import_superstruct17.union)([(0, import_superstruct17.string)(), (0, import_superstruct17.boolean)()])
|
|
761
|
+
})
|
|
762
|
+
);
|
|
763
|
+
var FileUploadEventStruct = (0, import_superstruct17.assign)(
|
|
764
|
+
GenericEventStruct,
|
|
765
|
+
(0, import_superstruct17.object)({
|
|
766
|
+
type: (0, import_superstruct17.literal)("FileUploadEvent" /* FileUploadEvent */),
|
|
767
|
+
name: (0, import_superstruct17.string)(),
|
|
768
|
+
file: (0, import_superstruct17.nullable)(FileStruct)
|
|
751
769
|
})
|
|
752
770
|
);
|
|
753
771
|
var UserInputEventStruct = (0, import_superstruct17.union)([
|
|
754
772
|
ButtonClickEventStruct,
|
|
755
773
|
FormSubmitEventStruct,
|
|
756
|
-
InputChangeEventStruct
|
|
774
|
+
InputChangeEventStruct,
|
|
775
|
+
FileUploadEventStruct
|
|
757
776
|
]);
|
|
758
777
|
|
|
759
778
|
// src/types/methods/dialog.ts
|
|
@@ -795,9 +814,9 @@ var import_superstruct19 = require("superstruct");
|
|
|
795
814
|
var import_utils6 = require("@metamask/utils");
|
|
796
815
|
var import_superstruct18 = require("superstruct");
|
|
797
816
|
var KeyStruct = nullUnion([(0, import_superstruct18.string)(), (0, import_superstruct18.number)()]);
|
|
798
|
-
var StringElementStruct =
|
|
817
|
+
var StringElementStruct = children([
|
|
799
818
|
(0, import_superstruct18.string)()
|
|
800
|
-
);
|
|
819
|
+
]);
|
|
801
820
|
var ElementStruct = (0, import_superstruct18.object)({
|
|
802
821
|
type: (0, import_superstruct18.string)(),
|
|
803
822
|
props: (0, import_superstruct18.record)((0, import_superstruct18.string)(), import_utils6.JsonStruct),
|
|
@@ -810,8 +829,8 @@ function nestable(struct) {
|
|
|
810
829
|
]);
|
|
811
830
|
return nestableStruct;
|
|
812
831
|
}
|
|
813
|
-
function
|
|
814
|
-
return nestable(
|
|
832
|
+
function children(structs) {
|
|
833
|
+
return nestable((0, import_superstruct18.nullable)(nullUnion([...structs, (0, import_superstruct18.boolean)()])));
|
|
815
834
|
}
|
|
816
835
|
function element(name, props = {}) {
|
|
817
836
|
return (0, import_superstruct18.object)({
|
|
@@ -827,6 +846,12 @@ var ButtonStruct2 = element("Button", {
|
|
|
827
846
|
variant: (0, import_superstruct18.optional)(nullUnion([literal("primary"), literal("destructive")])),
|
|
828
847
|
disabled: (0, import_superstruct18.optional)((0, import_superstruct18.boolean)())
|
|
829
848
|
});
|
|
849
|
+
var CheckboxStruct = element("Checkbox", {
|
|
850
|
+
name: (0, import_superstruct18.string)(),
|
|
851
|
+
checked: (0, import_superstruct18.optional)((0, import_superstruct18.boolean)()),
|
|
852
|
+
label: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
853
|
+
variant: (0, import_superstruct18.optional)(nullUnion([literal("default"), literal("toggle")]))
|
|
854
|
+
});
|
|
830
855
|
var InputStruct2 = element("Input", {
|
|
831
856
|
name: (0, import_superstruct18.string)(),
|
|
832
857
|
type: (0, import_superstruct18.optional)(
|
|
@@ -842,42 +867,47 @@ var OptionStruct = element("Option", {
|
|
|
842
867
|
var DropdownStruct = element("Dropdown", {
|
|
843
868
|
name: (0, import_superstruct18.string)(),
|
|
844
869
|
value: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
845
|
-
children:
|
|
870
|
+
children: children([OptionStruct])
|
|
846
871
|
});
|
|
872
|
+
var FileInputStruct = element(
|
|
873
|
+
"FileInput",
|
|
874
|
+
{
|
|
875
|
+
name: (0, import_superstruct18.string)(),
|
|
876
|
+
accept: nullUnion([(0, import_superstruct18.optional)((0, import_superstruct18.array)((0, import_superstruct18.string)()))]),
|
|
877
|
+
compact: (0, import_superstruct18.optional)((0, import_superstruct18.boolean)())
|
|
878
|
+
}
|
|
879
|
+
);
|
|
847
880
|
var FieldStruct = element("Field", {
|
|
848
881
|
label: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
849
882
|
error: (0, import_superstruct18.optional)((0, import_superstruct18.string)()),
|
|
850
883
|
children: nullUnion([
|
|
851
884
|
(0, import_superstruct18.tuple)([InputStruct2, ButtonStruct2]),
|
|
885
|
+
DropdownStruct,
|
|
886
|
+
FileInputStruct,
|
|
852
887
|
InputStruct2,
|
|
853
|
-
|
|
888
|
+
CheckboxStruct
|
|
854
889
|
])
|
|
855
890
|
});
|
|
856
891
|
var FormStruct2 = element("Form", {
|
|
857
|
-
children:
|
|
892
|
+
children: children(
|
|
893
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
894
|
+
[FieldStruct, (0, import_superstruct18.lazy)(() => BoxChildStruct)]
|
|
895
|
+
),
|
|
858
896
|
name: (0, import_superstruct18.string)()
|
|
859
897
|
});
|
|
860
898
|
var BoldStruct = element("Bold", {
|
|
861
|
-
children:
|
|
862
|
-
(0, import_superstruct18.
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
(0, import_superstruct18.lazy)(() => ItalicStruct)
|
|
867
|
-
])
|
|
868
|
-
)
|
|
869
|
-
)
|
|
899
|
+
children: children([
|
|
900
|
+
(0, import_superstruct18.string)(),
|
|
901
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
902
|
+
(0, import_superstruct18.lazy)(() => ItalicStruct)
|
|
903
|
+
])
|
|
870
904
|
});
|
|
871
905
|
var ItalicStruct = element("Italic", {
|
|
872
|
-
children:
|
|
873
|
-
(0, import_superstruct18.
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
(0, import_superstruct18.lazy)(() => BoldStruct)
|
|
878
|
-
])
|
|
879
|
-
)
|
|
880
|
-
)
|
|
906
|
+
children: children([
|
|
907
|
+
(0, import_superstruct18.string)(),
|
|
908
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
909
|
+
(0, import_superstruct18.lazy)(() => BoldStruct)
|
|
910
|
+
])
|
|
881
911
|
});
|
|
882
912
|
var FormattingStruct = nullUnion([
|
|
883
913
|
BoldStruct,
|
|
@@ -887,9 +917,9 @@ var AddressStruct2 = element("Address", {
|
|
|
887
917
|
address: import_utils6.HexChecksumAddressStruct
|
|
888
918
|
});
|
|
889
919
|
var BoxStruct = element("Box", {
|
|
890
|
-
children:
|
|
920
|
+
children: children(
|
|
891
921
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
892
|
-
(0, import_superstruct18.
|
|
922
|
+
[(0, import_superstruct18.lazy)(() => BoxChildStruct)]
|
|
893
923
|
),
|
|
894
924
|
direction: (0, import_superstruct18.optional)(nullUnion([literal("horizontal"), literal("vertical")])),
|
|
895
925
|
alignment: (0, import_superstruct18.optional)(
|
|
@@ -920,13 +950,33 @@ var ImageStruct2 = element("Image", {
|
|
|
920
950
|
});
|
|
921
951
|
var LinkStruct = element("Link", {
|
|
922
952
|
href: (0, import_superstruct18.string)(),
|
|
923
|
-
children:
|
|
953
|
+
children: children([FormattingStruct, (0, import_superstruct18.string)()])
|
|
924
954
|
});
|
|
925
955
|
var TextStruct2 = element("Text", {
|
|
926
|
-
children:
|
|
927
|
-
|
|
956
|
+
children: children([(0, import_superstruct18.string)(), BoldStruct, ItalicStruct, LinkStruct]),
|
|
957
|
+
alignment: (0, import_superstruct18.optional)(
|
|
958
|
+
nullUnion([literal("start"), literal("center"), literal("end")])
|
|
928
959
|
)
|
|
929
960
|
});
|
|
961
|
+
var TooltipChildStruct = nullUnion([
|
|
962
|
+
TextStruct2,
|
|
963
|
+
BoldStruct,
|
|
964
|
+
ItalicStruct,
|
|
965
|
+
LinkStruct,
|
|
966
|
+
ImageStruct2,
|
|
967
|
+
(0, import_superstruct18.boolean)()
|
|
968
|
+
]);
|
|
969
|
+
var TooltipContentStruct = nullUnion([
|
|
970
|
+
TextStruct2,
|
|
971
|
+
BoldStruct,
|
|
972
|
+
ItalicStruct,
|
|
973
|
+
LinkStruct,
|
|
974
|
+
(0, import_superstruct18.string)()
|
|
975
|
+
]);
|
|
976
|
+
var TooltipStruct = element("Tooltip", {
|
|
977
|
+
children: (0, import_superstruct18.nullable)(TooltipChildStruct),
|
|
978
|
+
content: TooltipContentStruct
|
|
979
|
+
});
|
|
930
980
|
var RowStruct2 = element("Row", {
|
|
931
981
|
label: (0, import_superstruct18.string)(),
|
|
932
982
|
children: nullUnion([AddressStruct2, ImageStruct2, TextStruct2, ValueStruct]),
|
|
@@ -937,27 +987,31 @@ var RowStruct2 = element("Row", {
|
|
|
937
987
|
});
|
|
938
988
|
var SpinnerStruct2 = element("Spinner");
|
|
939
989
|
var BoxChildStruct = nullUnion([
|
|
940
|
-
ButtonStruct2,
|
|
941
|
-
InputStruct2,
|
|
942
|
-
FormStruct2,
|
|
943
|
-
BoldStruct,
|
|
944
|
-
ItalicStruct,
|
|
945
990
|
AddressStruct2,
|
|
991
|
+
BoldStruct,
|
|
946
992
|
BoxStruct,
|
|
993
|
+
ButtonStruct2,
|
|
947
994
|
CopyableStruct2,
|
|
948
995
|
DividerStruct2,
|
|
996
|
+
DropdownStruct,
|
|
997
|
+
FileInputStruct,
|
|
998
|
+
FormStruct2,
|
|
949
999
|
HeadingStruct2,
|
|
1000
|
+
InputStruct2,
|
|
950
1001
|
ImageStruct2,
|
|
1002
|
+
ItalicStruct,
|
|
951
1003
|
LinkStruct,
|
|
952
1004
|
RowStruct2,
|
|
953
1005
|
SpinnerStruct2,
|
|
954
1006
|
TextStruct2,
|
|
955
|
-
|
|
1007
|
+
TooltipStruct,
|
|
1008
|
+
CheckboxStruct
|
|
956
1009
|
]);
|
|
957
1010
|
var RootJSXElementStruct = BoxChildStruct;
|
|
958
1011
|
var JSXElementStruct = nullUnion([
|
|
959
1012
|
ButtonStruct2,
|
|
960
1013
|
InputStruct2,
|
|
1014
|
+
FileInputStruct,
|
|
961
1015
|
FieldStruct,
|
|
962
1016
|
FormStruct2,
|
|
963
1017
|
BoldStruct,
|
|
@@ -974,14 +1028,17 @@ var JSXElementStruct = nullUnion([
|
|
|
974
1028
|
TextStruct2,
|
|
975
1029
|
DropdownStruct,
|
|
976
1030
|
OptionStruct,
|
|
977
|
-
ValueStruct
|
|
1031
|
+
ValueStruct,
|
|
1032
|
+
TooltipStruct,
|
|
1033
|
+
CheckboxStruct
|
|
978
1034
|
]);
|
|
979
1035
|
|
|
980
1036
|
// src/types/interface.ts
|
|
981
|
-
var
|
|
1037
|
+
var StateStruct = (0, import_superstruct19.union)([FileStruct, (0, import_superstruct19.string)(), (0, import_superstruct19.boolean)()]);
|
|
1038
|
+
var FormStateStruct = (0, import_superstruct19.record)((0, import_superstruct19.string)(), (0, import_superstruct19.nullable)(StateStruct));
|
|
982
1039
|
var InterfaceStateStruct = (0, import_superstruct19.record)(
|
|
983
1040
|
(0, import_superstruct19.string)(),
|
|
984
|
-
(0, import_superstruct19.union)([FormStateStruct, (0, import_superstruct19.nullable)(
|
|
1041
|
+
(0, import_superstruct19.union)([FormStateStruct, (0, import_superstruct19.nullable)(StateStruct)])
|
|
985
1042
|
);
|
|
986
1043
|
var ComponentOrElementStruct = (0, import_superstruct19.union)([
|
|
987
1044
|
ComponentStruct,
|