@ethlete/core 5.0.0-next.31 → 5.0.0-next.32

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,11 @@
1
1
  # @ethlete/core
2
2
 
3
+ ## 5.0.0-next.32
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ed58b19`](https://github.com/ethlete-io/ethdk/commit/ed58b19b1957f2051e0f1ef68c3814747af9ccd0) Thanks [@TomTomB](https://github.com/TomTomB)! - `etAutoSurface`: opening an overlay (date-picker, select, menu, …) no longer elevates unrelated surfaces on the base page. The overlay surface-context tracker is now matched by DOM containment, so an `etAutoSurface` only adopts an overlay's elevation when it actually renders inside that overlay's pane.
8
+
3
9
  ## 5.0.0-next.31
4
10
 
5
11
  ### Minor Changes
@@ -7577,15 +7577,26 @@ const [provideSurfaceContextTracker, injectSurfaceContextTracker] = createRootPr
7577
7577
  ...(ngDevMode ? [{ debugName: "topType" }] : /* istanbul ignore next */ []));
7578
7578
  const topElevation = computed(() => topEntry()?.elevation ?? 0, /* @ts-ignore */
7579
7579
  ...(ngDevMode ? [{ debugName: "topElevation" }] : /* istanbul ignore next */ []));
7580
- const register = (type, elevation) => {
7580
+ const register = (type, elevation, element) => {
7581
7581
  const id = `surface-ctx-${uniqueId++}`;
7582
- const entry = { id, type, elevation };
7582
+ const entry = { id, type, elevation, element };
7583
7583
  entries.update((e) => [...e, entry]);
7584
7584
  return () => {
7585
7585
  entries.update((e) => e.filter((item) => item.id !== id));
7586
7586
  };
7587
7587
  };
7588
- return { topType, topElevation, register };
7588
+ const surfaceForElement = (host) => {
7589
+ const stack = entries();
7590
+ // Walk newest-first so the innermost overlay containing `host` wins.
7591
+ for (let i = stack.length - 1; i >= 0; i--) {
7592
+ const entry = stack[i];
7593
+ if (entry && entry.element.contains(host)) {
7594
+ return { type: entry.type, elevation: entry.elevation };
7595
+ }
7596
+ }
7597
+ return null;
7598
+ };
7599
+ return { topType, topElevation, register, surfaceForElement };
7589
7600
  }, { name: 'SurfaceContextTracker' });
7590
7601
 
7591
7602
  class AutoSurfaceDirective {
@@ -7605,6 +7616,7 @@ class AutoSurfaceDirective {
7605
7616
  this.contextSurfaceProvider = inject(SURFACE_PROVIDER, { optional: true, skipSelf: true });
7606
7617
  this.surfaceThemes = injectSurfaceThemes({ optional: true });
7607
7618
  this.surfaceContextTracker = injectSurfaceContextTracker();
7619
+ this.elementRef = inject(ElementRef);
7608
7620
  /**
7609
7621
  * Explicit surface provider to resolve the surface relative to. Falls back to the
7610
7622
  * surface provider from the surrounding (trigger) context when not set.
@@ -7627,12 +7639,16 @@ class AutoSurfaceDirective {
7627
7639
  // An overlay's projected/portaled content keeps the injector of where it was
7628
7640
  // *declared* (the trigger location), not the pane it renders into — so the
7629
7641
  // injector-derived parent surface is one elevation too low. The surface-context
7630
- // tracker records the innermost open overlay's surface across that boundary, so
7631
- // consult it and take whichever parent surface sits higher. Panels that are
7632
- // themselves the overlay's surface opt out via ignoreOverlaySurfaceContext().
7633
- const overlayActive = this.consultsOverlayContext() && this.surfaceContextTracker.topType() !== null;
7634
- const overlayElevation = overlayActive ? this.surfaceContextTracker.topElevation() : null;
7635
- const overlayType = overlayActive ? this.surfaceContextTracker.topType() : null;
7642
+ // tracker records each open overlay's surface *and* its pane element, so we consult
7643
+ // only the overlay whose pane actually contains this element in the DOM (portaling
7644
+ // moves the DOM into the pane even though the injector stays at the trigger). An
7645
+ // auto-surface on the base page therefore stays put when an overlay opens elsewhere.
7646
+ // Panels that are themselves the overlay's surface opt out via ignoreOverlaySurfaceContext().
7647
+ const overlaySurface = this.consultsOverlayContext()
7648
+ ? this.surfaceContextTracker.surfaceForElement(this.elementRef.nativeElement)
7649
+ : null;
7650
+ const overlayElevation = overlaySurface?.elevation ?? null;
7651
+ const overlayType = overlaySurface?.type ?? null;
7636
7652
  let parentElevation;
7637
7653
  let parentType;
7638
7654
  if (overlayElevation !== null && (contextElevation === null || overlayElevation > contextElevation)) {