Skip to content

Commit 5d2ca2a

Browse files
josephperrottmmalerba
authored andcommitted
Move CanDisable mixin to MdExpansionPanel. (#6926)
1 parent 8a21881 commit 5d2ca2a

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/lib/expansion/accordion-item.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,26 @@ import {
1717
} from '@angular/core';
1818
import {UniqueSelectionDispatcher} from '../core';
1919
import {CdkAccordion} from './accordion';
20-
import {mixinDisabled, CanDisable} from '../core/common-behaviors/disabled';
2120

2221
/** Used to generate unique ID for each expansion panel. */
2322
let nextId = 0;
2423

25-
// Boilerplate for applying mixins to MdSlider.
26-
/** @docs-private */
27-
export class AccordionItemBase { }
28-
export const _AccordionItemMixinBase = mixinDisabled(AccordionItemBase);
29-
3024
/**
3125
* An abstract class to be extended and decorated as a component. Sets up all
3226
* events and attributes needed to be managed by a CdkAccordion parent.
3327
*/
3428
@Injectable()
35-
export class AccordionItem extends _AccordionItemMixinBase implements OnDestroy, CanDisable {
36-
/** Event emitted every time the MdAccordionChild is closed. */
29+
export class AccordionItem implements OnDestroy {
30+
/** Event emitted every time the AccordionItem is closed. */
3731
@Output() closed = new EventEmitter<void>();
38-
/** Event emitted every time the MdAccordionChild is opened. */
32+
/** Event emitted every time the AccordionItem is opened. */
3933
@Output() opened = new EventEmitter<void>();
40-
/** Event emitted when the MdAccordionChild is destroyed. */
34+
/** Event emitted when the AccordionItem is destroyed. */
4135
@Output() destroyed = new EventEmitter<void>();
42-
/** The unique MdAccordionChild id. */
36+
/** The unique AccordionItem id. */
4337
readonly id = `cdk-accordion-child-${nextId++}`;
4438

45-
/** Whether the MdAccordionChild is expanded. */
39+
/** Whether the AccordionItem is expanded. */
4640
@Input()
4741
get expanded(): boolean { return this._expanded; }
4842
set expanded(expanded: boolean) {
@@ -74,9 +68,6 @@ export class AccordionItem extends _AccordionItemMixinBase implements OnDestroy,
7468
constructor(@Optional() public accordion: CdkAccordion,
7569
private _changeDetectorRef: ChangeDetectorRef,
7670
protected _expansionDispatcher: UniqueSelectionDispatcher) {
77-
78-
super();
79-
8071
this._removeUniqueSelectionListener =
8172
_expansionDispatcher.listen((id: string, accordionId: string) => {
8273
if (this.accordion && !this.accordion.multi &&

src/lib/expansion/expansion-panel.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,19 @@ import {
3030
import {MdAccordion} from './accordion';
3131
import {AccordionItem} from './accordion-item';
3232
import {UniqueSelectionDispatcher} from '../core';
33+
import {mixinDisabled, CanDisable} from '../core/common-behaviors/disabled';
3334
import {Subject} from 'rxjs/Subject';
3435

36+
// Boilerplate for applying mixins to MdExpansionPanel.
37+
/** @docs-private */
38+
export class MdExpansionPanelBase extends AccordionItem {
39+
constructor(accordion: MdAccordion,
40+
_changeDetectorRef: ChangeDetectorRef,
41+
_uniqueSelectionDispatcher: UniqueSelectionDispatcher) {
42+
super(accordion, _changeDetectorRef, _uniqueSelectionDispatcher);
43+
}
44+
}
45+
export const _MdExpansionPanelMixinBase = mixinDisabled(MdExpansionPanelBase);
3546

3647
/** MdExpansionPanel's states. */
3748
export type MdExpansionPanelState = 'expanded' | 'collapsed';
@@ -54,7 +65,7 @@ export const EXPANSION_PANEL_ANIMATION_TIMING = '225ms cubic-bezier(0.4,0.0,0.2,
5465
templateUrl: './expansion-panel.html',
5566
encapsulation: ViewEncapsulation.None,
5667
changeDetection: ChangeDetectionStrategy.OnPush,
57-
inputs: ['disabled'],
68+
inputs: ['disabled', 'expanded'],
5869
host: {
5970
'class': 'mat-expansion-panel',
6071
'[class.mat-expanded]': 'expanded',
@@ -71,7 +82,8 @@ export const EXPANSION_PANEL_ANIMATION_TIMING = '225ms cubic-bezier(0.4,0.0,0.2,
7182
]),
7283
],
7384
})
74-
export class MdExpansionPanel extends AccordionItem implements OnChanges, OnDestroy {
85+
export class MdExpansionPanel extends _MdExpansionPanelMixinBase
86+
implements CanDisable, OnChanges, OnDestroy {
7587
/** Whether the toggle indicator should be hidden. */
7688
@Input() hideToggle: boolean = false;
7789

@@ -98,7 +110,6 @@ export class MdExpansionPanel extends AccordionItem implements OnChanges, OnDest
98110
if (this.accordion) {
99111
return (this.expanded ? this.accordion.displayMode : this._getExpandedState()) === 'default';
100112
}
101-
102113
return false;
103114
}
104115

0 commit comments

Comments
 (0)