@skyux/core 5.7.1 → 5.8.1

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.
@@ -1587,7 +1587,7 @@
1587
1587
  this.currentSubject.complete();
1588
1588
  };
1589
1589
  /**
1590
- * Suscribes to screen size changes.
1590
+ * Subscribes to screen size changes.
1591
1591
  * @param listener Specifies a function that is called when breakpoints change.
1592
1592
  */
1593
1593
  SkyMediaQueryService.prototype.subscribe = function (listener) {
@@ -2904,6 +2904,196 @@
2904
2904
  }]
2905
2905
  }] });
2906
2906
 
2907
+ /**
2908
+ * Service to create rxjs observables for changes to the content box dimensions of elements.
2909
+ */
2910
+ var SkyResizeObserverService = /** @class */ (function () {
2911
+ function SkyResizeObserverService(zone) {
2912
+ var _this = this;
2913
+ this.zone = zone;
2914
+ this._tracking = [];
2915
+ this._resizeObserver = new ResizeObserver(function (entries) {
2916
+ entries.forEach(function (entry) { return _this.callback(entry); });
2917
+ });
2918
+ }
2919
+ SkyResizeObserverService.prototype.ngOnDestroy = function () {
2920
+ this._resizeObserver.disconnect();
2921
+ };
2922
+ /**
2923
+ * Create rxjs observable to get size changes for an element ref.
2924
+ */
2925
+ SkyResizeObserverService.prototype.observe = function (element) {
2926
+ return this.observeAndTrack(element).subjectObservable;
2927
+ };
2928
+ SkyResizeObserverService.prototype.observeAndTrack = function (element) {
2929
+ var _this = this;
2930
+ var checkTracking = this._tracking.findIndex(function (value) {
2931
+ return !value.subject.closed && value.element === element.nativeElement;
2932
+ });
2933
+ if (checkTracking === -1) {
2934
+ this._resizeObserver.observe(element.nativeElement);
2935
+ }
2936
+ var subject = new rxjs.Subject();
2937
+ var subjectObservable = subject.pipe(operators.finalize(function () {
2938
+ // Are there any other tracking entries still watching this element?
2939
+ var checkTracking = _this._tracking.findIndex(function (value) {
2940
+ return (value.subject !== subject &&
2941
+ !value.subject.closed &&
2942
+ value.element === element.nativeElement);
2943
+ });
2944
+ if (checkTracking === -1) {
2945
+ _this._resizeObserver.unobserve(element.nativeElement);
2946
+ }
2947
+ }));
2948
+ var tracking = {
2949
+ element: element.nativeElement,
2950
+ subject: subject,
2951
+ subjectObservable: subjectObservable,
2952
+ };
2953
+ this._tracking.push(tracking);
2954
+ return tracking;
2955
+ };
2956
+ SkyResizeObserverService.prototype.callback = function (entry) {
2957
+ var _this = this;
2958
+ this._tracking
2959
+ .filter(function (value) { return !(value.subject.closed || value.subject.isStopped); })
2960
+ .forEach(function (value) {
2961
+ /* istanbul ignore else */
2962
+ if (value.element === entry.target) {
2963
+ _this.zone.run(function () {
2964
+ value.subject.next(entry);
2965
+ });
2966
+ }
2967
+ });
2968
+ };
2969
+ return SkyResizeObserverService;
2970
+ }());
2971
+ SkyResizeObserverService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyResizeObserverService, deps: [{ token: i0__namespace.NgZone }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2972
+ SkyResizeObserverService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyResizeObserverService, providedIn: 'any' });
2973
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyResizeObserverService, decorators: [{
2974
+ type: i0.Injectable,
2975
+ args: [{
2976
+ providedIn: 'any',
2977
+ }]
2978
+ }], ctorParameters: function () { return [{ type: i0__namespace.NgZone }]; } });
2979
+
2980
+ /**
2981
+ * Acts like `SkyMediaQueryService` for a container element, emitting the same responsive breakpoints.
2982
+ */
2983
+ var SkyResizeObserverMediaQueryService = /** @class */ (function () {
2984
+ function SkyResizeObserverMediaQueryService(resizeObserverService) {
2985
+ var _this = this;
2986
+ this.resizeObserverService = resizeObserverService;
2987
+ this._breakpoints = [
2988
+ {
2989
+ check: function (width) { return width <= 767; },
2990
+ name: exports.SkyMediaBreakpoints.xs,
2991
+ },
2992
+ {
2993
+ check: function (width) { return width > 767 && width <= 991; },
2994
+ name: exports.SkyMediaBreakpoints.sm,
2995
+ },
2996
+ {
2997
+ check: function (width) { return width > 991 && width <= 1199; },
2998
+ name: exports.SkyMediaBreakpoints.md,
2999
+ },
3000
+ {
3001
+ check: function (width) { return width > 1199; },
3002
+ name: exports.SkyMediaBreakpoints.lg,
3003
+ },
3004
+ ];
3005
+ this._currentBreakpointObservable = new rxjs.ReplaySubject(1);
3006
+ this._stopListening = new rxjs.Subject();
3007
+ this._stopListening.subscribe(function () {
3008
+ _this._target = undefined;
3009
+ _this.updateBreakpoint(undefined);
3010
+ });
3011
+ }
3012
+ Object.defineProperty(SkyResizeObserverMediaQueryService.prototype, "current", {
3013
+ /**
3014
+ * Returns the current breakpoint.
3015
+ */
3016
+ get: function () {
3017
+ return this._currentBreakpoint;
3018
+ },
3019
+ enumerable: false,
3020
+ configurable: true
3021
+ });
3022
+ SkyResizeObserverMediaQueryService.prototype.ngOnDestroy = function () {
3023
+ this._stopListening.next();
3024
+ this._currentBreakpoint = undefined;
3025
+ this._stopListening.complete();
3026
+ this._currentBreakpointObservable.complete();
3027
+ };
3028
+ /**
3029
+ * @internal
3030
+ */
3031
+ SkyResizeObserverMediaQueryService.prototype.destroy = function () {
3032
+ this.ngOnDestroy();
3033
+ };
3034
+ /**
3035
+ * Sets the container element to watch. The `SkyResizeObserverMediaQueryService` will only observe one element at a
3036
+ * time. Any previous subscriptions will be unsubscribed when a new element is observed.
3037
+ */
3038
+ SkyResizeObserverMediaQueryService.prototype.observe = function (element) {
3039
+ var _this = this;
3040
+ if (this._target) {
3041
+ if (this._target === element) {
3042
+ return this;
3043
+ }
3044
+ this._stopListening.next();
3045
+ }
3046
+ this._target = element;
3047
+ var width = element.nativeElement.offsetWidth;
3048
+ if (width) {
3049
+ var breakpoint = this.checkBreakpoint(width);
3050
+ this.updateBreakpoint(breakpoint);
3051
+ }
3052
+ this._resizeSubscription = this.resizeObserverService
3053
+ .observe(element)
3054
+ .pipe(operators.takeUntil(this._stopListening))
3055
+ .subscribe(function (value) {
3056
+ var breakpoint = _this.checkBreakpoint(value.contentRect.width);
3057
+ /* istanbul ignore else */
3058
+ if (breakpoint !== _this._currentBreakpoint) {
3059
+ _this.updateBreakpoint(breakpoint);
3060
+ }
3061
+ });
3062
+ return this;
3063
+ };
3064
+ /**
3065
+ * Stop watching the container element.
3066
+ */
3067
+ SkyResizeObserverMediaQueryService.prototype.unobserve = function () {
3068
+ this._stopListening.next();
3069
+ };
3070
+ /**
3071
+ * Subscribes to element size changes that cross breakpoints.
3072
+ */
3073
+ SkyResizeObserverMediaQueryService.prototype.subscribe = function (listener) {
3074
+ return this._currentBreakpointObservable
3075
+ .pipe(operators.takeUntil(this._stopListening))
3076
+ .subscribe(listener);
3077
+ };
3078
+ SkyResizeObserverMediaQueryService.prototype.updateBreakpoint = function (breakpoint) {
3079
+ this._currentBreakpoint = breakpoint;
3080
+ this._currentBreakpointObservable.next(breakpoint);
3081
+ };
3082
+ SkyResizeObserverMediaQueryService.prototype.checkBreakpoint = function (width) {
3083
+ var _a;
3084
+ return (_a = this._breakpoints.find(function (breakpoint) { return breakpoint.check(width); })) === null || _a === void 0 ? void 0 : _a.name;
3085
+ };
3086
+ return SkyResizeObserverMediaQueryService;
3087
+ }());
3088
+ SkyResizeObserverMediaQueryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyResizeObserverMediaQueryService, deps: [{ token: SkyResizeObserverService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
3089
+ SkyResizeObserverMediaQueryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyResizeObserverMediaQueryService, providedIn: 'any' });
3090
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyResizeObserverMediaQueryService, decorators: [{
3091
+ type: i0.Injectable,
3092
+ args: [{
3093
+ providedIn: 'any',
3094
+ }]
3095
+ }], ctorParameters: function () { return [{ type: SkyResizeObserverService }]; } });
3096
+
2907
3097
  function notifySubscribers(subscribers, item) {
2908
3098
  var e_1, _a;
2909
3099
  try {
@@ -3632,6 +3822,8 @@
3632
3822
  exports.SkyOverlayService = SkyOverlayService;
3633
3823
  exports.SkyPercentPipe = SkyPercentPipe;
3634
3824
  exports.SkyPercentPipeModule = SkyPercentPipeModule;
3825
+ exports.SkyResizeObserverMediaQueryService = SkyResizeObserverMediaQueryService;
3826
+ exports.SkyResizeObserverService = SkyResizeObserverService;
3635
3827
  exports.SkyScrollableHostService = SkyScrollableHostService;
3636
3828
  exports.SkyUIConfigService = SkyUIConfigService;
3637
3829
  exports.SkyViewkeeperHostOptions = SkyViewkeeperHostOptions;