@@ -2,11 +2,12 @@ import {
2
2
UUIHorizontalShakeAnimationValue ,
3
3
UUIHorizontalShakeKeyframes ,
4
4
} from '@umbraco-ui/uui-base/lib/animations' ;
5
+ import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils' ;
5
6
import {
6
- demandCustomElement ,
7
- findAncestorByAttributeValue ,
8
- } from '@umbraco-ui/uui-base/lib/utils' ;
9
- import { FormControlMixin , LabelMixin } from '@umbraco-ui/uui-base/lib/mixins' ;
7
+ FormControlMixin ,
8
+ LabelMixin ,
9
+ PopoverTargetMixin ,
10
+ } from '@umbraco-ui/uui-base/lib/mixins' ;
10
11
import { defineElement } from '@umbraco-ui/uui-base/lib/registration' ;
11
12
import {
12
13
iconCheck ,
@@ -46,7 +47,7 @@ export type UUIButtonType = 'submit' | 'button' | 'reset';
46
47
*/
47
48
@defineElement ( 'uui-button' )
48
49
export class UUIButtonElement extends FormControlMixin (
49
- LabelMixin ( '' , LitElement )
50
+ LabelMixin ( '' , PopoverTargetMixin ( LitElement ) )
50
51
) {
51
52
static styles = [
52
53
UUIHorizontalShakeKeyframes ,
@@ -418,15 +419,6 @@ export class UUIButtonElement extends FormControlMixin(
418
419
@property ( { type : String } )
419
420
public href ?: string ;
420
421
421
- /**
422
- * Set a popovertarget.
423
- * @type {string }
424
- * @attr
425
- * @default undefined
426
- */
427
- @property ( { type : String , attribute : 'popovertarget' } )
428
- public popoverContainerElement ?: string ;
429
-
430
422
/**
431
423
* Set an anchor tag target, only used when using href.
432
424
* @type {string }
@@ -439,12 +431,9 @@ export class UUIButtonElement extends FormControlMixin(
439
431
@query ( '#button' )
440
432
protected _button ! : HTMLInputElement ;
441
433
442
- #popoverIsOpen = false ;
443
-
444
434
constructor ( ) {
445
435
super ( ) ;
446
436
this . addEventListener ( 'click' , this . _onHostClick ) ;
447
- this . addEventListener ( 'uui-popover-before-toggle' , this . #popoverListener) ;
448
437
}
449
438
450
439
protected getFormElement ( ) : HTMLElement {
@@ -475,7 +464,7 @@ export class UUIButtonElement extends FormControlMixin(
475
464
}
476
465
}
477
466
478
- this . #updatePopover ( ) ;
467
+ this . _togglePopover ( ) ;
479
468
}
480
469
481
470
private _resetStateTimeout ?: number ;
@@ -520,30 +509,6 @@ export class UUIButtonElement extends FormControlMixin(
520
509
return html `< div id ="state "> ${ element } </ div > ` ;
521
510
}
522
511
523
- #popoverListener = ( event : any ) => {
524
- // Wait for the click event to finish before updating the popover state
525
- requestAnimationFrame ( ( ) => {
526
- this . #popoverIsOpen = event . detail . newState === 'open' ;
527
- } ) ;
528
- } ;
529
-
530
- #updatePopover = ( ) => {
531
- if ( ! this . popoverContainerElement ) return ;
532
-
533
- const popoverContainerElement = findAncestorByAttributeValue (
534
- this ,
535
- 'id' ,
536
- this . popoverContainerElement
537
- ) ;
538
- if ( ! popoverContainerElement ) return ;
539
-
540
- this . #popoverIsOpen
541
- ? // @ts -ignore - This is part of the new popover API, but typescript doesn't recognize it yet.
542
- popoverContainerElement . hidePopover ( )
543
- : // @ts -ignore - This is part of the new popover API, but typescript doesn't recognize it yet.
544
- popoverContainerElement . showPopover ( ) ;
545
- } ;
546
-
547
512
render ( ) {
548
513
return this . href
549
514
? html `
0 commit comments