@metamask/snaps-sdk 6.2.1 → 6.3.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/dist/index.mjs CHANGED
@@ -808,6 +808,187 @@ import {
808
808
  } from "@metamask/superstruct";
809
809
  import { JsonStruct as JsonStruct2 } from "@metamask/utils";
810
810
 
811
+ // src/jsx/component.ts
812
+ function removeUndefinedProps(props) {
813
+ return Object.fromEntries(
814
+ Object.entries(props).filter(([, value]) => value !== void 0)
815
+ );
816
+ }
817
+ function createSnapComponent(type) {
818
+ return (props) => {
819
+ const { key = null, ...rest } = props;
820
+ return {
821
+ type,
822
+ props: removeUndefinedProps(rest),
823
+ key
824
+ };
825
+ };
826
+ }
827
+
828
+ // src/jsx/components/Icon.ts
829
+ var IconName = /* @__PURE__ */ ((IconName2) => {
830
+ IconName2["AddSquare"] = "add-square";
831
+ IconName2["Add"] = "add";
832
+ IconName2["Arrow2Down"] = "arrow-2-down";
833
+ IconName2["Arrow2Left"] = "arrow-2-left";
834
+ IconName2["Arrow2Right"] = "arrow-2-right";
835
+ IconName2["Arrow2Up"] = "arrow-2-up";
836
+ IconName2["Arrow2UpRight"] = "arrow-2-up-right";
837
+ IconName2["ArrowDoubleLeft"] = "arrow-double-left";
838
+ IconName2["ArrowDoubleRight"] = "arrow-double-right";
839
+ IconName2["ArrowDown"] = "arrow-down";
840
+ IconName2["ArrowLeft"] = "arrow-left";
841
+ IconName2["ArrowRight"] = "arrow-right";
842
+ IconName2["ArrowUp"] = "arrow-up";
843
+ IconName2["BankToken"] = "bank-token";
844
+ IconName2["Bank"] = "bank";
845
+ IconName2["Book"] = "book";
846
+ IconName2["Bookmark"] = "bookmark";
847
+ IconName2["Bridge"] = "bridge";
848
+ IconName2["Calculator"] = "calculator";
849
+ IconName2["CardPos"] = "card-pos";
850
+ IconName2["CardToken"] = "card-token";
851
+ IconName2["Card"] = "card";
852
+ IconName2["Category"] = "category";
853
+ IconName2["Chart"] = "chart";
854
+ IconName2["CheckBold"] = "check-bold";
855
+ IconName2["Check"] = "check";
856
+ IconName2["Clock"] = "clock";
857
+ IconName2["Close"] = "close";
858
+ IconName2["CodeCircle"] = "code-circle";
859
+ IconName2["Coin"] = "coin";
860
+ IconName2["Confirmation"] = "confirmation";
861
+ IconName2["Connect"] = "connect";
862
+ IconName2["CopySuccess"] = "copy-success";
863
+ IconName2["Copy"] = "copy";
864
+ IconName2["Customize"] = "customize";
865
+ IconName2["Danger"] = "danger";
866
+ IconName2["Dark"] = "dark";
867
+ IconName2["Data"] = "data";
868
+ IconName2["Diagram"] = "diagram";
869
+ IconName2["DocumentCode"] = "document-code";
870
+ IconName2["DragDrop"] = "drag-drop";
871
+ IconName2["DraggingAnimation"] = "dragging-animation";
872
+ IconName2["PinningAnimation"] = "pinning-animation";
873
+ IconName2["Edit"] = "edit";
874
+ IconName2["Eraser"] = "eraser";
875
+ IconName2["Ethereum"] = "ethereum";
876
+ IconName2["Expand"] = "expand";
877
+ IconName2["Explore"] = "explore";
878
+ IconName2["Export"] = "export";
879
+ IconName2["EyeSlash"] = "eye-slash";
880
+ IconName2["Eye"] = "eye";
881
+ IconName2["Filter"] = "filter";
882
+ IconName2["Flag"] = "flag";
883
+ IconName2["FlashSlash"] = "flash-slash";
884
+ IconName2["Flash"] = "flash";
885
+ IconName2["FullCircle"] = "full-circle";
886
+ IconName2["Gas"] = "gas";
887
+ IconName2["GlobalSearch"] = "global-search";
888
+ IconName2["Global"] = "global";
889
+ IconName2["Graph"] = "graph";
890
+ IconName2["Hardware"] = "hardware";
891
+ IconName2["Heart"] = "heart";
892
+ IconName2["Hierarchy"] = "hierarchy";
893
+ IconName2["Home"] = "home";
894
+ IconName2["Import"] = "import";
895
+ IconName2["Info"] = "info";
896
+ IconName2["Key"] = "key";
897
+ IconName2["Light"] = "light";
898
+ IconName2["Link"] = "link";
899
+ IconName2["Loading"] = "loading";
900
+ IconName2["LockCircle"] = "lock-circle";
901
+ IconName2["LockSlash"] = "lock-slash";
902
+ IconName2["Lock"] = "lock";
903
+ IconName2["Login"] = "login";
904
+ IconName2["Logout"] = "logout";
905
+ IconName2["Menu"] = "menu";
906
+ IconName2["MessageQuestion"] = "message-question";
907
+ IconName2["Messages"] = "messages";
908
+ IconName2["MinusBold"] = "minus-bold";
909
+ IconName2["MinusSquare"] = "minus-square";
910
+ IconName2["Minus"] = "minus";
911
+ IconName2["Mobile"] = "mobile";
912
+ IconName2["Money"] = "money";
913
+ IconName2["Monitor"] = "monitor";
914
+ IconName2["MoreHorizontal"] = "more-horizontal";
915
+ IconName2["MoreVertical"] = "more-vertical";
916
+ IconName2["NotificationCircle"] = "notification-circle";
917
+ IconName2["Notification"] = "notification";
918
+ IconName2["PasswordCheck"] = "password-check";
919
+ IconName2["People"] = "people";
920
+ IconName2["Pin"] = "pin";
921
+ IconName2["ProgrammingArrows"] = "programming-arrows";
922
+ IconName2["Custody"] = "custody";
923
+ IconName2["Question"] = "question";
924
+ IconName2["Received"] = "received";
925
+ IconName2["Refresh"] = "refresh";
926
+ IconName2["Save"] = "save";
927
+ IconName2["ScanBarcode"] = "scan-barcode";
928
+ IconName2["ScanFocus"] = "scan-focus";
929
+ IconName2["Scan"] = "scan";
930
+ IconName2["Scroll"] = "scroll";
931
+ IconName2["Search"] = "search";
932
+ IconName2["SecurityCard"] = "security-card";
933
+ IconName2["SecurityCross"] = "security-cross";
934
+ IconName2["SecurityKey"] = "security-key";
935
+ IconName2["SecuritySearch"] = "security-search";
936
+ IconName2["SecuritySlash"] = "security-slash";
937
+ IconName2["SecurityTick"] = "security-tick";
938
+ IconName2["SecurityTime"] = "security-time";
939
+ IconName2["SecurityUser"] = "security-user";
940
+ IconName2["Security"] = "security";
941
+ IconName2["Send1"] = "send-1";
942
+ IconName2["Send2"] = "send-2";
943
+ IconName2["Setting"] = "setting";
944
+ IconName2["Slash"] = "slash";
945
+ IconName2["SnapsMobile"] = "snaps-mobile";
946
+ IconName2["SnapsPlus"] = "snaps-plus";
947
+ IconName2["Snaps"] = "snaps";
948
+ IconName2["Speedometer"] = "speedometer";
949
+ IconName2["Star"] = "star";
950
+ IconName2["Stake"] = "stake";
951
+ IconName2["Student"] = "student";
952
+ IconName2["SwapHorizontal"] = "swap-horizontal";
953
+ IconName2["SwapVertical"] = "swap-vertical";
954
+ IconName2["Tag"] = "tag";
955
+ IconName2["Tilde"] = "tilde";
956
+ IconName2["Timer"] = "timer";
957
+ IconName2["Trash"] = "trash";
958
+ IconName2["TrendDown"] = "trend-down";
959
+ IconName2["TrendUp"] = "trend-up";
960
+ IconName2["UserCircleAdd"] = "user-circle-add";
961
+ IconName2["UserCircleLink"] = "user-circle-link";
962
+ IconName2["UserCircleRemove"] = "user-circle-remove";
963
+ IconName2["UserCircle"] = "user-circle";
964
+ IconName2["User"] = "user";
965
+ IconName2["WalletCard"] = "wallet-card";
966
+ IconName2["WalletMoney"] = "wallet-money";
967
+ IconName2["Wallet"] = "wallet";
968
+ IconName2["Warning"] = "warning";
969
+ IconName2["Twitter"] = "twitter";
970
+ IconName2["QrCode"] = "qr-code";
971
+ IconName2["UserCheck"] = "user-check";
972
+ IconName2["Unpin"] = "unpin";
973
+ IconName2["Ban"] = "ban";
974
+ IconName2["Bold"] = "bold";
975
+ IconName2["CircleX"] = "circle-x";
976
+ IconName2["Download"] = "download";
977
+ IconName2["FileIcon"] = "file";
978
+ IconName2["Flask"] = "flask";
979
+ IconName2["Plug"] = "plug";
980
+ IconName2["Share"] = "share";
981
+ IconName2["Square"] = "square";
982
+ IconName2["Tint"] = "tint";
983
+ IconName2["Upload"] = "upload";
984
+ IconName2["Usb"] = "usb";
985
+ IconName2["Wifi"] = "wifi";
986
+ IconName2["PlusMinus"] = "plus-minus";
987
+ return IconName2;
988
+ })(IconName || {});
989
+ var TYPE = "Icon";
990
+ var Icon = createSnapComponent(TYPE);
991
+
811
992
  // src/jsx/validation.ts
812
993
  import {
813
994
  is as is3,
@@ -854,8 +1035,22 @@ function element(name, props = {}) {
854
1035
  key: nullable2(KeyStruct)
855
1036
  });
856
1037
  }
1038
+ var ImageStruct2 = element("Image", {
1039
+ src: svg(),
1040
+ alt: optional7(string11())
1041
+ });
1042
+ var IconNameStruct = nullUnion(
1043
+ Object.values(IconName).map((name) => literal(name))
1044
+ );
1045
+ var IconStruct = element("Icon", {
1046
+ name: IconNameStruct,
1047
+ color: optional7(
1048
+ nullUnion([literal("default"), literal("primary"), literal("muted")])
1049
+ ),
1050
+ size: optional7(nullUnion([literal("md"), literal("inherit")]))
1051
+ });
857
1052
  var ButtonStruct2 = element("Button", {
858
- children: StringElementStruct,
1053
+ children: children([StringElementStruct, ImageStruct2, IconStruct]),
859
1054
  name: optional7(string11()),
860
1055
  type: optional7(nullUnion([literal("button"), literal("submit")])),
861
1056
  variant: optional7(nullUnion([literal("primary"), literal("destructive")])),
@@ -877,13 +1072,33 @@ var InputStruct2 = element("Input", {
877
1072
  });
878
1073
  var OptionStruct = element("Option", {
879
1074
  value: string11(),
880
- children: string11()
1075
+ children: nullUnion([string11()])
881
1076
  });
882
1077
  var DropdownStruct = element("Dropdown", {
883
1078
  name: string11(),
884
1079
  value: optional7(string11()),
885
1080
  children: children([OptionStruct])
886
1081
  });
1082
+ var CardStruct = element("Card", {
1083
+ image: optional7(string11()),
1084
+ title: string11(),
1085
+ description: optional7(string11()),
1086
+ value: string11(),
1087
+ extra: optional7(string11())
1088
+ });
1089
+ var SelectorOptionStruct = element(
1090
+ "SelectorOption",
1091
+ {
1092
+ value: string11(),
1093
+ children: CardStruct
1094
+ }
1095
+ );
1096
+ var SelectorStruct = element("Selector", {
1097
+ name: string11(),
1098
+ title: string11(),
1099
+ value: optional7(string11()),
1100
+ children: children([SelectorOptionStruct])
1101
+ });
887
1102
  var RadioStruct = element("Radio", {
888
1103
  value: string11(),
889
1104
  children: string11()
@@ -910,7 +1125,8 @@ var FIELD_CHILDREN_ARRAY = [
910
1125
  DropdownStruct,
911
1126
  RadioGroupStruct,
912
1127
  FileInputStruct,
913
- CheckboxStruct
1128
+ CheckboxStruct,
1129
+ SelectorStruct
914
1130
  ];
915
1131
  var FieldChildUnionStruct = nullUnion([
916
1132
  ...FIELD_CHILDREN_ARRAY,
@@ -997,28 +1213,33 @@ var ValueStruct = element("Value", {
997
1213
  value: string11(),
998
1214
  extra: string11()
999
1215
  });
1000
- var CardStruct = element("Card", {
1001
- image: optional7(string11()),
1002
- title: string11(),
1003
- description: optional7(string11()),
1004
- value: string11(),
1005
- extra: optional7(string11())
1006
- });
1007
1216
  var HeadingStruct2 = element("Heading", {
1008
1217
  children: StringElementStruct
1009
1218
  });
1010
- var ImageStruct2 = element("Image", {
1011
- src: svg(),
1012
- alt: optional7(string11())
1013
- });
1014
1219
  var LinkStruct = element("Link", {
1015
1220
  href: string11(),
1016
1221
  children: children([FormattingStruct, string11()])
1017
1222
  });
1018
1223
  var TextStruct2 = element("Text", {
1019
- children: children([string11(), BoldStruct, ItalicStruct, LinkStruct]),
1224
+ children: children([
1225
+ string11(),
1226
+ BoldStruct,
1227
+ ItalicStruct,
1228
+ LinkStruct,
1229
+ IconStruct
1230
+ ]),
1020
1231
  alignment: optional7(
1021
1232
  nullUnion([literal("start"), literal("center"), literal("end")])
1233
+ ),
1234
+ color: optional7(
1235
+ nullUnion([
1236
+ literal("default"),
1237
+ literal("alternative"),
1238
+ literal("muted"),
1239
+ literal("error"),
1240
+ literal("success"),
1241
+ literal("warning")
1242
+ ])
1022
1243
  )
1023
1244
  });
1024
1245
  var TooltipChildStruct = nullUnion([
@@ -1027,6 +1248,7 @@ var TooltipChildStruct = nullUnion([
1027
1248
  ItalicStruct,
1028
1249
  LinkStruct,
1029
1250
  ImageStruct2,
1251
+ IconStruct,
1030
1252
  boolean4()
1031
1253
  ]);
1032
1254
  var TooltipContentStruct = nullUnion([
@@ -1034,6 +1256,7 @@ var TooltipContentStruct = nullUnion([
1034
1256
  BoldStruct,
1035
1257
  ItalicStruct,
1036
1258
  LinkStruct,
1259
+ IconStruct,
1037
1260
  string11()
1038
1261
  ]);
1039
1262
  var TooltipStruct = element("Tooltip", {
@@ -1070,7 +1293,9 @@ var BoxChildStruct = typedUnion([
1070
1293
  TextStruct2,
1071
1294
  TooltipStruct,
1072
1295
  CheckboxStruct,
1073
- CardStruct
1296
+ CardStruct,
1297
+ IconStruct,
1298
+ SelectorStruct
1074
1299
  ]);
1075
1300
  var RootJSXElementStruct = nullUnion([
1076
1301
  BoxChildStruct,
@@ -1103,7 +1328,10 @@ var JSXElementStruct = typedUnion([
1103
1328
  CheckboxStruct,
1104
1329
  FooterStruct,
1105
1330
  ContainerStruct,
1106
- CardStruct
1331
+ CardStruct,
1332
+ IconStruct,
1333
+ SelectorStruct,
1334
+ SelectorOptionStruct
1107
1335
  ]);
1108
1336
 
1109
1337
  // src/types/interface.ts