@@ -32,11 +32,23 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
3232@Component ( {
3333 selector : "cds-select, ibm-select" ,
3434 template : `
35- <div class="cds--form-item">
36- <ng-template [ngIf]="skeleton">
35+ <div
36+ [ngClass]="{
37+ 'cds--form-item': !skeleton,
38+ 'cds--select--fluid': fluid && !skeleton
39+ }">
40+ <ng-container *ngIf="skeleton && !fluid">
3741 <div *ngIf="label" class="cds--label cds--skeleton"></div>
3842 <div class="cds--select cds--skeleton"></div>
39- </ng-template>
43+ </ng-container>
44+ <ng-container *ngIf="skeleton && fluid">
45+ <div class="cds--list-box__wrapper--fluid">
46+ <div class="cds--list-box cds--skeleton">
47+ <div class="cds--list-box__label"></div>
48+ <div class="cds--list-box__field"></div>
49+ </div>
50+ </div>
51+ </ng-container>
4052 <div
4153 *ngIf="!skeleton"
4254 class="cds--select"
@@ -46,7 +58,9 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
4658 'cds--select--invalid': invalid,
4759 'cds--select--warning': warn,
4860 'cds--select--disabled': disabled,
49- 'cds--select--readonly': readonly
61+ 'cds--select--readonly': readonly,
62+ 'cds--select--fluid--invalid': fluid && invalid,
63+ 'cds--select--fluid--focus': fluid && focused
5064 }">
5165 <label
5266 *ngIf="label"
@@ -60,7 +74,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
6074 <ng-container *ngTemplateOutlet="noInline"></ng-container>
6175 </div>
6276 <div
63- *ngIf="helperText"
77+ *ngIf="helperText && !invalid && !warn && !skeleton && !fluid "
6478 class="cds--form__helper-text"
6579 [ngClass]="{
6680 'cds--form__helper-text--disabled': disabled
@@ -89,7 +103,9 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
89103 'cds--select-input--lg': size === 'lg'
90104 }"
91105 (mousedown)="onMouseDown($event)"
92- (keydown)="onKeyDown($event)">
106+ (keydown)="onKeyDown($event)"
107+ (focus)="fluid ? handleFocus($event) : null"
108+ (blur)="fluid ? handleFocus($event) : null">
93109 <ng-content></ng-content>
94110 </select>
95111 <svg
@@ -116,16 +132,30 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
116132 size="16"
117133 class="cds--select__invalid-icon cds--select__invalid-icon--warning">
118134 </svg>
135+ <ng-container *ngIf="fluid">
136+ <hr class="cds--select__divider" />
137+ <div
138+ *ngIf="invalid && invalidText" role="alert" class="cds--form-requirement" aria-live="polite">
139+ <ng-container *ngIf="!isTemplate(invalidText)">{{invalidText}}</ng-container>
140+ <ng-template *ngIf="isTemplate(invalidText)" [ngTemplateOutlet]="invalidText"></ng-template>
141+ </div>
142+ <div *ngIf="!invalid && warn" class="cds--form-requirement">
143+ <ng-container *ngIf="!isTemplate(warnText)">{{warnText}}</ng-container>
144+ <ng-template *ngIf="isTemplate(warnText)" [ngTemplateOutlet]="warnText"></ng-template>
145+ </div>
146+ </ng-container>
119147 </div>
120- <div
121- *ngIf="invalid && invalidText" role="alert" class="cds--form-requirement" aria-live="polite">
122- <ng-container *ngIf="!isTemplate(invalidText)">{{invalidText}}</ng-container>
123- <ng-template *ngIf="isTemplate(invalidText)" [ngTemplateOutlet]="invalidText"></ng-template>
124- </div>
125- <div *ngIf="!invalid && warn" class="cds--form-requirement">
126- <ng-container *ngIf="!isTemplate(warnText)">{{warnText}}</ng-container>
127- <ng-template *ngIf="isTemplate(warnText)" [ngTemplateOutlet]="warnText"></ng-template>
128- </div>
148+ <ng-container *ngIf="!fluid">
149+ <div
150+ *ngIf="invalid && invalidText" role="alert" class="cds--form-requirement" aria-live="polite">
151+ <ng-container *ngIf="!isTemplate(invalidText)">{{invalidText}}</ng-container>
152+ <ng-template *ngIf="isTemplate(invalidText)" [ngTemplateOutlet]="invalidText"></ng-template>
153+ </div>
154+ <div *ngIf="!invalid && warn" class="cds--form-requirement">
155+ <ng-container *ngIf="!isTemplate(warnText)">{{warnText}}</ng-container>
156+ <ng-template *ngIf="isTemplate(warnText)" [ngTemplateOutlet]="warnText"></ng-template>
157+ </div>
158+ </ng-container>
129159 </ng-template>
130160 ` ,
131161 providers : [
@@ -209,10 +239,17 @@ export class Select implements ControlValueAccessor, AfterViewInit {
209239 @Input ( ) theme : "light" | "dark" = "dark" ;
210240 @Input ( ) ariaLabel : string ;
211241
242+ /**
243+ * Experimental: enable fluid state
244+ */
245+ @Input ( ) fluid = false ;
246+
212247 @Output ( ) valueChange = new EventEmitter ( ) ;
213248
214249 @ViewChild ( "select" ) select : ElementRef ;
215250
251+ focused = false ;
252+
216253 protected _value ;
217254
218255 ngAfterViewInit ( ) {
@@ -296,9 +333,14 @@ export class Select implements ControlValueAccessor, AfterViewInit {
296333 }
297334 }
298335
336+ handleFocus ( event : FocusEvent ) {
337+ this . focused = event . type === "focus" ;
338+ }
339+
299340 /**
300341 * placeholder declarations. Replaced by the functions provided to `registerOnChange` and `registerOnTouched`
301342 */
302343 protected onChangeHandler = ( _ : any ) => { } ;
303344 protected onTouchedHandler = ( ) => { } ;
345+
304346}
0 commit comments