@@ -10,16 +10,16 @@ const speicalSyles = [ ButtonStyle.Spinner, ButtonStyle.Progress ];
1010const enableTuple = ( enabled : boolean , color = Color . Grayscaled ) => [ Color . Disabled , color ] [ enabled ? "values" : "reverse" ] ( ) as [ Color , Color ] ;
1111
1212export class ButtonComponent extends ColoredComponent {
13- prog = createElement ( "div" )
13+ prog = createElement ( "div" ) ;
1414 constructor ( string : string | Component ) {
1515 super ( ) ;
1616 this . wrapper . tabIndex = speicalSyles . includes ( ButtonStyle . Normal ) ? - 1 : accessibilityDisableTabOnDisabled ( ) ;
17- this . wrapper . classList . add ( "wbutton" , Color . Grayscaled , ButtonStyle . Normal )
17+ this . wrapper . classList . add ( "wbutton" , Color . Grayscaled , ButtonStyle . Normal ) ;
1818 this . wrapper . append ( loadingWheel ( ) ) ;
19- this . wrapper . onkeydown = accessibilityButton ( this . wrapper )
19+ this . wrapper . onkeydown = accessibilityButton ( this . wrapper ) ;
2020 this . wrapper . append ( typeof string == "string" ? string : string . draw ( ) ) ;
2121 }
22- setEnabled = ( enabled : boolean ) => this . wrapper . classList . replace ( ...enableTuple ( enabled ) )
22+ setEnabled = ( enabled : boolean ) => this . wrapper . classList . replace ( ...enableTuple ( enabled ) ) ;
2323 setStyle ( style : ButtonStyle , progress ?: number ) {
2424 this . wrapper . tabIndex = speicalSyles . includes ( style ) ? - 1 : accessibilityDisableTabOnDisabled ( ) ;
2525 changeClassAtIndex ( this . wrapper , style , 2 ) ;
@@ -42,8 +42,10 @@ export class ButtonComponent extends ColoredComponent {
4242 this . wrapper . style . justifyContent = type ;
4343 return this ;
4444 }
45- asLinkButton ( link : string ) : ButtonComponent {
46- this . wrapper . href = link ;
45+ asLinkButton ( url : string , target ?: string ) {
46+ this . wrapper . href = url ;
47+ if ( target )
48+ this . wrapper . target = target ;
4749 return this ;
4850 }
4951 setGrow ( value = 1 ) {
@@ -53,19 +55,19 @@ export class ButtonComponent extends ColoredComponent {
5355 onPromiseClick ( func : ( env : MouseEvent , e : ButtonComponent ) => Promise < void > ) {
5456 this . onClick ( async ( env , e ) => {
5557 const cssclass = this . wrapper . classList . item ( 2 ) ;
56- this . setStyle ( ButtonStyle . Spinner )
58+ this . setStyle ( ButtonStyle . Spinner ) ;
5759 await func ( env , e ) ;
5860 this . setStyle ( cssclass as ButtonStyle ) ;
59- } )
61+ } ) ;
6062 return this ;
6163 }
6264 onClick ( func : ( env : MouseEvent , e : ButtonComponent ) => void ) {
6365 if ( this . wrapper . classList . contains ( Color . Disabled ) ) return this ;
64- this . wrapper . addEventListener ( 'click' , ( e ) => func ( e , this ) )
66+ this . wrapper . addEventListener ( 'click' , ( e ) => func ( e , this ) ) ;
6567 return this ;
6668 }
6769 setColor ( color : Color ) {
68- this . setEnabled = ( enabled : boolean ) => this . wrapper . classList . replace ( ...enableTuple ( enabled , color ) )
70+ this . setEnabled = ( enabled : boolean ) => this . wrapper . classList . replace ( ...enableTuple ( enabled , color ) ) ;
6971 this . wrapper . tabIndex = speicalSyles . includes ( this . wrapper . classList [ 3 ] as ButtonStyle ) ? - 1 : accessibilityDisableTabOnDisabled ( color ) ;
7072 changeClassAtIndex ( this . wrapper , color , 1 ) ;
7173 return this ;
0 commit comments