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

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,21 @@
1
1
  # @ethlete/cdk
2
2
 
3
+ ## 5.0.0-next.46
4
+
5
+ ### Patch Changes
6
+
7
+ - Overlay: while the overlay enters, a backdrop click closes it; the second click of a double-click does not, so a double-click on the trigger no longer opens and closes it at once.
8
+
9
+ ## 5.0.0-next.45
10
+
11
+ ### Patch Changes
12
+
13
+ - The combobox now closes on Escape pressed during its enter animation instead of ignoring it.
14
+ - The `@nx/devkit` peer range is now `>=23.0.0`, matching the Nx floor of the migration guide.
15
+ - 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.
16
+ - 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.
17
+ - 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.
18
+
3
19
  ## 5.0.0-next.44
4
20
 
5
21
  ### 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, 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,9 @@ 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
+ const afterEnterStarted = (event) => this._containerInstance.animatedLifecycle.state() === "init" ? lifecycleState$.pipe(filter((state) => state !== "init"), take(1), observeOn(asapScheduler), map(() => event)) : of(event);
7078
+ merge(this.backdropClick().pipe(filter((event) => !this.isDoubleClickWhileEntering(event))), this.keydownEvents().pipe(filter((event) => event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event)))).pipe(concatMap(afterEnterStarted), takeUntil(this.afterClosed())).subscribe((event) => {
7050
7079
  const isEscapeKey = event.type === "keydown";
7051
7080
  const isBackdropClick = !isEscapeKey;
7052
7081
  if (this._isEscCloseControlledExternally && isEscapeKey || this._isBackdropCloseControlledExternally && isBackdropClick) return;
@@ -7056,6 +7085,10 @@ var OverlayRef = class {
7056
7085
  }
7057
7086
  });
7058
7087
  }
7088
+ isDoubleClickWhileEntering(event) {
7089
+ const state = this._containerInstance.animatedLifecycle.state();
7090
+ return event.detail > 1 && (state === "init" || state === "entering");
7091
+ }
7059
7092
  finishOverlayClose() {
7060
7093
  this._ref.close(this._result, { focusOrigin: this._closeInteractionType });
7061
7094
  this.componentInstance = null;
@@ -20275,6 +20308,10 @@ var ComboboxDirective = class ComboboxDirective {
20275
20308
  })).subscribe();
20276
20309
  }
20277
20310
  close() {
20311
+ if (!this._animatedOverlay.canUnmount()) return;
20312
+ this._animatedOverlay.unmount();
20313
+ }
20314
+ _closeFromOutsideClick() {
20278
20315
  if (!this._isOpen || this._animatedOverlay.isUnmounting()) return;
20279
20316
  this._animatedOverlay.unmount();
20280
20317
  }
@@ -20347,7 +20384,7 @@ var ComboboxDirective = class ComboboxDirective {
20347
20384
  return this._interpretKeyHandlerResult(result);
20348
20385
  }
20349
20386
  if (keyCode === ESCAPE) {
20350
- if (isOpen) {
20387
+ if (this._animatedOverlay.canUnmount()) {
20351
20388
  result.overlayOperation = "close";
20352
20389
  event.preventDefault();
20353
20390
  event.stopPropagation();
@@ -21128,7 +21165,7 @@ var ComboboxBodyComponent = class ComboboxBodyComponent {
21128
21165
  ...inputs
21129
21166
  }))));
21130
21167
  this._bodyTemplate = null;
21131
- outputToObservable(this.clickOutside.didClickOutside).pipe(tap(() => this.combobox.close()), takeUntilDestroyed()).subscribe();
21168
+ outputToObservable(this.clickOutside.didClickOutside).pipe(tap(() => this.combobox._closeFromOutsideClick()), takeUntilDestroyed()).subscribe();
21132
21169
  }
21133
21170
  setColorFromProvider(provider) {
21134
21171
  this.colorProvider.syncWithProvider(provider);
@@ -22132,6 +22169,10 @@ var SelectDirective = class SelectDirective {
22132
22169
  })).subscribe();
22133
22170
  }
22134
22171
  close() {
22172
+ if (!this._animatedOverlay.canUnmount()) return;
22173
+ this._animatedOverlay.unmount();
22174
+ }
22175
+ _closeFromOutsideClick() {
22135
22176
  if (!this._animatedOverlay.isMounted()) return;
22136
22177
  this._animatedOverlay.unmount();
22137
22178
  }
@@ -22363,7 +22404,7 @@ var SelectBodyDirective = class SelectBodyDirective {
22363
22404
  "aria-multiselectable": toSignal(this._select.multiple$),
22364
22405
  "aria-labelledby": toSignal(this._select.input.labelId$)
22365
22406
  });
22366
- outputToObservable(this._clickOutside.didClickOutside).pipe(tap(() => this._select.close()), takeUntilDestroyed()).subscribe();
22407
+ outputToObservable(this._clickOutside.didClickOutside).pipe(tap(() => this._select._closeFromOutsideClick()), takeUntilDestroyed()).subscribe();
22367
22408
  }
22368
22409
  static {
22369
22410
  this.ɵfac = i0.ɵɵngDeclareFactory({