@skyux/core 5.9.7 → 5.10.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.
Files changed (33) hide show
  1. package/bundles/skyux-core-testing.umd.js +30 -0
  2. package/bundles/skyux-core.umd.js +1000 -980
  3. package/documentation.json +104 -104
  4. package/esm2015/lib/modules/adapter-service/adapter.service.js +10 -6
  5. package/esm2015/lib/modules/adapter-service/adapter.service.js.map +1 -1
  6. package/esm2015/lib/modules/affix/affix.service.js +6 -2
  7. package/esm2015/lib/modules/affix/affix.service.js.map +1 -1
  8. package/esm2015/lib/modules/resize-observer/resize-observer-media-query.service.js +28 -21
  9. package/esm2015/lib/modules/resize-observer/resize-observer-media-query.service.js.map +1 -1
  10. package/esm2015/lib/modules/resize-observer/resize-observer.service.js +16 -10
  11. package/esm2015/lib/modules/resize-observer/resize-observer.service.js.map +1 -1
  12. package/esm2015/lib/modules/scrollable-host/scrollable-host.service.js +28 -25
  13. package/esm2015/lib/modules/scrollable-host/scrollable-host.service.js.map +1 -1
  14. package/esm2015/testing/core-testing.module.js +29 -0
  15. package/esm2015/testing/core-testing.module.js.map +1 -0
  16. package/esm2015/testing/mock-media-query.service.js +2 -0
  17. package/esm2015/testing/mock-media-query.service.js.map +1 -1
  18. package/esm2015/testing/mock-ui-config.service.js.map +1 -1
  19. package/esm2015/testing/public-api.js +1 -0
  20. package/esm2015/testing/public-api.js.map +1 -1
  21. package/fesm2015/skyux-core-testing.js +28 -2
  22. package/fesm2015/skyux-core-testing.js.map +1 -1
  23. package/fesm2015/skyux-core.js +85 -64
  24. package/fesm2015/skyux-core.js.map +1 -1
  25. package/lib/modules/adapter-service/adapter.service.d.ts +1 -1
  26. package/lib/modules/affix/affix.service.d.ts +1 -1
  27. package/lib/modules/resize-observer/resize-observer-media-query.service.d.ts +1 -4
  28. package/lib/modules/resize-observer/resize-observer.service.d.ts +1 -2
  29. package/lib/modules/scrollable-host/scrollable-host.service.d.ts +7 -4
  30. package/package.json +2 -2
  31. package/testing/core-testing.module.d.ts +6 -0
  32. package/testing/mock-ui-config.service.d.ts +2 -1
  33. package/testing/public-api.d.ts +1 -0
@@ -1,3 +1,5 @@
1
+ var _SkyCoreAdapterService_renderer;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { Injectable, RendererFactory2, } from '@angular/core';
2
4
  import { SkyMediaBreakpoints } from '../media-query/media-breakpoints';
3
5
  import * as i0 from "@angular/core";
@@ -17,7 +19,8 @@ const SKY_TABBABLE_SELECTOR = [
17
19
  export class SkyCoreAdapterService {
18
20
  constructor(rendererFactory) {
19
21
  this.rendererFactory = rendererFactory;
20
- this.renderer = this.rendererFactory.createRenderer(undefined, undefined);
22
+ _SkyCoreAdapterService_renderer.set(this, void 0);
23
+ __classPrivateFieldSet(this, _SkyCoreAdapterService_renderer, this.rendererFactory.createRenderer(undefined, null), "f");
21
24
  }
22
25
  /**
23
26
  * Set the responsive container CSS class for a given element.
@@ -28,10 +31,10 @@ export class SkyCoreAdapterService {
28
31
  */
29
32
  setResponsiveContainerClass(elementRef, breakpoint) {
30
33
  const nativeEl = elementRef.nativeElement;
31
- this.renderer.removeClass(nativeEl, 'sky-responsive-container-xs');
32
- this.renderer.removeClass(nativeEl, 'sky-responsive-container-sm');
33
- this.renderer.removeClass(nativeEl, 'sky-responsive-container-md');
34
- this.renderer.removeClass(nativeEl, 'sky-responsive-container-lg');
34
+ __classPrivateFieldGet(this, _SkyCoreAdapterService_renderer, "f").removeClass(nativeEl, 'sky-responsive-container-xs');
35
+ __classPrivateFieldGet(this, _SkyCoreAdapterService_renderer, "f").removeClass(nativeEl, 'sky-responsive-container-sm');
36
+ __classPrivateFieldGet(this, _SkyCoreAdapterService_renderer, "f").removeClass(nativeEl, 'sky-responsive-container-md');
37
+ __classPrivateFieldGet(this, _SkyCoreAdapterService_renderer, "f").removeClass(nativeEl, 'sky-responsive-container-lg');
35
38
  let newClass;
36
39
  switch (breakpoint) {
37
40
  case SkyMediaBreakpoints.xs: {
@@ -51,7 +54,7 @@ export class SkyCoreAdapterService {
51
54
  break;
52
55
  }
53
56
  }
54
- this.renderer.addClass(nativeEl, newClass);
57
+ __classPrivateFieldGet(this, _SkyCoreAdapterService_renderer, "f").addClass(nativeEl, newClass);
55
58
  }
56
59
  /**
57
60
  * This method temporarily enables/disables pointer events.
@@ -215,6 +218,7 @@ export class SkyCoreAdapterService {
215
218
  return hasBounds;
216
219
  }
217
220
  }
221
+ _SkyCoreAdapterService_renderer = new WeakMap();
218
222
  SkyCoreAdapterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyCoreAdapterService, deps: [{ token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable });
219
223
  SkyCoreAdapterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyCoreAdapterService, providedIn: 'root' });
220
224
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyCoreAdapterService, decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/adapter-service/adapter.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;;AAIvE,MAAM,qBAAqB,GAAG;IAC5B,SAAS;IACT,YAAY;IACZ,uBAAuB;IACvB,wBAAwB;IACxB,wBAAwB;IACxB,0BAA0B;IAC1B,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,yCAAyC;IACzC,6BAA6B;CAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAKb,MAAM,OAAO,qBAAqB;IAGhC,YAAoB,eAAiC;QAAjC,oBAAe,GAAf,eAAe,CAAkB;QACn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QAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,KAAK,MAAM,IAAI,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC;QAC3E,IAAI,QAAQ,EAAE;YACZ,OAAO,KAAK,CAAC;SACd;QAED,MAAM,SAAS,GAAG,CAAC,CAAC,CAClB,OAAO,CAAC,WAAW;YACnB,OAAO,CAAC,YAAY;YACpB,OAAO,CAAC,cAAc,EAAE,CAAC,MAAM,CAChC,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;;mHA7PU,qBAAqB;uHAArB,qBAAqB,cAFpB,MAAM;4FAEP,qBAAqB;kBAHjC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import {\n ElementRef,\n Injectable,\n Renderer2,\n RendererFactory2,\n} from '@angular/core';\n\nimport { SkyMediaBreakpoints } from '../media-query/media-breakpoints';\n\nimport { SkyFocusableChildrenOptions } from './focusable-children-options';\n\nconst SKY_TABBABLE_SELECTOR = [\n 'a[href]',\n 'area[href]',\n 'input:not([disabled])',\n 'button:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'iframe',\n 'object',\n 'embed',\n '*[contenteditable=true]:not([disabled])',\n '*[tabindex]:not([disabled])',\n].join(', ');\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyCoreAdapterService {\n private renderer: Renderer2;\n\n constructor(private rendererFactory: RendererFactory2) {\n this.renderer = this.rendererFactory.createRenderer(undefined, undefined);\n }\n\n /**\n * Set the responsive container CSS class for a given element.\n *\n * @param elementRef - The element that will recieve the new CSS class.\n * @param breakpoint - The SkyMediaBreakpoint will determine which class\n * gets set. For example a SkyMediaBreakpoint of `xs` will set a CSS class of `sky-responsive-container-xs`.\n */\n public setResponsiveContainerClass(\n elementRef: ElementRef,\n breakpoint: SkyMediaBreakpoints\n ): void {\n const nativeEl: HTMLElement = elementRef.nativeElement;\n\n this.renderer.removeClass(nativeEl, 'sky-responsive-container-xs');\n this.renderer.removeClass(nativeEl, 'sky-responsive-container-sm');\n this.renderer.removeClass(nativeEl, 'sky-responsive-container-md');\n this.renderer.removeClass(nativeEl, 'sky-responsive-container-lg');\n\n let newClass: string;\n\n switch (breakpoint) {\n case SkyMediaBreakpoints.xs: {\n newClass = 'sky-responsive-container-xs';\n break;\n }\n case SkyMediaBreakpoints.sm: {\n newClass = 'sky-responsive-container-sm';\n break;\n }\n case SkyMediaBreakpoints.md: {\n newClass = 'sky-responsive-container-md';\n break;\n }\n default: {\n newClass = 'sky-responsive-container-lg';\n break;\n }\n }\n\n this.renderer.addClass(nativeEl, newClass);\n }\n\n /**\n * This method temporarily enables/disables pointer events.\n * This is helpful to prevent iFrames from interfering with drag events.\n *\n * @param enable - Set to `true` to enable pointer events. Set to `false` to disable.\n */\n public toggleIframePointerEvents(enable: boolean): void {\n const iframes = document.querySelectorAll('iframe');\n for (let i = 0; i < iframes.length; i++) {\n // Setting to empty string will allow iframe to fall back to its prior CSS assignment.\n iframes[i].style.pointerEvents = enable ? '' : 'none';\n }\n }\n\n /**\n * Focuses on the first element found with an `autofocus` attribute inside the supplied `elementRef`.\n *\n * @param elementRef - The element to search within.\n * @return Returns `true` if a child element with autofocus is found.\n */\n public applyAutoFocus(elementRef: ElementRef): boolean {\n if (!elementRef) {\n return false;\n }\n\n const elementWithAutoFocus =\n elementRef.nativeElement.querySelector('[autofocus]');\n\n // Child was found with the autofocus property. Set focus and return true.\n if (elementWithAutoFocus) {\n elementWithAutoFocus.focus();\n return true;\n }\n\n // No children were found with autofocus property. Return false.\n return false;\n }\n\n /**\n * Sets focus on the first focusable child of the `elementRef` parameter.\n * If no focusable children are found, and `focusOnContainerIfNoChildrenFound` is `true`,\n * focus will be set on the container element.\n *\n * @param elementRef - The element to search within.\n * @param containerSelector - A CSS selector indicating the container that should\n * recieve focus if no focusable children are found.\n * @param focusOnContainerIfNoChildrenFound - It set to `true`, the container will\n * recieve focus if no focusable children are found.\n */\n public getFocusableChildrenAndApplyFocus(\n elementRef: ElementRef,\n containerSelector: string,\n focusOnContainerIfNoChildrenFound: boolean = false\n ): void {\n const containerElement =\n elementRef.nativeElement.querySelector(containerSelector);\n\n if (containerElement) {\n const focusableChildren = this.getFocusableChildren(containerElement);\n\n // Focus first focusable child if available. Otherwise, set focus on container.\n if (\n !this.focusFirstElement(focusableChildren) &&\n focusOnContainerIfNoChildrenFound\n ) {\n containerElement.focus();\n }\n }\n }\n\n /**\n * Returns an array of all focusable children of provided `element`.\n *\n * @param element - The HTMLElement to search within.\n * @param options - Options for getting focusable children.\n */\n public getFocusableChildren(\n element: HTMLElement,\n options?: SkyFocusableChildrenOptions\n ): HTMLElement[] {\n if (!element) {\n return [];\n }\n\n let elements = Array.prototype.slice.call(\n element.querySelectorAll(SKY_TABBABLE_SELECTOR)\n );\n\n // Unless ignoreTabIndex = true, filter out elements with tabindex = -1.\n if (!options || !options.ignoreTabIndex) {\n elements = elements.filter((el: HTMLElement) => {\n return el.tabIndex !== -1;\n });\n }\n\n // Unless ignoreVisibility = true, filter out elements that are not visible.\n if (!options || !options.ignoreVisibility) {\n elements = elements.filter((el: HTMLElement) => {\n return this.isVisible(el);\n });\n }\n\n return elements;\n }\n\n /**\n * Returns the clientWidth of the provided elementRef.\n * @param elementRef - The element to calculate width from.\n */\n public getWidth(elementRef: ElementRef): number {\n return elementRef.nativeElement.clientWidth;\n }\n\n /**\n * Checks if an event target has a higher z-index than a given element.\n * @param target The event target element.\n * @param element The element to test against. A z-index must be explicitly set for this element.\n */\n public isTargetAboveElement(\n target: EventTarget,\n element: HTMLElement\n ): boolean {\n const zIndex: string = getComputedStyle(element).zIndex;\n\n let el: HTMLElement = target as HTMLElement;\n\n while (el) {\n // Getting the computed style only works for elements that exist in the DOM.\n // In certain scenarios, an element is removed after a click event; by the time the event\n // bubbles up to other elements, however, the element has been removed and the computed style returns empty.\n // In this case, we'll need to check the z-index directly, via the style property.\n const targetZIndex: string =\n getComputedStyle(el).zIndex || el.style.zIndex;\n if (\n targetZIndex !== '' &&\n targetZIndex !== 'auto' &&\n +targetZIndex > +zIndex\n ) {\n return true;\n }\n\n el = el.parentElement as HTMLElement;\n }\n\n return false;\n }\n\n /**\n * Remove inline height styles from the provided elements.\n * @param elementRef - The element to search within.\n * @param selector - The CSS selector to use when finding elements for removing height.\n */\n public resetHeight(elementRef: ElementRef, selector: string): void {\n const children = elementRef.nativeElement.querySelectorAll(selector);\n /* istanbul ignore else */\n if (children.length > 0) {\n for (let i = 0; i < children.length; i++) {\n // Setting style attributes with Web API requires null instead of undefined.\n // tslint:disable-next-line: no-null-keyword\n children[i].style.height = null;\n }\n }\n }\n\n /**\n * Sets all element heights to match the height of the tallest element.\n * @param elementRef - The element to search within.\n * @param selector - The CSS selector to use when finding elements for syncing height.\n */\n public syncMaxHeight(elementRef: ElementRef, selector: string): void {\n const children = elementRef.nativeElement.querySelectorAll(selector);\n /* istanbul ignore else */\n if (children.length > 0) {\n let maxHeight = 0;\n for (let i = 0; i < children.length; i++) {\n maxHeight = Math.max(maxHeight, children[i].offsetHeight);\n }\n for (let i = 0; i < children.length; i++) {\n children[i].style.height = maxHeight + 'px';\n }\n }\n }\n\n private focusFirstElement(list: Array<HTMLElement>): boolean {\n if (list.length > 0) {\n list[0].focus();\n return true;\n }\n return false;\n }\n\n private isVisible(element: HTMLElement): boolean {\n const style = window.getComputedStyle(element);\n const isHidden = style.display === 'none' || style.visibility === 'hidden';\n if (isHidden) {\n return false;\n }\n\n const hasBounds = !!(\n element.offsetWidth ||\n element.offsetHeight ||\n element.getClientRects().length\n );\n return hasBounds;\n }\n}\n"]}
1
+ {"version":3,"file":"adapter.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/adapter-service/adapter.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAEL,UAAU,EAEV,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;;AAIvE,MAAM,qBAAqB,GAAG;IAC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,CAAC;IAEO,iBAAiB,CAAC,IAAwB;QAChD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,SAAS,CAAC,OAAoB;QACpC,MAAM,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,KAAK,MAAM,IAAI,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC;QAC3E,IAAI,QAAQ,EAAE;YACZ,OAAO,KAAK,CAAC;SACd;QAED,MAAM,SAAS,GAAG,CAAC,CAAC,CAClB,OAAO,CAAC,WAAW;YACnB,OAAO,CAAC,YAAY;YACpB,OAAO,CAAC,cAAc,EAAE,CAAC,MAAM,CAChC,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;;;mHA5PU,qBAAqB;uHAArB,qBAAqB,cAFpB,MAAM;4FAEP,qBAAqB;kBAHjC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import {\n ElementRef,\n Injectable,\n Renderer2,\n RendererFactory2,\n} from '@angular/core';\n\nimport { SkyMediaBreakpoints } from '../media-query/media-breakpoints';\n\nimport { SkyFocusableChildrenOptions } from './focusable-children-options';\n\nconst SKY_TABBABLE_SELECTOR = [\n 'a[href]',\n 'area[href]',\n 'input:not([disabled])',\n 'button:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'iframe',\n 'object',\n 'embed',\n '*[contenteditable=true]:not([disabled])',\n '*[tabindex]:not([disabled])',\n].join(', ');\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyCoreAdapterService {\n #renderer: Renderer2;\n\n constructor(private rendererFactory: RendererFactory2) {\n this.#renderer = this.rendererFactory.createRenderer(undefined, null);\n }\n\n /**\n * Set the responsive container CSS class for a given element.\n *\n * @param elementRef - The element that will recieve the new CSS class.\n * @param breakpoint - The SkyMediaBreakpoint will determine which class\n * gets set. For example a SkyMediaBreakpoint of `xs` will set a CSS class of `sky-responsive-container-xs`.\n */\n public setResponsiveContainerClass(\n elementRef: ElementRef,\n breakpoint: SkyMediaBreakpoints\n ): void {\n const nativeEl = elementRef.nativeElement;\n\n this.#renderer.removeClass(nativeEl, 'sky-responsive-container-xs');\n this.#renderer.removeClass(nativeEl, 'sky-responsive-container-sm');\n this.#renderer.removeClass(nativeEl, 'sky-responsive-container-md');\n this.#renderer.removeClass(nativeEl, 'sky-responsive-container-lg');\n\n let newClass: string;\n\n switch (breakpoint) {\n case SkyMediaBreakpoints.xs: {\n newClass = 'sky-responsive-container-xs';\n break;\n }\n case SkyMediaBreakpoints.sm: {\n newClass = 'sky-responsive-container-sm';\n break;\n }\n case SkyMediaBreakpoints.md: {\n newClass = 'sky-responsive-container-md';\n break;\n }\n default: {\n newClass = 'sky-responsive-container-lg';\n break;\n }\n }\n\n this.#renderer.addClass(nativeEl, newClass);\n }\n\n /**\n * This method temporarily enables/disables pointer events.\n * This is helpful to prevent iFrames from interfering with drag events.\n *\n * @param enable - Set to `true` to enable pointer events. Set to `false` to disable.\n */\n public toggleIframePointerEvents(enable: boolean): void {\n const iframes = document.querySelectorAll('iframe');\n for (let i = 0; i < iframes.length; i++) {\n // Setting to empty string will allow iframe to fall back to its prior CSS assignment.\n iframes[i].style.pointerEvents = enable ? '' : 'none';\n }\n }\n\n /**\n * Focuses on the first element found with an `autofocus` attribute inside the supplied `elementRef`.\n *\n * @param elementRef - The element to search within.\n * @return Returns `true` if a child element with autofocus is found.\n */\n public applyAutoFocus(elementRef: ElementRef): boolean {\n if (!elementRef) {\n return false;\n }\n\n const elementWithAutoFocus =\n elementRef.nativeElement.querySelector('[autofocus]');\n\n // Child was found with the autofocus property. Set focus and return true.\n if (elementWithAutoFocus) {\n elementWithAutoFocus.focus();\n return true;\n }\n\n // No children were found with autofocus property. Return false.\n return false;\n }\n\n /**\n * Sets focus on the first focusable child of the `elementRef` parameter.\n * If no focusable children are found, and `focusOnContainerIfNoChildrenFound` is `true`,\n * focus will be set on the container element.\n *\n * @param elementRef - The element to search within.\n * @param containerSelector - A CSS selector indicating the container that should\n * recieve focus if no focusable children are found.\n * @param focusOnContainerIfNoChildrenFound - It set to `true`, the container will\n * recieve focus if no focusable children are found.\n */\n public getFocusableChildrenAndApplyFocus(\n elementRef: ElementRef,\n containerSelector: string,\n focusOnContainerIfNoChildrenFound: boolean = false\n ): void {\n const containerElement =\n elementRef.nativeElement.querySelector(containerSelector);\n\n if (containerElement) {\n const focusableChildren = this.getFocusableChildren(containerElement);\n\n // Focus first focusable child if available. Otherwise, set focus on container.\n if (\n !this.focusFirstElement(focusableChildren) &&\n focusOnContainerIfNoChildrenFound\n ) {\n containerElement.focus();\n }\n }\n }\n\n /**\n * Returns an array of all focusable children of provided `element`.\n *\n * @param element - The HTMLElement to search within.\n * @param options - Options for getting focusable children.\n */\n public getFocusableChildren(\n element: HTMLElement,\n options?: SkyFocusableChildrenOptions\n ): HTMLElement[] {\n if (!element) {\n return [];\n }\n\n let elements = Array.prototype.slice.call(\n element.querySelectorAll(SKY_TABBABLE_SELECTOR)\n );\n\n // Unless ignoreTabIndex = true, filter out elements with tabindex = -1.\n if (!options || !options.ignoreTabIndex) {\n elements = elements.filter((el: HTMLElement) => {\n return el.tabIndex !== -1;\n });\n }\n\n // Unless ignoreVisibility = true, filter out elements that are not visible.\n if (!options || !options.ignoreVisibility) {\n elements = elements.filter((el: HTMLElement) => {\n return this.isVisible(el);\n });\n }\n\n return elements;\n }\n\n /**\n * Returns the clientWidth of the provided elementRef.\n * @param elementRef - The element to calculate width from.\n */\n public getWidth(elementRef: ElementRef): number {\n return elementRef.nativeElement.clientWidth;\n }\n\n /**\n * Checks if an event target has a higher z-index than a given element.\n * @param target The event target element.\n * @param element The element to test against. A z-index must be explicitly set for this element.\n */\n public isTargetAboveElement(\n target: EventTarget,\n element: HTMLElement\n ): boolean {\n const zIndex = getComputedStyle(element).zIndex;\n\n let el = target as HTMLElement;\n\n while (el) {\n // Getting the computed style only works for elements that exist in the DOM.\n // In certain scenarios, an element is removed after a click event; by the time the event\n // bubbles up to other elements, however, the element has been removed and the computed style returns empty.\n // In this case, we'll need to check the z-index directly, via the style property.\n const targetZIndex = getComputedStyle(el).zIndex || el.style.zIndex;\n if (\n targetZIndex !== '' &&\n targetZIndex !== 'auto' &&\n +targetZIndex > +zIndex\n ) {\n return true;\n }\n\n el = el.parentElement as HTMLElement;\n }\n\n return false;\n }\n\n /**\n * Remove inline height styles from the provided elements.\n * @param elementRef - The element to search within.\n * @param selector - The CSS selector to use when finding elements for removing height.\n */\n public resetHeight(elementRef: ElementRef, selector: string): void {\n const children = elementRef.nativeElement.querySelectorAll(selector);\n /* istanbul ignore else */\n if (children.length > 0) {\n for (let i = 0; i < children.length; i++) {\n // Setting style attributes with Web API requires null instead of undefined.\n // tslint:disable-next-line: no-null-keyword\n children[i].style.height = null;\n }\n }\n }\n\n /**\n * Sets all element heights to match the height of the tallest element.\n * @param elementRef - The element to search within.\n * @param selector - The CSS selector to use when finding elements for syncing height.\n */\n public syncMaxHeight(elementRef: ElementRef, selector: string): void {\n const children = elementRef.nativeElement.querySelectorAll(selector);\n /* istanbul ignore else */\n if (children.length > 0) {\n let maxHeight = 0;\n for (let i = 0; i < children.length; i++) {\n maxHeight = Math.max(maxHeight, children[i].offsetHeight);\n }\n for (let i = 0; i < children.length; i++) {\n children[i].style.height = maxHeight + 'px';\n }\n }\n }\n\n private focusFirstElement(list: Array<HTMLElement>): boolean {\n if (list.length > 0) {\n list[0].focus();\n return true;\n }\n return false;\n }\n\n private isVisible(element: HTMLElement): boolean {\n const style = window.getComputedStyle(element);\n const isHidden = style.display === 'none' || style.visibility === 'hidden';\n if (isHidden) {\n return false;\n }\n\n const hasBounds = !!(\n element.offsetWidth ||\n element.offsetHeight ||\n element.getClientRects().length\n );\n return hasBounds;\n }\n}\n"]}
@@ -1,18 +1,22 @@
1
+ var _SkyAffixService_renderer;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { Injectable, RendererFactory2, } from '@angular/core';
2
4
  import { SkyAffixer } from './affixer';
3
5
  import * as i0 from "@angular/core";
4
6
  export class SkyAffixService {
5
7
  constructor(rendererFactory) {
6
- this.renderer = rendererFactory.createRenderer(undefined, undefined);
8
+ _SkyAffixService_renderer.set(this, void 0);
9
+ __classPrivateFieldSet(this, _SkyAffixService_renderer, rendererFactory.createRenderer(undefined, null), "f");
7
10
  }
8
11
  /**
9
12
  * Creates an instance of [[SkyAffixer]].
10
13
  * @param affixed The element to be affixed.
11
14
  */
12
15
  createAffixer(affixed) {
13
- return new SkyAffixer(affixed.nativeElement, this.renderer);
16
+ return new SkyAffixer(affixed.nativeElement, __classPrivateFieldGet(this, _SkyAffixService_renderer, "f"));
14
17
  }
15
18
  }
19
+ _SkyAffixService_renderer = new WeakMap();
16
20
  SkyAffixService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAffixService, deps: [{ token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable });
17
21
  SkyAffixService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAffixService, providedIn: 'root' });
18
22
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyAffixService, decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"affix.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/affix/affix.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;AAKvC,MAAM,OAAO,eAAe;IAG1B,YAAY,eAAiC;QAC3C,IAAI,CAAC,QAAQ,GAAG,eAAe,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvE,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,OAAmB;QACtC,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;;6GAbU,eAAe;iHAAf,eAAe,cAFd,MAAM;4FAEP,eAAe;kBAH3B,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import {\n ElementRef,\n Injectable,\n Renderer2,\n RendererFactory2,\n} from '@angular/core';\n\nimport { SkyAffixer } from './affixer';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyAffixService {\n private renderer: Renderer2;\n\n constructor(rendererFactory: RendererFactory2) {\n this.renderer = rendererFactory.createRenderer(undefined, undefined);\n }\n\n /**\n * Creates an instance of [[SkyAffixer]].\n * @param affixed The element to be affixed.\n */\n public createAffixer(affixed: ElementRef): SkyAffixer {\n return new SkyAffixer(affixed.nativeElement, this.renderer);\n }\n}\n"]}
1
+ {"version":3,"file":"affix.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/affix/affix.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAEL,UAAU,EAEV,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;AAKvC,MAAM,OAAO,eAAe;IAG1B,YAAY,eAAiC;QAF7C,4CAAqB;QAGnB,uBAAA,IAAI,6BAAa,eAAe,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,MAAA,CAAC;IACnE,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,OAAmB;QACtC,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,aAAa,EAAE,uBAAA,IAAI,iCAAU,CAAC,CAAC;IAC/D,CAAC;;;6GAbU,eAAe;iHAAf,eAAe,cAFd,MAAM;4FAEP,eAAe;kBAH3B,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import {\n ElementRef,\n Injectable,\n Renderer2,\n RendererFactory2,\n} from '@angular/core';\n\nimport { SkyAffixer } from './affixer';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyAffixService {\n #renderer: Renderer2;\n\n constructor(rendererFactory: RendererFactory2) {\n this.#renderer = rendererFactory.createRenderer(undefined, null);\n }\n\n /**\n * Creates an instance of [[SkyAffixer]].\n * @param affixed The element to be affixed.\n */\n public createAffixer(affixed: ElementRef): SkyAffixer {\n return new SkyAffixer(affixed.nativeElement, this.#renderer);\n }\n}\n"]}
@@ -1,3 +1,5 @@
1
+ var _SkyResizeObserverMediaQueryService_breakpoints, _SkyResizeObserverMediaQueryService_currentBreakpointObservable, _SkyResizeObserverMediaQueryService_stopListening, _SkyResizeObserverMediaQueryService_target;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { Injectable } from '@angular/core';
2
4
  import { ReplaySubject, Subject } from 'rxjs';
3
5
  import { takeUntil } from 'rxjs/operators';
@@ -11,7 +13,7 @@ import * as i1 from "./resize-observer.service";
11
13
  export class SkyResizeObserverMediaQueryService {
12
14
  constructor(resizeObserverService) {
13
15
  this.resizeObserverService = resizeObserverService;
14
- this._breakpoints = [
16
+ _SkyResizeObserverMediaQueryService_breakpoints.set(this, [
15
17
  {
16
18
  check: (width) => width > 0 && width <= 767,
17
19
  name: SkyMediaBreakpoints.xs,
@@ -28,11 +30,12 @@ export class SkyResizeObserverMediaQueryService {
28
30
  check: (width) => width > 1199,
29
31
  name: SkyMediaBreakpoints.lg,
30
32
  },
31
- ];
32
- this._currentBreakpointObservable = new ReplaySubject(1);
33
- this._stopListening = new Subject();
34
- this._stopListening.subscribe(() => {
35
- this._target = undefined;
33
+ ]);
34
+ _SkyResizeObserverMediaQueryService_currentBreakpointObservable.set(this, new ReplaySubject(1));
35
+ _SkyResizeObserverMediaQueryService_stopListening.set(this, new Subject());
36
+ _SkyResizeObserverMediaQueryService_target.set(this, void 0);
37
+ __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_stopListening, "f").subscribe(() => {
38
+ __classPrivateFieldSet(this, _SkyResizeObserverMediaQueryService_target, undefined, "f");
36
39
  this.updateBreakpoint(undefined);
37
40
  });
38
41
  }
@@ -43,10 +46,10 @@ export class SkyResizeObserverMediaQueryService {
43
46
  return this._currentBreakpoint;
44
47
  }
45
48
  ngOnDestroy() {
46
- this._stopListening.next();
49
+ __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_stopListening, "f").next();
47
50
  this._currentBreakpoint = undefined;
48
- this._stopListening.complete();
49
- this._currentBreakpointObservable.complete();
51
+ __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_stopListening, "f").complete();
52
+ __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_currentBreakpointObservable, "f").complete();
50
53
  }
51
54
  /**
52
55
  * @internal
@@ -59,21 +62,21 @@ export class SkyResizeObserverMediaQueryService {
59
62
  * time. Any previous subscriptions will be unsubscribed when a new element is observed.
60
63
  */
61
64
  observe(element) {
62
- if (this._target) {
63
- if (this._target === element) {
65
+ if (__classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_target, "f")) {
66
+ if (__classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_target, "f") === element) {
64
67
  return this;
65
68
  }
66
- this._stopListening.next();
69
+ __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_stopListening, "f").next();
67
70
  }
68
- this._target = element;
71
+ __classPrivateFieldSet(this, _SkyResizeObserverMediaQueryService_target, element, "f");
69
72
  this.checkWidth(element);
70
73
  this.resizeObserverService
71
74
  .observe(element)
72
- .pipe(takeUntil(this._stopListening))
75
+ .pipe(takeUntil(__classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_stopListening, "f")))
73
76
  .subscribe((value) => {
74
77
  const breakpoint = this.checkBreakpoint(value.contentRect.width);
75
78
  /* istanbul ignore else */
76
- if (breakpoint !== this._currentBreakpoint) {
79
+ if (breakpoint !== this.current) {
77
80
  this.updateBreakpoint(breakpoint);
78
81
  }
79
82
  });
@@ -83,25 +86,28 @@ export class SkyResizeObserverMediaQueryService {
83
86
  * Stop watching the container element.
84
87
  */
85
88
  unobserve() {
86
- this._stopListening.next();
89
+ __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_stopListening, "f").next();
87
90
  }
88
91
  /**
89
92
  * Subscribes to element size changes that cross breakpoints.
90
93
  */
91
94
  subscribe(listener) {
92
- return this._currentBreakpointObservable
93
- .pipe(takeUntil(this._stopListening))
95
+ return __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_currentBreakpointObservable, "f")
96
+ .pipe(takeUntil(__classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_stopListening, "f")))
94
97
  .subscribe((value) => {
95
98
  listener(value);
96
99
  });
97
100
  }
98
101
  updateBreakpoint(breakpoint) {
99
102
  this._currentBreakpoint = breakpoint;
100
- this._currentBreakpointObservable.next(breakpoint);
103
+ __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_currentBreakpointObservable, "f").next(breakpoint);
101
104
  }
102
105
  checkBreakpoint(width) {
103
- var _a;
104
- return (_a = this._breakpoints.find((breakpoint) => breakpoint.check(width))) === null || _a === void 0 ? void 0 : _a.name;
106
+ const breakpoint = __classPrivateFieldGet(this, _SkyResizeObserverMediaQueryService_breakpoints, "f").find((breakpoint) => breakpoint.check(width));
107
+ /* istanbul ignore else */
108
+ if (breakpoint) {
109
+ return breakpoint.name;
110
+ }
105
111
  }
106
112
  checkWidth(element) {
107
113
  const width = element.nativeElement.offsetWidth || 0;
@@ -112,6 +118,7 @@ export class SkyResizeObserverMediaQueryService {
112
118
  }
113
119
  }
114
120
  }
121
+ _SkyResizeObserverMediaQueryService_breakpoints = new WeakMap(), _SkyResizeObserverMediaQueryService_currentBreakpointObservable = new WeakMap(), _SkyResizeObserverMediaQueryService_stopListening = new WeakMap(), _SkyResizeObserverMediaQueryService_target = new WeakMap();
115
122
  SkyResizeObserverMediaQueryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyResizeObserverMediaQueryService, deps: [{ token: i1.SkyResizeObserverService }], target: i0.ɵɵFactoryTarget.Injectable });
116
123
  SkyResizeObserverMediaQueryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyResizeObserverMediaQueryService, providedIn: 'any' });
117
124
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyResizeObserverMediaQueryService, decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"resize-observer-media-query.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/resize-observer/resize-observer-media-query.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAa,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAgB,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAGvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;;;AAErE;;GAEG;AAIH,MAAM,OAAO,kCAAkC;IAoC7C,YAAoB,qBAA+C;QAA/C,0BAAqB,GAArB,qBAAqB,CAA0B;QA5B3D,iBAAY,GAGd;YACJ;gBACE,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,GAAG;gBACnD,IAAI,EAAE,mBAAmB,CAAC,EAAE;aAC7B;YACD;gBACE,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,GAAG,IAAI,KAAK,IAAI,GAAG;gBACrD,IAAI,EAAE,mBAAmB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AC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC/C,0BAA0B;QAC1B,IAAI,UAAU,KAAK,IAAI,CAAC,kBAAkB,EAAE;YAC1C,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;SACnC;IACH,CAAC;;gIAtHU,kCAAkC;oIAAlC,kCAAkC,cAFjC,KAAK;4FAEN,kCAAkC;kBAH9C,UAAU;mBAAC;oBACV,UAAU,EAAE,KAAK;iBAClB","sourcesContent":["import { ElementRef, Injectable, OnDestroy } from '@angular/core';\n\nimport { ReplaySubject, Subject, Subscription } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyMediaBreakpoints } from '../media-query/media-breakpoints';\nimport { SkyMediaQueryListener } from '../media-query/media-query-listener';\n\nimport { SkyResizeObserverService } from './resize-observer.service';\n\n/**\n * Acts like `SkyMediaQueryService` for a container element, emitting the same responsive breakpoints.\n */\n@Injectable({\n providedIn: 'any',\n})\nexport class SkyResizeObserverMediaQueryService implements OnDestroy {\n /**\n * Returns the current breakpoint.\n */\n public get current(): SkyMediaBreakpoints | undefined {\n return this._currentBreakpoint;\n }\n\n private _breakpoints: {\n check: (width: number) => boolean;\n name: SkyMediaBreakpoints;\n }[] = [\n {\n check: (width: number) => width > 0 && width <= 767,\n name: SkyMediaBreakpoints.xs,\n },\n {\n check: (width: number) => width > 767 && width <= 991,\n name: SkyMediaBreakpoints.sm,\n },\n {\n check: (width: number) => width > 991 && width <= 1199,\n name: SkyMediaBreakpoints.md,\n },\n {\n check: (width: number) => width > 1199,\n name: SkyMediaBreakpoints.lg,\n },\n ];\n private _currentBreakpointObservable = new ReplaySubject<\n SkyMediaBreakpoints | undefined\n >(1);\n private _currentBreakpoint: SkyMediaBreakpoints;\n private _stopListening = new Subject<void>();\n private _target?: ElementRef;\n\n constructor(private resizeObserverService: SkyResizeObserverService) {\n this._stopListening.subscribe(() => {\n this._target = undefined;\n this.updateBreakpoint(undefined);\n });\n }\n\n public ngOnDestroy(): void {\n this._stopListening.next();\n this._currentBreakpoint = undefined;\n this._stopListening.complete();\n this._currentBreakpointObservable.complete();\n }\n\n /**\n * @internal\n */\n public destroy(): void {\n this.ngOnDestroy();\n }\n\n /**\n * Sets the container element to watch. The `SkyResizeObserverMediaQueryService` will only observe one element at a\n * time. Any previous subscriptions will be unsubscribed when a new element is observed.\n */\n public observe(element: ElementRef): SkyResizeObserverMediaQueryService {\n if (this._target) {\n if (this._target === element) {\n return this;\n }\n this._stopListening.next();\n }\n this._target = element;\n this.checkWidth(element);\n this.resizeObserverService\n .observe(element)\n .pipe(takeUntil(this._stopListening))\n .subscribe((value) => {\n const breakpoint = this.checkBreakpoint(value.contentRect.width);\n /* istanbul ignore else */\n if (breakpoint !== this._currentBreakpoint) {\n this.updateBreakpoint(breakpoint);\n }\n });\n return this;\n }\n\n /**\n * Stop watching the container element.\n */\n public unobserve(): void {\n this._stopListening.next();\n }\n\n /**\n * Subscribes to element size changes that cross breakpoints.\n */\n public subscribe(listener: SkyMediaQueryListener): Subscription {\n return this._currentBreakpointObservable\n .pipe(takeUntil(this._stopListening))\n .subscribe((value) => {\n listener(value);\n });\n }\n\n private updateBreakpoint(breakpoint: SkyMediaBreakpoints) {\n this._currentBreakpoint = breakpoint;\n this._currentBreakpointObservable.next(breakpoint);\n }\n\n private checkBreakpoint(width: number): SkyMediaBreakpoints | undefined {\n return this._breakpoints.find((breakpoint) => breakpoint.check(width))\n ?.name;\n }\n\n private checkWidth(element: ElementRef) {\n const width = (element.nativeElement as HTMLElement).offsetWidth || 0;\n const breakpoint = this.checkBreakpoint(width);\n /* istanbul ignore else */\n if (breakpoint !== this._currentBreakpoint) {\n this.updateBreakpoint(breakpoint);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"resize-observer-media-query.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/resize-observer/resize-observer-media-query.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAc,UAAU,EAAa,MAAM,eAAe,CAAC;A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6B;aACrC,IAAI,CAAC,SAAS,CAAC,uBAAA,IAAI,yDAAe,CAAC,CAAC;aACpC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACnB,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,gBAAgB,CAAC,UAA+B;QACtD,IAAI,CAAC,kBAAkB,GAAG,UAAU,CAAC;QACrC,uBAAA,IAAI,uEAA6B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;IAEO,eAAe,CAAC,KAAa;QACnC,MAAM,UAAU,GAAG,uBAAA,IAAI,uDAAa,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACvD,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CACxB,CAAC;QAEF,0BAA0B;QAC1B,IAAI,UAAU,EAAE;YACd,OAAO,UAAU,CAAC,IAAI,CAAC;SACxB;IACH,CAAC;IAEO,UAAU,CAAC,OAAmB;QACpC,MAAM,KAAK,GAAI,OAAO,CAAC,aAA6B,CAAC,WAAW,IAAI,CAAC,CAAC;QACtE,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC/C,0BAA0B;QAC1B,IAAI,UAAU,KAAK,IAAI,CAAC,kBAAkB,EAAE;YAC1C,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;SACnC;IACH,CAAC;;;gIApIU,kCAAkC;oIAAlC,kCAAkC,cAFjC,KAAK;4FAEN,kCAAkC;kBAH9C,UAAU;mBAAC;oBACV,UAAU,EAAE,KAAK;iBAClB","sourcesContent":["import { ElementRef, Injectable, OnDestroy } from '@angular/core';\n\nimport { ReplaySubject, Subject, Subscription } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyMediaBreakpoints } from '../media-query/media-breakpoints';\nimport { SkyMediaQueryListener } from '../media-query/media-query-listener';\n\nimport { SkyResizeObserverService } from './resize-observer.service';\n\n/**\n * Acts like `SkyMediaQueryService` for a container element, emitting the same responsive breakpoints.\n */\n@Injectable({\n providedIn: 'any',\n})\nexport class SkyResizeObserverMediaQueryService implements OnDestroy {\n /**\n * Returns the current breakpoint.\n */\n public get current(): SkyMediaBreakpoints | undefined {\n return this._currentBreakpoint;\n }\n\n #breakpoints: {\n check: (width: number) => boolean;\n name: SkyMediaBreakpoints;\n }[] = [\n {\n check: (width: number) => width > 0 && width <= 767,\n name: SkyMediaBreakpoints.xs,\n },\n {\n check: (width: number) => width > 767 && width <= 991,\n name: SkyMediaBreakpoints.sm,\n },\n {\n check: (width: number) => width > 991 && width <= 1199,\n name: SkyMediaBreakpoints.md,\n },\n {\n check: (width: number) => width > 1199,\n name: SkyMediaBreakpoints.lg,\n },\n ];\n\n #currentBreakpointObservable = new ReplaySubject<\n SkyMediaBreakpoints | undefined\n >(1);\n\n private _currentBreakpoint: SkyMediaBreakpoints;\n\n #stopListening = new Subject<void>();\n\n #target: ElementRef;\n\n constructor(private resizeObserverService: SkyResizeObserverService) {\n this.#stopListening.subscribe(() => {\n this.#target = undefined;\n this.updateBreakpoint(undefined);\n });\n }\n\n public ngOnDestroy(): void {\n this.#stopListening.next();\n this._currentBreakpoint = undefined;\n this.#stopListening.complete();\n this.#currentBreakpointObservable.complete();\n }\n\n /**\n * @internal\n */\n public destroy(): void {\n this.ngOnDestroy();\n }\n\n /**\n * Sets the container element to watch. The `SkyResizeObserverMediaQueryService` will only observe one element at a\n * time. Any previous subscriptions will be unsubscribed when a new element is observed.\n */\n public observe(element: ElementRef): SkyResizeObserverMediaQueryService {\n if (this.#target) {\n if (this.#target === element) {\n return this;\n }\n\n this.#stopListening.next();\n }\n\n this.#target = element;\n\n this.checkWidth(element);\n\n this.resizeObserverService\n .observe(element)\n .pipe(takeUntil(this.#stopListening))\n .subscribe((value) => {\n const breakpoint = this.checkBreakpoint(value.contentRect.width);\n /* istanbul ignore else */\n if (breakpoint !== this.current) {\n this.updateBreakpoint(breakpoint);\n }\n });\n return this;\n }\n\n /**\n * Stop watching the container element.\n */\n public unobserve(): void {\n this.#stopListening.next();\n }\n\n /**\n * Subscribes to element size changes that cross breakpoints.\n */\n public subscribe(listener: SkyMediaQueryListener): Subscription {\n return this.#currentBreakpointObservable\n .pipe(takeUntil(this.#stopListening))\n .subscribe((value) => {\n listener(value);\n });\n }\n\n private updateBreakpoint(breakpoint: SkyMediaBreakpoints) {\n this._currentBreakpoint = breakpoint;\n this.#currentBreakpointObservable.next(breakpoint);\n }\n\n private checkBreakpoint(width: number): SkyMediaBreakpoints | undefined {\n const breakpoint = this.#breakpoints.find((breakpoint) =>\n breakpoint.check(width)\n );\n\n /* istanbul ignore else */\n if (breakpoint) {\n return breakpoint.name;\n }\n }\n\n private checkWidth(element: ElementRef) {\n const width = (element.nativeElement as HTMLElement).offsetWidth || 0;\n const breakpoint = this.checkBreakpoint(width);\n /* istanbul ignore else */\n if (breakpoint !== this._currentBreakpoint) {\n this.updateBreakpoint(breakpoint);\n }\n }\n}\n"]}
@@ -1,3 +1,5 @@
1
+ var _SkyResizeObserverService_resizeObserver, _SkyResizeObserverService_tracking;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { Injectable, NgZone } from '@angular/core';
2
4
  import { Subject } from 'rxjs';
3
5
  import { finalize } from 'rxjs/operators';
@@ -8,13 +10,14 @@ import * as i0 from "@angular/core";
8
10
  export class SkyResizeObserverService {
9
11
  constructor(zone) {
10
12
  this.zone = zone;
11
- this._tracking = [];
12
- this._resizeObserver = new ResizeObserver((entries) => {
13
+ _SkyResizeObserverService_resizeObserver.set(this, void 0);
14
+ _SkyResizeObserverService_tracking.set(this, []);
15
+ __classPrivateFieldSet(this, _SkyResizeObserverService_resizeObserver, new ResizeObserver((entries) => {
13
16
  entries.forEach((entry) => this.callback(entry));
14
- });
17
+ }), "f");
15
18
  }
16
19
  ngOnDestroy() {
17
- this._resizeObserver.disconnect();
20
+ __classPrivateFieldGet(this, _SkyResizeObserverService_resizeObserver, "f").disconnect();
18
21
  }
19
22
  /**
20
23
  * Create rxjs observable to get size changes for an element ref.
@@ -23,22 +26,22 @@ export class SkyResizeObserverService {
23
26
  return this.observeAndTrack(element).subjectObservable;
24
27
  }
25
28
  observeAndTrack(element) {
26
- const checkTracking = this._tracking.findIndex((value) => {
29
+ const checkTracking = __classPrivateFieldGet(this, _SkyResizeObserverService_tracking, "f").findIndex((value) => {
27
30
  return !value.subject.closed && value.element === element.nativeElement;
28
31
  });
29
32
  if (checkTracking === -1) {
30
- this._resizeObserver.observe(element.nativeElement);
33
+ __classPrivateFieldGet(this, _SkyResizeObserverService_resizeObserver, "f").observe(element.nativeElement);
31
34
  }
32
35
  const subject = new Subject();
33
36
  const subjectObservable = subject.pipe(finalize(() => {
34
37
  // Are there any other tracking entries still watching this element?
35
- const checkTracking = this._tracking.findIndex((value) => {
38
+ const checkTracking = __classPrivateFieldGet(this, _SkyResizeObserverService_tracking, "f").findIndex((value) => {
36
39
  return (value.subject !== subject &&
37
40
  !value.subject.closed &&
38
41
  value.element === element.nativeElement);
39
42
  });
40
43
  if (checkTracking === -1) {
41
- this._resizeObserver.unobserve(element.nativeElement);
44
+ __classPrivateFieldGet(this, _SkyResizeObserverService_resizeObserver, "f").unobserve(element.nativeElement);
42
45
  }
43
46
  }));
44
47
  const tracking = {
@@ -46,15 +49,17 @@ export class SkyResizeObserverService {
46
49
  subject,
47
50
  subjectObservable,
48
51
  };
49
- this._tracking.push(tracking);
52
+ __classPrivateFieldGet(this, _SkyResizeObserverService_tracking, "f").push(tracking);
50
53
  return tracking;
51
54
  }
52
55
  callback(entry) {
53
- this._tracking
56
+ __classPrivateFieldGet(this, _SkyResizeObserverService_tracking, "f")
54
57
  .filter((value) => !(value.subject.closed || value.subject.isStopped))
55
58
  .forEach((value) => {
56
59
  /* istanbul ignore else */
57
60
  if (value.element === entry.target) {
61
+ // Execute the callback within NgZone because Angular does not "monkey patch"
62
+ // ResizeObserver like it does for other features in the DOM.
58
63
  this.zone.run(() => {
59
64
  value.subject.next(entry);
60
65
  });
@@ -62,6 +67,7 @@ export class SkyResizeObserverService {
62
67
  });
63
68
  }
64
69
  }
70
+ _SkyResizeObserverService_resizeObserver = new WeakMap(), _SkyResizeObserverService_tracking = new WeakMap();
65
71
  SkyResizeObserverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyResizeObserverService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
66
72
  SkyResizeObserverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyResizeObserverService, providedIn: 'any' });
67
73
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyResizeObserverService, decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"resize-observer.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/resize-observer/resize-observer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,EAAa,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAc,OAAO,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAQ1C;;GAEG;AAIH,MAAM,OAAO,wBAAwB;IAInC,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAFxB,cAAS,GAA6B,EAAE,CAAC;QAG/C,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CACvC,CAAC,OAA8B,EAAE,EAAE;YACjC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,CAAC,CACF,CAAC;IACJ,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;I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zC,IAAI,CAAC,SAAS;aACX,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;aACrE,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACjB,0BAA0B;YAC1B,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,MAAM,EAAE;gBAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;oBACjB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACP,CAAC;;sHAlEU,wBAAwB;0HAAxB,wBAAwB,cAFvB,KAAK;4FAEN,wBAAwB;kBAHpC,UAAU;mBAAC;oBACV,UAAU,EAAE,KAAK;iBAClB","sourcesContent":["import { ElementRef, Injectable, NgZone, OnDestroy } from '@angular/core';\n\nimport { Observable, Subject } from 'rxjs';\nimport { finalize } from 'rxjs/operators';\n\ntype ResizeObserverTracking = {\n element: Element;\n subject: Subject<ResizeObserverEntry>;\n subjectObservable: Observable<ResizeObserverEntry>;\n};\n\n/**\n * Service to create rxjs observables for changes to the content box dimensions of elements.\n */\n@Injectable({\n providedIn: 'any',\n})\nexport class SkyResizeObserverService implements OnDestroy {\n private _resizeObserver: ResizeObserver;\n private _tracking: ResizeObserverTracking[] = [];\n\n constructor(private zone: NgZone) {\n this._resizeObserver = new ResizeObserver(\n (entries: ResizeObserverEntry[]) => {\n entries.forEach((entry) => this.callback(entry));\n }\n );\n }\n\n public ngOnDestroy(): void {\n this._resizeObserver.disconnect();\n }\n\n /**\n * Create rxjs observable to get size changes for an element ref.\n */\n public observe(element: ElementRef): Observable<ResizeObserverEntry> {\n return this.observeAndTrack(element).subjectObservable;\n }\n\n private observeAndTrack(element: ElementRef): ResizeObserverTracking {\n const checkTracking = this._tracking.findIndex((value) => {\n return !value.subject.closed && value.element === element.nativeElement;\n });\n if (checkTracking === -1) {\n this._resizeObserver.observe(element.nativeElement);\n }\n const subject = new Subject<ResizeObserverEntry>();\n const subjectObservable = subject.pipe(\n finalize(() => {\n // Are there any other tracking entries still watching this element?\n const checkTracking = this._tracking.findIndex((value) => {\n return (\n value.subject !== subject &&\n !value.subject.closed &&\n value.element === element.nativeElement\n );\n });\n if (checkTracking === -1) {\n this._resizeObserver.unobserve(element.nativeElement);\n }\n })\n );\n const tracking = {\n element: element.nativeElement,\n subject,\n subjectObservable,\n };\n this._tracking.push(tracking);\n return tracking;\n }\n\n private callback(entry: ResizeObserverEntry) {\n this._tracking\n .filter((value) => !(value.subject.closed || value.subject.isStopped))\n .forEach((value) => {\n /* istanbul ignore else */\n if (value.element === entry.target) {\n this.zone.run(() => {\n value.subject.next(entry);\n });\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"resize-observer.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/resize-observer/resize-observer.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,EAAa,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAc,OAAO,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAQ1C;;GAEG;AAIH,MAAM,OAAO,wBAAwB;IAKnC,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAJhC,2DAAgC;QAEhC,6CAAsC,EAAE,EAAC;QAGvC,uBAAA,IAAI,4CAAmB,IAAI,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpD,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC,MAAA,CAAC;IACL,CAAC;IAEM,WAAW;QAChB,uBAAA,IAAI,gDAAgB,CAAC,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B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,QAAQ,CAAC,KAA0B;QACzC,uBAAA,IAAI,0CAAU;aACX,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;aACrE,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACjB,0BAA0B;YAC1B,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,MAAM,EAAE;gBAClC,6EAA6E;gBAC7E,6DAA6D;gBAC7D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;oBACjB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACP,CAAC;;;sHAzEU,wBAAwB;0HAAxB,wBAAwB,cAFvB,KAAK;4FAEN,wBAAwB;kBAHpC,UAAU;mBAAC;oBACV,UAAU,EAAE,KAAK;iBAClB","sourcesContent":["import { ElementRef, Injectable, NgZone, OnDestroy } from '@angular/core';\n\nimport { Observable, Subject } from 'rxjs';\nimport { finalize } from 'rxjs/operators';\n\ntype ResizeObserverTracking = {\n element: Element;\n subject: Subject<ResizeObserverEntry>;\n subjectObservable: Observable<ResizeObserverEntry>;\n};\n\n/**\n * Service to create rxjs observables for changes to the content box dimensions of elements.\n */\n@Injectable({\n providedIn: 'any',\n})\nexport class SkyResizeObserverService implements OnDestroy {\n #resizeObserver: ResizeObserver;\n\n #tracking: ResizeObserverTracking[] = [];\n\n constructor(private zone: NgZone) {\n this.#resizeObserver = new ResizeObserver((entries) => {\n entries.forEach((entry) => this.callback(entry));\n });\n }\n\n public ngOnDestroy(): void {\n this.#resizeObserver.disconnect();\n }\n\n /**\n * Create rxjs observable to get size changes for an element ref.\n */\n public observe(element: ElementRef): Observable<ResizeObserverEntry> {\n return this.observeAndTrack(element).subjectObservable;\n }\n\n private observeAndTrack(element: ElementRef): ResizeObserverTracking {\n const checkTracking = this.#tracking.findIndex((value) => {\n return !value.subject.closed && value.element === element.nativeElement;\n });\n\n if (checkTracking === -1) {\n this.#resizeObserver.observe(element.nativeElement);\n }\n\n const subject = new Subject<ResizeObserverEntry>();\n const subjectObservable = subject.pipe(\n finalize(() => {\n // Are there any other tracking entries still watching this element?\n const checkTracking = this.#tracking.findIndex((value) => {\n return (\n value.subject !== subject &&\n !value.subject.closed &&\n value.element === element.nativeElement\n );\n });\n\n if (checkTracking === -1) {\n this.#resizeObserver.unobserve(element.nativeElement);\n }\n })\n );\n\n const tracking = {\n element: element.nativeElement,\n subject,\n subjectObservable,\n };\n\n this.#tracking.push(tracking);\n\n return tracking;\n }\n\n private callback(entry: ResizeObserverEntry): void {\n this.#tracking\n .filter((value) => !(value.subject.closed || value.subject.isStopped))\n .forEach((value) => {\n /* istanbul ignore else */\n if (value.element === entry.target) {\n // Execute the callback within NgZone because Angular does not \"monkey patch\"\n // ResizeObserver like it does for other features in the DOM.\n this.zone.run(() => {\n value.subject.next(entry);\n });\n }\n });\n }\n}\n"]}
@@ -27,8 +27,7 @@ export class SkyScrollableHostService {
27
27
  /**
28
28
  * Returns an observable which emits the given element's current scrollable host
29
29
  * @param elementRef The element whose scrollable host is being requested
30
- * @param completionObservable An observable which alerts the internal observers that they should complete
31
- * @returns An observable which emits the current scrollable host
30
+ * @returns An observable which emits the current scrollable host element.
32
31
  * @internal
33
32
  */
34
33
  watchScrollableHost(elementRef) {
@@ -38,11 +37,13 @@ export class SkyScrollableHostService {
38
37
  return new Observable((subscriber) => {
39
38
  subscribers.push(subscriber);
40
39
  let scrollableHost = this.findScrollableHost(elementRef.nativeElement);
40
+ // Setup mutation observers only once, for all subscribers.
41
41
  if (subscribers.length === 1) {
42
42
  parentMutationObserver = this.mutationObserverSvc.create(() => {
43
43
  const newScrollableHost = this.findScrollableHost(elementRef.nativeElement);
44
+ // Reset observer if scrollable host changes.
44
45
  if (newScrollableHost !== scrollableHost &&
45
- elementRef.nativeElement.offsetParent) {
46
+ this.isElementVisible(elementRef)) {
46
47
  scrollableHost = newScrollableHost;
47
48
  this.observeForScrollableHostChanges(scrollableHost, parentMutationObserver);
48
49
  notifySubscribers(subscribers, scrollableHost);
@@ -50,7 +51,9 @@ export class SkyScrollableHostService {
50
51
  });
51
52
  this.observeForScrollableHostChanges(scrollableHost, parentMutationObserver);
52
53
  documentHiddenElementMutationObserver = this.mutationObserverSvc.create(() => {
53
- if (scrollableHost && !elementRef.nativeElement.offsetParent) {
54
+ if (scrollableHost && !this.isElementVisible(elementRef)) {
55
+ // If the scrollable host is not visible, set it to undefined and unsubscribe from its mutation changes.
56
+ // Then, observe the document element so that a new scrollable host can be found.
54
57
  scrollableHost = undefined;
55
58
  this.observeForScrollableHostChanges(scrollableHost, parentMutationObserver);
56
59
  notifySubscribers(subscribers, scrollableHost);
@@ -58,10 +61,11 @@ export class SkyScrollableHostService {
58
61
  });
59
62
  this.observeDocumentHiddenElementChanges(documentHiddenElementMutationObserver);
60
63
  }
64
+ // Emit the scrollable host to the subscriber.
61
65
  subscriber.next(scrollableHost);
66
+ // Teardown callback for the subscription.
62
67
  subscriber.add(() => {
63
68
  const subIndex = subscribers.indexOf(subscriber);
64
- /* sanity check */
65
69
  /* istanbul ignore else */
66
70
  if (subIndex >= 0) {
67
71
  subscribers.splice(subIndex, 1);
@@ -76,7 +80,6 @@ export class SkyScrollableHostService {
76
80
  /**
77
81
  * Returns an observable which emits whenever the element's scrollable host emits a scroll event. The observable will always emit the scroll events from the elements current scrollable host and will update based on any scrollable host changes. The observable will also emit once whenever the scrollable host changes.
78
82
  * @param elementRef The element whose scrollable host scroll events are being requested
79
- * @param completionObservable An observable which alerts the internal observers that they should complete
80
83
  * @returns An observable which emits when the elements scrollable host is scrolled or is changed
81
84
  */
82
85
  watchScrollableHostScrollEvents(elementRef) {
@@ -87,6 +90,7 @@ export class SkyScrollableHostService {
87
90
  let scrollEventSubscription;
88
91
  return new Observable((subscriber) => {
89
92
  subscribers.push(subscriber);
93
+ // Setup mutation observers only once, for all subscribers.
90
94
  if (subscribers.length === 1) {
91
95
  scrollableHostSubscription = this.watchScrollableHost(elementRef).subscribe((newScrollableHost) => {
92
96
  newScrollableHostObservable.next();
@@ -96,6 +100,8 @@ export class SkyScrollableHostService {
96
100
  }
97
101
  scrollableHost = newScrollableHost;
98
102
  newScrollableHostObservable = new Subject();
103
+ // Only subscribe to scroll events if the host element is defined.
104
+ /* istanbul ignore else */
99
105
  if (newScrollableHost) {
100
106
  scrollEventSubscription = fromEvent(newScrollableHost, 'scroll')
101
107
  .pipe(takeUntil(newScrollableHostObservable))
@@ -105,9 +111,9 @@ export class SkyScrollableHostService {
105
111
  }
106
112
  });
107
113
  }
114
+ // Teardown callback for the subscription.
108
115
  subscriber.add(() => {
109
116
  const subIndex = subscribers.indexOf(subscriber);
110
- /* sanity check */
111
117
  /* istanbul ignore else */
112
118
  if (subIndex >= 0) {
113
119
  subscribers.splice(subIndex, 1);
@@ -124,7 +130,6 @@ export class SkyScrollableHostService {
124
130
  const regex = /(auto|scroll)/;
125
131
  const windowObj = this.windowRef.nativeWindow;
126
132
  const bodyObj = windowObj.document.body;
127
- /* Sanity check */
128
133
  if (!element) {
129
134
  return windowObj;
130
135
  }
@@ -132,7 +137,7 @@ export class SkyScrollableHostService {
132
137
  let parent = element;
133
138
  do {
134
139
  parent = parent.parentNode;
135
- /* Sanity check for if this function is called for an element which has been removed from the DOM */
140
+ // Return `window` if the parent element has been removed from the DOM.
136
141
  if (!(parent instanceof HTMLElement)) {
137
142
  return windowObj;
138
143
  }
@@ -155,22 +160,20 @@ export class SkyScrollableHostService {
155
160
  }
156
161
  observeForScrollableHostChanges(element, mutationObserver) {
157
162
  mutationObserver.disconnect();
158
- if (element instanceof HTMLElement) {
159
- mutationObserver.observe(element, {
160
- attributes: true,
161
- attributeFilter: ['class', 'style'],
162
- childList: true,
163
- subtree: true,
164
- });
165
- }
166
- else {
167
- mutationObserver.observe(document.documentElement, {
168
- attributes: true,
169
- attributeFilter: ['class', 'style'],
170
- childList: true,
171
- subtree: true,
172
- });
173
- }
163
+ const target = element instanceof HTMLElement ? element : document.documentElement;
164
+ mutationObserver.observe(target, {
165
+ attributes: true,
166
+ attributeFilter: ['class', 'style'],
167
+ childList: true,
168
+ subtree: true,
169
+ });
170
+ }
171
+ /**
172
+ * Determines if an element is "visible" in the DOM.
173
+ * @see https://stackoverflow.com/a/11639664/6178885
174
+ */
175
+ isElementVisible(elementRef) {
176
+ return elementRef.nativeElement.offsetParent;
174
177
  }
175
178
  }
176
179
  SkyScrollableHostService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyScrollableHostService, deps: [{ token: i1.MutationObserverService }, { token: i2.SkyAppWindowRef }], target: i0.ɵɵFactoryTarget.Injectable });