@@ -15,6 +15,7 @@ import { LoggerService, queryListAndChanges$, SubscriptionLifecycle, TypedSimple
1515import { EMPTY , merge , Observable , of } from 'rxjs' ;
1616import { map , switchMap } from 'rxjs/operators' ;
1717import { IconSize } from '../icon/icon-size' ;
18+ import { SelectControlOptionComponent , SelectControlOptionPosition } from './select-control-option.component' ;
1819import { SelectGroupPosition } from './select-group-position' ;
1920import { SelectJustify } from './select-justify' ;
2021import { SelectOption } from './select-option' ;
@@ -74,22 +75,38 @@ import { SelectSize } from './select-size';
7475 </ht-popover-trigger>
7576 <ht-popover-content>
7677 <div class="select-content" [ngStyle]="{ 'minWidth.px': triggerContainer.offsetWidth }">
78+ <ng-container *htLetAsync="this.topControlItems$ as topControlItems">
79+ <div *ngIf="topControlItems?.length !== 0">
80+ <ng-container
81+ *ngTemplateOutlet="itemsTemplate; context: { items: topControlItems, showSelectionStatus: false }"
82+ ></ng-container>
83+
84+ <ht-divider></ht-divider>
85+ </div>
86+ </ng-container>
87+
88+ <ng-container
89+ *ngTemplateOutlet="itemsTemplate; context: { items: items, showSelectionStatus: true }"
90+ ></ng-container>
91+ </div>
92+
93+ <ng-template #itemsTemplate let-items="items" let-showSelectionStatus="showSelectionStatus">
7794 <div
7895 *ngFor="let item of items"
7996 (click)="this.onSelectionChange(item)"
8097 class="select-option"
8198 [ngClass]="this.size"
8299 >
100+ <ht-icon *ngIf="item.icon" class="icon" [icon]="item.icon" size="${ IconSize . Small } "> </ht-icon>
83101 <span class="label">{{ item.label }}</span>
84102 <ht-icon
85103 class="status-icon"
86- *ngIf="this.highlightSelected && this.isSelectedItem(item)"
104+ *ngIf="showSelectionStatus && this.highlightSelected && this.isSelectedItem(item)"
87105 icon="${ IconType . Checkmark } "
88106 size="${ IconSize . Small } "
89- >
90- </ht-icon>
107+ ></ht-icon>
91108 </div>
92- </div >
109+ </ng-template >
93110 </ht-popover-content>
94111 </ht-popover>
95112 </div>
@@ -132,10 +149,15 @@ export class SelectComponent<V> implements AfterContentInit, OnChanges {
132149 @ContentChildren ( SelectOptionComponent )
133150 public items ?: QueryList < SelectOptionComponent < V > > ;
134151
152+ @ContentChildren ( SelectControlOptionComponent )
153+ public controlItems ?: QueryList < SelectControlOptionComponent < V > > ;
154+
135155 public selected$ ?: Observable < SelectOption < V > | undefined > ;
136156
137157 public groupPosition : SelectGroupPosition = SelectGroupPosition . Ungrouped ;
138158
159+ public topControlItems$ ?: Observable < SelectControlOptionComponent < V > [ ] > ;
160+
139161 public get justifyClass ( ) : string {
140162 if ( this . justify !== undefined ) {
141163 return this . justify ;
@@ -151,6 +173,11 @@ export class SelectComponent<V> implements AfterContentInit, OnChanges {
151173
152174 public ngAfterContentInit ( ) : void {
153175 this . selected$ = this . buildObservableOfSelected ( ) ;
176+ if ( this . controlItems !== undefined ) {
177+ this . topControlItems$ = queryListAndChanges$ ( this . controlItems ) . pipe (
178+ map ( items => items . filter ( item => item . position === SelectControlOptionPosition . Top ) )
179+ ) ;
180+ }
154181 }
155182
156183 public ngOnChanges ( changes : TypedSimpleChanges < this> ) : void {
0 commit comments