@@ -40,7 +40,13 @@ import { Observable } from "rxjs";
4040@Component ( {
4141 selector : "cds-combo-box, ibm-combo-box" ,
4242 template : `
43- <div class="cds--list-box__wrapper">
43+ <div
44+ class="cds--list-box__wrapper"
45+ [ngClass]="{
46+ 'cds--list-box__wrapper--fluid': fluid,
47+ 'cds--list-box__wrapper--fluid--invalid': fluid && invalid,
48+ 'cds--list-box__wrapper--fluid--focus': fluid && _isFocused
49+ }">
4450 <label
4551 *ngIf="label"
4652 [for]="id"
@@ -64,7 +70,8 @@ import { Observable } from "rxjs";
6470 'cds--list-box--lg': size === 'lg',
6571 'cds--list-box--disabled': disabled,
6672 'cds--combo-box--readonly': readonly,
67- 'cds--combo-box--warning cds--list-box--warning': warn
73+ 'cds--combo-box--warning cds--list-box--warning': warn,
74+ 'cds--list-box--invalid': invalid
6875 }"
6976 class="cds--list-box cds--combo-box"
7077 [attr.data-invalid]="(invalid ? true : null)">
@@ -109,7 +116,8 @@ import { Observable } from "rxjs";
109116 [disabled]="disabled"
110117 [readOnly]="readonly"
111118 (input)="onSearch($event.target.value)"
112- (blur)="onBlur()"
119+ (focus)="fluid ? handleFocus($event) : null"
120+ (blur)="fluid ? handleFocus($event) : onBlur()"
113121 (keydown.enter)="onSubmit($event)"
114122 [value]="selectedValue"
115123 class="cds--text-input"
@@ -166,8 +174,9 @@ import { Observable } from "rxjs";
166174 <ng-content *ngIf="open"></ng-content>
167175 </div>
168176 </div>
177+ <hr *ngIf="fluid" class="cds--list-box__divider" />
169178 <div
170- *ngIf="helperText && !invalid && !warn"
179+ *ngIf="helperText && !invalid && !warn && !fluid "
171180 class="cds--form__helper-text"
172181 [ngClass]="{'cds--form__helper-text--disabled': disabled}">
173182 <ng-container *ngIf="!isTemplate(helperText)">{{helperText}}</ng-container>
@@ -368,6 +377,10 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
368377 * Set to `true` for readonly state.
369378 */
370379 @Input ( ) readonly = false ;
380+ /**
381+ * Experimental: enable fluid state
382+ */
383+ @Input ( ) fluid = false ;
371384 /**
372385 * Emits a ListItem
373386 *
@@ -426,7 +439,6 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
426439 @ViewChild ( "input" , { static : true } ) input : ElementRef ;
427440 @ViewChild ( "listbox" , { static : true } ) listbox : ElementRef ;
428441 @HostBinding ( "class.cds--list-box__wrapper" ) hostClass = true ;
429- @HostBinding ( "style.display" ) display = "block" ;
430442
431443 public open = false ;
432444
@@ -456,6 +468,8 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
456468 protected _clearSelectionTitle = this . i18n . getOverridable ( "COMBOBOX.CLEAR_SELECTED" ) ;
457469 protected _clearSelectionAria = this . i18n . getOverridable ( "COMBOBOX.A11Y.CLEAR_SELECTED" ) ;
458470
471+ protected _isFocused = false ;
472+
459473 /**
460474 * Creates an instance of ComboBox.
461475 */
@@ -680,7 +694,15 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
680694 // clearSelected can only fire on type=multi
681695 // so we just emit getSelected() (just in case there's any disabled but selected items)
682696 const selected = this . view . getSelected ( ) ;
683- this . propagateChangeCallback ( selected ) ;
697+
698+ // in case there are disabled items they should be mapped according to itemValueKey
699+ if ( this . itemValueKey && selected ) {
700+ const values = selected . map ( ( item ) => item [ this . itemValueKey ] ) ;
701+ this . propagateChangeCallback ( values ) ;
702+ } else {
703+ this . propagateChangeCallback ( selected ) ;
704+ }
705+
684706 this . selected . emit ( selected as any ) ;
685707 this . clear . emit ( event ) ;
686708 }
@@ -877,6 +899,10 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
877899 }
878900 }
879901
902+ handleFocus ( event : FocusEvent ) {
903+ this . _isFocused = event . type === "focus" ;
904+ }
905+
880906 protected updateSelected ( ) {
881907 const selected = this . view . getSelected ( ) ;
882908 if ( this . type === "multi" ) {
0 commit comments