@skyux/core 12.14.3 → 12.16.0

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.
@@ -2,8 +2,8 @@ import * as i0 from '@angular/core';
2
2
  import { NgModule, Injectable, inject, RendererFactory2, NgZone, EventEmitter, Output, Input, Directive, EnvironmentInjector, createEnvironmentInjector, createComponent, ChangeDetectorRef, ElementRef, ViewContainerRef, ViewChild, ChangeDetectionStrategy, Component, InjectionToken, input, effect, Optional, Inject, ApplicationRef, afterNextRender, Injector, Pipe, HostBinding, Renderer2, HostListener } from '@angular/core';
3
3
  import * as i1$1 from '@angular/common';
4
4
  import { DOCUMENT, CommonModule } from '@angular/common';
5
- import { Subject, Subscription, ReplaySubject, fromEvent, of, Observable, filter, map, distinctUntilChanged, shareReplay, observeOn, animationFrameScheduler, takeUntil as takeUntil$1, BehaviorSubject, combineLatestWith, concat } from 'rxjs';
6
- import { takeUntil, debounceTime, switchMap, map as map$1 } from 'rxjs/operators';
5
+ import { Subject, Subscription, ReplaySubject, fromEvent, of, Observable, filter, map, distinctUntilChanged, shareReplay, observeOn, animationFrameScheduler, takeUntil as takeUntil$1, BehaviorSubject, combineLatestWith, switchMap, concat, debounceTime as debounceTime$1 } from 'rxjs';
6
+ import { takeUntil, debounceTime, take } from 'rxjs/operators';
7
7
  import { ViewportRuler } from '@angular/cdk/overlay';
8
8
  import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
9
9
  import * as i1 from '@skyux/i18n';
@@ -3860,10 +3860,12 @@ class SkyScrollableHostService {
3860
3860
  #mutationObserverSvc;
3861
3861
  #windowRef;
3862
3862
  #resizeObserverSvc;
3863
- constructor(mutationObserverSvc, windowRef, resizeObserverSvc) {
3863
+ #zone;
3864
+ constructor(mutationObserverSvc, windowRef, resizeObserverSvc, zone) {
3864
3865
  this.#mutationObserverSvc = mutationObserverSvc;
3865
3866
  this.#resizeObserverSvc = resizeObserverSvc;
3866
3867
  this.#windowRef = windowRef;
3868
+ this.#zone = zone;
3867
3869
  }
3868
3870
  /**
3869
3871
  * Returns the given element's current scrollable host
@@ -3954,7 +3956,7 @@ class SkyScrollableHostService {
3954
3956
  /* istanbul ignore else */
3955
3957
  if (newScrollableHost) {
3956
3958
  scrollEventSubscription = fromEvent(newScrollableHost, 'scroll')
3957
- .pipe(takeUntil(newScrollableHostObservable))
3959
+ .pipe(takeUntil$1(newScrollableHostObservable))
3958
3960
  .subscribe(() => {
3959
3961
  notifySubscribers(subscribers);
3960
3962
  });
@@ -3980,7 +3982,7 @@ class SkyScrollableHostService {
3980
3982
  if (!this.#resizeObserverSvc) {
3981
3983
  return of('none');
3982
3984
  }
3983
- return this.watchScrollableHost(elementRef).pipe(combineLatestWith(additionalContainers), switchMap(([scrollableHost, additionalHosts]) => {
3985
+ const watch = () => this.watchScrollableHost(elementRef).pipe(combineLatestWith(additionalContainers), switchMap(([scrollableHost, additionalHosts]) => {
3984
3986
  const resizeObserverSvc = this.#resizeObserverSvc;
3985
3987
  if (!resizeObserverSvc ||
3986
3988
  ((!scrollableHost ||
@@ -3988,12 +3990,22 @@ class SkyScrollableHostService {
3988
3990
  additionalHosts.length === 0)) {
3989
3991
  return of('none');
3990
3992
  }
3993
+ const hostsParents = additionalHosts
3994
+ .map((container) => container.nativeElement?.offsetParent)
3995
+ .filter(Boolean);
3991
3996
  const inputs = [
3992
3997
  of(undefined),
3998
+ fromEvent(this.#windowRef.nativeWindow, 'resize'),
3999
+ fromEvent(this.#windowRef.nativeWindow, 'scroll'),
3993
4000
  ...additionalHosts.map((container) => resizeObserverSvc.observe(container)),
4001
+ fromEvent(hostsParents, 'scroll'),
4002
+ ...hostsParents.map((hostsParent) => resizeObserverSvc.observe({
4003
+ nativeElement: hostsParent,
4004
+ })),
3994
4005
  ];
3995
4006
  let getHostRect;
3996
- if (scrollableHost && scrollableHost !== this.#windowRef.nativeWindow) {
4007
+ if (scrollableHost &&
4008
+ scrollableHost !== this.#windowRef.nativeWindow) {
3997
4009
  inputs.push(resizeObserverSvc.observe({ nativeElement: scrollableHost }));
3998
4010
  getHostRect = () => scrollableHost.getBoundingClientRect();
3999
4011
  }
@@ -4005,7 +4017,7 @@ class SkyScrollableHostService {
4005
4017
  bottom: this.#windowRef.nativeWindow.innerHeight,
4006
4018
  });
4007
4019
  }
4008
- return concat(inputs).pipe(debounceTime(0, animationFrameScheduler), map$1(() => {
4020
+ return concat(inputs).pipe(observeOn(animationFrameScheduler), debounceTime$1(0), map(() => {
4009
4021
  const viewportSize = this.#getViewportSize();
4010
4022
  let { top, left, right, bottom } = getHostRect();
4011
4023
  for (const container of additionalHosts) {
@@ -4022,6 +4034,13 @@ class SkyScrollableHostService {
4022
4034
  return `inset(${top}px ${viewportSize.width - right}px ${viewportSize.height - bottom}px ${left}px)`;
4023
4035
  }));
4024
4036
  }));
4037
+ /* istanbul ignore else */
4038
+ if (this.#zone) {
4039
+ return this.#zone.runOutsideAngular(watch);
4040
+ }
4041
+ else {
4042
+ return watch();
4043
+ }
4025
4044
  }
4026
4045
  #findScrollableHost(element) {
4027
4046
  const regex = /(auto|scroll)/;
@@ -4080,7 +4099,7 @@ class SkyScrollableHostService {
4080
4099
  height: docElem.clientHeight,
4081
4100
  };
4082
4101
  }
4083
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SkyScrollableHostService, deps: [{ token: SkyMutationObserverService }, { token: SkyAppWindowRef }, { token: SkyResizeObserverService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
4102
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SkyScrollableHostService, deps: [{ token: SkyMutationObserverService }, { token: SkyAppWindowRef }, { token: SkyResizeObserverService, optional: true }, { token: i0.NgZone, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
4084
4103
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SkyScrollableHostService, providedIn: 'root' }); }
4085
4104
  }
4086
4105
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SkyScrollableHostService, decorators: [{
@@ -4090,6 +4109,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
4090
4109
  }]
4091
4110
  }], ctorParameters: () => [{ type: SkyMutationObserverService }, { type: SkyAppWindowRef }, { type: SkyResizeObserverService, decorators: [{
4092
4111
  type: Optional
4112
+ }] }, { type: i0.NgZone, decorators: [{
4113
+ type: Optional
4093
4114
  }] }] });
4094
4115
 
4095
4116
  /**
@@ -4316,7 +4337,7 @@ class SkyViewkeeper {
4316
4337
  syncElPosition(el, boundaryEl) {
4317
4338
  const verticalOffset = this.#calculateVerticalOffset();
4318
4339
  // When the element isn't visible, its size can't be calculated, so don't attempt syncing position in this case.
4319
- if (el.offsetWidth === 0 && el.offsetHeight === 0) {
4340
+ if (this.#isDestroyed || (el.offsetWidth === 0 && el.offsetHeight === 0)) {
4320
4341
  return;
4321
4342
  }
4322
4343
  const boundaryInfo = this.#getBoundaryInfo(el, boundaryEl);
@@ -4344,17 +4365,16 @@ class SkyViewkeeper {
4344
4365
  if (this.#el) {
4345
4366
  this.#unfixEl(this.#el);
4346
4367
  }
4347
- if (this.#verticalOffsetEl) {
4348
- this.#verticalOffsetEl.removeEventListener(EVT_AFTER_VIEWKEEPER_SYNC, this.#syncElPositionHandler);
4349
- this.#verticalOffsetEl.classList.remove(CLS_VIEWKEEPER_FIXED_NOT_LAST);
4350
- }
4368
+ this.#verticalOffsetEl?.removeEventListener(EVT_AFTER_VIEWKEEPER_SYNC, this.#syncElPositionHandler);
4369
+ this.#verticalOffsetEl?.classList.remove(CLS_VIEWKEEPER_FIXED_NOT_LAST);
4351
4370
  this.#spacerResizeObserver?.disconnect();
4352
4371
  this.#boundaryEl?.classList.remove(CLS_VIEWKEEPER_BOUNDARY);
4353
4372
  this.#el =
4354
4373
  this.#boundaryEl =
4355
4374
  this.#verticalOffsetEl =
4356
- this.#spacerResizeObserver =
4357
- undefined;
4375
+ this.#intersectionObserver =
4376
+ this.#spacerResizeObserver =
4377
+ undefined;
4358
4378
  this.#isDestroyed = true;
4359
4379
  }
4360
4380
  }
@@ -4563,6 +4583,8 @@ class SkyViewkeeperDirective {
4563
4583
  #scrollableHostWatchUnsubscribe;
4564
4584
  #viewkeepers = [];
4565
4585
  #viewkeeperSvc;
4586
+ #renderer = inject(RendererFactory2).createRenderer(undefined, null);
4587
+ #shadowElement;
4566
4588
  constructor(el, mutationObserverSvc, viewkeeperSvc, scrollableHostSvc) {
4567
4589
  this.#el = el;
4568
4590
  this.#mutationObserverSvc = mutationObserverSvc;
@@ -4577,16 +4599,24 @@ class SkyViewkeeperDirective {
4577
4599
  });
4578
4600
  }
4579
4601
  ngOnDestroy() {
4580
- /*istanbul ignore else*/
4581
- if (this.#observer) {
4582
- this.#observer.disconnect();
4602
+ this.#observer?.disconnect();
4603
+ this.#scrollableHostWatchUnsubscribe?.next();
4604
+ this.#scrollableHostWatchUnsubscribe?.complete();
4605
+ this.#destroyViewkeepers();
4606
+ if (this.#shadowElement) {
4607
+ this.#renderer.removeChild(this.#el.nativeElement, this.#shadowElement);
4583
4608
  }
4584
- /*istanbul ignore else*/
4585
- if (this.#scrollableHostWatchUnsubscribe) {
4586
- this.#scrollableHostWatchUnsubscribe.next();
4587
- this.#scrollableHostWatchUnsubscribe.complete();
4609
+ }
4610
+ ngAfterViewInit() {
4611
+ const shadowElement = this.#renderer.createElement('div');
4612
+ shadowElement.classList.add('sky-viewkeeper-shadow');
4613
+ if (this.#el.nativeElement.firstChild) {
4614
+ this.#renderer.insertBefore(this.#el.nativeElement, shadowElement, this.#el.nativeElement.firstChild);
4588
4615
  }
4589
- this.#destroyViewkeepers();
4616
+ else {
4617
+ this.#renderer.appendChild(this.#el.nativeElement, shadowElement);
4618
+ }
4619
+ this.#shadowElement = shadowElement;
4590
4620
  }
4591
4621
  #destroyViewkeepers() {
4592
4622
  for (const viewkeeper of this.#viewkeepers) {
@@ -4624,21 +4654,16 @@ class SkyViewkeeperDirective {
4624
4654
  #detectElements() {
4625
4655
  const viewkeeperEls = this.#getViewkeeperEls();
4626
4656
  if (this.#viewkeeperElsChanged(viewkeeperEls)) {
4627
- if (this.#scrollableHostWatchUnsubscribe) {
4628
- this.#scrollableHostWatchUnsubscribe.next();
4629
- this.#scrollableHostWatchUnsubscribe.complete();
4630
- this.#scrollableHostWatchUnsubscribe = new Subject();
4631
- }
4632
- else {
4633
- this.#scrollableHostWatchUnsubscribe = new Subject();
4634
- }
4657
+ this.#scrollableHostWatchUnsubscribe?.next();
4658
+ this.#scrollableHostWatchUnsubscribe?.complete();
4659
+ this.#scrollableHostWatchUnsubscribe = new Subject();
4635
4660
  if (this.#scrollableHostSvc) {
4636
4661
  this.#scrollableHostSvc
4637
4662
  .watchScrollableHost(this.#el)
4638
4663
  .pipe(takeUntil(this.#scrollableHostWatchUnsubscribe))
4639
4664
  .subscribe((scrollableHost) => {
4640
4665
  this.#destroyViewkeepers();
4641
- let previousViewkeeperEl;
4666
+ let previousViewkeeperEl = undefined;
4642
4667
  for (const viewkeeperEl of viewkeeperEls) {
4643
4668
  this.#viewkeepers.push(this.#viewkeeperSvc.create({
4644
4669
  boundaryEl: this.#el.nativeElement,
@@ -4653,11 +4678,32 @@ class SkyViewkeeperDirective {
4653
4678
  }
4654
4679
  });
4655
4680
  }
4681
+ this.#scrollableHostWatchUnsubscribe.pipe(take(1)).subscribe(() => {
4682
+ this.#shadowElement?.classList.remove('sky-viewkeeper-shadow--active');
4683
+ });
4684
+ fromEvent(viewkeeperEls, 'afterViewkeeperSync')
4685
+ .pipe(takeUntil(this.#scrollableHostWatchUnsubscribe), observeOn(animationFrameScheduler))
4686
+ .subscribe(() => {
4687
+ const applicable = viewkeeperEls.filter((el) => el.classList.contains('sky-viewkeeper-fixed') &&
4688
+ (!this.skyViewkeeperOmitShadow ||
4689
+ !el.matches(this.skyViewkeeperOmitShadow)));
4690
+ if (applicable.length === 0) {
4691
+ this.#shadowElement?.classList.remove('sky-viewkeeper-shadow--active');
4692
+ return;
4693
+ }
4694
+ this.#shadowElement?.classList.add('sky-viewkeeper-shadow--active');
4695
+ const boundingRectangles = applicable.map((el) => el.getBoundingClientRect());
4696
+ const left = boundingRectangles.reduce((num, rect) => Math.min(num, rect.left), Number.POSITIVE_INFINITY);
4697
+ const right = boundingRectangles.reduce((num, rect) => Math.max(num, rect.right), Number.NEGATIVE_INFINITY);
4698
+ const top = boundingRectangles.reduce((num, rect) => Math.min(num, rect.top), Number.POSITIVE_INFINITY);
4699
+ const bottom = boundingRectangles.reduce((num, rect) => Math.max(num, rect.bottom), Number.NEGATIVE_INFINITY);
4700
+ this.#renderer.setStyle(this.#shadowElement, 'inset', `${top}px ${window.innerWidth - right}px ${window.innerHeight - bottom}px ${left}px`);
4701
+ });
4656
4702
  this.#currentViewkeeperEls = viewkeeperEls;
4657
4703
  }
4658
4704
  }
4659
4705
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SkyViewkeeperDirective, deps: [{ token: i0.ElementRef }, { token: SkyMutationObserverService }, { token: SkyViewkeeperService }, { token: SkyScrollableHostService, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
4660
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.7", type: SkyViewkeeperDirective, isStandalone: false, selector: "[skyViewkeeper]", inputs: { skyViewkeeper: "skyViewkeeper" }, ngImport: i0 }); }
4706
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.7", type: SkyViewkeeperDirective, isStandalone: false, selector: "[skyViewkeeper]", inputs: { skyViewkeeper: "skyViewkeeper", skyViewkeeperOmitShadow: "skyViewkeeperOmitShadow" }, ngImport: i0 }); }
4661
4707
  }
4662
4708
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SkyViewkeeperDirective, decorators: [{
4663
4709
  type: Directive,
@@ -4669,6 +4715,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
4669
4715
  type: Optional
4670
4716
  }] }], propDecorators: { skyViewkeeper: [{
4671
4717
  type: Input
4718
+ }], skyViewkeeperOmitShadow: [{
4719
+ type: Input
4672
4720
  }] } });
4673
4721
 
4674
4722
  class SkyViewkeeperModule {
@@ -4701,7 +4749,7 @@ class Version {
4701
4749
  /**
4702
4750
  * Represents the version of @skyux/core.
4703
4751
  */
4704
- const VERSION = new Version('12.14.3');
4752
+ const VERSION = new Version('12.16.0');
4705
4753
 
4706
4754
  /**
4707
4755
  * Generated bundle index. Do not edit.