-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathweb-component.tsx
76 lines (65 loc) · 1.91 KB
/
web-component.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* eslint-disable @typescript-eslint/consistent-type-definitions */
import toWebComponent from "@r2wc/react-to-web-component";
import { NewSkipClientOptions, Widget, WidgetProps } from "./widget/Widget";
const WEB_COMPONENT_NAME = "skip-widget";
type WebComponentProps = WidgetProps & NewSkipClientOptions;
type PropDescriptors = {
[K in keyof WebComponentProps]: "any";
};
const widgetPropTypes: Required<PropDescriptors> = {
rootId: "any",
theme: "any",
brandColor: "any",
onlyTestnet: "any",
defaultRoute: "any",
settings: "any",
routeConfig: "any",
filter: "any",
filterOut: "any",
filterOutUnlessUserHasBalance: "any",
walletConnect: "any",
enableSentrySessionReplays: "any",
enableAmplitudeAnalytics: "any",
connectedAddresses: "any",
simulate: "any",
disableShadowDom: "any",
ibcEurekaHighlightedAssets: "any",
assetSymbolsSortedToTop: "any",
hideAssetsUnlessWalletTypeConnected: "any",
apiUrl: "any",
apiKey: "any",
endpointOptions: "any",
aminoTypes: "any",
registryTypes: "any",
chainIdsToAffiliates: "any",
cacheDurationMs: "any",
getCosmosSigner: "any",
getEVMSigner: "any",
getSVMSigner: "any",
onWalletConnected: "any",
onWalletDisconnected: "any",
onTransactionBroadcasted: "any",
onTransactionComplete: "any",
onTransactionFailed: "any",
onRouteUpdated: "any",
};
const WebComponent = toWebComponent(Widget, {
// @ts-expect-error any is not one of the valid types but it works
props: widgetPropTypes,
});
function initializeSkipWidget() {
if (!customElements.get(WEB_COMPONENT_NAME)) {
customElements.define(WEB_COMPONENT_NAME, WebComponent);
}
// Upgrade any existing skip-widget elements
document.querySelectorAll(WEB_COMPONENT_NAME).forEach((el) => {
customElements.upgrade(el);
});
}
initializeSkipWidget();
export default WebComponent;
declare global {
interface HTMLElementTagNameMap {
[WEB_COMPONENT_NAME]: WidgetProps;
}
}