Skip to content

refactor(material/select): remove deprecated APIs for v12 #21827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/material-experimental/mdc-select/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,4 @@ export {
MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY,
MAT_SELECT_TRIGGER,
MatSelectConfig,
SELECT_ITEM_HEIGHT_EM,
SELECT_MULTIPLE_PANEL_PADDING_X,
SELECT_PANEL_INDENT_PADDING_X,
SELECT_PANEL_MAX_HEIGHT,
SELECT_PANEL_PADDING_X,
SELECT_PANEL_VIEWPORT_PADDING,
} from '@angular/material/select';
13 changes: 12 additions & 1 deletion src/material/select/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,16 @@
*/

export * from './select-module';
export * from './select';
export * from './select-animations';
export {
MAT_SELECT_SCROLL_STRATEGY,
MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY,
MatSelectConfig,
MAT_SELECT_CONFIG,
MAT_SELECT_SCROLL_STRATEGY_PROVIDER,
MatSelectChange,
MAT_SELECT_TRIGGER,
_MatSelectBase,
MatSelect,
MatSelectTrigger
} from './select';
56 changes: 15 additions & 41 deletions src/material/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,16 @@ let nextUniqueId = 0;
* the trigger element.
*/

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

/**
* The panel's padding on the x-axis.
* @deprecated To be turned into a private variable.
* @breaking-change 12.0.0
*/
/** The panel's padding on the x-axis. */
export const SELECT_PANEL_PADDING_X = 16;

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

/**
* The height of the select items in `em` units.
* @deprecated To be turned into a private variable.
* @breaking-change 12.0.0
*/
/** The height of the select items in `em` units. */
export const SELECT_ITEM_HEIGHT_EM = 3;

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

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

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

/**
* Overlay pane containing the options.
* @deprecated To be turned into a private API.
* @breaking-change 10.0.0
* @docs-private
*/
@ViewChild(CdkConnectedOverlay) overlayDir: CdkConnectedOverlay;
/** Overlay pane containing the options. */
@ViewChild(CdkConnectedOverlay)
protected _overlayDir: CdkConnectedOverlay;

/** Classes to be passed to the select panel. Supports the same syntax as `ngClass`. */
@Input() panelClass: string|string[]|Set<string>|{[key: string]: any};
Expand Down Expand Up @@ -784,7 +758,7 @@ export abstract class _MatSelectBase<C> extends _MatSelectMixinBase implements A
* Callback that is invoked when the overlay panel has been attached.
*/
_onAttached(): void {
this.overlayDir.positionChange.pipe(take(1)).subscribe(() => {
this._overlayDir.positionChange.pipe(take(1)).subscribe(() => {
this._changeDetectorRef.detectChanges();
this._positioningSettled();
});
Expand Down Expand Up @@ -1223,9 +1197,9 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit

// Set the font size on the panel element once it exists.
this._ngZone.onStable.pipe(take(1)).subscribe(() => {
if (this._triggerFontSize && this.overlayDir.overlayRef &&
this.overlayDir.overlayRef.overlayElement) {
this.overlayDir.overlayRef.overlayElement.style.fontSize = `${this._triggerFontSize}px`;
if (this._triggerFontSize && this._overlayDir.overlayRef &&
this._overlayDir.overlayRef.overlayElement) {
this._overlayDir.overlayRef.overlayElement.style.fontSize = `${this._triggerFontSize}px`;
}
});
}
Expand Down Expand Up @@ -1253,7 +1227,7 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
if (this.panelOpen) {
this._scrollTop = 0;
} else {
this.overlayDir.offsetX = 0;
this._overlayDir.offsetX = 0;
this._changeDetectorRef.markForCheck();
}

Expand All @@ -1272,7 +1246,7 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
* content width in order to constrain the panel within the viewport.
*/
private _calculateOverlayOffsetX(): void {
const overlayRect = this.overlayDir.overlayRef.overlayElement.getBoundingClientRect();
const overlayRect = this._overlayDir.overlayRef.overlayElement.getBoundingClientRect();
const viewportSize = this._viewportRuler.getViewportSize();
const isRtl = this._isRtl();
const paddingWidth = this.multiple ? SELECT_MULTIPLE_PANEL_PADDING_X + SELECT_PANEL_PADDING_X :
Expand Down Expand Up @@ -1309,8 +1283,8 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
// Set the offset directly in order to avoid having to go through change detection and
// potentially triggering "changed after it was checked" errors. Round the value to avoid
// blurry content in some browsers.
this.overlayDir.offsetX = Math.round(offsetX);
this.overlayDir.overlayRef.updatePosition();
this._overlayDir.offsetX = Math.round(offsetX);
this._overlayDir.overlayRef.updatePosition();
}

/**
Expand Down
14 changes: 1 addition & 13 deletions tools/public_api_guard/material/select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export declare abstract class _MatSelectBase<C> extends _MatSelectMixinBase impl
_onChange: (value: any) => void;
_onTouched: () => void;
readonly _openedStream: Observable<void>;
protected _overlayDir: CdkConnectedOverlay;
_overlayPanelClass: string | string[];
_panelDoneAnimatingStream: Subject<string>;
protected _parentFormField: MatFormField;
Expand Down Expand Up @@ -36,7 +37,6 @@ export declare abstract class _MatSelectBase<C> extends _MatSelectMixinBase impl
abstract optionGroups: QueryList<MatOptgroup>;
readonly optionSelectionChanges: Observable<MatOptionSelectionChange>;
abstract options: QueryList<_MatOptionBase>;
overlayDir: CdkConnectedOverlay;
panel: ElementRef;
panelClass: string | string[] | Set<string> | {
[key: string]: any;
Expand Down Expand Up @@ -159,15 +159,3 @@ export declare class MatSelectTrigger {
static ɵdir: i0.ɵɵDirectiveDefWithMeta<MatSelectTrigger, "mat-select-trigger", never, {}, {}, never>;
static ɵfac: i0.ɵɵFactoryDef<MatSelectTrigger, never>;
}

export declare const SELECT_ITEM_HEIGHT_EM = 3;

export declare const SELECT_MULTIPLE_PANEL_PADDING_X: number;

export declare const SELECT_PANEL_INDENT_PADDING_X: number;

export declare const SELECT_PANEL_MAX_HEIGHT = 256;

export declare const SELECT_PANEL_PADDING_X = 16;

export declare const SELECT_PANEL_VIEWPORT_PADDING = 8;