@angular/material 14.0.2 → 14.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2133,10 +2133,6 @@ class MatDatepickerContent extends _MatDatepickerContentBase {
2133
2133
  this._closeButtonText = intl.closeCalendarLabel;
2134
2134
  }
2135
2135
  ngOnInit() {
2136
- // If we have actions, clone the model so that we have the ability to cancel the selection,
2137
- // otherwise update the global model directly. Note that we want to assign this as soon as
2138
- // possible, but `_actionsPortal` isn't available in the constructor so we do it in `ngOnInit`.
2139
- this._model = this._actionsPortal ? this._globalModel.clone() : this._globalModel;
2140
2136
  this._animationState = this.datepicker.touchUi ? 'enter-dialog' : 'enter-dropdown';
2141
2137
  }
2142
2138
  ngAfterViewInit() {
@@ -2184,6 +2180,23 @@ class MatDatepickerContent extends _MatDatepickerContentBase {
2184
2180
  this._globalModel.updateSelection(this._model.selection, this);
2185
2181
  }
2186
2182
  }
2183
+ /**
2184
+ * Assigns a new portal containing the datepicker actions.
2185
+ * @param portal Portal with the actions to be assigned.
2186
+ * @param forceRerender Whether a re-render of the portal should be triggered. This isn't
2187
+ * necessary if the portal is assigned during initialization, but it may be required if it's
2188
+ * added at a later point.
2189
+ */
2190
+ _assignActions(portal, forceRerender) {
2191
+ // If we have actions, clone the model so that we have the ability to cancel the selection,
2192
+ // otherwise update the global model directly. Note that we want to assign this as soon as
2193
+ // possible, but `_actionsPortal` isn't available in the constructor so we do it in `ngOnInit`.
2194
+ this._model = portal ? this._globalModel.clone() : this._globalModel;
2195
+ this._actionsPortal = portal;
2196
+ if (forceRerender) {
2197
+ this._changeDetectorRef.detectChanges();
2198
+ }
2199
+ }
2187
2200
  }
2188
2201
  MatDatepickerContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatDatepickerContent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: MatDateSelectionModel }, { token: i1$1.DateAdapter }, { token: MAT_DATE_RANGE_SELECTION_STRATEGY, optional: true }, { token: MatDatepickerIntl }], target: i0.ɵɵFactoryTarget.Component });
2189
2202
  MatDatepickerContent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.1", type: MatDatepickerContent, selector: "mat-datepicker-content", inputs: { color: "color" }, host: { listeners: { "@transformPanel.done": "_animationDone.next()" }, properties: { "@transformPanel": "_animationState", "class.mat-datepicker-content-touch": "datepicker.touchUi" }, classAttribute: "mat-datepicker-content" }, viewQueries: [{ propertyName: "_calendar", first: true, predicate: MatCalendar, descendants: true }], exportAs: ["matDatepickerContent"], usesInheritance: true, ngImport: i0, template: "<div\n cdkTrapFocus\n role=\"dialog\"\n [attr.aria-modal]=\"true\"\n [attr.aria-labelledby]=\"_dialogLabelId ?? undefined\"\n class=\"mat-datepicker-content-container\"\n [class.mat-datepicker-content-container-with-custom-header]=\"datepicker.calendarHeaderComponent\"\n [class.mat-datepicker-content-container-with-actions]=\"_actionsPortal\">\n <mat-calendar\n [id]=\"datepicker.id\"\n [ngClass]=\"datepicker.panelClass\"\n [startAt]=\"datepicker.startAt\"\n [startView]=\"datepicker.startView\"\n [minDate]=\"datepicker._getMinDate()\"\n [maxDate]=\"datepicker._getMaxDate()\"\n [dateFilter]=\"datepicker._getDateFilter()\"\n [headerComponent]=\"datepicker.calendarHeaderComponent\"\n [selected]=\"_getSelected()\"\n [dateClass]=\"datepicker.dateClass\"\n [comparisonStart]=\"comparisonStart\"\n [comparisonEnd]=\"comparisonEnd\"\n [@fadeInCalendar]=\"'enter'\"\n (yearSelected)=\"datepicker._selectYear($event)\"\n (monthSelected)=\"datepicker._selectMonth($event)\"\n (viewChanged)=\"datepicker._viewChanged($event)\"\n (_userSelection)=\"_handleUserSelection($event)\"></mat-calendar>\n\n <ng-template [cdkPortalOutlet]=\"_actionsPortal\"></ng-template>\n\n <!-- Invisible close button for screen reader users. -->\n <button\n type=\"button\"\n mat-raised-button\n [color]=\"color || 'primary'\"\n class=\"mat-datepicker-close-button\"\n [class.cdk-visually-hidden]=\"!_closeButtonFocused\"\n (focus)=\"_closeButtonFocused = true\"\n (blur)=\"_closeButtonFocused = false\"\n (click)=\"datepicker.close()\">{{ _closeButtonText }}</button>\n</div>\n", styles: [".mat-datepicker-content{display:block;border-radius:4px}.mat-datepicker-content .mat-calendar{width:296px;height:354px}.mat-datepicker-content .mat-datepicker-content-container-with-custom-header .mat-calendar{height:auto}.mat-datepicker-content .mat-datepicker-close-button{position:absolute;top:100%;left:0;margin-top:8px}.ng-animating .mat-datepicker-content .mat-datepicker-close-button{display:none}.mat-datepicker-content-container{display:flex;flex-direction:column;justify-content:space-between}.mat-datepicker-content-touch{display:block;max-height:80vh;position:relative;overflow:visible}.mat-datepicker-content-touch .mat-datepicker-content-container{min-height:312px;max-height:788px;min-width:250px;max-width:750px}.mat-datepicker-content-touch .mat-calendar{width:100%;height:auto}@media all and (orientation: landscape){.mat-datepicker-content-touch .mat-datepicker-content-container{width:64vh;height:80vh}}@media all and (orientation: portrait){.mat-datepicker-content-touch .mat-datepicker-content-container{width:80vw;height:100vw}.mat-datepicker-content-touch .mat-datepicker-content-container-with-actions{height:115vw}}"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i5.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { kind: "directive", type: i6.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "component", type: MatCalendar, selector: "mat-calendar", inputs: ["headerComponent", "startAt", "startView", "selected", "minDate", "maxDate", "dateFilter", "dateClass", "comparisonStart", "comparisonEnd"], outputs: ["selectedChange", "yearSelected", "monthSelected", "viewChanged", "_userSelection"], exportAs: ["matCalendar"] }], animations: [matDatepickerAnimations.transformPanel, matDatepickerAnimations.fadeInCalendar], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
@@ -2390,6 +2403,7 @@ class MatDatepickerBase {
2390
2403
  throw Error('A MatDatepicker can only be associated with a single actions row.');
2391
2404
  }
2392
2405
  this._actionsPortal = portal;
2406
+ this._componentRef?.instance._assignActions(portal, true);
2393
2407
  }
2394
2408
  /**
2395
2409
  * Removes a portal containing action buttons from the datepicker.
@@ -2398,6 +2412,7 @@ class MatDatepickerBase {
2398
2412
  removeActions(portal) {
2399
2413
  if (portal === this._actionsPortal) {
2400
2414
  this._actionsPortal = null;
2415
+ this._componentRef?.instance._assignActions(null, true);
2401
2416
  }
2402
2417
  }
2403
2418
  /** Open the calendar. */
@@ -2455,8 +2470,8 @@ class MatDatepickerBase {
2455
2470
  _forwardContentValues(instance) {
2456
2471
  instance.datepicker = this;
2457
2472
  instance.color = this.color;
2458
- instance._actionsPortal = this._actionsPortal;
2459
2473
  instance._dialogLabelId = this.datepickerInput.getOverlayLabelId();
2474
+ instance._assignActions(this._actionsPortal, false);
2460
2475
  }
2461
2476
  /** Opens the overlay with the calendar. */
2462
2477
  _openOverlay() {