Skip to content

Commit 99391e7

Browse files
authored
refactor(material/select): remove deprecated APIs for v12 (angular#21827)
Removes the APIs that were marked as deprecated for v12. BREAKING CHANGES: * `MatSelect._overlayDir` has been removed. * `SELECT_PANEL_MAX_HEIGHT` has been removed. * `SELECT_PANEL_PADDING_X` has been removed. * `SELECT_PANEL_INDENT_PADDING_X` has been removed. * `SELECT_ITEM_HEIGHT_EM` has been removed. * `SELECT_MULTIPLE_PANEL_PADDING_X` has been removed. * `SELECT_PANEL_VIEWPORT_PADDING` has been removed.
1 parent a405ce6 commit 99391e7

File tree

4 files changed

+28
-61
lines changed

4 files changed

+28
-61
lines changed

src/material-experimental/mdc-select/public-api.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,4 @@ export {
1616
MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY,
1717
MAT_SELECT_TRIGGER,
1818
MatSelectConfig,
19-
SELECT_ITEM_HEIGHT_EM,
20-
SELECT_MULTIPLE_PANEL_PADDING_X,
21-
SELECT_PANEL_INDENT_PADDING_X,
22-
SELECT_PANEL_MAX_HEIGHT,
23-
SELECT_PANEL_PADDING_X,
24-
SELECT_PANEL_VIEWPORT_PADDING,
2519
} from '@angular/material/select';

src/material/select/public-api.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,16 @@
77
*/
88

99
export * from './select-module';
10-
export * from './select';
1110
export * from './select-animations';
11+
export {
12+
MAT_SELECT_SCROLL_STRATEGY,
13+
MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY,
14+
MatSelectConfig,
15+
MAT_SELECT_CONFIG,
16+
MAT_SELECT_SCROLL_STRATEGY_PROVIDER,
17+
MatSelectChange,
18+
MAT_SELECT_TRIGGER,
19+
_MatSelectBase,
20+
MatSelect,
21+
MatSelectTrigger
22+
} from './select';

src/material/select/select.ts

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,16 @@ let nextUniqueId = 0;
110110
* the trigger element.
111111
*/
112112

113-
/**
114-
* The max height of the select's overlay panel.
115-
* @deprecated To be turned into a private variable.
116-
* @breaking-change 12.0.0
117-
*/
113+
/** The max height of the select's overlay panel. */
118114
export const SELECT_PANEL_MAX_HEIGHT = 256;
119115

120-
/**
121-
* The panel's padding on the x-axis.
122-
* @deprecated To be turned into a private variable.
123-
* @breaking-change 12.0.0
124-
*/
116+
/** The panel's padding on the x-axis. */
125117
export const SELECT_PANEL_PADDING_X = 16;
126118

127-
/**
128-
* The panel's x axis padding if it is indented (e.g. there is an option group).
129-
* @deprecated To be turned into a private variable.
130-
* @breaking-change 12.0.0
131-
*/
119+
/** The panel's x axis padding if it is indented (e.g. there is an option group). */
132120
export const SELECT_PANEL_INDENT_PADDING_X = SELECT_PANEL_PADDING_X * 2;
133121

134-
/**
135-
* The height of the select items in `em` units.
136-
* @deprecated To be turned into a private variable.
137-
* @breaking-change 12.0.0
138-
*/
122+
/** The height of the select items in `em` units. */
139123
export const SELECT_ITEM_HEIGHT_EM = 3;
140124

141125
// TODO(josephperrott): Revert to a constant after 2018 spec updates are fully merged.
@@ -147,18 +131,12 @@ export const SELECT_ITEM_HEIGHT_EM = 3;
147131
* (SELECT_PANEL_PADDING_X * 1.5) + 16 = 40
148132
* The padding is multiplied by 1.5 because the checkbox's margin is half the padding.
149133
* The checkbox width is 16px.
150-
*
151-
* @deprecated To be turned into a private variable.
152-
* @breaking-change 12.0.0
153134
*/
154135
export const SELECT_MULTIPLE_PANEL_PADDING_X = SELECT_PANEL_PADDING_X * 1.5 + 16;
155136

156137
/**
157138
* The select panel will only "fit" inside the viewport if it is positioned at
158139
* this value or more away from the viewport boundary.
159-
*
160-
* @deprecated To be turned into a private variable.
161-
* @breaking-change 12.0.0
162140
*/
163141
export const SELECT_PANEL_VIEWPORT_PADDING = 8;
164142

@@ -331,13 +309,9 @@ export abstract class _MatSelectBase<C> extends _MatSelectMixinBase implements A
331309
/** Panel containing the select options. */
332310
@ViewChild('panel') panel: ElementRef;
333311

334-
/**
335-
* Overlay pane containing the options.
336-
* @deprecated To be turned into a private API.
337-
* @breaking-change 10.0.0
338-
* @docs-private
339-
*/
340-
@ViewChild(CdkConnectedOverlay) overlayDir: CdkConnectedOverlay;
312+
/** Overlay pane containing the options. */
313+
@ViewChild(CdkConnectedOverlay)
314+
protected _overlayDir: CdkConnectedOverlay;
341315

342316
/** Classes to be passed to the select panel. Supports the same syntax as `ngClass`. */
343317
@Input() panelClass: string|string[]|Set<string>|{[key: string]: any};
@@ -785,7 +759,7 @@ export abstract class _MatSelectBase<C> extends _MatSelectMixinBase implements A
785759
* Callback that is invoked when the overlay panel has been attached.
786760
*/
787761
_onAttached(): void {
788-
this.overlayDir.positionChange.pipe(take(1)).subscribe(() => {
762+
this._overlayDir.positionChange.pipe(take(1)).subscribe(() => {
789763
this._changeDetectorRef.detectChanges();
790764
this._positioningSettled();
791765
});
@@ -1230,9 +1204,9 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
12301204

12311205
// Set the font size on the panel element once it exists.
12321206
this._ngZone.onStable.pipe(take(1)).subscribe(() => {
1233-
if (this._triggerFontSize && this.overlayDir.overlayRef &&
1234-
this.overlayDir.overlayRef.overlayElement) {
1235-
this.overlayDir.overlayRef.overlayElement.style.fontSize = `${this._triggerFontSize}px`;
1207+
if (this._triggerFontSize && this._overlayDir.overlayRef &&
1208+
this._overlayDir.overlayRef.overlayElement) {
1209+
this._overlayDir.overlayRef.overlayElement.style.fontSize = `${this._triggerFontSize}px`;
12361210
}
12371211
});
12381212
}
@@ -1260,7 +1234,7 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
12601234
if (this.panelOpen) {
12611235
this._scrollTop = 0;
12621236
} else {
1263-
this.overlayDir.offsetX = 0;
1237+
this._overlayDir.offsetX = 0;
12641238
this._changeDetectorRef.markForCheck();
12651239
}
12661240

@@ -1279,7 +1253,7 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
12791253
* content width in order to constrain the panel within the viewport.
12801254
*/
12811255
private _calculateOverlayOffsetX(): void {
1282-
const overlayRect = this.overlayDir.overlayRef.overlayElement.getBoundingClientRect();
1256+
const overlayRect = this._overlayDir.overlayRef.overlayElement.getBoundingClientRect();
12831257
const viewportSize = this._viewportRuler.getViewportSize();
12841258
const isRtl = this._isRtl();
12851259
const paddingWidth = this.multiple ? SELECT_MULTIPLE_PANEL_PADDING_X + SELECT_PANEL_PADDING_X :
@@ -1316,8 +1290,8 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
13161290
// Set the offset directly in order to avoid having to go through change detection and
13171291
// potentially triggering "changed after it was checked" errors. Round the value to avoid
13181292
// blurry content in some browsers.
1319-
this.overlayDir.offsetX = Math.round(offsetX);
1320-
this.overlayDir.overlayRef.updatePosition();
1293+
this._overlayDir.offsetX = Math.round(offsetX);
1294+
this._overlayDir.overlayRef.updatePosition();
13211295
}
13221296

13231297
/**

tools/public_api_guard/material/select.d.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export declare abstract class _MatSelectBase<C> extends _MatSelectMixinBase impl
88
_onChange: (value: any) => void;
99
_onTouched: () => void;
1010
readonly _openedStream: Observable<void>;
11+
protected _overlayDir: CdkConnectedOverlay;
1112
_overlayPanelClass: string | string[];
1213
_panelDoneAnimatingStream: Subject<string>;
1314
protected _parentFormField: MatFormField;
@@ -36,7 +37,6 @@ export declare abstract class _MatSelectBase<C> extends _MatSelectMixinBase impl
3637
abstract optionGroups: QueryList<MatOptgroup>;
3738
readonly optionSelectionChanges: Observable<MatOptionSelectionChange>;
3839
abstract options: QueryList<_MatOptionBase>;
39-
overlayDir: CdkConnectedOverlay;
4040
panel: ElementRef;
4141
panelClass: string | string[] | Set<string> | {
4242
[key: string]: any;
@@ -159,15 +159,3 @@ export declare class MatSelectTrigger {
159159
static ɵdir: i0.ɵɵDirectiveDefWithMeta<MatSelectTrigger, "mat-select-trigger", never, {}, {}, never>;
160160
static ɵfac: i0.ɵɵFactoryDef<MatSelectTrigger, never>;
161161
}
162-
163-
export declare const SELECT_ITEM_HEIGHT_EM = 3;
164-
165-
export declare const SELECT_MULTIPLE_PANEL_PADDING_X: number;
166-
167-
export declare const SELECT_PANEL_INDENT_PADDING_X: number;
168-
169-
export declare const SELECT_PANEL_MAX_HEIGHT = 256;
170-
171-
export declare const SELECT_PANEL_PADDING_X = 16;
172-
173-
export declare const SELECT_PANEL_VIEWPORT_PADDING = 8;

0 commit comments

Comments
 (0)