@@ -30,7 +30,14 @@ import { I18n } from "./../i18n/i18n.module";
3030 template : `
3131 <div
3232 class="bx--list-box"
33- [ngClass]="{'bx--dropdown--light': theme === 'light'}">
33+ [ngClass]="{
34+ 'bx--dropdown--light': theme === 'light',
35+ 'bx--dropdown': !skeleton,
36+ 'bx--list-box--inline': inline,
37+ 'bx--skeleton': skeleton,
38+ 'bx--dropdown-v2': skeleton,
39+ 'bx--form-item': skeleton
40+ }">
3441 <button
3542 type="button"
3643 #dropdownButton
@@ -42,7 +49,7 @@ import { I18n } from "./../i18n/i18n.module";
4249 (blur)="onBlur()"
4350 [disabled]="disabled">
4451 <span class="bx--list-box__label">{{getDisplayValue() | async}}</span>
45- <div class="bx--list-box__menu-icon" [ngClass]="{'bx--list-box__menu-icon--open': !menuIsClosed }">
52+ <div *ngIf="!skeleton" class="bx--list-box__menu-icon" [ngClass]="{'bx--list-box__menu-icon--open': !menuIsClosed }">
4653 <svg fill-rule="evenodd" height="5" role="img" viewBox="0 0 10 5" width="10" alt="Open menu" [attr.aria-label]="menuButtonLabel">
4754 <title>{{menuButtonLabel}}</title>
4855 <path d="M0 0l5 4.998L10 0z"></path>
@@ -93,6 +100,14 @@ export class Dropdown implements OnInit, AfterContentInit, OnDestroy {
93100 * Set to `true` to disable the dropdown.
94101 */
95102 @Input ( ) disabled = false ;
103+ /**
104+ * Set to `true` for a loading dropdown.
105+ */
106+ @Input ( ) skeleton = false ;
107+ /**
108+ * Set to `true` for an inline dropdown.
109+ */
110+ @Input ( ) inline = false ;
96111 /**
97112 * Deprecated. Dropdown now defaults to appending inline
98113 * Set to `true` if the `Dropdown` is to be appended to the DOM body.
@@ -198,33 +213,37 @@ export class Dropdown implements OnInit, AfterContentInit, OnDestroy {
198213 * The `type` property specifies whether the `Dropdown` allows single selection or multi selection.
199214 */
200215 ngOnInit ( ) {
201- this . view . type = this . type ;
216+ if ( ! this . skeleton ) {
217+ this . view . type = this . type ;
218+ }
202219 }
203220
204221 /**
205222 * Initializes classes and subscribes to events for single or multi selection.
206223 */
207224 ngAfterContentInit ( ) {
208- this . view . type = this . type ;
209- this . view . size = this . size ;
210- this . view . select . subscribe ( event => {
211- if ( this . type === "multi" ) {
212- this . propagateChange ( this . view . getSelected ( ) ) ;
213- } else {
214- this . closeMenu ( ) ;
215- this . dropdownButton . nativeElement . focus ( ) ;
216- if ( event . item && event . item . selected ) {
217- if ( this . value ) {
218- this . propagateChange ( event . item [ this . value ] ) ;
225+ if ( ! this . skeleton ) {
226+ this . view . type = this . type ;
227+ this . view . size = this . size ;
228+ this . view . select . subscribe ( event => {
229+ if ( this . type === "multi" ) {
230+ this . propagateChange ( this . view . getSelected ( ) ) ;
231+ } else {
232+ this . closeMenu ( ) ;
233+ this . dropdownButton . nativeElement . focus ( ) ;
234+ if ( event . item && event . item . selected ) {
235+ if ( this . value ) {
236+ this . propagateChange ( event . item [ this . value ] ) ;
237+ } else {
238+ this . propagateChange ( event . item ) ;
239+ }
219240 } else {
220- this . propagateChange ( event . item ) ;
241+ this . propagateChange ( null ) ;
221242 }
222- } else {
223- this . propagateChange ( null ) ;
224243 }
225- }
226- this . selected . emit ( event ) ;
227- } ) ;
244+ this . selected . emit ( event ) ;
245+ } ) ;
246+ }
228247 }
229248
230249 /**
@@ -323,17 +342,19 @@ export class Dropdown implements OnInit, AfterContentInit, OnDestroy {
323342 * Returns the display value if there is no selection, otherwise the selection will be returned.
324343 */
325344 getDisplayValue ( ) : Observable < string > {
326- let selected = this . view . getSelected ( ) ;
327- if ( selected && ! this . displayValue ) {
328- if ( this . type === "multi" ) {
329- return of ( `${ selected . length } ${ this . selectedLabel } ` ) ;
330- } else {
331- return of ( selected [ 0 ] . content ) ;
345+ if ( ! this . skeleton ) {
346+ let selected = this . view . getSelected ( ) ;
347+ if ( selected && ! this . displayValue ) {
348+ if ( this . type === "multi" ) {
349+ return of ( `${ selected . length } ${ this . selectedLabel } ` ) ;
350+ } else {
351+ return of ( selected [ 0 ] . content ) ;
352+ }
353+ } else if ( selected ) {
354+ return of ( this . displayValue ) ;
332355 }
333- } else if ( selected ) {
334- return of ( this . displayValue ) ;
356+ return of ( this . placeholder ) ;
335357 }
336- return of ( this . placeholder ) ;
337358 }
338359
339360 /**
0 commit comments