@skyux/core 12.5.0 → 12.7.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.
package/fesm2022/skyux-core.mjs
CHANGED
@@ -2,7 +2,7 @@ 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, concat } from 'rxjs';
|
5
|
+
import { Subject, Subscription, ReplaySubject, fromEvent, of, Observable, filter, map, distinctUntilChanged, shareReplay, observeOn, animationFrameScheduler, takeUntil as takeUntil$1, BehaviorSubject, combineLatestWith, concat } from 'rxjs';
|
6
6
|
import { takeUntil, debounceTime, switchMap, map as map$1 } from 'rxjs/operators';
|
7
7
|
import { ViewportRuler } from '@angular/cdk/overlay';
|
8
8
|
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
@@ -3690,6 +3690,7 @@ class SkyScrollShadowDirective {
|
|
3690
3690
|
return this.#_enabled;
|
3691
3691
|
}
|
3692
3692
|
#currentShadow;
|
3693
|
+
#boxShadows;
|
3693
3694
|
#mutationObserver;
|
3694
3695
|
#ngUnsubscribe;
|
3695
3696
|
#elRef;
|
@@ -3743,11 +3744,83 @@ class SkyScrollShadowDirective {
|
|
3743
3744
|
});
|
3744
3745
|
}
|
3745
3746
|
}
|
3747
|
+
#splitBoxShadowDetails(boxShadow) {
|
3748
|
+
const colorRegex = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/;
|
3749
|
+
const match = boxShadow.match(colorRegex);
|
3750
|
+
if (match) {
|
3751
|
+
const colorParts = `${match[1]}, ${match[2]}, ${match[3]}`; // Extract RGB values as a comma-separated string
|
3752
|
+
const opacity = match[4] ? parseFloat(match[4]) : 1; // Use the captured opacity or default to 1
|
3753
|
+
const lengths = boxShadow.replace(match[0], '').trim(); // Remove the color from the rest
|
3754
|
+
return { colorParts, opacity, lengths };
|
3755
|
+
}
|
3756
|
+
/* istanbul ignore next */
|
3757
|
+
return;
|
3758
|
+
}
|
3759
|
+
#formatBoxShadows(boxShadowString) {
|
3760
|
+
const boxShadows = [];
|
3761
|
+
let currentShadow = '';
|
3762
|
+
let openParentheses = 0;
|
3763
|
+
for (const char of boxShadowString) {
|
3764
|
+
if (char === ',' && openParentheses === 0) {
|
3765
|
+
const details = this.#splitBoxShadowDetails(currentShadow.trim());
|
3766
|
+
if (details) {
|
3767
|
+
boxShadows.push(details);
|
3768
|
+
}
|
3769
|
+
currentShadow = '';
|
3770
|
+
}
|
3771
|
+
else {
|
3772
|
+
currentShadow += char;
|
3773
|
+
if (char === '(') {
|
3774
|
+
openParentheses++;
|
3775
|
+
}
|
3776
|
+
else if (char === ')') {
|
3777
|
+
openParentheses--;
|
3778
|
+
}
|
3779
|
+
}
|
3780
|
+
}
|
3781
|
+
if (currentShadow.trim()) {
|
3782
|
+
const details = this.#splitBoxShadowDetails(currentShadow.trim());
|
3783
|
+
if (details) {
|
3784
|
+
boxShadows.push(details);
|
3785
|
+
}
|
3786
|
+
}
|
3787
|
+
return boxShadows;
|
3788
|
+
}
|
3789
|
+
#getBoxShadowInfo() {
|
3790
|
+
const elStyles = window.getComputedStyle(this.#elRef.nativeElement);
|
3791
|
+
const boxShadowStyle = elStyles.getPropertyValue('--sky-elevation-overflow');
|
3792
|
+
// Creating a temporary element and setting box shadow converts the color in the box shadows to rgba or rgb
|
3793
|
+
const tempEl = document.createElement('div');
|
3794
|
+
tempEl.style.setProperty('box-shadow', boxShadowStyle);
|
3795
|
+
const convertedBoxShadows = tempEl.style.getPropertyValue('box-shadow');
|
3796
|
+
const boxShadows = this.#formatBoxShadows(convertedBoxShadows);
|
3797
|
+
return boxShadows;
|
3798
|
+
}
|
3746
3799
|
#buildShadowStyle(pixelsFromEnd) {
|
3747
|
-
|
3748
|
-
|
3749
|
-
|
3750
|
-
|
3800
|
+
if (!this.#boxShadows) {
|
3801
|
+
const boxShadowInfo = this.#getBoxShadowInfo();
|
3802
|
+
if (boxShadowInfo.length > 0) {
|
3803
|
+
this.#boxShadows = boxShadowInfo;
|
3804
|
+
}
|
3805
|
+
else {
|
3806
|
+
this.#boxShadows = 'none';
|
3807
|
+
}
|
3808
|
+
}
|
3809
|
+
const boxShadowStyles = [];
|
3810
|
+
if (this.#boxShadows === 'none' || pixelsFromEnd === 0) {
|
3811
|
+
return 'none';
|
3812
|
+
}
|
3813
|
+
else {
|
3814
|
+
for (const shadow of this.#boxShadows) {
|
3815
|
+
const { colorParts, lengths, opacity } = shadow;
|
3816
|
+
// Progressively darken the shadow until the user scrolls 30 pixels from the top or bottom
|
3817
|
+
// of the scrollable element, with a max opacity of 0.3.
|
3818
|
+
const adjustedOpacity = Math.min(pixelsFromEnd / 30, 1) * opacity;
|
3819
|
+
const adjustedShadow = `${lengths} rgba(${colorParts}, ${adjustedOpacity})`;
|
3820
|
+
boxShadowStyles.push(adjustedShadow);
|
3821
|
+
}
|
3822
|
+
return boxShadowStyles.join(', ');
|
3823
|
+
}
|
3751
3824
|
}
|
3752
3825
|
#emitShadow(shadow) {
|
3753
3826
|
if (!this.#currentShadow ||
|
@@ -3903,25 +3976,50 @@ class SkyScrollableHostService {
|
|
3903
3976
|
});
|
3904
3977
|
});
|
3905
3978
|
}
|
3906
|
-
watchScrollableHostClipPathChanges(elementRef) {
|
3979
|
+
watchScrollableHostClipPathChanges(elementRef, additionalContainers = of([])) {
|
3907
3980
|
if (!this.#resizeObserverSvc) {
|
3908
3981
|
return of('none');
|
3909
3982
|
}
|
3910
|
-
return this.watchScrollableHost(elementRef).pipe(switchMap((scrollableHost) => {
|
3911
|
-
|
3912
|
-
|
3913
|
-
scrollableHost
|
3983
|
+
return this.watchScrollableHost(elementRef).pipe(combineLatestWith(additionalContainers), switchMap(([scrollableHost, additionalHosts]) => {
|
3984
|
+
const resizeObserverSvc = this.#resizeObserverSvc;
|
3985
|
+
if (!resizeObserverSvc ||
|
3986
|
+
((!scrollableHost ||
|
3987
|
+
scrollableHost === this.#windowRef.nativeWindow) &&
|
3988
|
+
additionalHosts.length === 0)) {
|
3914
3989
|
return of('none');
|
3915
3990
|
}
|
3916
|
-
|
3991
|
+
const inputs = [
|
3917
3992
|
of(undefined),
|
3918
|
-
|
3919
|
-
]
|
3993
|
+
...additionalHosts.map((container) => resizeObserverSvc.observe(container)),
|
3994
|
+
];
|
3995
|
+
let getHostRect;
|
3996
|
+
if (scrollableHost && scrollableHost !== this.#windowRef.nativeWindow) {
|
3997
|
+
inputs.push(resizeObserverSvc.observe({ nativeElement: scrollableHost }));
|
3998
|
+
getHostRect = () => scrollableHost.getBoundingClientRect();
|
3999
|
+
}
|
4000
|
+
else {
|
4001
|
+
getHostRect = () => ({
|
4002
|
+
top: 0,
|
4003
|
+
left: 0,
|
4004
|
+
right: this.#windowRef.nativeWindow.innerWidth,
|
4005
|
+
bottom: this.#windowRef.nativeWindow.innerHeight,
|
4006
|
+
});
|
4007
|
+
}
|
4008
|
+
return concat(inputs).pipe(debounceTime(0, animationFrameScheduler), map$1(() => {
|
3920
4009
|
const viewportSize = this.#getViewportSize();
|
3921
|
-
|
3922
|
-
|
3923
|
-
|
3924
|
-
|
4010
|
+
let { top, left, right, bottom } = getHostRect();
|
4011
|
+
for (const container of additionalHosts) {
|
4012
|
+
if (container.nativeElement?.offsetParent) {
|
4013
|
+
const containerRect = container.nativeElement.getBoundingClientRect();
|
4014
|
+
top = Math.max(top, containerRect.top);
|
4015
|
+
left = Math.max(left, containerRect.left);
|
4016
|
+
right = Math.min(right, containerRect.right);
|
4017
|
+
bottom = Math.min(bottom, containerRect.bottom);
|
4018
|
+
}
|
4019
|
+
}
|
4020
|
+
top = Math.max(0, top);
|
4021
|
+
left = Math.max(0, left);
|
4022
|
+
return `inset(${top}px ${viewportSize.width - right}px ${viewportSize.height - bottom}px ${left}px)`;
|
3925
4023
|
}));
|
3926
4024
|
}));
|
3927
4025
|
}
|
@@ -4603,7 +4701,7 @@ class Version {
|
|
4603
4701
|
/**
|
4604
4702
|
* Represents the version of @skyux/core.
|
4605
4703
|
*/
|
4606
|
-
const VERSION = new Version('12.
|
4704
|
+
const VERSION = new Version('12.7.0');
|
4607
4705
|
|
4608
4706
|
/**
|
4609
4707
|
* Generated bundle index. Do not edit.
|