@@ -13,6 +13,7 @@ import { EventType } from '../core/Event';
1313 * @property {String } textTransform - If the button text should be transformed
1414 * (uppercase, lowercase, capitalize)
1515 * @property {Boolean } disabled - Whether the button is disabled
16+ * @property {String } popup - The associated popup to show when the button is clicked
1617 *
1718 * @example
1819 * <wc-button type="control">Close</wc-button>
@@ -30,6 +31,7 @@ export class ButtonElement extends LitElement {
3031 this . type = '' ;
3132 this . textTransform = '' ;
3233 this . disabled = false ;
34+ this . popup = '' ;
3335 }
3436
3537 static get properties ( ) {
@@ -38,6 +40,7 @@ export class ButtonElement extends LitElement {
3840 type : { type : String } ,
3941 textTransform : { type : String } ,
4042 disabled : { type : Boolean } ,
43+ popup : { type : String } ,
4144 } ;
4245 }
4346
@@ -103,25 +106,48 @@ export class ButtonElement extends LitElement {
103106 }
104107 }
105108
109+ firstUpdated ( ) {
110+ if ( this . popup ) {
111+ // Attach the popover target element
112+ const buttonNode = this . shadowRoot . querySelector ( 'button' ) ;
113+ const targetNode = document . getElementById ( this . popup ) ;
114+ if ( buttonNode && targetNode ) {
115+ buttonNode . popoverTargetElement = targetNode ;
116+ }
117+ }
118+ }
119+
106120 renderButton ( ) {
107121 return html `
108- < button class =${ this . classes . join ( ' ' ) || nothing } ?disabled =${ this . disabled } name=${ this . name || nothing } value=${ this . buttonTitle || nothing } @click=${ this . onClick } >
122+ < button class =${ this . classes . join ( ' ' ) || nothing }
123+ name =${ this . name || nothing } value=${ this . buttonTitle || nothing }
124+ ?disabled=${ this . disabled }
125+ @click=${ this . onClick } >
109126 < slot > </ slot >
110127 </ button >
111128 ` ;
112129 }
113130
114131 renderSubmit ( ) {
115132 return html `
116- < button class =${ this . classes . join ( ' ' ) || nothing } type ="submit" ?disabled=${ this . disabled } name=${ this . name || nothing } value=${ this . buttonTitle || nothing } @click=${ this . onClick } > < slot > </ slot > </ button >
133+ < button class =${ this . classes . join ( ' ' ) || nothing }
134+ type ="submit" ?disabled=${ this . disabled }
135+ name=${ this . name || nothing } value=${ this . buttonTitle || nothing }
136+ ?disabled=${ this . disabled }
137+ @click=${ this . onClick } >
138+ < slot > </ slot >
139+ </ button >
117140 ` ;
118141 }
119142
120143 renderControl ( ) {
121144 const icon = this . controlButtonIcon ;
122145 if ( icon ) {
123146 return html `
124- < button class =${ this . classes . join ( ' ' ) || nothing } ?disabled =${ this . disabled } name=${ this . name || nothing } value=${ this . buttonTitle || nothing } @click=${ this . onClick } >
147+ < button class =${ this . classes . join ( ' ' ) || nothing }
148+ name =${ this . name || nothing } value=${ this . buttonTitle || nothing }
149+ ?disabled=${ this . disabled }
150+ @click=${ this . onClick } >
125151 < wc-icon name =${ icon } > </ wc-icon >
126152 </ button >
127153 ` ;
0 commit comments