-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select): add md-optgroup component
Adds the `md-optgroup` component, which can be used to group options inside of `md-select`, in a similar way to the native `optgroup`. Fixes #3182.
- Loading branch information
Showing
14 changed files
with
433 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@import '../theming/palette'; | ||
@import '../theming/theming'; | ||
|
||
@mixin mat-optgroup-theme($theme) { | ||
$foreground: map-get($theme, foreground); | ||
|
||
.mat-optgroup-label { | ||
color: mat-color($foreground, secondary-text); | ||
} | ||
|
||
.mat-optgroup-disabled .mat-optgroup-label { | ||
color: mat-color($foreground, hint-text); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@import '../style/menu-common'; | ||
@import '../style/vendor-prefixes'; | ||
|
||
@mixin mat-optgroup() { | ||
.mat-optgroup-label { | ||
@include mat-menu-item-base(); | ||
@include user-select(none); | ||
cursor: default; | ||
|
||
// TODO(crisbeto): should use the typography functions once #4375 is in. | ||
font-weight: bold; | ||
font-size: 14px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
import {MdRippleModule} from '../ripple/index'; | ||
import {MdSelectionModule} from '../selection/index'; | ||
import {MdOption} from './option'; | ||
import {MdOptgroup} from './optgroup'; | ||
|
||
|
||
@NgModule({ | ||
imports: [MdRippleModule, CommonModule, MdSelectionModule], | ||
exports: [MdOption, MdOptgroup], | ||
declarations: [MdOption, MdOptgroup] | ||
}) | ||
export class MdOptionModule {} | ||
|
||
|
||
export * from './option'; | ||
export * from './optgroup'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<label class="mat-optgroup-label" [id]="_labelId">{{ label }}</label> | ||
<ng-content select="md-option, mat-option"></ng-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {Component, ViewEncapsulation, ContentChildren, QueryList, Input} from '@angular/core'; | ||
import {mixinDisabled, CanDisable} from '../common-behaviors/disabled'; | ||
|
||
// Boilerplate for applying mixins to MdOptgroup. | ||
export class MdOptgroupBase { } | ||
export const _MdOptgroupMixinBase = mixinDisabled(MdOptgroupBase); | ||
|
||
// Counter for unique group ids. | ||
let nextId = 0; | ||
|
||
/** | ||
* Component that is used to group instances of `md-option`. | ||
*/ | ||
@Component({ | ||
moduleId: module.id, | ||
selector: 'md-optgroup, mat-optgroup', | ||
templateUrl: 'optgroup.html', | ||
encapsulation: ViewEncapsulation.None, | ||
inputs: ['disabled'], | ||
host: { | ||
'class': 'mat-optgroup', | ||
'[class.mat-optgroup-disabled]': 'disabled', | ||
'[attr.aria-disabled]': 'disabled.toString()', | ||
'[attr.aria-labelledby]': '_labelId', | ||
} | ||
}) | ||
export class MdOptgroup extends _MdOptgroupMixinBase implements CanDisable { | ||
/** Label for the option group. */ | ||
@Input() label: string; | ||
|
||
/** Unique id for the underlying label. */ | ||
_labelId: string = `mat-optgroup-label-${nextId++}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.