@ethlete/cdk 5.0.0-next.44 → 5.0.0-next.45

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @ethlete/cdk
2
2
 
3
+ ## 5.0.0-next.45
4
+
5
+ ### Patch Changes
6
+
7
+ - The combobox now closes on Escape pressed during its enter animation instead of ignoring it.
8
+ - The `@nx/devkit` peer range is now `>=23.0.0`, matching the Nx floor of the migration guide.
9
+ - Dialogs and selects now close on an Escape pressed during the enter animation instead of dropping it; the click that opens them still cannot close them.
10
+ - An auto-resized overlay, such as a menu, opened near the viewport bottom now flips to the top instead of staying squeezed below its trigger.
11
+ - The `to-v5` migration now renames `theme` and `altTheme` to `color` and `altColor` only on `et-button`, `et-fab`, `et-icon-button` and `et-text-button` hosts, not on app components with their own `theme` input.
12
+
3
13
  ## 5.0.0-next.44
4
14
 
5
15
  ### Patch Changes
@@ -4,7 +4,7 @@ import * as i1$5 from "@angular/cdk/portal";
4
4
  import { CdkPortal, CdkPortalOutlet, ComponentPortal, PortalModule, TemplatePortal } from "@angular/cdk/portal";
5
5
  import { DomSanitizer, Title } from "@angular/platform-browser";
6
6
  import { outputFromObservable, outputToObservable, takeUntilDestroyed, toObservable, toSignal } from "@angular/core/rxjs-interop";
7
- import { BehaviorSubject, EMPTY, Observable, ReplaySubject, Subject, Subscription, catchError, combineLatest, debounceTime, distinctUntilChanged, filter, finalize, from, fromEvent, map, merge, of, pairwise, shareReplay, skip, skipUntil, skipWhile, startWith, switchMap, take, takeUntil, takeWhile, tap, throwError, timer, withLatestFrom } from "rxjs";
7
+ import { BehaviorSubject, EMPTY, Observable, ReplaySubject, Subject, Subscription, asapScheduler, catchError, combineLatest, concatMap, debounceTime, distinctUntilChanged, filter, finalize, from, fromEvent, map, merge, observeOn, of, pairwise, shareReplay, skip, skipUntil, skipWhile, startWith, switchMap, take, takeUntil, takeWhile, tap, throwError, timer, withLatestFrom } from "rxjs";
8
8
  import { __decorate, __metadata } from "tslib";
9
9
  import { AsyncPipe, DOCUMENT as DOCUMENT$1, Location, NgClass, NgComponentOutlet, NgStyle, NgTemplateOutlet } from "@angular/common";
10
10
  import * as i1$4 from "@ethlete/core";
@@ -15,7 +15,7 @@ import { AutofillMonitor } from "@angular/cdk/text-field";
15
15
  import { FormControl, NG_VALUE_ACCESSOR, NgControl, Validators } from "@angular/forms";
16
16
  import { A, BACKSPACE, DOWN_ARROW, END, ENTER, ESCAPE, HOME, LEFT_ARROW, PAGE_DOWN, PAGE_UP, RIGHT_ARROW, SPACE, TAB as TAB$1, UP_ARROW, hasModifierKey } from "@angular/cdk/keycodes";
17
17
  import { NoopScrollStrategy, Overlay, OverlayRef as OverlayRef$1 } from "@angular/cdk/overlay";
18
- import { arrow, autoUpdate, computePosition, flip, hide, limitShift, offset, shift, size } from "@floating-ui/dom";
18
+ import { arrow, autoUpdate, computePosition, flip, hide, limitShift, offset, platform, shift, size } from "@floating-ui/dom";
19
19
  import { _isNumberValue, coerceCssPixelValue, coerceElement } from "@angular/cdk/coercion";
20
20
  import { CdkDialogContainer, Dialog, DialogConfig } from "@angular/cdk/dialog";
21
21
  import * as i1$3 from "@angular/router";
@@ -6450,6 +6450,32 @@ const createFormChangesTracker = (config) => {
6450
6450
  defaultFormValue: defaultFormValue.asReadonly()
6451
6451
  };
6452
6452
  };
6453
+ const FLOATING_MAX_SIZE_PROPERTIES = ["--et-floating-max-width", "--et-floating-max-height"];
6454
+ const platformMeasuringUncappedFloatingElFirst = (floatingEl) => {
6455
+ let measuredUncapped = false;
6456
+ return {
6457
+ ...platform,
6458
+ getDimensions: (element) => {
6459
+ if (element !== floatingEl || measuredUncapped) return platform.getDimensions(element);
6460
+ measuredUncapped = true;
6461
+ const caps = FLOATING_MAX_SIZE_PROPERTIES.map((name) => [name, floatingEl.style.getPropertyValue(name)]);
6462
+ if (caps.every(([, value]) => !value)) return platform.getDimensions(element);
6463
+ const scrolled = [...floatingEl.querySelectorAll("*")].filter((el) => el.scrollTop || el.scrollLeft).map((el) => ({
6464
+ el,
6465
+ top: el.scrollTop,
6466
+ left: el.scrollLeft
6467
+ }));
6468
+ for (const [name] of caps) floatingEl.style.removeProperty(name);
6469
+ const dimensions = platform.getDimensions(element);
6470
+ for (const [name, value] of caps) if (value) floatingEl.style.setProperty(name, value);
6471
+ for (const { el, top, left } of scrolled) {
6472
+ el.scrollTop = top;
6473
+ el.scrollLeft = left;
6474
+ }
6475
+ return dimensions;
6476
+ }
6477
+ };
6478
+ };
6453
6479
  var AnimatedOverlayDirective = class AnimatedOverlayDirective {
6454
6480
  constructor() {
6455
6481
  this.overlayService = inject(Overlay);
@@ -6608,10 +6634,9 @@ var AnimatedOverlayDirective = class AnimatedOverlayDirective {
6608
6634
  floatingEl.classList.add("et-floating-element");
6609
6635
  const refEl = this.referenceElement();
6610
6636
  const boundary = this.rootBoundary?.value();
6611
- this.floatingElCleanupFn = autoUpdate(refEl, floatingEl, () => {
6612
- this.updateFloatingPosition(floatingEl, refEl, boundary, floatingElArrow);
6613
- });
6614
- this.waitForRenderAndAnimate();
6637
+ const update = () => this.updateFloatingPosition(floatingEl, refEl, boundary, floatingElArrow);
6638
+ this.floatingElCleanupFn = autoUpdate(refEl, floatingEl, update);
6639
+ this.waitForRenderAndAnimate(update);
6615
6640
  });
6616
6641
  }
6617
6642
  getFloatingArrow() {
@@ -6623,7 +6648,8 @@ var AnimatedOverlayDirective = class AnimatedOverlayDirective {
6623
6648
  const middleware = this.buildFloatingMiddleware(floatingEl, boundary, floatingElArrow);
6624
6649
  computePosition(refEl, floatingEl, {
6625
6650
  placement: this.placement(),
6626
- middleware
6651
+ middleware,
6652
+ platform: this.autoResize() ? platformMeasuringUncappedFloatingElFirst(floatingEl) : platform
6627
6653
  }).then(({ x, y, placement, middlewareData }) => {
6628
6654
  this.applyFloatingStyles(floatingEl, x, y, placement);
6629
6655
  this.applyArrowStyles(floatingEl, middlewareData, floatingElArrow);
@@ -6682,9 +6708,10 @@ var AnimatedOverlayDirective = class AnimatedOverlayDirective {
6682
6708
  this.isHidden.set(false);
6683
6709
  }
6684
6710
  }
6685
- waitForRenderAndAnimate() {
6711
+ waitForRenderAndAnimate(updateFloatingPosition) {
6686
6712
  nextFrame(() => {
6687
6713
  if (!this.componentRef || this.state() !== "mounting") return;
6714
+ updateFloatingPosition();
6688
6715
  const lifecycle = this.componentRef.instance.animatedLifecycle?.();
6689
6716
  if (!lifecycle) {
6690
6717
  console.error("AnimatedOverlayDirective: The component does not have an AnimatedLifecycleDirective. Please add one to the component.");
@@ -7046,7 +7073,8 @@ var OverlayRef = class {
7046
7073
  });
7047
7074
  }
7048
7075
  setupCloseHandlers() {
7049
- merge(this.backdropClick(), this.keydownEvents().pipe(filter((event) => event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event)))).pipe(skipUntil(this._containerInstance.animatedLifecycle.state$.pipe(filter((e) => e === "entering"), switchMap(() => fromNextFrame()))), takeUntil(this.afterClosed())).subscribe((event) => {
7076
+ const lifecycleState$ = this._containerInstance.animatedLifecycle.state$;
7077
+ merge(this.backdropClick().pipe(skipUntil(lifecycleState$.pipe(filter((e) => e === "entering"), switchMap(() => fromNextFrame())))), this.keydownEvents().pipe(filter((event) => event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event)), concatMap((event) => this._containerInstance.animatedLifecycle.state() === "init" ? lifecycleState$.pipe(filter((state) => state !== "init"), take(1), observeOn(asapScheduler), map(() => event)) : of(event)))).pipe(takeUntil(this.afterClosed())).subscribe((event) => {
7050
7078
  const isEscapeKey = event.type === "keydown";
7051
7079
  const isBackdropClick = !isEscapeKey;
7052
7080
  if (this._isEscCloseControlledExternally && isEscapeKey || this._isBackdropCloseControlledExternally && isBackdropClick) return;
@@ -20275,6 +20303,10 @@ var ComboboxDirective = class ComboboxDirective {
20275
20303
  })).subscribe();
20276
20304
  }
20277
20305
  close() {
20306
+ if (!this._animatedOverlay.canUnmount()) return;
20307
+ this._animatedOverlay.unmount();
20308
+ }
20309
+ _closeFromOutsideClick() {
20278
20310
  if (!this._isOpen || this._animatedOverlay.isUnmounting()) return;
20279
20311
  this._animatedOverlay.unmount();
20280
20312
  }
@@ -20347,7 +20379,7 @@ var ComboboxDirective = class ComboboxDirective {
20347
20379
  return this._interpretKeyHandlerResult(result);
20348
20380
  }
20349
20381
  if (keyCode === ESCAPE) {
20350
- if (isOpen) {
20382
+ if (this._animatedOverlay.canUnmount()) {
20351
20383
  result.overlayOperation = "close";
20352
20384
  event.preventDefault();
20353
20385
  event.stopPropagation();
@@ -21128,7 +21160,7 @@ var ComboboxBodyComponent = class ComboboxBodyComponent {
21128
21160
  ...inputs
21129
21161
  }))));
21130
21162
  this._bodyTemplate = null;
21131
- outputToObservable(this.clickOutside.didClickOutside).pipe(tap(() => this.combobox.close()), takeUntilDestroyed()).subscribe();
21163
+ outputToObservable(this.clickOutside.didClickOutside).pipe(tap(() => this.combobox._closeFromOutsideClick()), takeUntilDestroyed()).subscribe();
21132
21164
  }
21133
21165
  setColorFromProvider(provider) {
21134
21166
  this.colorProvider.syncWithProvider(provider);
@@ -22132,6 +22164,10 @@ var SelectDirective = class SelectDirective {
22132
22164
  })).subscribe();
22133
22165
  }
22134
22166
  close() {
22167
+ if (!this._animatedOverlay.canUnmount()) return;
22168
+ this._animatedOverlay.unmount();
22169
+ }
22170
+ _closeFromOutsideClick() {
22135
22171
  if (!this._animatedOverlay.isMounted()) return;
22136
22172
  this._animatedOverlay.unmount();
22137
22173
  }
@@ -22363,7 +22399,7 @@ var SelectBodyDirective = class SelectBodyDirective {
22363
22399
  "aria-multiselectable": toSignal(this._select.multiple$),
22364
22400
  "aria-labelledby": toSignal(this._select.input.labelId$)
22365
22401
  });
22366
- outputToObservable(this._clickOutside.didClickOutside).pipe(tap(() => this._select.close()), takeUntilDestroyed()).subscribe();
22402
+ outputToObservable(this._clickOutside.didClickOutside).pipe(tap(() => this._select._closeFromOutsideClick()), takeUntilDestroyed()).subscribe();
22367
22403
  }
22368
22404
  static {
22369
22405
  this.ɵfac = i0.ɵɵngDeclareFactory({