@@ -10,34 +10,45 @@ import {
1010import hasMoved from ' ../utils/has-moved.ts' ;
1111import { isTesting } from ' @embroider/macros' ;
1212import { modifier } from ' ember-modifier' ;
13- import type { Dropdown , TRootEventType } from './basic-dropdown.ts' ;
13+ import { element } from ' ember-element-helper' ;
14+ import { or } from ' ember-truth-helpers' ;
15+ import style from ' ember-style-modifier' ;
16+ import { on } from ' @ember/modifier' ;
17+ import { fn } from ' @ember/helper' ;
18+ import { hash } from ' @ember/helper' ;
19+ import type {
20+ Dropdown ,
21+ TRootEventType ,
22+ HorizontalPosition ,
23+ VerticalPosition ,
24+ } from ' ../types.ts' ;
1425
1526export interface BasicDropdownContentSignature {
16- Element : Element ;
27+ Element: HTMLElement ;
1728 Args: {
1829 animationEnabled? : boolean ;
1930 transitioningInClass? : string ;
2031 transitionedInClass? : string ;
2132 transitioningOutClass? : string ;
2233 isTouchDevice? : boolean ;
2334 destination? : string ;
24- destinationElement ?: HTMLElement ;
35+ destinationElement? : HTMLElement | null ;
2536 dropdown? : Dropdown ;
2637 renderInPlace? : boolean ;
27- preventScroll ?: boolean ;
38+ preventScroll? : boolean | undefined ;
2839 rootEventType? : TRootEventType ;
2940 top? : string | undefined ;
3041 left? : string | undefined ;
3142 right? : string | undefined ;
3243 width? : string | undefined ;
3344 height? : string | undefined ;
34- otherStyles ?: Record < string , string > ;
35- hPosition ?: string ;
36- vPosition ?: string ;
45+ otherStyles? : Record <string , string | number | undefined >;
46+ hPosition? : HorizontalPosition | null ;
47+ vPosition? : VerticalPosition | null ;
3748 dir? : string ;
3849 defaultClass? : string ;
3950 overlay? : boolean ;
40- htmlTag ?: string ;
51+ htmlTag? : keyof HTMLElementTagNameMap ;
4152 onFocusIn? : (dropdown ? : Dropdown , event ? : FocusEvent ) => void ;
4253 onFocusOut? : (dropdown ? : Dropdown , event ? : FocusEvent ) => void ;
4354 onMouseEnter? : (dropdown ? : Dropdown , event ? : MouseEvent ) => void ;
@@ -514,12 +525,94 @@ export default class BasicDropdownContent extends Component<BasicDropdownContent
514525 el .addEventListener (' scroll' , this .repositionBound );
515526 });
516527 }
528+
517529 removeScrollEvents(): void {
518530 window .removeEventListener (' scroll' , this .repositionBound );
519531 this .scrollableAncestors .forEach ((el ) => {
520532 el .removeEventListener (' scroll' , this .repositionBound );
521533 });
522534 }
535+
536+ <template >
537+ {{#if @ dropdown.isOpen }}
538+ <div
539+ class =" ember-basic-dropdown-content-wormhole-origin"
540+ {{this .registerDropdownContentWormhole }}
541+ >
542+ {{#if @ renderInPlace }}
543+ {{#if @ overlay }}
544+ <div class =" ember-basic-dropdown-overlay" ></div >
545+ {{/if }}
546+
547+ {{#let ( element ( or @ htmlTag " div" ) ) as | OptionalTag | }}
548+ <OptionalTag
549+ id ={{this .dropdownId }}
550+ class =" ember-basic-dropdown-content ember-basic-dropdown-content--{{@ hPosition }}
551+ ember-basic-dropdown-content--{{@ vPosition }}
552+ {{this .animationClass }}{{if
553+ @ renderInPlace
554+ ' ember-basic-dropdown-content--in-place'
555+ }}
556+ {{@ defaultClass }} "
557+ dir ={{@ dir }}
558+ ...attributes
559+ {{style @ otherStyles this . positionStyles}}
560+ {{this .respondToEvents }}
561+ {{this .initiallyReposition }}
562+ {{this .observeMutations }}
563+ {{this .animateInAndOut }}
564+ {{on " focusin" ( fn ( or @ onFocusIn this . noop) @ dropdown) }}
565+ {{on " focusout" ( fn ( or @ onFocusOut this . noop) @ dropdown) }}
566+ {{on " mouseenter" ( fn ( or @ onMouseEnter this . noop) @ dropdown) }}
567+ {{on " mouseleave" ( fn ( or @ onMouseLeave this . noop) @ dropdown) }}
568+ {{! V1 compatibility - See #498 }}
569+ >
570+ {{ yield }}
571+ </OptionalTag >
572+ {{/let }}
573+ {{else if this . destinationElement }}
574+ {{#in-element this . destinationElement insertBefore =null }}
575+ {{#if @ overlay }}
576+ <div class =" ember-basic-dropdown-overlay" ></div >
577+ {{/if }}
578+
579+ {{#let ( element ( or @ htmlTag " div" ) ) as | OptionalTag | }}
580+ <OptionalTag
581+ id ={{this .dropdownId }}
582+ class =" ember-basic-dropdown-content ember-basic-dropdown-content--{{@ hPosition }}
583+ ember-basic-dropdown-content--{{@ vPosition }}
584+ {{this .animationClass }}{{if
585+ @ renderInPlace
586+ ' ember-basic-dropdown-content--in-place'
587+ }}
588+ {{@ defaultClass }} "
589+ dir ={{@ dir }}
590+ ...attributes
591+ {{style @ otherStyles this . positionStyles}}
592+ {{this .respondToEvents }}
593+ {{this .initiallyReposition }}
594+ {{this .observeMutations }}
595+ {{this .animateInAndOut }}
596+ {{on " focusin" ( fn ( or @ onFocusIn this . noop) @ dropdown) }}
597+ {{on " focusout" ( fn ( or @ onFocusOut this . noop) @ dropdown) }}
598+ {{on " mouseenter" ( fn ( or @ onMouseEnter this . noop) @ dropdown) }}
599+ {{on " mouseleave" ( fn ( or @ onMouseLeave this . noop) @ dropdown) }}
600+ {{! V1 compatibility - See #498 }}
601+ >
602+ {{ yield }}
603+ </OptionalTag >
604+ {{/let }}
605+ {{/in-element }}
606+ {{/if }}
607+ </div >
608+ {{else }}
609+ <div
610+ id ={{this .dropdownId }}
611+ class =" ember-basic-dropdown-content-placeholder"
612+ {{style ( hash display =" none" ) }}
613+ ></div >
614+ {{/if }}
615+ </template >
523616}
524617
525618function containsRelevantMutation(nodeList : NodeList ): boolean {
0 commit comments