File tree Expand file tree Collapse file tree 4 files changed +21
-7
lines changed
Expand file tree Collapse file tree 4 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,14 @@ const App: Component<AppProps> = props => {
3333 < ConnectorContext . Provider value = { appState . connector } >
3434 < GlobalStyles />
3535 < ThemeProvider theme = { themeState } >
36- < Show when = { appState . buttonRootId } >
37- < Portal mount = { document . getElementById ( appState . buttonRootId ! ) ! } >
38- < AccountButton />
39- </ Portal >
36+ < Show when = { Array . isArray ( appState . buttonRootId ) && appState . buttonRootId . length > 0 } >
37+ < >
38+ { appState . buttonRootId && ( appState . buttonRootId as string [ ] ) . map ( ( id ) => (
39+ < Portal mount = { document . getElementById ( id ) ! } >
40+ < AccountButton />
41+ </ Portal >
42+ ) ) }
43+ </ >
4044 </ Show >
4145 < Dynamic component = { globalStylesTag } >
4246 < WalletsModal />
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { Loadable } from 'src/models/loadable';
77
88export type AppState = {
99 connector : ITonConnect ;
10- buttonRootId : string | null ;
10+ buttonRootId : string | null | string [ ] ;
1111 language : Locales ;
1212 walletsListConfiguration : WalletsListConfiguration | { } ;
1313 connectRequestParameters ?: Loadable < ConnectAdditionalRequest > | null ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export interface TonConnectUiOptions {
1414 * HTML element id to attach the wallet connect button. If not passed button won't appear.
1515 * @default null.
1616 */
17- buttonRootId ?: string | null ;
17+ buttonRootId ?: string | null | string [ ] ;
1818
1919 /**
2020 * Language for the phrases it the UI elements.
Original file line number Diff line number Diff line change @@ -993,11 +993,21 @@ export class TonConnectUI {
993993 return rootId ;
994994 }
995995
996- private checkButtonRootExist ( buttonRootId : string | null | undefined ) : void | never {
996+ private checkButtonRootExist ( buttonRootId : string | string [ ] | null | undefined ) : void | never {
997997 if ( buttonRootId == null ) {
998998 return ;
999999 }
10001000
1001+ if ( Array . isArray ( buttonRootId ) ) {
1002+ for ( const buttonId of buttonRootId ) {
1003+ if ( document . getElementById ( buttonId ) ) {
1004+ return ;
1005+ }
1006+ }
1007+
1008+ throw new TonConnectUIError ( `${ buttonRootId } element not found in the document.` ) ;
1009+ }
1010+
10011011 if ( ! document . getElementById ( buttonRootId ) ) {
10021012 throw new TonConnectUIError ( `${ buttonRootId } element not found in the document.` ) ;
10031013 }
You can’t perform that action at this time.
0 commit comments